@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,6 +1,5 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { Observable, defer, from } from "rxjs";
|
|
4
3
|
import { reduce, filter, map } from "rxjs/operators";
|
|
5
4
|
import flatMap from "lodash/flatMap";
|
|
6
5
|
import omit from "lodash/omit";
|
|
@@ -32,7 +31,6 @@ import {
|
|
|
32
31
|
toTransactionRaw,
|
|
33
32
|
toTransactionStatusRaw,
|
|
34
33
|
} from "../../transaction";
|
|
35
|
-
import { getBalanceHistoryJS, getRanges } from "../../portfolio";
|
|
36
34
|
import { getAccountBridge, getCurrencyBridge } from "../../bridge";
|
|
37
35
|
import { mockDeviceWithAPDUs, releaseMockDevice } from "./mockDevice";
|
|
38
36
|
import { implicitMigration } from "../../migrations/accounts";
|
|
@@ -69,10 +67,7 @@ export function syncAccount<T extends Transaction>(
|
|
|
69
67
|
.toPromise();
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
export function testBridge<T extends Transaction>(
|
|
73
|
-
family: string,
|
|
74
|
-
data: DatasetTest<T>
|
|
75
|
-
) {
|
|
70
|
+
export function testBridge<T extends Transaction>(data: DatasetTest<T>): void {
|
|
76
71
|
// covers all bridges through many different accounts
|
|
77
72
|
// to test the common shared properties of bridges.
|
|
78
73
|
const accountsRelated: Array<{
|
|
@@ -120,7 +115,7 @@ export function testBridge<T extends Transaction>(
|
|
|
120
115
|
);
|
|
121
116
|
});
|
|
122
117
|
const accountsFoundInScanAccountsMap = {};
|
|
123
|
-
|
|
118
|
+
|
|
124
119
|
currenciesRelated.map(({ currencyData, currency }) => {
|
|
125
120
|
const bridge = getCurrencyBridge(currency);
|
|
126
121
|
|
|
@@ -212,16 +207,6 @@ export function testBridge<T extends Transaction>(
|
|
|
212
207
|
describe("scanAccounts", () => {
|
|
213
208
|
scanAccounts.forEach((sa) => {
|
|
214
209
|
// we start running the scan accounts in parallel!
|
|
215
|
-
preloadObservables.push(
|
|
216
|
-
defer(() =>
|
|
217
|
-
from(
|
|
218
|
-
scanAccountsCached(sa.apdus).then(
|
|
219
|
-
() => null,
|
|
220
|
-
() => {}
|
|
221
|
-
)
|
|
222
|
-
)
|
|
223
|
-
)
|
|
224
|
-
);
|
|
225
210
|
test(sa.name, async () => {
|
|
226
211
|
const accounts = await scanAccountsCached(sa.apdus);
|
|
227
212
|
accounts.forEach((a) => {
|
|
@@ -514,21 +499,6 @@ export function testBridge<T extends Transaction>(
|
|
|
514
499
|
});
|
|
515
500
|
});
|
|
516
501
|
});
|
|
517
|
-
makeTest(
|
|
518
|
-
"account balanceHistory (when exists) matches getBalanceHistoryJS",
|
|
519
|
-
async () => {
|
|
520
|
-
const account = await getSynced();
|
|
521
|
-
getRanges().forEach((range) => {
|
|
522
|
-
const balanceHistory =
|
|
523
|
-
account.balanceHistory && account.balanceHistory[range];
|
|
524
|
-
if (!balanceHistory) return;
|
|
525
|
-
const history = getBalanceHistoryJS(account, range);
|
|
526
|
-
expect(balanceHistory.map((b) => b.value)).toEqual(
|
|
527
|
-
history.map((b) => b.value)
|
|
528
|
-
);
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
);
|
|
532
502
|
describe("createTransaction", () => {
|
|
533
503
|
makeTest(
|
|
534
504
|
"empty transaction is an object with empty recipient and zero amount",
|
|
@@ -785,7 +755,4 @@ export function testBridge<T extends Transaction>(
|
|
|
785
755
|
});
|
|
786
756
|
});
|
|
787
757
|
});
|
|
788
|
-
return {
|
|
789
|
-
preloadObservables,
|
|
790
|
-
};
|
|
791
758
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import winston from "winston";
|
|
2
|
+
import { listen } from "@ledgerhq/logs";
|
|
1
3
|
import BigNumber from "bignumber.js";
|
|
2
4
|
import { setSupportedCurrencies } from "../../currencies";
|
|
3
5
|
import { setPlatformVersion } from "../../platform/version";
|
|
6
|
+
import { EnvName, setEnvUnsafe } from "../../env";
|
|
4
7
|
|
|
5
8
|
jest.setTimeout(360000);
|
|
6
9
|
|
|
@@ -62,3 +65,39 @@ setSupportedCurrencies([
|
|
|
62
65
|
"cardano",
|
|
63
66
|
"cardano_testnet",
|
|
64
67
|
]);
|
|
68
|
+
|
|
69
|
+
for (const k in process.env) setEnvUnsafe(k as EnvName, process.env[k]);
|
|
70
|
+
|
|
71
|
+
const { VERBOSE, VERBOSE_FILE } = process.env;
|
|
72
|
+
const logger = winston.createLogger({
|
|
73
|
+
level: "debug",
|
|
74
|
+
transports: [],
|
|
75
|
+
});
|
|
76
|
+
const { format } = winston;
|
|
77
|
+
const { combine, timestamp, json } = format;
|
|
78
|
+
const winstonFormat = combine(timestamp(), json());
|
|
79
|
+
|
|
80
|
+
if (VERBOSE_FILE) {
|
|
81
|
+
logger.add(
|
|
82
|
+
new winston.transports.File({
|
|
83
|
+
format: winstonFormat,
|
|
84
|
+
filename: VERBOSE_FILE,
|
|
85
|
+
level: "debug",
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
logger.add(
|
|
91
|
+
new winston.transports.Console({
|
|
92
|
+
format: winstonFormat,
|
|
93
|
+
silent: !VERBOSE,
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
// eslint-disable-next-line no-unused-vars
|
|
97
|
+
listen(({ type, message, ...rest }) => {
|
|
98
|
+
logger.log("debug", {
|
|
99
|
+
message: type + (message ? ": " + message : ""),
|
|
100
|
+
// $FlowFixMe
|
|
101
|
+
...rest,
|
|
102
|
+
});
|
|
103
|
+
});
|
package/src/api/Ripple.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { BigNumber } from "bignumber.js";
|
|
|
2
2
|
import { getEnv } from "../env";
|
|
3
3
|
import network from "../network";
|
|
4
4
|
import { parseCurrencyUnit, getCryptoCurrencyById } from "../currencies";
|
|
5
|
+
import { retry } from "../promise";
|
|
6
|
+
import { NEW_ACCOUNT_ERROR_MESSAGE } from "../families/ripple/bridge/js";
|
|
5
7
|
|
|
6
8
|
const defaultEndpoint = () => getEnv("API_RIPPLE_RPC");
|
|
7
9
|
|
|
@@ -47,74 +49,117 @@ export const getAccountInfo = async (
|
|
|
47
49
|
recipient: string,
|
|
48
50
|
current?: boolean
|
|
49
51
|
): Promise<AccountInfo> => {
|
|
50
|
-
const res =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
const res = async () => {
|
|
53
|
+
const res = await network({
|
|
54
|
+
method: "POST",
|
|
55
|
+
url: `${defaultEndpoint()}`,
|
|
56
|
+
data: {
|
|
57
|
+
method: "account_info",
|
|
58
|
+
params: [
|
|
59
|
+
{
|
|
60
|
+
account: recipient,
|
|
61
|
+
ledger_index: current ? "current" : "validated",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
if (
|
|
67
|
+
res.data.result.status !== "success" &&
|
|
68
|
+
res.data.result.error !== NEW_ACCOUNT_ERROR_MESSAGE
|
|
69
|
+
) {
|
|
70
|
+
throw new Error(`couldn't fetch account info ${recipient}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return res.data.result;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return retry(() => res(), {
|
|
77
|
+
maxRetry: getEnv("GET_CALLS_RETRY"),
|
|
62
78
|
});
|
|
63
|
-
return res.data.result;
|
|
64
79
|
};
|
|
65
80
|
|
|
66
81
|
export const getServerInfo = async (
|
|
67
82
|
endpointConfig?: string | null | undefined
|
|
68
83
|
): Promise<any> => {
|
|
69
|
-
const res =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
const res = async () => {
|
|
85
|
+
const res = await network({
|
|
86
|
+
method: "POST",
|
|
87
|
+
url: endpointConfig ?? `${defaultEndpoint()}`,
|
|
88
|
+
data: {
|
|
89
|
+
method: "server_info",
|
|
90
|
+
params: [
|
|
91
|
+
{
|
|
92
|
+
ledger_index: "validated",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
});
|
|
81
97
|
|
|
82
|
-
|
|
98
|
+
if (res.data.result.status !== "success") {
|
|
99
|
+
throw new Error(`couldn't fetch server info`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return res.data.result;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return retry(() => res(), {
|
|
106
|
+
maxRetry: getEnv("GET_CALLS_RETRY"),
|
|
107
|
+
});
|
|
83
108
|
};
|
|
84
109
|
|
|
85
110
|
export const getTransactions = async (
|
|
86
111
|
address: string,
|
|
87
112
|
options: any | undefined
|
|
88
113
|
): Promise<any> => {
|
|
89
|
-
const res =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
114
|
+
const res = async () => {
|
|
115
|
+
const res = await network({
|
|
116
|
+
method: "POST",
|
|
117
|
+
url: `${defaultEndpoint()}`,
|
|
118
|
+
data: {
|
|
119
|
+
method: "account_tx",
|
|
120
|
+
params: [
|
|
121
|
+
{
|
|
122
|
+
account: address,
|
|
123
|
+
ledger_index: "validated",
|
|
124
|
+
...options,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return res.data.result.transactions;
|
|
130
|
+
|
|
131
|
+
if (res.data.result.status !== "success") {
|
|
132
|
+
throw new Error(`couldn't getTransactions for ${address}`);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return retry(() => res(), {
|
|
137
|
+
maxRetry: getEnv("GET_CALLS_RETRY"),
|
|
102
138
|
});
|
|
103
|
-
return res.data.result.transactions;
|
|
104
139
|
};
|
|
105
140
|
|
|
106
141
|
export default async function getLedgerIndex(): Promise<number> {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
const res = async () => {
|
|
143
|
+
const ledgerResponse = await network({
|
|
144
|
+
method: "POST",
|
|
145
|
+
url: `${defaultEndpoint()}`,
|
|
146
|
+
data: {
|
|
147
|
+
method: "ledger",
|
|
148
|
+
params: [
|
|
149
|
+
{
|
|
150
|
+
ledger_index: "validated",
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (ledgerResponse.data.result.status !== "success") {
|
|
157
|
+
throw new Error(`couldn't fetch getLedgerIndex`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return ledgerResponse.data.result.ledger_index;
|
|
161
|
+
};
|
|
162
|
+
return retry(() => res(), {
|
|
163
|
+
maxRetry: getEnv("GET_CALLS_RETRY"),
|
|
118
164
|
});
|
|
119
|
-
return ledgerResponse.data.result.ledger_index;
|
|
120
165
|
}
|
package/src/apps/support.ts
CHANGED
|
@@ -21,7 +21,9 @@ export function shouldUpgrade(
|
|
|
21
21
|
appName === "Bitcoin"
|
|
22
22
|
) {
|
|
23
23
|
// https://donjon.ledger.com/lsb/010/
|
|
24
|
-
return !semver.satisfies(
|
|
24
|
+
return !semver.satisfies(appVersion || "", ">= 1.4.0", {
|
|
25
|
+
includePrerelease: true, // this will allow pre-release tags that would otherwise return false. E.g. 1.0.0-dev
|
|
26
|
+
});
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
return false;
|
|
@@ -43,7 +45,9 @@ export function mustUpgrade(
|
|
|
43
45
|
const range = appVersionsRequired[appName];
|
|
44
46
|
|
|
45
47
|
if (range) {
|
|
46
|
-
return !semver.satisfies(appVersion, range
|
|
48
|
+
return !semver.satisfies(appVersion || "", range, {
|
|
49
|
+
includePrerelease: true, // this will allow pre-release tags that would otherwise return false. E.g. 1.0.0-dev
|
|
50
|
+
});
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
return false;
|
package/src/bot/index.ts
CHANGED
|
@@ -22,11 +22,10 @@ import { runWithAppSpec } from "./engine";
|
|
|
22
22
|
import { formatReportForConsole, formatError } from "./formatters";
|
|
23
23
|
import {
|
|
24
24
|
initialState,
|
|
25
|
-
calculate,
|
|
26
25
|
loadCountervalues,
|
|
27
26
|
inferTrackingPairForAccounts,
|
|
28
27
|
} from "../countervalues/logic";
|
|
29
|
-
import { getPortfolio } from "../portfolio";
|
|
28
|
+
import { getPortfolio } from "../portfolio/v2";
|
|
30
29
|
type Arg = Partial<{
|
|
31
30
|
currency: string;
|
|
32
31
|
family: string;
|
|
@@ -119,23 +118,15 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
119
118
|
});
|
|
120
119
|
const period = "month";
|
|
121
120
|
|
|
122
|
-
const
|
|
123
|
-
countervaluesState
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
date,
|
|
127
|
-
value: v.toNumber(),
|
|
128
|
-
from: c,
|
|
129
|
-
to: usd,
|
|
130
|
-
}) || 0
|
|
131
|
-
)
|
|
132
|
-
: new BigNumber(0);
|
|
133
|
-
|
|
134
|
-
const portfolio = getPortfolio(allAccountsAfter, period, calc);
|
|
135
|
-
const totalUSD = countervaluesState
|
|
121
|
+
const portfolio = countervaluesState
|
|
122
|
+
? getPortfolio(allAccountsAfter, period, countervaluesState, usd)
|
|
123
|
+
: null;
|
|
124
|
+
const totalUSD = portfolio
|
|
136
125
|
? formatCurrencyUnit(
|
|
137
126
|
usd.units[0],
|
|
138
|
-
|
|
127
|
+
new BigNumber(
|
|
128
|
+
portfolio.balanceHistory[portfolio.balanceHistory.length - 1].value
|
|
129
|
+
),
|
|
139
130
|
{
|
|
140
131
|
showCode: true,
|
|
141
132
|
}
|
|
@@ -378,14 +369,25 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
|
|
|
378
369
|
}
|
|
379
370
|
|
|
380
371
|
if (countervaluesState && r.accountsAfter) {
|
|
381
|
-
const portfolio = getPortfolio(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
showCode: true,
|
|
387
|
-
}
|
|
372
|
+
const portfolio = getPortfolio(
|
|
373
|
+
r.accountsAfter,
|
|
374
|
+
period,
|
|
375
|
+
countervaluesState,
|
|
376
|
+
usd
|
|
388
377
|
);
|
|
378
|
+
const totalUSD = portfolio
|
|
379
|
+
? formatCurrencyUnit(
|
|
380
|
+
usd.units[0],
|
|
381
|
+
new BigNumber(
|
|
382
|
+
portfolio.balanceHistory[
|
|
383
|
+
portfolio.balanceHistory.length - 1
|
|
384
|
+
].value
|
|
385
|
+
),
|
|
386
|
+
{
|
|
387
|
+
showCode: true,
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
: "";
|
|
389
391
|
balance += " (" + totalUSD + ")";
|
|
390
392
|
}
|
|
391
393
|
|
package/src/bot/test.bot.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../__tests__/test-helpers/setup";
|
|
2
2
|
import { bot } from ".";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
jest.setTimeout(110 * 60 * 1000);
|
|
5
5
|
const { BOT_FILTER_CURRENCY, BOT_FILTER_FAMILY } = process.env;
|
|
6
6
|
test("bot", async () => {
|
|
File without changes
|
|
@@ -10,30 +10,8 @@ import React, {
|
|
|
10
10
|
useCallback,
|
|
11
11
|
ReactElement,
|
|
12
12
|
} from "react";
|
|
13
|
-
import type {
|
|
14
|
-
|
|
15
|
-
AccountLike,
|
|
16
|
-
PortfolioRange,
|
|
17
|
-
Currency,
|
|
18
|
-
CryptoCurrency,
|
|
19
|
-
TokenCurrency,
|
|
20
|
-
AccountPortfolio,
|
|
21
|
-
Portfolio,
|
|
22
|
-
CurrencyPortfolio,
|
|
23
|
-
AssetsDistribution,
|
|
24
|
-
Unit,
|
|
25
|
-
} from "../types";
|
|
26
|
-
import {
|
|
27
|
-
getBalanceHistoryWithCountervalue,
|
|
28
|
-
getPortfolio,
|
|
29
|
-
getCurrencyPortfolio,
|
|
30
|
-
getAssetsDistribution,
|
|
31
|
-
} from "../portfolio";
|
|
32
|
-
import {
|
|
33
|
-
getAccountCurrency,
|
|
34
|
-
flattenAccounts,
|
|
35
|
-
getAccountUnit,
|
|
36
|
-
} from "../account/helpers";
|
|
13
|
+
import type { Account, AccountLike, Currency, Unit } from "../types";
|
|
14
|
+
import { getAccountCurrency, getAccountUnit } from "../account/helpers";
|
|
37
15
|
import {
|
|
38
16
|
initialState,
|
|
39
17
|
calculate,
|
|
@@ -304,113 +282,6 @@ export function useCalculateMany(
|
|
|
304
282
|
// TODO how to approach perf for this? hash function of the datapoints? responsability on user land?
|
|
305
283
|
return calculateMany(state, dataPoints, query);
|
|
306
284
|
}
|
|
307
|
-
// TODO perf of the useCalculate*, does it even worth worrying?
|
|
308
|
-
// TODO move to portfolio module (I couldn't make useCountervaluesState to work there)
|
|
309
|
-
export function useBalanceHistoryWithCountervalue({
|
|
310
|
-
account,
|
|
311
|
-
range,
|
|
312
|
-
to,
|
|
313
|
-
}: {
|
|
314
|
-
account: AccountLike;
|
|
315
|
-
range: PortfolioRange;
|
|
316
|
-
to: Currency;
|
|
317
|
-
}): AccountPortfolio {
|
|
318
|
-
const from = getAccountCurrency(account);
|
|
319
|
-
const state = useCountervaluesState();
|
|
320
|
-
return useMemo(
|
|
321
|
-
() =>
|
|
322
|
-
getBalanceHistoryWithCountervalue(account, range, (_, value, date) => {
|
|
323
|
-
const countervalue = calculate(state, {
|
|
324
|
-
value: value.toNumber(),
|
|
325
|
-
from,
|
|
326
|
-
to,
|
|
327
|
-
disableRounding: true,
|
|
328
|
-
date,
|
|
329
|
-
});
|
|
330
|
-
return typeof countervalue === "number"
|
|
331
|
-
? new BigNumber(countervalue)
|
|
332
|
-
: countervalue;
|
|
333
|
-
}),
|
|
334
|
-
[account, from, to, range, state]
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
export function usePortfolio({
|
|
338
|
-
accounts,
|
|
339
|
-
range,
|
|
340
|
-
to,
|
|
341
|
-
}: {
|
|
342
|
-
accounts: Account[];
|
|
343
|
-
range: PortfolioRange;
|
|
344
|
-
to: Currency;
|
|
345
|
-
}): Portfolio {
|
|
346
|
-
const state = useCountervaluesState();
|
|
347
|
-
return useMemo(
|
|
348
|
-
() =>
|
|
349
|
-
getPortfolio(accounts, range, (from, value, date) => {
|
|
350
|
-
const countervalue = calculate(state, {
|
|
351
|
-
value: value.toNumber(),
|
|
352
|
-
from,
|
|
353
|
-
to,
|
|
354
|
-
disableRounding: true,
|
|
355
|
-
date,
|
|
356
|
-
});
|
|
357
|
-
return typeof countervalue === "number"
|
|
358
|
-
? new BigNumber(countervalue)
|
|
359
|
-
: countervalue;
|
|
360
|
-
}),
|
|
361
|
-
[accounts, range, state, to]
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
export function useCurrencyPortfolio({
|
|
365
|
-
accounts: rawAccounts,
|
|
366
|
-
range,
|
|
367
|
-
to,
|
|
368
|
-
currency,
|
|
369
|
-
}: {
|
|
370
|
-
accounts: Account[];
|
|
371
|
-
range: PortfolioRange;
|
|
372
|
-
to: Currency;
|
|
373
|
-
currency: CryptoCurrency | TokenCurrency;
|
|
374
|
-
}): CurrencyPortfolio {
|
|
375
|
-
const accounts = flattenAccounts(rawAccounts).filter(
|
|
376
|
-
(a) => getAccountCurrency(a) === currency
|
|
377
|
-
);
|
|
378
|
-
const state = useCountervaluesState();
|
|
379
|
-
return useMemo(
|
|
380
|
-
() =>
|
|
381
|
-
getCurrencyPortfolio(accounts, range, (from, value, date) => {
|
|
382
|
-
const countervalue = calculate(state, {
|
|
383
|
-
value: value.toNumber(),
|
|
384
|
-
from,
|
|
385
|
-
to,
|
|
386
|
-
disableRounding: true,
|
|
387
|
-
date,
|
|
388
|
-
});
|
|
389
|
-
return typeof countervalue === "number"
|
|
390
|
-
? new BigNumber(countervalue)
|
|
391
|
-
: countervalue;
|
|
392
|
-
}),
|
|
393
|
-
[accounts, range, state, to]
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
export function useDistribution({
|
|
397
|
-
accounts,
|
|
398
|
-
to,
|
|
399
|
-
}: {
|
|
400
|
-
accounts: Account[];
|
|
401
|
-
to: Currency;
|
|
402
|
-
}): AssetsDistribution {
|
|
403
|
-
const calc = useCalculateCountervalueCallback({
|
|
404
|
-
to,
|
|
405
|
-
});
|
|
406
|
-
return useMemo(() => {
|
|
407
|
-
return getAssetsDistribution(accounts, calc, {
|
|
408
|
-
minShowFirst: 6,
|
|
409
|
-
maxShowFirst: 6,
|
|
410
|
-
showFirstThreshold: 0.95,
|
|
411
|
-
});
|
|
412
|
-
}, [accounts, calc]);
|
|
413
|
-
}
|
|
414
285
|
|
|
415
286
|
export function useCalculateCountervalueCallback({
|
|
416
287
|
to,
|
|
@@ -118,7 +118,6 @@ Array [
|
|
|
118
118
|
"ethereum/erc20/thorchain_eth_rune",
|
|
119
119
|
"ethereum/erc20/acuteanglecoin",
|
|
120
120
|
"pivx",
|
|
121
|
-
"ethereum/erc20/constellation_token",
|
|
122
121
|
"ethereum/erc20/reserve_rights",
|
|
123
122
|
"ethereum/erc20/wcoin",
|
|
124
123
|
"ethereum/erc20/shipchain",
|
|
@@ -1747,6 +1746,7 @@ Array [
|
|
|
1747
1746
|
"ethereum/erc20/bavala",
|
|
1748
1747
|
"ethereum/erc20/bayc_history_-the_great_floor_sweep",
|
|
1749
1748
|
"ethereum/erc20/baz_token",
|
|
1749
|
+
"ethereum/erc20/bb_verse",
|
|
1750
1750
|
"ethereum/erc20/bbn",
|
|
1751
1751
|
"ethereum/erc20/bcap",
|
|
1752
1752
|
"ethereum/erc20/bcat",
|
|
@@ -2751,6 +2751,7 @@ Array [
|
|
|
2751
2751
|
"ethereum/erc20/eub_chain",
|
|
2752
2752
|
"ethereum/erc20/eur_tether__erc20_",
|
|
2753
2753
|
"ethereum/erc20/eurbase_stablecoin",
|
|
2754
|
+
"ethereum/erc20/euro_coin",
|
|
2754
2755
|
"ethereum/erc20/euro_stable_token",
|
|
2755
2756
|
"ethereum/erc20/europechain",
|
|
2756
2757
|
"ethereum/erc20/eurxb",
|
|
@@ -2868,6 +2869,7 @@ Array [
|
|
|
2868
2869
|
"ethereum/erc20/floki_wife",
|
|
2869
2870
|
"ethereum/erc20/flow_protocol",
|
|
2870
2871
|
"ethereum/erc20/flux",
|
|
2872
|
+
"ethereum/erc20/flux_(zel)",
|
|
2871
2873
|
"ethereum/erc20/flux_protocol",
|
|
2872
2874
|
"ethereum/erc20/fluz_fluz_global",
|
|
2873
2875
|
"ethereum/erc20/flynnjamm",
|
|
@@ -3412,6 +3414,7 @@ Array [
|
|
|
3412
3414
|
"ethereum/erc20/konomi",
|
|
3413
3415
|
"ethereum/erc20/korea_medical_tba",
|
|
3414
3416
|
"ethereum/erc20/koris",
|
|
3417
|
+
"ethereum/erc20/kounotori",
|
|
3415
3418
|
"ethereum/erc20/kper_network",
|
|
3416
3419
|
"ethereum/erc20/kpop",
|
|
3417
3420
|
"ethereum/erc20/kprcoin",
|
|
@@ -4678,6 +4681,7 @@ Array [
|
|
|
4678
4681
|
"ethereum/erc20/strikex",
|
|
4679
4682
|
"ethereum/erc20/strips_token",
|
|
4680
4683
|
"ethereum/erc20/strong",
|
|
4684
|
+
"ethereum/erc20/stronger",
|
|
4681
4685
|
"ethereum/erc20/stronghold",
|
|
4682
4686
|
"ethereum/erc20/strudel_finance",
|
|
4683
4687
|
"ethereum/erc20/successlife",
|
|
@@ -4899,6 +4903,7 @@ Array [
|
|
|
4899
4903
|
"ethereum/erc20/toka",
|
|
4900
4904
|
"ethereum/erc20/tokamak_network_token",
|
|
4901
4905
|
"ethereum/erc20/tokemak",
|
|
4906
|
+
"ethereum/erc20/tokemaksushilppool",
|
|
4902
4907
|
"ethereum/erc20/tokemon",
|
|
4903
4908
|
"ethereum/erc20/token_1337",
|
|
4904
4909
|
"ethereum/erc20/token_play",
|
|
@@ -5600,6 +5605,7 @@ Array [
|
|
|
5600
5605
|
"polygon/erc20/cerby_token",
|
|
5601
5606
|
"polygon/erc20/chainlink_token",
|
|
5602
5607
|
"polygon/erc20/chiliz",
|
|
5608
|
+
"polygon/erc20/city_of_block",
|
|
5603
5609
|
"polygon/erc20/clintex",
|
|
5604
5610
|
"polygon/erc20/clocks_token",
|
|
5605
5611
|
"polygon/erc20/conch_coin",
|
|
@@ -5872,6 +5878,7 @@ Array [
|
|
|
5872
5878
|
"bsc/bep20/bakerytoken",
|
|
5873
5879
|
"bsc/bep20/bat_true_dollar",
|
|
5874
5880
|
"bsc/bep20/bat_true_share",
|
|
5881
|
+
"bsc/bep20/bb_verse",
|
|
5875
5882
|
"bsc/bep20/bdollar",
|
|
5876
5883
|
"bsc/bep20/bdollar_share",
|
|
5877
5884
|
"bsc/bep20/bearn.fi",
|
|
@@ -5962,6 +5969,7 @@ Array [
|
|
|
5962
5969
|
"bsc/bep20/canyacoin",
|
|
5963
5970
|
"bsc/bep20/car",
|
|
5964
5971
|
"bsc/bep20/cartesi_token",
|
|
5972
|
+
"bsc/bep20/catcoin",
|
|
5965
5973
|
"bsc/bep20/catecoin",
|
|
5966
5974
|
"bsc/bep20/catecoin_old",
|
|
5967
5975
|
"bsc/bep20/ceek",
|
|
@@ -6051,6 +6059,7 @@ Array [
|
|
|
6051
6059
|
"bsc/bep20/floki_rocket",
|
|
6052
6060
|
"bsc/bep20/flokimooni",
|
|
6053
6061
|
"bsc/bep20/formation_finance",
|
|
6062
|
+
"bsc/bep20/foxfinancev2",
|
|
6054
6063
|
"bsc/bep20/free_coin_bsc",
|
|
6055
6064
|
"bsc/bep20/frmx_token",
|
|
6056
6065
|
"bsc/bep20/frog_inu",
|
|
@@ -6077,6 +6086,7 @@ Array [
|
|
|
6077
6086
|
"bsc/bep20/hacken_token",
|
|
6078
6087
|
"bsc/bep20/hakka_finance_on_xdai_on_bsc",
|
|
6079
6088
|
"bsc/bep20/happinesstoken",
|
|
6089
|
+
"bsc/bep20/happy_4th_of_july",
|
|
6080
6090
|
"bsc/bep20/hard",
|
|
6081
6091
|
"bsc/bep20/harmony_one",
|
|
6082
6092
|
"bsc/bep20/hedge_token",
|
|
@@ -6100,6 +6110,7 @@ Array [
|
|
|
6100
6110
|
"bsc/bep20/juggernaut_defi",
|
|
6101
6111
|
"bsc/bep20/julswap",
|
|
6102
6112
|
"bsc/bep20/jumptoken",
|
|
6113
|
+
"bsc/bep20/jupyter",
|
|
6103
6114
|
"bsc/bep20/jurassic_token",
|
|
6104
6115
|
"bsc/bep20/kaby_arena",
|
|
6105
6116
|
"bsc/bep20/kalmar_token",
|
|
@@ -6139,6 +6150,7 @@ Array [
|
|
|
6139
6150
|
"bsc/bep20/mobox",
|
|
6140
6151
|
"bsc/bep20/moeda_loyalty_points",
|
|
6141
6152
|
"bsc/bep20/moeda_seeds",
|
|
6153
|
+
"bsc/bep20/moneu_token",
|
|
6142
6154
|
"bsc/bep20/monsta_infinite_token",
|
|
6143
6155
|
"bsc/bep20/moomonster_token",
|
|
6144
6156
|
"bsc/bep20/moonienft_token",
|
|
@@ -6240,6 +6252,7 @@ Array [
|
|
|
6240
6252
|
"bsc/bep20/shambala",
|
|
6241
6253
|
"bsc/bep20/shard",
|
|
6242
6254
|
"bsc/bep20/shiba_inu",
|
|
6255
|
+
"bsc/bep20/shibnobi",
|
|
6243
6256
|
"bsc/bep20/shield_protocol",
|
|
6244
6257
|
"bsc/bep20/shill",
|
|
6245
6258
|
"bsc/bep20/shirtum",
|
|
@@ -6338,6 +6351,7 @@ Array [
|
|
|
6338
6351
|
"bsc/bep20/waultswap",
|
|
6339
6352
|
"bsc/bep20/wazirx_token",
|
|
6340
6353
|
"bsc/bep20/weather",
|
|
6354
|
+
"bsc/bep20/weed_inu",
|
|
6341
6355
|
"bsc/bep20/weetwo",
|
|
6342
6356
|
"bsc/bep20/weyu",
|
|
6343
6357
|
"bsc/bep20/wink",
|