@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
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache } from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type AccountData,
|
|
5
|
+
Aptos,
|
|
6
|
+
AptosConfig,
|
|
7
|
+
Ed25519PublicKey,
|
|
8
|
+
type GasEstimation,
|
|
9
|
+
type InputEntryFunctionData,
|
|
10
|
+
type InputGenerateTransactionOptions,
|
|
11
|
+
MimeType,
|
|
12
|
+
type RawTransaction,
|
|
13
|
+
type SimpleTransaction,
|
|
14
|
+
type TransactionResponse,
|
|
15
|
+
type UserTransactionResponse,
|
|
16
|
+
type Block,
|
|
17
|
+
type AptosSettings,
|
|
18
|
+
type MoveFunctionId,
|
|
19
|
+
Hex,
|
|
20
|
+
postAptosFullNode,
|
|
21
|
+
type PendingTransactionResponse,
|
|
22
|
+
} from "@aptos-labs/ts-sdk";
|
|
23
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
24
|
+
import network from "@ledgerhq/live-network";
|
|
25
|
+
import BigNumber from "bignumber.js";
|
|
26
|
+
import isUndefined from "lodash/isUndefined";
|
|
27
|
+
import { APTOS_ASSET_ID, DEFAULT_GAS, DEFAULT_GAS_PRICE, ESTIMATE_GAS_MUL } from "../constants";
|
|
28
|
+
import type { AptosBalance, AptosTransaction, TransactionOptions } from "../types";
|
|
29
|
+
import { GetAccountTransactionsData, GetAccountTransactionsDataGt } from "./graphql/queries";
|
|
30
|
+
import type {
|
|
31
|
+
GetAccountTransactionsDataQuery,
|
|
32
|
+
GetAccountTransactionsDataGtQueryVariables,
|
|
33
|
+
} from "./graphql/types";
|
|
34
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
35
|
+
import {
|
|
36
|
+
BlockInfo,
|
|
37
|
+
FeeEstimation,
|
|
38
|
+
Operation,
|
|
39
|
+
Pagination,
|
|
40
|
+
TransactionIntent,
|
|
41
|
+
} from "@ledgerhq/coin-framework/api/types";
|
|
42
|
+
import { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
|
|
43
|
+
import { log } from "@ledgerhq/logs";
|
|
44
|
+
import { transactionsToOperations } from "../logic/transactionsToOperations";
|
|
45
|
+
import { isTestnet } from "../logic/isTestnet";
|
|
46
|
+
|
|
47
|
+
const getApiEndpoint = (currencyId: string) =>
|
|
48
|
+
isTestnet(currencyId) ? getEnv("APTOS_TESTNET_API_ENDPOINT") : getEnv("APTOS_API_ENDPOINT");
|
|
49
|
+
const getIndexerEndpoint = (currencyId: string) =>
|
|
50
|
+
isTestnet(currencyId)
|
|
51
|
+
? getEnv("APTOS_TESTNET_INDEXER_ENDPOINT")
|
|
52
|
+
: getEnv("APTOS_INDEXER_ENDPOINT");
|
|
53
|
+
|
|
54
|
+
export class AptosAPI {
|
|
55
|
+
private readonly aptosConfig: AptosConfig;
|
|
56
|
+
private readonly aptosClient: Aptos;
|
|
57
|
+
private readonly apolloClient: ApolloClient<object>;
|
|
58
|
+
|
|
59
|
+
constructor(currencyIdOrSettings: AptosSettings | string) {
|
|
60
|
+
if (typeof currencyIdOrSettings === "string") {
|
|
61
|
+
this.aptosConfig = new AptosConfig({
|
|
62
|
+
fullnode: getApiEndpoint(currencyIdOrSettings),
|
|
63
|
+
indexer: getIndexerEndpoint(currencyIdOrSettings),
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
this.aptosConfig = new AptosConfig(currencyIdOrSettings);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.aptosClient = new Aptos(this.aptosConfig);
|
|
70
|
+
this.apolloClient = new ApolloClient({
|
|
71
|
+
uri: this.aptosConfig.indexer ?? "",
|
|
72
|
+
cache: new InMemoryCache(),
|
|
73
|
+
headers: {
|
|
74
|
+
"x-client": "ledger-live",
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getAccount(address: string): Promise<AccountData> {
|
|
80
|
+
return this.aptosClient.getAccountInfo({ accountAddress: address });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async getAccountInfo(address: string, startAt?: string) {
|
|
84
|
+
const [balance, transactions, blockHeight] = await Promise.all([
|
|
85
|
+
this.getCoinBalance(address, APTOS_ASSET_ID),
|
|
86
|
+
this.fetchTransactions(address, startAt),
|
|
87
|
+
this.getHeight(),
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
balance,
|
|
92
|
+
transactions,
|
|
93
|
+
blockHeight,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async estimateGasPrice(): Promise<GasEstimation> {
|
|
98
|
+
return this.aptosClient.getGasPriceEstimation();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async generateTransaction(
|
|
102
|
+
address: string,
|
|
103
|
+
payload: InputEntryFunctionData,
|
|
104
|
+
options: TransactionOptions,
|
|
105
|
+
): Promise<RawTransaction> {
|
|
106
|
+
const opts: Partial<InputGenerateTransactionOptions> = {};
|
|
107
|
+
if (!isUndefined(options.maxGasAmount)) {
|
|
108
|
+
opts.maxGasAmount = Number(options.maxGasAmount);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!isUndefined(options.gasUnitPrice)) {
|
|
112
|
+
opts.gasUnitPrice = Number(options.gasUnitPrice);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const { ledger_timestamp } = await this.aptosClient.getLedgerInfo();
|
|
117
|
+
opts.expireTimestamp = Number(Math.ceil(+ledger_timestamp / 1_000_000 + 2 * 60)); // in milliseconds
|
|
118
|
+
} catch {
|
|
119
|
+
// skip
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return this.aptosClient.transaction.build
|
|
123
|
+
.simple({
|
|
124
|
+
sender: address,
|
|
125
|
+
data: payload,
|
|
126
|
+
options: opts,
|
|
127
|
+
})
|
|
128
|
+
.then(t => t.rawTransaction)
|
|
129
|
+
.catch(error => {
|
|
130
|
+
throw error;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async simulateTransaction(
|
|
135
|
+
address: Ed25519PublicKey,
|
|
136
|
+
tx: RawTransaction,
|
|
137
|
+
options = {
|
|
138
|
+
estimateGasUnitPrice: true,
|
|
139
|
+
estimateMaxGasAmount: true,
|
|
140
|
+
estimatePrioritizedGasUnitPrice: false,
|
|
141
|
+
},
|
|
142
|
+
): Promise<UserTransactionResponse[]> {
|
|
143
|
+
return this.aptosClient.transaction.simulate.simple({
|
|
144
|
+
signerPublicKey: address,
|
|
145
|
+
transaction: { rawTransaction: tx } as SimpleTransaction,
|
|
146
|
+
options,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async broadcast(tx: string): Promise<string> {
|
|
151
|
+
const txBytes = Hex.fromHexString(tx).toUint8Array();
|
|
152
|
+
|
|
153
|
+
const pendingTx = await postAptosFullNode<Uint8Array, PendingTransactionResponse>({
|
|
154
|
+
aptosConfig: this.aptosClient.config,
|
|
155
|
+
body: txBytes,
|
|
156
|
+
path: "transactions",
|
|
157
|
+
originMethod: "",
|
|
158
|
+
contentType: MimeType.BCS_SIGNED_TRANSACTION,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return pendingTx.data.hash;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async getBalance(address: string, token: TokenCurrency): Promise<BigNumber> {
|
|
165
|
+
if (token.tokenType === "coin") {
|
|
166
|
+
return await this.getCoinBalance(address, token.contractAddress);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return await this.getFABalance(address, token.contractAddress);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async getLastBlock(): Promise<BlockInfo> {
|
|
173
|
+
const { block_height } = await this.aptosClient.getLedgerInfo();
|
|
174
|
+
const block = await this.aptosClient.getBlockByHeight({ blockHeight: Number(block_height) });
|
|
175
|
+
return {
|
|
176
|
+
height: Number(block.block_height),
|
|
177
|
+
hash: block.block_hash,
|
|
178
|
+
time: new Date(Number(block.block_timestamp)),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async getCoinBalance(address: string, contract_address: string): Promise<BigNumber> {
|
|
183
|
+
try {
|
|
184
|
+
const [balanceStr] = await this.aptosClient.view<[string]>({
|
|
185
|
+
payload: {
|
|
186
|
+
function: "0x1::coin::balance",
|
|
187
|
+
typeArguments: [contract_address],
|
|
188
|
+
functionArguments: [address],
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
const balance = parseInt(balanceStr, 10);
|
|
192
|
+
return new BigNumber(balance);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
log("error", "getCoinBalance", {
|
|
195
|
+
error,
|
|
196
|
+
});
|
|
197
|
+
return new BigNumber(0);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async getFABalance(address: string, contract_address: string): Promise<BigNumber> {
|
|
202
|
+
try {
|
|
203
|
+
const [balanceStr] = await this.aptosClient.view<[string]>({
|
|
204
|
+
payload: {
|
|
205
|
+
function: "0x1::primary_fungible_store::balance",
|
|
206
|
+
typeArguments: ["0x1::object::ObjectCore"],
|
|
207
|
+
functionArguments: [address, contract_address],
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
const balance = parseInt(balanceStr, 10);
|
|
211
|
+
return new BigNumber(balance);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
log("error", "getFABalance", {
|
|
214
|
+
error,
|
|
215
|
+
});
|
|
216
|
+
return new BigNumber(0);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async estimateFees(
|
|
221
|
+
transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>,
|
|
222
|
+
): Promise<FeeEstimation<AptosFeeParameters>> {
|
|
223
|
+
const publicKeyEd = new Ed25519PublicKey(transactionIntent.sender.xpub);
|
|
224
|
+
const fn: MoveFunctionId = "0x1::aptos_account::transfer_coins";
|
|
225
|
+
|
|
226
|
+
const txPayload: InputEntryFunctionData = {
|
|
227
|
+
function: fn,
|
|
228
|
+
typeArguments: [APTOS_ASSET_ID],
|
|
229
|
+
functionArguments: [transactionIntent.recipient, transactionIntent.amount],
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
const txOptions: TransactionOptions = {
|
|
233
|
+
maxGasAmount: DEFAULT_GAS.toString(),
|
|
234
|
+
gasUnitPrice: DEFAULT_GAS_PRICE.toString(),
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const tx = await this.generateTransaction(
|
|
238
|
+
transactionIntent.sender.freshAddress,
|
|
239
|
+
txPayload,
|
|
240
|
+
txOptions,
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const simulation = await this.simulateTransaction(publicKeyEd, tx);
|
|
244
|
+
const completedTx = simulation[0];
|
|
245
|
+
|
|
246
|
+
const gasLimit = new BigNumber(completedTx.gas_used).multipliedBy(ESTIMATE_GAS_MUL);
|
|
247
|
+
const gasPrice = new BigNumber(completedTx.gas_unit_price);
|
|
248
|
+
|
|
249
|
+
const expectedGas = gasPrice.multipliedBy(gasLimit);
|
|
250
|
+
|
|
251
|
+
return {
|
|
252
|
+
value: BigInt(expectedGas.toString()),
|
|
253
|
+
parameters: {
|
|
254
|
+
gasLimit: BigInt(gasLimit.toString()),
|
|
255
|
+
gasPrice: BigInt(gasPrice.toString()),
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async listOperations(
|
|
261
|
+
address: string,
|
|
262
|
+
pagination: Pagination,
|
|
263
|
+
): Promise<[Operation<AptosAsset>[], string]> {
|
|
264
|
+
const transactions = await this.getAccountInfo(address, pagination.minHeight.toString());
|
|
265
|
+
const [newOperations, _] = transactionsToOperations(address, transactions.transactions);
|
|
266
|
+
|
|
267
|
+
return [newOperations, ""];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
private async fetchTransactions(address: string, gt?: string) {
|
|
271
|
+
if (!address) {
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let query = GetAccountTransactionsData;
|
|
276
|
+
if (gt) {
|
|
277
|
+
query = GetAccountTransactionsDataGt;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const queryResponse = await this.apolloClient.query<
|
|
281
|
+
GetAccountTransactionsDataQuery,
|
|
282
|
+
GetAccountTransactionsDataGtQueryVariables
|
|
283
|
+
>({
|
|
284
|
+
query,
|
|
285
|
+
variables: {
|
|
286
|
+
address,
|
|
287
|
+
limit: 1000,
|
|
288
|
+
gt,
|
|
289
|
+
},
|
|
290
|
+
fetchPolicy: "network-only",
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
return Promise.all(
|
|
294
|
+
queryResponse.data.account_transactions.map(({ transaction_version }) => {
|
|
295
|
+
return this.richItemByVersion(transaction_version);
|
|
296
|
+
}),
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
private async richItemByVersion(version: number): Promise<AptosTransaction | null> {
|
|
301
|
+
try {
|
|
302
|
+
const tx: TransactionResponse = await this.aptosClient.getTransactionByVersion({
|
|
303
|
+
ledgerVersion: version,
|
|
304
|
+
});
|
|
305
|
+
const block = await this.getBlock(version);
|
|
306
|
+
return {
|
|
307
|
+
...tx,
|
|
308
|
+
block,
|
|
309
|
+
} as AptosTransaction;
|
|
310
|
+
} catch (error) {
|
|
311
|
+
log("error", "richItemByVersion", {
|
|
312
|
+
error,
|
|
313
|
+
});
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private async getHeight(): Promise<number> {
|
|
319
|
+
const { data } = await network<Block>({
|
|
320
|
+
method: "GET",
|
|
321
|
+
url: this.aptosConfig.fullnode ?? "",
|
|
322
|
+
});
|
|
323
|
+
return parseInt(data.block_height);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private async getBlock(version: number) {
|
|
327
|
+
const block = await this.aptosClient.getBlockByVersion({ ledgerVersion: version });
|
|
328
|
+
return {
|
|
329
|
+
height: parseInt(block.block_height),
|
|
330
|
+
hash: block.block_hash,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async getBalances(address: string): Promise<AptosBalance[]> {
|
|
335
|
+
const response = await this.aptosClient.getCurrentFungibleAssetBalances({
|
|
336
|
+
options: {
|
|
337
|
+
offset: 0,
|
|
338
|
+
limit: 1000,
|
|
339
|
+
where: {
|
|
340
|
+
asset_type: { _eq: APTOS_ASSET_ID }, // to return all asset balances (native / token) we should remove this filter
|
|
341
|
+
owner_address: { _eq: address },
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
return response.map(x => ({
|
|
347
|
+
asset_type: x.asset_type ?? "-",
|
|
348
|
+
amount: BigNumber(x.amount),
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -18,8 +18,8 @@ export const GetDelegatedStakingActivities = gql`
|
|
|
18
18
|
`;
|
|
19
19
|
export const GetAccountTransactionsData = gql`
|
|
20
20
|
query GetAccountTransactionsData($address: String, $limit: Int) {
|
|
21
|
-
|
|
22
|
-
where: {
|
|
21
|
+
account_transactions(
|
|
22
|
+
where: { account_address: { _eq: $address } }
|
|
23
23
|
order_by: { transaction_version: desc }
|
|
24
24
|
limit: $limit
|
|
25
25
|
) {
|
|
@@ -30,8 +30,8 @@ export const GetAccountTransactionsData = gql`
|
|
|
30
30
|
`;
|
|
31
31
|
export const GetAccountTransactionsDataGt = gql`
|
|
32
32
|
query GetAccountTransactionsDataGt($address: String, $limit: Int, $gt: bigint) {
|
|
33
|
-
|
|
34
|
-
where: {
|
|
33
|
+
account_transactions(
|
|
34
|
+
where: { account_address: { _eq: $address }, transaction_version: { _gt: $gt } }
|
|
35
35
|
order_by: { transaction_version: desc }
|
|
36
36
|
limit: $limit
|
|
37
37
|
) {
|
|
@@ -42,8 +42,8 @@ export const GetAccountTransactionsDataGt = gql`
|
|
|
42
42
|
`;
|
|
43
43
|
export const GetAccountTransactionsDataLt = gql`
|
|
44
44
|
query GetAccountTransactionsDataLt($address: String, $limit: Int, $lt: bigint) {
|
|
45
|
-
|
|
46
|
-
where: {
|
|
45
|
+
account_transactions(
|
|
46
|
+
where: { account_address: { _eq: $address }, transaction_version: { _lt: $lt } }
|
|
47
47
|
order_by: { transaction_version: desc }
|
|
48
48
|
limit: $limit
|
|
49
49
|
) {
|
|
@@ -22,9 +22,9 @@ export type GetAccountTransactionsDataQueryVariables = Exact<{
|
|
|
22
22
|
|
|
23
23
|
export type GetAccountTransactionsDataQuery = {
|
|
24
24
|
__typename?: "query_root";
|
|
25
|
-
|
|
26
|
-
__typename
|
|
27
|
-
transaction_version
|
|
25
|
+
account_transactions: Array<{
|
|
26
|
+
__typename?: "account_transactions";
|
|
27
|
+
transaction_version: number;
|
|
28
28
|
}>;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -36,9 +36,9 @@ export type GetAccountTransactionsDataGtQueryVariables = Exact<{
|
|
|
36
36
|
|
|
37
37
|
export type GetAccountTransactionsDataGtQuery = {
|
|
38
38
|
__typename?: "query_root";
|
|
39
|
-
|
|
40
|
-
__typename
|
|
41
|
-
transaction_version
|
|
39
|
+
account_transactions: Array<{
|
|
40
|
+
__typename?: "account_transactions";
|
|
41
|
+
transaction_version: number;
|
|
42
42
|
}>;
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -50,9 +50,9 @@ export type GetAccountTransactionsDataLtQueryVariables = Exact<{
|
|
|
50
50
|
|
|
51
51
|
export type GetAccountTransactionsDataLtQuery = {
|
|
52
52
|
__typename?: "query_root";
|
|
53
|
-
|
|
54
|
-
__typename
|
|
55
|
-
transaction_version
|
|
53
|
+
account_transactions: Array<{
|
|
54
|
+
__typename?: "account_transactions";
|
|
55
|
+
transaction_version: number;
|
|
56
56
|
}>;
|
|
57
57
|
};
|
|
58
58
|
|
package/src/network/index.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccountAddress,
|
|
3
|
-
AccountAuthenticatorEd25519,
|
|
4
3
|
Ed25519PublicKey,
|
|
5
4
|
Ed25519Signature,
|
|
6
|
-
generateSignedTransaction,
|
|
7
5
|
generateSigningMessageForTransaction,
|
|
8
|
-
Hex,
|
|
9
6
|
RawTransaction,
|
|
10
7
|
SimpleTransaction,
|
|
11
8
|
} from "@aptos-labs/ts-sdk";
|
|
12
|
-
import { SignerContext } from "@ledgerhq/coin-framework/
|
|
9
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
13
10
|
import { Account } from "@ledgerhq/types-live";
|
|
14
11
|
import { AptosSigner } from "../types";
|
|
15
12
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
13
|
+
import { combineSignedTransaction } from "../logic/combine";
|
|
14
|
+
export * from "./client";
|
|
16
15
|
|
|
17
16
|
export async function signTransaction(
|
|
18
17
|
signerContext: SignerContext<AptosSigner>,
|
|
@@ -40,15 +39,8 @@ export async function signTransaction(
|
|
|
40
39
|
async signer => await signer.signTransaction(derivationPath, Buffer.from(signingMessage)),
|
|
41
40
|
);
|
|
42
41
|
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const authenticator = new AccountAuthenticatorEd25519(
|
|
46
|
-
new Ed25519PublicKey(publicKey.toString("hex")),
|
|
47
|
-
signature,
|
|
48
|
-
);
|
|
42
|
+
const signature = new Ed25519Signature(response.signature.toString("hex"));
|
|
43
|
+
const pubkey = new Ed25519PublicKey(publicKey.toString("hex"));
|
|
49
44
|
|
|
50
|
-
return
|
|
51
|
-
transaction: { rawTransaction: rawTxn } as SimpleTransaction,
|
|
52
|
-
senderAuthenticator: authenticator,
|
|
53
|
-
});
|
|
45
|
+
return combineSignedTransaction(rawTxn, signature, pubkey);
|
|
54
46
|
}
|
package/src/test/bot-specs.ts
CHANGED
|
@@ -5,8 +5,9 @@ import BigNumber from "bignumber.js";
|
|
|
5
5
|
import type { Transaction } from "../types";
|
|
6
6
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
7
7
|
import { genericTestDestination, pickSiblings, botTest } from "@ledgerhq/coin-framework/bot/specs";
|
|
8
|
-
import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
|
|
9
|
-
import { acceptTransaction } from "./speculos-deviceActions";
|
|
8
|
+
import type { AppSpec, TransactionTestInput } from "@ledgerhq/coin-framework/bot/types";
|
|
9
|
+
import { acceptTokenTransaction, acceptTransaction } from "./speculos-deviceActions";
|
|
10
|
+
import { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
10
11
|
|
|
11
12
|
const MIN_SAFE = new BigNumber(0.0001);
|
|
12
13
|
const maxAccount = 6;
|
|
@@ -19,7 +20,7 @@ const aptosSpecs: AppSpec<Transaction> = {
|
|
|
19
20
|
appName: "Aptos",
|
|
20
21
|
},
|
|
21
22
|
genericDeviceAction: acceptTransaction,
|
|
22
|
-
testTimeout:
|
|
23
|
+
testTimeout: 2 * 60 * 1000,
|
|
23
24
|
minViableAmount: MIN_SAFE,
|
|
24
25
|
transactionCheck: ({ maxSpendable }) => {
|
|
25
26
|
invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
|
|
@@ -84,9 +85,68 @@ const aptosSpecs: AppSpec<Transaction> = {
|
|
|
84
85
|
);
|
|
85
86
|
},
|
|
86
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: "Send ~50% of token amount",
|
|
90
|
+
feature: "tokens",
|
|
91
|
+
maxRun: 1,
|
|
92
|
+
deviceAction: acceptTokenTransaction,
|
|
93
|
+
transaction: ({ account, bridge, siblings, maxSpendable }) => {
|
|
94
|
+
invariant(maxSpendable.gt(MIN_SAFE), "Balance is too low");
|
|
95
|
+
|
|
96
|
+
const senderTokenAcc = findTokenSubAccountWithBalance(account);
|
|
97
|
+
invariant(senderTokenAcc, "Sender token account with available balance not found");
|
|
98
|
+
|
|
99
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
100
|
+
|
|
101
|
+
const recipientTokenAcc = findTokenSubAccountWithBalance(sibling);
|
|
102
|
+
invariant(recipientTokenAcc, "Receiver token account with available balance not found");
|
|
103
|
+
|
|
104
|
+
const amount = senderTokenAcc.spendableBalance.div(2).integerValue();
|
|
105
|
+
const recipient = sibling.freshAddress;
|
|
106
|
+
const transaction = bridge.createTransaction(account);
|
|
107
|
+
const subAccountId = senderTokenAcc.id;
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
transaction,
|
|
111
|
+
updates: [{ subAccountId }, { recipient }, { amount }],
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
test: input => {
|
|
115
|
+
expectTokenAccountCorrectBalanceChange(input);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
87
118
|
],
|
|
88
119
|
};
|
|
89
120
|
|
|
121
|
+
function findTokenSubAccountWithBalance(account: Account) {
|
|
122
|
+
return account.subAccounts?.find(acc => acc.type === "TokenAccount" && acc.balance.gt(0)) as
|
|
123
|
+
| TokenAccount
|
|
124
|
+
| undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function expectTokenAccountCorrectBalanceChange({
|
|
128
|
+
account,
|
|
129
|
+
accountBeforeTransaction,
|
|
130
|
+
status,
|
|
131
|
+
transaction,
|
|
132
|
+
}: TransactionTestInput<Transaction>) {
|
|
133
|
+
const tokenAccId = transaction.subAccountId;
|
|
134
|
+
if (!tokenAccId) throw new Error("Wrong subAccountId");
|
|
135
|
+
|
|
136
|
+
const tokenAccAfterTx = account.subAccounts?.find(acc => acc.id === tokenAccId);
|
|
137
|
+
const tokenAccBeforeTx = accountBeforeTransaction.subAccounts?.find(acc => acc.id === tokenAccId);
|
|
138
|
+
|
|
139
|
+
if (!tokenAccAfterTx || !tokenAccBeforeTx) {
|
|
140
|
+
throw new Error("Token sub accounts not found!");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
botTest("Token balance decreased with operation", () =>
|
|
144
|
+
expect(tokenAccAfterTx.balance.toString()).toBe(
|
|
145
|
+
tokenAccBeforeTx.balance.minus(status.amount).toString(),
|
|
146
|
+
),
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
90
150
|
export default {
|
|
91
151
|
aptosSpecs,
|
|
92
152
|
};
|