@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getEnv } from "../../env";
|
|
2
|
+
import network from "../../network";
|
|
3
|
+
import { getSwapAPIBaseURL } from "./";
|
|
4
|
+
import { mockPostSwapAccepted, mockPostSwapCancelled } from "./mock";
|
|
5
|
+
import type { PostSwapAccepted, PostSwapCancelled } from "./types";
|
|
6
|
+
|
|
7
|
+
export const postSwapAccepted: PostSwapAccepted = async ({
|
|
8
|
+
provider,
|
|
9
|
+
swapId = "",
|
|
10
|
+
transactionId,
|
|
11
|
+
}) => {
|
|
12
|
+
if (getEnv("MOCK"))
|
|
13
|
+
return mockPostSwapAccepted({ provider, swapId, transactionId });
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Since swapId is requiered by the endpoit, don't call it if we don't have
|
|
17
|
+
* this info
|
|
18
|
+
*/
|
|
19
|
+
if (!swapId) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
await network({
|
|
25
|
+
method: "POST",
|
|
26
|
+
url: `${getSwapAPIBaseURL()}/swap/accepted`,
|
|
27
|
+
data: { provider, swapId, transactionId },
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(error);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const postSwapCancelled: PostSwapCancelled = async ({
|
|
37
|
+
provider,
|
|
38
|
+
swapId = "",
|
|
39
|
+
}) => {
|
|
40
|
+
if (getEnv("MOCK")) return mockPostSwapCancelled({ provider, swapId });
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Since swapId is requiered by the endpoit, don't call it if we don't have
|
|
44
|
+
* this info
|
|
45
|
+
*/
|
|
46
|
+
if (!swapId) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
await network({
|
|
52
|
+
method: "POST",
|
|
53
|
+
url: `${getSwapAPIBaseURL()}/swap/cancelled`,
|
|
54
|
+
data: { provider, swapId },
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error(error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
|
-
import type { Account, AccountLike } from "../../types/account";
|
|
3
2
|
import type {
|
|
4
|
-
AccountRawLike,
|
|
5
3
|
AccountRaw,
|
|
6
|
-
|
|
7
|
-
Transaction,
|
|
4
|
+
AccountRawLike,
|
|
8
5
|
CryptoCurrency,
|
|
6
|
+
Operation,
|
|
9
7
|
TokenCurrency,
|
|
8
|
+
Transaction,
|
|
10
9
|
TransactionRaw,
|
|
11
10
|
} from "../../types";
|
|
11
|
+
import type { Account, AccountLike } from "../../types/account";
|
|
12
12
|
|
|
13
13
|
/// v3 changes here, move me to another folder soon
|
|
14
14
|
export type ValidKYCStatus = "open" | "pending" | "approved" | "closed";
|
|
@@ -81,6 +81,39 @@ export type AvailableProviderV3 = {
|
|
|
81
81
|
pairs: Array<{ from: string; to: string; tradeMethod: string }>;
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
type CheckQuoteOkStatus = {
|
|
85
|
+
codeName: "RATE_VALID";
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
type ValidCheckQuoteErrorCodes =
|
|
89
|
+
| "UNKNOW_USER"
|
|
90
|
+
| "KYC_UNDEFINED"
|
|
91
|
+
| "KYC_PENDING"
|
|
92
|
+
| "KYC_FAILED"
|
|
93
|
+
| "KYC_UPGRADE_REQUIRED"
|
|
94
|
+
| "OVER_TRADE_LIMIT"
|
|
95
|
+
| "UNKNOWN_ERROR"
|
|
96
|
+
| "WITHDRAWALS_BLOCKED"
|
|
97
|
+
| "MFA_REQUIRED"
|
|
98
|
+
| "RATE_NOT_FOUND";
|
|
99
|
+
|
|
100
|
+
type CheckQuoteErrorStatus = {
|
|
101
|
+
codeName: ValidCheckQuoteErrorCodes;
|
|
102
|
+
error: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type CheckQuoteStatus = CheckQuoteOkStatus | CheckQuoteErrorStatus;
|
|
107
|
+
|
|
108
|
+
export type CheckQuote = ({
|
|
109
|
+
provider,
|
|
110
|
+
quoteId,
|
|
111
|
+
bearerToken,
|
|
112
|
+
}: {
|
|
113
|
+
provider: string;
|
|
114
|
+
quoteId: string;
|
|
115
|
+
bearerToken: string;
|
|
116
|
+
}) => Promise<CheckQuoteStatus>;
|
|
84
117
|
export type AvailableProvider = AvailableProviderV2 | AvailableProviderV3;
|
|
85
118
|
export type GetExchangeRates = (
|
|
86
119
|
arg0: Exchange,
|
|
@@ -93,6 +126,7 @@ export type InitSwapResult = {
|
|
|
93
126
|
transaction: Transaction;
|
|
94
127
|
swapId: string;
|
|
95
128
|
};
|
|
129
|
+
|
|
96
130
|
type ValidSwapStatus =
|
|
97
131
|
| "pending"
|
|
98
132
|
| "onhold"
|
|
@@ -108,7 +142,31 @@ export type SwapStatus = {
|
|
|
108
142
|
swapId: string;
|
|
109
143
|
status: ValidSwapStatus;
|
|
110
144
|
};
|
|
111
|
-
|
|
145
|
+
|
|
146
|
+
// -----
|
|
147
|
+
// Related to Swap state API call (accepted or cancelled)
|
|
148
|
+
|
|
149
|
+
type SwapStateRequest = {
|
|
150
|
+
provider: string;
|
|
151
|
+
swapId: string;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type SwapStateAcceptedRequest = SwapStateRequest & {
|
|
155
|
+
transactionId: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type SwapStateCancelledRequest = SwapStateRequest;
|
|
159
|
+
|
|
160
|
+
export type PostSwapAccepted = (
|
|
161
|
+
arg0: SwapStateAcceptedRequest
|
|
162
|
+
) => Promise<null>;
|
|
163
|
+
|
|
164
|
+
export type PostSwapCancelled = (
|
|
165
|
+
arg0: SwapStateCancelledRequest
|
|
166
|
+
) => Promise<null>;
|
|
167
|
+
|
|
168
|
+
// -----
|
|
169
|
+
|
|
112
170
|
export type UpdateAccountSwapStatus = (
|
|
113
171
|
arg0: Account
|
|
114
172
|
) => Promise<Account | null | undefined>;
|
|
@@ -125,6 +183,7 @@ export type SwapRequestEvent =
|
|
|
125
183
|
| {
|
|
126
184
|
type: "init-swap-error";
|
|
127
185
|
error: Error;
|
|
186
|
+
swapId: string;
|
|
128
187
|
}
|
|
129
188
|
| {
|
|
130
189
|
type: "init-swap-result";
|
|
@@ -203,3 +262,7 @@ export type InitSwapInputRaw = {
|
|
|
203
262
|
deviceId: string;
|
|
204
263
|
userId?: string;
|
|
205
264
|
};
|
|
265
|
+
|
|
266
|
+
export interface CustomMinOrMaxError extends Error {
|
|
267
|
+
amount: BigNumber;
|
|
268
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { Account, SubAccount } from "../../types";
|
|
2
|
+
import { isSwapOperationPending } from "./";
|
|
1
3
|
import { getMultipleStatus } from "./getStatus";
|
|
2
|
-
import type { SubAccount, Account } from "../../types";
|
|
3
4
|
import type {
|
|
4
|
-
UpdateAccountSwapStatus,
|
|
5
5
|
SwapOperation,
|
|
6
6
|
SwapStatusRequest,
|
|
7
|
+
UpdateAccountSwapStatus,
|
|
7
8
|
} from "./types";
|
|
8
|
-
import { operationStatusList } from "./";
|
|
9
9
|
|
|
10
10
|
const maybeGetUpdatedSwapHistory = async (
|
|
11
11
|
swapHistory: SwapOperation[] | null | undefined
|
|
@@ -16,7 +16,7 @@ const maybeGetUpdatedSwapHistory = async (
|
|
|
16
16
|
|
|
17
17
|
if (swapHistory) {
|
|
18
18
|
for (const { provider, swapId, status } of swapHistory) {
|
|
19
|
-
if (
|
|
19
|
+
if (isSwapOperationPending(status)) {
|
|
20
20
|
pendingSwapIds.push({
|
|
21
21
|
provider,
|
|
22
22
|
swapId,
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
+
import { getTokenById } from "@ledgerhq/cryptoassets/lib/tokens";
|
|
1
2
|
import BigNumber from "bignumber.js";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
pickExchangeRate,
|
|
5
|
-
getAccountTuplesForCurrency,
|
|
6
|
-
getAvailableAccountsById,
|
|
7
|
-
} from "./index";
|
|
8
|
-
import { getMockExchangeRate } from "../mock";
|
|
3
|
+
import { getCryptoCurrencyById } from "../../../currencies";
|
|
9
4
|
import { genAccount } from "../../../mock/account";
|
|
10
5
|
import type {
|
|
11
6
|
Account,
|
|
@@ -13,62 +8,14 @@ import type {
|
|
|
13
8
|
SubAccount,
|
|
14
9
|
TokenCurrency,
|
|
15
10
|
} from "../../../types";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
expect(setExchangeRate).toHaveBeenCalledTimes(1);
|
|
25
|
-
expect(setExchangeRate).toHaveBeenCalledWith(null);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("calls the callback function with null when no exchange rates are passed but there is an exchange rate", () => {
|
|
29
|
-
const setExchangeRate = jest.fn();
|
|
30
|
-
const exchangeRate = getMockExchangeRate({ provider: "wyre" });
|
|
31
|
-
pickExchangeRate([], exchangeRate, setExchangeRate);
|
|
32
|
-
|
|
33
|
-
expect(setExchangeRate).toHaveBeenCalledTimes(1);
|
|
34
|
-
expect(setExchangeRate).toHaveBeenCalledWith(null);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("calls the callback function with the first exchange rate when the exchange passed isn't included in the list", () => {
|
|
38
|
-
const setExchangeRate = jest.fn();
|
|
39
|
-
const firstExchangeRate = getMockExchangeRate({
|
|
40
|
-
provider: "changelly",
|
|
41
|
-
tradeMethod: "fixed",
|
|
42
|
-
});
|
|
43
|
-
const exchangeRates = [
|
|
44
|
-
firstExchangeRate,
|
|
45
|
-
getMockExchangeRate({ provider: "changelly", tradeMethod: "float" }),
|
|
46
|
-
];
|
|
47
|
-
const exchangeRate = getMockExchangeRate({ provider: "wyre" });
|
|
48
|
-
|
|
49
|
-
pickExchangeRate(exchangeRates, exchangeRate, setExchangeRate);
|
|
50
|
-
|
|
51
|
-
expect(setExchangeRate).toHaveBeenCalledTimes(1);
|
|
52
|
-
expect(setExchangeRate).toHaveBeenCalledWith(firstExchangeRate);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("calls the callback function with the passed exchange rate when the exchange passed is included in the list", () => {
|
|
56
|
-
const setExchangeRate = jest.fn();
|
|
57
|
-
const exchangeRate = getMockExchangeRate({
|
|
58
|
-
provider: "changelly",
|
|
59
|
-
tradeMethod: "fixed",
|
|
60
|
-
});
|
|
61
|
-
const exchangeRates = [
|
|
62
|
-
getMockExchangeRate({ provider: "changelly", tradeMethod: "float" }),
|
|
63
|
-
exchangeRate,
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
pickExchangeRate(exchangeRates, exchangeRate, setExchangeRate);
|
|
67
|
-
|
|
68
|
-
expect(setExchangeRate).toHaveBeenCalledTimes(1);
|
|
69
|
-
expect(setExchangeRate).toHaveBeenCalledWith(exchangeRate);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
11
|
+
import {
|
|
12
|
+
getAccountTuplesForCurrency,
|
|
13
|
+
getAvailableAccountsById,
|
|
14
|
+
getProviderName,
|
|
15
|
+
KYCStatus,
|
|
16
|
+
shouldShowKYCBanner,
|
|
17
|
+
shouldShowLoginBanner,
|
|
18
|
+
} from "./index";
|
|
72
19
|
|
|
73
20
|
/* TODO: Refacto these two function and move them to mock/account.ts if needed */
|
|
74
21
|
function* accountGenerator(currency: CryptoCurrency): Generator<Account> {
|
|
@@ -265,3 +212,120 @@ describe("swap/utils/getAvailableAccountsById", () => {
|
|
|
265
212
|
);
|
|
266
213
|
});
|
|
267
214
|
});
|
|
215
|
+
|
|
216
|
+
describe("swap/utils/shouldShowLoginBanner", () => {
|
|
217
|
+
test("should not display Login banner if no provider is specified", () => {
|
|
218
|
+
const result = shouldShowLoginBanner({
|
|
219
|
+
provider: undefined,
|
|
220
|
+
token: "token",
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
expect(result).toBe(false);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
["changelly", "wyre"].forEach((provider) => {
|
|
227
|
+
test(`should not display Login banner for ${provider}`, () => {
|
|
228
|
+
const result = shouldShowLoginBanner({
|
|
229
|
+
provider,
|
|
230
|
+
token: "token",
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
expect(result).toBe(false);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
["ftx", "ftxus"].forEach((provider) => {
|
|
238
|
+
describe(`${provider.toUpperCase()}`, () => {
|
|
239
|
+
test("should display Login banner if no token is provided", () => {
|
|
240
|
+
const result = shouldShowLoginBanner({
|
|
241
|
+
provider: provider,
|
|
242
|
+
token: undefined,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
expect(result).toBe(true);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test("should display Login banner if token is expired", () => {
|
|
249
|
+
/**
|
|
250
|
+
* TODO: add test by mocking `isJwtExpired`
|
|
251
|
+
*/
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test("should not display Login banner if token is not expired", () => {
|
|
255
|
+
/**
|
|
256
|
+
* TODO: add test by mocking `isJwtExpired`
|
|
257
|
+
*/
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe("swap/utils/shouldShowKYCBanner", () => {
|
|
264
|
+
test("should not display KYC banner if no provider is specified", () => {
|
|
265
|
+
const result = shouldShowKYCBanner({
|
|
266
|
+
provider: undefined,
|
|
267
|
+
kycStatus: "rejected",
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
expect(result).toBe(false);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test("should not display KYC banner if provider does not require KYC", () => {
|
|
274
|
+
const result = shouldShowKYCBanner({
|
|
275
|
+
provider: "changelly",
|
|
276
|
+
kycStatus: "rejected",
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
expect(result).toBe(false);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
["ftx", "ftxus", "wyre"].forEach((provider) => {
|
|
283
|
+
describe(`${provider.toUpperCase()}`, () => {
|
|
284
|
+
["pending", "upgradeRequired", "rejected"].forEach((status) => {
|
|
285
|
+
test(`should display KYC banner if kycStatus is ${status}`, () => {
|
|
286
|
+
const result = shouldShowKYCBanner({
|
|
287
|
+
provider,
|
|
288
|
+
kycStatus: status as KYCStatus,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
expect(result).toBe(true);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("should not display KYC banner if kycStatus is approved", () => {
|
|
296
|
+
const result = shouldShowKYCBanner({
|
|
297
|
+
provider,
|
|
298
|
+
kycStatus: "approved",
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
expect(result).toBe(false);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe("swap/utils/getProviderName", () => {
|
|
308
|
+
test("should return uppercase provider name for ftx", () => {
|
|
309
|
+
const expectedResult = "FTX";
|
|
310
|
+
|
|
311
|
+
const result = getProviderName("ftx");
|
|
312
|
+
|
|
313
|
+
expect(result).toBe(expectedResult);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test("should return uppercase provider name for ftxus", () => {
|
|
317
|
+
const expectedResult = "FTXUS";
|
|
318
|
+
|
|
319
|
+
const result = getProviderName("ftxus");
|
|
320
|
+
|
|
321
|
+
expect(result).toBe(expectedResult);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test("should return capitalized provider name for other provider", () => {
|
|
325
|
+
const expectedResult = "Changelly";
|
|
326
|
+
|
|
327
|
+
const result = getProviderName("changelly");
|
|
328
|
+
|
|
329
|
+
expect(result).toBe(expectedResult);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/cryptoassets";
|
|
2
|
-
import
|
|
2
|
+
import jwtDecode from "jwt-decode";
|
|
3
|
+
import { getProviderConfig } from "../";
|
|
4
|
+
import { getAccountCurrency, makeEmptyTokenAccount } from "../../../account";
|
|
5
|
+
import { getEnv } from "../../../env";
|
|
3
6
|
import { Account, SubAccount, TokenAccount } from "../../../types";
|
|
4
|
-
import type {
|
|
5
|
-
import { getAccountCurrency } from "../../../account";
|
|
7
|
+
import type { CheckQuoteStatus } from "../types";
|
|
6
8
|
|
|
9
|
+
// Note: looks like we can't use an enum because this is used in LLD js code
|
|
7
10
|
export const KYC_STATUS = {
|
|
8
11
|
pending: "pending",
|
|
9
12
|
rejected: "closed",
|
|
10
13
|
approved: "approved",
|
|
14
|
+
upgradeRequired: "upgradeRequired",
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
export type KYCStatus = keyof typeof KYC_STATUS;
|
|
14
18
|
|
|
15
|
-
export const pickExchangeRate = (
|
|
16
|
-
exchangeRates: ExchangeRate[],
|
|
17
|
-
exchangeRate: ExchangeRate | null | undefined,
|
|
18
|
-
setExchangeRate: (rate?: ExchangeRate | null) => void
|
|
19
|
-
): void => {
|
|
20
|
-
const hasRates = exchangeRates?.length > 0;
|
|
21
|
-
// If the user picked an exchange rate before, try to select the new one that matches.
|
|
22
|
-
// Otherwise pick the first one.
|
|
23
|
-
const rate =
|
|
24
|
-
hasRates &&
|
|
25
|
-
((exchangeRate &&
|
|
26
|
-
exchangeRates.find(
|
|
27
|
-
({ tradeMethod, provider }) =>
|
|
28
|
-
tradeMethod === exchangeRate.tradeMethod &&
|
|
29
|
-
provider === exchangeRate.provider
|
|
30
|
-
)) ||
|
|
31
|
-
exchangeRates[0]);
|
|
32
|
-
setExchangeRate(rate || null);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
19
|
export type AccountTuple = {
|
|
36
20
|
account: Account | null | undefined;
|
|
37
21
|
subAccount: SubAccount | null | undefined;
|
|
@@ -76,3 +60,124 @@ export const getAvailableAccountsById = (
|
|
|
76
60
|
accounts
|
|
77
61
|
.filter((acc) => getAccountCurrency(acc)?.id === id && !acc.disabled)
|
|
78
62
|
.sort((a, b) => b.balance.minus(a.balance).toNumber());
|
|
63
|
+
|
|
64
|
+
// Note: used in UI (LLD / LLM)
|
|
65
|
+
export const isJwtExpired = (jwtToken: string): boolean => {
|
|
66
|
+
/**
|
|
67
|
+
* Note:
|
|
68
|
+
* The JWT token should have at least an exp property (the expiration date of the token)
|
|
69
|
+
*/
|
|
70
|
+
const { exp } = jwtDecode<{ exp: number }>(jwtToken);
|
|
71
|
+
|
|
72
|
+
const currentTime = new Date().getTime() / 1000;
|
|
73
|
+
|
|
74
|
+
return currentTime > exp;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Note: used in UI (LLD / LLM)
|
|
78
|
+
export const getKYCStatusFromCheckQuoteStatus = (
|
|
79
|
+
checkQuoteStatus: CheckQuoteStatus
|
|
80
|
+
): KYCStatus | null => {
|
|
81
|
+
switch (checkQuoteStatus.codeName) {
|
|
82
|
+
case "KYC_PENDING":
|
|
83
|
+
return KYC_STATUS.pending as KYCStatus;
|
|
84
|
+
|
|
85
|
+
case "KYC_FAILED":
|
|
86
|
+
return KYC_STATUS.rejected as KYCStatus;
|
|
87
|
+
|
|
88
|
+
case "KYC_UNDEFINED":
|
|
89
|
+
case "KYC_UPGRADE_REQUIRED":
|
|
90
|
+
return KYC_STATUS.upgradeRequired as KYCStatus;
|
|
91
|
+
|
|
92
|
+
case "RATE_VALID":
|
|
93
|
+
return KYC_STATUS.approved as KYCStatus;
|
|
94
|
+
|
|
95
|
+
// FIXME: should handle all other non KYC related error cases somewhere
|
|
96
|
+
default:
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Note: used in UI (LLD / LLM)
|
|
102
|
+
export type WidgetTypes = "login" | "kyc" | "mfa";
|
|
103
|
+
export type FTXProviders = "ftx" | "ftxus";
|
|
104
|
+
export const getFTXURL = ({
|
|
105
|
+
type,
|
|
106
|
+
provider,
|
|
107
|
+
}: {
|
|
108
|
+
type: WidgetTypes;
|
|
109
|
+
provider: FTXProviders;
|
|
110
|
+
}): string => {
|
|
111
|
+
const baseUrl =
|
|
112
|
+
getEnv("MOCK_SWAP_WIDGET_BASE_URL") ||
|
|
113
|
+
(() => {
|
|
114
|
+
switch (provider) {
|
|
115
|
+
case "ftx":
|
|
116
|
+
return "https://ftx.com";
|
|
117
|
+
|
|
118
|
+
case "ftxus":
|
|
119
|
+
return "https://ftx.us";
|
|
120
|
+
|
|
121
|
+
default:
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
125
|
+
|
|
126
|
+
if (!baseUrl) {
|
|
127
|
+
throw new Error(`Could not find domain for ${provider}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return `${baseUrl}/${type}?hideFrame=true&ledgerLive=true`;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Note: used in UI (LLD / LLM)
|
|
134
|
+
export const shouldShowLoginBanner = ({
|
|
135
|
+
provider,
|
|
136
|
+
token,
|
|
137
|
+
}: {
|
|
138
|
+
provider?: string;
|
|
139
|
+
token?: string;
|
|
140
|
+
}): boolean => {
|
|
141
|
+
if (!provider) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const providerConfig = getProviderConfig(provider);
|
|
146
|
+
|
|
147
|
+
if (!providerConfig.needsBearerToken) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return !token || isJwtExpired(token);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Note: used in UI (LLD / LLM)
|
|
155
|
+
export const shouldShowKYCBanner = ({
|
|
156
|
+
provider,
|
|
157
|
+
kycStatus,
|
|
158
|
+
}: {
|
|
159
|
+
provider?: string;
|
|
160
|
+
kycStatus: KYCStatus;
|
|
161
|
+
}): boolean => {
|
|
162
|
+
if (!provider) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const providerConfig = getProviderConfig(provider);
|
|
167
|
+
|
|
168
|
+
if (!providerConfig.needsKYC) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return kycStatus !== KYC_STATUS.approved;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const getProviderName = (provider: string): string => {
|
|
176
|
+
switch (provider) {
|
|
177
|
+
case "ftx":
|
|
178
|
+
case "ftxus":
|
|
179
|
+
return provider.toUpperCase();
|
|
180
|
+
default:
|
|
181
|
+
return provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import "../../__tests__/test-helpers/setup";
|
|
3
|
+
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
2
4
|
import type { DatasetTest } from "../../types";
|
|
3
5
|
import {
|
|
4
6
|
InvalidAddressBecauseDestinationIsAlsoSource,
|
|
@@ -9,10 +11,10 @@ import { AlgorandASANotOptInInRecipient } from "../../errors";
|
|
|
9
11
|
import type { AlgorandTransaction } from "./types";
|
|
10
12
|
// const notCreatedAlgorandAddress =
|
|
11
13
|
// "ZBILW5BPM7AQU54YQZICSGS4J7KJ2XV6OC3DFUQ7BB4DVLYKKUEVWDDBGM";
|
|
14
|
+
|
|
12
15
|
const dataset: DatasetTest<AlgorandTransaction> = {
|
|
13
|
-
implementations: ["
|
|
14
|
-
|
|
15
|
-
currencies: {} || {
|
|
16
|
+
implementations: ["js"],
|
|
17
|
+
currencies: {
|
|
16
18
|
algorand: {
|
|
17
19
|
FIXME_ignoreAccountFields: [
|
|
18
20
|
"algorandResources.rewards", // We cant keep track of this since it's always moving
|
|
@@ -43,7 +45,7 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
43
45
|
FIXME_tests: ["balance is sum of ops"],
|
|
44
46
|
// Rewards issues
|
|
45
47
|
raw: {
|
|
46
|
-
id: "
|
|
48
|
+
id: "js:1:algorand:c8b672d16c497bb097a48f09a9cccf0c4c7d6391acb7a4e7cd3f236fadbef9c4:",
|
|
47
49
|
seedIdentifier:
|
|
48
50
|
"c8b672d16c497bb097a48f09a9cccf0c4c7d6391acb7a4e7cd3f236fadbef9c4",
|
|
49
51
|
name: "Algorand 1",
|
|
@@ -165,7 +167,7 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
165
167
|
transaction: (t) => ({
|
|
166
168
|
...t,
|
|
167
169
|
subAccountId:
|
|
168
|
-
"
|
|
170
|
+
"js:1:algorand:c8b672d16c497bb097a48f09a9cccf0c4c7d6391acb7a4e7cd3f236fadbef9c4:+312769",
|
|
169
171
|
amount: new BigNumber("1000"),
|
|
170
172
|
recipient:
|
|
171
173
|
"ZQVVJ2S4XWS542KXBBVIINOEHIDOEZKZWK725PWFNN2I5RNCUBI53RT2EY",
|
|
@@ -182,7 +184,7 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
182
184
|
transaction: (t) => ({
|
|
183
185
|
...t,
|
|
184
186
|
subAccountId:
|
|
185
|
-
"
|
|
187
|
+
"js:1:algorand:c8b672d16c497bb097a48f09a9cccf0c4c7d6391acb7a4e7cd3f236fadbef9c4:+312769",
|
|
186
188
|
amount: new BigNumber("1000"),
|
|
187
189
|
recipient:
|
|
188
190
|
"MECOWMKPKH2NWVZTS5V5RQDGFFYBT25KNLOPHG2KUMMNKU6FOHGJT24WBI",
|
|
@@ -198,7 +200,7 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
198
200
|
transaction: (t) => ({
|
|
199
201
|
...t,
|
|
200
202
|
subAccountId:
|
|
201
|
-
"
|
|
203
|
+
"js:1:algorand:c8b672d16c497bb097a48f09a9cccf0c4c7d6391acb7a4e7cd3f236fadbef9c4:+312769",
|
|
202
204
|
amount: new BigNumber("100000000000"),
|
|
203
205
|
recipient:
|
|
204
206
|
"MECOWMKPKH2NWVZTS5V5RQDGFFYBT25KNLOPHG2KUMMNKU6FOHGJT24WBI",
|
|
@@ -214,7 +216,7 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
214
216
|
},
|
|
215
217
|
{
|
|
216
218
|
raw: {
|
|
217
|
-
id: "
|
|
219
|
+
id: "js:1:algorand:6104eb314f51f4db5733976bd8c066297019ebaa6adcf39b4aa318d553c571cc:",
|
|
218
220
|
seedIdentifier:
|
|
219
221
|
"c8b672d16c497bb097a48f09a9cccf0c4c7d6391acb7a4e7cd3f236fadbef9c4",
|
|
220
222
|
xpub: "6104eb314f51f4db5733976bd8c066297019ebaa6adcf39b4aa318d553c571cc",
|
|
@@ -276,7 +278,7 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
276
278
|
transaction: (t) => ({
|
|
277
279
|
...t,
|
|
278
280
|
subAccountId:
|
|
279
|
-
"
|
|
281
|
+
"js:1:algorand:fef9cf3252121f000324dd819b2c1d76910413924acaf6779b30e1fa1874d7af:+312769",
|
|
280
282
|
amount: new BigNumber("1000"),
|
|
281
283
|
recipient:
|
|
282
284
|
"YWZPDCL5XQPCPGBXKB7KAG7YF2QGCGEX37YTSM55CPEPHKNE2ZSKRAXNQ4",
|
|
@@ -294,4 +296,5 @@ const dataset: DatasetTest<AlgorandTransaction> = {
|
|
|
294
296
|
},
|
|
295
297
|
},
|
|
296
298
|
};
|
|
297
|
-
|
|
299
|
+
|
|
300
|
+
testBridge(dataset);
|