@ledgerhq/coin-solana 0.7.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/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +16 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +9 -0
- package/lib/api/cached.d.ts +3 -0
- package/lib/api/cached.d.ts.map +1 -0
- package/lib/api/cached.js +40 -0
- package/lib/api/cached.js.map +1 -0
- package/lib/api/chain/account/index.d.ts +2 -0
- package/lib/api/chain/account/index.d.ts.map +1 -0
- package/lib/api/chain/account/index.js +8 -0
- package/lib/api/chain/account/index.js.map +1 -0
- package/lib/api/chain/account/parser.d.ts +10 -0
- package/lib/api/chain/account/parser.d.ts.map +1 -0
- package/lib/api/chain/account/parser.js +56 -0
- package/lib/api/chain/account/parser.js.map +1 -0
- package/lib/api/chain/account/stake.d.ts +237 -0
- package/lib/api/chain/account/stake.d.ts.map +1 -0
- package/lib/api/chain/account/stake.js +38 -0
- package/lib/api/chain/account/stake.js.map +1 -0
- package/lib/api/chain/account/token.d.ts +116 -0
- package/lib/api/chain/account/token.d.ts.map +1 -0
- package/lib/api/chain/account/token.js +42 -0
- package/lib/api/chain/account/token.js.map +1 -0
- package/lib/api/chain/account/vote.d.ts +252 -0
- package/lib/api/chain/account/vote.d.ts.map +1 -0
- package/lib/api/chain/account/vote.js +44 -0
- package/lib/api/chain/account/vote.js.map +1 -0
- package/lib/api/chain/index.d.ts +29 -0
- package/lib/api/chain/index.d.ts.map +1 -0
- package/lib/api/chain/index.js +99 -0
- package/lib/api/chain/index.js.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/index.js +21 -0
- package/lib/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/types.js +19 -0
- package/lib/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/memo/index.js +14 -0
- package/lib/api/chain/instruction/memo/index.js.map +1 -0
- package/lib/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/memo/types.js +16 -0
- package/lib/api/chain/instruction/memo/types.js.map +1 -0
- package/lib/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/stake/index.js +20 -0
- package/lib/api/chain/instruction/stake/index.js.map +1 -0
- package/lib/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/stake/types.js +80 -0
- package/lib/api/chain/instruction/stake/types.js.map +1 -0
- package/lib/api/chain/instruction/system/index.d.ts +15 -0
- package/lib/api/chain/instruction/system/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/system/index.js +20 -0
- package/lib/api/chain/instruction/system/index.js.map +1 -0
- package/lib/api/chain/instruction/system/types.d.ts +298 -0
- package/lib/api/chain/instruction/system/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/system/types.js +117 -0
- package/lib/api/chain/instruction/system/types.js.map +1 -0
- package/lib/api/chain/instruction/token/index.d.ts +15 -0
- package/lib/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/token/index.js +20 -0
- package/lib/api/chain/instruction/token/index.js.map +1 -0
- package/lib/api/chain/instruction/token/types.d.ts +497 -0
- package/lib/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/token/types.js +200 -0
- package/lib/api/chain/instruction/token/types.js.map +1 -0
- package/lib/api/chain/program/constants.d.ts +11 -0
- package/lib/api/chain/program/constants.d.ts.map +1 -0
- package/lib/api/chain/program/constants.js +14 -0
- package/lib/api/chain/program/constants.js.map +1 -0
- package/lib/api/chain/program/index.d.ts +2 -0
- package/lib/api/chain/program/index.d.ts.map +1 -0
- package/lib/api/chain/program/index.js +7 -0
- package/lib/api/chain/program/index.js.map +1 -0
- package/lib/api/chain/program/parser.d.ts +35 -0
- package/lib/api/chain/program/parser.d.ts.map +1 -0
- package/lib/api/chain/program/parser.js +66 -0
- package/lib/api/chain/program/parser.js.map +1 -0
- package/lib/api/chain/validators/bignum.d.ts +3 -0
- package/lib/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib/api/chain/validators/bignum.js +11 -0
- package/lib/api/chain/validators/bignum.js.map +1 -0
- package/lib/api/chain/validators/index.d.ts +10 -0
- package/lib/api/chain/validators/index.d.ts.map +1 -0
- package/lib/api/chain/validators/index.js +10 -0
- package/lib/api/chain/validators/index.js.map +1 -0
- package/lib/api/chain/validators/pubkey.d.ts +3 -0
- package/lib/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib/api/chain/validators/pubkey.js +7 -0
- package/lib/api/chain/validators/pubkey.js.map +1 -0
- package/lib/api/chain/web3.d.ts +43 -0
- package/lib/api/chain/web3.d.ts.map +1 -0
- package/lib/api/chain/web3.js +274 -0
- package/lib/api/chain/web3.js.map +1 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +25 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/logged.d.ts +3 -0
- package/lib/api/logged.d.ts.map +1 -0
- package/lib/api/logged.js +69 -0
- package/lib/api/logged.js.map +1 -0
- package/lib/api/queued.d.ts +3 -0
- package/lib/api/queued.d.ts.map +1 -0
- package/lib/api/queued.js +27 -0
- package/lib/api/queued.js.map +1 -0
- package/lib/api/traced.d.ts +3 -0
- package/lib/api/traced.d.ts.map +1 -0
- package/lib/api/traced.js +80 -0
- package/lib/api/traced.js.map +1 -0
- package/lib/bridge/bridge.d.ts +15 -0
- package/lib/bridge/bridge.d.ts.map +1 -0
- package/lib/bridge/bridge.js +139 -0
- package/lib/bridge/bridge.js.map +1 -0
- package/lib/bridge/js.d.ts +7 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +28 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +990 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/cli-transaction.d.ts +19 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +196 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib/datasets/solana.scanAccounts.1.js +12 -0
- package/lib/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +10 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +228 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +61 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +25 -0
- package/lib/errors.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +28 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/js-broadcast.d.ts +7 -0
- package/lib/js-broadcast.d.ts.map +1 -0
- package/lib/js-broadcast.js +37 -0
- package/lib/js-broadcast.js.map +1 -0
- package/lib/js-buildTransaction.d.ts +5 -0
- package/lib/js-buildTransaction.d.ts.map +1 -0
- package/lib/js-buildTransaction.js +67 -0
- package/lib/js-buildTransaction.js.map +1 -0
- package/lib/js-createTransaction.d.ts +5 -0
- package/lib/js-createTransaction.d.ts.map +1 -0
- package/lib/js-createTransaction.js +19 -0
- package/lib/js-createTransaction.js.map +1 -0
- package/lib/js-estimateMaxSpendable.d.ts +11 -0
- package/lib/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/js-estimateMaxSpendable.js +62 -0
- package/lib/js-estimateMaxSpendable.js.map +1 -0
- package/lib/js-getTransactionStatus.d.ts +5 -0
- package/lib/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/js-getTransactionStatus.js +71 -0
- package/lib/js-getTransactionStatus.js.map +1 -0
- package/lib/js-preload-data.d.ts +7 -0
- package/lib/js-preload-data.d.ts.map +1 -0
- package/lib/js-preload-data.js +45 -0
- package/lib/js-preload-data.js.map +1 -0
- package/lib/js-preload.d.ts +7 -0
- package/lib/js-preload.d.ts.map +1 -0
- package/lib/js-preload.js +67 -0
- package/lib/js-preload.js.map +1 -0
- package/lib/js-preload.test.d.ts +2 -0
- package/lib/js-preload.test.d.ts.map +1 -0
- package/lib/js-preload.test.js +9 -0
- package/lib/js-preload.test.js.map +1 -0
- package/lib/js-prepareTransaction.d.ts +5 -0
- package/lib/js-prepareTransaction.d.ts.map +1 -0
- package/lib/js-prepareTransaction.js +500 -0
- package/lib/js-prepareTransaction.js.map +1 -0
- package/lib/js-signOperation.d.ts +7 -0
- package/lib/js-signOperation.d.ts.map +1 -0
- package/lib/js-signOperation.js +153 -0
- package/lib/js-signOperation.js.map +1 -0
- package/lib/js-synchronization.d.ts +5 -0
- package/lib/js-synchronization.d.ts.map +1 -0
- package/lib/js-synchronization.js +464 -0
- package/lib/js-synchronization.js.map +1 -0
- package/lib/logic.d.ts +29 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +102 -0
- package/lib/logic.js.map +1 -0
- package/lib/serialization.d.ts +9 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +69 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signer.d.ts +11 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +409 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +8 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +217 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +153 -0
- package/lib/transaction.js.map +1 -0
- package/lib/tx-fees.d.ts +4 -0
- package/lib/tx-fees.d.ts.map +1 -0
- package/lib/tx-fees.js +167 -0
- package/lib/tx-fees.js.map +1 -0
- package/lib/types.d.ts +222 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +24 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +172 -0
- package/lib/utils.js.map +1 -0
- package/lib/validator-app/index.d.ts +22 -0
- package/lib/validator-app/index.d.ts.map +1 -0
- package/lib/validator-app/index.js +62 -0
- package/lib/validator-app/index.js.map +1 -0
- package/lib-es/api/cached.d.ts +3 -0
- package/lib-es/api/cached.d.ts.map +1 -0
- package/lib-es/api/cached.js +33 -0
- package/lib-es/api/cached.js.map +1 -0
- package/lib-es/api/chain/account/index.d.ts +2 -0
- package/lib-es/api/chain/account/index.d.ts.map +1 -0
- package/lib-es/api/chain/account/index.js +2 -0
- package/lib-es/api/chain/account/index.js.map +1 -0
- package/lib-es/api/chain/account/parser.d.ts +10 -0
- package/lib-es/api/chain/account/parser.d.ts.map +1 -0
- package/lib-es/api/chain/account/parser.js +48 -0
- package/lib-es/api/chain/account/parser.js.map +1 -0
- package/lib-es/api/chain/account/stake.d.ts +237 -0
- package/lib-es/api/chain/account/stake.d.ts.map +1 -0
- package/lib-es/api/chain/account/stake.js +35 -0
- package/lib-es/api/chain/account/stake.js.map +1 -0
- package/lib-es/api/chain/account/token.d.ts +116 -0
- package/lib-es/api/chain/account/token.d.ts.map +1 -0
- package/lib-es/api/chain/account/token.js +39 -0
- package/lib-es/api/chain/account/token.js.map +1 -0
- package/lib-es/api/chain/account/vote.d.ts +252 -0
- package/lib-es/api/chain/account/vote.d.ts.map +1 -0
- package/lib-es/api/chain/account/vote.js +41 -0
- package/lib-es/api/chain/account/vote.js.map +1 -0
- package/lib-es/api/chain/index.d.ts +29 -0
- package/lib-es/api/chain/index.d.ts.map +1 -0
- package/lib-es/api/chain/index.js +95 -0
- package/lib-es/api/chain/index.js.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.js +17 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.js +16 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib-es/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/memo/index.js +10 -0
- package/lib-es/api/chain/instruction/memo/index.js.map +1 -0
- package/lib-es/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib-es/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/memo/types.js +13 -0
- package/lib-es/api/chain/instruction/memo/types.js.map +1 -0
- package/lib-es/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/stake/index.js +16 -0
- package/lib-es/api/chain/instruction/stake/index.js.map +1 -0
- package/lib-es/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib-es/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/stake/types.js +77 -0
- package/lib-es/api/chain/instruction/stake/types.js.map +1 -0
- package/lib-es/api/chain/instruction/system/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/system/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/system/index.js +16 -0
- package/lib-es/api/chain/instruction/system/index.js.map +1 -0
- package/lib-es/api/chain/instruction/system/types.d.ts +298 -0
- package/lib-es/api/chain/instruction/system/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/system/types.js +114 -0
- package/lib-es/api/chain/instruction/system/types.js.map +1 -0
- package/lib-es/api/chain/instruction/token/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/token/index.js +16 -0
- package/lib-es/api/chain/instruction/token/index.js.map +1 -0
- package/lib-es/api/chain/instruction/token/types.d.ts +497 -0
- package/lib-es/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/token/types.js +197 -0
- package/lib-es/api/chain/instruction/token/types.js.map +1 -0
- package/lib-es/api/chain/program/constants.d.ts +11 -0
- package/lib-es/api/chain/program/constants.d.ts.map +1 -0
- package/lib-es/api/chain/program/constants.js +11 -0
- package/lib-es/api/chain/program/constants.js.map +1 -0
- package/lib-es/api/chain/program/index.d.ts +2 -0
- package/lib-es/api/chain/program/index.d.ts.map +1 -0
- package/lib-es/api/chain/program/index.js +2 -0
- package/lib-es/api/chain/program/index.js.map +1 -0
- package/lib-es/api/chain/program/parser.d.ts +35 -0
- package/lib-es/api/chain/program/parser.d.ts.map +1 -0
- package/lib-es/api/chain/program/parser.js +61 -0
- package/lib-es/api/chain/program/parser.js.map +1 -0
- package/lib-es/api/chain/validators/bignum.d.ts +3 -0
- package/lib-es/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib-es/api/chain/validators/bignum.js +8 -0
- package/lib-es/api/chain/validators/bignum.js.map +1 -0
- package/lib-es/api/chain/validators/index.d.ts +10 -0
- package/lib-es/api/chain/validators/index.d.ts.map +1 -0
- package/lib-es/api/chain/validators/index.js +7 -0
- package/lib-es/api/chain/validators/index.js.map +1 -0
- package/lib-es/api/chain/validators/pubkey.d.ts +3 -0
- package/lib-es/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib-es/api/chain/validators/pubkey.js +4 -0
- package/lib-es/api/chain/validators/pubkey.js.map +1 -0
- package/lib-es/api/chain/web3.d.ts +43 -0
- package/lib-es/api/chain/web3.d.ts.map +1 -0
- package/lib-es/api/chain/web3.js +251 -0
- package/lib-es/api/chain/web3.js.map +1 -0
- package/lib-es/api/index.d.ts +5 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +5 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/logged.d.ts +3 -0
- package/lib-es/api/logged.d.ts.map +1 -0
- package/lib-es/api/logged.js +65 -0
- package/lib-es/api/logged.js.map +1 -0
- package/lib-es/api/queued.d.ts +3 -0
- package/lib-es/api/queued.d.ts.map +1 -0
- package/lib-es/api/queued.js +23 -0
- package/lib-es/api/queued.js.map +1 -0
- package/lib-es/api/traced.d.ts +3 -0
- package/lib-es/api/traced.d.ts.map +1 -0
- package/lib-es/api/traced.js +76 -0
- package/lib-es/api/traced.js.map +1 -0
- package/lib-es/bridge/bridge.d.ts +15 -0
- package/lib-es/bridge/bridge.d.ts.map +1 -0
- package/lib-es/bridge/bridge.js +132 -0
- package/lib-es/bridge/bridge.js.map +1 -0
- package/lib-es/bridge/js.d.ts +7 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +24 -0
- package/lib-es/bridge/js.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +988 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +19 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +190 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib-es/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib-es/datasets/solana.scanAccounts.1.js +10 -0
- package/lib-es/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +10 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +223 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +61 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +22 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +23 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/js-broadcast.d.ts +7 -0
- package/lib-es/js-broadcast.d.ts.map +1 -0
- package/lib-es/js-broadcast.js +33 -0
- package/lib-es/js-broadcast.js.map +1 -0
- package/lib-es/js-buildTransaction.d.ts +5 -0
- package/lib-es/js-buildTransaction.d.ts.map +1 -0
- package/lib-es/js-buildTransaction.js +63 -0
- package/lib-es/js-buildTransaction.js.map +1 -0
- package/lib-es/js-createTransaction.d.ts +5 -0
- package/lib-es/js-createTransaction.d.ts.map +1 -0
- package/lib-es/js-createTransaction.js +17 -0
- package/lib-es/js-createTransaction.js.map +1 -0
- package/lib-es/js-estimateMaxSpendable.d.ts +11 -0
- package/lib-es/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/js-estimateMaxSpendable.js +55 -0
- package/lib-es/js-estimateMaxSpendable.js.map +1 -0
- package/lib-es/js-getTransactionStatus.d.ts +5 -0
- package/lib-es/js-getTransactionStatus.d.ts.map +1 -0
- package/lib-es/js-getTransactionStatus.js +69 -0
- package/lib-es/js-getTransactionStatus.js.map +1 -0
- package/lib-es/js-preload-data.d.ts +7 -0
- package/lib-es/js-preload-data.d.ts.map +1 -0
- package/lib-es/js-preload-data.js +39 -0
- package/lib-es/js-preload-data.js.map +1 -0
- package/lib-es/js-preload.d.ts +7 -0
- package/lib-es/js-preload.d.ts.map +1 -0
- package/lib-es/js-preload.js +62 -0
- package/lib-es/js-preload.js.map +1 -0
- package/lib-es/js-preload.test.d.ts +2 -0
- package/lib-es/js-preload.test.d.ts.map +1 -0
- package/lib-es/js-preload.test.js +7 -0
- package/lib-es/js-preload.test.js.map +1 -0
- package/lib-es/js-prepareTransaction.d.ts +5 -0
- package/lib-es/js-prepareTransaction.d.ts.map +1 -0
- package/lib-es/js-prepareTransaction.js +497 -0
- package/lib-es/js-prepareTransaction.js.map +1 -0
- package/lib-es/js-signOperation.d.ts +7 -0
- package/lib-es/js-signOperation.d.ts.map +1 -0
- package/lib-es/js-signOperation.js +146 -0
- package/lib-es/js-signOperation.js.map +1 -0
- package/lib-es/js-synchronization.d.ts +5 -0
- package/lib-es/js-synchronization.d.ts.map +1 -0
- package/lib-es/js-synchronization.js +457 -0
- package/lib-es/js-synchronization.js.map +1 -0
- package/lib-es/logic.d.ts +29 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +87 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/serialization.d.ts +9 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +60 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signer.d.ts +11 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +7 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +404 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +8 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +211 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/transaction.d.ts +15 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +147 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/tx-fees.d.ts +4 -0
- package/lib-es/tx-fees.d.ts.map +1 -0
- package/lib-es/tx-fees.js +160 -0
- package/lib-es/tx-fees.js.map +1 -0
- package/lib-es/types.d.ts +222 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +2 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/utils.d.ts +24 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +157 -0
- package/lib-es/utils.js.map +1 -0
- package/lib-es/validator-app/index.d.ts +22 -0
- package/lib-es/validator-app/index.d.ts.map +1 -0
- package/lib-es/validator-app/index.js +55 -0
- package/lib-es/validator-app/index.js.map +1 -0
- package/package.json +89 -0
- package/src/api/cached.ts +87 -0
- package/src/api/chain/account/index.ts +1 -0
- package/src/api/chain/account/parser.ts +63 -0
- package/src/api/chain/account/stake.ts +45 -0
- package/src/api/chain/account/token.ts +63 -0
- package/src/api/chain/account/vote.ts +55 -0
- package/src/api/chain/index.ts +203 -0
- package/src/api/chain/instruction/associated-token-account/index.ts +33 -0
- package/src/api/chain/instruction/associated-token-account/types.ts +23 -0
- package/src/api/chain/instruction/memo/index.ts +24 -0
- package/src/api/chain/instruction/memo/types.ts +18 -0
- package/src/api/chain/instruction/stake/index.ts +29 -0
- package/src/api/chain/instruction/stake/types.ts +95 -0
- package/src/api/chain/instruction/system/index.ts +30 -0
- package/src/api/chain/instruction/system/types.ts +141 -0
- package/src/api/chain/instruction/token/index.ts +30 -0
- package/src/api/chain/instruction/token/types.ts +222 -0
- package/src/api/chain/program/constants.ts +10 -0
- package/src/api/chain/program/index.ts +1 -0
- package/src/api/chain/program/parser.ts +120 -0
- package/src/api/chain/validators/bignum.ts +7 -0
- package/src/api/chain/validators/index.ts +9 -0
- package/src/api/chain/validators/pubkey.ts +8 -0
- package/src/api/chain/web3.ts +399 -0
- package/src/api/index.ts +4 -0
- package/src/api/logged.ts +70 -0
- package/src/api/queued.ts +25 -0
- package/src/api/traced.ts +89 -0
- package/src/bridge/bridge.ts +195 -0
- package/src/bridge/js.ts +44 -0
- package/src/bridge.integration.test.ts +1106 -0
- package/src/cli-transaction.ts +246 -0
- package/src/datasets/solana.scanAccounts.1.ts +9 -0
- package/src/deviceTransactionConfig.ts +302 -0
- package/src/errors.ts +61 -0
- package/src/hw-getAddress.ts +26 -0
- package/src/js-broadcast.ts +38 -0
- package/src/js-buildTransaction.ts +81 -0
- package/src/js-createTransaction.ts +20 -0
- package/src/js-estimateMaxSpendable.ts +72 -0
- package/src/js-getTransactionStatus.ts +72 -0
- package/src/js-preload-data.ts +46 -0
- package/src/js-preload.test.ts +14 -0
- package/src/js-preload.ts +74 -0
- package/src/js-prepareTransaction.ts +686 -0
- package/src/js-signOperation.ts +329 -0
- package/src/js-synchronization.ts +729 -0
- package/src/logic.ts +123 -0
- package/src/serialization.ts +81 -0
- package/src/signer.ts +21 -0
- package/src/specs.ts +514 -0
- package/src/speculos-deviceActions.ts +229 -0
- package/src/transaction.ts +194 -0
- package/src/tx-fees.ts +206 -0
- package/src/types.ts +284 -0
- package/src/utils.ts +176 -0
- package/src/validator-app/index.ts +79 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { findTokenById, findTokenByTicker } from "@ledgerhq/cryptoassets";
|
|
2
|
+
import type { Account, AccountLike, AccountLikeArray } from "@ledgerhq/types-live";
|
|
3
|
+
import invariant from "invariant";
|
|
4
|
+
import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index";
|
|
5
|
+
import { Transaction } from "./types";
|
|
6
|
+
import { assertUnreachable } from "./utils";
|
|
7
|
+
|
|
8
|
+
const modes = [
|
|
9
|
+
"send",
|
|
10
|
+
"optIn",
|
|
11
|
+
"stake.createAccount",
|
|
12
|
+
"stake.delegate",
|
|
13
|
+
"stake.undelegate",
|
|
14
|
+
"stake.withdraw",
|
|
15
|
+
"stake.split",
|
|
16
|
+
] as const;
|
|
17
|
+
type Mode = (typeof modes)[number];
|
|
18
|
+
|
|
19
|
+
// some options already specified for other blockchains like ethereum.
|
|
20
|
+
// trying to reuse existing ones like <token>, <mode>, etc.
|
|
21
|
+
const options = [
|
|
22
|
+
{
|
|
23
|
+
name: "solanaValidator",
|
|
24
|
+
type: String,
|
|
25
|
+
desc: "validator address to delegate to",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "solanaStakeAccount",
|
|
29
|
+
type: String,
|
|
30
|
+
desc: "stake account address to use in the transaction",
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
function inferTransactions(
|
|
35
|
+
transactions: Array<{
|
|
36
|
+
account: AccountLike;
|
|
37
|
+
mainAccount: Account;
|
|
38
|
+
transaction: Transaction;
|
|
39
|
+
}>,
|
|
40
|
+
opts: Partial<Record<string, string>>,
|
|
41
|
+
): Transaction[] {
|
|
42
|
+
const mode = inferMode(opts.mode);
|
|
43
|
+
|
|
44
|
+
// reusing ethereum token option, comes as array
|
|
45
|
+
const tokens: string[] | undefined = opts.token as any;
|
|
46
|
+
|
|
47
|
+
if (tokens !== undefined && tokens.length !== 1) {
|
|
48
|
+
throw new Error("only 1 token at a time supported for solana transactions");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const token = tokens?.[0];
|
|
52
|
+
|
|
53
|
+
return transactions.map(({ account, transaction }) => {
|
|
54
|
+
if (transaction.family !== "solana") {
|
|
55
|
+
throw new Error(`Solana family transaction expected, got <${transaction.family}>`);
|
|
56
|
+
}
|
|
57
|
+
switch (mode) {
|
|
58
|
+
case "send":
|
|
59
|
+
if (account.type === "Account") {
|
|
60
|
+
const solanaTx: Transaction = {
|
|
61
|
+
...transaction,
|
|
62
|
+
model: {
|
|
63
|
+
kind: "transfer",
|
|
64
|
+
uiState: {
|
|
65
|
+
memo: opts.memo,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
return solanaTx;
|
|
70
|
+
} else {
|
|
71
|
+
if (account.type !== "TokenAccount") {
|
|
72
|
+
throw new Error("expected token account");
|
|
73
|
+
}
|
|
74
|
+
const subAccountId = account.id;
|
|
75
|
+
const solanaTx: Transaction = {
|
|
76
|
+
...transaction,
|
|
77
|
+
subAccountId,
|
|
78
|
+
model: {
|
|
79
|
+
kind: "token.transfer",
|
|
80
|
+
uiState: {
|
|
81
|
+
memo: opts.memo,
|
|
82
|
+
subAccountId,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
return solanaTx;
|
|
87
|
+
}
|
|
88
|
+
case "optIn": {
|
|
89
|
+
if (token === undefined) {
|
|
90
|
+
throw new Error("token required");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (account.type !== "Account") {
|
|
94
|
+
throw new Error("expected main account");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const tokenCurrency = findTokenByTicker(token) ?? findTokenById(token);
|
|
98
|
+
|
|
99
|
+
if (!tokenCurrency) {
|
|
100
|
+
throw new Error(`token <${token}> not found`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const solanaTx: Transaction = {
|
|
104
|
+
...transaction,
|
|
105
|
+
model: {
|
|
106
|
+
kind: "token.createATA",
|
|
107
|
+
uiState: {
|
|
108
|
+
tokenId: tokenCurrency.id,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
return solanaTx;
|
|
113
|
+
}
|
|
114
|
+
case "stake.createAccount": {
|
|
115
|
+
const validator = opts.solanaValidator;
|
|
116
|
+
return {
|
|
117
|
+
...transaction,
|
|
118
|
+
model: {
|
|
119
|
+
kind: "stake.createAccount",
|
|
120
|
+
uiState: {
|
|
121
|
+
delegate: {
|
|
122
|
+
voteAccAddress: validator ?? "",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
case "stake.delegate":
|
|
129
|
+
return {
|
|
130
|
+
...transaction,
|
|
131
|
+
model: {
|
|
132
|
+
kind: "stake.delegate",
|
|
133
|
+
uiState: {
|
|
134
|
+
stakeAccAddr: opts.solanaStakeAccount ?? "",
|
|
135
|
+
voteAccAddr: opts.solanaValidator ?? "",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
case "stake.undelegate":
|
|
140
|
+
return {
|
|
141
|
+
...transaction,
|
|
142
|
+
model: {
|
|
143
|
+
kind: "stake.undelegate",
|
|
144
|
+
uiState: {
|
|
145
|
+
stakeAccAddr: opts.solanaStakeAccount ?? "",
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
case "stake.withdraw":
|
|
150
|
+
return {
|
|
151
|
+
...transaction,
|
|
152
|
+
model: {
|
|
153
|
+
kind: "stake.withdraw",
|
|
154
|
+
uiState: {
|
|
155
|
+
stakeAccAddr: opts.solanaStakeAccount ?? "",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
case "stake.split":
|
|
160
|
+
if (opts.solanaStakeAccount === undefined) {
|
|
161
|
+
throw new Error("stake account is required");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
...transaction,
|
|
166
|
+
model: {
|
|
167
|
+
kind: "stake.split",
|
|
168
|
+
uiState: {
|
|
169
|
+
stakeAccAddr: opts.solanaStakeAccount,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
default:
|
|
174
|
+
return assertUnreachable(mode);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function inferAccounts(mainAccount: Account, opts: Record<string, string>): AccountLikeArray {
|
|
180
|
+
invariant(mainAccount.currency.family === "solana", "solana family currency");
|
|
181
|
+
|
|
182
|
+
const mode = inferMode(opts.mode);
|
|
183
|
+
|
|
184
|
+
switch (mode) {
|
|
185
|
+
case "send": {
|
|
186
|
+
if (!opts.token) {
|
|
187
|
+
return [mainAccount];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// reusing ethereum token option, comes as array
|
|
191
|
+
const tokens: string[] = opts.token as any;
|
|
192
|
+
|
|
193
|
+
if (tokens.length !== 1) {
|
|
194
|
+
throw new Error("only 1 token at a time supported for solana");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const token = tokens[0];
|
|
198
|
+
|
|
199
|
+
const subAccount = mainAccount.subAccounts?.find(subAcc => {
|
|
200
|
+
const currency = getAccountCurrency(subAcc);
|
|
201
|
+
return token === currency.ticker || token === currency.id;
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (subAccount === undefined) {
|
|
205
|
+
throw new Error(
|
|
206
|
+
"token account '" +
|
|
207
|
+
opts.token +
|
|
208
|
+
"' not found. Available: " +
|
|
209
|
+
mainAccount.subAccounts?.map(subAcc => getAccountCurrency(subAcc).ticker).join(", "),
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return [subAccount];
|
|
213
|
+
}
|
|
214
|
+
case "optIn":
|
|
215
|
+
case "stake.createAccount":
|
|
216
|
+
case "stake.delegate":
|
|
217
|
+
case "stake.undelegate":
|
|
218
|
+
case "stake.withdraw":
|
|
219
|
+
case "stake.split":
|
|
220
|
+
// TODO: infer stake account for stake ops
|
|
221
|
+
return [mainAccount];
|
|
222
|
+
default:
|
|
223
|
+
return assertUnreachable(mode);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function inferMode(input?: string): Mode {
|
|
228
|
+
const mode: Mode | undefined = input
|
|
229
|
+
? modes.some(m => m === input)
|
|
230
|
+
? (input as Mode)
|
|
231
|
+
: undefined
|
|
232
|
+
: "send";
|
|
233
|
+
|
|
234
|
+
if (mode === undefined) {
|
|
235
|
+
throw new Error(`Unexpected mode <${mode}>. Supported modes: ${modes.join(", ")}`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return mode;
|
|
239
|
+
}
|
|
240
|
+
export default function makeCliTools() {
|
|
241
|
+
return {
|
|
242
|
+
options,
|
|
243
|
+
inferAccounts,
|
|
244
|
+
inferTransactions,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
name: "solana seed 1",
|
|
3
|
+
apdus: `
|
|
4
|
+
=> e005000009028000002c800001f5
|
|
5
|
+
<= 8bc4d3e507c0550e3d02ffb5f6daf0772240af8a09e32d236615b4a2272437029000
|
|
6
|
+
=> e00500000d038000002c800001f580000000
|
|
7
|
+
<= 56e75dba184e4a77652a1c79a329ffbc562c6bafc33036220c08c0d02ff047739000
|
|
8
|
+
`,
|
|
9
|
+
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
3
|
+
import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
|
|
4
|
+
import type { Account, AccountLike } from "@ledgerhq/types-live";
|
|
5
|
+
import type {
|
|
6
|
+
CommandDescriptor,
|
|
7
|
+
StakeCreateAccountCommand,
|
|
8
|
+
StakeDelegateCommand,
|
|
9
|
+
StakeSplitCommand,
|
|
10
|
+
StakeUndelegateCommand,
|
|
11
|
+
StakeWithdrawCommand,
|
|
12
|
+
TokenCreateATACommand,
|
|
13
|
+
TokenTransferCommand,
|
|
14
|
+
Transaction,
|
|
15
|
+
TransferCommand,
|
|
16
|
+
} from "./types";
|
|
17
|
+
import { assertUnreachable } from "./utils";
|
|
18
|
+
|
|
19
|
+
// do not show fields like 'To', 'Recipient', etc., as per Ledger policy
|
|
20
|
+
|
|
21
|
+
function getDeviceTransactionConfig({
|
|
22
|
+
account,
|
|
23
|
+
transaction,
|
|
24
|
+
}: {
|
|
25
|
+
account: AccountLike;
|
|
26
|
+
parentAccount: Account | null | undefined;
|
|
27
|
+
transaction: Transaction;
|
|
28
|
+
}): Array<DeviceTransactionField> {
|
|
29
|
+
const { commandDescriptor } = transaction.model;
|
|
30
|
+
if (commandDescriptor === undefined) {
|
|
31
|
+
throw new Error("missing command descriptor");
|
|
32
|
+
}
|
|
33
|
+
if (Object.keys(commandDescriptor.errors).length > 0) {
|
|
34
|
+
throw new Error("unexpected invalid command");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return fieldsForCommand(commandDescriptor, account);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default getDeviceTransactionConfig;
|
|
41
|
+
|
|
42
|
+
function fieldsForCommand(
|
|
43
|
+
commandDescriptor: CommandDescriptor,
|
|
44
|
+
account: AccountLike,
|
|
45
|
+
): DeviceTransactionField[] {
|
|
46
|
+
const { command } = commandDescriptor;
|
|
47
|
+
switch (command.kind) {
|
|
48
|
+
case "transfer":
|
|
49
|
+
return fieldsForTransfer(command);
|
|
50
|
+
case "token.transfer":
|
|
51
|
+
return fieldsForTokenTransfer(command);
|
|
52
|
+
case "token.createATA":
|
|
53
|
+
return fieldsForCreateATA(command);
|
|
54
|
+
case "stake.createAccount":
|
|
55
|
+
return fieldsForStakeCreateAccount(command, account);
|
|
56
|
+
case "stake.delegate":
|
|
57
|
+
return fieldsForStakeDelegate(command);
|
|
58
|
+
case "stake.undelegate":
|
|
59
|
+
return fieldsForStakeUndelegate(command);
|
|
60
|
+
case "stake.withdraw":
|
|
61
|
+
return fieldsForStakeWithdraw(command);
|
|
62
|
+
case "stake.split":
|
|
63
|
+
return fieldsForStakeSplit(command);
|
|
64
|
+
default:
|
|
65
|
+
return assertUnreachable(command);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function fieldsForTransfer(_command: TransferCommand): DeviceTransactionField[] {
|
|
70
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
71
|
+
|
|
72
|
+
fields.push({
|
|
73
|
+
type: "amount",
|
|
74
|
+
label: "Transfer",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return fields;
|
|
78
|
+
}
|
|
79
|
+
function fieldsForTokenTransfer(command: TokenTransferCommand): DeviceTransactionField[] {
|
|
80
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
81
|
+
|
|
82
|
+
if (command.recipientDescriptor.shouldCreateAsAssociatedTokenAccount) {
|
|
83
|
+
fields.push({
|
|
84
|
+
type: "address",
|
|
85
|
+
label: "Create token acct",
|
|
86
|
+
address: command.recipientDescriptor.tokenAccAddress,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
fields.push({
|
|
90
|
+
type: "address",
|
|
91
|
+
label: "From mint",
|
|
92
|
+
address: command.mintAddress,
|
|
93
|
+
});
|
|
94
|
+
fields.push({
|
|
95
|
+
type: "address",
|
|
96
|
+
label: "Funded by",
|
|
97
|
+
address: command.ownerAddress,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fields.push({
|
|
102
|
+
type: "amount",
|
|
103
|
+
label: "Transfer tokens",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
fields.push({
|
|
107
|
+
type: "address",
|
|
108
|
+
address: command.ownerAssociatedTokenAccountAddress,
|
|
109
|
+
label: "From",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
fields.push({
|
|
113
|
+
type: "address",
|
|
114
|
+
address: command.ownerAddress,
|
|
115
|
+
label: "Owner",
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
fields.push({
|
|
119
|
+
type: "address",
|
|
120
|
+
address: command.ownerAddress,
|
|
121
|
+
label: "Fee payer",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return fields;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function fieldsForCreateATA(command: TokenCreateATACommand): DeviceTransactionField[] {
|
|
128
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
129
|
+
|
|
130
|
+
fields.push({
|
|
131
|
+
type: "address",
|
|
132
|
+
label: "Create token acct",
|
|
133
|
+
address: command.associatedTokenAccountAddress,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
fields.push({
|
|
137
|
+
type: "address",
|
|
138
|
+
label: "From mint",
|
|
139
|
+
address: command.mint,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
fields.push({
|
|
143
|
+
type: "address",
|
|
144
|
+
label: "Owned by",
|
|
145
|
+
address: command.owner,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
fields.push({
|
|
149
|
+
type: "address",
|
|
150
|
+
label: "Funded by",
|
|
151
|
+
address: command.owner,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
fields.push({
|
|
155
|
+
type: "address",
|
|
156
|
+
label: "Fee payer",
|
|
157
|
+
address: command.owner,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return fields;
|
|
161
|
+
}
|
|
162
|
+
function fieldsForStakeCreateAccount(
|
|
163
|
+
command: StakeCreateAccountCommand,
|
|
164
|
+
account: AccountLike,
|
|
165
|
+
): DeviceTransactionField[] {
|
|
166
|
+
if (account.type !== "Account") {
|
|
167
|
+
throw new Error("unsupported account type");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const unit = account.currency.units[0];
|
|
171
|
+
|
|
172
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
173
|
+
|
|
174
|
+
fields.push({
|
|
175
|
+
type: "address",
|
|
176
|
+
label: "Delegate from",
|
|
177
|
+
address: command.stakeAccAddress,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// not using 'amount' field here because the field should
|
|
181
|
+
// show sum of amount and rent exempt amount
|
|
182
|
+
fields.push({
|
|
183
|
+
type: "text",
|
|
184
|
+
label: "Deposit",
|
|
185
|
+
value: formatCurrencyUnit(
|
|
186
|
+
unit,
|
|
187
|
+
new BigNumber(command.amount + command.stakeAccRentExemptAmount),
|
|
188
|
+
{
|
|
189
|
+
disableRounding: true,
|
|
190
|
+
showCode: true,
|
|
191
|
+
},
|
|
192
|
+
),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
fields.push({
|
|
196
|
+
type: "address",
|
|
197
|
+
label: "New authority",
|
|
198
|
+
address: command.fromAccAddress,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
fields.push({
|
|
202
|
+
type: "address",
|
|
203
|
+
label: "Vote account",
|
|
204
|
+
address: command.delegate.voteAccAddress,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return fields;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function fieldsForStakeDelegate(command: StakeDelegateCommand): DeviceTransactionField[] {
|
|
211
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
212
|
+
|
|
213
|
+
fields.push({
|
|
214
|
+
type: "address",
|
|
215
|
+
label: "Delegate from",
|
|
216
|
+
address: command.stakeAccAddr,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
fields.push({
|
|
220
|
+
type: "address",
|
|
221
|
+
label: "Vote account",
|
|
222
|
+
address: command.voteAccAddr,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return fields;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function fieldsForStakeUndelegate(command: StakeUndelegateCommand): DeviceTransactionField[] {
|
|
229
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
230
|
+
|
|
231
|
+
fields.push({
|
|
232
|
+
type: "address",
|
|
233
|
+
label: "Deactivate stake",
|
|
234
|
+
address: command.stakeAccAddr,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
return fields;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function fieldsForStakeWithdraw(command: StakeWithdrawCommand): DeviceTransactionField[] {
|
|
241
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
242
|
+
|
|
243
|
+
fields.push({
|
|
244
|
+
type: "amount",
|
|
245
|
+
label: "Stake withdraw",
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
fields.push({
|
|
249
|
+
type: "address",
|
|
250
|
+
label: "From",
|
|
251
|
+
address: command.stakeAccAddr,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return fields;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function fieldsForStakeSplit(command: StakeSplitCommand): DeviceTransactionField[] {
|
|
258
|
+
const fields: Array<DeviceTransactionField> = [];
|
|
259
|
+
|
|
260
|
+
fields.push({
|
|
261
|
+
type: "amount",
|
|
262
|
+
label: "Split stake",
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
fields.push({
|
|
266
|
+
type: "address",
|
|
267
|
+
label: "From",
|
|
268
|
+
address: command.stakeAccAddr,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
fields.push({
|
|
272
|
+
type: "address",
|
|
273
|
+
label: "To",
|
|
274
|
+
address: command.splitStakeAccAddr,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
fields.push({
|
|
278
|
+
type: "address",
|
|
279
|
+
label: "Base",
|
|
280
|
+
address: command.authorizedAccAddr,
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
fields.push({
|
|
284
|
+
type: "text",
|
|
285
|
+
label: "Seed",
|
|
286
|
+
value: command.seed,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
fields.push({
|
|
290
|
+
type: "address",
|
|
291
|
+
label: "Authorized by",
|
|
292
|
+
address: command.authorizedAccAddr,
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
fields.push({
|
|
296
|
+
type: "address",
|
|
297
|
+
label: "Fee payer",
|
|
298
|
+
address: command.authorizedAccAddr,
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
return fields;
|
|
302
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
|
+
|
|
3
|
+
export const SolanaAccountNotFunded = createCustomErrorClass("SolanaAccountNotFunded");
|
|
4
|
+
|
|
5
|
+
export const SolanaRecipientAssociatedTokenAccountWillBeFunded = createCustomErrorClass(
|
|
6
|
+
"SolanaAssociatedTokenAccountWillBeFunded",
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const SolanaMemoIsTooLong = createCustomErrorClass("SolanaMemoIsTooLong");
|
|
10
|
+
|
|
11
|
+
export const SolanaTokenAccountHoldsAnotherToken = createCustomErrorClass(
|
|
12
|
+
"SolanaTokenAccountHoldsAnotherToken",
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const SolanaTokenAccounNotInitialized = createCustomErrorClass(
|
|
16
|
+
"SolanaTokenAccounNotInitialized",
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const SolanaAddressOffEd25519 = createCustomErrorClass("SolanaAddressOfEd25519");
|
|
20
|
+
|
|
21
|
+
export const SolanaTokenRecipientIsSenderATA = createCustomErrorClass(
|
|
22
|
+
"SolanaTokenRecipientIsSenderATA",
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const SolanaValidatorRequired = createCustomErrorClass("SolanaValidatorRequired");
|
|
26
|
+
|
|
27
|
+
export const SolanaInvalidValidator = createCustomErrorClass("SolanaInvalidValidator");
|
|
28
|
+
|
|
29
|
+
export const SolanaStakeAccountRequired = createCustomErrorClass("SolanaStakeAccountRequired");
|
|
30
|
+
|
|
31
|
+
export const SolanaStakeAccountNotFound = createCustomErrorClass("SolanaStakeAccountNotFound");
|
|
32
|
+
|
|
33
|
+
export const SolanaStakeAccountNothingToWithdraw = createCustomErrorClass(
|
|
34
|
+
"SolanaStakeAccountNothingToWithdraw",
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const SolanaStakeAccountIsNotDelegatable = createCustomErrorClass(
|
|
38
|
+
"SolanaStakeAccountIsNotDelegatable",
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const SolanaStakeAccountIsNotUndelegatable = createCustomErrorClass(
|
|
42
|
+
"SolanaStakeAccountIsNotUndelegatable",
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const SolanaStakeAccountValidatorIsUnchangeable = createCustomErrorClass(
|
|
46
|
+
"SolanaStakeAccountValidatorIsUnchangeable",
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const SolanaStakeNoWithdrawAuth = createCustomErrorClass("SolanaStakeNoWithdrawAuth");
|
|
50
|
+
|
|
51
|
+
export const SolanaStakeNoStakeAuth = createCustomErrorClass("SolanaStakeNoStakeAuth");
|
|
52
|
+
|
|
53
|
+
export const SolanaUseAllAmountStakeWarning = createCustomErrorClass(
|
|
54
|
+
"SolanaUseAllAmountStakeWarning",
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export const SolanaTxSimulationFailedWhilePendingOp = createCustomErrorClass(
|
|
58
|
+
"SolanaTxSimulationFailedWhilePendingOp",
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export const SolanaTxConfirmationTimeout = createCustomErrorClass("SolanaTxConfirmationTimeout");
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
2
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
3
|
+
import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
|
|
4
|
+
import { SolanaAddress, SolanaSignature, SolanaSigner } from "./signer";
|
|
5
|
+
|
|
6
|
+
import bs58 from "bs58";
|
|
7
|
+
|
|
8
|
+
const resolver = (
|
|
9
|
+
signerContext: SignerContext<SolanaSigner, SolanaAddress | SolanaSignature>,
|
|
10
|
+
): GetAddressFn => {
|
|
11
|
+
return async (deviceId: string, { path, verify }: GetAddressOptions) => {
|
|
12
|
+
const { address } = (await signerContext(deviceId, signer =>
|
|
13
|
+
signer.getAddress(path, verify),
|
|
14
|
+
)) as SolanaAddress;
|
|
15
|
+
|
|
16
|
+
const publicKey = bs58.encode(address);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
address: publicKey,
|
|
20
|
+
publicKey,
|
|
21
|
+
path,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default resolver;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { log } from "@ledgerhq/logs";
|
|
2
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
3
|
+
import type { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
4
|
+
import { ChainAPI } from "./api";
|
|
5
|
+
import { SolanaTxConfirmationTimeout, SolanaTxSimulationFailedWhilePendingOp } from "./errors";
|
|
6
|
+
|
|
7
|
+
export const broadcastWithAPI = async (
|
|
8
|
+
{
|
|
9
|
+
account,
|
|
10
|
+
signedOperation,
|
|
11
|
+
}: {
|
|
12
|
+
account: Account;
|
|
13
|
+
signedOperation: SignedOperation;
|
|
14
|
+
},
|
|
15
|
+
api: ChainAPI,
|
|
16
|
+
): Promise<Operation> => {
|
|
17
|
+
const { signature, operation } = signedOperation;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const txSignature = await api.sendRawTransaction(Buffer.from(signature, "hex"));
|
|
21
|
+
return patchOperationWithHash(operation, txSignature);
|
|
22
|
+
} catch (e: any) {
|
|
23
|
+
// heuristics to make some errors more user friendly
|
|
24
|
+
if (e instanceof Error) {
|
|
25
|
+
log("broadcast-error", e.message);
|
|
26
|
+
|
|
27
|
+
if (e.message.includes("simulation failed") && account.pendingOperations.length > 0) {
|
|
28
|
+
throw new SolanaTxSimulationFailedWhilePendingOp();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (e.message.includes("was not confirmed in")) {
|
|
32
|
+
throw new SolanaTxConfirmationTimeout();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
};
|