@ledgerhq/coin-aptos 1.4.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +16 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/__tests__/api/index.test.d.ts +2 -0
- package/lib/__tests__/api/index.test.d.ts.map +1 -0
- package/lib/__tests__/api/index.test.js +447 -0
- package/lib/__tests__/api/index.test.js.map +1 -0
- package/lib/__tests__/bridge/broadcast.test.d.ts +2 -0
- package/lib/__tests__/bridge/broadcast.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/broadcast.test.js +98 -0
- package/lib/__tests__/bridge/broadcast.test.js.map +1 -0
- package/lib/__tests__/bridge/buildTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/buildTransaction.test.js +62 -0
- package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/createTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/createTransaction.test.js +38 -0
- package/lib/__tests__/bridge/createTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.js +43 -0
- package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.js +84 -0
- package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +188 -0
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.js +133 -0
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib/__tests__/bridge/index.test.d.ts +2 -0
- package/lib/__tests__/bridge/index.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/index.test.js +116 -0
- package/lib/__tests__/bridge/index.test.js.map +1 -0
- package/lib/__tests__/bridge/logic.test.d.ts +2 -0
- package/lib/__tests__/bridge/logic.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/logic.test.js +773 -0
- package/lib/__tests__/bridge/logic.test.js.map +1 -0
- package/lib/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/prepareTransaction.test.js +121 -0
- package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -0
- package/lib/__tests__/bridge/signOperation.test.d.ts +2 -0
- package/lib/__tests__/bridge/signOperation.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/signOperation.test.js +185 -0
- package/lib/__tests__/bridge/signOperation.test.js.map +1 -0
- package/lib/__tests__/bridge/synchronisation.test.d.ts +2 -0
- package/lib/__tests__/bridge/synchronisation.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/synchronisation.test.js +349 -0
- package/lib/__tests__/bridge/synchronisation.test.js.map +1 -0
- package/lib/__tests__/bridge/transaction.test.d.ts +2 -0
- package/lib/__tests__/bridge/transaction.test.d.ts.map +1 -0
- package/lib/__tests__/bridge/transaction.test.js +231 -0
- package/lib/__tests__/bridge/transaction.test.js.map +1 -0
- package/lib/__tests__/errors.test.d.ts +2 -0
- package/lib/__tests__/errors.test.d.ts.map +1 -0
- package/lib/__tests__/errors.test.js +18 -0
- package/lib/__tests__/errors.test.js.map +1 -0
- package/lib/__tests__/index.test.d.ts +2 -0
- package/lib/__tests__/index.test.d.ts.map +1 -0
- package/lib/__tests__/index.test.js +27 -0
- package/lib/__tests__/index.test.js.map +1 -0
- package/lib/__tests__/network/index.test.d.ts +2 -0
- package/lib/__tests__/network/index.test.d.ts.map +1 -0
- package/lib/__tests__/network/index.test.js +57 -0
- package/lib/__tests__/network/index.test.js.map +1 -0
- package/lib/__tests__/signer/index.test.d.ts +2 -0
- package/lib/__tests__/signer/index.test.d.ts.map +1 -0
- package/lib/__tests__/signer/index.test.js +37 -0
- package/lib/__tests__/signer/index.test.js.map +1 -0
- package/lib/api/graphql/queries.d.ts +5 -0
- package/lib/api/graphql/queries.d.ts.map +1 -0
- package/lib/api/graphql/queries.js +56 -0
- package/lib/api/graphql/queries.js.map +1 -0
- package/lib/api/graphql/types.d.ts +79 -0
- package/lib/api/graphql/types.d.ts.map +1 -0
- package/lib/api/graphql/types.js +3 -0
- package/lib/api/graphql/types.js.map +1 -0
- package/lib/api/index.d.ts +31 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +200 -0
- package/lib/api/index.js.map +1 -0
- package/lib/bridge/bridge.fixture.d.ts +4 -0
- package/lib/bridge/bridge.fixture.d.ts.map +1 -0
- package/lib/bridge/bridge.fixture.js +56 -0
- package/lib/bridge/bridge.fixture.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +7 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +20 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/buildTransaction.d.ts +7 -0
- package/lib/bridge/buildTransaction.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.js +28 -0
- package/lib/bridge/buildTransaction.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +4 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +20 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/deviceTransactionConfig.d.ts +11 -0
- package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/bridge/deviceTransactionConfig.js +23 -0
- package/lib/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +10 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +30 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getFeesForTransaction.d.ts +16 -0
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -0
- package/lib/bridge/getFeesForTransaction.js +74 -0
- package/lib/bridge/getFeesForTransaction.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +5 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +48 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +8 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +54 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/logic.d.ts +24 -0
- package/lib/bridge/logic.d.ts.map +1 -0
- package/lib/bridge/logic.js +200 -0
- package/lib/bridge/logic.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +5 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +44 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +11 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +77 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/synchronisation.d.ts +3 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -0
- package/lib/bridge/synchronisation.js +53 -0
- package/lib/bridge/synchronisation.js.map +1 -0
- package/lib/bridge/transaction.d.ts +15 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +37 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/constants.d.ts +19 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +33 -0
- package/lib/constants.js.map +1 -0
- package/lib/errors.d.ts +10 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +8 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/network/index.d.ts +6 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +39 -0
- package/lib/network/index.js.map +1 -0
- package/lib/signer/index.d.ts +6 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +23 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/test/bot-specs.d.ts +7 -0
- package/lib/test/bot-specs.d.ts.map +1 -0
- package/lib/test/bot-specs.js +77 -0
- package/lib/test/bot-specs.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts +4 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib/test/bridgeDatasetTest.js +85 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +19 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +59 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +4 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +20 -0
- package/lib/test/index.js.map +1 -0
- package/lib/test/speculos-deviceActions.d.ts +5 -0
- package/lib/test/speculos-deviceActions.d.ts.map +1 -0
- package/lib/test/speculos-deviceActions.js +46 -0
- package/lib/test/speculos-deviceActions.js.map +1 -0
- package/lib/types/bridge.d.ts +5 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.js +9 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/index.d.ts +62 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +19 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/signer.d.ts +27 -0
- package/lib/types/signer.d.ts.map +1 -0
- package/lib/types/signer.js +3 -0
- package/lib/types/signer.js.map +1 -0
- package/lib-es/__tests__/api/index.test.d.ts +2 -0
- package/lib-es/__tests__/api/index.test.d.ts.map +1 -0
- package/lib-es/__tests__/api/index.test.js +442 -0
- package/lib-es/__tests__/api/index.test.js.map +1 -0
- package/lib-es/__tests__/bridge/broadcast.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/broadcast.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/broadcast.test.js +93 -0
- package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.js +57 -0
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/createTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/createTransaction.test.js +33 -0
- package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +18 -0
- package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +79 -0
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +160 -0
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +128 -0
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib-es/__tests__/bridge/index.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/index.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/index.test.js +111 -0
- package/lib-es/__tests__/bridge/index.test.js.map +1 -0
- package/lib-es/__tests__/bridge/logic.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/logic.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/logic.test.js +768 -0
- package/lib-es/__tests__/bridge/logic.test.js.map +1 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.js +116 -0
- package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -0
- package/lib-es/__tests__/bridge/signOperation.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/signOperation.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/signOperation.test.js +157 -0
- package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -0
- package/lib-es/__tests__/bridge/synchronisation.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/synchronisation.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/synchronisation.test.js +347 -0
- package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -0
- package/lib-es/__tests__/bridge/transaction.test.d.ts +2 -0
- package/lib-es/__tests__/bridge/transaction.test.d.ts.map +1 -0
- package/lib-es/__tests__/bridge/transaction.test.js +226 -0
- package/lib-es/__tests__/bridge/transaction.test.js.map +1 -0
- package/lib-es/__tests__/errors.test.d.ts +2 -0
- package/lib-es/__tests__/errors.test.d.ts.map +1 -0
- package/lib-es/__tests__/errors.test.js +16 -0
- package/lib-es/__tests__/errors.test.js.map +1 -0
- package/lib-es/__tests__/index.test.d.ts +2 -0
- package/lib-es/__tests__/index.test.d.ts.map +1 -0
- package/lib-es/__tests__/index.test.js +25 -0
- package/lib-es/__tests__/index.test.js.map +1 -0
- package/lib-es/__tests__/network/index.test.d.ts +2 -0
- package/lib-es/__tests__/network/index.test.d.ts.map +1 -0
- package/lib-es/__tests__/network/index.test.js +55 -0
- package/lib-es/__tests__/network/index.test.js.map +1 -0
- package/lib-es/__tests__/signer/index.test.d.ts +2 -0
- package/lib-es/__tests__/signer/index.test.d.ts.map +1 -0
- package/lib-es/__tests__/signer/index.test.js +32 -0
- package/lib-es/__tests__/signer/index.test.js.map +1 -0
- package/lib-es/api/graphql/queries.d.ts +5 -0
- package/lib-es/api/graphql/queries.d.ts.map +1 -0
- package/lib-es/api/graphql/queries.js +53 -0
- package/lib-es/api/graphql/queries.js.map +1 -0
- package/lib-es/api/graphql/types.d.ts +79 -0
- package/lib-es/api/graphql/types.d.ts.map +1 -0
- package/lib-es/api/graphql/types.js +2 -0
- package/lib-es/api/graphql/types.js.map +1 -0
- package/lib-es/api/index.d.ts +31 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +193 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/bridge/bridge.fixture.d.ts +4 -0
- package/lib-es/bridge/bridge.fixture.d.ts.map +1 -0
- package/lib-es/bridge/bridge.fixture.js +48 -0
- package/lib-es/bridge/bridge.fixture.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +7 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +18 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/buildTransaction.d.ts +7 -0
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.js +26 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +4 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +15 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts +11 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.js +19 -0
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +10 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +28 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.d.ts +16 -0
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -0
- package/lib-es/bridge/getFeesForTransaction.js +66 -0
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +5 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +46 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +8 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +47 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/logic.d.ts +24 -0
- package/lib-es/bridge/logic.d.ts.map +1 -0
- package/lib-es/bridge/logic.js +183 -0
- package/lib-es/bridge/logic.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +5 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +39 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +11 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +70 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/synchronisation.d.ts +3 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -0
- package/lib-es/bridge/synchronisation.js +49 -0
- package/lib-es/bridge/synchronisation.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +15 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +31 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/constants.d.ts +19 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +30 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/errors.d.ts +10 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +5 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/index.d.ts +3 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +3 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/network/index.d.ts +6 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +35 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/signer/index.d.ts +6 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +21 -0
- package/lib-es/signer/index.js.map +1 -0
- package/lib-es/test/bot-specs.d.ts +7 -0
- package/lib-es/test/bot-specs.d.ts.map +1 -0
- package/lib-es/test/bot-specs.js +72 -0
- package/lib-es/test/bot-specs.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib-es/test/bridgeDatasetTest.js +79 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +19 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +53 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +4 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +4 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/test/speculos-deviceActions.d.ts +5 -0
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/test/speculos-deviceActions.js +43 -0
- package/lib-es/test/speculos-deviceActions.js.map +1 -0
- package/lib-es/types/bridge.d.ts +5 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.js +6 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/index.d.ts +62 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +3 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/signer.d.ts +27 -0
- package/lib-es/types/signer.d.ts.map +1 -0
- package/lib-es/types/signer.js +2 -0
- package/lib-es/types/signer.js.map +1 -0
- package/package.json +124 -0
- package/src/__tests__/api/index.test.ts +499 -0
- package/src/__tests__/bridge/broadcast.test.ts +98 -0
- package/src/__tests__/bridge/buildTransaction.test.ts +61 -0
- package/src/__tests__/bridge/createTransaction.test.ts +27 -0
- package/src/__tests__/bridge/deviceTransactionConfig.test.ts +19 -0
- package/src/__tests__/bridge/estimateMaxSpendable.test.ts +94 -0
- package/src/__tests__/bridge/getFeesForTransaction.test.ts +189 -0
- package/src/__tests__/bridge/getTransactionStatus.test.ts +155 -0
- package/src/__tests__/bridge/index.test.ts +108 -0
- package/src/__tests__/bridge/logic.test.ts +876 -0
- package/src/__tests__/bridge/prepareTransaction.test.ts +118 -0
- package/src/__tests__/bridge/signOperation.test.ts +178 -0
- package/src/__tests__/bridge/synchronisation.test.ts +374 -0
- package/src/__tests__/bridge/transaction.test.ts +261 -0
- package/src/__tests__/errors.test.ts +25 -0
- package/src/__tests__/index.test.ts +26 -0
- package/src/__tests__/network/index.test.ts +95 -0
- package/src/__tests__/signer/index.test.ts +24 -0
- package/src/api/graphql/queries.ts +53 -0
- package/src/api/graphql/types.ts +85 -0
- package/src/api/index.ts +224 -0
- package/src/bridge/bridge.fixture.ts +53 -0
- package/src/bridge/broadcast.ts +17 -0
- package/src/bridge/buildTransaction.ts +29 -0
- package/src/bridge/createTransaction.ts +17 -0
- package/src/bridge/deviceTransactionConfig.ts +30 -0
- package/src/bridge/estimateMaxSpendable.ts +35 -0
- package/src/bridge/getFeesForTransaction.ts +87 -0
- package/src/bridge/getTransactionStatus.ts +54 -0
- package/src/bridge/index.ts +65 -0
- package/src/bridge/logic.ts +265 -0
- package/src/bridge/prepareTransaction.ts +55 -0
- package/src/bridge/signOperation.ts +82 -0
- package/src/bridge/synchronisation.ts +50 -0
- package/src/bridge/transaction.ts +61 -0
- package/src/constants.ts +34 -0
- package/src/errors.ts +7 -0
- package/src/index.ts +3 -0
- package/src/network/index.ts +54 -0
- package/src/signer/index.ts +17 -0
- package/src/test/bot-specs.ts +86 -0
- package/src/test/bridgeDatasetTest.ts +82 -0
- package/src/test/cli.ts +80 -0
- package/src/test/index.ts +3 -0
- package/src/test/speculos-deviceActions.ts +52 -0
- package/src/types/bridge.ts +4 -0
- package/src/types/index.ts +74 -0
- package/src/types/signer.ts +26 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const logic_1 = require("../../bridge/logic");
|
|
9
|
+
jest.mock("@ledgerhq/cryptoassets", () => ({
|
|
10
|
+
getCryptoCurrencyById: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
describe("Aptos logic ", () => {
|
|
13
|
+
describe("isTestnet", () => {
|
|
14
|
+
it("should return true for testnet currencies", () => {
|
|
15
|
+
expect((0, logic_1.isTestnet)("aptos_testnet")).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
it("should return false for mainnet currencies", () => {
|
|
18
|
+
expect((0, logic_1.isTestnet)("aptos")).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe("getMaxSendBalance", () => {
|
|
22
|
+
it("should return the correct max send balance when amount is greater than total gas", () => {
|
|
23
|
+
const amount = new bignumber_js_1.default(1000000);
|
|
24
|
+
const gas = new bignumber_js_1.default(200);
|
|
25
|
+
const gasPrice = new bignumber_js_1.default(100);
|
|
26
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
27
|
+
expect(result.isEqualTo(amount.minus(gas.multipliedBy(gasPrice)))).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
it("should return zero when amount is less than total gas", () => {
|
|
30
|
+
const amount = new bignumber_js_1.default(1000);
|
|
31
|
+
const gas = new bignumber_js_1.default(200);
|
|
32
|
+
const gasPrice = new bignumber_js_1.default(100);
|
|
33
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
34
|
+
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
it("should return zero when amount is equal to total gas", () => {
|
|
37
|
+
const amount = new bignumber_js_1.default(20000);
|
|
38
|
+
const gas = new bignumber_js_1.default(200);
|
|
39
|
+
const gasPrice = new bignumber_js_1.default(100);
|
|
40
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
41
|
+
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
it("should handle zero amount", () => {
|
|
44
|
+
const amount = new bignumber_js_1.default(0);
|
|
45
|
+
const gas = new bignumber_js_1.default(200);
|
|
46
|
+
const gasPrice = new bignumber_js_1.default(100);
|
|
47
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
48
|
+
expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
it("should handle zero gas and gas price", () => {
|
|
51
|
+
const amount = new bignumber_js_1.default(1000000);
|
|
52
|
+
const gas = new bignumber_js_1.default(0);
|
|
53
|
+
const gasPrice = new bignumber_js_1.default(0);
|
|
54
|
+
const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
|
|
55
|
+
expect(result.isEqualTo(amount)).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe("normalizeTransactionOptions", () => {
|
|
59
|
+
it("should normalize transaction options", () => {
|
|
60
|
+
const options = {
|
|
61
|
+
maxGasAmount: "1000",
|
|
62
|
+
gasUnitPrice: "10",
|
|
63
|
+
};
|
|
64
|
+
const result = (0, logic_1.normalizeTransactionOptions)(options);
|
|
65
|
+
expect(result).toEqual(options);
|
|
66
|
+
});
|
|
67
|
+
it("should return undefined for empty values", () => {
|
|
68
|
+
const options = {
|
|
69
|
+
maxGasAmount: "",
|
|
70
|
+
gasUnitPrice: "",
|
|
71
|
+
};
|
|
72
|
+
const result = (0, logic_1.normalizeTransactionOptions)(options);
|
|
73
|
+
expect(result).toEqual({
|
|
74
|
+
maxGasAmount: undefined,
|
|
75
|
+
gasUnitPrice: undefined,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe("getBlankOperation", () => {
|
|
80
|
+
it("should return a blank operation", () => {
|
|
81
|
+
const tx = {
|
|
82
|
+
hash: "0x123",
|
|
83
|
+
block: { hash: "0xabc", height: 1 },
|
|
84
|
+
timestamp: "1000000",
|
|
85
|
+
sequence_number: "1",
|
|
86
|
+
version: "1",
|
|
87
|
+
};
|
|
88
|
+
const id = "test-id";
|
|
89
|
+
const result = (0, logic_1.getBlankOperation)(tx, id);
|
|
90
|
+
expect(result).toEqual({
|
|
91
|
+
id: "",
|
|
92
|
+
hash: "0x123",
|
|
93
|
+
type: "",
|
|
94
|
+
value: new bignumber_js_1.default(0),
|
|
95
|
+
fee: new bignumber_js_1.default(0),
|
|
96
|
+
blockHash: "0xabc",
|
|
97
|
+
blockHeight: 1,
|
|
98
|
+
senders: [],
|
|
99
|
+
recipients: [],
|
|
100
|
+
accountId: id,
|
|
101
|
+
date: new Date(1000),
|
|
102
|
+
extra: { version: "1" },
|
|
103
|
+
transactionSequenceNumber: 1,
|
|
104
|
+
hasFailed: false,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it("should return a blank operation even when some transaction fields are missing", () => {
|
|
108
|
+
const tx = {
|
|
109
|
+
hash: "0x123",
|
|
110
|
+
timestamp: "1000000",
|
|
111
|
+
sequence_number: "1",
|
|
112
|
+
};
|
|
113
|
+
const id = "test-id";
|
|
114
|
+
const result = (0, logic_1.getBlankOperation)(tx, id);
|
|
115
|
+
expect(result).toEqual({
|
|
116
|
+
id: "",
|
|
117
|
+
hash: "0x123",
|
|
118
|
+
type: "",
|
|
119
|
+
value: new bignumber_js_1.default(0),
|
|
120
|
+
fee: new bignumber_js_1.default(0),
|
|
121
|
+
blockHash: undefined,
|
|
122
|
+
blockHeight: undefined,
|
|
123
|
+
senders: [],
|
|
124
|
+
recipients: [],
|
|
125
|
+
accountId: id,
|
|
126
|
+
date: new Date(1000),
|
|
127
|
+
extra: { version: undefined },
|
|
128
|
+
transactionSequenceNumber: 1,
|
|
129
|
+
hasFailed: false,
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
describe("Aptos sync logic ", () => {
|
|
135
|
+
describe("compareAddress", () => {
|
|
136
|
+
it("should return true for identical addresses", () => {
|
|
137
|
+
const addressA = "0x1234567890abcdef";
|
|
138
|
+
const addressB = "0x1234567890abcdef";
|
|
139
|
+
expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
it("should return true for addresses with different cases", () => {
|
|
142
|
+
const addressA = "0x1234567890abcdef";
|
|
143
|
+
const addressB = "0x1234567890ABCDEF";
|
|
144
|
+
expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(true);
|
|
145
|
+
});
|
|
146
|
+
it("should return true for addresses with different hex formats", () => {
|
|
147
|
+
const addressA = "0x1234567890abcdef";
|
|
148
|
+
const addressB = "1234567890abcdef";
|
|
149
|
+
expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(true);
|
|
150
|
+
});
|
|
151
|
+
it("should return false for different addresses", () => {
|
|
152
|
+
const addressA = "0x1234567890abcdef";
|
|
153
|
+
const addressB = "0xfedcba0987654321";
|
|
154
|
+
expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(false);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
describe("getFunctionAddress", () => {
|
|
158
|
+
it("should return the function address when payload contains a function", () => {
|
|
159
|
+
const payload = {
|
|
160
|
+
function: "0x1::coin::transfer",
|
|
161
|
+
typeArguments: [],
|
|
162
|
+
functionArguments: [],
|
|
163
|
+
};
|
|
164
|
+
const result = (0, logic_1.getFunctionAddress)(payload);
|
|
165
|
+
expect(result).toBe("0x1");
|
|
166
|
+
});
|
|
167
|
+
it("should return undefined when payload does not contain a function", () => {
|
|
168
|
+
const payload = {
|
|
169
|
+
function: "::::",
|
|
170
|
+
typeArguments: [],
|
|
171
|
+
functionArguments: [],
|
|
172
|
+
};
|
|
173
|
+
const result = (0, logic_1.getFunctionAddress)(payload);
|
|
174
|
+
expect(result).toBeUndefined();
|
|
175
|
+
});
|
|
176
|
+
it("should return undefined when payload is empty", () => {
|
|
177
|
+
const payload = {};
|
|
178
|
+
const result = (0, logic_1.getFunctionAddress)(payload);
|
|
179
|
+
expect(result).toBeUndefined();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
describe("processRecipients", () => {
|
|
183
|
+
let op;
|
|
184
|
+
beforeEach(() => {
|
|
185
|
+
op = {
|
|
186
|
+
id: "",
|
|
187
|
+
hash: "",
|
|
188
|
+
type: "",
|
|
189
|
+
value: new bignumber_js_1.default(0),
|
|
190
|
+
fee: new bignumber_js_1.default(0),
|
|
191
|
+
blockHash: "",
|
|
192
|
+
blockHeight: 0,
|
|
193
|
+
senders: [],
|
|
194
|
+
recipients: [],
|
|
195
|
+
accountId: "",
|
|
196
|
+
date: new Date(),
|
|
197
|
+
extra: {},
|
|
198
|
+
transactionSequenceNumber: 0,
|
|
199
|
+
hasFailed: false,
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
it("should add recipient for transfer-like functions from LL account", () => {
|
|
203
|
+
const payload = {
|
|
204
|
+
function: "0x1::coin::transfer",
|
|
205
|
+
typeArguments: [],
|
|
206
|
+
functionArguments: ["0x13", 1], // from: &signer, to: address, amount: u64
|
|
207
|
+
};
|
|
208
|
+
(0, logic_1.processRecipients)(payload, "0x13", op, "0x1");
|
|
209
|
+
expect(op.recipients).toContain("0x13");
|
|
210
|
+
});
|
|
211
|
+
it("should add recipient for transfer-like functions from external account", () => {
|
|
212
|
+
const payload = {
|
|
213
|
+
function: "0x1::coin::transfer",
|
|
214
|
+
typeArguments: [],
|
|
215
|
+
functionArguments: ["0x12", 1], // from: &signer, to: address, amount: u64
|
|
216
|
+
};
|
|
217
|
+
(0, logic_1.processRecipients)(payload, "0x13", op, "0x1");
|
|
218
|
+
expect(op.recipients).toContain("0x12");
|
|
219
|
+
});
|
|
220
|
+
it("should add recipients for batch transfer functions", () => {
|
|
221
|
+
const payload = {
|
|
222
|
+
function: "0x1::aptos_account::batch_transfer_coins",
|
|
223
|
+
typeArguments: [constants_1.APTOS_ASSET_ID],
|
|
224
|
+
functionArguments: [
|
|
225
|
+
["0x12", "0x13"],
|
|
226
|
+
[1, 2],
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
op.senders.push("0x11");
|
|
230
|
+
(0, logic_1.processRecipients)(payload, "0x12", op, "0x1");
|
|
231
|
+
expect(op.recipients).toContain("0x12");
|
|
232
|
+
});
|
|
233
|
+
it("should add function address as recipient for other smart contracts", () => {
|
|
234
|
+
const payload = {
|
|
235
|
+
function: "0x2::other::contract",
|
|
236
|
+
typeArguments: [],
|
|
237
|
+
functionArguments: [["0x12"], [1]],
|
|
238
|
+
};
|
|
239
|
+
(0, logic_1.processRecipients)(payload, "0x11", op, "0x2");
|
|
240
|
+
expect(op.recipients).toContain("0x2");
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
describe("isChangeOfAptos", () => {
|
|
244
|
+
it("should return true for a valid change of Aptos", () => {
|
|
245
|
+
const change = {
|
|
246
|
+
type: "write_resource",
|
|
247
|
+
data: {
|
|
248
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
249
|
+
data: {
|
|
250
|
+
withdraw_events: {
|
|
251
|
+
guid: {
|
|
252
|
+
id: {
|
|
253
|
+
addr: "0x11",
|
|
254
|
+
creation_num: "2",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
const event = {
|
|
262
|
+
guid: {
|
|
263
|
+
account_address: "0x11",
|
|
264
|
+
creation_number: "2",
|
|
265
|
+
},
|
|
266
|
+
type: "0x1::coin::WithdrawEvent",
|
|
267
|
+
};
|
|
268
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
269
|
+
expect(result).toBe(true);
|
|
270
|
+
});
|
|
271
|
+
it("should return false for an invalid change of Aptos", () => {
|
|
272
|
+
const change = {
|
|
273
|
+
type: "write_resource",
|
|
274
|
+
data: {
|
|
275
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
276
|
+
data: {
|
|
277
|
+
withdraw_events: {
|
|
278
|
+
guid: {
|
|
279
|
+
id: {
|
|
280
|
+
addr: "0x12",
|
|
281
|
+
creation_num: "2",
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
const event = {
|
|
289
|
+
guid: {
|
|
290
|
+
account_address: "0x11",
|
|
291
|
+
creation_number: "1",
|
|
292
|
+
},
|
|
293
|
+
type: "0x1::coin::WithdrawEvent",
|
|
294
|
+
};
|
|
295
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
296
|
+
expect(result).toBe(false);
|
|
297
|
+
});
|
|
298
|
+
it("should return false for a change with a different WriteSet type", () => {
|
|
299
|
+
const change = {
|
|
300
|
+
type: "write_module",
|
|
301
|
+
data: {},
|
|
302
|
+
};
|
|
303
|
+
const event = {
|
|
304
|
+
guid: {
|
|
305
|
+
account_address: "0x1",
|
|
306
|
+
creation_number: "1",
|
|
307
|
+
},
|
|
308
|
+
type: "0x1::coin::WithdrawEvent",
|
|
309
|
+
};
|
|
310
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
311
|
+
expect(result).toBe(false);
|
|
312
|
+
});
|
|
313
|
+
it("should return false if no data in WriteSet Change", () => {
|
|
314
|
+
const change = {
|
|
315
|
+
type: "write_resource",
|
|
316
|
+
};
|
|
317
|
+
const event = {
|
|
318
|
+
guid: {
|
|
319
|
+
account_address: "0x11",
|
|
320
|
+
creation_number: "2",
|
|
321
|
+
},
|
|
322
|
+
type: "0x1::coin::WithdrawEvent",
|
|
323
|
+
};
|
|
324
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
325
|
+
expect(result).toBe(false);
|
|
326
|
+
});
|
|
327
|
+
it("should return false if no type in change data", () => {
|
|
328
|
+
const change = {
|
|
329
|
+
type: "write_resource",
|
|
330
|
+
data: {
|
|
331
|
+
data: {
|
|
332
|
+
withdraw_events: {
|
|
333
|
+
guid: {
|
|
334
|
+
id: {
|
|
335
|
+
addr: "0x11",
|
|
336
|
+
creation_num: "2",
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
const event = {
|
|
344
|
+
guid: {
|
|
345
|
+
account_address: "0x11",
|
|
346
|
+
creation_number: "2",
|
|
347
|
+
},
|
|
348
|
+
type: "0x1::coin::WithdrawEvent",
|
|
349
|
+
};
|
|
350
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
351
|
+
expect(result).toBe(false);
|
|
352
|
+
});
|
|
353
|
+
it("should return false for a change with a different WriteSet Change type", () => {
|
|
354
|
+
const change = {
|
|
355
|
+
type: "write_resource",
|
|
356
|
+
data: {
|
|
357
|
+
type: "0x1::coin::CoinStore<0x1::aptos_coin::ANY_OTHER_COIN>",
|
|
358
|
+
data: {
|
|
359
|
+
withdraw_events: {
|
|
360
|
+
guid: {
|
|
361
|
+
id: {
|
|
362
|
+
addr: "0x11",
|
|
363
|
+
creation_num: "2",
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
const event = {
|
|
371
|
+
guid: {
|
|
372
|
+
account_address: "0x11",
|
|
373
|
+
creation_number: "2",
|
|
374
|
+
},
|
|
375
|
+
type: "0x1::coin::WithdrawEvent",
|
|
376
|
+
};
|
|
377
|
+
const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
|
|
378
|
+
expect(result).toBe(false);
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
describe("getAptosAmounts", () => {
|
|
382
|
+
it("should calculate the correct amounts for withdraw and deposit events", () => {
|
|
383
|
+
const tx = {
|
|
384
|
+
events: [
|
|
385
|
+
{
|
|
386
|
+
type: "0x1::coin::WithdrawEvent",
|
|
387
|
+
guid: {
|
|
388
|
+
account_address: "0x11",
|
|
389
|
+
creation_number: "1",
|
|
390
|
+
},
|
|
391
|
+
data: {
|
|
392
|
+
amount: "100",
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
type: "0x1::coin::DepositEvent",
|
|
397
|
+
guid: {
|
|
398
|
+
account_address: "0x11",
|
|
399
|
+
creation_number: "2",
|
|
400
|
+
},
|
|
401
|
+
data: {
|
|
402
|
+
amount: "50",
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
changes: [
|
|
407
|
+
{
|
|
408
|
+
type: "write_resource",
|
|
409
|
+
data: {
|
|
410
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
411
|
+
data: {
|
|
412
|
+
withdraw_events: {
|
|
413
|
+
guid: {
|
|
414
|
+
id: {
|
|
415
|
+
addr: "0x11",
|
|
416
|
+
creation_num: "1",
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
deposit_events: {
|
|
421
|
+
guid: {
|
|
422
|
+
id: {
|
|
423
|
+
addr: "0x11",
|
|
424
|
+
creation_num: "2",
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
};
|
|
433
|
+
const address = "0x11";
|
|
434
|
+
const result = (0, logic_1.getAptosAmounts)(tx, address);
|
|
435
|
+
expect(result.amount_in).toEqual(new bignumber_js_1.default(50));
|
|
436
|
+
expect(result.amount_out).toEqual(new bignumber_js_1.default(100));
|
|
437
|
+
});
|
|
438
|
+
it("should return zero amounts if no matching events are found", () => {
|
|
439
|
+
const tx = {
|
|
440
|
+
events: [
|
|
441
|
+
{
|
|
442
|
+
type: "0x1::coin::WithdrawEvent",
|
|
443
|
+
guid: {
|
|
444
|
+
account_address: "0x11",
|
|
445
|
+
creation_number: "1",
|
|
446
|
+
},
|
|
447
|
+
data: {
|
|
448
|
+
amount: "100",
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
type: "0x1::coin::DepositEvent",
|
|
453
|
+
guid: {
|
|
454
|
+
account_address: "0x11",
|
|
455
|
+
creation_number: "2",
|
|
456
|
+
},
|
|
457
|
+
data: {
|
|
458
|
+
amount: "50",
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
],
|
|
462
|
+
changes: [
|
|
463
|
+
{
|
|
464
|
+
type: "write_resource",
|
|
465
|
+
data: {
|
|
466
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
467
|
+
data: {
|
|
468
|
+
withdraw_events: {
|
|
469
|
+
guid: {
|
|
470
|
+
id: {
|
|
471
|
+
addr: "0x12", // should fail by address check
|
|
472
|
+
creation_num: "1",
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
deposit_events: {
|
|
477
|
+
guid: {
|
|
478
|
+
id: {
|
|
479
|
+
addr: "0x11",
|
|
480
|
+
creation_num: "3", // should fail by number check
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
};
|
|
489
|
+
const address = "0x11";
|
|
490
|
+
const result = (0, logic_1.getAptosAmounts)(tx, address);
|
|
491
|
+
expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
|
|
492
|
+
expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
|
|
493
|
+
});
|
|
494
|
+
it("should handle transactions with other events", () => {
|
|
495
|
+
const tx = {
|
|
496
|
+
events: [
|
|
497
|
+
{
|
|
498
|
+
type: "0x1::coin::OtherEvent",
|
|
499
|
+
guid: {
|
|
500
|
+
account_address: "0x11",
|
|
501
|
+
creation_number: "1",
|
|
502
|
+
},
|
|
503
|
+
data: {
|
|
504
|
+
amount: "100",
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
],
|
|
508
|
+
};
|
|
509
|
+
const address = "0x1";
|
|
510
|
+
const result = (0, logic_1.getAptosAmounts)(tx, address);
|
|
511
|
+
expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
|
|
512
|
+
expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
describe("calculateAmount", () => {
|
|
516
|
+
it("should calculate the correct amount when the address is the sender", () => {
|
|
517
|
+
const address = "0x11";
|
|
518
|
+
const sender = "0x11";
|
|
519
|
+
const fee = new bignumber_js_1.default(10); // account pays fees
|
|
520
|
+
const amount_in = new bignumber_js_1.default(50);
|
|
521
|
+
const amount_out = new bignumber_js_1.default(100);
|
|
522
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
523
|
+
// LL negates the amount for SEND transactions during output
|
|
524
|
+
expect(result).toEqual(new bignumber_js_1.default(60)); // -(50 - 100 - 10)
|
|
525
|
+
});
|
|
526
|
+
it("should calculate the correct amount when the address is not the sender", () => {
|
|
527
|
+
const address = "0x11";
|
|
528
|
+
const sender = "0x12";
|
|
529
|
+
const fee = new bignumber_js_1.default(10); // sender pays fees
|
|
530
|
+
const amount_in = new bignumber_js_1.default(100);
|
|
531
|
+
const amount_out = new bignumber_js_1.default(50);
|
|
532
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
533
|
+
expect(result).toEqual(new bignumber_js_1.default(50)); // 100 - 50
|
|
534
|
+
});
|
|
535
|
+
it("should handle transactions with zero amounts", () => {
|
|
536
|
+
const address = "0x11";
|
|
537
|
+
const sender = "0x11";
|
|
538
|
+
const fee = new bignumber_js_1.default(10);
|
|
539
|
+
const amount_in = new bignumber_js_1.default(0);
|
|
540
|
+
const amount_out = new bignumber_js_1.default(0);
|
|
541
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
542
|
+
// LL negates the amount for SEND transactions during output
|
|
543
|
+
expect(result).toEqual(new bignumber_js_1.default(10)); // -(0 - 0 - 10)
|
|
544
|
+
});
|
|
545
|
+
it("should get negative numbers (for send tx with deposit to account)", () => {
|
|
546
|
+
const address = "0x11";
|
|
547
|
+
const sender = "0x11";
|
|
548
|
+
const fee = new bignumber_js_1.default(10);
|
|
549
|
+
const amount_in = new bignumber_js_1.default(100);
|
|
550
|
+
const amount_out = new bignumber_js_1.default(0);
|
|
551
|
+
const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
|
|
552
|
+
// LL negates the amount for SEND transactions during output
|
|
553
|
+
expect(result).toEqual(new bignumber_js_1.default(90).negated()); // 100 - 10
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
describe("txsToOps", () => {
|
|
557
|
+
it("should convert transactions to operations correctly", () => {
|
|
558
|
+
const address = "0x11";
|
|
559
|
+
const id = "test-id";
|
|
560
|
+
const txs = [
|
|
561
|
+
{
|
|
562
|
+
hash: "0x123",
|
|
563
|
+
sender: "0x11",
|
|
564
|
+
gas_used: "200",
|
|
565
|
+
gas_unit_price: "100",
|
|
566
|
+
success: true,
|
|
567
|
+
payload: {
|
|
568
|
+
type: "entry_function_payload",
|
|
569
|
+
function: "0x1::coin::transfer",
|
|
570
|
+
type_arguments: [],
|
|
571
|
+
arguments: ["0x12", 100],
|
|
572
|
+
},
|
|
573
|
+
events: [
|
|
574
|
+
{
|
|
575
|
+
type: "0x1::coin::WithdrawEvent",
|
|
576
|
+
guid: {
|
|
577
|
+
account_address: "0x11",
|
|
578
|
+
creation_number: "1",
|
|
579
|
+
},
|
|
580
|
+
data: {
|
|
581
|
+
amount: "100",
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
type: "0x1::coin::DepositEvent",
|
|
586
|
+
guid: {
|
|
587
|
+
account_address: "0x12",
|
|
588
|
+
creation_number: "2",
|
|
589
|
+
},
|
|
590
|
+
data: {
|
|
591
|
+
amount: "100",
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
changes: [
|
|
596
|
+
{
|
|
597
|
+
type: "write_resource",
|
|
598
|
+
data: {
|
|
599
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
600
|
+
data: {
|
|
601
|
+
withdraw_events: {
|
|
602
|
+
guid: {
|
|
603
|
+
id: {
|
|
604
|
+
addr: "0x11",
|
|
605
|
+
creation_num: "1",
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
deposit_events: {
|
|
610
|
+
guid: {
|
|
611
|
+
id: {
|
|
612
|
+
addr: "0x12",
|
|
613
|
+
creation_num: "2",
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
},
|
|
620
|
+
],
|
|
621
|
+
block: { hash: "0xabc", height: 1 },
|
|
622
|
+
timestamp: "1000000",
|
|
623
|
+
sequence_number: "1",
|
|
624
|
+
},
|
|
625
|
+
];
|
|
626
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
627
|
+
expect(result).toHaveLength(1);
|
|
628
|
+
expect(result[0]).toEqual({
|
|
629
|
+
id: expect.any(String),
|
|
630
|
+
hash: "0x123",
|
|
631
|
+
type: constants_1.DIRECTION.OUT,
|
|
632
|
+
value: new bignumber_js_1.default(20100),
|
|
633
|
+
fee: new bignumber_js_1.default(20000),
|
|
634
|
+
blockHash: "0xabc",
|
|
635
|
+
blockHeight: 1,
|
|
636
|
+
senders: ["0x11"],
|
|
637
|
+
recipients: ["0x12"],
|
|
638
|
+
accountId: id,
|
|
639
|
+
date: new Date(1000),
|
|
640
|
+
extra: { version: undefined },
|
|
641
|
+
transactionSequenceNumber: 1,
|
|
642
|
+
hasFailed: false,
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
it("should skip transactions without functions in payload", () => {
|
|
646
|
+
const address = "0x11";
|
|
647
|
+
const id = "test-id";
|
|
648
|
+
const txs = [
|
|
649
|
+
{
|
|
650
|
+
hash: "0x123",
|
|
651
|
+
sender: "0x11",
|
|
652
|
+
gas_used: "200",
|
|
653
|
+
gas_unit_price: "100",
|
|
654
|
+
success: true,
|
|
655
|
+
payload: {},
|
|
656
|
+
// payload: {
|
|
657
|
+
// type: "entry_function_payload",
|
|
658
|
+
// function: "0x1::coin::transfer",
|
|
659
|
+
// type_arguments: [],
|
|
660
|
+
// arguments: ["0x12", 100],
|
|
661
|
+
// } as EntryFunctionPayloadResponse,
|
|
662
|
+
events: [],
|
|
663
|
+
changes: [],
|
|
664
|
+
block: { hash: "0xabc", height: 1 },
|
|
665
|
+
timestamp: "1000000",
|
|
666
|
+
sequence_number: "1",
|
|
667
|
+
},
|
|
668
|
+
];
|
|
669
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
670
|
+
expect(result).toHaveLength(0);
|
|
671
|
+
});
|
|
672
|
+
it("should skip transactions that result in no Aptos change", () => {
|
|
673
|
+
const address = "0x11";
|
|
674
|
+
const id = "test-id";
|
|
675
|
+
const txs = [
|
|
676
|
+
{
|
|
677
|
+
hash: "0x123",
|
|
678
|
+
sender: "0x12",
|
|
679
|
+
gas_used: "200",
|
|
680
|
+
gas_unit_price: "100",
|
|
681
|
+
success: true,
|
|
682
|
+
payload: {
|
|
683
|
+
type: "entry_function_payload",
|
|
684
|
+
function: "0x1::coin::transfer",
|
|
685
|
+
type_arguments: [],
|
|
686
|
+
arguments: ["0x11", 100],
|
|
687
|
+
},
|
|
688
|
+
events: [],
|
|
689
|
+
changes: [],
|
|
690
|
+
block: { hash: "0xabc", height: 1 },
|
|
691
|
+
timestamp: "1000000",
|
|
692
|
+
sequence_number: "1",
|
|
693
|
+
},
|
|
694
|
+
];
|
|
695
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
696
|
+
expect(result).toHaveLength(0);
|
|
697
|
+
});
|
|
698
|
+
it("should handle failed transactions", () => {
|
|
699
|
+
const address = "0x11";
|
|
700
|
+
const id = "test-id";
|
|
701
|
+
const txs = [
|
|
702
|
+
{
|
|
703
|
+
hash: "0x123",
|
|
704
|
+
sender: "0x11",
|
|
705
|
+
gas_used: "200",
|
|
706
|
+
gas_unit_price: "100",
|
|
707
|
+
success: false,
|
|
708
|
+
payload: {
|
|
709
|
+
type: "entry_function_payload",
|
|
710
|
+
function: "0x1::coin::transfer",
|
|
711
|
+
type_arguments: [],
|
|
712
|
+
arguments: ["0x12", 100],
|
|
713
|
+
},
|
|
714
|
+
events: [
|
|
715
|
+
{
|
|
716
|
+
type: "0x1::coin::WithdrawEvent",
|
|
717
|
+
guid: {
|
|
718
|
+
account_address: "0x11",
|
|
719
|
+
creation_number: "1",
|
|
720
|
+
},
|
|
721
|
+
data: {
|
|
722
|
+
amount: "100",
|
|
723
|
+
},
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
type: "0x1::coin::DepositEvent",
|
|
727
|
+
guid: {
|
|
728
|
+
account_address: "0x12",
|
|
729
|
+
creation_number: "2",
|
|
730
|
+
},
|
|
731
|
+
data: {
|
|
732
|
+
amount: "100",
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
],
|
|
736
|
+
changes: [
|
|
737
|
+
{
|
|
738
|
+
type: "write_resource",
|
|
739
|
+
data: {
|
|
740
|
+
type: constants_1.APTOS_COIN_CHANGE,
|
|
741
|
+
data: {
|
|
742
|
+
withdraw_events: {
|
|
743
|
+
guid: {
|
|
744
|
+
id: {
|
|
745
|
+
addr: "0x11",
|
|
746
|
+
creation_num: "1",
|
|
747
|
+
},
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
deposit_events: {
|
|
751
|
+
guid: {
|
|
752
|
+
id: {
|
|
753
|
+
addr: "0x12",
|
|
754
|
+
creation_num: "2",
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
],
|
|
762
|
+
block: { hash: "0xabc", height: 1 },
|
|
763
|
+
timestamp: "1000000",
|
|
764
|
+
sequence_number: "1",
|
|
765
|
+
},
|
|
766
|
+
];
|
|
767
|
+
const result = (0, logic_1.txsToOps)({ address }, id, txs);
|
|
768
|
+
expect(result).toHaveLength(1);
|
|
769
|
+
expect(result[0].hasFailed).toBe(true);
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
//# sourceMappingURL=logic.test.js.map
|