@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,156 @@
|
|
|
1
|
+
export type FetchNetworkStatusResponse = {
|
|
2
|
+
current_block_identifier: {
|
|
3
|
+
index: number;
|
|
4
|
+
hash: string;
|
|
5
|
+
};
|
|
6
|
+
current_block_timestamp: number;
|
|
7
|
+
genesis_block_identifier: {
|
|
8
|
+
index: number;
|
|
9
|
+
hash: string;
|
|
10
|
+
};
|
|
11
|
+
oldest_block_identifier: {
|
|
12
|
+
index: number;
|
|
13
|
+
hash: string;
|
|
14
|
+
};
|
|
15
|
+
sync_status: {
|
|
16
|
+
current_index: number;
|
|
17
|
+
stage: string;
|
|
18
|
+
synced: boolean;
|
|
19
|
+
};
|
|
20
|
+
peers: Array<{
|
|
21
|
+
peer_id: string;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type FetchAccountBalanceResponse = {
|
|
26
|
+
block_identifier: {
|
|
27
|
+
index: number;
|
|
28
|
+
hash: string;
|
|
29
|
+
};
|
|
30
|
+
balances: Array<{
|
|
31
|
+
value: string;
|
|
32
|
+
currency: {
|
|
33
|
+
symbol: string;
|
|
34
|
+
decimals: number;
|
|
35
|
+
};
|
|
36
|
+
metadata: {
|
|
37
|
+
locked_balance: number;
|
|
38
|
+
liquid_balance: number;
|
|
39
|
+
total_balance: number;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
metadata: {
|
|
43
|
+
created_via_historical_lookup: boolean;
|
|
44
|
+
nonce: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type RosettaTransaction = {
|
|
49
|
+
block_identifier: {
|
|
50
|
+
index: number;
|
|
51
|
+
hash: string;
|
|
52
|
+
};
|
|
53
|
+
transaction: {
|
|
54
|
+
transaction_identifier: {
|
|
55
|
+
hash: string;
|
|
56
|
+
};
|
|
57
|
+
operations: Array<{
|
|
58
|
+
operation_identifier: {
|
|
59
|
+
index: number;
|
|
60
|
+
};
|
|
61
|
+
type:
|
|
62
|
+
| "fee_payment"
|
|
63
|
+
| "payment_source_dec"
|
|
64
|
+
| "payment_receiver_inc"
|
|
65
|
+
| "account_creation_fee_via_payment"
|
|
66
|
+
| "zkapp_fee_payer_dec"
|
|
67
|
+
| "delegate_change"
|
|
68
|
+
| "zkapp_balance_update";
|
|
69
|
+
status: "Success" | "Failed";
|
|
70
|
+
account: {
|
|
71
|
+
address: string;
|
|
72
|
+
metadata: {
|
|
73
|
+
token_id: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
amount?: {
|
|
77
|
+
value: string;
|
|
78
|
+
currency: {
|
|
79
|
+
symbol: string;
|
|
80
|
+
decimals: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
related_operations?: Array<{
|
|
84
|
+
index: number;
|
|
85
|
+
}>;
|
|
86
|
+
metadata?: {
|
|
87
|
+
delegate_change_target?: string;
|
|
88
|
+
};
|
|
89
|
+
}>;
|
|
90
|
+
metadata?: {
|
|
91
|
+
memo?: string;
|
|
92
|
+
nonce?: number;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
timestamp: number;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type FetchAccountTransactionsResponse = {
|
|
99
|
+
transactions: RosettaTransaction[];
|
|
100
|
+
total_count: number;
|
|
101
|
+
next_offset?: number;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type RosettaPreprocessResponse = {
|
|
105
|
+
options: {
|
|
106
|
+
sender: string;
|
|
107
|
+
token_id: string;
|
|
108
|
+
receiver: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type RosettaMetadataResponse = {
|
|
113
|
+
metadata: {
|
|
114
|
+
sender: string;
|
|
115
|
+
nonce: string;
|
|
116
|
+
token_id: string;
|
|
117
|
+
receiver: string;
|
|
118
|
+
account_creation_fee?: string;
|
|
119
|
+
};
|
|
120
|
+
suggested_fee: Array<{
|
|
121
|
+
value: string;
|
|
122
|
+
currency: {
|
|
123
|
+
symbol: string;
|
|
124
|
+
decimals: number;
|
|
125
|
+
};
|
|
126
|
+
metadata: {
|
|
127
|
+
minimum_fee: {
|
|
128
|
+
value: string;
|
|
129
|
+
currency: {
|
|
130
|
+
symbol: string;
|
|
131
|
+
decimals: number;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}>;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type RosettaSubmitResponse = {
|
|
139
|
+
transaction_identifier: {
|
|
140
|
+
hash: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type RosettaBlockInfoResponse = {
|
|
145
|
+
block: {
|
|
146
|
+
block_identifier: {
|
|
147
|
+
index: number;
|
|
148
|
+
hash: string;
|
|
149
|
+
};
|
|
150
|
+
parent_block_identifier: {
|
|
151
|
+
index: number;
|
|
152
|
+
hash: string;
|
|
153
|
+
};
|
|
154
|
+
timestamp: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { addNetworkIdentifier, buildAccountIdentifier, makeTransferPayload } from "./utils";
|
|
2
|
+
import {
|
|
3
|
+
MINA_DECIMALS,
|
|
4
|
+
MINA_SYMBOL,
|
|
5
|
+
MINA_TOKEN_ID,
|
|
6
|
+
MAINNET_NETWORK_IDENTIFIER,
|
|
7
|
+
} from "../../consts";
|
|
8
|
+
|
|
9
|
+
describe("addNetworkIdentifier", () => {
|
|
10
|
+
it("should add network identifier to an empty object", () => {
|
|
11
|
+
const result = addNetworkIdentifier({});
|
|
12
|
+
expect(result).toEqual(MAINNET_NETWORK_IDENTIFIER);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should add network identifier to an object with existing properties", () => {
|
|
16
|
+
const testObj = { test: "value" };
|
|
17
|
+
const result = addNetworkIdentifier(testObj);
|
|
18
|
+
expect(result).toEqual({
|
|
19
|
+
...MAINNET_NETWORK_IDENTIFIER,
|
|
20
|
+
test: "value",
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should override network identifier properties if they exist in input object", () => {
|
|
25
|
+
// Assuming MAINNET_NETWORK_IDENTIFIER has a property like { blockchain: 'Mina' }
|
|
26
|
+
const testObj = { blockchain: "mina" };
|
|
27
|
+
const result = addNetworkIdentifier(testObj);
|
|
28
|
+
expect(result.network_identifier.blockchain).toEqual("mina");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe("buildAccountIdentifier", () => {
|
|
33
|
+
it("should build correct account identifier with given address", () => {
|
|
34
|
+
const testAddress = "B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdtNtB5sNVpxyRwWGcDEhpMzc8g";
|
|
35
|
+
const result = buildAccountIdentifier(testAddress);
|
|
36
|
+
|
|
37
|
+
expect(result).toEqual({
|
|
38
|
+
account_identifier: {
|
|
39
|
+
address: testAddress,
|
|
40
|
+
metadata: {
|
|
41
|
+
token_id: MINA_TOKEN_ID,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("makeTransferPayload", () => {
|
|
49
|
+
const fromAddr = "sender-address";
|
|
50
|
+
const toAddr = "recipient-address";
|
|
51
|
+
const feeNano = 1000000;
|
|
52
|
+
const valueNano = 5000000;
|
|
53
|
+
|
|
54
|
+
it("should create a valid transfer payload with three operations", () => {
|
|
55
|
+
const result = makeTransferPayload(fromAddr, toAddr, feeNano, valueNano);
|
|
56
|
+
|
|
57
|
+
expect(result.operations).toHaveLength(3);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should correctly create fee payment operation", () => {
|
|
61
|
+
const result = makeTransferPayload(fromAddr, toAddr, feeNano, valueNano);
|
|
62
|
+
|
|
63
|
+
const feeOp = result.operations[0];
|
|
64
|
+
expect(feeOp.operation_identifier.index).toBe(0);
|
|
65
|
+
expect(feeOp.type).toBe("fee_payment");
|
|
66
|
+
expect(feeOp.account.address).toBe(fromAddr);
|
|
67
|
+
expect(feeOp.amount.value).toBe("-" + feeNano.toString());
|
|
68
|
+
expect(feeOp.amount.currency.symbol).toBe(MINA_SYMBOL);
|
|
69
|
+
expect(feeOp.amount.currency.decimals).toBe(MINA_DECIMALS);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should correctly create payment source operation", () => {
|
|
73
|
+
const result = makeTransferPayload(fromAddr, toAddr, feeNano, valueNano);
|
|
74
|
+
|
|
75
|
+
const sourceOp = result.operations[1];
|
|
76
|
+
expect(sourceOp.operation_identifier.index).toBe(1);
|
|
77
|
+
expect(sourceOp.type).toBe("payment_source_dec");
|
|
78
|
+
expect(sourceOp.account.address).toBe(fromAddr);
|
|
79
|
+
expect(sourceOp.amount.value).toBe("-" + valueNano.toString());
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should correctly create payment receiver operation with related operation", () => {
|
|
83
|
+
const result = makeTransferPayload(fromAddr, toAddr, feeNano, valueNano);
|
|
84
|
+
|
|
85
|
+
const receiverOp = result.operations[2];
|
|
86
|
+
expect(receiverOp.operation_identifier.index).toBe(2);
|
|
87
|
+
expect(receiverOp.type).toBe("payment_receiver_inc");
|
|
88
|
+
expect(receiverOp.account.address).toBe(toAddr);
|
|
89
|
+
expect(receiverOp.amount.value).toBe(valueNano.toString());
|
|
90
|
+
expect(receiverOp.relatedOps.related_operations).toEqual([{ index: 1 }]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("should handle zero values correctly", () => {
|
|
94
|
+
const result = makeTransferPayload(fromAddr, toAddr, 0, 0);
|
|
95
|
+
|
|
96
|
+
expect(result.operations[0].amount.value).toBe("-0");
|
|
97
|
+
expect(result.operations[1].amount.value).toBe("-0");
|
|
98
|
+
expect(result.operations[2].amount.value).toBe("0");
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MINA_DECIMALS,
|
|
3
|
+
MINA_SYMBOL,
|
|
4
|
+
MINA_TOKEN_ID,
|
|
5
|
+
MAINNET_NETWORK_IDENTIFIER,
|
|
6
|
+
} from "../../consts";
|
|
7
|
+
|
|
8
|
+
export const addNetworkIdentifier = (data: object) => {
|
|
9
|
+
return {
|
|
10
|
+
...MAINNET_NETWORK_IDENTIFIER,
|
|
11
|
+
...data,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const buildAccountIdentifier = (address: string) => {
|
|
16
|
+
return {
|
|
17
|
+
account_identifier: {
|
|
18
|
+
address,
|
|
19
|
+
metadata: {
|
|
20
|
+
token_id: MINA_TOKEN_ID,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function makeTransferPayload(from: string, to: string, feeNano: number, valueNano: number) {
|
|
27
|
+
function makeOperation(
|
|
28
|
+
idx: number,
|
|
29
|
+
relatedIdxs: number[],
|
|
30
|
+
opType: string,
|
|
31
|
+
addr: string,
|
|
32
|
+
value: number,
|
|
33
|
+
isPositive: boolean,
|
|
34
|
+
) {
|
|
35
|
+
const relatedOps =
|
|
36
|
+
relatedIdxs.length == 0
|
|
37
|
+
? {}
|
|
38
|
+
: {
|
|
39
|
+
related_operations: relatedIdxs.map(i => {
|
|
40
|
+
return { index: i };
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
operation_identifier: { index: idx },
|
|
46
|
+
relatedOps,
|
|
47
|
+
type: opType,
|
|
48
|
+
account: {
|
|
49
|
+
address: addr,
|
|
50
|
+
metadata: {
|
|
51
|
+
token_id: MINA_TOKEN_ID,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
amount: {
|
|
55
|
+
value: (isPositive ? "" : "-") + value.toString(),
|
|
56
|
+
currency: {
|
|
57
|
+
symbol: MINA_SYMBOL,
|
|
58
|
+
decimals: MINA_DECIMALS,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
operations: [
|
|
66
|
+
makeOperation(0, [], "fee_payment", from, feeNano, false),
|
|
67
|
+
makeOperation(1, [], "payment_source_dec", from, valueNano, false),
|
|
68
|
+
makeOperation(2, [1], "payment_receiver_inc", to, valueNano, true),
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Account, BroadcastArg } from "@ledgerhq/types-live";
|
|
2
|
+
import broadcast from "./broadcast";
|
|
3
|
+
jest.mock("@ledgerhq/coin-framework/operation");
|
|
4
|
+
jest.mock("../api");
|
|
5
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
6
|
+
import { broadcastTransaction as broadcastLogic } from "../api";
|
|
7
|
+
|
|
8
|
+
describe("broadcast", () => {
|
|
9
|
+
let patchOperationSpy: jest.SpyInstance;
|
|
10
|
+
let broadcastSpy: jest.SpyInstance;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
patchOperationSpy = jest.spyOn({ patchOperationWithHash }, "patchOperationWithHash");
|
|
13
|
+
broadcastSpy = jest.spyOn({ broadcastLogic }, "broadcastLogic");
|
|
14
|
+
broadcastSpy.mockResolvedValue("hash");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const signedOperation = {
|
|
18
|
+
signature: JSON.stringify({}),
|
|
19
|
+
operation: undefined,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it("should broadcast", () => {
|
|
23
|
+
broadcast({
|
|
24
|
+
signedOperation,
|
|
25
|
+
} as unknown as BroadcastArg<Account>);
|
|
26
|
+
expect(broadcastLogic).toHaveBeenCalledTimes(1);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should patch operation with hash", () => {
|
|
30
|
+
broadcast({
|
|
31
|
+
signedOperation,
|
|
32
|
+
} as unknown as BroadcastArg<Account>);
|
|
33
|
+
expect(patchOperationSpy).toHaveBeenCalledWith(undefined, "hash");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
2
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
|
+
import { broadcastTransaction } from "../api";
|
|
4
|
+
import { MinaSignedTransaction } from "../types/common";
|
|
5
|
+
|
|
6
|
+
const broadcast = async ({
|
|
7
|
+
signedOperation: { signature, operation },
|
|
8
|
+
}: {
|
|
9
|
+
signedOperation: SignedOperation;
|
|
10
|
+
}): Promise<Operation> => {
|
|
11
|
+
const signedPayload = JSON.parse(signature) as MinaSignedTransaction;
|
|
12
|
+
const hash = await broadcastTransaction(signedPayload);
|
|
13
|
+
|
|
14
|
+
return patchOperationWithHash(operation, hash);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default broadcast;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Account } from "@ledgerhq/types-live";
|
|
2
|
+
import { buildTransaction } from "./buildTransaction";
|
|
3
|
+
import { MINA_MAINNET_NETWORK_ID, MINA_PAYMENT_TYPE_ID } from "../consts";
|
|
4
|
+
import { getAccountNumFromPath } from "../common-logic";
|
|
5
|
+
import { BigNumber } from "bignumber.js";
|
|
6
|
+
import { Transaction } from "../types";
|
|
7
|
+
jest.mock("../common-logic");
|
|
8
|
+
|
|
9
|
+
describe("buildTransaction", () => {
|
|
10
|
+
let getAccountNumSpy: jest.SpyInstance;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
getAccountNumSpy = jest.spyOn({ getAccountNumFromPath }, "getAccountNumFromPath");
|
|
14
|
+
getAccountNumSpy.mockReturnValue(42); // Mock account number
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const mockAccount: Partial<Account> = {
|
|
18
|
+
freshAddress: "B62qrPN5Y5yq8kGE3FbVKbGTdTAJNdHm8qSqZhhtiu1Dq56Cmuo2aJ4",
|
|
19
|
+
freshAddressPath: "44'/12586'/0'/0/0",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const mockTransaction: Transaction = {
|
|
23
|
+
recipient: "B62qoDWfBZUxKpaoQCoMPJEysXXWv7reVgo7CEAjqx1xAYs3CsT8Gtz",
|
|
24
|
+
amount: new BigNumber(1000000000),
|
|
25
|
+
fees: {
|
|
26
|
+
fee: new BigNumber(1000000),
|
|
27
|
+
accountCreationFee: new BigNumber(0),
|
|
28
|
+
},
|
|
29
|
+
nonce: 5,
|
|
30
|
+
memo: "test transaction",
|
|
31
|
+
family: "mina",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
it("should build a transaction correctly", async () => {
|
|
35
|
+
const result = await buildTransaction(mockAccount as Account, mockTransaction);
|
|
36
|
+
|
|
37
|
+
expect(result).toEqual({
|
|
38
|
+
txType: MINA_PAYMENT_TYPE_ID,
|
|
39
|
+
senderAccount: 42,
|
|
40
|
+
senderAddress: mockAccount.freshAddress,
|
|
41
|
+
receiverAddress: mockTransaction.recipient,
|
|
42
|
+
amount: mockTransaction.amount.toNumber(),
|
|
43
|
+
fee: mockTransaction.fees.fee.toNumber(),
|
|
44
|
+
nonce: mockTransaction.nonce,
|
|
45
|
+
memo: mockTransaction.memo,
|
|
46
|
+
networkId: MINA_MAINNET_NETWORK_ID,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(getAccountNumFromPath).toHaveBeenCalledWith(mockAccount.freshAddressPath);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should handle empty memo", async () => {
|
|
53
|
+
const txWithoutMemo = {
|
|
54
|
+
...mockTransaction,
|
|
55
|
+
memo: undefined,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const result = await buildTransaction(mockAccount as Account, txWithoutMemo);
|
|
59
|
+
|
|
60
|
+
expect(result.memo).toBe("");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should throw error if accountNum is undefined", async () => {
|
|
64
|
+
getAccountNumSpy.mockReturnValue(undefined);
|
|
65
|
+
|
|
66
|
+
await expect(buildTransaction(mockAccount as Account, mockTransaction)).rejects.toThrow();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { log } from "@ledgerhq/logs";
|
|
2
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
3
|
+
import type { MinaUnsignedTransaction, Transaction } from "../types/common";
|
|
4
|
+
import { MINA_MAINNET_NETWORK_ID, MINA_PAYMENT_TYPE_ID } from "../consts";
|
|
5
|
+
import { getAccountNumFromPath } from "../common-logic";
|
|
6
|
+
import invariant from "invariant";
|
|
7
|
+
|
|
8
|
+
export const buildTransaction = async (
|
|
9
|
+
a: Account,
|
|
10
|
+
t: Transaction,
|
|
11
|
+
): Promise<MinaUnsignedTransaction> => {
|
|
12
|
+
try {
|
|
13
|
+
const accountNum = getAccountNumFromPath(a.freshAddressPath);
|
|
14
|
+
invariant(accountNum !== undefined, "mina: accountNum is required to build transaction");
|
|
15
|
+
return {
|
|
16
|
+
txType: MINA_PAYMENT_TYPE_ID,
|
|
17
|
+
senderAccount: accountNum,
|
|
18
|
+
senderAddress: a.freshAddress,
|
|
19
|
+
receiverAddress: t.recipient,
|
|
20
|
+
amount: t.amount.toNumber(),
|
|
21
|
+
fee: t.fees.fee.toNumber(),
|
|
22
|
+
nonce: t.nonce,
|
|
23
|
+
memo: t.memo ?? "",
|
|
24
|
+
networkId: MINA_MAINNET_NETWORK_ID,
|
|
25
|
+
};
|
|
26
|
+
} catch (e) {
|
|
27
|
+
log("error", "mina: error building transaction", {
|
|
28
|
+
error: e,
|
|
29
|
+
transaction: t,
|
|
30
|
+
account: a,
|
|
31
|
+
});
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Account, AccountLike, AccountLikeArray } from "@ledgerhq/types-live";
|
|
2
|
+
import invariant from "invariant";
|
|
3
|
+
import flatMap from "lodash/flatMap";
|
|
4
|
+
import type { Transaction } from "../types/common";
|
|
5
|
+
|
|
6
|
+
const options = [
|
|
7
|
+
{
|
|
8
|
+
name: "memo",
|
|
9
|
+
type: String,
|
|
10
|
+
desc: "set a memo",
|
|
11
|
+
},
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function inferAccounts(account: Account): AccountLikeArray {
|
|
15
|
+
invariant(account.currency.family === "mina", "mina family");
|
|
16
|
+
return [account];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function inferTransactions(
|
|
20
|
+
transactions: Array<{
|
|
21
|
+
account: AccountLike;
|
|
22
|
+
transaction: Transaction;
|
|
23
|
+
}>,
|
|
24
|
+
opts: Record<string, string>,
|
|
25
|
+
): Transaction[] {
|
|
26
|
+
return flatMap(transactions, ({ transaction }) => {
|
|
27
|
+
invariant(transaction.family === "mina", "mina family");
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
...transaction,
|
|
31
|
+
family: "mina",
|
|
32
|
+
memo: opts.memo,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function makeCliTools() {
|
|
38
|
+
return {
|
|
39
|
+
options,
|
|
40
|
+
inferAccounts,
|
|
41
|
+
inferTransactions,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Account, AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import { createTransaction } from "./createTransaction";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
|
|
5
|
+
describe("createTransaction", () => {
|
|
6
|
+
it("should create a 0 amount transaction", () => {
|
|
7
|
+
expect(createTransaction({} as AccountLike<Account>).amount.toNumber()).toEqual(0);
|
|
8
|
+
expect(createTransaction({} as AccountLike<Account>).recipient).toEqual("");
|
|
9
|
+
expect(createTransaction({} as AccountLike<Account>).useAllAmount).toEqual(false);
|
|
10
|
+
expect(createTransaction({} as AccountLike<Account>).fees).toEqual({
|
|
11
|
+
fee: new BigNumber(0),
|
|
12
|
+
accountCreationFee: new BigNumber(0),
|
|
13
|
+
});
|
|
14
|
+
expect(createTransaction({} as AccountLike<Account>).memo).toEqual(undefined);
|
|
15
|
+
expect(createTransaction({} as AccountLike<Account>).nonce).toEqual(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should create a transaction with boilerplate family", () => {
|
|
19
|
+
expect(createTransaction({} as AccountLike<Account>).family).toEqual("mina");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { MinaAccount, Transaction } from "../types/common";
|
|
3
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
4
|
+
|
|
5
|
+
export const createTransaction: AccountBridge<
|
|
6
|
+
Transaction,
|
|
7
|
+
MinaAccount
|
|
8
|
+
>["createTransaction"] = () => ({
|
|
9
|
+
family: "mina",
|
|
10
|
+
amount: new BigNumber(0),
|
|
11
|
+
recipient: "",
|
|
12
|
+
useAllAmount: false,
|
|
13
|
+
fees: {
|
|
14
|
+
fee: new BigNumber(0),
|
|
15
|
+
accountCreationFee: new BigNumber(0),
|
|
16
|
+
},
|
|
17
|
+
memo: undefined,
|
|
18
|
+
nonce: 0,
|
|
19
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Account, AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction, TransactionStatus } from "../types/common";
|
|
3
|
+
import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
|
|
4
|
+
|
|
5
|
+
function getDeviceTransactionConfig(_input: {
|
|
6
|
+
account: AccountLike;
|
|
7
|
+
parentAccount: Account | null | undefined;
|
|
8
|
+
transaction: Transaction;
|
|
9
|
+
status: TransactionStatus;
|
|
10
|
+
}): Array<DeviceTransactionField> {
|
|
11
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
12
|
+
return fields;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default getDeviceTransactionConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* When the memo is greater than 32 characters
|
|
5
|
+
*/
|
|
6
|
+
export const InvalidMemoMina = createCustomErrorClass("InvalidMemoMina");
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* When the user sends less than the account creation fee of 1 MINA
|
|
10
|
+
*/
|
|
11
|
+
export const AccountCreationFeeWarning = createCustomErrorClass("AccountCreationFeeWarning");
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* When the amount is less than the account creation fee of 1 MINA
|
|
15
|
+
*/
|
|
16
|
+
export const AmountTooSmall = createCustomErrorClass("AmountTooSmall");
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { AccountBridge } from "@ledgerhq/types-live";
|
|
3
|
+
import type { Transaction, MinaAccount } from "../types/common";
|
|
4
|
+
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
|
|
5
|
+
import { getMaxAmount } from "../common-logic";
|
|
6
|
+
import { createTransaction } from "./createTransaction";
|
|
7
|
+
import getEstimatedFees from "./getEstimatedFees";
|
|
8
|
+
|
|
9
|
+
const estimateMaxSpendable: AccountBridge<
|
|
10
|
+
Transaction,
|
|
11
|
+
MinaAccount
|
|
12
|
+
>["estimateMaxSpendable"] = async ({ account, parentAccount, transaction }): Promise<BigNumber> => {
|
|
13
|
+
const a = getMainAccount(account, parentAccount) as MinaAccount;
|
|
14
|
+
const t = {
|
|
15
|
+
...createTransaction(account),
|
|
16
|
+
...transaction,
|
|
17
|
+
amount: a.spendableBalance,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { fee } = await getEstimatedFees(t, a.freshAddress);
|
|
21
|
+
|
|
22
|
+
const maxSpendable = getMaxAmount(a, t, fee);
|
|
23
|
+
|
|
24
|
+
if (maxSpendable.lt(0)) {
|
|
25
|
+
return new BigNumber(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return maxSpendable;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default estimateMaxSpendable;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { getFees } from "../api";
|
|
3
|
+
import { Transaction } from "../types/common";
|
|
4
|
+
|
|
5
|
+
const getEstimatedFees = async (
|
|
6
|
+
transaction: Transaction,
|
|
7
|
+
address: string,
|
|
8
|
+
): Promise<{
|
|
9
|
+
fee: BigNumber;
|
|
10
|
+
accountCreationFee: BigNumber;
|
|
11
|
+
}> => {
|
|
12
|
+
const { fee, accountCreationFee } = await getFees(transaction, address);
|
|
13
|
+
|
|
14
|
+
return { fee, accountCreationFee };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default getEstimatedFees;
|