@ledgerhq/coin-solana 0.7.0-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +16 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +9 -0
- package/lib/api/cached.d.ts +3 -0
- package/lib/api/cached.d.ts.map +1 -0
- package/lib/api/cached.js +40 -0
- package/lib/api/cached.js.map +1 -0
- package/lib/api/chain/account/index.d.ts +2 -0
- package/lib/api/chain/account/index.d.ts.map +1 -0
- package/lib/api/chain/account/index.js +8 -0
- package/lib/api/chain/account/index.js.map +1 -0
- package/lib/api/chain/account/parser.d.ts +10 -0
- package/lib/api/chain/account/parser.d.ts.map +1 -0
- package/lib/api/chain/account/parser.js +56 -0
- package/lib/api/chain/account/parser.js.map +1 -0
- package/lib/api/chain/account/stake.d.ts +237 -0
- package/lib/api/chain/account/stake.d.ts.map +1 -0
- package/lib/api/chain/account/stake.js +38 -0
- package/lib/api/chain/account/stake.js.map +1 -0
- package/lib/api/chain/account/token.d.ts +116 -0
- package/lib/api/chain/account/token.d.ts.map +1 -0
- package/lib/api/chain/account/token.js +42 -0
- package/lib/api/chain/account/token.js.map +1 -0
- package/lib/api/chain/account/vote.d.ts +252 -0
- package/lib/api/chain/account/vote.d.ts.map +1 -0
- package/lib/api/chain/account/vote.js +44 -0
- package/lib/api/chain/account/vote.js.map +1 -0
- package/lib/api/chain/index.d.ts +29 -0
- package/lib/api/chain/index.d.ts.map +1 -0
- package/lib/api/chain/index.js +99 -0
- package/lib/api/chain/index.js.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/index.js +21 -0
- package/lib/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/types.js +19 -0
- package/lib/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/memo/index.js +14 -0
- package/lib/api/chain/instruction/memo/index.js.map +1 -0
- package/lib/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/memo/types.js +16 -0
- package/lib/api/chain/instruction/memo/types.js.map +1 -0
- package/lib/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/stake/index.js +20 -0
- package/lib/api/chain/instruction/stake/index.js.map +1 -0
- package/lib/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/stake/types.js +80 -0
- package/lib/api/chain/instruction/stake/types.js.map +1 -0
- package/lib/api/chain/instruction/system/index.d.ts +15 -0
- package/lib/api/chain/instruction/system/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/system/index.js +20 -0
- package/lib/api/chain/instruction/system/index.js.map +1 -0
- package/lib/api/chain/instruction/system/types.d.ts +298 -0
- package/lib/api/chain/instruction/system/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/system/types.js +117 -0
- package/lib/api/chain/instruction/system/types.js.map +1 -0
- package/lib/api/chain/instruction/token/index.d.ts +15 -0
- package/lib/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/token/index.js +20 -0
- package/lib/api/chain/instruction/token/index.js.map +1 -0
- package/lib/api/chain/instruction/token/types.d.ts +497 -0
- package/lib/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/token/types.js +200 -0
- package/lib/api/chain/instruction/token/types.js.map +1 -0
- package/lib/api/chain/program/constants.d.ts +11 -0
- package/lib/api/chain/program/constants.d.ts.map +1 -0
- package/lib/api/chain/program/constants.js +14 -0
- package/lib/api/chain/program/constants.js.map +1 -0
- package/lib/api/chain/program/index.d.ts +2 -0
- package/lib/api/chain/program/index.d.ts.map +1 -0
- package/lib/api/chain/program/index.js +7 -0
- package/lib/api/chain/program/index.js.map +1 -0
- package/lib/api/chain/program/parser.d.ts +35 -0
- package/lib/api/chain/program/parser.d.ts.map +1 -0
- package/lib/api/chain/program/parser.js +66 -0
- package/lib/api/chain/program/parser.js.map +1 -0
- package/lib/api/chain/validators/bignum.d.ts +3 -0
- package/lib/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib/api/chain/validators/bignum.js +11 -0
- package/lib/api/chain/validators/bignum.js.map +1 -0
- package/lib/api/chain/validators/index.d.ts +10 -0
- package/lib/api/chain/validators/index.d.ts.map +1 -0
- package/lib/api/chain/validators/index.js +10 -0
- package/lib/api/chain/validators/index.js.map +1 -0
- package/lib/api/chain/validators/pubkey.d.ts +3 -0
- package/lib/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib/api/chain/validators/pubkey.js +7 -0
- package/lib/api/chain/validators/pubkey.js.map +1 -0
- package/lib/api/chain/web3.d.ts +43 -0
- package/lib/api/chain/web3.d.ts.map +1 -0
- package/lib/api/chain/web3.js +274 -0
- package/lib/api/chain/web3.js.map +1 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +25 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/logged.d.ts +3 -0
- package/lib/api/logged.d.ts.map +1 -0
- package/lib/api/logged.js +69 -0
- package/lib/api/logged.js.map +1 -0
- package/lib/api/queued.d.ts +3 -0
- package/lib/api/queued.d.ts.map +1 -0
- package/lib/api/queued.js +27 -0
- package/lib/api/queued.js.map +1 -0
- package/lib/api/traced.d.ts +3 -0
- package/lib/api/traced.d.ts.map +1 -0
- package/lib/api/traced.js +80 -0
- package/lib/api/traced.js.map +1 -0
- package/lib/bridge/bridge.d.ts +15 -0
- package/lib/bridge/bridge.d.ts.map +1 -0
- package/lib/bridge/bridge.js +139 -0
- package/lib/bridge/bridge.js.map +1 -0
- package/lib/bridge/js.d.ts +7 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +28 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +990 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/cli-transaction.d.ts +19 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +196 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib/datasets/solana.scanAccounts.1.js +12 -0
- package/lib/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +10 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +228 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +61 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +25 -0
- package/lib/errors.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +28 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/js-broadcast.d.ts +7 -0
- package/lib/js-broadcast.d.ts.map +1 -0
- package/lib/js-broadcast.js +37 -0
- package/lib/js-broadcast.js.map +1 -0
- package/lib/js-buildTransaction.d.ts +5 -0
- package/lib/js-buildTransaction.d.ts.map +1 -0
- package/lib/js-buildTransaction.js +67 -0
- package/lib/js-buildTransaction.js.map +1 -0
- package/lib/js-createTransaction.d.ts +5 -0
- package/lib/js-createTransaction.d.ts.map +1 -0
- package/lib/js-createTransaction.js +19 -0
- package/lib/js-createTransaction.js.map +1 -0
- package/lib/js-estimateMaxSpendable.d.ts +11 -0
- package/lib/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/js-estimateMaxSpendable.js +62 -0
- package/lib/js-estimateMaxSpendable.js.map +1 -0
- package/lib/js-getTransactionStatus.d.ts +5 -0
- package/lib/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/js-getTransactionStatus.js +71 -0
- package/lib/js-getTransactionStatus.js.map +1 -0
- package/lib/js-preload-data.d.ts +7 -0
- package/lib/js-preload-data.d.ts.map +1 -0
- package/lib/js-preload-data.js +45 -0
- package/lib/js-preload-data.js.map +1 -0
- package/lib/js-preload.d.ts +7 -0
- package/lib/js-preload.d.ts.map +1 -0
- package/lib/js-preload.js +67 -0
- package/lib/js-preload.js.map +1 -0
- package/lib/js-preload.test.d.ts +2 -0
- package/lib/js-preload.test.d.ts.map +1 -0
- package/lib/js-preload.test.js +9 -0
- package/lib/js-preload.test.js.map +1 -0
- package/lib/js-prepareTransaction.d.ts +5 -0
- package/lib/js-prepareTransaction.d.ts.map +1 -0
- package/lib/js-prepareTransaction.js +500 -0
- package/lib/js-prepareTransaction.js.map +1 -0
- package/lib/js-signOperation.d.ts +7 -0
- package/lib/js-signOperation.d.ts.map +1 -0
- package/lib/js-signOperation.js +153 -0
- package/lib/js-signOperation.js.map +1 -0
- package/lib/js-synchronization.d.ts +5 -0
- package/lib/js-synchronization.d.ts.map +1 -0
- package/lib/js-synchronization.js +464 -0
- package/lib/js-synchronization.js.map +1 -0
- package/lib/logic.d.ts +29 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +102 -0
- package/lib/logic.js.map +1 -0
- package/lib/serialization.d.ts +9 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +69 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signer.d.ts +11 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +409 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +8 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +217 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +153 -0
- package/lib/transaction.js.map +1 -0
- package/lib/tx-fees.d.ts +4 -0
- package/lib/tx-fees.d.ts.map +1 -0
- package/lib/tx-fees.js +167 -0
- package/lib/tx-fees.js.map +1 -0
- package/lib/types.d.ts +222 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +24 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +172 -0
- package/lib/utils.js.map +1 -0
- package/lib/validator-app/index.d.ts +22 -0
- package/lib/validator-app/index.d.ts.map +1 -0
- package/lib/validator-app/index.js +62 -0
- package/lib/validator-app/index.js.map +1 -0
- package/lib-es/api/cached.d.ts +3 -0
- package/lib-es/api/cached.d.ts.map +1 -0
- package/lib-es/api/cached.js +33 -0
- package/lib-es/api/cached.js.map +1 -0
- package/lib-es/api/chain/account/index.d.ts +2 -0
- package/lib-es/api/chain/account/index.d.ts.map +1 -0
- package/lib-es/api/chain/account/index.js +2 -0
- package/lib-es/api/chain/account/index.js.map +1 -0
- package/lib-es/api/chain/account/parser.d.ts +10 -0
- package/lib-es/api/chain/account/parser.d.ts.map +1 -0
- package/lib-es/api/chain/account/parser.js +48 -0
- package/lib-es/api/chain/account/parser.js.map +1 -0
- package/lib-es/api/chain/account/stake.d.ts +237 -0
- package/lib-es/api/chain/account/stake.d.ts.map +1 -0
- package/lib-es/api/chain/account/stake.js +35 -0
- package/lib-es/api/chain/account/stake.js.map +1 -0
- package/lib-es/api/chain/account/token.d.ts +116 -0
- package/lib-es/api/chain/account/token.d.ts.map +1 -0
- package/lib-es/api/chain/account/token.js +39 -0
- package/lib-es/api/chain/account/token.js.map +1 -0
- package/lib-es/api/chain/account/vote.d.ts +252 -0
- package/lib-es/api/chain/account/vote.d.ts.map +1 -0
- package/lib-es/api/chain/account/vote.js +41 -0
- package/lib-es/api/chain/account/vote.js.map +1 -0
- package/lib-es/api/chain/index.d.ts +29 -0
- package/lib-es/api/chain/index.d.ts.map +1 -0
- package/lib-es/api/chain/index.js +95 -0
- package/lib-es/api/chain/index.js.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.js +17 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.js +16 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib-es/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/memo/index.js +10 -0
- package/lib-es/api/chain/instruction/memo/index.js.map +1 -0
- package/lib-es/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib-es/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/memo/types.js +13 -0
- package/lib-es/api/chain/instruction/memo/types.js.map +1 -0
- package/lib-es/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/stake/index.js +16 -0
- package/lib-es/api/chain/instruction/stake/index.js.map +1 -0
- package/lib-es/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib-es/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/stake/types.js +77 -0
- package/lib-es/api/chain/instruction/stake/types.js.map +1 -0
- package/lib-es/api/chain/instruction/system/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/system/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/system/index.js +16 -0
- package/lib-es/api/chain/instruction/system/index.js.map +1 -0
- package/lib-es/api/chain/instruction/system/types.d.ts +298 -0
- package/lib-es/api/chain/instruction/system/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/system/types.js +114 -0
- package/lib-es/api/chain/instruction/system/types.js.map +1 -0
- package/lib-es/api/chain/instruction/token/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/token/index.js +16 -0
- package/lib-es/api/chain/instruction/token/index.js.map +1 -0
- package/lib-es/api/chain/instruction/token/types.d.ts +497 -0
- package/lib-es/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/token/types.js +197 -0
- package/lib-es/api/chain/instruction/token/types.js.map +1 -0
- package/lib-es/api/chain/program/constants.d.ts +11 -0
- package/lib-es/api/chain/program/constants.d.ts.map +1 -0
- package/lib-es/api/chain/program/constants.js +11 -0
- package/lib-es/api/chain/program/constants.js.map +1 -0
- package/lib-es/api/chain/program/index.d.ts +2 -0
- package/lib-es/api/chain/program/index.d.ts.map +1 -0
- package/lib-es/api/chain/program/index.js +2 -0
- package/lib-es/api/chain/program/index.js.map +1 -0
- package/lib-es/api/chain/program/parser.d.ts +35 -0
- package/lib-es/api/chain/program/parser.d.ts.map +1 -0
- package/lib-es/api/chain/program/parser.js +61 -0
- package/lib-es/api/chain/program/parser.js.map +1 -0
- package/lib-es/api/chain/validators/bignum.d.ts +3 -0
- package/lib-es/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib-es/api/chain/validators/bignum.js +8 -0
- package/lib-es/api/chain/validators/bignum.js.map +1 -0
- package/lib-es/api/chain/validators/index.d.ts +10 -0
- package/lib-es/api/chain/validators/index.d.ts.map +1 -0
- package/lib-es/api/chain/validators/index.js +7 -0
- package/lib-es/api/chain/validators/index.js.map +1 -0
- package/lib-es/api/chain/validators/pubkey.d.ts +3 -0
- package/lib-es/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib-es/api/chain/validators/pubkey.js +4 -0
- package/lib-es/api/chain/validators/pubkey.js.map +1 -0
- package/lib-es/api/chain/web3.d.ts +43 -0
- package/lib-es/api/chain/web3.d.ts.map +1 -0
- package/lib-es/api/chain/web3.js +251 -0
- package/lib-es/api/chain/web3.js.map +1 -0
- package/lib-es/api/index.d.ts +5 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +5 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/logged.d.ts +3 -0
- package/lib-es/api/logged.d.ts.map +1 -0
- package/lib-es/api/logged.js +65 -0
- package/lib-es/api/logged.js.map +1 -0
- package/lib-es/api/queued.d.ts +3 -0
- package/lib-es/api/queued.d.ts.map +1 -0
- package/lib-es/api/queued.js +23 -0
- package/lib-es/api/queued.js.map +1 -0
- package/lib-es/api/traced.d.ts +3 -0
- package/lib-es/api/traced.d.ts.map +1 -0
- package/lib-es/api/traced.js +76 -0
- package/lib-es/api/traced.js.map +1 -0
- package/lib-es/bridge/bridge.d.ts +15 -0
- package/lib-es/bridge/bridge.d.ts.map +1 -0
- package/lib-es/bridge/bridge.js +132 -0
- package/lib-es/bridge/bridge.js.map +1 -0
- package/lib-es/bridge/js.d.ts +7 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +24 -0
- package/lib-es/bridge/js.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +988 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +19 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +190 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib-es/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib-es/datasets/solana.scanAccounts.1.js +10 -0
- package/lib-es/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +10 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +223 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +61 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +22 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +23 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/js-broadcast.d.ts +7 -0
- package/lib-es/js-broadcast.d.ts.map +1 -0
- package/lib-es/js-broadcast.js +33 -0
- package/lib-es/js-broadcast.js.map +1 -0
- package/lib-es/js-buildTransaction.d.ts +5 -0
- package/lib-es/js-buildTransaction.d.ts.map +1 -0
- package/lib-es/js-buildTransaction.js +63 -0
- package/lib-es/js-buildTransaction.js.map +1 -0
- package/lib-es/js-createTransaction.d.ts +5 -0
- package/lib-es/js-createTransaction.d.ts.map +1 -0
- package/lib-es/js-createTransaction.js +17 -0
- package/lib-es/js-createTransaction.js.map +1 -0
- package/lib-es/js-estimateMaxSpendable.d.ts +11 -0
- package/lib-es/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/js-estimateMaxSpendable.js +55 -0
- package/lib-es/js-estimateMaxSpendable.js.map +1 -0
- package/lib-es/js-getTransactionStatus.d.ts +5 -0
- package/lib-es/js-getTransactionStatus.d.ts.map +1 -0
- package/lib-es/js-getTransactionStatus.js +69 -0
- package/lib-es/js-getTransactionStatus.js.map +1 -0
- package/lib-es/js-preload-data.d.ts +7 -0
- package/lib-es/js-preload-data.d.ts.map +1 -0
- package/lib-es/js-preload-data.js +39 -0
- package/lib-es/js-preload-data.js.map +1 -0
- package/lib-es/js-preload.d.ts +7 -0
- package/lib-es/js-preload.d.ts.map +1 -0
- package/lib-es/js-preload.js +62 -0
- package/lib-es/js-preload.js.map +1 -0
- package/lib-es/js-preload.test.d.ts +2 -0
- package/lib-es/js-preload.test.d.ts.map +1 -0
- package/lib-es/js-preload.test.js +7 -0
- package/lib-es/js-preload.test.js.map +1 -0
- package/lib-es/js-prepareTransaction.d.ts +5 -0
- package/lib-es/js-prepareTransaction.d.ts.map +1 -0
- package/lib-es/js-prepareTransaction.js +497 -0
- package/lib-es/js-prepareTransaction.js.map +1 -0
- package/lib-es/js-signOperation.d.ts +7 -0
- package/lib-es/js-signOperation.d.ts.map +1 -0
- package/lib-es/js-signOperation.js +146 -0
- package/lib-es/js-signOperation.js.map +1 -0
- package/lib-es/js-synchronization.d.ts +5 -0
- package/lib-es/js-synchronization.d.ts.map +1 -0
- package/lib-es/js-synchronization.js +457 -0
- package/lib-es/js-synchronization.js.map +1 -0
- package/lib-es/logic.d.ts +29 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +87 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/serialization.d.ts +9 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +60 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signer.d.ts +11 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +7 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +404 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +8 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +211 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/transaction.d.ts +15 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +147 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/tx-fees.d.ts +4 -0
- package/lib-es/tx-fees.d.ts.map +1 -0
- package/lib-es/tx-fees.js +160 -0
- package/lib-es/tx-fees.js.map +1 -0
- package/lib-es/types.d.ts +222 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +2 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/utils.d.ts +24 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +157 -0
- package/lib-es/utils.js.map +1 -0
- package/lib-es/validator-app/index.d.ts +22 -0
- package/lib-es/validator-app/index.d.ts.map +1 -0
- package/lib-es/validator-app/index.js +55 -0
- package/lib-es/validator-app/index.js.map +1 -0
- package/package.json +89 -0
- package/src/api/cached.ts +87 -0
- package/src/api/chain/account/index.ts +1 -0
- package/src/api/chain/account/parser.ts +63 -0
- package/src/api/chain/account/stake.ts +45 -0
- package/src/api/chain/account/token.ts +63 -0
- package/src/api/chain/account/vote.ts +55 -0
- package/src/api/chain/index.ts +203 -0
- package/src/api/chain/instruction/associated-token-account/index.ts +33 -0
- package/src/api/chain/instruction/associated-token-account/types.ts +23 -0
- package/src/api/chain/instruction/memo/index.ts +24 -0
- package/src/api/chain/instruction/memo/types.ts +18 -0
- package/src/api/chain/instruction/stake/index.ts +29 -0
- package/src/api/chain/instruction/stake/types.ts +95 -0
- package/src/api/chain/instruction/system/index.ts +30 -0
- package/src/api/chain/instruction/system/types.ts +141 -0
- package/src/api/chain/instruction/token/index.ts +30 -0
- package/src/api/chain/instruction/token/types.ts +222 -0
- package/src/api/chain/program/constants.ts +10 -0
- package/src/api/chain/program/index.ts +1 -0
- package/src/api/chain/program/parser.ts +120 -0
- package/src/api/chain/validators/bignum.ts +7 -0
- package/src/api/chain/validators/index.ts +9 -0
- package/src/api/chain/validators/pubkey.ts +8 -0
- package/src/api/chain/web3.ts +399 -0
- package/src/api/index.ts +4 -0
- package/src/api/logged.ts +70 -0
- package/src/api/queued.ts +25 -0
- package/src/api/traced.ts +89 -0
- package/src/bridge/bridge.ts +195 -0
- package/src/bridge/js.ts +44 -0
- package/src/bridge.integration.test.ts +1106 -0
- package/src/cli-transaction.ts +246 -0
- package/src/datasets/solana.scanAccounts.1.ts +9 -0
- package/src/deviceTransactionConfig.ts +302 -0
- package/src/errors.ts +61 -0
- package/src/hw-getAddress.ts +26 -0
- package/src/js-broadcast.ts +38 -0
- package/src/js-buildTransaction.ts +81 -0
- package/src/js-createTransaction.ts +20 -0
- package/src/js-estimateMaxSpendable.ts +72 -0
- package/src/js-getTransactionStatus.ts +72 -0
- package/src/js-preload-data.ts +46 -0
- package/src/js-preload.test.ts +14 -0
- package/src/js-preload.ts +74 -0
- package/src/js-prepareTransaction.ts +686 -0
- package/src/js-signOperation.ts +329 -0
- package/src/js-synchronization.ts +729 -0
- package/src/logic.ts +123 -0
- package/src/serialization.ts +81 -0
- package/src/signer.ts +21 -0
- package/src/specs.ts +514 -0
- package/src/speculos-deviceActions.ts +229 -0
- package/src/transaction.ts +194 -0
- package/src/tx-fees.ts +206 -0
- package/src/types.ts +284 -0
- package/src/utils.ts +176 -0
- package/src/validator-app/index.ts +79 -0
- package/tsconfig.json +12 -0
package/lib-es/utils.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
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
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
11
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
+
var m = o[Symbol.asyncIterator], i;
|
|
13
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
14
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
15
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
16
|
+
};
|
|
17
|
+
import { clusterApiUrl } from "@solana/web3.js";
|
|
18
|
+
import { partition } from "lodash/fp";
|
|
19
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
20
|
+
// Hardcoding the Ledger validator info as backup,
|
|
21
|
+
// because backend is flaky and sometimes doesn't return it anymore
|
|
22
|
+
export const LEDGER_VALIDATOR = {
|
|
23
|
+
voteAccount: "26pV97Ce83ZQ6Kz9XT4td8tdoUFPTng8Fb8gPyc53dJx",
|
|
24
|
+
name: "Ledger by Figment",
|
|
25
|
+
avatarUrl: "https://s3.amazonaws.com/keybase_processed_uploads/3c47b62f3d28ecfd821536f69be82905_360_360.jpg",
|
|
26
|
+
wwwUrl: "https://www.ledger.com/staking",
|
|
27
|
+
activeStake: 4784119000000000,
|
|
28
|
+
commission: 7,
|
|
29
|
+
totalScore: 6,
|
|
30
|
+
};
|
|
31
|
+
export const SOLANA_DELEGATION_RESERVE = 0.01;
|
|
32
|
+
export const assertUnreachable = (_) => {
|
|
33
|
+
throw new Error("unreachable assertion failed");
|
|
34
|
+
};
|
|
35
|
+
export function drainSeqAsyncGen(...asyncGens) {
|
|
36
|
+
var _a, e_1, _b, _c;
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const items = [];
|
|
39
|
+
for (const gen of asyncGens) {
|
|
40
|
+
try {
|
|
41
|
+
for (var _d = true, gen_1 = (e_1 = void 0, __asyncValues(gen)), gen_1_1; gen_1_1 = yield gen_1.next(), _a = gen_1_1.done, !_a; _d = true) {
|
|
42
|
+
_c = gen_1_1.value;
|
|
43
|
+
_d = false;
|
|
44
|
+
const item = _c;
|
|
45
|
+
items.push(item);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
49
|
+
finally {
|
|
50
|
+
try {
|
|
51
|
+
if (!_d && !_a && (_b = gen_1.return)) yield _b.call(gen_1);
|
|
52
|
+
}
|
|
53
|
+
finally { if (e_1) throw e_1.error; }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return items;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function drainSeq(jobs) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const items = [];
|
|
62
|
+
for (const job of jobs) {
|
|
63
|
+
items.push(yield job());
|
|
64
|
+
}
|
|
65
|
+
return items;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export function endpointByCurrencyId(currencyId) {
|
|
69
|
+
const endpoints = {
|
|
70
|
+
solana: getEnv("API_SOLANA_PROXY"),
|
|
71
|
+
solana_devnet: clusterApiUrl("devnet"),
|
|
72
|
+
solana_testnet: clusterApiUrl("testnet"),
|
|
73
|
+
};
|
|
74
|
+
if (currencyId in endpoints) {
|
|
75
|
+
return endpoints[currencyId];
|
|
76
|
+
}
|
|
77
|
+
throw Error(`unexpected currency id format <${currencyId}>, should be like solana[_(testnet | devnet)]`);
|
|
78
|
+
}
|
|
79
|
+
export function clusterByCurrencyId(currencyId) {
|
|
80
|
+
const clusters = {
|
|
81
|
+
solana: "mainnet-beta",
|
|
82
|
+
solana_devnet: "devnet",
|
|
83
|
+
solana_testnet: "testnet",
|
|
84
|
+
};
|
|
85
|
+
if (currencyId in clusters) {
|
|
86
|
+
return clusters[currencyId];
|
|
87
|
+
}
|
|
88
|
+
throw Error(`unexpected currency id format <${currencyId}>, should be like solana[_(testnet | devnet)]`);
|
|
89
|
+
}
|
|
90
|
+
export function defaultVoteAccAddrByCurrencyId(currencyId) {
|
|
91
|
+
const voteAccAddrs = {
|
|
92
|
+
solana: LEDGER_VALIDATOR.voteAccount,
|
|
93
|
+
solana_devnet: undefined,
|
|
94
|
+
solana_testnet: undefined,
|
|
95
|
+
};
|
|
96
|
+
if (currencyId in voteAccAddrs) {
|
|
97
|
+
return voteAccAddrs[currencyId];
|
|
98
|
+
}
|
|
99
|
+
throw new Error(`unexpected currency id format <${currencyId}>, should be like solana[_(testnet | devnet)]`);
|
|
100
|
+
}
|
|
101
|
+
export function asyncQueue(config) {
|
|
102
|
+
const { delayBetweenRuns } = config;
|
|
103
|
+
const q = [];
|
|
104
|
+
const drain = () => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (q.length > 0) {
|
|
106
|
+
const { lazyPromise, resolve, reject } = q[q.length - 1];
|
|
107
|
+
try {
|
|
108
|
+
resolve(yield lazyPromise());
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
reject(e);
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
void setTimeout(() => {
|
|
115
|
+
q.pop();
|
|
116
|
+
void drain();
|
|
117
|
+
}, delayBetweenRuns);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const submit = (lazyPromise) => {
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
q.unshift({
|
|
124
|
+
lazyPromise,
|
|
125
|
+
resolve,
|
|
126
|
+
reject,
|
|
127
|
+
});
|
|
128
|
+
if (q.length === 1) {
|
|
129
|
+
void drain();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
submit,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export function swap(arr, i, j) {
|
|
138
|
+
const tmp = arr[i];
|
|
139
|
+
arr[i] = arr[j];
|
|
140
|
+
arr[j] = tmp;
|
|
141
|
+
}
|
|
142
|
+
// move Ledger validator to the first position
|
|
143
|
+
export function ledgerFirstValidators(validators) {
|
|
144
|
+
const [ledgerValidator, restValidators] = partition(v => v.voteAccount === LEDGER_VALIDATOR.voteAccount, validators);
|
|
145
|
+
return ledgerValidator.length
|
|
146
|
+
? ledgerValidator.concat(restValidators)
|
|
147
|
+
: [LEDGER_VALIDATOR].concat(restValidators);
|
|
148
|
+
}
|
|
149
|
+
export function profitableValidators(validators) {
|
|
150
|
+
return validators.filter(v => v.commission < 100);
|
|
151
|
+
}
|
|
152
|
+
// https://stackoverflow.com/a/60132060
|
|
153
|
+
export const tupleOfUnion = () => (array) => array;
|
|
154
|
+
export function sweetch(caze, cases) {
|
|
155
|
+
return cases[caze];
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,EAAW,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,kDAAkD;AAClD,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,WAAW,EAAE,8CAA8C;IAC3D,IAAI,EAAE,mBAAmB;IACzB,SAAS,EACP,iGAAiG;IACnG,MAAM,EAAE,gCAAgC;IACxC,WAAW,EAAE,gBAAgB;IAC7B,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,G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AAI,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Cluster } from "@solana/web3.js";
|
|
2
|
+
export type ValidatorsAppValidatorRaw = {
|
|
3
|
+
active_stake?: number | null;
|
|
4
|
+
commission?: number | null;
|
|
5
|
+
total_score?: number | null;
|
|
6
|
+
vote_account?: string | null;
|
|
7
|
+
name?: string | null;
|
|
8
|
+
avatar_url?: string | null;
|
|
9
|
+
delinquent?: boolean | null;
|
|
10
|
+
www_url?: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type ValidatorsAppValidator = {
|
|
13
|
+
activeStake: number;
|
|
14
|
+
commission: number;
|
|
15
|
+
totalScore: number;
|
|
16
|
+
voteAccount: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
avatarUrl?: string;
|
|
19
|
+
wwwUrl?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function getValidators(cluster: Extract<Cluster, "mainnet-beta" | "testnet">): Promise<ValidatorsAppValidator[]>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validator-app/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM1C,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAcF,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAoCnC"}
|
|
@@ -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,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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;aACH;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,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ledgerhq/coin-solana",
|
|
3
|
+
"version": "0.7.0-nightly.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.12.1-nightly.4",
|
|
58
|
+
"@ledgerhq/cryptoassets": "^12.1.1-nightly.0",
|
|
59
|
+
"@ledgerhq/devices": "^8.3.0",
|
|
60
|
+
"@ledgerhq/errors": "^6.16.4",
|
|
61
|
+
"@ledgerhq/live-env": "^2.0.1",
|
|
62
|
+
"@ledgerhq/live-network": "^1.2.1",
|
|
63
|
+
"@ledgerhq/logs": "^6.12.0",
|
|
64
|
+
"@ledgerhq/types-cryptoassets": "^7.11.0",
|
|
65
|
+
"@ledgerhq/types-live": "^6.47.0-nightly.3"
|
|
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
|
+
"prewatch": "pnpm build",
|
|
81
|
+
"watch": "tsc --watch",
|
|
82
|
+
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
|
|
83
|
+
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
|
|
84
|
+
"lint:fix": "pnpm lint --fix",
|
|
85
|
+
"test": "jest",
|
|
86
|
+
"typecheck": "tsc --noEmit",
|
|
87
|
+
"unimported": "unimported"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
getStakeAccountsByStakeAuth: makeLRUCache(
|
|
47
|
+
api.getStakeAccountsByStakeAuth,
|
|
48
|
+
cacheKeyAddress,
|
|
49
|
+
minutes(1),
|
|
50
|
+
),
|
|
51
|
+
|
|
52
|
+
getStakeAccountsByWithdrawAuth: makeLRUCache(
|
|
53
|
+
api.getStakeAccountsByWithdrawAuth,
|
|
54
|
+
cacheKeyAddress,
|
|
55
|
+
minutes(1),
|
|
56
|
+
),
|
|
57
|
+
|
|
58
|
+
getStakeActivation: makeLRUCache(api.getStakeActivation, cacheKeyAddress, minutes(1)),
|
|
59
|
+
|
|
60
|
+
getInflationReward: makeLRUCache(api.getInflationReward, cacheKeyByArgs, minutes(5)),
|
|
61
|
+
|
|
62
|
+
getVoteAccounts: makeLRUCache(api.getVoteAccounts, cacheKeyEmpty, minutes(1)),
|
|
63
|
+
|
|
64
|
+
getLatestBlockhash: makeLRUCache(api.getLatestBlockhash, cacheKeyEmpty, seconds(15)),
|
|
65
|
+
|
|
66
|
+
getFeeForMessage: makeLRUCache(
|
|
67
|
+
api.getFeeForMessage,
|
|
68
|
+
msg => msg.serialize().toString(),
|
|
69
|
+
minutes(1),
|
|
70
|
+
),
|
|
71
|
+
|
|
72
|
+
getSignaturesForAddress: makeLRUCache(api.getSignaturesForAddress, cacheKeyByArgs, seconds(30)),
|
|
73
|
+
|
|
74
|
+
getMinimumBalanceForRentExemption: makeLRUCache(
|
|
75
|
+
api.getMinimumBalanceForRentExemption,
|
|
76
|
+
cacheKeyMinimumBalanceForRentExemption,
|
|
77
|
+
minutes(5),
|
|
78
|
+
),
|
|
79
|
+
|
|
80
|
+
// do not cache
|
|
81
|
+
sendRawTransaction: api.sendRawTransaction,
|
|
82
|
+
|
|
83
|
+
getEpochInfo: makeLRUCache(api.getEpochInfo, cacheKeyEmpty, minutes(1)),
|
|
84
|
+
|
|
85
|
+
config: api.config,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -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
|
+
});
|