@ledgerhq/coin-aptos 2.0.0 → 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/CHANGELOG.md +26 -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.js +276 -9
- package/lib/__tests__/api/index.integ.test.js.map +1 -1
- package/lib/__tests__/api/index.test.js +1 -1
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/bridge/logic.test.js +8 -558
- package/lib/__tests__/bridge/logic.test.js.map +1 -1
- package/lib/__tests__/bridge/signOperation.test.js +7 -11
- package/lib/__tests__/bridge/signOperation.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__/{bridge → logic}/buildTransaction.test.js +14 -8
- 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 +1 -1
- 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.js +613 -9
- package/lib/__tests__/network/client.test.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +7 -12
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +1 -1
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/index.js +1 -1
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/logic.d.ts +1 -17
- package/lib/bridge/logic.d.ts.map +1 -1
- package/lib/bridge/logic.js +12 -204
- package/lib/bridge/logic.js.map +1 -1
- package/lib/bridge/prepareTransaction.js +1 -1
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +1 -1
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/constants.d.ts +7 -4
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +8 -4
- 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/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 +6 -4
- package/lib/network/client.d.ts.map +1 -1
- package/lib/network/client.js +50 -14
- package/lib/network/client.js.map +1 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +4 -7
- package/lib/network/index.js.map +1 -1
- package/lib/types/assets.d.ts +5 -1
- package/lib/types/assets.d.ts.map +1 -1
- package/lib/types/index.d.ts +4 -0
- 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.js +277 -10
- package/lib-es/__tests__/api/index.integ.test.js.map +1 -1
- package/lib-es/__tests__/api/index.test.js +1 -1
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/logic.test.js +8 -558
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
- package/lib-es/__tests__/bridge/signOperation.test.js +7 -11
- package/lib-es/__tests__/bridge/signOperation.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__/{bridge → logic}/buildTransaction.test.js +11 -5
- 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 +1 -1
- 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.js +614 -10
- package/lib-es/__tests__/network/client.test.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +7 -12
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +1 -1
- package/lib-es/bridge/getFeesForTransaction.js.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 +1 -17
- package/lib-es/bridge/logic.d.ts.map +1 -1
- package/lib-es/bridge/logic.js +6 -187
- package/lib-es/bridge/logic.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +1 -1
- 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 +1 -1
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/constants.d.ts +7 -4
- package/lib-es/constants.d.ts.map +1 -1
- package/lib-es/constants.js +7 -3
- 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/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 +6 -4
- package/lib-es/network/client.d.ts.map +1 -1
- package/lib-es/network/client.js +50 -14
- package/lib-es/network/client.js.map +1 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +5 -8
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/types/assets.d.ts +5 -1
- package/lib-es/types/assets.d.ts.map +1 -1
- package/lib-es/types/index.d.ts +4 -0
- package/lib-es/types/index.d.ts.map +1 -1
- package/package.json +10 -10
- 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 +355 -12
- package/src/__tests__/api/index.test.ts +1 -1
- package/src/__tests__/bridge/logic.test.ts +9 -654
- package/src/__tests__/bridge/signOperation.test.ts +7 -11
- package/src/__tests__/index.test.ts +1 -1
- package/src/__tests__/{bridge → logic}/buildTransaction.test.ts +14 -7
- 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 +1 -1
- 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 +650 -11
- package/src/api/index.ts +10 -13
- package/src/bridge/estimateMaxSpendable.ts +1 -1
- package/src/bridge/getFeesForTransaction.ts +1 -1
- package/src/bridge/index.ts +1 -1
- package/src/bridge/logic.ts +8 -279
- package/src/bridge/prepareTransaction.ts +1 -1
- package/src/bridge/signOperation.ts +1 -1
- package/src/config.ts +1 -1
- package/src/constants.ts +8 -4
- 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/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 +88 -29
- package/src/network/index.ts +4 -13
- package/src/types/assets.ts +6 -1
- package/src/types/index.ts +5 -0
- package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
- 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/bridge/buildTransaction.d.ts +0 -7
- package/lib/bridge/buildTransaction.d.ts.map +0 -1
- package/lib/bridge/buildTransaction.js +0 -45
- 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.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/bridge/buildTransaction.d.ts +0 -7
- package/lib-es/bridge/buildTransaction.d.ts.map +0 -1
- package/lib-es/bridge/buildTransaction.js +0 -43
- 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/bridge/buildTransaction.ts +0 -62
- /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/{bridge → logic}/createTransaction.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/{bridge → logic}/createTransaction.js +0 -0
- /package/src/{bridge → logic}/createTransaction.ts +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { Hex, RawTransaction, Deserializer } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import type { TransactionIntent } from "@ledgerhq/coin-framework/lib/api/types";
|
|
3
|
+
import { createApi } from "../../api";
|
|
4
|
+
import type { AptosAsset, AptosExtra, AptosSender } from "../../types/assets";
|
|
5
|
+
import { AptosAPI } from "../../network";
|
|
6
|
+
import { APTOS_ASSET_ID } from "../../constants";
|
|
7
|
+
|
|
8
|
+
jest.mock("../../network");
|
|
9
|
+
let mockedAptosApi: jest.Mocked<any>;
|
|
10
|
+
|
|
11
|
+
jest.mock("../../config", () => ({
|
|
12
|
+
setCoinConfig: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
describe("craftTransaction", () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
mockedAptosApi = jest.mocked(AptosAPI);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
jest.resetAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const SENDER_ADDR = "APTOS_1_ADDRESS";
|
|
25
|
+
const RECIPIENT_ADDR = "APTOS_2_ADDRESS";
|
|
26
|
+
|
|
27
|
+
const hexRawTx =
|
|
28
|
+
"0xfdde1012c0fac1f9a121eb3c8481c90d473df1c4180c070bd4f2549a6d06180400000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e736665720002203f5f0fcc8a909f23806e5efbdc1757e653fcd744de516a7de12b99b8417925c1080a00000000000000400d03000000000064000000000000002c721b6800000000b7";
|
|
29
|
+
|
|
30
|
+
const rawTxn = RawTransaction.deserialize(
|
|
31
|
+
new Deserializer(Hex.fromHexString(hexRawTx).toUint8Array()),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
it("creates a coin transaction", async () => {
|
|
35
|
+
const mockGenerateTransaction = jest.fn().mockResolvedValue(rawTxn);
|
|
36
|
+
const mockGetBalances = jest
|
|
37
|
+
.fn()
|
|
38
|
+
.mockResolvedValue([{ contractAddress: APTOS_ASSET_ID, amount: 12345 }]);
|
|
39
|
+
mockedAptosApi.mockImplementation(() => ({
|
|
40
|
+
generateTransaction: mockGenerateTransaction,
|
|
41
|
+
getBalances: mockGetBalances,
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const SENDER: AptosSender = {
|
|
45
|
+
xpub: "public-key",
|
|
46
|
+
freshAddress: SENDER_ADDR,
|
|
47
|
+
};
|
|
48
|
+
const api = createApi({
|
|
49
|
+
aptosSettings: {},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
53
|
+
type: "send",
|
|
54
|
+
sender: SENDER,
|
|
55
|
+
recipient: RECIPIENT_ADDR,
|
|
56
|
+
amount: 10n,
|
|
57
|
+
asset: { type: "native" },
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const tx = await api.craftTransaction(txArg);
|
|
61
|
+
|
|
62
|
+
expect(tx).not.toEqual("");
|
|
63
|
+
expect(Hex.isValid(tx).valid).toBeTruthy();
|
|
64
|
+
expect(mockGetBalances).toHaveBeenCalledTimes(0);
|
|
65
|
+
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
66
|
+
|
|
67
|
+
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
68
|
+
SENDER.freshAddress,
|
|
69
|
+
expect.objectContaining({
|
|
70
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
71
|
+
typeArguments: [APTOS_ASSET_ID],
|
|
72
|
+
functionArguments: [RECIPIENT_ADDR, txArg.amount.toString()],
|
|
73
|
+
}),
|
|
74
|
+
expect.anything(),
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("creates a native coin transaction using all amount available", async () => {
|
|
79
|
+
const mockGenerateTransaction = jest.fn().mockResolvedValue(rawTxn);
|
|
80
|
+
const mockGetBalances = jest
|
|
81
|
+
.fn()
|
|
82
|
+
.mockResolvedValue([{ contractAddress: APTOS_ASSET_ID, amount: 12345 }]);
|
|
83
|
+
mockedAptosApi.mockImplementation(() => ({
|
|
84
|
+
generateTransaction: mockGenerateTransaction,
|
|
85
|
+
getBalances: mockGetBalances,
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
const SENDER: AptosSender = {
|
|
89
|
+
xpub: "public-key",
|
|
90
|
+
freshAddress: SENDER_ADDR,
|
|
91
|
+
};
|
|
92
|
+
const api = createApi({
|
|
93
|
+
aptosSettings: {},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
97
|
+
type: "send",
|
|
98
|
+
sender: SENDER,
|
|
99
|
+
recipient: RECIPIENT_ADDR,
|
|
100
|
+
amount: 0n,
|
|
101
|
+
asset: { type: "native" },
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const tx = await api.craftTransaction(txArg);
|
|
105
|
+
|
|
106
|
+
expect(tx).not.toEqual("");
|
|
107
|
+
expect(Hex.isValid(tx).valid).toBeTruthy();
|
|
108
|
+
expect(mockGetBalances).toHaveBeenCalledTimes(1);
|
|
109
|
+
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
110
|
+
|
|
111
|
+
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
112
|
+
SENDER.freshAddress,
|
|
113
|
+
expect.objectContaining({
|
|
114
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
115
|
+
typeArguments: [APTOS_ASSET_ID],
|
|
116
|
+
functionArguments: [RECIPIENT_ADDR, "12345"],
|
|
117
|
+
}),
|
|
118
|
+
expect.anything(),
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("creates a coin token transaction", async () => {
|
|
123
|
+
const mockGenerateTransaction = jest.fn().mockResolvedValue(rawTxn);
|
|
124
|
+
const mockGetBalances = jest
|
|
125
|
+
.fn()
|
|
126
|
+
.mockResolvedValue([{ contractAddress: "0x42::token::Token", amount: 12345 }]);
|
|
127
|
+
mockedAptosApi.mockImplementation(() => ({
|
|
128
|
+
generateTransaction: mockGenerateTransaction,
|
|
129
|
+
getBalances: mockGetBalances,
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
const SENDER: AptosSender = {
|
|
133
|
+
xpub: "public-key",
|
|
134
|
+
freshAddress: SENDER_ADDR,
|
|
135
|
+
};
|
|
136
|
+
const api = createApi({
|
|
137
|
+
aptosSettings: {},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
141
|
+
type: "send",
|
|
142
|
+
sender: SENDER,
|
|
143
|
+
recipient: RECIPIENT_ADDR,
|
|
144
|
+
amount: 10n,
|
|
145
|
+
asset: { type: "token", standard: "coin", contractAddress: "0x42::token::Token" },
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const tx = await api.craftTransaction(txArg);
|
|
149
|
+
|
|
150
|
+
expect(tx).not.toEqual("");
|
|
151
|
+
expect(Hex.isValid(tx).valid).toBeTruthy();
|
|
152
|
+
expect(mockGetBalances).toHaveBeenCalledTimes(0);
|
|
153
|
+
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
154
|
+
|
|
155
|
+
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
156
|
+
SENDER.freshAddress,
|
|
157
|
+
expect.objectContaining({
|
|
158
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
159
|
+
typeArguments: ["0x42::token::Token"],
|
|
160
|
+
functionArguments: [RECIPIENT_ADDR, txArg.amount.toString()],
|
|
161
|
+
}),
|
|
162
|
+
expect.anything(),
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("creates a fungible_asset token transaction using all amount available", async () => {
|
|
167
|
+
const mockGenerateTransaction = jest.fn().mockResolvedValue(rawTxn);
|
|
168
|
+
const mockGetBalances = jest
|
|
169
|
+
.fn()
|
|
170
|
+
.mockResolvedValue([{ contractAddress: "0x42", amount: 12345 }]);
|
|
171
|
+
mockedAptosApi.mockImplementation(() => ({
|
|
172
|
+
generateTransaction: mockGenerateTransaction,
|
|
173
|
+
getBalances: mockGetBalances,
|
|
174
|
+
}));
|
|
175
|
+
|
|
176
|
+
const SENDER: AptosSender = {
|
|
177
|
+
xpub: "public-key",
|
|
178
|
+
freshAddress: SENDER_ADDR,
|
|
179
|
+
};
|
|
180
|
+
const api = createApi({
|
|
181
|
+
aptosSettings: {},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
185
|
+
type: "send",
|
|
186
|
+
sender: SENDER,
|
|
187
|
+
recipient: RECIPIENT_ADDR,
|
|
188
|
+
amount: 0n,
|
|
189
|
+
asset: { type: "token", standard: "fungible_asset", contractAddress: "0x42" },
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const tx = await api.craftTransaction(txArg);
|
|
193
|
+
|
|
194
|
+
expect(tx).not.toEqual("");
|
|
195
|
+
expect(Hex.isValid(tx).valid).toBeTruthy();
|
|
196
|
+
expect(mockGetBalances).toHaveBeenCalledTimes(1);
|
|
197
|
+
expect(mockGenerateTransaction).toHaveBeenCalledTimes(1);
|
|
198
|
+
|
|
199
|
+
expect(mockGenerateTransaction).toHaveBeenCalledWith(
|
|
200
|
+
SENDER.freshAddress,
|
|
201
|
+
expect.objectContaining({
|
|
202
|
+
function: "0x1::primary_fungible_store::transfer",
|
|
203
|
+
typeArguments: ["0x1::fungible_asset::Metadata"],
|
|
204
|
+
functionArguments: ["0x42", RECIPIENT_ADDR, "12345"],
|
|
205
|
+
}),
|
|
206
|
+
expect.anything(),
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("throws an exception for invalid tokenType", async () => {
|
|
211
|
+
const mockGenerateTransaction = jest.fn().mockResolvedValue(rawTxn);
|
|
212
|
+
const mockGetBalances = jest
|
|
213
|
+
.fn()
|
|
214
|
+
.mockResolvedValue([{ contractAddress: "0x42::token::Token", amount: 12345 }]);
|
|
215
|
+
mockedAptosApi.mockImplementation(() => ({
|
|
216
|
+
generateTransaction: mockGenerateTransaction,
|
|
217
|
+
getBalances: mockGetBalances,
|
|
218
|
+
}));
|
|
219
|
+
|
|
220
|
+
const SENDER: AptosSender = {
|
|
221
|
+
xpub: "public-key",
|
|
222
|
+
freshAddress: SENDER_ADDR,
|
|
223
|
+
};
|
|
224
|
+
const api = createApi({
|
|
225
|
+
aptosSettings: {},
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const txArg: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
|
|
229
|
+
type: "send",
|
|
230
|
+
sender: SENDER,
|
|
231
|
+
recipient: RECIPIENT_ADDR,
|
|
232
|
+
amount: 10n,
|
|
233
|
+
asset: { type: "token", standard: "asset", contractAddress: "0x42::token::Token" },
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
expect(async () => await api.craftTransaction(txArg)).rejects.toThrow(
|
|
237
|
+
"Token type asset not supported",
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
expect(mockGetBalances).toHaveBeenCalledTimes(0);
|
|
241
|
+
expect(mockGenerateTransaction).toHaveBeenCalledTimes(0);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AptosAPI } from "../../network";
|
|
2
|
+
import { getBalance } from "../../logic/getBalance";
|
|
3
|
+
import { APTOS_ASSET_ID } from "../../constants";
|
|
4
|
+
import BigNumber from "bignumber.js";
|
|
5
|
+
|
|
6
|
+
jest.mock("../../network", () => {
|
|
7
|
+
return {
|
|
8
|
+
AptosAPI: jest.fn().mockImplementation(() => ({
|
|
9
|
+
getBalances: jest.fn(),
|
|
10
|
+
})),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe("getBalance", () => {
|
|
15
|
+
let mockGetBalances: jest.Mock;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
|
|
20
|
+
mockGetBalances = jest
|
|
21
|
+
.fn()
|
|
22
|
+
.mockResolvedValue([{ asset_type: APTOS_ASSET_ID, amount: BigNumber(10) }]);
|
|
23
|
+
|
|
24
|
+
(AptosAPI as jest.Mock).mockImplementation(() => ({
|
|
25
|
+
getBalances: mockGetBalances,
|
|
26
|
+
}));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
jest.clearAllMocks();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should returns balance with value 10", async () => {
|
|
34
|
+
mockGetBalances.mockResolvedValue([{ asset_type: APTOS_ASSET_ID, amount: new BigNumber(10) }]);
|
|
35
|
+
|
|
36
|
+
const accountAddress = "0x4be47904b31063d60ac0dfde06e5dc203e647edbe853bae0e666ae5a763c3906";
|
|
37
|
+
const client = new AptosAPI("aptos");
|
|
38
|
+
const balance = await getBalance(client, accountAddress);
|
|
39
|
+
|
|
40
|
+
expect(balance).toBeDefined();
|
|
41
|
+
expect(balance).toMatchObject([{ value: BigInt(10), asset: { type: "native" } }]);
|
|
42
|
+
expect(mockGetBalances).toHaveBeenCalledWith(accountAddress);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Hex, Network } from "@aptos-labs/ts-sdk";
|
|
1
|
+
import { Deserializer, Hex, Network, RawTransaction } from "@aptos-labs/ts-sdk";
|
|
2
2
|
import { createApi } from "../../api";
|
|
3
3
|
import { getEnv } from "@ledgerhq/live-env";
|
|
4
|
-
import { AptosSender } from "../../types/assets";
|
|
4
|
+
import type { AptosSender } from "../../types/assets";
|
|
5
|
+
import { DEFAULT_GAS, DEFAULT_GAS_PRICE } from "../../constants";
|
|
5
6
|
|
|
6
7
|
describe("createApi", () => {
|
|
7
8
|
const api = createApi({
|
|
@@ -11,35 +12,43 @@ describe("createApi", () => {
|
|
|
11
12
|
indexer: getEnv("APTOS_INDEXER_ENDPOINT"),
|
|
12
13
|
},
|
|
13
14
|
});
|
|
15
|
+
|
|
14
16
|
const sender: AptosSender = {
|
|
15
|
-
xpub: "
|
|
16
|
-
freshAddress: "
|
|
17
|
+
xpub: "0x934887885b27a0407bf8a5e0bbc6b6371254bea94de5510e948bcc92dc0a519b",
|
|
18
|
+
freshAddress: "0x0ef3b40f6ecd5583218d1985e0d54b54e8785ad2ec2d27ed1720ec16bb11686f",
|
|
17
19
|
};
|
|
20
|
+
|
|
18
21
|
const recipient: AptosSender = {
|
|
19
|
-
xpub: "
|
|
20
|
-
freshAddress: "
|
|
22
|
+
xpub: "0x7fd6bfaac17c2c763f624b1f95cd4911e3646a5b777b03cc24f93ed0ac3f3e2b",
|
|
23
|
+
freshAddress: "0x4859a161dfe13081cf5a5eac409cd38f707c06176a21ddc875260c2ce63f3a28",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const tokenAccount: AptosSender = {
|
|
27
|
+
xpub: "0xeacada8192f15185637e475d7783e14486e232d8b9978ffa127383847ffc5318",
|
|
28
|
+
freshAddress: "0xb8922507317d85197d70c2bc1afc949c759fd0a62c8841a4300d1e2b63649bf6",
|
|
21
29
|
};
|
|
22
30
|
|
|
23
31
|
describe("lastBlock", () => {
|
|
24
32
|
it("returns the last block information", async () => {
|
|
25
33
|
const lastBlock = await api.lastBlock();
|
|
26
|
-
|
|
27
34
|
expect(lastBlock).toHaveProperty("hash");
|
|
28
35
|
expect(Hex.isValid(lastBlock.hash ?? "").valid).toBeTruthy();
|
|
29
36
|
|
|
30
37
|
expect(lastBlock).toHaveProperty("height");
|
|
31
38
|
expect(lastBlock.height).toBeGreaterThan(0);
|
|
32
39
|
|
|
40
|
+
const time = lastBlock.time as Date;
|
|
41
|
+
|
|
33
42
|
expect(lastBlock).toHaveProperty("time");
|
|
34
|
-
expect(lastBlock.time).
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
37
|
-
expect(
|
|
43
|
+
expect(lastBlock.time).toBeDefined();
|
|
44
|
+
expect(time.getFullYear()).toBeGreaterThan(0);
|
|
45
|
+
expect(time.getMonth() + 1).toBeGreaterThan(0);
|
|
46
|
+
expect(time.getDay() + 1).toBeGreaterThan(0);
|
|
38
47
|
});
|
|
39
48
|
});
|
|
40
49
|
|
|
41
50
|
describe("estimateFees", () => {
|
|
42
|
-
it("returns a
|
|
51
|
+
it("returns fee for a native asset", async () => {
|
|
43
52
|
const amount = BigInt(100);
|
|
44
53
|
|
|
45
54
|
const fees = await api.estimateFees({
|
|
@@ -54,5 +63,339 @@ describe("createApi", () => {
|
|
|
54
63
|
|
|
55
64
|
expect(fees.value).toBeGreaterThanOrEqual(0);
|
|
56
65
|
});
|
|
66
|
+
|
|
67
|
+
it("returns fee for a token coin", async () => {
|
|
68
|
+
const amount = BigInt(100);
|
|
69
|
+
|
|
70
|
+
const fees = await api.estimateFees({
|
|
71
|
+
asset: {
|
|
72
|
+
type: "token",
|
|
73
|
+
standard: "coin",
|
|
74
|
+
contractAddress:
|
|
75
|
+
"0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::usdc_coin::USDCoin",
|
|
76
|
+
},
|
|
77
|
+
type: "send",
|
|
78
|
+
sender,
|
|
79
|
+
amount,
|
|
80
|
+
recipient: recipient.freshAddress,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(fees.value).toBeGreaterThanOrEqual(0);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("returns fee for a token FA", async () => {
|
|
87
|
+
const amount = BigInt(100);
|
|
88
|
+
|
|
89
|
+
const fees = await api.estimateFees({
|
|
90
|
+
asset: {
|
|
91
|
+
type: "token",
|
|
92
|
+
standard: "fungible_asset",
|
|
93
|
+
contractAddress: "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b",
|
|
94
|
+
},
|
|
95
|
+
type: "send",
|
|
96
|
+
sender,
|
|
97
|
+
amount,
|
|
98
|
+
recipient: recipient.freshAddress,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(fees.value).toBeGreaterThanOrEqual(0);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe("craftTransaction", () => {
|
|
106
|
+
it("returns a native coin RawTransaction serialized into an hexadecimal string", async () => {
|
|
107
|
+
const hex = await api.craftTransaction(
|
|
108
|
+
{
|
|
109
|
+
amount: 1n,
|
|
110
|
+
sender: sender,
|
|
111
|
+
recipient: recipient.freshAddress,
|
|
112
|
+
type: "send",
|
|
113
|
+
asset: { type: "native" },
|
|
114
|
+
},
|
|
115
|
+
0n,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const rawTx = RawTransaction.deserialize(
|
|
119
|
+
new Deserializer(Hex.fromHexString(hex).toUint8Array()),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
expect(rawTx.sender.toString()).toBe(sender.freshAddress);
|
|
123
|
+
expect(rawTx.gas_unit_price.toString()).toBe(DEFAULT_GAS_PRICE.toString());
|
|
124
|
+
expect(rawTx.max_gas_amount.toString()).toBe(DEFAULT_GAS.toString());
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("returns a coin token RawTransaction serialized into an hexadecimal string", async () => {
|
|
128
|
+
const hex = await api.craftTransaction(
|
|
129
|
+
{
|
|
130
|
+
amount: 1n,
|
|
131
|
+
sender: sender,
|
|
132
|
+
recipient: recipient.freshAddress,
|
|
133
|
+
type: "send",
|
|
134
|
+
asset: {
|
|
135
|
+
type: "token",
|
|
136
|
+
standard: "coin",
|
|
137
|
+
contractAddress:
|
|
138
|
+
"0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::aptos_coin::AptosCoin",
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
0n,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const rawTx = RawTransaction.deserialize(
|
|
145
|
+
new Deserializer(Hex.fromHexString(hex).toUint8Array()),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect(rawTx.sender.toString()).toBe(sender.freshAddress);
|
|
149
|
+
expect(rawTx.gas_unit_price.toString()).toBe(DEFAULT_GAS_PRICE.toString());
|
|
150
|
+
expect(rawTx.max_gas_amount.toString()).toBe(DEFAULT_GAS.toString());
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("returns a use-all-amount coin token RawTransaction serialized into an hexadecimal string", async () => {
|
|
154
|
+
const hex = await api.craftTransaction(
|
|
155
|
+
{
|
|
156
|
+
amount: 0n,
|
|
157
|
+
sender: sender,
|
|
158
|
+
recipient: recipient.freshAddress,
|
|
159
|
+
type: "send",
|
|
160
|
+
asset: {
|
|
161
|
+
type: "token",
|
|
162
|
+
standard: "coin",
|
|
163
|
+
contractAddress:
|
|
164
|
+
"0x50788befc1107c0cc4473848a92e5c783c635866ce3c98de71d2eeb7d2a34f85::aptos_coin::AptosCoin",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
0n,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const rawTx = RawTransaction.deserialize(
|
|
171
|
+
new Deserializer(Hex.fromHexString(hex).toUint8Array()),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
expect(rawTx.sender.toString()).toBe(sender.freshAddress);
|
|
175
|
+
expect(rawTx.gas_unit_price.toString()).toBe(DEFAULT_GAS_PRICE.toString());
|
|
176
|
+
expect(rawTx.max_gas_amount.toString()).toBe(DEFAULT_GAS.toString());
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("returns a use-all-amount fungible_asset token RawTransaction serialized into an hexadecimal string", async () => {
|
|
180
|
+
const r = sender;
|
|
181
|
+
const s = recipient; // recipient contains fungible_assets balances
|
|
182
|
+
const hex = await api.craftTransaction(
|
|
183
|
+
{
|
|
184
|
+
amount: 0n,
|
|
185
|
+
sender: s,
|
|
186
|
+
recipient: r.freshAddress,
|
|
187
|
+
type: "send",
|
|
188
|
+
asset: {
|
|
189
|
+
type: "token",
|
|
190
|
+
standard: "fungible_asset",
|
|
191
|
+
contractAddress: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
0n,
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const rawTx = RawTransaction.deserialize(
|
|
198
|
+
new Deserializer(Hex.fromHexString(hex).toUint8Array()),
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
expect(rawTx.sender.toString()).toBe(s.freshAddress);
|
|
202
|
+
expect(rawTx.gas_unit_price.toString()).toBe(DEFAULT_GAS_PRICE.toString());
|
|
203
|
+
expect(rawTx.max_gas_amount.toString()).toBe(DEFAULT_GAS.toString());
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe("getBalance", () => {
|
|
208
|
+
it("return balances from account", async () => {
|
|
209
|
+
const balances = await api.getBalance(sender.freshAddress);
|
|
210
|
+
|
|
211
|
+
expect(balances.length).toBeGreaterThan(0);
|
|
212
|
+
expect(balances[0].value).toBeGreaterThanOrEqual(0);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe("listOperations", () => {
|
|
217
|
+
it("returns operations from account", async () => {
|
|
218
|
+
const block = await api.lastBlock();
|
|
219
|
+
|
|
220
|
+
const [operations] = await api.listOperations(sender.freshAddress, {
|
|
221
|
+
minHeight: block.height,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
expect(operations).toBeInstanceOf(Array);
|
|
225
|
+
expect(operations.length).toBeGreaterThanOrEqual(2);
|
|
226
|
+
|
|
227
|
+
const txINHash = "0xe1987b67878faff326a179d59ab0f5df89cc10cdcbccab1147b52735579832a5";
|
|
228
|
+
const txOUTHash = "0xee3866ab35797a39102aeff6bdeb70d3d4df65adedf9efedfddad88f27dc6fa4";
|
|
229
|
+
|
|
230
|
+
const operationIN = operations.find(operation => operation.id === txINHash);
|
|
231
|
+
const operationOUT = operations.find(operation => operation.id === txOUTHash);
|
|
232
|
+
|
|
233
|
+
expect(operationIN).toMatchObject({
|
|
234
|
+
type: "IN",
|
|
235
|
+
value: 11000000n,
|
|
236
|
+
recipients: [sender.freshAddress],
|
|
237
|
+
senders: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
238
|
+
asset: { type: "native" },
|
|
239
|
+
tx: {
|
|
240
|
+
hash: "0xe1987b67878faff326a179d59ab0f5df89cc10cdcbccab1147b52735579832a5",
|
|
241
|
+
block: { height: 0 },
|
|
242
|
+
fees: 99900n,
|
|
243
|
+
date: new Date("2025-05-29T13:16:30.763Z"),
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
expect(operationOUT).toMatchObject({
|
|
248
|
+
type: "OUT",
|
|
249
|
+
value: 2000000n,
|
|
250
|
+
recipients: ["0x4859a161dfe13081cf5a5eac409cd38f707c06176a21ddc875260c2ce63f3a28"],
|
|
251
|
+
senders: [sender.freshAddress],
|
|
252
|
+
asset: { type: "native" },
|
|
253
|
+
tx: {
|
|
254
|
+
hash: "0xee3866ab35797a39102aeff6bdeb70d3d4df65adedf9efedfddad88f27dc6fa4",
|
|
255
|
+
block: { height: 0 },
|
|
256
|
+
fees: 1100n,
|
|
257
|
+
date: new Date("2025-05-29T13:39:28.702Z"),
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe("listOperationsTokens", () => {
|
|
264
|
+
it("returns operations from account", async () => {
|
|
265
|
+
const block = await api.lastBlock();
|
|
266
|
+
|
|
267
|
+
const [operations] = await api.listOperations(tokenAccount.freshAddress, {
|
|
268
|
+
minHeight: block.height,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
expect(operations).toBeInstanceOf(Array);
|
|
272
|
+
expect(operations.length).toBeGreaterThanOrEqual(1);
|
|
273
|
+
|
|
274
|
+
const txINNativeHash = "0xd841b502ce333e5b9ac394db81e6597d9bbbe475e5b12966b98b843d91cc0a09";
|
|
275
|
+
const txOUTNativeHash = "0xb1114396c5b6f2f5ba955fa8e4102d0e3983d5ccdb0717ff792f6e4848e72366";
|
|
276
|
+
|
|
277
|
+
const txINLegacyCoinHash =
|
|
278
|
+
"0x6869c933396d976af85b273a825fe264a910d0064fe28ce97285073b9e5306bb";
|
|
279
|
+
const txOUTLegacyCoinHash =
|
|
280
|
+
"0xa720db7fe6327b1db23e778df5856ab1d8785d7e8edae98941a3f6e05fa58ddd";
|
|
281
|
+
|
|
282
|
+
const txINFungibleAssetHash =
|
|
283
|
+
"0x88856968603dee4f08579036bc30322b9a5f329561656888e3467ce27cc11ea7";
|
|
284
|
+
const txOUTFungibleAssetHash =
|
|
285
|
+
"0x8aa9e980760fe8aeb6804f387350b3019a2471aa61a5506a260c32cd5d6db32c";
|
|
286
|
+
|
|
287
|
+
const operationIN = operations.find(operation => operation.id === txINNativeHash);
|
|
288
|
+
const operationOUT = operations.find(operation => operation.id === txOUTNativeHash);
|
|
289
|
+
|
|
290
|
+
expect(operationIN).toMatchObject({
|
|
291
|
+
type: "IN",
|
|
292
|
+
value: 1000000n,
|
|
293
|
+
recipients: [tokenAccount.freshAddress],
|
|
294
|
+
senders: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
295
|
+
asset: { type: "native" },
|
|
296
|
+
tx: {
|
|
297
|
+
hash: "0xd841b502ce333e5b9ac394db81e6597d9bbbe475e5b12966b98b843d91cc0a09",
|
|
298
|
+
block: { height: 0 },
|
|
299
|
+
fees: 99900n,
|
|
300
|
+
date: new Date("2025-05-29T18:32:11.515Z"),
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
expect(operationOUT).toMatchObject({
|
|
305
|
+
type: "OUT",
|
|
306
|
+
value: 951100n,
|
|
307
|
+
recipients: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
308
|
+
senders: [tokenAccount.freshAddress],
|
|
309
|
+
asset: { type: "native" },
|
|
310
|
+
tx: {
|
|
311
|
+
hash: "0xb1114396c5b6f2f5ba955fa8e4102d0e3983d5ccdb0717ff792f6e4848e72366",
|
|
312
|
+
block: { height: 0 },
|
|
313
|
+
fees: 1100n,
|
|
314
|
+
date: new Date("2025-05-29T18:39:57.864Z"),
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
const coinIN = operations.find(operation => operation.id === txINLegacyCoinHash);
|
|
319
|
+
const coinOUT = operations.find(operation => operation.id === txOUTLegacyCoinHash);
|
|
320
|
+
|
|
321
|
+
expect(coinIN).toMatchObject({
|
|
322
|
+
type: "IN",
|
|
323
|
+
value: 2000000n,
|
|
324
|
+
recipients: [tokenAccount.freshAddress],
|
|
325
|
+
senders: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
326
|
+
asset: {
|
|
327
|
+
type: "token",
|
|
328
|
+
standard: "coin",
|
|
329
|
+
contractAddress:
|
|
330
|
+
"0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::StakedAptos",
|
|
331
|
+
},
|
|
332
|
+
tx: {
|
|
333
|
+
hash: "0x6869c933396d976af85b273a825fe264a910d0064fe28ce97285073b9e5306bb",
|
|
334
|
+
block: { height: 0 },
|
|
335
|
+
fees: 51100n,
|
|
336
|
+
date: new Date("2025-05-29T18:32:58.804Z"),
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
expect(coinOUT).toMatchObject({
|
|
341
|
+
type: "OUT",
|
|
342
|
+
value: 1000000n,
|
|
343
|
+
recipients: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
344
|
+
senders: [tokenAccount.freshAddress],
|
|
345
|
+
asset: {
|
|
346
|
+
type: "token",
|
|
347
|
+
standard: "coin",
|
|
348
|
+
contractAddress:
|
|
349
|
+
"0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::StakedAptos",
|
|
350
|
+
},
|
|
351
|
+
tx: {
|
|
352
|
+
hash: "0xa720db7fe6327b1db23e778df5856ab1d8785d7e8edae98941a3f6e05fa58ddd",
|
|
353
|
+
block: { height: 0 },
|
|
354
|
+
fees: 1200n,
|
|
355
|
+
date: new Date("2025-05-29T18:38:08.283Z"),
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
const fungibleAssetIN = operations.find(operation => operation.id === txINFungibleAssetHash);
|
|
360
|
+
const fungibleAssetOUT = operations.find(
|
|
361
|
+
operation => operation.id === txOUTFungibleAssetHash,
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
expect(fungibleAssetIN).toMatchObject({
|
|
365
|
+
type: "IN",
|
|
366
|
+
value: 1750n,
|
|
367
|
+
recipients: [tokenAccount.freshAddress],
|
|
368
|
+
senders: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
369
|
+
asset: {
|
|
370
|
+
type: "token",
|
|
371
|
+
standard: "fungible_asset",
|
|
372
|
+
contractAddress: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
|
|
373
|
+
},
|
|
374
|
+
tx: {
|
|
375
|
+
hash: "0x88856968603dee4f08579036bc30322b9a5f329561656888e3467ce27cc11ea7",
|
|
376
|
+
block: { height: 0 },
|
|
377
|
+
fees: 54300n,
|
|
378
|
+
date: new Date("2025-05-29T18:33:58.097Z"),
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
expect(fungibleAssetOUT).toMatchObject({
|
|
383
|
+
type: "OUT",
|
|
384
|
+
value: 1000n,
|
|
385
|
+
recipients: ["0x24dbf71ba20209753035505c51d4607ed67aa0c81b930d9ef4483ec84b349fcb"],
|
|
386
|
+
senders: [tokenAccount.freshAddress],
|
|
387
|
+
asset: {
|
|
388
|
+
type: "token",
|
|
389
|
+
standard: "fungible_asset",
|
|
390
|
+
contractAddress: "0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
|
|
391
|
+
},
|
|
392
|
+
tx: {
|
|
393
|
+
hash: "0x8aa9e980760fe8aeb6804f387350b3019a2471aa61a5506a260c32cd5d6db32c",
|
|
394
|
+
block: { height: 0 },
|
|
395
|
+
fees: 1000n,
|
|
396
|
+
date: new Date("2025-05-29T18:38:56.897Z"),
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
});
|
|
57
400
|
});
|
|
58
401
|
});
|