@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,251 @@
|
|
|
1
|
+
import Base from "./base";
|
|
2
|
+
import { InvalidAddress } from "@ledgerhq/errors";
|
|
3
|
+
import * as bjs from "bitcoinjs-lib";
|
|
4
|
+
import bs58checkBase from "bs58check/base";
|
|
5
|
+
import bs58check from "bs58check";
|
|
6
|
+
import createBlakeHash from "blake-hash";
|
|
7
|
+
import RIPEMD160 from "ripemd160";
|
|
8
|
+
import bs58 from "bs58";
|
|
9
|
+
import ecc from "tiny-secp256k1";
|
|
10
|
+
import createHash from "create-hash";
|
|
11
|
+
import createHmac from "create-hmac";
|
|
12
|
+
|
|
13
|
+
// the BIP32 class is inspired from https://github.com/bitcoinjs/bip32/blob/master/src/bip32.js
|
|
14
|
+
class BIP32 {
|
|
15
|
+
privateKey: any;
|
|
16
|
+
publicKey: any;
|
|
17
|
+
chainCode: any;
|
|
18
|
+
network: any;
|
|
19
|
+
depth: number;
|
|
20
|
+
index: number;
|
|
21
|
+
ParentFingerprint: number;
|
|
22
|
+
lowR: boolean;
|
|
23
|
+
constructor(
|
|
24
|
+
privateKey,
|
|
25
|
+
publicKey,
|
|
26
|
+
chainCode,
|
|
27
|
+
network,
|
|
28
|
+
depth = 0,
|
|
29
|
+
index = 0,
|
|
30
|
+
ParentFingerprint = 0x00000000
|
|
31
|
+
) {
|
|
32
|
+
this.privateKey = privateKey;
|
|
33
|
+
this.publicKey = publicKey;
|
|
34
|
+
this.chainCode = chainCode;
|
|
35
|
+
this.network = network;
|
|
36
|
+
this.depth = depth;
|
|
37
|
+
this.index = index;
|
|
38
|
+
this.ParentFingerprint = ParentFingerprint;
|
|
39
|
+
this.lowR = false;
|
|
40
|
+
}
|
|
41
|
+
pk() {
|
|
42
|
+
if (this.publicKey === undefined)
|
|
43
|
+
this.publicKey = ecc.pointFromScalar(this.privateKey, true);
|
|
44
|
+
return this.publicKey;
|
|
45
|
+
}
|
|
46
|
+
isNeutered() {
|
|
47
|
+
return this.privateKey === undefined;
|
|
48
|
+
}
|
|
49
|
+
neutered() {
|
|
50
|
+
return new BIP32(
|
|
51
|
+
undefined,
|
|
52
|
+
this.pk(),
|
|
53
|
+
this.chainCode,
|
|
54
|
+
this.network,
|
|
55
|
+
this.depth,
|
|
56
|
+
this.index,
|
|
57
|
+
this.ParentFingerprint
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
hmacSHA512(key, data) {
|
|
61
|
+
return createHmac("sha512", key).update(data).digest();
|
|
62
|
+
}
|
|
63
|
+
hash160(buffer) {
|
|
64
|
+
const sha256Hash = createHash("sha256").update(buffer).digest();
|
|
65
|
+
return createHash("rmd160").update(sha256Hash).digest();
|
|
66
|
+
}
|
|
67
|
+
fingerprint() {
|
|
68
|
+
return this.hash160(this.pk()).slice(0, 4);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
toBase58() {
|
|
72
|
+
const network = this.network;
|
|
73
|
+
const version = !this.isNeutered()
|
|
74
|
+
? network.bip32.private
|
|
75
|
+
: network.bip32.public;
|
|
76
|
+
const buffer = Buffer.allocUnsafe(78);
|
|
77
|
+
// 4 bytes: version bytes
|
|
78
|
+
buffer.writeUInt32BE(version, 0);
|
|
79
|
+
// 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
|
|
80
|
+
buffer.writeUInt8(this.depth, 4);
|
|
81
|
+
// 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
|
|
82
|
+
buffer.writeUInt32BE(this.ParentFingerprint, 5);
|
|
83
|
+
// 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
|
|
84
|
+
// This is encoded in big endian. (0x00000000 if master key)
|
|
85
|
+
buffer.writeUInt32BE(this.index, 9);
|
|
86
|
+
// 32 bytes: the chain code
|
|
87
|
+
this.chainCode.copy(buffer, 13);
|
|
88
|
+
// 33 bytes: the public key or private key data
|
|
89
|
+
if (!this.isNeutered()) {
|
|
90
|
+
// 0x00 + k for private keys
|
|
91
|
+
buffer.writeUInt8(0, 45);
|
|
92
|
+
this.privateKey.copy(buffer, 46);
|
|
93
|
+
// 33 bytes: the public key
|
|
94
|
+
} else {
|
|
95
|
+
// X9.62 encoding for public keys
|
|
96
|
+
this.pk().copy(buffer, 45);
|
|
97
|
+
}
|
|
98
|
+
return bs58check.encode(buffer);
|
|
99
|
+
}
|
|
100
|
+
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
|
|
101
|
+
derive(index) {
|
|
102
|
+
const isHardened = index >= 0x80000000;
|
|
103
|
+
const data = Buffer.allocUnsafe(37);
|
|
104
|
+
// Hardened child
|
|
105
|
+
if (isHardened) {
|
|
106
|
+
data[0] = 0x00;
|
|
107
|
+
this.privateKey.copy(data, 1);
|
|
108
|
+
data.writeUInt32BE(index, 33);
|
|
109
|
+
} else {
|
|
110
|
+
this.pk().copy(data, 0);
|
|
111
|
+
data.writeUInt32BE(index, 33);
|
|
112
|
+
}
|
|
113
|
+
const I = this.hmacSHA512(this.chainCode, data);
|
|
114
|
+
const IL = I.slice(0, 32);
|
|
115
|
+
const IR = I.slice(32);
|
|
116
|
+
// if parse256(IL) >= n, proceed with the next value for i
|
|
117
|
+
if (!ecc.isPrivate(IL)) return this.derive(index + 1);
|
|
118
|
+
// Private parent key -> private child key
|
|
119
|
+
let hd;
|
|
120
|
+
if (!this.isNeutered()) {
|
|
121
|
+
// ki = parse256(IL) + kpar (mod n)
|
|
122
|
+
const ki = ecc.privateAdd(this.privateKey, IL);
|
|
123
|
+
// In case ki == 0, proceed with the next value for i
|
|
124
|
+
if (ki == null) return this.derive(index + 1);
|
|
125
|
+
hd = new BIP32(
|
|
126
|
+
ki,
|
|
127
|
+
undefined,
|
|
128
|
+
IR,
|
|
129
|
+
this.network,
|
|
130
|
+
this.depth + 1,
|
|
131
|
+
index,
|
|
132
|
+
this.fingerprint().readUInt32BE(0)
|
|
133
|
+
);
|
|
134
|
+
} else {
|
|
135
|
+
// Ki = point(parse256(IL)) + Kpar
|
|
136
|
+
// = G*IL + Kpar
|
|
137
|
+
const Ki = ecc.pointAddScalar(this.pk(), IL, true);
|
|
138
|
+
// In case Ki is the point at infinity, proceed with the next value for i
|
|
139
|
+
if (Ki === null) return this.derive(index + 1);
|
|
140
|
+
hd = new BIP32(
|
|
141
|
+
undefined,
|
|
142
|
+
Ki,
|
|
143
|
+
IR,
|
|
144
|
+
this.network,
|
|
145
|
+
this.depth + 1,
|
|
146
|
+
index,
|
|
147
|
+
this.fingerprint().readUInt32BE(0)
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return hd;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
class Decred extends Base {
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
|
+
constructor({ network }: { network: any }) {
|
|
157
|
+
super({ network });
|
|
158
|
+
this.network.dustThreshold = 10000;
|
|
159
|
+
this.network.dustPolicy = "FIXED";
|
|
160
|
+
this.network.usesTimestampedTransaction = false;
|
|
161
|
+
}
|
|
162
|
+
static blake256(buffer: Buffer): Buffer {
|
|
163
|
+
let b = buffer;
|
|
164
|
+
if (buffer instanceof Uint8Array) {
|
|
165
|
+
b = Buffer.from(buffer);
|
|
166
|
+
}
|
|
167
|
+
return createBlakeHash("blake256").update(b).digest();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// refer to decred spec https://devdocs.decred.org/developer-guides/addresses/
|
|
171
|
+
static getAddressFromPk(publicKey: Buffer): string {
|
|
172
|
+
const prefix = Buffer.from("073f", "hex");
|
|
173
|
+
const pkhash = Buffer.concat([
|
|
174
|
+
prefix,
|
|
175
|
+
new RIPEMD160().update(Decred.blake256(publicKey)).digest(),
|
|
176
|
+
]);
|
|
177
|
+
const checksum = Decred._blake256x2(pkhash).slice(0, 4);
|
|
178
|
+
return bs58.encode(Buffer.concat([pkhash, checksum]));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static readonly _blake256x2 = (buffer: Buffer): Buffer =>
|
|
182
|
+
Decred.blake256(Decred.blake256(buffer));
|
|
183
|
+
static readonly bs58check = bs58checkBase(Decred._blake256x2);
|
|
184
|
+
toOutputScript(address: string): Buffer {
|
|
185
|
+
if (!this.validateAddress(address)) {
|
|
186
|
+
throw new InvalidAddress();
|
|
187
|
+
}
|
|
188
|
+
const decodeBase58 = Decred.bs58check.decode(address, Decred._blake256x2);
|
|
189
|
+
const prefix = address.toLocaleUpperCase().substring(0, 2);
|
|
190
|
+
if (prefix === "DC") {
|
|
191
|
+
return bjs.payments.p2sh({ hash: decodeBase58.slice(2) })
|
|
192
|
+
.output as Buffer;
|
|
193
|
+
} else if (prefix === "DE" || prefix === "DS") {
|
|
194
|
+
return bjs.payments.p2pkh({ hash: decodeBase58.slice(2) })
|
|
195
|
+
.output as Buffer;
|
|
196
|
+
}
|
|
197
|
+
throw new InvalidAddress();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// eslint-disable-next-line class-methods-use-this
|
|
201
|
+
validateAddress(address: string): boolean {
|
|
202
|
+
if (address.length < 25 || address.length > 36) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
Decred.bs58check.decode(address, Decred._blake256x2);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// get address given an address type
|
|
214
|
+
getAddress(
|
|
215
|
+
derivationMode: string,
|
|
216
|
+
xpub: string,
|
|
217
|
+
account: number,
|
|
218
|
+
index: number
|
|
219
|
+
): string {
|
|
220
|
+
if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
|
|
221
|
+
return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
|
|
222
|
+
}
|
|
223
|
+
let buffer: Buffer;
|
|
224
|
+
try {
|
|
225
|
+
buffer = Decred.bs58check.decode(xpub);
|
|
226
|
+
} catch {
|
|
227
|
+
buffer = bs58check.decode(xpub);
|
|
228
|
+
}
|
|
229
|
+
const depth = buffer[4];
|
|
230
|
+
const parentFingerprint = buffer.readUInt32BE(5);
|
|
231
|
+
const i = buffer.readUInt32BE(9);
|
|
232
|
+
const chainCode = buffer.slice(13, 45);
|
|
233
|
+
const X = buffer.slice(45, 78);
|
|
234
|
+
const hd = new BIP32(
|
|
235
|
+
undefined,
|
|
236
|
+
X,
|
|
237
|
+
chainCode,
|
|
238
|
+
this.network,
|
|
239
|
+
depth,
|
|
240
|
+
i,
|
|
241
|
+
parentFingerprint
|
|
242
|
+
);
|
|
243
|
+
const publicKey = hd.derive(account).derive(index).pk();
|
|
244
|
+
const address = Decred.getAddressFromPk(publicKey);
|
|
245
|
+
Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
|
|
246
|
+
address;
|
|
247
|
+
return address;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export default Decred;
|
|
@@ -98,6 +98,11 @@ export default function cryptoFactory(currency: Currency) {
|
|
|
98
98
|
res = new crypto.Bitcoin({ network });
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
|
+
case "decred": {
|
|
102
|
+
const network = coininfo.decred.main.toBitcoinJS();
|
|
103
|
+
res = new crypto.Decred({ network });
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
101
106
|
default: {
|
|
102
107
|
throw new Error(`Currency ${currency} doesn't exist!`);
|
|
103
108
|
}
|
|
@@ -59,16 +59,26 @@ class Litecoin extends Base implements ICrypto {
|
|
|
59
59
|
account: number,
|
|
60
60
|
index: number
|
|
61
61
|
): string {
|
|
62
|
+
if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
|
|
63
|
+
return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
|
|
64
|
+
}
|
|
65
|
+
let address: string;
|
|
62
66
|
switch (derivationMode) {
|
|
63
67
|
case DerivationModes.LEGACY:
|
|
64
|
-
|
|
68
|
+
address = this.getLegacyAddress(xpub, account, index);
|
|
69
|
+
break;
|
|
65
70
|
case DerivationModes.SEGWIT:
|
|
66
|
-
|
|
71
|
+
address = this.getSegWitAddress(xpub, account, index);
|
|
72
|
+
break;
|
|
67
73
|
case DerivationModes.NATIVE_SEGWIT:
|
|
68
|
-
|
|
74
|
+
address = this.getNativeSegWitAddress(xpub, account, index);
|
|
75
|
+
break;
|
|
69
76
|
default:
|
|
70
77
|
throw new Error("Should not be reachable");
|
|
71
78
|
}
|
|
79
|
+
Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
|
|
80
|
+
address;
|
|
81
|
+
return address;
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
// infer address type from its syntax
|
|
@@ -9,6 +9,7 @@ import coininfo from "coininfo";
|
|
|
9
9
|
import { InvalidAddress } from "@ledgerhq/errors";
|
|
10
10
|
import { DerivationModes } from "../types";
|
|
11
11
|
import { ICrypto } from "./types";
|
|
12
|
+
import Base from "./base";
|
|
12
13
|
|
|
13
14
|
class ZCash implements ICrypto {
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -52,7 +53,13 @@ class ZCash implements ICrypto {
|
|
|
52
53
|
account: number,
|
|
53
54
|
index: number
|
|
54
55
|
): string {
|
|
55
|
-
|
|
56
|
+
if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
|
|
57
|
+
return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
|
|
58
|
+
}
|
|
59
|
+
const address = this.getLegacyAddress(xpub, account, index);
|
|
60
|
+
Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
|
|
61
|
+
address;
|
|
62
|
+
return address;
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -9,6 +9,7 @@ import coininfo from "coininfo";
|
|
|
9
9
|
import { InvalidAddress } from "@ledgerhq/errors";
|
|
10
10
|
import { DerivationModes } from "../types";
|
|
11
11
|
import { ICrypto } from "./types";
|
|
12
|
+
import Base from "./base";
|
|
12
13
|
|
|
13
14
|
class Zen implements ICrypto {
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -72,7 +73,13 @@ class Zen implements ICrypto {
|
|
|
72
73
|
account: number,
|
|
73
74
|
index: number
|
|
74
75
|
): string {
|
|
75
|
-
|
|
76
|
+
if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
|
|
77
|
+
return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
|
|
78
|
+
}
|
|
79
|
+
const address = this.getLegacyAddress(xpub, account, index);
|
|
80
|
+
Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
|
|
81
|
+
address;
|
|
82
|
+
return address;
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -137,7 +137,12 @@ function outputWeight(derivationMode: string): number {
|
|
|
137
137
|
|
|
138
138
|
export function outputSize(currency: ICrypto, addr: string): number {
|
|
139
139
|
const scriptLen = currency.toOutputScript(addr).length;
|
|
140
|
-
|
|
140
|
+
let size = 1 + 8 + scriptLen;
|
|
141
|
+
// More bytes for decred, refer to https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp#L478
|
|
142
|
+
if (currency.network.name === "Decred") {
|
|
143
|
+
size += 8;
|
|
144
|
+
}
|
|
145
|
+
return size;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
/**
|
|
@@ -212,6 +212,8 @@ class BitcoinLikeWallet {
|
|
|
212
212
|
lockTime?: number;
|
|
213
213
|
sigHashType?: number;
|
|
214
214
|
segwit?: boolean;
|
|
215
|
+
hasTimestamp?: boolean;
|
|
216
|
+
initialTimestamp?: number;
|
|
215
217
|
additionals?: Array<string>;
|
|
216
218
|
expiryHeight?: Buffer;
|
|
217
219
|
hasExtraData?: boolean;
|
|
@@ -227,6 +229,8 @@ class BitcoinLikeWallet {
|
|
|
227
229
|
btc,
|
|
228
230
|
fromAccount,
|
|
229
231
|
txInfo,
|
|
232
|
+
hasTimestamp,
|
|
233
|
+
initialTimestamp,
|
|
230
234
|
additionals,
|
|
231
235
|
hasExtraData,
|
|
232
236
|
onDeviceSignatureRequested,
|
|
@@ -234,15 +238,24 @@ class BitcoinLikeWallet {
|
|
|
234
238
|
onDeviceStreaming,
|
|
235
239
|
} = params;
|
|
236
240
|
|
|
237
|
-
|
|
241
|
+
let length = txInfo.outputs.reduce((sum, output) => {
|
|
238
242
|
return sum + 8 + output.script.length + 1;
|
|
239
243
|
}, 1);
|
|
244
|
+
// refer to https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp#L478
|
|
245
|
+
// Decred has a witness and an expiry height
|
|
246
|
+
if (additionals && additionals.includes("decred")) {
|
|
247
|
+
length += 2 * txInfo.outputs.length;
|
|
248
|
+
}
|
|
240
249
|
const buffer = Buffer.allocUnsafe(length);
|
|
241
250
|
const bufferWriter = new BufferWriter(buffer, 0);
|
|
242
251
|
bufferWriter.writeVarInt(txInfo.outputs.length);
|
|
243
252
|
txInfo.outputs.forEach((txOut) => {
|
|
244
253
|
// xpub splits output into smaller outputs than SAFE_MAX_INT anyway
|
|
245
254
|
bufferWriter.writeUInt64(txOut.value.toNumber());
|
|
255
|
+
if (additionals && additionals.includes("decred")) {
|
|
256
|
+
bufferWriter.writeVarInt(0);
|
|
257
|
+
bufferWriter.writeVarInt(0);
|
|
258
|
+
}
|
|
246
259
|
bufferWriter.writeVarSlice(txOut.script);
|
|
247
260
|
});
|
|
248
261
|
const outputScriptHex = buffer.toString("hex");
|
|
@@ -260,7 +273,7 @@ class BitcoinLikeWallet {
|
|
|
260
273
|
log("hw", `splitTransaction`, {
|
|
261
274
|
transactionHex: i.txHex,
|
|
262
275
|
isSegwitSupported: true,
|
|
263
|
-
hasTimestamp
|
|
276
|
+
hasTimestamp,
|
|
264
277
|
hasExtraData,
|
|
265
278
|
additionals,
|
|
266
279
|
});
|
|
@@ -268,7 +281,7 @@ class BitcoinLikeWallet {
|
|
|
268
281
|
btc.splitTransaction(
|
|
269
282
|
i.txHex,
|
|
270
283
|
true,
|
|
271
|
-
|
|
284
|
+
hasTimestamp,
|
|
272
285
|
hasExtraData,
|
|
273
286
|
additionals
|
|
274
287
|
),
|
|
@@ -287,7 +300,7 @@ class BitcoinLikeWallet {
|
|
|
287
300
|
...(params.lockTime && { lockTime: params.lockTime }),
|
|
288
301
|
...(params.sigHashType && { sigHashType: params.sigHashType }),
|
|
289
302
|
...(params.segwit && { segwit: params.segwit }),
|
|
290
|
-
|
|
303
|
+
initialTimestamp,
|
|
291
304
|
...(params.expiryHeight && { expiryHeight: params.expiryHeight }),
|
|
292
305
|
...(txInfo.outputs[lastOutputIndex]?.isChange && {
|
|
293
306
|
changePath: `${fromAccount.params.path}/${fromAccount.params.index}'/${txInfo.changeAddress.account}/${txInfo.changeAddress.index}`,
|
|
@@ -302,7 +315,7 @@ class BitcoinLikeWallet {
|
|
|
302
315
|
...(params.lockTime && { lockTime: params.lockTime }),
|
|
303
316
|
...(params.sigHashType && { sigHashType: params.sigHashType }),
|
|
304
317
|
...(params.segwit && { segwit: params.segwit }),
|
|
305
|
-
|
|
318
|
+
initialTimestamp,
|
|
306
319
|
...(params.expiryHeight && { expiryHeight: params.expiryHeight }),
|
|
307
320
|
...(txInfo.outputs[lastOutputIndex]?.isChange && {
|
|
308
321
|
changePath: `${fromAccount.params.path}/${fromAccount.params.index}'/${txInfo.changeAddress.account}/${txInfo.changeAddress.index}`,
|
|
@@ -167,7 +167,10 @@ export const getAccountShape: GetAccountShape = async (
|
|
|
167
167
|
const operations = mergeOps(initialStableOperations, newOps);
|
|
168
168
|
|
|
169
169
|
const nfts = isNFTActive(currency)
|
|
170
|
-
? mergeNfts(
|
|
170
|
+
? mergeNfts(
|
|
171
|
+
initialAccount?.nfts || [],
|
|
172
|
+
nftsFromOperations(operations).filter((n) => n.amount.gt(0))
|
|
173
|
+
)
|
|
171
174
|
: undefined;
|
|
172
175
|
|
|
173
176
|
const accountShape: Partial<Account> = {
|
|
@@ -441,7 +444,7 @@ const txToOps =
|
|
|
441
444
|
if (receiving) {
|
|
442
445
|
const type = "NFT_IN";
|
|
443
446
|
all.push({
|
|
444
|
-
id: `${nftId}-${hash}-${type}-i${i}`,
|
|
447
|
+
id: `${nftId}-${hash}-${type}-i${i}_${j}`,
|
|
445
448
|
senders: [sender],
|
|
446
449
|
recipients: [receiver],
|
|
447
450
|
contract,
|
|
@@ -275,10 +275,10 @@ const fetchStakingProgress =
|
|
|
275
275
|
* @returns {SidecarTransactionMaterial}
|
|
276
276
|
*/
|
|
277
277
|
const fetchTransactionMaterial = async (
|
|
278
|
+
// By default we don't want any metadata.
|
|
278
279
|
withMetadata = false
|
|
279
280
|
): Promise<SidecarTransactionMaterial> => {
|
|
280
|
-
|
|
281
|
-
const params = withMetadata ? "" : "?noMeta=true";
|
|
281
|
+
const params = withMetadata ? "?metadata=scale" : "?noMeta=true";
|
|
282
282
|
const {
|
|
283
283
|
data,
|
|
284
284
|
}: {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { makeLRUCache } from "../../../cache";
|
|
2
|
+
import { ChainAPI } from "./chain";
|
|
3
|
+
import hash from "object-hash";
|
|
4
|
+
|
|
5
|
+
export function seconds(num: number, max = 100): Record<string, any> {
|
|
6
|
+
return {
|
|
7
|
+
max,
|
|
8
|
+
maxAge: num * 1000,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function minutes(num: number, max = 100): Record<string, any> {
|
|
13
|
+
return seconds(num * 60, max);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const cacheKeyAddress = (address: string) => address;
|
|
17
|
+
const cacheKeyEmpty = () => "" as const;
|
|
18
|
+
const cacheKeyAssocTokenAccAddress = (owner: string, mint: string) =>
|
|
19
|
+
`${owner}:${mint}`;
|
|
20
|
+
|
|
21
|
+
const cacheKeyTransactions = (signatures: string[]) =>
|
|
22
|
+
hash([...signatures].sort());
|
|
23
|
+
|
|
24
|
+
const cacheKeyByArgs = (...args: any[]) => hash(args);
|
|
25
|
+
|
|
26
|
+
export function cached(api: ChainAPI): ChainAPI {
|
|
27
|
+
return {
|
|
28
|
+
findAssocTokenAccAddress: makeLRUCache(
|
|
29
|
+
api.findAssocTokenAccAddress,
|
|
30
|
+
cacheKeyAssocTokenAccAddress,
|
|
31
|
+
minutes(1000)
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
getAccountInfo: makeLRUCache(
|
|
35
|
+
api.getAccountInfo,
|
|
36
|
+
cacheKeyAddress,
|
|
37
|
+
seconds(30)
|
|
38
|
+
),
|
|
39
|
+
|
|
40
|
+
getAssocTokenAccMinNativeBalance: makeLRUCache(
|
|
41
|
+
api.getAssocTokenAccMinNativeBalance,
|
|
42
|
+
cacheKeyEmpty,
|
|
43
|
+
minutes(5)
|
|
44
|
+
),
|
|
45
|
+
|
|
46
|
+
getBalance: makeLRUCache(api.getBalance, cacheKeyAddress, seconds(30)),
|
|
47
|
+
|
|
48
|
+
getBalanceAndContext: makeLRUCache(
|
|
49
|
+
api.getBalanceAndContext,
|
|
50
|
+
cacheKeyAddress,
|
|
51
|
+
seconds(30)
|
|
52
|
+
),
|
|
53
|
+
|
|
54
|
+
getParsedConfirmedTransactions: makeLRUCache(
|
|
55
|
+
api.getParsedConfirmedTransactions,
|
|
56
|
+
cacheKeyTransactions,
|
|
57
|
+
seconds(30)
|
|
58
|
+
),
|
|
59
|
+
|
|
60
|
+
getParsedTokenAccountsByOwner: makeLRUCache(
|
|
61
|
+
api.getParsedTokenAccountsByOwner,
|
|
62
|
+
cacheKeyAddress,
|
|
63
|
+
minutes(1)
|
|
64
|
+
),
|
|
65
|
+
|
|
66
|
+
getRecentBlockhash: makeLRUCache(
|
|
67
|
+
api.getRecentBlockhash,
|
|
68
|
+
cacheKeyEmpty,
|
|
69
|
+
seconds(5)
|
|
70
|
+
),
|
|
71
|
+
|
|
72
|
+
getTxFeeCalculator: makeLRUCache(
|
|
73
|
+
api.getTxFeeCalculator,
|
|
74
|
+
cacheKeyEmpty,
|
|
75
|
+
minutes(5)
|
|
76
|
+
),
|
|
77
|
+
|
|
78
|
+
getSignaturesForAddress: makeLRUCache(
|
|
79
|
+
api.getSignaturesForAddress,
|
|
80
|
+
cacheKeyByArgs,
|
|
81
|
+
seconds(30)
|
|
82
|
+
),
|
|
83
|
+
|
|
84
|
+
// do not cache
|
|
85
|
+
sendRawTransaction: api.sendRawTransaction,
|
|
86
|
+
|
|
87
|
+
config: api.config,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tryParseAsTokenAccount, parseTokenAccountInfo } from "./parser";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ParsedAccountData } from "@solana/web3.js";
|
|
2
|
+
import { create } from "superstruct";
|
|
3
|
+
import { ParsedInfo } from "../validators";
|
|
4
|
+
import { TokenAccount, TokenAccountInfo } from "./token";
|
|
5
|
+
|
|
6
|
+
export function parseTokenAccountInfo(info: unknown): TokenAccountInfo {
|
|
7
|
+
return create(info, TokenAccountInfo);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function tryParseAsTokenAccount(
|
|
11
|
+
data: ParsedAccountData
|
|
12
|
+
): TokenAccountInfo | undefined | Error {
|
|
13
|
+
const routine = () => {
|
|
14
|
+
const info = create(data.parsed, ParsedInfo);
|
|
15
|
+
|
|
16
|
+
if (data.program === "spl-token") {
|
|
17
|
+
const parsed = create(info, TokenAccount);
|
|
18
|
+
if (parsed.type === "account") {
|
|
19
|
+
return parseTokenAccountInfo(parsed.info);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return onThrowReturnError(routine);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function onThrowReturnError<R>(fn: () => R) {
|
|
30
|
+
try {
|
|
31
|
+
return fn();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return e instanceof Error ? e : new Error(JSON.stringify(e));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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([
|
|
9
|
+
"uninitialized",
|
|
10
|
+
"initialized",
|
|
11
|
+
"delegated",
|
|
12
|
+
"rewardsPool",
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
export type StakeMeta = Infer<typeof StakeMeta>;
|
|
16
|
+
export const StakeMeta = type({
|
|
17
|
+
rentExemptReserve: BigNumFromString,
|
|
18
|
+
authorized: type({
|
|
19
|
+
staker: PublicKeyFromString,
|
|
20
|
+
withdrawer: PublicKeyFromString,
|
|
21
|
+
}),
|
|
22
|
+
lockup: type({
|
|
23
|
+
unixTimestamp: number(),
|
|
24
|
+
epoch: number(),
|
|
25
|
+
custodian: PublicKeyFromString,
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type StakeAccountInfo = Infer<typeof StakeAccountInfo>;
|
|
30
|
+
export const StakeAccountInfo = type({
|
|
31
|
+
meta: StakeMeta,
|
|
32
|
+
stake: nullable(
|
|
33
|
+
type({
|
|
34
|
+
delegation: type({
|
|
35
|
+
voter: PublicKeyFromString,
|
|
36
|
+
stake: BigNumFromString,
|
|
37
|
+
activationEpoch: BigNumFromString,
|
|
38
|
+
deactivationEpoch: BigNumFromString,
|
|
39
|
+
warmupCooldownRate: number(),
|
|
40
|
+
}),
|
|
41
|
+
creditsObserved: number(),
|
|
42
|
+
})
|
|
43
|
+
),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type StakeAccount = Infer<typeof StakeAccount>;
|
|
47
|
+
export const StakeAccount = type({
|
|
48
|
+
type: StakeAccountType,
|
|
49
|
+
info: StakeAccountInfo,
|
|
50
|
+
});
|