@ledgerhq/coin-mina 1.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +24 -0
- package/CHANGELOG.md +15 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/jest.integ.config.js +8 -0
- package/lib/api/index.d.ts +13 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.integ.test.d.ts +2 -0
- package/lib/api/index.integ.test.d.ts.map +1 -0
- package/lib/api/index.integ.test.js +57 -0
- package/lib/api/index.integ.test.js.map +1 -0
- package/lib/api/index.js +91 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/rosetta/index.d.ts +9 -0
- package/lib/api/rosetta/index.d.ts.map +1 -0
- package/lib/api/rosetta/index.js +90 -0
- package/lib/api/rosetta/index.js.map +1 -0
- package/lib/api/rosetta/types.d.ts +143 -0
- package/lib/api/rosetta/types.d.ts.map +1 -0
- package/lib/api/rosetta/types.js +3 -0
- package/lib/api/rosetta/types.js.map +1 -0
- package/lib/api/rosetta/utils.d.ts +43 -0
- package/lib/api/rosetta/utils.d.ts.map +1 -0
- package/lib/api/rosetta/utils.js +60 -0
- package/lib/api/rosetta/utils.js.map +1 -0
- package/lib/api/rosetta/utils.test.d.ts +2 -0
- package/lib/api/rosetta/utils.test.d.ts.map +1 -0
- package/lib/api/rosetta/utils.test.js +82 -0
- package/lib/api/rosetta/utils.test.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +6 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +11 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/broadcast.test.d.ts +2 -0
- package/lib/bridge/broadcast.test.d.ts.map +1 -0
- package/lib/bridge/broadcast.test.js +36 -0
- package/lib/bridge/broadcast.test.js.map +1 -0
- package/lib/bridge/buildTransaction.d.ts +4 -0
- package/lib/bridge/buildTransaction.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.js +37 -0
- package/lib/bridge/buildTransaction.js.map +1 -0
- package/lib/bridge/buildTransaction.test.d.ts +2 -0
- package/lib/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.test.js +57 -0
- package/lib/bridge/buildTransaction.test.js.map +1 -0
- package/lib/bridge/cli-transaction.d.ts +18 -0
- package/lib/bridge/cli-transaction.d.ts.map +1 -0
- package/lib/bridge/cli-transaction.js +37 -0
- package/lib/bridge/cli-transaction.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 +21 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/createTransaction.test.d.ts +2 -0
- package/lib/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib/bridge/createTransaction.test.js +24 -0
- package/lib/bridge/createTransaction.test.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 +8 -0
- package/lib/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib/bridge/errors.d.ts +10 -0
- package/lib/bridge/errors.d.ts.map +1 -0
- package/lib/bridge/errors.js +17 -0
- package/lib/bridge/errors.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +5 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +26 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getEstimatedFees.d.ts +8 -0
- package/lib/bridge/getEstimatedFees.d.ts.map +1 -0
- package/lib/bridge/getEstimatedFees.js +9 -0
- package/lib/bridge/getEstimatedFees.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 +62 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.test.js +138 -0
- package/lib/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib/bridge/index.d.ts +14 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +59 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/index.test.d.ts +2 -0
- package/lib/bridge/index.test.d.ts.map +1 -0
- package/lib/bridge/index.test.js +32 -0
- package/lib/bridge/index.test.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +4 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +23 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.test.js +43 -0
- package/lib/bridge/prepareTransaction.test.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +12 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +72 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/signOperation.test.d.ts +2 -0
- package/lib/bridge/signOperation.test.d.ts.map +1 -0
- package/lib/bridge/signOperation.test.js +129 -0
- package/lib/bridge/signOperation.test.js.map +1 -0
- package/lib/bridge/synchronisation.d.ts +7 -0
- package/lib/bridge/synchronisation.d.ts.map +1 -0
- package/lib/bridge/synchronisation.js +155 -0
- package/lib/bridge/synchronisation.js.map +1 -0
- package/lib/bridge/synchronisation.test.d.ts +2 -0
- package/lib/bridge/synchronisation.test.d.ts.map +1 -0
- package/lib/bridge/synchronisation.test.js +164 -0
- package/lib/bridge/synchronisation.test.js.map +1 -0
- package/lib/bridge/transaction.d.ts +14 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +61 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/common-logic/index.d.ts +9 -0
- package/lib/common-logic/index.d.ts.map +1 -0
- package/lib/common-logic/index.js +96 -0
- package/lib/common-logic/index.js.map +1 -0
- package/lib/common-logic/index.test.d.ts +2 -0
- package/lib/common-logic/index.test.d.ts.map +1 -0
- package/lib/common-logic/index.test.js +181 -0
- package/lib/common-logic/index.test.js.map +1 -0
- package/lib/config.d.ts +9 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +16 -0
- package/lib/config.js.map +1 -0
- package/lib/consts.d.ts +16 -0
- package/lib/consts.d.ts.map +1 -0
- package/lib/consts.js +19 -0
- package/lib/consts.js.map +1 -0
- package/lib/signer/getAddress.d.ts +6 -0
- package/lib/signer/getAddress.d.ts.map +1 -0
- package/lib/signer/getAddress.js +22 -0
- package/lib/signer/getAddress.js.map +1 -0
- package/lib/signer/getAddress.test.d.ts +2 -0
- package/lib/signer/getAddress.test.d.ts.map +1 -0
- package/lib/signer/getAddress.test.js +106 -0
- package/lib/signer/getAddress.test.js.map +1 -0
- package/lib/signer/index.d.ts +3 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +8 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/test/bot-deviceActions.d.ts +4 -0
- package/lib/test/bot-deviceActions.d.ts.map +1 -0
- package/lib/test/bot-deviceActions.js +67 -0
- package/lib/test/bot-deviceActions.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 +107 -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 +174 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/fixtures.d.ts +55 -0
- package/lib/test/fixtures.d.ts.map +1 -0
- package/lib/test/fixtures.js +194 -0
- package/lib/test/fixtures.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/testUtils.d.ts +2 -0
- package/lib/test/testUtils.d.ts.map +1 -0
- package/lib/test/testUtils.js +8 -0
- package/lib/test/testUtils.js.map +1 -0
- package/lib/test/testUtils.test.d.ts +2 -0
- package/lib/test/testUtils.test.d.ts.map +1 -0
- package/lib/test/testUtils.test.js +11 -0
- package/lib/test/testUtils.test.js.map +1 -0
- package/lib/types/common.d.ts +55 -0
- package/lib/types/common.d.ts.map +1 -0
- package/lib/types/common.js +3 -0
- package/lib/types/common.js.map +1 -0
- package/lib/types/index.d.ts +3 -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 +32 -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/api/index.d.ts +13 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.integ.test.d.ts +2 -0
- package/lib-es/api/index.integ.test.d.ts.map +1 -0
- package/lib-es/api/index.integ.test.js +55 -0
- package/lib-es/api/index.integ.test.js.map +1 -0
- package/lib-es/api/index.js +79 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/rosetta/index.d.ts +8 -0
- package/lib-es/api/rosetta/index.d.ts.map +1 -0
- package/lib-es/api/rosetta/index.js +78 -0
- package/lib-es/api/rosetta/index.js.map +1 -0
- package/lib-es/api/rosetta/types.d.ts +143 -0
- package/lib-es/api/rosetta/types.d.ts.map +1 -0
- package/lib-es/api/rosetta/types.js +2 -0
- package/lib-es/api/rosetta/types.js.map +1 -0
- package/lib-es/api/rosetta/utils.d.ts +43 -0
- package/lib-es/api/rosetta/utils.d.ts.map +1 -0
- package/lib-es/api/rosetta/utils.js +54 -0
- package/lib-es/api/rosetta/utils.js.map +1 -0
- package/lib-es/api/rosetta/utils.test.d.ts +2 -0
- package/lib-es/api/rosetta/utils.test.d.ts.map +1 -0
- package/lib-es/api/rosetta/utils.test.js +80 -0
- package/lib-es/api/rosetta/utils.test.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +6 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +9 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/broadcast.test.d.ts +2 -0
- package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.test.js +31 -0
- package/lib-es/bridge/broadcast.test.js.map +1 -0
- package/lib-es/bridge/buildTransaction.d.ts +4 -0
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.js +30 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -0
- package/lib-es/bridge/buildTransaction.test.d.ts +2 -0
- package/lib-es/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.test.js +55 -0
- package/lib-es/bridge/buildTransaction.test.js.map +1 -0
- package/lib-es/bridge/cli-transaction.d.ts +18 -0
- package/lib-es/bridge/cli-transaction.d.ts.map +1 -0
- package/lib-es/bridge/cli-transaction.js +31 -0
- package/lib-es/bridge/cli-transaction.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 +14 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/createTransaction.test.d.ts +2 -0
- package/lib-es/bridge/createTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.test.js +19 -0
- package/lib-es/bridge/createTransaction.test.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 +6 -0
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib-es/bridge/errors.d.ts +10 -0
- package/lib-es/bridge/errors.d.ts.map +1 -0
- package/lib-es/bridge/errors.js +14 -0
- package/lib-es/bridge/errors.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +5 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +21 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getEstimatedFees.d.ts +8 -0
- package/lib-es/bridge/getEstimatedFees.d.ts.map +1 -0
- package/lib-es/bridge/getEstimatedFees.js +7 -0
- package/lib-es/bridge/getEstimatedFees.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 +60 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
- package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.test.js +133 -0
- package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
- package/lib-es/bridge/index.d.ts +14 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +50 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/index.test.d.ts +2 -0
- package/lib-es/bridge/index.test.d.ts.map +1 -0
- package/lib-es/bridge/index.test.js +30 -0
- package/lib-es/bridge/index.test.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +4 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +16 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
- package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.test.js +38 -0
- package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +12 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +64 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/signOperation.test.d.ts +2 -0
- package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.test.js +127 -0
- package/lib-es/bridge/signOperation.test.js.map +1 -0
- package/lib-es/bridge/synchronisation.d.ts +7 -0
- package/lib-es/bridge/synchronisation.d.ts.map +1 -0
- package/lib-es/bridge/synchronisation.js +147 -0
- package/lib-es/bridge/synchronisation.js.map +1 -0
- package/lib-es/bridge/synchronisation.test.d.ts +2 -0
- package/lib-es/bridge/synchronisation.test.d.ts.map +1 -0
- package/lib-es/bridge/synchronisation.test.js +159 -0
- package/lib-es/bridge/synchronisation.test.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +14 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +53 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/common-logic/index.d.ts +9 -0
- package/lib-es/common-logic/index.d.ts.map +1 -0
- package/lib-es/common-logic/index.js +84 -0
- package/lib-es/common-logic/index.js.map +1 -0
- package/lib-es/common-logic/index.test.d.ts +2 -0
- package/lib-es/common-logic/index.test.d.ts.map +1 -0
- package/lib-es/common-logic/index.test.js +179 -0
- package/lib-es/common-logic/index.test.js.map +1 -0
- package/lib-es/config.d.ts +9 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +11 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/consts.d.ts +16 -0
- package/lib-es/consts.d.ts.map +1 -0
- package/lib-es/consts.js +16 -0
- package/lib-es/consts.js.map +1 -0
- package/lib-es/signer/getAddress.d.ts +6 -0
- package/lib-es/signer/getAddress.d.ts.map +1 -0
- package/lib-es/signer/getAddress.js +17 -0
- package/lib-es/signer/getAddress.js.map +1 -0
- package/lib-es/signer/getAddress.test.d.ts +2 -0
- package/lib-es/signer/getAddress.test.d.ts.map +1 -0
- package/lib-es/signer/getAddress.test.js +101 -0
- package/lib-es/signer/getAddress.test.js.map +1 -0
- package/lib-es/signer/index.d.ts +3 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +3 -0
- package/lib-es/signer/index.js.map +1 -0
- package/lib-es/test/bot-deviceActions.d.ts +4 -0
- package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
- package/lib-es/test/bot-deviceActions.js +64 -0
- package/lib-es/test/bot-deviceActions.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 +102 -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 +171 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/fixtures.d.ts +55 -0
- package/lib-es/test/fixtures.d.ts.map +1 -0
- package/lib-es/test/fixtures.js +182 -0
- package/lib-es/test/fixtures.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/testUtils.d.ts +2 -0
- package/lib-es/test/testUtils.d.ts.map +1 -0
- package/lib-es/test/testUtils.js +4 -0
- package/lib-es/test/testUtils.js.map +1 -0
- package/lib-es/test/testUtils.test.d.ts +2 -0
- package/lib-es/test/testUtils.test.d.ts.map +1 -0
- package/lib-es/test/testUtils.test.js +9 -0
- package/lib-es/test/testUtils.test.js.map +1 -0
- package/lib-es/types/common.d.ts +55 -0
- package/lib-es/types/common.d.ts.map +1 -0
- package/lib-es/types/common.js +2 -0
- package/lib-es/types/common.js.map +1 -0
- package/lib-es/types/index.d.ts +3 -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 +32 -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 +143 -0
- package/src/api/index.integ.test.ts +62 -0
- package/src/api/index.ts +120 -0
- package/src/api/rosetta/index.ts +110 -0
- package/src/api/rosetta/types.ts +156 -0
- package/src/api/rosetta/utils.test.ts +100 -0
- package/src/api/rosetta/utils.ts +71 -0
- package/src/bridge/broadcast.test.ts +35 -0
- package/src/bridge/broadcast.ts +17 -0
- package/src/bridge/buildTransaction.test.ts +68 -0
- package/src/bridge/buildTransaction.ts +34 -0
- package/src/bridge/cli-transaction.ts +43 -0
- package/src/bridge/createTransaction.test.ts +21 -0
- package/src/bridge/createTransaction.ts +19 -0
- package/src/bridge/deviceTransactionConfig.ts +15 -0
- package/src/bridge/errors.ts +16 -0
- package/src/bridge/estimateMaxSpendable.ts +31 -0
- package/src/bridge/getEstimatedFees.ts +17 -0
- package/src/bridge/getTransactionStatus.test.ts +175 -0
- package/src/bridge/getTransactionStatus.ts +87 -0
- package/src/bridge/index.test.ts +39 -0
- package/src/bridge/index.ts +72 -0
- package/src/bridge/prepareTransaction.test.ts +43 -0
- package/src/bridge/prepareTransaction.ts +24 -0
- package/src/bridge/signOperation.test.ts +158 -0
- package/src/bridge/signOperation.ts +112 -0
- package/src/bridge/synchronisation.test.ts +184 -0
- package/src/bridge/synchronisation.ts +168 -0
- package/src/bridge/transaction.ts +69 -0
- package/src/common-logic/index.test.ts +225 -0
- package/src/common-logic/index.ts +97 -0
- package/src/config.ts +21 -0
- package/src/consts.ts +18 -0
- package/src/signer/getAddress.test.ts +131 -0
- package/src/signer/getAddress.ts +24 -0
- package/src/signer/index.ts +3 -0
- package/src/test/bot-deviceActions.ts +73 -0
- package/src/test/bot-specs.ts +130 -0
- package/src/test/bridgeDatasetTest.ts +180 -0
- package/src/test/fixtures.ts +226 -0
- package/src/test/index.ts +3 -0
- package/src/test/testUtils.test.ts +9 -0
- package/src/test/testUtils.ts +3 -0
- package/src/types/common.ts +70 -0
- package/src/types/index.ts +2 -0
- package/src/types/signer.ts +29 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import invariant from "invariant";
|
|
2
|
+
import { DeviceModelId } from "@ledgerhq/devices";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
import expect from "expect";
|
|
5
|
+
|
|
6
|
+
import type { MinaOperation, Transaction } from "../types/common";
|
|
7
|
+
import { genericTestDestination, botTest, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
|
|
8
|
+
import type { AppSpec, TransactionTestInput } from "@ledgerhq/coin-framework/bot/types";
|
|
9
|
+
import { acceptTransaction } from "./bot-deviceActions";
|
|
10
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
|
|
11
|
+
import { getRandomTransferID } from "./testUtils";
|
|
12
|
+
|
|
13
|
+
const maxAccount = 6;
|
|
14
|
+
// 0.1 MINA
|
|
15
|
+
const MIN_SAFE = new BigNumber(1 * 10 ** 8);
|
|
16
|
+
|
|
17
|
+
const minaSpecs: AppSpec<Transaction> = {
|
|
18
|
+
name: "Mina",
|
|
19
|
+
currency: getCryptoCurrencyById("mina"),
|
|
20
|
+
appQuery: {
|
|
21
|
+
model: DeviceModelId.nanoS,
|
|
22
|
+
appName: "Mina",
|
|
23
|
+
},
|
|
24
|
+
genericDeviceAction: acceptTransaction,
|
|
25
|
+
testTimeout: 15 * 60 * 1000,
|
|
26
|
+
minViableAmount: MIN_SAFE,
|
|
27
|
+
transactionCheck: ({ maxSpendable }) => {
|
|
28
|
+
invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
|
|
29
|
+
},
|
|
30
|
+
mutations: [
|
|
31
|
+
{
|
|
32
|
+
name: "Send ~50% to another account",
|
|
33
|
+
maxRun: 1,
|
|
34
|
+
testDestination: genericTestDestination,
|
|
35
|
+
feature: "send",
|
|
36
|
+
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
37
|
+
invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
|
|
38
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
39
|
+
const recipient = sibling.freshAddress;
|
|
40
|
+
const amount = maxSpendable.div(2).integerValue();
|
|
41
|
+
|
|
42
|
+
const transaction = bridge.createTransaction(account);
|
|
43
|
+
const updates: Array<Partial<Transaction>> = [
|
|
44
|
+
{
|
|
45
|
+
recipient,
|
|
46
|
+
},
|
|
47
|
+
{ amount },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
if (Math.random() < 0.5) {
|
|
51
|
+
updates.push({
|
|
52
|
+
memo: getRandomTransferID(),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
transaction,
|
|
58
|
+
updates,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
test: ({
|
|
63
|
+
accountBeforeTransaction,
|
|
64
|
+
operation,
|
|
65
|
+
account,
|
|
66
|
+
transaction,
|
|
67
|
+
}: TransactionTestInput<Transaction>) => {
|
|
68
|
+
botTest("account spendable balance decreased with operation", () =>
|
|
69
|
+
expect(account.spendableBalance).toEqual(
|
|
70
|
+
accountBeforeTransaction.spendableBalance
|
|
71
|
+
.minus(operation.value)
|
|
72
|
+
.minus((operation.extra as MinaOperation["extra"]).accountCreationFee),
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (transaction.memo) {
|
|
77
|
+
botTest("operation memo", () =>
|
|
78
|
+
expect(operation.extra).toMatchObject({
|
|
79
|
+
memo: transaction.memo,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "Transfer Max",
|
|
87
|
+
feature: "sendMax",
|
|
88
|
+
maxRun: 1,
|
|
89
|
+
transaction: ({ account, siblings, bridge }) => {
|
|
90
|
+
const updates: Array<Partial<Transaction>> = [
|
|
91
|
+
{
|
|
92
|
+
recipient: pickSiblings(siblings, maxAccount).freshAddress,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
useAllAmount: true,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
if (Math.random() < 0.5) {
|
|
100
|
+
updates.push({
|
|
101
|
+
memo: getRandomTransferID(),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
transaction: bridge.createTransaction(account),
|
|
107
|
+
updates,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
testDestination: genericTestDestination,
|
|
111
|
+
test: ({ account, transaction, operation }) => {
|
|
112
|
+
botTest("account spendable balance is zero", () =>
|
|
113
|
+
expect(account.spendableBalance.toString()).toBe("0"),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (transaction.memo) {
|
|
117
|
+
botTest("operation memo", () =>
|
|
118
|
+
expect(operation.extra).toMatchObject({
|
|
119
|
+
memo: transaction.memo,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export default {
|
|
129
|
+
minaSpecs,
|
|
130
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
AmountRequired,
|
|
4
|
+
InvalidAddress,
|
|
5
|
+
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
6
|
+
NotEnoughBalance,
|
|
7
|
+
} from "@ledgerhq/errors";
|
|
8
|
+
import type { DatasetTest, CurrenciesData } from "@ledgerhq/types-live";
|
|
9
|
+
import type { Transaction } from "../types/common";
|
|
10
|
+
import { fromTransactionRaw } from "../bridge/transaction";
|
|
11
|
+
import { InvalidMemoMina } from "../bridge/errors";
|
|
12
|
+
|
|
13
|
+
const ACCOUNT_ADDRESS = "B62qjWLs1W3J2fFGixeX49w1o7VvSGuMBNotnFhzs3PZ7PbtdFbhdeD";
|
|
14
|
+
const ACCOUNT_ADDRESS_1 = "B62qkWcHhoisWDCR7v3gvWzX6wXEVuGYLHXq3mSym4GEzfYXmSDv314";
|
|
15
|
+
|
|
16
|
+
const mina: CurrenciesData<Transaction> = {
|
|
17
|
+
FIXME_ignoreAccountFields: ["blockHash"],
|
|
18
|
+
scanAccounts: [
|
|
19
|
+
{
|
|
20
|
+
name: "mina seed 1",
|
|
21
|
+
apdus: `
|
|
22
|
+
=> e00201000400000000
|
|
23
|
+
<= 423632716a574c733157334a3266464769786558343977316f3756765347754d424e6f746e46687a7333505a3750627464466268646544009000
|
|
24
|
+
=> e00201000400000001
|
|
25
|
+
<= 423632716e4438387474693632364d694d6e7568504d624c69504c766664644657486a47667377795646754c5845614b644b366f344263009000
|
|
26
|
+
=> e00201000400000002
|
|
27
|
+
<= 423632716a7048577878544457506e474372714b546b56414b596f4e5250374c6e454b356564766d717151394658736e61313166674741009000
|
|
28
|
+
`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
accounts: [
|
|
32
|
+
{
|
|
33
|
+
// Skipping due to rewards being auto-compounded, no operation as evidence
|
|
34
|
+
FIXME_tests: ["balance is sum of ops"],
|
|
35
|
+
raw: {
|
|
36
|
+
id: `js:2:mina:${ACCOUNT_ADDRESS}:`,
|
|
37
|
+
seedIdentifier: `${ACCOUNT_ADDRESS}`,
|
|
38
|
+
name: "MINA 1",
|
|
39
|
+
derivationMode: "minabip44",
|
|
40
|
+
index: 0,
|
|
41
|
+
freshAddress: `${ACCOUNT_ADDRESS}`,
|
|
42
|
+
freshAddressPath: "44'/12586'/0'/0'/0'",
|
|
43
|
+
blockHeight: 0,
|
|
44
|
+
operations: [],
|
|
45
|
+
pendingOperations: [],
|
|
46
|
+
currencyId: "mina",
|
|
47
|
+
lastSyncDate: "",
|
|
48
|
+
balance: "1000000",
|
|
49
|
+
},
|
|
50
|
+
transactions: [
|
|
51
|
+
{
|
|
52
|
+
name: "not a valid address",
|
|
53
|
+
transaction: fromTransactionRaw({
|
|
54
|
+
family: "mina",
|
|
55
|
+
recipient: "novalidaddress",
|
|
56
|
+
fees: {
|
|
57
|
+
fee: new BigNumber(0).toString(),
|
|
58
|
+
accountCreationFee: new BigNumber(0).toString(),
|
|
59
|
+
},
|
|
60
|
+
amount: "1000",
|
|
61
|
+
memo: undefined,
|
|
62
|
+
nonce: 0,
|
|
63
|
+
}),
|
|
64
|
+
expectedStatus: {
|
|
65
|
+
errors: {
|
|
66
|
+
recipient: new InvalidAddress(),
|
|
67
|
+
},
|
|
68
|
+
warnings: {},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "not enough balance",
|
|
73
|
+
transaction: fromTransactionRaw({
|
|
74
|
+
family: "mina",
|
|
75
|
+
recipient: ACCOUNT_ADDRESS_1,
|
|
76
|
+
fees: {
|
|
77
|
+
fee: new BigNumber(0).toString(),
|
|
78
|
+
accountCreationFee: new BigNumber(0).toString(),
|
|
79
|
+
},
|
|
80
|
+
amount: (300 * 1e9).toString(),
|
|
81
|
+
memo: undefined,
|
|
82
|
+
nonce: 0,
|
|
83
|
+
}),
|
|
84
|
+
expectedStatus: {
|
|
85
|
+
errors: {
|
|
86
|
+
amount: new NotEnoughBalance(),
|
|
87
|
+
},
|
|
88
|
+
warnings: {},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "invalid Memo",
|
|
93
|
+
transaction: fromTransactionRaw({
|
|
94
|
+
family: "mina",
|
|
95
|
+
recipient: ACCOUNT_ADDRESS_1,
|
|
96
|
+
fees: {
|
|
97
|
+
fee: new BigNumber(0).toString(),
|
|
98
|
+
accountCreationFee: new BigNumber(0).toString(),
|
|
99
|
+
},
|
|
100
|
+
amount: "1000",
|
|
101
|
+
memo: "string greated than 32 chars is invalid",
|
|
102
|
+
nonce: 0,
|
|
103
|
+
}),
|
|
104
|
+
expectedStatus: {
|
|
105
|
+
errors: {
|
|
106
|
+
transaction: new InvalidMemoMina(),
|
|
107
|
+
},
|
|
108
|
+
warnings: {},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "amount Required",
|
|
113
|
+
transaction: fromTransactionRaw({
|
|
114
|
+
family: "mina",
|
|
115
|
+
recipient: ACCOUNT_ADDRESS_1,
|
|
116
|
+
memo: undefined,
|
|
117
|
+
amount: "0",
|
|
118
|
+
fees: {
|
|
119
|
+
fee: new BigNumber(0).toString(),
|
|
120
|
+
accountCreationFee: new BigNumber(0).toString(),
|
|
121
|
+
},
|
|
122
|
+
nonce: 0,
|
|
123
|
+
}),
|
|
124
|
+
expectedStatus: {
|
|
125
|
+
errors: {
|
|
126
|
+
amount: new AmountRequired(),
|
|
127
|
+
},
|
|
128
|
+
warnings: {},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "recipient same as source",
|
|
133
|
+
transaction: fromTransactionRaw({
|
|
134
|
+
family: "mina",
|
|
135
|
+
recipient: ACCOUNT_ADDRESS,
|
|
136
|
+
amount: "10",
|
|
137
|
+
fees: {
|
|
138
|
+
fee: new BigNumber(0).toString(),
|
|
139
|
+
accountCreationFee: new BigNumber(0).toString(),
|
|
140
|
+
},
|
|
141
|
+
memo: undefined,
|
|
142
|
+
nonce: 0,
|
|
143
|
+
}),
|
|
144
|
+
expectedStatus: {
|
|
145
|
+
errors: {
|
|
146
|
+
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
147
|
+
},
|
|
148
|
+
warnings: {},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "new account and sufficient amount",
|
|
153
|
+
transaction: fromTransactionRaw({
|
|
154
|
+
family: "mina",
|
|
155
|
+
recipient: ACCOUNT_ADDRESS_1,
|
|
156
|
+
amount: "1000",
|
|
157
|
+
fees: {
|
|
158
|
+
fee: new BigNumber(0).toString(),
|
|
159
|
+
accountCreationFee: new BigNumber(0).toString(),
|
|
160
|
+
},
|
|
161
|
+
memo: undefined,
|
|
162
|
+
nonce: 0,
|
|
163
|
+
}),
|
|
164
|
+
expectedStatus: {
|
|
165
|
+
amount: new BigNumber("1000"),
|
|
166
|
+
errors: {},
|
|
167
|
+
warnings: {},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const dataset: DatasetTest<Transaction> = {
|
|
176
|
+
implementations: ["js"],
|
|
177
|
+
currencies: {
|
|
178
|
+
mina,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { Account } from "@ledgerhq/types-live";
|
|
2
|
+
import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
3
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/lib/currencies";
|
|
4
|
+
import BigNumber from "bignumber.js";
|
|
5
|
+
import { RosettaBlockInfoResponse, RosettaTransaction } from "../api/rosetta/types";
|
|
6
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
7
|
+
import { MinaUnsignedTransaction } from "@ledgerhq/coin-mina/types";
|
|
8
|
+
import { DeviceId } from "@ledgerhq/types-live";
|
|
9
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
10
|
+
import { MinaSigner } from "@ledgerhq/coin-mina/types";
|
|
11
|
+
import { Transaction } from "../types";
|
|
12
|
+
|
|
13
|
+
// Mock account data
|
|
14
|
+
export const mockAccountData = {
|
|
15
|
+
blockHeight: 123,
|
|
16
|
+
balance: new BigNumber(1000),
|
|
17
|
+
spendableBalance: new BigNumber(900),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Mock block info
|
|
21
|
+
export const mockBlockInfo: RosettaBlockInfoResponse = {
|
|
22
|
+
block: {
|
|
23
|
+
block_identifier: { index: 123, hash: "block_hash" },
|
|
24
|
+
parent_block_identifier: { index: 122, hash: "parent_block_hash" },
|
|
25
|
+
timestamp: 1672531200000,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates a mock Rosetta transaction for testing
|
|
31
|
+
*/
|
|
32
|
+
export const createMockTxn = (options: {
|
|
33
|
+
type: string;
|
|
34
|
+
senderAddress: string;
|
|
35
|
+
receiverAddress: string;
|
|
36
|
+
status: "Success" | "Failed";
|
|
37
|
+
amount?: string;
|
|
38
|
+
fee?: string;
|
|
39
|
+
memo?: string;
|
|
40
|
+
}): RosettaTransaction => {
|
|
41
|
+
const {
|
|
42
|
+
type,
|
|
43
|
+
senderAddress,
|
|
44
|
+
receiverAddress,
|
|
45
|
+
amount = "1000",
|
|
46
|
+
fee = "100",
|
|
47
|
+
memo = "test memo",
|
|
48
|
+
status,
|
|
49
|
+
} = options;
|
|
50
|
+
|
|
51
|
+
const operations: RosettaTransaction["transaction"]["operations"] = [];
|
|
52
|
+
|
|
53
|
+
if (type !== "REDELEGATE") {
|
|
54
|
+
// Add fee operation for payment transactions
|
|
55
|
+
operations.push({
|
|
56
|
+
type: "fee_payment",
|
|
57
|
+
amount: { value: fee, currency: { symbol: "MINA", decimals: 9 } },
|
|
58
|
+
status,
|
|
59
|
+
account: { address: senderAddress, metadata: { token_id: "MINA" } },
|
|
60
|
+
operation_identifier: { index: 0 },
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
operations.push({
|
|
64
|
+
type: "payment_source_dec",
|
|
65
|
+
status,
|
|
66
|
+
account: { address: senderAddress, metadata: { token_id: "MINA" } },
|
|
67
|
+
operation_identifier: { index: 1 },
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
operations.push({
|
|
71
|
+
type: "payment_receiver_inc",
|
|
72
|
+
amount: { value: amount, currency: { symbol: "MINA", decimals: 9 } },
|
|
73
|
+
status,
|
|
74
|
+
account: { address: receiverAddress, metadata: { token_id: "MINA" } },
|
|
75
|
+
operation_identifier: { index: 2 },
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
// Delegate change operation
|
|
79
|
+
operations.push({
|
|
80
|
+
type: "delegate_change",
|
|
81
|
+
status,
|
|
82
|
+
account: { address: senderAddress, metadata: { token_id: "MINA" } },
|
|
83
|
+
operation_identifier: { index: 0 },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
transaction: {
|
|
89
|
+
transaction_identifier: { hash: "tx_hash" },
|
|
90
|
+
operations,
|
|
91
|
+
metadata: { memo },
|
|
92
|
+
},
|
|
93
|
+
block_identifier: { index: 123, hash: "block_hash" },
|
|
94
|
+
timestamp: 1672531200000,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates a mock account info object for testing
|
|
100
|
+
*/
|
|
101
|
+
export const createMockAccountInfo = (): AccountShapeInfo<Account> => ({
|
|
102
|
+
address: "test_address",
|
|
103
|
+
index: 0,
|
|
104
|
+
derivationPath: "m/44'/12586'/0'/0/0",
|
|
105
|
+
initialAccount: {
|
|
106
|
+
operations: [],
|
|
107
|
+
type: "Account",
|
|
108
|
+
id: "account_id",
|
|
109
|
+
seedIdentifier: "seed_identifier",
|
|
110
|
+
derivationMode: "minabip44",
|
|
111
|
+
index: 0,
|
|
112
|
+
freshAddress: "fresh_address",
|
|
113
|
+
freshAddressPath: "fresh_address_path",
|
|
114
|
+
used: true,
|
|
115
|
+
balance: new BigNumber(1000),
|
|
116
|
+
spendableBalance: new BigNumber(900),
|
|
117
|
+
creationDate: new Date(),
|
|
118
|
+
blockHeight: 123,
|
|
119
|
+
currency: getCryptoCurrencyById("mina") as CryptoCurrency,
|
|
120
|
+
operationsCount: 0,
|
|
121
|
+
pendingOperations: [],
|
|
122
|
+
lastSyncDate: new Date(),
|
|
123
|
+
subAccounts: [],
|
|
124
|
+
balanceHistoryCache: {
|
|
125
|
+
HOUR: { latestDate: null, balances: [] },
|
|
126
|
+
DAY: { latestDate: null, balances: [] },
|
|
127
|
+
WEEK: { latestDate: null, balances: [] },
|
|
128
|
+
},
|
|
129
|
+
swapHistory: [],
|
|
130
|
+
syncHash: undefined,
|
|
131
|
+
nfts: [],
|
|
132
|
+
},
|
|
133
|
+
currency: getCryptoCurrencyById("mina") as CryptoCurrency,
|
|
134
|
+
derivationMode: "minabip44",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Creates a mock Mina account for testing
|
|
139
|
+
*/
|
|
140
|
+
export const createMockAccount = (overrides?: Partial<Account>): Account => ({
|
|
141
|
+
id: "mock_account_id",
|
|
142
|
+
freshAddress: "B62qiVhtBtqakq8sNTHdCTXn6tETSK6gtsmNHRn1WdLqjGLpsHbw1xc",
|
|
143
|
+
freshAddressPath: "44'/12586'/0'/0/0",
|
|
144
|
+
type: "Account",
|
|
145
|
+
seedIdentifier: "seed_identifier",
|
|
146
|
+
derivationMode: "minabip44",
|
|
147
|
+
index: 0,
|
|
148
|
+
used: true,
|
|
149
|
+
balance: new BigNumber(1000),
|
|
150
|
+
spendableBalance: new BigNumber(900),
|
|
151
|
+
creationDate: new Date(),
|
|
152
|
+
blockHeight: 123,
|
|
153
|
+
currency: getCryptoCurrencyById("mina") as CryptoCurrency,
|
|
154
|
+
operationsCount: 0,
|
|
155
|
+
pendingOperations: [],
|
|
156
|
+
lastSyncDate: new Date(),
|
|
157
|
+
subAccounts: [],
|
|
158
|
+
balanceHistoryCache: {
|
|
159
|
+
HOUR: { latestDate: null, balances: [] },
|
|
160
|
+
DAY: { latestDate: null, balances: [] },
|
|
161
|
+
WEEK: { latestDate: null, balances: [] },
|
|
162
|
+
},
|
|
163
|
+
swapHistory: [],
|
|
164
|
+
syncHash: undefined,
|
|
165
|
+
nfts: [],
|
|
166
|
+
operations: [],
|
|
167
|
+
...overrides,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Creates a mock Mina transaction for testing
|
|
172
|
+
*/
|
|
173
|
+
export const createMockTransaction = (overrides?: Partial<Transaction>): Transaction => ({
|
|
174
|
+
family: "mina",
|
|
175
|
+
amount: new BigNumber(1000),
|
|
176
|
+
recipient: "B62qr5cXFjdnZXYxP5dEwRY7wENxcod4Q2oLxUDiq1QrBXZZyxMH8q4",
|
|
177
|
+
fees: {
|
|
178
|
+
fee: new BigNumber(10),
|
|
179
|
+
accountCreationFee: new BigNumber(0),
|
|
180
|
+
},
|
|
181
|
+
memo: "test memo",
|
|
182
|
+
nonce: 1,
|
|
183
|
+
...overrides,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Creates a mock unsigned transaction for testing
|
|
188
|
+
*/
|
|
189
|
+
export const createMockUnsignedTransaction = (
|
|
190
|
+
account: Partial<Account> = createMockAccount(),
|
|
191
|
+
transaction: Partial<Transaction> = createMockTransaction(),
|
|
192
|
+
): MinaUnsignedTransaction => ({
|
|
193
|
+
txType: 0,
|
|
194
|
+
senderAccount: 0,
|
|
195
|
+
senderAddress: account.freshAddress!,
|
|
196
|
+
receiverAddress: transaction.recipient!,
|
|
197
|
+
amount: transaction.amount!.toNumber(),
|
|
198
|
+
fee: transaction.fees!.fee.toNumber(),
|
|
199
|
+
nonce: transaction.nonce!,
|
|
200
|
+
memo: transaction.memo!,
|
|
201
|
+
networkId: 1,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Creates a mock device ID for testing
|
|
206
|
+
*/
|
|
207
|
+
export const mockDeviceId: DeviceId = "mock_device_id";
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Creates a mock signer context for testing
|
|
211
|
+
*/
|
|
212
|
+
export const createMockSignerContext = (
|
|
213
|
+
signatureResponse: { returnCode: string; signature: string } = {
|
|
214
|
+
returnCode: "0x9000",
|
|
215
|
+
signature: "mock_raw_signature",
|
|
216
|
+
},
|
|
217
|
+
): SignerContext<MinaSigner> =>
|
|
218
|
+
jest.fn().mockImplementation((deviceId, cb) => {
|
|
219
|
+
const mockSigner: MinaSigner = {
|
|
220
|
+
getAddress: jest.fn(),
|
|
221
|
+
signTransaction: jest.fn().mockResolvedValue(signatureResponse),
|
|
222
|
+
};
|
|
223
|
+
return cb(mockSigner);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// ... existing code ...
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
Account,
|
|
4
|
+
AccountRaw,
|
|
5
|
+
Operation,
|
|
6
|
+
TransactionCommon,
|
|
7
|
+
TransactionCommonRaw,
|
|
8
|
+
TransactionStatusCommon,
|
|
9
|
+
TransactionStatusCommonRaw,
|
|
10
|
+
} from "@ledgerhq/types-live";
|
|
11
|
+
|
|
12
|
+
export type Transaction = TransactionCommon & {
|
|
13
|
+
family: "mina";
|
|
14
|
+
fees: {
|
|
15
|
+
fee: BigNumber;
|
|
16
|
+
accountCreationFee: BigNumber;
|
|
17
|
+
};
|
|
18
|
+
memo: string | undefined;
|
|
19
|
+
nonce: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
23
|
+
family: "mina";
|
|
24
|
+
fees: {
|
|
25
|
+
fee: string;
|
|
26
|
+
accountCreationFee: string;
|
|
27
|
+
};
|
|
28
|
+
memo: string | undefined;
|
|
29
|
+
nonce: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type MinaAccount = Account;
|
|
33
|
+
|
|
34
|
+
export type MinaAPIAccount = {
|
|
35
|
+
blockHeight: number;
|
|
36
|
+
balance: BigNumber;
|
|
37
|
+
spendableBalance: BigNumber;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type MinaAccountRaw = AccountRaw;
|
|
41
|
+
|
|
42
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
43
|
+
|
|
44
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
45
|
+
|
|
46
|
+
export type StatusErrorMap = {
|
|
47
|
+
recipient?: Error;
|
|
48
|
+
amount?: Error;
|
|
49
|
+
fees?: Error;
|
|
50
|
+
transaction?: Error;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type MinaUnsignedTransaction = {
|
|
54
|
+
txType: number;
|
|
55
|
+
senderAccount: number;
|
|
56
|
+
senderAddress: string;
|
|
57
|
+
receiverAddress: string;
|
|
58
|
+
amount: number;
|
|
59
|
+
fee: number;
|
|
60
|
+
nonce: number;
|
|
61
|
+
memo: string;
|
|
62
|
+
networkId: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export interface MinaSignedTransaction {
|
|
66
|
+
signature: string;
|
|
67
|
+
transaction: MinaUnsignedTransaction;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type MinaOperation = Operation<{ memo: string | undefined; accountCreationFee: string }>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface SignTransactionArgs {
|
|
2
|
+
txType: number;
|
|
3
|
+
senderAccount: number;
|
|
4
|
+
senderAddress: string;
|
|
5
|
+
receiverAddress: string;
|
|
6
|
+
amount: number;
|
|
7
|
+
fee: number;
|
|
8
|
+
nonce: number;
|
|
9
|
+
validUntil?: number;
|
|
10
|
+
memo?: string;
|
|
11
|
+
networkId: number;
|
|
12
|
+
}
|
|
13
|
+
interface BaseLedgerResponse {
|
|
14
|
+
returnCode: string;
|
|
15
|
+
statusText?: string;
|
|
16
|
+
message?: string;
|
|
17
|
+
}
|
|
18
|
+
interface SignTransactionResponse extends BaseLedgerResponse {
|
|
19
|
+
signature?: string | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface GetAddressResponse extends BaseLedgerResponse {
|
|
23
|
+
publicKey?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export type MinaSignature = { signature?: string };
|
|
26
|
+
export interface MinaSigner {
|
|
27
|
+
getAddress(account?: number, verify?: boolean): Promise<GetAddressResponse>;
|
|
28
|
+
signTransaction(transaction: SignTransactionArgs): Promise<SignTransactionResponse>;
|
|
29
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"downlevelIteration": true,
|
|
7
|
+
"lib": ["es2020", "dom"],
|
|
8
|
+
"outDir": "lib",
|
|
9
|
+
"exactOptionalPropertyTypes": true,
|
|
10
|
+
"rootDir": "./src"
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"]
|
|
13
|
+
}
|