@ledgerhq/coin-solana 0.7.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +16 -0
- package/CHANGELOG.md +27 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/api/cached.d.ts +3 -0
- package/lib/api/cached.d.ts.map +1 -0
- package/lib/api/cached.js +41 -0
- package/lib/api/cached.js.map +1 -0
- package/lib/api/chain/account/index.d.ts +2 -0
- package/lib/api/chain/account/index.d.ts.map +1 -0
- package/lib/api/chain/account/index.js +8 -0
- package/lib/api/chain/account/index.js.map +1 -0
- package/lib/api/chain/account/parser.d.ts +10 -0
- package/lib/api/chain/account/parser.d.ts.map +1 -0
- package/lib/api/chain/account/parser.js +56 -0
- package/lib/api/chain/account/parser.js.map +1 -0
- package/lib/api/chain/account/stake.d.ts +237 -0
- package/lib/api/chain/account/stake.d.ts.map +1 -0
- package/lib/api/chain/account/stake.js +38 -0
- package/lib/api/chain/account/stake.js.map +1 -0
- package/lib/api/chain/account/token.d.ts +116 -0
- package/lib/api/chain/account/token.d.ts.map +1 -0
- package/lib/api/chain/account/token.js +42 -0
- package/lib/api/chain/account/token.js.map +1 -0
- package/lib/api/chain/account/vote.d.ts +252 -0
- package/lib/api/chain/account/vote.d.ts.map +1 -0
- package/lib/api/chain/account/vote.js +44 -0
- package/lib/api/chain/account/vote.js.map +1 -0
- package/lib/api/chain/index.d.ts +29 -0
- package/lib/api/chain/index.d.ts.map +1 -0
- package/lib/api/chain/index.js +96 -0
- package/lib/api/chain/index.js.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/index.js +21 -0
- package/lib/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/associated-token-account/types.js +19 -0
- package/lib/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/memo/index.js +14 -0
- package/lib/api/chain/instruction/memo/index.js.map +1 -0
- package/lib/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/memo/types.js +16 -0
- package/lib/api/chain/instruction/memo/types.js.map +1 -0
- package/lib/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/stake/index.js +20 -0
- package/lib/api/chain/instruction/stake/index.js.map +1 -0
- package/lib/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/stake/types.js +80 -0
- package/lib/api/chain/instruction/stake/types.js.map +1 -0
- package/lib/api/chain/instruction/system/index.d.ts +15 -0
- package/lib/api/chain/instruction/system/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/system/index.js +20 -0
- package/lib/api/chain/instruction/system/index.js.map +1 -0
- package/lib/api/chain/instruction/system/types.d.ts +298 -0
- package/lib/api/chain/instruction/system/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/system/types.js +117 -0
- package/lib/api/chain/instruction/system/types.js.map +1 -0
- package/lib/api/chain/instruction/token/index.d.ts +15 -0
- package/lib/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib/api/chain/instruction/token/index.js +20 -0
- package/lib/api/chain/instruction/token/index.js.map +1 -0
- package/lib/api/chain/instruction/token/types.d.ts +497 -0
- package/lib/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib/api/chain/instruction/token/types.js +200 -0
- package/lib/api/chain/instruction/token/types.js.map +1 -0
- package/lib/api/chain/program/constants.d.ts +11 -0
- package/lib/api/chain/program/constants.d.ts.map +1 -0
- package/lib/api/chain/program/constants.js +14 -0
- package/lib/api/chain/program/constants.js.map +1 -0
- package/lib/api/chain/program/index.d.ts +2 -0
- package/lib/api/chain/program/index.d.ts.map +1 -0
- package/lib/api/chain/program/index.js +7 -0
- package/lib/api/chain/program/index.js.map +1 -0
- package/lib/api/chain/program/parser.d.ts +35 -0
- package/lib/api/chain/program/parser.d.ts.map +1 -0
- package/lib/api/chain/program/parser.js +66 -0
- package/lib/api/chain/program/parser.js.map +1 -0
- package/lib/api/chain/validators/bignum.d.ts +3 -0
- package/lib/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib/api/chain/validators/bignum.js +11 -0
- package/lib/api/chain/validators/bignum.js.map +1 -0
- package/lib/api/chain/validators/index.d.ts +10 -0
- package/lib/api/chain/validators/index.d.ts.map +1 -0
- package/lib/api/chain/validators/index.js +10 -0
- package/lib/api/chain/validators/index.js.map +1 -0
- package/lib/api/chain/validators/pubkey.d.ts +3 -0
- package/lib/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib/api/chain/validators/pubkey.js +7 -0
- package/lib/api/chain/validators/pubkey.js.map +1 -0
- package/lib/api/chain/web3.d.ts +43 -0
- package/lib/api/chain/web3.d.ts.map +1 -0
- package/lib/api/chain/web3.js +272 -0
- package/lib/api/chain/web3.js.map +1 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +25 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/logged.d.ts +3 -0
- package/lib/api/logged.d.ts.map +1 -0
- package/lib/api/logged.js +69 -0
- package/lib/api/logged.js.map +1 -0
- package/lib/api/queued.d.ts +3 -0
- package/lib/api/queued.d.ts.map +1 -0
- package/lib/api/queued.js +27 -0
- package/lib/api/queued.js.map +1 -0
- package/lib/api/traced.d.ts +3 -0
- package/lib/api/traced.d.ts.map +1 -0
- package/lib/api/traced.js +80 -0
- package/lib/api/traced.js.map +1 -0
- package/lib/bridge/bridge.d.ts +15 -0
- package/lib/bridge/bridge.d.ts.map +1 -0
- package/lib/bridge/bridge.js +134 -0
- package/lib/bridge/bridge.js.map +1 -0
- package/lib/bridge/js.d.ts +7 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +28 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +988 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +7 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +37 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/buildTransaction.d.ts +5 -0
- package/lib/buildTransaction.d.ts.map +1 -0
- package/lib/buildTransaction.js +67 -0
- package/lib/buildTransaction.js.map +1 -0
- package/lib/cli-transaction.d.ts +19 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +196 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/createTransaction.d.ts +5 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +19 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib/datasets/solana.scanAccounts.1.js +12 -0
- package/lib/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +10 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +228 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +61 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +25 -0
- package/lib/errors.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +11 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +63 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +5 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +73 -0
- package/lib/getTransactionStatus.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +28 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/logic.d.ts +29 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +102 -0
- package/lib/logic.js.map +1 -0
- package/lib/preload-data.d.ts +7 -0
- package/lib/preload-data.d.ts.map +1 -0
- package/lib/preload-data.js +45 -0
- package/lib/preload-data.js.map +1 -0
- package/lib/preload.d.ts +7 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +67 -0
- package/lib/preload.js.map +1 -0
- package/lib/preload.test.d.ts +2 -0
- package/lib/preload.test.d.ts.map +1 -0
- package/lib/preload.test.js +9 -0
- package/lib/preload.test.js.map +1 -0
- package/lib/prepareTransaction.d.ts +5 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +500 -0
- package/lib/prepareTransaction.js.map +1 -0
- package/lib/serialization.d.ts +9 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +69 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signOperation.d.ts +7 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +153 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +11 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +409 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +8 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +217 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronization.d.ts +5 -0
- package/lib/synchronization.d.ts.map +1 -0
- package/lib/synchronization.js +463 -0
- package/lib/synchronization.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +154 -0
- package/lib/transaction.js.map +1 -0
- package/lib/tx-fees.d.ts +4 -0
- package/lib/tx-fees.d.ts.map +1 -0
- package/lib/tx-fees.js +167 -0
- package/lib/tx-fees.js.map +1 -0
- package/lib/types.d.ts +225 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +24 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +172 -0
- package/lib/utils.js.map +1 -0
- package/lib/validator-app/index.d.ts +22 -0
- package/lib/validator-app/index.d.ts.map +1 -0
- package/lib/validator-app/index.js +62 -0
- package/lib/validator-app/index.js.map +1 -0
- package/lib-es/api/cached.d.ts +3 -0
- package/lib-es/api/cached.d.ts.map +1 -0
- package/lib-es/api/cached.js +34 -0
- package/lib-es/api/cached.js.map +1 -0
- package/lib-es/api/chain/account/index.d.ts +2 -0
- package/lib-es/api/chain/account/index.d.ts.map +1 -0
- package/lib-es/api/chain/account/index.js +2 -0
- package/lib-es/api/chain/account/index.js.map +1 -0
- package/lib-es/api/chain/account/parser.d.ts +10 -0
- package/lib-es/api/chain/account/parser.d.ts.map +1 -0
- package/lib-es/api/chain/account/parser.js +48 -0
- package/lib-es/api/chain/account/parser.js.map +1 -0
- package/lib-es/api/chain/account/stake.d.ts +237 -0
- package/lib-es/api/chain/account/stake.d.ts.map +1 -0
- package/lib-es/api/chain/account/stake.js +35 -0
- package/lib-es/api/chain/account/stake.js.map +1 -0
- package/lib-es/api/chain/account/token.d.ts +116 -0
- package/lib-es/api/chain/account/token.d.ts.map +1 -0
- package/lib-es/api/chain/account/token.js +39 -0
- package/lib-es/api/chain/account/token.js.map +1 -0
- package/lib-es/api/chain/account/vote.d.ts +252 -0
- package/lib-es/api/chain/account/vote.d.ts.map +1 -0
- package/lib-es/api/chain/account/vote.js +41 -0
- package/lib-es/api/chain/account/vote.js.map +1 -0
- package/lib-es/api/chain/index.d.ts +29 -0
- package/lib-es/api/chain/index.d.ts.map +1 -0
- package/lib-es/api/chain/index.js +92 -0
- package/lib-es/api/chain/index.js.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.js +17 -0
- package/lib-es/api/chain/instruction/associated-token-account/index.js.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.d.ts +30 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.js +16 -0
- package/lib-es/api/chain/instruction/associated-token-account/types.js.map +1 -0
- package/lib-es/api/chain/instruction/memo/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/memo/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/memo/index.js +10 -0
- package/lib-es/api/chain/instruction/memo/index.js.map +1 -0
- package/lib-es/api/chain/instruction/memo/types.d.ts +21 -0
- package/lib-es/api/chain/instruction/memo/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/memo/types.js +13 -0
- package/lib-es/api/chain/instruction/memo/types.js.map +1 -0
- package/lib-es/api/chain/instruction/stake/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/stake/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/stake/index.js +16 -0
- package/lib-es/api/chain/instruction/stake/index.js.map +1 -0
- package/lib-es/api/chain/instruction/stake/types.d.ts +215 -0
- package/lib-es/api/chain/instruction/stake/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/stake/types.js +77 -0
- package/lib-es/api/chain/instruction/stake/types.js.map +1 -0
- package/lib-es/api/chain/instruction/system/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/system/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/system/index.js +16 -0
- package/lib-es/api/chain/instruction/system/index.js.map +1 -0
- package/lib-es/api/chain/instruction/system/types.d.ts +298 -0
- package/lib-es/api/chain/instruction/system/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/system/types.js +114 -0
- package/lib-es/api/chain/instruction/system/types.js.map +1 -0
- package/lib-es/api/chain/instruction/token/index.d.ts +15 -0
- package/lib-es/api/chain/instruction/token/index.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/token/index.js +16 -0
- package/lib-es/api/chain/instruction/token/index.js.map +1 -0
- package/lib-es/api/chain/instruction/token/types.d.ts +497 -0
- package/lib-es/api/chain/instruction/token/types.d.ts.map +1 -0
- package/lib-es/api/chain/instruction/token/types.js +197 -0
- package/lib-es/api/chain/instruction/token/types.js.map +1 -0
- package/lib-es/api/chain/program/constants.d.ts +11 -0
- package/lib-es/api/chain/program/constants.d.ts.map +1 -0
- package/lib-es/api/chain/program/constants.js +11 -0
- package/lib-es/api/chain/program/constants.js.map +1 -0
- package/lib-es/api/chain/program/index.d.ts +2 -0
- package/lib-es/api/chain/program/index.d.ts.map +1 -0
- package/lib-es/api/chain/program/index.js +2 -0
- package/lib-es/api/chain/program/index.js.map +1 -0
- package/lib-es/api/chain/program/parser.d.ts +35 -0
- package/lib-es/api/chain/program/parser.d.ts.map +1 -0
- package/lib-es/api/chain/program/parser.js +61 -0
- package/lib-es/api/chain/program/parser.js.map +1 -0
- package/lib-es/api/chain/validators/bignum.d.ts +3 -0
- package/lib-es/api/chain/validators/bignum.d.ts.map +1 -0
- package/lib-es/api/chain/validators/bignum.js +8 -0
- package/lib-es/api/chain/validators/bignum.js.map +1 -0
- package/lib-es/api/chain/validators/index.d.ts +10 -0
- package/lib-es/api/chain/validators/index.d.ts.map +1 -0
- package/lib-es/api/chain/validators/index.js +7 -0
- package/lib-es/api/chain/validators/index.js.map +1 -0
- package/lib-es/api/chain/validators/pubkey.d.ts +3 -0
- package/lib-es/api/chain/validators/pubkey.d.ts.map +1 -0
- package/lib-es/api/chain/validators/pubkey.js +4 -0
- package/lib-es/api/chain/validators/pubkey.js.map +1 -0
- package/lib-es/api/chain/web3.d.ts +43 -0
- package/lib-es/api/chain/web3.d.ts.map +1 -0
- package/lib-es/api/chain/web3.js +249 -0
- package/lib-es/api/chain/web3.js.map +1 -0
- package/lib-es/api/index.d.ts +5 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +5 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/logged.d.ts +3 -0
- package/lib-es/api/logged.d.ts.map +1 -0
- package/lib-es/api/logged.js +65 -0
- package/lib-es/api/logged.js.map +1 -0
- package/lib-es/api/queued.d.ts +3 -0
- package/lib-es/api/queued.d.ts.map +1 -0
- package/lib-es/api/queued.js +23 -0
- package/lib-es/api/queued.js.map +1 -0
- package/lib-es/api/traced.d.ts +3 -0
- package/lib-es/api/traced.d.ts.map +1 -0
- package/lib-es/api/traced.js +76 -0
- package/lib-es/api/traced.js.map +1 -0
- package/lib-es/bridge/bridge.d.ts +15 -0
- package/lib-es/bridge/bridge.d.ts.map +1 -0
- package/lib-es/bridge/bridge.js +127 -0
- package/lib-es/bridge/bridge.js.map +1 -0
- package/lib-es/bridge/js.d.ts +7 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +24 -0
- package/lib-es/bridge/js.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +986 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +7 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +33 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/buildTransaction.d.ts +5 -0
- package/lib-es/buildTransaction.d.ts.map +1 -0
- package/lib-es/buildTransaction.js +63 -0
- package/lib-es/buildTransaction.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +19 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +190 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/createTransaction.d.ts +5 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +15 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/datasets/solana.scanAccounts.1.d.ts +6 -0
- package/lib-es/datasets/solana.scanAccounts.1.d.ts.map +1 -0
- package/lib-es/datasets/solana.scanAccounts.1.js +10 -0
- package/lib-es/datasets/solana.scanAccounts.1.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +10 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +223 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +61 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +22 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +11 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +55 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +5 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +69 -0
- package/lib-es/getTransactionStatus.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +23 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/logic.d.ts +29 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +87 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/preload-data.d.ts +7 -0
- package/lib-es/preload-data.d.ts.map +1 -0
- package/lib-es/preload-data.js +39 -0
- package/lib-es/preload-data.js.map +1 -0
- package/lib-es/preload.d.ts +7 -0
- package/lib-es/preload.d.ts.map +1 -0
- package/lib-es/preload.js +62 -0
- package/lib-es/preload.js.map +1 -0
- package/lib-es/preload.test.d.ts +2 -0
- package/lib-es/preload.test.d.ts.map +1 -0
- package/lib-es/preload.test.js +7 -0
- package/lib-es/preload.test.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +5 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +497 -0
- package/lib-es/prepareTransaction.js.map +1 -0
- package/lib-es/serialization.d.ts +9 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +60 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signOperation.d.ts +7 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +146 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +11 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +7 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +404 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +8 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +211 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronization.d.ts +5 -0
- package/lib-es/synchronization.d.ts.map +1 -0
- package/lib-es/synchronization.js +456 -0
- package/lib-es/synchronization.js.map +1 -0
- package/lib-es/transaction.d.ts +15 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +148 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/tx-fees.d.ts +4 -0
- package/lib-es/tx-fees.d.ts.map +1 -0
- package/lib-es/tx-fees.js +160 -0
- package/lib-es/tx-fees.js.map +1 -0
- package/lib-es/types.d.ts +225 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +2 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/utils.d.ts +24 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +157 -0
- package/lib-es/utils.js.map +1 -0
- package/lib-es/validator-app/index.d.ts +22 -0
- package/lib-es/validator-app/index.d.ts.map +1 -0
- package/lib-es/validator-app/index.js +55 -0
- package/lib-es/validator-app/index.js.map +1 -0
- package/package.json +90 -0
- package/src/api/cached.ts +79 -0
- package/src/api/chain/account/index.ts +1 -0
- package/src/api/chain/account/parser.ts +63 -0
- package/src/api/chain/account/stake.ts +45 -0
- package/src/api/chain/account/token.ts +63 -0
- package/src/api/chain/account/vote.ts +55 -0
- package/src/api/chain/index.ts +212 -0
- package/src/api/chain/instruction/associated-token-account/index.ts +33 -0
- package/src/api/chain/instruction/associated-token-account/types.ts +23 -0
- package/src/api/chain/instruction/memo/index.ts +24 -0
- package/src/api/chain/instruction/memo/types.ts +18 -0
- package/src/api/chain/instruction/stake/index.ts +29 -0
- package/src/api/chain/instruction/stake/types.ts +95 -0
- package/src/api/chain/instruction/system/index.ts +30 -0
- package/src/api/chain/instruction/system/types.ts +141 -0
- package/src/api/chain/instruction/token/index.ts +30 -0
- package/src/api/chain/instruction/token/types.ts +222 -0
- package/src/api/chain/program/constants.ts +10 -0
- package/src/api/chain/program/index.ts +1 -0
- package/src/api/chain/program/parser.ts +120 -0
- package/src/api/chain/validators/bignum.ts +7 -0
- package/src/api/chain/validators/index.ts +9 -0
- package/src/api/chain/validators/pubkey.ts +8 -0
- package/src/api/chain/web3.ts +399 -0
- package/src/api/index.ts +4 -0
- package/src/api/logged.ts +70 -0
- package/src/api/queued.ts +25 -0
- package/src/api/traced.ts +89 -0
- package/src/bridge/bridge.ts +192 -0
- package/src/bridge/js.ts +42 -0
- package/src/bridge.integration.test.ts +1104 -0
- package/src/broadcast.ts +38 -0
- package/src/buildTransaction.ts +81 -0
- package/src/cli-transaction.ts +246 -0
- package/src/createTransaction.ts +18 -0
- package/src/datasets/solana.scanAccounts.1.ts +9 -0
- package/src/deviceTransactionConfig.ts +302 -0
- package/src/errors.ts +61 -0
- package/src/estimateMaxSpendable.ts +72 -0
- package/src/getTransactionStatus.ts +79 -0
- package/src/hw-getAddress.ts +22 -0
- package/src/logic.ts +123 -0
- package/src/preload-data.ts +46 -0
- package/src/preload.test.ts +14 -0
- package/src/preload.ts +74 -0
- package/src/prepareTransaction.ts +686 -0
- package/src/serialization.ts +81 -0
- package/src/signOperation.ts +315 -0
- package/src/signer.ts +10 -0
- package/src/specs.ts +514 -0
- package/src/speculos-deviceActions.ts +229 -0
- package/src/synchronization.ts +729 -0
- package/src/transaction.ts +199 -0
- package/src/tx-fees.ts +206 -0
- package/src/types.ts +291 -0
- package/src/utils.ts +176 -0
- package/src/validator-app/index.ts +79 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,1104 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import {
|
|
3
|
+
SolanaAccount,
|
|
4
|
+
SolanaStake,
|
|
5
|
+
Transaction,
|
|
6
|
+
TransactionModel,
|
|
7
|
+
TransactionStatus,
|
|
8
|
+
} from "./types";
|
|
9
|
+
import scanAccounts1 from "./datasets/solana.scanAccounts.1";
|
|
10
|
+
import {
|
|
11
|
+
AmountRequired,
|
|
12
|
+
InvalidAddress,
|
|
13
|
+
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
14
|
+
NotEnoughBalance,
|
|
15
|
+
RecipientRequired,
|
|
16
|
+
} from "@ledgerhq/errors";
|
|
17
|
+
import {
|
|
18
|
+
SolanaAccountNotFunded,
|
|
19
|
+
SolanaAddressOffEd25519,
|
|
20
|
+
SolanaInvalidValidator,
|
|
21
|
+
SolanaMemoIsTooLong,
|
|
22
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
23
|
+
SolanaRecipientAssociatedTokenAccountWillBeFunded,
|
|
24
|
+
SolanaStakeAccountNotFound,
|
|
25
|
+
SolanaStakeAccountRequired,
|
|
26
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
27
|
+
SolanaTokenAccountHoldsAnotherToken,
|
|
28
|
+
SolanaValidatorRequired,
|
|
29
|
+
} from "./errors";
|
|
30
|
+
import { encodeAccountIdWithTokenAccountAddress, MAX_MEMO_LENGTH } from "./logic";
|
|
31
|
+
import createTransaction from "./createTransaction";
|
|
32
|
+
import { compact } from "lodash/fp";
|
|
33
|
+
import { assertUnreachable } from "./utils";
|
|
34
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
35
|
+
import { ChainAPI } from "./api";
|
|
36
|
+
import {
|
|
37
|
+
SolanaStakeAccountIsNotDelegatable,
|
|
38
|
+
SolanaStakeAccountValidatorIsUnchangeable,
|
|
39
|
+
} from "./errors";
|
|
40
|
+
import getTransactionStatus from "./getTransactionStatus";
|
|
41
|
+
import { prepareTransaction } from "./prepareTransaction";
|
|
42
|
+
import type { Account, CurrenciesData, DatasetTest } from "@ledgerhq/types-live";
|
|
43
|
+
import { encodeAccountId } from "@ledgerhq/coin-framework/account/accountId";
|
|
44
|
+
import { LATEST_BLOCKHASH_MOCK } from "./api/chain";
|
|
45
|
+
|
|
46
|
+
// do not change real properties or the test will break
|
|
47
|
+
const testOnChainData = {
|
|
48
|
+
// --- real props ---
|
|
49
|
+
unfundedAddress: "7b6Q3ap8qRzfyvDw1Qce3fUV8C7WgFNzJQwYNTJm3KQo",
|
|
50
|
+
// 0/0
|
|
51
|
+
fundedSenderAddress: "AQbkEagmPgmsdAfS4X8V8UyJnXXjVPMvjeD15etqQ3Jh",
|
|
52
|
+
fundedSenderBalance: new BigNumber(83389840),
|
|
53
|
+
// 1000/0
|
|
54
|
+
fundedAddress: "ARRKL4FT4LMwpkhUw4xNbfiHqR7UdePtzGLvkszgydqZ",
|
|
55
|
+
wSolSenderAssocTokenAccAddress: "8RtwWeqdFz4EFuZU3MAadfYMWSdRMamjFrfq6BXkHuNN",
|
|
56
|
+
wSolSenderAssocTokenAccBalance: new BigNumber(7960720),
|
|
57
|
+
// 1000/0, mint - wrapped sol
|
|
58
|
+
wSolFundedAccountAssocTokenAccAddress: "Ax69sAxqBSdT3gMAUqXb8pUvgxSLCiXfTitMALEnFZTS",
|
|
59
|
+
// 0/0
|
|
60
|
+
notWSolTokenAccAddress: "Hsm3S2rhX4HwxYBaCyqgJ1cCtFyFSBu6HLy1bdvh7fKs",
|
|
61
|
+
validatorAddress: "9QU2QSxhb24FUX3Tu2FpczXjpK3VYrvRudywSZaM29mF",
|
|
62
|
+
fees: {
|
|
63
|
+
stakeAccountRentExempt: 2282880,
|
|
64
|
+
systemAccountRentExempt: 890880,
|
|
65
|
+
lamportsPerSignature: 5000,
|
|
66
|
+
},
|
|
67
|
+
// --- maybe outdated or not real, fine for tests ---
|
|
68
|
+
offEd25519Address: "6D8GtWkKJgToM5UoiByHqjQCCC9Dq1Hh7iNmU4jKSs14",
|
|
69
|
+
offEd25519Address2: "12rqwuEgBYiGhBrDJStCiqEtzQpTTiZbh7teNVLuYcFA",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const mainAccId = encodeAccountId({
|
|
73
|
+
type: "js",
|
|
74
|
+
version: "2",
|
|
75
|
+
currencyId: "solana",
|
|
76
|
+
xpubOrAddress: testOnChainData.fundedSenderAddress,
|
|
77
|
+
derivationMode: "solanaMain",
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
81
|
+
const wSolSubAccId = encodeAccountIdWithTokenAccountAddress(
|
|
82
|
+
mainAccId,
|
|
83
|
+
testOnChainData.wSolSenderAssocTokenAccAddress,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const fees = (signatureCount: number) =>
|
|
87
|
+
new BigNumber(signatureCount * testOnChainData.fees.lamportsPerSignature);
|
|
88
|
+
|
|
89
|
+
const zero = new BigNumber(0);
|
|
90
|
+
|
|
91
|
+
const solana: CurrenciesData<Transaction> = {
|
|
92
|
+
scanAccounts: [scanAccounts1],
|
|
93
|
+
// FIXME Ordering of validators must be always the same, for this test to be stable:
|
|
94
|
+
// https://github.com/LedgerHQ/ledger-live-common/blob/develop/src/__tests__/test-helpers/bridge.ts#L171-L188
|
|
95
|
+
FIXME_ignorePreloadFields: ["validators"],
|
|
96
|
+
accounts: [
|
|
97
|
+
{
|
|
98
|
+
raw: makeAccount(testOnChainData.fundedSenderAddress),
|
|
99
|
+
/*
|
|
100
|
+
Solana integration is written in such a way that requires
|
|
101
|
+
prepareTransaction to be called before any meaningfull status
|
|
102
|
+
can be calculated. The general bridge tests do not run prepareTransaction
|
|
103
|
+
on all tests, so skip them in the general runner, but make alternatives for them.
|
|
104
|
+
*/
|
|
105
|
+
FIXME_tests: [
|
|
106
|
+
"balance is sum of ops",
|
|
107
|
+
"Default empty recipient have a recipientError",
|
|
108
|
+
"invalid recipient have a recipientError",
|
|
109
|
+
"can be called on an empty transaction",
|
|
110
|
+
],
|
|
111
|
+
transactions: [
|
|
112
|
+
...recipientRequired(),
|
|
113
|
+
...recipientNotValid(),
|
|
114
|
+
...recipientIsSameAsSender(),
|
|
115
|
+
...memoIsTooLong(),
|
|
116
|
+
{
|
|
117
|
+
name: "status is error: called on an empty transaction",
|
|
118
|
+
transaction: createTransaction({} as any),
|
|
119
|
+
expectedStatus: {
|
|
120
|
+
errors: {
|
|
121
|
+
recipient: new RecipientRequired(),
|
|
122
|
+
},
|
|
123
|
+
warnings: {},
|
|
124
|
+
estimatedFees: fees(1),
|
|
125
|
+
amount: zero,
|
|
126
|
+
totalSpent: fees(1),
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
...transferTests(),
|
|
130
|
+
...stakingTests(),
|
|
131
|
+
//...tokenTests()
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const dataset: DatasetTest<Transaction> = {
|
|
138
|
+
implementations: [getEnv("MOCK") ? "mock" : "js"], // FIXME we should actually put both mock and js like other dataset do
|
|
139
|
+
currencies: {
|
|
140
|
+
solana,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
function makeAccount(freshAddress: string) {
|
|
145
|
+
return {
|
|
146
|
+
id: mainAccId,
|
|
147
|
+
seedIdentifier: "",
|
|
148
|
+
derivationMode: "solanaMain" as const,
|
|
149
|
+
index: 0,
|
|
150
|
+
freshAddress,
|
|
151
|
+
freshAddressPath: "",
|
|
152
|
+
blockHeight: 0,
|
|
153
|
+
operations: [],
|
|
154
|
+
pendingOperations: [],
|
|
155
|
+
currencyId: "solana",
|
|
156
|
+
lastSyncDate: "",
|
|
157
|
+
balance: "0",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type TransactionTestSpec = Exclude<
|
|
162
|
+
Exclude<
|
|
163
|
+
DatasetTest<Transaction>["currencies"][string]["accounts"],
|
|
164
|
+
undefined
|
|
165
|
+
>[number]["transactions"],
|
|
166
|
+
undefined
|
|
167
|
+
>[number];
|
|
168
|
+
|
|
169
|
+
function recipientRequired(): TransactionTestSpec[] {
|
|
170
|
+
const models: TransactionModel[] = [
|
|
171
|
+
// uncomment when tokens are supported
|
|
172
|
+
/*
|
|
173
|
+
{
|
|
174
|
+
kind: "token.transfer",
|
|
175
|
+
uiState: {
|
|
176
|
+
subAccountId: "",
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
*/
|
|
180
|
+
{
|
|
181
|
+
kind: "transfer",
|
|
182
|
+
uiState: {},
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
return models.map(model => {
|
|
186
|
+
return {
|
|
187
|
+
name: `${model.kind} :: status is error: recipient required`,
|
|
188
|
+
transaction: {
|
|
189
|
+
model,
|
|
190
|
+
amount: zero,
|
|
191
|
+
recipient: "",
|
|
192
|
+
family: "solana",
|
|
193
|
+
},
|
|
194
|
+
expectedStatus: {
|
|
195
|
+
errors: {
|
|
196
|
+
recipient: new RecipientRequired(),
|
|
197
|
+
},
|
|
198
|
+
warnings: {},
|
|
199
|
+
estimatedFees: fees(1),
|
|
200
|
+
amount: zero,
|
|
201
|
+
totalSpent: model.kind === "transfer" ? fees(1) : zero,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function recipientNotValid(): TransactionTestSpec[] {
|
|
208
|
+
return recipientRequired().map(spec => {
|
|
209
|
+
return {
|
|
210
|
+
...spec,
|
|
211
|
+
transaction: {
|
|
212
|
+
...(spec.transaction as Transaction),
|
|
213
|
+
recipient: "invalid address",
|
|
214
|
+
},
|
|
215
|
+
expectedStatus: {
|
|
216
|
+
...spec.expectedStatus,
|
|
217
|
+
errors: {
|
|
218
|
+
recipient: new InvalidAddress(),
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function recipientIsSameAsSender(): TransactionTestSpec[] {
|
|
226
|
+
return recipientRequired().map(spec => {
|
|
227
|
+
return {
|
|
228
|
+
...spec,
|
|
229
|
+
transaction: {
|
|
230
|
+
...(spec.transaction as Transaction),
|
|
231
|
+
recipient: testOnChainData.fundedSenderAddress,
|
|
232
|
+
},
|
|
233
|
+
expectedStatus: {
|
|
234
|
+
...spec.expectedStatus,
|
|
235
|
+
errors: {
|
|
236
|
+
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function memoIsTooLong(): TransactionTestSpec[] {
|
|
244
|
+
return compact(
|
|
245
|
+
recipientRequired().map(spec => {
|
|
246
|
+
const tx = spec.transaction as Transaction;
|
|
247
|
+
switch (tx.model.kind) {
|
|
248
|
+
case "transfer":
|
|
249
|
+
case "token.transfer":
|
|
250
|
+
tx.model.uiState.memo = "c".repeat(MAX_MEMO_LENGTH + 1);
|
|
251
|
+
return {
|
|
252
|
+
...spec,
|
|
253
|
+
transaction: {
|
|
254
|
+
...(spec.transaction as Transaction),
|
|
255
|
+
recipient: testOnChainData.fundedAddress,
|
|
256
|
+
},
|
|
257
|
+
expectedStatus: {
|
|
258
|
+
...spec.expectedStatus,
|
|
259
|
+
errors: {
|
|
260
|
+
memo: new SolanaMemoIsTooLong(),
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
case "token.createATA":
|
|
265
|
+
case "stake.createAccount":
|
|
266
|
+
case "stake.delegate":
|
|
267
|
+
case "stake.undelegate":
|
|
268
|
+
case "stake.withdraw":
|
|
269
|
+
case "stake.split":
|
|
270
|
+
return undefined;
|
|
271
|
+
default:
|
|
272
|
+
return assertUnreachable(tx.model);
|
|
273
|
+
}
|
|
274
|
+
}),
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function transferTests(): TransactionTestSpec[] {
|
|
279
|
+
return [
|
|
280
|
+
{
|
|
281
|
+
name: "transfer :: status is success: not all amount",
|
|
282
|
+
transaction: {
|
|
283
|
+
model: {
|
|
284
|
+
kind: "transfer",
|
|
285
|
+
uiState: {},
|
|
286
|
+
},
|
|
287
|
+
amount: testOnChainData.fundedSenderBalance.dividedBy(2),
|
|
288
|
+
recipient: testOnChainData.fundedAddress,
|
|
289
|
+
family: "solana",
|
|
290
|
+
},
|
|
291
|
+
expectedStatus: {
|
|
292
|
+
errors: {},
|
|
293
|
+
warnings: {},
|
|
294
|
+
estimatedFees: fees(1),
|
|
295
|
+
amount: testOnChainData.fundedSenderBalance.dividedBy(2),
|
|
296
|
+
totalSpent: testOnChainData.fundedSenderBalance.dividedBy(2).plus(fees(1)),
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name: "transfer :: status is success: all amount",
|
|
301
|
+
transaction: {
|
|
302
|
+
model: {
|
|
303
|
+
kind: "transfer",
|
|
304
|
+
uiState: {},
|
|
305
|
+
},
|
|
306
|
+
useAllAmount: true,
|
|
307
|
+
amount: zero,
|
|
308
|
+
recipient: testOnChainData.fundedAddress,
|
|
309
|
+
family: "solana",
|
|
310
|
+
},
|
|
311
|
+
expectedStatus: {
|
|
312
|
+
errors: {},
|
|
313
|
+
warnings: {},
|
|
314
|
+
estimatedFees: fees(1),
|
|
315
|
+
amount: testOnChainData.fundedSenderBalance
|
|
316
|
+
.minus(fees(1))
|
|
317
|
+
.minus(testOnChainData.fees.systemAccountRentExempt),
|
|
318
|
+
totalSpent: testOnChainData.fundedSenderBalance.minus(
|
|
319
|
+
testOnChainData.fees.systemAccountRentExempt,
|
|
320
|
+
),
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "transfer :: status is error: not enough balance, not all amount",
|
|
325
|
+
transaction: {
|
|
326
|
+
model: {
|
|
327
|
+
kind: "transfer",
|
|
328
|
+
uiState: {},
|
|
329
|
+
},
|
|
330
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
331
|
+
recipient: testOnChainData.fundedAddress,
|
|
332
|
+
family: "solana",
|
|
333
|
+
},
|
|
334
|
+
expectedStatus: {
|
|
335
|
+
errors: {
|
|
336
|
+
amount: new NotEnoughBalance(),
|
|
337
|
+
},
|
|
338
|
+
warnings: {},
|
|
339
|
+
estimatedFees: fees(1),
|
|
340
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
341
|
+
totalSpent: testOnChainData.fundedSenderBalance.plus(fees(1)),
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: "transfer :: status is error: amount is 0",
|
|
346
|
+
transaction: {
|
|
347
|
+
model: {
|
|
348
|
+
kind: "transfer",
|
|
349
|
+
uiState: {},
|
|
350
|
+
},
|
|
351
|
+
amount: zero,
|
|
352
|
+
recipient: testOnChainData.fundedAddress,
|
|
353
|
+
family: "solana",
|
|
354
|
+
},
|
|
355
|
+
expectedStatus: {
|
|
356
|
+
errors: {
|
|
357
|
+
amount: new AmountRequired(),
|
|
358
|
+
},
|
|
359
|
+
warnings: {},
|
|
360
|
+
estimatedFees: fees(1),
|
|
361
|
+
amount: zero,
|
|
362
|
+
totalSpent: fees(1),
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
name: "transfer :: status is error: amount is negative",
|
|
367
|
+
transaction: {
|
|
368
|
+
model: {
|
|
369
|
+
kind: "transfer",
|
|
370
|
+
uiState: {},
|
|
371
|
+
},
|
|
372
|
+
amount: new BigNumber(-1),
|
|
373
|
+
recipient: testOnChainData.fundedAddress,
|
|
374
|
+
family: "solana",
|
|
375
|
+
},
|
|
376
|
+
expectedStatus: {
|
|
377
|
+
errors: {
|
|
378
|
+
amount: new AmountRequired(),
|
|
379
|
+
},
|
|
380
|
+
warnings: {},
|
|
381
|
+
estimatedFees: fees(1),
|
|
382
|
+
amount: new BigNumber(-1),
|
|
383
|
+
totalSpent: zero,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
name: "transfer :: status is warning: recipient wallet not funded",
|
|
388
|
+
transaction: {
|
|
389
|
+
model: {
|
|
390
|
+
kind: "transfer",
|
|
391
|
+
uiState: {},
|
|
392
|
+
},
|
|
393
|
+
amount: new BigNumber(1),
|
|
394
|
+
recipient: testOnChainData.unfundedAddress,
|
|
395
|
+
family: "solana",
|
|
396
|
+
},
|
|
397
|
+
expectedStatus: {
|
|
398
|
+
errors: {},
|
|
399
|
+
warnings: {
|
|
400
|
+
recipient: new SolanaAccountNotFunded(),
|
|
401
|
+
},
|
|
402
|
+
estimatedFees: fees(1),
|
|
403
|
+
amount: new BigNumber(1),
|
|
404
|
+
totalSpent: fees(1).plus(1),
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "transfer :: status is warning: recipient address is off ed25519",
|
|
409
|
+
transaction: {
|
|
410
|
+
model: {
|
|
411
|
+
kind: "transfer",
|
|
412
|
+
uiState: {},
|
|
413
|
+
},
|
|
414
|
+
amount: new BigNumber(1),
|
|
415
|
+
recipient: testOnChainData.offEd25519Address,
|
|
416
|
+
family: "solana",
|
|
417
|
+
},
|
|
418
|
+
expectedStatus: {
|
|
419
|
+
errors: {},
|
|
420
|
+
warnings: {
|
|
421
|
+
recipient: new SolanaAccountNotFunded(),
|
|
422
|
+
recipientOffCurve: new SolanaAddressOffEd25519(),
|
|
423
|
+
},
|
|
424
|
+
estimatedFees: fees(1),
|
|
425
|
+
amount: new BigNumber(1),
|
|
426
|
+
totalSpent: fees(1).plus(1),
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// uncomment when tokens are supported
|
|
433
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
434
|
+
function tokenTests(): TransactionTestSpec[] {
|
|
435
|
+
return [
|
|
436
|
+
{
|
|
437
|
+
name: "token.transfer :: status is success: recipient is funded wallet, assoc token acc exists",
|
|
438
|
+
transaction: {
|
|
439
|
+
model: {
|
|
440
|
+
kind: "token.transfer",
|
|
441
|
+
uiState: {
|
|
442
|
+
subAccountId: wSolSubAccId,
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
446
|
+
recipient: testOnChainData.fundedAddress,
|
|
447
|
+
family: "solana",
|
|
448
|
+
},
|
|
449
|
+
expectedStatus: {
|
|
450
|
+
errors: {},
|
|
451
|
+
warnings: {},
|
|
452
|
+
estimatedFees: fees(1),
|
|
453
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
454
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "token.transfer :: status is success: recipient is correct mint token acc",
|
|
459
|
+
transaction: {
|
|
460
|
+
model: {
|
|
461
|
+
kind: "token.transfer",
|
|
462
|
+
uiState: {
|
|
463
|
+
subAccountId: wSolSubAccId,
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
467
|
+
recipient: testOnChainData.wSolFundedAccountAssocTokenAccAddress,
|
|
468
|
+
family: "solana",
|
|
469
|
+
},
|
|
470
|
+
expectedStatus: {
|
|
471
|
+
errors: {},
|
|
472
|
+
warnings: {},
|
|
473
|
+
estimatedFees: fees(1),
|
|
474
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
475
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "token.transfer :: status is error: recipient is another mint token acc",
|
|
480
|
+
transaction: {
|
|
481
|
+
model: {
|
|
482
|
+
kind: "token.transfer",
|
|
483
|
+
uiState: {
|
|
484
|
+
subAccountId: wSolSubAccId,
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
488
|
+
recipient: testOnChainData.notWSolTokenAccAddress,
|
|
489
|
+
family: "solana",
|
|
490
|
+
},
|
|
491
|
+
expectedStatus: {
|
|
492
|
+
errors: {
|
|
493
|
+
recipient: new SolanaTokenAccountHoldsAnotherToken(),
|
|
494
|
+
},
|
|
495
|
+
warnings: {},
|
|
496
|
+
estimatedFees: fees(1),
|
|
497
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
498
|
+
totalSpent: zero,
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
name: "token.transfer :: status is warning: recipient is off curve",
|
|
503
|
+
transaction: {
|
|
504
|
+
model: {
|
|
505
|
+
kind: "token.transfer",
|
|
506
|
+
uiState: {
|
|
507
|
+
subAccountId: wSolSubAccId,
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
511
|
+
recipient: testOnChainData.offEd25519Address,
|
|
512
|
+
family: "solana",
|
|
513
|
+
},
|
|
514
|
+
expectedStatus: {
|
|
515
|
+
errors: {
|
|
516
|
+
recipient: new SolanaAddressOffEd25519(),
|
|
517
|
+
},
|
|
518
|
+
warnings: {},
|
|
519
|
+
estimatedFees: fees(1),
|
|
520
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
521
|
+
totalSpent: zero,
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
name: "token.transfer :: status is success: recipient is wallet and no assoc token acc exists (will be created)",
|
|
526
|
+
transaction: {
|
|
527
|
+
model: {
|
|
528
|
+
kind: "token.transfer",
|
|
529
|
+
uiState: {
|
|
530
|
+
subAccountId: wSolSubAccId,
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
534
|
+
recipient: testOnChainData.unfundedAddress,
|
|
535
|
+
family: "solana",
|
|
536
|
+
},
|
|
537
|
+
expectedStatus: {
|
|
538
|
+
errors: {},
|
|
539
|
+
warnings: {
|
|
540
|
+
recipient: new SolanaAccountNotFunded(),
|
|
541
|
+
recipientAssociatedTokenAccount: new SolanaRecipientAssociatedTokenAccountWillBeFunded(),
|
|
542
|
+
},
|
|
543
|
+
// this fee is dynamic, skip
|
|
544
|
+
//estimatedFees: new BigNumber(2044280),
|
|
545
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
546
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
];
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function stakingTests(): TransactionTestSpec[] {
|
|
553
|
+
return [
|
|
554
|
+
{
|
|
555
|
+
name: "stake.createAccount :: status is error: amount is negative",
|
|
556
|
+
transaction: {
|
|
557
|
+
family: "solana",
|
|
558
|
+
model: {
|
|
559
|
+
kind: "stake.createAccount",
|
|
560
|
+
uiState: {
|
|
561
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
recipient: "",
|
|
565
|
+
amount: new BigNumber(-1),
|
|
566
|
+
},
|
|
567
|
+
expectedStatus: {
|
|
568
|
+
amount: new BigNumber(-1),
|
|
569
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
570
|
+
totalSpent: zero,
|
|
571
|
+
errors: {
|
|
572
|
+
amount: new AmountRequired(),
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: "stake.createAccount :: status is error: amount is zero",
|
|
578
|
+
transaction: {
|
|
579
|
+
family: "solana",
|
|
580
|
+
model: {
|
|
581
|
+
kind: "stake.createAccount",
|
|
582
|
+
uiState: {
|
|
583
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
recipient: "",
|
|
587
|
+
amount: zero,
|
|
588
|
+
},
|
|
589
|
+
expectedStatus: {
|
|
590
|
+
amount: zero,
|
|
591
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
592
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
593
|
+
errors: {
|
|
594
|
+
amount: new AmountRequired(),
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
name: "stake.createAccount :: status is error: not enough balance, not all amount",
|
|
600
|
+
transaction: {
|
|
601
|
+
family: "solana",
|
|
602
|
+
model: {
|
|
603
|
+
kind: "stake.createAccount",
|
|
604
|
+
uiState: {
|
|
605
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
recipient: "",
|
|
609
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
610
|
+
},
|
|
611
|
+
expectedStatus: {
|
|
612
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
613
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
614
|
+
totalSpent: fees(1)
|
|
615
|
+
.plus(testOnChainData.fees.stakeAccountRentExempt)
|
|
616
|
+
.plus(testOnChainData.fundedSenderBalance),
|
|
617
|
+
errors: {
|
|
618
|
+
amount: new NotEnoughBalance(),
|
|
619
|
+
},
|
|
620
|
+
},
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "stake.createAccount :: status is error: validator required",
|
|
624
|
+
transaction: {
|
|
625
|
+
family: "solana",
|
|
626
|
+
model: {
|
|
627
|
+
kind: "stake.createAccount",
|
|
628
|
+
uiState: {
|
|
629
|
+
delegate: { voteAccAddress: "" },
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
recipient: "",
|
|
633
|
+
amount: new BigNumber(1),
|
|
634
|
+
},
|
|
635
|
+
expectedStatus: {
|
|
636
|
+
amount: new BigNumber(1),
|
|
637
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
638
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
639
|
+
errors: {
|
|
640
|
+
voteAccAddr: new SolanaValidatorRequired(),
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
name: "stake.createAccount :: status is error: validator has invalid address",
|
|
646
|
+
transaction: {
|
|
647
|
+
family: "solana",
|
|
648
|
+
model: {
|
|
649
|
+
kind: "stake.createAccount",
|
|
650
|
+
uiState: {
|
|
651
|
+
delegate: { voteAccAddress: "invalid address" },
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
recipient: "",
|
|
655
|
+
amount: new BigNumber(1),
|
|
656
|
+
},
|
|
657
|
+
expectedStatus: {
|
|
658
|
+
amount: new BigNumber(1),
|
|
659
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
660
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
661
|
+
errors: {
|
|
662
|
+
voteAccAddr: new InvalidAddress(),
|
|
663
|
+
},
|
|
664
|
+
},
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: "stake.createAccount :: status is error: validator invalid",
|
|
668
|
+
transaction: {
|
|
669
|
+
family: "solana",
|
|
670
|
+
model: {
|
|
671
|
+
kind: "stake.createAccount",
|
|
672
|
+
uiState: {
|
|
673
|
+
delegate: { voteAccAddress: testOnChainData.fundedSenderAddress },
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
recipient: "",
|
|
677
|
+
amount: new BigNumber(1),
|
|
678
|
+
},
|
|
679
|
+
expectedStatus: {
|
|
680
|
+
amount: new BigNumber(1),
|
|
681
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
682
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
683
|
+
errors: {
|
|
684
|
+
voteAccAddr: new SolanaInvalidValidator(),
|
|
685
|
+
},
|
|
686
|
+
},
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
name: "stake.createAccount :: status is success, not all amount",
|
|
690
|
+
transaction: {
|
|
691
|
+
family: "solana",
|
|
692
|
+
model: {
|
|
693
|
+
kind: "stake.createAccount",
|
|
694
|
+
uiState: {
|
|
695
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
recipient: "",
|
|
699
|
+
amount: new BigNumber(1),
|
|
700
|
+
},
|
|
701
|
+
expectedStatus: {
|
|
702
|
+
amount: new BigNumber(1),
|
|
703
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
704
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
705
|
+
errors: {},
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
name: "stake.createAccount :: status is success, all amount",
|
|
710
|
+
transaction: {
|
|
711
|
+
family: "solana",
|
|
712
|
+
model: {
|
|
713
|
+
kind: "stake.createAccount",
|
|
714
|
+
uiState: {
|
|
715
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
recipient: "",
|
|
719
|
+
useAllAmount: true,
|
|
720
|
+
amount: zero,
|
|
721
|
+
},
|
|
722
|
+
expectedStatus: {
|
|
723
|
+
amount: testOnChainData.fundedSenderBalance
|
|
724
|
+
.minus(fees(1)) // transaction fee
|
|
725
|
+
.minus(fees(1).multipliedBy(2)) // undelegate + withdraw fees reserve
|
|
726
|
+
.minus(testOnChainData.fees.stakeAccountRentExempt)
|
|
727
|
+
.minus(testOnChainData.fees.systemAccountRentExempt),
|
|
728
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
729
|
+
totalSpent: testOnChainData.fundedSenderBalance
|
|
730
|
+
.minus(testOnChainData.fees.systemAccountRentExempt)
|
|
731
|
+
.minus(fees(1).multipliedBy(2)), // undelegate + withdraw fees reserve,
|
|
732
|
+
errors: {},
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
name: "stake.delegate :: status is error: stake account address and validator address required",
|
|
737
|
+
transaction: {
|
|
738
|
+
family: "solana",
|
|
739
|
+
model: {
|
|
740
|
+
kind: "stake.delegate",
|
|
741
|
+
uiState: {
|
|
742
|
+
stakeAccAddr: "",
|
|
743
|
+
voteAccAddr: "",
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
recipient: "",
|
|
747
|
+
amount: zero,
|
|
748
|
+
},
|
|
749
|
+
expectedStatus: {
|
|
750
|
+
amount: zero,
|
|
751
|
+
estimatedFees: fees(1),
|
|
752
|
+
totalSpent: fees(1),
|
|
753
|
+
errors: {
|
|
754
|
+
stakeAccAddr: new SolanaStakeAccountRequired(),
|
|
755
|
+
voteAccAddr: new SolanaValidatorRequired(),
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
name: "stake.delegate :: status is error: stake account address and validator address are invalid",
|
|
761
|
+
transaction: {
|
|
762
|
+
family: "solana",
|
|
763
|
+
model: {
|
|
764
|
+
kind: "stake.delegate",
|
|
765
|
+
uiState: {
|
|
766
|
+
stakeAccAddr: "invalid address",
|
|
767
|
+
voteAccAddr: "invalid address",
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
recipient: "",
|
|
771
|
+
amount: zero,
|
|
772
|
+
},
|
|
773
|
+
expectedStatus: {
|
|
774
|
+
amount: zero,
|
|
775
|
+
estimatedFees: fees(1),
|
|
776
|
+
totalSpent: fees(1),
|
|
777
|
+
errors: {
|
|
778
|
+
stakeAccAddr: new InvalidAddress(),
|
|
779
|
+
voteAccAddr: new InvalidAddress(),
|
|
780
|
+
},
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
name: "stake.delegate :: status is error: stake account not found",
|
|
785
|
+
transaction: {
|
|
786
|
+
family: "solana",
|
|
787
|
+
model: {
|
|
788
|
+
kind: "stake.delegate",
|
|
789
|
+
uiState: {
|
|
790
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
791
|
+
voteAccAddr: testOnChainData.validatorAddress,
|
|
792
|
+
},
|
|
793
|
+
},
|
|
794
|
+
recipient: "",
|
|
795
|
+
amount: zero,
|
|
796
|
+
},
|
|
797
|
+
expectedStatus: {
|
|
798
|
+
amount: zero,
|
|
799
|
+
estimatedFees: fees(1),
|
|
800
|
+
totalSpent: fees(1),
|
|
801
|
+
errors: {
|
|
802
|
+
stakeAccAddr: new SolanaStakeAccountNotFound(),
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "stake.undelegate :: status is error: stake account required",
|
|
808
|
+
transaction: {
|
|
809
|
+
family: "solana",
|
|
810
|
+
model: {
|
|
811
|
+
kind: "stake.undelegate",
|
|
812
|
+
uiState: {
|
|
813
|
+
stakeAccAddr: "",
|
|
814
|
+
},
|
|
815
|
+
},
|
|
816
|
+
recipient: "",
|
|
817
|
+
amount: zero,
|
|
818
|
+
},
|
|
819
|
+
expectedStatus: {
|
|
820
|
+
amount: zero,
|
|
821
|
+
estimatedFees: fees(1),
|
|
822
|
+
totalSpent: fees(1),
|
|
823
|
+
errors: {
|
|
824
|
+
stakeAccAddr: new SolanaStakeAccountRequired(),
|
|
825
|
+
},
|
|
826
|
+
},
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
name: "stake.undelegate :: status is error: stake account invalid",
|
|
830
|
+
transaction: {
|
|
831
|
+
family: "solana",
|
|
832
|
+
model: {
|
|
833
|
+
kind: "stake.undelegate",
|
|
834
|
+
uiState: {
|
|
835
|
+
stakeAccAddr: "invalid address",
|
|
836
|
+
},
|
|
837
|
+
},
|
|
838
|
+
recipient: "",
|
|
839
|
+
amount: zero,
|
|
840
|
+
},
|
|
841
|
+
expectedStatus: {
|
|
842
|
+
amount: zero,
|
|
843
|
+
estimatedFees: fees(1),
|
|
844
|
+
totalSpent: fees(1),
|
|
845
|
+
errors: {
|
|
846
|
+
stakeAccAddr: new InvalidAddress(),
|
|
847
|
+
},
|
|
848
|
+
},
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "stake.undelegate :: status is error: stake account not found",
|
|
852
|
+
transaction: {
|
|
853
|
+
family: "solana",
|
|
854
|
+
model: {
|
|
855
|
+
kind: "stake.undelegate",
|
|
856
|
+
uiState: {
|
|
857
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
recipient: "",
|
|
861
|
+
amount: zero,
|
|
862
|
+
},
|
|
863
|
+
expectedStatus: {
|
|
864
|
+
amount: zero,
|
|
865
|
+
estimatedFees: fees(1),
|
|
866
|
+
totalSpent: fees(1),
|
|
867
|
+
errors: {
|
|
868
|
+
stakeAccAddr: new SolanaStakeAccountNotFound(),
|
|
869
|
+
},
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
name: "stake.withdraw :: status is error: stake account required",
|
|
874
|
+
transaction: {
|
|
875
|
+
family: "solana",
|
|
876
|
+
model: {
|
|
877
|
+
kind: "stake.withdraw",
|
|
878
|
+
uiState: {
|
|
879
|
+
stakeAccAddr: "",
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
recipient: "",
|
|
883
|
+
amount: zero,
|
|
884
|
+
},
|
|
885
|
+
expectedStatus: {
|
|
886
|
+
amount: zero,
|
|
887
|
+
estimatedFees: fees(1),
|
|
888
|
+
totalSpent: fees(1),
|
|
889
|
+
errors: {
|
|
890
|
+
stakeAccAddr: new SolanaStakeAccountRequired(),
|
|
891
|
+
},
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
name: "stake.withdraw :: status is error: stake account address invalid",
|
|
896
|
+
transaction: {
|
|
897
|
+
family: "solana",
|
|
898
|
+
model: {
|
|
899
|
+
kind: "stake.withdraw",
|
|
900
|
+
uiState: {
|
|
901
|
+
stakeAccAddr: "invalid address",
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
recipient: "",
|
|
905
|
+
amount: zero,
|
|
906
|
+
},
|
|
907
|
+
expectedStatus: {
|
|
908
|
+
amount: zero,
|
|
909
|
+
estimatedFees: fees(1),
|
|
910
|
+
totalSpent: fees(1),
|
|
911
|
+
errors: {
|
|
912
|
+
stakeAccAddr: new InvalidAddress(),
|
|
913
|
+
},
|
|
914
|
+
},
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
name: "stake.withdraw :: status is error: stake account not found",
|
|
918
|
+
transaction: {
|
|
919
|
+
family: "solana",
|
|
920
|
+
model: {
|
|
921
|
+
kind: "stake.withdraw",
|
|
922
|
+
uiState: {
|
|
923
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
924
|
+
},
|
|
925
|
+
},
|
|
926
|
+
recipient: "",
|
|
927
|
+
amount: zero,
|
|
928
|
+
},
|
|
929
|
+
expectedStatus: {
|
|
930
|
+
amount: zero,
|
|
931
|
+
estimatedFees: fees(1),
|
|
932
|
+
totalSpent: fees(1),
|
|
933
|
+
errors: {
|
|
934
|
+
stakeAccAddr: new SolanaStakeAccountNotFound(),
|
|
935
|
+
},
|
|
936
|
+
},
|
|
937
|
+
},
|
|
938
|
+
];
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
const baseAccount = {
|
|
942
|
+
balance: new BigNumber(0),
|
|
943
|
+
spendableBalance: new BigNumber(0),
|
|
944
|
+
} as Account;
|
|
945
|
+
|
|
946
|
+
const baseTx = {
|
|
947
|
+
family: "solana",
|
|
948
|
+
recipient: "",
|
|
949
|
+
amount: new BigNumber(0),
|
|
950
|
+
} as Transaction;
|
|
951
|
+
|
|
952
|
+
const baseAPI = {
|
|
953
|
+
getLatestBlockhash: () => Promise.resolve(LATEST_BLOCKHASH_MOCK),
|
|
954
|
+
getFeeForMessage: (_msg: unknown) => Promise.resolve(testOnChainData.fees.lamportsPerSignature),
|
|
955
|
+
} as ChainAPI;
|
|
956
|
+
|
|
957
|
+
type StakeTestSpec = {
|
|
958
|
+
activationState: SolanaStake["activation"]["state"];
|
|
959
|
+
txModel: Transaction["model"];
|
|
960
|
+
expectedErrors: Record<string, Error>;
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Some business logic can not be described in terms of transactions and expected status
|
|
965
|
+
* in the test datasets, like stake activation/deactivation, because stake activation is
|
|
966
|
+
* not determenistic and changes with time. Hence the tests here to mock data
|
|
967
|
+
* to be determenistic.
|
|
968
|
+
*/
|
|
969
|
+
|
|
970
|
+
describe("solana staking", () => {
|
|
971
|
+
test("stake.delegate :: status is error: stake account is not delegatable", async () => {
|
|
972
|
+
const stakeDelegateModel: Transaction["model"] & {
|
|
973
|
+
kind: "stake.delegate";
|
|
974
|
+
} = {
|
|
975
|
+
kind: "stake.delegate",
|
|
976
|
+
uiState: {
|
|
977
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
978
|
+
voteAccAddr: testOnChainData.validatorAddress,
|
|
979
|
+
},
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
const stakeTests: StakeTestSpec[] = [
|
|
983
|
+
{
|
|
984
|
+
activationState: "activating",
|
|
985
|
+
txModel: stakeDelegateModel,
|
|
986
|
+
expectedErrors: {
|
|
987
|
+
fee: new NotEnoughBalance(),
|
|
988
|
+
stakeAccAddr: new SolanaStakeAccountIsNotDelegatable(),
|
|
989
|
+
},
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
activationState: "active",
|
|
993
|
+
txModel: stakeDelegateModel,
|
|
994
|
+
expectedErrors: {
|
|
995
|
+
fee: new NotEnoughBalance(),
|
|
996
|
+
stakeAccAddr: new SolanaStakeAccountIsNotDelegatable(),
|
|
997
|
+
},
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
activationState: "deactivating",
|
|
1001
|
+
txModel: {
|
|
1002
|
+
...stakeDelegateModel,
|
|
1003
|
+
uiState: {
|
|
1004
|
+
...stakeDelegateModel.uiState,
|
|
1005
|
+
voteAccAddr: testOnChainData.unfundedAddress,
|
|
1006
|
+
},
|
|
1007
|
+
},
|
|
1008
|
+
expectedErrors: {
|
|
1009
|
+
fee: new NotEnoughBalance(),
|
|
1010
|
+
stakeAccAddr: new SolanaStakeAccountValidatorIsUnchangeable(),
|
|
1011
|
+
},
|
|
1012
|
+
},
|
|
1013
|
+
];
|
|
1014
|
+
|
|
1015
|
+
for (const stakeTest of stakeTests) {
|
|
1016
|
+
await runStakeTest(stakeTest);
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
async function runStakeTest(stakeTestSpec: StakeTestSpec) {
|
|
1022
|
+
const api = {
|
|
1023
|
+
...baseAPI,
|
|
1024
|
+
getMinimumBalanceForRentExemption: () =>
|
|
1025
|
+
Promise.resolve(testOnChainData.fees.stakeAccountRentExempt),
|
|
1026
|
+
getAccountInfo: () => {
|
|
1027
|
+
return Promise.resolve({ data: mockedVoteAccount } as any);
|
|
1028
|
+
},
|
|
1029
|
+
} as ChainAPI;
|
|
1030
|
+
|
|
1031
|
+
const account: SolanaAccount = {
|
|
1032
|
+
...baseAccount,
|
|
1033
|
+
freshAddress: testOnChainData.fundedSenderAddress,
|
|
1034
|
+
solanaResources: {
|
|
1035
|
+
stakes: [
|
|
1036
|
+
{
|
|
1037
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
1038
|
+
delegation: {
|
|
1039
|
+
stake: 1,
|
|
1040
|
+
voteAccAddr: testOnChainData.validatorAddress,
|
|
1041
|
+
},
|
|
1042
|
+
activation: {
|
|
1043
|
+
state: stakeTestSpec.activationState,
|
|
1044
|
+
},
|
|
1045
|
+
} as SolanaStake,
|
|
1046
|
+
],
|
|
1047
|
+
unstakeReserve: BigNumber(0),
|
|
1048
|
+
},
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
const tx: Transaction = {
|
|
1052
|
+
...baseTx,
|
|
1053
|
+
model: stakeTestSpec.txModel,
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
const preparedTx = await prepareTransaction(account, tx, api);
|
|
1057
|
+
const status = await getTransactionStatus(account, preparedTx);
|
|
1058
|
+
|
|
1059
|
+
const expectedStatus: TransactionStatus = {
|
|
1060
|
+
amount: new BigNumber(0),
|
|
1061
|
+
estimatedFees: new BigNumber(testOnChainData.fees.lamportsPerSignature),
|
|
1062
|
+
totalSpent: new BigNumber(testOnChainData.fees.lamportsPerSignature),
|
|
1063
|
+
errors: stakeTestSpec.expectedErrors,
|
|
1064
|
+
warnings: {},
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
expect(status).toEqual(expectedStatus);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
const mockedVoteAccount = {
|
|
1071
|
+
parsed: {
|
|
1072
|
+
info: {
|
|
1073
|
+
authorizedVoters: [
|
|
1074
|
+
{
|
|
1075
|
+
authorizedVoter: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
|
|
1076
|
+
epoch: 283,
|
|
1077
|
+
},
|
|
1078
|
+
],
|
|
1079
|
+
authorizedWithdrawer: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
|
|
1080
|
+
commission: 7,
|
|
1081
|
+
epochCredits: [
|
|
1082
|
+
{
|
|
1083
|
+
credits: "98854605",
|
|
1084
|
+
epoch: 283,
|
|
1085
|
+
previousCredits: "98728105",
|
|
1086
|
+
},
|
|
1087
|
+
],
|
|
1088
|
+
lastTimestamp: { slot: 122422797, timestamp: 1645796249 },
|
|
1089
|
+
nodePubkey: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
|
|
1090
|
+
priorVoters: [],
|
|
1091
|
+
rootSlot: 122422766,
|
|
1092
|
+
votes: [{ confirmationCount: 1, slot: 122422797 }],
|
|
1093
|
+
},
|
|
1094
|
+
type: "vote",
|
|
1095
|
+
},
|
|
1096
|
+
program: "vote",
|
|
1097
|
+
space: 3731,
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
describe("Solana bridge", () => {
|
|
1101
|
+
test.todo(
|
|
1102
|
+
"This is an empty test to make jest command pass. Remove it once there is a real test.",
|
|
1103
|
+
);
|
|
1104
|
+
});
|