@ledgerhq/coin-aptos 1.9.6 → 1.10.0-nightly.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +18 -6
- package/CHANGELOG.md +24 -0
- package/jest.config.js +1 -1
- package/jest.integ.config.js +8 -0
- package/lib/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
- package/lib/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
- package/lib/__tests__/api/craftTransaction.unit.test.js +50 -0
- package/lib/__tests__/api/craftTransaction.unit.test.js.map +1 -0
- package/lib/__tests__/api/getBalance.unit.test.d.ts +2 -0
- package/lib/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
- package/lib/__tests__/api/getBalance.unit.test.js +41 -0
- package/lib/__tests__/api/getBalance.unit.test.js.map +1 -0
- package/lib/__tests__/api/index.integ.test.d.ts +2 -0
- package/lib/__tests__/api/index.integ.test.d.ts.map +1 -0
- package/lib/__tests__/api/index.integ.test.js +115 -0
- package/lib/__tests__/api/index.integ.test.js.map +1 -0
- package/lib/__tests__/api/index.test.js +48 -404
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/bridge/broadcast.test.js +5 -5
- package/lib/__tests__/bridge/broadcast.test.js.map +1 -1
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +115 -14
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getTransactionStatus.test.js +175 -37
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib/__tests__/bridge/logic.test.js +702 -478
- package/lib/__tests__/bridge/logic.test.js.map +1 -1
- package/lib/__tests__/bridge/prepareTransaction.test.js +3 -3
- package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/signOperation.test.js +137 -14
- package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib/__tests__/bridge/synchronisation.test.js +1215 -68
- package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib/__tests__/index.test.js +1 -1
- package/lib/__tests__/index.test.js.map +1 -1
- package/lib/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/logic/buildTransaction.test.js +112 -0
- package/lib/__tests__/logic/buildTransaction.test.js.map +1 -0
- package/lib/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/calculateAmount.unit.test.js +45 -0
- package/lib/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
- package/lib/__tests__/logic/combine.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/combine.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/combine.unit.test.js +47 -0
- package/lib/__tests__/logic/combine.unit.test.js.map +1 -0
- package/lib/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/compareAddress.unit.test.js +26 -0
- package/lib/__tests__/logic/compareAddress.unit.test.js.map +1 -0
- package/lib/__tests__/logic/createTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
- package/lib/__tests__/logic/createTransaction.test.js.map +1 -0
- package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js +186 -0
- package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
- package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/getFunctionAddress.unit.test.js +29 -0
- package/lib/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
- package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/getResourceAddress.unit.test.js +218 -0
- package/lib/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
- package/lib/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/isTestnet.unit.test.js +12 -0
- package/lib/__tests__/logic/isTestnet.unit.test.js.map +1 -0
- package/lib/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/processRecipients.unit.test.js +79 -0
- package/lib/__tests__/logic/processRecipients.unit.test.js.map +1 -0
- package/lib/__tests__/network/client.test.d.ts +2 -0
- package/lib/__tests__/network/client.test.d.ts.map +1 -0
- package/lib/__tests__/network/client.test.js +992 -0
- package/lib/__tests__/network/client.test.js.map +1 -0
- package/lib/api/index.d.ts +4 -30
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +19 -170
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/bridge.fixture.d.ts +2 -0
- package/lib/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib/bridge/bridge.fixture.js +85 -13
- package/lib/bridge/bridge.fixture.js.map +1 -1
- package/lib/bridge/broadcast.d.ts +3 -2
- package/lib/bridge/broadcast.d.ts.map +1 -1
- package/lib/bridge/broadcast.js +4 -3
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +6 -5
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +20 -14
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +28 -14
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.d.ts +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +1 -1
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/logic.d.ts +5 -19
- package/lib/bridge/logic.d.ts.map +1 -1
- package/lib/bridge/logic.js +50 -147
- package/lib/bridge/logic.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +5 -4
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +21 -7
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.d.ts +15 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -1
- package/lib/bridge/synchronisation.js +129 -6
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/config.d.ts +13 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +9 -0
- package/lib/config.js.map +1 -0
- package/lib/constants.d.ts +10 -2
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +13 -2
- package/lib/constants.js.map +1 -1
- package/lib/{bridge → logic}/buildTransaction.d.ts +1 -1
- package/lib/logic/buildTransaction.d.ts.map +1 -0
- package/lib/logic/buildTransaction.js +45 -0
- package/lib/logic/buildTransaction.js.map +1 -0
- package/lib/logic/calculateAmount.d.ts +3 -0
- package/lib/logic/calculateAmount.d.ts.map +1 -0
- package/lib/logic/calculateAmount.js +13 -0
- package/lib/logic/calculateAmount.js.map +1 -0
- package/lib/logic/combine.d.ts +4 -0
- package/lib/logic/combine.d.ts.map +1 -0
- package/lib/logic/combine.js +34 -0
- package/lib/logic/combine.js.map +1 -0
- package/lib/logic/craftTransaction.d.ts +5 -0
- package/lib/logic/craftTransaction.d.ts.map +1 -0
- package/lib/logic/craftTransaction.js +23 -0
- package/lib/logic/craftTransaction.js.map +1 -0
- package/lib/logic/createTransaction.d.ts.map +1 -0
- package/lib/{bridge → logic}/createTransaction.js +3 -3
- package/lib/logic/createTransaction.js.map +1 -0
- package/lib/logic/getBalance.d.ts +5 -0
- package/lib/logic/getBalance.d.ts.map +1 -0
- package/lib/logic/getBalance.js +12 -0
- package/lib/logic/getBalance.js.map +1 -0
- package/lib/logic/getCoinAndAmounts.d.ts +13 -0
- package/lib/logic/getCoinAndAmounts.d.ts.map +1 -0
- package/lib/logic/getCoinAndAmounts.js +112 -0
- package/lib/logic/getCoinAndAmounts.js.map +1 -0
- package/lib/logic/getFunctionAddress.d.ts +3 -0
- package/lib/logic/getFunctionAddress.d.ts.map +1 -0
- package/lib/logic/getFunctionAddress.js +12 -0
- package/lib/logic/getFunctionAddress.js.map +1 -0
- package/lib/logic/getResourceAddress.d.ts +4 -0
- package/lib/logic/getResourceAddress.d.ts.map +1 -0
- package/lib/logic/getResourceAddress.js +17 -0
- package/lib/logic/getResourceAddress.js.map +1 -0
- package/lib/logic/isTestnet.d.ts +2 -0
- package/lib/logic/isTestnet.d.ts.map +1 -0
- package/lib/logic/isTestnet.js +9 -0
- package/lib/logic/isTestnet.js.map +1 -0
- package/lib/logic/isWriteSetChangeWriteResource.d.ts +3 -0
- package/lib/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
- package/lib/logic/isWriteSetChangeWriteResource.js +8 -0
- package/lib/logic/isWriteSetChangeWriteResource.js.map +1 -0
- package/lib/logic/normalizeTransactionOptions.d.ts +3 -0
- package/lib/logic/normalizeTransactionOptions.d.ts.map +1 -0
- package/lib/logic/normalizeTransactionOptions.js +21 -0
- package/lib/logic/normalizeTransactionOptions.js.map +1 -0
- package/lib/logic/processRecipients.d.ts +6 -0
- package/lib/logic/processRecipients.d.ts.map +1 -0
- package/lib/logic/processRecipients.js +57 -0
- package/lib/logic/processRecipients.js.map +1 -0
- package/lib/logic/transactionsToOperations.d.ts +7 -0
- package/lib/logic/transactionsToOperations.d.ts.map +1 -0
- package/lib/logic/transactionsToOperations.js +85 -0
- package/lib/logic/transactionsToOperations.js.map +1 -0
- package/lib/network/client.d.ts +38 -0
- package/lib/network/client.d.ts.map +1 -0
- package/lib/network/client.js +266 -0
- package/lib/network/client.js.map +1 -0
- package/lib/network/graphql/queries.d.ts.map +1 -0
- package/lib/{api → network}/graphql/queries.js +6 -6
- package/lib/network/graphql/queries.js.map +1 -0
- package/lib/{api → network}/graphql/types.d.ts +9 -9
- package/lib/network/graphql/types.d.ts.map +1 -0
- package/lib/{api → network}/graphql/types.js.map +1 -1
- package/lib/network/index.d.ts +2 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +19 -7
- package/lib/network/index.js.map +1 -1
- package/lib/test/bot-specs.d.ts.map +1 -1
- package/lib/test/bot-specs.js +40 -1
- package/lib/test/bot-specs.js.map +1 -1
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib/test/bridgeDatasetTest.js +44 -62
- package/lib/test/bridgeDatasetTest.js.map +1 -1
- package/lib/test/speculos-deviceActions.d.ts +1 -0
- package/lib/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib/test/speculos-deviceActions.js +37 -5
- package/lib/test/speculos-deviceActions.js.map +1 -1
- package/lib/types/assets.d.ts +12 -0
- package/lib/types/assets.d.ts.map +1 -0
- package/lib/types/assets.js +3 -0
- package/lib/types/assets.js.map +1 -0
- package/lib/types/index.d.ts +22 -7
- package/lib/types/index.d.ts.map +1 -1
- package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
- package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/api/craftTransaction.unit.test.js +48 -0
- package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -0
- package/lib-es/__tests__/api/getBalance.unit.test.d.ts +2 -0
- package/lib-es/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/api/getBalance.unit.test.js +36 -0
- package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -0
- package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
- package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
- package/lib-es/__tests__/api/index.integ.test.js +113 -0
- package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
- package/lib-es/__tests__/api/index.test.js +52 -408
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/broadcast.test.js +2 -2
- package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +112 -11
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +177 -39
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib-es/__tests__/bridge/logic.test.js +702 -478
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
- package/lib-es/__tests__/bridge/prepareTransaction.test.js +2 -2
- package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/signOperation.test.js +137 -14
- package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib-es/__tests__/bridge/synchronisation.test.js +1213 -69
- package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib-es/__tests__/index.test.js +1 -1
- package/lib-es/__tests__/index.test.js.map +1 -1
- package/lib-es/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/buildTransaction.test.js +107 -0
- package/lib-es/__tests__/logic/buildTransaction.test.js.map +1 -0
- package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/calculateAmount.unit.test.js +40 -0
- package/lib-es/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/combine.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/combine.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/combine.unit.test.js +45 -0
- package/lib-es/__tests__/logic/combine.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/compareAddress.unit.test.js +24 -0
- package/lib-es/__tests__/logic/compareAddress.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/createTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
- package/lib-es/__tests__/logic/createTransaction.test.js.map +1 -0
- package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js +181 -0
- package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js +27 -0
- package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/getResourceAddress.unit.test.js +216 -0
- package/lib-es/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/isTestnet.unit.test.js +10 -0
- package/lib-es/__tests__/logic/isTestnet.unit.test.js.map +1 -0
- package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/processRecipients.unit.test.js +74 -0
- package/lib-es/__tests__/logic/processRecipients.unit.test.js.map +1 -0
- package/lib-es/__tests__/network/client.test.d.ts +2 -0
- package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
- package/lib-es/__tests__/network/client.test.js +987 -0
- package/lib-es/__tests__/network/client.test.js.map +1 -0
- package/lib-es/api/index.d.ts +4 -30
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +17 -168
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/bridge.fixture.d.ts +2 -0
- package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
- package/lib-es/bridge/bridge.fixture.js +82 -12
- package/lib-es/bridge/bridge.fixture.js.map +1 -1
- package/lib-es/bridge/broadcast.d.ts +3 -2
- package/lib-es/bridge/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.js +4 -3
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +4 -3
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +15 -9
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +28 -14
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.d.ts +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +1 -1
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/logic.d.ts +5 -19
- package/lib-es/bridge/logic.d.ts.map +1 -1
- package/lib-es/bridge/logic.js +44 -134
- package/lib-es/bridge/logic.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +5 -4
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +19 -5
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.d.ts +15 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -1
- package/lib-es/bridge/synchronisation.js +124 -4
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/config.d.ts +13 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +4 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/constants.d.ts +10 -2
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +9 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/{bridge → logic}/buildTransaction.d.ts +1 -1
- package/lib-es/logic/buildTransaction.d.ts.map +1 -0
- package/lib-es/logic/buildTransaction.js +43 -0
- package/lib-es/logic/buildTransaction.js.map +1 -0
- package/lib-es/logic/calculateAmount.d.ts +3 -0
- package/lib-es/logic/calculateAmount.d.ts.map +1 -0
- package/lib-es/logic/calculateAmount.js +9 -0
- package/lib-es/logic/calculateAmount.js.map +1 -0
- package/lib-es/logic/combine.d.ts +4 -0
- package/lib-es/logic/combine.d.ts.map +1 -0
- package/lib-es/logic/combine.js +29 -0
- package/lib-es/logic/combine.js.map +1 -0
- package/lib-es/logic/craftTransaction.d.ts +5 -0
- package/lib-es/logic/craftTransaction.d.ts.map +1 -0
- package/lib-es/logic/craftTransaction.js +16 -0
- package/lib-es/logic/craftTransaction.js.map +1 -0
- package/lib-es/logic/createTransaction.d.ts.map +1 -0
- package/lib-es/{bridge → logic}/createTransaction.js +1 -1
- package/lib-es/logic/createTransaction.js.map +1 -0
- package/lib-es/logic/getBalance.d.ts +5 -0
- package/lib-es/logic/getBalance.d.ts.map +1 -0
- package/lib-es/logic/getBalance.js +8 -0
- package/lib-es/logic/getBalance.js.map +1 -0
- package/lib-es/logic/getCoinAndAmounts.d.ts +13 -0
- package/lib-es/logic/getCoinAndAmounts.d.ts.map +1 -0
- package/lib-es/logic/getCoinAndAmounts.js +101 -0
- package/lib-es/logic/getCoinAndAmounts.js.map +1 -0
- package/lib-es/logic/getFunctionAddress.d.ts +3 -0
- package/lib-es/logic/getFunctionAddress.d.ts.map +1 -0
- package/lib-es/logic/getFunctionAddress.js +8 -0
- package/lib-es/logic/getFunctionAddress.js.map +1 -0
- package/lib-es/logic/getResourceAddress.d.ts +4 -0
- package/lib-es/logic/getResourceAddress.d.ts.map +1 -0
- package/lib-es/logic/getResourceAddress.js +13 -0
- package/lib-es/logic/getResourceAddress.js.map +1 -0
- package/lib-es/logic/isTestnet.d.ts +2 -0
- package/lib-es/logic/isTestnet.d.ts.map +1 -0
- package/lib-es/logic/isTestnet.js +5 -0
- package/lib-es/logic/isTestnet.js.map +1 -0
- package/lib-es/logic/isWriteSetChangeWriteResource.d.ts +3 -0
- package/lib-es/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
- package/lib-es/logic/isWriteSetChangeWriteResource.js +4 -0
- package/lib-es/logic/isWriteSetChangeWriteResource.js.map +1 -0
- package/lib-es/logic/normalizeTransactionOptions.d.ts +3 -0
- package/lib-es/logic/normalizeTransactionOptions.d.ts.map +1 -0
- package/lib-es/logic/normalizeTransactionOptions.js +17 -0
- package/lib-es/logic/normalizeTransactionOptions.js.map +1 -0
- package/lib-es/logic/processRecipients.d.ts +6 -0
- package/lib-es/logic/processRecipients.d.ts.map +1 -0
- package/lib-es/logic/processRecipients.js +53 -0
- package/lib-es/logic/processRecipients.js.map +1 -0
- package/lib-es/logic/transactionsToOperations.d.ts +7 -0
- package/lib-es/logic/transactionsToOperations.d.ts.map +1 -0
- package/lib-es/logic/transactionsToOperations.js +77 -0
- package/lib-es/logic/transactionsToOperations.js.map +1 -0
- package/lib-es/network/client.d.ts +38 -0
- package/lib-es/network/client.d.ts.map +1 -0
- package/lib-es/network/client.js +259 -0
- package/lib-es/network/client.js.map +1 -0
- package/lib-es/network/graphql/queries.d.ts.map +1 -0
- package/lib-es/{api → network}/graphql/queries.js +6 -6
- package/lib-es/network/graphql/queries.js.map +1 -0
- package/lib-es/{api → network}/graphql/types.d.ts +9 -9
- package/lib-es/network/graphql/types.d.ts.map +1 -0
- package/lib-es/{api → network}/graphql/types.js.map +1 -1
- package/lib-es/network/index.d.ts +2 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +6 -8
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/test/bot-specs.d.ts.map +1 -1
- package/lib-es/test/bot-specs.js +41 -2
- package/lib-es/test/bot-specs.js.map +1 -1
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
- package/lib-es/test/bridgeDatasetTest.js +44 -59
- package/lib-es/test/bridgeDatasetTest.js.map +1 -1
- package/lib-es/test/speculos-deviceActions.d.ts +1 -0
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib-es/test/speculos-deviceActions.js +36 -4
- package/lib-es/test/speculos-deviceActions.js.map +1 -1
- package/lib-es/types/assets.d.ts +12 -0
- package/lib-es/types/assets.d.ts.map +1 -0
- package/lib-es/types/assets.js +2 -0
- package/lib-es/types/assets.js.map +1 -0
- package/lib-es/types/index.d.ts +22 -7
- package/lib-es/types/index.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/__tests__/api/craftTransaction.unit.test.ts +70 -0
- package/src/__tests__/api/getBalance.unit.test.ts +44 -0
- package/src/__tests__/api/index.integ.test.ts +139 -0
- package/src/__tests__/api/index.test.ts +60 -477
- package/src/__tests__/bridge/broadcast.test.ts +2 -2
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +146 -11
- package/src/__tests__/bridge/getTransactionStatus.test.ts +217 -38
- package/src/__tests__/bridge/logic.test.ts +727 -568
- package/src/__tests__/bridge/prepareTransaction.test.ts +2 -2
- package/src/__tests__/bridge/signOperation.test.ts +153 -15
- package/src/__tests__/bridge/synchronisation.test.ts +1265 -71
- package/src/__tests__/index.test.ts +1 -1
- package/src/__tests__/logic/buildTransaction.test.ts +148 -0
- package/src/__tests__/logic/calculateAmount.unit.test.ts +51 -0
- package/src/__tests__/logic/combine.unit.test.ts +65 -0
- package/src/__tests__/logic/compareAddress.unit.test.ts +27 -0
- package/src/__tests__/{bridge → logic}/createTransaction.test.ts +2 -2
- package/src/__tests__/logic/getCoinAndAmounts.unit.test.ts +195 -0
- package/src/__tests__/logic/getFunctionAddress.unit.test.ts +33 -0
- package/src/__tests__/logic/getResourceAddress.unit.test.ts +241 -0
- package/src/__tests__/logic/isTestnet.unit.test.ts +11 -0
- package/src/__tests__/logic/processRecipients.unit.test.ts +87 -0
- package/src/__tests__/network/client.test.ts +1107 -0
- package/src/api/index.ts +29 -224
- package/src/bridge/bridge.fixture.ts +91 -12
- package/src/bridge/broadcast.ts +7 -7
- package/src/bridge/estimateMaxSpendable.ts +4 -3
- package/src/bridge/getFeesForTransaction.ts +17 -11
- package/src/bridge/getTransactionStatus.ts +35 -13
- package/src/bridge/index.ts +2 -2
- package/src/bridge/logic.ts +58 -194
- package/src/bridge/prepareTransaction.ts +7 -4
- package/src/bridge/signOperation.ts +21 -5
- package/src/bridge/synchronisation.ts +171 -4
- package/src/config.ts +19 -0
- package/src/constants.ts +18 -2
- package/src/logic/buildTransaction.ts +62 -0
- package/src/logic/calculateAmount.ts +15 -0
- package/src/logic/combine.ts +51 -0
- package/src/logic/craftTransaction.ts +26 -0
- package/src/{bridge → logic}/createTransaction.ts +1 -1
- package/src/logic/getBalance.ts +15 -0
- package/src/logic/getCoinAndAmounts.ts +141 -0
- package/src/logic/getFunctionAddress.ts +9 -0
- package/src/logic/getResourceAddress.ts +24 -0
- package/src/logic/isTestnet.ts +5 -0
- package/src/logic/isWriteSetChangeWriteResource.ts +7 -0
- package/src/logic/normalizeTransactionOptions.ts +18 -0
- package/src/logic/processRecipients.ts +87 -0
- package/src/logic/transactionsToOperations.ts +105 -0
- package/src/network/client.ts +351 -0
- package/src/{api → network}/graphql/queries.ts +6 -6
- package/src/{api → network}/graphql/types.ts +9 -9
- package/src/network/index.ts +6 -14
- package/src/test/bot-specs.ts +63 -3
- package/src/test/bridgeDatasetTest.ts +46 -59
- package/src/test/speculos-deviceActions.ts +40 -4
- package/src/types/assets.ts +15 -0
- package/src/types/index.ts +20 -1
- package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
- package/lib/__tests__/bridge/buildTransaction.test.js +0 -53
- package/lib/__tests__/bridge/buildTransaction.test.js.map +0 -1
- package/lib/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
- package/lib/__tests__/bridge/createTransaction.test.js.map +0 -1
- package/lib/api/graphql/queries.d.ts.map +0 -1
- package/lib/api/graphql/queries.js.map +0 -1
- package/lib/api/graphql/types.d.ts.map +0 -1
- package/lib/bridge/buildTransaction.d.ts.map +0 -1
- package/lib/bridge/buildTransaction.js +0 -19
- package/lib/bridge/buildTransaction.js.map +0 -1
- package/lib/bridge/createTransaction.d.ts.map +0 -1
- package/lib/bridge/createTransaction.js.map +0 -1
- package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
- package/lib-es/__tests__/bridge/buildTransaction.test.js +0 -48
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +0 -1
- package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
- package/lib-es/__tests__/bridge/createTransaction.test.js.map +0 -1
- package/lib-es/api/graphql/queries.d.ts.map +0 -1
- package/lib-es/api/graphql/queries.js.map +0 -1
- package/lib-es/api/graphql/types.d.ts.map +0 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +0 -1
- package/lib-es/bridge/buildTransaction.js +0 -17
- package/lib-es/bridge/buildTransaction.js.map +0 -1
- package/lib-es/bridge/createTransaction.d.ts.map +0 -1
- package/lib-es/bridge/createTransaction.js.map +0 -1
- package/src/__tests__/bridge/buildTransaction.test.ts +0 -61
- package/src/bridge/buildTransaction.ts +0 -29
- /package/lib/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
- /package/lib/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
- /package/lib/{bridge → logic}/createTransaction.d.ts +0 -0
- /package/lib/{api → network}/graphql/queries.d.ts +0 -0
- /package/lib/{api → network}/graphql/types.js +0 -0
- /package/lib-es/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
- /package/lib-es/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
- /package/lib-es/{bridge → logic}/createTransaction.d.ts +0 -0
- /package/lib-es/{api → network}/graphql/queries.d.ts +0 -0
- /package/lib-es/{api → network}/graphql/types.js +0 -0
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
3
7
|
const index_1 = require("@ledgerhq/cryptoassets/index");
|
|
4
8
|
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
9
|
+
const index_2 = require("@ledgerhq/coin-framework/account/index");
|
|
10
|
+
const network_1 = require("../../network");
|
|
7
11
|
const synchronisation_1 = require("../../bridge/synchronisation");
|
|
12
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
13
|
+
const bridge_fixture_1 = require("../../bridge/bridge.fixture");
|
|
14
|
+
const logic_1 = require("../../bridge/logic");
|
|
8
15
|
jest.mock("@ledgerhq/coin-framework/account", () => {
|
|
9
16
|
const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
|
|
10
17
|
const partialMockedModule = Object.keys(originalModule).reduce((pre, methodName) => {
|
|
@@ -14,18 +21,20 @@ jest.mock("@ledgerhq/coin-framework/account", () => {
|
|
|
14
21
|
return {
|
|
15
22
|
...partialMockedModule,
|
|
16
23
|
// mock all except these
|
|
24
|
+
encodeAccountId: originalModule.encodeAccountId,
|
|
17
25
|
decodeAccountId: originalModule.decodeAccountId,
|
|
26
|
+
encodeTokenAccountId: originalModule.encodeTokenAccountId,
|
|
18
27
|
};
|
|
19
28
|
});
|
|
20
|
-
const
|
|
21
|
-
jest.mock("../../
|
|
29
|
+
const mockedDecodeTokenAccountId = jest.mocked(account_1.decodeTokenAccountId);
|
|
30
|
+
jest.mock("../../network");
|
|
22
31
|
let mockedAptosAPI;
|
|
23
32
|
jest.mock("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
24
33
|
jest.mock("invariant", () => jest.fn());
|
|
34
|
+
jest.mock("../../bridge/logic");
|
|
25
35
|
describe("getAccountShape", () => {
|
|
26
36
|
beforeEach(() => {
|
|
27
|
-
mockedAptosAPI = jest.mocked(
|
|
28
|
-
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
37
|
+
mockedAptosAPI = jest.mocked(network_1.AptosAPI);
|
|
29
38
|
});
|
|
30
39
|
afterEach(() => {
|
|
31
40
|
jest.resetAllMocks();
|
|
@@ -40,6 +49,8 @@ describe("getAccountShape", () => {
|
|
|
40
49
|
getAccountInfo: mockGetAccountInfo,
|
|
41
50
|
}));
|
|
42
51
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
52
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
53
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
43
54
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
44
55
|
id: "1",
|
|
45
56
|
address: "address",
|
|
@@ -72,9 +83,8 @@ describe("getAccountShape", () => {
|
|
|
72
83
|
},
|
|
73
84
|
}, {});
|
|
74
85
|
expect(account.xpub).toEqual("address");
|
|
75
|
-
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
76
86
|
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
77
|
-
expect(mockGetAccountSpy).toHaveBeenCalledWith("address"
|
|
87
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
|
|
78
88
|
});
|
|
79
89
|
it("account without xpub", async () => {
|
|
80
90
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
@@ -86,6 +96,8 @@ describe("getAccountShape", () => {
|
|
|
86
96
|
getAccountInfo: mockGetAccountInfo,
|
|
87
97
|
}));
|
|
88
98
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
99
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
100
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
89
101
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
90
102
|
id: "1",
|
|
91
103
|
address: "address",
|
|
@@ -117,9 +129,8 @@ describe("getAccountShape", () => {
|
|
|
117
129
|
},
|
|
118
130
|
}, {});
|
|
119
131
|
expect(account.xpub).toEqual("1");
|
|
120
|
-
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
121
132
|
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
122
|
-
expect(mockGetAccountSpy).toHaveBeenCalledWith("address"
|
|
133
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
|
|
123
134
|
});
|
|
124
135
|
it("without initialAccount", async () => {
|
|
125
136
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
@@ -131,6 +142,8 @@ describe("getAccountShape", () => {
|
|
|
131
142
|
getAccountInfo: mockGetAccountInfo,
|
|
132
143
|
}));
|
|
133
144
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
145
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
146
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
134
147
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
135
148
|
id: "1",
|
|
136
149
|
address: "address",
|
|
@@ -142,9 +155,8 @@ describe("getAccountShape", () => {
|
|
|
142
155
|
deviceId: "1",
|
|
143
156
|
}, {});
|
|
144
157
|
expect(account.xpub).toEqual("");
|
|
145
|
-
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
146
158
|
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
147
|
-
expect(mockGetAccountSpy).toHaveBeenCalledWith("address"
|
|
159
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
|
|
148
160
|
});
|
|
149
161
|
it("initialAccount with operations", async () => {
|
|
150
162
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
@@ -156,6 +168,8 @@ describe("getAccountShape", () => {
|
|
|
156
168
|
getAccountInfo: mockGetAccountInfo,
|
|
157
169
|
}));
|
|
158
170
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
171
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
172
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
159
173
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
160
174
|
id: "1",
|
|
161
175
|
address: "address",
|
|
@@ -178,22 +192,8 @@ describe("getAccountShape", () => {
|
|
|
178
192
|
creationDate: new Date(),
|
|
179
193
|
blockHeight: 0,
|
|
180
194
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
181
|
-
|
|
182
|
-
operations: [
|
|
183
|
-
{
|
|
184
|
-
id: "1",
|
|
185
|
-
hash: "hash",
|
|
186
|
-
type: "OUT",
|
|
187
|
-
value: BigInt(10),
|
|
188
|
-
fee: BigInt(0),
|
|
189
|
-
blockHeight: 0,
|
|
190
|
-
blockHash: "blockHash",
|
|
191
|
-
accountId: "1",
|
|
192
|
-
senders: ["sender"],
|
|
193
|
-
recipients: ["recipient"],
|
|
194
|
-
date: new Date(),
|
|
195
|
-
},
|
|
196
|
-
],
|
|
195
|
+
operationsCount: 0,
|
|
196
|
+
operations: [],
|
|
197
197
|
pendingOperations: [],
|
|
198
198
|
lastSyncDate: new Date(),
|
|
199
199
|
balanceHistoryCache: {},
|
|
@@ -201,9 +201,8 @@ describe("getAccountShape", () => {
|
|
|
201
201
|
},
|
|
202
202
|
}, {});
|
|
203
203
|
expect(account.xpub).toEqual("1");
|
|
204
|
-
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
205
204
|
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
206
|
-
expect(mockGetAccountSpy).toHaveBeenCalledWith("address"
|
|
205
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
|
|
207
206
|
});
|
|
208
207
|
it("initialAccount with operations with extra", async () => {
|
|
209
208
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
@@ -215,6 +214,8 @@ describe("getAccountShape", () => {
|
|
|
215
214
|
getAccountInfo: mockGetAccountInfo,
|
|
216
215
|
}));
|
|
217
216
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
217
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
218
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
218
219
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
219
220
|
id: "1",
|
|
220
221
|
address: "address",
|
|
@@ -237,23 +238,8 @@ describe("getAccountShape", () => {
|
|
|
237
238
|
creationDate: new Date(),
|
|
238
239
|
blockHeight: 0,
|
|
239
240
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
240
|
-
|
|
241
|
-
operations: [
|
|
242
|
-
{
|
|
243
|
-
id: "1",
|
|
244
|
-
hash: "hash",
|
|
245
|
-
type: "OUT",
|
|
246
|
-
value: BigInt(10),
|
|
247
|
-
fee: BigInt(0),
|
|
248
|
-
blockHeight: 0,
|
|
249
|
-
blockHash: "blockHash",
|
|
250
|
-
accountId: "1",
|
|
251
|
-
senders: ["sender"],
|
|
252
|
-
recipients: ["recipient"],
|
|
253
|
-
date: new Date(),
|
|
254
|
-
extra: { version: 1 },
|
|
255
|
-
},
|
|
256
|
-
],
|
|
241
|
+
operationsCount: 0,
|
|
242
|
+
operations: [],
|
|
257
243
|
pendingOperations: [],
|
|
258
244
|
lastSyncDate: new Date(),
|
|
259
245
|
balanceHistoryCache: {},
|
|
@@ -261,9 +247,8 @@ describe("getAccountShape", () => {
|
|
|
261
247
|
},
|
|
262
248
|
}, {});
|
|
263
249
|
expect(account.xpub).toEqual("1");
|
|
264
|
-
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
265
250
|
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
266
|
-
expect(mockGetAccountSpy).toHaveBeenCalledWith("address"
|
|
251
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
|
|
267
252
|
});
|
|
268
253
|
it("get publicKey from rest", async () => {
|
|
269
254
|
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
@@ -275,6 +260,8 @@ describe("getAccountShape", () => {
|
|
|
275
260
|
getAccountInfo: mockGetAccountInfo,
|
|
276
261
|
}));
|
|
277
262
|
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
263
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
|
|
264
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([[], []]);
|
|
278
265
|
const account = await (0, synchronisation_1.getAccountShape)({
|
|
279
266
|
id: "1",
|
|
280
267
|
address: "address",
|
|
@@ -297,23 +284,8 @@ describe("getAccountShape", () => {
|
|
|
297
284
|
creationDate: new Date(),
|
|
298
285
|
blockHeight: 0,
|
|
299
286
|
currency: (0, index_1.getCryptoCurrencyById)("aptos"),
|
|
300
|
-
|
|
301
|
-
operations: [
|
|
302
|
-
{
|
|
303
|
-
id: "1",
|
|
304
|
-
hash: "hash",
|
|
305
|
-
type: "OUT",
|
|
306
|
-
value: BigInt(10),
|
|
307
|
-
fee: BigInt(0),
|
|
308
|
-
blockHeight: 0,
|
|
309
|
-
blockHash: "blockHash",
|
|
310
|
-
accountId: "1",
|
|
311
|
-
senders: ["sender"],
|
|
312
|
-
recipients: ["recipient"],
|
|
313
|
-
date: new Date(),
|
|
314
|
-
extra: { version: 1 },
|
|
315
|
-
},
|
|
316
|
-
],
|
|
287
|
+
operationsCount: 0,
|
|
288
|
+
operations: [],
|
|
317
289
|
pendingOperations: [],
|
|
318
290
|
lastSyncDate: new Date(),
|
|
319
291
|
balanceHistoryCache: {},
|
|
@@ -322,9 +294,1184 @@ describe("getAccountShape", () => {
|
|
|
322
294
|
rest: { publicKey: "restPublicKey" },
|
|
323
295
|
}, {});
|
|
324
296
|
expect(account.xpub).toEqual("restPublicKey");
|
|
325
|
-
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
326
297
|
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
327
|
-
expect(mockGetAccountSpy).toHaveBeenCalledWith("address"
|
|
298
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
|
|
299
|
+
});
|
|
300
|
+
it("initialAccount with operations with subOperations", async () => {
|
|
301
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
302
|
+
balance: (0, bignumber_js_1.default)(68254118),
|
|
303
|
+
transactions: [
|
|
304
|
+
{
|
|
305
|
+
version: "2532591427",
|
|
306
|
+
hash: "0x3f35",
|
|
307
|
+
state_change_hash: "0xb480",
|
|
308
|
+
event_root_hash: "0x3fa1",
|
|
309
|
+
state_checkpoint_hash: null,
|
|
310
|
+
gas_used: "12",
|
|
311
|
+
success: true,
|
|
312
|
+
vm_status: "Executed successfully",
|
|
313
|
+
accumulator_root_hash: "0x319f",
|
|
314
|
+
changes: [
|
|
315
|
+
{
|
|
316
|
+
address: "0x4e5e",
|
|
317
|
+
state_key_hash: "0x3c0c",
|
|
318
|
+
data: {
|
|
319
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
320
|
+
data: {
|
|
321
|
+
coin: {
|
|
322
|
+
value: "4000000",
|
|
323
|
+
},
|
|
324
|
+
deposit_events: {
|
|
325
|
+
counter: "9",
|
|
326
|
+
guid: {
|
|
327
|
+
id: {
|
|
328
|
+
addr: "0x4e5e",
|
|
329
|
+
creation_num: "4",
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
frozen: false,
|
|
334
|
+
withdraw_events: {
|
|
335
|
+
counter: "6",
|
|
336
|
+
guid: {
|
|
337
|
+
id: {
|
|
338
|
+
addr: "0x4e5e",
|
|
339
|
+
creation_num: "5",
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
type: "write_resource",
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
address: "0xa0d8",
|
|
349
|
+
state_key_hash: "0x1709",
|
|
350
|
+
data: {
|
|
351
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
352
|
+
data: {
|
|
353
|
+
coin: {
|
|
354
|
+
value: "68254118",
|
|
355
|
+
},
|
|
356
|
+
deposit_events: {
|
|
357
|
+
counter: "46",
|
|
358
|
+
guid: {
|
|
359
|
+
id: {
|
|
360
|
+
addr: "0xa0d8",
|
|
361
|
+
creation_num: "2",
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
frozen: false,
|
|
366
|
+
withdraw_events: {
|
|
367
|
+
counter: "89",
|
|
368
|
+
guid: {
|
|
369
|
+
id: {
|
|
370
|
+
addr: "0xa0d8",
|
|
371
|
+
creation_num: "3",
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
type: "write_resource",
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
address: "0xa0d8",
|
|
381
|
+
state_key_hash: "0x5520",
|
|
382
|
+
data: {
|
|
383
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
384
|
+
data: {
|
|
385
|
+
coin: {
|
|
386
|
+
value: "1000000",
|
|
387
|
+
},
|
|
388
|
+
deposit_events: {
|
|
389
|
+
counter: "7",
|
|
390
|
+
guid: {
|
|
391
|
+
id: {
|
|
392
|
+
addr: "0xa0d8",
|
|
393
|
+
creation_num: "10",
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
frozen: false,
|
|
398
|
+
withdraw_events: {
|
|
399
|
+
counter: "13",
|
|
400
|
+
guid: {
|
|
401
|
+
id: {
|
|
402
|
+
addr: "0xa0d8",
|
|
403
|
+
creation_num: "11",
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
type: "write_resource",
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
address: "0xa0d8",
|
|
413
|
+
state_key_hash: "0x6f1e",
|
|
414
|
+
data: {
|
|
415
|
+
type: "0x1::account::Account",
|
|
416
|
+
data: {
|
|
417
|
+
authentication_key: "0xa0d8",
|
|
418
|
+
coin_register_events: {
|
|
419
|
+
counter: "5",
|
|
420
|
+
guid: {
|
|
421
|
+
id: {
|
|
422
|
+
addr: "0xa0d8",
|
|
423
|
+
creation_num: "0",
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
guid_creation_num: "12",
|
|
428
|
+
key_rotation_events: {
|
|
429
|
+
counter: "0",
|
|
430
|
+
guid: {
|
|
431
|
+
id: {
|
|
432
|
+
addr: "0xa0d8",
|
|
433
|
+
creation_num: "1",
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
rotation_capability_offer: {
|
|
438
|
+
for: {
|
|
439
|
+
vec: [],
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
sequence_number: "122",
|
|
443
|
+
signer_capability_offer: {
|
|
444
|
+
for: {
|
|
445
|
+
vec: [],
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
type: "write_resource",
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
state_key_hash: "0x6e4b",
|
|
454
|
+
handle: "0x1b85",
|
|
455
|
+
key: "0x0619",
|
|
456
|
+
value: "0x1ddaf8da3b1497010000000000000000",
|
|
457
|
+
data: null,
|
|
458
|
+
type: "write_table_item",
|
|
459
|
+
},
|
|
460
|
+
],
|
|
461
|
+
sender: "0xa0d8",
|
|
462
|
+
sequence_number: "121",
|
|
463
|
+
max_gas_amount: "12",
|
|
464
|
+
gas_unit_price: "100",
|
|
465
|
+
expiration_timestamp_secs: "1743177404",
|
|
466
|
+
payload: {
|
|
467
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
468
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
469
|
+
arguments: ["0x4e5e", "1500000"],
|
|
470
|
+
type: "entry_function_payload",
|
|
471
|
+
},
|
|
472
|
+
signature: {
|
|
473
|
+
public_key: "0x474d",
|
|
474
|
+
signature: "0x0ad8",
|
|
475
|
+
type: "ed25519_signature",
|
|
476
|
+
},
|
|
477
|
+
events: [
|
|
478
|
+
{
|
|
479
|
+
guid: {
|
|
480
|
+
creation_number: "11",
|
|
481
|
+
account_address: "0xa0d8",
|
|
482
|
+
},
|
|
483
|
+
sequence_number: "12",
|
|
484
|
+
type: "0x1::coin::WithdrawEvent",
|
|
485
|
+
data: {
|
|
486
|
+
amount: "1500000",
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
guid: {
|
|
491
|
+
creation_number: "4",
|
|
492
|
+
account_address: "0x4e5e",
|
|
493
|
+
},
|
|
494
|
+
sequence_number: "8",
|
|
495
|
+
type: "0x1::coin::DepositEvent",
|
|
496
|
+
data: {
|
|
497
|
+
amount: "1500000",
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
guid: {
|
|
502
|
+
creation_number: "0",
|
|
503
|
+
account_address: "0x0",
|
|
504
|
+
},
|
|
505
|
+
sequence_number: "0",
|
|
506
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
507
|
+
data: {
|
|
508
|
+
execution_gas_units: "6",
|
|
509
|
+
io_gas_units: "6",
|
|
510
|
+
storage_fee_octas: "0",
|
|
511
|
+
storage_fee_refund_octas: "0",
|
|
512
|
+
total_charge_gas_units: "12",
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
],
|
|
516
|
+
timestamp: "1743177360481259",
|
|
517
|
+
type: "user_transaction",
|
|
518
|
+
block: {
|
|
519
|
+
height: 311948147,
|
|
520
|
+
hash: "0x6d02",
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
version: "2532549325",
|
|
525
|
+
hash: "0x9a6b",
|
|
526
|
+
state_change_hash: "0xa424",
|
|
527
|
+
event_root_hash: "0x0321",
|
|
528
|
+
state_checkpoint_hash: null,
|
|
529
|
+
gas_used: "12",
|
|
530
|
+
success: true,
|
|
531
|
+
vm_status: "Executed successfully",
|
|
532
|
+
accumulator_root_hash: "0xede9",
|
|
533
|
+
changes: [
|
|
534
|
+
{
|
|
535
|
+
address: "0x4e5e",
|
|
536
|
+
state_key_hash: "0x3c0c",
|
|
537
|
+
data: {
|
|
538
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
539
|
+
data: {
|
|
540
|
+
coin: {
|
|
541
|
+
value: "2500000",
|
|
542
|
+
},
|
|
543
|
+
deposit_events: {
|
|
544
|
+
counter: "8",
|
|
545
|
+
guid: {
|
|
546
|
+
id: {
|
|
547
|
+
addr: "0x4e5e",
|
|
548
|
+
creation_num: "4",
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
frozen: false,
|
|
553
|
+
withdraw_events: {
|
|
554
|
+
counter: "6",
|
|
555
|
+
guid: {
|
|
556
|
+
id: {
|
|
557
|
+
addr: "0x4e5e",
|
|
558
|
+
creation_num: "5",
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
type: "write_resource",
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
address: "0xa0d8",
|
|
568
|
+
state_key_hash: "0x1709",
|
|
569
|
+
data: {
|
|
570
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
571
|
+
data: {
|
|
572
|
+
coin: {
|
|
573
|
+
value: "68255318",
|
|
574
|
+
},
|
|
575
|
+
deposit_events: {
|
|
576
|
+
counter: "46",
|
|
577
|
+
guid: {
|
|
578
|
+
id: {
|
|
579
|
+
addr: "0xa0d8",
|
|
580
|
+
creation_num: "2",
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
frozen: false,
|
|
585
|
+
withdraw_events: {
|
|
586
|
+
counter: "89",
|
|
587
|
+
guid: {
|
|
588
|
+
id: {
|
|
589
|
+
addr: "0xa0d8",
|
|
590
|
+
creation_num: "3",
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
type: "write_resource",
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
address: "0xa0d8",
|
|
600
|
+
state_key_hash: "0x5520",
|
|
601
|
+
data: {
|
|
602
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
603
|
+
data: {
|
|
604
|
+
coin: {
|
|
605
|
+
value: "2500000",
|
|
606
|
+
},
|
|
607
|
+
deposit_events: {
|
|
608
|
+
counter: "7",
|
|
609
|
+
guid: {
|
|
610
|
+
id: {
|
|
611
|
+
addr: "0xa0d8",
|
|
612
|
+
creation_num: "10",
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
frozen: false,
|
|
617
|
+
withdraw_events: {
|
|
618
|
+
counter: "12",
|
|
619
|
+
guid: {
|
|
620
|
+
id: {
|
|
621
|
+
addr: "0xa0d8",
|
|
622
|
+
creation_num: "11",
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
type: "write_resource",
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
address: "0xa0d8",
|
|
632
|
+
state_key_hash: "0x6f1e",
|
|
633
|
+
data: {
|
|
634
|
+
type: "0x1::account::Account",
|
|
635
|
+
data: {
|
|
636
|
+
authentication_key: "0xa0d8",
|
|
637
|
+
coin_register_events: {
|
|
638
|
+
counter: "5",
|
|
639
|
+
guid: {
|
|
640
|
+
id: {
|
|
641
|
+
addr: "0xa0d8",
|
|
642
|
+
creation_num: "0",
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
},
|
|
646
|
+
guid_creation_num: "12",
|
|
647
|
+
key_rotation_events: {
|
|
648
|
+
counter: "0",
|
|
649
|
+
guid: {
|
|
650
|
+
id: {
|
|
651
|
+
addr: "0xa0d8",
|
|
652
|
+
creation_num: "1",
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
rotation_capability_offer: {
|
|
657
|
+
for: {
|
|
658
|
+
vec: [],
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
sequence_number: "121",
|
|
662
|
+
signer_capability_offer: {
|
|
663
|
+
for: {
|
|
664
|
+
vec: [],
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
type: "write_resource",
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
state_key_hash: "0x6e4b",
|
|
673
|
+
handle: "0x1b85",
|
|
674
|
+
key: "0x0619",
|
|
675
|
+
value: "0xe86e0039581497010000000000000000",
|
|
676
|
+
data: null,
|
|
677
|
+
type: "write_table_item",
|
|
678
|
+
},
|
|
679
|
+
],
|
|
680
|
+
sender: "0xa0d8",
|
|
681
|
+
sequence_number: "120",
|
|
682
|
+
max_gas_amount: "12",
|
|
683
|
+
gas_unit_price: "100",
|
|
684
|
+
expiration_timestamp_secs: "1743176706",
|
|
685
|
+
payload: {
|
|
686
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
687
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
688
|
+
arguments: ["0x4e5e", "2500000"],
|
|
689
|
+
type: "entry_function_payload",
|
|
690
|
+
},
|
|
691
|
+
signature: {
|
|
692
|
+
public_key: "0x474d",
|
|
693
|
+
signature: "0xb70e",
|
|
694
|
+
type: "ed25519_signature",
|
|
695
|
+
},
|
|
696
|
+
events: [
|
|
697
|
+
{
|
|
698
|
+
guid: {
|
|
699
|
+
creation_number: "11",
|
|
700
|
+
account_address: "0xa0d8",
|
|
701
|
+
},
|
|
702
|
+
sequence_number: "11",
|
|
703
|
+
type: "0x1::coin::WithdrawEvent",
|
|
704
|
+
data: {
|
|
705
|
+
amount: "2500000",
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
guid: {
|
|
710
|
+
creation_number: "4",
|
|
711
|
+
account_address: "0x4e5e",
|
|
712
|
+
},
|
|
713
|
+
sequence_number: "7",
|
|
714
|
+
type: "0x1::coin::DepositEvent",
|
|
715
|
+
data: {
|
|
716
|
+
amount: "2500000",
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
guid: {
|
|
721
|
+
creation_number: "0",
|
|
722
|
+
account_address: "0x0",
|
|
723
|
+
},
|
|
724
|
+
sequence_number: "0",
|
|
725
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
726
|
+
data: {
|
|
727
|
+
execution_gas_units: "6",
|
|
728
|
+
io_gas_units: "6",
|
|
729
|
+
storage_fee_octas: "0",
|
|
730
|
+
storage_fee_refund_octas: "0",
|
|
731
|
+
total_charge_gas_units: "12",
|
|
732
|
+
},
|
|
733
|
+
},
|
|
734
|
+
],
|
|
735
|
+
timestamp: "1743176594693251",
|
|
736
|
+
type: "user_transaction",
|
|
737
|
+
block: {
|
|
738
|
+
height: 311942427,
|
|
739
|
+
hash: "0x8655",
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
],
|
|
743
|
+
blockHeight: 316278241,
|
|
744
|
+
}));
|
|
745
|
+
const mockGetBalance = jest.fn().mockImplementation(() => (0, bignumber_js_1.default)(5000000));
|
|
746
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
747
|
+
getAccountInfo: mockGetAccountInfo,
|
|
748
|
+
getBalance: mockGetBalance,
|
|
749
|
+
}));
|
|
750
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
751
|
+
mockedDecodeTokenAccountId.mockReturnValue({
|
|
752
|
+
token: {
|
|
753
|
+
type: "TokenCurrency",
|
|
754
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
755
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
756
|
+
parentCurrency: {
|
|
757
|
+
type: "CryptoCurrency",
|
|
758
|
+
id: "aptos",
|
|
759
|
+
coinType: 637,
|
|
760
|
+
name: "Aptos",
|
|
761
|
+
managerAppName: "Aptos",
|
|
762
|
+
ticker: "APT",
|
|
763
|
+
scheme: "aptos",
|
|
764
|
+
color: "#231F20",
|
|
765
|
+
family: "aptos",
|
|
766
|
+
units: [
|
|
767
|
+
{
|
|
768
|
+
name: "APT",
|
|
769
|
+
code: "APT",
|
|
770
|
+
magnitude: 8,
|
|
771
|
+
},
|
|
772
|
+
],
|
|
773
|
+
explorerViews: [
|
|
774
|
+
{
|
|
775
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
776
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
777
|
+
},
|
|
778
|
+
],
|
|
779
|
+
},
|
|
780
|
+
name: "dstAPT",
|
|
781
|
+
tokenType: "coin",
|
|
782
|
+
ticker: "dstAPT",
|
|
783
|
+
disableCountervalue: false,
|
|
784
|
+
delisted: false,
|
|
785
|
+
units: [
|
|
786
|
+
{
|
|
787
|
+
name: "dstAPT",
|
|
788
|
+
code: "dstAPT",
|
|
789
|
+
magnitude: 8,
|
|
790
|
+
},
|
|
791
|
+
],
|
|
792
|
+
},
|
|
793
|
+
accountId: "js:2:aptos:6415:aptos",
|
|
794
|
+
});
|
|
795
|
+
const operations = [
|
|
796
|
+
{
|
|
797
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
798
|
+
hash: "0x3f35",
|
|
799
|
+
type: "FEES",
|
|
800
|
+
value: (0, bignumber_js_1.default)(1200),
|
|
801
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
802
|
+
blockHash: "0x6d02",
|
|
803
|
+
blockHeight: 311948147,
|
|
804
|
+
senders: ["0xa0d8"],
|
|
805
|
+
recipients: ["0x4e5e"],
|
|
806
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
807
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
808
|
+
extra: {
|
|
809
|
+
version: "2532591427",
|
|
810
|
+
},
|
|
811
|
+
transactionSequenceNumber: 121,
|
|
812
|
+
hasFailed: false,
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
|
|
816
|
+
hash: "0x9a6b",
|
|
817
|
+
type: "FEES",
|
|
818
|
+
value: (0, bignumber_js_1.default)(1200),
|
|
819
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
820
|
+
blockHash: "0x8655",
|
|
821
|
+
blockHeight: 311942427,
|
|
822
|
+
senders: ["0xa0d8"],
|
|
823
|
+
recipients: ["0x4e5e"],
|
|
824
|
+
accountId: "js:2:aptos:474d:aptos",
|
|
825
|
+
date: new Date("2025-03-28T15:43:14.693Z"),
|
|
826
|
+
extra: {
|
|
827
|
+
version: "2532549325",
|
|
828
|
+
},
|
|
829
|
+
transactionSequenceNumber: 120,
|
|
830
|
+
hasFailed: false,
|
|
831
|
+
},
|
|
832
|
+
];
|
|
833
|
+
const tokenOperations = [
|
|
834
|
+
{
|
|
835
|
+
id: "js:2:aptos:474d:aptos-0x3f35-OUT",
|
|
836
|
+
hash: "0x3f35",
|
|
837
|
+
type: "OUT",
|
|
838
|
+
value: (0, bignumber_js_1.default)(1500000),
|
|
839
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
840
|
+
blockHash: "0x6d02",
|
|
841
|
+
blockHeight: 311948147,
|
|
842
|
+
senders: ["0xa0d8"],
|
|
843
|
+
recipients: ["0x4e5e"],
|
|
844
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
845
|
+
date: new Date("2025-03-28T15:56:00.481Z"),
|
|
846
|
+
extra: {
|
|
847
|
+
version: "2532591427",
|
|
848
|
+
},
|
|
849
|
+
transactionSequenceNumber: 121,
|
|
850
|
+
hasFailed: false,
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
|
|
854
|
+
hash: "0x9a6b",
|
|
855
|
+
type: "OUT",
|
|
856
|
+
value: (0, bignumber_js_1.default)(2500000),
|
|
857
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
858
|
+
blockHash: "0x8655",
|
|
859
|
+
blockHeight: 311942427,
|
|
860
|
+
senders: ["0xa0d8"],
|
|
861
|
+
recipients: ["0x4e5e"],
|
|
862
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
863
|
+
date: new Date("2025-03-28T15:43:14.693Z"),
|
|
864
|
+
extra: {
|
|
865
|
+
version: "2532549325",
|
|
866
|
+
},
|
|
867
|
+
transactionSequenceNumber: 120,
|
|
868
|
+
hasFailed: false,
|
|
869
|
+
},
|
|
870
|
+
];
|
|
871
|
+
jest.mocked(jsHelpers_1.mergeOps).mockReturnValue(operations);
|
|
872
|
+
jest.mocked(logic_1.txsToOps).mockReturnValue([operations, tokenOperations]);
|
|
873
|
+
const info = {
|
|
874
|
+
currency: {
|
|
875
|
+
type: "CryptoCurrency",
|
|
876
|
+
id: "aptos",
|
|
877
|
+
coinType: 637,
|
|
878
|
+
name: "Aptos",
|
|
879
|
+
managerAppName: "Aptos",
|
|
880
|
+
ticker: "APT",
|
|
881
|
+
scheme: "aptos",
|
|
882
|
+
color: "#231F20",
|
|
883
|
+
family: "aptos",
|
|
884
|
+
units: [
|
|
885
|
+
{
|
|
886
|
+
name: "APT",
|
|
887
|
+
code: "APT",
|
|
888
|
+
magnitude: 8,
|
|
889
|
+
},
|
|
890
|
+
],
|
|
891
|
+
},
|
|
892
|
+
index: 0,
|
|
893
|
+
address: "0xa0d8",
|
|
894
|
+
derivationPath: "44'/637'/0'",
|
|
895
|
+
derivationMode: "aptos",
|
|
896
|
+
initialAccount: {
|
|
897
|
+
type: "Account",
|
|
898
|
+
id: "js:2:aptos:474d:aptos",
|
|
899
|
+
used: true,
|
|
900
|
+
seedIdentifier: "3086",
|
|
901
|
+
derivationMode: "aptos",
|
|
902
|
+
index: 0,
|
|
903
|
+
freshAddress: "0xa0d8",
|
|
904
|
+
freshAddressPath: "44'/637'/0'/0'/0'",
|
|
905
|
+
blockHeight: 316272224,
|
|
906
|
+
creationDate: "2025-01-16T14:17:41.076Z",
|
|
907
|
+
balance: (0, bignumber_js_1.default)(68254118),
|
|
908
|
+
spendableBalance: (0, bignumber_js_1.default)(68254118),
|
|
909
|
+
operations: [],
|
|
910
|
+
operationsCount: 0,
|
|
911
|
+
pendingOperations: [],
|
|
912
|
+
currency: {
|
|
913
|
+
type: "CryptoCurrency",
|
|
914
|
+
id: "aptos",
|
|
915
|
+
coinType: 637,
|
|
916
|
+
name: "Aptos",
|
|
917
|
+
managerAppName: "Aptos",
|
|
918
|
+
ticker: "APT",
|
|
919
|
+
scheme: "aptos",
|
|
920
|
+
color: "#231F20",
|
|
921
|
+
family: "aptos",
|
|
922
|
+
units: [
|
|
923
|
+
{
|
|
924
|
+
name: "APT",
|
|
925
|
+
code: "APT",
|
|
926
|
+
magnitude: 8,
|
|
927
|
+
},
|
|
928
|
+
],
|
|
929
|
+
},
|
|
930
|
+
lastSyncDate: new Date(),
|
|
931
|
+
swapHistory: [],
|
|
932
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
933
|
+
xpub: "474d",
|
|
934
|
+
subAccounts: [
|
|
935
|
+
{
|
|
936
|
+
type: "TokenAccount",
|
|
937
|
+
id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
938
|
+
parentId: "js:2:aptos:474d:aptos",
|
|
939
|
+
token: {
|
|
940
|
+
type: "TokenCurrency",
|
|
941
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
942
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
943
|
+
parentCurrency: {
|
|
944
|
+
type: "CryptoCurrency",
|
|
945
|
+
id: "aptos",
|
|
946
|
+
coinType: 637,
|
|
947
|
+
name: "Aptos",
|
|
948
|
+
managerAppName: "Aptos",
|
|
949
|
+
ticker: "APT",
|
|
950
|
+
scheme: "aptos",
|
|
951
|
+
color: "#231F20",
|
|
952
|
+
family: "aptos",
|
|
953
|
+
units: [
|
|
954
|
+
{
|
|
955
|
+
name: "APT",
|
|
956
|
+
code: "APT",
|
|
957
|
+
magnitude: 8,
|
|
958
|
+
},
|
|
959
|
+
],
|
|
960
|
+
},
|
|
961
|
+
name: "dstAPT",
|
|
962
|
+
tokenType: "coin",
|
|
963
|
+
ticker: "dstAPT",
|
|
964
|
+
disableCountervalue: false,
|
|
965
|
+
delisted: false,
|
|
966
|
+
units: [
|
|
967
|
+
{
|
|
968
|
+
name: "dstAPT",
|
|
969
|
+
code: "dstAPT",
|
|
970
|
+
magnitude: 8,
|
|
971
|
+
},
|
|
972
|
+
],
|
|
973
|
+
},
|
|
974
|
+
balance: (0, bignumber_js_1.default)(5000000),
|
|
975
|
+
spendableBalance: (0, bignumber_js_1.default)(5000000),
|
|
976
|
+
creationDate: "2025-03-11T09:33:46.840Z",
|
|
977
|
+
operations: [],
|
|
978
|
+
operationsCount: 0,
|
|
979
|
+
pendingOperations: [],
|
|
980
|
+
swapHistory: [],
|
|
981
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
982
|
+
},
|
|
983
|
+
],
|
|
984
|
+
},
|
|
985
|
+
};
|
|
986
|
+
const result = await (0, synchronisation_1.getAccountShape)(info, {});
|
|
987
|
+
expect(result.operations).toHaveLength(2);
|
|
988
|
+
expect(result.operations?.at(0)?.subOperations).toHaveLength(2);
|
|
989
|
+
expect(result.operations?.at(1)?.subOperations).toHaveLength(2);
|
|
990
|
+
expect(result.subAccounts).toHaveLength(1);
|
|
991
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(2);
|
|
992
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("0xa0d8");
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
describe("mergeSubAccounts", () => {
|
|
996
|
+
const initialSubAccount = {
|
|
997
|
+
type: "TokenAccount",
|
|
998
|
+
id: "subAccountId",
|
|
999
|
+
parentId: "accountId",
|
|
1000
|
+
token: {
|
|
1001
|
+
type: "TokenCurrency",
|
|
1002
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
1003
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
1004
|
+
parentCurrency: {
|
|
1005
|
+
type: "CryptoCurrency",
|
|
1006
|
+
id: "aptos",
|
|
1007
|
+
coinType: 637,
|
|
1008
|
+
name: "Aptos",
|
|
1009
|
+
managerAppName: "Aptos",
|
|
1010
|
+
ticker: "APT",
|
|
1011
|
+
scheme: "aptos",
|
|
1012
|
+
color: "#231F20",
|
|
1013
|
+
family: "aptos",
|
|
1014
|
+
units: [
|
|
1015
|
+
{
|
|
1016
|
+
name: "APT",
|
|
1017
|
+
code: "APT",
|
|
1018
|
+
magnitude: 8,
|
|
1019
|
+
},
|
|
1020
|
+
],
|
|
1021
|
+
explorerViews: [
|
|
1022
|
+
{
|
|
1023
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1024
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1025
|
+
},
|
|
1026
|
+
],
|
|
1027
|
+
},
|
|
1028
|
+
name: "dstAPT",
|
|
1029
|
+
tokenType: "coin",
|
|
1030
|
+
ticker: "dstAPT",
|
|
1031
|
+
disableCountervalue: false,
|
|
1032
|
+
delisted: false,
|
|
1033
|
+
units: [
|
|
1034
|
+
{
|
|
1035
|
+
name: "dstAPT",
|
|
1036
|
+
code: "dstAPT",
|
|
1037
|
+
magnitude: 8,
|
|
1038
|
+
},
|
|
1039
|
+
],
|
|
1040
|
+
},
|
|
1041
|
+
balance: (0, bignumber_js_1.default)(100),
|
|
1042
|
+
spendableBalance: (0, bignumber_js_1.default)(100),
|
|
1043
|
+
creationDate: new Date(),
|
|
1044
|
+
operationsCount: 0,
|
|
1045
|
+
operations: [],
|
|
1046
|
+
pendingOperations: [],
|
|
1047
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
1048
|
+
swapHistory: [],
|
|
1049
|
+
};
|
|
1050
|
+
const initialAccount = (0, bridge_fixture_1.createFixtureAccount)({
|
|
1051
|
+
subAccounts: [initialSubAccount],
|
|
1052
|
+
});
|
|
1053
|
+
it("return new subAccount if no old subAccounts", () => {
|
|
1054
|
+
expect((0, synchronisation_1.mergeSubAccounts)(undefined, [initialSubAccount])).toEqual([initialSubAccount]);
|
|
1055
|
+
});
|
|
1056
|
+
it("merge subAccounts properly if initialAccount has the same as new subAccounts", () => {
|
|
1057
|
+
expect((0, synchronisation_1.mergeSubAccounts)(initialAccount, [initialSubAccount])).toEqual([initialSubAccount]);
|
|
1058
|
+
});
|
|
1059
|
+
it("adds new sub account to initialAccount properly", () => {
|
|
1060
|
+
const newSubAccount = {
|
|
1061
|
+
type: "TokenAccount",
|
|
1062
|
+
id: "js:2:aptos:474d:aptos+aptos%2Ffungible~!underscore!~asset%2Fcellana~!underscore!~0x2ebb",
|
|
1063
|
+
parentId: "js:2:aptos:474d:aptos",
|
|
1064
|
+
token: {
|
|
1065
|
+
type: "TokenCurrency",
|
|
1066
|
+
id: "aptos/fungible_asset/cellana_0x2ebb",
|
|
1067
|
+
contractAddress: "0x2ebb",
|
|
1068
|
+
parentCurrency: {
|
|
1069
|
+
type: "CryptoCurrency",
|
|
1070
|
+
id: "aptos",
|
|
1071
|
+
coinType: 637,
|
|
1072
|
+
name: "Aptos",
|
|
1073
|
+
managerAppName: "Aptos",
|
|
1074
|
+
ticker: "APT",
|
|
1075
|
+
scheme: "aptos",
|
|
1076
|
+
color: "#231F20",
|
|
1077
|
+
family: "aptos",
|
|
1078
|
+
units: [
|
|
1079
|
+
{
|
|
1080
|
+
name: "APT",
|
|
1081
|
+
code: "APT",
|
|
1082
|
+
magnitude: 8,
|
|
1083
|
+
},
|
|
1084
|
+
],
|
|
1085
|
+
explorerViews: [
|
|
1086
|
+
{
|
|
1087
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1088
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1089
|
+
},
|
|
1090
|
+
],
|
|
1091
|
+
},
|
|
1092
|
+
name: "CELLANA",
|
|
1093
|
+
tokenType: "fungible_asset",
|
|
1094
|
+
ticker: "CELL",
|
|
1095
|
+
disableCountervalue: false,
|
|
1096
|
+
delisted: false,
|
|
1097
|
+
units: [
|
|
1098
|
+
{
|
|
1099
|
+
name: "CELLANA",
|
|
1100
|
+
code: "CELL",
|
|
1101
|
+
magnitude: 8,
|
|
1102
|
+
},
|
|
1103
|
+
],
|
|
1104
|
+
},
|
|
1105
|
+
balance: (0, bignumber_js_1.default)(22980368),
|
|
1106
|
+
spendableBalance: (0, bignumber_js_1.default)(22980368),
|
|
1107
|
+
creationDate: new Date(),
|
|
1108
|
+
operationsCount: 0,
|
|
1109
|
+
operations: [],
|
|
1110
|
+
pendingOperations: [],
|
|
1111
|
+
swapHistory: [],
|
|
1112
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
1113
|
+
};
|
|
1114
|
+
expect((0, synchronisation_1.mergeSubAccounts)(initialAccount, [newSubAccount])).toEqual([
|
|
1115
|
+
initialSubAccount,
|
|
1116
|
+
newSubAccount,
|
|
1117
|
+
]);
|
|
1118
|
+
});
|
|
1119
|
+
it("merge subAccounts properly when new subAccounts is different", () => {
|
|
1120
|
+
expect((0, synchronisation_1.mergeSubAccounts)(initialAccount, [{ ...initialSubAccount, balance: (0, bignumber_js_1.default)(150) }])).toEqual([{ ...initialSubAccount, balance: (0, bignumber_js_1.default)(150) }]);
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
describe("getSubAccountShape", () => {
|
|
1124
|
+
beforeEach(() => {
|
|
1125
|
+
mockedAptosAPI = jest.mocked(network_1.AptosAPI);
|
|
1126
|
+
});
|
|
1127
|
+
afterEach(() => {
|
|
1128
|
+
jest.resetAllMocks();
|
|
1129
|
+
});
|
|
1130
|
+
const currency = {
|
|
1131
|
+
type: "CryptoCurrency",
|
|
1132
|
+
id: "aptos",
|
|
1133
|
+
coinType: 637,
|
|
1134
|
+
name: "Aptos",
|
|
1135
|
+
managerAppName: "Aptos",
|
|
1136
|
+
ticker: "APT",
|
|
1137
|
+
scheme: "aptos",
|
|
1138
|
+
color: "#231F20",
|
|
1139
|
+
family: "aptos",
|
|
1140
|
+
units: [
|
|
1141
|
+
{
|
|
1142
|
+
name: "APT",
|
|
1143
|
+
code: "APT",
|
|
1144
|
+
magnitude: 8,
|
|
1145
|
+
},
|
|
1146
|
+
],
|
|
1147
|
+
explorerViews: [
|
|
1148
|
+
{
|
|
1149
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1150
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1151
|
+
},
|
|
1152
|
+
],
|
|
1153
|
+
};
|
|
1154
|
+
const address = "0xa0d8";
|
|
1155
|
+
const parentId = "js:2:aptos:474d:aptos";
|
|
1156
|
+
const token = {
|
|
1157
|
+
type: "TokenCurrency",
|
|
1158
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
1159
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
1160
|
+
parentCurrency: {
|
|
1161
|
+
type: "CryptoCurrency",
|
|
1162
|
+
id: "aptos",
|
|
1163
|
+
coinType: 637,
|
|
1164
|
+
name: "Aptos",
|
|
1165
|
+
managerAppName: "Aptos",
|
|
1166
|
+
ticker: "APT",
|
|
1167
|
+
scheme: "aptos",
|
|
1168
|
+
color: "#231F20",
|
|
1169
|
+
family: "aptos",
|
|
1170
|
+
units: [
|
|
1171
|
+
{
|
|
1172
|
+
name: "APT",
|
|
1173
|
+
code: "APT",
|
|
1174
|
+
magnitude: 8,
|
|
1175
|
+
},
|
|
1176
|
+
],
|
|
1177
|
+
explorerViews: [
|
|
1178
|
+
{
|
|
1179
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1180
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1181
|
+
},
|
|
1182
|
+
],
|
|
1183
|
+
},
|
|
1184
|
+
name: "dstAPT",
|
|
1185
|
+
tokenType: "coin",
|
|
1186
|
+
ticker: "dstAPT",
|
|
1187
|
+
disableCountervalue: false,
|
|
1188
|
+
delisted: false,
|
|
1189
|
+
units: [
|
|
1190
|
+
{
|
|
1191
|
+
name: "dstAPT",
|
|
1192
|
+
code: "dstAPT",
|
|
1193
|
+
magnitude: 8,
|
|
1194
|
+
},
|
|
1195
|
+
],
|
|
1196
|
+
};
|
|
1197
|
+
const firstOperationDate = new Date(10);
|
|
1198
|
+
const operations = [
|
|
1199
|
+
{
|
|
1200
|
+
id: "js:2:aptos:474d:aptos-0x2011-IN",
|
|
1201
|
+
hash: "0x2011",
|
|
1202
|
+
type: "IN",
|
|
1203
|
+
value: (0, bignumber_js_1.default)(2000000),
|
|
1204
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1205
|
+
blockHash: "0xf29363a5a78d784c702a8ea352ac3e1461092cc2347b305adcace14aa7b15d60",
|
|
1206
|
+
blockHeight: 315151047,
|
|
1207
|
+
senders: ["0x4e5e"],
|
|
1208
|
+
recipients: ["0xa0d8"],
|
|
1209
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1210
|
+
date: new Date(1000),
|
|
1211
|
+
extra: {
|
|
1212
|
+
version: "2553182323",
|
|
1213
|
+
},
|
|
1214
|
+
transactionSequenceNumber: 32,
|
|
1215
|
+
hasFailed: false,
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
id: "js:2:aptos:474d:aptos-0x06a6-IN",
|
|
1219
|
+
hash: "0x06a6",
|
|
1220
|
+
type: "IN",
|
|
1221
|
+
value: (0, bignumber_js_1.default)(2000000),
|
|
1222
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1223
|
+
blockHash: "0xbae2",
|
|
1224
|
+
blockHeight: 313836935,
|
|
1225
|
+
senders: ["0x4e5e"],
|
|
1226
|
+
recipients: ["0xa0d8"],
|
|
1227
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1228
|
+
date: firstOperationDate,
|
|
1229
|
+
extra: {
|
|
1230
|
+
version: "2544815758",
|
|
1231
|
+
},
|
|
1232
|
+
transactionSequenceNumber: 31,
|
|
1233
|
+
hasFailed: false,
|
|
1234
|
+
},
|
|
1235
|
+
];
|
|
1236
|
+
it("returns the correct information", async () => {
|
|
1237
|
+
const mockGetBalance = jest.fn().mockImplementation(() => (0, bignumber_js_1.default)(1234567));
|
|
1238
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
1239
|
+
getBalance: mockGetBalance,
|
|
1240
|
+
}));
|
|
1241
|
+
const subAccount = await (0, synchronisation_1.getSubAccountShape)(currency, address, parentId, token, operations);
|
|
1242
|
+
expect(subAccount).toEqual({
|
|
1243
|
+
type: "TokenAccount",
|
|
1244
|
+
id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1245
|
+
parentId,
|
|
1246
|
+
token,
|
|
1247
|
+
balance: (0, bignumber_js_1.default)(1234567),
|
|
1248
|
+
spendableBalance: (0, bignumber_js_1.default)(1234567),
|
|
1249
|
+
creationDate: firstOperationDate,
|
|
1250
|
+
operations,
|
|
1251
|
+
operationsCount: operations.length,
|
|
1252
|
+
pendingOperations: [],
|
|
1253
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
1254
|
+
swapHistory: [],
|
|
1255
|
+
});
|
|
1256
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
1257
|
+
});
|
|
1258
|
+
});
|
|
1259
|
+
describe("getSubAccounts", () => {
|
|
1260
|
+
beforeEach(() => {
|
|
1261
|
+
mockedAptosAPI = jest.mocked(network_1.AptosAPI);
|
|
1262
|
+
});
|
|
1263
|
+
afterEach(() => {
|
|
1264
|
+
jest.resetAllMocks();
|
|
1265
|
+
});
|
|
1266
|
+
const address = "0x4e5e";
|
|
1267
|
+
const infos = {
|
|
1268
|
+
currency: {
|
|
1269
|
+
type: "CryptoCurrency",
|
|
1270
|
+
id: "aptos",
|
|
1271
|
+
coinType: 637,
|
|
1272
|
+
name: "Aptos",
|
|
1273
|
+
managerAppName: "Aptos",
|
|
1274
|
+
ticker: "APT",
|
|
1275
|
+
scheme: "aptos",
|
|
1276
|
+
color: "#231F20",
|
|
1277
|
+
family: "aptos",
|
|
1278
|
+
units: [
|
|
1279
|
+
{
|
|
1280
|
+
name: "APT",
|
|
1281
|
+
code: "APT",
|
|
1282
|
+
magnitude: 8,
|
|
1283
|
+
},
|
|
1284
|
+
],
|
|
1285
|
+
explorerViews: [
|
|
1286
|
+
{
|
|
1287
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1288
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1289
|
+
},
|
|
1290
|
+
],
|
|
1291
|
+
},
|
|
1292
|
+
address,
|
|
1293
|
+
index: 1,
|
|
1294
|
+
derivationPath: "44'/637'/0'",
|
|
1295
|
+
derivationMode: "aptos",
|
|
1296
|
+
};
|
|
1297
|
+
const accountId = "js:2:aptos:3282:aptos";
|
|
1298
|
+
const lastTokenOperations = [
|
|
1299
|
+
{
|
|
1300
|
+
id: "js:2:aptos:474d:aptos-0x2011-IN",
|
|
1301
|
+
hash: "0x2011",
|
|
1302
|
+
type: "IN",
|
|
1303
|
+
value: (0, bignumber_js_1.default)(2000000),
|
|
1304
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1305
|
+
blockHash: "0xf29363a5a78d784c702a8ea352ac3e1461092cc2347b305adcace14aa7b15d60",
|
|
1306
|
+
blockHeight: 315151047,
|
|
1307
|
+
senders: ["0x4e5e"],
|
|
1308
|
+
recipients: ["0xa0d8"],
|
|
1309
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1310
|
+
date: new Date(1000),
|
|
1311
|
+
extra: {
|
|
1312
|
+
version: "2553182323",
|
|
1313
|
+
},
|
|
1314
|
+
transactionSequenceNumber: 32,
|
|
1315
|
+
hasFailed: false,
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
id: "js:2:aptos:474d:aptos-0x06a6-IN",
|
|
1319
|
+
hash: "0x06a6",
|
|
1320
|
+
type: "IN",
|
|
1321
|
+
value: (0, bignumber_js_1.default)(2000000),
|
|
1322
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1323
|
+
blockHash: "0xbae2",
|
|
1324
|
+
blockHeight: 313836935,
|
|
1325
|
+
senders: ["0x4e5e"],
|
|
1326
|
+
recipients: ["0xa0d8"],
|
|
1327
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1328
|
+
date: new Date(10),
|
|
1329
|
+
extra: {
|
|
1330
|
+
version: "2544815758",
|
|
1331
|
+
},
|
|
1332
|
+
transactionSequenceNumber: 31,
|
|
1333
|
+
hasFailed: false,
|
|
1334
|
+
},
|
|
1335
|
+
];
|
|
1336
|
+
it("returns the correct information", async () => {
|
|
1337
|
+
const mockGetBalance = jest.fn().mockImplementation(() => (0, bignumber_js_1.default)(1234567));
|
|
1338
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
1339
|
+
getBalance: mockGetBalance,
|
|
1340
|
+
}));
|
|
1341
|
+
mockedDecodeTokenAccountId.mockReturnValue({
|
|
1342
|
+
token: {
|
|
1343
|
+
type: "TokenCurrency",
|
|
1344
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
1345
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
1346
|
+
parentCurrency: {
|
|
1347
|
+
type: "CryptoCurrency",
|
|
1348
|
+
id: "aptos",
|
|
1349
|
+
coinType: 637,
|
|
1350
|
+
name: "Aptos",
|
|
1351
|
+
managerAppName: "Aptos",
|
|
1352
|
+
ticker: "APT",
|
|
1353
|
+
scheme: "aptos",
|
|
1354
|
+
color: "#231F20",
|
|
1355
|
+
family: "aptos",
|
|
1356
|
+
units: [
|
|
1357
|
+
{
|
|
1358
|
+
name: "APT",
|
|
1359
|
+
code: "APT",
|
|
1360
|
+
magnitude: 8,
|
|
1361
|
+
},
|
|
1362
|
+
],
|
|
1363
|
+
explorerViews: [
|
|
1364
|
+
{
|
|
1365
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1366
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1367
|
+
},
|
|
1368
|
+
],
|
|
1369
|
+
},
|
|
1370
|
+
name: "dstAPT",
|
|
1371
|
+
tokenType: "coin",
|
|
1372
|
+
ticker: "dstAPT",
|
|
1373
|
+
disableCountervalue: false,
|
|
1374
|
+
delisted: false,
|
|
1375
|
+
units: [
|
|
1376
|
+
{
|
|
1377
|
+
name: "dstAPT",
|
|
1378
|
+
code: "dstAPT",
|
|
1379
|
+
magnitude: 8,
|
|
1380
|
+
},
|
|
1381
|
+
],
|
|
1382
|
+
},
|
|
1383
|
+
accountId: "js:2:aptos:6415:aptos",
|
|
1384
|
+
});
|
|
1385
|
+
const result = await (0, synchronisation_1.getSubAccounts)(infos, address, accountId, lastTokenOperations);
|
|
1386
|
+
expect(result).toEqual([
|
|
1387
|
+
{
|
|
1388
|
+
type: "TokenAccount",
|
|
1389
|
+
id: "js:2:aptos:3282:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1390
|
+
parentId: "js:2:aptos:3282:aptos",
|
|
1391
|
+
token: {
|
|
1392
|
+
type: "TokenCurrency",
|
|
1393
|
+
id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
|
|
1394
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
1395
|
+
parentCurrency: {
|
|
1396
|
+
type: "CryptoCurrency",
|
|
1397
|
+
id: "aptos",
|
|
1398
|
+
coinType: 637,
|
|
1399
|
+
name: "Aptos",
|
|
1400
|
+
managerAppName: "Aptos",
|
|
1401
|
+
ticker: "APT",
|
|
1402
|
+
scheme: "aptos",
|
|
1403
|
+
color: "#231F20",
|
|
1404
|
+
family: "aptos",
|
|
1405
|
+
units: [
|
|
1406
|
+
{
|
|
1407
|
+
name: "APT",
|
|
1408
|
+
code: "APT",
|
|
1409
|
+
magnitude: 8,
|
|
1410
|
+
},
|
|
1411
|
+
],
|
|
1412
|
+
explorerViews: [
|
|
1413
|
+
{
|
|
1414
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
1415
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
1416
|
+
},
|
|
1417
|
+
],
|
|
1418
|
+
},
|
|
1419
|
+
name: "dstAPT",
|
|
1420
|
+
tokenType: "coin",
|
|
1421
|
+
ticker: "dstAPT",
|
|
1422
|
+
disableCountervalue: false,
|
|
1423
|
+
delisted: false,
|
|
1424
|
+
units: [
|
|
1425
|
+
{
|
|
1426
|
+
name: "dstAPT",
|
|
1427
|
+
code: "dstAPT",
|
|
1428
|
+
magnitude: 8,
|
|
1429
|
+
},
|
|
1430
|
+
],
|
|
1431
|
+
},
|
|
1432
|
+
balance: (0, bignumber_js_1.default)(1234567),
|
|
1433
|
+
spendableBalance: (0, bignumber_js_1.default)(1234567),
|
|
1434
|
+
creationDate: new Date(10),
|
|
1435
|
+
operations: [
|
|
1436
|
+
{
|
|
1437
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1438
|
+
blockHash: "0xf29363a5a78d784c702a8ea352ac3e1461092cc2347b305adcace14aa7b15d60",
|
|
1439
|
+
blockHeight: 315151047,
|
|
1440
|
+
date: new Date(1000),
|
|
1441
|
+
extra: { version: "2553182323" },
|
|
1442
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1443
|
+
hasFailed: false,
|
|
1444
|
+
hash: "0x2011",
|
|
1445
|
+
id: "js:2:aptos:474d:aptos-0x2011-IN",
|
|
1446
|
+
recipients: ["0xa0d8"],
|
|
1447
|
+
senders: ["0x4e5e"],
|
|
1448
|
+
transactionSequenceNumber: 32,
|
|
1449
|
+
type: "IN",
|
|
1450
|
+
value: (0, bignumber_js_1.default)(2000000),
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
|
|
1454
|
+
blockHash: "0xbae2",
|
|
1455
|
+
blockHeight: 313836935,
|
|
1456
|
+
date: new Date(10),
|
|
1457
|
+
fee: (0, bignumber_js_1.default)(1200),
|
|
1458
|
+
extra: { version: "2544815758" },
|
|
1459
|
+
hasFailed: false,
|
|
1460
|
+
hash: "0x06a6",
|
|
1461
|
+
id: "js:2:aptos:474d:aptos-0x06a6-IN",
|
|
1462
|
+
recipients: ["0xa0d8"],
|
|
1463
|
+
senders: ["0x4e5e"],
|
|
1464
|
+
transactionSequenceNumber: 31,
|
|
1465
|
+
type: "IN",
|
|
1466
|
+
value: (0, bignumber_js_1.default)(2000000),
|
|
1467
|
+
},
|
|
1468
|
+
],
|
|
1469
|
+
operationsCount: 2,
|
|
1470
|
+
pendingOperations: [],
|
|
1471
|
+
balanceHistoryCache: index_2.emptyHistoryCache,
|
|
1472
|
+
swapHistory: [],
|
|
1473
|
+
},
|
|
1474
|
+
]);
|
|
328
1475
|
});
|
|
329
1476
|
});
|
|
330
1477
|
//# sourceMappingURL=synchronisation.test.js.map
|