@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,55 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import network from "@ledgerhq/live-network/network";
|
|
11
|
+
import { compact } from "lodash/fp";
|
|
12
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
13
|
+
const MAX_VALIDATORS_NB = 1000; // Max number of validators to fetch
|
|
14
|
+
const URLS = {
|
|
15
|
+
validatorList: (cluster) => {
|
|
16
|
+
if (cluster === "testnet") {
|
|
17
|
+
const baseUrl = getEnv("SOLANA_TESTNET_VALIDATORS_APP_BASE_URL");
|
|
18
|
+
return `${baseUrl}/${cluster}.json?order=score&limit=${MAX_VALIDATORS_NB}`;
|
|
19
|
+
}
|
|
20
|
+
const baseUrl = getEnv("SOLANA_VALIDATORS_APP_BASE_URL");
|
|
21
|
+
return baseUrl;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export function getValidators(cluster) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const response = yield network({
|
|
27
|
+
method: "GET",
|
|
28
|
+
url: URLS.validatorList(cluster),
|
|
29
|
+
});
|
|
30
|
+
const allRawValidators = response.status === 200 ? response.data : [];
|
|
31
|
+
// validators app data is not clean: random properties can randomly contain
|
|
32
|
+
// data, null, undefined
|
|
33
|
+
const tryFromRawValidator = (validator) => {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
if (typeof validator.active_stake === "number" &&
|
|
36
|
+
typeof validator.commission === "number" &&
|
|
37
|
+
typeof validator.total_score === "number" &&
|
|
38
|
+
typeof validator.vote_account === "string" &&
|
|
39
|
+
validator.delinquent !== true) {
|
|
40
|
+
return {
|
|
41
|
+
activeStake: validator.active_stake,
|
|
42
|
+
commission: validator.commission,
|
|
43
|
+
totalScore: validator.total_score,
|
|
44
|
+
voteAccount: validator.vote_account,
|
|
45
|
+
name: (_a = validator.name) !== null && _a !== void 0 ? _a : undefined,
|
|
46
|
+
avatarUrl: (_b = validator.avatar_url) !== null && _b !== void 0 ? _b : undefined,
|
|
47
|
+
wwwUrl: (_c = validator.www_url) !== null && _c !== void 0 ? _c : undefined,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
};
|
|
52
|
+
return compact(allRawValidators.map(tryFromRawValidator));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validator-app/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,gCAAgC,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,oCAAoC;AAuBpE,MAAM,IAAI,GAAG;IACX,aAAa,EAAE,CAAC,OAAqD,EAAE,EAAE;QACvE,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,wCAAwC,CAAC,CAAC;YACjE,OAAO,GAAG,OAAO,IAAI,OAAO,2BAA2B,iBAAiB,EAAE,CAAC;QAC7E,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC;AAEF,MAAM,UAAgB,aAAa,CACjC,OAAqD;;QAErD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;YAC7B,MAAM,EAAE,KAAK;YACb,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;SACjC,CAAC,CAAC;QAEH,MAAM,gBAAgB,GACpB,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAE,QAAQ,CAAC,IAAoC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEhF,2EAA2E;QAC3E,wBAAwB;QACxB,MAAM,mBAAmB,GAAG,CAC1B,SAAoC,EACA,EAAE;;YACtC,IACE,OAAO,SAAS,CAAC,YAAY,KAAK,QAAQ;gBAC1C,OAAO,SAAS,CAAC,UAAU,KAAK,QAAQ;gBACxC,OAAO,SAAS,CAAC,WAAW,KAAK,QAAQ;gBACzC,OAAO,SAAS,CAAC,YAAY,KAAK,QAAQ;gBAC1C,SAAS,CAAC,UAAU,KAAK,IAAI,EAC7B,CAAC;gBACD,OAAO;oBACL,WAAW,EAAE,SAAS,CAAC,YAAY;oBACnC,UAAU,EAAE,SAAS,CAAC,UAAU;oBAChC,UAAU,EAAE,SAAS,CAAC,WAAW;oBACjC,WAAW,EAAE,SAAS,CAAC,YAAY;oBACnC,IAAI,EAAE,MAAA,SAAS,CAAC,IAAI,mCAAI,SAAS;oBACjC,SAAS,EAAE,MAAA,SAAS,CAAC,UAAU,mCAAI,SAAS;oBAC5C,MAAM,EAAE,MAAA,SAAS,CAAC,OAAO,mCAAI,SAAS;iBACvC,CAAC;YACJ,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,OAAO,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC5D,CAAC;CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ledgerhq/coin-solana",
|
|
3
|
+
"version": "0.7.0-next.0",
|
|
4
|
+
"description": "Ledger Solana Coin integration",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Ledger",
|
|
7
|
+
"LedgerWallet",
|
|
8
|
+
"sol",
|
|
9
|
+
"Solana",
|
|
10
|
+
"Hardware Wallet"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/LedgerHQ/ledger-live/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-solana",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"typesVersions": {
|
|
24
|
+
"*": {
|
|
25
|
+
"lib/*": [
|
|
26
|
+
"lib/*"
|
|
27
|
+
],
|
|
28
|
+
"lib-es/*": [
|
|
29
|
+
"lib-es/*"
|
|
30
|
+
],
|
|
31
|
+
"*": [
|
|
32
|
+
"lib/*"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
"./lib/*": "./lib/*.js",
|
|
38
|
+
"./lib-es/*": "./lib-es/*.js",
|
|
39
|
+
"./*": {
|
|
40
|
+
"require": "./lib/*.js",
|
|
41
|
+
"default": "./lib-es/*.js"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
"license": "Apache-2.0",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@solana/spl-token": "^0.3.7",
|
|
48
|
+
"@solana/web3.js": "1.77.3",
|
|
49
|
+
"bignumber.js": "^9.1.2",
|
|
50
|
+
"bs58": "^4.0.1",
|
|
51
|
+
"expect": "^27.4.6",
|
|
52
|
+
"invariant": "^2.2.2",
|
|
53
|
+
"lodash": "^4.17.21",
|
|
54
|
+
"object-hash": "^2.2.0",
|
|
55
|
+
"rxjs": "^7.8.1",
|
|
56
|
+
"superstruct": "0.14.2",
|
|
57
|
+
"@ledgerhq/coin-framework": "^0.14.0-next.0",
|
|
58
|
+
"@ledgerhq/cryptoassets": "^13.1.0-next.0",
|
|
59
|
+
"@ledgerhq/devices": "^8.4.0-next.0",
|
|
60
|
+
"@ledgerhq/errors": "^6.17.0-next.0",
|
|
61
|
+
"@ledgerhq/live-env": "^2.1.0-next.0",
|
|
62
|
+
"@ledgerhq/live-network": "^1.3.0-next.0",
|
|
63
|
+
"@ledgerhq/logs": "^6.12.0",
|
|
64
|
+
"@ledgerhq/types-cryptoassets": "^7.13.0-next.0",
|
|
65
|
+
"@ledgerhq/types-live": "^6.48.0-next.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/bs58": "^4.0.1",
|
|
69
|
+
"@types/invariant": "^2.2.2",
|
|
70
|
+
"@types/jest": "^29.5.10",
|
|
71
|
+
"@types/lodash": "^4.14.191",
|
|
72
|
+
"@types/object-hash": "^2.1.0",
|
|
73
|
+
"@faker-js/faker": "^8.4.1",
|
|
74
|
+
"jest": "^29.7.0",
|
|
75
|
+
"ts-jest": "^29.1.1"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"clean": "rimraf lib lib-es",
|
|
79
|
+
"build": "tsc && tsc -m ES6 --outDir lib-es",
|
|
80
|
+
"coverage": "jest --coverage --testPathIgnorePatterns='/bridge.integration.test.ts|node_modules|lib-es|lib/' --passWithNoTests && mv coverage/coverage-final.json coverage/coverage-solana.json",
|
|
81
|
+
"prewatch": "pnpm build",
|
|
82
|
+
"watch": "tsc --watch",
|
|
83
|
+
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
|
|
84
|
+
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
|
|
85
|
+
"lint:fix": "pnpm lint --fix",
|
|
86
|
+
"test": "jest",
|
|
87
|
+
"typecheck": "tsc --noEmit",
|
|
88
|
+
"unimported": "unimported"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { makeLRUCache, minutes, seconds } from "@ledgerhq/live-network/cache";
|
|
2
|
+
import hash from "object-hash";
|
|
3
|
+
import { ChainAPI } from "./chain";
|
|
4
|
+
|
|
5
|
+
const cacheKeyAddress = (address: string) => address;
|
|
6
|
+
const cacheKeyEmpty = () => "" as const;
|
|
7
|
+
const cacheKeyAssocTokenAccAddress = (owner: string, mint: string) => `${owner}:${mint}`;
|
|
8
|
+
const cacheKeyMinimumBalanceForRentExemption = (dataLengt: number) => dataLengt.toString();
|
|
9
|
+
|
|
10
|
+
const cacheKeyTransactions = (signatures: string[]) => hash([...signatures].sort());
|
|
11
|
+
|
|
12
|
+
const cacheKeyByArgs = (...args: any[]) => hash(args);
|
|
13
|
+
|
|
14
|
+
export function cached(api: ChainAPI): ChainAPI {
|
|
15
|
+
return {
|
|
16
|
+
findAssocTokenAccAddress: makeLRUCache(
|
|
17
|
+
api.findAssocTokenAccAddress,
|
|
18
|
+
cacheKeyAssocTokenAccAddress,
|
|
19
|
+
minutes(1000),
|
|
20
|
+
),
|
|
21
|
+
|
|
22
|
+
getAccountInfo: makeLRUCache(api.getAccountInfo, cacheKeyAddress, seconds(30)),
|
|
23
|
+
|
|
24
|
+
getAssocTokenAccMinNativeBalance: makeLRUCache(
|
|
25
|
+
api.getAssocTokenAccMinNativeBalance,
|
|
26
|
+
cacheKeyEmpty,
|
|
27
|
+
minutes(5),
|
|
28
|
+
),
|
|
29
|
+
|
|
30
|
+
getBalance: makeLRUCache(api.getBalance, cacheKeyAddress, seconds(30)),
|
|
31
|
+
|
|
32
|
+
getBalanceAndContext: makeLRUCache(api.getBalanceAndContext, cacheKeyAddress, seconds(30)),
|
|
33
|
+
|
|
34
|
+
getParsedTransactions: makeLRUCache(
|
|
35
|
+
api.getParsedTransactions,
|
|
36
|
+
cacheKeyTransactions,
|
|
37
|
+
seconds(30),
|
|
38
|
+
),
|
|
39
|
+
|
|
40
|
+
getParsedTokenAccountsByOwner: makeLRUCache(
|
|
41
|
+
api.getParsedTokenAccountsByOwner,
|
|
42
|
+
cacheKeyAddress,
|
|
43
|
+
minutes(1),
|
|
44
|
+
),
|
|
45
|
+
|
|
46
|
+
// cached by default in api
|
|
47
|
+
getStakeAccountsByStakeAuth: api.getStakeAccountsByStakeAuth,
|
|
48
|
+
getStakeAccountsByWithdrawAuth: api.getStakeAccountsByWithdrawAuth,
|
|
49
|
+
|
|
50
|
+
getStakeActivation: makeLRUCache(api.getStakeActivation, cacheKeyAddress, minutes(1)),
|
|
51
|
+
|
|
52
|
+
getInflationReward: makeLRUCache(api.getInflationReward, cacheKeyByArgs, minutes(5)),
|
|
53
|
+
|
|
54
|
+
getVoteAccounts: makeLRUCache(api.getVoteAccounts, cacheKeyEmpty, minutes(1)),
|
|
55
|
+
|
|
56
|
+
getLatestBlockhash: makeLRUCache(api.getLatestBlockhash, cacheKeyEmpty, seconds(15)),
|
|
57
|
+
|
|
58
|
+
getFeeForMessage: makeLRUCache(
|
|
59
|
+
api.getFeeForMessage,
|
|
60
|
+
msg => msg.serialize().toString(),
|
|
61
|
+
minutes(1),
|
|
62
|
+
),
|
|
63
|
+
|
|
64
|
+
getSignaturesForAddress: makeLRUCache(api.getSignaturesForAddress, cacheKeyByArgs, seconds(30)),
|
|
65
|
+
|
|
66
|
+
getMinimumBalanceForRentExemption: makeLRUCache(
|
|
67
|
+
api.getMinimumBalanceForRentExemption,
|
|
68
|
+
cacheKeyMinimumBalanceForRentExemption,
|
|
69
|
+
minutes(5),
|
|
70
|
+
),
|
|
71
|
+
|
|
72
|
+
// do not cache
|
|
73
|
+
sendRawTransaction: api.sendRawTransaction,
|
|
74
|
+
|
|
75
|
+
getEpochInfo: makeLRUCache(api.getEpochInfo, cacheKeyEmpty, minutes(1)),
|
|
76
|
+
|
|
77
|
+
config: api.config,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tryParseAsTokenAccount, parseTokenAccountInfo, tryParseAsVoteAccount } from "./parser";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ParsedAccountData } from "@solana/web3.js";
|
|
2
|
+
import { create } from "superstruct";
|
|
3
|
+
import { PARSED_PROGRAMS } from "../program/constants";
|
|
4
|
+
import { ParsedInfo } from "../validators";
|
|
5
|
+
import { StakeAccountInfo } from "./stake";
|
|
6
|
+
import { TokenAccount, TokenAccountInfo } from "./token";
|
|
7
|
+
import { VoteAccount, VoteAccountInfo } from "./vote";
|
|
8
|
+
|
|
9
|
+
export function parseTokenAccountInfo(info: unknown): TokenAccountInfo {
|
|
10
|
+
return create(info, TokenAccountInfo);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function tryParseAsTokenAccount(
|
|
14
|
+
data: ParsedAccountData,
|
|
15
|
+
): TokenAccountInfo | undefined | Error {
|
|
16
|
+
const routine = () => {
|
|
17
|
+
const info = create(data.parsed, ParsedInfo);
|
|
18
|
+
|
|
19
|
+
if (data.program === "spl-token") {
|
|
20
|
+
const parsed = create(info, TokenAccount);
|
|
21
|
+
if (parsed.type === "account") {
|
|
22
|
+
return parseTokenAccountInfo(parsed.info);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return onThrowReturnError(routine);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function parseVoteAccountInfo(info: unknown): VoteAccountInfo {
|
|
33
|
+
return create(info, VoteAccountInfo);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function tryParseAsVoteAccount(
|
|
37
|
+
data: ParsedAccountData,
|
|
38
|
+
): VoteAccountInfo | undefined | Error {
|
|
39
|
+
const routine = () => {
|
|
40
|
+
const info = create(data.parsed, ParsedInfo);
|
|
41
|
+
|
|
42
|
+
if (data.program === PARSED_PROGRAMS.VOTE) {
|
|
43
|
+
const parsed = create(info, VoteAccount);
|
|
44
|
+
return parseVoteAccountInfo(parsed.info);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return undefined;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return onThrowReturnError(routine);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function parseStakeAccountInfo(info: unknown): StakeAccountInfo {
|
|
54
|
+
return create(info, StakeAccountInfo);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onThrowReturnError<R>(fn: () => R) {
|
|
58
|
+
try {
|
|
59
|
+
return fn();
|
|
60
|
+
} catch (e) {
|
|
61
|
+
return e instanceof Error ? e : new Error(JSON.stringify(e));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
2
|
+
|
|
3
|
+
import { Infer, number, nullable, enums, type } from "superstruct";
|
|
4
|
+
import { PublicKeyFromString } from "../validators/pubkey";
|
|
5
|
+
import { BigNumFromString } from "../validators/bignum";
|
|
6
|
+
|
|
7
|
+
export type StakeAccountType = Infer<typeof StakeAccountType>;
|
|
8
|
+
export const StakeAccountType = enums(["uninitialized", "initialized", "delegated", "rewardsPool"]);
|
|
9
|
+
|
|
10
|
+
export type StakeMeta = Infer<typeof StakeMeta>;
|
|
11
|
+
export const StakeMeta = type({
|
|
12
|
+
rentExemptReserve: BigNumFromString,
|
|
13
|
+
authorized: type({
|
|
14
|
+
staker: PublicKeyFromString,
|
|
15
|
+
withdrawer: PublicKeyFromString,
|
|
16
|
+
}),
|
|
17
|
+
lockup: type({
|
|
18
|
+
unixTimestamp: number(),
|
|
19
|
+
epoch: number(),
|
|
20
|
+
custodian: PublicKeyFromString,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type StakeAccountInfo = Infer<typeof StakeAccountInfo>;
|
|
25
|
+
export const StakeAccountInfo = type({
|
|
26
|
+
meta: StakeMeta,
|
|
27
|
+
stake: nullable(
|
|
28
|
+
type({
|
|
29
|
+
delegation: type({
|
|
30
|
+
voter: PublicKeyFromString,
|
|
31
|
+
stake: BigNumFromString,
|
|
32
|
+
activationEpoch: BigNumFromString,
|
|
33
|
+
deactivationEpoch: BigNumFromString,
|
|
34
|
+
warmupCooldownRate: number(),
|
|
35
|
+
}),
|
|
36
|
+
creditsObserved: number(),
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type StakeAccount = Infer<typeof StakeAccount>;
|
|
42
|
+
export const StakeAccount = type({
|
|
43
|
+
type: StakeAccountType,
|
|
44
|
+
info: StakeAccountInfo,
|
|
45
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Infer,
|
|
5
|
+
number,
|
|
6
|
+
optional,
|
|
7
|
+
enums,
|
|
8
|
+
any,
|
|
9
|
+
boolean,
|
|
10
|
+
string,
|
|
11
|
+
array,
|
|
12
|
+
type,
|
|
13
|
+
nullable,
|
|
14
|
+
} from "superstruct";
|
|
15
|
+
import { PublicKeyFromString } from "../validators/pubkey";
|
|
16
|
+
|
|
17
|
+
export type TokenAccountType = Infer<typeof TokenAccountType>;
|
|
18
|
+
export const TokenAccountType = enums(["mint", "account", "multisig"]);
|
|
19
|
+
|
|
20
|
+
export type TokenAccountState = Infer<typeof AccountState>;
|
|
21
|
+
const AccountState = enums(["initialized", "uninitialized", "frozen"]);
|
|
22
|
+
|
|
23
|
+
const TokenAmount = type({
|
|
24
|
+
decimals: number(),
|
|
25
|
+
uiAmountString: string(),
|
|
26
|
+
amount: string(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type TokenAccountInfo = Infer<typeof TokenAccountInfo>;
|
|
30
|
+
export const TokenAccountInfo = type({
|
|
31
|
+
mint: PublicKeyFromString,
|
|
32
|
+
owner: PublicKeyFromString,
|
|
33
|
+
tokenAmount: TokenAmount,
|
|
34
|
+
delegate: optional(PublicKeyFromString),
|
|
35
|
+
state: AccountState,
|
|
36
|
+
isNative: boolean(),
|
|
37
|
+
rentExemptReserve: optional(TokenAmount),
|
|
38
|
+
delegatedAmount: optional(TokenAmount),
|
|
39
|
+
closeAuthority: optional(PublicKeyFromString),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export type MintAccountInfo = Infer<typeof MintAccountInfo>;
|
|
43
|
+
export const MintAccountInfo = type({
|
|
44
|
+
mintAuthority: nullable(PublicKeyFromString),
|
|
45
|
+
supply: string(),
|
|
46
|
+
decimals: number(),
|
|
47
|
+
isInitialized: boolean(),
|
|
48
|
+
freezeAuthority: nullable(PublicKeyFromString),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type MultisigAccountInfo = Infer<typeof MultisigAccountInfo>;
|
|
52
|
+
export const MultisigAccountInfo = type({
|
|
53
|
+
numRequiredSigners: number(),
|
|
54
|
+
numValidSigners: number(),
|
|
55
|
+
isInitialized: boolean(),
|
|
56
|
+
signers: array(PublicKeyFromString),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export type TokenAccount = Infer<typeof TokenAccount>;
|
|
60
|
+
export const TokenAccount = type({
|
|
61
|
+
type: TokenAccountType,
|
|
62
|
+
info: any(),
|
|
63
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
2
|
+
|
|
3
|
+
import { Infer, enums, number, array, type, nullable, string } from "superstruct";
|
|
4
|
+
import { PublicKeyFromString } from "../validators/pubkey";
|
|
5
|
+
|
|
6
|
+
export type VoteAccountType = Infer<typeof VoteAccountType>;
|
|
7
|
+
export const VoteAccountType = enums(["vote"]);
|
|
8
|
+
|
|
9
|
+
export type AuthorizedVoter = Infer<typeof AuthorizedVoter>;
|
|
10
|
+
export const AuthorizedVoter = type({
|
|
11
|
+
authorizedVoter: PublicKeyFromString,
|
|
12
|
+
epoch: number(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type PriorVoter = Infer<typeof PriorVoter>;
|
|
16
|
+
export const PriorVoter = type({
|
|
17
|
+
authorizedPubkey: PublicKeyFromString,
|
|
18
|
+
epochOfLastAuthorizedSwitch: number(),
|
|
19
|
+
targetEpoch: number(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type EpochCredits = Infer<typeof EpochCredits>;
|
|
23
|
+
export const EpochCredits = type({
|
|
24
|
+
epoch: number(),
|
|
25
|
+
credits: string(),
|
|
26
|
+
previousCredits: string(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type Vote = Infer<typeof Vote>;
|
|
30
|
+
export const Vote = type({
|
|
31
|
+
slot: number(),
|
|
32
|
+
confirmationCount: number(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type VoteAccountInfo = Infer<typeof VoteAccountInfo>;
|
|
36
|
+
export const VoteAccountInfo = type({
|
|
37
|
+
authorizedVoters: array(AuthorizedVoter),
|
|
38
|
+
authorizedWithdrawer: PublicKeyFromString,
|
|
39
|
+
commission: number(),
|
|
40
|
+
epochCredits: array(EpochCredits),
|
|
41
|
+
lastTimestamp: type({
|
|
42
|
+
slot: number(),
|
|
43
|
+
timestamp: number(),
|
|
44
|
+
}),
|
|
45
|
+
nodePubkey: PublicKeyFromString,
|
|
46
|
+
priorVoters: array(PriorVoter),
|
|
47
|
+
rootSlot: nullable(number()),
|
|
48
|
+
votes: array(Vote),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type VoteAccount = Infer<typeof VoteAccount>;
|
|
52
|
+
export const VoteAccount = type({
|
|
53
|
+
type: VoteAccountType,
|
|
54
|
+
info: VoteAccountInfo,
|
|
55
|
+
});
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TOKEN_PROGRAM_ID,
|
|
3
|
+
getAssociatedTokenAddress,
|
|
4
|
+
getMinimumBalanceForRentExemptAccount,
|
|
5
|
+
} from "@solana/spl-token";
|
|
6
|
+
import {
|
|
7
|
+
Connection,
|
|
8
|
+
FetchMiddleware,
|
|
9
|
+
VersionedMessage,
|
|
10
|
+
PublicKey,
|
|
11
|
+
sendAndConfirmRawTransaction,
|
|
12
|
+
SignaturesForAddressOptions,
|
|
13
|
+
StakeProgram,
|
|
14
|
+
} from "@solana/web3.js";
|
|
15
|
+
import { makeLRUCache, minutes } from "@ledgerhq/live-network/cache";
|
|
16
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
17
|
+
import { NetworkError } from "@ledgerhq/errors";
|
|
18
|
+
import { Awaited } from "../../logic";
|
|
19
|
+
|
|
20
|
+
export const LATEST_BLOCKHASH_MOCK = "EEbZs6DmDyDjucyYbo3LwVJU7pQYuVopYcYTSEZXskW3";
|
|
21
|
+
|
|
22
|
+
export type Config = {
|
|
23
|
+
readonly endpoint: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ChainAPI = Readonly<{
|
|
27
|
+
getBalance: (address: string) => Promise<number>;
|
|
28
|
+
|
|
29
|
+
getLatestBlockhash: () => Promise<string>;
|
|
30
|
+
|
|
31
|
+
getFeeForMessage: (message: VersionedMessage) => Promise<number | null>;
|
|
32
|
+
|
|
33
|
+
getBalanceAndContext: (address: string) => ReturnType<Connection["getBalanceAndContext"]>;
|
|
34
|
+
|
|
35
|
+
getParsedTokenAccountsByOwner: (
|
|
36
|
+
address: string,
|
|
37
|
+
) => ReturnType<Connection["getParsedTokenAccountsByOwner"]>;
|
|
38
|
+
|
|
39
|
+
getStakeAccountsByStakeAuth: (
|
|
40
|
+
authAddr: string,
|
|
41
|
+
) => ReturnType<Connection["getParsedProgramAccounts"]>;
|
|
42
|
+
|
|
43
|
+
getStakeAccountsByWithdrawAuth: (
|
|
44
|
+
authAddr: string,
|
|
45
|
+
) => ReturnType<Connection["getParsedProgramAccounts"]>;
|
|
46
|
+
|
|
47
|
+
getStakeActivation: (stakeAccAddr: string) => ReturnType<Connection["getStakeActivation"]>;
|
|
48
|
+
|
|
49
|
+
getInflationReward: (addresses: string[]) => ReturnType<Connection["getInflationReward"]>;
|
|
50
|
+
|
|
51
|
+
getVoteAccounts: () => ReturnType<Connection["getVoteAccounts"]>;
|
|
52
|
+
|
|
53
|
+
getSignaturesForAddress: (
|
|
54
|
+
address: string,
|
|
55
|
+
opts?: SignaturesForAddressOptions,
|
|
56
|
+
) => ReturnType<Connection["getSignaturesForAddress"]>;
|
|
57
|
+
|
|
58
|
+
getParsedTransactions: (signatures: string[]) => ReturnType<Connection["getParsedTransactions"]>;
|
|
59
|
+
|
|
60
|
+
getAccountInfo: (
|
|
61
|
+
address: string,
|
|
62
|
+
) => Promise<Awaited<ReturnType<Connection["getParsedAccountInfo"]>>["value"]>;
|
|
63
|
+
|
|
64
|
+
sendRawTransaction: (buffer: Buffer) => ReturnType<Connection["sendRawTransaction"]>;
|
|
65
|
+
|
|
66
|
+
findAssocTokenAccAddress: (owner: string, mint: string) => Promise<string>;
|
|
67
|
+
|
|
68
|
+
getAssocTokenAccMinNativeBalance: () => Promise<number>;
|
|
69
|
+
|
|
70
|
+
getMinimumBalanceForRentExemption: (dataLength: number) => Promise<number>;
|
|
71
|
+
|
|
72
|
+
getEpochInfo: () => ReturnType<Connection["getEpochInfo"]>;
|
|
73
|
+
|
|
74
|
+
config: Config;
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
// Naive mode, allow us to filter in sentry all this error comming from Sol RPC node
|
|
78
|
+
const remapErrors = (e: Error) => {
|
|
79
|
+
throw new NetworkError(e?.message);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export function getChainAPI(
|
|
83
|
+
config: Config,
|
|
84
|
+
logger?: (url: string, options: any) => void,
|
|
85
|
+
): ChainAPI {
|
|
86
|
+
const fetchMiddleware: FetchMiddleware | undefined =
|
|
87
|
+
logger === undefined
|
|
88
|
+
? undefined
|
|
89
|
+
: (url, options, fetch) => {
|
|
90
|
+
logger(url, options);
|
|
91
|
+
fetch(url, options);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const connection = () => {
|
|
95
|
+
return new Connection(config.endpoint, {
|
|
96
|
+
...(fetchMiddleware ? { fetchMiddleware } : {}),
|
|
97
|
+
commitment: "finalized",
|
|
98
|
+
confirmTransactionInitialTimeout: getEnv("SOLANA_TX_CONFIRMATION_TIMEOUT") || 0,
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
getBalance: (address: string) =>
|
|
104
|
+
connection().getBalance(new PublicKey(address)).catch(remapErrors),
|
|
105
|
+
|
|
106
|
+
getLatestBlockhash: () =>
|
|
107
|
+
connection()
|
|
108
|
+
.getLatestBlockhash()
|
|
109
|
+
.then(r => r.blockhash)
|
|
110
|
+
.catch(remapErrors),
|
|
111
|
+
|
|
112
|
+
getFeeForMessage: (msg: VersionedMessage) =>
|
|
113
|
+
connection()
|
|
114
|
+
.getFeeForMessage(msg)
|
|
115
|
+
.then(r => r.value)
|
|
116
|
+
.catch(remapErrors),
|
|
117
|
+
|
|
118
|
+
getBalanceAndContext: (address: string) =>
|
|
119
|
+
connection().getBalanceAndContext(new PublicKey(address)).catch(remapErrors),
|
|
120
|
+
|
|
121
|
+
getParsedTokenAccountsByOwner: (address: string) =>
|
|
122
|
+
connection()
|
|
123
|
+
.getParsedTokenAccountsByOwner(new PublicKey(address), {
|
|
124
|
+
programId: TOKEN_PROGRAM_ID,
|
|
125
|
+
})
|
|
126
|
+
.catch(remapErrors),
|
|
127
|
+
|
|
128
|
+
getStakeAccountsByStakeAuth: makeLRUCache(
|
|
129
|
+
(authAddr: string) =>
|
|
130
|
+
connection()
|
|
131
|
+
.getParsedProgramAccounts(StakeProgram.programId, {
|
|
132
|
+
filters: [
|
|
133
|
+
{
|
|
134
|
+
memcmp: {
|
|
135
|
+
offset: 12,
|
|
136
|
+
bytes: authAddr,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
})
|
|
141
|
+
.catch(remapErrors),
|
|
142
|
+
(addr: string) => addr,
|
|
143
|
+
minutes(3),
|
|
144
|
+
),
|
|
145
|
+
|
|
146
|
+
getStakeAccountsByWithdrawAuth: makeLRUCache(
|
|
147
|
+
(authAddr: string) =>
|
|
148
|
+
connection()
|
|
149
|
+
.getParsedProgramAccounts(StakeProgram.programId, {
|
|
150
|
+
filters: [
|
|
151
|
+
{
|
|
152
|
+
memcmp: {
|
|
153
|
+
offset: 44,
|
|
154
|
+
bytes: authAddr,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
})
|
|
159
|
+
.catch(remapErrors),
|
|
160
|
+
(addr: string) => addr,
|
|
161
|
+
minutes(3),
|
|
162
|
+
),
|
|
163
|
+
|
|
164
|
+
getStakeActivation: (stakeAccAddr: string) =>
|
|
165
|
+
connection().getStakeActivation(new PublicKey(stakeAccAddr)).catch(remapErrors),
|
|
166
|
+
|
|
167
|
+
getInflationReward: (addresses: string[]) =>
|
|
168
|
+
connection()
|
|
169
|
+
.getInflationReward(addresses.map(addr => new PublicKey(addr)))
|
|
170
|
+
.catch(remapErrors),
|
|
171
|
+
|
|
172
|
+
getVoteAccounts: () => connection().getVoteAccounts().catch(remapErrors),
|
|
173
|
+
|
|
174
|
+
getSignaturesForAddress: (address: string, opts?: SignaturesForAddressOptions) =>
|
|
175
|
+
connection().getSignaturesForAddress(new PublicKey(address), opts).catch(remapErrors),
|
|
176
|
+
|
|
177
|
+
getParsedTransactions: (signatures: string[]) =>
|
|
178
|
+
connection()
|
|
179
|
+
.getParsedTransactions(signatures, {
|
|
180
|
+
maxSupportedTransactionVersion: 0,
|
|
181
|
+
})
|
|
182
|
+
.catch(remapErrors),
|
|
183
|
+
|
|
184
|
+
getAccountInfo: (address: string) =>
|
|
185
|
+
connection()
|
|
186
|
+
.getParsedAccountInfo(new PublicKey(address))
|
|
187
|
+
.then(r => r.value)
|
|
188
|
+
.catch(remapErrors),
|
|
189
|
+
|
|
190
|
+
sendRawTransaction: (buffer: Buffer) => {
|
|
191
|
+
return sendAndConfirmRawTransaction(connection(), buffer, {
|
|
192
|
+
commitment: "confirmed",
|
|
193
|
+
}).catch(remapErrors);
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
findAssocTokenAccAddress: (owner: string, mint: string) => {
|
|
197
|
+
return getAssociatedTokenAddress(new PublicKey(mint), new PublicKey(owner))
|
|
198
|
+
.then(r => r.toBase58())
|
|
199
|
+
.catch(remapErrors);
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
getAssocTokenAccMinNativeBalance: () =>
|
|
203
|
+
getMinimumBalanceForRentExemptAccount(connection()).catch(remapErrors),
|
|
204
|
+
|
|
205
|
+
getMinimumBalanceForRentExemption: (dataLength: number) =>
|
|
206
|
+
connection().getMinimumBalanceForRentExemption(dataLength).catch(remapErrors),
|
|
207
|
+
|
|
208
|
+
getEpochInfo: () => connection().getEpochInfo().catch(remapErrors),
|
|
209
|
+
|
|
210
|
+
config,
|
|
211
|
+
};
|
|
212
|
+
}
|