@ledgerhq/live-common 27.0.0 → 27.1.0-next.1
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/xpub.syncing.integration.test.js +2 -2
- package/lib/__tests__/test-helpers/environment.d.ts +2 -0
- package/lib/__tests__/test-helpers/environment.d.ts.map +1 -0
- package/lib/__tests__/test-helpers/environment.js +107 -0
- package/lib/__tests__/test-helpers/environment.js.map +1 -0
- package/lib/__tests__/test-helpers/setup.d.ts +1 -1
- package/lib/__tests__/test-helpers/setup.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/setup.js +1 -101
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/account/serialization.d.ts +2 -0
- package/lib/account/serialization.d.ts.map +1 -1
- package/lib/account/serialization.js +105 -47
- package/lib/account/serialization.js.map +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +1 -0
- package/lib/apps/support.js.map +1 -1
- package/lib/bot/bot-test-context.d.ts +3 -0
- package/lib/bot/bot-test-context.d.ts.map +1 -0
- package/lib/bot/bot-test-context.js +26 -0
- package/lib/bot/bot-test-context.js.map +1 -0
- package/lib/bot/bot-test-context.test.d.ts +2 -0
- package/lib/bot/bot-test-context.test.d.ts.map +1 -0
- package/lib/bot/bot-test-context.test.js +41 -0
- package/lib/bot/bot-test-context.test.js.map +1 -0
- package/lib/bot/cli.d.ts +2 -0
- package/lib/bot/cli.d.ts.map +1 -0
- package/lib/bot/cli.js +14 -0
- package/lib/bot/cli.js.map +1 -0
- package/lib/bot/engine.d.ts +5 -5
- package/lib/bot/engine.d.ts.map +1 -1
- package/lib/bot/engine.js +161 -112
- package/lib/bot/engine.js.map +1 -1
- package/lib/bot/formatters.d.ts +2 -2
- package/lib/bot/formatters.d.ts.map +1 -1
- package/lib/bot/formatters.js +41 -15
- package/lib/bot/formatters.js.map +1 -1
- package/lib/bot/index.d.ts +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +90 -15
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts +2 -1
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +13 -9
- package/lib/bot/specs.js.map +1 -1
- package/lib/bot/types.d.ts +5 -2
- package/lib/bot/types.d.ts.map +1 -1
- package/lib/countervalues/logic.integration.test.js +65 -0
- package/lib/countervalues/logic.integration.test.js.map +1 -1
- package/lib/countervalues/modules/weth.d.ts.map +1 -1
- package/lib/countervalues/modules/weth.js +5 -10
- package/lib/countervalues/modules/weth.js.map +1 -1
- package/lib/currencies/sortByMarketcap.d.ts +0 -2
- package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
- package/lib/currencies/sortByMarketcap.js +3 -17
- package/lib/currencies/sortByMarketcap.js.map +1 -1
- package/lib/currencies/sortByMarketcap.test.js +0 -5
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/env.js +1 -1
- package/lib/families/algorand/specs.d.ts.map +1 -1
- package/lib/families/algorand/specs.js +18 -10
- package/lib/families/algorand/specs.js.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.d.ts +1 -4
- package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.js +25 -8
- package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
- package/lib/families/bitcoin/bridge/mock.d.ts.map +1 -1
- package/lib/families/bitcoin/bridge/mock.js +6 -1
- package/lib/families/bitcoin/bridge/mock.js.map +1 -1
- package/lib/families/bitcoin/datasets/bitcoin_cash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/bitcoin_cash.js +1 -1
- package/lib/families/bitcoin/datasets/bitcoin_cash.js.map +1 -1
- package/lib/families/bitcoin/datasets/dash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/dash.js +1 -1
- package/lib/families/bitcoin/datasets/dash.js.map +1 -1
- package/lib/families/bitcoin/datasets/decred.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/decred.js +1 -1
- package/lib/families/bitcoin/datasets/decred.js.map +1 -1
- package/lib/families/bitcoin/datasets/digibyte.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/digibyte.js +8 -2
- package/lib/families/bitcoin/datasets/digibyte.js.map +1 -1
- package/lib/families/bitcoin/datasets/dogecoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/dogecoin.js +1 -1
- package/lib/families/bitcoin/datasets/dogecoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/komodo.js +1 -1
- package/lib/families/bitcoin/datasets/komodo.js.map +1 -1
- package/lib/families/bitcoin/datasets/litecoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/litecoin.js +8 -2
- package/lib/families/bitcoin/datasets/litecoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/peercoin.js +1 -1
- package/lib/families/bitcoin/datasets/peercoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/pivx.js +1 -1
- package/lib/families/bitcoin/datasets/pivx.js.map +1 -1
- package/lib/families/bitcoin/datasets/qtum.js +1 -1
- package/lib/families/bitcoin/datasets/qtum.js.map +1 -1
- package/lib/families/bitcoin/datasets/stakenet.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/stakenet.js +1 -1
- package/lib/families/bitcoin/datasets/stakenet.js.map +1 -1
- package/lib/families/bitcoin/datasets/vertcoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/vertcoin.js +1 -1
- package/lib/families/bitcoin/datasets/vertcoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/viacoin.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/viacoin.js +1 -1
- package/lib/families/bitcoin/datasets/viacoin.js.map +1 -1
- package/lib/families/bitcoin/datasets/zcash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/zcash.js +1 -1
- package/lib/families/bitcoin/datasets/zcash.js.map +1 -1
- package/lib/families/bitcoin/datasets/zencash.d.ts.map +1 -1
- package/lib/families/bitcoin/datasets/zencash.js +1 -1
- package/lib/families/bitcoin/datasets/zencash.js.map +1 -1
- package/lib/families/bitcoin/platformAdapter.test.d.ts +2 -0
- package/lib/families/bitcoin/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/bitcoin/platformAdapter.test.js +48 -0
- package/lib/families/bitcoin/platformAdapter.test.js.map +1 -0
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +62 -24
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.d.ts +1 -4
- package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.js +2 -4
- package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/cardano/js-estimateMaxSpendable.js +1 -1
- package/lib/families/cardano/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/cardano/specs.d.ts.map +1 -1
- package/lib/families/cardano/specs.js +19 -8
- package/lib/families/cardano/specs.js.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.d.ts +1 -4
- package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.js +2 -2
- package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
- package/lib/families/celo/api/hubble.d.ts +6 -1
- package/lib/families/celo/api/hubble.d.ts.map +1 -1
- package/lib/families/celo/api/hubble.js +135 -13
- package/lib/families/celo/api/hubble.js.map +1 -1
- package/lib/families/celo/api/index.d.ts +1 -1
- package/lib/families/celo/api/index.d.ts.map +1 -1
- package/lib/families/celo/api/index.js +2 -1
- package/lib/families/celo/api/index.js.map +1 -1
- package/lib/families/celo/api/sdk.d.ts +22 -0
- package/lib/families/celo/api/sdk.d.ts.map +1 -1
- package/lib/families/celo/api/sdk.js +168 -1
- package/lib/families/celo/api/sdk.js.map +1 -1
- package/lib/families/celo/bridge/js.d.ts.map +1 -1
- package/lib/families/celo/bridge/js.js +4 -42
- package/lib/families/celo/bridge/js.js.map +1 -1
- package/lib/families/celo/cli-transaction.d.ts +12 -2
- package/lib/families/celo/cli-transaction.d.ts.map +1 -1
- package/lib/families/celo/cli-transaction.js +38 -4
- package/lib/families/celo/cli-transaction.js.map +1 -1
- package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts +1 -0
- package/lib/families/celo/datasets/celo.scanAccounts.1.d.ts.map +1 -1
- package/lib/families/celo/datasets/celo.scanAccounts.1.js +298 -2
- package/lib/families/celo/datasets/celo.scanAccounts.1.js.map +1 -1
- package/lib/families/celo/errors.d.ts +2 -0
- package/lib/families/celo/errors.d.ts.map +1 -0
- package/lib/families/celo/errors.js +6 -0
- package/lib/families/celo/errors.js.map +1 -0
- package/lib/families/celo/js-buildTransaction.d.ts +2 -3
- package/lib/families/celo/js-buildTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-buildTransaction.js +194 -19
- package/lib/families/celo/js-buildTransaction.js.map +1 -1
- package/lib/families/celo/js-createTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-createTransaction.js +3 -1
- package/lib/families/celo/js-createTransaction.js.map +1 -1
- package/lib/families/celo/js-estimateMaxSpendable.d.ts.map +1 -1
- package/lib/families/celo/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/celo/js-getFeesForTransaction.d.ts +2 -3
- package/lib/families/celo/js-getFeesForTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-getFeesForTransaction.js +137 -10
- package/lib/families/celo/js-getFeesForTransaction.js.map +1 -1
- package/lib/families/celo/js-getTransactionStatus.d.ts +2 -3
- package/lib/families/celo/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/celo/js-getTransactionStatus.js +97 -41
- package/lib/families/celo/js-getTransactionStatus.js.map +1 -1
- package/lib/families/celo/js-prepareTransaction.d.ts +2 -3
- package/lib/families/celo/js-prepareTransaction.d.ts.map +1 -1
- package/lib/families/celo/js-prepareTransaction.js +8 -3
- package/lib/families/celo/js-prepareTransaction.js.map +1 -1
- package/lib/families/celo/js-signOperation.d.ts.map +1 -1
- package/lib/families/celo/js-signOperation.js +17 -3
- package/lib/families/celo/js-signOperation.js.map +1 -1
- package/lib/families/celo/js-synchronisation.d.ts.map +1 -1
- package/lib/families/celo/js-synchronisation.js +51 -6
- package/lib/families/celo/js-synchronisation.js.map +1 -1
- package/lib/families/celo/logic.d.ts +21 -0
- package/lib/families/celo/logic.d.ts.map +1 -0
- package/lib/families/celo/logic.js +132 -0
- package/lib/families/celo/logic.js.map +1 -0
- package/lib/families/celo/preload.d.ts +10 -0
- package/lib/families/celo/preload.d.ts.map +1 -0
- package/lib/families/celo/preload.js +118 -0
- package/lib/families/celo/preload.js.map +1 -0
- package/lib/families/celo/react.d.ts +4 -0
- package/lib/families/celo/react.d.ts.map +1 -0
- package/lib/families/celo/react.js +47 -0
- package/lib/families/celo/react.js.map +1 -0
- package/lib/families/celo/serialization.d.ts +4 -0
- package/lib/families/celo/serialization.d.ts.map +1 -0
- package/lib/families/celo/serialization.js +55 -0
- package/lib/families/celo/serialization.js.map +1 -0
- package/lib/families/celo/specs/createActivateVoteMutation.d.ts +4 -0
- package/lib/families/celo/specs/createActivateVoteMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createActivateVoteMutation.js +38 -0
- package/lib/families/celo/specs/createActivateVoteMutation.js.map +1 -0
- package/lib/families/celo/specs/createLockMutation.d.ts +4 -0
- package/lib/families/celo/specs/createLockMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createLockMutation.js +40 -0
- package/lib/families/celo/specs/createLockMutation.js.map +1 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.d.ts +4 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.js +31 -0
- package/lib/families/celo/specs/createRegisterAccountMutation.js.map +1 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.d.ts +4 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.js +39 -0
- package/lib/families/celo/specs/createRevokeVoteMutation.js.map +1 -0
- package/lib/families/celo/specs/createSendMutation.d.ts +5 -0
- package/lib/families/celo/specs/createSendMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createSendMutation.js +44 -0
- package/lib/families/celo/specs/createSendMutation.js.map +1 -0
- package/lib/families/celo/specs/createUnlockMutation.d.ts +4 -0
- package/lib/families/celo/specs/createUnlockMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createUnlockMutation.js +37 -0
- package/lib/families/celo/specs/createUnlockMutation.js.map +1 -0
- package/lib/families/celo/specs/createVoteMutation.d.ts +4 -0
- package/lib/families/celo/specs/createVoteMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createVoteMutation.js +51 -0
- package/lib/families/celo/specs/createVoteMutation.js.map +1 -0
- package/lib/families/celo/specs/createWithdrawMutation.d.ts +4 -0
- package/lib/families/celo/specs/createWithdrawMutation.d.ts.map +1 -0
- package/lib/families/celo/specs/createWithdrawMutation.js +36 -0
- package/lib/families/celo/specs/createWithdrawMutation.js.map +1 -0
- package/lib/families/celo/specs/index.d.ts +9 -0
- package/lib/families/celo/specs/index.d.ts.map +1 -0
- package/lib/families/celo/specs/index.js +25 -0
- package/lib/families/celo/specs/index.js.map +1 -0
- package/lib/families/celo/specs.d.ts +1 -1
- package/lib/families/celo/specs.d.ts.map +1 -1
- package/lib/families/celo/specs.js +22 -37
- package/lib/families/celo/specs.js.map +1 -1
- package/lib/families/celo/speculos-deviceActions.d.ts +1 -4
- package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/celo/speculos-deviceActions.js +24 -4
- package/lib/families/celo/speculos-deviceActions.js.map +1 -1
- package/lib/families/celo/transaction.d.ts.map +1 -1
- package/lib/families/celo/transaction.js +8 -6
- package/lib/families/celo/transaction.js.map +1 -1
- package/lib/families/celo/types.d.ts +102 -1
- package/lib/families/celo/types.d.ts.map +1 -1
- package/lib/families/celo/validators.d.ts +3 -0
- package/lib/families/celo/validators.d.ts.map +1 -0
- package/lib/families/celo/validators.js +6 -0
- package/lib/families/celo/validators.js.map +1 -0
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +41 -25
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/cosmos/speculos-deviceActions.d.ts +1 -4
- package/lib/families/cosmos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cosmos/speculos-deviceActions.js +2 -4
- package/lib/families/cosmos/speculos-deviceActions.js.map +1 -1
- package/lib/families/crypto_org/specs.d.ts.map +1 -1
- package/lib/families/crypto_org/specs.js +3 -0
- package/lib/families/crypto_org/specs.js.map +1 -1
- package/lib/families/crypto_org/speculos-deviceActions.d.ts +1 -4
- package/lib/families/crypto_org/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/crypto_org/speculos-deviceActions.js +2 -2
- package/lib/families/crypto_org/speculos-deviceActions.js.map +1 -1
- package/lib/families/elrond/specs.d.ts.map +1 -1
- package/lib/families/elrond/specs.js +15 -2
- package/lib/families/elrond/specs.js.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.d.ts +1 -4
- package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.js +2 -4
- package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
- package/lib/families/ethereum/platformAdapter.test.d.ts +2 -0
- package/lib/families/ethereum/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/ethereum/platformAdapter.test.js +88 -0
- package/lib/families/ethereum/platformAdapter.test.js.map +1 -0
- package/lib/families/ethereum/specs.d.ts.map +1 -1
- package/lib/families/ethereum/specs.js +36 -12
- package/lib/families/ethereum/specs.js.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.d.ts +1 -4
- package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.js +2 -4
- package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
- package/lib/families/filecoin/specs.d.ts.map +1 -1
- package/lib/families/filecoin/specs.js +2 -0
- package/lib/families/filecoin/specs.js.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.d.ts +1 -4
- package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.js +2 -2
- package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/hedera/specs.d.ts.map +1 -1
- package/lib/families/hedera/specs.js +11 -3
- package/lib/families/hedera/specs.js.map +1 -1
- package/lib/families/hedera/speculos-deviceActions.d.ts +1 -4
- package/lib/families/hedera/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/hedera/speculos-deviceActions.js +4 -4
- package/lib/families/hedera/speculos-deviceActions.js.map +1 -1
- package/lib/families/osmosis/specs.d.ts.map +1 -1
- package/lib/families/osmosis/specs.js +13 -5
- package/lib/families/osmosis/specs.js.map +1 -1
- package/lib/families/osmosis/speculos-deviceActions.d.ts +1 -4
- package/lib/families/osmosis/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/osmosis/speculos-deviceActions.js +2 -4
- package/lib/families/osmosis/speculos-deviceActions.js.map +1 -1
- package/lib/families/polkadot/platformAdapter.test.d.ts +2 -0
- package/lib/families/polkadot/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/polkadot/platformAdapter.test.js +51 -0
- package/lib/families/polkadot/platformAdapter.test.js.map +1 -0
- package/lib/families/polkadot/specs.d.ts.map +1 -1
- package/lib/families/polkadot/specs.js +12 -1
- package/lib/families/polkadot/specs.js.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.d.ts +1 -4
- package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.js +2 -4
- package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
- package/lib/families/ripple/platformAdapter.test.d.ts +2 -0
- package/lib/families/ripple/platformAdapter.test.d.ts.map +1 -0
- package/lib/families/ripple/platformAdapter.test.js +51 -0
- package/lib/families/ripple/platformAdapter.test.js.map +1 -0
- package/lib/families/ripple/specs.d.ts.map +1 -1
- package/lib/families/ripple/specs.js +9 -4
- package/lib/families/ripple/specs.js.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.d.ts +1 -4
- package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.js +2 -4
- package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
- package/lib/families/solana/api/chain/instruction/token/types.d.ts +2 -2
- package/lib/families/solana/specs.d.ts.map +1 -1
- package/lib/families/solana/specs.js +29 -11
- package/lib/families/solana/specs.js.map +1 -1
- package/lib/families/solana/speculos-deviceActions.d.ts +0 -5
- package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/solana/speculos-deviceActions.js +0 -4
- package/lib/families/solana/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/api/horizon.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +15 -10
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/specs.d.ts.map +1 -1
- package/lib/families/stellar/specs.js +30 -12
- package/lib/families/stellar/specs.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts +1 -4
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +2 -4
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/tezos/bakers.whitelist-default.d.ts.map +1 -1
- package/lib/families/tezos/bakers.whitelist-default.js +1 -1
- package/lib/families/tezos/bakers.whitelist-default.js.map +1 -1
- package/lib/families/tezos/specs.d.ts.map +1 -1
- package/lib/families/tezos/specs.js +2 -0
- package/lib/families/tezos/specs.js.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.d.ts +1 -4
- package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.js +2 -2
- package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
- package/lib/families/tron/specs.d.ts.map +1 -1
- package/lib/families/tron/specs.js +49 -17
- package/lib/families/tron/specs.js.map +1 -1
- package/lib/families/tron/speculos-deviceActions.d.ts +1 -4
- package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tron/speculos-deviceActions.js +2 -4
- package/lib/families/tron/speculos-deviceActions.js.map +1 -1
- package/lib/generated/cli-transaction.d.ts +12 -2
- package/lib/generated/cli-transaction.d.ts.map +1 -1
- package/lib/hw/getGenuineCheckFromDeviceId.d.ts +22 -0
- package/lib/hw/getGenuineCheckFromDeviceId.d.ts.map +1 -0
- package/lib/hw/getGenuineCheckFromDeviceId.js +49 -0
- package/lib/hw/getGenuineCheckFromDeviceId.js.map +1 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.d.ts +2 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.d.ts.map +1 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.js +84 -0
- package/lib/hw/getGenuineCheckFromDeviceId.test.js.map +1 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.d.ts +17 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.d.ts.map +1 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.js +27 -0
- package/lib/hw/getLatestAvailableFirmwareFromDeviceId.js.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.d.ts +34 -0
- package/lib/hw/hooks/useGenuineCheck.d.ts.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.js +115 -0
- package/lib/hw/hooks/useGenuineCheck.js.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.test.d.ts +2 -0
- package/lib/hw/hooks/useGenuineCheck.test.d.ts.map +1 -0
- package/lib/hw/hooks/useGenuineCheck.test.js +316 -0
- package/lib/hw/hooks/useGenuineCheck.test.js.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.d.ts +29 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.d.ts.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.js +72 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.js.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.d.ts +2 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.d.ts.map +1 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.js +155 -0
- package/lib/hw/hooks/useGetLatestAvailableFirmware.test.js.map +1 -0
- package/lib/load/speculos.d.ts +1 -0
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +2 -1
- package/lib/load/speculos.js.map +1 -1
- package/lib/mock/fixtures/cryptoCurrencies.d.ts +5 -0
- package/lib/mock/fixtures/cryptoCurrencies.d.ts.map +1 -0
- package/lib/mock/fixtures/cryptoCurrencies.js +91 -0
- package/lib/mock/fixtures/cryptoCurrencies.js.map +1 -0
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +6 -0
- package/lib/operation.js.map +1 -1
- package/lib/platform/converters.test.js +44 -218
- package/lib/platform/converters.test.js.map +1 -1
- package/lib/platform/logic.d.ts +44 -0
- package/lib/platform/logic.d.ts.map +1 -1
- package/lib/platform/logic.js +147 -1
- package/lib/platform/logic.js.map +1 -1
- package/lib/platform/logic.test.d.ts +2 -0
- package/lib/platform/logic.test.d.ts.map +1 -0
- package/lib/platform/logic.test.js +903 -0
- package/lib/platform/logic.test.js.map +1 -0
- package/lib/platform/react.d.ts +6 -0
- package/lib/platform/react.d.ts.map +1 -1
- package/lib/platform/react.js +6 -0
- package/lib/platform/react.js.map +1 -1
- package/lib/platform/tracking.d.ts +1 -1
- package/lib/platform/tracking.d.ts.map +1 -1
- package/lib/platform/tracking.test.js +14 -41
- package/lib/platform/tracking.test.js.map +1 -1
- package/lib/reconciliation.d.ts.map +1 -1
- package/lib/reconciliation.js +39 -10
- package/lib/reconciliation.js.map +1 -1
- package/package.json +5 -7
- package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +2 -2
- package/src/__tests__/test-helpers/environment.ts +91 -0
- package/src/__tests__/test-helpers/setup.ts +2 -91
- package/src/account/serialization.ts +125 -66
- package/src/apps/support.ts +1 -0
- package/src/bot/bot-test-context.test.ts +37 -0
- package/src/bot/bot-test-context.ts +24 -0
- package/src/bot/cli.ts +18 -0
- package/src/bot/engine.ts +109 -73
- package/src/bot/formatters.ts +40 -14
- package/src/bot/index.ts +124 -18
- package/src/bot/specs.ts +10 -5
- package/src/bot/types.ts +7 -3
- package/src/countervalues/logic.integration.test.ts +50 -0
- package/src/countervalues/modules/weth.ts +9 -12
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +59 -1
- package/src/currencies/sortByMarketcap.test.ts +1 -12
- package/src/currencies/sortByMarketcap.ts +2 -22
- package/src/env.ts +1 -1
- package/src/families/algorand/__snapshots__/bridge.integration.test.ts.snap +733 -8
- package/src/families/algorand/specs.ts +26 -16
- package/src/families/algorand/speculos-deviceActions.ts +31 -10
- package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +43309 -7957
- package/src/families/bitcoin/bridge/mock.ts +7 -1
- package/src/families/bitcoin/datasets/bitcoin_cash.ts +73 -13
- package/src/families/bitcoin/datasets/dash.ts +29 -17
- package/src/families/bitcoin/datasets/decred.ts +42 -12
- package/src/families/bitcoin/datasets/digibyte.ts +9 -3
- package/src/families/bitcoin/datasets/dogecoin.ts +29 -17
- package/src/families/bitcoin/datasets/komodo.ts +22 -22
- package/src/families/bitcoin/datasets/litecoin.ts +9 -3
- package/src/families/bitcoin/datasets/peercoin.ts +17 -17
- package/src/families/bitcoin/datasets/pivx.ts +17 -17
- package/src/families/bitcoin/datasets/qtum.ts +40 -40
- package/src/families/bitcoin/datasets/stakenet.ts +56 -26
- package/src/families/bitcoin/datasets/vertcoin.ts +43 -55
- package/src/families/bitcoin/datasets/viacoin.ts +35 -23
- package/src/families/bitcoin/datasets/zcash.ts +78 -12
- package/src/families/bitcoin/datasets/zencash.ts +56 -10
- package/src/families/bitcoin/platformAdapter.test.ts +58 -0
- package/src/families/bitcoin/specs.ts +81 -41
- package/src/families/bitcoin/speculos-deviceActions.ts +68 -69
- package/src/families/cardano/js-estimateMaxSpendable.ts +1 -1
- package/src/families/cardano/specs.ts +28 -11
- package/src/families/cardano/speculos-deviceActions.ts +65 -66
- package/src/families/celo/__snapshots__/bridge.integration.test.ts.snap +134 -857
- package/src/families/celo/api/hubble.ts +113 -16
- package/src/families/celo/api/index.ts +1 -1
- package/src/families/celo/api/sdk.ts +88 -0
- package/src/families/celo/bridge/js.ts +2 -3
- package/src/families/celo/cli-transaction.ts +46 -2
- package/src/families/celo/datasets/celo.scanAccounts.1.ts +365 -5
- package/src/families/celo/errors.ts +5 -0
- package/src/families/celo/js-buildTransaction.ts +173 -20
- package/src/families/celo/js-createTransaction.ts +2 -0
- package/src/families/celo/js-estimateMaxSpendable.ts +2 -2
- package/src/families/celo/js-getFeesForTransaction.ts +118 -19
- package/src/families/celo/js-getTransactionStatus.ts +72 -17
- package/src/families/celo/js-prepareTransaction.ts +13 -7
- package/src/families/celo/js-signOperation.ts +22 -5
- package/src/families/celo/js-synchronisation.ts +32 -0
- package/src/families/celo/logic.ts +184 -0
- package/src/families/celo/preload.ts +78 -0
- package/src/families/celo/react.ts +35 -0
- package/src/families/celo/serialization.ts +61 -0
- package/src/families/celo/specs/createActivateVoteMutation.ts +44 -0
- package/src/families/celo/specs/createLockMutation.ts +46 -0
- package/src/families/celo/specs/createRegisterAccountMutation.ts +34 -0
- package/src/families/celo/specs/createRevokeVoteMutation.ts +43 -0
- package/src/families/celo/specs/createSendMutation.ts +44 -0
- package/src/families/celo/specs/createUnlockMutation.ts +44 -0
- package/src/families/celo/specs/createVoteMutation.ts +67 -0
- package/src/families/celo/specs/createWithdrawMutation.ts +44 -0
- package/src/families/celo/specs/index.ts +8 -0
- package/src/families/celo/specs.ts +34 -34
- package/src/families/celo/speculos-deviceActions.ts +63 -45
- package/src/families/celo/transaction.ts +12 -4
- package/src/families/celo/types.ts +113 -0
- package/src/families/celo/validators.ts +2 -0
- package/src/families/cosmos/__snapshots__/bridge.integration.test.ts.snap +246 -5
- package/src/families/cosmos/specs.ts +44 -28
- package/src/families/cosmos/speculos-deviceActions.ts +82 -83
- package/src/families/crypto_org/specs.ts +3 -0
- package/src/families/crypto_org/speculos-deviceActions.ts +58 -59
- package/src/families/elrond/specs.ts +21 -4
- package/src/families/elrond/speculos-deviceActions.ts +41 -42
- package/src/families/ethereum/__snapshots__/bridge.integration.test.ts.snap +90 -90
- package/src/families/ethereum/platformAdapter.test.ts +112 -0
- package/src/families/ethereum/specs.ts +47 -23
- package/src/families/ethereum/speculos-deviceActions.ts +93 -95
- package/src/families/filecoin/specs.ts +2 -1
- package/src/families/filecoin/speculos-deviceActions.ts +61 -62
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +57 -2
- package/src/families/hedera/specs.ts +13 -5
- package/src/families/hedera/speculos-deviceActions.ts +59 -60
- package/src/families/osmosis/specs.ts +15 -7
- package/src/families/osmosis/speculos-deviceActions.ts +82 -83
- package/src/families/polkadot/platformAdapter.test.ts +61 -0
- package/src/families/polkadot/specs.ts +20 -2
- package/src/families/polkadot/speculos-deviceActions.ts +83 -82
- package/src/families/ripple/platformAdapter.test.ts +54 -0
- package/src/families/ripple/specs.ts +14 -7
- package/src/families/ripple/speculos-deviceActions.ts +72 -73
- package/src/families/solana/specs.ts +33 -14
- package/src/families/solana/speculos-deviceActions.ts +0 -5
- package/src/families/stellar/api/horizon.ts +10 -6
- package/src/families/stellar/specs.ts +37 -19
- package/src/families/stellar/speculos-deviceActions.ts +85 -87
- package/src/families/tezos/bakers.whitelist-default.ts +0 -1
- package/src/families/tezos/specs.ts +2 -0
- package/src/families/tezos/speculos-deviceActions.ts +76 -77
- package/src/families/tron/specs.ts +67 -30
- package/src/families/tron/speculos-deviceActions.ts +81 -84
- package/src/hw/getGenuineCheckFromDeviceId.test.ts +98 -0
- package/src/hw/getGenuineCheckFromDeviceId.ts +61 -0
- package/src/hw/getLatestAvailableFirmwareFromDeviceId.ts +37 -0
- package/src/hw/hooks/useGenuineCheck.test.ts +232 -0
- package/src/hw/hooks/useGenuineCheck.ts +138 -0
- package/src/hw/hooks/useGetLatestAvailableFirmware.test.ts +111 -0
- package/src/hw/hooks/useGetLatestAvailableFirmware.ts +90 -0
- package/src/load/speculos.ts +2 -0
- package/src/mock/fixtures/cryptoCurrencies.ts +88 -0
- package/src/operation.ts +6 -0
- package/src/platform/converters.test.ts +49 -282
- package/src/platform/logic.test.ts +756 -0
- package/src/platform/logic.ts +285 -0
- package/src/platform/react.ts +6 -0
- package/src/platform/tracking.test.ts +6 -7
- package/src/platform/tracking.ts +1 -1
- package/src/reconciliation.ts +88 -43
- package/lib/bot/test.bot.d.ts +0 -2
- package/lib/bot/test.bot.d.ts.map +0 -1
- package/lib/bot/test.bot.js +0 -62
- package/lib/bot/test.bot.js.map +0 -1
- package/lib/generated/speculos-deviceActions.d.ts +0 -56
- package/lib/generated/speculos-deviceActions.d.ts.map +0 -1
- package/lib/generated/speculos-deviceActions.js +0 -42
- package/lib/generated/speculos-deviceActions.js.map +0 -1
- package/src/bot/test.bot.ts +0 -21
- package/src/generated/speculos-deviceActions.ts +0 -37
|
@@ -0,0 +1,903 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (_) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
73
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
74
|
+
if (!m) return o;
|
|
75
|
+
var i = m.call(o), r, ar = [], e;
|
|
76
|
+
try {
|
|
77
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
78
|
+
}
|
|
79
|
+
catch (error) { e = { error: error }; }
|
|
80
|
+
finally {
|
|
81
|
+
try {
|
|
82
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
83
|
+
}
|
|
84
|
+
finally { if (e) throw e.error; }
|
|
85
|
+
}
|
|
86
|
+
return ar;
|
|
87
|
+
};
|
|
88
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
89
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
90
|
+
if (ar || !(i in from)) {
|
|
91
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
92
|
+
ar[i] = from[i];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
96
|
+
};
|
|
97
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
98
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
99
|
+
};
|
|
100
|
+
exports.__esModule = true;
|
|
101
|
+
var logic_1 = require("./logic");
|
|
102
|
+
var cryptoCurrencies_1 = require("../mock/fixtures/cryptoCurrencies");
|
|
103
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
104
|
+
var converters = __importStar(require("./converters"));
|
|
105
|
+
var serializers = __importStar(require("./serializers"));
|
|
106
|
+
var signMessage = __importStar(require("../hw/signMessage/index"));
|
|
107
|
+
var currencies_1 = require("../currencies");
|
|
108
|
+
describe("receiveOnAccountLogic", function () {
|
|
109
|
+
// Given
|
|
110
|
+
var mockPlatformReceiveRequested = jest.fn();
|
|
111
|
+
var mockPlatformReceiveFail = jest.fn();
|
|
112
|
+
var context = createContextContainingAccountId({
|
|
113
|
+
platformReceiveRequested: mockPlatformReceiveRequested,
|
|
114
|
+
platformReceiveFail: mockPlatformReceiveFail
|
|
115
|
+
}, "11", "12");
|
|
116
|
+
var uiNavigation = jest.fn();
|
|
117
|
+
beforeEach(function () {
|
|
118
|
+
mockPlatformReceiveRequested.mockClear();
|
|
119
|
+
mockPlatformReceiveFail.mockClear();
|
|
120
|
+
uiNavigation.mockClear();
|
|
121
|
+
});
|
|
122
|
+
describe("when nominal case", function () {
|
|
123
|
+
// Given
|
|
124
|
+
var accountId = "ethereumjs:2:ethereum:0x012:";
|
|
125
|
+
var expectedResult = "Function called";
|
|
126
|
+
beforeEach(function () { return uiNavigation.mockResolvedValueOnce(expectedResult); });
|
|
127
|
+
it("calls uiNavigation callback with an accountAddress", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
128
|
+
var convertedAccount, result;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
convertedAccount = __assign(__assign({}, createPlatformAccount()), { address: "Converted address" });
|
|
133
|
+
jest
|
|
134
|
+
.spyOn(converters, "accountToPlatformAccount")
|
|
135
|
+
.mockReturnValueOnce(convertedAccount);
|
|
136
|
+
return [4 /*yield*/, (0, logic_1.receiveOnAccountLogic)(context, accountId, uiNavigation)];
|
|
137
|
+
case 1:
|
|
138
|
+
result = _a.sent();
|
|
139
|
+
// Then
|
|
140
|
+
expect(uiNavigation).toBeCalledTimes(1);
|
|
141
|
+
expect(uiNavigation.mock.calls[0][2]).toEqual("Converted address");
|
|
142
|
+
expect(result).toEqual(expectedResult);
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}); });
|
|
147
|
+
it("calls the tracking for success", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
// When
|
|
152
|
+
return [4 /*yield*/, (0, logic_1.receiveOnAccountLogic)(context, accountId, uiNavigation)];
|
|
153
|
+
case 1:
|
|
154
|
+
// When
|
|
155
|
+
_a.sent();
|
|
156
|
+
// Then
|
|
157
|
+
expect(mockPlatformReceiveRequested).toBeCalledTimes(1);
|
|
158
|
+
expect(mockPlatformReceiveFail).toBeCalledTimes(0);
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); });
|
|
163
|
+
});
|
|
164
|
+
describe("when account cannot be found", function () {
|
|
165
|
+
// Given
|
|
166
|
+
var nonFoundAccountId = "ethereumjs:2:ethereum:0x010:";
|
|
167
|
+
it("returns an error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
// When
|
|
172
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
switch (_a.label) {
|
|
175
|
+
case 0: return [4 /*yield*/, (0, logic_1.receiveOnAccountLogic)(context, nonFoundAccountId, uiNavigation)];
|
|
176
|
+
case 1:
|
|
177
|
+
_a.sent();
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}); }).rejects.toThrowError("Account required")];
|
|
182
|
+
case 1:
|
|
183
|
+
// When
|
|
184
|
+
_a.sent();
|
|
185
|
+
// Then
|
|
186
|
+
expect(uiNavigation).toBeCalledTimes(0);
|
|
187
|
+
return [2 /*return*/];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}); });
|
|
191
|
+
it("calls the tracking for error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
switch (_a.label) {
|
|
194
|
+
case 0:
|
|
195
|
+
// When
|
|
196
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
return __generator(this, function (_a) {
|
|
198
|
+
switch (_a.label) {
|
|
199
|
+
case 0: return [4 /*yield*/, (0, logic_1.receiveOnAccountLogic)(context, nonFoundAccountId, uiNavigation)];
|
|
200
|
+
case 1:
|
|
201
|
+
_a.sent();
|
|
202
|
+
return [2 /*return*/];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}); }).rejects.toThrow()];
|
|
206
|
+
case 1:
|
|
207
|
+
// When
|
|
208
|
+
_a.sent();
|
|
209
|
+
// Then
|
|
210
|
+
expect(mockPlatformReceiveRequested).toBeCalledTimes(1);
|
|
211
|
+
expect(mockPlatformReceiveFail).toBeCalledTimes(1);
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}); });
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("completeExchangeLogic", function () {
|
|
219
|
+
// Given
|
|
220
|
+
var mockPlatformCompleteExchangeRequested = jest.fn();
|
|
221
|
+
var context = createContextContainingAccountId({
|
|
222
|
+
platformCompleteExchangeRequested: mockPlatformCompleteExchangeRequested
|
|
223
|
+
}, "11", "12");
|
|
224
|
+
var uiNavigation = jest.fn();
|
|
225
|
+
beforeAll(function () {
|
|
226
|
+
(0, currencies_1.setSupportedCurrencies)(["bitcoin", "ethereum"]);
|
|
227
|
+
});
|
|
228
|
+
afterAll(function () {
|
|
229
|
+
(0, currencies_1.setSupportedCurrencies)([]);
|
|
230
|
+
});
|
|
231
|
+
beforeEach(function () {
|
|
232
|
+
mockPlatformCompleteExchangeRequested.mockClear();
|
|
233
|
+
uiNavigation.mockClear();
|
|
234
|
+
});
|
|
235
|
+
describe("when nominal case", function () {
|
|
236
|
+
// Given
|
|
237
|
+
var expectedResult = "Function called";
|
|
238
|
+
beforeEach(function () { return uiNavigation.mockResolvedValueOnce(expectedResult); });
|
|
239
|
+
it("calls uiNavigation callback", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
240
|
+
var fromAccount, rawPlatformTransaction, completeExchangeRequest, expectedTransaction, result;
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
switch (_a.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
fromAccount = (0, cryptoCurrencies_1.createFixtureAccount)("17");
|
|
245
|
+
context.accounts = __spreadArray(__spreadArray([], __read(context.accounts), false), [fromAccount], false);
|
|
246
|
+
rawPlatformTransaction = createRawEtherumTransaction();
|
|
247
|
+
completeExchangeRequest = {
|
|
248
|
+
provider: "provider",
|
|
249
|
+
fromAccountId: "ethereumjs:2:ethereum:0x017:",
|
|
250
|
+
toAccountId: "ethereumjs:2:ethereum:0x042:",
|
|
251
|
+
transaction: rawPlatformTransaction,
|
|
252
|
+
binaryPayload: "binaryPayload",
|
|
253
|
+
signature: "signature",
|
|
254
|
+
feesStrategy: "medium",
|
|
255
|
+
exchangeType: 8
|
|
256
|
+
};
|
|
257
|
+
expectedTransaction = {
|
|
258
|
+
family: "ethereum",
|
|
259
|
+
amount: new bignumber_js_1["default"]("1000000000"),
|
|
260
|
+
recipient: "0x0123456",
|
|
261
|
+
nonce: 8,
|
|
262
|
+
data: Buffer.from("Some data...", "hex"),
|
|
263
|
+
gasPrice: new bignumber_js_1["default"]("700000"),
|
|
264
|
+
userGasLimit: new bignumber_js_1["default"]("1200000"),
|
|
265
|
+
feesStrategy: "medium",
|
|
266
|
+
estimatedGasLimit: null,
|
|
267
|
+
feeCustomUnit: { name: "Gwei", code: "Gwei", magnitude: 9 },
|
|
268
|
+
mode: "send",
|
|
269
|
+
networkInfo: null,
|
|
270
|
+
useAllAmount: false
|
|
271
|
+
};
|
|
272
|
+
return [4 /*yield*/, (0, logic_1.completeExchangeLogic)(context, completeExchangeRequest, uiNavigation)];
|
|
273
|
+
case 1:
|
|
274
|
+
result = _a.sent();
|
|
275
|
+
// Then
|
|
276
|
+
expect(uiNavigation).toBeCalledTimes(1);
|
|
277
|
+
expect(uiNavigation.mock.calls[0][0]).toEqual({
|
|
278
|
+
provider: "provider",
|
|
279
|
+
exchange: {
|
|
280
|
+
fromAccount: fromAccount,
|
|
281
|
+
fromParentAccount: null,
|
|
282
|
+
toAccount: undefined,
|
|
283
|
+
toParentAccount: null
|
|
284
|
+
},
|
|
285
|
+
transaction: expectedTransaction,
|
|
286
|
+
binaryPayload: "binaryPayload",
|
|
287
|
+
signature: "signature",
|
|
288
|
+
feesStrategy: "medium",
|
|
289
|
+
exchangeType: 8
|
|
290
|
+
});
|
|
291
|
+
expect(result).toEqual(expectedResult);
|
|
292
|
+
return [2 /*return*/];
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}); });
|
|
296
|
+
it.each(["slow", "medium", "fast", "custom"])("calls uiNavigation with a transaction that has the %s feeStrategy", function (expectedFeeStrategy) { return __awaiter(void 0, void 0, void 0, function () {
|
|
297
|
+
var fromAccount, rawPlatformTransaction, completeExchangeRequest;
|
|
298
|
+
return __generator(this, function (_a) {
|
|
299
|
+
switch (_a.label) {
|
|
300
|
+
case 0:
|
|
301
|
+
fromAccount = (0, cryptoCurrencies_1.createFixtureAccount)("17");
|
|
302
|
+
context.accounts = __spreadArray(__spreadArray([], __read(context.accounts), false), [fromAccount], false);
|
|
303
|
+
rawPlatformTransaction = createRawEtherumTransaction();
|
|
304
|
+
completeExchangeRequest = {
|
|
305
|
+
provider: "provider",
|
|
306
|
+
fromAccountId: "ethereumjs:2:ethereum:0x017:",
|
|
307
|
+
toAccountId: "ethereumjs:2:ethereum:0x042:",
|
|
308
|
+
transaction: rawPlatformTransaction,
|
|
309
|
+
binaryPayload: "binaryPayload",
|
|
310
|
+
signature: "signature",
|
|
311
|
+
feesStrategy: expectedFeeStrategy,
|
|
312
|
+
exchangeType: 8
|
|
313
|
+
};
|
|
314
|
+
// When
|
|
315
|
+
return [4 /*yield*/, (0, logic_1.completeExchangeLogic)(context, completeExchangeRequest, uiNavigation)];
|
|
316
|
+
case 1:
|
|
317
|
+
// When
|
|
318
|
+
_a.sent();
|
|
319
|
+
// Then
|
|
320
|
+
expect(uiNavigation).toBeCalledTimes(1);
|
|
321
|
+
expect(uiNavigation.mock.calls[0][0]["transaction"].feesStrategy).toEqual(expectedFeeStrategy);
|
|
322
|
+
return [2 /*return*/];
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}); });
|
|
326
|
+
it("calls the tracking for success", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
327
|
+
var completeExchangeRequest;
|
|
328
|
+
return __generator(this, function (_a) {
|
|
329
|
+
switch (_a.label) {
|
|
330
|
+
case 0:
|
|
331
|
+
completeExchangeRequest = {
|
|
332
|
+
provider: "provider",
|
|
333
|
+
fromAccountId: "ethereumjs:2:ethereum:0x012:",
|
|
334
|
+
toAccountId: "ethereumjs:2:ethereum:0x042:",
|
|
335
|
+
transaction: createRawEtherumTransaction(),
|
|
336
|
+
binaryPayload: "binaryPayload",
|
|
337
|
+
signature: "signature",
|
|
338
|
+
feesStrategy: "feeStrategy",
|
|
339
|
+
exchangeType: 8
|
|
340
|
+
};
|
|
341
|
+
// When
|
|
342
|
+
return [4 /*yield*/, (0, logic_1.completeExchangeLogic)(context, completeExchangeRequest, uiNavigation)];
|
|
343
|
+
case 1:
|
|
344
|
+
// When
|
|
345
|
+
_a.sent();
|
|
346
|
+
// Then
|
|
347
|
+
expect(mockPlatformCompleteExchangeRequested).toBeCalledTimes(1);
|
|
348
|
+
return [2 /*return*/];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}); });
|
|
352
|
+
});
|
|
353
|
+
describe("when Account is from a different family than the transaction", function () {
|
|
354
|
+
// Given
|
|
355
|
+
var expectedResult = "Function called";
|
|
356
|
+
beforeEach(function () { return uiNavigation.mockResolvedValueOnce(expectedResult); });
|
|
357
|
+
it("returns an error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
358
|
+
var fromAccount, rawPlatformTransaction, completeExchangeRequest;
|
|
359
|
+
return __generator(this, function (_a) {
|
|
360
|
+
switch (_a.label) {
|
|
361
|
+
case 0:
|
|
362
|
+
fromAccount = (0, cryptoCurrencies_1.createFixtureAccount)("17");
|
|
363
|
+
context.accounts = __spreadArray(__spreadArray([], __read(context.accounts), false), [fromAccount], false);
|
|
364
|
+
rawPlatformTransaction = createRawBitcoinTransaction();
|
|
365
|
+
completeExchangeRequest = {
|
|
366
|
+
provider: "provider",
|
|
367
|
+
fromAccountId: "ethereumjs:2:ethereum:0x017:",
|
|
368
|
+
toAccountId: "ethereumjs:2:ethereum:0x042:",
|
|
369
|
+
transaction: rawPlatformTransaction,
|
|
370
|
+
binaryPayload: "binaryPayload",
|
|
371
|
+
signature: "signature",
|
|
372
|
+
feesStrategy: "feeStrategy",
|
|
373
|
+
exchangeType: 8
|
|
374
|
+
};
|
|
375
|
+
// When
|
|
376
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
377
|
+
return __generator(this, function (_a) {
|
|
378
|
+
switch (_a.label) {
|
|
379
|
+
case 0: return [4 /*yield*/, (0, logic_1.completeExchangeLogic)(context, completeExchangeRequest, uiNavigation)];
|
|
380
|
+
case 1:
|
|
381
|
+
_a.sent();
|
|
382
|
+
return [2 /*return*/];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}); }).rejects.toThrowError("Account and transaction must be from the same family")];
|
|
386
|
+
case 1:
|
|
387
|
+
// When
|
|
388
|
+
_a.sent();
|
|
389
|
+
// Then
|
|
390
|
+
expect(uiNavigation).toBeCalledTimes(0);
|
|
391
|
+
return [2 /*return*/];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}); });
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
describe("broadcastTransactionLogic", function () {
|
|
398
|
+
// Given
|
|
399
|
+
var mockplatformBroadcastFail = jest.fn();
|
|
400
|
+
var context = createContextContainingAccountId({
|
|
401
|
+
platformBroadcastFail: mockplatformBroadcastFail
|
|
402
|
+
}, "11", "12");
|
|
403
|
+
var uiNavigation = jest.fn();
|
|
404
|
+
beforeEach(function () {
|
|
405
|
+
mockplatformBroadcastFail.mockClear();
|
|
406
|
+
uiNavigation.mockClear();
|
|
407
|
+
});
|
|
408
|
+
describe("when nominal case", function () {
|
|
409
|
+
// Given
|
|
410
|
+
var accountId = "ethereumjs:2:ethereum:0x012:";
|
|
411
|
+
var rawSignedTransaction = createSignedOperationRaw();
|
|
412
|
+
it("calls uiNavigation callback with a signedOperation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
413
|
+
var expectedResult, signedOperation, result;
|
|
414
|
+
return __generator(this, function (_a) {
|
|
415
|
+
switch (_a.label) {
|
|
416
|
+
case 0:
|
|
417
|
+
expectedResult = "Function called";
|
|
418
|
+
signedOperation = createSignedOperation();
|
|
419
|
+
jest
|
|
420
|
+
.spyOn(serializers, "deserializePlatformSignedTransaction")
|
|
421
|
+
.mockReturnValueOnce(signedOperation);
|
|
422
|
+
uiNavigation.mockResolvedValueOnce(expectedResult);
|
|
423
|
+
return [4 /*yield*/, (0, logic_1.broadcastTransactionLogic)(context, accountId, rawSignedTransaction, uiNavigation)];
|
|
424
|
+
case 1:
|
|
425
|
+
result = _a.sent();
|
|
426
|
+
// Then
|
|
427
|
+
expect(uiNavigation).toBeCalledTimes(1);
|
|
428
|
+
expect(uiNavigation.mock.calls[0][2]).toEqual(signedOperation);
|
|
429
|
+
expect(result).toEqual(expectedResult);
|
|
430
|
+
return [2 /*return*/];
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}); });
|
|
434
|
+
it("calls the tracking for success", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
435
|
+
return __generator(this, function (_a) {
|
|
436
|
+
switch (_a.label) {
|
|
437
|
+
case 0:
|
|
438
|
+
// When
|
|
439
|
+
return [4 /*yield*/, (0, logic_1.broadcastTransactionLogic)(context, accountId, rawSignedTransaction, uiNavigation)];
|
|
440
|
+
case 1:
|
|
441
|
+
// When
|
|
442
|
+
_a.sent();
|
|
443
|
+
// Then
|
|
444
|
+
expect(mockplatformBroadcastFail).toBeCalledTimes(0);
|
|
445
|
+
return [2 /*return*/];
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}); });
|
|
449
|
+
});
|
|
450
|
+
describe("when account cannot be found", function () {
|
|
451
|
+
// Given
|
|
452
|
+
var nonFoundAccountId = "ethereumjs:2:ethereum:0x010:";
|
|
453
|
+
var rawSignedTransaction = createSignedOperationRaw();
|
|
454
|
+
it("returns an error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
455
|
+
var expectedResult, signedOperation;
|
|
456
|
+
return __generator(this, function (_a) {
|
|
457
|
+
switch (_a.label) {
|
|
458
|
+
case 0:
|
|
459
|
+
expectedResult = "Function called";
|
|
460
|
+
signedOperation = createSignedOperation();
|
|
461
|
+
jest
|
|
462
|
+
.spyOn(serializers, "deserializePlatformSignedTransaction")
|
|
463
|
+
.mockReturnValueOnce(signedOperation);
|
|
464
|
+
uiNavigation.mockResolvedValueOnce(expectedResult);
|
|
465
|
+
// When
|
|
466
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
467
|
+
return __generator(this, function (_a) {
|
|
468
|
+
switch (_a.label) {
|
|
469
|
+
case 0: return [4 /*yield*/, (0, logic_1.broadcastTransactionLogic)(context, nonFoundAccountId, rawSignedTransaction, uiNavigation)];
|
|
470
|
+
case 1:
|
|
471
|
+
_a.sent();
|
|
472
|
+
return [2 /*return*/];
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
}); }).rejects.toThrowError("Account required")];
|
|
476
|
+
case 1:
|
|
477
|
+
// When
|
|
478
|
+
_a.sent();
|
|
479
|
+
// Then
|
|
480
|
+
expect(uiNavigation).toBeCalledTimes(0);
|
|
481
|
+
return [2 /*return*/];
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}); });
|
|
485
|
+
it("calls the tracking for error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
486
|
+
return __generator(this, function (_a) {
|
|
487
|
+
switch (_a.label) {
|
|
488
|
+
case 0:
|
|
489
|
+
// When
|
|
490
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
491
|
+
return __generator(this, function (_a) {
|
|
492
|
+
switch (_a.label) {
|
|
493
|
+
case 0: return [4 /*yield*/, (0, logic_1.broadcastTransactionLogic)(context, nonFoundAccountId, rawSignedTransaction, uiNavigation)];
|
|
494
|
+
case 1:
|
|
495
|
+
_a.sent();
|
|
496
|
+
return [2 /*return*/];
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}); }).rejects.toThrow()];
|
|
500
|
+
case 1:
|
|
501
|
+
// When
|
|
502
|
+
_a.sent();
|
|
503
|
+
// Then
|
|
504
|
+
expect(mockplatformBroadcastFail).toBeCalledTimes(1);
|
|
505
|
+
return [2 /*return*/];
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}); });
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
describe("signMessageLogic", function () {
|
|
512
|
+
// Given
|
|
513
|
+
var mockPlatformSignMessageRequested = jest.fn();
|
|
514
|
+
var mockPlatformSignMessageFail = jest.fn();
|
|
515
|
+
var context = createContextContainingAccountId({
|
|
516
|
+
platformSignMessageRequested: mockPlatformSignMessageRequested,
|
|
517
|
+
platformSignMessageFail: mockPlatformSignMessageFail
|
|
518
|
+
}, "11", "12");
|
|
519
|
+
var uiNavigation = jest.fn();
|
|
520
|
+
beforeEach(function () {
|
|
521
|
+
mockPlatformSignMessageRequested.mockClear();
|
|
522
|
+
mockPlatformSignMessageFail.mockClear();
|
|
523
|
+
uiNavigation.mockClear();
|
|
524
|
+
});
|
|
525
|
+
describe("when nominal case", function () {
|
|
526
|
+
// Given
|
|
527
|
+
var accountId = "ethereumjs:2:ethereum:0x012:";
|
|
528
|
+
var messageToSign = "Message to sign";
|
|
529
|
+
var spyPrepareMessageToSign = jest.spyOn(signMessage, "prepareMessageToSign");
|
|
530
|
+
beforeEach(function () { return spyPrepareMessageToSign.mockClear(); });
|
|
531
|
+
it("calls uiNavigation callback with a signedOperation", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
532
|
+
var expectedResult, formattedMessage, result;
|
|
533
|
+
return __generator(this, function (_a) {
|
|
534
|
+
switch (_a.label) {
|
|
535
|
+
case 0:
|
|
536
|
+
expectedResult = "Function called";
|
|
537
|
+
formattedMessage = createMessageData();
|
|
538
|
+
spyPrepareMessageToSign.mockReturnValueOnce(formattedMessage);
|
|
539
|
+
uiNavigation.mockResolvedValueOnce(expectedResult);
|
|
540
|
+
return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, accountId, messageToSign, uiNavigation)];
|
|
541
|
+
case 1:
|
|
542
|
+
result = _a.sent();
|
|
543
|
+
// Then
|
|
544
|
+
expect(uiNavigation).toBeCalledTimes(1);
|
|
545
|
+
expect(uiNavigation.mock.calls[0][1]).toEqual(formattedMessage);
|
|
546
|
+
expect(result).toEqual(expectedResult);
|
|
547
|
+
return [2 /*return*/];
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}); });
|
|
551
|
+
it("calls the tracking for success", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
552
|
+
return __generator(this, function (_a) {
|
|
553
|
+
switch (_a.label) {
|
|
554
|
+
case 0:
|
|
555
|
+
// When
|
|
556
|
+
return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, accountId, messageToSign, uiNavigation)];
|
|
557
|
+
case 1:
|
|
558
|
+
// When
|
|
559
|
+
_a.sent();
|
|
560
|
+
// Then
|
|
561
|
+
expect(mockPlatformSignMessageRequested).toBeCalledTimes(1);
|
|
562
|
+
expect(mockPlatformSignMessageFail).toBeCalledTimes(0);
|
|
563
|
+
return [2 /*return*/];
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
}); });
|
|
567
|
+
});
|
|
568
|
+
describe("when account cannot be found", function () {
|
|
569
|
+
// Given
|
|
570
|
+
var nonFoundAccountId = "ethereumjs:2:ethereum:0x010:";
|
|
571
|
+
var messageToSign = "Message to sign";
|
|
572
|
+
it("returns an error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
573
|
+
return __generator(this, function (_a) {
|
|
574
|
+
switch (_a.label) {
|
|
575
|
+
case 0:
|
|
576
|
+
// When
|
|
577
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
578
|
+
return __generator(this, function (_a) {
|
|
579
|
+
switch (_a.label) {
|
|
580
|
+
case 0: return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, nonFoundAccountId, messageToSign, uiNavigation)];
|
|
581
|
+
case 1:
|
|
582
|
+
_a.sent();
|
|
583
|
+
return [2 /*return*/];
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
}); }).rejects.toThrowError("account not found")];
|
|
587
|
+
case 1:
|
|
588
|
+
// When
|
|
589
|
+
_a.sent();
|
|
590
|
+
// Then
|
|
591
|
+
expect(uiNavigation).toBeCalledTimes(0);
|
|
592
|
+
return [2 /*return*/];
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}); });
|
|
596
|
+
it("calls the tracking for error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
597
|
+
return __generator(this, function (_a) {
|
|
598
|
+
switch (_a.label) {
|
|
599
|
+
case 0:
|
|
600
|
+
// When
|
|
601
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
602
|
+
return __generator(this, function (_a) {
|
|
603
|
+
switch (_a.label) {
|
|
604
|
+
case 0: return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, nonFoundAccountId, messageToSign, uiNavigation)];
|
|
605
|
+
case 1:
|
|
606
|
+
_a.sent();
|
|
607
|
+
return [2 /*return*/];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}); }).rejects.toThrow()];
|
|
611
|
+
case 1:
|
|
612
|
+
// When
|
|
613
|
+
_a.sent();
|
|
614
|
+
// Then
|
|
615
|
+
expect(mockPlatformSignMessageRequested).toBeCalledTimes(1);
|
|
616
|
+
expect(mockPlatformSignMessageFail).toBeCalledTimes(1);
|
|
617
|
+
return [2 /*return*/];
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}); });
|
|
621
|
+
});
|
|
622
|
+
describe("when account found is not of type 'Account'", function () {
|
|
623
|
+
// Given
|
|
624
|
+
var tokenAccountId = "15";
|
|
625
|
+
var messageToSign = "Message to sign";
|
|
626
|
+
context.accounts = __spreadArray([
|
|
627
|
+
createTokenAccount(tokenAccountId)
|
|
628
|
+
], __read(context.accounts), false);
|
|
629
|
+
it("returns an error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
630
|
+
return __generator(this, function (_a) {
|
|
631
|
+
switch (_a.label) {
|
|
632
|
+
case 0:
|
|
633
|
+
// When
|
|
634
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
635
|
+
return __generator(this, function (_a) {
|
|
636
|
+
switch (_a.label) {
|
|
637
|
+
case 0: return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, tokenAccountId, messageToSign, uiNavigation)];
|
|
638
|
+
case 1:
|
|
639
|
+
_a.sent();
|
|
640
|
+
return [2 /*return*/];
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}); }).rejects.toThrowError("account provided should be the main one")];
|
|
644
|
+
case 1:
|
|
645
|
+
// When
|
|
646
|
+
_a.sent();
|
|
647
|
+
// Then
|
|
648
|
+
expect(uiNavigation).toBeCalledTimes(0);
|
|
649
|
+
return [2 /*return*/];
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}); });
|
|
653
|
+
it("calls the tracking for error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
654
|
+
return __generator(this, function (_a) {
|
|
655
|
+
switch (_a.label) {
|
|
656
|
+
case 0:
|
|
657
|
+
// When
|
|
658
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
659
|
+
return __generator(this, function (_a) {
|
|
660
|
+
switch (_a.label) {
|
|
661
|
+
case 0: return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, tokenAccountId, messageToSign, uiNavigation)];
|
|
662
|
+
case 1:
|
|
663
|
+
_a.sent();
|
|
664
|
+
return [2 /*return*/];
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}); }).rejects.toThrow()];
|
|
668
|
+
case 1:
|
|
669
|
+
// When
|
|
670
|
+
_a.sent();
|
|
671
|
+
// Then
|
|
672
|
+
expect(mockPlatformSignMessageRequested).toBeCalledTimes(1);
|
|
673
|
+
expect(mockPlatformSignMessageFail).toBeCalledTimes(1);
|
|
674
|
+
return [2 /*return*/];
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}); });
|
|
678
|
+
});
|
|
679
|
+
describe("when inner call prepareMessageToSign raise an error", function () {
|
|
680
|
+
// Given
|
|
681
|
+
var accountId = "ethereumjs:2:ethereum:0x012:";
|
|
682
|
+
var messageToSign = "Message to sign";
|
|
683
|
+
var spyPrepareMessageToSign = jest.spyOn(signMessage, "prepareMessageToSign");
|
|
684
|
+
beforeEach(function () { return spyPrepareMessageToSign.mockClear(); });
|
|
685
|
+
it("returns an error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
686
|
+
return __generator(this, function (_a) {
|
|
687
|
+
switch (_a.label) {
|
|
688
|
+
case 0:
|
|
689
|
+
// Given
|
|
690
|
+
spyPrepareMessageToSign.mockImplementationOnce(function () {
|
|
691
|
+
throw new Error("Some error");
|
|
692
|
+
});
|
|
693
|
+
// When
|
|
694
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
695
|
+
return __generator(this, function (_a) {
|
|
696
|
+
switch (_a.label) {
|
|
697
|
+
case 0: return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, accountId, messageToSign, uiNavigation)];
|
|
698
|
+
case 1:
|
|
699
|
+
_a.sent();
|
|
700
|
+
return [2 /*return*/];
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}); }).rejects.toThrowError("Some error")];
|
|
704
|
+
case 1:
|
|
705
|
+
// When
|
|
706
|
+
_a.sent();
|
|
707
|
+
// Then
|
|
708
|
+
expect(uiNavigation).toBeCalledTimes(0);
|
|
709
|
+
return [2 /*return*/];
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}); });
|
|
713
|
+
it("calls the tracking for error", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
714
|
+
return __generator(this, function (_a) {
|
|
715
|
+
switch (_a.label) {
|
|
716
|
+
case 0:
|
|
717
|
+
// Given
|
|
718
|
+
spyPrepareMessageToSign.mockImplementationOnce(function () {
|
|
719
|
+
throw new Error("Some error");
|
|
720
|
+
});
|
|
721
|
+
// When
|
|
722
|
+
return [4 /*yield*/, expect(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
723
|
+
return __generator(this, function (_a) {
|
|
724
|
+
switch (_a.label) {
|
|
725
|
+
case 0: return [4 /*yield*/, (0, logic_1.signMessageLogic)(context, accountId, messageToSign, uiNavigation)];
|
|
726
|
+
case 1:
|
|
727
|
+
_a.sent();
|
|
728
|
+
return [2 /*return*/];
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}); }).rejects.toThrow()];
|
|
732
|
+
case 1:
|
|
733
|
+
// When
|
|
734
|
+
_a.sent();
|
|
735
|
+
// Then
|
|
736
|
+
expect(mockPlatformSignMessageRequested).toBeCalledTimes(1);
|
|
737
|
+
expect(mockPlatformSignMessageFail).toBeCalledTimes(1);
|
|
738
|
+
return [2 /*return*/];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
}); });
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
function createAppManifest(id) {
|
|
745
|
+
if (id === void 0) { id = "1"; }
|
|
746
|
+
return {
|
|
747
|
+
id: id,
|
|
748
|
+
private: false,
|
|
749
|
+
name: "New App Manifest",
|
|
750
|
+
url: "https://www.ledger.com",
|
|
751
|
+
homepageUrl: "https://www.ledger.com",
|
|
752
|
+
supportUrl: "https://www.ledger.com",
|
|
753
|
+
icon: null,
|
|
754
|
+
platform: "all",
|
|
755
|
+
apiVersion: "1.0.0",
|
|
756
|
+
manifestVersion: "1.0.0",
|
|
757
|
+
branch: "debug",
|
|
758
|
+
params: undefined,
|
|
759
|
+
categories: [],
|
|
760
|
+
currencies: "*",
|
|
761
|
+
content: {
|
|
762
|
+
shortDescription: {
|
|
763
|
+
en: "short description"
|
|
764
|
+
},
|
|
765
|
+
description: {
|
|
766
|
+
en: "description"
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
permissions: [],
|
|
770
|
+
domains: []
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
function createContextContainingAccountId(tracking) {
|
|
774
|
+
var accountIds = [];
|
|
775
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
776
|
+
accountIds[_i - 1] = arguments[_i];
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
manifest: createAppManifest(),
|
|
780
|
+
accounts: __spreadArray(__spreadArray([], __read(accountIds.map(function (val) { return (0, cryptoCurrencies_1.createFixtureAccount)(val); })), false), [
|
|
781
|
+
(0, cryptoCurrencies_1.createFixtureAccount)(),
|
|
782
|
+
], false),
|
|
783
|
+
tracking: tracking
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function createSignedOperation() {
|
|
787
|
+
var operation = {
|
|
788
|
+
id: "42",
|
|
789
|
+
hash: "hashed",
|
|
790
|
+
type: "IN",
|
|
791
|
+
value: new bignumber_js_1["default"](0),
|
|
792
|
+
fee: new bignumber_js_1["default"](0),
|
|
793
|
+
senders: [],
|
|
794
|
+
recipients: [],
|
|
795
|
+
blockHeight: null,
|
|
796
|
+
blockHash: null,
|
|
797
|
+
accountId: "14",
|
|
798
|
+
date: new Date(),
|
|
799
|
+
extra: {}
|
|
800
|
+
};
|
|
801
|
+
return {
|
|
802
|
+
operation: operation,
|
|
803
|
+
signature: "Signature",
|
|
804
|
+
expirationDate: null
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function createSignedOperationRaw() {
|
|
808
|
+
var rawOperation = {
|
|
809
|
+
id: "12",
|
|
810
|
+
hash: "123456",
|
|
811
|
+
type: "CREATE",
|
|
812
|
+
value: "0",
|
|
813
|
+
fee: "0",
|
|
814
|
+
senders: [],
|
|
815
|
+
recipients: [],
|
|
816
|
+
blockHeight: null,
|
|
817
|
+
blockHash: null,
|
|
818
|
+
accountId: "12",
|
|
819
|
+
date: "01/01/1970",
|
|
820
|
+
extra: {}
|
|
821
|
+
};
|
|
822
|
+
return {
|
|
823
|
+
operation: rawOperation,
|
|
824
|
+
signature: "Signature",
|
|
825
|
+
expirationDate: null
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function createPlatformAccount() {
|
|
829
|
+
return {
|
|
830
|
+
id: "12",
|
|
831
|
+
name: "",
|
|
832
|
+
address: "",
|
|
833
|
+
currency: "",
|
|
834
|
+
balance: new bignumber_js_1["default"](0),
|
|
835
|
+
spendableBalance: new bignumber_js_1["default"](0),
|
|
836
|
+
blockHeight: 0,
|
|
837
|
+
lastSyncDate: new Date()
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
function createMessageData() {
|
|
841
|
+
return {
|
|
842
|
+
currency: (0, cryptoCurrencies_1.createFixtureCryptoCurrency)("eth"),
|
|
843
|
+
path: "path",
|
|
844
|
+
derivationMode: "ethM",
|
|
845
|
+
message: "default message",
|
|
846
|
+
rawMessage: "raw default message"
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
function createTokenAccount(id) {
|
|
850
|
+
if (id === void 0) { id = "32"; }
|
|
851
|
+
return {
|
|
852
|
+
type: "TokenAccount",
|
|
853
|
+
id: id,
|
|
854
|
+
parentId: "whatever",
|
|
855
|
+
token: createTokenCurrency(),
|
|
856
|
+
balance: new bignumber_js_1["default"](0),
|
|
857
|
+
spendableBalance: new bignumber_js_1["default"](0),
|
|
858
|
+
creationDate: new Date(),
|
|
859
|
+
operationsCount: 0,
|
|
860
|
+
operations: [],
|
|
861
|
+
pendingOperations: [],
|
|
862
|
+
starred: false,
|
|
863
|
+
balanceHistoryCache: {
|
|
864
|
+
WEEK: { latestDate: null, balances: [] },
|
|
865
|
+
HOUR: { latestDate: null, balances: [] },
|
|
866
|
+
DAY: { latestDate: null, balances: [] }
|
|
867
|
+
},
|
|
868
|
+
swapHistory: []
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
function createTokenCurrency() {
|
|
872
|
+
return {
|
|
873
|
+
type: "TokenCurrency",
|
|
874
|
+
id: "3",
|
|
875
|
+
contractAddress: "",
|
|
876
|
+
parentCurrency: (0, cryptoCurrencies_1.createFixtureCryptoCurrency)("eth"),
|
|
877
|
+
tokenType: "",
|
|
878
|
+
//-- CurrencyCommon
|
|
879
|
+
name: "",
|
|
880
|
+
ticker: "",
|
|
881
|
+
units: []
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function createRawEtherumTransaction() {
|
|
885
|
+
return {
|
|
886
|
+
family: "ethereum",
|
|
887
|
+
amount: "1000000000",
|
|
888
|
+
recipient: "0x0123456",
|
|
889
|
+
nonce: 8,
|
|
890
|
+
data: "Some data...",
|
|
891
|
+
gasPrice: "700000",
|
|
892
|
+
gasLimit: "1200000"
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function createRawBitcoinTransaction() {
|
|
896
|
+
return {
|
|
897
|
+
family: "bitcoin",
|
|
898
|
+
amount: "1000000000",
|
|
899
|
+
recipient: "0x0123456",
|
|
900
|
+
feePerByte: "900000"
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
//# sourceMappingURL=logic.test.js.map
|