Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.9.0 #4

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dart_tool/extension_discovery/vs_code.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":2,"entries":[{"package":"xrpl_dart","rootUri":"../","packageUri":"lib/"}]}
{"version":2,"entries":[{"package":"blockchain_utils","rootUri":"../../blockchain_utils/","packageUri":"lib/"},{"package":"xrpl_dart","rootUri":"../","packageUri":"lib/"}]}
4 changes: 2 additions & 2 deletions .dart_tool/package_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"name": "blockchain_utils",
"rootUri": "file:///D:/dart/pub_cache/hosted/pub.dev/blockchain_utils-3.5.0",
"rootUri": "file:///D:/dart/pub_cache/hosted/pub.dev/blockchain_utils-3.6.0",
"packageUri": "lib/",
"languageVersion": "2.15"
},
Expand Down Expand Up @@ -302,7 +302,7 @@
"languageVersion": "2.15"
}
],
"generated": "2024-11-25T05:52:56.836008Z",
"generated": "2024-12-04T18:01:45.570438Z",
"generator": "pub",
"generatorVersion": "3.5.4",
"flutterRoot": "file:///C:/env/flutter_windows_3.24.5-stable/flutter",
Expand Down
Binary file added .dart_tool/pub/bin/test/test.dart-3.5.4.snapshot
Binary file not shown.
Binary file modified .dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE1
Binary file not shown.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.9.0
- Fix parsing RPC Error.
- Important Notice: This is the final version supporting Dart v2. The next release will require Dart v3.3 or higher.

## 4.8.0

- Update dependencies.
Expand Down
10 changes: 10 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,13 @@
include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
# Uncomment the following section to specify additional rules.
linter:
rules:
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

# Additional information about this file can be found at
# https://dart.dev/tools/analysis
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ packages:
dependency: "direct main"
description:
name: blockchain_utils
sha256: eebd06ff3709be5c660be72f0b0ee8f524fbb9e20752436f19f07f3be8ee6d1f
sha256: "1e4f30b98d92f7ccf2eda009a23b53871a1c9b8b6dfa00bb1eb17ec00ae5eeeb"
url: "https://pub.dev"
source: hosted
version: "3.5.0"
version: "3.6.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -278,7 +278,7 @@ packages:
path: ".."
relative: true
source: path
version: "4.8.0"
version: "4.9.0"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ dependencies:
http: ^1.1.2
web_socket_channel: ^2.4.0
asn1lib: ^1.5.0
blockchain_utils: ^3.5.0
blockchain_utils: ^3.6.0
# blockchain_utils:
# path: ../../bitcoin/blockchain_utils
# path: ../../blockchain_utils

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/crypto/keypair/xrpl_private_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class XrpSeedUtils {
for (BigInt rawRoot = BigInt.zero;
rawRoot < sqMax;
rawRoot += BigInt.zero) {
List<int> root = List<int>.filled(sqSize, 0);
final List<int> root = List<int>.filled(sqSize, 0);
for (int i = 0; i < sqSize; i++) {
root[i] = ((rawRoot >> (8 * (sqSize - 1 - i))) & bigMask8).toInt();
}
Expand Down Expand Up @@ -263,7 +263,7 @@ class XRPPrivateKey {
/// [privateKey] is the hexadecimal private key to be used for XRP transactions.
factory XRPPrivateKey.fromHex(String privateKey,
{XRPKeyAlgorithm? algorithm}) {
List<int> bytes = BytesUtils.fromHexString(privateKey);
final List<int> bytes = BytesUtils.fromHexString(privateKey);
return XRPPrivateKey.fromBytes(bytes, algorithm: algorithm);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/src/rpc/on_chain_models/ledger_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class LedgerInfo {
}

int calculateFeeDynamically() {
double queuePct = currentQueueSize / maxQueueSize;
int feeLow =
final double queuePct = currentQueueSize / maxQueueSize;
final int feeLow =
(drops.minimumFee * 1.5).round().clamp(drops.minimumFee * 10, 1000);

int possibleFeeMedium;
Expand All @@ -41,10 +41,10 @@ class LedgerInfo {
((drops.minimumFee + drops.medianFee) / 2).round());
}

int feeMedium =
final int feeMedium =
(possibleFeeMedium * 15).round().clamp(possibleFeeMedium, 10000);

int feeHigh = (math
final int feeHigh = (math
.max(10 * drops.minimumFee,
(math.max(drops.medianFee, drops.openLedgerFee) * 1.1))
.round())
Expand Down
19 changes: 10 additions & 9 deletions lib/src/rpc/provider/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ class XRPLRpc {
return true;
}

List<String> sourceDecomp = source.split(".");
List<String> targetDecomp = target.split(".");
int sourceMajor = int.parse(sourceDecomp[0]);
int sourceMinor = int.parse(sourceDecomp[1]);
int targetMajor = int.parse(targetDecomp[0]);
int targetMinor = int.parse(targetDecomp[1]);
final List<String> sourceDecomp = source.split(".");
final List<String> targetDecomp = target.split(".");
final int sourceMajor = int.parse(sourceDecomp[0]);
final int sourceMinor = int.parse(sourceDecomp[1]);
final int targetMajor = int.parse(targetDecomp[0]);
final int targetMinor = int.parse(targetDecomp[1]);

/// Compare major version
if (sourceMajor != targetMajor) {
Expand All @@ -107,8 +107,8 @@ class XRPLRpc {
return sourceMinor < targetMinor;
}

List<String> sourcePatch = sourceDecomp[2].split("-");
List<String> targetPatch = targetDecomp[2].split("-");
final List<String> sourcePatch = sourceDecomp[2].split("-");
final List<String> targetPatch = targetDecomp[2].split("-");
int sourcePatchVersion = int.parse(sourcePatch[0]);
int targetPatchVersion = int.parse(targetPatch[0]);
if (sourcePatchVersion != targetPatchVersion) {
Expand Down Expand Up @@ -219,7 +219,8 @@ class XRPLRpc {
throw RPCError(
errorCode: code,
message: message?.toString() ?? '',
request: data["request"] ?? request.params,
request: StringUtils.tryToJson<Map<String, dynamic>>(
data["request"] ?? request.params),
details: StringUtils.tryToJson<Map<String, dynamic>>(data['error']) ??
data);
}
Expand Down
24 changes: 12 additions & 12 deletions lib/src/utility/fulfillment/ans1/ans1_raw_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import 'asn1_codec_exception.dart';
class ASN1RawEncoder {
/// Encode an ASN.1 raw value
static List<int> encode(ANS1RawOptions raw) {
List<int> buf = _encodeIdentifier(raw);
final List<int> buf = _encodeIdentifier(raw);

// Add length information and raw data
if (!raw.indefinite) {
int length = raw.content.length;
final int length = raw.content.length;
buf.addAll(_encodeLength(length));
buf.addAll(raw.content);
} else {
Expand All @@ -52,10 +52,10 @@ class ASN1RawEncoder {
if (value == 0) {
return [0];
}
List<int> encoded = [];
final List<int> encoded = [];

// Determine the number of bytes needed to represent the value
int byteCount = (value.bitLength + 7) ~/ 8;
final int byteCount = (value.bitLength + 7) ~/ 8;

// Encode value
for (int i = byteCount - 1; i >= 0; i--) {
Expand All @@ -74,7 +74,7 @@ class ASN1RawEncoder {
throw ASN1CodecException('invalid class value: ${node.classValue}');
}

List<int> identifier = List<int>.from([0x00], growable: true);
final List<int> identifier = List<int>.from([0x00], growable: true);

// Class (bits 7 and 6) + primitive/constructed (1 bit) + tag (5 bits)
identifier[0] += ((node.classValue & 0x03) << 6);
Expand All @@ -97,12 +97,12 @@ class ASN1RawEncoder {

/// Encode a multi-byte tag
static List<int> _encodeMultiByteTag(int tag) {
int bufLen = ((32 - 1) ~/ 7) + 1; // Assuming a 32-bit integer
List<int> buf = List.filled(bufLen, 0);
const int bufLen = ((32 - 1) ~/ 7) + 1; // Assuming a 32-bit integer
final List<int> buf = List.filled(bufLen, 0);

for (int i = 0; i < buf.length; i++) {
int shift = 7 * (buf.length - i - 1);
int mask = 0x7F << shift;
final int shift = 7 * (buf.length - i - 1);
final int mask = 0x7F << shift;
buf[i] = ((tag & mask) >> shift) & mask8;
// Only the last byte is not marked with 0x80
if (i != buf.length - 1) {
Expand All @@ -120,12 +120,12 @@ class ASN1RawEncoder {
return [length];
}

int bufLen = 4; // Assuming a 32-bit integer
const int bufLen = 4; // Assuming a 32-bit integer
List<int> buf = List.filled(bufLen, 0);

for (int i = 0; i < buf.length; i++) {
int shift = (buf.length - i - 1) * 8;
int mask = mask8 << shift;
final int shift = (buf.length - i - 1) * 8;
final int mask = mask8 << shift;
buf[i] = ((mask & length) >> shift) & mask8;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/src/utility/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class XRPHelper {
const int maxXRPLTime = 4294967296;

/// Calculate the Ripple time.
int rippleTime =
final int rippleTime =
dateTime.toUtc().millisecondsSinceEpoch ~/ 1000 - rippleEpoch;

/// Check if the calculated time is before the Ripple Epoch.
Expand Down Expand Up @@ -174,8 +174,8 @@ class XRPHelper {
"Unable to parse the parameter given to get_xchain_claim_id. 'meta' must be the metadata from an XChainCreateClaimID transaction. Received $meta instead.");
}

List affectedNodes = meta['AffectedNodes'];
List createdNodes = affectedNodes.where((node) {
final List affectedNodes = meta['AffectedNodes'];
final List createdNodes = affectedNodes.where((node) {
return isCreatedNode(node) &&
node['CreatedNode']?['LedgerEntryType'] == 'XChainOwnedClaimID';
}).toList();
Expand Down Expand Up @@ -212,7 +212,7 @@ class XRPHelper {
int createFlag(List<int> flags) {
if (flags.isEmpty) return 0;
int accumulator = 0;
for (int i in flags) {
for (final int i in flags) {
accumulator |= i;
}
return accumulator;
Expand Down
1 change: 0 additions & 1 deletion lib/src/xrpl/address/xrpl.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:blockchain_utils/bip/coin_conf/coins_conf.dart';
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:xrpl_dart/src/crypto/crypto.dart';
import 'package:xrpl_dart/src/xrpl/exception/exceptions.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/src/xrpl/bytes/definations/definations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class XRPLDefinitions {

/// Get the field type ID by field name
static int getFieldTypeId(String fieldName) {
String fieldType = getFieldTypeByName(fieldName);
final String fieldType = getFieldTypeByName(fieldName);
final int? fieldTypeId = _typeOrdinalMap[fieldType];
if (fieldTypeId == null) {
throw const XRPLBinaryCodecException(
Expand Down Expand Up @@ -74,10 +74,10 @@ class XRPLDefinitions {

/// Get field instance by field name
static FieldInstance getFieldInstance(String fieldName) {
FieldInfo info =
final FieldInfo info =
FieldInfo.fromJson(_definationsFields[_fieldKey][fieldName]);

FieldHeader fieldHeader = getFieldHeaderFromName(fieldName);
final FieldHeader fieldHeader = getFieldHeaderFromName(fieldName);
return FieldInstance(info, fieldName, fieldHeader);
}

Expand Down
Loading
Loading