From 5d78f882e70d78fe41198117f6faadd92741a5b7 Mon Sep 17 00:00:00 2001 From: Wei Hau Lim Date: Sat, 28 May 2022 12:13:36 +0800 Subject: [PATCH 1/4] bug fix: retrieving aggregate txns returns error --- lib/src/api/dto/transaction_dto.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/api/dto/transaction_dto.dart b/lib/src/api/dto/transaction_dto.dart index 44cf627..af654d7 100644 --- a/lib/src/api/dto/transaction_dto.dart +++ b/lib/src/api/dto/transaction_dto.dart @@ -266,8 +266,11 @@ class AggregateTransactionDTO extends AbstractTransactionDTO { deadline = UInt64DTO.fromJson(json['deadline']); cosignatures = AggregateTransactionCosignatureDTO.listFromJson( json['cosignatures'].cast()); - print(json['transactions']); - transactions = txnDeserialize(json['transactions'], 'List'); + if (json['transactions'] == null) { + transactions = []; + } else { + transactions = txnDeserialize(json['transactions'], 'List'); + } } List? cosignatures; From c4c2cfbeb42f9a298734f2f0523c085b723dc6ad Mon Sep 17 00:00:00 2001 From: Wei Hau Lim Date: Mon, 30 May 2022 11:18:51 +0800 Subject: [PATCH 2/4] version: 0.0.7+8 --- CHANGELOG.md | 55 ++ README.md | 11 +- analysis_options.yaml | 4 +- example/api_accounts.dart | 14 +- example/api_blockchain.dart | 2 +- example/api_metadat.dart | 2 +- example/api_mosaics.dart | 2 +- example/api_namespace.dart | 2 +- example/api_network.dart | 2 +- example/api_node.dart | 2 +- example/api_transactions.dart | 11 +- example/example.dart | 49 - .../account_metadata_transaction.dart | 2 +- .../mosaic_definition_transaction.dart | 2 +- .../mosaic_metadata_transaction.dart | 2 +- .../mosaic_supply_change_transaction.dart | 2 +- .../transactions/transfer_transaction.dart | 2 +- example/xpx_chain_sdk.dart | 47 + gen_schemas.sh | 2 +- lib/imp/buffer.dart | 34 - lib/imp/buffer/model.dart | 22 - ...account_properties_transaction_buffer.dart | 275 ------ .../model/aggregate_transaction_buffer.dart | 186 ---- .../model/alias_transaction_buffer.dart | 199 ---- .../model/exchange_transaction_buffer.dart | 868 ------------------ .../model/lock_funds_transaction_buffer.dart | 215 ----- .../modify_contract_transaction_buffer.dart | 367 -------- .../modify_metadata_transaction_buffer.dart | 340 ------- ...y_multisig_account_transaction_buffer.dart | 213 ----- .../mosaic_alias_transaction_buffer.dart | 199 ---- .../mosaic_definition_transaction_buffer.dart | 308 ------- ...saic_supply_change_transaction_buffer.dart | 198 ---- ...register_namespace_transaction_buffer.dart | 226 ----- .../model/secret_lock_transaction_buffer.dart | 243 ----- .../secret_proof_transaction_buffer.dart | 210 ----- lib/imp/buffer/model/transactions_buffer.dart | 46 - .../model/transfer_transaction_buffer.dart | 385 -------- lib/imp/buffer/schema.dart | 15 - lib/imp/buffer/schema/buffer_schema.dart | 204 ---- .../buffer_schema_account_property.dart | 16 - .../schema/buffer_schema_aggregate.dart | 10 - .../buffer/schema/buffer_schema_alias.dart | 11 - .../buffer/schema/buffer_schema_exchange.dart | 55 -- .../schema/buffer_schema_lockFunds.dart | 12 - .../buffer_schema_mosaic_definition.dart | 19 - .../buffer_schema_mosaic_supply_change.dart | 11 - .../buffer/schema/buffer_schema_multisig.dart | 17 - .../buffer_schema_register_namespace.dart | 13 - .../buffer/schema/buffer_schema_transfer.dart | 21 - lib/src/api/api.dart | 7 +- lib/src/api/api_account_routes.dart | 140 +-- lib/src/api/api_blockchain_routes.dart | 5 +- lib/src/api/api_client.dart | 23 +- lib/src/api/api_exchange_routes.dart | 4 +- lib/src/api/api_internal.dart | 44 - lib/src/api/api_metadata_routes.dart | 2 +- lib/src/api/api_mosaic_routes.dart | 4 +- lib/src/api/api_namespace_routes.dart | 4 +- lib/src/api/api_network_routes.dart | 4 +- lib/src/api/api_node_routes.dart | 2 +- lib/src/api/api_transaction_routes.dart | 33 +- lib/src/api/dto.dart | 4 +- lib/src/api/dto/mosaic_levy_dto.dart | 1 + lib/src/api/dto/transaction_count_dto.dart | 1 + lib/src/api/dto/transaction_dto.dart | 8 +- lib/src/api/metadata_query_params.dart | 12 +- lib/src/api/transaction_query_params.dart | 15 +- lib/src/model.dart | 2 + lib/src/model/account.dart | 3 +- lib/src/model/account/account_dto.dart | 67 -- lib/src/model/account/account_model.dart | 182 ---- lib/src/model/account/account_properties.dart | 18 +- .../model/account/account_properties_dto.dart | 73 -- .../model/account/account_property_dto.dart | 280 ------ lib/src/model/account/address.dart | 1 - lib/src/model/account/address_model.dart | 76 -- lib/src/model/alias.dart | 3 +- lib/src/model/alias/alias_dto.dart | 93 -- lib/src/model/alias/alias_internal.dart | 18 - lib/src/model/alias/alias_model.dart | 11 + lib/src/model/blockchain.dart | 3 +- lib/src/model/blockchain/block_dto.dart | 137 --- lib/src/model/blockchain/block_model.dart | 168 ---- lib/src/model/blockchain/height_dto.dart | 17 - .../blockchain/merkle_proof_info_dto.dart | 31 - lib/src/model/entity_types.dart | 2 +- lib/src/model/exchange.dart | 7 +- lib/src/model/exchange/exchange_dto.dart | 262 ------ lib/src/model/message.dart | 2 +- lib/src/model/message/message_dto.dart | 14 - lib/src/model/message/message_model.dart | 155 ---- lib/src/model/metadata.dart | 3 +- lib/src/model/metadata/metadata_type.dart | 1 + lib/src/model/mosaic.dart | 3 +- lib/src/model/mosaic/mosaic_dto.dart | 317 ------- lib/src/model/mosaic/mosaic_model.dart | 243 ----- lib/src/model/multisig.dart | 2 +- lib/src/model/multisig/multisig_dto.dart | 79 -- lib/src/model/multisig/multisig_model.dart | 124 --- lib/src/model/namespace.dart | 3 +- lib/src/model/namespace/namespace_dto.dart | 237 ----- lib/src/model/namespace/namespace_model.dart | 197 ---- lib/src/model/network.dart | 2 +- lib/src/model/node.dart | 3 +- lib/src/model/node/node_time_dto.dart | 27 - lib/src/model/transaction.dart | 9 +- .../announce_transaction_info_dto.dart | 22 - lib/src/model/transaction/buffer/buffer.dart | 34 + ...ransaction_catapult.buffers_generated.dart | 9 + ...ransaction_catapult.buffers_generated.dart | 11 + ...ransaction_catapult.buffers_generated.dart | 9 + ...ransaction_catapult.buffers_generated.dart | 9 + ...ransaction_catapult.buffers_generated.dart | 9 + ...ransaction_catapult.buffers_generated.dart | 39 + ...ransaction_catapult.buffers_generated.dart | 7 + ...ransaction_catapult.buffers_generated.dart | 11 + ...ransaction_catapult.buffers_generated.dart | 12 + ...ransaction_catapult.buffers_generated.dart | 17 + ...ransaction_catapult.buffers_generated.dart | 15 + ...fy_mosaic_levy_transactions_generated.dart | 13 + ...ransaction_catapult.buffers_generated.dart | 14 +- ...ransaction_catapult.buffers_generated.dart | 15 + ...ic_remove_levy_transactions_generated.dart | 8 + ...ransaction_catapult.buffers_generated.dart | 10 + ...ransaction_catapult.buffers_generated.dart | 12 + ...ransaction_catapult.buffers_generated.dart | 33 + ...ransaction_catapult.buffers_generated.dart | 12 + ...ransaction_catapult.buffers_generated.dart | 13 + ...ransaction_catapult.buffers_generated.dart | 12 + ...ransaction_catapult.buffers_generated.dart | 112 +++ ...ransaction_catapult.buffers_generated.dart | 37 +- ...ransaction_catapult.buffers_generated.dart | 17 +- .../buffer/transactions_buffer.dart | 0 ...ransaciton_account_properties_address.dart | 2 +- ...aciton_account_properties_entity_type.dart | 2 +- ...transaciton_account_properties_mosaic.dart | 2 +- .../transaction/transaction_aggregate.dart | 22 +- .../model/transaction/transaction_dto.dart | 300 ------ .../model/transaction/transaction_hashes.dart | 29 - .../transaction/transaction_internal.dart | 49 + .../model/transaction/transaction_model.dart | 365 -------- .../transaction_mosaic_metadata.dart | 4 +- .../transaction/transaction_multisig.dart | 11 +- .../model/transaction/transaction_type.dart | 81 +- lib/src/model/uint64/uint64_dto.dart | 47 - lib/src/utils.dart | 2 + .../utils/all_errors.dart} | 2 +- .../utils/consts.dart} | 2 +- lib/{xpx_sdk.dart => xpx_chain_sdk.dart} | 1 - pubspec.yaml | 2 +- schemas/README.md | 1 + 151 files changed, 914 insertions(+), 8863 deletions(-) delete mode 100644 example/example.dart create mode 100644 example/xpx_chain_sdk.dart delete mode 100644 lib/imp/buffer.dart delete mode 100644 lib/imp/buffer/model.dart delete mode 100644 lib/imp/buffer/model/account_properties_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/aggregate_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/alias_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/exchange_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/lock_funds_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/modify_contract_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/modify_metadata_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/modify_multisig_account_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/mosaic_alias_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/mosaic_definition_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/mosaic_supply_change_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/register_namespace_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/secret_lock_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/secret_proof_transaction_buffer.dart delete mode 100644 lib/imp/buffer/model/transactions_buffer.dart delete mode 100644 lib/imp/buffer/model/transfer_transaction_buffer.dart delete mode 100644 lib/imp/buffer/schema.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_account_property.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_aggregate.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_alias.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_exchange.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_lockFunds.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_mosaic_definition.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_mosaic_supply_change.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_multisig.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_register_namespace.dart delete mode 100644 lib/imp/buffer/schema/buffer_schema_transfer.dart delete mode 100644 lib/src/api/api_internal.dart delete mode 100644 lib/src/model/account/account_dto.dart delete mode 100644 lib/src/model/account/account_model.dart delete mode 100644 lib/src/model/account/account_properties_dto.dart delete mode 100644 lib/src/model/account/account_property_dto.dart delete mode 100644 lib/src/model/account/address_model.dart delete mode 100644 lib/src/model/alias/alias_dto.dart delete mode 100644 lib/src/model/alias/alias_internal.dart delete mode 100644 lib/src/model/blockchain/block_dto.dart delete mode 100644 lib/src/model/blockchain/block_model.dart delete mode 100644 lib/src/model/blockchain/height_dto.dart delete mode 100644 lib/src/model/blockchain/merkle_proof_info_dto.dart delete mode 100644 lib/src/model/exchange/exchange_dto.dart delete mode 100644 lib/src/model/message/message_dto.dart delete mode 100644 lib/src/model/message/message_model.dart delete mode 100644 lib/src/model/mosaic/mosaic_dto.dart delete mode 100644 lib/src/model/mosaic/mosaic_model.dart delete mode 100644 lib/src/model/multisig/multisig_dto.dart delete mode 100644 lib/src/model/multisig/multisig_model.dart delete mode 100644 lib/src/model/namespace/namespace_dto.dart delete mode 100644 lib/src/model/namespace/namespace_model.dart delete mode 100644 lib/src/model/node/node_time_dto.dart delete mode 100644 lib/src/model/transaction/announce_transaction_info_dto.dart create mode 100644 lib/src/model/transaction/buffer/buffer.dart rename lib/{imp => src/model/transaction}/buffer/schema_account_link_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_alias_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_exchange_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_harvester_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_modify_mosaic_levy_transactions_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart (98%) rename lib/{imp => src/model/transaction}/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_mosaic_remove_levy_transactions_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_network_config_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_operation_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_storage_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart (99%) rename lib/{imp => src/model/transaction}/buffer/schema_transfer_transaction_catapult.buffers_generated.dart (98%) rename lib/{imp => src/model/transaction}/buffer/transactions_buffer.dart (100%) delete mode 100644 lib/src/model/transaction/transaction_dto.dart delete mode 100644 lib/src/model/transaction/transaction_hashes.dart delete mode 100644 lib/src/model/transaction/transaction_model.dart delete mode 100644 lib/src/model/uint64/uint64_dto.dart rename lib/{xpx_sdk_all_errors.dart => src/utils/all_errors.dart} (98%) rename lib/{xpx_sdk_consts.dart => src/utils/consts.dart} (99%) rename lib/{xpx_sdk.dart => xpx_chain_sdk.dart} (86%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02a05c1..4cc74a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,43 +1,79 @@ +## 0.0.7+8 +[FIXED] fixed bug ModifyMultisigAccountTransaction. + +## 0.0.7+7 + +### Updates + +[UPDATE] exclude buffer analyzer. +[UPDATE] update imports. + +## 0.0.7+6 + +### Fixed bugs + +[FIXED] fixed bug get partialTransactions. + ## 0.0.7+5 + ### Updates + [UPDATE] update README ## 0.0.7+4 + ### New Features + [ADD] Metadata version V2 support. ## 0.0.7+2 + ### New Features + [ADD] Transaction examples api. ## 0.0.7+1 + ### Updates + [UPDATE] sdk: '>=2.16.0'. ## 0.0.6+6 + ### Updates + [UPDATE] Homepage URL. ## 0.0.6+5 + ### New Features + [ADD] Message encrypted. ### Updates + [UPDATE] format code. ## 0.0.5+5 + [ADD] Message toJson method. ## 0.0.5+4 + ### Updates + [UPDATE] analysis code. ## 0.0.5+3 + ### Updates + [UPDATE] format code. ## 0.0.5+2 + ### New Features + [ADD] AccountPropertiesAddressTransaction. [ADD] AccountPropertiesMosaicTransaction. @@ -45,7 +81,9 @@ [ADD] AccountPropertiesEntityTypeTransaction. ## 0.0.5+1 + ### New Features + [ADD] AddExchangeOfferTransaction model. [ADD] Extension AliasTypeToInt and AliasActionTypeToInt. @@ -59,6 +97,7 @@ [ADD] ExchangeRoutes Api. ### Updates + [UPDATE] BigInt method. [UPDATE] Buffer Endian. @@ -66,11 +105,15 @@ [UPDATE] Unnecessary new keyword. ## 0.0.4+1 + ### New Features + [UPDATE] Update Sirius chain 0.5.0 ## 0.0.3+5 + ### New Features + [ADD] ModifyMultisigAccountTransaction support. [ADD] Get ModifyMultisigInfo. @@ -88,6 +131,7 @@ [ADD] CosignatureTransaction class. ### Updates + [UPDATE] Reformat style. [UPDATE] Update example. @@ -103,16 +147,21 @@ [UPDATE] fixed bug in TableArrayAttribute. ## 0.0.3+4 + ### Updates + [UPDATE] latest published versions for http dependency. ## 0.0.3+3 + ### Updates + [UPDATE] Reformat style. [UPDATE] Update example. ### Fixed bugs + [FIXED] fixed bug in Deadline null [FIXED] fixed bug in MosaicSupplyChangeTransaction @@ -134,7 +183,9 @@ [FIXED] fixed bug in BlockInfoDTO ## 0.0.3+2 + ### Updates + [UPDATE] Reformat style. [UPDATE] rename Config Class. @@ -144,9 +195,11 @@ [UPDATE] examples. ## 0.0.3+1 + - Initial version, created by Eleazar Garrido. ### New Features + [ADD] Get Account MultiSig Info. [ADD] Get Account MultiSign Graph Info. @@ -156,6 +209,7 @@ [ADD] Get Transactions Statuses. ### Updates + [UPDATE] Documentation fixes. [UPDATE] Reformat style. @@ -165,6 +219,7 @@ [UPDATE] examples. ### Fixed bugs + [FIXED] Undefined name 'HEX'. [DELETED] removed unused functions. diff --git a/README.md b/README.md index ddbfcb6..00595de 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -The ProximaX Sirius Chain Dart SDK works as a lightweight Dart library for interacting with the Sirius Blockchain. It provides a complete library set coverage, and supports synchronous and asynchronous requests. +The ProximaX Sirius Chain Dart SDK works as a lightweight Dart library for interacting with the Sirius Blockchain. It +provides a complete library set coverage, and supports synchronous and asynchronous requests. **1. Depend on it** @@ -11,7 +12,7 @@ Add this to your package's pubspec.yaml file: ```dart dependencies: - xpx_chain_sdk: 0.0.7+5 + xpx_chain_sdk: 0.0.7+8 ``` **2. Install it** @@ -47,6 +48,8 @@ Examples are in the [examples](https://github.com/proximax-storage/dart-xpx-chai For more examples, go to our [wiki](https://github.com/proximax-storage/dart-xpx-chain-sdk/wiki) ## Contribution ## -We'd love to get more people involved in the project. Please feel free to raise any issues or PR and we'll review your contribution. - + +We'd love to get more people involved in the project. Please feel free to raise any issues or PR and we'll review your +contribution. + Copyright (c) 2019 ProximaX Limited diff --git a/analysis_options.yaml b/analysis_options.yaml index a02e4e9..5775565 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -8,7 +8,7 @@ analyzer: implicit-casts: true implicit-dynamic: true exclude: - - lib/imp/** + - lib/src/model/transaction/buffer/** # ## ALL lint rules are included. Unused lints should be commented ## out with a reason. An up to date list of all options is here @@ -228,7 +228,7 @@ linter: # Name non-constant identifiers using lowerCamelCase. # recommendation: recommended # 0 issues - - non_constant_identifier_names : false + - non_constant_identifier_names: false # Omit type annotations for local variables. # recommendation: avoid diff --git a/example/api_accounts.dart b/example/api_accounts.dart index aea4b30..97b3e97 100644 --- a/example/api_accounts.dart +++ b/example/api_accounts.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; @@ -59,7 +59,8 @@ void main() async { // Gets an array of transactions for which an account is the sender or receiver. try { - final result = await client.account.transactions(accountOne.address); + final result = await client.account + .transactions(accountOne, TransactionQueryParams()..embedded = true); print(result); } on Exception catch (e) { print('Exception when calling Account->Transactions: $e\n'); @@ -68,8 +69,7 @@ void main() async { // Gets an array of incoming transactions. // A transaction is said to be incoming with respect to an account if the account is the recipient of the transaction. try { - final result = - await client.account.incomingTransactions(accountOne.address); + final result = await client.account.incomingTransactions(accountOne); print(result); } on Exception catch (e) { print('Exception when calling Account->IncomingTransactions: $e\n'); @@ -86,8 +86,7 @@ void main() async { // Gets the array of transactions not included in a block where an account is the sender or receiver. try { - final result = - await client.account.unconfirmedTransactions(accountOne.address); + final result = await client.account.unconfirmedTransactions(accountOne); print(result); } on Exception catch (e) { print('Exception when calling Account->UnconfirmedTransactions: $e\n'); @@ -95,7 +94,8 @@ void main() async { // Gets an array of [aggregate bonded transactions] where the account is the sender or requires to cosign the transaction. try { - final result = await client.account.partialTransactions(accountOne.address); + final result = await client.account.partialTransactions( + accountOne, TransactionQueryParams()..embedded = true); print(result); } on Exception catch (e) { print('Exception when calling Account->AggregateBondedTransactions: $e\n'); diff --git a/example/api_blockchain.dart b/example/api_blockchain.dart index a8e29dd..d0133ab 100644 --- a/example/api_blockchain.dart +++ b/example/api_blockchain.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io'; diff --git a/example/api_metadat.dart b/example/api_metadat.dart index aec843d..5e3d8dd 100644 --- a/example/api_metadat.dart +++ b/example/api_metadat.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; diff --git a/example/api_mosaics.dart b/example/api_mosaics.dart index ef100b8..7cd2f90 100644 --- a/example/api_mosaics.dart +++ b/example/api_mosaics.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; diff --git a/example/api_namespace.dart b/example/api_namespace.dart index 9eefa17..c895b6f 100644 --- a/example/api_namespace.dart +++ b/example/api_namespace.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; diff --git a/example/api_network.dart b/example/api_network.dart index d52e74c..7914360 100644 --- a/example/api_network.dart +++ b/example/api_network.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; diff --git a/example/api_node.dart b/example/api_node.dart index 848af8a..75998dc 100644 --- a/example/api_node.dart +++ b/example/api_node.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; diff --git a/example/api_transactions.dart b/example/api_transactions.dart index 93ab89f..ab26400 100644 --- a/example/api_transactions.dart +++ b/example/api_transactions.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; void main() async { const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000'; @@ -13,7 +13,7 @@ void main() async { final client = SiriusClient.fromUrl(baseUrl); const hashOne = - 'B3543906F375F9259FC4687EAE644FF71982ED1AEA97E9AAF6D031B200DE849C'; + '8454782DB6B2BC5764A9EB74C8A7AE4A4024A83BBC7E37626663C21F5C7F5B8C'; const hashTwo = 'BF9B3AF29569A17B2FC72204A793A3984FB14022AD597D4D5E997D0965F97E02'; @@ -36,11 +36,16 @@ void main() async { print('Exception when calling Transaction->GetTransaction: $e\n'); } + final txnQueryParams = TransactionQueryParams() + ..embedded = true + ..signerPublicKey = + "785B6EDD55934391C4C0CBFCF5ECDCBC5104CB781178616A99167480418282BD"; + // Returns a [Transaction] information given a transactionId or hash. try { /// Get a transaction information given a transactionId or hash. final result = await client.transaction - .getTransactionsByGroup(TransactionGroupType.confirmed); + .getTransactionsByGroup(TransactionGroupType.confirmed, txnQueryParams); print(result); } on Exception catch (e) { print('Exception when calling Transaction->GetTransaction: $e\n'); diff --git a/example/example.dart b/example/example.dart deleted file mode 100644 index 8d4b7f7..0000000 --- a/example/example.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; - -/// Simple Account API AnnounceTransaction -void main() async { - const baseUrl = 'http://bctestnet2.brimstone.xpxsirius.io:3000'; - - /// Creating a client instance - /// xpx_chain_sdk uses the Dart's native HttpClient. - /// Depending on the platform, you may want to use either - /// the one which comes from dart:io or the BrowserClient - /// example: - /// 1- import 'package:http/browser_client.dart'; - /// 2- var client = newClient(config, BrowserClient()); - final client = SiriusClient.fromUrl(baseUrl, null); - - final generationHash = await client.generationHash; - - final networkType = await client.networkType; - - /// Create an Account from a given Private key. - final account = - Account.fromPrivateKey('6703EBF8E23AFE09DA34EA27DD0A75DCB8A237AB6DB89E7A8C7545FE4B5155E1', networkType); - - /// Create an Address from a given Public key. - final recipient = Address.fromRawAddress('VDI5IS-5YXT5G-LRT5RS-S3EZIB-4QOAI2-6GLWR2-TDK7'); - - /// Create a transaction type transfer - final tx = TransferTransaction( - // The maximum amount of time to include the transaction in the blockchain. - Deadline(hours: 1), - // The Address of the recipient account. - recipient, - // The List of mosaic to be sent. - [xpx(10)], - // The transaction message of 1024 characters. - PlainMessage(payload: 'Transfer from Dart sdk'), - networkType); - - final stx = account.signTransaction(tx, generationHash); - - try { - final restTx = await client.transaction.announce(stx); - print(restTx); - print('Hash: ${stx.hash}'); - print('Signer: ${account.publicAccount.publicKey}'); - } on Exception catch (e) { - print('Exception when calling Transaction->Announce: $e\n'); - } -} diff --git a/example/transactions/account_metadata_transaction.dart b/example/transactions/account_metadata_transaction.dart index 6606717..da63893 100644 --- a/example/transactions/account_metadata_transaction.dart +++ b/example/transactions/account_metadata_transaction.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; /// Simple Account API AnnounceTransaction void main() async { diff --git a/example/transactions/mosaic_definition_transaction.dart b/example/transactions/mosaic_definition_transaction.dart index 0df355d..1238d31 100644 --- a/example/transactions/mosaic_definition_transaction.dart +++ b/example/transactions/mosaic_definition_transaction.dart @@ -1,4 +1,4 @@ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; /// Simple Account API AnnounceTransaction void main() async { diff --git a/example/transactions/mosaic_metadata_transaction.dart b/example/transactions/mosaic_metadata_transaction.dart index cd78ed6..1bdc723 100644 --- a/example/transactions/mosaic_metadata_transaction.dart +++ b/example/transactions/mosaic_metadata_transaction.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; /// Simple Account API AnnounceTransaction void main() async { diff --git a/example/transactions/mosaic_supply_change_transaction.dart b/example/transactions/mosaic_supply_change_transaction.dart index a36fdd1..f924ff1 100644 --- a/example/transactions/mosaic_supply_change_transaction.dart +++ b/example/transactions/mosaic_supply_change_transaction.dart @@ -1,4 +1,4 @@ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; /// Simple Account API AnnounceTransaction void main() async { diff --git a/example/transactions/transfer_transaction.dart b/example/transactions/transfer_transaction.dart index 17948d2..126014d 100644 --- a/example/transactions/transfer_transaction.dart +++ b/example/transactions/transfer_transaction.dart @@ -1,4 +1,4 @@ -import 'package:xpx_chain_sdk/xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; /// Simple Account API AnnounceTransaction void main() async { diff --git a/example/xpx_chain_sdk.dart b/example/xpx_chain_sdk.dart new file mode 100644 index 0000000..ad0662b --- /dev/null +++ b/example/xpx_chain_sdk.dart @@ -0,0 +1,47 @@ +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; + +void main() async { + const privateKey = + 'B3543906F375F9259FC4687EAE644FF71982ED1AEA97E9AAF6D031B200DE849C'; + + /// Create an Account from a given Private key. + final accountOne = + await Account.fromPrivateKey(privateKey, NetworkType.PUBLIC_TEST); + print(accountOne); + + /// Create an random Account from a given networkType. + final accountTwo = await Account.random(NetworkType.PUBLIC_TEST); + print(accountTwo); + + const publicKey = + '9a6a4e41d2b69dfe899c0c34d56261059986340cf83fc597d4b6715ab9e77ac8'; + + /// Create an Account from a given publicKey hex string. + final publicAccount = + PublicAccount.fromPublicKey(publicKey, NetworkType.PUBLIC_TEST); + print(publicAccount); + + const rawAddress = 'VAQXZH7TDE6EMG7KIGJ5KPCHHAEDYK4VIMLZD7VK'; + + /// Creates an Sirius 'Address' from a given raw address string. + /// + /// A Sirius raw address string looks like: + /// * VAQXZH7TDE6EMG7KIGJ5KPCHHAEDYK4VIMLZD7VK or VAQXZH-7TDE6E-MG7KIG-J5KPCH-HAEDYK-4VIMLZ-D7VK. + final addressOne = Address.fromRawAddress(rawAddress); + print(addressOne); + + /// Create an [Address] from a given public key. + final addressTwo = Address.fromPublicKey(publicKey, NetworkType.PUBLIC_TEST); + print(addressTwo); + + const encodedAddress = 'A83850DF3301785F586F156D71879E870626093580406EBC5A'; + + /// Create an Symbol `Address` from the given hex string address + /// + /// A hex string address looks like: 908E2C873E8552039933562AFB74A193B48BDD300BEBDB93. + /// + /// * Before: A83850DF3301785F586F156D71879E870626093580406EBC5A + /// * After: VA4FBXZTAF4F6WDPCVWXDB46Q4DCMCJVQBAG5PC2 + final addressThree = Address.fromEncoded(encodedAddress); + print(addressThree); +} diff --git a/gen_schemas.sh b/gen_schemas.sh index 8103936..9dbe421 100755 --- a/gen_schemas.sh +++ b/gen_schemas.sh @@ -16,7 +16,7 @@ fi # Run `flatc`. Note: This requires you to compile using `cmake` from the # root `/flatbuffers` directory. if [ -e /usr/local/bin/flatc ]; then - flatc --no-warnings --gen-all --dart -o ../lib/imp/buffer/ --schema *.fbs + flatc --no-warnings --gen-all --dart -o ../lib/src/model/transaction/buffer/ --schema *.fbs else echo 'flatc' could not be found. Make sure to build FlatBuffers from the \ $rootdir directory. diff --git a/lib/imp/buffer.dart b/lib/imp/buffer.dart deleted file mode 100644 index 71fae55..0000000 --- a/lib/imp/buffer.dart +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 ProximaX Limited. All rights reserved. - * Use of this source code is governed by the Apache 2.0 - * license that can be found in the LICENSE file. - */ - -library xpx_chain_sdk.buffer; - -export 'buffer/schema_account_link_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_account_properties_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_aggregate_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_alias_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_exchange_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_harvester_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_modify_mosaic_levy_transactions_generated.dart'; -export 'buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_mosaic_remove_levy_transactions_generated.dart'; -export 'buffer/schema_mosaic_remove_levy_transactions_generated.dart'; -export 'buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_network_config_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_operation_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_storage_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_supercontract_transaction_catapult.buffers_generated.dart'; -export 'buffer/schema_transfer_transaction_catapult.buffers_generated.dart'; -export 'buffer/transactions_buffer.dart'; diff --git a/lib/imp/buffer/model.dart b/lib/imp/buffer/model.dart deleted file mode 100644 index 480f084..0000000 --- a/lib/imp/buffer/model.dart +++ /dev/null @@ -1,22 +0,0 @@ -library xpx_chain_sdk.buffer.model; - -import 'dart:typed_data'; - -import 'package:flat_buffers/flat_buffers.dart' as fb; - -part 'model/account_properties_transaction_buffer.dart'; -part 'model/aggregate_transaction_buffer.dart'; -part 'model/alias_transaction_buffer.dart'; -part 'model/exchange_transaction_buffer.dart'; -part 'model/lock_funds_transaction_buffer.dart'; -part 'model/modify_contract_transaction_buffer.dart'; -part 'model/modify_metadata_transaction_buffer.dart'; -part 'model/modify_multisig_account_transaction_buffer.dart'; -part 'model/mosaic_alias_transaction_buffer.dart'; -part 'model/mosaic_definition_transaction_buffer.dart'; -part 'model/mosaic_supply_change_transaction_buffer.dart'; -part 'model/register_namespace_transaction_buffer.dart'; -part 'model/secret_lock_transaction_buffer.dart'; -part 'model/secret_proof_transaction_buffer.dart'; -part 'model/transactions_buffer.dart'; -part 'model/transfer_transaction_buffer.dart'; diff --git a/lib/imp/buffer/model/account_properties_transaction_buffer.dart b/lib/imp/buffer/model/account_properties_transaction_buffer.dart deleted file mode 100644 index 01a0e55..0000000 --- a/lib/imp/buffer/model/account_properties_transaction_buffer.dart +++ /dev/null @@ -1,275 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class PropertyModificationBuffer { - factory PropertyModificationBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - PropertyModificationBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _PropertyModificationBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get modificationType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); - - /// In case of address it is 25 bytes array. In case of mosaic it is 8 byte array(or 2 uint32 array). - /// In case of transaction it is 2 byte array(ushort) - List get value => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - @override - String toString() => 'PropertyModificationBuffer{modificationType: $modificationType, value: $value}'; -} - -class _PropertyModificationBufferReader extends fb.TableReader { - const _PropertyModificationBufferReader(); - - @override - PropertyModificationBuffer createObject(fb.BufferContext bc, int offset) => PropertyModificationBuffer._(bc, offset); -} - -class PropertyModificationBufferBuilder { - PropertyModificationBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addModificationType(int modificationType) { - fbBuilder.addUint8(0, modificationType); - return fbBuilder.offset; - } - - int addValueOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class PropertyModificationBufferObjectBuilder extends fb.ObjectBuilder { - PropertyModificationBufferObjectBuilder({ - int modificationType, - List value, - }) : _modificationType = modificationType, - _value = value; - - final int _modificationType; - final List _value; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int valueOffset = _value?.isNotEmpty == true ? fbBuilder.writeListUint8(_value) : null; - - fbBuilder.startTable(); - fbBuilder.addUint8(0, _modificationType); - if (valueOffset != null) { - fbBuilder.addOffset(1, valueOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class AccountPropertiesTransactionBuffer { - factory AccountPropertiesTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - AccountPropertiesTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _AccountPropertiesTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get propertyType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - int get modificationCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0); - - List get modifications => - const fb.ListReader(PropertyModificationBuffer.reader) - .vTableGet(_bc, _bcOffset, 22, null); - - @override - String toString() => - 'AccountPropertiesTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, propertyType: $propertyType, modificationCount: $modificationCount, modifications: $modifications}'; -} - -class _AccountPropertiesTransactionBufferReader extends fb.TableReader { - const _AccountPropertiesTransactionBufferReader(); - - @override - AccountPropertiesTransactionBuffer createObject(fb.BufferContext bc, int offset) => - AccountPropertiesTransactionBuffer._(bc, offset); -} - -class AccountPropertiesTransactionBufferBuilder { - AccountPropertiesTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint32(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addPropertyType(int propertyType) { - fbBuilder.addUint8(7, propertyType); - return fbBuilder.offset; - } - - int addModificationCount(int modificationCount) { - fbBuilder.addUint8(8, modificationCount); - return fbBuilder.offset; - } - - int addModificationsOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class AccountPropertiesTransactionBufferObjectBuilder extends fb.ObjectBuilder { - AccountPropertiesTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - int propertyType, - int modificationCount, - List modifications, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _propertyType = propertyType, - _modificationCount = modificationCount, - _modifications = modifications; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final int _propertyType; - final int _modificationCount; - final List _modifications; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int modificationsOffset = _modifications?.isNotEmpty == true - ? fbBuilder.writeList(_modifications.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint32(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _propertyType); - fbBuilder.addUint8(8, _modificationCount); - if (modificationsOffset != null) { - fbBuilder.addOffset(9, modificationsOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/aggregate_transaction_buffer.dart b/lib/imp/buffer/model/aggregate_transaction_buffer.dart deleted file mode 100644 index a18dd41..0000000 --- a/lib/imp/buffer/model/aggregate_transaction_buffer.dart +++ /dev/null @@ -1,186 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class AggregateTransactionBuffer { - factory AggregateTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - AggregateTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _AggregateTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get transactionsSize => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get transactions => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 20, null); - - @override - String toString() => 'AggregateTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' transactionsSize: $transactionsSize,' - ' transactions: $transactions}'; -} - -class _AggregateTransactionBufferReader extends fb.TableReader { - const _AggregateTransactionBufferReader(); - - @override - AggregateTransactionBuffer createObject(fb.BufferContext bc, int offset) => AggregateTransactionBuffer._(bc, offset); -} - -class AggregateTransactionBufferBuilder { - AggregateTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addTransactionsSize(int transactionsSize) { - fbBuilder.addUint32(7, transactionsSize); - return fbBuilder.offset; - } - - int addTransactionsOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class AggregateTransactionBufferObjectBuilder extends fb.ObjectBuilder { - AggregateTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - int transactionsSize, - List transactions, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _transactionsSize = transactionsSize, - _transactions = transactions; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final int _transactionsSize; - final List _transactions; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int transactionsOffset = _transactions?.isNotEmpty == true ? fbBuilder.writeListUint8(_transactions) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - - fbBuilder.addUint32(7, _transactionsSize); - if (transactionsOffset != null) { - fbBuilder.addOffset(8, transactionsOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/alias_transaction_buffer.dart b/lib/imp/buffer/model/alias_transaction_buffer.dart deleted file mode 100644 index efe5870..0000000 --- a/lib/imp/buffer/model/alias_transaction_buffer.dart +++ /dev/null @@ -1,199 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class AliasTransactionBuffer { - factory AliasTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - AliasTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _AliasTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get actionType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get namespaceId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 20, null); - - /// In case of address it is 25 bytes array. In case of mosaic - /// it is 8 byte array(or 2 uint32 array) - List get aliasId => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 22, null); - - @override - String toString() => 'AliasTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' maxFee: $maxFee,' - ' deadline: $deadline,' - ' actionType: $actionType,' - ' namespaceId: $namespaceId,' - ' aliasId: $aliasId}'; -} - -class _AliasTransactionBufferReader extends fb.TableReader { - const _AliasTransactionBufferReader(); - - @override - AliasTransactionBuffer createObject(fb.BufferContext bc, int offset) => AliasTransactionBuffer._(bc, offset); -} - -class AliasTransactionBufferBuilder { - AliasTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addActionType(int actionType) { - fbBuilder.addUint8(7, actionType); - return fbBuilder.offset; - } - - int addNamespaceIdOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addAliasIdOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class AliasTransactionBufferObjectBuilder extends fb.ObjectBuilder { - AliasTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - int actionType, - List namespaceId, - List aliasId, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _actionType = actionType, - _namespaceId = namespaceId, - _aliasId = aliasId; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final int _actionType; - final List _namespaceId; - final List _aliasId; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int namespaceIdOffset = _namespaceId?.isNotEmpty == true ? fbBuilder.writeListUint32(_namespaceId) : null; - final int aliasIdOffset = _aliasId?.isNotEmpty == true ? fbBuilder.writeListUint8(_aliasId) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _actionType); - if (namespaceIdOffset != null) { - fbBuilder.addOffset(8, namespaceIdOffset); - } - if (aliasIdOffset != null) { - fbBuilder.addOffset(9, aliasIdOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/exchange_transaction_buffer.dart b/lib/imp/buffer/model/exchange_transaction_buffer.dart deleted file mode 100644 index 0a25bf0..0000000 --- a/lib/imp/buffer/model/exchange_transaction_buffer.dart +++ /dev/null @@ -1,868 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class AddExchangeOfferTransactionBuffer { - factory AddExchangeOfferTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - AddExchangeOfferTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _AddExchangeOfferTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get offersCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get offers => - const fb.ListReader(AddExchangeOfferBuffer.reader).vTableGet(_bc, _bcOffset, 20, null); - - @override - String toString() => - 'AddExchangeOfferTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, offersCount: $offersCount, offers: $offers}'; -} - -class _AddExchangeOfferTransactionBufferReader extends fb.TableReader { - const _AddExchangeOfferTransactionBufferReader(); - - @override - AddExchangeOfferTransactionBuffer createObject(fb.BufferContext bc, int offset) => - AddExchangeOfferTransactionBuffer._(bc, offset); -} - -class AddExchangeOfferTransactionBufferBuilder { - AddExchangeOfferTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint32(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addOffersCount(int offersCount) { - fbBuilder.addUint8(7, offersCount); - return fbBuilder.offset; - } - - int addOffersOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class AddExchangeOfferTransactionBufferObjectBuilder extends fb.ObjectBuilder { - AddExchangeOfferTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - int offersCount, - List offers, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _offersCount = offersCount, - _offers = offers; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final int _offersCount; - final List _offers; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int offersOffset = _offers?.isNotEmpty == true - ? fbBuilder.writeList(_offers.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint32(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _offersCount); - if (offersOffset != null) { - fbBuilder.addOffset(8, offersOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class ExchangeOfferTransactionBuffer { - factory ExchangeOfferTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - ExchangeOfferTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _ExchangeOfferTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get offersCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get offers => - const fb.ListReader(ExchangeOfferBuffer.reader).vTableGet(_bc, _bcOffset, 20, null); - - @override - String toString() => - 'ExchangeOfferTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, offersCount: $offersCount, offers: $offers}'; -} - -class _ExchangeOfferTransactionBufferReader extends fb.TableReader { - const _ExchangeOfferTransactionBufferReader(); - - @override - ExchangeOfferTransactionBuffer createObject(fb.BufferContext bc, int offset) => - ExchangeOfferTransactionBuffer._(bc, offset); -} - -class ExchangeOfferTransactionBufferBuilder { - ExchangeOfferTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint32(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addOffersCount(int offersCount) { - fbBuilder.addUint8(7, offersCount); - return fbBuilder.offset; - } - - int addOffersOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class ExchangeOfferTransactionBufferObjectBuilder extends fb.ObjectBuilder { - ExchangeOfferTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - int offersCount, - List offers, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _offersCount = offersCount, - _offers = offers; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final int _offersCount; - final List _offers; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int offersOffset = _offers?.isNotEmpty == true - ? fbBuilder.writeList(_offers.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint32(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _offersCount); - if (offersOffset != null) { - fbBuilder.addOffset(8, offersOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class RemoveExchangeOfferTransactionBuffer { - factory RemoveExchangeOfferTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - RemoveExchangeOfferTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _RemoveExchangeOfferTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get offersCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get offers => - const fb.ListReader(RemoveExchangeOfferBuffer.reader) - .vTableGet(_bc, _bcOffset, 20, null); - - @override - String toString() => - 'RemoveExchangeOfferTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, offersCount: $offersCount, offers: $offers}'; -} - -class _RemoveExchangeOfferTransactionBufferReader extends fb.TableReader { - const _RemoveExchangeOfferTransactionBufferReader(); - - @override - RemoveExchangeOfferTransactionBuffer createObject(fb.BufferContext bc, int offset) => - RemoveExchangeOfferTransactionBuffer._(bc, offset); -} - -class RemoveExchangeOfferTransactionBufferBuilder { - RemoveExchangeOfferTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint32(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addOffersCount(int offersCount) { - fbBuilder.addUint8(7, offersCount); - return fbBuilder.offset; - } - - int addOffersOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class RemoveExchangeOfferTransactionBufferObjectBuilder extends fb.ObjectBuilder { - RemoveExchangeOfferTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - int offersCount, - List offers, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _offersCount = offersCount, - _offers = offers; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final int _offersCount; - final List _offers; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int offersOffset = _offers?.isNotEmpty == true - ? fbBuilder.writeList(_offers.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint32(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _offersCount); - if (offersOffset != null) { - fbBuilder.addOffset(8, offersOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class AddExchangeOfferBuffer { - factory AddExchangeOfferBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - AddExchangeOfferBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _AddExchangeOfferBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 4, null); - - List get mosaicAmount => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get cost => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 10, 0); - - List get duration => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 12, null); - - @override - String toString() => - 'AddExchangeOfferBuffer{mosaicId: $mosaicId, mosaicAmount: $mosaicAmount, cost: $cost, type: $type, duration: $duration}'; -} - -class _AddExchangeOfferBufferReader extends fb.TableReader { - const _AddExchangeOfferBufferReader(); - - @override - AddExchangeOfferBuffer createObject(fb.BufferContext bc, int offset) => AddExchangeOfferBuffer._(bc, offset); -} - -class AddExchangeOfferBufferBuilder { - AddExchangeOfferBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(0, offset); - return fbBuilder.offset; - } - - int addMosaicAmountOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addCostOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint8(3, type); - return fbBuilder.offset; - } - - int addDurationOffset(int offset) { - fbBuilder.addOffset(4, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class AddExchangeOfferBufferObjectBuilder extends fb.ObjectBuilder { - AddExchangeOfferBufferObjectBuilder({ - List mosaicId, - List mosaicAmount, - List cost, - int type, - List duration, - }) : _mosaicId = mosaicId, - _mosaicAmount = mosaicAmount, - _cost = cost, - _type = type, - _duration = duration; - - final List _mosaicId; - final List _mosaicAmount; - final List _cost; - final int _type; - final List _duration; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - final int mosaicAmountOffset = _mosaicAmount?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicAmount) : null; - final int costOffset = _cost?.isNotEmpty == true ? fbBuilder.writeListUint32(_cost) : null; - final int durationOffset = _duration?.isNotEmpty == true ? fbBuilder.writeListUint32(_duration) : null; - - fbBuilder.startTable(); - if (mosaicIdOffset != null) { - fbBuilder.addOffset(0, mosaicIdOffset); - } - if (mosaicAmountOffset != null) { - fbBuilder.addOffset(1, mosaicAmountOffset); - } - if (costOffset != null) { - fbBuilder.addOffset(2, costOffset); - } - fbBuilder.addUint8(3, _type); - if (durationOffset != null) { - fbBuilder.addOffset(4, durationOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class ExchangeOfferBuffer { - factory ExchangeOfferBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - ExchangeOfferBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _ExchangeOfferBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 4, null); - - List get mosaicAmount => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get cost => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 10, 0); - - List get owner => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 12, null); - - @override - String toString() => - 'ExchangeOfferBuffer{mosaicId: $mosaicId, mosaicAmount: $mosaicAmount, cost: $cost, type: $type, owner: $owner}'; -} - -class _ExchangeOfferBufferReader extends fb.TableReader { - const _ExchangeOfferBufferReader(); - - @override - ExchangeOfferBuffer createObject(fb.BufferContext bc, int offset) => ExchangeOfferBuffer._(bc, offset); -} - -class ExchangeOfferBufferBuilder { - ExchangeOfferBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(0, offset); - return fbBuilder.offset; - } - - int addMosaicAmountOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addCostOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint8(3, type); - return fbBuilder.offset; - } - - int addOwnerOffset(int offset) { - fbBuilder.addOffset(4, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class ExchangeOfferBufferObjectBuilder extends fb.ObjectBuilder { - ExchangeOfferBufferObjectBuilder({ - List mosaicId, - List mosaicAmount, - List cost, - int type, - List owner, - }) : _mosaicId = mosaicId, - _mosaicAmount = mosaicAmount, - _cost = cost, - _type = type, - _owner = owner; - - final List _mosaicId; - final List _mosaicAmount; - final List _cost; - final int _type; - final List _owner; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - final int mosaicAmountOffset = _mosaicAmount?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicAmount) : null; - final int costOffset = _cost?.isNotEmpty == true ? fbBuilder.writeListUint32(_cost) : null; - final int ownerOffset = _owner?.isNotEmpty == true ? fbBuilder.writeListUint8(_owner) : null; - - fbBuilder.startTable(); - if (mosaicIdOffset != null) { - fbBuilder.addOffset(0, mosaicIdOffset); - } - if (mosaicAmountOffset != null) { - fbBuilder.addOffset(1, mosaicAmountOffset); - } - if (costOffset != null) { - fbBuilder.addOffset(2, costOffset); - } - fbBuilder.addUint8(3, _type); - if (ownerOffset != null) { - fbBuilder.addOffset(4, ownerOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class RemoveExchangeOfferBuffer { - factory RemoveExchangeOfferBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - RemoveExchangeOfferBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _RemoveExchangeOfferBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 4, null); - - int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 6, 0); - - @override - String toString() => 'RemoveExchangeOfferBuffer{mosaicId: $mosaicId, type: $type}'; -} - -class _RemoveExchangeOfferBufferReader extends fb.TableReader { - const _RemoveExchangeOfferBufferReader(); - - @override - RemoveExchangeOfferBuffer createObject(fb.BufferContext bc, int offset) => RemoveExchangeOfferBuffer._(bc, offset); -} - -class RemoveExchangeOfferBufferBuilder { - RemoveExchangeOfferBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(0, offset); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint8(1, type); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class RemoveExchangeOfferBufferObjectBuilder extends fb.ObjectBuilder { - RemoveExchangeOfferBufferObjectBuilder({ - List mosaicId, - int type, - }) : _mosaicId = mosaicId, - _type = type; - - final List _mosaicId; - final int _type; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - - fbBuilder.startTable(); - if (mosaicIdOffset != null) { - fbBuilder.addOffset(0, mosaicIdOffset); - } - fbBuilder.addUint8(1, _type); - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/lock_funds_transaction_buffer.dart b/lib/imp/buffer/model/lock_funds_transaction_buffer.dart deleted file mode 100644 index 881067a..0000000 --- a/lib/imp/buffer/model/lock_funds_transaction_buffer.dart +++ /dev/null @@ -1,215 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class LockFundsTransactionBuffer { - factory LockFundsTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - LockFundsTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _LockFundsTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 18, null); - - List get mosaicAmount => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 20, null); - - List get duration => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 22, null); - - List get hash => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 24, null); - - @override - String toString() => 'LockFundsTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' mosaicId: $mosaicId,' - ' mosaicAmount: $mosaicAmount,' - ' duration: $duration,' - ' hash: $hash}'; -} - -class _LockFundsTransactionBufferReader extends fb.TableReader { - const _LockFundsTransactionBufferReader(); - - @override - LockFundsTransactionBuffer createObject(fb.BufferContext bc, int offset) => LockFundsTransactionBuffer._(bc, offset); -} - -class LockFundsTransactionBufferBuilder { - LockFundsTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(7, offset); - return fbBuilder.offset; - } - - int addMosaicAmountOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addDurationOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int addHashOffset(int offset) { - fbBuilder.addOffset(10, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class LockFundsTransactionBufferObjectBuilder extends fb.ObjectBuilder { - LockFundsTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - List mosaicId, - List mosaicAmount, - List duration, - List hash, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _mosaicId = mosaicId, - _mosaicAmount = mosaicAmount, - _duration = duration, - _hash = hash; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final List _mosaicId; - final List _mosaicAmount; - final List _duration; - final List _hash; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - final int mosaicAmountOffset = _mosaicAmount?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicAmount) : null; - final int durationOffset = _duration?.isNotEmpty == true ? fbBuilder.writeListUint32(_duration) : null; - final int hashOffset = _hash?.isNotEmpty == true ? fbBuilder.writeListUint8(_hash) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - if (mosaicIdOffset != null) { - fbBuilder.addOffset(7, mosaicIdOffset); - } - if (mosaicAmountOffset != null) { - fbBuilder.addOffset(8, mosaicAmountOffset); - } - if (durationOffset != null) { - fbBuilder.addOffset(9, durationOffset); - } - if (hashOffset != null) { - fbBuilder.addOffset(10, hashOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/modify_contract_transaction_buffer.dart b/lib/imp/buffer/model/modify_contract_transaction_buffer.dart deleted file mode 100644 index 7d9be7a..0000000 --- a/lib/imp/buffer/model/modify_contract_transaction_buffer.dart +++ /dev/null @@ -1,367 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class CosignatoryModificationBuffer { - factory CosignatoryModificationBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - CosignatoryModificationBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _CosignatoryModificationBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get cosignatoryPublicKey => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - @override - String toString() => 'CosignatoryModificationBuffer{' - 'type: $type,' - ' cosignatoryPublicKey: $cosignatoryPublicKey}'; -} - -class _CosignatoryModificationBufferReader extends fb.TableReader { - const _CosignatoryModificationBufferReader(); - - @override - CosignatoryModificationBuffer createObject(fb.BufferContext bc, int offset) => - CosignatoryModificationBuffer._(bc, offset); -} - -class CosignatoryModificationBufferBuilder { - CosignatoryModificationBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addType(int type) { - fbBuilder.addUint8(0, type); - return fbBuilder.offset; - } - - int addCosignatoryPublicKeyOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class CosignatoryModificationBufferObjectBuilder extends fb.ObjectBuilder { - CosignatoryModificationBufferObjectBuilder({ - int type, - List cosignatoryPublicKey, - }) : _type = type, - _cosignatoryPublicKey = cosignatoryPublicKey; - - final int _type; - final List _cosignatoryPublicKey; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int cosignatoryPublicKeyOffset = - _cosignatoryPublicKey?.isNotEmpty == true ? fbBuilder.writeListUint8(_cosignatoryPublicKey) : null; - - fbBuilder.startTable(); - fbBuilder.addUint8(0, _type); - if (cosignatoryPublicKeyOffset != null) { - fbBuilder.addOffset(1, cosignatoryPublicKeyOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class ModifyContractTransactionBuffer { - factory ModifyContractTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - ModifyContractTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _ModifyContractTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - List get durationDelta => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 18, null); - - List get hash => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 20, null); - - int get numCustomers => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); - - int get numExecutors => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); - - int get numVerifiers => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 26, 0); - - List get customers => - const fb.ListReader(CosignatoryModificationBuffer.reader) - .vTableGet(_bc, _bcOffset, 28, null); - - List get executors => - const fb.ListReader(CosignatoryModificationBuffer.reader) - .vTableGet(_bc, _bcOffset, 30, null); - - List get verifiers => - const fb.ListReader(CosignatoryModificationBuffer.reader) - .vTableGet(_bc, _bcOffset, 32, null); - - @override - String toString() => 'ModifyContractTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' durationDelta: $durationDelta,' - ' hash: $hash,' - ' numCustomers: $numCustomers,' - ' numExecutors: $numExecutors,' - ' numVerifiers: $numVerifiers,' - ' customers: $customers,' - ' executors: $executors,' - ' verifiers: $verifiers}'; -} - -class _ModifyContractTransactionBufferReader extends fb.TableReader { - const _ModifyContractTransactionBufferReader(); - - @override - ModifyContractTransactionBuffer createObject(fb.BufferContext bc, int offset) => - ModifyContractTransactionBuffer._(bc, offset); -} - -class ModifyContractTransactionBufferBuilder { - ModifyContractTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addDurationDeltaOffset(int offset) { - fbBuilder.addOffset(7, offset); - return fbBuilder.offset; - } - - int addHashOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addNumCustomers(int numCustomers) { - fbBuilder.addUint8(9, numCustomers); - return fbBuilder.offset; - } - - int addNumExecutors(int numExecutors) { - fbBuilder.addUint8(10, numExecutors); - return fbBuilder.offset; - } - - int addNumVerifiers(int numVerifiers) { - fbBuilder.addUint8(11, numVerifiers); - return fbBuilder.offset; - } - - int addCustomersOffset(int offset) { - fbBuilder.addOffset(12, offset); - return fbBuilder.offset; - } - - int addExecutorsOffset(int offset) { - fbBuilder.addOffset(13, offset); - return fbBuilder.offset; - } - - int addVerifiersOffset(int offset) { - fbBuilder.addOffset(14, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class ModifyContractTransactionBufferObjectBuilder extends fb.ObjectBuilder { - ModifyContractTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - List durationDelta, - List hash, - int numCustomers, - int numExecutors, - int numVerifiers, - List customers, - List executors, - List verifiers, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _durationDelta = durationDelta, - _hash = hash, - _numCustomers = numCustomers, - _numExecutors = numExecutors, - _numVerifiers = numVerifiers, - _customers = customers, - _executors = executors, - _verifiers = verifiers; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final List _durationDelta; - final List _hash; - final int _numCustomers; - final int _numExecutors; - final int _numVerifiers; - final List _customers; - final List _executors; - final List _verifiers; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int durationDeltaOffset = - _durationDelta?.isNotEmpty == true ? fbBuilder.writeListUint32(_durationDelta) : null; - final int hashOffset = _hash?.isNotEmpty == true ? fbBuilder.writeListUint8(_hash) : null; - final int customersOffset = _customers?.isNotEmpty == true - ? fbBuilder.writeList(_customers.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - final int executorsOffset = _executors?.isNotEmpty == true - ? fbBuilder.writeList(_executors.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - final int verifiersOffset = _verifiers?.isNotEmpty == true - ? fbBuilder.writeList(_verifiers.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - if (durationDeltaOffset != null) { - fbBuilder.addOffset(7, durationDeltaOffset); - } - if (hashOffset != null) { - fbBuilder.addOffset(8, hashOffset); - } - fbBuilder.addUint8(9, _numCustomers); - fbBuilder.addUint8(10, _numExecutors); - fbBuilder.addUint8(11, _numVerifiers); - if (customersOffset != null) { - fbBuilder.addOffset(12, customersOffset); - } - if (executorsOffset != null) { - fbBuilder.addOffset(13, executorsOffset); - } - if (verifiersOffset != null) { - fbBuilder.addOffset(14, verifiersOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/modify_metadata_transaction_buffer.dart b/lib/imp/buffer/model/modify_metadata_transaction_buffer.dart deleted file mode 100644 index 7b9aacd..0000000 --- a/lib/imp/buffer/model/modify_metadata_transaction_buffer.dart +++ /dev/null @@ -1,340 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class MetadataModificationBuffer { - factory MetadataModificationBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MetadataModificationBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _MetadataModificationBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - int get modificationType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 6, 0); - - int get keySize => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 8, 0); - - List get valueSize => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 10, null); - - List get key => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 12, null); - - List get value => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 14, null); - - @override - String toString() => 'MetadataModificationBuffer{' - 'size: $size,' - ' modificationType: $modificationType,' - ' keySize: $keySize,' - ' valueSize: $valueSize,' - ' key: $key,' - ' value: $value}'; -} - -class _MetadataModificationBufferReader extends fb.TableReader { - const _MetadataModificationBufferReader(); - - @override - MetadataModificationBuffer createObject(fb.BufferContext bc, int offset) => MetadataModificationBuffer._(bc, offset); -} - -class MetadataModificationBufferBuilder { - MetadataModificationBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addModificationType(int modificationType) { - fbBuilder.addUint8(1, modificationType); - return fbBuilder.offset; - } - - int addKeySize(int keySize) { - fbBuilder.addUint8(2, keySize); - return fbBuilder.offset; - } - - int addValueSizeOffset(int offset) { - fbBuilder.addOffset(3, offset); - return fbBuilder.offset; - } - - int addKeyOffset(int offset) { - fbBuilder.addOffset(4, offset); - return fbBuilder.offset; - } - - int addValueOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MetadataModificationBufferObjectBuilder extends fb.ObjectBuilder { - MetadataModificationBufferObjectBuilder({ - int size, - int modificationType, - int keySize, - List valueSize, - List key, - List value, - }) : _size = size, - _modificationType = modificationType, - _keySize = keySize, - _valueSize = valueSize, - _key = key, - _value = value; - - final int _size; - final int _modificationType; - final int _keySize; - final List _valueSize; - final List _key; - final List _value; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int valueSizeOffset = _valueSize?.isNotEmpty == true ? fbBuilder.writeListUint8(_valueSize) : null; - final int keyOffset = _key?.isNotEmpty == true ? fbBuilder.writeListUint8(_key) : null; - final int valueOffset = _value?.isNotEmpty == true ? fbBuilder.writeListUint8(_value) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - fbBuilder.addUint8(1, _modificationType); - fbBuilder.addUint8(2, _keySize); - if (valueSizeOffset != null) { - fbBuilder.addOffset(3, valueSizeOffset); - } - if (keyOffset != null) { - fbBuilder.addOffset(4, keyOffset); - } - if (valueOffset != null) { - fbBuilder.addOffset(5, valueOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class ModifyMetadataTransactionBuffer { - factory ModifyMetadataTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - ModifyMetadataTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _ModifyMetadataTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get metadataType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get metadataId => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 20, null); - - List get modifications => - const fb.ListReader(MetadataModificationBuffer.reader) - .vTableGet(_bc, _bcOffset, 22, null); - - @override - String toString() => 'ModifyMetadataTransactionBuffer{size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' metadataType: $metadataType,' - ' metadataId: $metadataId,' - ' modifications: $modifications}'; -} - -class _ModifyMetadataTransactionBufferReader extends fb.TableReader { - const _ModifyMetadataTransactionBufferReader(); - - @override - ModifyMetadataTransactionBuffer createObject(fb.BufferContext bc, int offset) => - ModifyMetadataTransactionBuffer._(bc, offset); -} - -class ModifyMetadataTransactionBufferBuilder { - ModifyMetadataTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addMetadataType(int metadataType) { - fbBuilder.addUint8(7, metadataType); - return fbBuilder.offset; - } - - int addMetadataIdOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addModificationsOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class ModifyMetadataTransactionBufferObjectBuilder extends fb.ObjectBuilder { - ModifyMetadataTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - int metadataType, - List metadataId, - List modifications, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _metadataType = metadataType, - _metadataId = metadataId, - _modifications = modifications; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final int _metadataType; - final List _metadataId; - final List _modifications; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int metadataIdOffset = _metadataId?.isNotEmpty == true ? fbBuilder.writeListUint8(_metadataId) : null; - final int modificationsOffset = _modifications?.isNotEmpty == true - ? fbBuilder.writeList(_modifications.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _metadataType); - if (metadataIdOffset != null) { - fbBuilder.addOffset(8, metadataIdOffset); - } - if (modificationsOffset != null) { - fbBuilder.addOffset(9, modificationsOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/modify_multisig_account_transaction_buffer.dart b/lib/imp/buffer/model/modify_multisig_account_transaction_buffer.dart deleted file mode 100644 index 5e8da97..0000000 --- a/lib/imp/buffer/model/modify_multisig_account_transaction_buffer.dart +++ /dev/null @@ -1,213 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class ModifyMultisigAccountTransactionBuffer { - factory ModifyMultisigAccountTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - ModifyMultisigAccountTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = - _ModifyMultisigAccountTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get minRemovalDelta => const fb.Int8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - int get minApprovalDelta => const fb.Int8Reader().vTableGet(_bc, _bcOffset, 20, 0); - - int get numModifications => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); - - List get modifications => - const fb.ListReader(CosignatoryModificationBuffer.reader) - .vTableGet(_bc, _bcOffset, 24, null); - - @override - String toString() => 'ModifyMultisigAccountTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' minRemovalDelta: $minRemovalDelta,' - ' minApprovalDelta: $minApprovalDelta,' - ' numModifications: $numModifications,' - ' modifications: $modifications}'; -} - -class _ModifyMultisigAccountTransactionBufferReader extends fb.TableReader { - const _ModifyMultisigAccountTransactionBufferReader(); - - @override - ModifyMultisigAccountTransactionBuffer createObject(fb.BufferContext bc, int offset) => - ModifyMultisigAccountTransactionBuffer._(bc, offset); -} - -class ModifyMultisigAccountTransactionBufferBuilder { - ModifyMultisigAccountTransactionBufferBuilder(this.fbBuilder) - : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addMinRemovalDelta(int minRemovalDelta) { - fbBuilder.addInt8(7, minRemovalDelta); - return fbBuilder.offset; - } - - int addMinApprovalDelta(int minApprovalDelta) { - fbBuilder.addInt8(8, minApprovalDelta); - return fbBuilder.offset; - } - - int addNumModifications(int numModifications) { - fbBuilder.addUint8(9, numModifications); - return fbBuilder.offset; - } - - int addModificationsOffset(int offset) { - fbBuilder.addOffset(10, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class ModifyMultisigAccountTransactionBufferObjectBuilder extends fb.ObjectBuilder { - ModifyMultisigAccountTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - int minRemovalDelta, - int minApprovalDelta, - int numModifications, - List modifications, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _minRemovalDelta = minRemovalDelta, - _minApprovalDelta = minApprovalDelta, - _numModifications = numModifications, - _modifications = modifications; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final int _minRemovalDelta; - final int _minApprovalDelta; - final int _numModifications; - final List _modifications; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int modificationsOffset = _modifications?.isNotEmpty == true - ? fbBuilder.writeList(_modifications.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addInt8(7, _minRemovalDelta); - fbBuilder.addInt8(8, _minApprovalDelta); - fbBuilder.addUint8(9, _numModifications); - if (modificationsOffset != null) { - fbBuilder.addOffset(10, modificationsOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/mosaic_alias_transaction_buffer.dart b/lib/imp/buffer/model/mosaic_alias_transaction_buffer.dart deleted file mode 100644 index c81578f..0000000 --- a/lib/imp/buffer/model/mosaic_alias_transaction_buffer.dart +++ /dev/null @@ -1,199 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class MosaicAliasDefinitionTransactionBuffer { - factory MosaicAliasDefinitionTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MosaicAliasDefinitionTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = - _MosaicAliasDefinitionTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - List get namespaceId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 18, null); - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 20, null); - - int get aliasAction => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); - - @override - String toString() => 'MosaicAliasDefinitionTransactionBuffer{size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' namespaceId: $namespaceId,' - ' mosaicId: $mosaicId,' - ' aliasAction: $aliasAction}'; -} - -class _MosaicAliasDefinitionTransactionBufferReader extends fb.TableReader { - const _MosaicAliasDefinitionTransactionBufferReader(); - - @override - MosaicAliasDefinitionTransactionBuffer createObject(fb.BufferContext bc, int offset) => - MosaicAliasDefinitionTransactionBuffer._(bc, offset); -} - -class MosaicAliasDefinitionTransactionBufferBuilder { - MosaicAliasDefinitionTransactionBufferBuilder(this.fbBuilder) - : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addNamespaceIdOffset(int offset) { - fbBuilder.addOffset(7, offset); - return fbBuilder.offset; - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addAliasAction(int aliasAction) { - fbBuilder.addUint8(9, aliasAction); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MosaicAliasDefinitionTransactionBufferObjectBuilder extends fb.ObjectBuilder { - MosaicAliasDefinitionTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - List namespaceId, - List mosaicId, - int aliasAction, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _namespaceId = namespaceId, - _mosaicId = mosaicId, - _aliasAction = aliasAction; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final List _namespaceId; - final List _mosaicId; - final int _aliasAction; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int namespaceIdOffset = _namespaceId?.isNotEmpty == true ? fbBuilder.writeListUint32(_namespaceId) : null; - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - if (namespaceIdOffset != null) { - fbBuilder.addOffset(7, namespaceIdOffset); - } - if (mosaicIdOffset != null) { - fbBuilder.addOffset(8, mosaicIdOffset); - } - fbBuilder.addUint8(9, _aliasAction); - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/mosaic_definition_transaction_buffer.dart b/lib/imp/buffer/model/mosaic_definition_transaction_buffer.dart deleted file mode 100644 index 703cd48..0000000 --- a/lib/imp/buffer/model/mosaic_definition_transaction_buffer.dart +++ /dev/null @@ -1,308 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class MosaicPropertyB { - factory MosaicPropertyB(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MosaicPropertyB._(this._bc, this._bcOffset); - - static const fb.Reader reader = _MosaicPropertyReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get mosaicPropertyId => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get value => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 6, null); - - @override - String toString() => 'MosaicProperty{mosaicPropertyId: $mosaicPropertyId, value: $value}'; -} - -class _MosaicPropertyReader extends fb.TableReader { - const _MosaicPropertyReader(); - - @override - MosaicPropertyB createObject(fb.BufferContext bc, int offset) => MosaicPropertyB._(bc, offset); -} - -class MosaicPropertyBuilder { - MosaicPropertyBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addMosaicPropertyId(int mosaicPropertyId) { - fbBuilder.addUint8(0, mosaicPropertyId); - return fbBuilder.offset; - } - - int addValueOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MosaicPropertyObjectBuilder extends fb.ObjectBuilder { - MosaicPropertyObjectBuilder({ - int mosaicPropertyId, - List value, - }) : _mosaicPropertyId = mosaicPropertyId, - _value = value; - - final int _mosaicPropertyId; - final List _value; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int valueOffset = _value?.isNotEmpty == true ? fbBuilder.writeListUint32(_value) : null; - - fbBuilder.startTable(); - fbBuilder.addUint8(0, _mosaicPropertyId); - if (valueOffset != null) { - fbBuilder.addOffset(1, valueOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class MosaicDefinitionTransactionBuffer { - factory MosaicDefinitionTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MosaicDefinitionTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _MosaicDefinitionTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get mosaicNonce => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 20, null); - - int get numOptionalProperties => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); - - int get flags => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); - - int get divisibility => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 26, 0); - - List get optionalProperties => - const fb.ListReader(MosaicPropertyB.reader).vTableGet(_bc, _bcOffset, 28, null); - - @override - String toString() => - 'MosaicDefinitionTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, mosaicNonce: $mosaicNonce, mosaicId: $mosaicId, numOptionalProperties: $numOptionalProperties, flags: $flags, divisibility: $divisibility, optionalProperties: $optionalProperties}'; -} - -class _MosaicDefinitionTransactionBufferReader extends fb.TableReader { - const _MosaicDefinitionTransactionBufferReader(); - - @override - MosaicDefinitionTransactionBuffer createObject(fb.BufferContext bc, int offset) => - MosaicDefinitionTransactionBuffer._(bc, offset); -} - -class MosaicDefinitionTransactionBufferBuilder { - MosaicDefinitionTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addMosaicNonce(int mosaicNonce) { - fbBuilder.addUint32(7, mosaicNonce); - return fbBuilder.offset; - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addNumOptionalProperties(int numOptionalProperties) { - fbBuilder.addUint8(9, numOptionalProperties); - return fbBuilder.offset; - } - - int addFlags(int flags) { - fbBuilder.addUint8(10, flags); - return fbBuilder.offset; - } - - int addDivisibility(int divisibility) { - fbBuilder.addUint8(11, divisibility); - return fbBuilder.offset; - } - - int addOptionalPropertiesOffset(int offset) { - fbBuilder.addOffset(12, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MosaicDefinitionTransactionBufferObjectBuilder extends fb.ObjectBuilder { - MosaicDefinitionTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - int mosaicNonce, - List mosaicId, - int numOptionalProperties, - int flags, - int divisibility, - List optionalProperties, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _mosaicNonce = mosaicNonce, - _mosaicId = mosaicId, - _numOptionalProperties = numOptionalProperties, - _flags = flags, - _divisibility = divisibility, - _optionalProperties = optionalProperties; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final int _mosaicNonce; - final List _mosaicId; - final int _numOptionalProperties; - final int _flags; - final int _divisibility; - final List _optionalProperties; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - final int optionalPropertiesOffset = _optionalProperties?.isNotEmpty == true - ? fbBuilder.writeList(_optionalProperties.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint32(7, _mosaicNonce); - if (mosaicIdOffset != null) { - fbBuilder.addOffset(8, mosaicIdOffset); - } - fbBuilder.addUint8(9, _numOptionalProperties); - fbBuilder.addUint8(10, _flags); - fbBuilder.addUint8(11, _divisibility); - if (optionalPropertiesOffset != null) { - fbBuilder.addOffset(12, optionalPropertiesOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/mosaic_supply_change_transaction_buffer.dart b/lib/imp/buffer/model/mosaic_supply_change_transaction_buffer.dart deleted file mode 100644 index 6ecf46d..0000000 --- a/lib/imp/buffer/model/mosaic_supply_change_transaction_buffer.dart +++ /dev/null @@ -1,198 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class MosaicSupplyChangeTransactionBuffer { - factory MosaicSupplyChangeTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MosaicSupplyChangeTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _MosaicSupplyChangeTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 18, null); - - int get direction => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0); - - List get delta => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 22, null); - - @override - String toString() => 'MosaicSupplyChangeTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' mosaicId: $mosaicId,' - ' direction: $direction,' - ' delta: $delta}'; -} - -class _MosaicSupplyChangeTransactionBufferReader extends fb.TableReader { - const _MosaicSupplyChangeTransactionBufferReader(); - - @override - MosaicSupplyChangeTransactionBuffer createObject(fb.BufferContext bc, int offset) => - MosaicSupplyChangeTransactionBuffer._(bc, offset); -} - -class MosaicSupplyChangeTransactionBufferBuilder { - MosaicSupplyChangeTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(7, offset); - return fbBuilder.offset; - } - - int addDirection(int direction) { - fbBuilder.addUint8(8, direction); - return fbBuilder.offset; - } - - int addDeltaOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MosaicSupplyChangeTransactionBufferObjectBuilder extends fb.ObjectBuilder { - MosaicSupplyChangeTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - List mosaicId, - int direction, - List delta, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _mosaicId = mosaicId, - _direction = direction, - _delta = delta; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final List _mosaicId; - final int _direction; - final List _delta; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - final int deltaOffset = _delta?.isNotEmpty == true ? fbBuilder.writeListUint32(_delta) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - if (mosaicIdOffset != null) { - fbBuilder.addOffset(7, mosaicIdOffset); - } - fbBuilder.addUint8(8, _direction); - if (deltaOffset != null) { - fbBuilder.addOffset(9, deltaOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/register_namespace_transaction_buffer.dart b/lib/imp/buffer/model/register_namespace_transaction_buffer.dart deleted file mode 100644 index 4ef03d7..0000000 --- a/lib/imp/buffer/model/register_namespace_transaction_buffer.dart +++ /dev/null @@ -1,226 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class RegisterNamespaceTransactionBuffer { - factory RegisterNamespaceTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - RegisterNamespaceTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _RegisterNamespaceTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get namespaceType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get durationParentId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 20, null); - - List get namespaceId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 22, null); - - int get namespaceNameSize => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); - - String get namespaceName => const fb.StringReader().vTableGet(_bc, _bcOffset, 26, null); - - @override - String toString() => 'RegisterNamespaceTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' namespaceType: $namespaceType,' - ' durationParentId: $durationParentId,' - ' namespaceId: $namespaceId,' - ' namespaceNameSize: $namespaceNameSize,' - ' namespaceName: $namespaceName}'; -} - -class _RegisterNamespaceTransactionBufferReader extends fb.TableReader { - const _RegisterNamespaceTransactionBufferReader(); - - @override - RegisterNamespaceTransactionBuffer createObject(fb.BufferContext bc, int offset) => - RegisterNamespaceTransactionBuffer._(bc, offset); -} - -class RegisterNamespaceTransactionBufferBuilder { - RegisterNamespaceTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addNamespaceType(int namespaceType) { - fbBuilder.addUint8(7, namespaceType); - return fbBuilder.offset; - } - - int addDurationParentIdOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addNamespaceIdOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int addNamespaceNameSize(int namespaceNameSize) { - fbBuilder.addUint8(10, namespaceNameSize); - return fbBuilder.offset; - } - - int addNamespaceNameOffset(int offset) { - fbBuilder.addOffset(11, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class RegisterNamespaceTransactionBufferObjectBuilder extends fb.ObjectBuilder { - RegisterNamespaceTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - int namespaceType, - List durationParentId, - List namespaceId, - int namespaceNameSize, - String namespaceName, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _namespaceType = namespaceType, - _durationParentId = durationParentId, - _namespaceId = namespaceId, - _namespaceNameSize = namespaceNameSize, - _namespaceName = namespaceName; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final int _namespaceType; - final List _durationParentId; - final List _namespaceId; - final int _namespaceNameSize; - final String _namespaceName; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int durationParentIdOffset = - _durationParentId?.isNotEmpty == true ? fbBuilder.writeListUint32(_durationParentId) : null; - final int namespaceIdOffset = _namespaceId?.isNotEmpty == true ? fbBuilder.writeListUint32(_namespaceId) : null; - final int namespaceNameOffset = fbBuilder.writeString(_namespaceName); - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _namespaceType); - if (durationParentIdOffset != null) { - fbBuilder.addOffset(8, durationParentIdOffset); - } - if (namespaceIdOffset != null) { - fbBuilder.addOffset(9, namespaceIdOffset); - } - fbBuilder.addUint8(10, _namespaceNameSize); - if (namespaceNameOffset != null) { - fbBuilder.addOffset(11, namespaceNameOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/secret_lock_transaction_buffer.dart b/lib/imp/buffer/model/secret_lock_transaction_buffer.dart deleted file mode 100644 index d8bef7b..0000000 --- a/lib/imp/buffer/model/secret_lock_transaction_buffer.dart +++ /dev/null @@ -1,243 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class SecretLockTransactionBuffer { - factory SecretLockTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - SecretLockTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _SecretLockTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - List get mosaicId => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 18, null); - - List get mosaicAmount => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 20, null); - - List get duration => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 22, null); - - int get hashAlgorithm => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); - - List get secret => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 26, null); - - List get recipient => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 28, null); - - @override - String toString() => 'SecretLockTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' mosaicId: $mosaicId,' - ' mosaicAmount: $mosaicAmount,' - ' duration: $duration,' - ' hashAlgorithm: $hashAlgorithm,' - ' secret: $secret,' - ' recipient: $recipient}'; -} - -class _SecretLockTransactionBufferReader extends fb.TableReader { - const _SecretLockTransactionBufferReader(); - - @override - SecretLockTransactionBuffer createObject(fb.BufferContext bc, int offset) => - SecretLockTransactionBuffer._(bc, offset); -} - -class SecretLockTransactionBufferBuilder { - SecretLockTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addMosaicIdOffset(int offset) { - fbBuilder.addOffset(7, offset); - return fbBuilder.offset; - } - - int addMosaicAmountOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addDurationOffset(int offset) { - fbBuilder.addOffset(9, offset); - return fbBuilder.offset; - } - - int addHashAlgorithm(int hashAlgorithm) { - fbBuilder.addUint8(10, hashAlgorithm); - return fbBuilder.offset; - } - - int addSecretOffset(int offset) { - fbBuilder.addOffset(11, offset); - return fbBuilder.offset; - } - - int addRecipientOffset(int offset) { - fbBuilder.addOffset(12, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class SecretLockTransactionBufferObjectBuilder extends fb.ObjectBuilder { - SecretLockTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - List mosaicId, - List mosaicAmount, - List duration, - int hashAlgorithm, - List secret, - List recipient, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _mosaicId = mosaicId, - _mosaicAmount = mosaicAmount, - _duration = duration, - _hashAlgorithm = hashAlgorithm, - _secret = secret, - _recipient = recipient; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final List _mosaicId; - final List _mosaicAmount; - final List _duration; - final int _hashAlgorithm; - final List _secret; - final List _recipient; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int mosaicIdOffset = _mosaicId?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicId) : null; - final int mosaicAmountOffset = _mosaicAmount?.isNotEmpty == true ? fbBuilder.writeListUint32(_mosaicAmount) : null; - final int durationOffset = _duration?.isNotEmpty == true ? fbBuilder.writeListUint32(_duration) : null; - final int secretOffset = _secret?.isNotEmpty == true ? fbBuilder.writeListUint8(_secret) : null; - final int recipientOffset = _recipient?.isNotEmpty == true ? fbBuilder.writeListUint8(_recipient) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - if (mosaicIdOffset != null) { - fbBuilder.addOffset(7, mosaicIdOffset); - } - if (mosaicAmountOffset != null) { - fbBuilder.addOffset(8, mosaicAmountOffset); - } - if (durationOffset != null) { - fbBuilder.addOffset(9, durationOffset); - } - fbBuilder.addUint8(10, _hashAlgorithm); - if (secretOffset != null) { - fbBuilder.addOffset(11, secretOffset); - } - if (recipientOffset != null) { - fbBuilder.addOffset(12, recipientOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/secret_proof_transaction_buffer.dart b/lib/imp/buffer/model/secret_proof_transaction_buffer.dart deleted file mode 100644 index 24005e2..0000000 --- a/lib/imp/buffer/model/secret_proof_transaction_buffer.dart +++ /dev/null @@ -1,210 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class SecretProofTransactionBuffer { - factory SecretProofTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - SecretProofTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _SecretProofTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get fee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - int get hashAlgorithm => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); - - List get secret => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 20, null); - - int get proofSize => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 22, 0); - - List get proof => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 24, null); - - @override - String toString() => 'SecretProofTransactionBuffer{' - 'size: $size,' - ' signature: $signature,' - ' signer: $signer,' - ' version: $version,' - ' type: $type,' - ' fee: $fee,' - ' deadline: $deadline,' - ' hashAlgorithm: $hashAlgorithm,' - ' secret: $secret,' - ' proofSize: $proofSize,' - ' proof: $proof}'; -} - -class _SecretProofTransactionBufferReader extends fb.TableReader { - const _SecretProofTransactionBufferReader(); - - @override - SecretProofTransactionBuffer createObject(fb.BufferContext bc, int offset) => - SecretProofTransactionBuffer._(bc, offset); -} - -class SecretProofTransactionBufferBuilder { - SecretProofTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint16(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addHashAlgorithm(int hashAlgorithm) { - fbBuilder.addUint8(7, hashAlgorithm); - return fbBuilder.offset; - } - - int addSecretOffset(int offset) { - fbBuilder.addOffset(8, offset); - return fbBuilder.offset; - } - - int addProofSize(int proofSize) { - fbBuilder.addUint16(9, proofSize); - return fbBuilder.offset; - } - - int addProofOffset(int offset) { - fbBuilder.addOffset(10, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class SecretProofTransactionBufferObjectBuilder extends fb.ObjectBuilder { - SecretProofTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List fee, - List deadline, - int hashAlgorithm, - List secret, - int proofSize, - List proof, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _fee = fee, - _deadline = deadline, - _hashAlgorithm = hashAlgorithm, - _secret = secret, - _proofSize = proofSize, - _proof = proof; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _fee; - final List _deadline; - final int _hashAlgorithm; - final List _secret; - final int _proofSize; - final List _proof; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null, 'fbBuilder must not be null'); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int feeOffset = _fee?.isNotEmpty == true ? fbBuilder.writeListUint32(_fee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int secretOffset = _secret?.isNotEmpty == true ? fbBuilder.writeListUint8(_secret) : null; - final int proofOffset = _proof?.isNotEmpty == true ? fbBuilder.writeListUint8(_proof) : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint16(3, _version); - fbBuilder.addUint16(4, _type); - if (feeOffset != null) { - fbBuilder.addOffset(5, feeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - fbBuilder.addUint8(7, _hashAlgorithm); - if (secretOffset != null) { - fbBuilder.addOffset(8, secretOffset); - } - fbBuilder.addUint16(9, _proofSize); - if (proofOffset != null) { - fbBuilder.addOffset(10, proofOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/model/transactions_buffer.dart b/lib/imp/buffer/model/transactions_buffer.dart deleted file mode 100644 index 3282797..0000000 --- a/lib/imp/buffer/model/transactions_buffer.dart +++ /dev/null @@ -1,46 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class Transactions { - Transactions(this.fbBuilder) : assert(fbBuilder != null, 'fbBuilder must not be null'); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint32(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } -} diff --git a/lib/imp/buffer/model/transfer_transaction_buffer.dart b/lib/imp/buffer/model/transfer_transaction_buffer.dart deleted file mode 100644 index 36445c6..0000000 --- a/lib/imp/buffer/model/transfer_transaction_buffer.dart +++ /dev/null @@ -1,385 +0,0 @@ -part of xpx_chain_sdk.buffer.model; - -class MessageBuffer { - factory MessageBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MessageBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _MessageBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get payload => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - @override - String toString() => 'MessageBuffer{type: $type, payload: $payload}'; -} - -class _MessageBufferReader extends fb.TableReader { - const _MessageBufferReader(); - - @override - MessageBuffer createObject(fb.BufferContext bc, int offset) => MessageBuffer._(bc, offset); -} - -class MessageBufferBuilder { - MessageBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addType(int type) { - fbBuilder.addUint8(0, type); - return fbBuilder.offset; - } - - int addPayloadOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MessageBufferObjectBuilder extends fb.ObjectBuilder { - MessageBufferObjectBuilder({ - int type, - List payload, - }) : _type = type, - _payload = payload; - - final int _type; - final List _payload; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int payloadOffset = _payload?.isNotEmpty == true ? fbBuilder.writeListUint8(_payload) : null; - - fbBuilder.startTable(); - fbBuilder.addUint8(0, _type); - if (payloadOffset != null) { - fbBuilder.addOffset(1, payloadOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class MosaicBuffer { - factory MosaicBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - MosaicBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _MosaicBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - List get id => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 4, null); - - List get amount => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 6, null); - - @override - String toString() => 'MosaicBuffer{id: $id, amount: $amount}'; -} - -class _MosaicBufferReader extends fb.TableReader { - const _MosaicBufferReader(); - - @override - MosaicBuffer createObject(fb.BufferContext bc, int offset) => MosaicBuffer._(bc, offset); -} - -class MosaicBufferBuilder { - MosaicBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addIdOffset(int offset) { - fbBuilder.addOffset(0, offset); - return fbBuilder.offset; - } - - int addAmountOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class MosaicBufferObjectBuilder extends fb.ObjectBuilder { - MosaicBufferObjectBuilder({ - List id, - List amount, - }) : _id = id, - _amount = amount; - - final List _id; - final List _amount; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int idOffset = _id?.isNotEmpty == true ? fbBuilder.writeListUint32(_id) : null; - final int amountOffset = _amount?.isNotEmpty == true ? fbBuilder.writeListUint32(_amount) : null; - - fbBuilder.startTable(); - if (idOffset != null) { - fbBuilder.addOffset(0, idOffset); - } - if (amountOffset != null) { - fbBuilder.addOffset(1, amountOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} - -class TransferTransactionBuffer { - factory TransferTransactionBuffer(List bytes) { - final fb.BufferContext rootRef = fb.BufferContext.fromBytes(bytes); - return reader.read(rootRef, 0); - } - - TransferTransactionBuffer._(this._bc, this._bcOffset); - - static const fb.Reader reader = _TransferTransactionBufferReader(); - - final fb.BufferContext _bc; - final int _bcOffset; - - int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); - - List get signature => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 6, null); - - List get signer => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 8, null); - - int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); - - int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); - - List get maxFee => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 14, null); - - List get deadline => const fb.ListReader(fb.Uint32Reader()).vTableGet(_bc, _bcOffset, 16, null); - - List get recipient => const fb.ListReader(fb.Uint8Reader()).vTableGet(_bc, _bcOffset, 18, null); - - int get messageSize => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 20, 0); - - int get numMosaics => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); - - MessageBuffer get message => MessageBuffer.reader.vTableGet(_bc, _bcOffset, 24, null); - - List get mosaics => - const fb.ListReader(MosaicBuffer.reader).vTableGet(_bc, _bcOffset, 26, null); - - @override - String toString() => - 'TransferTransactionBuffer{size: $size, signature: $signature, signer: $signer, version: $version, type: $type, maxFee: $maxFee, deadline: $deadline, recipient: $recipient, messageSize: $messageSize, numMosaics: $numMosaics, message: $message, mosaics: $mosaics}'; -} - -class _TransferTransactionBufferReader extends fb.TableReader { - const _TransferTransactionBufferReader(); - - @override - TransferTransactionBuffer createObject(fb.BufferContext bc, int offset) => TransferTransactionBuffer._(bc, offset); -} - -class TransferTransactionBufferBuilder { - TransferTransactionBufferBuilder(this.fbBuilder) : assert(fbBuilder != null); - - final fb.Builder fbBuilder; - - void begin() { - fbBuilder.startTable(); - } - - int addSize(int size) { - fbBuilder.addUint32(0, size); - return fbBuilder.offset; - } - - int addSignatureOffset(int offset) { - fbBuilder.addOffset(1, offset); - return fbBuilder.offset; - } - - int addSignerOffset(int offset) { - fbBuilder.addOffset(2, offset); - return fbBuilder.offset; - } - - int addVersion(int version) { - fbBuilder.addUint32(3, version); - return fbBuilder.offset; - } - - int addType(int type) { - fbBuilder.addUint16(4, type); - return fbBuilder.offset; - } - - int addMaxFeeOffset(int offset) { - fbBuilder.addOffset(5, offset); - return fbBuilder.offset; - } - - int addDeadlineOffset(int offset) { - fbBuilder.addOffset(6, offset); - return fbBuilder.offset; - } - - int addRecipientOffset(int offset) { - fbBuilder.addOffset(7, offset); - return fbBuilder.offset; - } - - int addMessageSize(int messageSize) { - fbBuilder.addUint16(8, messageSize); - return fbBuilder.offset; - } - - int addNumMosaics(int numMosaics) { - fbBuilder.addUint8(9, numMosaics); - return fbBuilder.offset; - } - - int addMessageOffset(int offset) { - fbBuilder.addOffset(10, offset); - return fbBuilder.offset; - } - - int addMosaicsOffset(int offset) { - fbBuilder.addOffset(11, offset); - return fbBuilder.offset; - } - - int finish() => fbBuilder.endTable(); -} - -class TransferTransactionBufferObjectBuilder extends fb.ObjectBuilder { - TransferTransactionBufferObjectBuilder({ - int size, - List signature, - List signer, - int version, - int type, - List maxFee, - List deadline, - List recipient, - int messageSize, - int numMosaics, - MessageBufferObjectBuilder message, - List mosaics, - }) : _size = size, - _signature = signature, - _signer = signer, - _version = version, - _type = type, - _maxFee = maxFee, - _deadline = deadline, - _recipient = recipient, - _messageSize = messageSize, - _numMosaics = numMosaics, - _message = message, - _mosaics = mosaics; - - final int _size; - final List _signature; - final List _signer; - final int _version; - final int _type; - final List _maxFee; - final List _deadline; - final List _recipient; - final int _messageSize; - final int _numMosaics; - final MessageBufferObjectBuilder _message; - final List _mosaics; - - /// Finish building, and store into the [fbBuilder]. - @override - int finish(fb.Builder fbBuilder) { - assert(fbBuilder != null); - final int signatureOffset = _signature?.isNotEmpty == true ? fbBuilder.writeListUint8(_signature) : null; - final int signerOffset = _signer?.isNotEmpty == true ? fbBuilder.writeListUint8(_signer) : null; - final int maxFeeOffset = _maxFee?.isNotEmpty == true ? fbBuilder.writeListUint32(_maxFee) : null; - final int deadlineOffset = _deadline?.isNotEmpty == true ? fbBuilder.writeListUint32(_deadline) : null; - final int recipientOffset = _recipient?.isNotEmpty == true ? fbBuilder.writeListUint8(_recipient) : null; - final int messageOffset = _message?.getOrCreateOffset(fbBuilder); - final int mosaicsOffset = _mosaics?.isNotEmpty == true - ? fbBuilder.writeList(_mosaics.map((b) => b.getOrCreateOffset(fbBuilder)).toList()) - : null; - - fbBuilder.startTable(); - fbBuilder.addUint32(0, _size); - if (signatureOffset != null) { - fbBuilder.addOffset(1, signatureOffset); - } - if (signerOffset != null) { - fbBuilder.addOffset(2, signerOffset); - } - fbBuilder.addUint32(3, _version); - fbBuilder.addUint16(4, _type); - if (maxFeeOffset != null) { - fbBuilder.addOffset(5, maxFeeOffset); - } - if (deadlineOffset != null) { - fbBuilder.addOffset(6, deadlineOffset); - } - if (recipientOffset != null) { - fbBuilder.addOffset(7, recipientOffset); - } - fbBuilder.addUint16(8, _messageSize); - fbBuilder.addUint8(9, _numMosaics); - if (messageOffset != null) { - fbBuilder.addOffset(10, messageOffset); - } - if (mosaicsOffset != null) { - fbBuilder.addOffset(11, mosaicsOffset); - } - return fbBuilder.endTable(); - } - - /// Convenience method to serialize to byte list. - @override - Uint8List toBytes([String fileIdentifier]) { - final fb.Builder fbBuilder = fb.Builder(); - final int offset = finish(fbBuilder); - return fbBuilder.finish(offset, fileIdentifier); - } -} diff --git a/lib/imp/buffer/schema.dart b/lib/imp/buffer/schema.dart deleted file mode 100644 index a780561..0000000 --- a/lib/imp/buffer/schema.dart +++ /dev/null @@ -1,15 +0,0 @@ -library xpx_chain_sdk.buffer.schema; - -import 'dart:typed_data'; - -part 'schema/buffer_schema.dart'; -part 'schema/buffer_schema_account_property.dart'; -part 'schema/buffer_schema_aggregate.dart'; -part 'schema/buffer_schema_alias.dart'; -part 'schema/buffer_schema_exchange.dart'; -part 'schema/buffer_schema_lockFunds.dart'; -part 'schema/buffer_schema_mosaic_definition.dart'; -part 'schema/buffer_schema_mosaic_supply_change.dart'; -part 'schema/buffer_schema_multisig.dart'; -part 'schema/buffer_schema_register_namespace.dart'; -part 'schema/buffer_schema_transfer.dart'; diff --git a/lib/imp/buffer/schema/buffer_schema.dart b/lib/imp/buffer/schema/buffer_schema.dart deleted file mode 100644 index 066bb66..0000000 --- a/lib/imp/buffer/schema/buffer_schema.dart +++ /dev/null @@ -1,204 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -const _byteSize = 1, _shortSize = 2, _intSize = 4; - -// ignore: one_member_abstracts -abstract class SchemaAttribute { - Uint8List serialize(Uint8List buffer, int position, int innerObjectPosition); -} - -class Schema { - Schema(this.schemaDefinition); - - List schemaDefinition; - - Uint8List serialize(Uint8List buffer) { - final resultBytes = []; - var i = 0; - for (final schemaDefinition in schemaDefinition) { - final v = schemaDefinition.serialize(buffer, 4 + (i * 2), buffer[0]); - if (v.isNotEmpty) { - resultBytes.addAll(v); - } - - ++i; - } - return Uint8List.fromList(resultBytes); - } -} - -abstract class AbstractSchemaAttribute { - AbstractSchemaAttribute(this.name); - - String name; - - Uint8List findParam(int innerObjectPosition, int position, Uint8List buffer, int size) { - final offset = this.offset(innerObjectPosition, position, buffer); - if (offset == 0) { - return Uint8List(0); - } - - final v = buffer.getRange(offset + innerObjectPosition, offset + innerObjectPosition + size).toList(); - - return Uint8List.fromList(v); - } - - Uint8List findVector(int innerObjectPosition, int position, Uint8List buffer, int size) { - final offset = this.offset(innerObjectPosition, position, buffer); - - final offsetLong = offset + innerObjectPosition; - final vecStart = vector(offsetLong, buffer); - final vecLength = vectorLength(offsetLong, buffer) * size; - - if (offset == 0) { - return Uint8List(0); - } - - final v = buffer.getRange(vecStart, vecStart + vecLength).toList(); - - return Uint8List.fromList(v); - } - - int offset(int innerObjectPosition, int position, Uint8List buffer) { - final vTable = innerObjectPosition - readUint32(innerObjectPosition, buffer); - return position < readUint16(vTable, buffer) ? readUint16(vTable + position, buffer) : 0; - } - - int readUint16(int offset, Uint8List buffer) { - final b = buffer.getRange(offset.toUnsigned(32), 2 + offset.toUnsigned(32)).toList(); - return (b[0]) | (b[1]) << 8; - } - - int readUint32(int offset, Uint8List buffer) { - final b = buffer.getRange(offset.toUnsigned(32), offset.toUnsigned(32) + 4).toList(); - return (b[0]) | (b[1]) << 8 | (b[2]) << 16 | (b[3]) << 24; - } - - int vector(int offset, Uint8List buffer) => offset + readUint32(offset, buffer) + 4; - - int vectorLength(int offset, Uint8List buffer) => readUint32(offset + readUint32(offset, buffer), buffer); - - int findObjectStartPosition(int innerObjectPosition, int position, Uint8List buffer) { - final offset = this.offset(innerObjectPosition, position, buffer); - return indirect(offset + innerObjectPosition, buffer); - } - - int findArrayLength(int innerObjectPosition, int position, Uint8List buffer) { - final offset = this.offset(innerObjectPosition, position, buffer); - if (offset == 0) { - return 0; - } - return vectorLength(innerObjectPosition + offset, buffer); - } - - int findObjectArrayElementStartPosition(int innerObjectPosition, int position, Uint8List buffer, int startPosition) { - final offset = this.offset(innerObjectPosition, position, buffer); - final vector = this.vector(innerObjectPosition + offset, buffer); - - return indirect(vector + startPosition * 4, buffer); - } - - int indirect(int offset, Uint8List buffer) => offset + readUint32(offset, buffer); - - @override - String toString() => '$name'; -} - -class ArrayAttribute extends AbstractSchemaAttribute implements SchemaAttribute { - ArrayAttribute(String name, this.size) : super(name); - - int size; - - @override - Uint8List serialize(Uint8List buffer, int position, int innerObjectPosition) => - findVector(innerObjectPosition, position, buffer, size); - - @override - String toString() => '$name, $size'; -} - -class ScalarAttribute extends AbstractSchemaAttribute implements SchemaAttribute { - ScalarAttribute(String name, this.size) : super(name); - - int size; - - @override - Uint8List serialize(Uint8List buffer, int position, int innerObjectPosition) => - findParam(innerObjectPosition, position, buffer, size); - - @override - String toString() => '$name, $size'; -} - -class TableArrayAttribute extends AbstractSchemaAttribute implements SchemaAttribute { - TableArrayAttribute(String name, this.schema) : super(name); - - List schema; - - @override - Uint8List serialize(Uint8List buffer, int position, int innerObjectPosition) { - final List resultBytes = []; - - final arrayLength = findArrayLength(innerObjectPosition, position, buffer); - - for (int i = 0; i < arrayLength; i++) { - final startArrayPosition = findObjectArrayElementStartPosition(innerObjectPosition, position, buffer, i); - int j = 0; - for (final element in schema) { - final tmp = element.serialize(buffer, 4 + j * 2, startArrayPosition); - - if (tmp.length == 1) { - resultBytes.addAll([tmp.elementAt(0)]); - } else { - resultBytes.addAll(tmp); - } - ++j; - } - } - - return Uint8List.fromList(resultBytes); - } -} - -class TableAttribute extends AbstractSchemaAttribute implements SchemaAttribute { - TableAttribute(String name, this.schema) : super(name); - - List schema; - - @override - Uint8List serialize(Uint8List buffer, int position, int innerObjectPosition) { - final resultBytes = []; - final tableStartPosition = findObjectStartPosition(innerObjectPosition, position, buffer); - - int j = 0; - for (final element in schema) { - final tmp = element.serialize(buffer, 4 + j * 2, tableStartPosition); - ++j; - if (tmp.length == 1) { - resultBytes.addAll([tmp.elementAt(0)]); - } else { - resultBytes.addAll(tmp); - } - } - - return Uint8List.fromList(resultBytes); - } -} - -ArrayAttribute arrayAttribute(String name, int size) => ArrayAttribute(name, size); - -ScalarAttribute scalarAttribute(String name, int size) => ScalarAttribute(name, size); - -TableArrayAttribute tableArrayAttribute(String name, List schema) => TableArrayAttribute(name, schema); - -TableAttribute tableAttribute(String name, List schema) => TableAttribute(name, schema); - -List commonSchema() => [ - scalarAttribute('size', _intSize), - arrayAttribute('signature', _byteSize), - arrayAttribute('signer', _byteSize), - scalarAttribute('version', _intSize), - scalarAttribute('type', _shortSize), - arrayAttribute('maxFee', _intSize), - arrayAttribute('deadline', _intSize), - ]; diff --git a/lib/imp/buffer/schema/buffer_schema_account_property.dart b/lib/imp/buffer/schema/buffer_schema_account_property.dart deleted file mode 100644 index 62c18a6..0000000 --- a/lib/imp/buffer/schema/buffer_schema_account_property.dart +++ /dev/null @@ -1,16 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema accountPropertyTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('propertyType', _byteSize), - scalarAttribute('modificationCount', _byteSize), - tableArrayAttribute( - 'modifications', - Schema([ - scalarAttribute('modificationType', _byteSize), - arrayAttribute('value', _byteSize), - ]).schemaDefinition) - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_aggregate.dart b/lib/imp/buffer/schema/buffer_schema_aggregate.dart deleted file mode 100644 index 11f4f0b..0000000 --- a/lib/imp/buffer/schema/buffer_schema_aggregate.dart +++ /dev/null @@ -1,10 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema aggregateTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('transactionsSize', _intSize), - arrayAttribute('transactions', _byteSize), - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_alias.dart b/lib/imp/buffer/schema/buffer_schema_alias.dart deleted file mode 100644 index 3a09fe2..0000000 --- a/lib/imp/buffer/schema/buffer_schema_alias.dart +++ /dev/null @@ -1,11 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema aliasTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('actionType', _byteSize), - arrayAttribute('namespaceId', _intSize), - arrayAttribute('aliasId', _byteSize) - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_exchange.dart b/lib/imp/buffer/schema/buffer_schema_exchange.dart deleted file mode 100644 index 00b44cf..0000000 --- a/lib/imp/buffer/schema/buffer_schema_exchange.dart +++ /dev/null @@ -1,55 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema addExchangeOfferTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('offersCount', _byteSize), - tableArrayAttribute( - 'offers', - Schema([ - arrayAttribute('mosaicId', _intSize), - arrayAttribute('mosaicAmount', _intSize), - arrayAttribute('cost', _intSize), - scalarAttribute('type', _byteSize), - arrayAttribute('duration', _intSize), - ]).schemaDefinition) - ]; - - schemaDefinition.insertAll(0, commonSchema()); - - return Schema(schemaDefinition); -} - -Schema exchangeOfferTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('offersCount', _byteSize), - tableArrayAttribute( - 'offers', - Schema([ - arrayAttribute('mosaicId', _intSize), - arrayAttribute('mosaicAmount', _intSize), - arrayAttribute('cost', _intSize), - scalarAttribute('type', _byteSize), - arrayAttribute('owner', _byteSize), - ]).schemaDefinition) - ]; - - schemaDefinition.insertAll(0, commonSchema()); - - return Schema(schemaDefinition); -} - -Schema removeExchangeOfferTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('offersCount', _byteSize), - tableArrayAttribute( - 'offers', - Schema([ - arrayAttribute('mosaicId', _intSize), - scalarAttribute('type', _byteSize), - ]).schemaDefinition) - ]; - - schemaDefinition.insertAll(0, commonSchema()); - - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_lockFunds.dart b/lib/imp/buffer/schema/buffer_schema_lockFunds.dart deleted file mode 100644 index 8f073d3..0000000 --- a/lib/imp/buffer/schema/buffer_schema_lockFunds.dart +++ /dev/null @@ -1,12 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema lockFundsTransactionSchema() { - final List schemaDefinition = [ - arrayAttribute('mosaicId', _intSize), - arrayAttribute('mosaicAmount', _intSize), - arrayAttribute('duration', _intSize), - arrayAttribute('hash', _byteSize), - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_mosaic_definition.dart b/lib/imp/buffer/schema/buffer_schema_mosaic_definition.dart deleted file mode 100644 index e951f82..0000000 --- a/lib/imp/buffer/schema/buffer_schema_mosaic_definition.dart +++ /dev/null @@ -1,19 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema mosaicDefinitionTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('mosaicNonce', _intSize), - arrayAttribute('mosaicId', _intSize), - scalarAttribute('numOptionalProperties', _byteSize), - scalarAttribute('flags', _byteSize), - scalarAttribute('divisibility', _byteSize), - tableArrayAttribute( - 'modifications', - Schema([ - scalarAttribute('mosaicPropertyId', _byteSize), - arrayAttribute('value', _intSize), - ]).schemaDefinition) - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_mosaic_supply_change.dart b/lib/imp/buffer/schema/buffer_schema_mosaic_supply_change.dart deleted file mode 100644 index 5f47d6b..0000000 --- a/lib/imp/buffer/schema/buffer_schema_mosaic_supply_change.dart +++ /dev/null @@ -1,11 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema mosaicSupplyChangeTransactionSchema() { - final List schemaDefinition = [ - arrayAttribute('mosaicId', _intSize), - scalarAttribute('direction', _byteSize), - arrayAttribute('delta', _intSize) - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_multisig.dart b/lib/imp/buffer/schema/buffer_schema_multisig.dart deleted file mode 100644 index d022000..0000000 --- a/lib/imp/buffer/schema/buffer_schema_multisig.dart +++ /dev/null @@ -1,17 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema modifyMultisigAccountTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('minRemovalDelta', _byteSize), - scalarAttribute('minApprovalDelta', _byteSize), - scalarAttribute('numModifications', _byteSize), - tableArrayAttribute( - 'modification', - Schema([ - scalarAttribute('type', _byteSize), - arrayAttribute('cosignatoryPublicKey', _byteSize), - ]).schemaDefinition) - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_register_namespace.dart b/lib/imp/buffer/schema/buffer_schema_register_namespace.dart deleted file mode 100644 index 36e18f0..0000000 --- a/lib/imp/buffer/schema/buffer_schema_register_namespace.dart +++ /dev/null @@ -1,13 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema registerNamespaceTransactionSchema() { - final List schemaDefinition = [ - scalarAttribute('namespaceType', _byteSize), - arrayAttribute('durationParentId', _intSize), - arrayAttribute('namespaceId', _intSize), - scalarAttribute('namespaceNameSize', _byteSize), - arrayAttribute('name', _byteSize) - ]; - schemaDefinition.insertAll(0, commonSchema()); - return Schema(schemaDefinition); -} diff --git a/lib/imp/buffer/schema/buffer_schema_transfer.dart b/lib/imp/buffer/schema/buffer_schema_transfer.dart deleted file mode 100644 index fc99261..0000000 --- a/lib/imp/buffer/schema/buffer_schema_transfer.dart +++ /dev/null @@ -1,21 +0,0 @@ -part of xpx_chain_sdk.buffer.schema; - -Schema transferTransactionSchema() { - final List schemaDefinition = [ - arrayAttribute('recipient', _byteSize), - scalarAttribute('messageSize', _shortSize), - scalarAttribute('numMosaics', _byteSize), - tableAttribute( - 'message', Schema([scalarAttribute('type', _byteSize), arrayAttribute('payload', _byteSize)]).schemaDefinition), - tableArrayAttribute( - 'mosaics', - Schema([ - arrayAttribute('id', _intSize), - arrayAttribute('amount', _intSize), - ]).schemaDefinition) - ]; - - schemaDefinition.insertAll(0, commonSchema()); - - return Schema(schemaDefinition); -} diff --git a/lib/src/api/api.dart b/lib/src/api/api.dart index a404579..07dd127 100644 --- a/lib/src/api/api.dart +++ b/lib/src/api/api.dart @@ -11,11 +11,8 @@ import 'dart:convert' show json; import 'package:dio/dio.dart'; import 'package:http/http.dart' as http; -import 'package:xpx_chain_sdk/src/model/multisig.dart'; -import 'package:xpx_chain_sdk/xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; -import '../../xpx_sdk.dart'; -import '../model/metadata.dart'; import 'dto.dart'; part 'api_account_routes.dart'; @@ -35,4 +32,4 @@ part 'page_query_params.dart'; part 'query_params.dart'; part 'transaction_query_params.dart'; -_ApiClient defaultApiClient = _ApiClient(null, null); +ApiClient defaultApiClient = ApiClient(null, null); diff --git a/lib/src/api/api_account_routes.dart b/lib/src/api/api_account_routes.dart index b9e2a0c..0526536 100644 --- a/lib/src/api/api_account_routes.dart +++ b/lib/src/api/api_account_routes.dart @@ -7,10 +7,10 @@ part of xpx_chain_sdk.api; class AccountRoutesApi { - AccountRoutesApi([_ApiClient? _apiClient]) + AccountRoutesApi([ApiClient? _apiClient]) : _apiClient = _apiClient ?? defaultApiClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; static const _accountInfoRoute = '/account/{accountId}'; static const _accountsInfoRoute = '/account'; @@ -122,30 +122,24 @@ class AccountRoutesApi { /// param: pageSize The number of transactions to return for each request. /// param: id The transaction id up to which transactions are returned. /// param: ordering The ordering criteria: * -id - Descending order by id. * id - Ascending order by id. - Future> transactions(Address address, - {TransactionQueryParams? txnQueryParams}) async { - // create path and map variables - const String path = _transactionsRoute; - + Future> transactions(PublicAccount account, + [TransactionQueryParams? txnQueryParams]) async { // query params final List queryParams = []; if (txnQueryParams != null) { + txnQueryParams.publicKey = account.publicKey; queryParams.addAll(txnQueryParams.toQueryParams()); + } else { + queryParams.add(QueryParam('publicKey', account.publicKey)); } - queryParams.add(QueryParam('address', address.address)); - - final response = await _apiClient.get(path, null, queryParams); - - if (response.statusCode! >= 299) { - throw ApiException(response.statusCode!, response.data); - } else if (response.data != null) { - final List resp = - _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); - } else { - return []; + bool firstLevel = true; + if (txnQueryParams != null && !txnQueryParams.firstLevel) { + firstLevel = false; } + return internalGetTransactions( + _apiClient, _transactionsRoute, queryParams, null, + firstLevel: firstLevel); } /// Get incoming transactions @@ -153,29 +147,23 @@ class AccountRoutesApi { /// Gets an List of incoming transactions. /// A transaction is said to be incoming with respect to an /// account if the account is the recipient of the transaction. - Future> incomingTransactions(Address address, - {TransactionQueryParams? txnQueryParams}) async { - // create path and map variables - const String path = _transactionsRoute; - + Future> incomingTransactions(PublicAccount account, + [TransactionQueryParams? txnQueryParams]) async { // query params final List queryParams = []; if (txnQueryParams != null) { queryParams.addAll(txnQueryParams.toQueryParams()); + } else { + queryParams.add(QueryParam('recipientAddress', account.address.address)); } - queryParams.add(QueryParam('recipientAddress', address.address)); - final response = await _apiClient.get(path, null, queryParams); - - if (response.statusCode! >= 299) { - throw ApiException(response.statusCode!, response.data); - } else if (response.data != null) { - final List resp = - _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); - } else { - return []; + bool firstLevel = true; + if (txnQueryParams != null && !txnQueryParams.firstLevel) { + firstLevel = false; } + return internalGetTransactions( + _apiClient, _transactionsRoute, queryParams, null, + firstLevel: firstLevel); } /// Get outgoing transactions @@ -184,72 +172,65 @@ class AccountRoutesApi { /// A transaction is said to be outgoing with respect to an /// account if the account is the sender of the transaction. Future> outgoingTransactions(PublicAccount account, - {TransactionQueryParams? txnQueryParams}) async { - const String path = _transactionsRoute; - + [TransactionQueryParams? txnQueryParams]) async { // query params final List queryParams = []; if (txnQueryParams != null) { + txnQueryParams.signerPublicKey = account.publicKey; queryParams.addAll(txnQueryParams.toQueryParams()); + } else { + queryParams.add(QueryParam('signerPublicKey', account.publicKey)); } - queryParams.add(QueryParam('signerPublicKey', account.publicKey)); - - final response = await _apiClient.get(path, null, queryParams); - if (response.statusCode! >= 299) { - throw ApiException(response.statusCode!, response.data); - } else if (response.data != null) { - final List resp = - _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); - } else { - return []; + bool firstLevel = true; + if (txnQueryParams != null && !txnQueryParams.firstLevel) { + firstLevel = false; } + return internalGetTransactions( + _apiClient, _transactionsRoute, queryParams, null, + firstLevel: firstLevel); } /// Get unconfirmed transactions /// /// Gets the List of transactions not included in a block where an account /// is the sender or receiver. - Future> unconfirmedTransactions(Address address, - {TransactionQueryParams? txnQueryParams}) async { - // create path and map variables - const String path = _unconfirmedTransactionsRoute; - + Future> unconfirmedTransactions(PublicAccount account, + [TransactionQueryParams? txnQueryParams]) async { // query params final List queryParams = []; if (txnQueryParams != null) { + txnQueryParams.signerPublicKey = account.publicKey; queryParams.addAll(txnQueryParams.toQueryParams()); + } else { + queryParams.add(QueryParam('signerPublicKey', account.publicKey)); } - queryParams.add(QueryParam('address', address.address)); - - final response = await _apiClient.get(path, null, queryParams); - if (response.statusCode! >= 299) { - throw ApiException(response.statusCode!, response.data); - } else if (response.data != null) { - final List resp = - _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); - } else { - return []; + bool firstLevel = true; + if (txnQueryParams != null && !txnQueryParams.firstLevel) { + firstLevel = false; } + return internalGetTransactions( + _apiClient, _unconfirmedTransactionsRoute, queryParams, null, + firstLevel: firstLevel); } /// Get aggregate bonded transactions information /// /// Gets an List of [aggregate bonded transactions] where the account is /// the sender or requires to cosign the transaction. - Future> partialTransactions(Address address, - {TransactionQueryParams? txnQueryParams}) async { + Future> partialTransactions(PublicAccount account, + [TransactionQueryParams? txnQueryParams]) async { const String path = _aggregateBondedTransactionsRoute; // query params final List queryParams = []; if (txnQueryParams != null) { + txnQueryParams.publicKey = account.publicKey; queryParams.addAll(txnQueryParams.toQueryParams()); + } else { + queryParams.add(QueryParam('publicKey', account.publicKey)); } - queryParams.add(QueryParam('address', address.address)); final response = await _apiClient.get(path, null, queryParams); @@ -258,7 +239,28 @@ class AccountRoutesApi { } else if (response.data != null) { final List resp = _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); + + final allTransaction = + resp.map(deserializeDTO).toList().cast(); + + var aggregateBondedTransactions = []; + for (var transaction in allTransaction) { + if (transaction.entityType() == TransactionType.aggregateBonded) { + aggregateBondedTransactions.add(transaction as AggregateTransaction); + } + } + + for (var transaction in allTransaction) { + if (transaction.entityType() != TransactionType.aggregateBonded) { + final aggregateTransaction = aggregateBondedTransactions.firstWhere( + (element) => + element.absTransaction().transactionHash == + transaction.absTransaction().aggregateHash); + aggregateTransaction.innerTransactions.add(transaction); + } + } + + return aggregateBondedTransactions; } else { return []; } diff --git a/lib/src/api/api_blockchain_routes.dart b/lib/src/api/api_blockchain_routes.dart index a17cbd6..fa8bc43 100644 --- a/lib/src/api/api_blockchain_routes.dart +++ b/lib/src/api/api_blockchain_routes.dart @@ -7,13 +7,14 @@ part of xpx_chain_sdk.api; class BlockchainRoutesApi { - BlockchainRoutesApi([_ApiClient? apiClient]) + BlockchainRoutesApi([ApiClient? apiClient]) : _apiClient = apiClient ?? defaultApiClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; static const _blockchainHeightRoute = '/chain/height'; static const _blockByHeightRoute = '/block/{height}'; + // static const _blockReceiptsRoute = '/block/{height}/receipts'; static const _blockchainScoreRoute = '/chain/score'; static const _diagnosticStorageRoute = '/diagnostic/storage'; diff --git a/lib/src/api/api_client.dart b/lib/src/api/api_client.dart index e1f8a3f..1a9728c 100644 --- a/lib/src/api/api_client.dart +++ b/lib/src/api/api_client.dart @@ -25,7 +25,8 @@ class SiriusClient { /// It's been chosen because it's easy to use. final Dio httpClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; + Future? _networkType; BlockchainRoutesApi? _blockChain; AccountRoutesApi? _account; ExchangeRoutesApi? _exchange; @@ -68,7 +69,7 @@ class SiriusClient { Future get generationHash => _getGenerationHash(); - Future get networkType => _getNetworkType(); + Future get networkType => _networkType ??= _getNetworkType(); Future _getGenerationHash() async { final BlockInfo? hash = await blockChain.getBlockByHeight(1.toHeight); @@ -84,14 +85,14 @@ class SiriusClient { // ignore: parameter_assignments client ??= http.Client(); - final _ApiClient apiClient = _ApiClient(baseUrl, Dio()); + final ApiClient apiClient = ApiClient(baseUrl, Dio()); return SiriusClient._(apiClient, Dio()); } } -class _ApiClient { - _ApiClient(this.baseUrl, this._client); +class ApiClient { + ApiClient(this.baseUrl, this._client); String? baseUrl; @@ -270,18 +271,6 @@ class _ApiClient { options.headers!.addAll(headerParams); } - // if (body is http.MultipartRequest) { - // final request = http.MultipartRequest(method, url); - // request.fields.addAll(body.fields); - // request.files.addAll(body.files); - // request.headers.addAll(body.headers); - // // if (options != null ) { - // // request.headers.addAll(options!.headers); - // // } - // - // // final response = await _client!.send(request); - // // return await Response.fromStream(response); - // } else { final msgBody = contentType == 'application/x-www-form-urlencoded' ? formParams : serialize(body); diff --git a/lib/src/api/api_exchange_routes.dart b/lib/src/api/api_exchange_routes.dart index eef7a32..d063b4a 100644 --- a/lib/src/api/api_exchange_routes.dart +++ b/lib/src/api/api_exchange_routes.dart @@ -7,10 +7,10 @@ part of xpx_chain_sdk.api; class ExchangeRoutesApi { - ExchangeRoutesApi([_ApiClient? _apiClient]) + ExchangeRoutesApi([ApiClient? _apiClient]) : _apiClient = _apiClient ?? defaultApiClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; /// Return [List] with same operation type and mosaic id. /// Example: If you want to buy Storage units, you need diff --git a/lib/src/api/api_internal.dart b/lib/src/api/api_internal.dart deleted file mode 100644 index a00445c..0000000 --- a/lib/src/api/api_internal.dart +++ /dev/null @@ -1,44 +0,0 @@ -part of xpx_chain_sdk.api; - -const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; - -// port from Java version -Iterable _convertParametersForCollectionFormat(String collectionFormat, String name, value) { - final params = []; - - // preconditions - if (name == null || name.isEmpty || value == null) { - return params; - } - - if (value is! List) { - params.add(QueryParam(name, _parameterToString(value))); - return params; - } - - final List values = value; - - // get the collection format - // ignore: parameter_assignments - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) ? 'csv' : collectionFormat; // default: csv - - if (collectionFormat == 'multi') { - return values.map((v) => QueryParam(name, _parameterToString(v))); - } - - final String delimiter = _delimiters[collectionFormat] ?? ','; - - params.add(QueryParam(name, values.map(_parameterToString).join(delimiter))); - return params; -} - -/// Format the given parameter object into string. -String _parameterToString(value) { - if (value == null) { - return ''; - } else if (value is DateTime) { - return value.toUtc().toIso8601String(); - } else { - return value.toString(); - } -} diff --git a/lib/src/api/api_metadata_routes.dart b/lib/src/api/api_metadata_routes.dart index 1f89016..0b25522 100644 --- a/lib/src/api/api_metadata_routes.dart +++ b/lib/src/api/api_metadata_routes.dart @@ -9,7 +9,7 @@ part of xpx_chain_sdk.api; class MetadataRoutesApi { MetadataRoutesApi(this._apiClient); - final _ApiClient _apiClient; + final ApiClient _apiClient; static const _metadataV2InfoRoute = '/metadata_v2/{compositeHash}'; static const _metadatasV2InfoRoute = '/metadata_v2'; diff --git a/lib/src/api/api_mosaic_routes.dart b/lib/src/api/api_mosaic_routes.dart index 4dc389f..6bf4018 100644 --- a/lib/src/api/api_mosaic_routes.dart +++ b/lib/src/api/api_mosaic_routes.dart @@ -7,10 +7,10 @@ part of xpx_chain_sdk.api; class MosaicRoutesApi { - MosaicRoutesApi([_ApiClient? apiClient]) + MosaicRoutesApi([ApiClient? apiClient]) : _apiClient = apiClient ?? defaultApiClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; static const _mosaicRoute = '/mosaic/{mosaicId}'; static const _mosaicsRoute = '/mosaic'; diff --git a/lib/src/api/api_namespace_routes.dart b/lib/src/api/api_namespace_routes.dart index 8db92ed..c786b51 100644 --- a/lib/src/api/api_namespace_routes.dart +++ b/lib/src/api/api_namespace_routes.dart @@ -7,10 +7,10 @@ part of xpx_chain_sdk.api; class NamespaceRoutesApi { - NamespaceRoutesApi([_ApiClient? _apiClient]) + NamespaceRoutesApi([ApiClient? _apiClient]) : _apiClient = _apiClient ?? defaultApiClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; static const _namespaceRoute = '/namespace/{namespaceId}'; static const _namespacesFromAccountRoute = '/account/{accountId}/namespaces'; diff --git a/lib/src/api/api_network_routes.dart b/lib/src/api/api_network_routes.dart index 3550a83..f8bca0e 100644 --- a/lib/src/api/api_network_routes.dart +++ b/lib/src/api/api_network_routes.dart @@ -7,10 +7,10 @@ part of xpx_chain_sdk.api; class NetworkRoutesApi { - NetworkRoutesApi([_ApiClient? apiClient]) + NetworkRoutesApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient; - final _ApiClient apiClient; + final ApiClient apiClient; /// Get the current network type of the chain /// diff --git a/lib/src/api/api_node_routes.dart b/lib/src/api/api_node_routes.dart index ede7df8..e37df8d 100644 --- a/lib/src/api/api_node_routes.dart +++ b/lib/src/api/api_node_routes.dart @@ -9,7 +9,7 @@ part of xpx_chain_sdk.api; class NodeRoutesApi { NodeRoutesApi(this._apiClient); - final _ApiClient _apiClient; + final ApiClient _apiClient; static const _nodeInfoRoute = '/node/info'; static const _nodeTimeRoute = '/node/time'; diff --git a/lib/src/api/api_transaction_routes.dart b/lib/src/api/api_transaction_routes.dart index 2798761..44f66aa 100644 --- a/lib/src/api/api_transaction_routes.dart +++ b/lib/src/api/api_transaction_routes.dart @@ -7,10 +7,10 @@ part of xpx_chain_sdk.api; class TransactionRoutesApi { - TransactionRoutesApi([_ApiClient? _apiClient]) + TransactionRoutesApi([ApiClient? _apiClient]) : _apiClient = _apiClient ?? defaultApiClient; - final _ApiClient _apiClient; + final ApiClient _apiClient; // routes for TransactionApi. static const _announceTransactionRoute = '/transactions'; @@ -112,7 +112,7 @@ class TransactionRoutesApi { /// GetTransactionsByGroup returns an array of Transaction's for passed TransactionGroupType. Future> getTransactionsByGroup( TransactionGroupType groupType, - {TransactionQueryParams? txnQueryParams}) async { + [TransactionQueryParams? txnQueryParams]) async { // create path and map variables final String path = _transactionsRoute.replaceAll('{group}', groupType.name); @@ -123,17 +123,12 @@ class TransactionRoutesApi { queryParams.addAll(txnQueryParams.toQueryParams()); } - final response = await _apiClient.get(path, null, queryParams); - - if (response.statusCode! >= 299) { - throw ApiException(response.statusCode!, response.data); - } else if (response.data != null) { - final List resp = - _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); - } else { - return []; + bool firstLevel = true; + if (txnQueryParams != null && !txnQueryParams.firstLevel) { + firstLevel = false; } + return internalGetTransactions(_apiClient, path, queryParams, null, + firstLevel: firstLevel); } /// Get transactions information @@ -154,17 +149,7 @@ class TransactionRoutesApi { final String path = _transactionsRoute.replaceAll('{group}', groupType.name); - final response = await _apiClient.post(path, postBody); - - if (response.statusCode! >= 299) { - throw ApiException(response.statusCode!, response.data); - } else if (response.data != null) { - final List resp = - _apiClient.deserialize(response.data, 'List'); - return resp.map(deserializeDTO).toList().cast(); - } else { - return []; - } + return internalGetTransactions(_apiClient, path, [], postBody); } /// Get transaction status diff --git a/lib/src/api/dto.dart b/lib/src/api/dto.dart index 6b89187..d213c65 100644 --- a/lib/src/api/dto.dart +++ b/lib/src/api/dto.dart @@ -7,9 +7,7 @@ library xpx_chain_sdk.api.dto; import 'package:fixnum/fixnum.dart'; - -import '../../xpx_sdk.dart'; -import '../../xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; part 'dto/account_dto.dart'; part 'dto/account_metadata_v2.dart'; diff --git a/lib/src/api/dto/mosaic_levy_dto.dart b/lib/src/api/dto/mosaic_levy_dto.dart index e37fca8..7d4b080 100644 --- a/lib/src/api/dto/mosaic_levy_dto.dart +++ b/lib/src/api/dto/mosaic_levy_dto.dart @@ -14,6 +14,7 @@ class MosaicLevyDTO { mosaicId = UInt64DTO.fromJson(json['mosaicId']); fee = UInt64DTO.fromJson(json['fee']); } + late final int type; late final String recipient; late final UInt64DTO mosaicId; diff --git a/lib/src/api/dto/transaction_count_dto.dart b/lib/src/api/dto/transaction_count_dto.dart index 43b1eeb..88d48b9 100644 --- a/lib/src/api/dto/transaction_count_dto.dart +++ b/lib/src/api/dto/transaction_count_dto.dart @@ -10,6 +10,7 @@ class TransactionCountDTO { type = json['type'] as int; count = json['count'] as int; } + late final int type; late final int count; } diff --git a/lib/src/api/dto/transaction_dto.dart b/lib/src/api/dto/transaction_dto.dart index 44cf627..114a028 100644 --- a/lib/src/api/dto/transaction_dto.dart +++ b/lib/src/api/dto/transaction_dto.dart @@ -52,7 +52,6 @@ class AggregateTransactionInfoDTO { AggregateTransactionInfoDTO.fromJson(Map json) { meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - transaction = json['transaction'] != null ? AggregateTransactionDTO.fromJson(json['transaction']) : null; @@ -266,12 +265,13 @@ class AggregateTransactionDTO extends AbstractTransactionDTO { deadline = UInt64DTO.fromJson(json['deadline']); cosignatures = AggregateTransactionCosignatureDTO.listFromJson( json['cosignatures'].cast()); - print(json['transactions']); - transactions = txnDeserialize(json['transactions'], 'List'); + if (json['transactions'] != null) { + transactions = txnDeserialize(json['transactions'], 'List'); + } } List? cosignatures; - List? transactions; + List transactions = []; @override Map toJson() => { diff --git a/lib/src/api/metadata_query_params.dart b/lib/src/api/metadata_query_params.dart index 40a0f92..c2ccba0 100644 --- a/lib/src/api/metadata_query_params.dart +++ b/lib/src/api/metadata_query_params.dart @@ -7,19 +7,19 @@ part of xpx_chain_sdk.api; class MetadataSortingField { - MetadataSortingField(this.value); + MetadataSortingField(this._value); - static MetadataSortingField VALUE = + static MetadataSortingField value = MetadataSortingField('metadataEntry.value'); - static MetadataSortingField VALUE_SIZE = + static MetadataSortingField valueSize = MetadataSortingField('metadataEntry.valueSize'); - String value; + final String _value; @override - String toString() => value; + String toString() => _value; - String toJson() => value; + String toJson() => _value; } class MetadataFieldOrder { diff --git a/lib/src/api/transaction_query_params.dart b/lib/src/api/transaction_query_params.dart index 29617b2..ce36ed6 100644 --- a/lib/src/api/transaction_query_params.dart +++ b/lib/src/api/transaction_query_params.dart @@ -68,7 +68,7 @@ class TransactionQueryParams { int? pageSize; int? ageNumber; List? type; - bool? embedded; + bool embedded = false; Order_v2? order; TransactionSortingField? sortField; Height? toHeight; @@ -78,6 +78,7 @@ class TransactionQueryParams { String? recipientAddress; String? address; String? publicKey; + bool firstLevel = true; void updateFieldOrder(TransactionFieldOrder transactionFieldOrder) { sortField = transactionFieldOrder.sortingField; @@ -86,8 +87,15 @@ class TransactionQueryParams { Iterable toQueryParams() { final params = []; - toJson() - .forEach((key, value) => params.add(QueryParam(key, value.toString()))); + toJson().forEach((key, value) { + if (value is List) { + for (var element in value) { + params.add(QueryParam('$key%5B%5D', element.toString())); + } + } else { + params.add(QueryParam(key, value.toString())); + } + }); return params; } @@ -115,6 +123,7 @@ class TransactionQueryParams { writeNotNull('signerPublicKey', signerPublicKey); writeNotNull('recipientAddress', recipientAddress); writeNotNull('address', address); + writeNotNull('firstLevel', firstLevel); writeNotNull('publicKey', publicKey); return val; diff --git a/lib/src/model.dart b/lib/src/model.dart index 6b774ac..848d966 100644 --- a/lib/src/model.dart +++ b/lib/src/model.dart @@ -12,7 +12,9 @@ export 'package:xpx_chain_sdk/src/model/blockchain.dart'; export 'package:xpx_chain_sdk/src/model/entity_types.dart'; export 'package:xpx_chain_sdk/src/model/exchange.dart'; export 'package:xpx_chain_sdk/src/model/message.dart'; +export 'package:xpx_chain_sdk/src/model/metadata.dart'; export 'package:xpx_chain_sdk/src/model/mosaic.dart'; +export 'package:xpx_chain_sdk/src/model/multisig.dart'; export 'package:xpx_chain_sdk/src/model/namespace.dart'; export 'package:xpx_chain_sdk/src/model/network.dart'; export 'package:xpx_chain_sdk/src/model/node.dart'; diff --git a/lib/src/model/account.dart b/lib/src/model/account.dart index 164329d..4da69fe 100644 --- a/lib/src/model/account.dart +++ b/lib/src/model/account.dart @@ -12,8 +12,7 @@ import 'package:base32/base32.dart'; import 'package:convert/convert.dart' show hex; import 'package:pointycastle/api.dart'; import 'package:sha3/sha3.dart'; -import 'package:xpx_chain_sdk/xpx_sdk.dart'; -import 'package:xpx_chain_sdk/xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; import 'package:xpx_crypto/xpx_crypto.dart' as crypto; import '../api/dto.dart'; diff --git a/lib/src/model/account/account_dto.dart b/lib/src/model/account/account_dto.dart deleted file mode 100644 index 6102135..0000000 --- a/lib/src/model/account/account_dto.dart +++ /dev/null @@ -1,67 +0,0 @@ -part of xpx_chain_sdk.account; - -class AccountDTO { - AccountDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - address = json['address']; - addressHeight = UInt64DTO.fromJson(json['addressHeight']); - _publicKey = json['publicKey']; - _publicKeyHeight = UInt64DTO.fromJson(json['publicKeyHeight']); - _mosaics = MosaicDTO.listFromJson(json['mosaics']); - _accountType = json['accountType']; - _linkedAccountKey = json['linkedAccountKey']; - } - - String address; - - UInt64DTO addressHeight; - - String _publicKey; - - UInt64DTO _publicKeyHeight; - - List _mosaics = []; - - int _accountType; - - String _linkedAccountKey; - - Map toJson() => { - 'address': address, - 'addressHeight': addressHeight, - 'publicKey': _publicKey, - 'publicKeyHeight': _publicKeyHeight, - 'mosaics': _mosaics, - 'accountType': _accountType, - 'linkedAccountKey': _linkedAccountKey, - }; -} - -class AccountInfoDTO { - AccountInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _account = AccountDTO.fromJson(json['account']); - } - - AccountDTO _account; - - Map toJson() => {'account': _account}; -} - -class AccountNamesDTO { - AccountNamesDTO(); - - AccountNamesDTO.fromJson(Map json) { - if (json == null) return; - address = json['address']; - _names = (json['names'] == null) - ? null - : - // ignore: avoid_as - (json['names'] as List).cast(); - } - - /* The address of the account in hexadecimal. */ - String address; - - /* The mosaic linked namespace names. */ - List _names; -} diff --git a/lib/src/model/account/account_model.dart b/lib/src/model/account/account_model.dart deleted file mode 100644 index cebbc15..0000000 --- a/lib/src/model/account/account_model.dart +++ /dev/null @@ -1,182 +0,0 @@ -part of xpx_chain_sdk.account; - -class Account { - Account._(this.publicAccount, this.account); - - /// Create an Account from a given hex private key. - static Account fromPrivateKey(String shex, int networkType) { - final account = crypto.KeyPair.fromHexString(shex); - - final publicKey = ByteUtils.bytesToHex(account.publicKey.raw); - - final publicAccount = PublicAccount.fromPublicKey(publicKey, networkType); - return Account._(publicAccount, account); - } - - /// Create an Account from a given networkType. - static Account random(int networkType) { - final kp = crypto.KeyPair.fromRandomKeyPair(); - final acc = Account.fromPrivateKey(kp.privateKey.toString(), networkType); - final publicAccount = acc.publicAccount; - final account = acc.account; - return Account._(publicAccount, account); - } - - /// Creates an encrypted message from this account to the [recipientPublicAccount]. - EncryptedMessage encryptMessage(String plainTextMessage, PublicAccount recipientPublicAccount) => - EncryptedMessage.create(plainTextMessage, account.privateKey.toString(), recipientPublicAccount.publicKey, - HexUtils.isHex(plainTextMessage)); - - /// Decrypts an encrypted message received by this account from [senderPublicAccount]. - PlainMessage decryptMessage(EncryptedMessage encryptedMessage, PublicAccount senderPublicAccount, - [isHexMessage = false]) => - EncryptedMessage.decrypt( - encryptedMessage, account.privateKey.toString(), senderPublicAccount.publicKey, isHexMessage); - - PublicAccount publicAccount; - crypto.KeyPair account; - - String get publicKey => publicAccount.publicKey; - - Address get address => publicAccount.address; - - @override - String toString() => publicAccount.toString(); - - Map toJson() => {'publicAccount': publicAccount, 'account': account}; - - /// Signs raw data. - String signData(String rawData) { - final String hex = HexUtils.utf8ToHex(rawData); - final Uint8List data = HexUtils.hexToBytes(hex); - final Uint8List signedData = account.sign(data); - return ByteUtils.bytesToHex(signedData); - } - - SignedTransaction signTransaction(Transaction tx, String generationHash) => - signTransactionWith(tx, this, generationHash); - - SignedTransaction signWithCosignatures(Transaction tx, List cosignatories, String generationHash) => - signTransactionWithCosignatures(tx, this, cosignatories, generationHash); - - CosignatureSignedTransaction signCosignatureTransaction(CosignatureTransaction tx) => - signCosignatureTransactionRwa(tx, this); -} - -class PublicAccount { - PublicAccount._(this.publicKey, this.address); - - /// Create an Account from a given publicKey hex string. - static PublicAccount fromPublicKey(String publicKey, int networkType) { - if (publicKey == null || (publicKeySize != publicKey.length && 66 != publicKey.length)) { - throw errInvalidPublicKey; - } - final address = Address.fromPublicKey(publicKey, networkType); - return PublicAccount._(publicKey, address); - } - - String publicKey; - Address address; - - @override - String toString() => '${toJson()}'; - - /// Verifies a signature. - bool verifySignature(String data, String signature) { - if (signature == null) { - throw errNullSignature; - } - if (64 != (signature.length / 2)) { - throw errInvalidSignature; - } - if (signature.length % 2 != 0) { - throw errInvalidHexadecimal; - } - - final kp = crypto.KeyPair(); - kp.publicKey.raw = Uint8List.fromList(hex.decode(publicKey)); - - final String hexData = HexUtils.utf8ToHex(data); - - return kp.verify(Uint8List.fromList(hex.decode(hexData)), Uint8List.fromList(hex.decode(signature))); - } - - Map toJson() => {'address': address, 'publicKey': publicKey}; -} - -class AccountNames { - AccountNames._(this.address, this.names); - - static AccountNames fromDto(AccountNamesDTO dto) { - final address = Address.fromEncoded(dto.address); - final names = (dto._names == null) ? null : dto._names.cast(); - return AccountNames._(address, names); - } - - /* The address of the account in hexadecimal. */ - Address address; - - /* The mosaic linked namespace names. */ - List names; - - static List listFromJson(List json) => - json == null ? [] : json.map(AccountNames.fromDto).toList(); - - @override - String toString() => '{\n' - '\taddress: $address,\n' - '\tnames: $names\n' - ' }'; -} - -class AccountInfo { - AccountInfo.fromDTO(AccountInfoDTO v) { - final List mList = List(v._account._mosaics.length); - for (var i = 0; i < v._account._mosaics.length; i++) { - mList[i] = Mosaic.fromDTO(v._account._mosaics[i]); - } - - address = Address.fromEncoded(v._account.address); - addressHeight = v._account.addressHeight.toUint64(); - publicKey = v._account._publicKey; - publicKeyHeight = v._account._publicKeyHeight.toUint64(); - accountType = v._account._accountType; - linkedAccountKey = v._account._linkedAccountKey; - mosaics = mList; - } - - Address address; - Uint64 addressHeight; - String publicKey; - Uint64 publicKeyHeight; - List mosaics; - int accountType; - String linkedAccountKey; - num reputation; - - @override - String toString() => '{\n' - '\t"address": $address,\n' - '\t"addressHeight": $addressHeight,\n' - '\t"publicKey": $publicKey,\n' - '\t"publicKeyHeight": $publicKeyHeight,\n' - '\t"accountType": $accountType,\n' - '\t"linkedAccountKey": $linkedAccountKey,\n' - '\t"mosaics": $mosaics,\n' - '\t"reputation": $reputation,\n' - '}\n'; - - Map toJson() => { - 'address': address, - 'addressHeight': addressHeight, - 'publicKey': publicKey, - 'publicKeyHeight': publicKeyHeight, - 'accountType': accountType, - 'linkedAccountKey': linkedAccountKey, - 'mosaics': mosaics, - 'reputation': reputation - }; - - static List listFromDTO(List dto) => - dto == null ? null : dto.map((value) => AccountInfo.fromDTO(value)).toList(); -} diff --git a/lib/src/model/account/account_properties.dart b/lib/src/model/account/account_properties.dart index b1bf8c7..24b99ff 100644 --- a/lib/src/model/account/account_properties.dart +++ b/lib/src/model/account/account_properties.dart @@ -95,13 +95,13 @@ class AccountPropertiesMosaicModification { AssetId? assetId; static List listFromJson( - List? json) => - json == null + List json) => + json.isEmpty ? [] : json.map(AccountPropertiesMosaicModification.fromDto).toList(); @override - String toString() => '${toJson()}'; + String toString() => encoder.convert(this); Map toJson() { final data = {}; @@ -129,13 +129,13 @@ class AccountPropertiesAddressModification { Address? address; static List listFromJson( - List? json) => - json == null + List json) => + json.isEmpty ? [] : json.map(AccountPropertiesAddressModification.fromDto).toList(); @override - String toString() => '${toJson()}'; + String toString() => encoder.convert(this); Map toJson() { final data = {}; @@ -164,13 +164,13 @@ class AccountPropertiesEntityTypeModification { TransactionType? transactionType; static List listFromJson( - List? json) => - json == null + List json) => + json.isEmpty ? [] : json.map(AccountPropertiesEntityTypeModification.fromDto).toList(); @override - String toString() => '${toJson()}'; + String toString() => encoder.convert(this); Map toJson() { final data = {}; diff --git a/lib/src/model/account/account_properties_dto.dart b/lib/src/model/account/account_properties_dto.dart deleted file mode 100644 index b876882..0000000 --- a/lib/src/model/account/account_properties_dto.dart +++ /dev/null @@ -1,73 +0,0 @@ -part of xpx_chain_sdk.account; - -class AccountPropertiesDTO { - AccountPropertiesDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - final jsonRaw = json['accountProperties']; - - address = jsonRaw['address']; - - properties = AccountPropertyDTO.listFromJson(jsonRaw['properties']); - } - - String address; - - List properties = []; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertiesDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final Map map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AccountPropertiesDTO.fromJson(value)); - } - return map; - } - - Map toJson() => {'address': address, 'properties': properties}; -} - -class AccountPropertiesInfoDTO { - AccountPropertiesInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - meta = AccountPropertiesMetaDTO.fromJson(json['meta']); - _accountProperties = AccountPropertiesDTO.fromJson(json['accountProperties']); - } - - AccountPropertiesMetaDTO meta; - - AccountPropertiesDTO _accountProperties; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertiesInfoDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final Map map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AccountPropertiesInfoDTO.fromJson(value)); - } - return map; - } - - Map toJson() => {'meta': meta, 'accountProperties': _accountProperties}; -} - -class AccountPropertiesMetaDTO { - AccountPropertiesMetaDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _id = json['id']; - } - - String _id; - - Map toJson() => {'id': _id}; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertiesMetaDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final Map map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AccountPropertiesMetaDTO.fromJson(value)); - } - return map; - } -} diff --git a/lib/src/model/account/account_property_dto.dart b/lib/src/model/account/account_property_dto.dart deleted file mode 100644 index 5707b03..0000000 --- a/lib/src/model/account/account_property_dto.dart +++ /dev/null @@ -1,280 +0,0 @@ -part of xpx_chain_sdk.account; - -class AccountPropertyDTO { - AccountPropertyDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - propertyType = json['propertyType']; - - if (propertyType & 0x01 != 0) { - addresses = List.from(json['values']); - } else if (propertyType & 0x02 != 0) { - mosaicIds = UInt64DTO.listFromJson(json['values']); - } else if (propertyType & 0x04 != 0) { - entityTypes = List.from(json['values']); - } else { - throw errUnknownPropertyType; - } - } - - int propertyType; - List addresses; - List mosaicIds; - List entityTypes; - - Map toJson() { - final data = {}; - data['propertyType'] = propertyType; - data['addresses'] = addresses; - data['mosaicIds'] = mosaicIds; - data['entityTypes'] = entityTypes; - - return data; - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertyDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AccountPropertyDTO.fromJson(value)); - } - return map; - } -} - -class AccountPropertiesAddressModificationDTO { - AccountPropertiesAddressModificationDTO(this.modificationType, this.address); - - AccountPropertiesAddressModificationDTO.fromJson(Map json) { - modificationType = json['type']; - address = json['value']; - } - - int modificationType; - String address; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertiesAddressModificationDTO.fromJson(value)).toList(); -} - -class AccountPropertiesAddressTransactionInfoDTO { - AccountPropertiesAddressTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = - json['transaction'] != null ? AccountPropertiesAddressTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - AccountPropertiesAddressTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class AccountPropertiesAddressTransactionDTO extends AbstractTransactionDTO { - AccountPropertiesAddressTransactionDTO( - {String signature, String signer, int version, int type, List maxFee, List deadline}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - AccountPropertiesAddressTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - propertyType = json['propertyType']; - modifications = AccountPropertiesAddressModificationDTO.listFromJson(json['modifications']); - } - - List modifications; - int propertyType; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['propertyType'] = propertyType; - data['modifications'] = modifications; - - return data; - } -} - -class AccountPropertiesMosaicModificationDTO { - AccountPropertiesMosaicModificationDTO(this.modificationType, this.assetId); - - AccountPropertiesMosaicModificationDTO.fromJson(Map json) { - modificationType = json['type']; - assetId = UInt64DTO.fromJson(json['value']); - } - - int modificationType; - UInt64DTO assetId; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertiesMosaicModificationDTO.fromJson(value)).toList(); -} - -class AccountPropertiesMosaicTransactionInfoDTO { - AccountPropertiesMosaicTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = - json['transaction'] != null ? AccountPropertiesMosaicTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - AccountPropertiesMosaicTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class AccountPropertiesMosaicTransactionDTO extends AbstractTransactionDTO { - AccountPropertiesMosaicTransactionDTO( - {String signature, String signer, int version, int type, List maxFee, List deadline}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - AccountPropertiesMosaicTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - propertyType = json['propertyType']; - modifications = AccountPropertiesMosaicModificationDTO.listFromJson(json['modifications']); - } - - List modifications; - int propertyType; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['propertyType'] = propertyType; - data['modifications'] = modifications; - - return data; - } -} - -class AccountPropertiesEntityTypeModificationDTO { - AccountPropertiesEntityTypeModificationDTO(this.modificationType, this.entityType); - - AccountPropertiesEntityTypeModificationDTO.fromJson(Map json) { - modificationType = json['type']; - entityType = json['value']; - } - - int modificationType; - int entityType; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AccountPropertiesEntityTypeModificationDTO.fromJson(value)).toList(); -} - -class AccountPropertiesEntityTypeTransactionInfoDTO { - AccountPropertiesEntityTypeTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = - json['transaction'] != null ? AccountPropertiesEntityTypeTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - AccountPropertiesEntityTypeTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class AccountPropertiesEntityTypeTransactionDTO extends AbstractTransactionDTO { - AccountPropertiesEntityTypeTransactionDTO( - {String signature, String signer, int version, int type, List maxFee, List deadline}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - AccountPropertiesEntityTypeTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - propertyType = json['propertyType']; - modifications = AccountPropertiesEntityTypeModificationDTO.listFromJson(json['modifications']); - } - - List modifications; - int propertyType; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['propertyType'] = propertyType; - data['modifications'] = modifications; - - return data; - } -} diff --git a/lib/src/model/account/address.dart b/lib/src/model/account/address.dart index fbca44b..95d5f38 100644 --- a/lib/src/model/account/address.dart +++ b/lib/src/model/account/address.dart @@ -38,7 +38,6 @@ class Address { } NetworkType networkType; - String address; String get pretty => _pretty(address); diff --git a/lib/src/model/account/address_model.dart b/lib/src/model/account/address_model.dart deleted file mode 100644 index 5664217..0000000 --- a/lib/src/model/account/address_model.dart +++ /dev/null @@ -1,76 +0,0 @@ -part of xpx_chain_sdk.account; - -class Address { - Address._(this.address, this.networkType); - - static Address fromEncoded(String encoded) { - final pH = hex.decode(encoded); - final parsed = base32.encode(pH); - final a = Address.fromRawAddress(parsed); - return Address._(a.address, a.networkType); - } - - /// Create an [Address] from a given public key. - static Address fromPublicKey(String pKey, int networkType) { - if (networkType == null || NetworkType.getType(networkType) == 0) { - throw ArgumentError('Network type unsupported'); - } - final address = _generateEncodedAddress(pKey, networkType); - return Address._(address, networkType); - } - - /// Create an [Address] from a given raw address - static Address fromRawAddress(String address) { - final addressRaw = address.trim().replaceAll('-', '').toUpperCase(); - - if (addressRaw.length != addressEncodeSize) { - throw ArgumentError('Address $addressRaw has to be $addressEncodeSize characters long'); - } - - return Address._(addressRaw, addressNet[addressRaw[0]]); - } - - int networkType; - - String address; - - String get pretty => _pretty(address); - - Uint8List decode() => base32.decode(address); - - @override - String toString() => '${toJson()}'; - - static String _pretty(final String address) { - final buffer = StringBuffer(); - - for (int i = 0; i < 6; i++) { - // ignore: use_string_buffers - buffer.write(address.substring(i * 6, i * 6 + 6) + '-'); - } - // ignore: join_return_with_assignment - buffer.write(address.substring(address.length - 4)); - return buffer.toString(); - } - - Map toJson() => {'networkType': networkType, 'address': address}; -} - -class Addresses { - Addresses(); - - Addresses.fromJson(Map json) : assert(json != null, 'json must not be null') { - addresses = (json['addresses']).map((item) => item).toList(); - } - - Addresses.fromList(List
list) : assert(list != null, 'list must not be null') { - addresses = list.map((item) => item).toList(); - } - - List
addresses = []; - - @override - String toString() => 'addresses:$addresses'; - - Map toJson() => {'addresses': addresses.map((a) => a.address).toList()}; -} diff --git a/lib/src/model/alias.dart b/lib/src/model/alias.dart index 036f299..41edd6a 100644 --- a/lib/src/model/alias.dart +++ b/lib/src/model/alias.dart @@ -6,7 +6,6 @@ library xpx_chain_sdk.model.alias; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; -part 'alias/alias_internal.dart'; part 'alias/alias_model.dart'; diff --git a/lib/src/model/alias/alias_dto.dart b/lib/src/model/alias/alias_dto.dart deleted file mode 100644 index 17d8f6c..0000000 --- a/lib/src/model/alias/alias_dto.dart +++ /dev/null @@ -1,93 +0,0 @@ -part of xpx_chain_sdk.alias; - -class AddressAliasDTO extends AbstractTransactionDTO { - AddressAliasDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - deadline = UInt64DTO.fromJson(json['deadline']); - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - aliasAction = json['aliasAction']; - address = json['address']; - namespaceId = UInt64DTO.fromJson(json['namespaceId']); - } - - int aliasAction; - String address; - UInt64DTO namespaceId; - - @override - Map toJson() { - final data = {}; - data['aliasAction'] = aliasAction; - data['address'] = address; - data['namespaceId'] = namespaceId; - return data; - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AddressAliasDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AddressAliasDTO.fromJson(value)); - } - return map; - } -} - -class AddressAliasTransactionInfoDTO { - AddressAliasTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = json['transaction'] != null ? AddressAliasDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - AddressAliasDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class AliasDTO { - AliasDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - aliasAction = json['aliasAction']; - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - address = json['address']; - } - - int aliasAction; - UInt64DTO mosaicId; - String address; - - Map toJson() { - final data = {}; - data['aliasAction'] = aliasAction; - data['mosaicId'] = mosaicId; - data['address'] = address; - - return data; - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AliasDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AliasDTO.fromJson(value)); - } - return map; - } -} diff --git a/lib/src/model/alias/alias_internal.dart b/lib/src/model/alias/alias_internal.dart deleted file mode 100644 index 78d91b7..0000000 --- a/lib/src/model/alias/alias_internal.dart +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2018 ProximaX Limited. All rights reserved. - * Use of this source code is governed by the Apache 2.0 - * license that can be found in the LICENSE file. - */ - -part of xpx_chain_sdk.model.alias; - -AliasType getAliasType(int value) { - switch (value) { - case 1: - return AliasType.mosaicAliasType; - case 0: - return AliasType.addressAliasType; - default: - return AliasType.noneAliasType; - } -} diff --git a/lib/src/model/alias/alias_model.dart b/lib/src/model/alias/alias_model.dart index 70780f0..ac7e83e 100644 --- a/lib/src/model/alias/alias_model.dart +++ b/lib/src/model/alias/alias_model.dart @@ -13,6 +13,17 @@ enum AliasType { addressAliasType, } +AliasType getAliasType(int value) { + switch (value) { + case 1: + return AliasType.mosaicAliasType; + case 0: + return AliasType.addressAliasType; + default: + return AliasType.noneAliasType; + } +} + enum AliasActionType { aliasLink, aliasUnlink } extension AliasTypeToInt on AliasType { diff --git a/lib/src/model/blockchain.dart b/lib/src/model/blockchain.dart index 7a1c76c..f24db76 100644 --- a/lib/src/model/blockchain.dart +++ b/lib/src/model/blockchain.dart @@ -6,7 +6,8 @@ library xpx_chain_sdk.model.blockchain; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; + import '../api/dto.dart'; part 'blockchain/block_info.dart'; diff --git a/lib/src/model/blockchain/block_dto.dart b/lib/src/model/blockchain/block_dto.dart deleted file mode 100644 index 68bcd1d..0000000 --- a/lib/src/model/blockchain/block_dto.dart +++ /dev/null @@ -1,137 +0,0 @@ -part of xpx_chain_sdk.blockchain; - -class BlockDTO { - BlockDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - _height = UInt64DTO.fromJson(json['height']); - _timestamp = UInt64DTO.fromJson(json['timestamp']); - _difficulty = UInt64DTO.fromJson(json['difficulty']); - feeMultiplier = json['feeMultiplier']; - _previousBlockHash = json['previousBlockHash']; - _blockTransactionsHash = json['blockTransactionsHash']; - _blockReceiptsHash = json['blockReceiptsHash']; - _stateHash = json['stateHash']; - _beneficiaryPublicKey = json['beneficiary'] != '0000000000000000000000000000000000000000000000000000000000000000' - ? json['beneficiary'] - : null; - feeInterest = json['feeInterest']; - feeInterestDenominator = json['feeInterestDenominator']; - } - - String signature; - - String signer; - - num version; - - num type; - - UInt64DTO _height; - - UInt64DTO _timestamp; - - UInt64DTO _difficulty; - - int feeMultiplier; - - int feeInterest; - - int feeInterestDenominator; - - String _previousBlockHash; - - String _blockTransactionsHash; - - String _blockReceiptsHash; - - String _stateHash; - - String _beneficiaryPublicKey; - - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['height'] = _height; - data['timestamp'] = _timestamp; - data['difficulty'] = _difficulty; - data['feeMultiplier'] = feeMultiplier; - data['feeMultiplier'] = feeMultiplier; - data['blockTransactionsHash'] = _blockTransactionsHash; - data['blockReceiptsHash'] = _blockReceiptsHash; - data['stateHash'] = _stateHash; - data['beneficiary'] = _beneficiaryPublicKey; - - return data; - } -} - -class BlockInfoDTO { - BlockInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - meta = BlockMetaDTO.fromJson(json['meta']); - _block = BlockDTO.fromJson(json['block']); - } - - BlockMetaDTO meta; - - BlockDTO _block; - - Map toJson() { - final data = {}; - data['meta'] = meta; - data['block'] = _block; - - return data; - } -} - -class BlockMetaDTO { - BlockMetaDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _hash = json['hash']; - _generationHash = json['generationHash']; - _totalFee = UInt64DTO.fromJson(json['totalFee']); - _numTransactions = json['numTransactions']; - } - - String _hash; - - String _generationHash; - - UInt64DTO _totalFee; - - num _numTransactions; - - Map toJson() { - final data = {}; - data['hash'] = _hash; - data['generationHash'] = _generationHash; - data['totalFee'] = _totalFee; - data['numTransactions'] = _numTransactions; - - return data; - } -} - -class BlockchainScoreDTO { - BlockchainScoreDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _scoreHigh = UInt64DTO.fromJson(json['scoreHigh']); - _scoreLow = UInt64DTO.fromJson(json['scoreLow']); - } - - UInt64DTO _scoreHigh; - - UInt64DTO _scoreLow; - - Map toJson() { - final data = {}; - data['scoreHigh'] = _scoreHigh; - data['scoreLow'] = _scoreLow; - - return data; - } -} diff --git a/lib/src/model/blockchain/block_model.dart b/lib/src/model/blockchain/block_model.dart deleted file mode 100644 index 625712b..0000000 --- a/lib/src/model/blockchain/block_model.dart +++ /dev/null @@ -1,168 +0,0 @@ -part of xpx_chain_sdk.blockchain; - -class BlockInfo { - BlockInfo.fromDTO(BlockInfoDTO v) { - networkType = extractNetworkType(v._block.version); - blockHash = v.meta._hash; - generationHash = v.meta._generationHash; - totalFee = v.meta._totalFee.toUint64(); - numTransactions = v.meta._numTransactions; - signature = v._block.signature; - signer = PublicAccount.fromPublicKey(v._block.signer, networkType); - version = v._block.version; - type = v._block.type; - height = v._block._height.toUint64(); - timestamp = DateTime.fromMillisecondsSinceEpoch( - v._block._timestamp.toUint64().toInt() + timestampNemesisBlock.toUtc().millisecondsSinceEpoch); - difficulty = v._block._difficulty.toUint64(); - feeMultiplier = v._block.feeMultiplier; - previousBlockHash = v._block._previousBlockHash; - blockTransactionsHash = v._block._blockTransactionsHash; - blockReceiptsHash = v._block._blockReceiptsHash; - stateHash = v._block._stateHash; - beneficiary = v._block._beneficiaryPublicKey != null - ? PublicAccount.fromPublicKey(v._block._beneficiaryPublicKey, networkType) - : null; - feeInterest = v._block.feeInterest; - feeInterestDenominator = v._block.feeInterestDenominator; - } - - int networkType; - String blockHash; - String generationHash; - Uint64 totalFee; - int numTransactions; - String signature; - PublicAccount signer; - int version; - int type; - Uint64 height; - DateTime timestamp; - Uint64 difficulty; - int feeMultiplier; - String previousBlockHash; - String blockTransactionsHash; - String blockReceiptsHash; - String stateHash; - PublicAccount beneficiary; - int feeInterest; - int feeInterestDenominator; - - @override - String toString() { - final sb = StringBuffer() - ..writeln('\n{') - ..writeln('\tnetworkType: $networkType,') - ..writeln('\tblockHash: $blockHash,') - ..writeln('\tgenerationHash: $generationHash,') - ..writeln('\ttotalFee: $totalFee,') - ..writeln('\tnumTransactions: $numTransactions,') - ..writeln('\tsignature: $signature,') - ..writeln('\tsigner: $signer,') - ..writeln('\tversion: $version,') - ..writeln('\ttype: $type,') - ..writeln('\theight: $height,') - ..writeln('\ttimestamp: $timestamp,') - ..writeln('\tdifficulty: $difficulty,') - ..writeln('\tfeeMultiplier: $feeMultiplier,') - ..writeln('\tpreviousBlockHash: $previousBlockHash,') - ..writeln('\tblockTransactionsHash: $blockTransactionsHash,') - ..writeln('\tblockReceiptsHash: $blockReceiptsHash,') - ..writeln('\tstateHash: $stateHash,') - ..writeln('\tbeneficiary: $beneficiary') - ..writeln('\tfeeInterest: $feeInterest') - ..writeln('\tfeeInterestDenominator: $feeInterestDenominator') - ..write('}'); - return sb.toString(); - } - - Map toJson() { - final data = {}; - data['networkType'] = networkType; - data['hash'] = blockHash; - data['generationHash'] = generationHash; - data['totalFee'] = totalFee; - data['numTransactions'] = numTransactions; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['height'] = height; - data['timestamp'] = timestamp; - data['difficulty'] = difficulty; - data['feeMultiplier'] = feeMultiplier; - data['previousBlockHash'] = previousBlockHash; - data['blockTransactionsHash'] = blockTransactionsHash; - data['blockReceiptsHash'] = blockReceiptsHash; - data['stateHash'] = stateHash; - data['beneficiary'] = beneficiary.publicKey; - data['feeInterest'] = feeInterest; - data['beneficiary'] = feeInterestDenominator; - return data; - } - - static List listFromDTO(List json) => - json == null ? null : json.map((value) => BlockInfo.fromDTO(value)).toList(); -} - -class Height { - Height.fromDTO(HeightDTO v) { - height = v._height.toUint64(); - } - - Uint64 height; - - @override - String toString() => '$height'; - - Map toJson() { - final data = {}; - data['height'] = height; - return data; - } -} - -class BlockchainScore { - BlockchainScore.fromDTO(BlockchainScoreDTO dto) : assert(dto != null, 'dto must not be null') { - score = Uint64.fromInts(dto._scoreLow.toUint64().toInt(), dto._scoreHigh.toUint64().toInt()); - } - - Uint64 score; - - @override - String toString() => '$score'; - - Map toJson() { - final data = {}; - data['score'] = score; - return data; - } -} - -class BlockchainStorageInfo { - BlockchainStorageInfo.fromJson(Map json) : assert(json != null, 'json must not be null') { - numBlocks = json['numBlocks']; - numTransactions = json['numTransactions']; - numAccounts = json['numAccounts']; - } - - int numBlocks; - - int numTransactions; - - int numAccounts; - - @override - String toString() => '{numBlocks:$numBlocks,' - ' numTransactions:$numTransactions,' - ' numAccounts:$numAccounts}'; - - Map toJson() { - final data = {}; - data['numBlocks'] = numBlocks; - data['numTransactions'] = numTransactions; - data['numAccounts'] = numAccounts; - - return data; - } -} diff --git a/lib/src/model/blockchain/height_dto.dart b/lib/src/model/blockchain/height_dto.dart deleted file mode 100644 index e374881..0000000 --- a/lib/src/model/blockchain/height_dto.dart +++ /dev/null @@ -1,17 +0,0 @@ -part of xpx_chain_sdk.blockchain; - -class HeightDTO { - HeightDTO(this._height); - - HeightDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _height = UInt64DTO.fromJson(json['height']); - } - - UInt64DTO _height; - - Map toJson() { - final data = {}; - data['height'] = _height; - return data; - } -} diff --git a/lib/src/model/blockchain/merkle_proof_info_dto.dart b/lib/src/model/blockchain/merkle_proof_info_dto.dart deleted file mode 100644 index 829a6d6..0000000 --- a/lib/src/model/blockchain/merkle_proof_info_dto.dart +++ /dev/null @@ -1,31 +0,0 @@ -part of xpx_chain_sdk.blockchain; - -class MerkleProofInfoDTO { - MerkleProofInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _payload = MerkleProofInfoPayload.fromJson(json['payload']); - type = json['type']; - } - - MerkleProofInfoPayload _payload; - - String type; - - Map toJson() { - final data = {}; - data['payload'] = _payload; - data['type'] = type; - - return data; - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => MerkleProofInfoDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = MerkleProofInfoDTO.fromJson(value)); - } - return map; - } -} diff --git a/lib/src/model/entity_types.dart b/lib/src/model/entity_types.dart index 323d2bb..d63f623 100644 --- a/lib/src/model/entity_types.dart +++ b/lib/src/model/entity_types.dart @@ -6,7 +6,7 @@ library xpx_chain_sdk.model.entity_types; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; typedef Amount = Uint64; typedef Height = Uint64; diff --git a/lib/src/model/exchange.dart b/lib/src/model/exchange.dart index 6c8e556..3ee23fe 100644 --- a/lib/src/model/exchange.dart +++ b/lib/src/model/exchange.dart @@ -7,11 +7,8 @@ library xpx_chain_sdk.model.exchange; import 'package:flat_buffers/flat_buffers.dart' as fb; -import 'package:xpx_chain_sdk/imp/buffer.dart'; -import 'package:xpx_chain_sdk/src/model/mosaic.dart'; -import 'package:xpx_chain_sdk/src/model/transaction.dart'; -import 'package:xpx_chain_sdk/src/model/uint64.dart'; -import 'package:xpx_chain_sdk/xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/src/model/transaction/buffer/buffer.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; import '../api/dto.dart'; diff --git a/lib/src/model/exchange/exchange_dto.dart b/lib/src/model/exchange/exchange_dto.dart deleted file mode 100644 index ff46b8b..0000000 --- a/lib/src/model/exchange/exchange_dto.dart +++ /dev/null @@ -1,262 +0,0 @@ -part of xpx_chain_sdk.exchange; - -class OfferDTO { - OfferDTO.fromJson(Map json) { - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - mosaicAmount = UInt64DTO.fromJson(json['mosaicAmount']); - cost = UInt64DTO.fromJson(json['cost']); - type = OfferType(json['type']); - } - - UInt64DTO mosaicId; - UInt64DTO mosaicAmount; - UInt64DTO cost; - OfferType type; -} - -class RemoveOfferDTO { - RemoveOfferDTO.fromJson(Map json) { - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - offerType = OfferType(json['offerType']); - } - - UInt64DTO mosaicId; - OfferType offerType; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => RemoveOfferDTO.fromJson(value)).toList(); -} - -class AddOfferDTO extends OfferDTO { - AddOfferDTO.fromJson(Map json) : super.fromJson(json) { - duration = UInt64DTO.fromJson(json['duration']); - } - - UInt64DTO duration; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AddOfferDTO.fromJson(value)).toList(); -} - -class ConfirmationOfferDTO extends OfferDTO { - ConfirmationOfferDTO.fromJson(Map json) : super.fromJson(json) { - owner = json['owner']; - } - - String owner; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => ConfirmationOfferDTO.fromJson(value)).toList(); -} - -class OfferInfoDTO { - OfferInfoDTO.fromJson(Map json) : super() { - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - amount = UInt64DTO.fromJson(json['amount']); - priceDenominator = UInt64DTO.fromJson(json['initialAmount']); - priceNumerator = UInt64DTO.fromJson(json['initialCost']); - deadline = UInt64DTO.fromJson(json['deadline']); - price = json['price']; - owner = json['owner']; - type = json['type']; - } - - UInt64DTO mosaicId; - UInt64DTO amount; - UInt64DTO priceNumerator; - UInt64DTO priceDenominator; - UInt64DTO deadline; - String owner; - int type; - int price; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => OfferInfoDTO.fromJson(value)).toList(); -} - -class ExchangeDTO { - ExchangeDTO.fromJson(Map json) { - json = json['exchange']; - owner = json['owner']; - buyOffers = OfferInfoDTO.listFromJson(json['buyOffers']); - sellOffers = OfferInfoDTO.listFromJson(json['sellOffers']); - } - - String owner; - List buyOffers; - List sellOffers; -} - -class ExchangeOfferTransactionInfoDTO { - ExchangeOfferTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - transaction = json['transaction'] != null ? ExchangeOfferTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - ExchangeOfferTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class ExchangeOfferTransactionDTO extends AbstractTransactionDTO { - ExchangeOfferTransactionDTO( - {String signature, String signer, int version, int type, List maxFee, List deadline}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - ExchangeOfferTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - offers = ConfirmationOfferDTO.listFromJson(json['offers']); - } - - List offers; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['owner'] = offers; - return data; - } -} - -class AddExchangeOfferTransactionInfoDTO { - AddExchangeOfferTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - transaction = json['transaction'] != null ? AddExchangeOfferTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - AddExchangeOfferTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class AddExchangeOfferTransactionDTO extends AbstractTransactionDTO { - AddExchangeOfferTransactionDTO( - {String signature, String signer, int version, int type, List maxFee, List deadline}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - AddExchangeOfferTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - offers = AddOfferDTO.listFromJson(json['offers']); - } - - List offers; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - return data; - } -} - -class RemoveExchangeOfferTransactionInfoDTO { - RemoveExchangeOfferTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - transaction = json['transaction'] != null ? RemoveExchangeOfferTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - RemoveExchangeOfferTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class RemoveExchangeOfferTransactionDTO extends AbstractTransactionDTO { - RemoveExchangeOfferTransactionDTO( - {String signature, String signer, int version, int type, List maxFee, List deadline}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - RemoveExchangeOfferTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - offers = RemoveOfferDTO.listFromJson(json['offers']); - } - - List offers; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['offers'] = offers; - - return data; - } -} diff --git a/lib/src/model/message.dart b/lib/src/model/message.dart index 62609f6..96cc899 100644 --- a/lib/src/model/message.dart +++ b/lib/src/model/message.dart @@ -10,9 +10,9 @@ import 'dart:convert' show utf8; import 'dart:typed_data'; import 'package:convert/convert.dart' show hex; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; import 'package:xpx_crypto/xpx_crypto.dart' as crypto; -import '../../xpx_sdk.dart'; import '../api/dto.dart'; part 'message/encrypted_message.dart'; diff --git a/lib/src/model/message/message_dto.dart b/lib/src/model/message/message_dto.dart deleted file mode 100644 index 777b825..0000000 --- a/lib/src/model/message/message_dto.dart +++ /dev/null @@ -1,14 +0,0 @@ -part of xpx_chain_sdk.message; - -// Message -class MessageDTO { - MessageDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - type = json['type']; - _payload = json['payload']; - } - - int type; - String _payload; - - Map toJson() => {'type': type, 'tayload': _payload}; -} diff --git a/lib/src/model/message/message_model.dart b/lib/src/model/message/message_model.dart deleted file mode 100644 index 4e15a40..0000000 --- a/lib/src/model/message/message_model.dart +++ /dev/null @@ -1,155 +0,0 @@ -part of xpx_chain_sdk.message; - -class Message { - Message(this.type, this.payload); - - Message.fromDTO(MessageDTO dto) { - if (dto?._payload == null) { - return; - } - if (_hexadecimal.hasMatch(dto._payload)) { - payload = hex.decode(dto._payload); - } else { - payload = Uint8List.fromList(dto._payload.codeUnits); - } - type = MessageType.getType(dto.type); - } - - MessageType type; - Uint8List payload; - - String get payloadAsString => utf8.decode(payload); - - @override - String toString() => '${toJson()}'; - - Map toJson() { - final data = {}; - data['type'] = type; - data['payload'] = payloadAsString; - return data; - } -} - -class MessageType { - const MessageType(this.value); - - static const String invalidType = 'invalid message type'; - - static const MessageType unencrypted = MessageType(0x00); - - static const MessageType encrypted = MessageType(0x01); - - static final List values = [unencrypted, encrypted]; - - final int value; - - static MessageType getType(final int value) { - for (var i = 0; i < values.length; i++) { - if (values[i].value == value) { - return values[i]; - } - } - - throw ArgumentError(invalidType); - } - - @override - String toString() => '$value'; - - Map toJson() => {'value': value}; -} - -class PlainMessage extends Message { - factory PlainMessage({final Uint8List bytes, final String payload}) { - if (payload == null && bytes == null) { - throw ArgumentError('The message payload must not be null'); - } - - if (bytes != null && bytes.isNotEmpty) { - return PlainMessage._(bytes); - } - - if (_hexadecimal.hasMatch(payload)) { - return PlainMessage._(Uint8List.fromList(payload.codeUnits)); - } - return PlainMessage._(Uint8List.fromList(payload.codeUnits)); - } - - PlainMessage._(Uint8List payload) : super(MessageType.unencrypted, payload); - - static final PlainMessage empty = PlainMessage(payload: ''); -} - -/// An encrypted message model defines a secure message that has been encrypted using -/// the Symbol's SDK libraries. -/// -/// Please note: -/// The strategy to encrypt and decrypt should be consistent between the different SDKs. -/// A client may send a transaction using a different encryption strategy than the recipient. -/// Even though the same encryption algorithm is used, the outcome may still be different -/// depending on the encoding process. -/// -/// The encryption strategy this SDK uses is UTF-8 and hex encodings: -/// "plain text" string -> utf8 byte array -> encrypted byte array -> hex string -class EncryptedMessage extends Message { - // private constructor - EncryptedMessage._(String encryptedPayload) : super(MessageType.encrypted, HexUtils.hexToBytes(encryptedPayload)); - - // Developer note: - // If one to allow to create a EncryptedMessage object using this constructor, make sure to - // put in place a check to see if the payload (in bytes) is actually encrypted or not. - // factory EncryptedMessage(final Uint8List encryptedPayload) { - // if (encryptedPayload == null) { - // throw new ArgumentError('The message payload must not be null'); - // } - // - // return new EncryptedMessage._(encryptedPayload); - // } - - /// Creates an encrypted message from [plainTextMessage]. - /// - /// The message is encrypted using a shared key generated by the [senderPrivateKey] and - /// the [recipientPublicKey]. The recipient can decrypt this message using this shared key by - /// taking the sender's public key and the recipient's public key. - static EncryptedMessage create(String plainTextMessage, String senderPrivateKey, String recipientPublicKey, - [isHexMessage = false]) { - ArgumentError.checkNotNull(plainTextMessage); - - // Encrypts the message - final String encryptedPayload = - crypto.encryptMessage(plainTextMessage, senderPrivateKey, recipientPublicKey, isHexMessage); - - return EncryptedMessage._(encryptedPayload); - } - - /// Creates an encrypted message from [payload]. - /// - /// The [payload] is a hex encoded string. - static EncryptedMessage fromPayload(final String payload) { - if (!HexUtils.isHex(payload)) { - throw new ArgumentError('message payload is not a valid hex string'); - } - - return new EncryptedMessage._(payload); - } - - /// Decrypts an [encryptedMessage] sent for the [networkType]. - /// - /// Returns a UTF-8 formatted string. - static PlainMessage decrypt(EncryptedMessage encryptedMessage, String recipientPrivateKey, String senderPublicKey, - [isHexMessage = false]) { - ArgumentError.checkNotNull(encryptedMessage); - ArgumentError.checkNotNull(encryptedMessage.payload); - - final String decrypted = crypto.decryptMessage( - ByteUtils.bytesToHex(encryptedMessage.payload), recipientPrivateKey, senderPublicKey, isHexMessage); - return PlainMessage(payload: decrypted); - } - - @override - String get payloadAsString => hex.encode(payload); - - @override - String toString() => '{type: $type, payload: ${ByteUtils.bytesToHex(payload)}}'; -} diff --git a/lib/src/model/metadata.dart b/lib/src/model/metadata.dart index dbc5c72..df77306 100644 --- a/lib/src/model/metadata.dart +++ b/lib/src/model/metadata.dart @@ -6,7 +6,8 @@ library xpx_chain_sdk.model.metadata; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; + import '../api/dto.dart'; part 'metadata/address_metadata.dart'; diff --git a/lib/src/model/metadata/metadata_type.dart b/lib/src/model/metadata/metadata_type.dart index 2ebf4be..662d9cd 100644 --- a/lib/src/model/metadata/metadata_type.dart +++ b/lib/src/model/metadata/metadata_type.dart @@ -16,6 +16,7 @@ enum MetadataType { extension MetadataTypeExt on MetadataType { int get toInt => index; + String get getName { switch (this) { case MetadataType.metadataAccount: diff --git a/lib/src/model/mosaic.dart b/lib/src/model/mosaic.dart index 182f7ea..0f0a870 100644 --- a/lib/src/model/mosaic.dart +++ b/lib/src/model/mosaic.dart @@ -12,9 +12,8 @@ import 'dart:typed_data' show Uint8List; import 'package:convert/convert.dart' show hex; import 'package:fixnum/fixnum.dart'; import 'package:sha3/sha3.dart'; -import 'package:xpx_chain_sdk/xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; -import '../../xpx_sdk.dart'; import '../api/dto.dart'; part 'mosaic/mosaic.dart'; diff --git a/lib/src/model/mosaic/mosaic_dto.dart b/lib/src/model/mosaic/mosaic_dto.dart deleted file mode 100644 index 45db223..0000000 --- a/lib/src/model/mosaic/mosaic_dto.dart +++ /dev/null @@ -1,317 +0,0 @@ -part of xpx_chain_sdk.mosaic; - -class MosaicDTO { - MosaicDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _id = UInt64DTO.fromJson(json['id']); - _amount = UInt64DTO.fromJson(json['amount']); - } - - UInt64DTO _id; - - UInt64DTO _amount; - - Map toJson() { - final data = {}; - data['id'] = _id; - data['amount'] = _amount; - - return data; - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => MosaicDTO.fromJson(value)).toList(); -} - -class MosaicInfoDTO { - MosaicInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - meta = MosaicMetaDTO.fromJson(json['meta']); - _mosaic = MosaicDefinitionDTO.fromJson(json['mosaic']); - } - - MosaicMetaDTO meta; - - MosaicDefinitionDTO _mosaic; - - Map toJson() { - final data = {}; - data['meta'] = meta; - data['mosaic'] = _mosaic; - - return data; - } -} - -class MosaicMetaDTO { - MosaicMetaDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _id = json['id']; - } - - String _id; - - Map toJson() => {'id': _id}; -} - -class MosaicDefinitionDTO { - MosaicDefinitionDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - _supply = UInt64DTO.fromJson(json['supply']); - _height = UInt64DTO.fromJson(json['height']); - _owner = json['owner']; - _revision = json['revision']; - - if (json['properties'] != null) { - _properties = []; - for (int i = 0; i < 3; i++) { - _properties.add(_MosaicPropertyDTO.fromJson(json['properties'][i])); - } - } - } - - UInt64DTO mosaicId; - UInt64DTO _supply; - UInt64DTO _height; - String _owner; - int _revision; - List<_MosaicPropertyDTO> _properties; -} - -class MosaicNameDTO { - MosaicNameDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _parentId = json['parentId'] != null ? UInt64DTO.fromJson(json['parentId']) : null; - - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - _names = List.from(json['names']); - } - - UInt64DTO _parentId; - - UInt64DTO mosaicId; - - List _names; - - Map toJson() { - final data = {}; - data['parentId'] = _parentId; - data['mosaicId'] = mosaicId; - data['names'] = _names; - - return data; - } -} - -class _MosaicPropertyDTO { - _MosaicPropertyDTO.fromJson(Map value) { - _id = value['id']; - _value = UInt64DTO.fromJson(value['value']); - } - - int _id; - UInt64DTO _value; - - static List<_MosaicPropertyDTO> listFromJson(List json) => - json == null ? null : json.map((value) => _MosaicPropertyDTO.fromJson(value)).toList(); - - Map toJson() { - final data = {}; - data['id'] = _id; - data['value'] = _value; - - return data; - } -} - -class MosaicDefinitionTransactionInfoDTO { - MosaicDefinitionTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - transaction = json['transaction'] != null ? MosaicDefinitionTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - MosaicDefinitionTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class MosaicDefinitionTransactionDTO extends AbstractTransactionDTO { - MosaicDefinitionTransactionDTO( - {String signature, - String signer, - int version, - int type, - List maxFee, - List deadline, - this.mosaicId, - this.mosaicNonce, - this.properties, - this.duration}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - MosaicDefinitionTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - mosaicNonce = json['mosaicNonce']; - properties = _MosaicPropertyDTO.listFromJson(json['properties']); - duration = UInt64DTO.fromJson(json['duration']); - } - - UInt64DTO mosaicId; - int mosaicNonce; - List<_MosaicPropertyDTO> properties; - UInt64DTO duration; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['duration'] = duration; - return data; - } -} - -class MosaicSupplyChangeTransactionInfoDTO { - MosaicSupplyChangeTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = json['transaction'] != null ? _MosaicSupplyChangeTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - _MosaicSupplyChangeTransactionDTO transaction; - - Map toJson() { - final data = {}; - - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class _MosaicSupplyChangeTransactionDTO extends AbstractTransactionDTO { - _MosaicSupplyChangeTransactionDTO( - {String signature, - String signer, - int version, - int type, - List maxFee, - List deadline, - this.mosaicId, - this.direction, - this.delta}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - } - - _MosaicSupplyChangeTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - direction = json['direction']; - delta = UInt64DTO.fromJson(json['delta']); - } - - UInt64DTO mosaicId; - int direction; - UInt64DTO delta; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['mosaicId'] = mosaicId; - data['direction'] = direction; - data['delta'] = delta; - return data; - } -} - -class MosaicAliasTransactionInfoDTO { - MosaicAliasTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = json['transaction'] != null ? MosaicAliasDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - MosaicAliasDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class MosaicAliasDTO extends AbstractTransactionDTO { - MosaicAliasDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - deadline = UInt64DTO.fromJson(json['deadline']); - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - aliasAction = json['aliasAction']; - mosaicId = UInt64DTO.fromJson(json['mosaicId']); - namespaceId = UInt64DTO.fromJson(json['namespaceId']); - } - - int aliasAction; - UInt64DTO mosaicId; - UInt64DTO namespaceId; - - @override - Map toJson() { - final data = {}; - data['aliasAction'] = aliasAction; - data['mosaicId'] = mosaicId; - data['namespaceId'] = namespaceId; - return data; - } -} diff --git a/lib/src/model/mosaic/mosaic_model.dart b/lib/src/model/mosaic/mosaic_model.dart deleted file mode 100644 index 255e806..0000000 --- a/lib/src/model/mosaic/mosaic_model.dart +++ /dev/null @@ -1,243 +0,0 @@ -part of xpx_chain_sdk.mosaic; - -enum MosaicPropertyId { - mosaicPropertyFlagsId, - mosaicPropertyDivisibilityId, - mosaicPropertyDurationId, -} - -class Mosaic { - Mosaic(this.assetId, this.amount) { - if (assetId == null) { - throw errNullMosaicId; - } else if (amount == null) { - throw errNullMosaicAmount; - } else if (amount.isZero) { - throw errNullMosaicAmount; - } else { - assetId = assetId; - amount = amount; - } - } - - Mosaic.fromDTO(MosaicDTO v) { - assetId = MosaicId.fromId(v._id.toUint64()); - amount = v._amount.toUint64(); - } - - AssetId assetId; - Uint64 amount; - - @override - String toString() => '\n\t{\n' - '\t"assetId": ${assetId.toHex()},\n' - '\t"amount": $amount\n' - '\t}'; - - Map toJson() { - final data = {}; - data['id'] = assetId.toHex(); - data['amount'] = amount; - return data; - } - - static List listFromDTO(List json) => - json == null ? [] : json.map((value) => Mosaic.fromDTO(value)).toList(); -} - -class MosaicId extends AssetId { - factory MosaicId({final Uint64 id}) { - if (id == null) { - throw errNullId; - } - - return MosaicId._(id); - } - - const MosaicId._(final Uint64 id) : super(id); - - MosaicId.fromId(final Uint64 id) : super(id); - - MosaicId.fromUint64(final Uint64 bigInt) : super(bigInt); - - static MosaicId fromHex(final String hex) { - if (hex.isEmpty) { - throw ArgumentError('The hexString must not be null or empty'); - } - - if (0 != (hex.length % 2)) { - throw ArgumentError('invalid hex'); - } - final Uint64 bigInt = Uint64.fromHex(hex); - return MosaicId._(bigInt); - } - - static MosaicId fromNonceAndOwner(int nonce, String ownerPublicKey) { - if (ownerPublicKey.length != 64) { - throw errInvalidOwnerPublicKey; - } - - return MosaicId._(_generateMosaicId(nonce, ownerPublicKey)); - } - - @override - String toString() => '${toHex()}'; - - @override - int get hashCode => 'MosaicId'.hashCode ^ super.hashCode; - - @override - bool operator ==(final other) => - identical(this, other) || other is MosaicId && runtimeType == other.runtimeType && toBytes() == other.toBytes(); -} - -class MosaicIds { - MosaicIds.fromList(List list) : assert(list != null, 'list must not be null') { - _list = list.map((item) => item).toList(); - } - - List _list = []; - - @override - String toString() => '{mosaicIds:$_list}'; - - Map toJson() { - final data = {}; - data['mosaicIds'] = _list.map((id) => id.toHex()).toList(); - return data; - } -} - -class MosaicInfo { - MosaicInfo.fromDTO(MosaicInfoDTO dto) : assert(dto != null, 'dto must not be null') { - mosaicId = MosaicId(id: dto._mosaic.mosaicId.toUint64()); - supply = dto._mosaic._supply.toUint64(); - height = dto._mosaic._height.toUint64(); - owner = dto._mosaic._owner; - revision = dto._mosaic._revision; - properties = MosaicProperties.fromDTO(dto._mosaic._properties); - } - - MosaicId mosaicId; - Uint64 supply; - Uint64 height; - String owner; - int revision; - MosaicProperties properties; - - @override - String toString() { - final sb = StringBuffer() - ..writeln('{') - ..writeln('\t"assetId": ${mosaicId.toHex()},') - ..writeln('\t"supply": $supply,') - ..writeln('\t"height": $height,') - ..writeln('\t"owner": $owner,') - ..writeln('\t"revision": $revision,') - ..writeln('\t"properties": $properties'); - sb.write('}'); - return sb.toString(); - } - - static List listFromDTO(List json) => - json == null ? null : json.map((value) => MosaicInfo.fromDTO(value)).toList(); -} - -class MosaicName { - MosaicName.fromDTO(MosaicNameDTO dto) : assert(dto != null, 'dto must not be null') { - mosaicId = MosaicId.fromId(dto.mosaicId.toUint64()); - names = dto._names != null ? List.from(dto._names) : null; - } - - MosaicId mosaicId; - - List names; - - @override - String toString() => '"assetId":${mosaicId.toHex()},' - ' "names":$names}'; - - static List listFromDTO(List json) => - json == null ? null : json.map((value) => MosaicName.fromDTO(value)).toList(); -} - -class MosaicProperty { - MosaicProperty(this.id, this.value); - - MosaicProperty.fromDTO(_MosaicPropertyDTO dto) { - if (dto == null) return; - id = getPropertyId(dto._id); - value = dto._value.toUint64(); - } - - MosaicPropertyId id; - - Uint64 value; - - static List listFromDTO(List<_MosaicPropertyDTO> json) => - json == null ? [] : json.map((value) => MosaicProperty.fromDTO(value)).toList(); - - @override - String toString() => 'id: $id, value: $value'; - - Map toJson() => {'id': id, 'value': value}; -} - -/// MosaicProperties structure describes mosaic properties. -class MosaicProperties { - MosaicProperties( - // ignore: avoid_positional_boolean_parameters - this.supplyMutable, - this.transferable, - this.divisibility, - Uint64 duration, - [this.optionalProperties]) { - optionalProperties = duration.toInt() != 0 - ? List.from([MosaicProperty(MosaicPropertyId.mosaicPropertyDurationId, duration)]) - : List(0); - } - - MosaicProperties.fromDTO(List<_MosaicPropertyDTO> value) : assert(value != null, 'mosaic Properties is not valid') { - var flags = Uint64.zero; - - divisibility = 0; - - for (_MosaicPropertyDTO property in value) { - switch (property._id) { - case 0: - flags = property._value.toUint64(); - break; - case 1: - divisibility = property._value.toUint64().toInt(); - break; - case 2: - optionalProperties = []; - break; - default: - throw errPropertyId; - } - } - - supplyMutable = hasBits(flags, getSupplyMutable); - transferable = hasBits(flags, getTransferable); - } - - bool supplyMutable; - bool transferable; - int divisibility; - List optionalProperties; - - @override - String toString() { - final sb = StringBuffer() - ..writeln('{') - ..writeln('\t\t"supplyMutable": $supplyMutable,') - ..writeln('\t\t"transferable": $transferable,'); - if (optionalProperties != null) { - sb.writeln('\t\t"optionalProperties": $optionalProperties,'); - } - sb.writeln('\t\t"divisibility": $divisibility'); - sb.write('\t}'); - return sb.toString(); - } -} diff --git a/lib/src/model/multisig.dart b/lib/src/model/multisig.dart index 5f415e2..36abe02 100644 --- a/lib/src/model/multisig.dart +++ b/lib/src/model/multisig.dart @@ -6,7 +6,7 @@ library xpx_chain_sdk.model.multisig; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; part 'multisig/multisig.dart'; part 'multisig/multisig_account_graph_info.dart'; diff --git a/lib/src/model/multisig/multisig_dto.dart b/lib/src/model/multisig/multisig_dto.dart deleted file mode 100644 index 76ad6f2..0000000 --- a/lib/src/model/multisig/multisig_dto.dart +++ /dev/null @@ -1,79 +0,0 @@ -part of xpx_chain_sdk.multisig; - -class MultisigCosignatoryModificationDTO { - MultisigCosignatoryModificationDTO(this.type, this.cosignatoryPublicKey); - - MultisigCosignatoryModificationDTO.fromJson(Map json) { - type = json['type']; - cosignatoryPublicKey = json['cosignatoryPublicKey']; - } - - int type; - String cosignatoryPublicKey; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => MultisigCosignatoryModificationDTO.fromJson(value)).toList(); - - Map toJson() { - final data = {}; - data['type'] = type; - data['cosignatoryPublicKey'] = cosignatoryPublicKey; - return data; - } -} - -class ModifyMultisigAccountTransactionInfoDTO { - ModifyMultisigAccountTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - transaction = - json['transaction'] != null ? _ModifyMultisigAccountTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - _ModifyMultisigAccountTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class _ModifyMultisigAccountTransactionDTO extends AbstractTransactionDTO { - _ModifyMultisigAccountTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - modifications = MultisigCosignatoryModificationDTO.listFromJson(json['modifications']); - minApprovalDelta = json['minApprovalDelta']; - minRemovalDelta = json['minRemovalDelta']; - } - - int minApprovalDelta; - int minRemovalDelta; - List modifications; - - List transactions; - - @override - Map toJson() => { - 'signature': signature, - 'signer': signer, - 'version': version, - 'type': type, - 'maxFee': fee, - 'deadline': deadline, - 'minApprovalDelta': minApprovalDelta, - 'minRemovalDelta': minRemovalDelta, - 'modifications': modifications, - }; -} diff --git a/lib/src/model/multisig/multisig_model.dart b/lib/src/model/multisig/multisig_model.dart deleted file mode 100644 index 0e9e992..0000000 --- a/lib/src/model/multisig/multisig_model.dart +++ /dev/null @@ -1,124 +0,0 @@ -part of xpx_chain_sdk.multisig; - -class Multisig { - Multisig.fromJson(Map json) : assert(json != null, 'json must not be null') { - accountAddress = Address.fromEncoded(json['accountAddress']); - account = PublicAccount.fromPublicKey(json['account'], accountAddress.networkType); - minApproval = json['minApproval']; - minRemoval = json['minRemoval']; - cosignatories = List.from(json['cosignatories']); - multisigAccounts = List.from(json['multisigAccounts']); - } - - PublicAccount account; - - Address accountAddress; - - int minApproval; - - int minRemoval; - - List cosignatories = []; - - List multisigAccounts = []; - - @override - String toString() { - final sb = StringBuffer() - ..write('{\n') - ..writeln('\taccount: $account,') - ..writeln('\tminApproval: $minApproval,') - ..writeln('\tminRemoval: $minRemoval,') - ..writeln('\tcosignatories: $cosignatories,') - ..writeln('\tmultisigAccounts: $multisigAccounts') - ..write('}\n'); - return sb.toString(); - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => Multisig.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = Multisig.fromJson(value)); - } - return map; - } - - Map toJson() { - final data = {}; - data['account'] = account; - data['accountAddress'] = accountAddress; - data['minApproval'] = minApproval; - data['minRemoval'] = minRemoval; - data['cosignatories'] = cosignatories; - data['multisigAccounts'] = multisigAccounts; - - return data; - } -} - -class MultisigAccountGraphInfo { - MultisigAccountGraphInfo.fromJson(Map json) : assert(json != null, 'json must not be null') { - level = json['level']; - multisigEntries = MultisigAccountInfo.listFromJson(json['multisigEntries']); - } - - int level; - - List multisigEntries = []; - - @override - String toString() => '{\n' - '\tlevel: $level,\n' - '\tmultisigEntries: $multisigEntries\n' - '}\n'; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => MultisigAccountGraphInfo.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = MultisigAccountGraphInfo.fromJson(value)); - } - return map; - } - - Map toJson() { - final data = {}; - data['level'] = level; - data['multisigEntries'] = multisigEntries; - - return data; - } -} - -class MultisigAccountInfo { - MultisigAccountInfo.fromJson(Map json) : assert(json != null, 'json must not be null') { - multisig = Multisig.fromJson(json['multisig']); - } - - Multisig multisig; - - @override - String toString() => '$multisig'; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => MultisigAccountInfo.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = MultisigAccountInfo.fromJson(value)); - } - return map; - } - - Map toJson() { - final data = {}; - data['multisig'] = multisig; - return data; - } -} diff --git a/lib/src/model/namespace.dart b/lib/src/model/namespace.dart index 205726f..3a090e5 100644 --- a/lib/src/model/namespace.dart +++ b/lib/src/model/namespace.dart @@ -10,9 +10,8 @@ import 'dart:typed_data'; import 'package:fixnum/fixnum.dart'; import 'package:sha3/sha3.dart'; -import 'package:xpx_chain_sdk/xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; -import '../../xpx_sdk.dart'; import '../api/dto.dart'; part 'namespace/namespace_id.dart'; diff --git a/lib/src/model/namespace/namespace_dto.dart b/lib/src/model/namespace/namespace_dto.dart deleted file mode 100644 index 4d2a93a..0000000 --- a/lib/src/model/namespace/namespace_dto.dart +++ /dev/null @@ -1,237 +0,0 @@ -part of xpx_chain_sdk.namespace; - -class NamespaceDTO { - NamespaceDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - owner = json['owner']; - ownerAddress = json['ownerAddress']; - startHeight = UInt64DTO.fromJson(json['startHeight']); - endHeight = UInt64DTO.fromJson(json['endHeight']); - depth = json['depth']; - level0 = UInt64DTO.fromJson(json['level0']); - level1 = UInt64DTO.fromJson(json['level1']); - level2 = UInt64DTO.fromJson(json['level2']); - type = json['type']; - alias = AliasDTO.fromJson(json['alias']); - parentId = UInt64DTO.fromJson(json['parentId']); - } - - String owner; - String ownerAddress; - UInt64DTO startHeight; - UInt64DTO endHeight; - int depth; - UInt64DTO level0; - UInt64DTO level1; - UInt64DTO level2; - int type; - AliasDTO alias; - UInt64DTO parentId; - - Map toJson() { - final data = {}; - data['owner'] = owner; - data['ownerAddress'] = ownerAddress; - data['startHeight'] = startHeight; - data['endHeight'] = endHeight; - data['depth'] = depth; - data['level0'] = level0; - data['level1'] = level1; - data['level2'] = level2; - data['type'] = type; - data['alias'] = alias; - data['parentId'] = parentId; - - return data; - } - - static List listFromJson(List json) => - json == null ? null : json.map((value) => NamespaceDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = NamespaceDTO.fromJson(value)); - } - return map; - } -} - -class NamespaceInfoDTO { - NamespaceInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - meta = NamespaceMetaDTO.fromJson(json['meta']); - _namespace = NamespaceDTO.fromJson(json['namespace']); - } - - NamespaceMetaDTO meta; - - NamespaceDTO _namespace; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => NamespaceInfoDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = NamespaceInfoDTO.fromJson(value)); - } - return map; - } - - Map toJson() { - final data = {}; - data['meta'] = meta; - data['namespace'] = _namespace; - - return data; - } -} - -class NamespaceMetaDTO { - NamespaceMetaDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - id = json['id']; - active = json['active']; - index = json['index']; - } - - String id; - - bool active; - - int index; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => NamespaceMetaDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = NamespaceMetaDTO.fromJson(value)); - } - return map; - } - - Map toJson() { - final data = {}; - data['id'] = id; - data['active'] = active; - data['index'] = index; - - return data; - } -} - -class NamespaceNameDTO { - NamespaceNameDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - parentId = UInt64DTO.fromJson(json['parentId']); - namespaceId = UInt64DTO.fromJson(json['namespaceId']); - name = json['name']; - } - - UInt64DTO parentId; - - UInt64DTO namespaceId; - - String name; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => NamespaceNameDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = NamespaceNameDTO.fromJson(value)); - } - return map; - } - - Map toJson() { - final data = {}; - data['parentId'] = parentId; - data['namespaceId'] = namespaceId; - data['name'] = name; - - return data; - } -} - -class RegisterNamespaceTransactionInfoDTO { - RegisterNamespaceTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - transaction = json['transaction'] != null ? RegisterNamespaceTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - RegisterNamespaceTransactionDTO transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (transaction != null) { - data['transaction'] = transaction.toJson(); - } - return data; - } -} - -class RegisterNamespaceTransactionDTO extends AbstractTransactionDTO { - RegisterNamespaceTransactionDTO( - {String signature, - String signer, - int version, - int type, - List maxFee, - List deadline, - this.namespaceId, - this.namespaceType, - this.name, - UInt64DTO parenId, - this.duration}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - this.deadline = UInt64DTO.fromJson(deadline); - fee = UInt64DTO.fromJson(maxFee); - parentId = UInt64DTO.fromJson(parenId); - } - - RegisterNamespaceTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - - namespaceId = UInt64DTO.fromJson(json['namespaceId']); - namespaceType = json['namespaceType']; - name = json['name']; - parentId = json['parentId'] != null ? UInt64DTO.fromJson(json['parentId']) : null; - - duration = json['duration'] != null ? UInt64DTO.fromJson(json['duration']) : null; - } - - UInt64DTO namespaceId; - int namespaceType; - String name; - UInt64DTO duration; - UInt64DTO parentId; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['namespaceId'] = namespaceId; - data['namespaceType'] = namespaceType; - data['name'] = name; - data['duration'] = duration; - return data; - } -} diff --git a/lib/src/model/namespace/namespace_model.dart b/lib/src/model/namespace/namespace_model.dart deleted file mode 100644 index 89ac94c..0000000 --- a/lib/src/model/namespace/namespace_model.dart +++ /dev/null @@ -1,197 +0,0 @@ -part of xpx_chain_sdk.namespace; - -class NamespaceId extends AssetId { - factory NamespaceId({final Uint64 id}) { - if (id == null) { - throw errNullId; - } - - return NamespaceId._(id); - } - - const NamespaceId._(final Uint64 id) : super(id); - - /// NewNamespaceIdFromName generate Id from namespaceName - NamespaceId.fromName(String namespaceName) : super(generateNamespacePath(namespaceName)); - - NamespaceId.fromId(final Uint64 id) : super(id); - - NamespaceId.fromBigInt(final Uint64 bigInt) : super(bigInt); - - static NamespaceId fromHex(final String hex) { - if (hex.isEmpty) { - throw ArgumentError('The hexString must not be null or empty'); - } - - if (0 != (hex.length % 2)) { - throw ArgumentError('invalid hex'); - } - final Uint64 bigInt = Uint64.fromHex(hex); - return NamespaceId._(bigInt); - } - - @override - int get hashCode => 'NamespaceId'.hashCode ^ super.hashCode; - - @override - bool operator ==(final other) => - identical(this, other) || - other is NamespaceId && runtimeType == other.runtimeType && toBytes() == other.toBytes(); -} - -class NamespaceName { - NamespaceName.fromDTO(NamespaceNameDTO dto) : assert(dto != null, 'dto must not be null') { - parentId = dto.parentId == null ? NamespaceId._(dto.parentId.toUint64()) : null; - namespaceId = NamespaceId._(dto.namespaceId.toUint64()); - name = dto.name; - } - - NamespaceId parentId; - - NamespaceId namespaceId; - - String name; - - @override - String toString() { - final sb = StringBuffer()..writeln('\n{'); - if (parentId != null) { - sb.writeln('\tparentId: ${parentId.toHex()},'); - } - sb.writeln('\tnamespaceId: ${namespaceId.toHex()},'); - sb.writeln('\tname: $name,'); - sb.writeln('\n{'); - return sb.toString(); - } - - static List listFromDTO(List json) => - json == null ? null : json.map((value) => NamespaceName.fromDTO(value)).toList(); - - Map toJson() { - final data = {}; - if (parentId != null) { - data['parentId'] = parentId.toHex(); - } - data['namespaceId'] = namespaceId.toHex(); - data['name'] = name; - - return data; - } -} - -class NamespaceInfo { - NamespaceInfo(); - - NamespaceInfo.fromDTO(NamespaceInfoDTO dto) : assert(dto != null, 'dto must not be null') { - metaId = dto.meta.id; - active = dto.meta.active; - index = dto.meta.index; - - final _ownerAddress = Address.fromEncoded(dto._namespace.ownerAddress); - - owner = PublicAccount.fromPublicKey(dto._namespace.owner, _ownerAddress.networkType); - - startHeight = dto._namespace.startHeight.toUint64(); - endHeight = dto._namespace.endHeight.toUint64(); - depth = dto._namespace.depth; - levels = extractLevels(dto); - typeSpace = dto._namespace.type; - - alias = - dto._namespace.alias.address != null ? Alias(address: Address.fromEncoded(dto._namespace.alias.address)) : null; - if (dto._namespace.parentId.toUint64().toInt() != 0) { - namespaceId = NamespaceId._(levels[0]); - parent = NamespaceInfo()..namespaceId = NamespaceId._(dto._namespace.parentId.toUint64()); - } else { - namespaceId = NamespaceId._(levels[0]); - } - } - - bool active; - - int index; - - NamespaceId namespaceId; - - String fullName; - - String metaId; - - int typeSpace; - - int depth; - - List levels; - - NamespaceInfo parent; - - PublicAccount owner; - - Uint64 startHeight; - - Uint64 endHeight; - - Alias alias; - - @override - String toString() => '{\n' - '\tnamespaceId: $namespaceId,\n' - '\tactive: $active,\n' - '\tindex: $index,\n' - '\tmetaId: $metaId,\n' - '\ttypeSpace: $typeSpace,\n' - '\tdepth: $depth,\n' - '\tlevels: $levels,\n' - '\tparent: $parent,\n' - '\talias: $alias,\n' - '\towner:$owner,\n' - '\tstartHeight: $startHeight,\n' - '\tendHeight: $endHeight\n' - '}\n'; - - static List listFromDTO(List json) => - json == null ? null : json.map((value) => NamespaceInfo.fromDTO(value)).toList(); - - Map toJson() { - final data = {}; - data['active'] = active; - data['index'] = index; - data['namespaceId'] = namespaceId; - data['fullName'] = fullName; - data['metaId'] = metaId; - data['typeSpace'] = typeSpace; - data['depth'] = depth; - data['levels'] = levels; - data['parent'] = parent; - data['owner'] = owner; - data['startHeight'] = startHeight; - data['endHeight'] = endHeight; - data['alias'] = alias; - - return data; - } -} - -class NamespaceIds { - NamespaceIds.fromList(List list) : assert(list != null, 'list must not be null') { - _list = list.map((item) => item).toList(); - } - - List _list = []; - - @override - String toString() => '{"namespaceIds":$_list}'; - - Map toJson() { - final data = {}; - - final List nsIds = List(_list.length); - - for (int i = 0; i < _list.length; i++) { - nsIds[i] = _list[i].toHex(); - } - - data['namespaceIds'] = nsIds; - return data; - } -} diff --git a/lib/src/model/network.dart b/lib/src/model/network.dart index 56b06f0..6121da9 100644 --- a/lib/src/model/network.dart +++ b/lib/src/model/network.dart @@ -6,7 +6,7 @@ library xpx_chain_sdk.model.network; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; part 'network/network_info.dart'; part 'network/network_type.dart'; diff --git a/lib/src/model/node.dart b/lib/src/model/node.dart index ca4dc3f..56f7721 100644 --- a/lib/src/model/node.dart +++ b/lib/src/model/node.dart @@ -6,7 +6,8 @@ library xpx_chain_sdk.model.node; -import '../../xpx_sdk.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; + import '../api/dto.dart'; part 'node/node_info.dart'; diff --git a/lib/src/model/node/node_time_dto.dart b/lib/src/model/node/node_time_dto.dart deleted file mode 100644 index 8493f63..0000000 --- a/lib/src/model/node/node_time_dto.dart +++ /dev/null @@ -1,27 +0,0 @@ -part of xpx_chain_sdk.node; - -class NodeTime { - NodeTime.fromJson(Map json) : assert(json != null, 'json must not be null') { - _communicationTimestamps = CommunicationTimestamps.fromJson(json['communicationTimestamps']); - } - - CommunicationTimestamps _communicationTimestamps; - - @override - String toString() => '{\n' - '\t"communicationTimestamps": $_communicationTimestamps' - '}\n'; - - Map toJson() => {'communicationTimestamps': _communicationTimestamps}; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => NodeTime.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = NodeTime.fromJson(value)); - } - return map; - } -} diff --git a/lib/src/model/transaction.dart b/lib/src/model/transaction.dart index bede548..6e78186 100644 --- a/lib/src/model/transaction.dart +++ b/lib/src/model/transaction.dart @@ -10,17 +10,16 @@ import 'dart:math'; import 'dart:typed_data'; import 'package:base32/base32.dart'; +import 'package:collection/collection.dart'; import 'package:convert/convert.dart' show hex; import 'package:flat_buffers/flat_buffers.dart' as fb; import 'package:sha3/sha3.dart'; -import 'package:xpx_chain_sdk/imp/buffer.dart' as $buffer; -import 'package:xpx_chain_sdk/imp/buffer/transactions_buffer.dart' - as $txn_buffer; import 'package:xpx_chain_sdk/src/model/transaction/schema.dart'; -import 'package:xpx_chain_sdk/xpx_sdk_all_errors.dart'; +import 'package:xpx_chain_sdk/xpx_chain_sdk.dart'; -import '../../xpx_sdk.dart'; import '../api/dto.dart'; +import 'transaction/buffer/buffer.dart' as $buffer; +import 'transaction/buffer/transactions_buffer.dart' as $txn_buffer; part 'transaction/abstract_transaction.dart'; part 'transaction/asset_id.dart'; diff --git a/lib/src/model/transaction/announce_transaction_info_dto.dart b/lib/src/model/transaction/announce_transaction_info_dto.dart deleted file mode 100644 index 2b16483..0000000 --- a/lib/src/model/transaction/announce_transaction_info_dto.dart +++ /dev/null @@ -1,22 +0,0 @@ -part of xpx_chain_sdk.transaction; - -class AnnounceTransactionInfoDTO { - AnnounceTransactionInfoDTO.fromJson(Map json) : assert(json != null, 'json must not be null') { - _message = json['message']; - } - - String _message; - - Map toJson() => {'message': _message}; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => AnnounceTransactionInfoDTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = AnnounceTransactionInfoDTO.fromJson(value)); - } - return map; - } -} diff --git a/lib/src/model/transaction/buffer/buffer.dart b/lib/src/model/transaction/buffer/buffer.dart new file mode 100644 index 0000000..6bca4d0 --- /dev/null +++ b/lib/src/model/transaction/buffer/buffer.dart @@ -0,0 +1,34 @@ +/* + * Copyright 2018 ProximaX Limited. All rights reserved. + * Use of this source code is governed by the Apache 2.0 + * license that can be found in the LICENSE file. + */ + +library xpx_chain_sdk.model.transaction.buffer; + +export 'schema_account_link_transaction_catapult.buffers_generated.dart'; +export 'schema_account_properties_transaction_catapult.buffers_generated.dart'; +export 'schema_aggregate_transaction_catapult.buffers_generated.dart'; +export 'schema_alias_transaction_catapult.buffers_generated.dart'; +export 'schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart'; +export 'schema_exchange_transaction_catapult.buffers_generated.dart'; +export 'schema_harvester_transaction_catapult.buffers_generated.dart'; +export 'schema_lock_funds_transaction_catapult.buffers_generated.dart'; +export 'schema_metadata_v2_transaction_catapult.buffers_generated.dart'; +export 'schema_modify_contract_transaction_catapult.buffers_generated.dart'; +export 'schema_modify_metadata_transaction_catapult.buffers_generated.dart'; +export 'schema_modify_mosaic_levy_transactions_generated.dart'; +export 'schema_modify_multisig_account_transaction_catapult.buffers_generated.dart'; +export 'schema_mosaic_definition_transaction_catapult.buffers_generated.dart'; +export 'schema_mosaic_remove_levy_transactions_generated.dart'; +export 'schema_mosaic_remove_levy_transactions_generated.dart'; +export 'schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart'; +export 'schema_network_config_transaction_catapult.buffers_generated.dart'; +export 'schema_operation_transaction_catapult.buffers_generated.dart'; +export 'schema_register_namespace_transaction_catapult.buffers_generated.dart'; +export 'schema_secret_lock_transaction_catapult.buffers_generated.dart'; +export 'schema_secret_proof_transaction_catapult.buffers_generated.dart'; +export 'schema_storage_transaction_catapult.buffers_generated.dart'; +export 'schema_supercontract_transaction_catapult.buffers_generated.dart'; +export 'schema_transfer_transaction_catapult.buffers_generated.dart'; +export 'transactions_buffer.dart'; diff --git a/lib/imp/buffer/schema_account_link_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_account_link_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_account_link_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_account_link_transaction_catapult.buffers_generated.dart index 97bf408..07f9588 100644 --- a/lib/imp/buffer/schema_account_link_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_account_link_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class AccountLinkTransactionBuffer { AccountLinkTransactionBuffer._(this._bc, this._bcOffset); + factory AccountLinkTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,18 +22,26 @@ class AccountLinkTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get remoteAccountKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + int get linkAction => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0); @override diff --git a/lib/imp/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart index aab8258..f0edc93 100644 --- a/lib/imp/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_account_properties_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class PropertyModificationBuffer { PropertyModificationBuffer._(this._bc, this._bcOffset); + factory PropertyModificationBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -99,6 +100,7 @@ class PropertyModificationBufferObjectBuilder extends fb.ObjectBuilder { class AccountPropertiesTransactionBuffer { AccountPropertiesTransactionBuffer._(this._bc, this._bcOffset); + factory AccountPropertiesTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -111,20 +113,29 @@ class AccountPropertiesTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get propertyType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + int get modificationCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0); + List? get modifications => const fb.ListReader( PropertyModificationBuffer.reader) diff --git a/lib/imp/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart index c23c6c5..958d0df 100644 --- a/lib/imp/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_aggregate_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class AggregateTransactionBuffer { AggregateTransactionBuffer._(this._bc, this._bcOffset); + factory AggregateTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,18 +22,26 @@ class AggregateTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get transactionsSize => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get transactions => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); diff --git a/lib/imp/buffer/schema_alias_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_alias_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_alias_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_alias_transaction_catapult.buffers_generated.dart index e4a5cca..cca6fd9 100644 --- a/lib/imp/buffer/schema_alias_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_alias_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class AliasTransactionBuffer { AliasTransactionBuffer._(this._bc, this._bcOffset); + factory AliasTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,17 +22,25 @@ class AliasTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get actionType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get namespaceId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); diff --git a/lib/imp/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart index a1d5ba9..d44229a 100644 --- a/lib/imp/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_blockchain_upgrade_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class BlockchainUpgradeTransactionBuffer { BlockchainUpgradeTransactionBuffer._(this._bc, this._bcOffset); + factory BlockchainUpgradeTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,18 +22,26 @@ class BlockchainUpgradeTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get upgradePeriod => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + List? get newBlockChainVersion => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); diff --git a/lib/imp/buffer/schema_exchange_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_exchange_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_exchange_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_exchange_transaction_catapult.buffers_generated.dart index a40a447..f376b95 100644 --- a/lib/imp/buffer/schema_exchange_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_exchange_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class AddExchangeOfferTransactionBuffer { AddExchangeOfferTransactionBuffer._(this._bc, this._bcOffset); + factory AddExchangeOfferTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,18 +22,26 @@ class AddExchangeOfferTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get offersCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get offers => const fb.ListReader(AddExchangeOfferBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 20); @@ -182,6 +191,7 @@ class AddExchangeOfferTransactionBufferObjectBuilder extends fb.ObjectBuilder { class ExchangeOfferTransactionBuffer { ExchangeOfferTransactionBuffer._(this._bc, this._bcOffset); + factory ExchangeOfferTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -194,18 +204,26 @@ class ExchangeOfferTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get offersCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get offers => const fb.ListReader(ExchangeOfferBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 20); @@ -355,6 +373,7 @@ class ExchangeOfferTransactionBufferObjectBuilder extends fb.ObjectBuilder { class RemoveExchangeOfferTransactionBuffer { RemoveExchangeOfferTransactionBuffer._(this._bc, this._bcOffset); + factory RemoveExchangeOfferTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -367,18 +386,26 @@ class RemoveExchangeOfferTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get offersCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get offers => const fb.ListReader( RemoveExchangeOfferBuffer.reader) @@ -530,6 +557,7 @@ class RemoveExchangeOfferTransactionBufferObjectBuilder class AddExchangeOfferBuffer { AddExchangeOfferBuffer._(this._bc, this._bcOffset); + factory AddExchangeOfferBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -543,11 +571,15 @@ class AddExchangeOfferBuffer { List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 4); + List? get mosaicAmount => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 6); + List? get cost => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 8); + int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 10, 0); + List? get duration => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 12); @@ -656,6 +688,7 @@ class AddExchangeOfferBufferObjectBuilder extends fb.ObjectBuilder { class ExchangeOfferBuffer { ExchangeOfferBuffer._(this._bc, this._bcOffset); + factory ExchangeOfferBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -669,11 +702,15 @@ class ExchangeOfferBuffer { List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 4); + List? get mosaicAmount => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 6); + List? get cost => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 8); + int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 10, 0); + List? get owner => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 12); @@ -781,6 +818,7 @@ class ExchangeOfferBufferObjectBuilder extends fb.ObjectBuilder { class RemoveExchangeOfferBuffer { RemoveExchangeOfferBuffer._(this._bc, this._bcOffset); + factory RemoveExchangeOfferBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -794,6 +832,7 @@ class RemoveExchangeOfferBuffer { List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 4); + int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 6, 0); @override diff --git a/lib/imp/buffer/schema_harvester_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_harvester_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_harvester_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_harvester_transaction_catapult.buffers_generated.dart index 40b4c5d..2dd5df8 100644 --- a/lib/imp/buffer/schema_harvester_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_harvester_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class HarvesterTransactionBuffer { HarvesterTransactionBuffer._(this._bc, this._bcOffset); + factory HarvesterTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,14 +22,20 @@ class HarvesterTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); diff --git a/lib/imp/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart index 5448374..4e25e91 100644 --- a/lib/imp/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_lock_funds_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class LockFundsTransactionBuffer { LockFundsTransactionBuffer._(this._bc, this._bcOffset); + factory LockFundsTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,22 +22,32 @@ class LockFundsTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + List? get mosaicAmount => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); + List? get duration => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 22); + List? get hash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 24); diff --git a/lib/imp/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart index eae13d8..2550e2d 100644 --- a/lib/imp/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_metadata_v2_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class MetadataV2transactionBuffer { MetadataV2transactionBuffer._(this._bc, this._bcOffset); + factory MetadataV2transactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,18 +22,26 @@ class MetadataV2transactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get targetKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get scopedMetadataKey => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); @@ -40,10 +49,13 @@ class MetadataV2transactionBuffer { /// In case of address it is empty array. In case of mosaic or namespace id it is 8 byte array(or 2 uint32 array) List? get targetId => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 22); + List? get valueSizeDelta => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 24); + List? get valueSize => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); + List? get value => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 28); diff --git a/lib/imp/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart index 6f1190d..e17766e 100644 --- a/lib/imp/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class CosignatoryModificationBuffer { CosignatoryModificationBuffer._(this._bc, this._bcOffset); + factory CosignatoryModificationBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,6 +22,7 @@ class CosignatoryModificationBuffer { final int _bcOffset; int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get cosignatoryPublicKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); @@ -96,6 +98,7 @@ class CosignatoryModificationBufferObjectBuilder extends fb.ObjectBuilder { class ModifyContractTransactionBuffer { ModifyContractTransactionBuffer._(this._bc, this._bcOffset); + factory ModifyContractTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -108,34 +111,48 @@ class ModifyContractTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get durationDelta => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + List? get hash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + int get numCustomers => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); + int get numExecutors => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); + int get numVerifiers => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 26, 0); + List? get customers => const fb.ListReader( CosignatoryModificationBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 28); + List? get executors => const fb.ListReader( CosignatoryModificationBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 30); + List? get verifiers => const fb.ListReader( CosignatoryModificationBuffer.reader) diff --git a/lib/imp/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart index 4a5ba63..0e13d2c 100644 --- a/lib/imp/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_modify_metadata_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class MetadataModificationBuffer { MetadataModificationBuffer._(this._bc, this._bcOffset); + factory MetadataModificationBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,13 +22,18 @@ class MetadataModificationBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + int get modificationType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 6, 0); + int get keySize => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 8, 0); + List? get valueSize => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 10); + List? get key => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 12); + List? get value => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 14); @@ -142,6 +148,7 @@ class MetadataModificationBufferObjectBuilder extends fb.ObjectBuilder { class ModifyMetadataTransactionBuffer { ModifyMetadataTransactionBuffer._(this._bc, this._bcOffset); + factory ModifyMetadataTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -154,22 +161,30 @@ class ModifyMetadataTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get metadataType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); /// In case of address it is 25 bytes array. In case of mosaic or namespace it is 8 byte array(or 2 uint32 array) List? get metadataId => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + List? get modifications => const fb.ListReader( MetadataModificationBuffer.reader) diff --git a/lib/imp/buffer/schema_modify_mosaic_levy_transactions_generated.dart b/lib/src/model/transaction/buffer/schema_modify_mosaic_levy_transactions_generated.dart similarity index 99% rename from lib/imp/buffer/schema_modify_mosaic_levy_transactions_generated.dart rename to lib/src/model/transaction/buffer/schema_modify_mosaic_levy_transactions_generated.dart index 4186115..0d39f6b 100644 --- a/lib/imp/buffer/schema_modify_mosaic_levy_transactions_generated.dart +++ b/lib/src/model/transaction/buffer/schema_modify_mosaic_levy_transactions_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class MosaicLevy { MosaicLevy._(this._bc, this._bcOffset); + factory MosaicLevy(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -20,10 +21,13 @@ class MosaicLevy { final int _bcOffset; int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get recipient => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 8); + List? get fee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 10); @@ -119,6 +123,7 @@ class MosaicLevyObjectBuilder extends fb.ObjectBuilder { class ModifyMosaicLevyTransactionBuffer { ModifyMosaicLevyTransactionBuffer._(this._bc, this._bcOffset); + factory ModifyMosaicLevyTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -131,18 +136,26 @@ class ModifyMosaicLevyTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + MosaicLevy? get levy => MosaicLevy.reader.vTableGetNullable(_bc, _bcOffset, 20); diff --git a/lib/imp/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart similarity index 98% rename from lib/imp/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart index cb00887..dae2473 100644 --- a/lib/imp/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_modify_multisig_account_transaction_catapult.buffers_generated.dart @@ -6,10 +6,12 @@ library catapult.buffers; import 'dart:typed_data' show Uint8List; import 'package:flat_buffers/flat_buffers.dart' as fb; -import 'package:xpx_chain_sdk/imp/buffer/schema_modify_contract_transaction_catapult.buffers_generated.dart'; + +import './schema_modify_contract_transaction_catapult.buffers_generated.dart'; class ModifyMultisigAccountTransactionBuffer { ModifyMultisigAccountTransactionBuffer._(this._bc, this._bcOffset); + factory ModifyMultisigAccountTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -22,22 +24,32 @@ class ModifyMultisigAccountTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get minRemovalDelta => const fb.Int8Reader().vTableGet(_bc, _bcOffset, 18, 0); + int get minApprovalDelta => const fb.Int8Reader().vTableGet(_bc, _bcOffset, 20, 0); + int get numModifications => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); + List? get modifications => const fb.ListReader( CosignatoryModificationBuffer.reader) diff --git a/lib/imp/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart index 6a64bb1..d786c7d 100644 --- a/lib/imp/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_mosaic_definition_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class MosaicProperty { MosaicProperty._(this._bc, this._bcOffset); + factory MosaicProperty(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,6 +22,7 @@ class MosaicProperty { int get mosaicPropertyId => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get value => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 6); @@ -94,6 +96,7 @@ class MosaicPropertyObjectBuilder extends fb.ObjectBuilder { class MosaicDefinitionTransactionBuffer { MosaicDefinitionTransactionBuffer._(this._bc, this._bcOffset); + factory MosaicDefinitionTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -106,25 +109,37 @@ class MosaicDefinitionTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get mosaicNonce => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); + int get numOptionalProperties => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); + int get flags => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); + int get divisibility => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 26, 0); + List? get optionalProperties => const fb.ListReader(MosaicProperty.reader) .vTableGetNullable(_bc, _bcOffset, 28); diff --git a/lib/imp/buffer/schema_mosaic_remove_levy_transactions_generated.dart b/lib/src/model/transaction/buffer/schema_mosaic_remove_levy_transactions_generated.dart similarity index 99% rename from lib/imp/buffer/schema_mosaic_remove_levy_transactions_generated.dart rename to lib/src/model/transaction/buffer/schema_mosaic_remove_levy_transactions_generated.dart index c7dae5b..4d1a874 100644 --- a/lib/imp/buffer/schema_mosaic_remove_levy_transactions_generated.dart +++ b/lib/src/model/transaction/buffer/schema_mosaic_remove_levy_transactions_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class RemoveMosaicLevyTransactionBuffer { RemoveMosaicLevyTransactionBuffer._(this._bc, this._bcOffset); + factory RemoveMosaicLevyTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,16 +22,23 @@ class RemoveMosaicLevyTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); diff --git a/lib/imp/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart index d11958b..8ea6034 100644 --- a/lib/imp/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_mosaic_supply_change_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class MosaicSupplyChangeTransactionBuffer { MosaicSupplyChangeTransactionBuffer._(this._bc, this._bcOffset); + factory MosaicSupplyChangeTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,19 +22,28 @@ class MosaicSupplyChangeTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + int get direction => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0); + List? get delta => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 22); diff --git a/lib/imp/buffer/schema_network_config_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_network_config_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_network_config_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_network_config_transaction_catapult.buffers_generated.dart index 7e8859e..babac35 100644 --- a/lib/imp/buffer/schema_network_config_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_network_config_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class NetworkConfigTransactionBuffer { NetworkConfigTransactionBuffer._(this._bc, this._bcOffset); + factory NetworkConfigTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,24 +22,35 @@ class NetworkConfigTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get applyHeightDelta => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + int get networkConfigSize => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 20, 0); + int get supportedEntityVersionsSize => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 22, 0); + List? get networkConfig => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 24); + List? get supportedEntityVersions => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); diff --git a/lib/imp/buffer/schema_operation_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_operation_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_operation_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_operation_transaction_catapult.buffers_generated.dart index ca2eb88..b55dc50 100644 --- a/lib/imp/buffer/schema_operation_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_operation_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class OperationIdentifyTransactionBuffer { OperationIdentifyTransactionBuffer._(this._bc, this._bcOffset); + factory OperationIdentifyTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,16 +22,23 @@ class OperationIdentifyTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get operationToken => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); @@ -169,6 +177,7 @@ class OperationIdentifyTransactionBufferObjectBuilder extends fb.ObjectBuilder { class MosaicBuffer { MosaicBuffer._(this._bc, this._bcOffset); + factory MosaicBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -181,6 +190,7 @@ class MosaicBuffer { List? get id => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 4); + List? get amount => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 6); @@ -255,6 +265,7 @@ class MosaicBufferObjectBuilder extends fb.ObjectBuilder { class StartOperationTransactionBuffer { StartOperationTransactionBuffer._(this._bc, this._bcOffset); + factory StartOperationTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -267,25 +278,36 @@ class StartOperationTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get mosaicsCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get duration => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); + int get executorsCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); + List? get mosaics => const fb.ListReader(MosaicBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 24); + List? get executors => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); @@ -465,6 +487,7 @@ class StartOperationTransactionBufferObjectBuilder extends fb.ObjectBuilder { class EndOperationTransactionBuffer { EndOperationTransactionBuffer._(this._bc, this._bcOffset); + factory EndOperationTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -477,21 +500,31 @@ class EndOperationTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get mosaicsCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get operationToken => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + int get status => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 22, 0); + List? get mosaics => const fb.ListReader(MosaicBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 24); diff --git a/lib/imp/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart index a2888e3..1897e4e 100644 --- a/lib/imp/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_register_namespace_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class RegisterNamespaceTransactionBuffer { RegisterNamespaceTransactionBuffer._(this._bc, this._bcOffset); + factory RegisterNamespaceTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,24 +22,35 @@ class RegisterNamespaceTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get namespaceType => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get durationParentId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); + List? get namespaceId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 22); + int get namespaceNameSize => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); + String? get namespaceName => const fb.StringReader().vTableGetNullable(_bc, _bcOffset, 26); diff --git a/lib/imp/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart index d49cff3..07cbc7e 100644 --- a/lib/imp/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_secret_lock_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class SecretLockTransactionBuffer { SecretLockTransactionBuffer._(this._bc, this._bcOffset); + factory SecretLockTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,26 +22,38 @@ class SecretLockTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get mosaicId => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 18); + List? get mosaicAmount => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); + List? get duration => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 22); + int get hashAlgorithm => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 24, 0); + List? get secret => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); + List? get recipient => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 28); diff --git a/lib/imp/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart index 8e957ac..7e5b0fc 100644 --- a/lib/imp/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_secret_proof_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class SecretProofTransactionBuffer { SecretProofTransactionBuffer._(this._bc, this._bcOffset); + factory SecretProofTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,23 +22,34 @@ class SecretProofTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get hashAlgorithm => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get secret => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + List? get recipient => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 22); + int get proofSize => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 24, 0); + List? get proof => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); diff --git a/lib/imp/buffer/schema_storage_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_storage_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_storage_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_storage_transaction_catapult.buffers_generated.dart index 52b29b4..5287dd4 100644 --- a/lib/imp/buffer/schema_storage_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_storage_transaction_catapult.buffers_generated.dart @@ -9,6 +9,7 @@ import 'package:flat_buffers/flat_buffers.dart' as fb; class PrepareDriveTransactionBuffer { PrepareDriveTransactionBuffer._(this._bc, this._bcOffset); + factory PrepareDriveTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,29 +22,43 @@ class PrepareDriveTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get owner => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get duration => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 20); + List? get billingPeriod => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 22); + List? get billingPrice => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 24); + List? get driveSize => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 26); + int get replicas => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 28, 0); + int get minReplicators => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 30, 0); + int get percentApprovers => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 32, 0); @@ -253,6 +268,7 @@ class PrepareDriveTransactionBufferObjectBuilder extends fb.ObjectBuilder { class JoinToDriveTransactionBuffer { JoinToDriveTransactionBuffer._(this._bc, this._bcOffset); + factory JoinToDriveTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -265,16 +281,23 @@ class JoinToDriveTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); @@ -411,6 +434,7 @@ class JoinToDriveTransactionBufferObjectBuilder extends fb.ObjectBuilder { class AddActionBuffer { AddActionBuffer._(this._bc, this._bcOffset); + factory AddActionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -423,6 +447,7 @@ class AddActionBuffer { List? get fileHash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 4); + List? get fileSize => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); @@ -498,6 +523,7 @@ class AddActionBufferObjectBuilder extends fb.ObjectBuilder { class RemoveActionBuffer { RemoveActionBuffer._(this._bc, this._bcOffset); + factory RemoveActionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -511,6 +537,7 @@ class RemoveActionBuffer { List? get fileHash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 4); + List? get fileSize => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); @@ -586,6 +613,7 @@ class RemoveActionBufferObjectBuilder extends fb.ObjectBuilder { class FileBuffer { FileBuffer._(this._bc, this._bcOffset); + factory FileBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -660,6 +688,7 @@ class FileBufferObjectBuilder extends fb.ObjectBuilder { class UploadInfoBuffer { UploadInfoBuffer._(this._bc, this._bcOffset); + factory UploadInfoBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -672,6 +701,7 @@ class UploadInfoBuffer { List? get replicator => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 4); + List? get uploaded => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 6); @@ -747,6 +777,7 @@ class UploadInfoBufferObjectBuilder extends fb.ObjectBuilder { class DriveFileSystemTransactionBuffer { DriveFileSystemTransactionBuffer._(this._bc, this._bcOffset); + factory DriveFileSystemTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -759,29 +790,42 @@ class DriveFileSystemTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get rootHash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + List? get xorRootHash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 22); + List? get addActionsCount => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 24); + List? get removeActionsCount => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); + List? get addActions => const fb.ListReader(AddActionBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 28); + List? get removeActions => const fb.ListReader(RemoveActionBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 30); @@ -993,6 +1037,7 @@ class DriveFileSystemTransactionBufferObjectBuilder extends fb.ObjectBuilder { class FilesDepositTransactionBuffer { FilesDepositTransactionBuffer._(this._bc, this._bcOffset); + factory FilesDepositTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1005,20 +1050,29 @@ class FilesDepositTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + int get filesCount => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 20, 0); + List? get files => const fb.ListReader(FileBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 22); @@ -1178,6 +1232,7 @@ class FilesDepositTransactionBufferObjectBuilder extends fb.ObjectBuilder { class EndDriveTransactionBuffer { EndDriveTransactionBuffer._(this._bc, this._bcOffset); + factory EndDriveTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1190,16 +1245,23 @@ class EndDriveTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); @@ -1336,6 +1398,7 @@ class EndDriveTransactionBufferObjectBuilder extends fb.ObjectBuilder { class DriveFilesRewardTransactionBuffer { DriveFilesRewardTransactionBuffer._(this._bc, this._bcOffset); + factory DriveFilesRewardTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1348,18 +1411,26 @@ class DriveFilesRewardTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + int get uploadInfosCount => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 18, 0); + List? get uploadInfos => const fb.ListReader(UploadInfoBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 20); @@ -1509,6 +1580,7 @@ class DriveFilesRewardTransactionBufferObjectBuilder extends fb.ObjectBuilder { class StartDriveVerificationTransactionBuffer { StartDriveVerificationTransactionBuffer._(this._bc, this._bcOffset); + factory StartDriveVerificationTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1521,16 +1593,23 @@ class StartDriveVerificationTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); @@ -1669,6 +1748,7 @@ class StartDriveVerificationTransactionBufferObjectBuilder class BlockHashBuffer { BlockHashBuffer._(this._bc, this._bcOffset); + factory BlockHashBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1743,6 +1823,7 @@ class BlockHashBufferObjectBuilder extends fb.ObjectBuilder { class VerificationFailureBuffer { VerificationFailureBuffer._(this._bc, this._bcOffset); + factory VerificationFailureBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1755,8 +1836,10 @@ class VerificationFailureBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get replicator => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get blockHashes => const fb.ListReader(BlockHashBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 8); @@ -1845,6 +1928,7 @@ class VerificationFailureBufferObjectBuilder extends fb.ObjectBuilder { class EndDriveVerificationTransactionBuffer { EndDriveVerificationTransactionBuffer._(this._bc, this._bcOffset); + factory EndDriveVerificationTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -1857,16 +1941,23 @@ class EndDriveVerificationTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get failures => const fb.ListReader( VerificationFailureBuffer.reader) @@ -2009,6 +2100,7 @@ class EndDriveVerificationTransactionBufferObjectBuilder class StartFileDownloadTransactionBuffer { StartFileDownloadTransactionBuffer._(this._bc, this._bcOffset); + factory StartFileDownloadTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -2021,19 +2113,28 @@ class StartFileDownloadTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + int get fileCount => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 20, 0); + List? get files => const fb.ListReader(AddActionBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 22); @@ -2194,6 +2295,7 @@ class StartFileDownloadTransactionBufferObjectBuilder extends fb.ObjectBuilder { class EndFileDownloadTransactionBuffer { EndFileDownloadTransactionBuffer._(this._bc, this._bcOffset); + factory EndFileDownloadTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -2206,21 +2308,31 @@ class EndFileDownloadTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get recipient => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get operationToken => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + int get fileCount => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 22, 0); + List? get files => const fb.ListReader(RemoveActionBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 24); diff --git a/lib/imp/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart similarity index 99% rename from lib/imp/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart index 8567996..7a4d62f 100644 --- a/lib/imp/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_supercontract_transaction_catapult.buffers_generated.dart @@ -6,10 +6,12 @@ library catapult.buffers; import 'dart:typed_data' show Uint8List; import 'package:flat_buffers/flat_buffers.dart' as fb; -import 'package:xpx_chain_sdk/imp/buffer/schema_operation_transaction_catapult.buffers_generated.dart'; + +import './schema_operation_transaction_catapult.buffers_generated.dart'; class DeployTransactionBuffer { DeployTransactionBuffer._(this._bc, this._bcOffset); + factory DeployTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -22,22 +24,32 @@ class DeployTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get owner => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); + List? get fileHash => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 22); + List? get vmVersion => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 24); @@ -207,6 +219,7 @@ class DeployTransactionBufferObjectBuilder extends fb.ObjectBuilder { class StartExecuteTransactionBuffer { StartExecuteTransactionBuffer._(this._bc, this._bcOffset); + factory StartExecuteTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -219,29 +232,42 @@ class StartExecuteTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get superContract => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + int get functionSize => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 20, 0); + int get mosaicsCount => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); + List? get dataSize => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 24); + List? get function => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 26); + List? get mosaics => const fb.ListReader(MosaicBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 28); + List? get data => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 30); @@ -443,6 +469,7 @@ class StartExecuteTransactionBufferObjectBuilder extends fb.ObjectBuilder { class DeactivateTransactionBuffer { DeactivateTransactionBuffer._(this._bc, this._bcOffset); + factory DeactivateTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -455,18 +482,26 @@ class DeactivateTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get superContract => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + List? get driveKey => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 20); diff --git a/lib/imp/buffer/schema_transfer_transaction_catapult.buffers_generated.dart b/lib/src/model/transaction/buffer/schema_transfer_transaction_catapult.buffers_generated.dart similarity index 98% rename from lib/imp/buffer/schema_transfer_transaction_catapult.buffers_generated.dart rename to lib/src/model/transaction/buffer/schema_transfer_transaction_catapult.buffers_generated.dart index 1ed31d4..2d1edca 100644 --- a/lib/imp/buffer/schema_transfer_transaction_catapult.buffers_generated.dart +++ b/lib/src/model/transaction/buffer/schema_transfer_transaction_catapult.buffers_generated.dart @@ -6,10 +6,12 @@ library catapult.buffers; import 'dart:typed_data' show Uint8List; import 'package:flat_buffers/flat_buffers.dart' as fb; -import 'package:xpx_chain_sdk/imp/buffer/schema_operation_transaction_catapult.buffers_generated.dart'; + +import './schema_operation_transaction_catapult.buffers_generated.dart'; class MessageBuffer { MessageBuffer._(this._bc, this._bcOffset); + factory MessageBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -21,6 +23,7 @@ class MessageBuffer { final int _bcOffset; int get type => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get payload => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); @@ -94,6 +97,7 @@ class MessageBufferObjectBuilder extends fb.ObjectBuilder { class TransferTransactionBuffer { TransferTransactionBuffer._(this._bc, this._bcOffset); + factory TransferTransactionBuffer(List bytes) { final rootRef = fb.BufferContext.fromBytes(bytes); return reader.read(rootRef, 0); @@ -106,23 +110,34 @@ class TransferTransactionBuffer { final int _bcOffset; int get size => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 4, 0); + List? get signature => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 6); + List? get signer => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 8); + int get version => const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 10, 0); + int get type => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 12, 0); + List? get maxFee => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 14); + List? get deadline => const fb.ListReader(fb.Uint32Reader()) .vTableGetNullable(_bc, _bcOffset, 16); + List? get recipient => const fb.Uint8ListReader().vTableGetNullable(_bc, _bcOffset, 18); + int get messageSize => const fb.Uint16Reader().vTableGet(_bc, _bcOffset, 20, 0); + int get numMosaics => const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 22, 0); + MessageBuffer? get message => MessageBuffer.reader.vTableGetNullable(_bc, _bcOffset, 24); + List? get mosaics => const fb.ListReader(MosaicBuffer.reader) .vTableGetNullable(_bc, _bcOffset, 26); diff --git a/lib/imp/buffer/transactions_buffer.dart b/lib/src/model/transaction/buffer/transactions_buffer.dart similarity index 100% rename from lib/imp/buffer/transactions_buffer.dart rename to lib/src/model/transaction/buffer/transactions_buffer.dart diff --git a/lib/src/model/transaction/transaciton_account_properties_address.dart b/lib/src/model/transaction/transaciton_account_properties_address.dart index 23f59fa..e897d22 100644 --- a/lib/src/model/transaction/transaciton_account_properties_address.dart +++ b/lib/src/model/transaction/transaciton_account_properties_address.dart @@ -19,7 +19,7 @@ class AccountPropertiesAddressTransaction extends AbstractTransaction : super.fromDto(dto.transaction!, dto.meta!) { propertyType = AccountPropertyType.fromInt(dto.transaction!.propertyType); modifications = AccountPropertiesAddressModification.listFromJson( - dto.transaction!.modifications); + dto.transaction!.modifications!); } AccountPropertyType? propertyType; diff --git a/lib/src/model/transaction/transaciton_account_properties_entity_type.dart b/lib/src/model/transaction/transaciton_account_properties_entity_type.dart index 3c3d71b..5b37980 100644 --- a/lib/src/model/transaction/transaciton_account_properties_entity_type.dart +++ b/lib/src/model/transaction/transaciton_account_properties_entity_type.dart @@ -19,7 +19,7 @@ class AccountPropertiesEntityTypeTransaction extends AbstractTransaction : super.fromDto(dto.transaction!, dto.meta!) { propertyType = AccountPropertyType.fromInt(dto.transaction!.propertyType); modifications = AccountPropertiesEntityTypeModification.listFromJson( - dto.transaction!.modifications); + dto.transaction!.modifications!); } AccountPropertyType? propertyType; diff --git a/lib/src/model/transaction/transaciton_account_properties_mosaic.dart b/lib/src/model/transaction/transaciton_account_properties_mosaic.dart index 5aedbe5..71da559 100644 --- a/lib/src/model/transaction/transaciton_account_properties_mosaic.dart +++ b/lib/src/model/transaction/transaciton_account_properties_mosaic.dart @@ -19,7 +19,7 @@ class AccountPropertiesMosaicTransaction extends AbstractTransaction : super.fromDto(dto.transaction!, dto.meta!) { propertyType = AccountPropertyType.fromInt(dto.transaction!.propertyType); modifications = AccountPropertiesMosaicModification.listFromJson( - dto.transaction!.modifications); + dto.transaction!.modifications!); } AccountPropertyType? propertyType; diff --git a/lib/src/model/transaction/transaction_aggregate.dart b/lib/src/model/transaction/transaction_aggregate.dart index 5af1735..12a4b43 100644 --- a/lib/src/model/transaction/transaction_aggregate.dart +++ b/lib/src/model/transaction/transaction_aggregate.dart @@ -40,13 +40,15 @@ class AggregateTransaction extends AbstractTransaction implements Transaction { AggregateTransaction.fromDTO(AggregateTransactionInfoDTO dto) : super.fromDto(dto.transaction!, dto.meta!) { - innerTransactions = - dto.transaction!.transactions!.map(deserializeDTO).toList(); + if (dto.transaction!.transactions.isNotEmpty) { + innerTransactions = + dto.transaction!.transactions.map(deserializeDTO).toList(); + } cosignatures = AggregateTransactionCosignature.listFromDTO( networkType.identifier, dto.transaction!.cosignatures); } - List? innerTransactions; + List innerTransactions = []; List? cosignatures; @override @@ -54,12 +56,6 @@ class AggregateTransaction extends AbstractTransaction implements Transaction { AbstractTransaction get abstractTransaction => absTransaction(); - static List listFromDTO( - List json) => - json.isEmpty - ? [] - : json.map(AggregateTransaction.fromDTO).toList(); - @override String toString() => encoder.convert(this); @@ -73,7 +69,9 @@ class AggregateTransaction extends AbstractTransaction implements Transaction { } } - writeNotNull('innerTransactions', innerTransactions); + if (innerTransactions.isNotEmpty) { + writeNotNull('innerTransactions', innerTransactions); + } writeNotNull('cosignatures', cosignatures); return val; @@ -82,7 +80,7 @@ class AggregateTransaction extends AbstractTransaction implements Transaction { @override int size() { int sizeOfInnerTransactions = 0; - for (final itx in innerTransactions!) { + for (final itx in innerTransactions) { sizeOfInnerTransactions += itx!.size() - signatureSize - maxFeeSize - deadLineSize; } @@ -98,7 +96,7 @@ class AggregateTransaction extends AbstractTransaction implements Transaction { // InnerTransactions final txsBytes = []; - for (final itx in innerTransactions!) { + for (final itx in innerTransactions) { final txb = toAggregateTransactionBytes(itx!); txsBytes.addAll(txb); } diff --git a/lib/src/model/transaction/transaction_dto.dart b/lib/src/model/transaction/transaction_dto.dart deleted file mode 100644 index 0888c70..0000000 --- a/lib/src/model/transaction/transaction_dto.dart +++ /dev/null @@ -1,300 +0,0 @@ -part of xpx_chain_sdk.transaction; - -class AbstractTransactionDTO { - int type; - int version; - UInt64DTO fee; - UInt64DTO deadline; - String signature; - String signer; - - Map toJson() => { - 'signature': signature, - 'signer': signer, - 'version': version, - 'type': type, - 'maxFee': fee, - 'deadline': deadline, - }; -} - -class TransferTransactionInfoDTO { - TransferTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - _transaction = json['transaction'] != null ? _TransferTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - _TransferTransactionDTO _transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (_transaction != null) { - data['transaction'] = _transaction.toJson(); - } - return data; - } -} - -class AggregateTransactionInfoDTO { - AggregateTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - _transaction = json['transaction'] != null ? _AggregateTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - _AggregateTransactionDTO _transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (_transaction != null) { - data['transaction'] = _transaction.toJson(); - } - return data; - } -} - -class MetaTransactionDTO { - MetaTransactionDTO( - {List height, - String hash, - String merkleComponentHash, - int index, - String id, - String aggregateHash, - String aggregateId}) { - _height = UInt64DTO.fromJson(height); - _hash = hash; - _merkleComponentHash = merkleComponentHash; - _index = index; - _id = id; - _aggregateHash = aggregateHash; - _aggregateId = aggregateId; - } - - MetaTransactionDTO.fromJson(Map json) { - _height = UInt64DTO.fromJson(json['height']); - _hash = json['hash']; - _merkleComponentHash = json['merkleComponentHash']; - _index = json['index']; - _id = json['id']; - _aggregateHash = json['aggregateHash']; - _aggregateId = json['aggregateId']; - } - - UInt64DTO _height; - String _hash; - String _merkleComponentHash; - int _index; - String _id; - String _aggregateHash; - String _aggregateId; - - Map toJson() { - final data = {}; - data['height'] = _height; - data['hash'] = _hash; - data['merkleComponentHash'] = _merkleComponentHash; - data['index'] = _index; - data['id'] = _id; - return data; - } -} - -class _AggregateTransactionCosignatureDTO { - _AggregateTransactionCosignatureDTO({String signature, String signer}) { - signature = signature; - signer = signer; - } - - _AggregateTransactionCosignatureDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - } - - String signature; - String signer; - - static List<_AggregateTransactionCosignatureDTO> listFromJson(List json) => - json == null ? null : json.map((value) => _AggregateTransactionCosignatureDTO.fromJson(value)).toList(); - - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - return data; - } -} - -class LockFundsTransactionInfoDTO { - LockFundsTransactionInfoDTO.fromJson(Map json) { - meta = json['meta'] != null ? MetaTransactionDTO.fromJson(json['meta']) : null; - - _transaction = json['transaction'] != null ? LockFundsTransactionDTO.fromJson(json['transaction']) : null; - } - - MetaTransactionDTO meta; - LockFundsTransactionDTO _transaction; - - Map toJson() { - final data = {}; - if (meta != null) { - data['meta'] = meta.toJson(); - } - if (_transaction != null) { - data['transaction'] = _transaction.toJson(); - } - return data; - } -} - -class _TransferTransactionDTO extends AbstractTransactionDTO { - _TransferTransactionDTO( - {String signature, - String signer, - int version, - int type, - List maxFee, - List deadline, - String recipient, - List mosaics, - MessageDTO message}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - fee = UInt64DTO.fromJson(maxFee); - this.deadline = UInt64DTO.fromJson(deadline); - _recipient = recipient; - _mosaics = mosaics; - _message = message; - } - - _TransferTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - _recipient = json['recipient']; - - if (json['mosaics'] != null) { - final List mosaics = []; - json['mosaics'].forEach((value) { - mosaics.add(MosaicDTO.fromJson(value)); - }); - _mosaics = mosaics; - } - _message = json['message'] != null ? MessageDTO.fromJson(json['message']) : null; - } - - String _recipient; - List _mosaics; - MessageDTO _message; - - @override - Map toJson() { - final data = {}; - data['signature'] = signature; - data['signer'] = signer; - data['version'] = version; - data['type'] = type; - data['maxFee'] = fee; - data['deadline'] = deadline; - data['recipient'] = _recipient; - if (_mosaics != null) { - data['mosaics'] = _mosaics.map((v) => v.toJson()).toList(); - } - data['message'] = _message; - return data; - } -} - -class _AggregateTransactionDTO extends AbstractTransactionDTO { - _AggregateTransactionDTO( - {String signature, - String signer, - int version, - int type, - List maxFee, - List deadline, - List<_AggregateTransactionCosignatureDTO> cosignatures, - List transactions}) { - this.signature = signature; - this.signer = signer; - this.version = version; - this.type = type; - fee = UInt64DTO.fromJson(maxFee); - this.deadline = UInt64DTO.fromJson(deadline); - _cosignatures = cosignatures; - _transactions = transactions; - } - - _AggregateTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - _cosignatures = _AggregateTransactionCosignatureDTO.listFromJson(json['cosignatures']); - _transactions = txnDeserialize(json['transactions'], 'List'); - } - - List<_AggregateTransactionCosignatureDTO> _cosignatures; - List _transactions; - - @override - Map toJson() => { - 'signature': signature, - 'signer': signer, - 'version': version, - 'type': type, - 'maxFee': fee, - 'deadline': deadline, - 'cosignatures': _cosignatures, - 'transactions': _transactions, - }; -} - -class LockFundsTransactionDTO extends AbstractTransactionDTO { - LockFundsTransactionDTO.fromJson(Map json) { - signature = json['signature']; - signer = json['signer']; - version = json['version']; - type = json['type']; - fee = UInt64DTO.fromJson(json['maxFee']); - deadline = UInt64DTO.fromJson(json['deadline']); - _assetId = UInt64DTO.fromJson(json['mosaicId']); - _amount = UInt64DTO.fromJson(json['amount']); - _duration = UInt64DTO.fromJson(json['duration']); - _hash = json['hash']; - } - - UInt64DTO _assetId; - UInt64DTO _amount; - UInt64DTO _duration; - String _hash; - - @override - Map toJson() => { - 'signature': signature, - 'signer': signer, - 'version': version, - 'type': type, - 'maxFee': fee, - 'deadline': deadline, - 'mosaicId': _assetId, - 'amount': _amount, - 'duration': _duration, - 'hash': _hash, - }; -} diff --git a/lib/src/model/transaction/transaction_hashes.dart b/lib/src/model/transaction/transaction_hashes.dart deleted file mode 100644 index d03e1a8..0000000 --- a/lib/src/model/transaction/transaction_hashes.dart +++ /dev/null @@ -1,29 +0,0 @@ -part of xpx_chain_sdk.transaction; - -class TransactionHashes { - TransactionHashes.fromJson(Map json) : assert(json != null, 'json must not be null') { - hashes = (json['hashes']).map((item) => item).toList(); - } - - TransactionHashes.fromList(List list) : assert(list != null, 'json must not be null') { - hashes = list.map((item) => item).toList(); - } - - List hashes = []; - - @override - String toString() => '{hashes=$hashes}'; - - Map toJson() => {'hashes': hashes}; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => TransactionHashes.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = TransactionHashes.fromJson(value)); - } - return map; - } -} diff --git a/lib/src/model/transaction/transaction_internal.dart b/lib/src/model/transaction/transaction_internal.dart index 0914381..4f8bd4a 100644 --- a/lib/src/model/transaction/transaction_internal.dart +++ b/lib/src/model/transaction/transaction_internal.dart @@ -414,3 +414,52 @@ Uint8List hexDecodeStringOdd(final String s) { } return Uint8List.fromList(hex.decode(data)); } + +List fixAggregate(List allTransaction) { + final containsAggregate = allTransaction.firstWhereOrNull((element) => + element.entityType() == TransactionType.aggregateCompleted || + element.entityType() == TransactionType.aggregateBonded); + + if (containsAggregate != null) { + for (var transaction in allTransaction) { + if (transaction.entityType() != TransactionType.aggregateCompleted && + transaction.entityType() != TransactionType.aggregateBonded) { + final aggregateTransaction = allTransaction.firstWhere((element) => + element.absTransaction().transactionHash == + transaction.absTransaction().aggregateHash) as AggregateTransaction; + aggregateTransaction.innerTransactions.add(transaction); + final indexATx = allTransaction.indexOf(aggregateTransaction); + allTransaction[indexATx] = aggregateTransaction; + } + } + + final respAll = []; + for (var transaction in allTransaction) { + if (transaction.absTransaction().aggregateHash == null) + respAll.add(transaction); + } + return respAll; + } + return allTransaction; +} + +Future> internalGetTransactions(ApiClient client, String path, + List queryParams, Object? postBody, + {bool firstLevel = true}) async { + final response = await client.get(path, postBody, queryParams); + + if (response.statusCode! >= 299) { + throw ApiException(response.statusCode!, response.data); + } else if (response.data != null) { + final List resp = client.deserialize(response.data, 'List'); + final allTransaction = + resp.map(deserializeDTO).toList().cast(); + + if (firstLevel) { + return allTransaction; + } else + return fixAggregate(allTransaction); + } else { + return []; + } +} diff --git a/lib/src/model/transaction/transaction_model.dart b/lib/src/model/transaction/transaction_model.dart deleted file mode 100644 index fc4d064..0000000 --- a/lib/src/model/transaction/transaction_model.dart +++ /dev/null @@ -1,365 +0,0 @@ -part of xpx_chain_sdk.transaction; - -// CosignatureSignedTransaction -class CosignatureSignedTransaction { - CosignatureSignedTransaction(this._parentHash, this.signature, this.signer); - - final String _parentHash; - final String signature; - final String signer; - - String get hash => _parentHash; - - @override - String toString() => '{\n' - '\t"parentHash": $_parentHash\n' - '\t"signature": $signature\n' - '\t"signer": $signer\n' - '}\n'; - - Map toJson() { - final data = {}; - data['parentHash'] = _parentHash; - data['signature'] = signature; - data['signer'] = signer; - return data; - } -} - -abstract class Transaction { - AbstractTransaction absTransaction(); - - TransactionType entityType(); - - Map toJson(); - - Uint8List generateBytes(); - - int _size(); -} - -// Transaction Info -mixin TransactionInfo { - Uint64 height; - int index; - String id; - String transactionHash; - String merkleComponentHash; - String aggregateHash; - String aggregateId; - - TransactionInfo get getTransactionInfo => this; - - String _transactionInfoToString() { - final sb = StringBuffer() - ..writeln('{') - ..writeln('\t\t\t"height": $height,') - ..writeln('\t\t\t"index": $index,') - ..writeln('\t\t\t"id": $id,'); - if (transactionHash != null) { - sb.writeln('\t\t\t"transactionHash": $transactionHash,'); - } - if (merkleComponentHash != null) { - sb.writeln('\t\t\t"merkleComponentHash": $merkleComponentHash,'); - } - if (aggregateHash != null) { - sb.writeln('\t\t\t"aggregateHash": $aggregateHash,'); - } - if (aggregateId != null) { - sb.writeln('\t\t\t"aggregateId": $aggregateId,'); - } - sb.write('\t\t}'); - return sb.toString(); - } - - @override - String toString() => _transactionInfoToString(); - - Map toJson() => _transactionInfoToJson(); - - Map _transactionInfoToJson() { - final data = {}; - data['height'] = height; - data['index'] = index; - data['id'] = id; - data['transactionHash'] = transactionHash; - data['merkleComponentHash'] = merkleComponentHash; - data['aggregateHash'] = aggregateHash; - data['aggregateId'] = aggregateId; - - return data; - } -} - -class TransactionType { - const TransactionType._internal(this.value); - - static const TransactionType aggregateCompleted = TransactionType._internal(0x4141); - - static const TransactionType aggregateBonded = TransactionType._internal(0x4241); - - static const TransactionType addressAlias = TransactionType._internal(0x424E); - - static const TransactionType metadataAddress = TransactionType._internal(0x413d); - - static const TransactionType metadataMosaic = TransactionType._internal(0x423d); - - static const TransactionType metadataNamespace = TransactionType._internal(0x433d); - - static const TransactionType mosaicDefinition = TransactionType._internal(0x414d); - - static const TransactionType mosaicAlias = TransactionType._internal(0x434e); - - static const TransactionType mosaicSupplyChange = TransactionType._internal(0x424d); - - static const TransactionType modifyMultisig = TransactionType._internal(0x4155); - - static const TransactionType modifyContract = TransactionType._internal(0x4157); - - static const TransactionType registerNamespace = TransactionType._internal(0x414e); - - static const TransactionType transfer = TransactionType._internal(0x4154); - - static const TransactionType lock = TransactionType._internal(0x4148); - - static const TransactionType secretLock = TransactionType._internal(0x4152); - - static const TransactionType secretProof = TransactionType._internal(0x4252); - - static const TransactionType addExchangeOffer = TransactionType._internal(0x415D); - - static const TransactionType exchangeOffer = TransactionType._internal(0x425D); - - static const TransactionType removeExchangeOffer = TransactionType._internal(0x435D); - - static const TransactionType accountPropertyAddress = TransactionType._internal(0x4150); - - static const TransactionType accountPropertyMosaic = TransactionType._internal(0x4250); - - static const TransactionType accountPropertyEntityType = TransactionType._internal(0x4350); - - final int value; - - static final List list = [ - accountPropertyAddress, - accountPropertyMosaic, - accountPropertyEntityType, - aggregateCompleted, - aggregateBonded, - addressAlias, - metadataAddress, - metadataMosaic, - metadataNamespace, - mosaicDefinition, - mosaicAlias, - mosaicSupplyChange, - modifyMultisig, - modifyContract, - registerNamespace, - transfer, - lock, - secretLock, - secretProof, - addExchangeOffer, - exchangeOffer, - removeExchangeOffer - ]; - - static TransactionType fromInt(int value) { - for (var type in list) { - if (type.value == value) { - return type; - } - } - - throw errUnknownTransactionType; - } - - Uint8List toBytes() { - final buffer = Uint8List(2).buffer; - final s = ByteData.view(buffer); - - s.setInt16(0, TransactionType.addExchangeOffer.value, Endian.little); - return buffer.asUint8List(); - } - - @override - String toString() => value.toString(); - - Map toJson() { - final data = {}; - data['value'] = value; - return data; - } -} - -class Deadline { - Deadline( - {int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0, int microseconds = 0}) { - final d = Duration( - days: days, - hours: hours, - minutes: minutes, - seconds: seconds, - milliseconds: milliseconds, - microseconds: microseconds); - value = DateTime.now().add(d); - } - - Deadline.fromUInt64DTO(UInt64DTO data) - : assert(data.lower != null || data.higher == null, 'lower or higher must not be null') { - value = data.toUint64() != null - ? DateTime.fromMillisecondsSinceEpoch( - data.toUint64().toInt() + timestampNemesisBlock.toUtc().millisecondsSinceEpoch) - : null; - } - - DateTime value; - - @override - String toString() { - if (value != null) { - return '$value ${value.timeZoneName}'; - } else { - return 'null'; - } - } - - int toBlockchainTimestamp() => value.millisecondsSinceEpoch - timestampNemesisBlock.millisecondsSinceEpoch; -} - -class SignedTransaction { - SignedTransaction([this.transactionType, this.payload, this.hash]); - - SignedTransaction.fromJson(Map json) { - transactionType = json['transactionType']; - payload = json['payload']; - hash = json['hash']; - } - - int transactionType; - String payload; - String hash; - - @override - String toString() => '{\n' - '\t"transactionType": $transactionType\n' - '\t"payload": $payload\n' - '\t"hash": $hash\n' - '}\n'; - - Map toJson() { - final data = {}; - data['transactionType'] = transactionType; - data['payload'] = payload; - data['hash'] = hash; - return data; - } -} - -class AbstractTransaction with TransactionInfo { - AbstractTransaction( - [this.networkType, this.deadline, this.type, this.version, this.maxFee, this.signature, this.signer]); - - AbstractTransaction.fromDto(AbstractTransactionDTO absValue, MetaTransactionDTO metaValue) { - networkType = extractNetworkType(absValue.version); - deadline = Deadline.fromUInt64DTO(absValue.deadline); - type = TransactionType.fromInt(absValue.type); - version = extractVersion(absValue.version); - maxFee = absValue.fee.toUint64(); - signature = absValue.signature; - signer = PublicAccount.fromPublicKey(absValue.signer, networkType); - _generateMeta(metaValue); - } - - int networkType; - Deadline deadline; - TransactionType type; - int version; - Uint64 maxFee; - String signature; - PublicAccount signer; - - PublicAccount get toAggregate => signer; - - set toAggregate(PublicAccount signer) => this.signer = signer; - - void _generateMeta(MetaTransactionDTO dto) { - height = dto._height.toUint64(); - index = dto._index; - id = dto._id; - transactionHash = dto._hash; - merkleComponentHash = dto._merkleComponentHash; - aggregateHash = dto._aggregateHash; - aggregateId = dto._aggregateId; - } - - Map _generateVector(fb.Builder builder) { - final Map data = {}; - data['versionV'] = (networkType << 24) + version; - data['signatureV'] = builder.writeListUint8(Uint8List(signatureSize)); - data['signerV'] = builder.writeListUint8(Uint8List(signerSize)); - data['deadlineV'] = builder.writeListUint32(Uint64(deadline.toBlockchainTimestamp()).toIntArray()); - data['feeV'] = builder.writeListUint32(maxFee != null ? maxFee.toIntArray() : [0, 0]); - return data; - } - - void _buildVector(fb.Builder builder, Map vector) { - Transactions(builder) - ..addSignatureOffset(vector['signatureV']) - ..addSignerOffset(vector['signerV']) - ..addVersion(vector['versionV']) - ..addType(type.value) - ..addFeeOffset(vector['feeV']) - ..addDeadlineOffset(vector['deadlineV']); - } - - AbstractTransaction _absTransaction() => this; - - bool isUnconfirmed() => height.toInt() == 0 && transactionHash == merkleComponentHash; - - bool isConfirmed() => height.toInt() > 0; - - bool hasMissingSignatures() => height.toInt() == 0 && transactionHash != merkleComponentHash; - - bool isUnannounced() => this == null; - - @override - String toString() => _absToString(); - - String _absToString() { - final sb = StringBuffer() - ..writeln('{') - ..writeln('\t\t"transactionInfo": ${_transactionInfoToString()},') - ..writeln('\t\t"networkType": $networkType,') - ..writeln('\t\t"type": $type') - ..writeln('\t\t"version": $version,'); - if (maxFee != null) { - sb.writeln('\t\t"maxFee": $maxFee,'); - } - if (deadline != null) { - sb.writeln('\t\t"deadline": $deadline,'); - } - if (signature != null) { - sb.writeln('\t\t"signature": $signature,'); - } - sb.writeln('\t\t"signer": $signer,'); - sb.write('\t},'); - return sb.toString(); - } - - @override - Map toJson() => _absToJson(); - - Map _absToJson() { - final Map data = {}..addAll(_transactionInfoToJson()); - data['networkType'] = networkType; - data['type'] = type; - data['version'] = version; - data['maxFee'] = maxFee; - data['deadline'] = deadline; - data['signature'] = signature; - data['signer'] = signer; - return data; - } -} diff --git a/lib/src/model/transaction/transaction_mosaic_metadata.dart b/lib/src/model/transaction/transaction_mosaic_metadata.dart index faebc21..383b989 100644 --- a/lib/src/model/transaction/transaction_mosaic_metadata.dart +++ b/lib/src/model/transaction/transaction_mosaic_metadata.dart @@ -10,7 +10,7 @@ part of xpx_chain_sdk.model.transaction; /// class MosaicMetadataTransaction extends BasicMetadataTransaction implements Transaction { - MosaicMetadataTransaction( + MosaicMetadataTransaction._( this.targetMosaicId, PublicAccount targetAccount, Uint64 scopedMetadataKey, @@ -75,7 +75,7 @@ class MosaicMetadataTransaction extends BasicMetadataTransaction valueDifferenceBytes[i] = valueUint8List[i] ^ oldValueUint8List[i]; } - return MosaicMetadataTransaction( + return MosaicMetadataTransaction._( targetMosaicId, targetAccount, scopedMetadataKey, diff --git a/lib/src/model/transaction/transaction_multisig.dart b/lib/src/model/transaction/transaction_multisig.dart index 37a71e1..eb1c08b 100644 --- a/lib/src/model/transaction/transaction_multisig.dart +++ b/lib/src/model/transaction/transaction_multisig.dart @@ -51,7 +51,7 @@ class MultisigCosignatoryModification { /// class ModifyMultisigAccountTransaction extends AbstractTransaction implements Transaction { - ModifyMultisigAccountTransaction( + ModifyMultisigAccountTransaction.create( Deadline deadline, int minApproval, int minRemoval, @@ -73,15 +73,6 @@ class ModifyMultisigAccountTransaction extends AbstractTransaction ModifyMultisigAccountTransaction.fromDTO( ModifyMultisigAccountTransactionInfoDTO dto) : super.fromDto(dto.transaction!, dto.meta!) { - type = TransactionType.fromInt(dto.transaction!.type); - deadline = Deadline.fromUInt64DTO(dto.transaction!.deadline!); - signature = dto.transaction!.signature; - networkType = - NetworkType.fromInt(extractNetworkType(dto.transaction!.version!)); - version = extractVersion(dto.transaction!.version!); - maxFee = dto.transaction!.fee!.toUint64(); - signer = PublicAccount.fromPublicKey(dto.transaction!.signer, networkType); - minApprovalDelta = dto.transaction!.minApprovalDelta; minRemovalDelta = dto.transaction!.minRemovalDelta; modifications = MultisigCosignatoryModification.listFromDTO( diff --git a/lib/src/model/transaction/transaction_type.dart b/lib/src/model/transaction/transaction_type.dart index 42990a7..439b80a 100644 --- a/lib/src/model/transaction/transaction_type.dart +++ b/lib/src/model/transaction/transaction_type.dart @@ -7,88 +7,97 @@ part of xpx_chain_sdk.model.transaction; class TransactionType { - const TransactionType._internal(this.value); + const TransactionType._internal(this.value, this.name); static const TransactionType aggregateCompleted = - TransactionType._internal(0x4141); + TransactionType._internal(0x4141, 'aggregateCompleted'); // 16705 static const TransactionType aggregateBonded = - TransactionType._internal(0x4241); // 4241 + TransactionType._internal(0x4241, 'aggregateBonded'); // 16961 - static const TransactionType addressAlias = TransactionType._internal(0x424E); + static const TransactionType addressAlias = + TransactionType._internal(0x424E, 'addressAlias'); // 16974 static const TransactionType metadataAddress = - TransactionType._internal(0x413d); + TransactionType._internal(0x413d, 'metadataAddress'); // 16701 static const TransactionType metadataMosaic = - TransactionType._internal(0x423d); + TransactionType._internal(0x423d, 'metadataMosaic'); // 16957 static const TransactionType metadataNamespace = - TransactionType._internal(0x433d); + TransactionType._internal(0x433d, 'metadataNamespace'); // 17213 /// Modify account metadata transaction type - NEM static const TransactionType accountMetadataV2 = - TransactionType._internal(0x413F); // 16703 + TransactionType._internal(0x413F, 'accountMetadataV2'); // 16703 /// Modify mosaic metadata transaction type - NEM static const TransactionType mosaicMetadataV2 = - TransactionType._internal(0x423F); + TransactionType._internal(0x423F, 'mosaicMetadataV2'); // 16959 /// Modify namespace metadata transaction type - NEM static const TransactionType namespaceMetadataV2 = - TransactionType._internal(0x433F); + TransactionType._internal(0x433F, 'namespaceMetadataV2'); // 17215 static const TransactionType mosaicDefinition = - TransactionType._internal(0x414d); + TransactionType._internal(0x414d, 'mosaicDefinition'); // 16717 - static const TransactionType mosaicAlias = TransactionType._internal(0x434e); + static const TransactionType mosaicAlias = + TransactionType._internal(0x434e, 'mosaicAlias'); static const TransactionType mosaicSupplyChange = - TransactionType._internal(0x424d); + TransactionType._internal(0x424d, 'mosaicSupplyChange'); // 16973 static const TransactionType modifyMultisig = - TransactionType._internal(0x4155); + TransactionType._internal(0x4155, 'modifyMultisig'); // 16725 static const TransactionType modifyContract = - TransactionType._internal(0x4157); + TransactionType._internal(0x4157, 'modifyContract'); // 16727 static const TransactionType registerNamespace = - TransactionType._internal(0x414e); + TransactionType._internal(0x414e, 'registerNamespace'); // 16718 - static const TransactionType transfer = TransactionType._internal(0x4154); + static const TransactionType transfer = + TransactionType._internal(0x4154, 'transfer'); // 16724 - static const TransactionType lock = TransactionType._internal(0x4148); + static const TransactionType lock = + TransactionType._internal(0x4148, 'lock'); // 16712 - static const TransactionType secretLock = TransactionType._internal(0x4152); + static const TransactionType secretLock = + TransactionType._internal(0x4152, 'secretLock'); // 16722 - static const TransactionType secretProof = TransactionType._internal(0x4252); + static const TransactionType secretProof = + TransactionType._internal(0x4252, 'secretProof'); // 16978 static const TransactionType addExchangeOffer = - TransactionType._internal(0x415D); + TransactionType._internal(0x415D, 'addExchangeOffer'); // 16733 static const TransactionType exchangeOffer = - TransactionType._internal(0x425D); + TransactionType._internal(0x425D, 'exchangeOffer'); // 16989 static const TransactionType removeExchangeOffer = - TransactionType._internal(0x435D); + TransactionType._internal(0x435D, 'removeExchangeOffer'); // 17245 static const TransactionType accountPropertyAddress = - TransactionType._internal(0x4150); + TransactionType._internal(0x4150, 'accountPropertyAddress'); // 16720 static const TransactionType accountPropertyMosaic = - TransactionType._internal(0x4250); + TransactionType._internal(0x4250, 'accountPropertyMosaic'); // 16976 static const TransactionType accountPropertyEntityType = - TransactionType._internal(0x4350); + TransactionType._internal(0x4350, 'accountPropertyEntityType'); // 17232 static const TransactionType networkConfigEntityType = - TransactionType._internal(0x4159); + TransactionType._internal(0x4159, 'networkConfigEntityType'); // 16729 static const TransactionType blockchainUpgrade = - TransactionType._internal(0x4158); + TransactionType._internal(0x4158, 'blockchainUpgrade'); // 16728 final int value; + /// This TransactionType's name. + final String name; + static final List list = [ accountPropertyAddress, accountPropertyMosaic, @@ -125,8 +134,6 @@ class TransactionType { return type; } } - print(value); - throw errUnknownTransactionType; } @@ -134,12 +141,22 @@ class TransactionType { final buffer = Uint8List(2).buffer; final s = ByteData.view(buffer); - s.setInt16(0, TransactionType.addExchangeOffer.value, Endian.little); + s.setInt16(0, value, Endian.little); return buffer.asUint8List(); } + /// Returns this TransactionType's [name]. @override - String toString() => encoder.convert(this); + String toString() => name; int toJson() => value; + + // Subclasses will typically have a private constructor and a fixed set of + // instances, so `Object.operator==()` will work, and does not need to + // be overridden explicitly. + @override + bool operator ==(Object other); + + @override + int get hashCode => value; } diff --git a/lib/src/model/uint64/uint64_dto.dart b/lib/src/model/uint64/uint64_dto.dart deleted file mode 100644 index 4ef32eb..0000000 --- a/lib/src/model/uint64/uint64_dto.dart +++ /dev/null @@ -1,47 +0,0 @@ -part of xpx_chain_sdk.uint64; - -class UInt64DTO { - UInt64DTO([this.higher, this.lower]); - - UInt64DTO.fromJson(json) { - if (json == null) { - return; - } - - higher = Int32(json[0]); - lower = Int32(json[1]); - } - - UInt64DTO.fromBigInt(BigInt v) : assert(v != null, 'json must not be null') { - final u64 = v.toInt(); - higher = Int32(u64 & 0xFFFFFFFF); - lower = Int32(u64 >> 32); - } - - Int32 lower, higher; - - static List listFromJson(List json) => - json == null ? null : json.map((value) => UInt64DTO.fromJson(value)).toList(); - - static Map mapFromJson(Map> json) { - final map = {}; - if (json != null && json.isNotEmpty) { - json.forEach((key, value) => map[key] = UInt64DTO.fromJson(value)); - } - return map; - } - - Uint64 toUint64() { - if (lower == null || higher == null) { - return null; - } - return Uint64.fromDto(this); - } - - Map toJson() { - final data = {}; - data['higher'] = higher; - data['lower'] = lower; - return data; - } -} diff --git a/lib/src/utils.dart b/lib/src/utils.dart index ae094e7..028880f 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -12,6 +12,8 @@ import 'dart:typed_data'; import 'package:convert/convert.dart'; +part './utils/all_errors.dart'; part './utils/byte_utils.dart'; +part './utils/consts.dart'; part './utils/hex_utils.dart'; part './utils/json_utils.dart'; diff --git a/lib/xpx_sdk_all_errors.dart b/lib/src/utils/all_errors.dart similarity index 98% rename from lib/xpx_sdk_all_errors.dart rename to lib/src/utils/all_errors.dart index 42d1096..abda70b 100644 --- a/lib/xpx_sdk_all_errors.dart +++ b/lib/src/utils/all_errors.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -library xpx_chain_sdk.error; +part of xpx_chain_sdk.model.utils; /// Mosaic errors final errNullMosaicId = Exception('mosaicId must not be null'); diff --git a/lib/xpx_sdk_consts.dart b/lib/src/utils/consts.dart similarity index 99% rename from lib/xpx_sdk_consts.dart rename to lib/src/utils/consts.dart index a0f75d3..7d70db3 100644 --- a/lib/xpx_sdk_consts.dart +++ b/lib/src/utils/consts.dart @@ -4,7 +4,7 @@ * license that can be found in the LICENSE file. */ -library xpx_chain_sdk.cons; +part of xpx_chain_sdk.model.utils; enum MultisigCosignatoryModificationType { add, remove } diff --git a/lib/xpx_sdk.dart b/lib/xpx_chain_sdk.dart similarity index 86% rename from lib/xpx_sdk.dart rename to lib/xpx_chain_sdk.dart index fa05737..bcfaacd 100644 --- a/lib/xpx_sdk.dart +++ b/lib/xpx_chain_sdk.dart @@ -9,4 +9,3 @@ library xpx_chain_sdk; export 'package:xpx_chain_sdk/src/api.dart'; export 'package:xpx_chain_sdk/src/model.dart'; export 'package:xpx_chain_sdk/src/utils.dart'; -export 'package:xpx_chain_sdk/xpx_sdk_consts.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 24de850..1be901c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: xpx_chain_sdk -version: 0.0.7+5 +version: 0.0.7+8 #author: 'Eleazar Garrido , ProximaX Devops ' description: 'The ProximaX Sirius Chain Dart SDK works as a async lightweight Dart library for interacting with the Sirius Blockchain.' homepage: https://github.com/proximax-storage diff --git a/schemas/README.md b/schemas/README.md index 734e140..4d39c70 100644 --- a/schemas/README.md +++ b/schemas/README.md @@ -13,6 +13,7 @@ cmake -G "Unix Makefiles" make cd - ``` + You can use syntax like: ```$xslt From f6cb17d0b525375e23b49c0f3170237828057524 Mon Sep 17 00:00:00 2001 From: shinneng Date: Mon, 30 May 2022 13:09:24 +0800 Subject: [PATCH 3/4] update ci to github actions --- .github/workflows/publish.yaml | 21 +++++++++++++++++++++ .travis/publish.sh | 14 -------------- 2 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/publish.yaml delete mode 100644 .travis/publish.sh diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..33868a3 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,21 @@ +name: Publish sdk + +on: + release: + types: [published] + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Publish + uses: sakebook/actions-flutter-pub-publisher@v1.4.0 + with: + credential: ${{ secrets.PUB_CREDENTIALS_JSON }} + flutter_package: false + skip_test: true + dry_run: false \ No newline at end of file diff --git a/.travis/publish.sh b/.travis/publish.sh deleted file mode 100644 index 0ebf614..0000000 --- a/.travis/publish.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -mkdir -p ~/.pub-cache - -cat < ~/.pub-cache/credentials.json -{ - "accessToken":"$accessToken", - "refreshToken":"$refreshToken", - "tokenEndpoint":"$tokenEndpoint", - "scopes": [$scopes_array], - "expiration":$expiration -} -EOF - -pub publish -f \ No newline at end of file From 8ff5fe88c8260c8765ca492837ddee46baa743b1 Mon Sep 17 00:00:00 2001 From: shinneng Date: Mon, 30 May 2022 14:04:40 +0800 Subject: [PATCH 4/4] fix missing dependencies --- pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pubspec.yaml b/pubspec.yaml index 1be901c..bb56272 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,6 +18,7 @@ dependencies: convert: ^3.0.1 fixnum: ^1.0.0 flat_buffers: ^2.0.5 + collection: ^1.16.0 #dev_dependencies: # build_web_compilers: any