@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,499 @@
|
|
|
1
|
+
import { ApolloClient } from "@apollo/client";
|
|
2
|
+
import {
|
|
3
|
+
AccountAddress,
|
|
4
|
+
Aptos,
|
|
5
|
+
ChainId,
|
|
6
|
+
Ed25519PublicKey,
|
|
7
|
+
InputEntryFunctionData,
|
|
8
|
+
RawTransaction,
|
|
9
|
+
Serializable,
|
|
10
|
+
post,
|
|
11
|
+
} from "@aptos-labs/ts-sdk";
|
|
12
|
+
import network from "@ledgerhq/live-network";
|
|
13
|
+
import BigNumber from "bignumber.js";
|
|
14
|
+
import { AptosAPI } from "../../api";
|
|
15
|
+
|
|
16
|
+
jest.mock("@aptos-labs/ts-sdk");
|
|
17
|
+
jest.mock("@apollo/client");
|
|
18
|
+
let mockedAptos: jest.Mocked<any>;
|
|
19
|
+
let mockedApolloClient: jest.Mocked<any>;
|
|
20
|
+
let mockedPost = jest.fn();
|
|
21
|
+
|
|
22
|
+
jest.mock("@ledgerhq/live-network/network");
|
|
23
|
+
const mockedNetwork = jest.mocked(network);
|
|
24
|
+
|
|
25
|
+
describe("Aptos API", () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
mockedAptos = jest.mocked(Aptos);
|
|
28
|
+
mockedApolloClient = jest.mocked(ApolloClient);
|
|
29
|
+
mockedPost = jest.mocked(post);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => jest.clearAllMocks());
|
|
33
|
+
|
|
34
|
+
it("builds the client properly for mainnet", () => {
|
|
35
|
+
const api = new AptosAPI("aptos");
|
|
36
|
+
|
|
37
|
+
expect(api.broadcast).toBeDefined();
|
|
38
|
+
expect(typeof api.broadcast).toBe("function");
|
|
39
|
+
expect(api.estimateGasPrice).toBeDefined();
|
|
40
|
+
expect(typeof api.estimateGasPrice).toBe("function");
|
|
41
|
+
expect(api.generateTransaction).toBeDefined();
|
|
42
|
+
expect(typeof api.generateTransaction).toBe("function");
|
|
43
|
+
expect(api.getAccount).toBeDefined();
|
|
44
|
+
expect(typeof api.getAccount).toBe("function");
|
|
45
|
+
expect(api.getAccountInfo).toBeDefined();
|
|
46
|
+
expect(typeof api.getAccountInfo).toBe("function");
|
|
47
|
+
expect(api.simulateTransaction).toBeDefined();
|
|
48
|
+
expect(typeof api.simulateTransaction).toBe("function");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("builds the client properly for testnet", () => {
|
|
52
|
+
const api = new AptosAPI("aptos_testnet");
|
|
53
|
+
|
|
54
|
+
expect(api.broadcast).toBeDefined();
|
|
55
|
+
expect(typeof api.broadcast).toBe("function");
|
|
56
|
+
expect(api.estimateGasPrice).toBeDefined();
|
|
57
|
+
expect(typeof api.estimateGasPrice).toBe("function");
|
|
58
|
+
expect(api.generateTransaction).toBeDefined();
|
|
59
|
+
expect(typeof api.generateTransaction).toBe("function");
|
|
60
|
+
expect(api.getAccount).toBeDefined();
|
|
61
|
+
expect(typeof api.getAccount).toBe("function");
|
|
62
|
+
expect(api.getAccountInfo).toBeDefined();
|
|
63
|
+
expect(typeof api.getAccountInfo).toBe("function");
|
|
64
|
+
expect(api.simulateTransaction).toBeDefined();
|
|
65
|
+
expect(typeof api.simulateTransaction).toBe("function");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("getAccount", () => {
|
|
69
|
+
it("calls getAccountInfo", async () => {
|
|
70
|
+
const mockGetAccountInfo = jest.fn();
|
|
71
|
+
mockedAptos.mockImplementation(() => ({
|
|
72
|
+
getAccountInfo: mockGetAccountInfo,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
76
|
+
|
|
77
|
+
const api = new AptosAPI("aptos");
|
|
78
|
+
await api.getAccount("address");
|
|
79
|
+
|
|
80
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith({
|
|
81
|
+
accountAddress: "address",
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("getAccountInfo", () => {
|
|
87
|
+
it("calls getBalance, fetchTransactions and getHeight", async () => {
|
|
88
|
+
mockedAptos.mockImplementation(() => ({
|
|
89
|
+
view: jest.fn().mockReturnValue(["123"]),
|
|
90
|
+
getTransactionByVersion: jest.fn().mockReturnValue({
|
|
91
|
+
type: "user_transaction",
|
|
92
|
+
version: "v1",
|
|
93
|
+
}),
|
|
94
|
+
getBlockByVersion: jest.fn().mockReturnValue({
|
|
95
|
+
block_height: "1",
|
|
96
|
+
block_hash: "83ca6d",
|
|
97
|
+
}),
|
|
98
|
+
}));
|
|
99
|
+
|
|
100
|
+
mockedNetwork.mockResolvedValue(
|
|
101
|
+
Promise.resolve({
|
|
102
|
+
data: {
|
|
103
|
+
account: {
|
|
104
|
+
account_number: 1,
|
|
105
|
+
sequence: 0,
|
|
106
|
+
pub_key: { key: "k", "@type": "type" },
|
|
107
|
+
base_account: {
|
|
108
|
+
account_number: 2,
|
|
109
|
+
sequence: 42,
|
|
110
|
+
pub_key: { key: "k2", "@type": "type2" },
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
block_height: "999",
|
|
114
|
+
},
|
|
115
|
+
status: 200,
|
|
116
|
+
headers: {} as any,
|
|
117
|
+
statusText: "",
|
|
118
|
+
config: {
|
|
119
|
+
headers: {} as any,
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
mockedApolloClient.mockImplementation(() => ({
|
|
125
|
+
query: async () => ({
|
|
126
|
+
data: {
|
|
127
|
+
address_version_from_move_resources: [{ transaction_version: "v1" }],
|
|
128
|
+
},
|
|
129
|
+
loading: false,
|
|
130
|
+
networkStatus: 7,
|
|
131
|
+
}),
|
|
132
|
+
}));
|
|
133
|
+
|
|
134
|
+
const api = new AptosAPI("aptos");
|
|
135
|
+
const accountInfo = await api.getAccountInfo("APTOS_1_ADDRESS", "1");
|
|
136
|
+
|
|
137
|
+
expect(accountInfo.balance).toEqual(new BigNumber(123));
|
|
138
|
+
expect(accountInfo.transactions).toEqual([
|
|
139
|
+
{
|
|
140
|
+
type: "user_transaction",
|
|
141
|
+
version: "v1",
|
|
142
|
+
block: {
|
|
143
|
+
height: 1,
|
|
144
|
+
hash: "83ca6d",
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
expect(accountInfo.blockHeight).toEqual(999);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("return balance = 0 if it fails to fetch balance", async () => {
|
|
152
|
+
mockedAptos.mockImplementation(() => ({
|
|
153
|
+
view: jest.fn().mockImplementation(() => {
|
|
154
|
+
throw new Error("error");
|
|
155
|
+
}),
|
|
156
|
+
getTransactionByVersion: jest.fn().mockReturnValue({
|
|
157
|
+
type: "user_transaction",
|
|
158
|
+
version: "v1",
|
|
159
|
+
}),
|
|
160
|
+
getBlockByVersion: jest.fn().mockReturnValue({
|
|
161
|
+
block_height: "1",
|
|
162
|
+
block_hash: "83ca6d",
|
|
163
|
+
}),
|
|
164
|
+
}));
|
|
165
|
+
|
|
166
|
+
mockedNetwork.mockResolvedValue(
|
|
167
|
+
Promise.resolve({
|
|
168
|
+
data: {
|
|
169
|
+
account: {
|
|
170
|
+
account_number: 1,
|
|
171
|
+
sequence: 0,
|
|
172
|
+
pub_key: { key: "k", "@type": "type" },
|
|
173
|
+
base_account: {
|
|
174
|
+
account_number: 2,
|
|
175
|
+
sequence: 42,
|
|
176
|
+
pub_key: { key: "k2", "@type": "type2" },
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
block_height: "999",
|
|
180
|
+
},
|
|
181
|
+
status: 200,
|
|
182
|
+
headers: {} as any,
|
|
183
|
+
statusText: "",
|
|
184
|
+
config: {
|
|
185
|
+
headers: {} as any,
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
mockedApolloClient.mockImplementation(() => ({
|
|
191
|
+
query: async () => ({
|
|
192
|
+
data: {
|
|
193
|
+
address_version_from_move_resources: [{ transaction_version: "v1" }],
|
|
194
|
+
},
|
|
195
|
+
loading: false,
|
|
196
|
+
networkStatus: 7,
|
|
197
|
+
}),
|
|
198
|
+
}));
|
|
199
|
+
|
|
200
|
+
const api = new AptosAPI("aptos");
|
|
201
|
+
const accountInfo = await api.getAccountInfo("APTOS_1_ADDRESS", "1");
|
|
202
|
+
|
|
203
|
+
expect(accountInfo.balance).toEqual(new BigNumber(0));
|
|
204
|
+
expect(accountInfo.transactions).toEqual([
|
|
205
|
+
{
|
|
206
|
+
type: "user_transaction",
|
|
207
|
+
version: "v1",
|
|
208
|
+
block: {
|
|
209
|
+
height: 1,
|
|
210
|
+
hash: "83ca6d",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
]);
|
|
214
|
+
expect(accountInfo.blockHeight).toEqual(999);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("returns no transactions if it the address is empty", async () => {
|
|
218
|
+
mockedAptos.mockImplementation(() => ({
|
|
219
|
+
view: jest.fn().mockReturnValue(["123"]),
|
|
220
|
+
getTransactionByVersion: jest.fn().mockReturnValue({
|
|
221
|
+
type: "user_transaction",
|
|
222
|
+
version: "v1",
|
|
223
|
+
}),
|
|
224
|
+
getBlockByVersion: jest.fn().mockReturnValue({
|
|
225
|
+
block_height: "1",
|
|
226
|
+
block_hash: "83ca6d",
|
|
227
|
+
}),
|
|
228
|
+
}));
|
|
229
|
+
|
|
230
|
+
mockedNetwork.mockResolvedValue(
|
|
231
|
+
Promise.resolve({
|
|
232
|
+
data: {
|
|
233
|
+
account: {
|
|
234
|
+
account_number: 1,
|
|
235
|
+
sequence: 0,
|
|
236
|
+
pub_key: { key: "k", "@type": "type" },
|
|
237
|
+
base_account: {
|
|
238
|
+
account_number: 2,
|
|
239
|
+
sequence: 42,
|
|
240
|
+
pub_key: { key: "k2", "@type": "type2" },
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
block_height: "999",
|
|
244
|
+
},
|
|
245
|
+
status: 200,
|
|
246
|
+
headers: {} as any,
|
|
247
|
+
statusText: "",
|
|
248
|
+
config: {
|
|
249
|
+
headers: {} as any,
|
|
250
|
+
},
|
|
251
|
+
}),
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
mockedApolloClient.mockImplementation(() => ({
|
|
255
|
+
query: async () => ({
|
|
256
|
+
data: {
|
|
257
|
+
address_version_from_move_resources: [{ transaction_version: "v1" }],
|
|
258
|
+
},
|
|
259
|
+
loading: false,
|
|
260
|
+
networkStatus: 7,
|
|
261
|
+
}),
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
const api = new AptosAPI("aptos");
|
|
265
|
+
const accountInfo = await api.getAccountInfo("", "1");
|
|
266
|
+
|
|
267
|
+
expect(accountInfo.balance).toEqual(new BigNumber(123));
|
|
268
|
+
expect(accountInfo.transactions).toEqual([]);
|
|
269
|
+
expect(accountInfo.blockHeight).toEqual(999);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("returns a null transaction if it fails to getTransactionByVersion", async () => {
|
|
273
|
+
mockedAptos.mockImplementation(() => ({
|
|
274
|
+
view: jest.fn().mockReturnValue(["123"]),
|
|
275
|
+
getTransactionByVersion: jest.fn().mockImplementation(() => {
|
|
276
|
+
throw new Error("error");
|
|
277
|
+
}),
|
|
278
|
+
getBlockByVersion: jest.fn().mockReturnValue({
|
|
279
|
+
block_height: "1",
|
|
280
|
+
block_hash: "83ca6d",
|
|
281
|
+
}),
|
|
282
|
+
}));
|
|
283
|
+
|
|
284
|
+
mockedNetwork.mockResolvedValue(
|
|
285
|
+
Promise.resolve({
|
|
286
|
+
data: {
|
|
287
|
+
account: {
|
|
288
|
+
account_number: 1,
|
|
289
|
+
sequence: 0,
|
|
290
|
+
pub_key: { key: "k", "@type": "type" },
|
|
291
|
+
base_account: {
|
|
292
|
+
account_number: 2,
|
|
293
|
+
sequence: 42,
|
|
294
|
+
pub_key: { key: "k2", "@type": "type2" },
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
block_height: "999",
|
|
298
|
+
},
|
|
299
|
+
status: 200,
|
|
300
|
+
headers: {} as any,
|
|
301
|
+
statusText: "",
|
|
302
|
+
config: {
|
|
303
|
+
headers: {} as any,
|
|
304
|
+
},
|
|
305
|
+
}),
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
mockedApolloClient.mockImplementation(() => ({
|
|
309
|
+
query: async () => ({
|
|
310
|
+
data: {
|
|
311
|
+
address_version_from_move_resources: [{ transaction_version: "v1" }],
|
|
312
|
+
},
|
|
313
|
+
loading: false,
|
|
314
|
+
networkStatus: 7,
|
|
315
|
+
}),
|
|
316
|
+
}));
|
|
317
|
+
|
|
318
|
+
const api = new AptosAPI("aptos");
|
|
319
|
+
const accountInfo = await api.getAccountInfo("APTOS_1_ADDRESS", "1");
|
|
320
|
+
|
|
321
|
+
expect(accountInfo.balance).toEqual(new BigNumber(123));
|
|
322
|
+
expect(accountInfo.transactions).toEqual([null]);
|
|
323
|
+
expect(accountInfo.blockHeight).toEqual(999);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
describe("estimateGasPrice", () => {
|
|
328
|
+
it("estimates the gas price", async () => {
|
|
329
|
+
const gasEstimation = { gas_estimate: 100 };
|
|
330
|
+
mockedAptos.mockImplementation(() => ({
|
|
331
|
+
getGasPriceEstimation: jest.fn().mockReturnValue(gasEstimation),
|
|
332
|
+
}));
|
|
333
|
+
|
|
334
|
+
const api = new AptosAPI("aptos");
|
|
335
|
+
const gasPrice = await api.estimateGasPrice();
|
|
336
|
+
|
|
337
|
+
expect(gasPrice.gas_estimate).toEqual(100);
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
describe("generateTransaction", () => {
|
|
342
|
+
const payload: InputEntryFunctionData = {
|
|
343
|
+
function: "0x1::coin::transfer",
|
|
344
|
+
functionArguments: ["0x13", 1],
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
it("generates a transaction without expireTimestamp", async () => {
|
|
348
|
+
const options = {
|
|
349
|
+
maxGasAmount: "100",
|
|
350
|
+
gasUnitPrice: "50",
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const mockSimple = jest.fn().mockImplementation(async () => ({
|
|
354
|
+
rawTransaction: null,
|
|
355
|
+
}));
|
|
356
|
+
mockedAptos.mockImplementation(() => ({
|
|
357
|
+
transaction: {
|
|
358
|
+
build: {
|
|
359
|
+
simple: mockSimple,
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
}));
|
|
363
|
+
|
|
364
|
+
const mockSimpleSpy = jest.spyOn({ simple: mockSimple }, "simple");
|
|
365
|
+
|
|
366
|
+
const api = new AptosAPI("aptos");
|
|
367
|
+
await api.generateTransaction("APTOS_1_ADDRESS", payload, options);
|
|
368
|
+
|
|
369
|
+
expect(mockSimpleSpy).toHaveBeenCalledWith({
|
|
370
|
+
data: payload,
|
|
371
|
+
options: {
|
|
372
|
+
maxGasAmount: Number(options.maxGasAmount),
|
|
373
|
+
gasUnitPrice: Number(options.gasUnitPrice),
|
|
374
|
+
},
|
|
375
|
+
sender: "APTOS_1_ADDRESS",
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("generates a transaction with default expireTimestamp", async () => {
|
|
380
|
+
const options = {
|
|
381
|
+
maxGasAmount: "100",
|
|
382
|
+
gasUnitPrice: "50",
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const mockSimple = jest.fn().mockImplementation(async () => ({
|
|
386
|
+
rawTransaction: null,
|
|
387
|
+
}));
|
|
388
|
+
const mockGetLedgerInfo = jest.fn().mockImplementation(async () => ({
|
|
389
|
+
ledger_timestamp: "0",
|
|
390
|
+
}));
|
|
391
|
+
mockedAptos.mockImplementation(() => ({
|
|
392
|
+
transaction: {
|
|
393
|
+
build: {
|
|
394
|
+
simple: mockSimple,
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
getLedgerInfo: mockGetLedgerInfo,
|
|
398
|
+
}));
|
|
399
|
+
|
|
400
|
+
const mockSimpleSpy = jest.spyOn({ simple: mockSimple }, "simple");
|
|
401
|
+
|
|
402
|
+
const api = new AptosAPI("aptos");
|
|
403
|
+
await api.generateTransaction("APTOS_1_ADDRESS", payload, options);
|
|
404
|
+
|
|
405
|
+
expect(mockSimpleSpy).toHaveBeenCalledWith({
|
|
406
|
+
data: payload,
|
|
407
|
+
options: {
|
|
408
|
+
maxGasAmount: Number(options.maxGasAmount),
|
|
409
|
+
gasUnitPrice: Number(options.gasUnitPrice),
|
|
410
|
+
expireTimestamp: 120,
|
|
411
|
+
},
|
|
412
|
+
sender: "APTOS_1_ADDRESS",
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it("throws an error when failing to build a transaction", async () => {
|
|
417
|
+
const options = {
|
|
418
|
+
maxGasAmount: "100",
|
|
419
|
+
gasUnitPrice: "50",
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const mockSimple = jest.fn().mockImplementation(async () => null);
|
|
423
|
+
mockedAptos.mockImplementation(() => ({
|
|
424
|
+
transaction: {
|
|
425
|
+
build: {
|
|
426
|
+
simple: mockSimple,
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
}));
|
|
430
|
+
|
|
431
|
+
const api = new AptosAPI("aptos");
|
|
432
|
+
expect(
|
|
433
|
+
async () => await api.generateTransaction("APTOS_1_ADDRESS", payload, options),
|
|
434
|
+
).rejects.toThrow();
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
describe("simulateTransaction", () => {
|
|
439
|
+
it("simulates a transaction with the correct options", async () => {
|
|
440
|
+
const mockSimple = jest.fn().mockImplementation(async () => ({
|
|
441
|
+
rawTransaction: null,
|
|
442
|
+
}));
|
|
443
|
+
mockedAptos.mockImplementation(() => ({
|
|
444
|
+
transaction: {
|
|
445
|
+
simulate: {
|
|
446
|
+
simple: mockSimple,
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
}));
|
|
450
|
+
|
|
451
|
+
const mockSimpleSpy = jest.spyOn({ simple: mockSimple }, "simple");
|
|
452
|
+
|
|
453
|
+
const api = new AptosAPI("aptos");
|
|
454
|
+
const address = new Ed25519PublicKey("APTOS_1_ADDRESS");
|
|
455
|
+
const tx = new RawTransaction(
|
|
456
|
+
new AccountAddress(Uint8Array.from(Buffer.from("APTOS_2_ADDRESS"))),
|
|
457
|
+
BigInt(1),
|
|
458
|
+
"" as unknown as Serializable,
|
|
459
|
+
BigInt(100),
|
|
460
|
+
BigInt(50),
|
|
461
|
+
BigInt(1),
|
|
462
|
+
{ chainId: 1 } as ChainId,
|
|
463
|
+
);
|
|
464
|
+
await api.simulateTransaction(address, tx);
|
|
465
|
+
|
|
466
|
+
expect(mockSimpleSpy).toHaveBeenCalledWith({
|
|
467
|
+
signerPublicKey: address,
|
|
468
|
+
transaction: { rawTransaction: tx },
|
|
469
|
+
options: {
|
|
470
|
+
estimateGasUnitPrice: true,
|
|
471
|
+
estimateMaxGasAmount: true,
|
|
472
|
+
estimatePrioritizedGasUnitPrice: false,
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
describe("broadcast", () => {
|
|
478
|
+
it("broadcasts the transaction", async () => {
|
|
479
|
+
mockedPost.mockImplementation(async () => ({ data: { hash: "ok" } }));
|
|
480
|
+
const mockedPostSpy = jest.spyOn({ post: mockedPost }, "post");
|
|
481
|
+
|
|
482
|
+
mockedAptos.mockImplementation(() => ({
|
|
483
|
+
config: "config",
|
|
484
|
+
}));
|
|
485
|
+
|
|
486
|
+
const api = new AptosAPI("aptos");
|
|
487
|
+
await api.broadcast("signature");
|
|
488
|
+
|
|
489
|
+
expect(mockedPostSpy).toHaveBeenCalledWith({
|
|
490
|
+
contentType: "application/x.aptos.signed_transaction+bcs",
|
|
491
|
+
aptosConfig: "config",
|
|
492
|
+
body: Uint8Array.from(Buffer.from("signature", "hex")),
|
|
493
|
+
path: "transactions",
|
|
494
|
+
type: "Fullnode",
|
|
495
|
+
originMethod: "",
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import broadcast from "../../bridge/broadcast";
|
|
2
|
+
import { AptosAPI } from "../../api";
|
|
3
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
4
|
+
import type { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
|
|
7
|
+
jest.mock("../../api");
|
|
8
|
+
jest.mock("@ledgerhq/coin-framework/operation");
|
|
9
|
+
|
|
10
|
+
describe("broadcast", () => {
|
|
11
|
+
const mockAccount: Account = {
|
|
12
|
+
type: "Account",
|
|
13
|
+
seedIdentifier: "mockSeedIdentifier",
|
|
14
|
+
operationsCount: 0,
|
|
15
|
+
id: "mockAccountId",
|
|
16
|
+
currency: {
|
|
17
|
+
type: "CryptoCurrency",
|
|
18
|
+
id: "aptos",
|
|
19
|
+
name: "Aptos",
|
|
20
|
+
ticker: "APT",
|
|
21
|
+
units: [{ name: "APT", code: "APT", magnitude: 6 }],
|
|
22
|
+
managerAppName: "Aptos",
|
|
23
|
+
coinType: 637,
|
|
24
|
+
scheme: "aptos",
|
|
25
|
+
color: "#000000",
|
|
26
|
+
family: "aptos",
|
|
27
|
+
blockAvgTime: 5,
|
|
28
|
+
explorerViews: [],
|
|
29
|
+
},
|
|
30
|
+
balance: BigNumber(1000),
|
|
31
|
+
spendableBalance: BigNumber(1000),
|
|
32
|
+
operations: [],
|
|
33
|
+
pendingOperations: [],
|
|
34
|
+
lastSyncDate: new Date(),
|
|
35
|
+
blockHeight: 0,
|
|
36
|
+
index: 0,
|
|
37
|
+
derivationMode: "",
|
|
38
|
+
freshAddress: "",
|
|
39
|
+
freshAddressPath: "",
|
|
40
|
+
used: false,
|
|
41
|
+
swapHistory: [],
|
|
42
|
+
creationDate: new Date(),
|
|
43
|
+
balanceHistoryCache: {
|
|
44
|
+
HOUR: { latestDate: 0, balances: [] },
|
|
45
|
+
DAY: { latestDate: 0, balances: [] },
|
|
46
|
+
WEEK: { latestDate: 0, balances: [] },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const mockOperation: Operation = {
|
|
51
|
+
id: "mockOperationId",
|
|
52
|
+
hash: "",
|
|
53
|
+
type: "OUT",
|
|
54
|
+
value: BigNumber(100),
|
|
55
|
+
fee: BigNumber(1),
|
|
56
|
+
senders: ["sender"],
|
|
57
|
+
recipients: ["recipient"],
|
|
58
|
+
blockHeight: null,
|
|
59
|
+
blockHash: null,
|
|
60
|
+
accountId: "mockAccountId",
|
|
61
|
+
date: new Date(),
|
|
62
|
+
extra: {},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const mockSignedOperation: SignedOperation = {
|
|
66
|
+
operation: mockOperation,
|
|
67
|
+
signature: "mockSignature",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
it("should broadcast the signed operation and return the patched operation", async () => {
|
|
71
|
+
const mockHash = "mockHash";
|
|
72
|
+
(AptosAPI.prototype.broadcast as jest.Mock).mockResolvedValue(mockHash);
|
|
73
|
+
(patchOperationWithHash as jest.Mock).mockReturnValue({
|
|
74
|
+
...mockOperation,
|
|
75
|
+
hash: mockHash,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const result = await broadcast({
|
|
79
|
+
signedOperation: mockSignedOperation,
|
|
80
|
+
account: mockAccount,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(AptosAPI.prototype.broadcast).toHaveBeenCalledWith("mockSignature");
|
|
84
|
+
expect(patchOperationWithHash).toHaveBeenCalledWith(mockOperation, mockHash);
|
|
85
|
+
expect(result).toEqual({ ...mockOperation, hash: mockHash });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should throw an error if broadcast fails", async () => {
|
|
89
|
+
(AptosAPI.prototype.broadcast as jest.Mock).mockRejectedValue(new Error("Broadcast failed"));
|
|
90
|
+
|
|
91
|
+
await expect(
|
|
92
|
+
broadcast({
|
|
93
|
+
signedOperation: mockSignedOperation,
|
|
94
|
+
account: mockAccount,
|
|
95
|
+
}),
|
|
96
|
+
).rejects.toThrow("Broadcast failed");
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
|
|
2
|
+
import buildTransaction from "../../bridge/buildTransaction";
|
|
3
|
+
import { AptosAPI } from "../../api";
|
|
4
|
+
import { normalizeTransactionOptions } from "../../bridge/logic";
|
|
5
|
+
import { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
|
|
6
|
+
import { TransactionOptions } from "../../types";
|
|
7
|
+
|
|
8
|
+
const generateTransaction = jest.fn(() => "tx");
|
|
9
|
+
|
|
10
|
+
jest.mock("../../bridge/logic", () => ({
|
|
11
|
+
normalizeTransactionOptions: jest.fn(() => ({
|
|
12
|
+
maxGasAmount: "100",
|
|
13
|
+
gasUnitPrice: "200",
|
|
14
|
+
})),
|
|
15
|
+
DEFAULT_GAS: 100,
|
|
16
|
+
DEFAULT_GAS_PRICE: 200,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock("../../api", () => {
|
|
20
|
+
return {
|
|
21
|
+
AptosAPI: function () {
|
|
22
|
+
return {
|
|
23
|
+
generateTransaction,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("buildTransaction Test", () => {
|
|
30
|
+
it("should return tx", async () => {
|
|
31
|
+
const account = createFixtureAccount();
|
|
32
|
+
const transaction = createFixtureTransaction();
|
|
33
|
+
const aptosClient = new AptosAPI(account.currency.id);
|
|
34
|
+
const result = await buildTransaction(account, transaction, aptosClient);
|
|
35
|
+
|
|
36
|
+
const expected = "tx";
|
|
37
|
+
|
|
38
|
+
expect(result).toBe(expected);
|
|
39
|
+
|
|
40
|
+
const mockedNormalizeTransactionOptions = jest.mocked(normalizeTransactionOptions);
|
|
41
|
+
|
|
42
|
+
expect(mockedNormalizeTransactionOptions).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(generateTransaction).toHaveBeenCalledTimes(1);
|
|
44
|
+
|
|
45
|
+
const generateTransactionArgs: [string, InputEntryFunctionData, TransactionOptions][] =
|
|
46
|
+
generateTransaction.mock.calls[0];
|
|
47
|
+
|
|
48
|
+
expect(mockedNormalizeTransactionOptions.mock.calls[0][0]).toEqual({
|
|
49
|
+
maxGasAmount: "0",
|
|
50
|
+
gasUnitPrice: "0",
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(generateTransactionArgs[0]).toBe("address");
|
|
54
|
+
expect(generateTransactionArgs[1]).toEqual({
|
|
55
|
+
function: "0x1::aptos_account::transfer_coins",
|
|
56
|
+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
57
|
+
functionArguments: ["", "0"],
|
|
58
|
+
});
|
|
59
|
+
expect(generateTransactionArgs[2]).toEqual({ maxGasAmount: "100", gasUnitPrice: "200" });
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import createTransaction from "../../bridge/createTransaction";
|
|
3
|
+
|
|
4
|
+
jest.mock("../../bridge/logic", () => ({
|
|
5
|
+
DEFAULT_GAS: 100,
|
|
6
|
+
DEFAULT_GAS_PRICE: 200,
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
describe("createTransaction Test", () => {
|
|
10
|
+
it("should return a transaction object", async () => {
|
|
11
|
+
const result = createTransaction();
|
|
12
|
+
|
|
13
|
+
const expected = {
|
|
14
|
+
family: "aptos",
|
|
15
|
+
mode: "send",
|
|
16
|
+
amount: BigNumber(0),
|
|
17
|
+
recipient: "",
|
|
18
|
+
useAllAmount: false,
|
|
19
|
+
options: {
|
|
20
|
+
maxGasAmount: "100",
|
|
21
|
+
gasUnitPrice: "200",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
expect(result).toEqual(expected);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import getDeviceTransactionConfig, { methodToString } from "../../bridge/deviceTransactionConfig";
|
|
2
|
+
|
|
3
|
+
describe("deviceTransactionConfig", () => {
|
|
4
|
+
test("methodToString", () => {
|
|
5
|
+
expect(methodToString(0)).toBe("Coin transfer");
|
|
6
|
+
expect(methodToString(1)).toBe("Unknown");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("getDeviceTransactionConfig", () => {
|
|
10
|
+
const fields = getDeviceTransactionConfig();
|
|
11
|
+
expect(fields).toMatchObject([
|
|
12
|
+
{
|
|
13
|
+
type: "text",
|
|
14
|
+
label: "Type",
|
|
15
|
+
value: "Coin transfer",
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
});
|
|
19
|
+
});
|