diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 29ab16d..47bd377 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -27,7 +27,7 @@ }, { "name": "blockchain_utils", - "rootUri": "file:///Users/macbookpro/.pub-cache/hosted/pub.dev/blockchain_utils-2.1.2", + "rootUri": "file:///Users/macbookpro/.pub-cache/hosted/pub.dev/blockchain_utils-3.0.0", "packageUri": "lib/", "languageVersion": "2.15" }, @@ -67,6 +67,12 @@ "packageUri": "lib/", "languageVersion": "3.0" }, + { + "name": "flutter_lints", + "rootUri": "file:///Users/macbookpro/.pub-cache/hosted/pub.dev/flutter_lints-4.0.0", + "packageUri": "lib/", + "languageVersion": "3.1" + }, { "name": "frontend_server_client", "rootUri": "file:///Users/macbookpro/.pub-cache/hosted/pub.dev/frontend_server_client-4.0.0", @@ -105,9 +111,9 @@ }, { "name": "lints", - "rootUri": "file:///Users/macbookpro/.pub-cache/hosted/pub.dev/lints-3.0.0", + "rootUri": "file:///Users/macbookpro/.pub-cache/hosted/pub.dev/lints-4.0.0", "packageUri": "lib/", - "languageVersion": "3.0" + "languageVersion": "3.1" }, { "name": "logging", @@ -296,7 +302,7 @@ "languageVersion": "2.15" } ], - "generated": "2024-04-20T14:47:52.470454Z", + "generated": "2024-05-30T05:31:17.826794Z", "generator": "pub", "generatorVersion": "3.3.3" } diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset index 001a013..841e688 100644 --- a/.dart_tool/package_config_subset +++ b/.dart_tool/package_config_subset @@ -14,6 +14,10 @@ async 2.18 file:///Users/macbookpro/.pub-cache/hosted/pub.dev/async-2.11.0/ file:///Users/macbookpro/.pub-cache/hosted/pub.dev/async-2.11.0/lib/ +blockchain_utils +2.15 +file:///Users/macbookpro/.pub-cache/hosted/pub.dev/blockchain_utils-3.0.0/ +file:///Users/macbookpro/.pub-cache/hosted/pub.dev/blockchain_utils-3.0.0/lib/ boolean_selector 2.17 file:///Users/macbookpro/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/ @@ -38,6 +42,10 @@ file 3.0 file:///Users/macbookpro/.pub-cache/hosted/pub.dev/file-7.0.0/ file:///Users/macbookpro/.pub-cache/hosted/pub.dev/file-7.0.0/lib/ +flutter_lints +3.1 +file:///Users/macbookpro/.pub-cache/hosted/pub.dev/flutter_lints-4.0.0/ +file:///Users/macbookpro/.pub-cache/hosted/pub.dev/flutter_lints-4.0.0/lib/ frontend_server_client 3.0 file:///Users/macbookpro/.pub-cache/hosted/pub.dev/frontend_server_client-4.0.0/ @@ -63,9 +71,9 @@ js file:///Users/macbookpro/.pub-cache/hosted/pub.dev/js-0.7.1/ file:///Users/macbookpro/.pub-cache/hosted/pub.dev/js-0.7.1/lib/ lints -3.0 -file:///Users/macbookpro/.pub-cache/hosted/pub.dev/lints-3.0.0/ -file:///Users/macbookpro/.pub-cache/hosted/pub.dev/lints-3.0.0/lib/ +3.1 +file:///Users/macbookpro/.pub-cache/hosted/pub.dev/lints-4.0.0/ +file:///Users/macbookpro/.pub-cache/hosted/pub.dev/lints-4.0.0/lib/ logging 2.19 file:///Users/macbookpro/.pub-cache/hosted/pub.dev/logging-1.2.0/ @@ -186,10 +194,6 @@ yaml 2.19 file:///Users/macbookpro/.pub-cache/hosted/pub.dev/yaml-3.1.2/ file:///Users/macbookpro/.pub-cache/hosted/pub.dev/yaml-3.1.2/lib/ -blockchain_utils -2.15 -file:///Users/macbookpro/Documents/bitcoin/blockchain_utils/ -file:///Users/macbookpro/Documents/bitcoin/blockchain_utils/lib/ xrpl_dart 2.15 file:///Users/macbookpro/Documents/xrpl_dart/ diff --git a/.dart_tool/pub/bin/test/test.dart-3.3.3.snapshot b/.dart_tool/pub/bin/test/test.dart-3.3.3.snapshot deleted file mode 100644 index 4679f5a..0000000 Binary files a/.dart_tool/pub/bin/test/test.dart-3.3.3.snapshot and /dev/null differ diff --git a/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE1 b/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE1 index 54f60fa..8273150 100644 Binary files a/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE1 and b/.dart_tool/test/incremental_kernel.Ly9AZGFydD0yLjE1 differ diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd9bc0..2c42144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,32 @@ +## 4.2.0 + +- Update dependencies. +- Some API changed please review the examples. + ## 4.1.2 - - Update dependencies. +- Update dependencies. ## 4.1.1 - - Update dependencies. +- Update dependencies. ## 4.1.0 - - Update dependencies. +- Update dependencies. ## 4.0.1 - - Update the README. +- Update the README. ## 4.0.0 - - Changed the package name from xrp_dart to xrpl_dart to match the already existing SDK naming convention +- Changed the package name from xrp_dart to xrpl_dart to match the already existing SDK naming convention ## 3.0.3 - - Corrected fee calculation in the autoFill method. - - Updated dependencies for enhanced performance and security. +- Corrected fee calculation in the autoFill method. +- Updated dependencies for enhanced performance and security. ## 3.0.2 @@ -44,22 +49,20 @@ - XChainCreateBridge - XChainModifyBridge - ## 2.0.0 -* Remove unused dependencies. -* Update dependencies. -* Fix Some method for web. - +- Remove unused dependencies. +- Update dependencies. +- Fix Some method for web. ## 1.1.0 -* Update dependencies. +- Update dependencies. ## 0.2.0 -* Removing inefficient methods. +- Removing inefficient methods. ## 0.1.0 -* TODO: Release. +- TODO: Release. diff --git a/README.md b/README.md index 626846b..6496b05 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ For BIP32 HD wallet, BIP39, and Secret storage definitions, please refer to the ## Features ### Transaction Types + The XRP Ledger accommodates a diverse range of transaction types, each tailored for specific purposes. Some of these are outlined below: - Payment Transactions: Standard transactions used to send XRP or Issue from one address to another. @@ -26,21 +27,27 @@ The XRP Ledger accommodates a diverse range of transaction types, each tailored - XChainClaim: Transaction completes a cross-chain transfer of value. - XChainCreateBridge: Transaction creates a new Bridge ledger. ... + ### Addresses + - classAddress: They are straightforward representations of the recipient's address on the XRP Ledger - xAddress: newer format, which provides additional features and interoperability. xAddresses include destination tags by default and are designed to simplify cross-network transactions and improve address interoperability ### Sign + - Sign XRP transactions with ED25519 and SECP256K1 algorithms. ### JSON-RPC Support + This package streamlines communication with XRP nodes using both the JSON-RPC protocol and WebSocket technology. While endeavors have been undertaken to integrate all methods into RPC, it's crucial to acknowledge that, currently, the majority of data APIs are presented in JSON format and haven't been entirely modeled. The addition of WebSocket support enhances the package's versatility for real-time and asynchronous interactions with XRP nodes. ## EXAMPLES + Discover at least one example for each transaction type in the [examples](https://github.com/mrtnetwork/xrpl_dart/tree/main/example/lib) folder. ### Key and addresses -``` + +```dart /// create random privateKey final randomPrivate = XRPPrivateKey.random(algorithm: CryptoAlgorithm.SECP256K1); @@ -64,13 +71,16 @@ Discover at least one example for each transaction type in the [examples](https: final sig = private.sign(...) ``` + ### Transaction -Every transaction type has a dedicated class for transaction creation. + +Every transaction type has a dedicated class for transaction creation. Descriptions for some of these classes are outlined below. Explore training examples for each transaction type in the examples folder [here](https://github.com/mrtnetwork/xrpl_dart/tree/main/example/lib/examples). + - Simple payment - ``` + ```dart final transaction = Payment( destination: destination, // destination account account: ownerAddress, // Sender account @@ -78,9 +88,10 @@ Explore training examples for each transaction type in the examples folder [here signingPubKey: ownerPublic); // Sender's public key ``` + - NTF, mint, createOffer, acceptOffer - - ``` + + ```dart // mint token final transaction = NFTokenMint( flags: NFTokenMintFlag.TF_TRANSFERABLE.value, @@ -109,8 +120,10 @@ Explore training examples for each transaction type in the examples folder [here ); ``` + - Completely create, sign, and send transactions - ``` + + ```dart // create escrowCreate transaction final escrowCreate = EscrowCreate( account: ownerAddress, @@ -151,7 +164,7 @@ Check out the [http_service](https://github.com/mrtnetwork/xrpl_dart/blob/main/e - HTTP JSON RPC -``` +```dart /// access devent final rpc = await XRPLRpc.devNet((httpUri, websocketUri) async { service = RPCHttpService(httpUri, http.Client()); @@ -168,9 +181,10 @@ Check out the [http_service](https://github.com/mrtnetwork/xrpl_dart/blob/main/e await rpc.request(RPCServerDefinitions()); ... ``` + - WEBSOCKET JSON RPC -``` +```dart /// access devent final rpc = await XRPLRpc.devNet((httpUri, websocketUri) async { service = await RPCWebSocketService.connect(websocketUri); @@ -188,7 +202,7 @@ Check out the [http_service](https://github.com/mrtnetwork/xrpl_dart/blob/main/e - WEBSOCKET Subscribe -``` +```dart /// stream event void onEnvet(Map event) {} @@ -210,7 +224,7 @@ Check out the [http_service](https://github.com/mrtnetwork/xrpl_dart/blob/main/e - Tailor the RPC response to your specifications. -``` +```dart /// Create a class that inherits from XRPLedgerRequest and customize it for handling Account NFT Offers IDs. Here's an example: class RPCAccountNftOffersIDs extends XRPLedgerRequest> { RPCAccountNftOffersIDs({ @@ -250,12 +264,11 @@ class RPCAccountNftOffersIDs extends XRPLedgerRequest> { ## Contributing Contributions are welcome! Please follow these guidelines: - - Fork the repository and create a new branch. - - Make your changes and ensure tests pass. - - Submit a pull request with a detailed description of your changes. -## Feature requests and bugs # - -Please file feature requests and bugs in the issue tracker. +- Fork the repository and create a new branch. +- Make your changes and ensure tests pass. +- Submit a pull request with a detailed description of your changes. +## Feature requests and bugs +Please file feature requests and bugs in the issue tracker. diff --git a/analysis_options.yaml b/analysis_options.yaml index 12e713a..8b41229 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml - +#include: package:lints/recommended.yaml +include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/example/pubspec.lock b/example/pubspec.lock index 2ad6b80..20b0795 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -20,10 +20,11 @@ packages: blockchain_utils: dependency: "direct main" description: - path: "../../bitcoin/blockchain_utils" - relative: true - source: path - version: "2.1.1" + name: blockchain_utils + sha256: "699d72427447814bd574b95b0d3baf9b2c0ec9c9b82deef3c6264c6f5efa4406" + url: "https://pub.dev" + source: hosted + version: "3.0.0" boolean_selector: dependency: transitive description: @@ -277,6 +278,6 @@ packages: path: ".." relative: true source: path - version: "4.1.1" + version: "4.1.2" sdks: dart: ">=3.3.0 <4.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d531a19..d07dfd8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -35,8 +35,9 @@ dependencies: http: ^1.1.2 web_socket_channel: ^2.4.0 asn1lib: ^1.5.0 - blockchain_utils: - path: ../../bitcoin/blockchain_utils + blockchain_utils: ^3.0.0 + # blockchain_utils: + # path: ../../bitcoin/blockchain_utils # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. diff --git a/lib/src/crypto/keypair/xrpl_private_key.dart b/lib/src/crypto/keypair/xrpl_private_key.dart index 479be23..74ed492 100644 --- a/lib/src/crypto/keypair/xrpl_private_key.dart +++ b/lib/src/crypto/keypair/xrpl_private_key.dart @@ -306,7 +306,7 @@ class XRPPrivateKey { final toPrive = IPrivateKey.fromBytes(keyBytes, algorithm.curveType); return toPrive; } catch (e) { - throw XRPLAddressCodecException("Invalid private key"); + throw const XRPLAddressCodecException("Invalid private key"); } } diff --git a/lib/src/crypto/keypair/xrpl_public_key.dart b/lib/src/crypto/keypair/xrpl_public_key.dart index cfae0c0..cd0ebcf 100644 --- a/lib/src/crypto/keypair/xrpl_public_key.dart +++ b/lib/src/crypto/keypair/xrpl_public_key.dart @@ -37,7 +37,7 @@ class XRPPublicKey { } } - throw XRPLAddressCodecException( + throw const XRPLAddressCodecException( "invalid public key. public key length must be ${RippleKeyConst.publicKeyLength} bytes"); } @@ -50,7 +50,7 @@ class XRPPublicKey { } return IPublicKey.fromBytes(keyBytes, algorithm.curveType); } catch (e) { - throw XRPLAddressCodecException("invalid public key"); + throw const XRPLAddressCodecException("invalid public key"); } } diff --git a/lib/src/utility/fulfillment/ans1/ans1_raw_encoder.dart b/lib/src/utility/fulfillment/ans1/ans1_raw_encoder.dart index 13bf92a..02020ea 100644 --- a/lib/src/utility/fulfillment/ans1/ans1_raw_encoder.dart +++ b/lib/src/utility/fulfillment/ans1/ans1_raw_encoder.dart @@ -37,7 +37,7 @@ class ASN1RawEncoder { } else { // Indefinite length uses 0x80, data..., 0x00, 0x00 if (!raw.constructed) { - throw ASN1CodecException( + throw const ASN1CodecException( 'indefinite length is only allowed for constructed types'); } buf.add(0x80); diff --git a/lib/src/xrpl/address/xrpl.dart b/lib/src/xrpl/address/xrpl.dart index 44e87f3..c54a666 100644 --- a/lib/src/xrpl/address/xrpl.dart +++ b/lib/src/xrpl/address/xrpl.dart @@ -43,7 +43,7 @@ class XRPAddress { XrpAddrDecoder().decodeAddr(address); return XRPAddress._(address, null); } catch (e) { - throw XRPLAddressCodecException("Invalid ripple address"); + throw const XRPLAddressCodecException("Invalid ripple address"); } } diff --git a/lib/src/xrpl/bytes/binery_serializer/binary_parser.dart b/lib/src/xrpl/bytes/binery_serializer/binary_parser.dart index dbe8e5f..8db93bd 100644 --- a/lib/src/xrpl/bytes/binery_serializer/binary_parser.dart +++ b/lib/src/xrpl/bytes/binery_serializer/binary_parser.dart @@ -66,17 +66,18 @@ class _BinaryParserConst { /// A class for parsing binary data represented as a hexadecimal string. class BinaryParser { final List _bytes; - int position = 0; + int _position = 0; - BinaryParser(List bytes) : _bytes = BytesUtils.toBytes(bytes); + BinaryParser(List bytes) + : _bytes = BytesUtils.toBytes(bytes, unmodifiable: true); /// Get the remaining length of bytes to be parsed - int get length => _bytes.length - position; + int get length => _bytes.length - _position; /// Peek at the next byte without advancing the position int? peek() { if (length > 0) { - return _bytes[position]; + return _bytes[_position]; } return null; } @@ -87,13 +88,13 @@ class BinaryParser { throw XRPLBinaryCodecException( 'BinaryParser can\'t skip $n bytes, only contains $length.'); } - position += n; + _position += n; } /// Read and return a specified number of bytes List read(int n) { - final result = _bytes.sublist(position, position + n); - position += n; + final result = _bytes.sublist(_position, _position + n); + _position += n; return result; } diff --git a/lib/src/xrpl/bytes/binery_serializer/binary_serializer.dart b/lib/src/xrpl/bytes/binery_serializer/binary_serializer.dart index 1335aec..805664a 100644 --- a/lib/src/xrpl/bytes/binery_serializer/binary_serializer.dart +++ b/lib/src/xrpl/bytes/binery_serializer/binary_serializer.dart @@ -121,7 +121,7 @@ class BinarySerializer { return [byte1, byte2, byte3]; } - throw XRPLBinaryCodecException( + throw const XRPLBinaryCodecException( 'VariableLength field must be <= ${_BinerySerializerConst._maxLengthValue} bytes long'); } } diff --git a/lib/src/xrpl/models/base/transaction.dart b/lib/src/xrpl/models/base/transaction.dart index f2b4d2c..ee4b60f 100644 --- a/lib/src/xrpl/models/base/transaction.dart +++ b/lib/src/xrpl/models/base/transaction.dart @@ -171,7 +171,7 @@ class XRPTransaction extends XRPLBase { _networkId = networkId, memos = List.unmodifiable(memos ?? []) { if (_multisigSigners.isNotEmpty && _signer != null) { - throw XRPLTransactionException( + throw const XRPLTransactionException( "Utilize multisigSigners for multisig transactions, or signer for single-signature transactions."); } } @@ -225,7 +225,7 @@ class XRPTransaction extends XRPLBase { void setSignature(XRPLSignature? signature) { if (isMultisig) { - throw XRPLTransactionException( + throw const XRPLTransactionException( "use setMultiSigSignature method for multi-signature transactions"); } _signer = signature; @@ -233,7 +233,7 @@ class XRPTransaction extends XRPLBase { void setMultiSigSignature(List sigs) { if (_signer != null) { - throw XRPLTransactionException( + throw const XRPLTransactionException( "Please avoid setting setMultiSigSignature for non-multi-sig transactions"); } _multisigSigners = List.unmodifiable(sigs @@ -308,15 +308,15 @@ class XRPTransaction extends XRPLBase { String toBlob({bool forSigning = true}) { if (forSigning) { if (isMultisig) { - throw XRPLTransactionException( + throw const XRPLTransactionException( "use toMultisigBlob for multisign transaction."); } if (ticketSequance != null && sequence != 0) { - throw XRPLTransactionException( + throw const XRPLTransactionException( "Set the sequence to 0 when using the ticketSequence"); } if (fee == null) { - throw XRPLTransactionException("invalid transaction fee"); + throw const XRPLTransactionException("invalid transaction fee"); } } final result = STObject.fromValue(toXrpl(), forSigning).toBytes(); @@ -330,11 +330,11 @@ class XRPTransaction extends XRPLBase { String toMultisigBlob(String address) { final result = STObject.fromValue(toXrpl(), true).toBytes(); - final accountIdBytes = AccountID.fromValue(address).toBytes(); + final addr = XRPAddress(address, allowXAddress: true); return BytesUtils.toHexString([ ..._TransactionUtils._transactionMultisigPrefix, ...result, - ...accountIdBytes + ...addr.toBytes() ], lowerCase: false); } @@ -342,7 +342,7 @@ class XRPTransaction extends XRPLBase { if (!(signer?.isReady ?? false) && (_multisigSigners.isEmpty || _multisigSigners.any((element) => !element.isReady))) { - throw XRPLTransactionException( + throw const XRPLTransactionException( "Cannot get the hash from an unsigned Transaction."); } final encodeStr = @@ -368,8 +368,17 @@ class XRPTransaction extends XRPLBase { } factory XRPTransaction.fromBlob(String hexBlob) { - final p = BinaryParser(BytesUtils.fromHexString(hexBlob)); - final data = STObject.fromParser(p); + List toBytes = BytesUtils.fromHexString(hexBlob); + final prefix = toBytes.sublist(0, 4); + if (bytesEqual(prefix, _TransactionUtils._transactionMultisigPrefix) || + bytesEqual(prefix, _TransactionUtils._transactionSignaturePrefix)) { + toBytes = toBytes.sublist(4); + if (bytesEqual(prefix, _TransactionUtils._transactionMultisigPrefix)) { + toBytes = toBytes.sublist(0, toBytes.length - Hash160.lengthBytes); + } + } + final parser = BinaryParser(toBytes); + final data = STObject.fromParser(parser); final toJson = data.toJson(); final formatJson = _TransactionUtils._formattedDict(toJson); return _findTransactionObject(formatJson); diff --git a/pubspec.lock b/pubspec.lock index 1ff7bc1..73bd674 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: "direct main" description: name: blockchain_utils - sha256: b0d73432f145ba6f9299c362ea6d8ea9804d5422c34180abee7854b7adcb869d + sha256: "699d72427447814bd574b95b0d3baf9b2c0ec9c9b82deef3c6264c6f5efa4406" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "3.0.0" boolean_selector: dependency: transitive description: @@ -89,6 +89,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" + url: "https://pub.dev" + source: hosted + version: "4.0.0" frontend_server_client: dependency: transitive description: @@ -141,10 +149,10 @@ packages: dependency: "direct dev" description: name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "4.0.0" logging: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 13b7bee..1123648 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: xrpl_dart description: Easily sign, create, and send all types of XRP transactions using the xrpl_dart package. Manage your XRP Ledger transactions securely and with ease. -version: 4.1.2 +version: 4.2.0 homepage: "https://github.com/mrtnetwork/xrpl_dart" repository: "https://github.com/mrtnetwork/xrpl_dart" Author: mrhaydari.t@gmail.com @@ -15,13 +15,14 @@ environment: sdk: '>=2.15.0 <4.0.0' dependencies: - blockchain_utils: ^2.1.2 + blockchain_utils: ^3.0.0 # blockchain_utils: # path: ../bitcoin/blockchain_utils dev_dependencies: - lints: ^3.0.0 + lints: ^4.0.0 test: ^1.25.2 + flutter_lints: ^4.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/transaction_test.dart b/test/transaction_test.dart new file mode 100644 index 0000000..8832d01 --- /dev/null +++ b/test/transaction_test.dart @@ -0,0 +1,93 @@ +import 'package:blockchain_utils/binary/utils.dart'; +import 'package:test/test.dart'; +import 'package:xrpl_dart/xrpl_dart.dart'; + +final String memoData = BytesUtils.toHexString( + "https://github.com/mrtnetwork/xrpl_dart".codeUnits, + lowerCase: false); +final String memoType = + BytesUtils.toHexString("Text".codeUnits, lowerCase: false); +final String mempFormat = + BytesUtils.toHexString("text/plain".codeUnits, lowerCase: false); +final exampleMemo = + XRPLMemo(memoData: memoData, memoFormat: mempFormat, memoType: memoType); +void main() { + group("Transaction", () { + _test(); + }); +} + +void _test() { + test("Payment", () { + const blob = + "535458001200002200000000240010ABFB201B0010AC53614000000000B71B0068400000000000000A732103A21EB8F8A58DE60D923621F63B6E821A1B0383401CBE37AE089571F3A4DDE5D181143609670A615BEDD7A20A0F76E5055FD2ED5DC984831457DAE62CD8431521DB6E01B2E26BADCB1E425FDDF9EA7C04546578747D2768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F646172747E0A746578742F706C61696EE1F1"; + final transaction = XRPTransaction.fromBlob(blob); + expect(transaction.toBlob(), blob); + expect(transaction.transactionType, XRPLTransactionType.payment); + expect(transaction.memos[0].memoData, memoData); + expect((transaction as Payment).amount.xrp, BigInt.from(12000000)); + }); + test("Payment_2", () { + const blob = + "535458001200002200000000240010ABFD2E00000019201B0010AFAA614000000000B71B0068400000000000000A732103A21EB8F8A58DE60D923621F63B6E821A1B0383401CBE37AE089571F3A4DDE5D181143609670A615BEDD7A20A0F76E5055FD2ED5DC9848314115697DFBB6E9D9C713A241D87FFB54C8728B937F9EA7C04546578747D2768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F646172747E0A746578742F706C61696EE1F1"; + final transaction = XRPTransaction.fromBlob(blob); + expect(transaction.toBlob(), blob); + expect(transaction.transactionType, XRPLTransactionType.payment); + expect(transaction.memos[0].memoData, memoData); + expect((transaction as Payment).amount.xrp, BigInt.from(12000000)); + expect((transaction).destinationTag, 25); + final fromXrpl = XRPTransaction.fromBlob(transaction.toBlob()); + expect(transaction.toXrpl(), fromXrpl.toXrpl()); + }); + test("MintNFT", () { + const blob = + "535458001200192200000000240010ABFE201B0010B010202A0000000168400000000000000A732103A21EB8F8A58DE60D923621F63B6E821A1B0383401CBE37AE089571F3A4DDE5D1752768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F6461727481143609670A615BEDD7A20A0F76E5055FD2ED5DC984F9EA7C04546578747D2768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F646172747E0A746578742F706C61696EE1F1"; + final transaction = XRPTransaction.fromBlob(blob); + expect(transaction.toBlob(), blob); + expect(transaction.account, "rnv5kChGCSrzKPJi6BidxiU3e3N9fxpfxq"); + expect(transaction.transactionType, XRPLTransactionType.nftokenMint); + expect(transaction.signer?.signingPubKey, + "03A21EB8F8A58DE60D923621F63B6E821A1B0383401CBE37AE089571F3A4DDE5D1"); + expect((transaction as NFTokenMint).nftokenTaxon, 1); + }); + test("SignerListSet", () { + const blob = + "5354580012000C2200000000240010B04F201B0010B08320230000000268400000000000000A73210372A211BC750CBC51D1D29FB3D1615FD508D714F44BDDCC475029037346DFE12D8114F5CADBD9540B4DD2CBFD9FD1BDDFE4A302B2E1CEF4EB130001811462F2390039B80AFC196183290C3775974B9055CEE1EB1300028114238A512BFDB5FE589291A2009C21C22537D4FD4CE1F1F9EA7C04546578747D2768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F646172747E0A746578742F706C61696EE1F1"; + final transaction = XRPTransaction.fromBlob(blob); + expect(transaction.toBlob(), blob); + expect(transaction.account, "rPQdZ1gtxLCZidafWTRDerhUeZAsZAvM29"); + expect(transaction.transactionType, XRPLTransactionType.signerListSet); + expect(transaction.signer?.signingPubKey, + "0372A211BC750CBC51D1D29FB3D1615FD508D714F44BDDCC475029037346DFE12D"); + final signerListSet = (transaction as SignerListSet); + final signers = signerListSet.signerEntries!; + + expect(signers[0].account, "rwpBPjsKpBDXKu1P7y19zTAPW4DkiqsavL"); + expect(signers[1].account, "rhNvM9trpqmybHviu3PYRtTGg5bEGWruJg"); + expect(signerListSet.signerQuorum, 2); + final fromXrpl = XRPTransaction.fromBlob(transaction.toBlob()); + expect(transaction.toXrpl(), fromXrpl.toXrpl()); + }); + test("AccountSet", () { + const blob = + "535458001200032200000000240010B050201B0010B0C820210000000468400000000000000A73210372A211BC750CBC51D1D29FB3D1615FD508D714F44BDDCC475029037346DFE12D8114F5CADBD9540B4DD2CBFD9FD1BDDFE4A302B2E1CEF9EA7C04546578747D2768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F646172747E0A746578742F706C61696EE1F1"; + final transaction = XRPTransaction.fromBlob(blob); + expect(transaction.toBlob(), blob); + expect(transaction.account, "rPQdZ1gtxLCZidafWTRDerhUeZAsZAvM29"); + expect(transaction.transactionType, XRPLTransactionType.accountSet); + expect(transaction.signer?.signingPubKey, + "0372A211BC750CBC51D1D29FB3D1615FD508D714F44BDDCC475029037346DFE12D"); + final accountSet = (transaction as AccountSet); + + expect(accountSet.setFlag, AccountSetAsfFlag.asfDisableMaster); + final fromXrpl = XRPTransaction.fromBlob(transaction.toBlob()); + expect(transaction.toXrpl(), fromXrpl.toXrpl()); + }); + test("Multisig", () { + const blob = + "534D54001200002200000000240010B053201B0010B239614000000000B71B0068400000000000002873008114F5CADBD9540B4DD2CBFD9FD1BDDFE4A302B2E1CE83143609670A615BEDD7A20A0F76E5055FD2ED5DC984F9EA7C04546578747D2768747470733A2F2F6769746875622E636F6D2F6D72746E6574776F726B2F7872706C5F646172747E0A746578742F706C61696EE1F162F2390039B80AFC196183290C3775974B9055CE"; + final transaction = XRPTransaction.fromBlob(blob); + expect( + transaction.toMultisigBlob("rwpBPjsKpBDXKu1P7y19zTAPW4DkiqsavL"), blob); + }); +}