@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
|
@@ -13,20 +13,16 @@ const generateTransaction = jest.fn(() => "tx");
|
|
|
13
13
|
|
|
14
14
|
jest.mock("../../network/client", () => {
|
|
15
15
|
return {
|
|
16
|
-
AptosAPI:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
},
|
|
16
|
+
AptosAPI: () => ({
|
|
17
|
+
generateTransaction,
|
|
18
|
+
}),
|
|
21
19
|
};
|
|
22
20
|
});
|
|
23
21
|
|
|
24
|
-
jest.mock("../../
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
};
|
|
22
|
+
jest.mock("../../logic/buildTransaction", () => {
|
|
23
|
+
return () => ({
|
|
24
|
+
sequence_number: "789",
|
|
25
|
+
});
|
|
30
26
|
});
|
|
31
27
|
|
|
32
28
|
jest.mock("../../network");
|
|
@@ -12,7 +12,7 @@ jest.mock("../types", () => jest.fn());
|
|
|
12
12
|
jest.mock("../bridge/getTransactionStatus", () => jest.fn());
|
|
13
13
|
jest.mock("../bridge/estimateMaxSpendable", () => jest.fn());
|
|
14
14
|
jest.mock("../bridge/prepareTransaction", () => jest.fn());
|
|
15
|
-
jest.mock("../
|
|
15
|
+
jest.mock("../logic/createTransaction", () => jest.fn());
|
|
16
16
|
jest.mock("../bridge/synchronisation", () => jest.fn());
|
|
17
17
|
jest.mock("../bridge/signOperation", () => jest.fn());
|
|
18
18
|
jest.mock("../bridge/broadcast", () => jest.fn());
|
|
@@ -4,23 +4,30 @@ import {
|
|
|
4
4
|
createFixtureTransaction,
|
|
5
5
|
createFixtureTransactionWithSubAccount,
|
|
6
6
|
} from "../../bridge/bridge.fixture";
|
|
7
|
-
import buildTransaction from "../../
|
|
7
|
+
import buildTransaction from "../../logic/buildTransaction";
|
|
8
8
|
import { AptosAPI } from "../../network";
|
|
9
|
-
import { normalizeTransactionOptions } from "../../
|
|
10
|
-
import { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
|
|
11
|
-
import { TransactionOptions } from "../../types";
|
|
9
|
+
import { normalizeTransactionOptions } from "../../logic/normalizeTransactionOptions";
|
|
10
|
+
import type { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
|
|
11
|
+
import type { TransactionOptions } from "../../types";
|
|
12
12
|
|
|
13
13
|
const generateTransaction = jest.fn(() => "tx");
|
|
14
14
|
|
|
15
|
-
jest.mock("../../
|
|
15
|
+
jest.mock("../../logic/normalizeTransactionOptions", () => ({
|
|
16
16
|
normalizeTransactionOptions: jest.fn(() => ({
|
|
17
17
|
maxGasAmount: "100",
|
|
18
18
|
gasUnitPrice: "200",
|
|
19
19
|
})),
|
|
20
|
-
DEFAULT_GAS: 100,
|
|
21
|
-
DEFAULT_GAS_PRICE: 200,
|
|
22
20
|
}));
|
|
23
21
|
|
|
22
|
+
jest.mock("../../constants", () => {
|
|
23
|
+
const originalModules = jest.requireActual("../../constants");
|
|
24
|
+
return {
|
|
25
|
+
...originalModules,
|
|
26
|
+
DEFAULT_GAS: 100,
|
|
27
|
+
DEFAULT_GAS_PRICE: 200,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
24
31
|
jest.mock("../../network", () => {
|
|
25
32
|
return {
|
|
26
33
|
AptosAPI: function () {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { calculateAmount } from "../../logic/calculateAmount";
|
|
3
|
+
|
|
4
|
+
describe("calculateAmount", () => {
|
|
5
|
+
it("should calculate the correct amount when the address is the sender", () => {
|
|
6
|
+
const address = "0x11";
|
|
7
|
+
const sender = "0x11";
|
|
8
|
+
const amount_in = new BigNumber(50);
|
|
9
|
+
const amount_out = new BigNumber(100);
|
|
10
|
+
|
|
11
|
+
const result = calculateAmount(sender, address, amount_in, amount_out);
|
|
12
|
+
|
|
13
|
+
// LL negates the amount for SEND transactions during output
|
|
14
|
+
expect(result).toEqual(new BigNumber(50)); // -(50 - 100 - 10)
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should calculate the correct amount when the address is not the sender", () => {
|
|
18
|
+
const address = "0x11";
|
|
19
|
+
const sender = "0x12";
|
|
20
|
+
const amount_in = new BigNumber(100);
|
|
21
|
+
const amount_out = new BigNumber(50);
|
|
22
|
+
|
|
23
|
+
const result = calculateAmount(sender, address, amount_in, amount_out);
|
|
24
|
+
|
|
25
|
+
expect(result).toEqual(new BigNumber(50)); // 100 - 50
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should handle transactions with zero amounts", () => {
|
|
29
|
+
const address = "0x11";
|
|
30
|
+
const sender = "0x11";
|
|
31
|
+
const amount_in = new BigNumber(0);
|
|
32
|
+
const amount_out = new BigNumber(0);
|
|
33
|
+
|
|
34
|
+
const result = calculateAmount(sender, address, amount_in, amount_out);
|
|
35
|
+
|
|
36
|
+
// LL negates the amount for SEND transactions during output
|
|
37
|
+
expect(result).toEqual(new BigNumber(0)); // -(0 - 0 - 10)
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should get negative numbers (for send tx with deposit to account)", () => {
|
|
41
|
+
const address = "0x11";
|
|
42
|
+
const sender = "0x11";
|
|
43
|
+
const amount_in = new BigNumber(100);
|
|
44
|
+
const amount_out = new BigNumber(0);
|
|
45
|
+
|
|
46
|
+
const result = calculateAmount(sender, address, amount_in, amount_out);
|
|
47
|
+
|
|
48
|
+
// LL negates the amount for SEND transactions during output
|
|
49
|
+
expect(result).toEqual(new BigNumber(100).negated()); // 100 - 10
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createFixtureAccount } from "../../bridge/bridge.fixture";
|
|
2
|
+
import { Hex, generateSignedTransaction } from "@aptos-labs/ts-sdk";
|
|
3
|
+
import { combine } from "../../logic/combine";
|
|
4
|
+
|
|
5
|
+
const hexRawTx =
|
|
6
|
+
"0xfdde1012c0fac1f9a121eb3c8481c90d473df1c4180c070bd4f2549a6d06180400000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e736665720002203f5f0fcc8a909f23806e5efbdc1757e653fcd744de516a7de12b99b8417925c1080a00000000000000400d03000000000064000000000000002c721b6800000000b7";
|
|
7
|
+
|
|
8
|
+
jest.mock("@aptos-labs/ts-sdk", () => {
|
|
9
|
+
const originalModule = jest.requireActual("@aptos-labs/ts-sdk");
|
|
10
|
+
return {
|
|
11
|
+
...originalModule,
|
|
12
|
+
generateSignedTransaction: jest
|
|
13
|
+
.fn()
|
|
14
|
+
.mockImplementation(() => Hex.fromHexString(hexRawTx).toUint8Array()),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("combine", () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
jest.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should throws an error when no public key is provided", async () => {
|
|
24
|
+
const account = createFixtureAccount();
|
|
25
|
+
const signature = "0x7aa193705193f4";
|
|
26
|
+
|
|
27
|
+
expect(() => combine(hexRawTx, signature, account.xpub)).toThrow(
|
|
28
|
+
"account must have a public key",
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(generateSignedTransaction).not.toHaveBeenCalled();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should throws an error when no valid hex value is provided for signature", async () => {
|
|
35
|
+
const account = createFixtureAccount();
|
|
36
|
+
const signature = "signature";
|
|
37
|
+
|
|
38
|
+
expect(() => combine(hexRawTx, signature, account.xpub)).toThrow(
|
|
39
|
+
"signature must be a valid hex value",
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(generateSignedTransaction).not.toHaveBeenCalled();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should throws an error when no valid hex value is provided for tx", async () => {
|
|
46
|
+
const account = createFixtureAccount();
|
|
47
|
+
const signature = "0x7aa193705193f4";
|
|
48
|
+
|
|
49
|
+
expect(() => combine("tx", signature, account.xpub)).toThrow("tx must be a valid hex value");
|
|
50
|
+
|
|
51
|
+
expect(generateSignedTransaction).not.toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should sign a transaction", async () => {
|
|
55
|
+
const signature =
|
|
56
|
+
"0xbcdf10dc816488eca24b108056e2109220542f599caa4d81ac54556d63a777636ded8cafe972f68657bbee176f398cf332030df0f1dc2235f8f3d39456a5b90c";
|
|
57
|
+
const account = createFixtureAccount();
|
|
58
|
+
account.xpub = "0xb69a68cc64f7aa193705193f4dd598320a0a74baf7e4b50c9980c5bd60a82390";
|
|
59
|
+
|
|
60
|
+
const result = combine(hexRawTx, signature, account.xpub);
|
|
61
|
+
|
|
62
|
+
expect(generateSignedTransaction).toHaveBeenCalledTimes(1);
|
|
63
|
+
expect(result).not.toBe("");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { compareAddress } from "../../logic/getCoinAndAmounts";
|
|
2
|
+
|
|
3
|
+
describe("compareAddress", () => {
|
|
4
|
+
it("should return true for identical addresses", () => {
|
|
5
|
+
const addressA = "0x1234567890abcdef";
|
|
6
|
+
const addressB = "0x1234567890abcdef";
|
|
7
|
+
expect(compareAddress(addressA, addressB)).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should return true for addresses with different cases", () => {
|
|
11
|
+
const addressA = "0x1234567890abcdef";
|
|
12
|
+
const addressB = "0x1234567890ABCDEF";
|
|
13
|
+
expect(compareAddress(addressA, addressB)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should return true for addresses with different hex formats", () => {
|
|
17
|
+
const addressA = "0x1234567890abcdef";
|
|
18
|
+
const addressB = "1234567890abcdef";
|
|
19
|
+
expect(compareAddress(addressA, addressB)).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should return false for different addresses", () => {
|
|
23
|
+
const addressA = "0x1234567890abcdef";
|
|
24
|
+
const addressB = "0xfedcba0987654321";
|
|
25
|
+
expect(compareAddress(addressA, addressB)).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { AptosTransaction } from "../../types";
|
|
3
|
+
import { getCoinAndAmounts } from "../../logic/getCoinAndAmounts";
|
|
4
|
+
import {
|
|
5
|
+
APTOS_ASSET_ID,
|
|
6
|
+
APTOS_COIN_CHANGE,
|
|
7
|
+
APTOS_FUNGIBLE_STORE,
|
|
8
|
+
APTOS_OBJECT_CORE,
|
|
9
|
+
} from "../../constants";
|
|
10
|
+
|
|
11
|
+
describe("getCoinAndAmounts", () => {
|
|
12
|
+
it("should calculate the correct legacy coins amounts for withdraw and deposit events", () => {
|
|
13
|
+
const tx = {
|
|
14
|
+
events: [
|
|
15
|
+
{
|
|
16
|
+
type: "0x1::coin::WithdrawEvent",
|
|
17
|
+
guid: {
|
|
18
|
+
account_address: "0x11",
|
|
19
|
+
creation_number: "1",
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
amount: "100",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "0x1::coin::DepositEvent",
|
|
27
|
+
guid: {
|
|
28
|
+
account_address: "0x11",
|
|
29
|
+
creation_number: "2",
|
|
30
|
+
},
|
|
31
|
+
data: {
|
|
32
|
+
amount: "50",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
changes: [
|
|
37
|
+
{
|
|
38
|
+
type: "write_resource",
|
|
39
|
+
data: {
|
|
40
|
+
type: APTOS_COIN_CHANGE,
|
|
41
|
+
data: {
|
|
42
|
+
withdraw_events: {
|
|
43
|
+
guid: {
|
|
44
|
+
id: {
|
|
45
|
+
addr: "0x11",
|
|
46
|
+
creation_num: "1",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
deposit_events: {
|
|
51
|
+
guid: {
|
|
52
|
+
id: {
|
|
53
|
+
addr: "0x11",
|
|
54
|
+
creation_num: "2",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
} as unknown as AptosTransaction;
|
|
63
|
+
|
|
64
|
+
const address = "0x11";
|
|
65
|
+
const result = getCoinAndAmounts(tx, address);
|
|
66
|
+
|
|
67
|
+
expect(result.amount_in).toEqual(new BigNumber(50));
|
|
68
|
+
expect(result.amount_out).toEqual(new BigNumber(100));
|
|
69
|
+
expect(result.coin_id).toEqual(APTOS_ASSET_ID);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should calculate the correct fungible asset amounts for withdraw and deposit events", () => {
|
|
73
|
+
const tx = {
|
|
74
|
+
events: [
|
|
75
|
+
{
|
|
76
|
+
type: "0x1::fungible_asset::Withdraw",
|
|
77
|
+
guid: {
|
|
78
|
+
account_address: "0x11",
|
|
79
|
+
creation_number: "1",
|
|
80
|
+
},
|
|
81
|
+
data: {
|
|
82
|
+
amount: "100",
|
|
83
|
+
store: "0x22",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "0x1::fungible_asset::Deposit",
|
|
88
|
+
guid: {
|
|
89
|
+
account_address: "0x11",
|
|
90
|
+
creation_number: "2",
|
|
91
|
+
},
|
|
92
|
+
data: {
|
|
93
|
+
amount: "50",
|
|
94
|
+
store: "0x33",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
changes: [
|
|
99
|
+
{
|
|
100
|
+
type: "write_resource",
|
|
101
|
+
address: "0x22",
|
|
102
|
+
data: {
|
|
103
|
+
type: APTOS_FUNGIBLE_STORE,
|
|
104
|
+
data: {
|
|
105
|
+
metadata: {
|
|
106
|
+
inner: "0x44",
|
|
107
|
+
},
|
|
108
|
+
transfer_events: {
|
|
109
|
+
guid: {
|
|
110
|
+
id: {
|
|
111
|
+
addr: "0x11",
|
|
112
|
+
creation_num: "2",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: "write_resource",
|
|
121
|
+
address: "0x22",
|
|
122
|
+
data: {
|
|
123
|
+
type: APTOS_OBJECT_CORE,
|
|
124
|
+
data: {
|
|
125
|
+
owner: "0x11",
|
|
126
|
+
transfer_events: {
|
|
127
|
+
guid: {
|
|
128
|
+
id: {
|
|
129
|
+
addr: "0x22",
|
|
130
|
+
creation_num: "2",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: "write_resource",
|
|
139
|
+
data: {
|
|
140
|
+
type: APTOS_COIN_CHANGE,
|
|
141
|
+
data: {
|
|
142
|
+
withdraw_events: {
|
|
143
|
+
guid: {
|
|
144
|
+
id: {
|
|
145
|
+
addr: "0x11",
|
|
146
|
+
creation_num: "1",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
deposit_events: {
|
|
151
|
+
guid: {
|
|
152
|
+
id: {
|
|
153
|
+
addr: "0x11",
|
|
154
|
+
creation_num: "2",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
} as unknown as AptosTransaction;
|
|
163
|
+
|
|
164
|
+
const address = "0x11";
|
|
165
|
+
const result = getCoinAndAmounts(tx, address);
|
|
166
|
+
|
|
167
|
+
expect(result.amount_in).toEqual(new BigNumber(0));
|
|
168
|
+
expect(result.amount_out).toEqual(new BigNumber(100));
|
|
169
|
+
expect(result.coin_id).toEqual("0x44");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("should handle transactions with other events", () => {
|
|
173
|
+
const tx = {
|
|
174
|
+
events: [
|
|
175
|
+
{
|
|
176
|
+
type: "0x1::coin::OtherEvent",
|
|
177
|
+
guid: {
|
|
178
|
+
account_address: "0x11",
|
|
179
|
+
creation_number: "1",
|
|
180
|
+
},
|
|
181
|
+
data: {
|
|
182
|
+
amount: "100",
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
} as unknown as AptosTransaction;
|
|
187
|
+
|
|
188
|
+
const address = "0x1";
|
|
189
|
+
const result = getCoinAndAmounts(tx, address);
|
|
190
|
+
|
|
191
|
+
expect(result.amount_in).toEqual(new BigNumber(0));
|
|
192
|
+
expect(result.amount_out).toEqual(new BigNumber(0));
|
|
193
|
+
expect(result.coin_id).toEqual(null);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { getFunctionAddress } from "../../logic/getFunctionAddress";
|
|
3
|
+
|
|
4
|
+
describe("getFunctionAddress", () => {
|
|
5
|
+
it("should return the function address when payload contains a function", () => {
|
|
6
|
+
const payload: InputEntryFunctionData = {
|
|
7
|
+
function: "0x1::coin::transfer",
|
|
8
|
+
typeArguments: [],
|
|
9
|
+
functionArguments: [],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const result = getFunctionAddress(payload);
|
|
13
|
+
expect(result).toBe("0x1");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should return undefined when payload does not contain a function", () => {
|
|
17
|
+
const payload = {
|
|
18
|
+
function: "::::",
|
|
19
|
+
typeArguments: [],
|
|
20
|
+
functionArguments: [],
|
|
21
|
+
} as InputEntryFunctionData;
|
|
22
|
+
|
|
23
|
+
const result = getFunctionAddress(payload);
|
|
24
|
+
expect(result).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should return undefined when payload is empty", () => {
|
|
28
|
+
const payload = {} as InputEntryFunctionData;
|
|
29
|
+
|
|
30
|
+
const result = getFunctionAddress(payload);
|
|
31
|
+
expect(result).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { WriteSetChange, Event } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { AptosTransaction } from "../../types";
|
|
3
|
+
import { getResourceAddress } from "../../logic/getResourceAddress";
|
|
4
|
+
import { APTOS_ASSET_ID, APTOS_COIN_CHANGE, APTOS_FUNGIBLE_STORE } from "../../constants";
|
|
5
|
+
import { getEventCoinAddress, getEventFAAddress } from "../../logic/getCoinAndAmounts";
|
|
6
|
+
|
|
7
|
+
describe("getResourceAddress", () => {
|
|
8
|
+
it("should return coin name from the change", () => {
|
|
9
|
+
const change = {
|
|
10
|
+
type: "write_resource",
|
|
11
|
+
data: {
|
|
12
|
+
type: APTOS_COIN_CHANGE,
|
|
13
|
+
data: {
|
|
14
|
+
withdraw_events: {
|
|
15
|
+
guid: {
|
|
16
|
+
id: {
|
|
17
|
+
addr: "0x11",
|
|
18
|
+
creation_num: "2",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
} as unknown as WriteSetChange;
|
|
25
|
+
|
|
26
|
+
const tx: AptosTransaction = {
|
|
27
|
+
hash: "0x123",
|
|
28
|
+
block: { hash: "0xabc", height: 1 },
|
|
29
|
+
timestamp: "1000000",
|
|
30
|
+
sequence_number: "1",
|
|
31
|
+
version: "1",
|
|
32
|
+
changes: [change],
|
|
33
|
+
} as unknown as AptosTransaction;
|
|
34
|
+
|
|
35
|
+
const event = {
|
|
36
|
+
guid: {
|
|
37
|
+
account_address: "0x11",
|
|
38
|
+
creation_number: "2",
|
|
39
|
+
},
|
|
40
|
+
type: "0x1::coin::WithdrawEvent",
|
|
41
|
+
} as Event;
|
|
42
|
+
|
|
43
|
+
const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
|
|
44
|
+
expect(result).toEqual(APTOS_ASSET_ID);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should return null for not finding the valid coin in change", () => {
|
|
48
|
+
const change = {
|
|
49
|
+
type: "write_resource",
|
|
50
|
+
data: {
|
|
51
|
+
type: APTOS_COIN_CHANGE,
|
|
52
|
+
data: {
|
|
53
|
+
withdraw_events: {
|
|
54
|
+
guid: {
|
|
55
|
+
id: {
|
|
56
|
+
addr: "0x12",
|
|
57
|
+
creation_num: "2",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
} as unknown as WriteSetChange;
|
|
64
|
+
|
|
65
|
+
const tx: AptosTransaction = {
|
|
66
|
+
hash: "0x123",
|
|
67
|
+
block: { hash: "0xabc", height: 1 },
|
|
68
|
+
timestamp: "1000000",
|
|
69
|
+
sequence_number: "1",
|
|
70
|
+
version: "1",
|
|
71
|
+
changes: [change],
|
|
72
|
+
} as unknown as AptosTransaction;
|
|
73
|
+
|
|
74
|
+
const event = {
|
|
75
|
+
guid: {
|
|
76
|
+
account_address: "0x11",
|
|
77
|
+
creation_number: "1",
|
|
78
|
+
},
|
|
79
|
+
type: "0x1::coin::WithdrawEvent",
|
|
80
|
+
} as Event;
|
|
81
|
+
|
|
82
|
+
const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
|
|
83
|
+
expect(result).toBe(null);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("should return null for not finding the event name in change", () => {
|
|
87
|
+
const change = {
|
|
88
|
+
type: "write_resource",
|
|
89
|
+
data: {
|
|
90
|
+
type: APTOS_COIN_CHANGE,
|
|
91
|
+
data: {
|
|
92
|
+
other_events: {
|
|
93
|
+
guid: {
|
|
94
|
+
id: {
|
|
95
|
+
addr: "0x12",
|
|
96
|
+
creation_num: "2",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
} as unknown as WriteSetChange;
|
|
103
|
+
|
|
104
|
+
const tx: AptosTransaction = {
|
|
105
|
+
hash: "0x123",
|
|
106
|
+
block: { hash: "0xabc", height: 1 },
|
|
107
|
+
timestamp: "1000000",
|
|
108
|
+
sequence_number: "1",
|
|
109
|
+
version: "1",
|
|
110
|
+
changes: [change],
|
|
111
|
+
} as unknown as AptosTransaction;
|
|
112
|
+
|
|
113
|
+
const event = {
|
|
114
|
+
guid: {
|
|
115
|
+
account_address: "0x11",
|
|
116
|
+
creation_number: "1",
|
|
117
|
+
},
|
|
118
|
+
type: "0x1::coin::WithdrawEvent",
|
|
119
|
+
} as Event;
|
|
120
|
+
|
|
121
|
+
const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
|
|
122
|
+
expect(result).toBe(null);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("should return fungible asset address", () => {
|
|
126
|
+
const change = {
|
|
127
|
+
type: "write_resource",
|
|
128
|
+
address: "0xsomeaddress",
|
|
129
|
+
data: {
|
|
130
|
+
type: APTOS_FUNGIBLE_STORE,
|
|
131
|
+
data: {
|
|
132
|
+
metadata: {
|
|
133
|
+
inner: "0xassetaddress",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
} as unknown as WriteSetChange;
|
|
138
|
+
|
|
139
|
+
const tx: AptosTransaction = {
|
|
140
|
+
hash: "0x123",
|
|
141
|
+
block: { hash: "0xabc", height: 1 },
|
|
142
|
+
timestamp: "1000000",
|
|
143
|
+
sequence_number: "1",
|
|
144
|
+
version: "1",
|
|
145
|
+
changes: [change],
|
|
146
|
+
} as unknown as AptosTransaction;
|
|
147
|
+
|
|
148
|
+
const event = {
|
|
149
|
+
guid: {
|
|
150
|
+
account_address: "0x0",
|
|
151
|
+
creation_number: "0",
|
|
152
|
+
},
|
|
153
|
+
type: "0x1::fungible_asset::Deposit",
|
|
154
|
+
data: {
|
|
155
|
+
amount: "100",
|
|
156
|
+
store: "0xsomeaddress",
|
|
157
|
+
},
|
|
158
|
+
} as Event;
|
|
159
|
+
|
|
160
|
+
const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
|
|
161
|
+
expect(result).toEqual("0xassetaddress");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("should return null address instead of fungible asset when wrong type", () => {
|
|
165
|
+
const change = {
|
|
166
|
+
type: "write_resource",
|
|
167
|
+
address: "0xsomeaddress",
|
|
168
|
+
data: {
|
|
169
|
+
type: APTOS_COIN_CHANGE,
|
|
170
|
+
data: {
|
|
171
|
+
metadata: {
|
|
172
|
+
inner: "0xassetaddress",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
} as unknown as WriteSetChange;
|
|
177
|
+
|
|
178
|
+
const tx: AptosTransaction = {
|
|
179
|
+
hash: "0x123",
|
|
180
|
+
block: { hash: "0xabc", height: 1 },
|
|
181
|
+
timestamp: "1000000",
|
|
182
|
+
sequence_number: "1",
|
|
183
|
+
version: "1",
|
|
184
|
+
changes: [change],
|
|
185
|
+
} as unknown as AptosTransaction;
|
|
186
|
+
|
|
187
|
+
const event = {
|
|
188
|
+
guid: {
|
|
189
|
+
account_address: "0x0",
|
|
190
|
+
creation_number: "0",
|
|
191
|
+
},
|
|
192
|
+
type: "0x1::fungible_asset::Deposit",
|
|
193
|
+
data: {
|
|
194
|
+
amount: "100",
|
|
195
|
+
store: "0xsomeaddress",
|
|
196
|
+
},
|
|
197
|
+
} as Event;
|
|
198
|
+
|
|
199
|
+
const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
|
|
200
|
+
expect(result).toEqual(null);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should return null address instead of fungible asset when wrong event address", () => {
|
|
204
|
+
const change = {
|
|
205
|
+
type: "write_resource",
|
|
206
|
+
address: "0xsomeaddress",
|
|
207
|
+
data: {
|
|
208
|
+
type: APTOS_FUNGIBLE_STORE,
|
|
209
|
+
data: {
|
|
210
|
+
metadata: {
|
|
211
|
+
inner: "0xassetaddress",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
} as unknown as WriteSetChange;
|
|
216
|
+
|
|
217
|
+
const tx: AptosTransaction = {
|
|
218
|
+
hash: "0x123",
|
|
219
|
+
block: { hash: "0xabc", height: 1 },
|
|
220
|
+
timestamp: "1000000",
|
|
221
|
+
sequence_number: "1",
|
|
222
|
+
version: "1",
|
|
223
|
+
changes: [change],
|
|
224
|
+
} as unknown as AptosTransaction;
|
|
225
|
+
|
|
226
|
+
const event = {
|
|
227
|
+
guid: {
|
|
228
|
+
account_address: "0x0",
|
|
229
|
+
creation_number: "0",
|
|
230
|
+
},
|
|
231
|
+
type: "0x1::fungible_asset::Deposit",
|
|
232
|
+
data: {
|
|
233
|
+
amount: "100",
|
|
234
|
+
store: "0xwrongaddress",
|
|
235
|
+
},
|
|
236
|
+
} as Event;
|
|
237
|
+
|
|
238
|
+
const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
|
|
239
|
+
expect(result).toEqual(null);
|
|
240
|
+
});
|
|
241
|
+
});
|