@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
package/src/api/index.ts
CHANGED
|
@@ -1,225 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
GetAccountTransactionsDataQuery,
|
|
31
|
-
GetAccountTransactionsDataGtQueryVariables,
|
|
32
|
-
} from "./graphql/types";
|
|
33
|
-
|
|
34
|
-
const getApiEndpoint = (currencyId: string) =>
|
|
35
|
-
isTestnet(currencyId) ? getEnv("APTOS_TESTNET_API_ENDPOINT") : getEnv("APTOS_API_ENDPOINT");
|
|
36
|
-
const getIndexerEndpoint = (currencyId: string) =>
|
|
37
|
-
isTestnet(currencyId)
|
|
38
|
-
? getEnv("APTOS_TESTNET_INDEXER_ENDPOINT")
|
|
39
|
-
: getEnv("APTOS_INDEXER_ENDPOINT");
|
|
40
|
-
|
|
41
|
-
export class AptosAPI {
|
|
42
|
-
private apiUrl: string;
|
|
43
|
-
private indexerUrl: string;
|
|
44
|
-
private aptosConfig: AptosConfig;
|
|
45
|
-
private aptosClient: Aptos;
|
|
46
|
-
private apolloClient: ApolloClient<object>;
|
|
47
|
-
|
|
48
|
-
constructor(currencyId: string) {
|
|
49
|
-
this.apiUrl = getApiEndpoint(currencyId);
|
|
50
|
-
this.indexerUrl = getIndexerEndpoint(currencyId);
|
|
51
|
-
this.aptosConfig = new AptosConfig({
|
|
52
|
-
fullnode: this.apiUrl,
|
|
53
|
-
indexer: this.indexerUrl,
|
|
54
|
-
});
|
|
55
|
-
this.aptosClient = new Aptos(this.aptosConfig);
|
|
56
|
-
this.apolloClient = new ApolloClient({
|
|
57
|
-
uri: this.indexerUrl,
|
|
58
|
-
cache: new InMemoryCache(),
|
|
59
|
-
headers: {
|
|
60
|
-
"x-client": "ledger-live",
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async getAccount(address: string): Promise<AccountData> {
|
|
66
|
-
return this.aptosClient.getAccountInfo({ accountAddress: address });
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async getAccountInfo(address: string, startAt: string) {
|
|
70
|
-
const [balance, transactions, blockHeight] = await Promise.all([
|
|
71
|
-
this.getBalance(address),
|
|
72
|
-
this.fetchTransactions(address, startAt),
|
|
73
|
-
this.getHeight(),
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
balance,
|
|
78
|
-
transactions,
|
|
79
|
-
blockHeight,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async estimateGasPrice(): Promise<GasEstimation> {
|
|
84
|
-
return this.aptosClient.getGasPriceEstimation();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async generateTransaction(
|
|
88
|
-
address: string,
|
|
89
|
-
payload: InputEntryFunctionData,
|
|
90
|
-
options: TransactionOptions,
|
|
91
|
-
): Promise<RawTransaction> {
|
|
92
|
-
const opts: Partial<InputGenerateTransactionOptions> = {};
|
|
93
|
-
if (!isUndefined(options.maxGasAmount)) {
|
|
94
|
-
opts.maxGasAmount = Number(options.maxGasAmount);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!isUndefined(options.gasUnitPrice)) {
|
|
98
|
-
opts.gasUnitPrice = Number(options.gasUnitPrice);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
const { ledger_timestamp } = await this.aptosClient.getLedgerInfo();
|
|
103
|
-
opts.expireTimestamp = Number(Math.ceil(+ledger_timestamp / 1_000_000 + 2 * 60)); // in milliseconds
|
|
104
|
-
} catch {
|
|
105
|
-
// skip
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return this.aptosClient.transaction.build
|
|
109
|
-
.simple({
|
|
110
|
-
sender: address,
|
|
111
|
-
data: payload,
|
|
112
|
-
options: opts,
|
|
113
|
-
})
|
|
114
|
-
.then(t => t.rawTransaction)
|
|
115
|
-
.catch(error => {
|
|
116
|
-
throw error;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async simulateTransaction(
|
|
121
|
-
address: Ed25519PublicKey,
|
|
122
|
-
tx: RawTransaction,
|
|
123
|
-
options = {
|
|
124
|
-
estimateGasUnitPrice: true,
|
|
125
|
-
estimateMaxGasAmount: true,
|
|
126
|
-
estimatePrioritizedGasUnitPrice: false,
|
|
127
|
-
},
|
|
128
|
-
): Promise<UserTransactionResponse[]> {
|
|
129
|
-
return this.aptosClient.transaction.simulate.simple({
|
|
130
|
-
signerPublicKey: address,
|
|
131
|
-
transaction: { rawTransaction: tx } as SimpleTransaction,
|
|
132
|
-
options,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async broadcast(signature: string): Promise<string> {
|
|
137
|
-
const txBytes = Uint8Array.from(Buffer.from(signature, "hex"));
|
|
138
|
-
const pendingTx = await post<PostRequestOptions, TransactionResponse>({
|
|
139
|
-
contentType: MimeType.BCS_SIGNED_TRANSACTION,
|
|
140
|
-
aptosConfig: this.aptosClient.config,
|
|
141
|
-
body: txBytes,
|
|
142
|
-
path: "transactions",
|
|
143
|
-
type: AptosApiType.FULLNODE,
|
|
144
|
-
originMethod: "",
|
|
145
|
-
});
|
|
146
|
-
return pendingTx.data.hash;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private async getBalance(address: string): Promise<BigNumber> {
|
|
150
|
-
try {
|
|
151
|
-
const [balanceStr] = await this.aptosClient.view<[string]>({
|
|
152
|
-
payload: {
|
|
153
|
-
function: "0x1::coin::balance",
|
|
154
|
-
typeArguments: [APTOS_ASSET_ID],
|
|
155
|
-
functionArguments: [address],
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
const balance = parseInt(balanceStr, 10);
|
|
159
|
-
return new BigNumber(balance);
|
|
160
|
-
} catch (_) {
|
|
161
|
-
return new BigNumber(0);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
private async fetchTransactions(address: string, gt?: string) {
|
|
166
|
-
if (!address) {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let query = GetAccountTransactionsData;
|
|
171
|
-
if (gt) {
|
|
172
|
-
query = GetAccountTransactionsDataGt;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const queryResponse = await this.apolloClient.query<
|
|
176
|
-
GetAccountTransactionsDataQuery,
|
|
177
|
-
GetAccountTransactionsDataGtQueryVariables
|
|
178
|
-
>({
|
|
179
|
-
query,
|
|
180
|
-
variables: {
|
|
181
|
-
address,
|
|
182
|
-
limit: 1000,
|
|
183
|
-
gt,
|
|
184
|
-
},
|
|
185
|
-
fetchPolicy: "network-only",
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
return Promise.all(
|
|
189
|
-
queryResponse.data.address_version_from_move_resources.map(({ transaction_version }) => {
|
|
190
|
-
return this.richItemByVersion(transaction_version);
|
|
191
|
-
}),
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
private async richItemByVersion(version: number): Promise<AptosTransaction | null> {
|
|
196
|
-
try {
|
|
197
|
-
const tx: TransactionResponse = await this.aptosClient.getTransactionByVersion({
|
|
198
|
-
ledgerVersion: version,
|
|
199
|
-
});
|
|
200
|
-
const block = await this.getBlock(version);
|
|
201
|
-
return {
|
|
202
|
-
...tx,
|
|
203
|
-
block,
|
|
204
|
-
} as AptosTransaction;
|
|
205
|
-
} catch (error) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
private async getHeight(): Promise<number> {
|
|
211
|
-
const { data } = await network<Block>({
|
|
212
|
-
method: "GET",
|
|
213
|
-
url: this.apiUrl,
|
|
214
|
-
});
|
|
215
|
-
return parseInt(data.block_height);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
private async getBlock(version: number) {
|
|
219
|
-
const block = await this.aptosClient.getBlockByVersion({ ledgerVersion: version });
|
|
220
|
-
return {
|
|
221
|
-
height: parseInt(block.block_height),
|
|
222
|
-
hash: block.block_hash,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
1
|
+
import type { Api } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
+
import type { AptosConfig as AptosConfigApi } from "../config";
|
|
3
|
+
import type { Balance, Pagination, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
4
|
+
import coinConfig from "../config";
|
|
5
|
+
import type { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
|
|
6
|
+
import { AptosAPI } from "../network";
|
|
7
|
+
import { combine } from "../logic/combine";
|
|
8
|
+
import { craftTransaction } from "../logic/craftTransaction";
|
|
9
|
+
import { getBalance } from "../logic/getBalance";
|
|
10
|
+
|
|
11
|
+
export function createApi(
|
|
12
|
+
config: AptosConfigApi,
|
|
13
|
+
): Api<AptosAsset, AptosExtra, AptosSender, AptosFeeParameters> {
|
|
14
|
+
coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
|
|
15
|
+
|
|
16
|
+
const client = new AptosAPI(config.aptosSettings);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
broadcast: (tx: string) => client.broadcast(tx),
|
|
20
|
+
combine: (tx, signature, pubkey): string => combine(tx, signature, pubkey),
|
|
21
|
+
craftTransaction: (transactionIntent, _customFees): Promise<string> =>
|
|
22
|
+
craftTransaction(client, transactionIntent),
|
|
23
|
+
estimateFees: (transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>) =>
|
|
24
|
+
client.estimateFees(transactionIntent),
|
|
25
|
+
getBalance: (address): Promise<Balance<AptosAsset>[]> => getBalance(client, address),
|
|
26
|
+
lastBlock: () => client.getLastBlock(),
|
|
27
|
+
listOperations: (address: string, pagination: Pagination) =>
|
|
28
|
+
client.listOperations(address, pagination),
|
|
29
|
+
};
|
|
225
30
|
}
|
|
@@ -3,6 +3,7 @@ import { faker } from "@faker-js/faker";
|
|
|
3
3
|
import type { AptosAccount, Transaction } from "../types/index";
|
|
4
4
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
5
5
|
import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index";
|
|
6
|
+
import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
|
|
6
7
|
|
|
7
8
|
const currency = getCryptoCurrencyById("aptos");
|
|
8
9
|
|
|
@@ -18,35 +19,113 @@ export function createFixtureAccount(account?: Partial<AptosAccount>): AptosAcco
|
|
|
18
19
|
seedIdentifier: faker.string.uuid(),
|
|
19
20
|
derivationMode: "",
|
|
20
21
|
index: faker.number.int(),
|
|
21
|
-
freshAddress:
|
|
22
|
-
freshAddressPath:
|
|
22
|
+
freshAddress: freshAddress.address,
|
|
23
|
+
freshAddressPath: freshAddress.derivationPath,
|
|
23
24
|
used: true,
|
|
24
|
-
balance:
|
|
25
|
-
spendableBalance:
|
|
25
|
+
balance: new BigNumber(0),
|
|
26
|
+
spendableBalance: new BigNumber(0),
|
|
26
27
|
creationDate: faker.date.past(),
|
|
27
28
|
blockHeight: faker.number.int({ min: 100_000, max: 200_000 }),
|
|
28
29
|
currency,
|
|
29
|
-
operationsCount:
|
|
30
|
-
operations:
|
|
31
|
-
pendingOperations:
|
|
30
|
+
operationsCount: 0,
|
|
31
|
+
operations: [],
|
|
32
|
+
pendingOperations: [],
|
|
32
33
|
lastSyncDate: new Date(),
|
|
33
34
|
balanceHistoryCache: emptyHistoryCache,
|
|
34
35
|
swapHistory: [],
|
|
36
|
+
...account,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function createFixtureAccountWithSubAccount(
|
|
41
|
+
tokenType: string,
|
|
42
|
+
account?: Partial<AptosAccount>,
|
|
43
|
+
): AptosAccount {
|
|
44
|
+
const freshAddress = {
|
|
45
|
+
address: "address",
|
|
46
|
+
derivationPath: "derivation_path",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const id = faker.string.uuid();
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
type: "Account",
|
|
53
|
+
id,
|
|
54
|
+
seedIdentifier: faker.string.uuid(),
|
|
55
|
+
derivationMode: "",
|
|
56
|
+
index: faker.number.int(),
|
|
57
|
+
freshAddress: freshAddress.address,
|
|
58
|
+
freshAddressPath: freshAddress.derivationPath,
|
|
59
|
+
used: true,
|
|
60
|
+
balance: new BigNumber(0),
|
|
61
|
+
spendableBalance: new BigNumber(0),
|
|
62
|
+
creationDate: faker.date.past(),
|
|
63
|
+
blockHeight: faker.number.int({ min: 100_000, max: 200_000 }),
|
|
64
|
+
currency,
|
|
65
|
+
operationsCount: 0,
|
|
66
|
+
operations: [],
|
|
67
|
+
pendingOperations: [],
|
|
68
|
+
lastSyncDate: new Date(),
|
|
69
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
70
|
+
swapHistory: [],
|
|
71
|
+
subAccounts: [
|
|
72
|
+
{
|
|
73
|
+
id: "1",
|
|
74
|
+
parentId: id,
|
|
75
|
+
type: "TokenAccount",
|
|
76
|
+
token: {
|
|
77
|
+
type: "TokenCurrency",
|
|
78
|
+
id: "aptToken",
|
|
79
|
+
contractAddress: "contract_address",
|
|
80
|
+
parentCurrency: currency,
|
|
81
|
+
tokenType,
|
|
82
|
+
} as TokenCurrency,
|
|
83
|
+
balance: BigNumber(1000),
|
|
84
|
+
spendableBalance: BigNumber(1000),
|
|
85
|
+
creationDate: new Date(),
|
|
86
|
+
operationsCount: 0,
|
|
87
|
+
operations: [],
|
|
88
|
+
pendingOperations: [],
|
|
89
|
+
balanceHistoryCache: emptyHistoryCache,
|
|
90
|
+
swapHistory: [],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
...account,
|
|
35
94
|
};
|
|
36
95
|
}
|
|
37
96
|
|
|
38
97
|
export function createFixtureTransaction(tx?: Partial<Transaction>): Transaction {
|
|
39
98
|
const transaction: Transaction = {
|
|
40
|
-
amount:
|
|
41
|
-
recipient:
|
|
42
|
-
useAllAmount:
|
|
99
|
+
amount: new BigNumber(0),
|
|
100
|
+
recipient: "recipient",
|
|
101
|
+
useAllAmount: false,
|
|
102
|
+
family: "aptos",
|
|
103
|
+
mode: "send",
|
|
104
|
+
fees: null,
|
|
105
|
+
options: {
|
|
106
|
+
maxGasAmount: BigNumber(0).toString(),
|
|
107
|
+
gasUnitPrice: BigNumber(0).toString(),
|
|
108
|
+
},
|
|
109
|
+
...tx,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return transaction;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function createFixtureTransactionWithSubAccount(tx?: Partial<Transaction>): Transaction {
|
|
116
|
+
const transaction: Transaction = {
|
|
117
|
+
amount: new BigNumber(0),
|
|
118
|
+
recipient: "recipient",
|
|
119
|
+
useAllAmount: false,
|
|
43
120
|
family: "aptos",
|
|
44
|
-
mode:
|
|
45
|
-
fees:
|
|
121
|
+
mode: "send",
|
|
122
|
+
fees: null,
|
|
46
123
|
options: {
|
|
47
124
|
maxGasAmount: BigNumber(0).toString(),
|
|
48
125
|
gasUnitPrice: BigNumber(0).toString(),
|
|
49
126
|
},
|
|
127
|
+
subAccountId: "1",
|
|
128
|
+
...tx,
|
|
50
129
|
};
|
|
51
130
|
|
|
52
131
|
return transaction;
|
package/src/bridge/broadcast.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
2
2
|
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
|
-
import { AptosAPI } from "../
|
|
3
|
+
import { AptosAPI } from "../network";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
signedOperation,
|
|
7
|
-
account,
|
|
8
|
-
}: {
|
|
5
|
+
type broadcastFunc = {
|
|
9
6
|
signedOperation: SignedOperation;
|
|
10
7
|
account: Account;
|
|
11
|
-
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const broadcast = async ({ signedOperation, account }: broadcastFunc): Promise<Operation> => {
|
|
12
11
|
const { signature, operation } = signedOperation;
|
|
13
|
-
const
|
|
12
|
+
const client = new AptosAPI(account.currency.id);
|
|
13
|
+
const hash = await client.broadcast(signature);
|
|
14
14
|
return patchOperationWithHash(operation, hash);
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Account, AccountLike } from "@ledgerhq/types-live";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
3
|
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
|
|
4
|
-
import { AptosAPI } from "../
|
|
4
|
+
import { AptosAPI } from "../network";
|
|
5
5
|
import { getEstimatedGas } from "./getFeesForTransaction";
|
|
6
|
-
import {
|
|
6
|
+
import { getMaxSendBalance } from "./logic";
|
|
7
7
|
import type { Transaction } from "../types";
|
|
8
|
+
import { DEFAULT_GAS, DEFAULT_GAS_PRICE } from "../constants";
|
|
8
9
|
|
|
9
10
|
const estimateMaxSpendable = async ({
|
|
10
11
|
account,
|
|
@@ -29,7 +30,7 @@ const estimateMaxSpendable = async ({
|
|
|
29
30
|
gasUnitPrice = BigNumber(estimate.gasUnitPrice);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
return getMaxSendBalance(
|
|
33
|
+
return getMaxSendBalance(maxGasAmount, gasUnitPrice, mainAccount, transaction);
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export default estimateMaxSpendable;
|
|
@@ -3,10 +3,11 @@ import { log } from "@ledgerhq/logs";
|
|
|
3
3
|
import type { Account } from "@ledgerhq/types-live";
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
5
5
|
import { makeLRUCache, seconds } from "@ledgerhq/live-network/cache";
|
|
6
|
-
import { AptosAPI } from "../
|
|
7
|
-
import
|
|
8
|
-
import { DEFAULT_GAS, DEFAULT_GAS_PRICE, ESTIMATE_GAS_MUL } from "
|
|
6
|
+
import { AptosAPI } from "../network";
|
|
7
|
+
import { getTokenAccount } from "./logic";
|
|
8
|
+
import { DEFAULT_GAS, DEFAULT_GAS_PRICE, ESTIMATE_GAS_MUL } from "../constants";
|
|
9
9
|
import type { Transaction, TransactionErrors } from "../types";
|
|
10
|
+
import buildTransaction from "../logic/buildTransaction";
|
|
10
11
|
|
|
11
12
|
type IGetEstimatedGasReturnType = {
|
|
12
13
|
fees: BigNumber;
|
|
@@ -49,16 +50,18 @@ export const getFee = async (
|
|
|
49
50
|
|
|
50
51
|
const expectedGas = gasPrice.multipliedBy(gasLimit);
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
if (!completedTx.success) {
|
|
54
|
+
if (completedTx.vm_status.includes("MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS")) {
|
|
55
|
+
res.errors.maxGasAmount = "GasInsufficientBalance";
|
|
56
|
+
} else if (
|
|
57
|
+
!completedTx.vm_status.includes("INSUFFICIENT_BALANCE") &&
|
|
58
|
+
!completedTx.vm_status.includes("0x203ed") // 0x203ed -> PROLOGUE_ECANT_PAY_GAS_DEPOSIT equivalent to INSUFFICIENT_BALANCE_FOR_TRANSACTION_FEE
|
|
59
|
+
) {
|
|
60
|
+
// INSUFFICIENT_BALANCE will be processed by getTransactionStatus
|
|
59
61
|
throw Error(`Simulation failed with following error: ${completedTx.vm_status}`);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
64
|
+
|
|
62
65
|
res.fees = expectedGas;
|
|
63
66
|
res.estimate.maxGasAmount = gasLimit.toString();
|
|
64
67
|
res.estimate.gasUnitPrice = completedTx.gas_unit_price;
|
|
@@ -72,7 +75,10 @@ export const getFee = async (
|
|
|
72
75
|
|
|
73
76
|
const CACHE = makeLRUCache(
|
|
74
77
|
getFee,
|
|
75
|
-
(account: Account, transaction: Transaction) =>
|
|
78
|
+
(account: Account, transaction: Transaction) => {
|
|
79
|
+
const tokenAccount = getTokenAccount(account, transaction);
|
|
80
|
+
return `${tokenAccount ? tokenAccount.id : account.id}-${transaction.amount.toString()}}`;
|
|
81
|
+
},
|
|
76
82
|
seconds(30),
|
|
77
83
|
);
|
|
78
84
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumber } from "bignumber.js";
|
|
2
1
|
import {
|
|
3
2
|
NotEnoughBalance,
|
|
4
3
|
RecipientRequired,
|
|
@@ -6,40 +5,63 @@ import {
|
|
|
6
5
|
FeeNotLoaded,
|
|
7
6
|
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
8
7
|
AmountRequired,
|
|
8
|
+
NotEnoughBalanceFees,
|
|
9
9
|
} from "@ledgerhq/errors";
|
|
10
10
|
import type { Account } from "@ledgerhq/types-live";
|
|
11
|
+
import { BigNumber } from "bignumber.js";
|
|
11
12
|
import type { Transaction, TransactionStatus } from "../types";
|
|
12
13
|
|
|
13
14
|
import { AccountAddress } from "@aptos-labs/ts-sdk";
|
|
15
|
+
import { getTokenAccount } from "./logic";
|
|
14
16
|
|
|
15
17
|
const getTransactionStatus = async (a: Account, t: Transaction): Promise<TransactionStatus> => {
|
|
16
18
|
const errors: Record<string, Error> = {};
|
|
17
19
|
const warnings = {};
|
|
18
20
|
|
|
21
|
+
if (!t.recipient) {
|
|
22
|
+
errors.recipient = new RecipientRequired();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!AccountAddress.isValid({ input: t.recipient }).valid && !errors.recipient) {
|
|
26
|
+
errors.recipient = new InvalidAddress("", { currencyName: a.currency.name });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (t.recipient === a.freshAddress && !errors.recipient) {
|
|
30
|
+
errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
if (!t.fees) {
|
|
20
34
|
errors.fees = new FeeNotLoaded();
|
|
21
35
|
}
|
|
22
36
|
|
|
23
37
|
const estimatedFees = t.fees || BigNumber(0);
|
|
24
38
|
|
|
25
|
-
if (t.amount.
|
|
39
|
+
if (t.amount.lte(0)) {
|
|
26
40
|
errors.amount = new AmountRequired();
|
|
27
41
|
}
|
|
28
42
|
|
|
29
|
-
const
|
|
43
|
+
const tokenAccount = getTokenAccount(a, t);
|
|
30
44
|
|
|
31
|
-
const
|
|
45
|
+
const amount = t.useAllAmount
|
|
46
|
+
? tokenAccount
|
|
47
|
+
? tokenAccount.spendableBalance
|
|
48
|
+
: a.spendableBalance.minus(estimatedFees).isLessThan(0)
|
|
49
|
+
? BigNumber(0)
|
|
50
|
+
: a.spendableBalance.minus(estimatedFees)
|
|
51
|
+
: t.amount;
|
|
32
52
|
|
|
33
|
-
|
|
34
|
-
errors.amount = new NotEnoughBalance();
|
|
35
|
-
}
|
|
53
|
+
const totalSpent = tokenAccount ? amount : amount.plus(estimatedFees);
|
|
36
54
|
|
|
37
|
-
if (
|
|
38
|
-
errors.
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
if (tokenAccount && t.errors?.maxGasAmount == "GasInsufficientBalance" && !errors.amount) {
|
|
56
|
+
errors.amount = new NotEnoughBalanceFees();
|
|
57
|
+
}
|
|
58
|
+
if (
|
|
59
|
+
tokenAccount
|
|
60
|
+
? tokenAccount.spendableBalance.isLessThan(totalSpent) ||
|
|
61
|
+
a.spendableBalance.isLessThan(estimatedFees)
|
|
62
|
+
: a.spendableBalance.isLessThan(totalSpent) && !errors.amount
|
|
63
|
+
) {
|
|
64
|
+
errors.amount = new NotEnoughBalance();
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
return Promise.resolve({
|
package/src/bridge/index.ts
CHANGED
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
updateTransaction,
|
|
7
7
|
} from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
8
8
|
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
9
|
-
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
9
|
+
import type { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
10
10
|
import type { Account, AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
|
|
11
11
|
import resolver from "../signer";
|
|
12
12
|
import type { Transaction, TransactionStatus, AptosSigner } from "../types";
|
|
13
13
|
import getTransactionStatus from "./getTransactionStatus";
|
|
14
14
|
import estimateMaxSpendable from "./estimateMaxSpendable";
|
|
15
15
|
import prepareTransaction from "./prepareTransaction";
|
|
16
|
-
import createTransaction from "./createTransaction";
|
|
17
16
|
import { getAccountShape } from "./synchronisation";
|
|
18
17
|
import buildSignOperation from "./signOperation";
|
|
19
18
|
import broadcast from "./broadcast";
|
|
19
|
+
import createTransaction from "../logic/createTransaction";
|
|
20
20
|
|
|
21
21
|
function buildCurrencyBridge(signerContext: SignerContext<AptosSigner>): CurrencyBridge {
|
|
22
22
|
const getAddress = resolver(signerContext);
|