@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,360 +0,0 @@
|
|
|
1
|
-
import "./test-helpers/staticTime";
|
|
2
|
-
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { getCryptoCurrencyById } from "../currencies";
|
|
4
|
-
import {
|
|
5
|
-
getDates,
|
|
6
|
-
getBalanceHistory,
|
|
7
|
-
getBalanceHistoryWithCountervalue,
|
|
8
|
-
getPortfolio,
|
|
9
|
-
getCurrencyPortfolio,
|
|
10
|
-
getAssetsDistribution,
|
|
11
|
-
} from "../portfolio";
|
|
12
|
-
import type { Account } from "../types";
|
|
13
|
-
import { genAccount } from "../mock/account";
|
|
14
|
-
import { getBTCValues } from "../countervalues/mock";
|
|
15
|
-
const baseMockBTCRates = getBTCValues();
|
|
16
|
-
const accounts = Array(100)
|
|
17
|
-
.fill(null)
|
|
18
|
-
.map((_, j) => genAccount("portfolio_" + j));
|
|
19
|
-
test("getBalanceHistory(*,month) returns an array of 30 items", () => {
|
|
20
|
-
const history = getBalanceHistory(genAccount("seed_1"), "month");
|
|
21
|
-
expect(history).toBeInstanceOf(Array);
|
|
22
|
-
expect(history.length).toBe(30);
|
|
23
|
-
expect(history).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
test("getBalanceHistory(*,year) works as well", () => {
|
|
26
|
-
const history = getBalanceHistory(genAccount("seed_2"), "year");
|
|
27
|
-
expect(history).toBeInstanceOf(Array);
|
|
28
|
-
expect(history.length).toBe(52);
|
|
29
|
-
expect(history).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
test("getDates matches getBalanceHistory dates", () => {
|
|
32
|
-
const history = getBalanceHistory(genAccount("seed_2"), "year");
|
|
33
|
-
const dates = getDates("year");
|
|
34
|
-
expect(history.map((p) => p.date)).toMatchObject(dates);
|
|
35
|
-
});
|
|
36
|
-
test("getBalanceHistory last item is now and have an amount equals to account balance", () => {
|
|
37
|
-
const account = genAccount("seed_3");
|
|
38
|
-
const history = getBalanceHistory(account, "month");
|
|
39
|
-
expect(history[history.length - 1].date).toMatchObject(new Date());
|
|
40
|
-
expect(history[history.length - 1].value).toBe(account.balance);
|
|
41
|
-
expect(history).toMatchSnapshot();
|
|
42
|
-
});
|
|
43
|
-
test("getBalanceHistoryWithCountervalue basic", () => {
|
|
44
|
-
const account = genAccount("bro4", {
|
|
45
|
-
subAccountsCount: 0,
|
|
46
|
-
});
|
|
47
|
-
const history = getBalanceHistory(account, "month");
|
|
48
|
-
const cv = getBalanceHistoryWithCountervalue(
|
|
49
|
-
account,
|
|
50
|
-
"month",
|
|
51
|
-
(c, value) => value
|
|
52
|
-
);
|
|
53
|
-
expect(cv.countervalueAvailable).toBe(true);
|
|
54
|
-
// expect(
|
|
55
|
-
// cv.history.map((p) => ({ date: p.date, value: p.countervalue }))
|
|
56
|
-
// ).toMatchObject(history);
|
|
57
|
-
expect(
|
|
58
|
-
cv.history.map((p) => ({
|
|
59
|
-
date: p.date,
|
|
60
|
-
value: p.value,
|
|
61
|
-
}))
|
|
62
|
-
).toMatchObject(history);
|
|
63
|
-
});
|
|
64
|
-
test("getPortfolio works with one account and is identically to that account history", () => {
|
|
65
|
-
const account = genAccount("seed_4", {
|
|
66
|
-
subAccountsCount: 0,
|
|
67
|
-
});
|
|
68
|
-
const history = getBalanceHistory(account, "week");
|
|
69
|
-
const portfolio = getPortfolio(
|
|
70
|
-
[account],
|
|
71
|
-
"week",
|
|
72
|
-
(account, value) => value // using identity, at any time, 1 token = 1 USD
|
|
73
|
-
);
|
|
74
|
-
expect(portfolio.availableAccounts).toMatchObject([account]);
|
|
75
|
-
expect(portfolio.balanceAvailable).toBe(true);
|
|
76
|
-
expect(portfolio.balanceHistory).toMatchObject(history);
|
|
77
|
-
expect(portfolio.balanceHistory).toMatchSnapshot();
|
|
78
|
-
});
|
|
79
|
-
test("getCurrencyPortfolio works with one account and is identically to that account history", () => {
|
|
80
|
-
const account = genAccount("seed_4", {
|
|
81
|
-
subAccountsCount: 0,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const calc = (account, value) => value.times(0.1);
|
|
85
|
-
|
|
86
|
-
const { history } = getBalanceHistoryWithCountervalue(account, "week", calc);
|
|
87
|
-
const accounts: Account[] = [account];
|
|
88
|
-
const portfolio = getCurrencyPortfolio(accounts, "week", calc);
|
|
89
|
-
expect(portfolio.countervalueAvailable).toBe(true);
|
|
90
|
-
expect(portfolio.history).toMatchObject(history);
|
|
91
|
-
expect(portfolio.history).toMatchSnapshot();
|
|
92
|
-
});
|
|
93
|
-
test("getBalanceHistoryWithCountervalue to have proper countervalues", () => {
|
|
94
|
-
const account = genAccount("bro1", {
|
|
95
|
-
subAccountsCount: 0,
|
|
96
|
-
});
|
|
97
|
-
const history = getBalanceHistory(account, "week");
|
|
98
|
-
|
|
99
|
-
const calc = (account, value) => value.times(3);
|
|
100
|
-
|
|
101
|
-
const cv = getBalanceHistoryWithCountervalue(account, "week", calc);
|
|
102
|
-
expect(
|
|
103
|
-
cv.history.map((p) => ({
|
|
104
|
-
date: p.date,
|
|
105
|
-
value: p.countervalue.div(3),
|
|
106
|
-
}))
|
|
107
|
-
).toMatchObject(history);
|
|
108
|
-
});
|
|
109
|
-
test("getBalanceHistoryWithCountervalue is same as getPortfolio with one account", () => {
|
|
110
|
-
const account = genAccount("bro2", {
|
|
111
|
-
subAccountsCount: 0,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const calc = (account, value) => value.times(3);
|
|
115
|
-
|
|
116
|
-
const cv = getBalanceHistoryWithCountervalue(account, "month", calc);
|
|
117
|
-
const portfolio = getPortfolio([account], "month", calc);
|
|
118
|
-
expect(
|
|
119
|
-
cv.history.map((p) => ({
|
|
120
|
-
date: p.date,
|
|
121
|
-
value: p.countervalue,
|
|
122
|
-
}))
|
|
123
|
-
).toMatchObject(portfolio.balanceHistory);
|
|
124
|
-
});
|
|
125
|
-
test("getPortfolio calculateCounterValue can returns missing countervalue", () => {
|
|
126
|
-
const account = genAccount("seed_6", {
|
|
127
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
128
|
-
subAccountsCount: 0,
|
|
129
|
-
});
|
|
130
|
-
const account2 = genAccount("seed_7", {
|
|
131
|
-
currency: getCryptoCurrencyById("ethereum"),
|
|
132
|
-
subAccountsCount: 0,
|
|
133
|
-
});
|
|
134
|
-
const history = getBalanceHistory(account, "month");
|
|
135
|
-
const portfolio = getPortfolio([account, account2], "month", (c, value) =>
|
|
136
|
-
c.id === "bitcoin" ? value : null
|
|
137
|
-
);
|
|
138
|
-
expect(portfolio.balanceHistory).toMatchObject(history);
|
|
139
|
-
expect(portfolio.balanceAvailable).toBe(true);
|
|
140
|
-
expect(portfolio.unavailableCurrencies.length).toBe(1);
|
|
141
|
-
});
|
|
142
|
-
test("getPortfolio with twice same account will double the amounts", () => {
|
|
143
|
-
const account = genAccount("seed_5", {
|
|
144
|
-
subAccountsCount: 0,
|
|
145
|
-
});
|
|
146
|
-
const history = getBalanceHistory(account, "week");
|
|
147
|
-
const allHistory = getPortfolio(
|
|
148
|
-
[account, account],
|
|
149
|
-
"week",
|
|
150
|
-
(c, value) => value // using identity, at any time, 1 token = 1 USD
|
|
151
|
-
);
|
|
152
|
-
allHistory.balanceHistory.forEach((h, i) => {
|
|
153
|
-
expect(h.value.toString()).toBe(history[i].value.times(2).toString());
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
test("getCurrencyPortfolio with twice same account will double the amounts", () => {
|
|
157
|
-
const account = genAccount("seed_5", {
|
|
158
|
-
subAccountsCount: 0,
|
|
159
|
-
});
|
|
160
|
-
const history = getBalanceHistory(account, "week");
|
|
161
|
-
const accounts: Account[] = [account, account];
|
|
162
|
-
const allHistory = getCurrencyPortfolio(
|
|
163
|
-
accounts,
|
|
164
|
-
"week",
|
|
165
|
-
(c, value) => value // using identity, at any time, 1 token = 1 USD
|
|
166
|
-
);
|
|
167
|
-
allHistory.history.forEach((h, i) => {
|
|
168
|
-
expect(h.value.toString()).toBe(history[i].value.times(2).toString());
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
test("getPortfolio calculateCounterValue is taken into account", () => {
|
|
172
|
-
const account = genAccount("seed_6", {
|
|
173
|
-
subAccountsCount: 0,
|
|
174
|
-
});
|
|
175
|
-
const history = getBalanceHistory(account, "month");
|
|
176
|
-
const portfolio = getPortfolio([account, account], "month", (c, value) =>
|
|
177
|
-
value.div(2)
|
|
178
|
-
);
|
|
179
|
-
expect(portfolio.balanceHistory).toMatchObject(history);
|
|
180
|
-
});
|
|
181
|
-
test("getCurrencyPortfolio calculateCounterValue is taken into account", () => {
|
|
182
|
-
const account = genAccount("seed_6", {
|
|
183
|
-
subAccountsCount: 0,
|
|
184
|
-
});
|
|
185
|
-
const { history } = getBalanceHistoryWithCountervalue(
|
|
186
|
-
account,
|
|
187
|
-
"month",
|
|
188
|
-
(c, value) => value
|
|
189
|
-
);
|
|
190
|
-
const accounts: Account[] = [account, account];
|
|
191
|
-
const portfolio = getCurrencyPortfolio(accounts, "month", (c, value) =>
|
|
192
|
-
value.div(2)
|
|
193
|
-
);
|
|
194
|
-
expect(portfolio.history.map((h) => h.value.div(2).toString())).toMatchObject(
|
|
195
|
-
history.map((h) => h.value.toString())
|
|
196
|
-
);
|
|
197
|
-
expect(portfolio.history.map((h) => h.countervalue.toString())).toMatchObject(
|
|
198
|
-
history.map((h) => h.countervalue.toString())
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
test("getPortfolio calculateCounterValue can returns missing countervalue", () => {
|
|
202
|
-
const account = genAccount("seed_6", {
|
|
203
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
204
|
-
subAccountsCount: 0,
|
|
205
|
-
});
|
|
206
|
-
const account2 = genAccount("seed_7", {
|
|
207
|
-
currency: getCryptoCurrencyById("ethereum"),
|
|
208
|
-
subAccountsCount: 0,
|
|
209
|
-
});
|
|
210
|
-
const history = getBalanceHistory(account, "month");
|
|
211
|
-
const portfolio = getPortfolio([account, account2], "month", (c, value) =>
|
|
212
|
-
c.id === "bitcoin" ? value : null
|
|
213
|
-
);
|
|
214
|
-
expect(portfolio.balanceHistory).toMatchObject(history);
|
|
215
|
-
expect(portfolio.balanceAvailable).toBe(true);
|
|
216
|
-
expect(portfolio.unavailableCurrencies.length).toBe(1);
|
|
217
|
-
});
|
|
218
|
-
test("getCurrencyPortfolio calculateCounterValue can miss countervalue", () => {
|
|
219
|
-
const account = genAccount("seed_6", {
|
|
220
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
221
|
-
subAccountsCount: 0,
|
|
222
|
-
});
|
|
223
|
-
const account2 = genAccount("seed_7", {
|
|
224
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
225
|
-
subAccountsCount: 0,
|
|
226
|
-
});
|
|
227
|
-
const history = getBalanceHistory(account, "month");
|
|
228
|
-
const history2 = getBalanceHistory(account2, "month");
|
|
229
|
-
const accs: Account[] = [account, account2];
|
|
230
|
-
const portfolio = getCurrencyPortfolio(accs, "month", () => null);
|
|
231
|
-
expect(portfolio.history).toMatchObject(
|
|
232
|
-
history.map((p, i) => ({ ...p, value: p.value.plus(history2[i].value) }))
|
|
233
|
-
);
|
|
234
|
-
expect(portfolio.countervalueAvailable).toBe(false);
|
|
235
|
-
});
|
|
236
|
-
test("getPortfolio calculateCounterValue can complete fails", () => {
|
|
237
|
-
const account = genAccount("seed_6", {
|
|
238
|
-
subAccountsCount: 0,
|
|
239
|
-
});
|
|
240
|
-
const account2 = genAccount("seed_7", {
|
|
241
|
-
subAccountsCount: 0,
|
|
242
|
-
});
|
|
243
|
-
const portfolio = getPortfolio([account, account2], "month", () => null);
|
|
244
|
-
expect(portfolio.balanceAvailable).toBe(false);
|
|
245
|
-
});
|
|
246
|
-
test("getPortfolio with lot of accounts", () => {
|
|
247
|
-
const portfolio = getPortfolio(
|
|
248
|
-
accounts,
|
|
249
|
-
"week",
|
|
250
|
-
(c, value) => value // using identity, at any time, 1 token = 1 USD
|
|
251
|
-
);
|
|
252
|
-
expect(portfolio.balanceHistory).toMatchSnapshot();
|
|
253
|
-
});
|
|
254
|
-
test("getAssetsDistribution 1", () => {
|
|
255
|
-
const assetsDistribution = getAssetsDistribution(
|
|
256
|
-
accounts,
|
|
257
|
-
(currency, value) => {
|
|
258
|
-
const rate = baseMockBTCRates[currency.ticker];
|
|
259
|
-
if (rate) return value.times(rate);
|
|
260
|
-
}
|
|
261
|
-
);
|
|
262
|
-
expect(assetsDistribution.isAvailable).toBe(true);
|
|
263
|
-
expect(assetsDistribution.showFirst).toBe(2);
|
|
264
|
-
expect(
|
|
265
|
-
assetsDistribution.list.reduce((sum, o) => sum + o.distribution, 0)
|
|
266
|
-
).toBeCloseTo(1);
|
|
267
|
-
expect(
|
|
268
|
-
assetsDistribution.list.map((o) => [
|
|
269
|
-
o.currency.ticker,
|
|
270
|
-
o.amount,
|
|
271
|
-
o.countervalue,
|
|
272
|
-
o.distribution,
|
|
273
|
-
])
|
|
274
|
-
).toMatchSnapshot();
|
|
275
|
-
});
|
|
276
|
-
test("getAssetsDistribution mult", () => {
|
|
277
|
-
const calc = (currency, value) => {
|
|
278
|
-
const rate = baseMockBTCRates[currency.ticker];
|
|
279
|
-
if (rate) return value.times(rate);
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
for (let i = 0; i < accounts.length; i++) {
|
|
283
|
-
const assetsDistribution = getAssetsDistribution(
|
|
284
|
-
accounts.slice(0, i),
|
|
285
|
-
calc
|
|
286
|
-
);
|
|
287
|
-
// identity cached by ref
|
|
288
|
-
expect(getAssetsDistribution(accounts.slice(0, i), calc)).toBe(
|
|
289
|
-
assetsDistribution
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
if (assetsDistribution.isAvailable) {
|
|
293
|
-
expect(assetsDistribution.sum.toString()).toBe(
|
|
294
|
-
assetsDistribution.list
|
|
295
|
-
.reduce(
|
|
296
|
-
(sum: BigNumber, o) => sum.plus(o.countervalue),
|
|
297
|
-
new BigNumber(0)
|
|
298
|
-
)
|
|
299
|
-
.toString()
|
|
300
|
-
);
|
|
301
|
-
expect(assetsDistribution.showFirst).toBeLessThanOrEqual(
|
|
302
|
-
assetsDistribution.list.length
|
|
303
|
-
);
|
|
304
|
-
expect(
|
|
305
|
-
assetsDistribution.list.reduce((sum, o) => sum + o.distribution, 0)
|
|
306
|
-
).toBeCloseTo(1);
|
|
307
|
-
} else {
|
|
308
|
-
expect(assetsDistribution.list.length).toBe(0);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
test("getPortfolio do not crash if range history have different size", () => {
|
|
313
|
-
let account1 = genAccount("seed_8", {
|
|
314
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
315
|
-
});
|
|
316
|
-
let account2 = genAccount("seed_9", {
|
|
317
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
318
|
-
});
|
|
319
|
-
let account3 = genAccount("seed_10", {
|
|
320
|
-
currency: getCryptoCurrencyById("bitcoin"),
|
|
321
|
-
});
|
|
322
|
-
const history1 = getBalanceHistory(account1, "month");
|
|
323
|
-
const history2 = getBalanceHistory(account2, "month");
|
|
324
|
-
|
|
325
|
-
const calc = (c, value) => value;
|
|
326
|
-
|
|
327
|
-
getPortfolio([account1, account2, account3], "month", calc);
|
|
328
|
-
account1 = {
|
|
329
|
-
...account1,
|
|
330
|
-
balanceHistory: {
|
|
331
|
-
month: history1.concat(history1),
|
|
332
|
-
year: undefined,
|
|
333
|
-
week: undefined,
|
|
334
|
-
day: undefined,
|
|
335
|
-
},
|
|
336
|
-
};
|
|
337
|
-
getPortfolio([account1, account2, account3], "month", calc);
|
|
338
|
-
account2 = {
|
|
339
|
-
...account2,
|
|
340
|
-
balanceHistory: {
|
|
341
|
-
month: history2.slice(5),
|
|
342
|
-
year: undefined,
|
|
343
|
-
week: undefined,
|
|
344
|
-
day: undefined,
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
getPortfolio([account1, account2, account3], "month", calc);
|
|
348
|
-
account3 = {
|
|
349
|
-
...account3,
|
|
350
|
-
balanceHistory: {
|
|
351
|
-
month: [],
|
|
352
|
-
year: undefined,
|
|
353
|
-
week: undefined,
|
|
354
|
-
day: undefined,
|
|
355
|
-
},
|
|
356
|
-
};
|
|
357
|
-
const portfolio = getPortfolio([account1, account2, account3], "month", calc);
|
|
358
|
-
expect(portfolio.balanceAvailable).toBe(true);
|
|
359
|
-
expect(portfolio.unavailableCurrencies.length).toBe(0);
|
|
360
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { listen } from "@ledgerhq/logs";
|
|
3
|
-
import "./setup";
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
namespace NodeJS {
|
|
7
|
-
interface Global {
|
|
8
|
-
_JEST_SETUP: (testName: string) => void;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const setup = (testName) => {
|
|
14
|
-
global._JEST_SETUP(testName);
|
|
15
|
-
};
|
|
16
|
-
// eslint-disable-next-line no-unused-vars
|
|
17
|
-
listen(({ type, message }) => {
|
|
18
|
-
console.log(type + (message ? ": " + message : ""));
|
|
19
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import winston from "winston";
|
|
3
|
-
import { listen } from "@ledgerhq/logs";
|
|
4
|
-
import "./setup";
|
|
5
|
-
import { EnvName, setEnvUnsafe } from "../../env";
|
|
6
|
-
|
|
7
|
-
let setupCalled = null;
|
|
8
|
-
export const setup = (testId) => {
|
|
9
|
-
if (setupCalled) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
"setup(" + testId + "): was already called with " + setupCalled
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
setupCalled = testId;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
for (const k in process.env) setEnvUnsafe(k as EnvName, process.env[k]);
|
|
18
|
-
|
|
19
|
-
const { VERBOSE, VERBOSE_FILE } = process.env;
|
|
20
|
-
const logger = winston.createLogger({
|
|
21
|
-
level: "debug",
|
|
22
|
-
transports: [],
|
|
23
|
-
});
|
|
24
|
-
const { format } = winston;
|
|
25
|
-
const { combine, timestamp, json } = format;
|
|
26
|
-
const winstonFormat = combine(timestamp(), json());
|
|
27
|
-
|
|
28
|
-
if (VERBOSE_FILE) {
|
|
29
|
-
logger.add(
|
|
30
|
-
new winston.transports.File({
|
|
31
|
-
format: winstonFormat,
|
|
32
|
-
filename: VERBOSE_FILE,
|
|
33
|
-
level: "debug",
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
logger.add(
|
|
39
|
-
new winston.transports.Console({
|
|
40
|
-
format: winstonFormat,
|
|
41
|
-
silent: !VERBOSE,
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
// eslint-disable-next-line no-unused-vars
|
|
45
|
-
listen(({ type, message, ...rest }) => {
|
|
46
|
-
logger.log("debug", {
|
|
47
|
-
message: type + (message ? ": " + message : ""),
|
|
48
|
-
// $FlowFixMe
|
|
49
|
-
...rest,
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DatasetTest } from "../../types";
|
|
2
|
-
import type { Transaction } from "./types";
|
|
3
|
-
// import crypto_org_croeseid from "./datasets/croeseid";
|
|
4
|
-
|
|
5
|
-
const dataset: DatasetTest<Transaction> = {
|
|
6
|
-
implementations: ["mock", "js"],
|
|
7
|
-
currencies: {
|
|
8
|
-
// TODO a QA need to restore this testing (if it's still up?)
|
|
9
|
-
// crypto_org_croeseid,
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default dataset;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// This test suite is flaky, it times out randomly on the CI.
|
|
2
|
-
// Hence the renaming of the file.
|
|
3
|
-
import { setup } from "../../__tests__/test-helpers/libcore-setup";
|
|
4
|
-
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
5
|
-
import dataset from "./test-dataset";
|
|
6
|
-
|
|
7
|
-
setup("ethereum");
|
|
8
|
-
testBridge("ethereum", dataset);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { setup } from "../../__tests__/test-helpers/libcore-setup";
|
|
2
|
-
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
3
|
-
import dataset from "./test-dataset";
|
|
4
|
-
|
|
5
|
-
import { getAccountBridge } from "../../bridge";
|
|
6
|
-
import {
|
|
7
|
-
decodeAccountId,
|
|
8
|
-
encodeAccountId,
|
|
9
|
-
fromAccountRaw,
|
|
10
|
-
} from "../../account";
|
|
11
|
-
import { InvalidAddress } from "@ledgerhq/errors";
|
|
12
|
-
|
|
13
|
-
setup("filecoin");
|
|
14
|
-
testBridge("filecoin", dataset);
|
|
15
|
-
|
|
16
|
-
describe("estimateMaxSpendable", () => {
|
|
17
|
-
test("it should failed on invalid recipient", async () => {
|
|
18
|
-
const accounts = dataset.currencies["filecoin"].accounts || [];
|
|
19
|
-
const accountData = accounts[0];
|
|
20
|
-
|
|
21
|
-
const account = fromAccountRaw({
|
|
22
|
-
...accountData.raw,
|
|
23
|
-
id: encodeAccountId({
|
|
24
|
-
...decodeAccountId(accountData.raw.id),
|
|
25
|
-
type: dataset.implementations[0],
|
|
26
|
-
}),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const accountBridge = getAccountBridge(account);
|
|
30
|
-
const estimate = async () => {
|
|
31
|
-
await accountBridge.estimateMaxSpendable({
|
|
32
|
-
account,
|
|
33
|
-
transaction: { recipient: "notavalidrecipient" },
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
await expect(estimate).rejects.toThrowError(new InvalidAddress());
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { setup } from "../../__tests__/test-helpers/libcore-setup";
|
|
2
|
-
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
|
3
|
-
import dataset from "./test-dataset";
|
|
4
|
-
import { disconnect } from "./api";
|
|
5
|
-
import { BigNumber } from "bignumber.js";
|
|
6
|
-
import { canUnbond, MAX_UNLOCKINGS } from "./logic";
|
|
7
|
-
import type { Account } from "../../types";
|
|
8
|
-
|
|
9
|
-
// Disconnect all api clients that could be open.
|
|
10
|
-
afterAll(async () => {
|
|
11
|
-
await disconnect();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
setup("polkadot");
|
|
15
|
-
testBridge("polkadot", dataset);
|
|
16
|
-
|
|
17
|
-
describe("canUnbond", () => {
|
|
18
|
-
test("can unbond", () => {
|
|
19
|
-
const account: Partial<Account> = {
|
|
20
|
-
polkadotResources: {
|
|
21
|
-
controller: "",
|
|
22
|
-
stash: "",
|
|
23
|
-
nonce: 0,
|
|
24
|
-
numSlashingSpans: 0,
|
|
25
|
-
lockedBalance: new BigNumber(10000),
|
|
26
|
-
unlockedBalance: new BigNumber(0),
|
|
27
|
-
unlockingBalance: new BigNumber(0),
|
|
28
|
-
nominations: [],
|
|
29
|
-
unlockings: [
|
|
30
|
-
...Array(MAX_UNLOCKINGS - 1).map(() => ({
|
|
31
|
-
amount: new BigNumber(Math.random()),
|
|
32
|
-
completionDate: new Date(),
|
|
33
|
-
})),
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
expect(canUnbond(account as Account)).toBeTruthy();
|
|
38
|
-
});
|
|
39
|
-
test("can't unbond because unlockings is too much", () => {
|
|
40
|
-
const account: Partial<Account> = {
|
|
41
|
-
polkadotResources: {
|
|
42
|
-
controller: "",
|
|
43
|
-
stash: "",
|
|
44
|
-
nonce: 0,
|
|
45
|
-
numSlashingSpans: 0,
|
|
46
|
-
lockedBalance: new BigNumber(1000000),
|
|
47
|
-
unlockedBalance: new BigNumber(0),
|
|
48
|
-
unlockingBalance: new BigNumber(0),
|
|
49
|
-
nominations: [],
|
|
50
|
-
unlockings: [
|
|
51
|
-
...Array(MAX_UNLOCKINGS).map(() => ({
|
|
52
|
-
amount: new BigNumber(Math.random()),
|
|
53
|
-
completionDate: new Date(),
|
|
54
|
-
})),
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
expect(canUnbond(account as Account)).toBeFalsy();
|
|
59
|
-
});
|
|
60
|
-
test("can't unbond because not enough lockedBalance", () => {
|
|
61
|
-
const account: Partial<Account> = {
|
|
62
|
-
polkadotResources: {
|
|
63
|
-
controller: "",
|
|
64
|
-
stash: "",
|
|
65
|
-
nonce: 0,
|
|
66
|
-
numSlashingSpans: 0,
|
|
67
|
-
lockedBalance: new BigNumber(100),
|
|
68
|
-
unlockedBalance: new BigNumber(0),
|
|
69
|
-
unlockingBalance: new BigNumber(100),
|
|
70
|
-
nominations: [],
|
|
71
|
-
unlockings: [
|
|
72
|
-
...Array(MAX_UNLOCKINGS).map(() => ({
|
|
73
|
-
amount: new BigNumber(Math.random()),
|
|
74
|
-
completionDate: new Date(),
|
|
75
|
-
})),
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
expect(canUnbond(account as Account)).toBeFalsy();
|
|
80
|
-
});
|
|
81
|
-
});
|