Skip to content

Commit

Permalink
V4.5.0
Browse files Browse the repository at this point in the history
- Update dependencies.
- Important Notice: This is the final version supporting Dart v2. The next release will require Dart v3.3 or higher.
  • Loading branch information
mrtnetwork committed Dec 4, 2024
1 parent 6889eac commit 5d7adfc
Show file tree
Hide file tree
Showing 65 changed files with 321 additions and 319 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
31 changes: 7 additions & 24 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -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
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
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ada/src/address/era/shelly/core/shelly_address.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class ADAShellyAddress extends ADAAddress {

/// Deserializes a CBOR object into an ADAShellyAddress instance.
static T deserialize<T extends ADAShellyAddress>(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",
Expand Down
2 changes: 1 addition & 1 deletion lib/ada/src/models/metadata/utils/metadata_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class TransactionMetadataUtils {

static TransactionMetadata _encodeMap(
Map value, MetadataJsonSchema jsonSchema) {
Map<TransactionMetadata, TransactionMetadata> values = {};
final Map<TransactionMetadata, TransactionMetadata> values = {};
for (final i in value.entries) {
TransactionMetadata? key;
if (jsonSchema == MetadataJsonSchema.basicConversions &&
Expand Down
2 changes: 1 addition & 1 deletion lib/ada/src/models/plutus/plutus/types/bytes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PlutusBytes extends PlutusData {
@override
CborObject toCbor() {
if (value.length > PlutusDataUtils.chunkSize) {
List<List<int>> chunks = [];
final List<List<int>> chunks = [];
for (var i = 0; i < value.length; i += PlutusDataUtils.chunkSize) {
chunks.add(value.sublist(
i,
Expand Down
4 changes: 2 additions & 2 deletions lib/ada/src/models/plutus/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ class PlutusDataUtils {
}

static PlutusData _encodeMap(Map value, PlutusJsonSchema jsonSchema) {
Map<PlutusData, PlutusData> values = {};
final Map<PlutusData, PlutusData> 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)});
}
Expand Down
16 changes: 8 additions & 8 deletions lib/ada/src/models/transaction/output/models/multi_assets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ class MultiAsset with ADASerialization implements Comparable<MultiAsset> {
}

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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class ADAAccountSummaryResponse {
});

factory ADAAccountSummaryResponse.fromJson(Map<String, dynamic> json) {
var receivedSumList = json['received_sum'] as List;
List<ADAAmountResponse> receivedSum = receivedSumList
final receivedSumList = json['received_sum'] as List;
final List<ADAAmountResponse> receivedSum = receivedSumList
.map((item) => ADAAmountResponse.fromJson(item))
.toList();

var sentSumList = json['sent_sum'] as List;
List<ADAAmountResponse> sentSum =
final sentSumList = json['sent_sum'] as List;
final List<ADAAmountResponse> sentSum =
sentSumList.map((item) => ADAAmountResponse.fromJson(item)).toList();

return ADAAccountSummaryResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ADAAddressSummaryResponse {
});

factory ADAAddressSummaryResponse.fromJson(Map<String, dynamic> json) {
var amountList = json['amount'] as List;
List<ADAAmountResponse> amounts =
final amountList = json['amount'] as List;
final List<ADAAmountResponse> amounts =
amountList.map((item) => ADAAmountResponse.fromJson(item)).toList();

return ADAAddressSummaryResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class ADABlockAddressTransactionsResponse {

factory ADABlockAddressTransactionsResponse.fromJson(
Map<String, dynamic> json) {
var transactionsList = json['transactions'] as List;
List<String> transactions =
final transactionsList = json['transactions'] as List;
final List<String> transactions =
transactionsList.map((item) => item['tx_hash'] as String).toList();

return ADABlockAddressTransactionsResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class BlockforestProviderUtils {
static final RegExp _pathParamRegex = RegExp(r':\w+');
static List<String> extractParams(String url) {
Iterable<Match> matches = _pathParamRegex.allMatches(url);
List<String> params = [];
for (Match match in matches) {
final Iterable<Match> matches = _pathParamRegex.allMatches(url);
final List<String> params = [];
for (final Match match in matches) {
params.add(match.group(0)!);
}
return List<String>.unmodifiable(params);
Expand Down
16 changes: 10 additions & 6 deletions lib/ethereum/src/models/fee_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,26 @@ class FeeHistory {
FeeHistorical toFee() {
FeeHistorical toPriority(List<_FeeHistorical> priorities, BigInt baseFee) {
BigInt avg(List<BigInt> 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(
Expand Down
22 changes: 11 additions & 11 deletions lib/ethereum/src/rlp/decode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class RLPDecoder {
/// Decode an RLP-encoded array.
static _Decoded _decodeArray(
List<int> data, int offset, int childOffset, int length) {
List<dynamic> result = [];
final List<dynamic> result = [];

while (childOffset < offset + 1 + length) {
_Decoded decoded = _decode(data, childOffset);
final _Decoded decoded = _decode(data, childOffset);

result.add(decoded.result);

Expand All @@ -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<int> result = data.sublist(
final int lengthLength = data[offset] - 0xb7;
final int length = _decodeLength(data, offset + 1, lengthLength);
final List<int> 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<int> result = data.sublist(offset + 1, offset + 1 + length);
final int length = data[offset] - 0x80;
final List<int> result = data.sublist(offset + 1, offset + 1 + length);
return _Decoded(consumed: (1 + length), result: result);
}

Expand All @@ -63,7 +63,7 @@ class RLPDecoder {
/// Decode an RLP-encoded list of items.
static List<dynamic> decode(List<int> 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");
}
Expand Down
10 changes: 5 additions & 5 deletions lib/ethereum/src/rlp/encode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class RLPEncoder {
/// Encodes an integer value into its RLP representation.
static List<int> _encodeArray(int value) {
List<int> result = [];
final List<int> result = [];
while (value != 0) {
result.insert(0, value & 0xff);
value >>= 8;
Expand All @@ -13,7 +13,7 @@ class RLPEncoder {
/// Recursive encoding of the given object using RLP.
static List<int> _encode(List<dynamic> object) {
if (object is! List<int>) {
List<int> payload = [];
final List<int> payload = [];
for (final child in object) {
payload.addAll(_encode(child));
}
Expand All @@ -23,12 +23,12 @@ class RLPEncoder {
return payload;
}

List<int> length = _encodeArray(payload.length);
final List<int> length = _encodeArray(payload.length);
length.insert(0, 0xf7 + length.length);
return [...length, ...payload];
}

List<int> data = List.from(object, growable: true);
final List<int> data = List.from(object, growable: true);

if (data.length == 1 && data[0] <= 0x7f) {
return data;
Expand All @@ -37,7 +37,7 @@ class RLPEncoder {
return data;
}

List<int> length = _encodeArray(data.length);
final List<int> length = _encodeArray(data.length);
length.insert(0, 0xb7 + length.length);

return [...length, ...data];
Expand Down
24 changes: 12 additions & 12 deletions lib/ethereum/src/transaction/eth_transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ class _ETHTransactionUtils {
///
/// Returns an [ETHTransaction] object representing the legacy transaction.
static ETHTransaction _fromLegacy(List<dynamic> 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]);
Expand Down Expand Up @@ -137,9 +137,9 @@ class _ETHTransactionUtils {
/// Converts the decoded data to an EIP-2930 transaction.
static ETHTransaction _fromEIP2930(List<dynamic> 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]);
Expand Down Expand Up @@ -173,10 +173,10 @@ class _ETHTransactionUtils {
/// Converts the decoded data to an EIP-1559 transaction.
static ETHTransaction _fromEIP1559(List<dynamic> 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]);
Expand Down Expand Up @@ -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<int> _toEIP1559([ETHSignature? sig]) {
List<List<dynamic>> fields = [
final List<List<dynamic>> fields = [
_ETHTransactionUtils.bigintToBytes(chainId),
_ETHTransactionUtils.intToBytes(nonce),
_ETHTransactionUtils.bigintToBytes(maxPriorityFeePerGas!),
Expand Down Expand Up @@ -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<int> _toLegacy([ETHSignature? sig]) {
List<List<int>> fields = [
final List<List<int>> fields = [
_ETHTransactionUtils.intToBytes(nonce),
_ETHTransactionUtils.bigintToBytes(gasPrice!),
_ETHTransactionUtils.bigintToBytes(gasLimit),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class LayoutSerializable {

Map<String, dynamic> toJson() {
final json = serialize()..removeWhere((k, v) => v == null);
Map<String, dynamic> toHuman = {};
final Map<String, dynamic> toHuman = {};
for (final i in json.entries) {
toHuman[i.key] = _toString(i.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _Utils {
]);

static List<AuthorityScope> decodeScoops(List<bool> bytes) {
List<AuthorityScope> scopes = [];
final List<AuthorityScope> scopes = [];
for (int i = 0; i < AuthorityScope.values.length; i++) {
if (!bytes[i]) continue;
scopes.add(AuthorityScope.fromValue(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class MetaplexAuctionHouseProgramLayout extends ProgramLayout {
static ProgramLayout fromBytes(List<int> data) {
final decode =
ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data);
MetaplexAuctionHouseProgramInstruction? instruction =
final MetaplexAuctionHouseProgramInstruction? instruction =
MetaplexAuctionHouseProgramInstruction.getInstruction(
decode["instruction"]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class MetaplexAuctioneerProgramLayout extends ProgramLayout {
static ProgramLayout fromBytes(List<int> data) {
final decode =
ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data);
MetaplexAuctioneerProgramInstruction? instruction =
final MetaplexAuctioneerProgramInstruction? instruction =
MetaplexAuctioneerProgramInstruction.getInstruction(
decode["instruction"]);

Expand Down
Loading

0 comments on commit 5d7adfc

Please sign in to comment.