@ledgerhq/coin-aptos 2.0.0-nightly.5 → 2.1.0-next.0
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 +178 -34
- package/jest.config.js +2 -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 +187 -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 +319 -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 +703 -479
- 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 +114 -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/normalizeAddress.unit.test.d.ts +2 -0
- package/lib/__tests__/logic/normalizeAddress.unit.test.d.ts.map +1 -0
- package/lib/__tests__/logic/normalizeAddress.unit.test.js +12 -0
- package/lib/__tests__/logic/normalizeAddress.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 +1124 -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 +13 -2
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +17 -2
- package/lib/constants.js.map +1 -1
- package/lib/logic/buildTransaction.d.ts +9 -0
- package/lib/logic/buildTransaction.d.ts.map +1 -0
- package/lib/logic/buildTransaction.js +47 -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 +68 -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/normalizeAddress.d.ts +2 -0
- package/lib/logic/normalizeAddress.d.ts.map +1 -0
- package/lib/logic/normalizeAddress.js +12 -0
- package/lib/logic/normalizeAddress.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 +58 -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 +89 -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 +283 -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 +16 -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 +185 -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 +317 -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 +703 -479
- 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 +109 -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/normalizeAddress.unit.test.d.ts +2 -0
- package/lib-es/__tests__/logic/normalizeAddress.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/logic/normalizeAddress.unit.test.js +10 -0
- package/lib-es/__tests__/logic/normalizeAddress.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 +1119 -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 +13 -2
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +13 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/logic/buildTransaction.d.ts +9 -0
- 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 +38 -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/normalizeAddress.d.ts +2 -0
- package/lib-es/logic/normalizeAddress.d.ts.map +1 -0
- package/lib-es/logic/normalizeAddress.js +8 -0
- package/lib-es/logic/normalizeAddress.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 +54 -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 +81 -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 +276 -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 +16 -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 +16 -13
- package/src/__tests__/api/craftTransaction.unit.test.ts +243 -0
- package/src/__tests__/api/getBalance.unit.test.ts +44 -0
- package/src/__tests__/api/index.integ.test.ts +401 -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 +728 -569
- 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 +150 -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/normalizeAddress.unit.test.ts +15 -0
- package/src/__tests__/logic/processRecipients.unit.test.ts +95 -0
- package/src/__tests__/network/client.test.ts +1257 -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 +22 -2
- package/src/logic/buildTransaction.ts +70 -0
- package/src/logic/calculateAmount.ts +15 -0
- package/src/logic/combine.ts +51 -0
- package/src/logic/craftTransaction.ts +65 -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/normalizeAddress.ts +8 -0
- package/src/logic/normalizeTransactionOptions.ts +18 -0
- package/src/logic/processRecipients.ts +88 -0
- package/src/logic/transactionsToOperations.ts +106 -0
- package/src/network/client.ts +374 -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 +20 -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 +0 -7
- 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 +0 -7
- 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,80 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EntryFunctionPayloadResponse,
|
|
3
|
-
Event,
|
|
4
|
-
InputEntryFunctionData,
|
|
5
|
-
WriteSetChange,
|
|
6
|
-
} from "@aptos-labs/ts-sdk";
|
|
7
|
-
import type { Operation, OperationType } from "@ledgerhq/types-live";
|
|
1
|
+
import { EntryFunctionPayloadResponse } from "@aptos-labs/ts-sdk";
|
|
8
2
|
import BigNumber from "bignumber.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
calculateAmount,
|
|
12
|
-
compareAddress,
|
|
13
|
-
getAptosAmounts,
|
|
14
|
-
getFunctionAddress,
|
|
15
|
-
isChangeOfAptos,
|
|
16
|
-
isTestnet,
|
|
17
|
-
processRecipients,
|
|
18
|
-
getMaxSendBalance,
|
|
19
|
-
normalizeTransactionOptions,
|
|
20
|
-
getBlankOperation,
|
|
21
|
-
txsToOps,
|
|
22
|
-
} from "../../bridge/logic";
|
|
3
|
+
import { APTOS_COIN_CHANGE, DIRECTION } from "../../constants";
|
|
4
|
+
import { getMaxSendBalance, getBlankOperation, txsToOps } from "../../bridge/logic";
|
|
23
5
|
import type { AptosTransaction, TransactionOptions } from "../../types";
|
|
6
|
+
import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
|
|
7
|
+
import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
|
|
8
|
+
import { decodeTokenAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
|
|
9
|
+
import { normalizeTransactionOptions } from "../../logic/normalizeTransactionOptions";
|
|
24
10
|
|
|
25
|
-
jest.mock("@ledgerhq/cryptoassets"
|
|
26
|
-
|
|
27
|
-
}));
|
|
11
|
+
jest.mock("@ledgerhq/cryptoassets");
|
|
12
|
+
jest.mock("@ledgerhq/coin-framework/account/index");
|
|
28
13
|
|
|
29
14
|
describe("Aptos logic ", () => {
|
|
30
|
-
describe("isTestnet", () => {
|
|
31
|
-
it("should return true for testnet currencies", () => {
|
|
32
|
-
expect(isTestnet("aptos_testnet")).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should return false for mainnet currencies", () => {
|
|
36
|
-
expect(isTestnet("aptos")).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
15
|
describe("getMaxSendBalance", () => {
|
|
41
16
|
it("should return the correct max send balance when amount is greater than total gas", () => {
|
|
42
17
|
const amount = new BigNumber(1000000);
|
|
18
|
+
const account = createFixtureAccount({ balance: amount, spendableBalance: amount });
|
|
19
|
+
const transaction = createFixtureTransaction();
|
|
43
20
|
const gas = new BigNumber(200);
|
|
44
21
|
const gasPrice = new BigNumber(100);
|
|
45
|
-
const result = getMaxSendBalance(
|
|
22
|
+
const result = getMaxSendBalance(gas, gasPrice, account, transaction);
|
|
46
23
|
expect(result.isEqualTo(amount.minus(gas.multipliedBy(gasPrice)))).toBe(true);
|
|
47
24
|
});
|
|
48
25
|
|
|
49
26
|
it("should return zero when amount is less than total gas", () => {
|
|
50
|
-
const
|
|
27
|
+
const account = createFixtureAccount();
|
|
28
|
+
const transaction = createFixtureTransaction();
|
|
51
29
|
const gas = new BigNumber(200);
|
|
52
30
|
const gasPrice = new BigNumber(100);
|
|
53
|
-
const result = getMaxSendBalance(
|
|
31
|
+
const result = getMaxSendBalance(gas, gasPrice, account, transaction);
|
|
54
32
|
expect(result.isEqualTo(new BigNumber(0))).toBe(true);
|
|
55
33
|
});
|
|
56
34
|
|
|
57
35
|
it("should return zero when amount is equal to total gas", () => {
|
|
58
|
-
const
|
|
36
|
+
const account = createFixtureAccount();
|
|
37
|
+
const transaction = createFixtureTransaction();
|
|
59
38
|
const gas = new BigNumber(200);
|
|
60
39
|
const gasPrice = new BigNumber(100);
|
|
61
|
-
const result = getMaxSendBalance(
|
|
40
|
+
const result = getMaxSendBalance(gas, gasPrice, account, transaction);
|
|
62
41
|
expect(result.isEqualTo(new BigNumber(0))).toBe(true);
|
|
63
42
|
});
|
|
64
43
|
|
|
65
44
|
it("should handle zero amount", () => {
|
|
66
|
-
const
|
|
45
|
+
const account = createFixtureAccount();
|
|
46
|
+
const transaction = createFixtureTransaction();
|
|
67
47
|
const gas = new BigNumber(200);
|
|
68
48
|
const gasPrice = new BigNumber(100);
|
|
69
|
-
const result = getMaxSendBalance(
|
|
49
|
+
const result = getMaxSendBalance(gas, gasPrice, account, transaction);
|
|
70
50
|
expect(result.isEqualTo(new BigNumber(0))).toBe(true);
|
|
71
51
|
});
|
|
72
52
|
|
|
73
53
|
it("should handle zero gas and gas price", () => {
|
|
74
54
|
const amount = new BigNumber(1000000);
|
|
55
|
+
const account = createFixtureAccount({ balance: amount, spendableBalance: amount });
|
|
56
|
+
const transaction = createFixtureTransaction();
|
|
75
57
|
const gas = new BigNumber(0);
|
|
76
58
|
const gasPrice = new BigNumber(0);
|
|
77
|
-
const result = getMaxSendBalance(
|
|
59
|
+
const result = getMaxSendBalance(gas, gasPrice, account, transaction);
|
|
78
60
|
expect(result.isEqualTo(amount)).toBe(true);
|
|
79
61
|
});
|
|
80
62
|
});
|
|
@@ -114,7 +96,7 @@ describe("Aptos logic ", () => {
|
|
|
114
96
|
version: "1",
|
|
115
97
|
} as unknown as AptosTransaction;
|
|
116
98
|
|
|
117
|
-
const id = "
|
|
99
|
+
const id = "test_id";
|
|
118
100
|
const result = getBlankOperation(tx, id);
|
|
119
101
|
|
|
120
102
|
expect(result).toEqual({
|
|
@@ -142,7 +124,7 @@ describe("Aptos logic ", () => {
|
|
|
142
124
|
sequence_number: "1",
|
|
143
125
|
} as unknown as AptosTransaction;
|
|
144
126
|
|
|
145
|
-
const id = "
|
|
127
|
+
const id = "test_id";
|
|
146
128
|
const result = getBlankOperation(tx, id);
|
|
147
129
|
|
|
148
130
|
expect(result).toEqual({
|
|
@@ -166,490 +148,10 @@ describe("Aptos logic ", () => {
|
|
|
166
148
|
});
|
|
167
149
|
|
|
168
150
|
describe("Aptos sync logic ", () => {
|
|
169
|
-
describe("compareAddress", () => {
|
|
170
|
-
it("should return true for identical addresses", () => {
|
|
171
|
-
const addressA = "0x1234567890abcdef";
|
|
172
|
-
const addressB = "0x1234567890abcdef";
|
|
173
|
-
expect(compareAddress(addressA, addressB)).toBe(true);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("should return true for addresses with different cases", () => {
|
|
177
|
-
const addressA = "0x1234567890abcdef";
|
|
178
|
-
const addressB = "0x1234567890ABCDEF";
|
|
179
|
-
expect(compareAddress(addressA, addressB)).toBe(true);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("should return true for addresses with different hex formats", () => {
|
|
183
|
-
const addressA = "0x1234567890abcdef";
|
|
184
|
-
const addressB = "1234567890abcdef";
|
|
185
|
-
expect(compareAddress(addressA, addressB)).toBe(true);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("should return false for different addresses", () => {
|
|
189
|
-
const addressA = "0x1234567890abcdef";
|
|
190
|
-
const addressB = "0xfedcba0987654321";
|
|
191
|
-
expect(compareAddress(addressA, addressB)).toBe(false);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe("getFunctionAddress", () => {
|
|
196
|
-
it("should return the function address when payload contains a function", () => {
|
|
197
|
-
const payload: InputEntryFunctionData = {
|
|
198
|
-
function: "0x1::coin::transfer",
|
|
199
|
-
typeArguments: [],
|
|
200
|
-
functionArguments: [],
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const result = getFunctionAddress(payload);
|
|
204
|
-
expect(result).toBe("0x1");
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it("should return undefined when payload does not contain a function", () => {
|
|
208
|
-
const payload = {
|
|
209
|
-
function: "::::",
|
|
210
|
-
typeArguments: [],
|
|
211
|
-
functionArguments: [],
|
|
212
|
-
} as InputEntryFunctionData;
|
|
213
|
-
|
|
214
|
-
const result = getFunctionAddress(payload);
|
|
215
|
-
expect(result).toBeUndefined();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("should return undefined when payload is empty", () => {
|
|
219
|
-
const payload = {} as InputEntryFunctionData;
|
|
220
|
-
|
|
221
|
-
const result = getFunctionAddress(payload);
|
|
222
|
-
expect(result).toBeUndefined();
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe("processRecipients", () => {
|
|
227
|
-
let op: Operation;
|
|
228
|
-
|
|
229
|
-
beforeEach(() => {
|
|
230
|
-
op = {
|
|
231
|
-
id: "",
|
|
232
|
-
hash: "",
|
|
233
|
-
type: "" as OperationType,
|
|
234
|
-
value: new BigNumber(0),
|
|
235
|
-
fee: new BigNumber(0),
|
|
236
|
-
blockHash: "",
|
|
237
|
-
blockHeight: 0,
|
|
238
|
-
senders: [],
|
|
239
|
-
recipients: [],
|
|
240
|
-
accountId: "",
|
|
241
|
-
date: new Date(),
|
|
242
|
-
extra: {},
|
|
243
|
-
transactionSequenceNumber: 0,
|
|
244
|
-
hasFailed: false,
|
|
245
|
-
};
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("should add recipient for transfer-like functions from LL account", () => {
|
|
249
|
-
const payload: InputEntryFunctionData = {
|
|
250
|
-
function: "0x1::coin::transfer",
|
|
251
|
-
typeArguments: [],
|
|
252
|
-
functionArguments: ["0x13", 1], // from: &signer, to: address, amount: u64
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
processRecipients(payload, "0x13", op, "0x1");
|
|
256
|
-
expect(op.recipients).toContain("0x13");
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it("should add recipient for transfer-like functions from external account", () => {
|
|
260
|
-
const payload: InputEntryFunctionData = {
|
|
261
|
-
function: "0x1::coin::transfer",
|
|
262
|
-
typeArguments: [],
|
|
263
|
-
functionArguments: ["0x12", 1], // from: &signer, to: address, amount: u64
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
processRecipients(payload, "0x13", op, "0x1");
|
|
267
|
-
expect(op.recipients).toContain("0x12");
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it("should add recipients for batch transfer functions", () => {
|
|
271
|
-
const payload: InputEntryFunctionData = {
|
|
272
|
-
function: "0x1::aptos_account::batch_transfer_coins",
|
|
273
|
-
typeArguments: [APTOS_ASSET_ID],
|
|
274
|
-
functionArguments: [
|
|
275
|
-
["0x12", "0x13"],
|
|
276
|
-
[1, 2],
|
|
277
|
-
],
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
op.senders.push("0x11");
|
|
281
|
-
processRecipients(payload, "0x12", op, "0x1");
|
|
282
|
-
expect(op.recipients).toContain("0x12");
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("should add function address as recipient for other smart contracts", () => {
|
|
286
|
-
const payload: InputEntryFunctionData = {
|
|
287
|
-
function: "0x2::other::contract",
|
|
288
|
-
typeArguments: [],
|
|
289
|
-
functionArguments: [["0x12"], [1]],
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
processRecipients(payload, "0x11", op, "0x2");
|
|
293
|
-
expect(op.recipients).toContain("0x2");
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
describe("isChangeOfAptos", () => {
|
|
298
|
-
it("should return true for a valid change of Aptos", () => {
|
|
299
|
-
const change = {
|
|
300
|
-
type: "write_resource",
|
|
301
|
-
data: {
|
|
302
|
-
type: APTOS_COIN_CHANGE,
|
|
303
|
-
data: {
|
|
304
|
-
withdraw_events: {
|
|
305
|
-
guid: {
|
|
306
|
-
id: {
|
|
307
|
-
addr: "0x11",
|
|
308
|
-
creation_num: "2",
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
} as unknown as WriteSetChange;
|
|
315
|
-
|
|
316
|
-
const event = {
|
|
317
|
-
guid: {
|
|
318
|
-
account_address: "0x11",
|
|
319
|
-
creation_number: "2",
|
|
320
|
-
},
|
|
321
|
-
type: "0x1::coin::WithdrawEvent",
|
|
322
|
-
} as Event;
|
|
323
|
-
|
|
324
|
-
const result = isChangeOfAptos(change, event, "withdraw_events");
|
|
325
|
-
expect(result).toBe(true);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it("should return false for an invalid change of Aptos", () => {
|
|
329
|
-
const change = {
|
|
330
|
-
type: "write_resource",
|
|
331
|
-
data: {
|
|
332
|
-
type: APTOS_COIN_CHANGE,
|
|
333
|
-
data: {
|
|
334
|
-
withdraw_events: {
|
|
335
|
-
guid: {
|
|
336
|
-
id: {
|
|
337
|
-
addr: "0x12",
|
|
338
|
-
creation_num: "2",
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
} as unknown as WriteSetChange;
|
|
345
|
-
|
|
346
|
-
const event = {
|
|
347
|
-
guid: {
|
|
348
|
-
account_address: "0x11",
|
|
349
|
-
creation_number: "1",
|
|
350
|
-
},
|
|
351
|
-
type: "0x1::coin::WithdrawEvent",
|
|
352
|
-
} as Event;
|
|
353
|
-
|
|
354
|
-
const result = isChangeOfAptos(change, event, "withdraw_events");
|
|
355
|
-
expect(result).toBe(false);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
it("should return false for a change with a different WriteSet type", () => {
|
|
359
|
-
const change = {
|
|
360
|
-
type: "write_module",
|
|
361
|
-
data: {},
|
|
362
|
-
} as unknown as WriteSetChange;
|
|
363
|
-
|
|
364
|
-
const event = {
|
|
365
|
-
guid: {
|
|
366
|
-
account_address: "0x1",
|
|
367
|
-
creation_number: "1",
|
|
368
|
-
},
|
|
369
|
-
type: "0x1::coin::WithdrawEvent",
|
|
370
|
-
} as Event;
|
|
371
|
-
|
|
372
|
-
const result = isChangeOfAptos(change, event, "withdraw_events");
|
|
373
|
-
expect(result).toBe(false);
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
it("should return false if no data in WriteSet Change", () => {
|
|
377
|
-
const change = {
|
|
378
|
-
type: "write_resource",
|
|
379
|
-
} as unknown as WriteSetChange;
|
|
380
|
-
|
|
381
|
-
const event = {
|
|
382
|
-
guid: {
|
|
383
|
-
account_address: "0x11",
|
|
384
|
-
creation_number: "2",
|
|
385
|
-
},
|
|
386
|
-
type: "0x1::coin::WithdrawEvent",
|
|
387
|
-
} as Event;
|
|
388
|
-
|
|
389
|
-
const result = isChangeOfAptos(change, event, "withdraw_events");
|
|
390
|
-
expect(result).toBe(false);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
it("should return false if no type in change data", () => {
|
|
394
|
-
const change = {
|
|
395
|
-
type: "write_resource",
|
|
396
|
-
data: {
|
|
397
|
-
data: {
|
|
398
|
-
withdraw_events: {
|
|
399
|
-
guid: {
|
|
400
|
-
id: {
|
|
401
|
-
addr: "0x11",
|
|
402
|
-
creation_num: "2",
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
} as unknown as WriteSetChange;
|
|
409
|
-
|
|
410
|
-
const event = {
|
|
411
|
-
guid: {
|
|
412
|
-
account_address: "0x11",
|
|
413
|
-
creation_number: "2",
|
|
414
|
-
},
|
|
415
|
-
type: "0x1::coin::WithdrawEvent",
|
|
416
|
-
} as Event;
|
|
417
|
-
|
|
418
|
-
const result = isChangeOfAptos(change, event, "withdraw_events");
|
|
419
|
-
expect(result).toBe(false);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it("should return false for a change with a different WriteSet Change type", () => {
|
|
423
|
-
const change = {
|
|
424
|
-
type: "write_resource",
|
|
425
|
-
data: {
|
|
426
|
-
type: "0x1::coin::CoinStore<0x1::aptos_coin::ANY_OTHER_COIN>",
|
|
427
|
-
data: {
|
|
428
|
-
withdraw_events: {
|
|
429
|
-
guid: {
|
|
430
|
-
id: {
|
|
431
|
-
addr: "0x11",
|
|
432
|
-
creation_num: "2",
|
|
433
|
-
},
|
|
434
|
-
},
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
},
|
|
438
|
-
} as unknown as WriteSetChange;
|
|
439
|
-
|
|
440
|
-
const event = {
|
|
441
|
-
guid: {
|
|
442
|
-
account_address: "0x11",
|
|
443
|
-
creation_number: "2",
|
|
444
|
-
},
|
|
445
|
-
type: "0x1::coin::WithdrawEvent",
|
|
446
|
-
} as Event;
|
|
447
|
-
|
|
448
|
-
const result = isChangeOfAptos(change, event, "withdraw_events");
|
|
449
|
-
expect(result).toBe(false);
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
describe("getAptosAmounts", () => {
|
|
454
|
-
it("should calculate the correct amounts for withdraw and deposit events", () => {
|
|
455
|
-
const tx = {
|
|
456
|
-
events: [
|
|
457
|
-
{
|
|
458
|
-
type: "0x1::coin::WithdrawEvent",
|
|
459
|
-
guid: {
|
|
460
|
-
account_address: "0x11",
|
|
461
|
-
creation_number: "1",
|
|
462
|
-
},
|
|
463
|
-
data: {
|
|
464
|
-
amount: "100",
|
|
465
|
-
},
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
type: "0x1::coin::DepositEvent",
|
|
469
|
-
guid: {
|
|
470
|
-
account_address: "0x11",
|
|
471
|
-
creation_number: "2",
|
|
472
|
-
},
|
|
473
|
-
data: {
|
|
474
|
-
amount: "50",
|
|
475
|
-
},
|
|
476
|
-
},
|
|
477
|
-
],
|
|
478
|
-
changes: [
|
|
479
|
-
{
|
|
480
|
-
type: "write_resource",
|
|
481
|
-
data: {
|
|
482
|
-
type: APTOS_COIN_CHANGE,
|
|
483
|
-
data: {
|
|
484
|
-
withdraw_events: {
|
|
485
|
-
guid: {
|
|
486
|
-
id: {
|
|
487
|
-
addr: "0x11",
|
|
488
|
-
creation_num: "1",
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
deposit_events: {
|
|
493
|
-
guid: {
|
|
494
|
-
id: {
|
|
495
|
-
addr: "0x11",
|
|
496
|
-
creation_num: "2",
|
|
497
|
-
},
|
|
498
|
-
},
|
|
499
|
-
},
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
},
|
|
503
|
-
],
|
|
504
|
-
} as unknown as AptosTransaction;
|
|
505
|
-
|
|
506
|
-
const address = "0x11";
|
|
507
|
-
const result = getAptosAmounts(tx, address);
|
|
508
|
-
|
|
509
|
-
expect(result.amount_in).toEqual(new BigNumber(50));
|
|
510
|
-
expect(result.amount_out).toEqual(new BigNumber(100));
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
it("should return zero amounts if no matching events are found", () => {
|
|
514
|
-
const tx = {
|
|
515
|
-
events: [
|
|
516
|
-
{
|
|
517
|
-
type: "0x1::coin::WithdrawEvent",
|
|
518
|
-
guid: {
|
|
519
|
-
account_address: "0x11",
|
|
520
|
-
creation_number: "1",
|
|
521
|
-
},
|
|
522
|
-
data: {
|
|
523
|
-
amount: "100",
|
|
524
|
-
},
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
type: "0x1::coin::DepositEvent",
|
|
528
|
-
guid: {
|
|
529
|
-
account_address: "0x11",
|
|
530
|
-
creation_number: "2",
|
|
531
|
-
},
|
|
532
|
-
data: {
|
|
533
|
-
amount: "50",
|
|
534
|
-
},
|
|
535
|
-
},
|
|
536
|
-
],
|
|
537
|
-
changes: [
|
|
538
|
-
{
|
|
539
|
-
type: "write_resource",
|
|
540
|
-
data: {
|
|
541
|
-
type: APTOS_COIN_CHANGE,
|
|
542
|
-
data: {
|
|
543
|
-
withdraw_events: {
|
|
544
|
-
guid: {
|
|
545
|
-
id: {
|
|
546
|
-
addr: "0x12", // should fail by address check
|
|
547
|
-
creation_num: "1",
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
},
|
|
551
|
-
deposit_events: {
|
|
552
|
-
guid: {
|
|
553
|
-
id: {
|
|
554
|
-
addr: "0x11",
|
|
555
|
-
creation_num: "3", // should fail by number check
|
|
556
|
-
},
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
|
-
},
|
|
561
|
-
},
|
|
562
|
-
],
|
|
563
|
-
} as unknown as AptosTransaction;
|
|
564
|
-
|
|
565
|
-
const address = "0x11";
|
|
566
|
-
const result = getAptosAmounts(tx, address);
|
|
567
|
-
|
|
568
|
-
expect(result.amount_in).toEqual(new BigNumber(0));
|
|
569
|
-
expect(result.amount_out).toEqual(new BigNumber(0));
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
it("should handle transactions with other events", () => {
|
|
573
|
-
const tx = {
|
|
574
|
-
events: [
|
|
575
|
-
{
|
|
576
|
-
type: "0x1::coin::OtherEvent",
|
|
577
|
-
guid: {
|
|
578
|
-
account_address: "0x11",
|
|
579
|
-
creation_number: "1",
|
|
580
|
-
},
|
|
581
|
-
data: {
|
|
582
|
-
amount: "100",
|
|
583
|
-
},
|
|
584
|
-
},
|
|
585
|
-
],
|
|
586
|
-
} as unknown as AptosTransaction;
|
|
587
|
-
|
|
588
|
-
const address = "0x1";
|
|
589
|
-
const result = getAptosAmounts(tx, address);
|
|
590
|
-
|
|
591
|
-
expect(result.amount_in).toEqual(new BigNumber(0));
|
|
592
|
-
expect(result.amount_out).toEqual(new BigNumber(0));
|
|
593
|
-
});
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
describe("calculateAmount", () => {
|
|
597
|
-
it("should calculate the correct amount when the address is the sender", () => {
|
|
598
|
-
const address = "0x11";
|
|
599
|
-
const sender = "0x11";
|
|
600
|
-
const fee = new BigNumber(10); // account pays fees
|
|
601
|
-
const amount_in = new BigNumber(50);
|
|
602
|
-
const amount_out = new BigNumber(100);
|
|
603
|
-
|
|
604
|
-
const result = calculateAmount(sender, address, fee, amount_in, amount_out);
|
|
605
|
-
|
|
606
|
-
// LL negates the amount for SEND transactions during output
|
|
607
|
-
expect(result).toEqual(new BigNumber(60)); // -(50 - 100 - 10)
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
it("should calculate the correct amount when the address is not the sender", () => {
|
|
611
|
-
const address = "0x11";
|
|
612
|
-
const sender = "0x12";
|
|
613
|
-
const fee = new BigNumber(10); // sender pays fees
|
|
614
|
-
const amount_in = new BigNumber(100);
|
|
615
|
-
const amount_out = new BigNumber(50);
|
|
616
|
-
|
|
617
|
-
const result = calculateAmount(sender, address, fee, amount_in, amount_out);
|
|
618
|
-
|
|
619
|
-
expect(result).toEqual(new BigNumber(50)); // 100 - 50
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
it("should handle transactions with zero amounts", () => {
|
|
623
|
-
const address = "0x11";
|
|
624
|
-
const sender = "0x11";
|
|
625
|
-
const fee = new BigNumber(10);
|
|
626
|
-
const amount_in = new BigNumber(0);
|
|
627
|
-
const amount_out = new BigNumber(0);
|
|
628
|
-
|
|
629
|
-
const result = calculateAmount(sender, address, fee, amount_in, amount_out);
|
|
630
|
-
|
|
631
|
-
// LL negates the amount for SEND transactions during output
|
|
632
|
-
expect(result).toEqual(new BigNumber(10)); // -(0 - 0 - 10)
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
it("should get negative numbers (for send tx with deposit to account)", () => {
|
|
636
|
-
const address = "0x11";
|
|
637
|
-
const sender = "0x11";
|
|
638
|
-
const fee = new BigNumber(10);
|
|
639
|
-
const amount_in = new BigNumber(100);
|
|
640
|
-
const amount_out = new BigNumber(0);
|
|
641
|
-
|
|
642
|
-
const result = calculateAmount(sender, address, fee, amount_in, amount_out);
|
|
643
|
-
|
|
644
|
-
// LL negates the amount for SEND transactions during output
|
|
645
|
-
expect(result).toEqual(new BigNumber(90).negated()); // 100 - 10
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
|
|
649
151
|
describe("txsToOps", () => {
|
|
650
|
-
it("should convert transactions to operations correctly", () => {
|
|
152
|
+
it("should convert Aptos transactions to operations correctly", () => {
|
|
651
153
|
const address = "0x11";
|
|
652
|
-
const id = "
|
|
154
|
+
const id = "test_id";
|
|
653
155
|
const txs: AptosTransaction[] = [
|
|
654
156
|
{
|
|
655
157
|
hash: "0x123",
|
|
@@ -717,19 +219,19 @@ describe("Aptos sync logic ", () => {
|
|
|
717
219
|
} as unknown as AptosTransaction,
|
|
718
220
|
];
|
|
719
221
|
|
|
720
|
-
const result = txsToOps({ address }, id, txs);
|
|
222
|
+
const [result] = txsToOps({ address }, id, txs);
|
|
721
223
|
|
|
722
224
|
expect(result).toHaveLength(1);
|
|
723
225
|
expect(result[0]).toEqual({
|
|
724
226
|
id: expect.any(String),
|
|
725
227
|
hash: "0x123",
|
|
726
228
|
type: DIRECTION.OUT,
|
|
727
|
-
value: new BigNumber(
|
|
229
|
+
value: new BigNumber(100),
|
|
728
230
|
fee: new BigNumber(20000),
|
|
729
231
|
blockHash: "0xabc",
|
|
730
232
|
blockHeight: 1,
|
|
731
233
|
senders: ["0x11"],
|
|
732
|
-
recipients: ["
|
|
234
|
+
recipients: ["0x0000000000000000000000000000000000000000000000000000000000000012"],
|
|
733
235
|
accountId: id,
|
|
734
236
|
date: new Date(1000),
|
|
735
237
|
extra: { version: undefined },
|
|
@@ -740,7 +242,7 @@ describe("Aptos sync logic ", () => {
|
|
|
740
242
|
|
|
741
243
|
it("should skip transactions without functions in payload", () => {
|
|
742
244
|
const address = "0x11";
|
|
743
|
-
const id = "
|
|
245
|
+
const id = "test_id";
|
|
744
246
|
const txs: AptosTransaction[] = [
|
|
745
247
|
{
|
|
746
248
|
hash: "0x123",
|
|
@@ -749,12 +251,6 @@ describe("Aptos sync logic ", () => {
|
|
|
749
251
|
gas_unit_price: "100",
|
|
750
252
|
success: true,
|
|
751
253
|
payload: {} as EntryFunctionPayloadResponse,
|
|
752
|
-
// payload: {
|
|
753
|
-
// type: "entry_function_payload",
|
|
754
|
-
// function: "0x1::coin::transfer",
|
|
755
|
-
// type_arguments: [],
|
|
756
|
-
// arguments: ["0x12", 100],
|
|
757
|
-
// } as EntryFunctionPayloadResponse,
|
|
758
254
|
events: [],
|
|
759
255
|
changes: [],
|
|
760
256
|
block: { hash: "0xabc", height: 1 },
|
|
@@ -763,14 +259,14 @@ describe("Aptos sync logic ", () => {
|
|
|
763
259
|
} as unknown as AptosTransaction,
|
|
764
260
|
];
|
|
765
261
|
|
|
766
|
-
const result = txsToOps({ address }, id, txs);
|
|
262
|
+
const [result] = txsToOps({ address }, id, txs);
|
|
767
263
|
|
|
768
264
|
expect(result).toHaveLength(0);
|
|
769
265
|
});
|
|
770
266
|
|
|
771
267
|
it("should skip transactions that result in no Aptos change", () => {
|
|
772
268
|
const address = "0x11";
|
|
773
|
-
const id = "
|
|
269
|
+
const id = "test_id";
|
|
774
270
|
const txs: AptosTransaction[] = [
|
|
775
271
|
{
|
|
776
272
|
hash: "0x123",
|
|
@@ -792,85 +288,748 @@ describe("Aptos sync logic ", () => {
|
|
|
792
288
|
} as unknown as AptosTransaction,
|
|
793
289
|
];
|
|
794
290
|
|
|
795
|
-
const result = txsToOps({ address }, id, txs);
|
|
291
|
+
const [result] = txsToOps({ address }, id, txs);
|
|
796
292
|
|
|
797
293
|
expect(result).toHaveLength(0);
|
|
798
294
|
});
|
|
799
295
|
|
|
800
296
|
it("should handle failed transactions", () => {
|
|
801
|
-
const address = "
|
|
802
|
-
const id = "
|
|
297
|
+
const address = "0xa0d8";
|
|
298
|
+
const id = "test_id";
|
|
803
299
|
const txs: AptosTransaction[] = [
|
|
804
300
|
{
|
|
805
|
-
hash: "
|
|
806
|
-
sender: "
|
|
301
|
+
hash: "0x0189",
|
|
302
|
+
sender: "0xa0d8",
|
|
807
303
|
gas_used: "200",
|
|
808
304
|
gas_unit_price: "100",
|
|
809
305
|
success: false,
|
|
810
306
|
payload: {
|
|
811
|
-
type: "entry_function_payload",
|
|
812
307
|
function: "0x1::coin::transfer",
|
|
813
|
-
type_arguments: [],
|
|
814
|
-
arguments: ["
|
|
308
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
309
|
+
arguments: ["0x4e5e", "50000000"],
|
|
310
|
+
type: "entry_function_payload",
|
|
815
311
|
} as EntryFunctionPayloadResponse,
|
|
816
312
|
events: [
|
|
817
313
|
{
|
|
818
|
-
type: "0x1::coin::WithdrawEvent",
|
|
819
314
|
guid: {
|
|
820
|
-
|
|
821
|
-
|
|
315
|
+
creation_number: "0",
|
|
316
|
+
account_address: "0x0",
|
|
822
317
|
},
|
|
318
|
+
sequence_number: "0",
|
|
319
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
823
320
|
data: {
|
|
824
|
-
|
|
321
|
+
execution_gas_units: "5",
|
|
322
|
+
io_gas_units: "4",
|
|
323
|
+
storage_fee_octas: "0",
|
|
324
|
+
storage_fee_refund_octas: "0",
|
|
325
|
+
total_charge_gas_units: "8",
|
|
825
326
|
},
|
|
826
327
|
},
|
|
328
|
+
],
|
|
329
|
+
changes: [
|
|
827
330
|
{
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
account_address: "0x12",
|
|
831
|
-
creation_number: "2",
|
|
832
|
-
},
|
|
331
|
+
address: "0xa0d8",
|
|
332
|
+
state_key_hash: "0x1709",
|
|
833
333
|
data: {
|
|
834
|
-
|
|
334
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
335
|
+
data: {
|
|
336
|
+
coin: {
|
|
337
|
+
value: "573163341",
|
|
338
|
+
},
|
|
339
|
+
deposit_events: {
|
|
340
|
+
counter: "45",
|
|
341
|
+
guid: {
|
|
342
|
+
id: {
|
|
343
|
+
addr: "0xa0d8",
|
|
344
|
+
creation_num: "2",
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
frozen: false,
|
|
349
|
+
withdraw_events: {
|
|
350
|
+
counter: "82",
|
|
351
|
+
guid: {
|
|
352
|
+
id: {
|
|
353
|
+
addr: "0xa0d8",
|
|
354
|
+
creation_num: "3",
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
835
359
|
},
|
|
360
|
+
type: "write_resource",
|
|
836
361
|
},
|
|
837
|
-
],
|
|
838
|
-
changes: [
|
|
839
362
|
{
|
|
840
|
-
|
|
363
|
+
address: "0xa0d8",
|
|
364
|
+
state_key_hash: "0x6f1e",
|
|
841
365
|
data: {
|
|
842
|
-
type:
|
|
366
|
+
type: "0x1::account::Account",
|
|
843
367
|
data: {
|
|
844
|
-
|
|
368
|
+
authentication_key: "0xa0d8",
|
|
369
|
+
coin_register_events: {
|
|
370
|
+
counter: "5",
|
|
845
371
|
guid: {
|
|
846
372
|
id: {
|
|
847
|
-
addr: "
|
|
848
|
-
creation_num: "
|
|
373
|
+
addr: "0xa0d8",
|
|
374
|
+
creation_num: "0",
|
|
849
375
|
},
|
|
850
376
|
},
|
|
851
377
|
},
|
|
852
|
-
|
|
378
|
+
guid_creation_num: "12",
|
|
379
|
+
key_rotation_events: {
|
|
380
|
+
counter: "0",
|
|
853
381
|
guid: {
|
|
854
382
|
id: {
|
|
855
|
-
addr: "
|
|
856
|
-
creation_num: "
|
|
383
|
+
addr: "0xa0d8",
|
|
384
|
+
creation_num: "1",
|
|
857
385
|
},
|
|
858
386
|
},
|
|
859
387
|
},
|
|
388
|
+
rotation_capability_offer: {
|
|
389
|
+
for: {
|
|
390
|
+
vec: [],
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
sequence_number: "83",
|
|
394
|
+
signer_capability_offer: {
|
|
395
|
+
for: {
|
|
396
|
+
vec: [],
|
|
397
|
+
},
|
|
398
|
+
},
|
|
860
399
|
},
|
|
861
400
|
},
|
|
401
|
+
type: "write_resource",
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
state_key_hash: "0x6e4b",
|
|
405
|
+
handle: "0x1b85",
|
|
406
|
+
key: "0x0619",
|
|
407
|
+
value: "0x72c5e483c25c96010000000000000000",
|
|
408
|
+
data: null,
|
|
409
|
+
type: "write_table_item",
|
|
862
410
|
},
|
|
863
411
|
],
|
|
864
|
-
block: {
|
|
412
|
+
block: {
|
|
413
|
+
hash: "0xc496",
|
|
414
|
+
height: 1,
|
|
415
|
+
},
|
|
865
416
|
timestamp: "1000000",
|
|
866
417
|
sequence_number: "1",
|
|
867
418
|
} as unknown as AptosTransaction,
|
|
868
419
|
];
|
|
869
420
|
|
|
870
|
-
const result = txsToOps({ address }, id, txs);
|
|
421
|
+
const [result] = txsToOps({ address }, id, txs);
|
|
871
422
|
|
|
872
423
|
expect(result).toHaveLength(1);
|
|
873
|
-
expect(result[0]
|
|
424
|
+
expect(result[0]).toEqual({
|
|
425
|
+
id: expect.any(String),
|
|
426
|
+
hash: "0x0189",
|
|
427
|
+
type: DIRECTION.OUT,
|
|
428
|
+
value: new BigNumber(20000),
|
|
429
|
+
fee: new BigNumber(20000),
|
|
430
|
+
blockHash: "0xc496",
|
|
431
|
+
blockHeight: 1,
|
|
432
|
+
senders: ["0xa0d8"],
|
|
433
|
+
recipients: ["0x0000000000000000000000000000000000000000000000000000000000004e5e"],
|
|
434
|
+
accountId: id,
|
|
435
|
+
date: new Date(1000),
|
|
436
|
+
extra: { version: undefined },
|
|
437
|
+
transactionSequenceNumber: 1,
|
|
438
|
+
hasFailed: true,
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it("should convert Aptos token transactions to operations correctly", () => {
|
|
443
|
+
(findTokenByAddressInCurrency as jest.Mock).mockReturnValue({
|
|
444
|
+
type: "TokenCurrency",
|
|
445
|
+
id: "aptos/coin/dstapt::staked_coin::stakedaptos",
|
|
446
|
+
contractAddress: "0xd111::staked_coin::StakedAptos",
|
|
447
|
+
parentCurrency: {
|
|
448
|
+
type: "CryptoCurrency",
|
|
449
|
+
id: "aptos",
|
|
450
|
+
coinType: 637,
|
|
451
|
+
name: "Aptos",
|
|
452
|
+
managerAppName: "Aptos",
|
|
453
|
+
ticker: "APT",
|
|
454
|
+
scheme: "aptos",
|
|
455
|
+
color: "#231F20",
|
|
456
|
+
family: "aptos",
|
|
457
|
+
units: [
|
|
458
|
+
{
|
|
459
|
+
name: "APT",
|
|
460
|
+
code: "APT",
|
|
461
|
+
magnitude: 8,
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
explorerViews: [
|
|
465
|
+
{
|
|
466
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
467
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
},
|
|
471
|
+
name: "dstAPT",
|
|
472
|
+
tokenType: "coin",
|
|
473
|
+
ticker: "dstAPT",
|
|
474
|
+
disableCountervalue: false,
|
|
475
|
+
delisted: false,
|
|
476
|
+
units: [
|
|
477
|
+
{
|
|
478
|
+
name: "dstAPT",
|
|
479
|
+
code: "dstAPT",
|
|
480
|
+
magnitude: 8,
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
jest.mock("../../bridge/logic", () => ({
|
|
486
|
+
...jest.requireActual("../../bridge/logic"),
|
|
487
|
+
getResourceAddress: jest.fn().mockReturnValue("0xd111::staked_coin::StakedAptos"),
|
|
488
|
+
}));
|
|
489
|
+
|
|
490
|
+
(decodeTokenAccountId as jest.Mock).mockReturnValue({
|
|
491
|
+
accountId: "token_account_id",
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
const address = "0xa0d";
|
|
495
|
+
const id = "test_id";
|
|
496
|
+
const txs: AptosTransaction[] = [
|
|
497
|
+
{
|
|
498
|
+
hash: "0x123",
|
|
499
|
+
sender: address,
|
|
500
|
+
gas_used: "200",
|
|
501
|
+
gas_unit_price: "100",
|
|
502
|
+
success: true,
|
|
503
|
+
payload: {
|
|
504
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
505
|
+
type_arguments: ["0xd111::staked_coin::StakedAptos"],
|
|
506
|
+
arguments: ["0x4e5", "1500000"],
|
|
507
|
+
type: "entry_function_payload",
|
|
508
|
+
} as EntryFunctionPayloadResponse,
|
|
509
|
+
events: [
|
|
510
|
+
{
|
|
511
|
+
guid: {
|
|
512
|
+
creation_number: "11",
|
|
513
|
+
account_address: "0xa0d",
|
|
514
|
+
},
|
|
515
|
+
sequence_number: "12",
|
|
516
|
+
type: "0x1::coin::WithdrawEvent",
|
|
517
|
+
data: {
|
|
518
|
+
amount: "1500000",
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
guid: {
|
|
523
|
+
creation_number: "4",
|
|
524
|
+
account_address: "0x4e5",
|
|
525
|
+
},
|
|
526
|
+
sequence_number: "8",
|
|
527
|
+
type: "0x1::coin::DepositEvent",
|
|
528
|
+
data: {
|
|
529
|
+
amount: "1500000",
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
guid: {
|
|
534
|
+
creation_number: "0",
|
|
535
|
+
account_address: "0x0",
|
|
536
|
+
},
|
|
537
|
+
sequence_number: "0",
|
|
538
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
539
|
+
data: {
|
|
540
|
+
execution_gas_units: "6",
|
|
541
|
+
io_gas_units: "6",
|
|
542
|
+
storage_fee_octas: "0",
|
|
543
|
+
storage_fee_refund_octas: "0",
|
|
544
|
+
total_charge_gas_units: "12",
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
],
|
|
548
|
+
changes: [
|
|
549
|
+
{
|
|
550
|
+
address: "0x4e5",
|
|
551
|
+
state_key_hash: "0x3c0",
|
|
552
|
+
data: {
|
|
553
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
554
|
+
data: {
|
|
555
|
+
coin: {
|
|
556
|
+
value: "4000000",
|
|
557
|
+
},
|
|
558
|
+
deposit_events: {
|
|
559
|
+
counter: "9",
|
|
560
|
+
guid: {
|
|
561
|
+
id: {
|
|
562
|
+
addr: "0x4e5",
|
|
563
|
+
creation_num: "4",
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
frozen: false,
|
|
568
|
+
withdraw_events: {
|
|
569
|
+
counter: "6",
|
|
570
|
+
guid: {
|
|
571
|
+
id: {
|
|
572
|
+
addr: "0x4e5",
|
|
573
|
+
creation_num: "5",
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
type: "write_resource",
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
address: "0xa0d",
|
|
583
|
+
state_key_hash: "0x1709",
|
|
584
|
+
data: {
|
|
585
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
586
|
+
data: {
|
|
587
|
+
coin: {
|
|
588
|
+
value: "68254118",
|
|
589
|
+
},
|
|
590
|
+
deposit_events: {
|
|
591
|
+
counter: "46",
|
|
592
|
+
guid: {
|
|
593
|
+
id: {
|
|
594
|
+
addr: "0xa0d",
|
|
595
|
+
creation_num: "2",
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
frozen: false,
|
|
600
|
+
withdraw_events: {
|
|
601
|
+
counter: "89",
|
|
602
|
+
guid: {
|
|
603
|
+
id: {
|
|
604
|
+
addr: "0xa0d",
|
|
605
|
+
creation_num: "3",
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
type: "write_resource",
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
address: "0xa0d",
|
|
615
|
+
state_key_hash: "0x5520",
|
|
616
|
+
data: {
|
|
617
|
+
type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
|
|
618
|
+
data: {
|
|
619
|
+
coin: {
|
|
620
|
+
value: "1000000",
|
|
621
|
+
},
|
|
622
|
+
deposit_events: {
|
|
623
|
+
counter: "7",
|
|
624
|
+
guid: {
|
|
625
|
+
id: {
|
|
626
|
+
addr: "0xa0d",
|
|
627
|
+
creation_num: "10",
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
frozen: false,
|
|
632
|
+
withdraw_events: {
|
|
633
|
+
counter: "13",
|
|
634
|
+
guid: {
|
|
635
|
+
id: {
|
|
636
|
+
addr: "0xa0d",
|
|
637
|
+
creation_num: "11",
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
type: "write_resource",
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
address: "0xa0d",
|
|
647
|
+
state_key_hash: "0x6f1e",
|
|
648
|
+
data: {
|
|
649
|
+
type: "0x1::account::Account",
|
|
650
|
+
data: {
|
|
651
|
+
authentication_key: "0xa0d",
|
|
652
|
+
coin_register_events: {
|
|
653
|
+
counter: "5",
|
|
654
|
+
guid: {
|
|
655
|
+
id: {
|
|
656
|
+
addr: "0xa0d",
|
|
657
|
+
creation_num: "0",
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
guid_creation_num: "12",
|
|
662
|
+
key_rotation_events: {
|
|
663
|
+
counter: "0",
|
|
664
|
+
guid: {
|
|
665
|
+
id: {
|
|
666
|
+
addr: "0xa0d",
|
|
667
|
+
creation_num: "1",
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
rotation_capability_offer: {
|
|
672
|
+
for: {
|
|
673
|
+
vec: [],
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
sequence_number: "122",
|
|
677
|
+
signer_capability_offer: {
|
|
678
|
+
for: {
|
|
679
|
+
vec: [],
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
type: "write_resource",
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
state_key_hash: "0x6e4b",
|
|
688
|
+
handle: "0x1b85",
|
|
689
|
+
key: "0x0619",
|
|
690
|
+
value: "0x1ddaf8da3b1497010000000000000000",
|
|
691
|
+
data: null,
|
|
692
|
+
type: "write_table_item",
|
|
693
|
+
},
|
|
694
|
+
],
|
|
695
|
+
block: { hash: "0xabc", height: 1 },
|
|
696
|
+
timestamp: "1000000",
|
|
697
|
+
sequence_number: "1",
|
|
698
|
+
} as unknown as AptosTransaction,
|
|
699
|
+
];
|
|
700
|
+
|
|
701
|
+
const [ops, tokenOps] = txsToOps({ address }, id, txs);
|
|
702
|
+
|
|
703
|
+
expect(ops).toHaveLength(1);
|
|
704
|
+
expect(ops[0]).toEqual({
|
|
705
|
+
id: expect.any(String),
|
|
706
|
+
hash: "0x123",
|
|
707
|
+
type: "FEES",
|
|
708
|
+
value: new BigNumber(20000),
|
|
709
|
+
fee: new BigNumber(20000),
|
|
710
|
+
blockHash: "0xabc",
|
|
711
|
+
blockHeight: 1,
|
|
712
|
+
senders: ["0xa0d"],
|
|
713
|
+
recipients: ["0x00000000000000000000000000000000000000000000000000000000000004e5"],
|
|
714
|
+
accountId: "token_account_id",
|
|
715
|
+
date: new Date(1000),
|
|
716
|
+
extra: { version: undefined },
|
|
717
|
+
transactionSequenceNumber: 1,
|
|
718
|
+
hasFailed: false,
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
expect(tokenOps).toHaveLength(1);
|
|
722
|
+
expect(tokenOps[0]).toEqual({
|
|
723
|
+
id: expect.any(String),
|
|
724
|
+
hash: "0x123",
|
|
725
|
+
type: DIRECTION.OUT,
|
|
726
|
+
value: new BigNumber(1500000),
|
|
727
|
+
fee: new BigNumber(20000),
|
|
728
|
+
blockHash: "0xabc",
|
|
729
|
+
blockHeight: 1,
|
|
730
|
+
senders: ["0xa0d"],
|
|
731
|
+
recipients: ["0x00000000000000000000000000000000000000000000000000000000000004e5"],
|
|
732
|
+
date: new Date(1000),
|
|
733
|
+
extra: { version: undefined },
|
|
734
|
+
transactionSequenceNumber: 1,
|
|
735
|
+
hasFailed: false,
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
it("should convert Aptos token transactions to operations correctly", () => {
|
|
740
|
+
(findTokenByAddressInCurrency as jest.Mock).mockReturnValue({
|
|
741
|
+
type: "TokenCurrency",
|
|
742
|
+
id: "aptos/fungible_asset/cellana_0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
|
|
743
|
+
contractAddress: "0x2ebb",
|
|
744
|
+
parentCurrency: {
|
|
745
|
+
type: "CryptoCurrency",
|
|
746
|
+
id: "aptos",
|
|
747
|
+
coinType: 637,
|
|
748
|
+
name: "Aptos",
|
|
749
|
+
managerAppName: "Aptos",
|
|
750
|
+
ticker: "APT",
|
|
751
|
+
scheme: "aptos",
|
|
752
|
+
color: "#231F20",
|
|
753
|
+
family: "aptos",
|
|
754
|
+
units: [
|
|
755
|
+
{
|
|
756
|
+
name: "APT",
|
|
757
|
+
code: "APT",
|
|
758
|
+
magnitude: 8,
|
|
759
|
+
},
|
|
760
|
+
],
|
|
761
|
+
explorerViews: [
|
|
762
|
+
{
|
|
763
|
+
address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
|
|
764
|
+
tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
|
|
765
|
+
},
|
|
766
|
+
],
|
|
767
|
+
},
|
|
768
|
+
name: "CELLANA",
|
|
769
|
+
tokenType: "fungible_asset",
|
|
770
|
+
ticker: "CELL",
|
|
771
|
+
disableCountervalue: false,
|
|
772
|
+
delisted: false,
|
|
773
|
+
units: [
|
|
774
|
+
{
|
|
775
|
+
name: "CELLANA",
|
|
776
|
+
code: "CELL",
|
|
777
|
+
magnitude: 8,
|
|
778
|
+
},
|
|
779
|
+
],
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
jest.mock("../../bridge/logic", () => ({
|
|
783
|
+
...jest.requireActual("../../bridge/logic"),
|
|
784
|
+
getResourceAddress: jest.fn().mockReturnValue("0x2ebb"),
|
|
785
|
+
}));
|
|
786
|
+
|
|
787
|
+
(encodeTokenAccountId as jest.Mock).mockReturnValue("token_account_id");
|
|
788
|
+
|
|
789
|
+
const txs: AptosTransaction[] = [
|
|
790
|
+
{
|
|
791
|
+
hash: "0x10c9",
|
|
792
|
+
sender: "0xa0d8",
|
|
793
|
+
gas_used: "200",
|
|
794
|
+
gas_unit_price: "100",
|
|
795
|
+
success: true,
|
|
796
|
+
payload: {
|
|
797
|
+
function: "0x1::primary_fungible_store::transfer",
|
|
798
|
+
type_arguments: ["0x1::fungible_asset::Metadata"],
|
|
799
|
+
arguments: [
|
|
800
|
+
{
|
|
801
|
+
inner: "0x2ebb",
|
|
802
|
+
},
|
|
803
|
+
"0x6b8c",
|
|
804
|
+
"193",
|
|
805
|
+
],
|
|
806
|
+
type: "entry_function_payload",
|
|
807
|
+
} as EntryFunctionPayloadResponse,
|
|
808
|
+
events: [
|
|
809
|
+
{
|
|
810
|
+
guid: {
|
|
811
|
+
creation_number: "0",
|
|
812
|
+
account_address: "0x0",
|
|
813
|
+
},
|
|
814
|
+
sequence_number: "0",
|
|
815
|
+
type: "0x1::fungible_asset::Withdraw",
|
|
816
|
+
data: {
|
|
817
|
+
amount: "193",
|
|
818
|
+
store: "0xd475",
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
guid: {
|
|
823
|
+
creation_number: "0",
|
|
824
|
+
account_address: "0x0",
|
|
825
|
+
},
|
|
826
|
+
sequence_number: "0",
|
|
827
|
+
type: "0x1::fungible_asset::Deposit",
|
|
828
|
+
data: {
|
|
829
|
+
amount: "193",
|
|
830
|
+
store: "0xaaa9",
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
guid: {
|
|
835
|
+
creation_number: "0",
|
|
836
|
+
account_address: "0x0",
|
|
837
|
+
},
|
|
838
|
+
sequence_number: "0",
|
|
839
|
+
type: "0x1::transaction_fee::FeeStatement",
|
|
840
|
+
data: {
|
|
841
|
+
execution_gas_units: "4",
|
|
842
|
+
io_gas_units: "6",
|
|
843
|
+
storage_fee_octas: "0",
|
|
844
|
+
storage_fee_refund_octas: "0",
|
|
845
|
+
total_charge_gas_units: "10",
|
|
846
|
+
},
|
|
847
|
+
},
|
|
848
|
+
],
|
|
849
|
+
changes: [
|
|
850
|
+
{
|
|
851
|
+
address: "0xaaa9",
|
|
852
|
+
state_key_hash: "0x9a17",
|
|
853
|
+
data: {
|
|
854
|
+
type: "0x1::fungible_asset::FungibleStore",
|
|
855
|
+
data: {
|
|
856
|
+
balance: "10044959",
|
|
857
|
+
frozen: false,
|
|
858
|
+
metadata: {
|
|
859
|
+
inner: "0x2ebb",
|
|
860
|
+
},
|
|
861
|
+
},
|
|
862
|
+
},
|
|
863
|
+
type: "write_resource",
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
address: "0xaaa9",
|
|
867
|
+
state_key_hash: "0x9a17",
|
|
868
|
+
data: {
|
|
869
|
+
type: "0x1::object::ObjectCore",
|
|
870
|
+
data: {
|
|
871
|
+
allow_ungated_transfer: false,
|
|
872
|
+
guid_creation_num: "1125899906842625",
|
|
873
|
+
owner: "0x6b8c",
|
|
874
|
+
transfer_events: {
|
|
875
|
+
counter: "0",
|
|
876
|
+
guid: {
|
|
877
|
+
id: {
|
|
878
|
+
addr: "0xaaa9",
|
|
879
|
+
creation_num: "1125899906842624",
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
},
|
|
883
|
+
},
|
|
884
|
+
},
|
|
885
|
+
type: "write_resource",
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
address: "0xa0d8",
|
|
889
|
+
state_key_hash: "0x1709",
|
|
890
|
+
data: {
|
|
891
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
|
|
892
|
+
data: {
|
|
893
|
+
coin: {
|
|
894
|
+
value: "98423118",
|
|
895
|
+
},
|
|
896
|
+
deposit_events: {
|
|
897
|
+
counter: "46",
|
|
898
|
+
guid: {
|
|
899
|
+
id: {
|
|
900
|
+
addr: "0xa0d8",
|
|
901
|
+
creation_num: "2",
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
frozen: false,
|
|
906
|
+
withdraw_events: {
|
|
907
|
+
counter: "88",
|
|
908
|
+
guid: {
|
|
909
|
+
id: {
|
|
910
|
+
addr: "0xa0d8",
|
|
911
|
+
creation_num: "3",
|
|
912
|
+
},
|
|
913
|
+
},
|
|
914
|
+
},
|
|
915
|
+
},
|
|
916
|
+
},
|
|
917
|
+
type: "write_resource",
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
address: "0xa0d8",
|
|
921
|
+
state_key_hash: "0x6f1e",
|
|
922
|
+
data: {
|
|
923
|
+
type: "0x1::account::Account",
|
|
924
|
+
data: {
|
|
925
|
+
authentication_key: "0xa0d8",
|
|
926
|
+
coin_register_events: {
|
|
927
|
+
counter: "5",
|
|
928
|
+
guid: {
|
|
929
|
+
id: {
|
|
930
|
+
addr: "0xa0d8",
|
|
931
|
+
creation_num: "0",
|
|
932
|
+
},
|
|
933
|
+
},
|
|
934
|
+
},
|
|
935
|
+
guid_creation_num: "12",
|
|
936
|
+
key_rotation_events: {
|
|
937
|
+
counter: "0",
|
|
938
|
+
guid: {
|
|
939
|
+
id: {
|
|
940
|
+
addr: "0xa0d8",
|
|
941
|
+
creation_num: "1",
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
},
|
|
945
|
+
rotation_capability_offer: {
|
|
946
|
+
for: {
|
|
947
|
+
vec: [],
|
|
948
|
+
},
|
|
949
|
+
},
|
|
950
|
+
sequence_number: "108",
|
|
951
|
+
signer_capability_offer: {
|
|
952
|
+
for: {
|
|
953
|
+
vec: [],
|
|
954
|
+
},
|
|
955
|
+
},
|
|
956
|
+
},
|
|
957
|
+
},
|
|
958
|
+
type: "write_resource",
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
address: "0xd475",
|
|
962
|
+
state_key_hash: "0x7567",
|
|
963
|
+
data: {
|
|
964
|
+
type: "0x1::fungible_asset::FungibleStore",
|
|
965
|
+
data: {
|
|
966
|
+
balance: "14000",
|
|
967
|
+
frozen: false,
|
|
968
|
+
metadata: {
|
|
969
|
+
inner: "0x2ebb",
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
},
|
|
973
|
+
type: "write_resource",
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
address: "0xd475",
|
|
977
|
+
state_key_hash: "0x7567",
|
|
978
|
+
data: {
|
|
979
|
+
type: "0x1::object::ObjectCore",
|
|
980
|
+
data: {
|
|
981
|
+
allow_ungated_transfer: false,
|
|
982
|
+
guid_creation_num: "1125899906842625",
|
|
983
|
+
owner: "0xa0d8",
|
|
984
|
+
transfer_events: {
|
|
985
|
+
counter: "0",
|
|
986
|
+
guid: {
|
|
987
|
+
id: {
|
|
988
|
+
addr: "0xd475",
|
|
989
|
+
creation_num: "1125899906842624",
|
|
990
|
+
},
|
|
991
|
+
},
|
|
992
|
+
},
|
|
993
|
+
},
|
|
994
|
+
},
|
|
995
|
+
type: "write_resource",
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
state_key_hash: "0x6e4b",
|
|
999
|
+
handle: "0x1b85",
|
|
1000
|
+
key: "0x0619",
|
|
1001
|
+
value: "0xad4388dc7daf96010000000000000000",
|
|
1002
|
+
data: null,
|
|
1003
|
+
type: "write_table_item",
|
|
1004
|
+
},
|
|
1005
|
+
],
|
|
1006
|
+
block: { hash: "0xabc", height: 1 },
|
|
1007
|
+
timestamp: "1000000",
|
|
1008
|
+
sequence_number: "1",
|
|
1009
|
+
} as unknown as AptosTransaction,
|
|
1010
|
+
];
|
|
1011
|
+
|
|
1012
|
+
const [ops, tokenOps] = txsToOps({ address: "0x6b8c" }, "test_id", txs);
|
|
1013
|
+
|
|
1014
|
+
expect(ops).toHaveLength(0);
|
|
1015
|
+
|
|
1016
|
+
expect(tokenOps).toHaveLength(1);
|
|
1017
|
+
expect(tokenOps[0]).toEqual({
|
|
1018
|
+
id: expect.any(String),
|
|
1019
|
+
accountId: "token_account_id",
|
|
1020
|
+
hash: "0x10c9",
|
|
1021
|
+
type: DIRECTION.IN,
|
|
1022
|
+
value: new BigNumber(193),
|
|
1023
|
+
fee: new BigNumber(20000),
|
|
1024
|
+
blockHash: "0xabc",
|
|
1025
|
+
blockHeight: 1,
|
|
1026
|
+
senders: ["0xa0d8"],
|
|
1027
|
+
recipients: ["0x0000000000000000000000000000000000000000000000000000000000006b8c"],
|
|
1028
|
+
date: new Date(1000),
|
|
1029
|
+
extra: { version: undefined },
|
|
1030
|
+
transactionSequenceNumber: 1,
|
|
1031
|
+
hasFailed: false,
|
|
1032
|
+
});
|
|
874
1033
|
});
|
|
875
1034
|
});
|
|
876
1035
|
});
|