@ledgerhq/coin-solana 0.7.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +16 -0
- package/CHANGELOG.md +27 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/api/cached.d.ts +3 -0
- package/lib/api/cached.d.ts.map +1 -0
- package/lib/api/cached.js +41 -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 +96 -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 +272 -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 +134 -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 +988 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +7 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +37 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/buildTransaction.d.ts +5 -0
- package/lib/buildTransaction.d.ts.map +1 -0
- package/lib/buildTransaction.js +67 -0
- package/lib/buildTransaction.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/createTransaction.d.ts +5 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +19 -0
- package/lib/createTransaction.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/estimateMaxSpendable.d.ts +11 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +63 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +5 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +73 -0
- package/lib/getTransactionStatus.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/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/preload-data.d.ts +7 -0
- package/lib/preload-data.d.ts.map +1 -0
- package/lib/preload-data.js +45 -0
- package/lib/preload-data.js.map +1 -0
- package/lib/preload.d.ts +7 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +67 -0
- package/lib/preload.js.map +1 -0
- package/lib/preload.test.d.ts +2 -0
- package/lib/preload.test.d.ts.map +1 -0
- package/lib/preload.test.js +9 -0
- package/lib/preload.test.js.map +1 -0
- package/lib/prepareTransaction.d.ts +5 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +500 -0
- package/lib/prepareTransaction.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/signOperation.d.ts +7 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +153 -0
- package/lib/signOperation.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/synchronization.d.ts +5 -0
- package/lib/synchronization.d.ts.map +1 -0
- package/lib/synchronization.js +463 -0
- package/lib/synchronization.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +154 -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 +225 -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 +34 -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 +92 -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 +249 -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 +127 -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 +986 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +7 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +33 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/buildTransaction.d.ts +5 -0
- package/lib-es/buildTransaction.d.ts.map +1 -0
- package/lib-es/buildTransaction.js +63 -0
- package/lib-es/buildTransaction.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/createTransaction.d.ts +5 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +15 -0
- package/lib-es/createTransaction.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/estimateMaxSpendable.d.ts +11 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +55 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +5 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +69 -0
- package/lib-es/getTransactionStatus.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/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/preload-data.d.ts +7 -0
- package/lib-es/preload-data.d.ts.map +1 -0
- package/lib-es/preload-data.js +39 -0
- package/lib-es/preload-data.js.map +1 -0
- package/lib-es/preload.d.ts +7 -0
- package/lib-es/preload.d.ts.map +1 -0
- package/lib-es/preload.js +62 -0
- package/lib-es/preload.js.map +1 -0
- package/lib-es/preload.test.d.ts +2 -0
- package/lib-es/preload.test.d.ts.map +1 -0
- package/lib-es/preload.test.js +7 -0
- package/lib-es/preload.test.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +5 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +497 -0
- package/lib-es/prepareTransaction.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/signOperation.d.ts +7 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +146 -0
- package/lib-es/signOperation.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/synchronization.d.ts +5 -0
- package/lib-es/synchronization.d.ts.map +1 -0
- package/lib-es/synchronization.js +456 -0
- package/lib-es/synchronization.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 +148 -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 +225 -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 +90 -0
- package/src/api/cached.ts +79 -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 +212 -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 +192 -0
- package/src/bridge/js.ts +42 -0
- package/src/bridge.integration.test.ts +1104 -0
- package/src/broadcast.ts +38 -0
- package/src/buildTransaction.ts +81 -0
- package/src/cli-transaction.ts +246 -0
- package/src/createTransaction.ts +18 -0
- package/src/datasets/solana.scanAccounts.1.ts +9 -0
- package/src/deviceTransactionConfig.ts +302 -0
- package/src/errors.ts +61 -0
- package/src/estimateMaxSpendable.ts +72 -0
- package/src/getTransactionStatus.ts +79 -0
- package/src/hw-getAddress.ts +22 -0
- package/src/logic.ts +123 -0
- package/src/preload-data.ts +46 -0
- package/src/preload.test.ts +14 -0
- package/src/preload.ts +74 -0
- package/src/prepareTransaction.ts +686 -0
- package/src/serialization.ts +81 -0
- package/src/signOperation.ts +315 -0
- package/src/signer.ts +10 -0
- package/src/specs.ts +514 -0
- package/src/speculos-deviceActions.ts +229 -0
- package/src/synchronization.ts +729 -0
- package/src/transaction.ts +199 -0
- package/src/tx-fees.ts +206 -0
- package/src/types.ts +291 -0
- package/src/utils.ts +176 -0
- package/src/validator-app/index.ts +79 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import type {
|
|
3
|
+
Command,
|
|
4
|
+
StakeCreateAccountCommand,
|
|
5
|
+
StakeDelegateCommand,
|
|
6
|
+
StakeSplitCommand,
|
|
7
|
+
StakeUndelegateCommand,
|
|
8
|
+
StakeWithdrawCommand,
|
|
9
|
+
TokenCreateATACommand,
|
|
10
|
+
TokenTransferCommand,
|
|
11
|
+
Transaction,
|
|
12
|
+
TransactionRaw,
|
|
13
|
+
TransferCommand,
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { formatTransactionStatus } from "@ledgerhq/coin-framework/formatters";
|
|
16
|
+
import {
|
|
17
|
+
fromTransactionCommonRaw,
|
|
18
|
+
fromTransactionStatusRawCommon as fromTransactionStatusRaw,
|
|
19
|
+
toTransactionCommonRaw,
|
|
20
|
+
toTransactionStatusRawCommon as toTransactionStatusRaw,
|
|
21
|
+
} from "@ledgerhq/coin-framework/serialization";
|
|
22
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
23
|
+
import { getTokenById } from "@ledgerhq/cryptoassets/index";
|
|
24
|
+
import { findSubAccountById, getAccountCurrency } from "@ledgerhq/coin-framework/account";
|
|
25
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies";
|
|
26
|
+
import { assertUnreachable } from "./utils";
|
|
27
|
+
import { toTokenId } from "./logic";
|
|
28
|
+
|
|
29
|
+
export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
|
|
30
|
+
const common = fromTransactionCommonRaw(tr);
|
|
31
|
+
const { family, model } = tr;
|
|
32
|
+
return {
|
|
33
|
+
...common,
|
|
34
|
+
family,
|
|
35
|
+
model: JSON.parse(model),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const toTransactionRaw = (t: Transaction): TransactionRaw => {
|
|
40
|
+
const common = toTransactionCommonRaw(t);
|
|
41
|
+
const { family, model } = t;
|
|
42
|
+
return {
|
|
43
|
+
...common,
|
|
44
|
+
family,
|
|
45
|
+
model: JSON.stringify(model),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const lamportsToSOL = (account: Account, amount: number) => {
|
|
50
|
+
return formatCurrencyUnit(getAccountCurrency(account).units[0], new BigNumber(amount), {
|
|
51
|
+
showCode: true,
|
|
52
|
+
disableRounding: true,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const formatTransaction = (tx: Transaction, mainAccount: Account): string => {
|
|
57
|
+
if (tx.model.commandDescriptor === undefined) {
|
|
58
|
+
throw new Error("can not format unprepared transaction");
|
|
59
|
+
}
|
|
60
|
+
const { commandDescriptor } = tx.model;
|
|
61
|
+
|
|
62
|
+
if (Object.keys(commandDescriptor.errors).length > 0) {
|
|
63
|
+
throw new Error("can not format invalid transaction");
|
|
64
|
+
}
|
|
65
|
+
return formatCommand(mainAccount, tx, commandDescriptor.command);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function formatCommand(mainAccount: Account, tx: Transaction, command: Command) {
|
|
69
|
+
switch (command.kind) {
|
|
70
|
+
case "transfer":
|
|
71
|
+
return formatTransfer(mainAccount, tx, command);
|
|
72
|
+
case "token.transfer":
|
|
73
|
+
return formatTokenTransfer(mainAccount, tx, command);
|
|
74
|
+
case "token.createATA":
|
|
75
|
+
return formatCreateATA(command);
|
|
76
|
+
case "stake.createAccount":
|
|
77
|
+
return formatStakeCreateAccount(mainAccount, tx, command);
|
|
78
|
+
case "stake.delegate":
|
|
79
|
+
return formatStakeDelegate(command);
|
|
80
|
+
case "stake.undelegate":
|
|
81
|
+
return formatStakeUndelegate(command);
|
|
82
|
+
case "stake.withdraw":
|
|
83
|
+
return formatStakeWithdraw(mainAccount, tx, command);
|
|
84
|
+
case "stake.split":
|
|
85
|
+
return formatStakeSplit(mainAccount, tx, command);
|
|
86
|
+
default:
|
|
87
|
+
return assertUnreachable(command);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function formatStakeCreateAccount(
|
|
92
|
+
mainAccount: Account,
|
|
93
|
+
tx: Transaction,
|
|
94
|
+
command: StakeCreateAccountCommand,
|
|
95
|
+
) {
|
|
96
|
+
const amount = lamportsToSOL(mainAccount, command.amount + command.stakeAccRentExemptAmount);
|
|
97
|
+
const str = [
|
|
98
|
+
` CREATE STAKE ACCOUNT: ${command.stakeAccAddress}`,
|
|
99
|
+
` FROM: ${command.fromAccAddress}`,
|
|
100
|
+
` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
|
|
101
|
+
` SEED: ${command.seed}`,
|
|
102
|
+
` VALIDATOR: ${command.delegate.voteAccAddress}`,
|
|
103
|
+
]
|
|
104
|
+
.filter(Boolean)
|
|
105
|
+
.join("\n");
|
|
106
|
+
|
|
107
|
+
return "\n" + str;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function formatTransfer(mainAccount: Account, tx: Transaction, command: TransferCommand) {
|
|
111
|
+
const amount = lamportsToSOL(mainAccount, command.amount);
|
|
112
|
+
const str = [
|
|
113
|
+
` SEND: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
|
|
114
|
+
` TO: ${command.recipient}`,
|
|
115
|
+
command.memo ? ` MEMO: ${command.memo}` : "",
|
|
116
|
+
]
|
|
117
|
+
.filter(Boolean)
|
|
118
|
+
.join("\n");
|
|
119
|
+
|
|
120
|
+
return "\n" + str;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function formatTokenTransfer(mainAccount: Account, tx: Transaction, command: TokenTransferCommand) {
|
|
124
|
+
if (!tx.subAccountId) {
|
|
125
|
+
throw new Error("expected subaccountId on transaction");
|
|
126
|
+
}
|
|
127
|
+
const subAccount = findSubAccountById(mainAccount, tx.subAccountId);
|
|
128
|
+
if (!subAccount || subAccount.type !== "TokenAccount") {
|
|
129
|
+
throw new Error("token subaccount expected");
|
|
130
|
+
}
|
|
131
|
+
const amount = formatCurrencyUnit(
|
|
132
|
+
getAccountCurrency(subAccount).units[0],
|
|
133
|
+
new BigNumber(command.amount),
|
|
134
|
+
{
|
|
135
|
+
showCode: true,
|
|
136
|
+
disableRounding: true,
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
const recipient = command.recipientDescriptor.walletAddress;
|
|
140
|
+
const str = [
|
|
141
|
+
` SEND: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
|
|
142
|
+
` TO: ${recipient}`,
|
|
143
|
+
command.memo ? ` MEMO: ${command.memo}` : "",
|
|
144
|
+
]
|
|
145
|
+
.filter(Boolean)
|
|
146
|
+
.join("\n");
|
|
147
|
+
return "\n" + str;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function formatCreateATA(command: TokenCreateATACommand) {
|
|
151
|
+
const token = getTokenById(toTokenId(command.mint));
|
|
152
|
+
const str = [` OPT IN TOKEN: ${token.ticker}`].filter(Boolean).join("\n");
|
|
153
|
+
return "\n" + str;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function formatStakeDelegate(command: StakeDelegateCommand) {
|
|
157
|
+
const str = [` DELEGATE: ${command.stakeAccAddr}`, ` TO: ${command.voteAccAddr}`]
|
|
158
|
+
.filter(Boolean)
|
|
159
|
+
.join("\n");
|
|
160
|
+
return "\n" + str;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function formatStakeUndelegate(command: StakeUndelegateCommand) {
|
|
164
|
+
const str = [` UNDELEGATE: ${command.stakeAccAddr}`].filter(Boolean).join("\n");
|
|
165
|
+
return "\n" + str;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function formatStakeWithdraw(mainAccount: Account, tx: Transaction, command: StakeWithdrawCommand) {
|
|
169
|
+
const amount = lamportsToSOL(mainAccount, command.amount);
|
|
170
|
+
const str = [
|
|
171
|
+
` WITHDRAW FROM: ${command.stakeAccAddr}`,
|
|
172
|
+
` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
|
|
173
|
+
` TO: ${command.toAccAddr}`,
|
|
174
|
+
]
|
|
175
|
+
.filter(Boolean)
|
|
176
|
+
.join("\n");
|
|
177
|
+
return "\n" + str;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function formatStakeSplit(mainAccount: Account, tx: Transaction, command: StakeSplitCommand) {
|
|
181
|
+
const amount = lamportsToSOL(mainAccount, command.amount);
|
|
182
|
+
const str = [
|
|
183
|
+
` SPLIT: ${command.stakeAccAddr}`,
|
|
184
|
+
` AMOUNT: ${amount}${tx.useAllAmount ? " (ALL)" : ""}`,
|
|
185
|
+
` TO: ${command.splitStakeAccAddr}`,
|
|
186
|
+
]
|
|
187
|
+
.filter(Boolean)
|
|
188
|
+
.join("\n");
|
|
189
|
+
return "\n" + str;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default {
|
|
193
|
+
formatTransaction,
|
|
194
|
+
fromTransactionRaw,
|
|
195
|
+
toTransactionRaw,
|
|
196
|
+
fromTransactionStatusRaw,
|
|
197
|
+
toTransactionStatusRaw,
|
|
198
|
+
formatTransactionStatus,
|
|
199
|
+
};
|
package/src/tx-fees.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { ChainAPI } from "./api";
|
|
2
|
+
import { buildTransactionWithAPI } from "./buildTransaction";
|
|
3
|
+
import createTransaction from "./createTransaction";
|
|
4
|
+
import { Transaction, TransactionModel } from "./types";
|
|
5
|
+
import { assertUnreachable } from "./utils";
|
|
6
|
+
import { VersionedTransaction as OnChainTransaction } from "@solana/web3.js";
|
|
7
|
+
import { log } from "@ledgerhq/logs";
|
|
8
|
+
|
|
9
|
+
const DEFAULT_TX_FEE = 5000;
|
|
10
|
+
|
|
11
|
+
export async function estimateTxFee(
|
|
12
|
+
api: ChainAPI,
|
|
13
|
+
address: string,
|
|
14
|
+
kind: TransactionModel["kind"],
|
|
15
|
+
) {
|
|
16
|
+
const tx = createDummyTx(address, kind);
|
|
17
|
+
const [onChainTx] = await buildTransactionWithAPI(address, tx, api);
|
|
18
|
+
|
|
19
|
+
let fee = await api.getFeeForMessage(onChainTx.message);
|
|
20
|
+
|
|
21
|
+
if (typeof fee !== "number") {
|
|
22
|
+
// Sometimes getFeeForMessage doesn't return valid fees, because onChainTx.message.recentBlockhash
|
|
23
|
+
// is outdated --> retrying with a next blockhash
|
|
24
|
+
log("debug", `Solana api.getFeeForMessage returned invalid fee: <${fee}>`);
|
|
25
|
+
fee = await retryWithNewBlockhash(api, onChainTx);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof fee !== "number") {
|
|
29
|
+
log(
|
|
30
|
+
"error",
|
|
31
|
+
`Solana unexpected fee: <${fee}>, after retry with a new blockhash. Fallback to the default.`,
|
|
32
|
+
);
|
|
33
|
+
// If still failing, fallback to a default fees value
|
|
34
|
+
fee = DEFAULT_TX_FEE;
|
|
35
|
+
}
|
|
36
|
+
return fee;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const createDummyTx = (address: string, kind: TransactionModel["kind"]) => {
|
|
40
|
+
switch (kind) {
|
|
41
|
+
case "transfer":
|
|
42
|
+
return createDummyTransferTx(address);
|
|
43
|
+
case "stake.createAccount":
|
|
44
|
+
return createDummyStakeCreateAccountTx(address);
|
|
45
|
+
case "stake.delegate":
|
|
46
|
+
return createDummyStakeDelegateTx(address);
|
|
47
|
+
case "stake.undelegate":
|
|
48
|
+
return createDummyStakeUndelegateTx(address);
|
|
49
|
+
case "stake.withdraw":
|
|
50
|
+
return createDummyStakeWithdrawTx(address);
|
|
51
|
+
case "stake.split":
|
|
52
|
+
case "token.createATA":
|
|
53
|
+
case "token.transfer":
|
|
54
|
+
throw new Error(`not implemented for <${kind}>`);
|
|
55
|
+
default:
|
|
56
|
+
return assertUnreachable(kind);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const createDummyTransferTx = (address: string): Transaction => {
|
|
61
|
+
return {
|
|
62
|
+
...createTransaction({} as any),
|
|
63
|
+
model: {
|
|
64
|
+
kind: "transfer",
|
|
65
|
+
uiState: {},
|
|
66
|
+
commandDescriptor: {
|
|
67
|
+
command: {
|
|
68
|
+
kind: "transfer",
|
|
69
|
+
amount: 0,
|
|
70
|
+
recipient: address,
|
|
71
|
+
sender: address,
|
|
72
|
+
},
|
|
73
|
+
...commandDescriptorCommons,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const createDummyStakeCreateAccountTx = (address: string): Transaction => {
|
|
80
|
+
return {
|
|
81
|
+
...createTransaction({} as any),
|
|
82
|
+
model: {
|
|
83
|
+
kind: "stake.createAccount",
|
|
84
|
+
uiState: {} as any,
|
|
85
|
+
commandDescriptor: {
|
|
86
|
+
command: {
|
|
87
|
+
kind: "stake.createAccount",
|
|
88
|
+
amount: 0,
|
|
89
|
+
delegate: {
|
|
90
|
+
voteAccAddress: randomAddresses[0],
|
|
91
|
+
},
|
|
92
|
+
fromAccAddress: address,
|
|
93
|
+
seed: "",
|
|
94
|
+
stakeAccAddress: randomAddresses[1],
|
|
95
|
+
stakeAccRentExemptAmount: 0,
|
|
96
|
+
},
|
|
97
|
+
...commandDescriptorCommons,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const createDummyStakeDelegateTx = (address: string): Transaction => {
|
|
104
|
+
return {
|
|
105
|
+
...createTransaction({} as any),
|
|
106
|
+
model: {
|
|
107
|
+
kind: "stake.delegate",
|
|
108
|
+
uiState: {} as any,
|
|
109
|
+
commandDescriptor: {
|
|
110
|
+
command: {
|
|
111
|
+
kind: "stake.delegate",
|
|
112
|
+
authorizedAccAddr: address,
|
|
113
|
+
stakeAccAddr: randomAddresses[0],
|
|
114
|
+
voteAccAddr: randomAddresses[1],
|
|
115
|
+
},
|
|
116
|
+
...commandDescriptorCommons,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const createDummyStakeUndelegateTx = (address: string): Transaction => {
|
|
123
|
+
return {
|
|
124
|
+
...createTransaction({} as any),
|
|
125
|
+
model: {
|
|
126
|
+
kind: "stake.undelegate",
|
|
127
|
+
uiState: {} as any,
|
|
128
|
+
commandDescriptor: {
|
|
129
|
+
command: {
|
|
130
|
+
kind: "stake.undelegate",
|
|
131
|
+
authorizedAccAddr: address,
|
|
132
|
+
stakeAccAddr: randomAddresses[0],
|
|
133
|
+
},
|
|
134
|
+
...commandDescriptorCommons,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const createDummyStakeWithdrawTx = (address: string): Transaction => {
|
|
141
|
+
return {
|
|
142
|
+
...createTransaction({} as any),
|
|
143
|
+
model: {
|
|
144
|
+
kind: "stake.withdraw",
|
|
145
|
+
uiState: {} as any,
|
|
146
|
+
commandDescriptor: {
|
|
147
|
+
command: {
|
|
148
|
+
kind: "stake.withdraw",
|
|
149
|
+
amount: 0,
|
|
150
|
+
authorizedAccAddr: address,
|
|
151
|
+
stakeAccAddr: randomAddresses[0],
|
|
152
|
+
toAccAddr: randomAddresses[1],
|
|
153
|
+
},
|
|
154
|
+
...commandDescriptorCommons,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const commandDescriptorCommons = {
|
|
161
|
+
errors: {},
|
|
162
|
+
fee: 0,
|
|
163
|
+
warnings: {},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// pregenerate for better caching
|
|
167
|
+
const randomAddresses = [
|
|
168
|
+
"HxCvgjSbF8HMt3fj8P3j49jmajNCMwKAqBu79HUDPtkM",
|
|
169
|
+
"AjmMiagw33Ad4WdPR3y2QWsDXaLxmsiSZEpMfpT1Q9uZ",
|
|
170
|
+
"AVHhsobqNw3b3XD43fz7Crq3d3UxFYZfHAByh7ogZoeN",
|
|
171
|
+
"FvbvvXMY4Rf1AtGG7UHJUesjt8FFgPnPy6o83Dna9mXK",
|
|
172
|
+
"AEtRo9MKfLqGtjvxdz8H93R7SQxXLEkibVSJbs9XKnD1",
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
async function retryWithNewBlockhash(api: ChainAPI, onChainTx: OnChainTransaction) {
|
|
176
|
+
if (onChainTx.message.recentBlockhash === undefined) {
|
|
177
|
+
throw new Error("expected recentBlockhash");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
onChainTx.message.recentBlockhash = await waitNextBlockhash(
|
|
181
|
+
api,
|
|
182
|
+
onChainTx.message.recentBlockhash,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return api.getFeeForMessage(onChainTx.message);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function sleep(durationMS: number): Promise<void> {
|
|
189
|
+
return new Promise(res => setTimeout(res, durationMS));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function waitNextBlockhash(api: ChainAPI, currentBlockhash: string) {
|
|
193
|
+
const sleepTimeMS = 5000;
|
|
194
|
+
for (let i = 0; i < 5; i++) {
|
|
195
|
+
log("info", `sleeping for ${sleepTimeMS} ms, waiting for a new blockhash`);
|
|
196
|
+
await sleep(sleepTimeMS);
|
|
197
|
+
const blockhash = await api.getLatestBlockhash();
|
|
198
|
+
if (blockhash !== currentBlockhash) {
|
|
199
|
+
log("info", "got a new blockhash");
|
|
200
|
+
return blockhash;
|
|
201
|
+
}
|
|
202
|
+
log("info", "got same blockhash");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
throw new Error("next blockhash timeout");
|
|
206
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
Account,
|
|
4
|
+
AccountRaw,
|
|
5
|
+
Operation,
|
|
6
|
+
TransactionCommon,
|
|
7
|
+
TransactionCommonRaw,
|
|
8
|
+
TransactionStatusCommon,
|
|
9
|
+
TransactionStatusCommonRaw,
|
|
10
|
+
} from "@ledgerhq/types-live";
|
|
11
|
+
import { ValidatorsAppValidator } from "./validator-app";
|
|
12
|
+
|
|
13
|
+
export type TransferCommand = {
|
|
14
|
+
kind: "transfer";
|
|
15
|
+
sender: string;
|
|
16
|
+
recipient: string;
|
|
17
|
+
amount: number;
|
|
18
|
+
memo?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type TokenCreateATACommand = {
|
|
22
|
+
kind: "token.createATA";
|
|
23
|
+
owner: string;
|
|
24
|
+
mint: string;
|
|
25
|
+
associatedTokenAccountAddress: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type StakeCreateAccountCommand = {
|
|
29
|
+
kind: "stake.createAccount";
|
|
30
|
+
fromAccAddress: string;
|
|
31
|
+
stakeAccAddress: string;
|
|
32
|
+
seed: string;
|
|
33
|
+
amount: number;
|
|
34
|
+
stakeAccRentExemptAmount: number;
|
|
35
|
+
delegate: {
|
|
36
|
+
voteAccAddress: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type StakeDelegateCommand = {
|
|
41
|
+
kind: "stake.delegate";
|
|
42
|
+
authorizedAccAddr: string;
|
|
43
|
+
stakeAccAddr: string;
|
|
44
|
+
voteAccAddr: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type StakeUndelegateCommand = {
|
|
48
|
+
kind: "stake.undelegate";
|
|
49
|
+
authorizedAccAddr: string;
|
|
50
|
+
stakeAccAddr: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type StakeWithdrawCommand = {
|
|
54
|
+
kind: "stake.withdraw";
|
|
55
|
+
authorizedAccAddr: string;
|
|
56
|
+
stakeAccAddr: string;
|
|
57
|
+
toAccAddr: string;
|
|
58
|
+
amount: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type StakeSplitCommand = {
|
|
62
|
+
kind: "stake.split";
|
|
63
|
+
authorizedAccAddr: string;
|
|
64
|
+
stakeAccAddr: string;
|
|
65
|
+
amount: number;
|
|
66
|
+
seed: string;
|
|
67
|
+
splitStakeAccAddr: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type TokenRecipientDescriptor = {
|
|
71
|
+
walletAddress: string;
|
|
72
|
+
tokenAccAddress: string;
|
|
73
|
+
shouldCreateAsAssociatedTokenAccount: boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type TokenTransferCommand = {
|
|
77
|
+
kind: "token.transfer";
|
|
78
|
+
ownerAddress: string;
|
|
79
|
+
ownerAssociatedTokenAccountAddress: string;
|
|
80
|
+
recipientDescriptor: TokenRecipientDescriptor;
|
|
81
|
+
amount: number;
|
|
82
|
+
mintAddress: string;
|
|
83
|
+
mintDecimals: number;
|
|
84
|
+
memo?: string | undefined;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type Command =
|
|
88
|
+
| TransferCommand
|
|
89
|
+
| TokenTransferCommand
|
|
90
|
+
| TokenCreateATACommand
|
|
91
|
+
| StakeCreateAccountCommand
|
|
92
|
+
| StakeDelegateCommand
|
|
93
|
+
| StakeUndelegateCommand
|
|
94
|
+
| StakeWithdrawCommand
|
|
95
|
+
| StakeSplitCommand;
|
|
96
|
+
|
|
97
|
+
export type CommandDescriptor = {
|
|
98
|
+
command: Command;
|
|
99
|
+
fee: number;
|
|
100
|
+
warnings: Record<string, Error>;
|
|
101
|
+
errors: Record<string, Error>;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type TransferTransaction = {
|
|
105
|
+
kind: "transfer";
|
|
106
|
+
uiState: {
|
|
107
|
+
memo?: string | undefined;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type TokenTransferTransaction = {
|
|
112
|
+
kind: "token.transfer";
|
|
113
|
+
uiState: {
|
|
114
|
+
subAccountId: string;
|
|
115
|
+
memo?: string | undefined;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type TokenCreateATATransaction = {
|
|
120
|
+
kind: "token.createATA";
|
|
121
|
+
uiState: {
|
|
122
|
+
tokenId: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type StakeCreateAccountTransaction = {
|
|
127
|
+
kind: "stake.createAccount";
|
|
128
|
+
uiState: {
|
|
129
|
+
delegate: {
|
|
130
|
+
voteAccAddress: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type StakeDelegateTransaction = {
|
|
136
|
+
kind: "stake.delegate";
|
|
137
|
+
uiState: {
|
|
138
|
+
stakeAccAddr: string;
|
|
139
|
+
voteAccAddr: string;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export type StakeUndelegateTransaction = {
|
|
144
|
+
kind: "stake.undelegate";
|
|
145
|
+
uiState: {
|
|
146
|
+
stakeAccAddr: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type StakeWithdrawTransaction = {
|
|
151
|
+
kind: "stake.withdraw";
|
|
152
|
+
uiState: {
|
|
153
|
+
stakeAccAddr: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type StakeSplitTransaction = {
|
|
158
|
+
kind: "stake.split";
|
|
159
|
+
uiState: {
|
|
160
|
+
stakeAccAddr: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export type TransactionModel = { commandDescriptor?: CommandDescriptor } & (
|
|
165
|
+
| TransferTransaction
|
|
166
|
+
| TokenTransferTransaction
|
|
167
|
+
| TokenCreateATATransaction
|
|
168
|
+
| StakeCreateAccountTransaction
|
|
169
|
+
| StakeDelegateTransaction
|
|
170
|
+
| StakeUndelegateTransaction
|
|
171
|
+
| StakeWithdrawTransaction
|
|
172
|
+
| StakeSplitTransaction
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
export type Transaction = TransactionCommon & {
|
|
176
|
+
family: "solana";
|
|
177
|
+
model: TransactionModel;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
181
|
+
family: "solana";
|
|
182
|
+
model: string;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export type SolanaStake = {
|
|
186
|
+
stakeAccAddr: string;
|
|
187
|
+
hasStakeAuth: boolean;
|
|
188
|
+
hasWithdrawAuth: boolean;
|
|
189
|
+
delegation:
|
|
190
|
+
| {
|
|
191
|
+
stake: number;
|
|
192
|
+
voteAccAddr: string;
|
|
193
|
+
}
|
|
194
|
+
| undefined;
|
|
195
|
+
stakeAccBalance: number;
|
|
196
|
+
rentExemptReserve: number;
|
|
197
|
+
withdrawable: number;
|
|
198
|
+
activation: {
|
|
199
|
+
state: "active" | "inactive" | "activating" | "deactivating";
|
|
200
|
+
active: number;
|
|
201
|
+
inactive: number;
|
|
202
|
+
};
|
|
203
|
+
reward?:
|
|
204
|
+
| {
|
|
205
|
+
amount: number;
|
|
206
|
+
}
|
|
207
|
+
| undefined;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export type SolanaStakeWithMeta = {
|
|
211
|
+
stake: SolanaStake;
|
|
212
|
+
meta: {
|
|
213
|
+
validator?: {
|
|
214
|
+
name?: string;
|
|
215
|
+
img?: string;
|
|
216
|
+
url?: string;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export type SolanaResources = {
|
|
222
|
+
stakes: SolanaStake[];
|
|
223
|
+
unstakeReserve: BigNumber;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export type SolanaResourcesRaw = {
|
|
227
|
+
stakes: string;
|
|
228
|
+
unstakeReserve: string;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export type SolanaValidator = {
|
|
232
|
+
voteAccAddr: string;
|
|
233
|
+
commission: number;
|
|
234
|
+
activatedStake: number;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export type SolanaPreloadDataV1 = {
|
|
238
|
+
version: "1";
|
|
239
|
+
validatorsWithMeta: SolanaValidatorWithMeta[];
|
|
240
|
+
validators: ValidatorsAppValidator[];
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// exists for discriminated union to work
|
|
244
|
+
export type SolanaPreloadDataV2 = {
|
|
245
|
+
version: "2";
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export type SolanaPreloadData = SolanaPreloadDataV1 | SolanaPreloadDataV2;
|
|
249
|
+
|
|
250
|
+
export type SolanaValidatorWithMeta = {
|
|
251
|
+
validator: SolanaValidator;
|
|
252
|
+
meta: {
|
|
253
|
+
name?: string;
|
|
254
|
+
img?: string;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export type StakeAction = "deactivate" | "activate" | "withdraw" | "reactivate";
|
|
259
|
+
|
|
260
|
+
export type SolanaAccount = Account & { solanaResources: SolanaResources };
|
|
261
|
+
|
|
262
|
+
export type SolanaAccountRaw = AccountRaw & {
|
|
263
|
+
solanaResources: SolanaResourcesRaw;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
267
|
+
|
|
268
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
269
|
+
|
|
270
|
+
export type SolanaOperation = Operation<SolanaOperationExtra>;
|
|
271
|
+
export type SolanaOperationRaw = Operation<SolanaOperationExtraRaw>;
|
|
272
|
+
|
|
273
|
+
export type ExtraStakeInfo = {
|
|
274
|
+
address: string;
|
|
275
|
+
amount: BigNumber;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export type ExtraStakeInfoRaw = {
|
|
279
|
+
address: string;
|
|
280
|
+
amount: string;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export type SolanaOperationExtra = {
|
|
284
|
+
memo?: string | undefined;
|
|
285
|
+
stake?: ExtraStakeInfo;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export type SolanaOperationExtraRaw = {
|
|
289
|
+
memo?: string | undefined;
|
|
290
|
+
stake?: ExtraStakeInfoRaw;
|
|
291
|
+
};
|