@ledgerhq/coin-canton 0.2.0-nightly.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/.env.integ.test.example +2 -0
- package/.eslintrc.js +22 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +29 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +21 -0
- package/jest.integ.config.js +8 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +44 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/index.test.d.ts +2 -0
- package/lib/api/index.test.d.ts.map +1 -0
- package/lib/api/index.test.js +16 -0
- package/lib/api/index.test.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +4 -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 +35 -0
- package/lib/bridge/broadcast.test.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 +19 -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 +12 -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 +21 -0
- package/lib/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib/bridge/deviceTransactionConfig.test.d.ts +2 -0
- package/lib/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
- package/lib/bridge/deviceTransactionConfig.test.js +22 -0
- package/lib/bridge/deviceTransactionConfig.test.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +4 -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/getTransactionStatus.d.ts +4 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +78 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +11 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +51 -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 +31 -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 +20 -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 +30 -0
- package/lib/bridge/prepareTransaction.test.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +5 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +71 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/sync.d.ts +3 -0
- package/lib/bridge/sync.d.ts.map +1 -0
- package/lib/bridge/sync.js +86 -0
- package/lib/bridge/sync.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 +50 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/bridge/updateTransaction.d.ts +4 -0
- package/lib/bridge/updateTransaction.d.ts.map +1 -0
- package/lib/bridge/updateTransaction.js +17 -0
- package/lib/bridge/updateTransaction.js.map +1 -0
- package/lib/common-logic/account/getBalance.d.ts +3 -0
- package/lib/common-logic/account/getBalance.d.ts.map +1 -0
- package/lib/common-logic/account/getBalance.js +10 -0
- package/lib/common-logic/account/getBalance.js.map +1 -0
- package/lib/common-logic/account/getNextSequence.d.ts +2 -0
- package/lib/common-logic/account/getNextSequence.d.ts.map +1 -0
- package/lib/common-logic/account/getNextSequence.js +9 -0
- package/lib/common-logic/account/getNextSequence.js.map +1 -0
- package/lib/common-logic/common.d.ts +3 -0
- package/lib/common-logic/common.d.ts.map +1 -0
- package/lib/common-logic/common.js +11 -0
- package/lib/common-logic/common.js.map +1 -0
- package/lib/common-logic/history/lastBlock.d.ts +3 -0
- package/lib/common-logic/history/lastBlock.d.ts.map +1 -0
- package/lib/common-logic/history/lastBlock.js +13 -0
- package/lib/common-logic/history/lastBlock.js.map +1 -0
- package/lib/common-logic/history/listOperations.d.ts +11 -0
- package/lib/common-logic/history/listOperations.d.ts.map +1 -0
- package/lib/common-logic/history/listOperations.js +52 -0
- package/lib/common-logic/history/listOperations.js.map +1 -0
- package/lib/common-logic/index.d.ts +11 -0
- package/lib/common-logic/index.d.ts.map +1 -0
- package/lib/common-logic/index.js +24 -0
- package/lib/common-logic/index.js.map +1 -0
- package/lib/common-logic/transaction/broadcast.d.ts +2 -0
- package/lib/common-logic/transaction/broadcast.d.ts.map +1 -0
- package/lib/common-logic/transaction/broadcast.js +9 -0
- package/lib/common-logic/transaction/broadcast.js.map +1 -0
- package/lib/common-logic/transaction/combine.d.ts +2 -0
- package/lib/common-logic/transaction/combine.d.ts.map +1 -0
- package/lib/common-logic/transaction/combine.js +9 -0
- package/lib/common-logic/transaction/combine.js.map +1 -0
- package/lib/common-logic/transaction/craftTransaction.d.ts +15 -0
- package/lib/common-logic/transaction/craftTransaction.d.ts.map +1 -0
- package/lib/common-logic/transaction/craftTransaction.js +20 -0
- package/lib/common-logic/transaction/craftTransaction.js.map +1 -0
- package/lib/common-logic/transaction/estimateFees.d.ts +2 -0
- package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -0
- package/lib/common-logic/transaction/estimateFees.js +21 -0
- package/lib/common-logic/transaction/estimateFees.js.map +1 -0
- package/lib/common-logic/utils.d.ts +6 -0
- package/lib/common-logic/utils.d.ts.map +1 -0
- package/lib/common-logic/utils.js +22 -0
- package/lib/common-logic/utils.js.map +1 -0
- package/lib/config.d.ts +12 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +9 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +4 -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/indexer.d.ts +6 -0
- package/lib/network/indexer.d.ts.map +1 -0
- package/lib/network/indexer.js +19 -0
- package/lib/network/indexer.js.map +1 -0
- package/lib/network/mock-network.d.ts +5 -0
- package/lib/network/mock-network.d.ts.map +1 -0
- package/lib/network/mock-network.js +29 -0
- package/lib/network/mock-network.js.map +1 -0
- package/lib/network/node.d.ts +12 -0
- package/lib/network/node.d.ts.map +1 -0
- package/lib/network/node.js +92 -0
- package/lib/network/node.js.map +1 -0
- package/lib/network/types.d.ts +47 -0
- package/lib/network/types.d.ts.map +1 -0
- package/lib/network/types.js +7 -0
- package/lib/network/types.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 +14 -0
- package/lib/signer/getAddress.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 +11 -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 +44 -0
- package/lib/test/bot-deviceActions.js.map +1 -0
- package/lib/test/bot-specs.d.ts +2 -0
- package/lib/test/bot-specs.d.ts.map +1 -0
- package/lib/test/bot-specs.js +79 -0
- package/lib/test/bot-specs.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts +5 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib/test/bridgeDatasetTest.js +148 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +26 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +36 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +5 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +26 -0
- package/lib/test/index.js.map +1 -0
- package/lib/types/bridge.d.ts +23 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.js +3 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/errors.d.ts +4 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +6 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/index.d.ts +13 -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 +10 -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 +4 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +38 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/index.test.d.ts +2 -0
- package/lib-es/api/index.test.d.ts.map +1 -0
- package/lib-es/api/index.test.js +14 -0
- package/lib-es/api/index.test.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +4 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +7 -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 +33 -0
- package/lib-es/bridge/broadcast.test.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 +12 -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 +10 -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 +19 -0
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.test.d.ts +2 -0
- package/lib-es/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.test.js +17 -0
- package/lib-es/bridge/deviceTransactionConfig.test.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +19 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +71 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +11 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +45 -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 +29 -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 +13 -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 +25 -0
- package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +5 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +67 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/sync.d.ts +3 -0
- package/lib-es/bridge/sync.d.ts.map +1 -0
- package/lib-es/bridge/sync.js +79 -0
- package/lib-es/bridge/sync.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 +44 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/bridge/updateTransaction.d.ts +4 -0
- package/lib-es/bridge/updateTransaction.d.ts.map +1 -0
- package/lib-es/bridge/updateTransaction.js +13 -0
- package/lib-es/bridge/updateTransaction.js.map +1 -0
- package/lib-es/common-logic/account/getBalance.d.ts +3 -0
- package/lib-es/common-logic/account/getBalance.d.ts.map +1 -0
- package/lib-es/common-logic/account/getBalance.js +7 -0
- package/lib-es/common-logic/account/getBalance.js.map +1 -0
- package/lib-es/common-logic/account/getNextSequence.d.ts +2 -0
- package/lib-es/common-logic/account/getNextSequence.d.ts.map +1 -0
- package/lib-es/common-logic/account/getNextSequence.js +6 -0
- package/lib-es/common-logic/account/getNextSequence.js.map +1 -0
- package/lib-es/common-logic/common.d.ts +3 -0
- package/lib-es/common-logic/common.d.ts.map +1 -0
- package/lib-es/common-logic/common.js +7 -0
- package/lib-es/common-logic/common.js.map +1 -0
- package/lib-es/common-logic/history/lastBlock.d.ts +3 -0
- package/lib-es/common-logic/history/lastBlock.d.ts.map +1 -0
- package/lib-es/common-logic/history/lastBlock.js +10 -0
- package/lib-es/common-logic/history/lastBlock.js.map +1 -0
- package/lib-es/common-logic/history/listOperations.d.ts +11 -0
- package/lib-es/common-logic/history/listOperations.d.ts.map +1 -0
- package/lib-es/common-logic/history/listOperations.js +49 -0
- package/lib-es/common-logic/history/listOperations.js.map +1 -0
- package/lib-es/common-logic/index.d.ts +11 -0
- package/lib-es/common-logic/index.d.ts.map +1 -0
- package/lib-es/common-logic/index.js +11 -0
- package/lib-es/common-logic/index.js.map +1 -0
- package/lib-es/common-logic/transaction/broadcast.d.ts +2 -0
- package/lib-es/common-logic/transaction/broadcast.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/broadcast.js +6 -0
- package/lib-es/common-logic/transaction/broadcast.js.map +1 -0
- package/lib-es/common-logic/transaction/combine.d.ts +2 -0
- package/lib-es/common-logic/transaction/combine.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/combine.js +6 -0
- package/lib-es/common-logic/transaction/combine.js.map +1 -0
- package/lib-es/common-logic/transaction/craftTransaction.d.ts +15 -0
- package/lib-es/common-logic/transaction/craftTransaction.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/craftTransaction.js +17 -0
- package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -0
- package/lib-es/common-logic/transaction/estimateFees.d.ts +2 -0
- package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/estimateFees.js +18 -0
- package/lib-es/common-logic/transaction/estimateFees.js.map +1 -0
- package/lib-es/common-logic/utils.d.ts +6 -0
- package/lib-es/common-logic/utils.d.ts.map +1 -0
- package/lib-es/common-logic/utils.js +13 -0
- package/lib-es/common-logic/utils.js.map +1 -0
- package/lib-es/config.d.ts +12 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +4 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/index.d.ts +4 -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/indexer.d.ts +6 -0
- package/lib-es/network/indexer.d.ts.map +1 -0
- package/lib-es/network/indexer.js +12 -0
- package/lib-es/network/indexer.js.map +1 -0
- package/lib-es/network/mock-network.d.ts +5 -0
- package/lib-es/network/mock-network.d.ts.map +1 -0
- package/lib-es/network/mock-network.js +25 -0
- package/lib-es/network/mock-network.js.map +1 -0
- package/lib-es/network/node.d.ts +12 -0
- package/lib-es/network/node.d.ts.map +1 -0
- package/lib-es/network/node.js +80 -0
- package/lib-es/network/node.js.map +1 -0
- package/lib-es/network/types.d.ts +47 -0
- package/lib-es/network/types.d.ts.map +1 -0
- package/lib-es/network/types.js +4 -0
- package/lib-es/network/types.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 +12 -0
- package/lib-es/signer/getAddress.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 +6 -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 +41 -0
- package/lib-es/test/bot-deviceActions.js.map +1 -0
- package/lib-es/test/bot-specs.d.ts +1 -0
- package/lib-es/test/bot-specs.d.ts.map +1 -0
- package/lib-es/test/bot-specs.js +78 -0
- package/lib-es/test/bot-specs.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts +5 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib-es/test/bridgeDatasetTest.js +142 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +26 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +30 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +5 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +6 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/types/bridge.d.ts +23 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.js +2 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/errors.d.ts +4 -0
- package/lib-es/types/errors.d.ts.map +1 -0
- package/lib-es/types/errors.js +3 -0
- package/lib-es/types/errors.js.map +1 -0
- package/lib-es/types/index.d.ts +13 -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 +10 -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 +137 -0
- package/src/api/index.test.ts +15 -0
- package/src/api/index.ts +65 -0
- package/src/bridge/broadcast.test.ts +36 -0
- package/src/bridge/broadcast.ts +11 -0
- package/src/bridge/createTransaction.test.ts +12 -0
- package/src/bridge/createTransaction.ts +14 -0
- package/src/bridge/deviceTransactionConfig.test.ts +22 -0
- package/src/bridge/deviceTransactionConfig.ts +34 -0
- package/src/bridge/estimateMaxSpendable.ts +25 -0
- package/src/bridge/getTransactionStatus.ts +88 -0
- package/src/bridge/index.test.ts +31 -0
- package/src/bridge/index.ts +62 -0
- package/src/bridge/prepareTransaction.test.ts +29 -0
- package/src/bridge/prepareTransaction.ts +25 -0
- package/src/bridge/signOperation.ts +93 -0
- package/src/bridge/sync.ts +106 -0
- package/src/bridge/transaction.ts +61 -0
- package/src/bridge/updateTransaction.ts +17 -0
- package/src/common-logic/account/getBalance.ts +8 -0
- package/src/common-logic/account/getNextSequence.ts +6 -0
- package/src/common-logic/common.ts +9 -0
- package/src/common-logic/history/lastBlock.ts +11 -0
- package/src/common-logic/history/listOperations.ts +64 -0
- package/src/common-logic/index.ts +11 -0
- package/src/common-logic/transaction/broadcast.ts +6 -0
- package/src/common-logic/transaction/combine.ts +6 -0
- package/src/common-logic/transaction/craftTransaction.ts +36 -0
- package/src/common-logic/transaction/estimateFees.ts +16 -0
- package/src/common-logic/utils.ts +18 -0
- package/src/config.ts +12 -0
- package/src/index.ts +4 -0
- package/src/network/indexer.ts +17 -0
- package/src/network/mock-network.ts +25 -0
- package/src/network/node.ts +94 -0
- package/src/network/types.ts +51 -0
- package/src/signer/getAddress.ts +20 -0
- package/src/signer/index.ts +7 -0
- package/src/test/bot-deviceActions.ts +48 -0
- package/src/test/bot-specs.ts +76 -0
- package/src/test/bridgeDatasetTest.ts +147 -0
- package/src/test/cli.ts +44 -0
- package/src/test/index.ts +6 -0
- package/src/types/bridge.ts +33 -0
- package/src/types/errors.ts +3 -0
- package/src/types/index.ts +13 -0
- package/src/types/signer.ts +11 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction } from "../types";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
declare function inferTransactions(transactions: Array<{
|
|
5
|
+
account: AccountLike;
|
|
6
|
+
transaction: Transaction;
|
|
7
|
+
}>, opts: {
|
|
8
|
+
tag?: number | null | undefined;
|
|
9
|
+
fee?: string;
|
|
10
|
+
}, { inferAmount, }: {
|
|
11
|
+
inferAmount: (account: AccountLike, fee?: string) => BigNumber | null | undefined;
|
|
12
|
+
}): Transaction[];
|
|
13
|
+
export default function makeCliTools(): {
|
|
14
|
+
options: ({
|
|
15
|
+
name: string;
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
desc: string;
|
|
18
|
+
} | {
|
|
19
|
+
name: string;
|
|
20
|
+
type: NumberConstructor;
|
|
21
|
+
desc: string;
|
|
22
|
+
})[];
|
|
23
|
+
inferTransactions: typeof inferTransactions;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/test/cli.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,SAAS,MAAM,cAAc,CAAC;AAerC,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,EACF,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACvD,EACE,WAAW,GACZ,EAAE;IAAE,WAAW,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,SAAS,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GACvF,WAAW,EAAE,CASf;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;;;;;;;;;;;EAKnC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import invariant from "invariant";
|
|
2
|
+
const options = [
|
|
3
|
+
{
|
|
4
|
+
name: "fee",
|
|
5
|
+
type: String,
|
|
6
|
+
desc: "how much fee",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
name: "tag",
|
|
10
|
+
type: Number,
|
|
11
|
+
desc: "ripple tag",
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
function inferTransactions(transactions, opts, { inferAmount, }) {
|
|
15
|
+
return transactions.flatMap(({ transaction, account }) => {
|
|
16
|
+
invariant(transaction.family === "canton", "Canton family");
|
|
17
|
+
return {
|
|
18
|
+
...transaction,
|
|
19
|
+
fee: inferAmount(account, opts.fee || "0.001brp"),
|
|
20
|
+
tag: opts.tag,
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export default function makeCliTools() {
|
|
25
|
+
return {
|
|
26
|
+
options,
|
|
27
|
+
inferTransactions,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/test/cli.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAKlC,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,cAAc;KACrB;IACD;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,YAAY;KACnB;CACF,CAAC;AAEF,SAAS,iBAAiB,CACxB,YAGE,EACF,IAAuD,EACvD,EACE,WAAW,GAC2E;IAExF,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QACvD,SAAS,CAAC,WAAW,CAAC,MAAM,KAAK,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC5D,OAAO;YACL,GAAG,WAAW;YACd,GAAG,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC;YACjD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,OAAO;QACL,OAAO;QACP,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,OAAO,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,OAAO,CAAC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,+BAA+B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw } from "@ledgerhq/types-live";
|
|
3
|
+
export type NetworkInfo = {
|
|
4
|
+
family: "canton";
|
|
5
|
+
serverFee: BigNumber;
|
|
6
|
+
baseReserve: BigNumber;
|
|
7
|
+
};
|
|
8
|
+
export type NetworkInfoRaw = {
|
|
9
|
+
family: "canton";
|
|
10
|
+
serverFee: string;
|
|
11
|
+
baseReserve: string;
|
|
12
|
+
};
|
|
13
|
+
export type Transaction = TransactionCommon & {
|
|
14
|
+
family: "canton";
|
|
15
|
+
fee: BigNumber | null | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
18
|
+
family: "canton";
|
|
19
|
+
fee: string | null | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
22
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
23
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC5C,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AACxD,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;EAA4C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./bridge";
|
|
2
|
+
export * from "./signer";
|
|
3
|
+
export type BoilerplateNativeTransaction = {
|
|
4
|
+
TransactionType: "Payment";
|
|
5
|
+
Account: string;
|
|
6
|
+
Amount: string;
|
|
7
|
+
Destination: string;
|
|
8
|
+
Fee: string;
|
|
9
|
+
Sequence: number;
|
|
10
|
+
SigningPubKey?: string;
|
|
11
|
+
TxnSignature?: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,MAAM,MAAM,4BAA4B,GAAG;IACzC,eAAe,EAAE,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type BoilerplateAddress = {
|
|
2
|
+
publicKey: string;
|
|
3
|
+
address: string;
|
|
4
|
+
};
|
|
5
|
+
export type BoilerplateSignature = string;
|
|
6
|
+
export interface BoilerplateSigner {
|
|
7
|
+
getAddress(path: string): Promise<BoilerplateAddress>;
|
|
8
|
+
signTransaction(path: string, rawTx: string): Promise<BoilerplateSignature>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ledgerhq/coin-canton",
|
|
3
|
+
"version": "0.2.0-nightly.0",
|
|
4
|
+
"description": "Canton coin integration",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Ledger",
|
|
7
|
+
"LedgerWallet",
|
|
8
|
+
"canton",
|
|
9
|
+
"Hardware Wallet"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/LedgerHQ/ledger-live/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-canton",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
"lib/*": [
|
|
25
|
+
"lib/*"
|
|
26
|
+
],
|
|
27
|
+
"lib-es/*": [
|
|
28
|
+
"lib-es/*"
|
|
29
|
+
],
|
|
30
|
+
"api": [
|
|
31
|
+
"lib/api/index"
|
|
32
|
+
],
|
|
33
|
+
"deviceTransactionConfig": [
|
|
34
|
+
"lib/bridge/deviceTransactionConfig"
|
|
35
|
+
],
|
|
36
|
+
"logic": [
|
|
37
|
+
"lib/logic/index"
|
|
38
|
+
],
|
|
39
|
+
"specs": [
|
|
40
|
+
"lib/test/bot-specs"
|
|
41
|
+
],
|
|
42
|
+
"transaction": [
|
|
43
|
+
"lib/bridge/transaction"
|
|
44
|
+
],
|
|
45
|
+
"types": [
|
|
46
|
+
"lib/types/index"
|
|
47
|
+
],
|
|
48
|
+
"*": [
|
|
49
|
+
"lib/*",
|
|
50
|
+
"lib/bridge/*",
|
|
51
|
+
"lib/logic/*",
|
|
52
|
+
"lib/signer/*",
|
|
53
|
+
"lib/test/*",
|
|
54
|
+
"lib/types/*"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"exports": {
|
|
59
|
+
"./lib/*": "./lib/*.js",
|
|
60
|
+
"./lib-es/*": "./lib-es/*.js",
|
|
61
|
+
"./api": {
|
|
62
|
+
"require": "./lib/api/index.js",
|
|
63
|
+
"default": "./lib-es/api/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./deviceTransactionConfig": {
|
|
66
|
+
"require": "./lib/bridge/deviceTransactionConfig.js",
|
|
67
|
+
"default": "./lib-es/bridge/deviceTransactionConfig.js"
|
|
68
|
+
},
|
|
69
|
+
"./logic": {
|
|
70
|
+
"require": "./lib/logic/index.js",
|
|
71
|
+
"default": "./lib-es/logic/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./signer": {
|
|
74
|
+
"require": "./lib/signer/index.js",
|
|
75
|
+
"default": "./lib-es/signer/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./specs": {
|
|
78
|
+
"require": "./lib/test/bot-specs.js",
|
|
79
|
+
"default": "./lib-es/test/bot-specs.js"
|
|
80
|
+
},
|
|
81
|
+
"./transaction": {
|
|
82
|
+
"require": "./lib/bridge/transaction.js",
|
|
83
|
+
"default": "./lib-es/bridge/transaction.js"
|
|
84
|
+
},
|
|
85
|
+
"./types": {
|
|
86
|
+
"require": "./lib/types/index.js",
|
|
87
|
+
"default": "./lib-es/types/index.js"
|
|
88
|
+
},
|
|
89
|
+
"./*": {
|
|
90
|
+
"require": "./lib/*.js",
|
|
91
|
+
"default": "./lib-es/*.js"
|
|
92
|
+
},
|
|
93
|
+
".": {
|
|
94
|
+
"require": "./lib/index.js",
|
|
95
|
+
"default": "./lib-es/index.js"
|
|
96
|
+
},
|
|
97
|
+
"./package.json": "./package.json"
|
|
98
|
+
},
|
|
99
|
+
"license": "Apache-2.0",
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"bignumber.js": "^9.1.2",
|
|
102
|
+
"invariant": "^2.2.4",
|
|
103
|
+
"rxjs": "^7.8.1",
|
|
104
|
+
"@ledgerhq/coin-framework": "^6.0.0-nightly.3",
|
|
105
|
+
"@ledgerhq/cryptoassets": "^13.23.0-nightly.2",
|
|
106
|
+
"@ledgerhq/devices": "8.4.8",
|
|
107
|
+
"@ledgerhq/errors": "^6.23.0",
|
|
108
|
+
"@ledgerhq/live-env": "^2.13.0-nightly.0",
|
|
109
|
+
"@ledgerhq/live-network": "^2.0.14-nightly.0",
|
|
110
|
+
"@ledgerhq/types-live": "^6.79.0-nightly.1"
|
|
111
|
+
},
|
|
112
|
+
"devDependencies": {
|
|
113
|
+
"@types/invariant": "^2.2.37",
|
|
114
|
+
"@types/jest": "^29.5.12",
|
|
115
|
+
"dotenv": "^16.4.5",
|
|
116
|
+
"expect": "^27.4.6",
|
|
117
|
+
"jest": "^29.7.0",
|
|
118
|
+
"ts-jest": "^29.1.1",
|
|
119
|
+
"typescript": "^5.4.5",
|
|
120
|
+
"@ledgerhq/types-cryptoassets": "^7.24.0-nightly.1",
|
|
121
|
+
"@ledgerhq/disable-network-setup": "^0.0.0"
|
|
122
|
+
},
|
|
123
|
+
"scripts": {
|
|
124
|
+
"clean": "rimraf lib lib-es",
|
|
125
|
+
"build": "tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es",
|
|
126
|
+
"coverage": "jest --coverage || true",
|
|
127
|
+
"prewatch": "pnpm build",
|
|
128
|
+
"watch": "tsc --watch",
|
|
129
|
+
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
|
|
130
|
+
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
|
|
131
|
+
"lint:fix": "pnpm lint --fix",
|
|
132
|
+
"test": "jest",
|
|
133
|
+
"test-integ": "DOTENV_CONFIG_PATH=.env.integ.test jest --config=jest.integ.config.js --passWithNoTests",
|
|
134
|
+
"typecheck": "tsc --noEmit",
|
|
135
|
+
"unimported": "unimported"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createApi } from ".";
|
|
2
|
+
import { CantonConfig } from "../config";
|
|
3
|
+
|
|
4
|
+
describe("createApi", () => {
|
|
5
|
+
it("should return every api methods", () => {
|
|
6
|
+
const api = createApi({} as CantonConfig);
|
|
7
|
+
expect(api.broadcast).toBeDefined();
|
|
8
|
+
expect(api.combine).toBeDefined();
|
|
9
|
+
expect(api.craftTransaction).toBeDefined();
|
|
10
|
+
expect(api.estimateFees).toBeDefined();
|
|
11
|
+
expect(api.getBalance).toBeDefined();
|
|
12
|
+
expect(api.lastBlock).toBeDefined();
|
|
13
|
+
expect(api.listOperations).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AlpacaApi,
|
|
3
|
+
Block,
|
|
4
|
+
BlockInfo,
|
|
5
|
+
FeeEstimation,
|
|
6
|
+
TransactionIntent,
|
|
7
|
+
} from "@ledgerhq/coin-framework/api/index";
|
|
8
|
+
import coinConfig, { type CantonConfig } from "../config";
|
|
9
|
+
import {
|
|
10
|
+
broadcast,
|
|
11
|
+
combine,
|
|
12
|
+
craftTransaction,
|
|
13
|
+
estimateFees,
|
|
14
|
+
getBalance,
|
|
15
|
+
getNextValidSequence,
|
|
16
|
+
lastBlock,
|
|
17
|
+
listOperations,
|
|
18
|
+
} from "../common-logic";
|
|
19
|
+
import BigNumber from "bignumber.js";
|
|
20
|
+
|
|
21
|
+
export function createApi(config: CantonConfig): AlpacaApi {
|
|
22
|
+
coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
broadcast,
|
|
26
|
+
combine,
|
|
27
|
+
craftTransaction: craft,
|
|
28
|
+
estimateFees: estimate,
|
|
29
|
+
getBalance,
|
|
30
|
+
lastBlock,
|
|
31
|
+
listOperations,
|
|
32
|
+
getBlock(_height): Promise<Block> {
|
|
33
|
+
throw new Error("getBlock is not supported");
|
|
34
|
+
},
|
|
35
|
+
getBlockInfo(_height: number): Promise<BlockInfo> {
|
|
36
|
+
throw new Error("getBlockInfo is not supported");
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function craft(transactionIntent: TransactionIntent): Promise<string> {
|
|
42
|
+
const nextSequenceNumber = await getNextValidSequence(transactionIntent.sender);
|
|
43
|
+
const tx = await craftTransaction(
|
|
44
|
+
{ address: transactionIntent.sender, nextSequenceNumber },
|
|
45
|
+
{
|
|
46
|
+
recipient: transactionIntent.recipient,
|
|
47
|
+
amount: new BigNumber(transactionIntent.amount.toString()),
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
return tx.serializedTransaction;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function estimate(transactionIntent: TransactionIntent): Promise<FeeEstimation> {
|
|
54
|
+
const { serializedTransaction } = await craftTransaction(
|
|
55
|
+
{ address: transactionIntent.sender },
|
|
56
|
+
{
|
|
57
|
+
recipient: transactionIntent.recipient,
|
|
58
|
+
amount: new BigNumber(transactionIntent.amount.toString()),
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const value = await estimateFees(serializedTransaction);
|
|
63
|
+
|
|
64
|
+
return { value };
|
|
65
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Account, BroadcastArg } from "@ledgerhq/types-live";
|
|
2
|
+
import { broadcast } from "./broadcast";
|
|
3
|
+
jest.mock("@ledgerhq/coin-framework/operation");
|
|
4
|
+
jest.mock("../common-logic");
|
|
5
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
6
|
+
import { broadcast as broadcastLogic } from "../common-logic";
|
|
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
|
+
it("should broadcast", () => {
|
|
18
|
+
broadcast({
|
|
19
|
+
signedOperation: {
|
|
20
|
+
signature: undefined,
|
|
21
|
+
operation: undefined,
|
|
22
|
+
},
|
|
23
|
+
} as unknown as BroadcastArg<Account>);
|
|
24
|
+
expect(broadcastLogic).toHaveBeenCalledTimes(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should patch operation with hash", () => {
|
|
28
|
+
broadcast({
|
|
29
|
+
signedOperation: {
|
|
30
|
+
signature: undefined,
|
|
31
|
+
operation: undefined,
|
|
32
|
+
},
|
|
33
|
+
} as unknown as BroadcastArg<Account>);
|
|
34
|
+
expect(patchOperationSpy).toHaveBeenCalledWith(undefined, "hash");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
|
+
import { broadcast as broadcastLogic } from "../common-logic";
|
|
4
|
+
import { Transaction } from "../types";
|
|
5
|
+
|
|
6
|
+
export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
|
|
7
|
+
signedOperation: { signature, operation },
|
|
8
|
+
}) => {
|
|
9
|
+
const hash = await broadcastLogic(signature);
|
|
10
|
+
return patchOperationWithHash(operation, hash);
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Account, AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import { createTransaction } from "./createTransaction";
|
|
3
|
+
|
|
4
|
+
describe("createTransaction", () => {
|
|
5
|
+
it("should create a 0 amount transaction", () => {
|
|
6
|
+
expect(createTransaction({} as AccountLike<Account>).amount.toNumber()).toEqual(0);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should create a transaction with boilerplate family", () => {
|
|
10
|
+
expect(createTransaction({} as AccountLike<Account>).family).toEqual("boilerplate");
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { Transaction } from "../types";
|
|
3
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
4
|
+
|
|
5
|
+
// We create an empty transaction that will be filled later
|
|
6
|
+
export const createTransaction: AccountBridge<Transaction>["createTransaction"] = () => ({
|
|
7
|
+
family: "canton",
|
|
8
|
+
amount: new BigNumber(0),
|
|
9
|
+
recipient: "",
|
|
10
|
+
fee: null,
|
|
11
|
+
memo: undefined,
|
|
12
|
+
networkInfo: null,
|
|
13
|
+
feeCustomUnit: null,
|
|
14
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import getDeviceTransactionConfig from "./deviceTransactionConfig";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
|
|
4
|
+
describe("getDeviceTransactionConfig", () => {
|
|
5
|
+
it("should return amount field when it's more than 0", () => {
|
|
6
|
+
expect(
|
|
7
|
+
getDeviceTransactionConfig({
|
|
8
|
+
transaction: {},
|
|
9
|
+
status: { amount: new BigNumber(1), estimatedFees: new BigNumber(0) },
|
|
10
|
+
} as any)[0],
|
|
11
|
+
).toEqual({ type: "amount", label: "Amount" });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should return fee field when it's more than 0", () => {
|
|
15
|
+
expect(
|
|
16
|
+
getDeviceTransactionConfig({
|
|
17
|
+
transaction: {},
|
|
18
|
+
status: { amount: new BigNumber(0), estimatedFees: new BigNumber(1) },
|
|
19
|
+
} as any)[0],
|
|
20
|
+
).toEqual({ type: "fees", label: "Fees" });
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AccountLike, Account } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction, TransactionStatus } from "../types";
|
|
3
|
+
import type { CommonDeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
|
|
4
|
+
|
|
5
|
+
// This method adds additional fields that need to be reviewed when signing a transaction on the device.
|
|
6
|
+
function getDeviceTransactionConfig({
|
|
7
|
+
transaction: {},
|
|
8
|
+
status: { amount, estimatedFees },
|
|
9
|
+
}: {
|
|
10
|
+
account: AccountLike;
|
|
11
|
+
parentAccount: Account | null | undefined;
|
|
12
|
+
transaction: Transaction;
|
|
13
|
+
status: TransactionStatus;
|
|
14
|
+
}): Array<CommonDeviceTransactionField> {
|
|
15
|
+
const fields: Array<CommonDeviceTransactionField> = [];
|
|
16
|
+
|
|
17
|
+
if (!amount.isZero()) {
|
|
18
|
+
fields.push({
|
|
19
|
+
type: "amount",
|
|
20
|
+
label: "Amount",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!estimatedFees.isZero()) {
|
|
25
|
+
fields.push({
|
|
26
|
+
type: "fees",
|
|
27
|
+
label: "Fees",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return fields;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default getDeviceTransactionConfig;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
3
|
+
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
|
|
4
|
+
import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets/abandonseed";
|
|
5
|
+
import { getTransactionStatus } from "./getTransactionStatus";
|
|
6
|
+
import { prepareTransaction } from "./prepareTransaction";
|
|
7
|
+
import { createTransaction } from "./createTransaction";
|
|
8
|
+
import { Transaction } from "../types";
|
|
9
|
+
|
|
10
|
+
export const estimateMaxSpendable: AccountBridge<Transaction>["estimateMaxSpendable"] = async ({
|
|
11
|
+
account,
|
|
12
|
+
parentAccount,
|
|
13
|
+
transaction,
|
|
14
|
+
}) => {
|
|
15
|
+
const mainAccount = getMainAccount(account, parentAccount);
|
|
16
|
+
const newTransaction = await prepareTransaction(mainAccount, {
|
|
17
|
+
...createTransaction(account),
|
|
18
|
+
...transaction,
|
|
19
|
+
// fee estimation might require a recipient to work, in that case, we use a dummy one
|
|
20
|
+
recipient: transaction?.recipient || getAbandonSeedAddress("boilerplate"),
|
|
21
|
+
amount: new BigNumber(0),
|
|
22
|
+
});
|
|
23
|
+
const status = await getTransactionStatus(mainAccount, newTransaction);
|
|
24
|
+
return BigNumber.max(0, account.spendableBalance.minus(status.estimatedFees));
|
|
25
|
+
};
|