@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,118 @@
|
|
|
1
|
+
import prepareTransaction from "../../bridge/prepareTransaction";
|
|
2
|
+
import { AptosAPI } from "../../api";
|
|
3
|
+
import { getEstimatedGas } from "../../bridge/getFeesForTransaction";
|
|
4
|
+
import { getMaxSendBalance } from "../../bridge/logic";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
7
|
+
import type { Transaction } from "../../types";
|
|
8
|
+
|
|
9
|
+
jest.mock("../../api");
|
|
10
|
+
jest.mock("../../bridge/getFeesForTransaction");
|
|
11
|
+
jest.mock("../../bridge/logic");
|
|
12
|
+
|
|
13
|
+
describe("Aptos prepareTransaction", () => {
|
|
14
|
+
describe("prepareTransaction", () => {
|
|
15
|
+
let account: Account;
|
|
16
|
+
let transaction: Transaction;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
account = {
|
|
20
|
+
id: "test-account-id",
|
|
21
|
+
name: "Test Account",
|
|
22
|
+
currency: {
|
|
23
|
+
id: "aptos",
|
|
24
|
+
name: "Aptos",
|
|
25
|
+
ticker: "APT",
|
|
26
|
+
units: [{ name: "Aptos", code: "APT", magnitude: 6 }],
|
|
27
|
+
},
|
|
28
|
+
spendableBalance: new BigNumber(1000),
|
|
29
|
+
balance: new BigNumber(1000),
|
|
30
|
+
blockHeight: 0,
|
|
31
|
+
operations: [],
|
|
32
|
+
pendingOperations: [],
|
|
33
|
+
unit: { code: "APT", name: "Aptos", magnitude: 6 },
|
|
34
|
+
lastSyncDate: new Date(),
|
|
35
|
+
subAccounts: [],
|
|
36
|
+
} as unknown as Account;
|
|
37
|
+
|
|
38
|
+
transaction = {
|
|
39
|
+
amount: new BigNumber(0),
|
|
40
|
+
recipient: "",
|
|
41
|
+
useAllAmount: false,
|
|
42
|
+
fees: new BigNumber(0),
|
|
43
|
+
} as Transaction;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should return the transaction if recipient is not set", async () => {
|
|
47
|
+
const result = await prepareTransaction(account, transaction);
|
|
48
|
+
expect(result).toEqual(transaction);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should return the transaction with zero fees if amount is zero and useAllAmount is false", async () => {
|
|
52
|
+
transaction.recipient = "test-recipient";
|
|
53
|
+
const result = await prepareTransaction(account, transaction);
|
|
54
|
+
expect(result.fees?.isZero()).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should set the amount to max sendable balance if useAllAmount is true", async () => {
|
|
58
|
+
transaction.recipient = "test-recipient";
|
|
59
|
+
transaction.useAllAmount = true;
|
|
60
|
+
(getMaxSendBalance as jest.Mock).mockReturnValue(new BigNumber(900));
|
|
61
|
+
(getEstimatedGas as jest.Mock).mockResolvedValue({
|
|
62
|
+
fees: new BigNumber(2000),
|
|
63
|
+
estimate: { maxGasAmount: new BigNumber(200), gasUnitPrice: new BigNumber(10) },
|
|
64
|
+
errors: {},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const result = await prepareTransaction(account, transaction);
|
|
68
|
+
expect(result.amount.isEqualTo(new BigNumber(900))).toBe(true);
|
|
69
|
+
expect(result.fees?.isEqualTo(new BigNumber(2000))).toBe(true);
|
|
70
|
+
expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
|
|
71
|
+
expect(result.errors).toEqual({});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should call getEstimatedGas and set the transaction fees, estimate, and errors", async () => {
|
|
75
|
+
transaction.recipient = "test-recipient";
|
|
76
|
+
transaction.amount = new BigNumber(100);
|
|
77
|
+
(getEstimatedGas as jest.Mock).mockResolvedValue({
|
|
78
|
+
fees: new BigNumber(10),
|
|
79
|
+
estimate: { maxGasAmount: new BigNumber(200) },
|
|
80
|
+
errors: {},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const result = await prepareTransaction(account, transaction);
|
|
84
|
+
expect(getEstimatedGas).toHaveBeenCalledWith(account, transaction, expect.any(AptosAPI));
|
|
85
|
+
expect(result.fees?.isEqualTo(new BigNumber(10))).toBe(true);
|
|
86
|
+
expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
|
|
87
|
+
expect(result.errors).toEqual({});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should return the transaction with updated fees and estimate if recipient is set and amount is not zero", async () => {
|
|
91
|
+
transaction.recipient = "test-recipient";
|
|
92
|
+
transaction.amount = new BigNumber(100);
|
|
93
|
+
(getEstimatedGas as jest.Mock).mockResolvedValue({
|
|
94
|
+
fees: new BigNumber(2000),
|
|
95
|
+
estimate: { maxGasAmount: new BigNumber(200), gasUnitPrice: new BigNumber(10) },
|
|
96
|
+
errors: {},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const result = await prepareTransaction(account, transaction);
|
|
100
|
+
expect(result.fees?.isEqualTo(new BigNumber(2000))).toBe(true);
|
|
101
|
+
expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
|
|
102
|
+
expect(result.errors).toEqual({});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("should set maxGasAmount in options", async () => {
|
|
106
|
+
transaction.recipient = "test-recipient";
|
|
107
|
+
transaction.amount = new BigNumber(100);
|
|
108
|
+
(getEstimatedGas as jest.Mock).mockResolvedValue({
|
|
109
|
+
fees: new BigNumber(2000),
|
|
110
|
+
estimate: { maxGasAmount: new BigNumber(200), gasUnitPrice: new BigNumber(10) },
|
|
111
|
+
errors: {},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const result = await prepareTransaction(account, transaction);
|
|
115
|
+
expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { SignerContext } from "@ledgerhq/coin-framework/lib/signer";
|
|
4
|
+
import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
|
|
5
|
+
import buildSignOperation, { getAddress } from "../../bridge/signOperation";
|
|
6
|
+
import { AptosSigner } from "../../types";
|
|
7
|
+
import { signTransaction } from "../../network";
|
|
8
|
+
|
|
9
|
+
jest.mock("../../api", () => {
|
|
10
|
+
return {
|
|
11
|
+
AptosAPI: function () {
|
|
12
|
+
return {
|
|
13
|
+
generateTransaction: jest.fn(() => "tx"),
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
jest.mock("../../bridge/buildTransaction", () => {
|
|
20
|
+
return function () {
|
|
21
|
+
return {
|
|
22
|
+
sequence_number: "789",
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
jest.mock("../../network");
|
|
28
|
+
let mockedSignTransaction: jest.Mocked<any>;
|
|
29
|
+
|
|
30
|
+
describe("getAddress", () => {
|
|
31
|
+
it("should return address and derivationPath", () => {
|
|
32
|
+
const account = createFixtureAccount();
|
|
33
|
+
expect(getAddress(account)).toEqual({ address: "address", derivationPath: "derivation_path" });
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("buildSignOperation", () => {
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
mockedSignTransaction = jest.mocked(signTransaction);
|
|
40
|
+
});
|
|
41
|
+
afterEach(() => jest.clearAllMocks());
|
|
42
|
+
|
|
43
|
+
it("should thrown an error", async () => {
|
|
44
|
+
mockedSignTransaction.mockImplementation(() => {
|
|
45
|
+
throw new Error("observable-catch-error");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const account = createFixtureAccount();
|
|
49
|
+
const transaction = createFixtureTransaction();
|
|
50
|
+
|
|
51
|
+
account.id = "js:2:aptos:0x000:";
|
|
52
|
+
transaction.mode = "send";
|
|
53
|
+
|
|
54
|
+
const observable = await buildSignOperation({} as unknown as SignerContext<AptosSigner>)({
|
|
55
|
+
account,
|
|
56
|
+
deviceId: "1",
|
|
57
|
+
transaction,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
observable.subscribe({
|
|
61
|
+
error: err => {
|
|
62
|
+
expect(err.message).toBe("observable-catch-error");
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should return 3 operations", async () => {
|
|
68
|
+
mockedSignTransaction.mockReturnValue("signedTx");
|
|
69
|
+
|
|
70
|
+
const date = new Date("2020-01-01");
|
|
71
|
+
jest.useFakeTimers().setSystemTime(date);
|
|
72
|
+
|
|
73
|
+
const account = createFixtureAccount();
|
|
74
|
+
const transaction = createFixtureTransaction();
|
|
75
|
+
|
|
76
|
+
account.id = "js:2:aptos:0x000:";
|
|
77
|
+
transaction.mode = "send";
|
|
78
|
+
|
|
79
|
+
const observable = await buildSignOperation({} as unknown as SignerContext<AptosSigner>)({
|
|
80
|
+
account,
|
|
81
|
+
deviceId: "1",
|
|
82
|
+
transaction,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(observable).toBeInstanceOf(Observable);
|
|
86
|
+
|
|
87
|
+
const expectedValues = [
|
|
88
|
+
{ type: "device-signature-requested" },
|
|
89
|
+
{ type: "device-signature-granted" },
|
|
90
|
+
{
|
|
91
|
+
type: "signed",
|
|
92
|
+
signedOperation: {
|
|
93
|
+
operation: {
|
|
94
|
+
id: "js:2:aptos:0x000:--OUT",
|
|
95
|
+
hash: "",
|
|
96
|
+
type: "OUT",
|
|
97
|
+
value: new BigNumber(0),
|
|
98
|
+
fee: new BigNumber(0),
|
|
99
|
+
extra: {},
|
|
100
|
+
blockHash: null,
|
|
101
|
+
blockHeight: null,
|
|
102
|
+
senders: [account.freshAddress],
|
|
103
|
+
recipients: [transaction.recipient],
|
|
104
|
+
accountId: "js:2:aptos:0x000:",
|
|
105
|
+
date,
|
|
106
|
+
transactionSequenceNumber: 789,
|
|
107
|
+
},
|
|
108
|
+
signature: "7369676e65645478",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
let i = 0;
|
|
114
|
+
|
|
115
|
+
observable.forEach(signOperationEvent => {
|
|
116
|
+
expect(signOperationEvent).toEqual(expectedValues[i]);
|
|
117
|
+
i++;
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("should return 3 operations with all amount", async () => {
|
|
122
|
+
mockedSignTransaction.mockReturnValue("signedTx");
|
|
123
|
+
|
|
124
|
+
const date = new Date("2020-01-01");
|
|
125
|
+
jest.useFakeTimers().setSystemTime(date);
|
|
126
|
+
|
|
127
|
+
const account = createFixtureAccount();
|
|
128
|
+
const transaction = createFixtureTransaction();
|
|
129
|
+
|
|
130
|
+
account.balance = new BigNumber(40);
|
|
131
|
+
transaction.fees = new BigNumber(30);
|
|
132
|
+
transaction.useAllAmount = true;
|
|
133
|
+
|
|
134
|
+
account.id = "js:2:aptos:0x000:";
|
|
135
|
+
transaction.mode = "send";
|
|
136
|
+
|
|
137
|
+
const observable = await buildSignOperation({} as unknown as SignerContext<AptosSigner>)({
|
|
138
|
+
account,
|
|
139
|
+
deviceId: "1",
|
|
140
|
+
transaction,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(observable).toBeInstanceOf(Observable);
|
|
144
|
+
|
|
145
|
+
const expectedValues = [
|
|
146
|
+
{ type: "device-signature-requested" },
|
|
147
|
+
{ type: "device-signature-granted" },
|
|
148
|
+
{
|
|
149
|
+
type: "signed",
|
|
150
|
+
signedOperation: {
|
|
151
|
+
operation: {
|
|
152
|
+
id: "js:2:aptos:0x000:--OUT",
|
|
153
|
+
hash: "",
|
|
154
|
+
type: "OUT",
|
|
155
|
+
value: new BigNumber(10),
|
|
156
|
+
fee: transaction.fees,
|
|
157
|
+
extra: {},
|
|
158
|
+
blockHash: null,
|
|
159
|
+
blockHeight: null,
|
|
160
|
+
senders: [account.freshAddress],
|
|
161
|
+
recipients: [transaction.recipient],
|
|
162
|
+
accountId: "js:2:aptos:0x000:",
|
|
163
|
+
date,
|
|
164
|
+
transactionSequenceNumber: 789,
|
|
165
|
+
},
|
|
166
|
+
signature: "7369676e65645478",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
let i = 0;
|
|
172
|
+
|
|
173
|
+
observable.forEach(signOperationEvent => {
|
|
174
|
+
expect(signOperationEvent).toEqual(expectedValues[i]);
|
|
175
|
+
i++;
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
2
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
|
|
3
|
+
import { Account, SyncConfig } from "@ledgerhq/types-live";
|
|
4
|
+
import { encodeAccountId } from "@ledgerhq/coin-framework/account";
|
|
5
|
+
import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
6
|
+
import { AptosAPI } from "../../api";
|
|
7
|
+
import { getAccountShape } from "../../bridge/synchronisation";
|
|
8
|
+
|
|
9
|
+
jest.mock("@ledgerhq/coin-framework/account", () => {
|
|
10
|
+
const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
|
|
11
|
+
const partialMockedModule = Object.keys(originalModule).reduce(
|
|
12
|
+
(pre: { [key: string]: jest.Mock }, methodName) => {
|
|
13
|
+
pre[methodName] = jest.fn();
|
|
14
|
+
return pre;
|
|
15
|
+
},
|
|
16
|
+
{} as { [key: string]: jest.Mock },
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
...partialMockedModule,
|
|
20
|
+
// mock all except these
|
|
21
|
+
decodeAccountId: originalModule.decodeAccountId,
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const mockedEncodeAccountId = jest.mocked(encodeAccountId);
|
|
26
|
+
|
|
27
|
+
jest.mock("../../api");
|
|
28
|
+
let mockedAptosAPI: jest.Mocked<any>;
|
|
29
|
+
|
|
30
|
+
jest.mock("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
31
|
+
jest.mock("invariant", () => jest.fn());
|
|
32
|
+
|
|
33
|
+
describe("getAccountShape", () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
mockedAptosAPI = jest.mocked(AptosAPI);
|
|
36
|
+
jest.mocked(mergeOps).mockReturnValue([]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
jest.resetAllMocks();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("account with xpub", async () => {
|
|
44
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
45
|
+
balance: BigInt(0),
|
|
46
|
+
transactions: [],
|
|
47
|
+
blockHeight: 0,
|
|
48
|
+
}));
|
|
49
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
50
|
+
getAccountInfo: mockGetAccountInfo,
|
|
51
|
+
}));
|
|
52
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
53
|
+
|
|
54
|
+
const account = await getAccountShape(
|
|
55
|
+
{
|
|
56
|
+
id: "1",
|
|
57
|
+
address: "address",
|
|
58
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
59
|
+
derivationMode: "",
|
|
60
|
+
index: 0,
|
|
61
|
+
xpub: "address",
|
|
62
|
+
derivationPath: "",
|
|
63
|
+
deviceId: "1",
|
|
64
|
+
initialAccount: {
|
|
65
|
+
id: "1:1:1:1:1",
|
|
66
|
+
xpub: "address",
|
|
67
|
+
seedIdentifier: "1",
|
|
68
|
+
derivationMode: "",
|
|
69
|
+
index: 0,
|
|
70
|
+
freshAddress: "address",
|
|
71
|
+
freshAddressPath: "",
|
|
72
|
+
used: true,
|
|
73
|
+
balance: BigInt(10),
|
|
74
|
+
spendableBalance: BigInt(10),
|
|
75
|
+
creationDate: new Date(),
|
|
76
|
+
blockHeight: 0,
|
|
77
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
78
|
+
operationsCount: 0,
|
|
79
|
+
operations: [],
|
|
80
|
+
pendingOperations: [],
|
|
81
|
+
lastSyncDate: new Date(),
|
|
82
|
+
balanceHistoryCache: {},
|
|
83
|
+
swapHistory: [],
|
|
84
|
+
},
|
|
85
|
+
} as unknown as AccountShapeInfo<Account>,
|
|
86
|
+
{} as SyncConfig,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(account.xpub).toEqual("address");
|
|
90
|
+
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
91
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
92
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("account without xpub", async () => {
|
|
96
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
97
|
+
balance: BigInt(0),
|
|
98
|
+
transactions: [],
|
|
99
|
+
blockHeight: 0,
|
|
100
|
+
}));
|
|
101
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
102
|
+
getAccountInfo: mockGetAccountInfo,
|
|
103
|
+
}));
|
|
104
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
105
|
+
|
|
106
|
+
const account = await getAccountShape(
|
|
107
|
+
{
|
|
108
|
+
id: "1",
|
|
109
|
+
address: "address",
|
|
110
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
111
|
+
derivationMode: "",
|
|
112
|
+
index: 0,
|
|
113
|
+
xpub: "address",
|
|
114
|
+
derivationPath: "",
|
|
115
|
+
deviceId: "1",
|
|
116
|
+
initialAccount: {
|
|
117
|
+
id: "1:1:1:1:1",
|
|
118
|
+
seedIdentifier: "1",
|
|
119
|
+
derivationMode: "",
|
|
120
|
+
index: 0,
|
|
121
|
+
freshAddress: "address",
|
|
122
|
+
freshAddressPath: "",
|
|
123
|
+
used: true,
|
|
124
|
+
balance: BigInt(10),
|
|
125
|
+
spendableBalance: BigInt(10),
|
|
126
|
+
creationDate: new Date(),
|
|
127
|
+
blockHeight: 0,
|
|
128
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
129
|
+
operationsCount: 0,
|
|
130
|
+
operations: [],
|
|
131
|
+
pendingOperations: [],
|
|
132
|
+
lastSyncDate: new Date(),
|
|
133
|
+
balanceHistoryCache: {},
|
|
134
|
+
swapHistory: [],
|
|
135
|
+
},
|
|
136
|
+
} as unknown as AccountShapeInfo<Account>,
|
|
137
|
+
{} as SyncConfig,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect(account.xpub).toEqual("1");
|
|
141
|
+
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
142
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
143
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("without initialAccount", async () => {
|
|
147
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
148
|
+
balance: BigInt(0),
|
|
149
|
+
transactions: [],
|
|
150
|
+
blockHeight: 0,
|
|
151
|
+
}));
|
|
152
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
153
|
+
getAccountInfo: mockGetAccountInfo,
|
|
154
|
+
}));
|
|
155
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
156
|
+
|
|
157
|
+
const account = await getAccountShape(
|
|
158
|
+
{
|
|
159
|
+
id: "1",
|
|
160
|
+
address: "address",
|
|
161
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
162
|
+
derivationMode: "",
|
|
163
|
+
index: 0,
|
|
164
|
+
xpub: "address",
|
|
165
|
+
derivationPath: "",
|
|
166
|
+
deviceId: "1",
|
|
167
|
+
} as unknown as AccountShapeInfo<Account>,
|
|
168
|
+
{} as SyncConfig,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(account.xpub).toEqual("");
|
|
172
|
+
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
173
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
174
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("initialAccount with operations", async () => {
|
|
178
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
179
|
+
balance: BigInt(0),
|
|
180
|
+
transactions: [],
|
|
181
|
+
blockHeight: 0,
|
|
182
|
+
}));
|
|
183
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
184
|
+
getAccountInfo: mockGetAccountInfo,
|
|
185
|
+
}));
|
|
186
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
187
|
+
|
|
188
|
+
const account = await getAccountShape(
|
|
189
|
+
{
|
|
190
|
+
id: "1",
|
|
191
|
+
address: "address",
|
|
192
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
193
|
+
derivationMode: "",
|
|
194
|
+
index: 0,
|
|
195
|
+
xpub: "address",
|
|
196
|
+
derivationPath: "",
|
|
197
|
+
deviceId: "1",
|
|
198
|
+
initialAccount: {
|
|
199
|
+
id: "1:1:1:1:1",
|
|
200
|
+
seedIdentifier: "1",
|
|
201
|
+
derivationMode: "",
|
|
202
|
+
index: 0,
|
|
203
|
+
freshAddress: "address",
|
|
204
|
+
freshAddressPath: "",
|
|
205
|
+
used: true,
|
|
206
|
+
balance: BigInt(10),
|
|
207
|
+
spendableBalance: BigInt(10),
|
|
208
|
+
creationDate: new Date(),
|
|
209
|
+
blockHeight: 0,
|
|
210
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
211
|
+
t: 1,
|
|
212
|
+
operations: [
|
|
213
|
+
{
|
|
214
|
+
id: "1",
|
|
215
|
+
hash: "hash",
|
|
216
|
+
type: "OUT",
|
|
217
|
+
value: BigInt(10),
|
|
218
|
+
fee: BigInt(0),
|
|
219
|
+
blockHeight: 0,
|
|
220
|
+
blockHash: "blockHash",
|
|
221
|
+
accountId: "1",
|
|
222
|
+
senders: ["sender"],
|
|
223
|
+
recipients: ["recipient"],
|
|
224
|
+
date: new Date(),
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
pendingOperations: [],
|
|
228
|
+
lastSyncDate: new Date(),
|
|
229
|
+
balanceHistoryCache: {},
|
|
230
|
+
swapHistory: [],
|
|
231
|
+
},
|
|
232
|
+
} as unknown as AccountShapeInfo<Account>,
|
|
233
|
+
{} as SyncConfig,
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
expect(account.xpub).toEqual("1");
|
|
237
|
+
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
238
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
239
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("initialAccount with operations with extra", async () => {
|
|
243
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
244
|
+
balance: BigInt(0),
|
|
245
|
+
transactions: [],
|
|
246
|
+
blockHeight: 0,
|
|
247
|
+
}));
|
|
248
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
249
|
+
getAccountInfo: mockGetAccountInfo,
|
|
250
|
+
}));
|
|
251
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
252
|
+
|
|
253
|
+
const account = await getAccountShape(
|
|
254
|
+
{
|
|
255
|
+
id: "1",
|
|
256
|
+
address: "address",
|
|
257
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
258
|
+
derivationMode: "",
|
|
259
|
+
index: 0,
|
|
260
|
+
xpub: "address",
|
|
261
|
+
derivationPath: "",
|
|
262
|
+
deviceId: "1",
|
|
263
|
+
initialAccount: {
|
|
264
|
+
id: "1:1:1:1:1",
|
|
265
|
+
seedIdentifier: "1",
|
|
266
|
+
derivationMode: "",
|
|
267
|
+
index: 0,
|
|
268
|
+
freshAddress: "address",
|
|
269
|
+
freshAddressPath: "",
|
|
270
|
+
used: true,
|
|
271
|
+
balance: BigInt(10),
|
|
272
|
+
spendableBalance: BigInt(10),
|
|
273
|
+
creationDate: new Date(),
|
|
274
|
+
blockHeight: 0,
|
|
275
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
276
|
+
t: 1,
|
|
277
|
+
operations: [
|
|
278
|
+
{
|
|
279
|
+
id: "1",
|
|
280
|
+
hash: "hash",
|
|
281
|
+
type: "OUT",
|
|
282
|
+
value: BigInt(10),
|
|
283
|
+
fee: BigInt(0),
|
|
284
|
+
blockHeight: 0,
|
|
285
|
+
blockHash: "blockHash",
|
|
286
|
+
accountId: "1",
|
|
287
|
+
senders: ["sender"],
|
|
288
|
+
recipients: ["recipient"],
|
|
289
|
+
date: new Date(),
|
|
290
|
+
extra: { version: 1 },
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
pendingOperations: [],
|
|
294
|
+
lastSyncDate: new Date(),
|
|
295
|
+
balanceHistoryCache: {},
|
|
296
|
+
swapHistory: [],
|
|
297
|
+
},
|
|
298
|
+
} as unknown as AccountShapeInfo<Account>,
|
|
299
|
+
{} as SyncConfig,
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
expect(account.xpub).toEqual("1");
|
|
303
|
+
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
304
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
305
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address", 1);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("get publicKey from rest", async () => {
|
|
309
|
+
const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
|
|
310
|
+
balance: BigInt(0),
|
|
311
|
+
transactions: [],
|
|
312
|
+
blockHeight: 0,
|
|
313
|
+
}));
|
|
314
|
+
mockedAptosAPI.mockImplementation(() => ({
|
|
315
|
+
getAccountInfo: mockGetAccountInfo,
|
|
316
|
+
}));
|
|
317
|
+
const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
|
|
318
|
+
|
|
319
|
+
const account = await getAccountShape(
|
|
320
|
+
{
|
|
321
|
+
id: "1",
|
|
322
|
+
address: "address",
|
|
323
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
324
|
+
derivationMode: "",
|
|
325
|
+
index: 0,
|
|
326
|
+
xpub: "address",
|
|
327
|
+
derivationPath: "",
|
|
328
|
+
deviceId: "1",
|
|
329
|
+
initialAccount: {
|
|
330
|
+
id: "1:1:1:1:1",
|
|
331
|
+
seedIdentifier: "1",
|
|
332
|
+
derivationMode: "",
|
|
333
|
+
index: 0,
|
|
334
|
+
freshAddress: "address",
|
|
335
|
+
freshAddressPath: "",
|
|
336
|
+
used: true,
|
|
337
|
+
balance: BigInt(10),
|
|
338
|
+
spendableBalance: BigInt(10),
|
|
339
|
+
creationDate: new Date(),
|
|
340
|
+
blockHeight: 0,
|
|
341
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
342
|
+
t: 1,
|
|
343
|
+
operations: [
|
|
344
|
+
{
|
|
345
|
+
id: "1",
|
|
346
|
+
hash: "hash",
|
|
347
|
+
type: "OUT",
|
|
348
|
+
value: BigInt(10),
|
|
349
|
+
fee: BigInt(0),
|
|
350
|
+
blockHeight: 0,
|
|
351
|
+
blockHash: "blockHash",
|
|
352
|
+
accountId: "1",
|
|
353
|
+
senders: ["sender"],
|
|
354
|
+
recipients: ["recipient"],
|
|
355
|
+
date: new Date(),
|
|
356
|
+
extra: { version: 1 },
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
pendingOperations: [],
|
|
360
|
+
lastSyncDate: new Date(),
|
|
361
|
+
balanceHistoryCache: {},
|
|
362
|
+
swapHistory: [],
|
|
363
|
+
},
|
|
364
|
+
rest: { publicKey: "restPublicKey" },
|
|
365
|
+
} as unknown as AccountShapeInfo<Account>,
|
|
366
|
+
{} as SyncConfig,
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
expect(account.xpub).toEqual("restPublicKey");
|
|
370
|
+
expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
|
|
371
|
+
expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
|
|
372
|
+
expect(mockGetAccountSpy).toHaveBeenCalledWith("address", 1);
|
|
373
|
+
});
|
|
374
|
+
});
|