@ledgerhq/live-common 27.0.0 → 27.0.1-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/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.map +1 -1
- package/lib/account/serialization.js +83 -40
- package/lib/account/serialization.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/specs.d.ts.map +1 -1
- package/lib/families/celo/specs.js +2 -0
- 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 +2 -4
- package/lib/families/celo/speculos-deviceActions.js.map +1 -1
- 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/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/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/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 +28 -10
- package/lib/reconciliation.js.map +1 -1
- package/package.json +5 -6
- 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 +103 -64
- 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/specs.ts +2 -0
- package/src/families/celo/speculos-deviceActions.ts +42 -43
- 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/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 +66 -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
package/src/bot/formatters.ts
CHANGED
|
@@ -8,30 +8,54 @@ import {
|
|
|
8
8
|
import { formatCurrencyUnit } from "../currencies";
|
|
9
9
|
import type { MutationReport, AppCandidate } from "./types";
|
|
10
10
|
import type { Transaction } from "../generated/types";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { getContext } from "./bot-test-context";
|
|
12
|
+
|
|
13
|
+
const formatTimeMinSec = (t: number) => {
|
|
14
|
+
const totalsecs = Math.round(t / 1000);
|
|
15
|
+
const min = Math.floor(totalsecs / 60);
|
|
16
|
+
const sec = totalsecs - min * 60;
|
|
17
|
+
if (!sec) return `${min}min`;
|
|
18
|
+
return `${min}min ${sec}s`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const formatTime = (t: number): string =>
|
|
22
|
+
!t
|
|
23
|
+
? "N/A"
|
|
24
|
+
: t > 3000
|
|
25
|
+
? t > 100000
|
|
26
|
+
? formatTimeMinSec(t)
|
|
27
|
+
: `${Math.round(t / 100) / 10}s`
|
|
14
28
|
: `${t < 5 ? t.toFixed(2) : t.toFixed(0)}ms`;
|
|
15
29
|
|
|
16
30
|
const formatDt = (from, to) => (from && to ? formatTime(to - from) : "?");
|
|
17
31
|
|
|
18
|
-
export function formatAppCandidate(appCandidate: AppCandidate) {
|
|
32
|
+
export function formatAppCandidate(appCandidate: AppCandidate): string {
|
|
19
33
|
return `${appCandidate.appName} ${appCandidate.appVersion} on ${appCandidate.model} ${appCandidate.firmware}`;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
export function formatError(e:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
out = "raw object: " + JSON.stringify(e);
|
|
27
|
-
} catch (_e) {
|
|
36
|
+
export function formatError(e: unknown, longform = false): string {
|
|
37
|
+
let out = "";
|
|
38
|
+
if (!e || typeof e !== "object") {
|
|
28
39
|
out = String(e);
|
|
40
|
+
} else if (e instanceof Error) {
|
|
41
|
+
const ctx = getContext(e);
|
|
42
|
+
if (ctx) out += `TEST ${ctx}\n`;
|
|
43
|
+
out += String(e);
|
|
44
|
+
} else {
|
|
45
|
+
try {
|
|
46
|
+
out = "raw object: " + JSON.stringify(e);
|
|
47
|
+
} catch (_e) {
|
|
48
|
+
out = String(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (longform) {
|
|
52
|
+
return out.slice(0, 500);
|
|
29
53
|
}
|
|
30
|
-
return out.replace(/\n/g, " ").slice(0,
|
|
54
|
+
return out.replace(/[`]/g, "").replace(/\n/g, " ").slice(0, 200);
|
|
31
55
|
}
|
|
32
56
|
|
|
33
57
|
export function formatReportForConsole<T extends Transaction>({
|
|
34
|
-
|
|
58
|
+
resyncAccountsDuration,
|
|
35
59
|
appCandidate,
|
|
36
60
|
account,
|
|
37
61
|
maxSpendable,
|
|
@@ -54,7 +78,9 @@ export function formatReportForConsole<T extends Transaction>({
|
|
|
54
78
|
error,
|
|
55
79
|
}: MutationReport<T>): string {
|
|
56
80
|
let str = "";
|
|
57
|
-
str += `
|
|
81
|
+
str += `necessary accounts resynced in ${formatTime(
|
|
82
|
+
resyncAccountsDuration
|
|
83
|
+
)}\n`;
|
|
58
84
|
str += `▬ ${formatAppCandidate(appCandidate)}\n`;
|
|
59
85
|
|
|
60
86
|
if (account) {
|
|
@@ -149,7 +175,7 @@ export function formatReportForConsole<T extends Transaction>({
|
|
|
149
175
|
}
|
|
150
176
|
|
|
151
177
|
if (error) {
|
|
152
|
-
str += `⚠️ ${formatError(error)}\n`;
|
|
178
|
+
str += `⚠️ ${formatError(error, true)}\n`;
|
|
153
179
|
}
|
|
154
180
|
|
|
155
181
|
return str;
|
package/src/bot/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { BigNumber } from "bignumber.js";
|
|
5
|
+
import uniq from "lodash/uniq";
|
|
5
6
|
import groupBy from "lodash/groupBy";
|
|
6
7
|
import { log } from "@ledgerhq/logs";
|
|
7
8
|
import invariant from "invariant";
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
} from "../currencies";
|
|
19
20
|
import { isAccountEmpty, toAccountRaw } from "../account";
|
|
20
21
|
import { runWithAppSpec } from "./engine";
|
|
21
|
-
import { formatReportForConsole, formatError } from "./formatters";
|
|
22
|
+
import { formatReportForConsole, formatError, formatTime } from "./formatters";
|
|
22
23
|
import {
|
|
23
24
|
initialState,
|
|
24
25
|
loadCountervalues,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
} from "../countervalues/logic";
|
|
27
28
|
import { getPortfolio } from "../portfolio/v2";
|
|
28
29
|
import { Account } from "@ledgerhq/types-live";
|
|
30
|
+
import { getContext } from "./bot-test-context";
|
|
29
31
|
type Arg = Partial<{
|
|
30
32
|
currency: string;
|
|
31
33
|
family: string;
|
|
@@ -48,7 +50,11 @@ function makeAppJSON(accounts: Account[]) {
|
|
|
48
50
|
return JSON.stringify(jsondata);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
export async function bot({
|
|
53
|
+
export async function bot({
|
|
54
|
+
currency,
|
|
55
|
+
family,
|
|
56
|
+
mutation,
|
|
57
|
+
}: Arg = {}): Promise<void> {
|
|
52
58
|
const SEED = getEnv("SEED");
|
|
53
59
|
invariant(SEED, "SEED required");
|
|
54
60
|
const specs: any[] = [];
|
|
@@ -86,6 +92,7 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
|
|
95
|
+
const timeBefore = Date.now();
|
|
89
96
|
const results: Array<SpecReport<any>> = await promiseAllBatched(
|
|
90
97
|
getEnv("BOT_MAX_CONCURRENT"),
|
|
91
98
|
specs,
|
|
@@ -94,7 +101,7 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
94
101
|
specsLogs.push(logs);
|
|
95
102
|
return runWithAppSpec(spec, (message) => {
|
|
96
103
|
log("bot", message);
|
|
97
|
-
console.log(message);
|
|
104
|
+
if (process.env.CI) console.log(message);
|
|
98
105
|
logs.push(message);
|
|
99
106
|
}).catch((fatalError) => ({
|
|
100
107
|
spec,
|
|
@@ -105,14 +112,15 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
105
112
|
}));
|
|
106
113
|
}
|
|
107
114
|
);
|
|
108
|
-
const
|
|
115
|
+
const totalDuration = Date.now() - timeBefore;
|
|
116
|
+
const allAppPaths = uniq(results.map((r) => r.appPath || "").sort());
|
|
109
117
|
const allAccountsAfter = flatMap(results, (r) => r.accountsAfter || []);
|
|
110
118
|
let countervaluesError;
|
|
111
119
|
const countervaluesState = await loadCountervalues(initialState, {
|
|
112
120
|
trackingPairs: inferTrackingPairForAccounts(allAccountsAfter, usd),
|
|
113
121
|
autofillGaps: true,
|
|
114
122
|
}).catch((e) => {
|
|
115
|
-
console.error(e);
|
|
123
|
+
if (process.env.CI) console.error(e);
|
|
116
124
|
countervaluesError = e;
|
|
117
125
|
return null;
|
|
118
126
|
});
|
|
@@ -174,7 +182,7 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
174
182
|
(s) => s.unavailableMutations
|
|
175
183
|
);
|
|
176
184
|
|
|
177
|
-
if (specFatals.length) {
|
|
185
|
+
if (specFatals.length && process.env.CI) {
|
|
178
186
|
console.error(`================== SPEC ERRORS =====================\n`);
|
|
179
187
|
specFatals.forEach((c) => {
|
|
180
188
|
console.error(c.fatalError);
|
|
@@ -182,7 +190,7 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
182
190
|
});
|
|
183
191
|
}
|
|
184
192
|
|
|
185
|
-
if (errorCases.length) {
|
|
193
|
+
if (errorCases.length && process.env.CI) {
|
|
186
194
|
console.error(`================== MUTATION ERRORS =====================\n`);
|
|
187
195
|
errorCases.forEach((c) => {
|
|
188
196
|
console.error(formatReportForConsole(c));
|
|
@@ -247,6 +255,8 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
247
255
|
)}`;
|
|
248
256
|
const success = mutationReports.length - errorCases.length;
|
|
249
257
|
|
|
258
|
+
title += `⏲ ${formatTime(totalDuration)} `;
|
|
259
|
+
|
|
250
260
|
if (success > 0) {
|
|
251
261
|
title += `✅ ${success} txs `;
|
|
252
262
|
}
|
|
@@ -326,22 +336,35 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
326
336
|
body += `<summary>${specFatals.length} critical spec errors</summary>\n\n`;
|
|
327
337
|
specFatals.forEach(({ spec, fatalError }) => {
|
|
328
338
|
body += `**Spec ${spec.name} failed!**\n`;
|
|
329
|
-
body += "```\n" + formatError(fatalError) + "\n```\n\n";
|
|
339
|
+
body += "```\n" + formatError(fatalError, true) + "\n```\n\n";
|
|
330
340
|
slackBody += `❌ *Spec ${spec.name}*: \`${formatError(fatalError)}\`\n`;
|
|
331
341
|
});
|
|
332
342
|
body += "</details>\n\n";
|
|
333
343
|
}
|
|
334
344
|
|
|
345
|
+
// summarize the error causes
|
|
346
|
+
const dedupedErrorCauses: string[] = [];
|
|
347
|
+
errorCases.forEach((m) => {
|
|
348
|
+
if (!m.error) return;
|
|
349
|
+
const ctx = getContext(m.error);
|
|
350
|
+
if (!ctx) return;
|
|
351
|
+
const cause = m.spec.name + " > " + ctx;
|
|
352
|
+
if (!dedupedErrorCauses.includes(cause)) {
|
|
353
|
+
dedupedErrorCauses.push(cause);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
if (dedupedErrorCauses.length > 0) {
|
|
357
|
+
slackBody += "*Hints:*\n";
|
|
358
|
+
dedupedErrorCauses.forEach((cause) => {
|
|
359
|
+
slackBody += `- ${cause}\n`;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
335
363
|
if (errorCases.length) {
|
|
336
364
|
body += "<details>\n";
|
|
337
365
|
body += `<summary>${errorCases.length} mutation errors</summary>\n\n`;
|
|
338
366
|
errorCases.forEach((c) => {
|
|
339
|
-
body +=
|
|
340
|
-
"```\n" +
|
|
341
|
-
formatReportForConsole(c) +
|
|
342
|
-
"\n" +
|
|
343
|
-
formatError(c.error) +
|
|
344
|
-
"\n```\n\n";
|
|
367
|
+
body += "```\n" + formatReportForConsole(c) + "\n```\n\n";
|
|
345
368
|
});
|
|
346
369
|
body += "</details>\n\n";
|
|
347
370
|
}
|
|
@@ -475,6 +498,89 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
475
498
|
});
|
|
476
499
|
body += "\n</details>\n\n";
|
|
477
500
|
|
|
501
|
+
// Add performance details
|
|
502
|
+
body += "<details>\n";
|
|
503
|
+
body += `<summary>Performance ⏲ ${formatTime(totalDuration)}</summary>\n\n`;
|
|
504
|
+
body += "**Time spent for each spec:** (total across mutations)\n";
|
|
505
|
+
|
|
506
|
+
function sumMutation(mutations, f) {
|
|
507
|
+
return mutations?.reduce((sum, m) => sum + (f(m) || 0), 0) || 0;
|
|
508
|
+
}
|
|
509
|
+
function sumResults(f) {
|
|
510
|
+
return results.reduce((sum, r) => sum + (f(r) || 0), 0);
|
|
511
|
+
}
|
|
512
|
+
function sumResultsMutation(f) {
|
|
513
|
+
return sumResults((r) => sumMutation(r.mutations, f));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
body +=
|
|
517
|
+
"| Spec (accounts) | preload | scan | re-sync | tx status | sign op | broadcast | mutation confirm |\n";
|
|
518
|
+
body += "|---|---|---|---|---|---|---|---|\n";
|
|
519
|
+
|
|
520
|
+
body += "| **TOTAL** |";
|
|
521
|
+
body += `**${formatTime(sumResults((r) => r.preloadDuration))}** |`;
|
|
522
|
+
body += `**${formatTime(sumResults((r) => r.scanDuration))}** |`;
|
|
523
|
+
body += `**${formatTime(
|
|
524
|
+
sumResultsMutation((m) => m.resyncAccountsDuration || 0)
|
|
525
|
+
)}** |`;
|
|
526
|
+
body += `**${formatTime(
|
|
527
|
+
sumResultsMutation((m) =>
|
|
528
|
+
m.mutationTime && m.statusTime ? m.statusTime - m.mutationTime : 0
|
|
529
|
+
)
|
|
530
|
+
)}** |`;
|
|
531
|
+
body += `**${formatTime(
|
|
532
|
+
sumResultsMutation((m) =>
|
|
533
|
+
m.statusTime && m.signedTime ? m.signedTime - m.statusTime : 0
|
|
534
|
+
)
|
|
535
|
+
)}** |`;
|
|
536
|
+
body += `**${formatTime(
|
|
537
|
+
sumResultsMutation((m) =>
|
|
538
|
+
m.signedTime && m.broadcastedTime ? m.broadcastedTime - m.signedTime : 0
|
|
539
|
+
)
|
|
540
|
+
)}** |`;
|
|
541
|
+
body += `**${formatTime(
|
|
542
|
+
sumResultsMutation((m) =>
|
|
543
|
+
m.broadcastedTime && m.confirmedTime
|
|
544
|
+
? m.confirmedTime - m.broadcastedTime
|
|
545
|
+
: 0
|
|
546
|
+
)
|
|
547
|
+
)}** |\n`;
|
|
548
|
+
|
|
549
|
+
results.forEach((r) => {
|
|
550
|
+
body += `| ${r.spec.name} (${
|
|
551
|
+
(r.accountsBefore || []).filter((a) => a.used).length
|
|
552
|
+
}) |`;
|
|
553
|
+
body += `${formatTime(r.preloadDuration || 0)} |`;
|
|
554
|
+
body += `${formatTime(r.scanDuration || 0)} |`;
|
|
555
|
+
body += `${formatTime(
|
|
556
|
+
sumMutation(r.mutations, (m) => m.resyncAccountsDuration || 0)
|
|
557
|
+
)} |`;
|
|
558
|
+
body += `${formatTime(
|
|
559
|
+
sumMutation(r.mutations, (m) =>
|
|
560
|
+
m.mutationTime && m.statusTime ? m.statusTime - m.mutationTime : 0
|
|
561
|
+
)
|
|
562
|
+
)} |`;
|
|
563
|
+
body += `${formatTime(
|
|
564
|
+
sumMutation(r.mutations, (m) =>
|
|
565
|
+
m.statusTime && m.signedTime ? m.signedTime - m.statusTime : 0
|
|
566
|
+
)
|
|
567
|
+
)} |`;
|
|
568
|
+
body += `${formatTime(
|
|
569
|
+
sumMutation(r.mutations, (m) =>
|
|
570
|
+
m.signedTime && m.broadcastedTime ? m.broadcastedTime - m.signedTime : 0
|
|
571
|
+
)
|
|
572
|
+
)} |`;
|
|
573
|
+
body += `${formatTime(
|
|
574
|
+
sumMutation(r.mutations, (m) =>
|
|
575
|
+
m.broadcastedTime && m.confirmedTime
|
|
576
|
+
? m.confirmedTime - m.broadcastedTime
|
|
577
|
+
: 0
|
|
578
|
+
)
|
|
579
|
+
)} |\n`;
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
body += "\n</details>\n\n";
|
|
583
|
+
|
|
478
584
|
const { BOT_REPORT_FOLDER } = process.env;
|
|
479
585
|
|
|
480
586
|
const slackCommentTemplate = `${String(
|
|
@@ -494,13 +600,13 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
494
600
|
"utf-8"
|
|
495
601
|
),
|
|
496
602
|
fs.promises.writeFile(
|
|
497
|
-
path.join(BOT_REPORT_FOLDER, "
|
|
498
|
-
makeAppJSON(
|
|
603
|
+
path.join(BOT_REPORT_FOLDER, "app.json"),
|
|
604
|
+
makeAppJSON(allAccountsAfter),
|
|
499
605
|
"utf-8"
|
|
500
606
|
),
|
|
501
607
|
fs.promises.writeFile(
|
|
502
|
-
path.join(BOT_REPORT_FOLDER, "
|
|
503
|
-
|
|
608
|
+
path.join(BOT_REPORT_FOLDER, "coin-apps.json"),
|
|
609
|
+
JSON.stringify(allAppPaths),
|
|
504
610
|
"utf-8"
|
|
505
611
|
),
|
|
506
612
|
]);
|
package/src/bot/specs.ts
CHANGED
|
@@ -7,6 +7,9 @@ import { isAccountEmpty } from "../account";
|
|
|
7
7
|
import type { DeviceAction, DeviceActionArg } from "./types";
|
|
8
8
|
import { Account } from "@ledgerhq/types-live";
|
|
9
9
|
import type { Transaction } from "../generated/types";
|
|
10
|
+
import { botTest } from "./bot-test-context";
|
|
11
|
+
|
|
12
|
+
export { botTest };
|
|
10
13
|
|
|
11
14
|
const stepValueTransformDefault = (s) => s.trim();
|
|
12
15
|
|
|
@@ -89,11 +92,13 @@ export function deviceActionFlow<T extends Transaction>(
|
|
|
89
92
|
currentStep.stepValueTransform || stepValueTransformDefault;
|
|
90
93
|
|
|
91
94
|
if (!ignoreAssertionFailure) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
botTest("deviceAction confirm step '" + stepTitle + "'", () =>
|
|
96
|
+
expect({
|
|
97
|
+
[stepTitle]: stepValueTransform(stepValue),
|
|
98
|
+
}).toMatchObject({
|
|
99
|
+
[stepTitle]: expectedValue(arg, acc).trim(),
|
|
100
|
+
})
|
|
101
|
+
);
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
|
package/src/bot/types.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type MutationSpec<T extends Transaction> = {
|
|
|
66
66
|
account: Account;
|
|
67
67
|
bridge: AccountBridge<T>;
|
|
68
68
|
}) => T | null | undefined;
|
|
69
|
-
// Express the device actions to do (buttons,..) and validate the device screen
|
|
69
|
+
// Express the device actions to do (buttons,..) and validate the device screen. overrides genericDeviceAction
|
|
70
70
|
deviceAction?: DeviceAction<T, any>;
|
|
71
71
|
// how much time to wait in maximum to reach the final state
|
|
72
72
|
testTimeout?: number;
|
|
@@ -102,17 +102,21 @@ export type AppSpec<T extends Transaction> = {
|
|
|
102
102
|
transactionCheck?: (arg: TransactionArg<T>) => void;
|
|
103
103
|
// Implement a test that also runs on each mutation after the operation is applied to the account
|
|
104
104
|
test?: (arg0: TransactionTestInput<T>) => void;
|
|
105
|
+
// Express the device actions to do (buttons,..) and validate the device screen
|
|
106
|
+
genericDeviceAction: DeviceAction<T, any>;
|
|
105
107
|
};
|
|
106
108
|
export type SpecReport<T extends Transaction> = {
|
|
107
109
|
spec: AppSpec<T>;
|
|
108
|
-
|
|
110
|
+
appPath?: string;
|
|
111
|
+
scanDuration?: number;
|
|
112
|
+
preloadDuration?: number;
|
|
109
113
|
accountsBefore?: Account[];
|
|
110
114
|
accountsAfter?: Account[];
|
|
111
115
|
mutations?: MutationReport<T>[];
|
|
112
116
|
fatalError?: Error;
|
|
113
117
|
};
|
|
114
118
|
export type MutationReport<T extends Transaction> = {
|
|
115
|
-
|
|
119
|
+
resyncAccountsDuration: number;
|
|
116
120
|
spec: AppSpec<T>;
|
|
117
121
|
appCandidate: AppCandidate;
|
|
118
122
|
account?: Account;
|
|
@@ -3,11 +3,13 @@ import { initialState, loadCountervalues, calculate } from "./logic";
|
|
|
3
3
|
import {
|
|
4
4
|
getFiatCurrencyByTicker,
|
|
5
5
|
getCryptoCurrencyById,
|
|
6
|
+
getTokenById,
|
|
6
7
|
findCurrencyByTicker,
|
|
7
8
|
} from "../currencies";
|
|
8
9
|
import { getBTCValues } from "../countervalues/mock";
|
|
9
10
|
import { Currency } from "@ledgerhq/types-cryptoassets";
|
|
10
11
|
|
|
12
|
+
const ethereum = getCryptoCurrencyById("ethereum");
|
|
11
13
|
const bitcoin = getCryptoCurrencyById("bitcoin");
|
|
12
14
|
const usd = getFiatCurrencyByTicker("USD");
|
|
13
15
|
const now = Date.now();
|
|
@@ -130,3 +132,51 @@ describe("extreme cases", () => {
|
|
|
130
132
|
expect(currenciesWithCVs.length).toBeGreaterThan(0);
|
|
131
133
|
});
|
|
132
134
|
});
|
|
135
|
+
|
|
136
|
+
describe("WETH rules", () => {
|
|
137
|
+
test("ethereum WETH have countervalues", async () => {
|
|
138
|
+
const weth = getTokenById("ethereum/erc20/weth");
|
|
139
|
+
const state = await loadCountervalues(initialState, {
|
|
140
|
+
// NB: inferTrackingPairForAccounts would infer eth->usd with the WETH module
|
|
141
|
+
// we set this explicitly just to confirm that asking weth->usd will make it work
|
|
142
|
+
trackingPairs: [
|
|
143
|
+
{
|
|
144
|
+
from: ethereum,
|
|
145
|
+
to: usd,
|
|
146
|
+
startDate: new Date(now - 10 * 24 * 60 * 60 * 1000),
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
autofillGaps: true,
|
|
150
|
+
disableAutoRecoverErrors: true,
|
|
151
|
+
});
|
|
152
|
+
const value = calculate(state, {
|
|
153
|
+
disableRounding: true,
|
|
154
|
+
from: weth,
|
|
155
|
+
to: usd,
|
|
156
|
+
value: 1000000,
|
|
157
|
+
});
|
|
158
|
+
expect(value).toBeGreaterThan(0);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("ethereum goerli WETH doesn't countervalues", async () => {
|
|
162
|
+
const weth = getTokenById("ethereum_goerli/erc20/wrapped_ether");
|
|
163
|
+
const state = await loadCountervalues(initialState, {
|
|
164
|
+
trackingPairs: [
|
|
165
|
+
{
|
|
166
|
+
from: ethereum,
|
|
167
|
+
to: usd,
|
|
168
|
+
startDate: new Date(now - 1 * 24 * 60 * 60 * 1000),
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
autofillGaps: true,
|
|
172
|
+
disableAutoRecoverErrors: true,
|
|
173
|
+
});
|
|
174
|
+
const value = calculate(state, {
|
|
175
|
+
disableRounding: true,
|
|
176
|
+
from: weth,
|
|
177
|
+
to: usd,
|
|
178
|
+
value: 1000000,
|
|
179
|
+
});
|
|
180
|
+
expect(value).toBe(undefined);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import type { Module } from "./types";
|
|
1
|
+
import type { Module, Pair } from "./types";
|
|
2
2
|
import { getCryptoCurrencyById } from "../../currencies";
|
|
3
|
+
|
|
3
4
|
const ETH = getCryptoCurrencyById("ethereum");
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
from: pair.from,
|
|
14
|
-
to: ETH,
|
|
15
|
-
};
|
|
6
|
+
const wethId = "ethereum/erc20/weth";
|
|
7
|
+
|
|
8
|
+
const remap = (pair: Pair): Pair => {
|
|
9
|
+
if (pair.from.type === "TokenCurrency" && pair.from.id === wethId)
|
|
10
|
+
return { from: ETH, to: pair.to };
|
|
11
|
+
if (pair.to.type === "TokenCurrency" && pair.to.id === wethId)
|
|
12
|
+
return { from: pair.from, to: ETH };
|
|
16
13
|
return pair;
|
|
17
14
|
};
|
|
18
15
|
|