@ledgerhq/live-common 21.20.0 → 21.21.0-rc.2
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/lib/__tests__/families/bitcoin/wallet-btc/utils.test.js +4 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/utils.test.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js +12 -0
- package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js.map +1 -1
- package/lib/__tests__/test-helpers/setup.js +1 -0
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/account/pending.d.ts +1 -1
- package/lib/api/Ledger.d.ts.map +1 -1
- package/lib/api/Ledger.js +12 -2
- package/lib/api/Ledger.js.map +1 -1
- package/lib/api/explorerConfig/index.d.ts.map +1 -1
- package/lib/api/explorerConfig/index.js +5 -1
- package/lib/api/explorerConfig/index.js.map +1 -1
- package/lib/data/icons/react/cro.d.ts +8 -0
- package/lib/data/icons/react/cro.d.ts.map +1 -0
- package/lib/data/icons/react/cro.js +33 -0
- package/lib/data/icons/react/cro.js.map +1 -0
- package/lib/data/icons/react/index.d.ts +2 -0
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +12 -8
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/react/sol.d.ts +8 -0
- package/lib/data/icons/react/sol.d.ts.map +1 -0
- package/lib/data/icons/react/sol.js +30 -0
- package/lib/data/icons/react/sol.js.map +1 -0
- package/lib/data/icons/reactNative/cro.d.ts +8 -0
- package/lib/data/icons/reactNative/cro.d.ts.map +1 -0
- package/lib/data/icons/reactNative/cro.js +34 -0
- package/lib/data/icons/reactNative/cro.js.map +1 -0
- package/lib/data/icons/reactNative/index.d.ts +2 -0
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +12 -8
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/data/icons/reactNative/sol.d.ts +8 -0
- package/lib/data/icons/reactNative/sol.d.ts.map +1 -0
- package/lib/data/icons/reactNative/sol.js +31 -0
- package/lib/data/icons/reactNative/sol.js.map +1 -0
- package/lib/derivation.d.ts +7 -0
- package/lib/derivation.d.ts.map +1 -1
- package/lib/derivation.js +16 -1
- package/lib/derivation.js.map +1 -1
- package/lib/errors.d.ts +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -0
- package/lib/errors.js.map +1 -1
- package/lib/families/bitcoin/exchange.d.ts +1 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.d.ts.map +1 -1
- package/lib/families/bitcoin/getAccountNetworkInfo.js +3 -2
- package/lib/families/bitcoin/getAccountNetworkInfo.js.map +1 -1
- package/lib/families/bitcoin/js-signOperation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-signOperation.js +7 -2
- package/lib/families/bitcoin/js-signOperation.js.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.d.ts +2 -2
- package/lib/families/bitcoin/specs.d.ts +1 -0
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +14 -1
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +8 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts +16 -0
- package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js +248 -0
- package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/factory.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/factory.js +5 -0
- package/lib/families/bitcoin/wallet-btc/crypto/factory.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/index.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/index.js +3 -1
- package/lib/families/bitcoin/wallet-btc/crypto/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js +13 -3
- package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js +8 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js +8 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.js +6 -1
- package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts +2 -0
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +15 -7
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/lib/families/crypto_org/js-synchronisation.d.ts +2 -2
- package/lib/families/elrond/js-synchronisation.d.ts +2 -2
- package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
- package/lib/families/ethereum/synchronisation.js +2 -2
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/families/polkadot/api/sidecar.js +4 -2
- package/lib/families/polkadot/api/sidecar.js.map +1 -1
- package/lib/families/polkadot/js-synchronisation.d.ts +2 -2
- package/lib/families/solana/api/cached.d.ts +5 -0
- package/lib/families/solana/api/cached.d.ts.map +1 -0
- package/lib/families/solana/api/cached.js +80 -0
- package/lib/families/solana/api/cached.js.map +1 -0
- package/lib/families/solana/api/chain/account/index.d.ts +2 -0
- package/lib/families/solana/api/chain/account/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/account/index.js +14 -0
- package/lib/families/solana/api/chain/account/index.js.map +1 -0
- package/lib/families/solana/api/chain/account/parser.d.ts +5 -0
- package/lib/families/solana/api/chain/account/parser.d.ts.map +1 -0
- package/lib/families/solana/api/chain/account/parser.js +33 -0
- package/lib/families/solana/api/chain/account/parser.js.map +1 -0
- package/lib/families/solana/api/chain/account/stake.d.ts +237 -0
- package/lib/families/solana/api/chain/account/stake.d.ts.map +1 -0
- package/lib/families/solana/api/chain/account/stake.js +43 -0
- package/lib/families/solana/api/chain/account/stake.js.map +1 -0
- package/lib/families/solana/api/chain/account/token.d.ts +116 -0
- package/lib/families/solana/api/chain/account/token.d.ts.map +1 -0
- package/lib/families/solana/api/chain/account/token.js +42 -0
- package/lib/families/solana/api/chain/account/token.js.map +1 -0
- package/lib/families/solana/api/chain/index.d.ts +22 -0
- package/lib/families/solana/api/chain/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/index.js +54 -0
- package/lib/families/solana/api/chain/index.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/index.js +21 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/types.js +19 -0
- package/lib/families/solana/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib/families/solana/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/memo/index.js +14 -0
- package/lib/families/solana/api/chain/instruction/memo/index.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib/families/solana/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/memo/types.js +16 -0
- package/lib/families/solana/api/chain/instruction/memo/types.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib/families/solana/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/stake/index.js +20 -0
- package/lib/families/solana/api/chain/instruction/stake/index.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib/families/solana/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/stake/types.js +80 -0
- package/lib/families/solana/api/chain/instruction/stake/types.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/token/index.d.ts +15 -0
- package/lib/families/solana/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/token/index.js +20 -0
- package/lib/families/solana/api/chain/instruction/token/index.js.map +1 -0
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +497 -0
- package/lib/families/solana/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib/families/solana/api/chain/instruction/token/types.js +205 -0
- package/lib/families/solana/api/chain/instruction/token/types.js.map +1 -0
- package/lib/families/solana/api/chain/program/constants.d.ts +11 -0
- package/lib/families/solana/api/chain/program/constants.d.ts.map +1 -0
- package/lib/families/solana/api/chain/program/constants.js +14 -0
- package/lib/families/solana/api/chain/program/constants.js.map +1 -0
- package/lib/families/solana/api/chain/program/index.d.ts +2 -0
- package/lib/families/solana/api/chain/program/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/program/index.js +14 -0
- package/lib/families/solana/api/chain/program/index.js.map +1 -0
- package/lib/families/solana/api/chain/program/parser.d.ts +30 -0
- package/lib/families/solana/api/chain/program/parser.d.ts.map +1 -0
- package/lib/families/solana/api/chain/program/parser.js +70 -0
- package/lib/families/solana/api/chain/program/parser.js.map +1 -0
- package/lib/families/solana/api/chain/validators/bignum.d.ts +3 -0
- package/lib/families/solana/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib/families/solana/api/chain/validators/bignum.js +11 -0
- package/lib/families/solana/api/chain/validators/bignum.js.map +1 -0
- package/lib/families/solana/api/chain/validators/index.d.ts +10 -0
- package/lib/families/solana/api/chain/validators/index.d.ts.map +1 -0
- package/lib/families/solana/api/chain/validators/index.js +10 -0
- package/lib/families/solana/api/chain/validators/index.js.map +1 -0
- package/lib/families/solana/api/chain/validators/pubkey.d.ts +3 -0
- package/lib/families/solana/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib/families/solana/api/chain/validators/pubkey.js +7 -0
- package/lib/families/solana/api/chain/validators/pubkey.js.map +1 -0
- package/lib/families/solana/api/chain/web3.d.ts +29 -0
- package/lib/families/solana/api/chain/web3.d.ts.map +1 -0
- package/lib/families/solana/api/chain/web3.js +287 -0
- package/lib/families/solana/api/chain/web3.js.map +1 -0
- package/lib/families/solana/api/index.d.ts +5 -0
- package/lib/families/solana/api/index.d.ts.map +1 -0
- package/lib/families/solana/api/index.js +21 -0
- package/lib/families/solana/api/index.js.map +1 -0
- package/lib/families/solana/api/logged.d.ts +3 -0
- package/lib/families/solana/api/logged.d.ts.map +1 -0
- package/lib/families/solana/api/logged.js +53 -0
- package/lib/families/solana/api/logged.js.map +1 -0
- package/lib/families/solana/api/queued.d.ts +3 -0
- package/lib/families/solana/api/queued.d.ts.map +1 -0
- package/lib/families/solana/api/queued.js +31 -0
- package/lib/families/solana/api/queued.js.map +1 -0
- package/lib/families/solana/bridge/bridge.d.ts +12 -0
- package/lib/families/solana/bridge/bridge.d.ts.map +1 -0
- package/lib/families/solana/bridge/bridge.js +218 -0
- package/lib/families/solana/bridge/bridge.js.map +1 -0
- package/lib/families/solana/bridge/js.d.ts +6 -0
- package/lib/families/solana/bridge/js.d.ts.map +1 -0
- package/lib/families/solana/bridge/js.js +15 -0
- package/lib/families/solana/bridge/js.js.map +1 -0
- package/lib/families/solana/bridge/mock-data.d.ts +186 -0
- package/lib/families/solana/bridge/mock-data.d.ts.map +1 -0
- package/lib/families/solana/bridge/mock-data.js +23 -0
- package/lib/families/solana/bridge/mock-data.js.map +1 -0
- package/lib/families/solana/bridge/mock.d.ts +6 -0
- package/lib/families/solana/bridge/mock.d.ts.map +1 -0
- package/lib/families/solana/bridge/mock.js +75 -0
- package/lib/families/solana/bridge/mock.js.map +1 -0
- package/lib/families/solana/cli-transaction.d.ts +14 -0
- package/lib/families/solana/cli-transaction.d.ts.map +1 -0
- package/lib/families/solana/cli-transaction.js +137 -0
- package/lib/families/solana/cli-transaction.js.map +1 -0
- package/lib/families/solana/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib/families/solana/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib/families/solana/datasets/solana.scanAccounts.1.js +7 -0
- package/lib/families/solana/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib/families/solana/deviceTransactionConfig.d.ts +10 -0
- package/lib/families/solana/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/families/solana/deviceTransactionConfig.js +121 -0
- package/lib/families/solana/deviceTransactionConfig.js.map +1 -0
- package/lib/families/solana/errors.d.ts +25 -0
- package/lib/families/solana/errors.d.ts.map +1 -0
- package/lib/families/solana/errors.js +13 -0
- package/lib/families/solana/errors.js.map +1 -0
- package/lib/families/solana/hw-getAddress.d.ts +4 -0
- package/lib/families/solana/hw-getAddress.d.ts.map +1 -0
- package/lib/families/solana/hw-getAddress.js +66 -0
- package/lib/families/solana/hw-getAddress.js.map +1 -0
- package/lib/families/solana/js-broadcast.d.ts +7 -0
- package/lib/families/solana/js-broadcast.d.ts.map +1 -0
- package/lib/families/solana/js-broadcast.js +59 -0
- package/lib/families/solana/js-broadcast.js.map +1 -0
- package/lib/families/solana/js-buildTransaction.d.ts +6 -0
- package/lib/families/solana/js-buildTransaction.d.ts.map +1 -0
- package/lib/families/solana/js-buildTransaction.js +123 -0
- package/lib/families/solana/js-buildTransaction.js.map +1 -0
- package/lib/families/solana/js-createTransaction.d.ts +6 -0
- package/lib/families/solana/js-createTransaction.d.ts.map +1 -0
- package/lib/families/solana/js-createTransaction.js +35 -0
- package/lib/families/solana/js-createTransaction.js.map +1 -0
- package/lib/families/solana/js-estimateMaxSpendable.d.ts +7 -0
- package/lib/families/solana/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/families/solana/js-estimateMaxSpendable.js +72 -0
- package/lib/families/solana/js-estimateMaxSpendable.js.map +1 -0
- package/lib/families/solana/js-getTransactionStatus.d.ts +5 -0
- package/lib/families/solana/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/families/solana/js-getTransactionStatus.js +106 -0
- package/lib/families/solana/js-getTransactionStatus.js.map +1 -0
- package/lib/families/solana/js-prepareTransaction.d.ts +6 -0
- package/lib/families/solana/js-prepareTransaction.d.ts.map +1 -0
- package/lib/families/solana/js-prepareTransaction.js +380 -0
- package/lib/families/solana/js-prepareTransaction.js.map +1 -0
- package/lib/families/solana/js-signOperation.d.ts +10 -0
- package/lib/families/solana/js-signOperation.d.ts.map +1 -0
- package/lib/families/solana/js-signOperation.js +193 -0
- package/lib/families/solana/js-signOperation.js.map +1 -0
- package/lib/families/solana/js-synchronization.d.ts +5 -0
- package/lib/families/solana/js-synchronization.d.ts.map +1 -0
- package/lib/families/solana/js-synchronization.js +464 -0
- package/lib/families/solana/js-synchronization.js.map +1 -0
- package/lib/families/solana/logic.d.ts +15 -0
- package/lib/families/solana/logic.d.ts.map +1 -0
- package/lib/families/solana/logic.js +49 -0
- package/lib/families/solana/logic.js.map +1 -0
- package/lib/families/solana/specs.d.ts +7 -0
- package/lib/families/solana/specs.d.ts.map +1 -0
- package/lib/families/solana/specs.js +100 -0
- package/lib/families/solana/specs.js.map +1 -0
- package/lib/families/solana/speculos-deviceActions.d.ts +8 -0
- package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -0
- package/lib/families/solana/speculos-deviceActions.js +60 -0
- package/lib/families/solana/speculos-deviceActions.js.map +1 -0
- package/lib/families/solana/test-dataset.d.ts +5 -0
- package/lib/families/solana/test-dataset.d.ts.map +1 -0
- package/lib/families/solana/test-dataset.js +396 -0
- package/lib/families/solana/test-dataset.js.map +1 -0
- package/lib/families/solana/transaction.d.ts +12 -0
- package/lib/families/solana/transaction.d.ts.map +1 -0
- package/lib/families/solana/transaction.js +109 -0
- package/lib/families/solana/transaction.js.map +1 -0
- package/lib/families/solana/types.d.ts +84 -0
- package/lib/families/solana/types.d.ts.map +1 -0
- package/lib/families/solana/types.js +6 -0
- package/lib/families/solana/types.js.map +1 -0
- package/lib/families/solana/utils.d.ts +10 -0
- package/lib/families/solana/utils.d.ts.map +1 -0
- package/lib/families/solana/utils.js +194 -0
- package/lib/families/solana/utils.js.map +1 -0
- package/lib/families/stellar/js-synchronization.d.ts +2 -2
- package/lib/generated/bridge/js.d.ts +4 -0
- package/lib/generated/bridge/js.d.ts.map +1 -1
- package/lib/generated/bridge/js.js +8 -6
- package/lib/generated/bridge/js.js.map +1 -1
- package/lib/generated/bridge/mock.d.ts +4 -0
- package/lib/generated/bridge/mock.d.ts.map +1 -1
- package/lib/generated/bridge/mock.js +6 -4
- package/lib/generated/bridge/mock.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +9 -0
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/generated/cli-transaction.js +8 -6
- package/lib/generated/cli-transaction.js.map +1 -1
- package/lib/generated/deviceTransactionConfig.d.ts +2 -0
- package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/generated/deviceTransactionConfig.js +8 -6
- package/lib/generated/deviceTransactionConfig.js.map +1 -1
- package/lib/generated/exchange.d.ts +1 -1
- package/lib/generated/hw-getAddress.d.ts +1 -0
- package/lib/generated/hw-getAddress.d.ts.map +1 -1
- package/lib/generated/hw-getAddress.js +8 -6
- package/lib/generated/hw-getAddress.js.map +1 -1
- package/lib/generated/specs.d.ts +4 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/generated/specs.js +8 -6
- package/lib/generated/specs.js.map +1 -1
- package/lib/generated/speculos-deviceActions.d.ts +3 -0
- package/lib/generated/speculos-deviceActions.d.ts.map +1 -1
- package/lib/generated/speculos-deviceActions.js +8 -6
- package/lib/generated/speculos-deviceActions.js.map +1 -1
- package/lib/generated/test-dataset.d.ts +1 -0
- package/lib/generated/test-dataset.d.ts.map +1 -1
- package/lib/generated/test-dataset.js +8 -6
- package/lib/generated/test-dataset.js.map +1 -1
- package/lib/generated/transaction.d.ts +5 -0
- package/lib/generated/transaction.d.ts.map +1 -1
- package/lib/generated/transaction.js +8 -6
- package/lib/generated/transaction.js.map +1 -1
- package/lib/generated/types.d.ts +12 -6
- package/lib/generated/types.d.ts.map +1 -1
- package/lib/generated/types.js +5 -3
- package/lib/generated/types.js.map +1 -1
- package/lib/nft/helpers.js +1 -1
- package/lib/nft/helpers.js.map +1 -1
- package/package.json +8 -4
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +113 -0
- package/src/__tests__/families/bitcoin/wallet-btc/utils.test.ts +4 -0
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +12 -0
- package/src/__tests__/test-helpers/setup.ts +1 -0
- package/src/api/Ledger.ts +11 -1
- package/src/api/explorerConfig/index.ts +1 -3
- package/src/data/icons/react/cro.tsx +12 -0
- package/src/data/icons/react/index.tsx +2 -0
- package/src/data/icons/react/sol.tsx +12 -0
- package/src/data/icons/reactNative/cro.tsx +13 -0
- package/src/data/icons/reactNative/index.tsx +2 -0
- package/src/data/icons/reactNative/sol.tsx +13 -0
- package/src/data/icons/svg/CRO.svg +6 -0
- package/src/data/icons/svg/SOL.svg +3 -0
- package/src/derivation.ts +13 -0
- package/src/errors.ts +1 -0
- package/src/families/bitcoin/getAccountNetworkInfo.ts +5 -2
- package/src/families/bitcoin/js-signOperation.ts +4 -7
- package/src/families/bitcoin/specs.ts +16 -0
- package/src/families/bitcoin/wallet-btc/crypto/base.ts +1 -1
- package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +8 -1
- package/src/families/bitcoin/wallet-btc/crypto/decred.ts +251 -0
- package/src/families/bitcoin/wallet-btc/crypto/factory.ts +5 -0
- package/src/families/bitcoin/wallet-btc/crypto/index.ts +1 -0
- package/src/families/bitcoin/wallet-btc/crypto/litecoin.ts +13 -3
- package/src/families/bitcoin/wallet-btc/crypto/types.ts +1 -0
- package/src/families/bitcoin/wallet-btc/crypto/zec.ts +8 -1
- package/src/families/bitcoin/wallet-btc/crypto/zen.ts +8 -1
- package/src/families/bitcoin/wallet-btc/utils.ts +6 -1
- package/src/families/bitcoin/wallet-btc/wallet.ts +18 -5
- package/src/families/ethereum/synchronisation.ts +5 -2
- package/src/families/polkadot/api/sidecar.ts +2 -2
- package/src/families/solana/api/cached.ts +89 -0
- package/src/families/solana/api/chain/account/index.ts +1 -0
- package/src/families/solana/api/chain/account/parser.ts +35 -0
- package/src/families/solana/api/chain/account/stake.ts +50 -0
- package/src/families/solana/api/chain/account/token.ts +63 -0
- package/src/families/solana/api/chain/index.ts +115 -0
- package/src/families/solana/api/chain/instruction/associated-token-account/index.ts +37 -0
- package/src/families/solana/api/chain/instruction/associated-token-account/types.ts +23 -0
- package/src/families/solana/api/chain/instruction/memo/index.ts +24 -0
- package/src/families/solana/api/chain/instruction/memo/types.ts +18 -0
- package/src/families/solana/api/chain/instruction/stake/index.ts +29 -0
- package/src/families/solana/api/chain/instruction/stake/types.ts +95 -0
- package/src/families/solana/api/chain/instruction/token/index.ts +30 -0
- package/src/families/solana/api/chain/instruction/token/types.ts +237 -0
- package/src/families/solana/api/chain/program/constants.ts +10 -0
- package/src/families/solana/api/chain/program/index.ts +1 -0
- package/src/families/solana/api/chain/program/parser.ts +122 -0
- package/src/families/solana/api/chain/validators/bignum.ts +11 -0
- package/src/families/solana/api/chain/validators/index.ts +9 -0
- package/src/families/solana/api/chain/validators/pubkey.ts +8 -0
- package/src/families/solana/api/chain/web3.ts +258 -0
- package/src/families/solana/api/index.ts +4 -0
- package/src/families/solana/api/logged.ts +50 -0
- package/src/families/solana/api/queued.ts +23 -0
- package/src/families/solana/bridge/bridge.ts +169 -0
- package/src/families/solana/bridge/js.ts +28 -0
- package/src/families/solana/bridge/mock-data.ts +22 -0
- package/src/families/solana/bridge/mock.ts +80 -0
- package/src/families/solana/cli-transaction.ts +175 -0
- package/src/families/solana/datasets/solana.scanAccounts.1.ts +9 -0
- package/src/families/solana/deviceTransactionConfig.ts +160 -0
- package/src/families/solana/errors.ts +32 -0
- package/src/families/solana/hw-getAddress.ts +20 -0
- package/src/families/solana/js-broadcast.ts +20 -0
- package/src/families/solana/js-buildTransaction.ts +75 -0
- package/src/families/solana/js-createTransaction.ts +27 -0
- package/src/families/solana/js-estimateMaxSpendable.ts +29 -0
- package/src/families/solana/js-getTransactionStatus.ts +78 -0
- package/src/families/solana/js-prepareTransaction.ts +423 -0
- package/src/families/solana/js-signOperation.ts +230 -0
- package/src/families/solana/js-synchronization.ts +544 -0
- package/src/families/solana/logic.ts +52 -0
- package/src/families/solana/specs.ts +100 -0
- package/src/families/solana/speculos-deviceActions.ts +59 -0
- package/src/families/solana/test-dataset.ts +572 -0
- package/src/families/solana/transaction.ts +146 -0
- package/src/families/solana/types.ts +110 -0
- package/src/families/solana/utils.ts +80 -0
- package/src/generated/bridge/js.ts +3 -0
- package/src/generated/bridge/mock.ts +3 -0
- package/src/generated/cli-transaction.ts +3 -0
- package/src/generated/deviceTransactionConfig.ts +3 -0
- package/src/generated/hw-getAddress.ts +3 -0
- package/src/generated/specs.ts +3 -0
- package/src/generated/speculos-deviceActions.ts +3 -0
- package/src/generated/test-dataset.ts +3 -0
- package/src/generated/transaction.ts +3 -0
- package/src/generated/types.ts +14 -0
- package/src/nft/helpers.ts +1 -1
|
@@ -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,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3
|
+
Token,
|
|
4
|
+
TOKEN_PROGRAM_ID,
|
|
5
|
+
} from "@solana/spl-token";
|
|
6
|
+
import {
|
|
7
|
+
Cluster,
|
|
8
|
+
clusterApiUrl,
|
|
9
|
+
Connection,
|
|
10
|
+
FeeCalculator,
|
|
11
|
+
PublicKey,
|
|
12
|
+
SignaturesForAddressOptions,
|
|
13
|
+
} from "@solana/web3.js";
|
|
14
|
+
import { Awaited } from "../../logic";
|
|
15
|
+
|
|
16
|
+
export type Config = {
|
|
17
|
+
readonly cluster: Cluster;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ChainAPI = Readonly<{
|
|
21
|
+
getBalance: (address: string) => Promise<number>;
|
|
22
|
+
|
|
23
|
+
getRecentBlockhash: () => Promise<string>;
|
|
24
|
+
|
|
25
|
+
getTxFeeCalculator: () => Promise<FeeCalculator>;
|
|
26
|
+
|
|
27
|
+
getBalanceAndContext: (
|
|
28
|
+
address: string
|
|
29
|
+
) => ReturnType<Connection["getBalanceAndContext"]>;
|
|
30
|
+
|
|
31
|
+
getParsedTokenAccountsByOwner: (
|
|
32
|
+
address: string
|
|
33
|
+
) => ReturnType<Connection["getParsedTokenAccountsByOwner"]>;
|
|
34
|
+
|
|
35
|
+
getSignaturesForAddress: (
|
|
36
|
+
address: string,
|
|
37
|
+
opts?: SignaturesForAddressOptions
|
|
38
|
+
) => ReturnType<Connection["getSignaturesForAddress"]>;
|
|
39
|
+
|
|
40
|
+
getParsedConfirmedTransactions: (
|
|
41
|
+
signatures: string[]
|
|
42
|
+
) => ReturnType<Connection["getParsedConfirmedTransactions"]>;
|
|
43
|
+
|
|
44
|
+
getAccountInfo: (
|
|
45
|
+
address: string
|
|
46
|
+
) => Promise<
|
|
47
|
+
Awaited<ReturnType<Connection["getParsedAccountInfo"]>>["value"]
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
sendRawTransaction: (
|
|
51
|
+
buffer: Buffer
|
|
52
|
+
) => ReturnType<Connection["sendRawTransaction"]>;
|
|
53
|
+
|
|
54
|
+
findAssocTokenAccAddress: (owner: string, mint: string) => Promise<string>;
|
|
55
|
+
|
|
56
|
+
getAssocTokenAccMinNativeBalance: () => Promise<number>;
|
|
57
|
+
|
|
58
|
+
config: Config;
|
|
59
|
+
}>;
|
|
60
|
+
|
|
61
|
+
export function getChainAPI(config: Config): ChainAPI {
|
|
62
|
+
const connection = () =>
|
|
63
|
+
new Connection(clusterApiUrl(config.cluster), "finalized");
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
getBalance: (address: string) =>
|
|
67
|
+
connection().getBalance(new PublicKey(address)),
|
|
68
|
+
|
|
69
|
+
getRecentBlockhash: () =>
|
|
70
|
+
connection()
|
|
71
|
+
.getRecentBlockhash()
|
|
72
|
+
.then((r) => r.blockhash),
|
|
73
|
+
|
|
74
|
+
getTxFeeCalculator: () =>
|
|
75
|
+
connection()
|
|
76
|
+
.getRecentBlockhash()
|
|
77
|
+
.then((r) => r.feeCalculator),
|
|
78
|
+
|
|
79
|
+
getBalanceAndContext: (address: string) =>
|
|
80
|
+
connection().getBalanceAndContext(new PublicKey(address)),
|
|
81
|
+
|
|
82
|
+
getParsedTokenAccountsByOwner: (address: string) =>
|
|
83
|
+
connection().getParsedTokenAccountsByOwner(new PublicKey(address), {
|
|
84
|
+
programId: TOKEN_PROGRAM_ID,
|
|
85
|
+
}),
|
|
86
|
+
getSignaturesForAddress: (
|
|
87
|
+
address: string,
|
|
88
|
+
opts?: SignaturesForAddressOptions
|
|
89
|
+
) => connection().getSignaturesForAddress(new PublicKey(address), opts),
|
|
90
|
+
|
|
91
|
+
getParsedConfirmedTransactions: (signatures: string[]) =>
|
|
92
|
+
connection().getParsedConfirmedTransactions(signatures),
|
|
93
|
+
|
|
94
|
+
getAccountInfo: (address: string) =>
|
|
95
|
+
connection()
|
|
96
|
+
.getParsedAccountInfo(new PublicKey(address))
|
|
97
|
+
.then((r) => r.value),
|
|
98
|
+
|
|
99
|
+
sendRawTransaction: (buffer: Buffer) =>
|
|
100
|
+
connection().sendRawTransaction(buffer),
|
|
101
|
+
|
|
102
|
+
findAssocTokenAccAddress: (owner: string, mint: string) =>
|
|
103
|
+
Token.getAssociatedTokenAddress(
|
|
104
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
105
|
+
TOKEN_PROGRAM_ID,
|
|
106
|
+
new PublicKey(mint),
|
|
107
|
+
new PublicKey(owner)
|
|
108
|
+
).then((r) => r.toBase58()),
|
|
109
|
+
|
|
110
|
+
getAssocTokenAccMinNativeBalance: () =>
|
|
111
|
+
Token.getMinBalanceRentForExemptAccount(connection()),
|
|
112
|
+
|
|
113
|
+
config,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ParsedInfo } from "../../validators";
|
|
2
|
+
import { create, Infer } from "superstruct";
|
|
3
|
+
import { ParsedInstruction } from "@solana/web3.js";
|
|
4
|
+
import {
|
|
5
|
+
AssociatedTokenAccountInstructionType,
|
|
6
|
+
IX_STRUCTS,
|
|
7
|
+
IX_TITLES,
|
|
8
|
+
} from "./types";
|
|
9
|
+
|
|
10
|
+
import { PARSED_PROGRAMS } from "../../program/constants";
|
|
11
|
+
|
|
12
|
+
export function parseAssociatedTokenAccountInstruction(
|
|
13
|
+
ix: ParsedInstruction & {
|
|
14
|
+
program: typeof PARSED_PROGRAMS.SPL_ASSOCIATED_TOKEN_ACCOUNT;
|
|
15
|
+
}
|
|
16
|
+
): AssociatedTokenAccountInstructionDescriptor {
|
|
17
|
+
// TODO: check this
|
|
18
|
+
const parsed = create(ix.parsed, ParsedInfo);
|
|
19
|
+
//const { type: rawType, info } = parsed;
|
|
20
|
+
const type: AssociatedTokenAccountInstructionType = "associate";
|
|
21
|
+
const title = IX_TITLES[type];
|
|
22
|
+
const struct = IX_STRUCTS[type];
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
type: "associate",
|
|
26
|
+
title: title,
|
|
27
|
+
info: create(parsed.info, struct as any) as any,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type AssociatedTokenAccountInstructionDescriptor = {
|
|
32
|
+
[K in AssociatedTokenAccountInstructionType]: {
|
|
33
|
+
title: typeof IX_TITLES[K];
|
|
34
|
+
type: K;
|
|
35
|
+
info: Infer<typeof IX_STRUCTS[K]>;
|
|
36
|
+
};
|
|
37
|
+
}[AssociatedTokenAccountInstructionType];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { enums, type, Infer } from "superstruct";
|
|
2
|
+
import { PublicKeyFromString } from "../../validators/pubkey";
|
|
3
|
+
|
|
4
|
+
type AssociateInfo = Infer<typeof AssociateInfo>;
|
|
5
|
+
export const AssociateInfo = type({
|
|
6
|
+
account: PublicKeyFromString,
|
|
7
|
+
mint: PublicKeyFromString,
|
|
8
|
+
wallet: PublicKeyFromString,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type AssociatedTokenAccountInstructionType = Infer<
|
|
12
|
+
typeof AssociatedTokenAccountInstructionType
|
|
13
|
+
>;
|
|
14
|
+
// not a real instruction type, added for structure
|
|
15
|
+
export const AssociatedTokenAccountInstructionType = enums(["associate"]);
|
|
16
|
+
|
|
17
|
+
export const IX_STRUCTS = {
|
|
18
|
+
associate: AssociateInfo,
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
export const IX_TITLES = {
|
|
22
|
+
associate: "Associate",
|
|
23
|
+
} as const;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ParsedInstruction } from "@solana/web3.js";
|
|
2
|
+
import { IX_STRUCTS, IX_TITLES, MemoInstructionType } from "./types";
|
|
3
|
+
import { Infer } from "superstruct";
|
|
4
|
+
import { PARSED_PROGRAMS } from "../../program/constants";
|
|
5
|
+
|
|
6
|
+
export function parseSplMemoInstruction(
|
|
7
|
+
ix: ParsedInstruction & { program: typeof PARSED_PROGRAMS.SPL_MEMO }
|
|
8
|
+
): MemoInstructionDescriptor {
|
|
9
|
+
return {
|
|
10
|
+
title: "Save",
|
|
11
|
+
type: "save",
|
|
12
|
+
info: {
|
|
13
|
+
data: ix.parsed,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type MemoInstructionDescriptor = {
|
|
19
|
+
[K in MemoInstructionType]: {
|
|
20
|
+
title: typeof IX_TITLES[K];
|
|
21
|
+
type: K;
|
|
22
|
+
info: Infer<typeof IX_STRUCTS[K]>;
|
|
23
|
+
};
|
|
24
|
+
}[MemoInstructionType];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { enums, type, string, Infer } from "superstruct";
|
|
2
|
+
|
|
3
|
+
type SaveInfo = Infer<typeof SaveInfo>;
|
|
4
|
+
export const SaveInfo = type({
|
|
5
|
+
data: string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type MemoInstructionType = Infer<typeof MemoInstructionType>;
|
|
9
|
+
// not a real instruction type, added for structure
|
|
10
|
+
export const MemoInstructionType = enums(["save"]);
|
|
11
|
+
|
|
12
|
+
export const IX_STRUCTS = {
|
|
13
|
+
save: SaveInfo,
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export const IX_TITLES = {
|
|
17
|
+
save: "Save",
|
|
18
|
+
} as const;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ParsedInfo } from "../../validators";
|
|
2
|
+
import { create, Infer } from "superstruct";
|
|
3
|
+
import { ParsedInstruction } from "@solana/web3.js";
|
|
4
|
+
import { StakeInstructionType, IX_STRUCTS, IX_TITLES } from "./types";
|
|
5
|
+
import { PARSED_PROGRAMS } from "../../program/constants";
|
|
6
|
+
|
|
7
|
+
export function parseStakeInstruction(
|
|
8
|
+
ix: ParsedInstruction & { program: typeof PARSED_PROGRAMS.STAKE }
|
|
9
|
+
): StakeInstructionDescriptor {
|
|
10
|
+
const parsed = create(ix.parsed, ParsedInfo);
|
|
11
|
+
const { type: rawType, info } = parsed;
|
|
12
|
+
const type = create(rawType, StakeInstructionType);
|
|
13
|
+
const title = IX_TITLES[type];
|
|
14
|
+
const struct = IX_STRUCTS[type];
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
type,
|
|
18
|
+
title: title as any,
|
|
19
|
+
info: create(info, struct as any) as any,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type StakeInstructionDescriptor = {
|
|
24
|
+
[K in StakeInstructionType]: {
|
|
25
|
+
title: typeof IX_TITLES[K];
|
|
26
|
+
type: K;
|
|
27
|
+
info: Infer<typeof IX_STRUCTS[K]>;
|
|
28
|
+
};
|
|
29
|
+
}[StakeInstructionType];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
2
|
+
|
|
3
|
+
import { enums, number, type, string, Infer } from "superstruct";
|
|
4
|
+
import { PublicKeyFromString } from "../../validators/pubkey";
|
|
5
|
+
|
|
6
|
+
export type InitializeInfo = Infer<typeof InitializeInfo>;
|
|
7
|
+
export const InitializeInfo = type({
|
|
8
|
+
stakeAccount: PublicKeyFromString,
|
|
9
|
+
authorized: type({
|
|
10
|
+
staker: PublicKeyFromString,
|
|
11
|
+
withdrawer: PublicKeyFromString,
|
|
12
|
+
}),
|
|
13
|
+
lockup: type({
|
|
14
|
+
unixTimestamp: number(),
|
|
15
|
+
epoch: number(),
|
|
16
|
+
custodian: PublicKeyFromString,
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type DelegateInfo = Infer<typeof DelegateInfo>;
|
|
21
|
+
export const DelegateInfo = type({
|
|
22
|
+
stakeAccount: PublicKeyFromString,
|
|
23
|
+
voteAccount: PublicKeyFromString,
|
|
24
|
+
stakeAuthority: PublicKeyFromString,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type AuthorizeInfo = Infer<typeof AuthorizeInfo>;
|
|
28
|
+
export const AuthorizeInfo = type({
|
|
29
|
+
authorityType: string(),
|
|
30
|
+
stakeAccount: PublicKeyFromString,
|
|
31
|
+
authority: PublicKeyFromString,
|
|
32
|
+
newAuthority: PublicKeyFromString,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type SplitInfo = Infer<typeof SplitInfo>;
|
|
36
|
+
export const SplitInfo = type({
|
|
37
|
+
stakeAccount: PublicKeyFromString,
|
|
38
|
+
stakeAuthority: PublicKeyFromString,
|
|
39
|
+
newSplitAccount: PublicKeyFromString,
|
|
40
|
+
lamports: number(),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export type WithdrawInfo = Infer<typeof WithdrawInfo>;
|
|
44
|
+
export const WithdrawInfo = type({
|
|
45
|
+
stakeAccount: PublicKeyFromString,
|
|
46
|
+
withdrawAuthority: PublicKeyFromString,
|
|
47
|
+
destination: PublicKeyFromString,
|
|
48
|
+
lamports: number(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type DeactivateInfo = Infer<typeof DeactivateInfo>;
|
|
52
|
+
export const DeactivateInfo = type({
|
|
53
|
+
stakeAccount: PublicKeyFromString,
|
|
54
|
+
stakeAuthority: PublicKeyFromString,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type MergeInfo = Infer<typeof MergeInfo>;
|
|
58
|
+
export const MergeInfo = type({
|
|
59
|
+
source: PublicKeyFromString,
|
|
60
|
+
destination: PublicKeyFromString,
|
|
61
|
+
stakeAuthority: PublicKeyFromString,
|
|
62
|
+
stakeHistorySysvar: PublicKeyFromString,
|
|
63
|
+
clockSysvar: PublicKeyFromString,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export type StakeInstructionType = Infer<typeof StakeInstructionType>;
|
|
67
|
+
export const StakeInstructionType = enums([
|
|
68
|
+
"initialize",
|
|
69
|
+
"delegate",
|
|
70
|
+
"authorize",
|
|
71
|
+
"split",
|
|
72
|
+
"withdraw",
|
|
73
|
+
"deactivate",
|
|
74
|
+
"merge",
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
export const IX_STRUCTS = {
|
|
78
|
+
initialize: InitializeInfo,
|
|
79
|
+
delegate: DelegateInfo,
|
|
80
|
+
authorize: AuthorizeInfo,
|
|
81
|
+
split: SplitInfo,
|
|
82
|
+
withdraw: WithdrawInfo,
|
|
83
|
+
deactivate: DeactivateInfo,
|
|
84
|
+
merge: MergeInfo,
|
|
85
|
+
} as const;
|
|
86
|
+
|
|
87
|
+
export const IX_TITLES = {
|
|
88
|
+
initialize: "Initialize",
|
|
89
|
+
delegate: "Delegate",
|
|
90
|
+
authorize: "Authorize",
|
|
91
|
+
split: "Split",
|
|
92
|
+
withdraw: "Withdraw",
|
|
93
|
+
deactivate: "Deactive",
|
|
94
|
+
merge: "Merge",
|
|
95
|
+
} as const;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ParsedInstruction } from "@solana/web3.js";
|
|
2
|
+
import { IX_STRUCTS, IX_TITLES, TokenInstructionType } from "./types";
|
|
3
|
+
|
|
4
|
+
import { ParsedInfo } from "../../validators";
|
|
5
|
+
import { create, Infer } from "superstruct";
|
|
6
|
+
import { PARSED_PROGRAMS } from "../../program/constants";
|
|
7
|
+
|
|
8
|
+
export function parseSplTokenInstruction(
|
|
9
|
+
ix: ParsedInstruction & { program: typeof PARSED_PROGRAMS.SPL_TOKEN }
|
|
10
|
+
): TokenInstructionDescriptor {
|
|
11
|
+
const parsed = create(ix.parsed, ParsedInfo);
|
|
12
|
+
const { type: rawType, info } = parsed;
|
|
13
|
+
const type = create(rawType, TokenInstructionType);
|
|
14
|
+
const title = IX_TITLES[type];
|
|
15
|
+
const struct = IX_STRUCTS[type];
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
type,
|
|
19
|
+
title: title as any,
|
|
20
|
+
info: create(info, struct as any) as any,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type TokenInstructionDescriptor = {
|
|
25
|
+
[K in TokenInstructionType]: {
|
|
26
|
+
title: typeof IX_TITLES[K];
|
|
27
|
+
type: K;
|
|
28
|
+
info: Infer<typeof IX_STRUCTS[K]>;
|
|
29
|
+
};
|
|
30
|
+
}[TokenInstructionType];
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-redeclare */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
enums,
|
|
5
|
+
type,
|
|
6
|
+
Infer,
|
|
7
|
+
number,
|
|
8
|
+
string,
|
|
9
|
+
optional,
|
|
10
|
+
array,
|
|
11
|
+
nullable,
|
|
12
|
+
union,
|
|
13
|
+
} from "superstruct";
|
|
14
|
+
import { PublicKeyFromString } from "../../validators/pubkey";
|
|
15
|
+
|
|
16
|
+
export type TokenAmountUi = Infer<typeof TokenAmountUi>;
|
|
17
|
+
export const TokenAmountUi = type({
|
|
18
|
+
amount: string(),
|
|
19
|
+
decimals: number(),
|
|
20
|
+
uiAmountString: string(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const InitializeMint = type({
|
|
24
|
+
mint: PublicKeyFromString,
|
|
25
|
+
decimals: number(),
|
|
26
|
+
mintAuthority: PublicKeyFromString,
|
|
27
|
+
rentSysvar: PublicKeyFromString,
|
|
28
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const InitializeAccount = type({
|
|
32
|
+
account: PublicKeyFromString,
|
|
33
|
+
mint: PublicKeyFromString,
|
|
34
|
+
owner: PublicKeyFromString,
|
|
35
|
+
rentSysvar: PublicKeyFromString,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const InitializeMultisig = type({
|
|
39
|
+
multisig: PublicKeyFromString,
|
|
40
|
+
rentSysvar: PublicKeyFromString,
|
|
41
|
+
signers: array(PublicKeyFromString),
|
|
42
|
+
m: number(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export type Transfer = Infer<typeof Transfer>;
|
|
46
|
+
export const Transfer = type({
|
|
47
|
+
source: PublicKeyFromString,
|
|
48
|
+
destination: PublicKeyFromString,
|
|
49
|
+
amount: union([string(), number()]),
|
|
50
|
+
authority: optional(PublicKeyFromString),
|
|
51
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
52
|
+
signers: optional(array(PublicKeyFromString)),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const Approve = type({
|
|
56
|
+
source: PublicKeyFromString,
|
|
57
|
+
delegate: PublicKeyFromString,
|
|
58
|
+
amount: union([string(), number()]),
|
|
59
|
+
owner: optional(PublicKeyFromString),
|
|
60
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
61
|
+
signers: optional(array(PublicKeyFromString)),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const Revoke = type({
|
|
65
|
+
source: PublicKeyFromString,
|
|
66
|
+
owner: optional(PublicKeyFromString),
|
|
67
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
68
|
+
signers: optional(array(PublicKeyFromString)),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const AuthorityType = enums([
|
|
72
|
+
"mintTokens",
|
|
73
|
+
"freezeAccount",
|
|
74
|
+
"accountOwner",
|
|
75
|
+
"closeAccount",
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
const SetAuthority = type({
|
|
79
|
+
mint: optional(PublicKeyFromString),
|
|
80
|
+
account: optional(PublicKeyFromString),
|
|
81
|
+
authorityType: AuthorityType,
|
|
82
|
+
newAuthority: nullable(PublicKeyFromString),
|
|
83
|
+
authority: optional(PublicKeyFromString),
|
|
84
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
85
|
+
signers: optional(array(PublicKeyFromString)),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const MintTo = type({
|
|
89
|
+
mint: PublicKeyFromString,
|
|
90
|
+
account: PublicKeyFromString,
|
|
91
|
+
amount: union([string(), number()]),
|
|
92
|
+
mintAuthority: optional(PublicKeyFromString),
|
|
93
|
+
multisigMintAuthority: optional(PublicKeyFromString),
|
|
94
|
+
signers: optional(array(PublicKeyFromString)),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const Burn = type({
|
|
98
|
+
account: PublicKeyFromString,
|
|
99
|
+
mint: PublicKeyFromString,
|
|
100
|
+
amount: union([string(), number()]),
|
|
101
|
+
authority: optional(PublicKeyFromString),
|
|
102
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
103
|
+
signers: optional(array(PublicKeyFromString)),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const CloseAccount = type({
|
|
107
|
+
account: PublicKeyFromString,
|
|
108
|
+
destination: PublicKeyFromString,
|
|
109
|
+
owner: optional(PublicKeyFromString),
|
|
110
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
111
|
+
signers: optional(array(PublicKeyFromString)),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const FreezeAccount = type({
|
|
115
|
+
account: PublicKeyFromString,
|
|
116
|
+
mint: PublicKeyFromString,
|
|
117
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
118
|
+
multisigFreezeAuthority: optional(PublicKeyFromString),
|
|
119
|
+
signers: optional(array(PublicKeyFromString)),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const ThawAccount = type({
|
|
123
|
+
account: PublicKeyFromString,
|
|
124
|
+
mint: PublicKeyFromString,
|
|
125
|
+
freezeAuthority: optional(PublicKeyFromString),
|
|
126
|
+
multisigFreezeAuthority: optional(PublicKeyFromString),
|
|
127
|
+
signers: optional(array(PublicKeyFromString)),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export type TransferChecked = Infer<typeof TransferChecked>;
|
|
131
|
+
export const TransferChecked = type({
|
|
132
|
+
source: PublicKeyFromString,
|
|
133
|
+
mint: PublicKeyFromString,
|
|
134
|
+
destination: PublicKeyFromString,
|
|
135
|
+
authority: optional(PublicKeyFromString),
|
|
136
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
137
|
+
signers: optional(array(PublicKeyFromString)),
|
|
138
|
+
tokenAmount: TokenAmountUi,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const ApproveChecked = type({
|
|
142
|
+
source: PublicKeyFromString,
|
|
143
|
+
mint: PublicKeyFromString,
|
|
144
|
+
delegate: PublicKeyFromString,
|
|
145
|
+
owner: optional(PublicKeyFromString),
|
|
146
|
+
multisigOwner: optional(PublicKeyFromString),
|
|
147
|
+
signers: optional(array(PublicKeyFromString)),
|
|
148
|
+
tokenAmount: TokenAmountUi,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const MintToChecked = type({
|
|
152
|
+
account: PublicKeyFromString,
|
|
153
|
+
mint: PublicKeyFromString,
|
|
154
|
+
mintAuthority: optional(PublicKeyFromString),
|
|
155
|
+
multisigMintAuthority: optional(PublicKeyFromString),
|
|
156
|
+
signers: optional(array(PublicKeyFromString)),
|
|
157
|
+
tokenAmount: TokenAmountUi,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const BurnChecked = type({
|
|
161
|
+
account: PublicKeyFromString,
|
|
162
|
+
mint: PublicKeyFromString,
|
|
163
|
+
authority: optional(PublicKeyFromString),
|
|
164
|
+
multisigAuthority: optional(PublicKeyFromString),
|
|
165
|
+
signers: optional(array(PublicKeyFromString)),
|
|
166
|
+
tokenAmount: TokenAmountUi,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export type TokenInstructionType = Infer<typeof TokenInstructionType>;
|
|
170
|
+
export const TokenInstructionType = enums([
|
|
171
|
+
"initializeMint",
|
|
172
|
+
"initializeAccount",
|
|
173
|
+
"initializeMultisig",
|
|
174
|
+
"transfer",
|
|
175
|
+
"approve",
|
|
176
|
+
"revoke",
|
|
177
|
+
"setAuthority",
|
|
178
|
+
"mintTo",
|
|
179
|
+
"burn",
|
|
180
|
+
"closeAccount",
|
|
181
|
+
"freezeAccount",
|
|
182
|
+
"thawAccount",
|
|
183
|
+
"transfer2",
|
|
184
|
+
"approve2",
|
|
185
|
+
"mintTo2",
|
|
186
|
+
"burn2",
|
|
187
|
+
"transferChecked",
|
|
188
|
+
"approveChecked",
|
|
189
|
+
"mintToChecked",
|
|
190
|
+
"burnChecked",
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
export const IX_STRUCTS = {
|
|
194
|
+
initializeMint: InitializeMint,
|
|
195
|
+
initializeAccount: InitializeAccount,
|
|
196
|
+
initializeMultisig: InitializeMultisig,
|
|
197
|
+
transfer: Transfer,
|
|
198
|
+
approve: Approve,
|
|
199
|
+
revoke: Revoke,
|
|
200
|
+
setAuthority: SetAuthority,
|
|
201
|
+
mintTo: MintTo,
|
|
202
|
+
burn: Burn,
|
|
203
|
+
closeAccount: CloseAccount,
|
|
204
|
+
freezeAccount: FreezeAccount,
|
|
205
|
+
thawAccount: ThawAccount,
|
|
206
|
+
transfer2: TransferChecked,
|
|
207
|
+
approve2: ApproveChecked,
|
|
208
|
+
mintTo2: MintToChecked,
|
|
209
|
+
burn2: BurnChecked,
|
|
210
|
+
transferChecked: TransferChecked,
|
|
211
|
+
approveChecked: ApproveChecked,
|
|
212
|
+
mintToChecked: MintToChecked,
|
|
213
|
+
burnChecked: BurnChecked,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const IX_TITLES = {
|
|
217
|
+
initializeMint: "Initialize Mint",
|
|
218
|
+
initializeAccount: "Initialize Account",
|
|
219
|
+
initializeMultisig: "Initialize Multisig",
|
|
220
|
+
transfer: "Transfer",
|
|
221
|
+
approve: "Approve",
|
|
222
|
+
revoke: "Revoke",
|
|
223
|
+
setAuthority: "Set Authority",
|
|
224
|
+
mintTo: "Mint To",
|
|
225
|
+
burn: "Burn",
|
|
226
|
+
closeAccount: "Close Account",
|
|
227
|
+
freezeAccount: "Freeze Account",
|
|
228
|
+
thawAccount: "Thaw Account",
|
|
229
|
+
transfer2: "Transfer (Checked)",
|
|
230
|
+
approve2: "Approve (Checked)",
|
|
231
|
+
mintTo2: "Mint To (Checked)",
|
|
232
|
+
burn2: "Burn (Checked)",
|
|
233
|
+
transferChecked: "Transfer (Checked)",
|
|
234
|
+
approveChecked: "Approve (Checked)",
|
|
235
|
+
mintToChecked: "Mint To (Checked)",
|
|
236
|
+
burnChecked: "Burn (Checked)",
|
|
237
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const PARSED_PROGRAMS = {
|
|
2
|
+
SPL_ASSOCIATED_TOKEN_ACCOUNT: "spl-associated-token-account",
|
|
3
|
+
BPF_LOADER: "bpf-loader",
|
|
4
|
+
BPF_UPGRADEABLE_LOADER: "bpf-upgradeable-loader",
|
|
5
|
+
SPL_MEMO: "spl-memo",
|
|
6
|
+
STAKE: "stake",
|
|
7
|
+
SYSTEM: "system",
|
|
8
|
+
SPL_TOKEN: "spl-token",
|
|
9
|
+
VOTE: "vote",
|
|
10
|
+
} as const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { parse, parseQuiet } from "./parser";
|