@ledgerhq/live-common 23.1.0 → 24.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/mocks/account.js +3 -3
- package/lib/__tests__/mocks/account.js.map +1 -1
- package/lib/__tests__/test-helpers/bridge.d.ts +1 -4
- package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
- package/lib/__tests__/test-helpers/bridge.js +1 -28
- package/lib/__tests__/test-helpers/bridge.js.map +1 -1
- package/lib/__tests__/test-helpers/setup.js +51 -0
- package/lib/__tests__/test-helpers/setup.js.map +1 -1
- package/lib/api/Ripple.d.ts.map +1 -1
- package/lib/api/Ripple.js +113 -68
- package/lib/api/Ripple.js.map +1 -1
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +6 -2
- package/lib/apps/support.js.map +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +13 -19
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/test.bot.d.ts +1 -1
- package/lib/bot/test.bot.d.ts.map +1 -1
- package/lib/bot/test.bot.js +1 -2
- package/lib/bot/test.bot.js.map +1 -1
- package/lib/countervalues/logic.integration.test.d.ts +2 -0
- package/lib/countervalues/logic.integration.test.d.ts.map +1 -0
- package/lib/countervalues/{logic.test.js → logic.integration.test.js} +1 -1
- package/lib/countervalues/logic.integration.test.js.map +1 -0
- package/lib/countervalues/react.d.ts +1 -21
- package/lib/countervalues/react.d.ts.map +1 -1
- package/lib/countervalues/react.js +1 -77
- package/lib/countervalues/react.js.map +1 -1
- package/lib/derivation.d.ts +1 -0
- package/lib/derivation.d.ts.map +1 -1
- package/lib/derivation.js +3 -2
- package/lib/derivation.js.map +1 -1
- package/lib/env.d.ts +16 -6
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +11 -1
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/errors.d.ts +0 -3
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -3
- package/lib/errors.js.map +1 -1
- package/lib/exchange/index.d.ts +5 -0
- package/lib/exchange/index.d.ts.map +1 -1
- package/lib/exchange/index.js.map +1 -1
- package/lib/exchange/swap/checkQuote.d.ts +4 -0
- package/lib/exchange/swap/checkQuote.d.ts.map +1 -0
- package/lib/{families/tezos/bridge.test.js → exchange/swap/checkQuote.js} +35 -36
- package/lib/exchange/swap/checkQuote.js.map +1 -0
- package/lib/exchange/swap/checkQuote.test.d.ts +2 -0
- package/lib/exchange/swap/checkQuote.test.d.ts.map +1 -0
- package/lib/{families/filecoin/bridge.test.js → exchange/swap/checkQuote.test.js} +53 -42
- package/lib/exchange/swap/checkQuote.test.js.map +1 -0
- package/lib/exchange/swap/completeExchange.d.ts.map +1 -1
- package/lib/exchange/swap/completeExchange.js +9 -9
- package/lib/exchange/swap/completeExchange.js.map +1 -1
- package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
- package/lib/exchange/swap/getExchangeRates.js +3 -1
- package/lib/exchange/swap/getExchangeRates.js.map +1 -1
- package/lib/exchange/swap/getExchangeRates.test.js +1 -2
- package/lib/exchange/swap/getExchangeRates.test.js.map +1 -1
- package/lib/exchange/swap/getProviders.d.ts.map +1 -1
- package/lib/exchange/swap/getProviders.js +10 -4
- package/lib/exchange/swap/getProviders.js.map +1 -1
- package/lib/exchange/swap/getStatus.d.ts +1 -3
- package/lib/exchange/swap/getStatus.d.ts.map +1 -1
- package/lib/exchange/swap/getStatus.js +2 -30
- package/lib/exchange/swap/getStatus.js.map +1 -1
- package/lib/exchange/swap/hooks/usePollKYCStatus.test.js +4 -5
- package/lib/exchange/swap/hooks/usePollKYCStatus.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useProviderRates.d.ts +3 -4
- package/lib/exchange/swap/hooks/useProviderRates.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useProviderRates.js +35 -5
- package/lib/exchange/swap/hooks/useProviderRates.js.map +1 -1
- package/lib/exchange/swap/hooks/useProviderRates.test.js +107 -3
- package/lib/exchange/swap/hooks/useProviderRates.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useSwapProviders.test.js +1 -2
- package/lib/exchange/swap/hooks/useSwapProviders.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts +5 -4
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.js +6 -6
- package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.d.ts +4 -3
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.js +8 -5
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.js.map +1 -1
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.test.js +37 -7
- package/lib/exchange/swap/hooks/useUpdateMaxAmount.test.js.map +1 -1
- package/lib/exchange/swap/index.d.ts +10 -8
- package/lib/exchange/swap/index.d.ts.map +1 -1
- package/lib/exchange/swap/index.js +43 -18
- package/lib/exchange/swap/index.js.map +1 -1
- package/lib/exchange/swap/index.test.d.ts +2 -0
- package/lib/exchange/swap/index.test.d.ts.map +1 -0
- package/lib/exchange/swap/index.test.js +30 -0
- package/lib/exchange/swap/index.test.js.map +1 -0
- package/lib/exchange/swap/initSwap.d.ts +1 -1
- package/lib/exchange/swap/initSwap.d.ts.map +1 -1
- package/lib/exchange/swap/initSwap.js +30 -25
- package/lib/exchange/swap/initSwap.js.map +1 -1
- package/lib/exchange/swap/mock.d.ts +5 -2
- package/lib/exchange/swap/mock.d.ts.map +1 -1
- package/lib/exchange/swap/mock.js +127 -6
- package/lib/exchange/swap/mock.js.map +1 -1
- package/lib/exchange/swap/postSwapState.d.ts +4 -0
- package/lib/exchange/swap/postSwapState.d.ts.map +1 -0
- package/lib/exchange/swap/postSwapState.js +121 -0
- package/lib/exchange/swap/postSwapState.js.map +1 -0
- package/lib/exchange/swap/types.d.ts +30 -2
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/exchange/swap/updateAccountSwapStatus.d.ts.map +1 -1
- package/lib/exchange/swap/updateAccountSwapStatus.js +2 -2
- package/lib/exchange/swap/updateAccountSwapStatus.js.map +1 -1
- package/lib/exchange/swap/utils/index.d.ts +19 -2
- package/lib/exchange/swap/utils/index.d.ts.map +1 -1
- package/lib/exchange/swap/utils/index.js +96 -20
- package/lib/exchange/swap/utils/index.js.map +1 -1
- package/lib/exchange/swap/utils/index.test.js +95 -48
- package/lib/exchange/swap/utils/index.test.js.map +1 -1
- package/lib/families/algorand/bridge.integration.test.d.ts +2 -0
- package/lib/families/algorand/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/algorand/{test-dataset.js → bridge.integration.test.js} +12 -11
- package/lib/families/algorand/bridge.integration.test.js.map +1 -0
- package/lib/families/bitcoin/bridge.integration.test.d.ts +2 -0
- package/lib/families/bitcoin/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/bitcoin/{test-dataset.js → bridge.integration.test.js} +17 -14
- package/lib/families/bitcoin/bridge.integration.test.js.map +1 -0
- package/lib/families/bitcoin/descriptor.d.ts.map +1 -1
- package/lib/families/bitcoin/descriptor.js +2 -1
- package/lib/families/bitcoin/descriptor.js.map +1 -1
- package/lib/families/bitcoin/satstack.d.ts.map +1 -1
- package/lib/families/bitcoin/satstack.js +5 -6
- package/lib/families/bitcoin/satstack.js.map +1 -1
- package/lib/families/bitcoin/satstack.test.js +4 -1
- package/lib/families/bitcoin/satstack.test.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +1 -2
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/cardano/bridge.integration.test.d.ts +2 -0
- package/lib/families/cardano/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/cardano/{test-dataset.js → bridge.integration.test.js} +4 -2
- package/lib/families/cardano/bridge.integration.test.js.map +1 -0
- package/lib/families/celo/bridge.integration.test.d.ts +2 -0
- package/lib/families/celo/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/celo/bridge.integration.test.js +16 -0
- package/lib/families/celo/bridge.integration.test.js.map +1 -0
- package/lib/families/cosmos/bridge.integration.test.d.ts +2 -0
- package/lib/families/cosmos/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/cosmos/{test-dataset.js → bridge.integration.test.js} +5 -4
- package/lib/families/cosmos/bridge.integration.test.js.map +1 -0
- package/lib/families/cosmos/speculos-deviceActions.js +2 -2
- package/lib/families/crypto_org/bridge.integration.test.d.ts +2 -0
- package/lib/families/crypto_org/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/crypto_org/bridge.integration.test.js +16 -0
- package/lib/families/crypto_org/bridge.integration.test.js.map +1 -0
- package/lib/families/elrond/bridge.integration.test.d.ts +2 -0
- package/lib/families/elrond/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/elrond/{test-dataset.js → bridge.integration.test.js} +5 -5
- package/lib/families/elrond/bridge.integration.test.js.map +1 -0
- package/lib/families/ethereum/bridge.integration.test.d.ts +2 -0
- package/lib/families/ethereum/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/ethereum/{test-dataset.js → bridge.integration.test.js} +8 -24
- package/lib/families/ethereum/bridge.integration.test.js.map +1 -0
- package/lib/families/ethereum/datasets/ethereum1.d.ts +3 -0
- package/lib/families/ethereum/datasets/ethereum1.d.ts.map +1 -0
- package/lib/families/ethereum/datasets/ethereum1.js +22 -0
- package/lib/families/ethereum/datasets/ethereum1.js.map +1 -0
- package/lib/families/ethereum/modules/compound.resilience.integration.test.d.ts +2 -0
- package/lib/families/ethereum/modules/compound.resilience.integration.test.d.ts.map +1 -0
- package/lib/families/ethereum/modules/{compound.resilience.test.js → compound.resilience.integration.test.js} +3 -3
- package/lib/families/ethereum/modules/compound.resilience.integration.test.js.map +1 -0
- package/lib/families/ethereum/modules/erc1155.d.ts.map +1 -1
- package/lib/families/ethereum/modules/erc1155.js +5 -1
- package/lib/families/ethereum/modules/erc1155.js.map +1 -1
- package/lib/families/ethereum/modules/erc721.d.ts.map +1 -1
- package/lib/families/ethereum/modules/erc721.js +5 -0
- package/lib/families/ethereum/modules/erc721.js.map +1 -1
- package/lib/families/ethereum/nft.unit.test.js +35 -15
- package/lib/families/ethereum/nft.unit.test.js.map +1 -1
- package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
- package/lib/families/ethereum/synchronisation.integration.test.d.ts +2 -0
- package/lib/families/ethereum/synchronisation.integration.test.d.ts.map +1 -0
- package/lib/families/ethereum/{synchronisation.test.js → synchronisation.integration.test.js} +4 -4
- package/lib/families/ethereum/synchronisation.integration.test.js.map +1 -0
- package/lib/families/ethereum/synchronisation.js +17 -13
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/families/filecoin/bridge.integration.test.d.ts +2 -0
- package/lib/families/filecoin/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/filecoin/{test-dataset.js → bridge.integration.test.js} +84 -3
- package/lib/families/filecoin/bridge.integration.test.js.map +1 -0
- package/lib/families/hedera/bridge.integration.test.d.ts +2 -0
- package/lib/families/hedera/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/hedera/{test-dataset.js → bridge.integration.test.js} +5 -3
- package/lib/families/hedera/bridge.integration.test.js.map +1 -0
- package/lib/families/polkadot/bridge.integration.test.d.ts +2 -0
- package/lib/families/polkadot/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/polkadot/{test-dataset.js → bridge.integration.test.js} +138 -4
- package/lib/families/polkadot/bridge.integration.test.js.map +1 -0
- package/lib/families/ripple/bridge.integration.test.d.ts +2 -0
- package/lib/families/ripple/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/ripple/{test-dataset.js → bridge.integration.test.js} +4 -2
- package/lib/families/ripple/bridge.integration.test.js.map +1 -0
- package/lib/families/solana/api/chain/account/token.d.ts +1 -1
- package/lib/families/solana/api/chain/account/vote.d.ts +12 -12
- package/lib/families/solana/api/chain/instruction/system/types.d.ts +4 -4
- package/lib/families/solana/bridge.integration.test.d.ts +2 -0
- package/lib/families/solana/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/solana/{test-dataset.js → bridge.integration.test.js} +289 -73
- package/lib/families/solana/bridge.integration.test.js.map +1 -0
- package/lib/families/stellar/bridge.integration.test.d.ts +2 -0
- package/lib/families/stellar/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/stellar/{test-dataset.js → bridge.integration.test.js} +9 -8
- package/lib/families/stellar/bridge.integration.test.js.map +1 -0
- package/lib/families/stellar/js-estimateMaxSpendable.d.ts.map +1 -1
- package/lib/families/stellar/js-estimateMaxSpendable.js +2 -2
- package/lib/families/stellar/js-estimateMaxSpendable.js.map +1 -1
- package/lib/families/tezos/{test-dataset.d.ts → bridge.integration.test.d.ts} +2 -5
- package/lib/families/tezos/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/tezos/{test-dataset.js → bridge.integration.test.js} +73 -2
- package/lib/families/tezos/bridge.integration.test.js.map +1 -0
- package/lib/families/tezos/synchronisation.js +2 -2
- package/lib/families/tezos/synchronisation.js.map +1 -1
- package/lib/families/tron/bridge.integration.test.d.ts +2 -0
- package/lib/families/tron/bridge.integration.test.d.ts.map +1 -0
- package/lib/families/tron/{test-dataset.js → bridge.integration.test.js} +5 -4
- package/lib/families/tron/bridge.integration.test.js.map +1 -0
- package/lib/hw/actions/initSwap.d.ts +4 -3
- package/lib/hw/actions/initSwap.d.ts.map +1 -1
- package/lib/hw/actions/initSwap.js +7 -5
- package/lib/hw/actions/initSwap.js.map +1 -1
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +5 -2
- package/lib/load/speculos.js.map +1 -1
- package/lib/nft/nftOperationId.d.ts +15 -0
- package/lib/nft/nftOperationId.d.ts.map +1 -0
- package/lib/nft/nftOperationId.js +50 -0
- package/lib/nft/nftOperationId.js.map +1 -0
- package/lib/operation.d.ts +1 -1
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +23 -1
- package/lib/operation.js.map +1 -1
- package/lib/portfolio/v2/index.d.ts +6 -1
- package/lib/portfolio/v2/index.d.ts.map +1 -1
- package/lib/portfolio/v2/index.js +7 -3
- package/lib/portfolio/v2/index.js.map +1 -1
- package/lib/portfolio/v2/range.d.ts +7 -1
- package/lib/portfolio/v2/range.d.ts.map +1 -1
- package/lib/portfolio/v2/range.js +37 -18
- package/lib/portfolio/v2/range.js.map +1 -1
- package/lib/portfolio/v2/range.test.d.ts +2 -0
- package/lib/portfolio/v2/range.test.d.ts.map +1 -0
- package/lib/portfolio/v2/range.test.js +51 -0
- package/lib/portfolio/v2/range.test.js.map +1 -0
- package/package.json +14 -10
- package/src/__tests__/mocks/account.ts +3 -3
- package/src/__tests__/test-helpers/bridge.ts +2 -35
- package/src/__tests__/test-helpers/setup.ts +39 -0
- package/src/api/Ripple.ts +97 -52
- package/src/apps/support.ts +6 -2
- package/src/bot/index.ts +26 -24
- package/src/bot/test.bot.ts +2 -2
- package/src/countervalues/{logic.test.ts → logic.integration.test.ts} +0 -0
- package/src/countervalues/react.tsx +2 -131
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +15 -1
- package/src/derivation.ts +2 -1
- package/src/env.ts +12 -2
- package/src/errors.ts +0 -1
- package/src/exchange/index.ts +7 -0
- package/src/exchange/swap/checkQuote.test.ts +53 -0
- package/src/exchange/swap/checkQuote.ts +34 -0
- package/src/exchange/swap/completeExchange.ts +9 -11
- package/src/exchange/swap/getExchangeRates.test.ts +1 -2
- package/src/exchange/swap/getExchangeRates.ts +5 -3
- package/src/exchange/swap/getProviders.ts +12 -4
- package/src/exchange/swap/getStatus.ts +2 -12
- package/src/exchange/swap/hooks/usePollKYCStatus.test.ts +1 -3
- package/src/exchange/swap/hooks/useProviderRates.test.ts +104 -3
- package/src/exchange/swap/hooks/useProviderRates.ts +57 -9
- package/src/exchange/swap/hooks/useSwapProviders.test.ts +1 -3
- package/src/exchange/swap/hooks/useSwapTransaction.ts +14 -13
- package/src/exchange/swap/hooks/useUpdateMaxAmount.test.ts +33 -7
- package/src/exchange/swap/hooks/useUpdateMaxAmount.ts +13 -7
- package/src/exchange/swap/index.test.ts +36 -0
- package/src/exchange/swap/index.ts +51 -30
- package/src/exchange/swap/initSwap.ts +54 -40
- package/src/exchange/swap/mock.ts +128 -13
- package/src/exchange/swap/postSwapState.ts +61 -0
- package/src/exchange/swap/types.ts +68 -5
- package/src/exchange/swap/updateAccountSwapStatus.ts +4 -4
- package/src/exchange/swap/utils/index.test.ts +127 -63
- package/src/exchange/swap/utils/index.ts +128 -23
- package/src/families/algorand/{test-dataset.ts → bridge.integration.test.ts} +13 -10
- package/src/families/bitcoin/__snapshots__/bridge.integration.test.ts.snap +27607 -0
- package/src/families/bitcoin/{test-dataset.ts → bridge.integration.test.ts} +18 -13
- package/src/families/bitcoin/descriptor.ts +1 -0
- package/src/families/bitcoin/satstack.test.ts +4 -1
- package/src/families/bitcoin/satstack.ts +9 -5
- package/src/families/bitcoin/specs.ts +0 -1
- package/src/families/cardano/__snapshots__/{bridge.test.ts.snap → bridge.integration.test.ts.snap} +0 -0
- package/src/families/cardano/{test-dataset.ts → bridge.integration.test.ts} +3 -1
- package/src/families/celo/bridge.integration.test.ts +14 -0
- package/src/families/cosmos/__snapshots__/{bridge.test.ts.snap → bridge.integration.test.ts.snap} +0 -0
- package/src/families/cosmos/{test-dataset.ts → bridge.integration.test.ts} +17 -15
- package/src/families/cosmos/speculos-deviceActions.ts +2 -2
- package/src/families/crypto_org/__snapshots__/bridge.integration.test.ts.snap +2968 -0
- package/src/families/crypto_org/bridge.integration.test.ts +14 -0
- package/src/families/elrond/__snapshots__/bridge.integration.test.ts.snap +207 -0
- package/src/families/elrond/{test-dataset.ts → bridge.integration.test.ts} +6 -4
- package/src/families/ethereum/__snapshots__/bridge.integration.test.ts.snap +3263 -0
- package/src/families/ethereum/{test-dataset.ts → bridge.integration.test.ts} +6 -19
- package/src/families/ethereum/datasets/ethereum1.ts +20 -0
- package/src/families/ethereum/modules/{compound.resilience.test.ts → compound.resilience.integration.test.ts} +1 -1
- package/src/families/ethereum/modules/erc1155.ts +12 -5
- package/src/families/ethereum/modules/erc721.ts +11 -0
- package/src/families/ethereum/nft.unit.test.ts +24 -17
- package/src/families/ethereum/{synchronisation.test.ts → synchronisation.integration.test.ts} +1 -1
- package/src/families/ethereum/synchronisation.ts +22 -18
- package/src/families/filecoin/__snapshots__/{bridge.test.ts.snap → bridge.integration.test.ts.snap} +0 -0
- package/src/families/filecoin/{test-dataset.ts → bridge.integration.test.ts} +35 -3
- package/src/families/hedera/__snapshots__/bridge.integration.test.ts.snap +5 -0
- package/src/families/hedera/{test-dataset.ts → bridge.integration.test.ts} +5 -2
- package/src/families/polkadot/{test-dataset.ts → bridge.integration.test.ts} +81 -5
- package/src/families/ripple/{test-dataset.ts → bridge.integration.test.ts} +5 -1
- package/src/families/solana/__snapshots__/{bridge.test.ts.snap → bridge.integration.test.ts.snap} +0 -0
- package/src/families/solana/{test-dataset.ts → bridge.integration.test.ts} +170 -5
- package/src/families/stellar/__snapshots__/{bridge.test.ts.snap → bridge.integration.test.ts.snap} +0 -0
- package/src/families/stellar/{test-dataset.ts → bridge.integration.test.ts} +5 -3
- package/src/families/stellar/js-estimateMaxSpendable.ts +3 -1
- package/src/families/tezos/{test-dataset.ts → bridge.integration.test.ts} +22 -1
- package/src/families/tezos/synchronisation.ts +1 -1
- package/src/families/tron/{test-dataset.ts → bridge.integration.test.ts} +6 -5
- package/src/hw/actions/initSwap.ts +20 -9
- package/src/load/speculos.ts +5 -2
- package/src/nft/nftOperationId.ts +47 -0
- package/src/operation.ts +50 -1
- package/src/portfolio/v2/index.ts +7 -2
- package/src/portfolio/v2/range.test.ts +66 -0
- package/src/portfolio/v2/range.ts +22 -8
- package/lib/__tests__/portfolio.d.ts +0 -2
- package/lib/__tests__/portfolio.d.ts.map +0 -1
- package/lib/__tests__/portfolio.js +0 -297
- package/lib/__tests__/portfolio.js.map +0 -1
- package/lib/__tests__/test-helpers/libcore-setup.d.ts +0 -3
- package/lib/__tests__/test-helpers/libcore-setup.d.ts.map +0 -1
- package/lib/__tests__/test-helpers/libcore-setup.js +0 -68
- package/lib/__tests__/test-helpers/libcore-setup.js.map +0 -1
- package/lib/__tests__/test-helpers/libcore-setup.native.d.ts +0 -10
- package/lib/__tests__/test-helpers/libcore-setup.native.d.ts.map +0 -1
- package/lib/__tests__/test-helpers/libcore-setup.native.js +0 -16
- package/lib/__tests__/test-helpers/libcore-setup.native.js.map +0 -1
- package/lib/countervalues/logic.test.d.ts +0 -2
- package/lib/countervalues/logic.test.d.ts.map +0 -1
- package/lib/countervalues/logic.test.js.map +0 -1
- package/lib/families/algorand/test-dataset.d.ts +0 -5
- package/lib/families/algorand/test-dataset.d.ts.map +0 -1
- package/lib/families/algorand/test-dataset.js.map +0 -1
- package/lib/families/bitcoin/test-dataset.d.ts +0 -5
- package/lib/families/bitcoin/test-dataset.d.ts.map +0 -1
- package/lib/families/bitcoin/test-dataset.js.map +0 -1
- package/lib/families/cardano/bridge.test.d.ts +0 -2
- package/lib/families/cardano/bridge.test.d.ts.map +0 -1
- package/lib/families/cardano/bridge.test.js +0 -11
- package/lib/families/cardano/bridge.test.js.map +0 -1
- package/lib/families/cardano/test-dataset.d.ts +0 -5
- package/lib/families/cardano/test-dataset.d.ts.map +0 -1
- package/lib/families/cardano/test-dataset.js.map +0 -1
- package/lib/families/cosmos/bridge.test.d.ts +0 -2
- package/lib/families/cosmos/bridge.test.d.ts.map +0 -1
- package/lib/families/cosmos/bridge.test.js +0 -11
- package/lib/families/cosmos/bridge.test.js.map +0 -1
- package/lib/families/cosmos/test-dataset.d.ts +0 -5
- package/lib/families/cosmos/test-dataset.d.ts.map +0 -1
- package/lib/families/cosmos/test-dataset.js.map +0 -1
- package/lib/families/crypto_org/test-dataset.d.ts +0 -5
- package/lib/families/crypto_org/test-dataset.d.ts.map +0 -1
- package/lib/families/crypto_org/test-dataset.js +0 -12
- package/lib/families/crypto_org/test-dataset.js.map +0 -1
- package/lib/families/elrond/test-dataset.d.ts +0 -5
- package/lib/families/elrond/test-dataset.d.ts.map +0 -1
- package/lib/families/elrond/test-dataset.js.map +0 -1
- package/lib/families/ethereum/modules/compound.resilience.test.d.ts +0 -2
- package/lib/families/ethereum/modules/compound.resilience.test.d.ts.map +0 -1
- package/lib/families/ethereum/modules/compound.resilience.test.js.map +0 -1
- package/lib/families/ethereum/synchronisation.test.d.ts +0 -2
- package/lib/families/ethereum/synchronisation.test.d.ts.map +0 -1
- package/lib/families/ethereum/synchronisation.test.js.map +0 -1
- package/lib/families/ethereum/test-dataset.d.ts +0 -6
- package/lib/families/ethereum/test-dataset.d.ts.map +0 -1
- package/lib/families/ethereum/test-dataset.js.map +0 -1
- package/lib/families/filecoin/bridge.test.d.ts +0 -2
- package/lib/families/filecoin/bridge.test.d.ts.map +0 -1
- package/lib/families/filecoin/bridge.test.js.map +0 -1
- package/lib/families/filecoin/test-dataset.d.ts +0 -5
- package/lib/families/filecoin/test-dataset.d.ts.map +0 -1
- package/lib/families/filecoin/test-dataset.js.map +0 -1
- package/lib/families/hedera/test-dataset.d.ts +0 -5
- package/lib/families/hedera/test-dataset.d.ts.map +0 -1
- package/lib/families/hedera/test-dataset.js.map +0 -1
- package/lib/families/polkadot/bridge.test.d.ts +0 -2
- package/lib/families/polkadot/bridge.test.d.ts.map +0 -1
- package/lib/families/polkadot/bridge.test.js +0 -145
- package/lib/families/polkadot/bridge.test.js.map +0 -1
- package/lib/families/polkadot/test-dataset.d.ts +0 -5
- package/lib/families/polkadot/test-dataset.d.ts.map +0 -1
- package/lib/families/polkadot/test-dataset.js.map +0 -1
- package/lib/families/ripple/bridge.test.d.ts +0 -2
- package/lib/families/ripple/bridge.test.d.ts.map +0 -1
- package/lib/families/ripple/bridge.test.js +0 -11
- package/lib/families/ripple/bridge.test.js.map +0 -1
- package/lib/families/ripple/test-dataset.d.ts +0 -5
- package/lib/families/ripple/test-dataset.d.ts.map +0 -1
- package/lib/families/ripple/test-dataset.js.map +0 -1
- package/lib/families/solana/bridge.test.d.ts +0 -2
- package/lib/families/solana/bridge.test.d.ts.map +0 -1
- package/lib/families/solana/bridge.test.js +0 -11
- package/lib/families/solana/bridge.test.js.map +0 -1
- package/lib/families/solana/test-dataset.d.ts +0 -23
- package/lib/families/solana/test-dataset.d.ts.map +0 -1
- package/lib/families/solana/test-dataset.js.map +0 -1
- package/lib/families/solana/test-specifics.d.ts +0 -9
- package/lib/families/solana/test-specifics.d.ts.map +0 -1
- package/lib/families/solana/test-specifics.js +0 -237
- package/lib/families/solana/test-specifics.js.map +0 -1
- package/lib/families/stellar/bridge.test.d.ts +0 -2
- package/lib/families/stellar/bridge.test.d.ts.map +0 -1
- package/lib/families/stellar/bridge.test.js +0 -11
- package/lib/families/stellar/bridge.test.js.map +0 -1
- package/lib/families/stellar/test-dataset.d.ts +0 -7
- package/lib/families/stellar/test-dataset.d.ts.map +0 -1
- package/lib/families/stellar/test-dataset.js.map +0 -1
- package/lib/families/tezos/bridge.test.d.ts +0 -2
- package/lib/families/tezos/bridge.test.d.ts.map +0 -1
- package/lib/families/tezos/bridge.test.js.map +0 -1
- package/lib/families/tezos/test-dataset.d.ts.map +0 -1
- package/lib/families/tezos/test-dataset.js.map +0 -1
- package/lib/families/tron/test-dataset.d.ts +0 -5
- package/lib/families/tron/test-dataset.d.ts.map +0 -1
- package/lib/families/tron/test-dataset.js.map +0 -1
- package/lib/generated/test-dataset.d.ts +0 -19
- package/lib/generated/test-dataset.d.ts.map +0 -1
- package/lib/generated/test-dataset.js +0 -38
- package/lib/generated/test-dataset.js.map +0 -1
- package/lib/portfolio/index.d.ts +0 -30
- package/lib/portfolio/index.d.ts.map +0 -1
- package/lib/portfolio/index.js +0 -399
- package/lib/portfolio/index.js.map +0 -1
- package/lib/portfolio/range.d.ts +0 -12
- package/lib/portfolio/range.d.ts.map +0 -1
- package/lib/portfolio/range.js +0 -73
- package/lib/portfolio/range.js.map +0 -1
- package/src/__tests__/__snapshots__/portfolio.ts.snap +0 -2770
- package/src/__tests__/portfolio.ts +0 -360
- package/src/__tests__/test-helpers/libcore-setup.native.ts +0 -19
- package/src/__tests__/test-helpers/libcore-setup.ts +0 -51
- package/src/families/bitcoin/bridge.test.ts.bak +0 -6
- package/src/families/cardano/bridge.test.ts +0 -6
- package/src/families/cosmos/bridge.test.ts +0 -6
- package/src/families/crypto_org/test-dataset.ts +0 -13
- package/src/families/ethereum/bridge.test.ts.bak +0 -8
- package/src/families/filecoin/bridge.test.ts +0 -39
- package/src/families/polkadot/bridge.test.ts +0 -81
- package/src/families/ripple/bridge.test.ts +0 -6
- package/src/families/solana/bridge.test.ts +0 -6
- package/src/families/solana/test-specifics.ts +0 -170
- package/src/families/stellar/bridge.test.ts +0 -6
- package/src/families/tezos/bridge.test.ts +0 -24
- package/src/generated/test-dataset.ts +0 -48
- package/src/portfolio/index.ts +0 -505
- package/src/portfolio/range.ts +0 -71
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import "../../__tests__/test-helpers/setup";
|
|
2
|
+
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
1
3
|
import BigNumber from "bignumber.js";
|
|
2
4
|
import { CurrenciesData, DatasetTest, encodeAccountId } from "../../types";
|
|
3
|
-
|
|
4
|
-
import { Transaction, TransactionModel } from "./types";
|
|
5
|
-
|
|
5
|
+
import { SolanaStake, Transaction, TransactionModel } from "./types";
|
|
6
6
|
import scanAccounts1 from "./datasets/solana.scanAccounts.1";
|
|
7
7
|
import {
|
|
8
8
|
AmountRequired,
|
|
@@ -32,9 +32,17 @@ import createTransaction from "./js-createTransaction";
|
|
|
32
32
|
import { compact } from "lodash/fp";
|
|
33
33
|
import { assertUnreachable } from "./utils";
|
|
34
34
|
import { getEnv } from "../../env";
|
|
35
|
+
import { Account, TransactionStatus } from "../../types";
|
|
36
|
+
import { ChainAPI } from "./api";
|
|
37
|
+
import {
|
|
38
|
+
SolanaStakeAccountIsNotDelegatable,
|
|
39
|
+
SolanaStakeAccountValidatorIsUnchangeable,
|
|
40
|
+
} from "./errors";
|
|
41
|
+
import getTransactionStatus from "./js-getTransactionStatus";
|
|
42
|
+
import { prepareTransaction } from "./js-prepareTransaction";
|
|
35
43
|
|
|
36
44
|
// do not change real properties or the test will break
|
|
37
|
-
|
|
45
|
+
const testOnChainData = {
|
|
38
46
|
// --- real props ---
|
|
39
47
|
unfundedAddress: "7b6Q3ap8qRzfyvDw1Qce3fUV8C7WgFNzJQwYNTJm3KQo",
|
|
40
48
|
// 0/0
|
|
@@ -951,4 +959,161 @@ function stakingTests(): TransactionTestSpec[] {
|
|
|
951
959
|
];
|
|
952
960
|
}
|
|
953
961
|
|
|
954
|
-
|
|
962
|
+
testBridge(dataset);
|
|
963
|
+
|
|
964
|
+
const baseAccount = {
|
|
965
|
+
balance: new BigNumber(0),
|
|
966
|
+
spendableBalance: new BigNumber(0),
|
|
967
|
+
} as Account;
|
|
968
|
+
|
|
969
|
+
const baseTx = {
|
|
970
|
+
family: "solana",
|
|
971
|
+
recipient: "",
|
|
972
|
+
amount: new BigNumber(0),
|
|
973
|
+
} as Transaction;
|
|
974
|
+
|
|
975
|
+
const baseAPI = {
|
|
976
|
+
getFeeForMessage: (_msg: unknown) =>
|
|
977
|
+
Promise.resolve(testOnChainData.fees.lamportsPerSignature),
|
|
978
|
+
} as ChainAPI;
|
|
979
|
+
|
|
980
|
+
type StakeTestSpec = {
|
|
981
|
+
activationState: SolanaStake["activation"]["state"];
|
|
982
|
+
txModel: Transaction["model"];
|
|
983
|
+
expectedErrors: Record<string, Error>;
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Some business logic can not be described in terms of transactions and expected status
|
|
988
|
+
* in the test datasets, like stake activation/deactivation, because stake activation is
|
|
989
|
+
* not determenistic and changes with time. Hence the tests here to mock data
|
|
990
|
+
* to be determenistic.
|
|
991
|
+
*/
|
|
992
|
+
|
|
993
|
+
describe("solana staking", () => {
|
|
994
|
+
test("stake.delegate :: status is error: stake account is not delegatable", async () => {
|
|
995
|
+
const stakeDelegateModel: Transaction["model"] & {
|
|
996
|
+
kind: "stake.delegate";
|
|
997
|
+
} = {
|
|
998
|
+
kind: "stake.delegate",
|
|
999
|
+
uiState: {
|
|
1000
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
1001
|
+
voteAccAddr: testOnChainData.validatorAddress,
|
|
1002
|
+
},
|
|
1003
|
+
};
|
|
1004
|
+
|
|
1005
|
+
const stakeTests: StakeTestSpec[] = [
|
|
1006
|
+
{
|
|
1007
|
+
activationState: "activating",
|
|
1008
|
+
txModel: stakeDelegateModel,
|
|
1009
|
+
expectedErrors: {
|
|
1010
|
+
fee: new NotEnoughBalance(),
|
|
1011
|
+
stakeAccAddr: new SolanaStakeAccountIsNotDelegatable(),
|
|
1012
|
+
},
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
activationState: "active",
|
|
1016
|
+
txModel: stakeDelegateModel,
|
|
1017
|
+
expectedErrors: {
|
|
1018
|
+
fee: new NotEnoughBalance(),
|
|
1019
|
+
stakeAccAddr: new SolanaStakeAccountIsNotDelegatable(),
|
|
1020
|
+
},
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
activationState: "deactivating",
|
|
1024
|
+
txModel: {
|
|
1025
|
+
...stakeDelegateModel,
|
|
1026
|
+
uiState: {
|
|
1027
|
+
...stakeDelegateModel.uiState,
|
|
1028
|
+
voteAccAddr: testOnChainData.unfundedAddress,
|
|
1029
|
+
},
|
|
1030
|
+
},
|
|
1031
|
+
expectedErrors: {
|
|
1032
|
+
fee: new NotEnoughBalance(),
|
|
1033
|
+
stakeAccAddr: new SolanaStakeAccountValidatorIsUnchangeable(),
|
|
1034
|
+
},
|
|
1035
|
+
},
|
|
1036
|
+
];
|
|
1037
|
+
|
|
1038
|
+
for (const stakeTest of stakeTests) {
|
|
1039
|
+
await runStakeTest(stakeTest);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
async function runStakeTest(stakeTestSpec: StakeTestSpec) {
|
|
1045
|
+
const api = {
|
|
1046
|
+
...baseAPI,
|
|
1047
|
+
getMinimumBalanceForRentExemption: () =>
|
|
1048
|
+
Promise.resolve(testOnChainData.fees.stakeAccountRentExempt),
|
|
1049
|
+
getAccountInfo: () => {
|
|
1050
|
+
return Promise.resolve({ data: mockedVoteAccount } as any);
|
|
1051
|
+
},
|
|
1052
|
+
} as ChainAPI;
|
|
1053
|
+
|
|
1054
|
+
const account: Account = {
|
|
1055
|
+
...baseAccount,
|
|
1056
|
+
solanaResources: {
|
|
1057
|
+
stakes: [
|
|
1058
|
+
{
|
|
1059
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
1060
|
+
delegation: {
|
|
1061
|
+
stake: 1,
|
|
1062
|
+
voteAccAddr: testOnChainData.validatorAddress,
|
|
1063
|
+
},
|
|
1064
|
+
activation: {
|
|
1065
|
+
state: stakeTestSpec.activationState,
|
|
1066
|
+
},
|
|
1067
|
+
} as SolanaStake,
|
|
1068
|
+
],
|
|
1069
|
+
},
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
const tx: Transaction = {
|
|
1073
|
+
...baseTx,
|
|
1074
|
+
model: stakeTestSpec.txModel,
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
const preparedTx = await prepareTransaction(account, tx, api);
|
|
1078
|
+
const status = await getTransactionStatus(account, preparedTx);
|
|
1079
|
+
|
|
1080
|
+
const expectedStatus: TransactionStatus = {
|
|
1081
|
+
amount: new BigNumber(0),
|
|
1082
|
+
estimatedFees: new BigNumber(testOnChainData.fees.lamportsPerSignature),
|
|
1083
|
+
totalSpent: new BigNumber(testOnChainData.fees.lamportsPerSignature),
|
|
1084
|
+
errors: stakeTestSpec.expectedErrors,
|
|
1085
|
+
warnings: {},
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
expect(status).toEqual(expectedStatus);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
const mockedVoteAccount = {
|
|
1092
|
+
parsed: {
|
|
1093
|
+
info: {
|
|
1094
|
+
authorizedVoters: [
|
|
1095
|
+
{
|
|
1096
|
+
authorizedVoter: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
|
|
1097
|
+
epoch: 283,
|
|
1098
|
+
},
|
|
1099
|
+
],
|
|
1100
|
+
authorizedWithdrawer: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
|
|
1101
|
+
commission: 7,
|
|
1102
|
+
epochCredits: [
|
|
1103
|
+
{
|
|
1104
|
+
credits: "98854605",
|
|
1105
|
+
epoch: 283,
|
|
1106
|
+
previousCredits: "98728105",
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
lastTimestamp: { slot: 122422797, timestamp: 1645796249 },
|
|
1110
|
+
nodePubkey: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
|
|
1111
|
+
priorVoters: [],
|
|
1112
|
+
rootSlot: 122422766,
|
|
1113
|
+
votes: [{ confirmationCount: 1, slot: 122422797 }],
|
|
1114
|
+
},
|
|
1115
|
+
type: "vote",
|
|
1116
|
+
},
|
|
1117
|
+
program: "vote",
|
|
1118
|
+
space: 3731,
|
|
1119
|
+
};
|
package/src/families/stellar/__snapshots__/{bridge.test.ts.snap → bridge.integration.test.ts.snap}
RENAMED
|
File without changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "../../__tests__/test-helpers/setup";
|
|
2
|
+
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
1
3
|
import { BigNumber } from "bignumber.js";
|
|
2
4
|
import type { DatasetTest } from "../../types";
|
|
3
5
|
import {
|
|
@@ -13,10 +15,10 @@ import {
|
|
|
13
15
|
addMultisignStellarMockAddresses,
|
|
14
16
|
} from "./bridge/mock";
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
const notCreatedStellarMockAddress =
|
|
17
19
|
"GAW46JE3SHIAYLNNNQCAZFQ437WB5ZH7LDRDWR5LVDWHCTHCKYB6RCCH";
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
const multisignStellarMockAddress =
|
|
20
22
|
"GCDDN6T2LJN3T7SPWJQV6BCCL5KNY5GBN7X4CMSZLDEXDHXAH32TOAHS";
|
|
21
23
|
|
|
22
24
|
addNotCreatedStellarMockAddresses(notCreatedStellarMockAddress);
|
|
@@ -347,4 +349,4 @@ const dataset: DatasetTest<Transaction> = {
|
|
|
347
349
|
},
|
|
348
350
|
};
|
|
349
351
|
|
|
350
|
-
|
|
352
|
+
testBridge(dataset);
|
|
@@ -2,11 +2,13 @@ import { getMainAccount } from "../../account";
|
|
|
2
2
|
import createTransaction from "./js-createTransaction";
|
|
3
3
|
import prepareTransaction from "./js-prepareTransaction";
|
|
4
4
|
import getTransactionStatus from "./js-getTransactionStatus";
|
|
5
|
-
import { notCreatedStellarMockAddress } from "./test-dataset";
|
|
6
5
|
import type { Account, AccountLike } from "../../types";
|
|
7
6
|
import type { Transaction } from "./types";
|
|
8
7
|
import BigNumber from "bignumber.js";
|
|
9
8
|
|
|
9
|
+
const notCreatedStellarMockAddress =
|
|
10
|
+
"GAW46JE3SHIAYLNNNQCAZFQ437WB5ZH7LDRDWR5LVDWHCTHCKYB6RCCH";
|
|
11
|
+
|
|
10
12
|
const estimateMaxSpendable = async ({
|
|
11
13
|
account,
|
|
12
14
|
parentAccount,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import "../../__tests__/test-helpers/setup";
|
|
2
|
+
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
3
|
+
import { fromAccountRaw } from "../../account";
|
|
4
|
+
import { loadAccountDelegation, listBakers } from "./bakers";
|
|
5
|
+
import whitelist from "./bakers.whitelist-default";
|
|
6
|
+
|
|
1
7
|
import { AmountRequired, NotEnoughBalance } from "@ledgerhq/errors";
|
|
2
8
|
import type { DatasetTest } from "../../types";
|
|
3
9
|
import type { Transaction } from "./types";
|
|
@@ -100,7 +106,6 @@ const dataset: DatasetTest<Transaction> = {
|
|
|
100
106
|
},
|
|
101
107
|
},
|
|
102
108
|
};
|
|
103
|
-
export default dataset;
|
|
104
109
|
|
|
105
110
|
function makeAccount(name, pubkey, address, derivationMode) {
|
|
106
111
|
return {
|
|
@@ -123,3 +128,19 @@ function makeAccount(name, pubkey, address, derivationMode) {
|
|
|
123
128
|
subAccounts: [],
|
|
124
129
|
};
|
|
125
130
|
}
|
|
131
|
+
|
|
132
|
+
testBridge(dataset);
|
|
133
|
+
|
|
134
|
+
describe("tezos bakers", () => {
|
|
135
|
+
// FIXME Flaky test that will fail every time a Tezos baker is discontinued
|
|
136
|
+
test("getting the bakers", async () => {
|
|
137
|
+
const list = await listBakers(whitelist);
|
|
138
|
+
expect(list.map((o) => o.address)).toEqual(whitelist);
|
|
139
|
+
});
|
|
140
|
+
// TODO we'll need two accounts to test diff cases
|
|
141
|
+
test("load account baker info", async () => {
|
|
142
|
+
const account = fromAccountRaw(accountTZrevealedDelegating);
|
|
143
|
+
const delegation = await loadAccountDelegation(account);
|
|
144
|
+
expect(delegation).toBe(null);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -208,7 +208,7 @@ const txToOp =
|
|
|
208
208
|
type = "CREATE";
|
|
209
209
|
maybeValue = new BigNumber(tx.contractBalance || 0);
|
|
210
210
|
senders = [address];
|
|
211
|
-
recipients = [tx.originatedContract
|
|
211
|
+
recipients = [tx.originatedContract?.address || ""];
|
|
212
212
|
break;
|
|
213
213
|
case "activation":
|
|
214
214
|
type = "IN";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import "../../__tests__/test-helpers/setup";
|
|
2
|
+
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
1
3
|
import invariant from "invariant";
|
|
2
4
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import type { DatasetTest } from "../../types";
|
|
5
|
+
import type { CurrenciesData, DatasetTest } from "../../types";
|
|
4
6
|
import { fromTransactionRaw } from "./transaction";
|
|
5
7
|
import type { Transaction } from "./types";
|
|
6
8
|
import { activationFees } from "./constants";
|
|
@@ -38,8 +40,7 @@ const getTokenAccountId = (account, id) =>
|
|
|
38
40
|
)
|
|
39
41
|
).id;
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
const tron = {
|
|
43
|
+
const tron: CurrenciesData<Transaction> = {
|
|
43
44
|
FIXME_ignoreAccountFields: [
|
|
44
45
|
"tronResources.cacheTransactionInfoById", // this is a cache, don't save it
|
|
45
46
|
"tronResources.unwithdrawnReward", // it changes every vote cycles
|
|
@@ -771,8 +772,8 @@ const tron = {
|
|
|
771
772
|
const dataset: DatasetTest<Transaction> = {
|
|
772
773
|
implementations: ["tronjs"],
|
|
773
774
|
currencies: {
|
|
774
|
-
|
|
775
|
+
tron,
|
|
775
776
|
},
|
|
776
777
|
};
|
|
777
778
|
|
|
778
|
-
|
|
779
|
+
testBridge(dataset);
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { scan, tap, catchError } from "rxjs/operators";
|
|
1
|
+
import { log } from "@ledgerhq/logs";
|
|
3
2
|
import { useEffect, useState } from "react";
|
|
3
|
+
import { concat, Observable, of } from "rxjs";
|
|
4
|
+
import { catchError, scan, tap } from "rxjs/operators";
|
|
4
5
|
import { getMainAccount } from "../../account";
|
|
5
|
-
import type { ConnectAppEvent, Input as ConnectAppInput } from "../connectApp";
|
|
6
|
-
import type { InitSwapInput, SwapTransaction } from "../../exchange/swap/types";
|
|
7
|
-
import type { Action, Device } from "./types";
|
|
8
|
-
import type { AppState } from "./app";
|
|
9
|
-
import { log } from "@ledgerhq/logs";
|
|
10
|
-
import { createAction as createAppAction } from "./app";
|
|
11
6
|
import type {
|
|
12
7
|
Exchange,
|
|
13
8
|
ExchangeRate,
|
|
9
|
+
InitSwapInput,
|
|
14
10
|
InitSwapResult,
|
|
15
11
|
SwapRequestEvent,
|
|
12
|
+
SwapTransaction,
|
|
16
13
|
} from "../../exchange/swap/types";
|
|
14
|
+
import type { ConnectAppEvent, Input as ConnectAppInput } from "../connectApp";
|
|
15
|
+
import type { AppState } from "./app";
|
|
16
|
+
import { createAction as createAppAction } from "./app";
|
|
17
|
+
import type { Action, Device } from "./types";
|
|
17
18
|
|
|
18
19
|
type State = {
|
|
19
20
|
initSwapResult: InitSwapResult | null | undefined;
|
|
20
21
|
initSwapRequested: boolean;
|
|
21
22
|
initSwapError: Error | null | undefined;
|
|
23
|
+
swapId?: string;
|
|
22
24
|
error?: Error;
|
|
23
25
|
isLoading: boolean;
|
|
24
26
|
freezeReduxDevice: boolean;
|
|
@@ -40,6 +42,7 @@ type Result =
|
|
|
40
42
|
}
|
|
41
43
|
| {
|
|
42
44
|
initSwapError: Error;
|
|
45
|
+
swapId?: string;
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
type InitSwapAction = Action<InitSwapRequest, InitSwapState, Result>;
|
|
@@ -47,6 +50,7 @@ type InitSwapAction = Action<InitSwapRequest, InitSwapState, Result>;
|
|
|
47
50
|
const mapResult = ({
|
|
48
51
|
initSwapResult,
|
|
49
52
|
initSwapError,
|
|
53
|
+
swapId,
|
|
50
54
|
}: InitSwapState): Result | null | undefined =>
|
|
51
55
|
initSwapResult
|
|
52
56
|
? {
|
|
@@ -55,12 +59,14 @@ const mapResult = ({
|
|
|
55
59
|
: initSwapError
|
|
56
60
|
? {
|
|
57
61
|
initSwapError,
|
|
62
|
+
swapId,
|
|
58
63
|
}
|
|
59
64
|
: null;
|
|
60
65
|
|
|
61
66
|
const initialState: State = {
|
|
62
67
|
initSwapResult: null,
|
|
63
68
|
initSwapError: null,
|
|
69
|
+
swapId: undefined,
|
|
64
70
|
initSwapRequested: false,
|
|
65
71
|
isLoading: true,
|
|
66
72
|
freezeReduxDevice: false,
|
|
@@ -72,7 +78,12 @@ const reducer = (state: State, e: SwapRequestEvent) => {
|
|
|
72
78
|
return { ...state, freezeReduxDevice: true };
|
|
73
79
|
|
|
74
80
|
case "init-swap-error":
|
|
75
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
...state,
|
|
83
|
+
initSwapError: e.error,
|
|
84
|
+
swapId: e.swapId,
|
|
85
|
+
isLoading: false,
|
|
86
|
+
};
|
|
76
87
|
|
|
77
88
|
case "init-swap-requested":
|
|
78
89
|
return {
|
package/src/load/speculos.ts
CHANGED
|
@@ -316,8 +316,11 @@ export function appCandidatesMatches(
|
|
|
316
316
|
hackBadSemver(appCandidate.firmware),
|
|
317
317
|
searchFirmware
|
|
318
318
|
))) &&
|
|
319
|
-
(!search.appVersion
|
|
320
|
-
|
|
319
|
+
((!search.appVersion &&
|
|
320
|
+
!appCandidate.appVersion.includes("prerelease") &&
|
|
321
|
+
!appCandidate.appVersion.includes("rc")) ||
|
|
322
|
+
(search.appVersion &&
|
|
323
|
+
semver.satisfies(appCandidate.appVersion, search.appVersion)))
|
|
321
324
|
);
|
|
322
325
|
}
|
|
323
326
|
export const findAppCandidate = (
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function encodeERC721OperationId(
|
|
2
|
+
nftId: string,
|
|
3
|
+
hash: string,
|
|
4
|
+
type: string
|
|
5
|
+
): string {
|
|
6
|
+
return `${nftId}-${hash}-${type}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function decodeERC721OperationId(id: string): {
|
|
10
|
+
nftId: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
type: string;
|
|
13
|
+
} {
|
|
14
|
+
const [nftId, hash, type] = id.split("-");
|
|
15
|
+
return {
|
|
16
|
+
nftId,
|
|
17
|
+
hash,
|
|
18
|
+
type,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function encodeERC1155OperationId(
|
|
23
|
+
nftId: string,
|
|
24
|
+
hash: string,
|
|
25
|
+
type: string,
|
|
26
|
+
i = 0,
|
|
27
|
+
j = 0
|
|
28
|
+
): string {
|
|
29
|
+
return `${nftId}-${hash}-${type}-i${i}_${j}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function decodeERC1155OperationId(id: string): {
|
|
33
|
+
nftId: string;
|
|
34
|
+
hash: string;
|
|
35
|
+
type: string;
|
|
36
|
+
i: number;
|
|
37
|
+
j: number;
|
|
38
|
+
} {
|
|
39
|
+
const [nftId, hash, type, i, j] = id.split("-");
|
|
40
|
+
return {
|
|
41
|
+
nftId,
|
|
42
|
+
hash,
|
|
43
|
+
type,
|
|
44
|
+
i: Number(i),
|
|
45
|
+
j: Number(j),
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/operation.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
|
-
import
|
|
2
|
+
import { encodeNftId } from "./nft";
|
|
3
|
+
import {
|
|
4
|
+
encodeERC1155OperationId,
|
|
5
|
+
encodeERC721OperationId,
|
|
6
|
+
} from "./nft/nftOperationId";
|
|
7
|
+
import {
|
|
8
|
+
Account,
|
|
9
|
+
AccountLike,
|
|
10
|
+
decodeAccountId,
|
|
11
|
+
NFTStandard,
|
|
12
|
+
Operation,
|
|
13
|
+
} from "./types";
|
|
14
|
+
|
|
15
|
+
const nftOperationIdEncoderPerStandard: Record<
|
|
16
|
+
NFTStandard,
|
|
17
|
+
(...args: any[]) => string
|
|
18
|
+
> = {
|
|
19
|
+
ERC721: encodeERC721OperationId,
|
|
20
|
+
ERC1155: encodeERC1155OperationId,
|
|
21
|
+
};
|
|
3
22
|
|
|
4
23
|
export function findOperationInAccount(
|
|
5
24
|
{ operations, pendingOperations }: AccountLike,
|
|
@@ -32,6 +51,16 @@ export function findOperationInAccount(
|
|
|
32
51
|
for (let i = 0; i < pendingOperations.length; i++) {
|
|
33
52
|
const op = pendingOperations[i];
|
|
34
53
|
if (op.id === operationId) return op;
|
|
54
|
+
|
|
55
|
+
if (op.nftOperations) {
|
|
56
|
+
const nftOps = op.nftOperations;
|
|
57
|
+
|
|
58
|
+
for (let j = 0; j < nftOps.length; j++) {
|
|
59
|
+
const nftOp = nftOps[j];
|
|
60
|
+
|
|
61
|
+
if (nftOp.id === operationId) return nftOp;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
35
64
|
}
|
|
36
65
|
|
|
37
66
|
return null;
|
|
@@ -73,6 +102,26 @@ export function patchOperationWithHash(
|
|
|
73
102
|
hash,
|
|
74
103
|
id: encodeOperationId(op.accountId, hash, op.type),
|
|
75
104
|
})),
|
|
105
|
+
nftOperations:
|
|
106
|
+
operation.nftOperations &&
|
|
107
|
+
operation.nftOperations.map((nftOp, i) => {
|
|
108
|
+
const { currencyId } = decodeAccountId(operation.accountId);
|
|
109
|
+
const nftId = encodeNftId(
|
|
110
|
+
operation.accountId,
|
|
111
|
+
nftOp.contract || "",
|
|
112
|
+
nftOp.tokenId || "",
|
|
113
|
+
currencyId
|
|
114
|
+
);
|
|
115
|
+
const nftOperationIdEncoder =
|
|
116
|
+
nftOperationIdEncoderPerStandard[nftOp?.standard || ""] ||
|
|
117
|
+
nftOperationIdEncoderPerStandard.ERC721;
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
...nftOp,
|
|
121
|
+
hash,
|
|
122
|
+
id: nftOperationIdEncoder(nftId, hash, nftOp.type, 0, i),
|
|
123
|
+
};
|
|
124
|
+
}),
|
|
76
125
|
};
|
|
77
126
|
}
|
|
78
127
|
|
|
@@ -24,8 +24,13 @@ import type {
|
|
|
24
24
|
ValueChange,
|
|
25
25
|
} from "./types";
|
|
26
26
|
import { getPortfolioRangeConfig, getDates } from "./range";
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
|
|
28
|
+
export const defaultAssetsDistribution = {
|
|
29
|
+
minShowFirst: 1,
|
|
30
|
+
maxShowFirst: 6,
|
|
31
|
+
showFirstThreshold: 0.95,
|
|
32
|
+
};
|
|
33
|
+
export type AssetsDistributionOpts = typeof defaultAssetsDistribution;
|
|
29
34
|
|
|
30
35
|
export function getPortfolioCount(
|
|
31
36
|
accounts: AccountLike[],
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
startOfHour,
|
|
3
|
+
startOfMonth,
|
|
4
|
+
startOfDay,
|
|
5
|
+
startOfWeek,
|
|
6
|
+
getPortfolioRangeConfig,
|
|
7
|
+
getDates,
|
|
8
|
+
getRanges,
|
|
9
|
+
} from "./range";
|
|
10
|
+
|
|
11
|
+
describe("startOfHour", () => {
|
|
12
|
+
test("basic test", () => {
|
|
13
|
+
expect(startOfHour(new Date(1655827384305)).toISOString()).toBe(
|
|
14
|
+
"2022-06-21T16:00:00.000Z"
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe("startOfDay", () => {
|
|
19
|
+
test("basic test", () => {
|
|
20
|
+
expect(startOfDay(new Date(1655827384305)).toISOString()).toBe(
|
|
21
|
+
"2022-06-21T04:00:00.000Z"
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("startOfMonth", () => {
|
|
26
|
+
test("basic test", () => {
|
|
27
|
+
expect(startOfMonth(new Date(1655827384305)).toISOString()).toBe(
|
|
28
|
+
"2022-06-01T04:00:00.000Z"
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("startOfWeek", () => {
|
|
33
|
+
test("basic test", () => {
|
|
34
|
+
expect(startOfWeek(new Date(1655827384305)).toISOString()).toBe(
|
|
35
|
+
"2022-06-19T04:00:00.000Z"
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe("getPortfolioRangeConfig", () => {
|
|
40
|
+
test("returns a value for day", () => {
|
|
41
|
+
expect(getPortfolioRangeConfig("day")).toBeDefined();
|
|
42
|
+
});
|
|
43
|
+
test("returns a value for week", () => {
|
|
44
|
+
expect(getPortfolioRangeConfig("week")).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
test("returns a value for month", () => {
|
|
47
|
+
expect(getPortfolioRangeConfig("month")).toBeDefined();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe("getDates", () => {
|
|
51
|
+
test("day returns an array of asked size", () => {
|
|
52
|
+
expect(getDates("day", 100).length).toEqual(100);
|
|
53
|
+
});
|
|
54
|
+
test("week returns an array of asked size", () => {
|
|
55
|
+
expect(getDates("week", 100).length).toEqual(100);
|
|
56
|
+
});
|
|
57
|
+
test("month returns an array of asked size", () => {
|
|
58
|
+
expect(getDates("month", 100).length).toEqual(100);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("getRanges", () => {
|
|
63
|
+
test("returns a non empty array", () => {
|
|
64
|
+
expect(getRanges().length).toBeGreaterThan(0);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
weekIncrement,
|
|
3
|
-
dayIncrement,
|
|
4
|
-
hourIncrement,
|
|
5
|
-
startOfWeek,
|
|
6
|
-
startOfDay,
|
|
7
|
-
startOfHour,
|
|
8
|
-
} from "../range";
|
|
9
1
|
import type { PortfolioRangeConfig, PortfolioRange } from "./types";
|
|
2
|
+
|
|
3
|
+
export const hourIncrement = 60 * 60 * 1000;
|
|
4
|
+
export const dayIncrement = 24 * hourIncrement;
|
|
5
|
+
export const weekIncrement = 7 * dayIncrement;
|
|
6
|
+
|
|
7
|
+
export function startOfHour(t: Date): Date {
|
|
8
|
+
return new Date(t.getFullYear(), t.getMonth(), t.getDate(), t.getHours());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function startOfMonth(t: Date): Date {
|
|
12
|
+
return new Date(t.getFullYear(), t.getMonth(), 1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function startOfDay(t: Date): Date {
|
|
16
|
+
return new Date(t.getFullYear(), t.getMonth(), t.getDate());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function startOfWeek(t: Date): Date {
|
|
20
|
+
const d = startOfDay(t);
|
|
21
|
+
return new Date(d.getTime() - d.getDay() * dayIncrement);
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
export function getPortfolioRangeConfig(
|
|
11
25
|
r: PortfolioRange
|
|
12
26
|
): PortfolioRangeConfig {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../src/__tests__/portfolio.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|