diff --git a/CHANGELOG.md b/CHANGELOG.md index 3873c25..74c09d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.5.0 + +- Update dependencies. +- Important Notice: This is the final version supporting Dart v2. The next release will require Dart v3.3 or higher. + ## 4.4.0 - Update dependencies. diff --git a/analysis_options.yaml b/analysis_options.yaml index fdbd308..231b316 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,26 +1,9 @@ -# This file configures the analyzer to use the lint rule set from `package:lint` - -include: package:flutter_lints/flutter.yaml # For production apps -# include: package:lint/casual.yaml # For code samples, hackathons and other non-production code -# include: package:lint/package.yaml # Use this for packages with public API - - -# You might want to exclude auto-generated files from dart analysis -analyzer: - exclude: - #- '**.freezed.dart' - #- '**.g.dart' - -# You can customize the lint rules set to your own liking. A list of all rules -# can be found at https://dart-lang.github.io/linter/lints/options/options.html +# include: package:lints/recommended.yaml +include: package:flutter_lints/flutter.yaml +# Uncomment the following section to specify additional rules. linter: rules: - # Util classes are awesome! - # avoid_classes_with_only_static_members: false - - # Make constructors the first thing in every class - # sort_constructors_first: true - - # Choose wisely, but you don't have to - # prefer_double_quotes: true - # prefer_single_quotes: true \ No newline at end of file + prefer_final_locals: true # Warns when a local variable could be final + prefer_final_in_for_each: true # Warns when a forEach variable could be final + prefer_const_constructors: true # Warns when a constructor could be const + prefer_const_declarations: true # Warns when a declaration could be const diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7fb1d93..f803a48 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -28,9 +28,9 @@ dependencies: path: ../ web_socket_channel: ^2.4.0 http: ^1.1.0 - blockchain_utils: - path: ../../blockchain_utils - # blockchain_utils: ^3.4.0 + # blockchain_utils: + # path: ../../blockchain_utils + blockchain_utils: ^3.6.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 diff --git a/lib/ada/src/address/era/shelly/core/shelly_address.dart b/lib/ada/src/address/era/shelly/core/shelly_address.dart index fe116b9..d37911e 100644 --- a/lib/ada/src/address/era/shelly/core/shelly_address.dart +++ b/lib/ada/src/address/era/shelly/core/shelly_address.dart @@ -43,7 +43,7 @@ abstract class ADAShellyAddress extends ADAAddress { /// Deserializes a CBOR object into an ADAShellyAddress instance. static T deserialize(CborBytesValue cbor) { - ADAAddress address = ADAAddress.deserialize(cbor); + final ADAAddress address = ADAAddress.deserialize(cbor); if (address is! T) { throw ADAPluginException("Invalid address type.", details: { "Excepted": "$T", diff --git a/lib/ada/src/models/metadata/utils/metadata_utils.dart b/lib/ada/src/models/metadata/utils/metadata_utils.dart index 26bff99..18a84ad 100644 --- a/lib/ada/src/models/metadata/utils/metadata_utils.dart +++ b/lib/ada/src/models/metadata/utils/metadata_utils.dart @@ -159,7 +159,7 @@ class TransactionMetadataUtils { static TransactionMetadata _encodeMap( Map value, MetadataJsonSchema jsonSchema) { - Map values = {}; + final Map values = {}; for (final i in value.entries) { TransactionMetadata? key; if (jsonSchema == MetadataJsonSchema.basicConversions && diff --git a/lib/ada/src/models/plutus/plutus/types/bytes.dart b/lib/ada/src/models/plutus/plutus/types/bytes.dart index ea21df9..4207ccb 100644 --- a/lib/ada/src/models/plutus/plutus/types/bytes.dart +++ b/lib/ada/src/models/plutus/plutus/types/bytes.dart @@ -22,7 +22,7 @@ class PlutusBytes extends PlutusData { @override CborObject toCbor() { if (value.length > PlutusDataUtils.chunkSize) { - List> chunks = []; + final List> chunks = []; for (var i = 0; i < value.length; i += PlutusDataUtils.chunkSize) { chunks.add(value.sublist( i, diff --git a/lib/ada/src/models/plutus/utils/utils.dart b/lib/ada/src/models/plutus/utils/utils.dart index e0bf75f..c969c4d 100644 --- a/lib/ada/src/models/plutus/utils/utils.dart +++ b/lib/ada/src/models/plutus/utils/utils.dart @@ -134,9 +134,9 @@ class PlutusDataUtils { } static PlutusData _encodeMap(Map value, PlutusJsonSchema jsonSchema) { - Map values = {}; + final Map values = {}; for (final i in value.entries) { - PlutusData key = + final PlutusData key = _encodeString(schame: jsonSchema, value: i.key, isKey: true); values.addAll({key: parsePlutus(i.value, jsonSchema)}); } diff --git a/lib/ada/src/models/transaction/output/models/multi_assets.dart b/lib/ada/src/models/transaction/output/models/multi_assets.dart index 5f2ce42..d5cc620 100644 --- a/lib/ada/src/models/transaction/output/models/multi_assets.dart +++ b/lib/ada/src/models/transaction/output/models/multi_assets.dart @@ -68,18 +68,18 @@ class MultiAsset with ADASerialization implements Comparable { } BigInt _amount(MultiAsset ma, PolicyID pid, AssetName aname) { - BigInt? amount = ma.assets[pid]?.assets[aname]; + final BigInt? amount = ma.assets[pid]?.assets[aname]; return amount ?? BigInt.zero; } bool _compare(MultiAsset lhs, MultiAsset rhs) { - for (var entry in lhs.assets.entries) { - PolicyID pid = entry.key; - Assets? assets = entry.value; - for (var assetEntry in assets.assets.entries) { - AssetName aname = assetEntry.key; - BigInt amount = assetEntry.value; - BigInt rhsAmount = _amount(rhs, pid, aname); + for (final entry in lhs.assets.entries) { + final PolicyID pid = entry.key; + final Assets assets = entry.value; + for (final assetEntry in assets.assets.entries) { + final AssetName aname = assetEntry.key; + final BigInt amount = assetEntry.value; + final BigInt rhsAmount = _amount(rhs, pid, aname); if (amount - rhsAmount > BigInt.zero) { return false; } diff --git a/lib/ada/src/provider/blockfrost/models/models/account_summery.dart b/lib/ada/src/provider/blockfrost/models/models/account_summery.dart index 0f6c95e..8852f13 100644 --- a/lib/ada/src/provider/blockfrost/models/models/account_summery.dart +++ b/lib/ada/src/provider/blockfrost/models/models/account_summery.dart @@ -21,13 +21,13 @@ class ADAAccountSummaryResponse { }); factory ADAAccountSummaryResponse.fromJson(Map json) { - var receivedSumList = json['received_sum'] as List; - List receivedSum = receivedSumList + final receivedSumList = json['received_sum'] as List; + final List receivedSum = receivedSumList .map((item) => ADAAmountResponse.fromJson(item)) .toList(); - var sentSumList = json['sent_sum'] as List; - List sentSum = + final sentSumList = json['sent_sum'] as List; + final List sentSum = sentSumList.map((item) => ADAAmountResponse.fromJson(item)).toList(); return ADAAccountSummaryResponse( diff --git a/lib/ada/src/provider/blockfrost/models/models/address_summery.dart b/lib/ada/src/provider/blockfrost/models/models/address_summery.dart index b8ffa90..f94535e 100644 --- a/lib/ada/src/provider/blockfrost/models/models/address_summery.dart +++ b/lib/ada/src/provider/blockfrost/models/models/address_summery.dart @@ -25,8 +25,8 @@ class ADAAddressSummaryResponse { }); factory ADAAddressSummaryResponse.fromJson(Map json) { - var amountList = json['amount'] as List; - List amounts = + final amountList = json['amount'] as List; + final List amounts = amountList.map((item) => ADAAmountResponse.fromJson(item)).toList(); return ADAAddressSummaryResponse( diff --git a/lib/ada/src/provider/blockfrost/models/models/block_address_transactions.dart b/lib/ada/src/provider/blockfrost/models/models/block_address_transactions.dart index dd0f6c4..ea4fc4d 100644 --- a/lib/ada/src/provider/blockfrost/models/models/block_address_transactions.dart +++ b/lib/ada/src/provider/blockfrost/models/models/block_address_transactions.dart @@ -12,8 +12,8 @@ class ADABlockAddressTransactionsResponse { factory ADABlockAddressTransactionsResponse.fromJson( Map json) { - var transactionsList = json['transactions'] as List; - List transactions = + final transactionsList = json['transactions'] as List; + final List transactions = transactionsList.map((item) => item['tx_hash'] as String).toList(); return ADABlockAddressTransactionsResponse( diff --git a/lib/ada/src/provider/blockfrost/utils/blockforest_provider_utils.dart b/lib/ada/src/provider/blockfrost/utils/blockforest_provider_utils.dart index 505236b..7be60a7 100644 --- a/lib/ada/src/provider/blockfrost/utils/blockforest_provider_utils.dart +++ b/lib/ada/src/provider/blockfrost/utils/blockforest_provider_utils.dart @@ -1,9 +1,9 @@ class BlockforestProviderUtils { static final RegExp _pathParamRegex = RegExp(r':\w+'); static List extractParams(String url) { - Iterable matches = _pathParamRegex.allMatches(url); - List params = []; - for (Match match in matches) { + final Iterable matches = _pathParamRegex.allMatches(url); + final List params = []; + for (final Match match in matches) { params.add(match.group(0)!); } return List.unmodifiable(params); diff --git a/lib/ethereum/src/models/fee_history.dart b/lib/ethereum/src/models/fee_history.dart index 3416675..f0621b0 100644 --- a/lib/ethereum/src/models/fee_history.dart +++ b/lib/ethereum/src/models/fee_history.dart @@ -53,22 +53,26 @@ class FeeHistory { FeeHistorical toFee() { FeeHistorical toPriority(List<_FeeHistorical> priorities, BigInt baseFee) { BigInt avg(List arr) { - BigInt sum = arr.reduce((a, v) => a + v); + final BigInt sum = arr.reduce((a, v) => a + v); return sum ~/ BigInt.from(arr.length); } - BigInt slow = avg(priorities.map((b) { + final BigInt slow = avg(priorities.map((b) { return b.priorityFeePerGas[0]; }).toList()); - BigInt average = + final BigInt average = avg(priorities.map((b) => b.priorityFeePerGas[1]).toList()); - BigInt fast = avg(priorities.map((b) => b.priorityFeePerGas[2]).toList()); + final BigInt fast = + avg(priorities.map((b) => b.priorityFeePerGas[2]).toList()); return FeeHistorical( slow: slow, high: fast, normal: average, baseFee: baseFee); } - int minLength = [gasUsedRatio.length, baseFeePerGas.length, reward.length] - .reduce((min, current) => current < min ? current : min); + final int minLength = [ + gasUsedRatio.length, + baseFeePerGas.length, + reward.length + ].reduce((min, current) => current < min ? current : min); final List<_FeeHistorical> historical = List.generate( minLength, (index) => _FeeHistorical( diff --git a/lib/ethereum/src/rlp/decode.dart b/lib/ethereum/src/rlp/decode.dart index 69974f9..7ed1cd6 100644 --- a/lib/ethereum/src/rlp/decode.dart +++ b/lib/ethereum/src/rlp/decode.dart @@ -15,10 +15,10 @@ class RLPDecoder { /// Decode an RLP-encoded array. static _Decoded _decodeArray( List data, int offset, int childOffset, int length) { - List result = []; + final List result = []; while (childOffset < offset + 1 + length) { - _Decoded decoded = _decode(data, childOffset); + final _Decoded decoded = _decode(data, childOffset); result.add(decoded.result); @@ -38,22 +38,22 @@ class RLPDecoder { } if (data[offset] >= 0xf8) { - int lengthLength = data[offset] - 0xf7; - int length = _decodeLength(data, offset + 1, lengthLength); + final int lengthLength = data[offset] - 0xf7; + final int length = _decodeLength(data, offset + 1, lengthLength); return _decodeArray( data, offset, offset + 1 + lengthLength, lengthLength + length); } else if (data[offset] >= 0xc0) { - int length = data[offset] - 0xc0; + final int length = data[offset] - 0xc0; return _decodeArray(data, offset, offset + 1, length); } else if (data[offset] >= 0xb8) { - int lengthLength = data[offset] - 0xb7; - int length = _decodeLength(data, offset + 1, lengthLength); - List result = data.sublist( + final int lengthLength = data[offset] - 0xb7; + final int length = _decodeLength(data, offset + 1, lengthLength); + final List result = data.sublist( offset + 1 + lengthLength, offset + 1 + lengthLength + length); return _Decoded(consumed: (1 + lengthLength + length), result: result); } else if (data[offset] >= 0x80) { - int length = data[offset] - 0x80; - List result = data.sublist(offset + 1, offset + 1 + length); + final int length = data[offset] - 0x80; + final List result = data.sublist(offset + 1, offset + 1 + length); return _Decoded(consumed: (1 + length), result: result); } @@ -63,7 +63,7 @@ class RLPDecoder { /// Decode an RLP-encoded list of items. static List decode(List data) { try { - _Decoded decoded = _decode(data, 0); + final _Decoded decoded = _decode(data, 0); if (decoded.consumed != data.length) { throw const ETHPluginException("invalid rpl payload bytes"); } diff --git a/lib/ethereum/src/rlp/encode.dart b/lib/ethereum/src/rlp/encode.dart index 521a268..b313e7d 100644 --- a/lib/ethereum/src/rlp/encode.dart +++ b/lib/ethereum/src/rlp/encode.dart @@ -2,7 +2,7 @@ class RLPEncoder { /// Encodes an integer value into its RLP representation. static List _encodeArray(int value) { - List result = []; + final List result = []; while (value != 0) { result.insert(0, value & 0xff); value >>= 8; @@ -13,7 +13,7 @@ class RLPEncoder { /// Recursive encoding of the given object using RLP. static List _encode(List object) { if (object is! List) { - List payload = []; + final List payload = []; for (final child in object) { payload.addAll(_encode(child)); } @@ -23,12 +23,12 @@ class RLPEncoder { return payload; } - List length = _encodeArray(payload.length); + final List length = _encodeArray(payload.length); length.insert(0, 0xf7 + length.length); return [...length, ...payload]; } - List data = List.from(object, growable: true); + final List data = List.from(object, growable: true); if (data.length == 1 && data[0] <= 0x7f) { return data; @@ -37,7 +37,7 @@ class RLPEncoder { return data; } - List length = _encodeArray(data.length); + final List length = _encodeArray(data.length); length.insert(0, 0xb7 + length.length); return [...length, ...data]; diff --git a/lib/ethereum/src/transaction/eth_transaction.dart b/lib/ethereum/src/transaction/eth_transaction.dart index b339532..d8a55cb 100644 --- a/lib/ethereum/src/transaction/eth_transaction.dart +++ b/lib/ethereum/src/transaction/eth_transaction.dart @@ -99,9 +99,9 @@ class _ETHTransactionUtils { /// /// Returns an [ETHTransaction] object representing the legacy transaction. static ETHTransaction _fromLegacy(List decode) { - int nonce = IntUtils.fromBytes(decode[0]); - BigInt gasPrice = BigintUtils.fromBytes(decode[1]); - BigInt gasLimit = BigintUtils.fromBytes(decode[2]); + final int nonce = IntUtils.fromBytes(decode[0]); + final BigInt gasPrice = BigintUtils.fromBytes(decode[1]); + final BigInt gasLimit = BigintUtils.fromBytes(decode[2]); final ETHAddress? to = (decode[3] as List).isEmpty ? null : ETHAddress.fromBytes(decode[3]); final value = BigintUtils.fromBytes(decode[4]); @@ -137,9 +137,9 @@ class _ETHTransactionUtils { /// Converts the decoded data to an EIP-2930 transaction. static ETHTransaction _fromEIP2930(List decode) { final BigInt chainId = BigintUtils.fromBytes(decode[0]); - int nonce = IntUtils.fromBytes(decode[1]); - BigInt gasPrice = BigintUtils.fromBytes(decode[2]); - BigInt gasLimit = BigintUtils.fromBytes(decode[3]); + final int nonce = IntUtils.fromBytes(decode[1]); + final BigInt gasPrice = BigintUtils.fromBytes(decode[2]); + final BigInt gasLimit = BigintUtils.fromBytes(decode[3]); final ETHAddress? to = (decode[4] as List).isEmpty ? null : ETHAddress.fromBytes(decode[4]); final value = BigintUtils.fromBytes(decode[5]); @@ -173,10 +173,10 @@ class _ETHTransactionUtils { /// Converts the decoded data to an EIP-1559 transaction. static ETHTransaction _fromEIP1559(List decode) { final BigInt chainId = BigintUtils.fromBytes(decode[0]); - int nonce = IntUtils.fromBytes(decode[1]); - BigInt maxPriorityFeePerGas = BigintUtils.fromBytes(decode[2]); - BigInt maxFeePerGas = BigintUtils.fromBytes(decode[3]); - BigInt gasLimit = BigintUtils.fromBytes(decode[4]); + final int nonce = IntUtils.fromBytes(decode[1]); + final BigInt maxPriorityFeePerGas = BigintUtils.fromBytes(decode[2]); + final BigInt maxFeePerGas = BigintUtils.fromBytes(decode[3]); + final BigInt gasLimit = BigintUtils.fromBytes(decode[4]); final ETHAddress? to = (decode[5] as List).isEmpty ? null : ETHAddress.fromBytes(decode[5]); final value = BigintUtils.fromBytes(decode[6]); @@ -385,7 +385,7 @@ class ETHTransaction { /// Converts the [ETHTransaction] to its EIP-1559 serialized form. /// If [sig] is provided, includes the signature fields in the serialization. List _toEIP1559([ETHSignature? sig]) { - List> fields = [ + final List> fields = [ _ETHTransactionUtils.bigintToBytes(chainId), _ETHTransactionUtils.intToBytes(nonce), _ETHTransactionUtils.bigintToBytes(maxPriorityFeePerGas!), @@ -431,7 +431,7 @@ class ETHTransaction { /// Converts the [ETHTransaction] to its legacy (pre-EIP-155) serialized form. /// If [sig] is provided, includes the signature fields in the serialization. List _toLegacy([ETHSignature? sig]) { - List> fields = [ + final List> fields = [ _ETHTransactionUtils.intToBytes(nonce), _ETHTransactionUtils.bigintToBytes(gasPrice!), _ETHTransactionUtils.bigintToBytes(gasLimit), diff --git a/lib/solana/src/borsh_serialization/core/borsh_serializable.dart b/lib/solana/src/borsh_serialization/core/borsh_serializable.dart index 8bd3662..74bcba6 100644 --- a/lib/solana/src/borsh_serialization/core/borsh_serializable.dart +++ b/lib/solana/src/borsh_serialization/core/borsh_serializable.dart @@ -65,7 +65,7 @@ abstract class LayoutSerializable { Map toJson() { final json = serialize()..removeWhere((k, v) => v == null); - Map toHuman = {}; + final Map toHuman = {}; for (final i in json.entries) { toHuman[i.key] = _toString(i.value); } diff --git a/lib/solana/src/instructions/metaplex/auction_house/accounts/accounts/auction_house.dart b/lib/solana/src/instructions/metaplex/auction_house/accounts/accounts/auction_house.dart index 8e397f2..e3310fa 100644 --- a/lib/solana/src/instructions/metaplex/auction_house/accounts/accounts/auction_house.dart +++ b/lib/solana/src/instructions/metaplex/auction_house/accounts/accounts/auction_house.dart @@ -28,7 +28,7 @@ class _Utils { ]); static List decodeScoops(List bytes) { - List scopes = []; + final List scopes = []; for (int i = 0; i < AuthorityScope.values.length; i++) { if (!bytes[i]) continue; scopes.add(AuthorityScope.fromValue(i)); diff --git a/lib/solana/src/instructions/metaplex/auction_house/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/auction_house/layouts/instruction/program_layout.dart index da9fc65..87bed2e 100644 --- a/lib/solana/src/instructions/metaplex/auction_house/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/auction_house/layouts/instruction/program_layout.dart @@ -44,7 +44,7 @@ abstract class MetaplexAuctionHouseProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexAuctionHouseProgramInstruction? instruction = + final MetaplexAuctionHouseProgramInstruction? instruction = MetaplexAuctionHouseProgramInstruction.getInstruction( decode["instruction"]); diff --git a/lib/solana/src/instructions/metaplex/auctioneer/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/auctioneer/layouts/instruction/program_layout.dart index d2214aa..824c93a 100644 --- a/lib/solana/src/instructions/metaplex/auctioneer/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/auctioneer/layouts/instruction/program_layout.dart @@ -19,7 +19,7 @@ abstract class MetaplexAuctioneerProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexAuctioneerProgramInstruction? instruction = + final MetaplexAuctioneerProgramInstruction? instruction = MetaplexAuctioneerProgramInstruction.getInstruction( decode["instruction"]); diff --git a/lib/solana/src/instructions/metaplex/bubblegum/layouts/instructions/program_layout.dart b/lib/solana/src/instructions/metaplex/bubblegum/layouts/instructions/program_layout.dart index 3d8f090..49db01f 100644 --- a/lib/solana/src/instructions/metaplex/bubblegum/layouts/instructions/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/bubblegum/layouts/instructions/program_layout.dart @@ -33,7 +33,7 @@ abstract class MetaplexBubblegumProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexBubblegumProgramInstruction? instruction = + final MetaplexBubblegumProgramInstruction? instruction = MetaplexBubblegumProgramInstruction.getInstruction( decode["instruction"]); switch (instruction) { diff --git a/lib/solana/src/instructions/metaplex/candy_machine_core/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/candy_machine_core/layouts/instruction/program_layout.dart index 570344c..4a09792 100644 --- a/lib/solana/src/instructions/metaplex/candy_machine_core/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/candy_machine_core/layouts/instruction/program_layout.dart @@ -34,7 +34,7 @@ abstract class MetaplexCandyMachineProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexCandyMachineProgramInstruction? instruction = + final MetaplexCandyMachineProgramInstruction? instruction = MetaplexCandyMachineProgramInstruction.getInstruction( decode["instruction"]); diff --git a/lib/solana/src/instructions/metaplex/fixed_price_sale/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/fixed_price_sale/layouts/instruction/program_layout.dart index 96a419d..1e5cc35 100644 --- a/lib/solana/src/instructions/metaplex/fixed_price_sale/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/fixed_price_sale/layouts/instruction/program_layout.dart @@ -27,7 +27,7 @@ abstract class MetaplexFixedPriceSaleProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexFixedPriceSaleProgramInstruction? instruction = + final MetaplexFixedPriceSaleProgramInstruction? instruction = MetaplexFixedPriceSaleProgramInstruction.getInstruction( decode["instruction"]); diff --git a/lib/solana/src/instructions/metaplex/gumdrop/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/gumdrop/layouts/instruction/program_layout.dart index 914e2d5..cac9f98 100644 --- a/lib/solana/src/instructions/metaplex/gumdrop/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/gumdrop/layouts/instruction/program_layout.dart @@ -25,7 +25,7 @@ abstract class MetaplexGumdropProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexGumdropProgramInstruction? instruction = + final MetaplexGumdropProgramInstruction? instruction = MetaplexGumdropProgramInstruction.getInstruction(decode["instruction"]); switch (instruction) { diff --git a/lib/solana/src/instructions/metaplex/hydra/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/hydra/layouts/instruction/program_layout.dart index a84ab14..a488514 100644 --- a/lib/solana/src/instructions/metaplex/hydra/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/hydra/layouts/instruction/program_layout.dart @@ -29,7 +29,7 @@ abstract class MetaplexHydraProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexHydraProgramInstruction? instruction = + final MetaplexHydraProgramInstruction? instruction = MetaplexHydraProgramInstruction.getInstruction(decode["instruction"]); switch (instruction) { case MetaplexHydraProgramInstruction.processAddMemberNft: diff --git a/lib/solana/src/instructions/metaplex/nft_packs/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/nft_packs/layouts/instruction/program_layout.dart index 6a9dc8a..cc6468d 100644 --- a/lib/solana/src/instructions/metaplex/nft_packs/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/nft_packs/layouts/instruction/program_layout.dart @@ -28,7 +28,7 @@ abstract class MetaplexNFTPacksProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexNFTPacksProgramInstruction? instruction = + final MetaplexNFTPacksProgramInstruction? instruction = MetaplexNFTPacksProgramInstruction.getInstruction( decode["instruction"]); diff --git a/lib/solana/src/instructions/metaplex/token_entangler/layouts/instruction/program_layout.dart b/lib/solana/src/instructions/metaplex/token_entangler/layouts/instruction/program_layout.dart index 9328f2d..872f838 100644 --- a/lib/solana/src/instructions/metaplex/token_entangler/layouts/instruction/program_layout.dart +++ b/lib/solana/src/instructions/metaplex/token_entangler/layouts/instruction/program_layout.dart @@ -18,7 +18,7 @@ abstract class MetaplexTokenEntanglerProgramLayout extends ProgramLayout { static ProgramLayout fromBytes(List data) { final decode = ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data); - MetaplexTokenEntanglerProgramInstruction? instruction = + final MetaplexTokenEntanglerProgramInstruction? instruction = MetaplexTokenEntanglerProgramInstruction.getInstruction( decode["instruction"]); switch (instruction) { diff --git a/lib/solana/src/instructions/name_service/layouts/layouts/update.dart b/lib/solana/src/instructions/name_service/layouts/layouts/update.dart index 04a7f48..b3705ae 100644 --- a/lib/solana/src/instructions/name_service/layouts/layouts/update.dart +++ b/lib/solana/src/instructions/name_service/layouts/layouts/update.dart @@ -17,7 +17,7 @@ class NameServiceUpdateLayout extends NameServiceProgramLayout { /// Creates a NameServiceUpdateLayout instance from buffer data. factory NameServiceUpdateLayout.fromBuffer(List data) { - Map decode = ProgramLayout.decodeAndValidateStruct( + final Map decode = ProgramLayout.decodeAndValidateStruct( layout: _layout, bytes: data, instruction: NameServiceProgramInstruction.update.insturction, diff --git a/lib/solana/src/instructions/name_service/name_service_twitter_helper.dart b/lib/solana/src/instructions/name_service/name_service_twitter_helper.dart index 7755c66..f2dc736 100644 --- a/lib/solana/src/instructions/name_service/name_service_twitter_helper.dart +++ b/lib/solana/src/instructions/name_service/name_service_twitter_helper.dart @@ -22,7 +22,7 @@ class NameServiceProgramTwitterHelper { nameParent: NameServiceProgramConst.twitterRootPrentRegisteryKey, ); - List instructions = [ + final List instructions = [ NameServiceProgram.create( nameKey: twitterHandleRegistryKey, nameOwnerKey: verifiedPubkey, diff --git a/lib/solana/src/instructions/name_service/utils/utils.dart b/lib/solana/src/instructions/name_service/utils/utils.dart index 3aa55f5..40b8d6e 100644 --- a/lib/solana/src/instructions/name_service/utils/utils.dart +++ b/lib/solana/src/instructions/name_service/utils/utils.dart @@ -18,7 +18,7 @@ class NameServiceProgramUtils { SolAddress? nameClass, SolAddress? nameParent, }) { - List> seeds = [hashedName]; + final List> seeds = [hashedName]; seeds.add(nameClass?.toBytes() ?? List.filled(32, 0)); seeds.add(nameParent?.toBytes() ?? List.filled(32, 0)); return SolanaUtils.findProgramAddress( diff --git a/lib/solana/src/instructions/spl_token/utils/utils/spl_token2022_utils.dart b/lib/solana/src/instructions/spl_token/utils/utils/spl_token2022_utils.dart index 4a05c9d..c5188ab 100644 --- a/lib/solana/src/instructions/spl_token/utils/utils/spl_token2022_utils.dart +++ b/lib/solana/src/instructions/spl_token/utils/utils/spl_token2022_utils.dart @@ -9,15 +9,15 @@ class SPLToken2022Utils { static const int lengthSize = 2; static List getExtensionTypes(List tlvData) { - List extensionTypes = []; + final List extensionTypes = []; int extensionTypeIndex = 0; while (extensionTypeIndex < tlvData.length) { - int entryType = IntUtils.fromBytes( + final int entryType = IntUtils.fromBytes( tlvData.sublist(extensionTypeIndex, extensionTypeIndex + typeSize), byteOrder: Endian.little); extensionTypes.add(entryType); - int entryLength = IntUtils.fromBytes( + final int entryLength = IntUtils.fromBytes( tlvData.sublist(extensionTypeIndex + typeSize, extensionTypeIndex + typeSize + lengthSize), byteOrder: Endian.little); @@ -31,14 +31,14 @@ class SPLToken2022Utils { {required ExtensionType extension, required List tlvData}) { int extensionTypeIndex = 0; while (extensionTypeIndex + typeSize + lengthSize <= tlvData.length) { - int entryType = IntUtils.fromBytes( + final int entryType = IntUtils.fromBytes( tlvData.sublist(extensionTypeIndex, extensionTypeIndex + typeSize), byteOrder: Endian.little); - int entryLength = IntUtils.fromBytes( + final int entryLength = IntUtils.fromBytes( tlvData.sublist(extensionTypeIndex + typeSize, extensionTypeIndex + typeSize + lengthSize), byteOrder: Endian.little); - int typeIndex = extensionTypeIndex + typeSize + lengthSize; + final int typeIndex = extensionTypeIndex + typeSize + lengthSize; if (entryType == extension.value) { return tlvData.sublist(typeIndex, typeIndex + entryLength); } diff --git a/lib/solana/src/instructions/spl_token/utils/utils/transfer_hook_utils.dart b/lib/solana/src/instructions/spl_token/utils/utils/transfer_hook_utils.dart index 8f33e3c..5105212 100644 --- a/lib/solana/src/instructions/spl_token/utils/utils/transfer_hook_utils.dart +++ b/lib/solana/src/instructions/spl_token/utils/utils/transfer_hook_utils.dart @@ -11,7 +11,7 @@ class TransferHookUtils { if (seeds.isEmpty) { throw const SolanaPluginException("Transfer hook invalid seeds"); } - int length = seeds[0]; + final int length = seeds[0]; if (seeds.length < length + 1) { throw const SolanaPluginException("Transfer hook invalid seeds"); } @@ -23,8 +23,8 @@ class TransferHookUtils { if (seeds.length < 2) { throw const SolanaPluginException("Transfer hook invalid seeds"); } - int index = seeds[0]; - int length = seeds[1]; + final int index = seeds[0]; + final int length = seeds[1]; if (instructionData.length < length + index) { throw const SolanaPluginException("Transfer hook invalid seeds"); } @@ -36,7 +36,7 @@ class TransferHookUtils { if (seeds.isEmpty) { throw const SolanaPluginException("Transfer hook invalid seeds"); } - int index = seeds[0]; + final int index = seeds[0]; if (previousMetas.length <= index) { throw const SolanaPluginException("Transfer hook invalid seeds"); } @@ -50,13 +50,13 @@ class TransferHookUtils { if (seeds.length < 3) { throw const SolanaPluginException("Transfer hook invalid seeds"); } - int accountIndex = seeds[0]; - int dataIndex = seeds[1]; - int length = seeds[2]; + final int accountIndex = seeds[0]; + final int dataIndex = seeds[1]; + final int length = seeds[2]; if (previousMetas.length <= accountIndex) { throw const SolanaPluginException("Transfer hook invalid seeds"); } - SolanaAccountInfo? accountInfo = await connection.request( + final SolanaAccountInfo? accountInfo = await connection.request( SolanaRPCGetAccountInfo( account: previousMetas[accountIndex].publicKey)); if (accountInfo == null) { @@ -74,8 +74,8 @@ class TransferHookUtils { required List previousMetas, required List instructionData, required SolanaRPC connection}) async { - int discriminator = seeds[0]; - List remaining = seeds.sublist(1); + final int discriminator = seeds[0]; + final List remaining = seeds.sublist(1); switch (discriminator) { case 0: return null; @@ -102,7 +102,7 @@ class TransferHookUtils { required List previousMetas, required List instructionData, required SolanaRPC connection}) async { - List> unpackedSeeds = []; + final List> unpackedSeeds = []; int i = 0; while (i < 32) { final seed = await unpackFirstSeed( @@ -137,7 +137,7 @@ class TransferHookUtils { if (extraMeta.discriminator == 1) { programId = transferHookProgramId; } else { - int accountIndex = extraMeta.discriminator - (1 << 7); + final int accountIndex = extraMeta.discriminator - (1 << 7); if (previousMetas.length <= accountIndex) { throw const SolanaPluginException("account not found."); } diff --git a/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/create.dart b/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/create.dart index 0e209b8..f73ea24 100644 --- a/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/create.dart +++ b/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/create.dart @@ -26,7 +26,7 @@ class SPLTokenMetaDataInitializeLayout extends SPLTokenMetaDataProgramLayout { /// Decodes the provided byte array to construct a new [SPLTokenMetaDataInitializeLayout] instance. factory SPLTokenMetaDataInitializeLayout.fromBuffer(List data) { - Map decode = + final Map decode = SPLTokenMetaDataProgramLayout.decodeAndValidateStruct( layout: staticLayout, bytes: data, diff --git a/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/update.dart b/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/update.dart index b39ba37..b689e63 100644 --- a/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/update.dart +++ b/lib/solana/src/instructions/spl_token_meta_data/layouts/layouts/update.dart @@ -13,7 +13,7 @@ class SPLTokenMetaDataUpdateLayout extends SPLTokenMetaDataProgramLayout { /// Decodes the provided byte array to construct a new `SPLTokenMetaDataUpdateLayout` instance. factory SPLTokenMetaDataUpdateLayout.fromBuffer(List bytes) { - Map decode = + final Map decode = SPLTokenMetaDataProgramLayout.decodeAndValidateStruct( layout: _layout, bytes: bytes, diff --git a/lib/solana/src/instructions/stake_pool/layouts/layouts/create_token_meta_data.dart b/lib/solana/src/instructions/stake_pool/layouts/layouts/create_token_meta_data.dart index ea9dcc2..732c9d6 100644 --- a/lib/solana/src/instructions/stake_pool/layouts/layouts/create_token_meta_data.dart +++ b/lib/solana/src/instructions/stake_pool/layouts/layouts/create_token_meta_data.dart @@ -43,7 +43,7 @@ class StakePoolCreateTokenMetaDataLayout extends StakePoolProgramLayout { return StakePoolCreateTokenMetaDataLayout._(name, uri, symbol); } factory StakePoolCreateTokenMetaDataLayout.fromBuffer(List data) { - Map decode = ProgramLayout.decodeAndValidateStruct( + final Map decode = ProgramLayout.decodeAndValidateStruct( layout: staticLayout, bytes: data, instruction: diff --git a/lib/solana/src/instructions/stake_pool/program_helper.dart b/lib/solana/src/instructions/stake_pool/program_helper.dart index aac0472..ed67b18 100644 --- a/lib/solana/src/instructions/stake_pool/program_helper.dart +++ b/lib/solana/src/instructions/stake_pool/program_helper.dart @@ -419,7 +419,7 @@ class StakePoolProgramHelper { final instructions = []; int startIndex = 0; - List> validatorChunks = + final List> validatorChunks = _arrayChunk(validatorList.validators, 5); for (final validatorChunk in validatorChunks) { diff --git a/lib/solana/src/models/transaction/account_key.dart b/lib/solana/src/models/transaction/account_key.dart index 45bb260..dc0a756 100644 --- a/lib/solana/src/models/transaction/account_key.dart +++ b/lib/solana/src/models/transaction/account_key.dart @@ -50,7 +50,7 @@ class MessageAccountKeys { throw const SolanaPluginException( 'Account index overflow encountered during compilation'); } - Map keyIndexMap = {}; + final Map keyIndexMap = {}; for (final keySegment in _keySegments.expand((segment) => segment)) { keyIndexMap[keySegment.address] = keyIndexMap.length; } diff --git a/lib/solana/src/rpc/core/core.dart b/lib/solana/src/rpc/core/core.dart index bc2cd55..e775ccb 100644 --- a/lib/solana/src/rpc/core/core.dart +++ b/lib/solana/src/rpc/core/core.dart @@ -92,7 +92,7 @@ abstract class SolanaRPCRequest extends LoockupLedgerRequest /// Converts the request parameters to a [SolanaRequestDetails] object. SolanaRequestDetails toRequest(int requestId) { - List inJson = [...toJson(), ...super.toJson()]; + final List inJson = [...toJson(), ...super.toJson()]; inJson.removeWhere((v) => v == null); final params = { "jsonrpc": "2.0", diff --git a/lib/solana/src/rpc/utils/solana_rpc_utils.dart b/lib/solana/src/rpc/utils/solana_rpc_utils.dart index 2fe05cf..1543eec 100644 --- a/lib/solana/src/rpc/utils/solana_rpc_utils.dart +++ b/lib/solana/src/rpc/utils/solana_rpc_utils.dart @@ -7,7 +7,7 @@ class SolanaRPCUtils { /// Returns a merged configuration map or null if no valid configuration is found. static Map? createConfig( List?> configs) { - Map config = {}; + final Map config = {}; for (final i in configs) { if (i == null) continue; for (final k in i.keys) { diff --git a/lib/solana/src/transaction/core/core.dart b/lib/solana/src/transaction/core/core.dart index 1c3ae7f..4984e18 100644 --- a/lib/solana/src/transaction/core/core.dart +++ b/lib/solana/src/transaction/core/core.dart @@ -60,8 +60,9 @@ abstract class VersionedMessage { /// Constructs a versioned message from a serialized buffer. factory VersionedMessage.fromBuffer(List serializedMessage) { - int prefix = serializedMessage[0]; - int maskedPrefix = prefix & SolanaTransactionConstant.versionPrefixMask; + final int prefix = serializedMessage[0]; + final int maskedPrefix = + prefix & SolanaTransactionConstant.versionPrefixMask; if (maskedPrefix == prefix) { return Message.fromBuffer(serializedMessage); } diff --git a/lib/solana/src/transaction/message/message_v0.dart b/lib/solana/src/transaction/message/message_v0.dart index 6c01bcf..5eb2f54 100644 --- a/lib/solana/src/transaction/message/message_v0.dart +++ b/lib/solana/src/transaction/message/message_v0.dart @@ -116,13 +116,13 @@ class MessageV0 implements VersionedMessage { List addressLookupTableAccounts) { final List writable = []; final List readonly = []; - for (var tableLookup in addressTableLookups) { + for (final tableLookup in addressTableLookups) { final tableAccount = addressLookupTableAccounts.firstWhere( (account) => account.key == tableLookup.accountKey, orElse: () => throw SolanaPluginException( 'Failed to find address lookup table account for table key ${tableLookup.accountKey}'), ); - for (var index in tableLookup.writableIndexes) { + for (final index in tableLookup.writableIndexes) { if (index < tableAccount.addresses.length) { writable.add(tableAccount.addresses[index]); } else { @@ -130,7 +130,7 @@ class MessageV0 implements VersionedMessage { 'Failed to find address for index $index in address lookup table ${tableLookup.accountKey}'); } } - for (var index in tableLookup.readonlyIndexes) { + for (final index in tableLookup.readonlyIndexes) { if (index < tableAccount.addresses.length) { readonly.add(tableAccount.addresses[index]); } else { diff --git a/lib/solana/src/transaction/transaction/transaction.dart b/lib/solana/src/transaction/transaction/transaction.dart index 57f1034..793c3ac 100644 --- a/lib/solana/src/transaction/transaction/transaction.dart +++ b/lib/solana/src/transaction/transaction/transaction.dart @@ -252,7 +252,7 @@ class SolanaTransaction { .verify(message: serializeMessage(), signature: signature)) { throw const SolanaPluginException("Signature verification failed."); } - List> currentSigs = List.from(_signatures); + final List> currentSigs = List.from(_signatures); currentSigs[signerIndex] = List.unmodifiable(signature); _signatures = List>.unmodifiable(currentSigs); } diff --git a/lib/solana/src/transaction/utils/utils.dart b/lib/solana/src/transaction/utils/utils.dart index 18a86f6..de79c0e 100644 --- a/lib/solana/src/transaction/utils/utils.dart +++ b/lib/solana/src/transaction/utils/utils.dart @@ -12,7 +12,7 @@ import 'package:on_chain/solana/src/utils/layouts.dart'; class SolanaTransactionUtils { /// encode int to bytes static List _encodeLength(int len) { - List bytes = []; + final List bytes = []; var remLen = len; for (;;) { var elem = remLen & 0x7f; @@ -33,7 +33,7 @@ class SolanaTransactionUtils { int len = 0; int size = 0; for (;;) { - int elem = bytes.removeAt(0); + final int elem = bytes.removeAt(0); len |= (elem & 0x7f) << size * 7; size += 1; if ((elem & 0x80) == 0) { @@ -84,7 +84,7 @@ class SolanaTransactionUtils { var serializedLength = 0; final serializedInstructions = List.filled(SolanaTransactionConstant.packetDataSize, 0); - for (var instruction in compiledInstructions) { + for (final instruction in compiledInstructions) { final encodedAccountKeyIndexesLength = SolanaTransactionUtils._encodeLength(instruction.accounts.length); final encodedDataLength = @@ -199,7 +199,8 @@ class SolanaTransactionUtils { /// convert bytes to Message V0 static MessageV0 deserializeV0(List serializedMessage) { - List byteArray = List.from(serializedMessage, growable: true); + final List byteArray = + List.from(serializedMessage, growable: true); final prefix = byteArray.removeAt(0); final maskedPrefix = prefix & SolanaTransactionConstant.versionPrefixMask; assert(prefix != maskedPrefix, @@ -273,11 +274,11 @@ class SolanaTransactionUtils { /// convert bytes to Message static Tuple>> deserializeTransaction( List serializedTransaction) { - List byteArray = [...serializedTransaction]; - List> signatures = []; - int signaturesLength = _decodeLength(byteArray); + final List byteArray = [...serializedTransaction]; + final List> signatures = []; + final int signaturesLength = _decodeLength(byteArray); for (int i = 0; i < signaturesLength; i++) { - int offset = i * SolanaTransactionConstant.signatureLengthInBytes; + final int offset = i * SolanaTransactionConstant.signatureLengthInBytes; signatures.add(byteArray.sublist( offset, offset + SolanaTransactionConstant.signatureLengthInBytes)); } @@ -314,7 +315,7 @@ class SolanaTransactionUtils { List.filled(SolanaTransactionConstant.packetDataSize, 0); instructionBuffer.setAll(0, instructionCount); int instructionBufferLength = instructionCount.length; - for (var instruction in instructions) { + for (final instruction in instructions) { final instructionLayout = LayoutConst.struct([ LayoutConst.u8(property: 'programIdIndex'), LayoutConst.blob((instruction['keyIndicesCount'] as List).length, @@ -368,33 +369,34 @@ class SolanaTransactionUtils { /// convert Bytes to legacy message static Message deserializeMessageLegacy(List bytes) { List byteArray = List.from(bytes); - int numRequiredSignatures = byteArray.removeAt(0); + final int numRequiredSignatures = byteArray.removeAt(0); if (numRequiredSignatures != (numRequiredSignatures & SolanaTransactionConstant.versionPrefixMask)) { throw const SolanaPluginException('invalid versioned Message'); } - int numReadonlySignedAccounts = byteArray.removeAt(0); - int numReadonlyUnsignedAccounts = byteArray.removeAt(0); - int accountCount = SolanaTransactionUtils._decodeLength(byteArray); - List accountKeys = []; + final int numReadonlySignedAccounts = byteArray.removeAt(0); + final int numReadonlyUnsignedAccounts = byteArray.removeAt(0); + final int accountCount = SolanaTransactionUtils._decodeLength(byteArray); + final List accountKeys = []; for (int i = 0; i < accountCount; i++) { - List account = + final List account = byteArray.sublist(0, SolanaTransactionConstant.publicKeyLength); byteArray = byteArray.sublist(SolanaTransactionConstant.publicKeyLength); accountKeys.add(SolAddress.uncheckBytes(account)); } - List recentBlockhash = + final List recentBlockhash = byteArray.sublist(0, SolanaTransactionConstant.publicKeyLength); byteArray = byteArray.sublist(SolanaTransactionConstant.publicKeyLength); - int instructionCount = SolanaTransactionUtils._decodeLength(byteArray); - List instructions = []; + final int instructionCount = + SolanaTransactionUtils._decodeLength(byteArray); + final List instructions = []; for (int i = 0; i < instructionCount; i++) { - int programIdIndex = byteArray.removeAt(0); - int accountCount = SolanaTransactionUtils._decodeLength(byteArray); - List accounts = byteArray.sublist(0, accountCount); + final int programIdIndex = byteArray.removeAt(0); + final int accountCount = SolanaTransactionUtils._decodeLength(byteArray); + final List accounts = byteArray.sublist(0, accountCount); byteArray = byteArray.sublist(accountCount); - int dataLength = SolanaTransactionUtils._decodeLength(byteArray); - List data = byteArray.sublist(0, dataLength); + final int dataLength = SolanaTransactionUtils._decodeLength(byteArray); + final List data = byteArray.sublist(0, dataLength); byteArray = byteArray.sublist(dataLength); instructions.add(CompiledInstruction( programIdIndex: programIdIndex, accounts: accounts, data: data)); diff --git a/lib/solana/src/zlib/src/decompress.dart b/lib/solana/src/zlib/src/decompress.dart index 4c2ba5a..72b3220 100644 --- a/lib/solana/src/zlib/src/decompress.dart +++ b/lib/solana/src/zlib/src/decompress.dart @@ -5,32 +5,32 @@ import 'package:on_chain/solana/src/exception/exception.dart'; class ZlibDecoder { /// Decompresses the input data using DEFLATE algorithm static List decompress(List input) { - _BitReader bitReader = _BitReader(input); + final _BitReader bitReader = _BitReader(input); final int cmf = bitReader.readByte(); - int cm = cmf & 15; + final int cm = cmf & 15; if (cm != 8) { throw const SolanaPluginException('invalid CM'); } - int cinfo = (cmf >> 4) & 15; // Compression info + final int cinfo = (cmf >> 4) & 15; // Compression info if (cinfo > 7) { throw const SolanaPluginException('invalid CINFO'); } - int flg = bitReader.readByte(); + final int flg = bitReader.readByte(); if ((cmf * 256 + flg) % 31 != 0) { throw const SolanaPluginException('CMF+FLG checksum failed'); } - int fdict = (flg >> 5) & 1; + final int fdict = (flg >> 5) & 1; if (fdict != 0) { throw const SolanaPluginException('preset dictionary not supported'); } - List out = _inflate(bitReader); // decompress DEFLATE data + final List out = _inflate(bitReader); // decompress DEFLATE data bitReader.readBytes(4); return out; } static void _noCompressionBlock(_BitReader bitReader, List out) { - int len = bitReader.readBytes(2); + final int len = bitReader.readBytes(2); bitReader.readBytes(2); for (int i = 0; i < len; i++) { out.add(bitReader.readByte()); @@ -40,7 +40,7 @@ class ZlibDecoder { static String _decodeSymbol(_BitReader bitReader, _HuffmanTree tree) { _Node node = tree.root; while (node.left != null || node.right != null) { - int b = bitReader.readBit(); + final int b = bitReader.readBit(); node = (b != 0) ? node.right! : node.left!; } return node.symbol; @@ -49,7 +49,7 @@ class ZlibDecoder { static void _inflateBlock(_BitReader bitReader, _HuffmanTree lengthTree, _HuffmanTree distanceTree, List out) { while (true) { - String sym = _decodeSymbol(bitReader, lengthTree); + final String sym = _decodeSymbol(bitReader, lengthTree); int symbol = int.parse(sym); if (symbol <= 255) { out.add(symbol); @@ -57,10 +57,11 @@ class ZlibDecoder { return; } else { symbol -= 257; - int length = bitReader.readBits(_ZlibConst.lengthExtraBits[symbol]) + - _ZlibConst.lengthBase[symbol]; - String distSym = _decodeSymbol(bitReader, distanceTree); - int dist = bitReader + final int length = + bitReader.readBits(_ZlibConst.lengthExtraBits[symbol]) + + _ZlibConst.lengthBase[symbol]; + final String distSym = _decodeSymbol(bitReader, distanceTree); + final int dist = bitReader .readBits(_ZlibConst.distanceExtraBits[int.parse(distSym)]) + _ZlibConst.distanceBase[int.parse(distSym)]; for (int i = 0; i < length; i++) { @@ -72,10 +73,10 @@ class ZlibDecoder { static List _inflate(_BitReader bitReader) { int bitFinal = 0; - List out = []; + final List out = []; while (bitFinal != 1) { bitFinal = bitReader.readBit(); - int type = bitReader.readBits(2); + final int type = bitReader.readBits(2); if (type == 0) { _noCompressionBlock(bitReader, out); } else if (type == 1) { @@ -101,11 +102,11 @@ class ZlibDecoder { ...List.filled(24, 7), ...List.filled(8, 8) ]; - _HuffmanTree literalLengthTree = + final _HuffmanTree literalLengthTree = _blListToTree(bl, List.generate(286, (index) => index)); bl = List.filled(32, 5); - _HuffmanTree distanceTree = + final _HuffmanTree distanceTree = _blListToTree(bl, List.generate(30, (index) => index)); _inflateBlock(bitReader, literalLengthTree, distanceTree, out); @@ -113,25 +114,25 @@ class ZlibDecoder { /// cc static _HuffmanTree _blListToTree(List bl, List alphabet) { - int maxBits = + final int maxBits = bl.reduce((value, element) => value > element ? value : element); - List blCount = List.filled(maxBits + 1, 0); - for (var bitlen in bl) { + final List blCount = List.filled(maxBits + 1, 0); + for (final bitlen in bl) { if (bitlen != 0) { blCount[bitlen]++; } } - List nextCode = [0, 0]; + final List nextCode = [0, 0]; for (int bits = 2; bits <= maxBits; bits++) { nextCode.add((nextCode[bits - 1] + blCount[bits - 1]) << 1); } - _HuffmanTree t = _HuffmanTree(); - int min = alphabet.length < bl.length ? alphabet.length : bl.length; + final _HuffmanTree t = _HuffmanTree(); + final int min = alphabet.length < bl.length ? alphabet.length : bl.length; for (int i = 0; i < min; i++) { - int c = alphabet[i]; - int bitlen = bl[i]; + final int c = alphabet[i]; + final int bitlen = bl[i]; if (bitlen != 0) { t.insert(nextCode[bitlen], bitlen, c.toString()); nextCode[bitlen]++; @@ -141,34 +142,34 @@ class ZlibDecoder { } static Tuple<_HuffmanTree, _HuffmanTree> _decodeTrees(_BitReader r) { - int hlit = r.readBits(5) + 257; - int hdist = r.readBits(5) + 1; - int hclen = r.readBits(4) + 4; - List codeLengthTreeBl = List.filled(19, 0); + final int hlit = r.readBits(5) + 257; + final int hdist = r.readBits(5) + 1; + final int hclen = r.readBits(4) + 4; + final List codeLengthTreeBl = List.filled(19, 0); for (int i = 0; i < hclen; i++) { codeLengthTreeBl[_ZlibConst.codeLengthCodesOrder[i]] = r.readBits(3); } - _HuffmanTree codeLengthTree = _blListToTree( + final _HuffmanTree codeLengthTree = _blListToTree( codeLengthTreeBl, List.generate(19, (index) => index)); - List bl = []; + final List bl = []; while (bl.length < hlit + hdist) { - String sym = _decodeSymbol(r, codeLengthTree); - int symbol = int.parse(sym); + final String sym = _decodeSymbol(r, codeLengthTree); + final int symbol = int.parse(sym); if (symbol >= 0 && symbol <= 15) { bl.add(symbol); } else if (symbol == 16) { - int prevCodeLength = bl[bl.length - 1]; - int repeatLength = r.readBits(2) + 3; + final int prevCodeLength = bl[bl.length - 1]; + final int repeatLength = r.readBits(2) + 3; for (int i = 0; i < repeatLength; i++) { bl.add(prevCodeLength); } } else if (symbol == 17) { - int repeatLength = r.readBits(3) + 3; + final int repeatLength = r.readBits(3) + 3; for (int i = 0; i < repeatLength; i++) { bl.add(0); } } else if (symbol == 18) { - int repeatLength = r.readBits(7) + 11; + final int repeatLength = r.readBits(7) + 11; for (int i = 0; i < repeatLength; i++) { bl.add(0); } @@ -176,9 +177,9 @@ class ZlibDecoder { throw const SolanaPluginException('invalid symbol'); } } - _HuffmanTree literalLengthTree = _blListToTree( + final _HuffmanTree literalLengthTree = _blListToTree( bl.sublist(0, hlit), List.generate(286, (index) => index)); - _HuffmanTree distanceTree = _blListToTree( + final _HuffmanTree distanceTree = _blListToTree( bl.sublist(hlit), List.generate(30, (index) => index)); return Tuple(literalLengthTree, distanceTree); } @@ -205,7 +206,7 @@ class _HuffmanTree { // Insert an entry into the tree mapping `codeword` of len `n` to `symbol` _Node node = root; for (int i = n - 1; i >= 0; i--) { - int b = codeword & (1 << i); + final int b = codeword & (1 << i); _Node? nextNode; if (b != 0) { nextNode = node.right; @@ -387,7 +388,7 @@ class _BitReader { /// Method to read a byte int readByte() { _numbits = 0; - int byte = _data[_pos]; + final int byte = _data[_pos]; _pos++; return byte; } @@ -399,7 +400,7 @@ class _BitReader { _numbits = 8; } _numbits--; - int bit = _byte & 1; + final int bit = _byte & 1; _byte >>= 1; return bit; } diff --git a/lib/solidity/abi/eip712/eip712.dart b/lib/solidity/abi/eip712/eip712.dart index 51157ab..d19cd9c 100644 --- a/lib/solidity/abi/eip712/eip712.dart +++ b/lib/solidity/abi/eip712/eip712.dart @@ -118,7 +118,7 @@ class Eip712TypedData implements EIP712Base { for (final i in jsonTypes.entries) { final List values = i.value; - List eip712Types = + final List eip712Types = values.map((e) => Eip712TypeDetails.fromJson(e)).toList(); types[i.key] = eip712Types; } diff --git a/lib/solidity/abi/eip712/utils.dart b/lib/solidity/abi/eip712/utils.dart index 37a2ed1..e34b324 100644 --- a/lib/solidity/abi/eip712/utils.dart +++ b/lib/solidity/abi/eip712/utils.dart @@ -141,10 +141,10 @@ class _EIP712Utils { /// The struct is defined in the Eip712TypedData, and the data parameter contains field values. static List encodeStruct( Eip712TypedData typedData, String type, Map data) { - List types = [bytes32TypeName]; - List inputBytes = [getMethodSigature(typedData, type)]; + final List types = [bytes32TypeName]; + final List inputBytes = [getMethodSigature(typedData, type)]; - for (Eip712TypeDetails field in typedData.types[type]!) { + for (final field in typedData.types[type]!) { if (data[field.name] == null) { if (typedData.version == EIP712Version.v3) continue; throw SolidityAbiException( @@ -152,7 +152,7 @@ class _EIP712Utils { details: {'data': data, 'field': field}); } - dynamic value = data[field.name]; + final value = data[field.name]; final encodedValue = encodeValue(typedData, field.type, value); types.add(encodedValue.item1); inputBytes.add(encodedValue.item2); @@ -165,8 +165,8 @@ class _EIP712Utils { /// Recursively collects dependencies for the specified type and its subtypes. static List getDependencies(Eip712TypedData typedData, String type, [List dependencies = const []]) { - RegExpMatch? match = typeRegex.firstMatch(type); - String actualType = match != null ? match.group(0)! : type; + final RegExpMatch? match = typeRegex.firstMatch(type); + final String actualType = match != null ? match.group(0)! : type; if (dependencies.contains(actualType)) { return dependencies; @@ -192,10 +192,10 @@ class _EIP712Utils { /// The type name is expected to follow the pattern `typeName[length]` where `length` is an optional integer. /// Returns a Tuple containing the array type and its length, or null if the type name does not match the pattern. static Tuple? extractArrayType(String typeName) { - RegExpMatch? match = arrayRegex.firstMatch(typeName); + final RegExpMatch? match = arrayRegex.firstMatch(typeName); if (match == null) return null; - String arrayType = match.group(1)!; - int length = int.parse(match.group(2) ?? '0'); + final String arrayType = match.group(1)!; + final int length = int.parse(match.group(2) ?? '0'); return Tuple(arrayType, length); } @@ -221,8 +221,9 @@ class _EIP712Utils { final encodedData = data .map((item) => encodeValue(typedData, isArray.item1, item)) .toList(); - List types = encodedData.map((item) => item.item1).toList(); - List values = encodedData.map((item) => item.item2).toList(); + final List types = encodedData.map((item) => item.item1).toList(); + final List values = + encodedData.map((item) => item.item2).toList(); return Tuple(bytes32TypeName, QuickCrypto.keccack256Hash(_EIP712Utils.abiEncode(types, values))); } @@ -271,7 +272,8 @@ class _EIP712Utils { /// Generates the method signature hash for a given EIP-712 typed data and type. /// The method signature includes all dependencies and their corresponding types and names. static List getMethodSigature(Eip712TypedData typedData, String type) { - List dependencies = List.from(getDependencies(typedData, type)); + final List dependencies = + List.from(getDependencies(typedData, type)); dependencies.sort(); final encode = dependencies .map( diff --git a/lib/solidity/abi/types/array.dart b/lib/solidity/abi/types/array.dart index 91b738e..6cf9de1 100644 --- a/lib/solidity/abi/types/array.dart +++ b/lib/solidity/abi/types/array.dart @@ -11,7 +11,7 @@ class ArrayCoder implements ABICoder> { final encodedParams = input.map((e) => param.item1.abiEncode(e)).toList(); final dynamicItems = encodedParams.isNotEmpty && encodedParams.first.isDynamic; - bool isDynamic = param.item2 == -1; + final isDynamic = param.item2 == -1; if (!isDynamic && input.length != param.item2) { throw const SolidityAbiException("Invalid argument length detected."); } @@ -42,7 +42,7 @@ class ArrayCoder implements ABICoder> { int consumed = 0; int size = extract.item2; List remainingBytes = List.from(bytes); - List result = []; + final List result = []; if (size.isNegative) { final length = const NumbersCoder().decode(AbiParameter.uint32, bytes); size = length.result.toInt(); diff --git a/lib/solidity/abi/types/tuple.dart b/lib/solidity/abi/types/tuple.dart index 29a7784..5669565 100644 --- a/lib/solidity/abi/types/tuple.dart +++ b/lib/solidity/abi/types/tuple.dart @@ -9,13 +9,13 @@ class TupleCoder implements ABICoder> { @override EncoderResult abiEncode(AbiParameter params, List input) { bool isDynamic = false; - List encoded = []; + final List encoded = []; if (input.length != params.components.length) { throw const SolidityAbiException("Invalid argument length detected."); } for (int i = 0; i < params.components.length; i++) { final paramComponent = params.components[i]; - EncoderResult result = paramComponent.abiEncode(input[i]); + final EncoderResult result = paramComponent.abiEncode(input[i]); if (result.isDynamic) { isDynamic = true; } @@ -29,7 +29,9 @@ class TupleCoder implements ABICoder> { } final re = encoded.map((e) => e.encoded).toList(); return EncoderResult( - isDynamic: false, encoded: [for (var i in re) ...i], name: params.name); + isDynamic: false, + encoded: [for (final i in re) ...i], + name: params.name); } /// Decodes a tuple of dynamic values from the given ABI-encoded bytes. @@ -41,13 +43,13 @@ class TupleCoder implements ABICoder> { return DecoderResult(result: [], consumed: consumed, name: params.name); } int dynamicConsumed = 0; - List result = []; + final List result = []; for (int index = 0; index < params.components.length; index++) { - AbiParameter childParam = params.components[index]; + final AbiParameter childParam = params.components[index]; DecoderResult decodedResult; if (childParam.isDynamic) { - DecoderResult offsetResult = const NumbersCoder() + final DecoderResult offsetResult = const NumbersCoder() .decode(AbiParameter.uint32, bytes.sublist(consumed)); decodedResult = _ABIUtils.decodeParamFromAbiParameter( @@ -76,18 +78,20 @@ class TupleCoder implements ABICoder> { @override EncoderResult legacyEip712Encode( AbiParameter params, List input, bool keepSize) { - List encoded = []; + final List encoded = []; if (input.length != params.components.length) { throw const SolidityAbiException("Invalid argument length detected."); } for (int i = 0; i < params.components.length; i++) { final paramComponent = params.components[i]; - EncoderResult result = + final EncoderResult result = paramComponent.legacyEip712Encode(input[i], keepSize); encoded.add(result); } final re = encoded.map((e) => e.encoded).toList(); return EncoderResult( - isDynamic: false, encoded: [for (var i in re) ...i], name: params.name); + isDynamic: false, + encoded: [for (final i in re) ...i], + name: params.name); } } diff --git a/lib/solidity/abi/utils/utils.dart b/lib/solidity/abi/utils/utils.dart index ee0b30f..d8f3d23 100644 --- a/lib/solidity/abi/utils/utils.dart +++ b/lib/solidity/abi/utils/utils.dart @@ -35,17 +35,17 @@ class _ABIUtils { static List encodeDynamicParams(List encodedParams) { int staticSize = 0; int dynamicSize = 0; - List staticParams = []; - List dynamicParams = []; + final List staticParams = []; + final List dynamicParams = []; - for (EncoderResult encodedParam in encodedParams) { + for (final encodedParam in encodedParams) { if (encodedParam.isDynamic) { staticSize += ABIConst.uintBytesLength; } else { staticSize += encodedParam.encoded.length; } } - for (EncoderResult encodedParam in encodedParams) { + for (final encodedParam in encodedParams) { if (encodedParam.isDynamic) { staticParams.add(const NumbersCoder().abiEncode( AbiParameter.uint256, BigInt.from(staticSize + dynamicSize))); @@ -64,10 +64,10 @@ class _ABIUtils { /// Extracts the array type and size information from the given ABI parameter. static Tuple toArrayType(AbiParameter abi) { - int arrayParenthesisStart = abi.type.lastIndexOf('['); - String arrayParamType = abi.type.substring(0, arrayParenthesisStart); - String sizeString = abi.type.substring(arrayParenthesisStart); - int size = -1; + final int arrayParenthesisStart = abi.type.lastIndexOf('['); + final String arrayParamType = abi.type.substring(0, arrayParenthesisStart); + final String sizeString = abi.type.substring(arrayParenthesisStart); + const int size = -1; if (sizeString != '[]') { final parseSize = int.tryParse(sizeString.substring(1, sizeString.length - 1)); @@ -173,7 +173,7 @@ class _ABIValidator { } else if (type.startsWith("uint")) { final spl = type.split("uint"); bitLength = int.parse(spl[1]); - sign = true; + sign = false; } else { throw SolidityAbiException( "Invalid type name provided for number codec.", diff --git a/lib/solidity/address/core.dart b/lib/solidity/address/core.dart index d15c4ec..0db0679 100644 --- a/lib/solidity/address/core.dart +++ b/lib/solidity/address/core.dart @@ -1,5 +1,4 @@ import 'package:blockchain_utils/bip/address/eth_addr.dart'; -import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart'; import 'package:blockchain_utils/blockchain_utils.dart'; /// An abstract class representing a hexadecimal address in solidity smart conteract system. diff --git a/lib/solidity/contract/fragments.dart b/lib/solidity/contract/fragments.dart index 43ef30f..a995631 100644 --- a/lib/solidity/contract/fragments.dart +++ b/lib/solidity/contract/fragments.dart @@ -346,7 +346,7 @@ class AbiErrorFragment implements AbiBaseFragment { /// Decodes the error parameters from the encoded bytes. List decodeError(List encodedParams) { - List encodeBytes = + final List encodeBytes = List.from(encodedParams.sublist(ABIConst.selectorLength)); final abi = AbiParameter(name: "", type: "tuple", components: List.from(inputs)) diff --git a/lib/tron/src/protbuf/decoder.dart b/lib/tron/src/protbuf/decoder.dart index 03e0291..24f9bce 100644 --- a/lib/tron/src/protbuf/decoder.dart +++ b/lib/tron/src/protbuf/decoder.dart @@ -43,7 +43,7 @@ class ProtocolBufferDecoder { int shift = 0; int index = 0; while (true) { - int byte = data[index++]; + final int byte = data[index++]; value |= (byte & 0x7F) << shift; if ((byte & 0x80) == 0) { break; @@ -58,7 +58,7 @@ class ProtocolBufferDecoder { int shift = 0; int index = 0; while (true) { - int byte = data[index++]; + final int byte = data[index++]; value |= BigInt.from((byte & 0x7F)) << shift; if ((byte & 0x80) == 0) { break; diff --git a/lib/tron/src/protbuf/encoder.dart b/lib/tron/src/protbuf/encoder.dart index 7da3a29..5f2f431 100644 --- a/lib/tron/src/protbuf/encoder.dart +++ b/lib/tron/src/protbuf/encoder.dart @@ -59,7 +59,7 @@ class ProtocolBufferEncoder { /// Encode a [Map] with the given [fieldNumber] and [value]. static List _encodeMap(int fieldNumber, Map value) { - List result = []; + final List result = []; for (final i in value.entries) { final key = encode(1, i.key); final val = encode(2, i.value); @@ -73,8 +73,8 @@ class ProtocolBufferEncoder { /// Encode length of the data for the given [fieldNumber] and [value]. static List _encodeLength(int fieldNumber, int value) { _validateInt(value); - List result = []; - int tag = (fieldNumber << 3) | 2; + final List result = []; + final int tag = (fieldNumber << 3) | 2; result.addAll(_encodeVarint32(tag)); result.addAll(_encodeVarint32(value)); @@ -84,7 +84,7 @@ class ProtocolBufferEncoder { /// Encode a list with the given [fieldNumber] and [value]. static List _encodeList(int fieldNumber, List value) { if (value.isEmpty) return []; - List result = []; + final List result = []; for (final i in value) { result.addAll(encode(fieldNumber, i)); } @@ -94,10 +94,10 @@ class ProtocolBufferEncoder { /// Encode a [BigInt] with the given [fieldNumber] and [value]. static List _encodeBigInt(int fieldNumber, BigInt value) { _validateBigInt(value); - List result = []; + final List result = []; // Combine field number and wire type (0 for varint) - int tag = (fieldNumber << 3) | 0; + final int tag = (fieldNumber << 3) | 0; BigInt mybeZigZag = value; if (value.isNegative) { mybeZigZag = ((value & _maxInt64) | _minInt64); @@ -111,7 +111,7 @@ class ProtocolBufferEncoder { /// Utility function to encode a 64-bit varint. static List _encodeVarintBigInt(BigInt value) { - List result = []; + final List result = []; while (value > BigInt.from(0x7F)) { result.add((value & BigInt.from(0x7F) | BigInt.from(0x80)).toInt()); value >>= 7; @@ -122,7 +122,7 @@ class ProtocolBufferEncoder { /// Encode a 32-bit varint with the given [value]. static List _encodeVarint32(int value) { - List result = []; + final List result = []; while (value > 0x7F) { result.add((value & 0x7F) | 0x80); value >>= 7; @@ -134,8 +134,8 @@ class ProtocolBufferEncoder { /// Encode an [int] with the given [fieldNumber] static List _encodeInt(int fieldNumber, int value) { _validateInt(value); - List result = []; - int tag = (fieldNumber << 3) | 0; + final List result = []; + final int tag = (fieldNumber << 3) | 0; result.addAll(_encodeVarint32(tag)); if (value.isNegative) { final BigInt zigzag = ((BigInt.from(value) & _maxInt64) | _minInt64); @@ -149,7 +149,7 @@ class ProtocolBufferEncoder { /// Encode a byte array with the given [fieldNumber] and [value]. static List _encodeBytes(int fieldNumber, List value) { - List result = []; + final List result = []; result.addAll(_encodeLength(fieldNumber, value.length)); result.addAll(value); diff --git a/lib/tron/src/utils/tron_helper.dart b/lib/tron/src/utils/tron_helper.dart index a9b7b5f..b7630cf 100644 --- a/lib/tron/src/utils/tron_helper.dart +++ b/lib/tron/src/utils/tron_helper.dart @@ -21,7 +21,7 @@ class TronHelper { /// Decodes permission operations from a hex representation. static List decodePermissionOperation( final String operations) { - List accountPermissions = []; + final List accountPermissions = []; final operationBytes = BytesUtils.fromHexString(operations); for (int i = 0; i < 32; i++) { for (int j = 0; j < 8; j++) { @@ -43,7 +43,7 @@ class TronHelper { List values) { final valuesInt = values.map((e) => e.value).toList(); final List operationBuffer = List.filled(32, 0); - for (int value in valuesInt) { + for (final int value in valuesInt) { operationBuffer[value ~/ 8] |= (1 << (value % 8)); } return List.from(operationBuffer); diff --git a/pubspec.yaml b/pubspec.yaml index 1247fbc..176de6f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: on_chain description: Streamline Ethereum, Tron, Solana and Cardano operations. Effortlessly create transactions, interact with smart contracts, sign, and send transactions. -version: 4.4.0 +version: 4.5.0 homepage: "https://github.com/mrtnetwork/on_chain" repository: "https://github.com/mrtnetwork/on_chain" Author: mrhaydari.t@gmail.com @@ -17,7 +17,7 @@ environment: dependencies: - blockchain_utils: ^3.5.0 + blockchain_utils: ^3.6.0 # blockchain_utils: # path: ../blockchain_utils diff --git a/test/abi/eip712/v4_test.dart b/test/abi/eip712/v4_test.dart index 6c29661..26a18a2 100644 --- a/test/abi/eip712/v4_test.dart +++ b/test/abi/eip712/v4_test.dart @@ -106,7 +106,7 @@ void main() { expect(test1.encodeHex(), "184dd59e6ca7b7b98ad9b5e02c0e38ab6951bdd854a16d2cf7aaaf6a5ad485d3"); - EIP712Base json = EIP712Base.fromJson(test1.toJson()); + final EIP712Base json = EIP712Base.fromJson(test1.toJson()); expect(json.encodeHex(), "184dd59e6ca7b7b98ad9b5e02c0e38ab6951bdd854a16d2cf7aaaf6a5ad485d3"); }); diff --git a/test/ada/auxiliary_data_serialization_test.dart b/test/ada/auxiliary_data_serialization_test.dart index 9a1d716..3009a04 100644 --- a/test/ada/auxiliary_data_serialization_test.dart +++ b/test/ada/auxiliary_data_serialization_test.dart @@ -77,7 +77,7 @@ void _serialization() { final au = AuxiliaryData.fromCborBytes( BytesUtils.fromHexString("a1182aa163717765187b")); expect(au.serializeHex(), "a1182aa163717765187b"); - AuxiliaryData fromJson = AuxiliaryData.fromJson(au.toJson()); + final AuxiliaryData fromJson = AuxiliaryData.fromJson(au.toJson()); expect(fromJson.serializeHex(), "a1182aa163717765187b"); }); } diff --git a/test/solana/tests/name_service/compile_legacy_test.dart b/test/solana/tests/name_service/compile_legacy_test.dart index 4d357a7..bafff8d 100644 --- a/test/solana/tests/name_service/compile_legacy_test.dart +++ b/test/solana/tests/name_service/compile_legacy_test.dart @@ -18,7 +18,7 @@ void _create() { final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.create( layout: NameServiceCreateLayout( @@ -56,7 +56,7 @@ void _update() { test("update", () { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.update( layout: NameServiceUpdateLayout( @@ -90,7 +90,7 @@ void _transfer() { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.transfer( layout: NameServiceTransferLayout(newOwnerKey: account1.address), nameAccountKey: account1.address, @@ -124,7 +124,7 @@ void _delete() { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.delete( nameOwnerKey: owner.address, nameAccountKey: account1.address, @@ -155,7 +155,7 @@ void _realloc() { test("realloc", () { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.realloc( nameOwnerKey: owner.address, nameAccountKey: account1.address, diff --git a/test/solana/tests/name_service/compile_v0_test.dart b/test/solana/tests/name_service/compile_v0_test.dart index d58b830..390ff61 100644 --- a/test/solana/tests/name_service/compile_v0_test.dart +++ b/test/solana/tests/name_service/compile_v0_test.dart @@ -18,7 +18,7 @@ void _create() { final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.create( layout: NameServiceCreateLayout( @@ -56,7 +56,7 @@ void _update() { test("update", () { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.update( layout: NameServiceUpdateLayout( @@ -90,7 +90,7 @@ void _transfer() { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.transfer( layout: NameServiceTransferLayout(newOwnerKey: account1.address), nameAccountKey: account1.address, @@ -124,7 +124,7 @@ void _delete() { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.delete( nameOwnerKey: owner.address, nameAccountKey: account1.address, @@ -152,7 +152,7 @@ void _realloc() { test("realloc", () { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = NameServiceProgram.realloc( nameOwnerKey: owner.address, nameAccountKey: account1.address, diff --git a/test/solana/tests/stake/compile_legacy_test.dart b/test/solana/tests/stake/compile_legacy_test.dart index 4ec2d88..8c738ad 100644 --- a/test/solana/tests/stake/compile_legacy_test.dart +++ b/test/solana/tests/stake/compile_legacy_test.dart @@ -21,7 +21,7 @@ void _initialize() { final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final program = SystemProgram.createAccount( from: owner.address, newAccountPubKey: account5.address, @@ -59,7 +59,7 @@ void _delegate() { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.delegate( authorizedPubkey: owner.address, @@ -93,7 +93,7 @@ void _authorize() { final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.authorize( authorizedPubkey: owner.address, custodianPubkey: account1.address, @@ -127,7 +127,7 @@ void _authorizeWithSeed() { final account3 = QuickWalletForTest(index: 407); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.authorizeWithSeed( authorityBase: owner.address, custodianPubkey: account1.address, @@ -162,7 +162,7 @@ void _split() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final createAccount = SystemProgram.createAccount( from: owner.address, @@ -202,7 +202,7 @@ void _merge() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.merge( authorizedPubkey: owner.address, @@ -234,7 +234,7 @@ void _withdraw() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.withdraw( authorizedPubkey: owner.address, toPubkey: account6.address, @@ -264,7 +264,7 @@ void _deactivate() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.deactivate( authorizedPubkey: owner.address, stakePubkey: account5.address); diff --git a/test/solana/tests/stake/compile_v0_test.dart b/test/solana/tests/stake/compile_v0_test.dart index 5068d0e..8acdfd6 100644 --- a/test/solana/tests/stake/compile_v0_test.dart +++ b/test/solana/tests/stake/compile_v0_test.dart @@ -21,7 +21,7 @@ void _initialize() { final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final program = SystemProgram.createAccount( from: owner.address, newAccountPubKey: account5.address, @@ -59,7 +59,7 @@ void _delegate() { final owner = QuickWalletForTest(index: 406); final account1 = QuickWalletForTest(index: 405); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.delegate( authorizedPubkey: owner.address, @@ -93,7 +93,7 @@ void _authorize() { final account1 = QuickWalletForTest(index: 405); final account3 = QuickWalletForTest(index: 407); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.authorize( authorizedPubkey: owner.address, custodianPubkey: account1.address, @@ -127,7 +127,7 @@ void _authorizeWithSeed() { final account3 = QuickWalletForTest(index: 407); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.authorizeWithSeed( authorityBase: owner.address, custodianPubkey: account1.address, @@ -162,7 +162,7 @@ void _split() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final createAccount = SystemProgram.createAccount( from: owner.address, @@ -202,7 +202,7 @@ void _merge() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.merge( authorizedPubkey: owner.address, @@ -234,7 +234,7 @@ void _withdraw() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); final account6 = QuickWalletForTest(index: 410); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.withdraw( authorizedPubkey: owner.address, toPubkey: account6.address, @@ -264,7 +264,7 @@ void _deactivate() { final owner = QuickWalletForTest(index: 406); final account5 = QuickWalletForTest(index: 408); - String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; + const String blockHash = "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"; final initialize = StakeProgram.deactivate( authorizedPubkey: owner.address, stakePubkey: account5.address); diff --git a/test/solana/tests/system/compiled_message_legacy_test.dart b/test/solana/tests/system/compiled_message_legacy_test.dart index 3d85234..5e69681 100644 --- a/test/solana/tests/system/compiled_message_legacy_test.dart +++ b/test/solana/tests/system/compiled_message_legacy_test.dart @@ -33,7 +33,7 @@ void _systemCreateAccount() { programId: SystemProgramConst.programId, space: BigInt.from(200))); - SolanaTransaction transaction = SolanaTransaction( + final SolanaTransaction transaction = SolanaTransaction( instructions: [create], recentBlockhash: SolAddress.uncheckCurve( "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"), diff --git a/test/solana/tests/system/compiled_message_v0_test.dart b/test/solana/tests/system/compiled_message_v0_test.dart index f890bdf..33389ef 100644 --- a/test/solana/tests/system/compiled_message_v0_test.dart +++ b/test/solana/tests/system/compiled_message_v0_test.dart @@ -33,7 +33,7 @@ void _systemCreateAccount() { programId: SystemProgramConst.programId, space: BigInt.from(200))); - SolanaTransaction transaction = SolanaTransaction( + final SolanaTransaction transaction = SolanaTransaction( instructions: [create], recentBlockhash: SolAddress.uncheckCurve( "GWWy2aAev5X3TMRVwdw8W2KMN3dyVrHrQMZukGTf9R1A"), diff --git a/test/solana/tests/zlib/bit_reader.dart b/test/solana/tests/zlib/bit_reader.dart index 1675edd..3dc47f5 100644 --- a/test/solana/tests/zlib/bit_reader.dart +++ b/test/solana/tests/zlib/bit_reader.dart @@ -7,7 +7,7 @@ class BitReader { int readByte() { _numbits = 0; - int byte = _data[_pos]; + final int byte = _data[_pos]; _pos++; return byte; } @@ -18,7 +18,7 @@ class BitReader { _numbits = 8; } _numbits--; - int bit = _byte & 1; + final int bit = _byte & 1; _byte >>= 1; return bit; } diff --git a/test/solana/tests/zlib/decompress.dart b/test/solana/tests/zlib/decompress.dart index e2c1a40..32924af 100644 --- a/test/solana/tests/zlib/decompress.dart +++ b/test/solana/tests/zlib/decompress.dart @@ -5,32 +5,32 @@ import 'constant.dart'; class ZlibDecoder { static List decompress(List input) { - BitReader bitReader = BitReader(input); + final BitReader bitReader = BitReader(input); final int cmf = bitReader.readByte(); - int cm = cmf & 15; + final int cm = cmf & 15; if (cm != 8) { throw const MessageException('invalid CM'); } - int cinfo = (cmf >> 4) & 15; // Compression info + final int cinfo = (cmf >> 4) & 15; // Compression info if (cinfo > 7) { throw const MessageException('invalid CINFO'); } - int flg = bitReader.readByte(); + final int flg = bitReader.readByte(); if ((cmf * 256 + flg) % 31 != 0) { throw const MessageException('CMF+FLG checksum failed'); } - int fdict = (flg >> 5) & 1; + final int fdict = (flg >> 5) & 1; if (fdict != 0) { throw const MessageException('preset dictionary not supported'); } - List out = _inflate(bitReader); // decompress DEFLATE data + final List out = _inflate(bitReader); // decompress DEFLATE data bitReader.readBytes(4); return out; } static void _noCompressionBlock(BitReader bitReader, List out) { - int len = bitReader.readBytes(2); + final int len = bitReader.readBytes(2); bitReader.readBytes(2); for (int i = 0; i < len; i++) { out.add(bitReader.readByte()); @@ -40,7 +40,7 @@ class ZlibDecoder { static String _decodeSymbol(BitReader bitReader, _HuffmanTree tree) { _Node node = tree.root; while (node.left != null || node.right != null) { - int b = bitReader.readBit(); + final int b = bitReader.readBit(); node = (b != 0) ? node.right! : node.left!; } return node.symbol; @@ -49,7 +49,7 @@ class ZlibDecoder { static void _inflateBlock(BitReader bitReader, _HuffmanTree lengthTree, _HuffmanTree distanceTree, List out) { while (true) { - String sym = _decodeSymbol(bitReader, lengthTree); + final String sym = _decodeSymbol(bitReader, lengthTree); int symbol = int.parse(sym); if (symbol <= 255) { out.add(symbol); @@ -57,10 +57,11 @@ class ZlibDecoder { return; } else { symbol -= 257; - int length = bitReader.readBits(ZlibConst.lengthExtraBits[symbol]) + - ZlibConst.lengthBase[symbol]; - String distSym = _decodeSymbol(bitReader, distanceTree); - int dist = bitReader + final int length = + bitReader.readBits(ZlibConst.lengthExtraBits[symbol]) + + ZlibConst.lengthBase[symbol]; + final String distSym = _decodeSymbol(bitReader, distanceTree); + final int dist = bitReader .readBits(ZlibConst.distanceExtraBits[int.parse(distSym)]) + ZlibConst.distanceBase[int.parse(distSym)]; for (int i = 0; i < length; i++) { @@ -72,10 +73,10 @@ class ZlibDecoder { static List _inflate(BitReader bitReader) { int bitFinal = 0; - List out = []; + final List out = []; while (bitFinal != 1) { bitFinal = bitReader.readBit(); - int type = bitReader.readBits(2); + final int type = bitReader.readBits(2); if (type == 0) { _noCompressionBlock(bitReader, out); } else if (type == 1) { @@ -101,11 +102,11 @@ class ZlibDecoder { ...List.filled(24, 7), ...List.filled(8, 8) ]; - _HuffmanTree literalLengthTree = + final _HuffmanTree literalLengthTree = _blListToTree(bl, List.generate(286, (index) => index)); bl = List.filled(32, 5); - _HuffmanTree distanceTree = + final _HuffmanTree distanceTree = _blListToTree(bl, List.generate(30, (index) => index)); _inflateBlock(bitReader, literalLengthTree, distanceTree, out); @@ -113,25 +114,25 @@ class ZlibDecoder { /// cc static _HuffmanTree _blListToTree(List bl, List alphabet) { - int maxBits = + final int maxBits = bl.reduce((value, element) => value > element ? value : element); - List blCount = List.filled(maxBits + 1, 0); - for (var bitlen in bl) { + final List blCount = List.filled(maxBits + 1, 0); + for (final bitlen in bl) { if (bitlen != 0) { blCount[bitlen]++; } } - List nextCode = [0, 0]; + final List nextCode = [0, 0]; for (int bits = 2; bits <= maxBits; bits++) { nextCode.add((nextCode[bits - 1] + blCount[bits - 1]) << 1); } - _HuffmanTree t = _HuffmanTree(); - int min = alphabet.length < bl.length ? alphabet.length : bl.length; + final _HuffmanTree t = _HuffmanTree(); + final int min = alphabet.length < bl.length ? alphabet.length : bl.length; for (int i = 0; i < min; i++) { - int c = alphabet[i]; - int bitlen = bl[i]; + final int c = alphabet[i]; + final int bitlen = bl[i]; if (bitlen != 0) { t.insert(nextCode[bitlen], bitlen, c.toString()); nextCode[bitlen]++; @@ -141,34 +142,34 @@ class ZlibDecoder { } static Tuple<_HuffmanTree, _HuffmanTree> _decodeTrees(BitReader r) { - int hlit = r.readBits(5) + 257; - int hdist = r.readBits(5) + 1; - int hclen = r.readBits(4) + 4; - List codeLengthTreeBl = List.filled(19, 0); + final int hlit = r.readBits(5) + 257; + final int hdist = r.readBits(5) + 1; + final int hclen = r.readBits(4) + 4; + final List codeLengthTreeBl = List.filled(19, 0); for (int i = 0; i < hclen; i++) { codeLengthTreeBl[ZlibConst.codeLengthCodesOrder[i]] = r.readBits(3); } - _HuffmanTree codeLengthTree = _blListToTree( + final _HuffmanTree codeLengthTree = _blListToTree( codeLengthTreeBl, List.generate(19, (index) => index)); - List bl = []; + final List bl = []; while (bl.length < hlit + hdist) { - String sym = _decodeSymbol(r, codeLengthTree); - int symbol = int.parse(sym); + final String sym = _decodeSymbol(r, codeLengthTree); + final int symbol = int.parse(sym); if (symbol >= 0 && symbol <= 15) { bl.add(symbol); } else if (symbol == 16) { - int prevCodeLength = bl[bl.length - 1]; - int repeatLength = r.readBits(2) + 3; + final int prevCodeLength = bl[bl.length - 1]; + final int repeatLength = r.readBits(2) + 3; for (int i = 0; i < repeatLength; i++) { bl.add(prevCodeLength); } } else if (symbol == 17) { - int repeatLength = r.readBits(3) + 3; + final int repeatLength = r.readBits(3) + 3; for (int i = 0; i < repeatLength; i++) { bl.add(0); } } else if (symbol == 18) { - int repeatLength = r.readBits(7) + 11; + final int repeatLength = r.readBits(7) + 11; for (int i = 0; i < repeatLength; i++) { bl.add(0); } @@ -176,9 +177,9 @@ class ZlibDecoder { throw const MessageException('invalid symbol'); } } - _HuffmanTree literalLengthTree = _blListToTree( + final _HuffmanTree literalLengthTree = _blListToTree( bl.sublist(0, hlit), List.generate(286, (index) => index)); - _HuffmanTree distanceTree = _blListToTree( + final _HuffmanTree distanceTree = _blListToTree( bl.sublist(hlit), List.generate(30, (index) => index)); return Tuple(literalLengthTree, distanceTree); } @@ -205,7 +206,7 @@ class _HuffmanTree { // Insert an entry into the tree mapping `codeword` of len `n` to `symbol` _Node node = root; for (int i = n - 1; i >= 0; i--) { - int b = codeword & (1 << i); + final int b = codeword & (1 << i); _Node? nextNode; if (b != 0) { nextNode = node.right;