@ledgerhq/live-common 27.2.0 → 27.3.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apps/logic.test.js +1 -1
- package/lib/apps/logic.test.js.map +1 -1
- package/lib/apps/polyfill.d.ts +1 -1
- package/lib/apps/polyfill.d.ts.map +1 -1
- package/lib/apps/polyfill.js +6 -3
- package/lib/apps/polyfill.js.map +1 -1
- package/lib/apps/polyfill.test.d.ts +2 -0
- package/lib/apps/polyfill.test.d.ts.map +1 -0
- package/lib/apps/polyfill.test.js +25 -0
- package/lib/apps/polyfill.test.js.map +1 -0
- package/lib/apps/support.d.ts.map +1 -1
- package/lib/apps/support.js +3 -2
- package/lib/apps/support.js.map +1 -1
- package/lib/bot/engine.d.ts.map +1 -1
- package/lib/bot/engine.js +154 -45
- package/lib/bot/engine.js.map +1 -1
- package/lib/bot/formatters.d.ts +1 -1
- package/lib/bot/formatters.d.ts.map +1 -1
- package/lib/bot/formatters.js +9 -3
- package/lib/bot/formatters.js.map +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +29 -11
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts +12 -1
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +75 -1
- package/lib/bot/specs.js.map +1 -1
- package/lib/bot/types.d.ts +18 -1
- package/lib/bot/types.d.ts.map +1 -1
- package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
- package/lib/currencies/sortByMarketcap.js +5 -1
- package/lib/currencies/sortByMarketcap.js.map +1 -1
- package/lib/currencies/support.d.ts.map +1 -1
- package/lib/currencies/support.js +2 -1
- package/lib/currencies/support.js.map +1 -1
- package/lib/derivation.d.ts.map +1 -1
- package/lib/derivation.js +2 -4
- package/lib/derivation.js.map +1 -1
- package/lib/env.js +1 -1
- package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
- package/lib/exchange/swap/getExchangeRates.js +6 -3
- package/lib/exchange/swap/getExchangeRates.js.map +1 -1
- package/lib/exchange/swap/getProviders.d.ts.map +1 -1
- package/lib/exchange/swap/getProviders.js +45 -5
- package/lib/exchange/swap/getProviders.js.map +1 -1
- package/lib/exchange/swap/getProviders.test.d.ts +2 -0
- package/lib/exchange/swap/getProviders.test.d.ts.map +1 -0
- package/lib/exchange/swap/getProviders.test.js +519 -0
- package/lib/exchange/swap/getProviders.test.js.map +1 -0
- package/lib/exchange/swap/hooks/useProviderRates.d.ts +1 -0
- package/lib/exchange/swap/hooks/useProviderRates.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useProviderRates.js +19 -4
- package/lib/exchange/swap/hooks/useProviderRates.js.map +1 -1
- package/lib/exchange/swap/hooks/useProviderRates.test.js +42 -0
- package/lib/exchange/swap/hooks/useProviderRates.test.js.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts +1 -0
- package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.js +2 -1
- package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
- package/lib/exchange/swap/index.d.ts +2 -1
- package/lib/exchange/swap/index.d.ts.map +1 -1
- package/lib/exchange/swap/index.js +11 -1
- package/lib/exchange/swap/index.js.map +1 -1
- package/lib/exchange/swap/index.test.js +22 -0
- package/lib/exchange/swap/index.test.js.map +1 -1
- package/lib/exchange/swap/mock.js +1 -1
- package/lib/exchange/swap/mock.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +14 -0
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/exchange/swap/utils/index.d.ts +1 -0
- package/lib/exchange/swap/utils/index.d.ts.map +1 -1
- package/lib/exchange/swap/utils/index.js +6 -1
- package/lib/exchange/swap/utils/index.js.map +1 -1
- package/lib/exchange/swap/utils/index.test.js +12 -0
- package/lib/exchange/swap/utils/index.test.js.map +1 -1
- package/lib/families/algorand/specs.d.ts.map +1 -1
- package/lib/families/algorand/specs.js +2 -0
- package/lib/families/algorand/specs.js.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/algorand/speculos-deviceActions.js +2 -29
- package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts +0 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +65 -48
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/bitcoin/speculos-deviceActions.js +2 -22
- package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/cardano/specs.d.ts.map +1 -1
- package/lib/families/cardano/specs.js +9 -4
- package/lib/families/cardano/specs.js.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/cardano/speculos-deviceActions.js +2 -10
- package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
- package/lib/families/celo/specs/createSendMutation.d.ts +1 -0
- package/lib/families/celo/specs/createSendMutation.d.ts.map +1 -1
- package/lib/families/celo/specs/createSendMutation.js +7 -5
- package/lib/families/celo/specs/createSendMutation.js.map +1 -1
- package/lib/families/celo/specs.d.ts.map +1 -1
- package/lib/families/celo/specs.js +1 -0
- package/lib/families/celo/specs.js.map +1 -1
- package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/celo/speculos-deviceActions.js +3 -10
- package/lib/families/celo/speculos-deviceActions.js.map +1 -1
- package/lib/families/cosmos/helpers.d.ts +9 -0
- package/lib/families/cosmos/helpers.d.ts.map +1 -0
- package/lib/families/cosmos/helpers.js +20 -0
- package/lib/families/cosmos/helpers.js.map +1 -0
- package/lib/families/cosmos/helpers.unit.test.d.ts +2 -0
- package/lib/families/cosmos/helpers.unit.test.d.ts.map +1 -0
- package/lib/families/cosmos/helpers.unit.test.js +56 -0
- package/lib/families/cosmos/helpers.unit.test.js.map +1 -0
- package/lib/families/cosmos/js-signOperation.d.ts.map +1 -1
- package/lib/families/cosmos/js-signOperation.js +5 -3
- package/lib/families/cosmos/js-signOperation.js.map +1 -1
- package/lib/families/cosmos/js-synchronisation.d.ts.map +1 -1
- package/lib/families/cosmos/js-synchronisation.js +99 -95
- package/lib/families/cosmos/js-synchronisation.js.map +1 -1
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +5 -1
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/crypto_org/specs.d.ts.map +1 -1
- package/lib/families/crypto_org/specs.js +9 -8
- package/lib/families/crypto_org/specs.js.map +1 -1
- package/lib/families/elrond/specs.d.ts.map +1 -1
- package/lib/families/elrond/specs.js +1 -0
- package/lib/families/elrond/specs.js.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/elrond/speculos-deviceActions.js +3 -8
- package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
- package/lib/families/ethereum/specs.d.ts.map +1 -1
- package/lib/families/ethereum/specs.js +20 -8
- package/lib/families/ethereum/specs.js.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ethereum/speculos-deviceActions.js +10 -33
- package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
- package/lib/families/evm/specs.d.ts.map +1 -1
- package/lib/families/evm/specs.js +20 -10
- package/lib/families/evm/specs.js.map +1 -1
- package/lib/families/evm/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/evm/speculos-deviceActions.js +5 -25
- package/lib/families/evm/speculos-deviceActions.js.map +1 -1
- package/lib/families/filecoin/specs.d.ts.map +1 -1
- package/lib/families/filecoin/specs.js +3 -0
- package/lib/families/filecoin/specs.js.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/filecoin/speculos-deviceActions.js +6 -7
- package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
- package/lib/families/hedera/specs.d.ts.map +1 -1
- package/lib/families/hedera/specs.js +2 -0
- package/lib/families/hedera/specs.js.map +1 -1
- package/lib/families/osmosis/specs.d.ts.map +1 -1
- package/lib/families/osmosis/specs.js +3 -0
- package/lib/families/osmosis/specs.js.map +1 -1
- package/lib/families/polkadot/specs.d.ts.map +1 -1
- package/lib/families/polkadot/specs.js +4 -1
- package/lib/families/polkadot/specs.js.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/polkadot/speculos-deviceActions.js +3 -10
- package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
- package/lib/families/ripple/specs.d.ts.map +1 -1
- package/lib/families/ripple/specs.js +2 -0
- package/lib/families/ripple/specs.js.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/ripple/speculos-deviceActions.js +2 -22
- package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
- package/lib/families/solana/specs.d.ts.map +1 -1
- package/lib/families/solana/specs.js +7 -3
- package/lib/families/solana/specs.js.map +1 -1
- package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/solana/speculos-deviceActions.js +5 -7
- package/lib/families/solana/speculos-deviceActions.js.map +1 -1
- package/lib/families/stellar/specs.d.ts.map +1 -1
- package/lib/families/stellar/specs.js +1 -0
- package/lib/families/stellar/specs.js.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/stellar/speculos-deviceActions.js +4 -8
- package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
- package/lib/families/tezos/specs.d.ts.map +1 -1
- package/lib/families/tezos/specs.js +6 -1
- package/lib/families/tezos/specs.js.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tezos/speculos-deviceActions.js +6 -11
- package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
- package/lib/families/tron/specs.d.ts.map +1 -1
- package/lib/families/tron/specs.js +16 -1
- package/lib/families/tron/specs.js.map +1 -1
- package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
- package/lib/families/tron/speculos-deviceActions.js +2 -14
- package/lib/families/tron/speculos-deviceActions.js.map +1 -1
- package/lib/families/tron/synchronisation.integration.test.d.ts +2 -0
- package/lib/families/tron/synchronisation.integration.test.d.ts.map +1 -0
- package/lib/families/tron/{synchronisation.test.js → synchronisation.integration.test.js} +1 -1
- package/lib/families/tron/synchronisation.integration.test.js.map +1 -0
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +6 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/generated/specs.d.ts +0 -1
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/hw/actions/installLanguage.js +1 -1
- package/lib/hw/extractOnboardingState.d.ts +5 -1
- package/lib/hw/extractOnboardingState.d.ts.map +1 -1
- package/lib/hw/extractOnboardingState.js +17 -9
- package/lib/hw/extractOnboardingState.js.map +1 -1
- package/lib/hw/extractOnboardingState.test.js +21 -11
- package/lib/hw/extractOnboardingState.test.js.map +1 -1
- package/lib/load/speculos.d.ts.map +1 -1
- package/lib/load/speculos.js +39 -15
- package/lib/load/speculos.js.map +1 -1
- package/lib/manager/hooks.d.ts +4 -1
- package/lib/manager/hooks.d.ts.map +1 -1
- package/lib/manager/hooks.js +4 -3
- package/lib/manager/hooks.js.map +1 -1
- package/lib/manager/localization.js +2 -2
- package/lib/manager/localization.js.map +1 -1
- package/lib/mock/account.d.ts.map +1 -1
- package/lib/mock/account.js +17 -19
- package/lib/mock/account.js.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.js +5 -1
- package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib/postOnboarding/PostOnboardingProvider.d.ts +20 -0
- package/lib/postOnboarding/PostOnboardingProvider.d.ts.map +1 -0
- package/lib/postOnboarding/PostOnboardingProvider.js +33 -0
- package/lib/postOnboarding/PostOnboardingProvider.js.map +1 -0
- package/lib/postOnboarding/actions.d.ts +20 -0
- package/lib/postOnboarding/actions.d.ts.map +1 -0
- package/lib/postOnboarding/actions.js +37 -0
- package/lib/postOnboarding/actions.js.map +1 -0
- package/lib/postOnboarding/hooks/index.d.ts +6 -0
- package/lib/postOnboarding/hooks/index.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/index.js +22 -0
- package/lib/postOnboarding/hooks/index.js.map +1 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts +8 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js +16 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js.map +1 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts +2 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js +75 -0
- package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts +3 -0
- package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingContext.js +10 -0
- package/lib/postOnboarding/hooks/usePostOnboardingContext.js.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts +8 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js +20 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts +2 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js +64 -0
- package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts +12 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.js +65 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.js.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts +2 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js +129 -0
- package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js.map +1 -0
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts +13 -0
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts.map +1 -0
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js +34 -0
- package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js.map +1 -0
- package/lib/postOnboarding/mock.d.ts +8 -0
- package/lib/postOnboarding/mock.d.ts.map +1 -0
- package/lib/postOnboarding/mock.js +46 -0
- package/lib/postOnboarding/mock.js.map +1 -0
- package/lib/postOnboarding/reducer.d.ts +22 -0
- package/lib/postOnboarding/reducer.d.ts.map +1 -0
- package/lib/postOnboarding/reducer.js +71 -0
- package/lib/postOnboarding/reducer.js.map +1 -0
- package/lib/postOnboarding/reducer.test.d.ts +2 -0
- package/lib/postOnboarding/reducer.test.d.ts.map +1 -0
- package/lib/postOnboarding/reducer.test.js +251 -0
- package/lib/postOnboarding/reducer.test.js.map +1 -0
- package/package.json +24 -20
- package/src/__tests__/__snapshots__/portfolio.v2.ts.snap +16 -0
- package/src/apps/__snapshots__/logic.test.ts.snap +18 -11
- package/src/apps/logic.test.ts +1 -2
- package/src/apps/polyfill.test.ts +24 -0
- package/src/apps/polyfill.ts +7 -2
- package/src/apps/support.ts +2 -1
- package/src/bot/engine.ts +178 -35
- package/src/bot/formatters.ts +15 -2
- package/src/bot/index.ts +48 -19
- package/src/bot/specs.ts +95 -1
- package/src/bot/types.ts +23 -1
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +55 -6
- package/src/currencies/sortByMarketcap.ts +6 -1
- package/src/currencies/support.ts +2 -1
- package/src/derivation.ts +2 -4
- package/src/env.ts +1 -1
- package/src/exchange/swap/getExchangeRates.ts +12 -5
- package/src/exchange/swap/getProviders.test.ts +450 -0
- package/src/exchange/swap/getProviders.ts +31 -8
- package/src/exchange/swap/hooks/useProviderRates.test.ts +43 -0
- package/src/exchange/swap/hooks/useProviderRates.ts +22 -3
- package/src/exchange/swap/hooks/useSwapTransaction.ts +3 -1
- package/src/exchange/swap/index.test.ts +36 -1
- package/src/exchange/swap/index.ts +15 -0
- package/src/exchange/swap/mock.ts +2 -2
- package/src/exchange/swap/types.ts +11 -0
- package/src/exchange/swap/utils/index.test.ts +19 -0
- package/src/exchange/swap/utils/index.ts +5 -0
- package/src/families/algorand/specs.ts +3 -1
- package/src/families/algorand/speculos-deviceActions.ts +4 -35
- package/src/families/bitcoin/specs.ts +72 -56
- package/src/families/bitcoin/speculos-deviceActions.ts +3 -26
- package/src/families/cardano/specs.ts +9 -4
- package/src/families/cardano/speculos-deviceActions.ts +3 -14
- package/src/families/celo/specs/createSendMutation.ts +5 -3
- package/src/families/celo/specs.ts +2 -0
- package/src/families/celo/speculos-deviceActions.ts +6 -14
- package/src/families/cosmos/__snapshots__/bridge.integration.test.ts.snap +24 -44
- package/src/families/cosmos/helpers.ts +21 -0
- package/src/families/cosmos/helpers.unit.test.ts +63 -0
- package/src/families/cosmos/js-signOperation.ts +6 -3
- package/src/families/cosmos/js-synchronisation.ts +120 -119
- package/src/families/cosmos/specs.ts +11 -2
- package/src/families/crypto_org/specs.ts +12 -19
- package/src/families/elrond/specs.ts +1 -0
- package/src/families/elrond/speculos-deviceActions.ts +4 -9
- package/src/families/ethereum/specs.ts +34 -38
- package/src/families/ethereum/speculos-deviceActions.ts +16 -46
- package/src/families/evm/specs.ts +18 -8
- package/src/families/evm/speculos-deviceActions.ts +7 -35
- package/src/families/filecoin/specs.ts +4 -1
- package/src/families/filecoin/speculos-deviceActions.ts +7 -8
- package/src/families/hedera/specs.ts +3 -1
- package/src/families/osmosis/specs.ts +4 -1
- package/src/families/polkadot/specs.ts +11 -2
- package/src/families/polkadot/speculos-deviceActions.ts +5 -16
- package/src/families/ripple/specs.ts +3 -1
- package/src/families/ripple/speculos-deviceActions.ts +3 -28
- package/src/families/solana/specs.ts +15 -4
- package/src/families/solana/speculos-deviceActions.ts +6 -8
- package/src/families/stellar/specs.ts +1 -0
- package/src/families/stellar/speculos-deviceActions.ts +5 -11
- package/src/families/tezos/specs.ts +7 -5
- package/src/families/tezos/speculos-deviceActions.ts +9 -16
- package/src/families/tron/specs.ts +31 -3
- package/src/families/tron/speculos-deviceActions.ts +4 -12
- package/src/families/tron/{synchronisation.test.ts → synchronisation.integration.test.ts} +0 -0
- package/src/featureFlags/defaultFeatures.ts +6 -0
- package/src/hw/actions/installLanguage.ts +1 -1
- package/src/hw/extractOnboardingState.test.ts +29 -12
- package/src/hw/extractOnboardingState.ts +17 -9
- package/src/load/speculos.ts +42 -21
- package/src/manager/hooks.ts +6 -6
- package/src/manager/localization.ts +2 -2
- package/src/mock/account.ts +18 -20
- package/src/notifications/ServiceStatusProvider/index.tsx +8 -1
- package/src/postOnboarding/PostOnboardingProvider.tsx +49 -0
- package/src/postOnboarding/actions.ts +40 -0
- package/src/postOnboarding/hooks/index.ts +5 -0
- package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.ts +82 -0
- package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.ts +12 -0
- package/src/postOnboarding/hooks/usePostOnboardingContext.ts +9 -0
- package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.ts +83 -0
- package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.ts +22 -0
- package/src/postOnboarding/hooks/usePostOnboardingHubState.test.ts +184 -0
- package/src/postOnboarding/hooks/usePostOnboardingHubState.ts +56 -0
- package/src/postOnboarding/hooks/useStartPostOnboardingCallback.ts +38 -0
- package/src/postOnboarding/mock.ts +53 -0
- package/src/postOnboarding/reducer.test.ts +247 -0
- package/src/postOnboarding/reducer.ts +105 -0
- package/lib/families/tron/synchronisation.test.d.ts +0 -2
- package/lib/families/tron/synchronisation.test.d.ts.map +0 -1
- package/lib/families/tron/synchronisation.test.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
2
|
import { getCryptoCurrencyById, parseCurrencyUnit } from "../../../currencies";
|
|
3
|
-
import { pickSiblings } from "../../../bot/specs";
|
|
3
|
+
import { genericTestDestination, pickSiblings } from "../../../bot/specs";
|
|
4
4
|
import { MutationSpec } from "../../../bot/types";
|
|
5
5
|
import type { Transaction } from "../types";
|
|
6
6
|
|
|
7
|
-
const maxAccount =
|
|
7
|
+
const maxAccount = 10;
|
|
8
8
|
const currency = getCryptoCurrencyById("celo");
|
|
9
|
-
const minimalAmount = parseCurrencyUnit(currency.units[0], "0.001");
|
|
9
|
+
export const minimalAmount = parseCurrencyUnit(currency.units[0], "0.001");
|
|
10
10
|
|
|
11
11
|
export const createSend50PercentMutation = (): MutationSpec<Transaction> => ({
|
|
12
12
|
name: "Celo: Move 50% to another account",
|
|
13
13
|
maxRun: 1,
|
|
14
|
+
testDestination: genericTestDestination,
|
|
14
15
|
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
15
16
|
invariant(
|
|
16
17
|
maxSpendable.gt(minimalAmount),
|
|
@@ -29,6 +30,7 @@ export const createSend50PercentMutation = (): MutationSpec<Transaction> => ({
|
|
|
29
30
|
export const createSendMaxMutation = (): MutationSpec<Transaction> => ({
|
|
30
31
|
name: "Celo: Send max to another account",
|
|
31
32
|
maxRun: 1,
|
|
33
|
+
testDestination: genericTestDestination,
|
|
32
34
|
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
33
35
|
invariant(
|
|
34
36
|
maxSpendable.gt(minimalAmount),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
2
2
|
import { getCryptoCurrencyById } from "../../currencies";
|
|
3
3
|
import {
|
|
4
|
+
minimalAmount,
|
|
4
5
|
createLockMutation,
|
|
5
6
|
createRegisterAccountMutation,
|
|
6
7
|
createSend50PercentMutation,
|
|
@@ -35,6 +36,7 @@ const celo: AppSpec<Transaction> = {
|
|
|
35
36
|
},
|
|
36
37
|
testTimeout: 2 * 60 * 1000,
|
|
37
38
|
genericDeviceAction: acceptTransaction,
|
|
39
|
+
minViableAmount: minimalAmount,
|
|
38
40
|
mutations: [
|
|
39
41
|
send50PercentMutation,
|
|
40
42
|
sendMaxMutation,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DeviceAction } from "../../bot/types";
|
|
2
2
|
import type { Transaction } from "./types";
|
|
3
|
-
import { deviceActionFlow } from "../../bot/specs";
|
|
4
|
-
|
|
3
|
+
import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
|
|
4
|
+
|
|
5
5
|
const typeWording = {
|
|
6
6
|
send: "Send",
|
|
7
7
|
lock: "Lock",
|
|
@@ -23,18 +23,10 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
|
|
|
23
23
|
{
|
|
24
24
|
title: "Amount",
|
|
25
25
|
button: "Rr",
|
|
26
|
-
expectedValue: ({ account, status }) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
disableRounding: true,
|
|
31
|
-
});
|
|
32
|
-
if (!formattedValue.includes(".")) {
|
|
33
|
-
// if the value is pure integer, in the app it will automatically add an .0
|
|
34
|
-
return formattedValue + ".0";
|
|
35
|
-
}
|
|
36
|
-
return formattedValue;
|
|
37
|
-
},
|
|
26
|
+
expectedValue: ({ account, status }) =>
|
|
27
|
+
formatDeviceAmount(account.currency, status.amount, {
|
|
28
|
+
forceFloating: true,
|
|
29
|
+
}),
|
|
38
30
|
},
|
|
39
31
|
{
|
|
40
32
|
title: "Address",
|
|
@@ -217,23 +217,19 @@ Array [
|
|
|
217
217
|
"address": "cosmosvaloper1vf44d85es37hwl9f4h9gv0e064m0lla60j9luj",
|
|
218
218
|
"amount": "180",
|
|
219
219
|
},
|
|
220
|
-
Object {
|
|
221
|
-
"address": "cosmosvaloper1vf44d85es37hwl9f4h9gv0e064m0lla60j9luj",
|
|
222
|
-
"amount": "180",
|
|
223
|
-
},
|
|
224
220
|
],
|
|
225
221
|
},
|
|
226
222
|
"fee": "10619",
|
|
227
223
|
"hash": "1F069773A16D0B028E3F90E23290B52DA7708082D258A22B8B786C615C272D5C",
|
|
228
|
-
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-1F069773A16D0B028E3F90E23290B52DA7708082D258A22B8B786C615C272D5C-
|
|
224
|
+
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-1F069773A16D0B028E3F90E23290B52DA7708082D258A22B8B786C615C272D5C-REWARD",
|
|
229
225
|
"operator": undefined,
|
|
230
226
|
"recipients": Array [],
|
|
231
227
|
"senders": Array [],
|
|
232
228
|
"standard": undefined,
|
|
233
229
|
"tokenId": undefined,
|
|
234
230
|
"transactionSequenceNumber": 89,
|
|
235
|
-
"type": "
|
|
236
|
-
"value": "
|
|
231
|
+
"type": "REWARD",
|
|
232
|
+
"value": "180",
|
|
237
233
|
},
|
|
238
234
|
Object {
|
|
239
235
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -258,7 +254,7 @@ Array [
|
|
|
258
254
|
"tokenId": undefined,
|
|
259
255
|
"transactionSequenceNumber": 86,
|
|
260
256
|
"type": "REWARD",
|
|
261
|
-
"value": "
|
|
257
|
+
"value": "12037",
|
|
262
258
|
},
|
|
263
259
|
Object {
|
|
264
260
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -403,7 +399,7 @@ Array [
|
|
|
403
399
|
"tokenId": undefined,
|
|
404
400
|
"transactionSequenceNumber": 75,
|
|
405
401
|
"type": "REWARD",
|
|
406
|
-
"value": "
|
|
402
|
+
"value": "239",
|
|
407
403
|
},
|
|
408
404
|
Object {
|
|
409
405
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -465,23 +461,19 @@ Array [
|
|
|
465
461
|
"address": "cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d",
|
|
466
462
|
"amount": "6166",
|
|
467
463
|
},
|
|
468
|
-
Object {
|
|
469
|
-
"address": "cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d",
|
|
470
|
-
"amount": "6166",
|
|
471
|
-
},
|
|
472
464
|
],
|
|
473
465
|
},
|
|
474
466
|
"fee": "10650",
|
|
475
467
|
"hash": "72E55F86B856BA8558F63075D653D02795A1FF4F33053398F221FF3FBBB02601",
|
|
476
|
-
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-72E55F86B856BA8558F63075D653D02795A1FF4F33053398F221FF3FBBB02601-
|
|
468
|
+
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-72E55F86B856BA8558F63075D653D02795A1FF4F33053398F221FF3FBBB02601-REWARD",
|
|
477
469
|
"operator": undefined,
|
|
478
470
|
"recipients": Array [],
|
|
479
471
|
"senders": Array [],
|
|
480
472
|
"standard": undefined,
|
|
481
473
|
"tokenId": undefined,
|
|
482
474
|
"transactionSequenceNumber": 87,
|
|
483
|
-
"type": "
|
|
484
|
-
"value": "
|
|
475
|
+
"type": "REWARD",
|
|
476
|
+
"value": "6166",
|
|
485
477
|
},
|
|
486
478
|
Object {
|
|
487
479
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -542,23 +534,19 @@ Array [
|
|
|
542
534
|
"address": "cosmosvaloper1grgelyng2v6v3t8z87wu3sxgt9m5s03xfytvz7",
|
|
543
535
|
"amount": "65",
|
|
544
536
|
},
|
|
545
|
-
Object {
|
|
546
|
-
"address": "cosmosvaloper1grgelyng2v6v3t8z87wu3sxgt9m5s03xfytvz7",
|
|
547
|
-
"amount": "65",
|
|
548
|
-
},
|
|
549
537
|
],
|
|
550
538
|
},
|
|
551
539
|
"fee": "10414",
|
|
552
540
|
"hash": "8440FE9905C9BCBD71A6A366AC150ECBD0EFFD040F5D39B255EE4708364497A2",
|
|
553
|
-
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-8440FE9905C9BCBD71A6A366AC150ECBD0EFFD040F5D39B255EE4708364497A2-
|
|
541
|
+
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-8440FE9905C9BCBD71A6A366AC150ECBD0EFFD040F5D39B255EE4708364497A2-REWARD",
|
|
554
542
|
"operator": undefined,
|
|
555
543
|
"recipients": Array [],
|
|
556
544
|
"senders": Array [],
|
|
557
545
|
"standard": undefined,
|
|
558
546
|
"tokenId": undefined,
|
|
559
547
|
"transactionSequenceNumber": 88,
|
|
560
|
-
"type": "
|
|
561
|
-
"value": "
|
|
548
|
+
"type": "REWARD",
|
|
549
|
+
"value": "65",
|
|
562
550
|
},
|
|
563
551
|
Object {
|
|
564
552
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -607,7 +595,7 @@ Array [
|
|
|
607
595
|
"tokenId": undefined,
|
|
608
596
|
"transactionSequenceNumber": 0,
|
|
609
597
|
"type": "REWARD",
|
|
610
|
-
"value": "
|
|
598
|
+
"value": "15935",
|
|
611
599
|
},
|
|
612
600
|
Object {
|
|
613
601
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -704,7 +692,7 @@ Array [
|
|
|
704
692
|
"tokenId": undefined,
|
|
705
693
|
"transactionSequenceNumber": 85,
|
|
706
694
|
"type": "REWARD",
|
|
707
|
-
"value": "
|
|
695
|
+
"value": "136432",
|
|
708
696
|
},
|
|
709
697
|
Object {
|
|
710
698
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -753,7 +741,7 @@ Array [
|
|
|
753
741
|
"tokenId": undefined,
|
|
754
742
|
"transactionSequenceNumber": 84,
|
|
755
743
|
"type": "REWARD",
|
|
756
|
-
"value": "
|
|
744
|
+
"value": "47300",
|
|
757
745
|
},
|
|
758
746
|
Object {
|
|
759
747
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -790,23 +778,19 @@ Array [
|
|
|
790
778
|
"address": "cosmosvaloper1crqm3598z6qmyn2kkcl9dz7uqs4qdqnr6s8jdn",
|
|
791
779
|
"amount": "34610",
|
|
792
780
|
},
|
|
793
|
-
Object {
|
|
794
|
-
"address": "cosmosvaloper1crqm3598z6qmyn2kkcl9dz7uqs4qdqnr6s8jdn",
|
|
795
|
-
"amount": "34610",
|
|
796
|
-
},
|
|
797
781
|
],
|
|
798
782
|
},
|
|
799
783
|
"fee": "10913",
|
|
800
784
|
"hash": "B8D042E6B4AFB580E2D6DD20F2EDCD4E97791EF46DDD0AE112D7B771F6A9B0A4",
|
|
801
|
-
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-B8D042E6B4AFB580E2D6DD20F2EDCD4E97791EF46DDD0AE112D7B771F6A9B0A4-
|
|
785
|
+
"id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-B8D042E6B4AFB580E2D6DD20F2EDCD4E97791EF46DDD0AE112D7B771F6A9B0A4-REWARD",
|
|
802
786
|
"operator": undefined,
|
|
803
787
|
"recipients": Array [],
|
|
804
788
|
"senders": Array [],
|
|
805
789
|
"standard": undefined,
|
|
806
790
|
"tokenId": undefined,
|
|
807
791
|
"transactionSequenceNumber": 82,
|
|
808
|
-
"type": "
|
|
809
|
-
"value": "
|
|
792
|
+
"type": "REWARD",
|
|
793
|
+
"value": "34610",
|
|
810
794
|
},
|
|
811
795
|
Object {
|
|
812
796
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -928,7 +912,7 @@ Array [
|
|
|
928
912
|
"tokenId": undefined,
|
|
929
913
|
"transactionSequenceNumber": 81,
|
|
930
914
|
"type": "REWARD",
|
|
931
|
-
"value": "
|
|
915
|
+
"value": "2347",
|
|
932
916
|
},
|
|
933
917
|
Object {
|
|
934
918
|
"accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
|
|
@@ -977,7 +961,7 @@ Array [
|
|
|
977
961
|
"tokenId": undefined,
|
|
978
962
|
"transactionSequenceNumber": 83,
|
|
979
963
|
"type": "REWARD",
|
|
980
|
-
"value": "
|
|
964
|
+
"value": "281690",
|
|
981
965
|
},
|
|
982
966
|
],
|
|
983
967
|
Array [
|
|
@@ -1078,7 +1062,7 @@ Array [
|
|
|
1078
1062
|
"tokenId": undefined,
|
|
1079
1063
|
"transactionSequenceNumber": 3,
|
|
1080
1064
|
"type": "REDELEGATE",
|
|
1081
|
-
"value": "
|
|
1065
|
+
"value": "11233",
|
|
1082
1066
|
},
|
|
1083
1067
|
Object {
|
|
1084
1068
|
"accountId": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:",
|
|
@@ -1491,7 +1475,7 @@ Array [
|
|
|
1491
1475
|
"tokenId": undefined,
|
|
1492
1476
|
"transactionSequenceNumber": 5,
|
|
1493
1477
|
"type": "DELEGATE",
|
|
1494
|
-
"value": "
|
|
1478
|
+
"value": "10906",
|
|
1495
1479
|
},
|
|
1496
1480
|
],
|
|
1497
1481
|
Array [
|
|
@@ -1724,23 +1708,19 @@ Array [
|
|
|
1724
1708
|
"address": "cosmosvaloper17zcpywlhgcpk7ff505vr8mnc4wwpv5fcta6enz",
|
|
1725
1709
|
"amount": "0",
|
|
1726
1710
|
},
|
|
1727
|
-
Object {
|
|
1728
|
-
"address": "cosmosvaloper17zcpywlhgcpk7ff505vr8mnc4wwpv5fcta6enz",
|
|
1729
|
-
"amount": "1",
|
|
1730
|
-
},
|
|
1731
1711
|
],
|
|
1732
1712
|
},
|
|
1733
1713
|
"fee": "8399",
|
|
1734
1714
|
"hash": "DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F10501",
|
|
1735
|
-
"id": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:-DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F10501-
|
|
1715
|
+
"id": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:-DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F10501-REWARD",
|
|
1736
1716
|
"operator": undefined,
|
|
1737
1717
|
"recipients": Array [],
|
|
1738
1718
|
"senders": Array [],
|
|
1739
1719
|
"standard": undefined,
|
|
1740
1720
|
"tokenId": undefined,
|
|
1741
1721
|
"transactionSequenceNumber": 25,
|
|
1742
|
-
"type": "
|
|
1743
|
-
"value": "
|
|
1722
|
+
"type": "REWARD",
|
|
1723
|
+
"value": "0",
|
|
1744
1724
|
},
|
|
1745
1725
|
Object {
|
|
1746
1726
|
"accountId": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Message = {
|
|
2
|
+
type: string;
|
|
3
|
+
attributes: { [key: string]: any };
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const getMainMessage = (messages: Message[]): Message => {
|
|
7
|
+
const messagePriorities: string[] = [
|
|
8
|
+
"withdraw_rewards",
|
|
9
|
+
"unbond",
|
|
10
|
+
"redelegate",
|
|
11
|
+
"delegate",
|
|
12
|
+
"transfer",
|
|
13
|
+
];
|
|
14
|
+
const sortedTypes = messages
|
|
15
|
+
.filter((m) => messagePriorities.includes(m.type))
|
|
16
|
+
.sort(
|
|
17
|
+
(a, b) =>
|
|
18
|
+
messagePriorities.indexOf(a.type) - messagePriorities.indexOf(b.type)
|
|
19
|
+
);
|
|
20
|
+
return sortedTypes[0];
|
|
21
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getMainMessage } from "./helpers";
|
|
2
|
+
|
|
3
|
+
describe("getMainMessage", () => {
|
|
4
|
+
it("should return reward message with delegate and reward messages (claim rewards, compound)", () => {
|
|
5
|
+
const exec = getMainMessage([
|
|
6
|
+
{
|
|
7
|
+
type: "delegate",
|
|
8
|
+
attributes: {},
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: "withdraw_rewards",
|
|
12
|
+
attributes: {},
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
15
|
+
expect(exec.type).toEqual("withdraw_rewards");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should return unbond message with unbound and transfer messages", () => {
|
|
19
|
+
expect(
|
|
20
|
+
getMainMessage([
|
|
21
|
+
{
|
|
22
|
+
type: "unbond",
|
|
23
|
+
attributes: {},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "transfer",
|
|
27
|
+
attributes: {},
|
|
28
|
+
},
|
|
29
|
+
]).type
|
|
30
|
+
).toEqual("unbond");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should return first transfer message with multiple transfer messages", () => {
|
|
34
|
+
const firstTransfer = {
|
|
35
|
+
type: "transfer",
|
|
36
|
+
attributes: {},
|
|
37
|
+
};
|
|
38
|
+
expect(
|
|
39
|
+
getMainMessage([
|
|
40
|
+
firstTransfer,
|
|
41
|
+
{
|
|
42
|
+
type: "transfer",
|
|
43
|
+
attributes: {},
|
|
44
|
+
},
|
|
45
|
+
])
|
|
46
|
+
).toEqual(firstTransfer);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should return redelegate message with delegate/redelegate messages", () => {
|
|
50
|
+
expect(
|
|
51
|
+
getMainMessage([
|
|
52
|
+
{
|
|
53
|
+
type: "delegate",
|
|
54
|
+
attributes: {},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "redelegate",
|
|
58
|
+
attributes: {},
|
|
59
|
+
},
|
|
60
|
+
]).type
|
|
61
|
+
).toEqual("redelegate");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -153,9 +153,12 @@ const signOperation = ({
|
|
|
153
153
|
id: encodeOperationId(accountId, hash, type),
|
|
154
154
|
hash,
|
|
155
155
|
type,
|
|
156
|
-
value:
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
value:
|
|
157
|
+
type === "REWARD"
|
|
158
|
+
? new BigNumber(0)
|
|
159
|
+
: transaction.useAllAmount
|
|
160
|
+
? account.spendableBalance
|
|
161
|
+
: transaction.amount.plus(fee),
|
|
159
162
|
fee,
|
|
160
163
|
extra,
|
|
161
164
|
blockHash: null,
|
|
@@ -11,6 +11,25 @@ import { pubkeyToAddress, decodeBech32Pubkey } from "@cosmjs/amino";
|
|
|
11
11
|
import { encodeOperationId } from "../../operation";
|
|
12
12
|
import { CosmosDelegationInfo } from "./types";
|
|
13
13
|
import type { Operation, OperationType } from "@ledgerhq/types-live";
|
|
14
|
+
import { getMainMessage } from "./helpers";
|
|
15
|
+
|
|
16
|
+
const getBlankOperation = (tx, fees, id) => ({
|
|
17
|
+
id: "",
|
|
18
|
+
hash: tx.txhash,
|
|
19
|
+
type: "" as OperationType,
|
|
20
|
+
value: new BigNumber(0),
|
|
21
|
+
fee: fees,
|
|
22
|
+
blockHash: null,
|
|
23
|
+
blockHeight: tx.height,
|
|
24
|
+
senders: [] as string[],
|
|
25
|
+
recipients: [] as string[],
|
|
26
|
+
accountId: id,
|
|
27
|
+
date: new Date(tx.timestamp),
|
|
28
|
+
extra: {
|
|
29
|
+
validators: [] as CosmosDelegationInfo[],
|
|
30
|
+
},
|
|
31
|
+
transactionSequenceNumber: parseInt(tx.tx.auth_info.signer_infos[0].sequence),
|
|
32
|
+
});
|
|
14
33
|
|
|
15
34
|
const txToOps = (info: any, id: string, txs: any): Operation[] => {
|
|
16
35
|
const { address, currency } = info;
|
|
@@ -23,126 +42,108 @@ const txToOps = (info: any, id: string, txs: any): Operation[] => {
|
|
|
23
42
|
if (elem.denom === currency.units[1].code) fees = fees.plus(elem.amount);
|
|
24
43
|
});
|
|
25
44
|
|
|
26
|
-
const op: Operation =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
attributes.recipient &&
|
|
60
|
-
attributes.amount
|
|
61
|
-
) {
|
|
62
|
-
op.senders.push(attributes.sender);
|
|
63
|
-
op.recipients.push(attributes.recipient);
|
|
64
|
-
|
|
65
|
-
if (attributes.amount.indexOf(currency.units[1].code) != -1) {
|
|
66
|
-
op.value = op.value.plus(
|
|
67
|
-
attributes.amount.replace(currency.units[1].code, "")
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!op.type && attributes.sender === address) {
|
|
72
|
-
op.type = "OUT";
|
|
73
|
-
op.value = op.value.plus(fees);
|
|
74
|
-
} else if (!op.type && attributes.recipient === address) {
|
|
75
|
-
op.type = "IN";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
|
|
80
|
-
case "withdraw_rewards":
|
|
81
|
-
if (
|
|
82
|
-
(attributes.amount &&
|
|
83
|
-
attributes.amount.indexOf(currency.units[1].code) != -1) ||
|
|
84
|
-
// handle specifc case with empty amount value like
|
|
85
|
-
// tx DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F1050
|
|
86
|
-
attributes.amount === ""
|
|
87
|
-
) {
|
|
88
|
-
op.type = "REWARD";
|
|
89
|
-
op.value = new BigNumber(fees);
|
|
90
|
-
op.extra.validators.push({
|
|
91
|
-
address: attributes.validator,
|
|
92
|
-
amount:
|
|
93
|
-
attributes.amount.replace(currency.units[1].code, "") || 0,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
|
|
98
|
-
case "delegate":
|
|
99
|
-
if (
|
|
100
|
-
attributes.amount &&
|
|
101
|
-
attributes.amount.indexOf(currency.units[1].code) != -1
|
|
102
|
-
) {
|
|
103
|
-
op.type = "DELEGATE";
|
|
104
|
-
op.value = new BigNumber(fees);
|
|
105
|
-
op.extra.validators.push({
|
|
106
|
-
address: attributes.validator,
|
|
107
|
-
amount: attributes.amount.replace(currency.units[1].code, ""),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
|
|
112
|
-
case "redelegate":
|
|
113
|
-
if (
|
|
114
|
-
attributes.amount &&
|
|
115
|
-
attributes.amount.indexOf(currency.units[1].code) != -1 &&
|
|
116
|
-
attributes.destination_validator &&
|
|
117
|
-
attributes.source_validator
|
|
118
|
-
) {
|
|
119
|
-
op.type = "REDELEGATE";
|
|
120
|
-
op.value = new BigNumber(fees);
|
|
121
|
-
op.extra.validators.push({
|
|
122
|
-
address: attributes.destination_validator,
|
|
123
|
-
amount: attributes.amount.replace(currency.units[1].code, ""),
|
|
124
|
-
});
|
|
125
|
-
op.extra.sourceValidator = attributes.source_validator;
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
|
|
129
|
-
case "unbond":
|
|
130
|
-
if (
|
|
131
|
-
attributes.amount &&
|
|
132
|
-
attributes.amount.indexOf(currency.units[1].code) != -1 &&
|
|
133
|
-
attributes.validator
|
|
134
|
-
) {
|
|
135
|
-
op.type = "UNDELEGATE";
|
|
136
|
-
op.value = new BigNumber(fees);
|
|
137
|
-
op.extra.validators.push({
|
|
138
|
-
address: attributes.validator,
|
|
139
|
-
amount: attributes.amount.replace(currency.units[1].code, ""),
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
45
|
+
const op: Operation = getBlankOperation(tx, fees, id);
|
|
46
|
+
|
|
47
|
+
const messages = tx.logs.map((log) => log.events).flat(1);
|
|
48
|
+
|
|
49
|
+
const message = getMainMessage(messages);
|
|
50
|
+
|
|
51
|
+
if (message == null) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// parse attributes as key:value
|
|
56
|
+
const attributes: { [id: string]: any } = {};
|
|
57
|
+
message.attributes.forEach((item) => (attributes[item.key] = item.value));
|
|
58
|
+
|
|
59
|
+
// https://docs.cosmos.network/v0.42/modules/staking/07_events.html
|
|
60
|
+
switch (message.type) {
|
|
61
|
+
case "transfer":
|
|
62
|
+
if (attributes.sender && attributes.recipient && attributes.amount) {
|
|
63
|
+
op.senders.push(attributes.sender);
|
|
64
|
+
op.recipients.push(attributes.recipient);
|
|
65
|
+
|
|
66
|
+
if (attributes.amount.indexOf(currency.units[1].code) != -1) {
|
|
67
|
+
op.value = op.value.plus(
|
|
68
|
+
attributes.amount.replace(currency.units[1].code, "")
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!op.type && attributes.sender === address) {
|
|
73
|
+
op.type = "OUT";
|
|
74
|
+
op.value = op.value.plus(fees);
|
|
75
|
+
} else if (!op.type && attributes.recipient === address) {
|
|
76
|
+
op.type = "IN";
|
|
77
|
+
}
|
|
143
78
|
}
|
|
144
|
-
|
|
145
|
-
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
case "withdraw_rewards":
|
|
82
|
+
if (
|
|
83
|
+
(attributes.amount &&
|
|
84
|
+
attributes.amount.indexOf(currency.units[1].code) != -1) ||
|
|
85
|
+
// handle specifc case with empty amount value like
|
|
86
|
+
// tx DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F1050
|
|
87
|
+
attributes.amount === ""
|
|
88
|
+
) {
|
|
89
|
+
op.type = "REWARD";
|
|
90
|
+
const reward = message.attributes
|
|
91
|
+
.find((attr) => attr.key === "amount")
|
|
92
|
+
.value.replace("uatom", "");
|
|
93
|
+
op.value = new BigNumber(reward || 0);
|
|
94
|
+
op.extra.validators.push({
|
|
95
|
+
address: attributes.validator,
|
|
96
|
+
amount: attributes.amount.replace(currency.units[1].code, "") || 0,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case "delegate":
|
|
102
|
+
if (
|
|
103
|
+
attributes.amount &&
|
|
104
|
+
attributes.amount.indexOf(currency.units[1].code) != -1
|
|
105
|
+
) {
|
|
106
|
+
op.type = "DELEGATE";
|
|
107
|
+
op.value = new BigNumber(fees);
|
|
108
|
+
op.extra.validators.push({
|
|
109
|
+
address: attributes.validator,
|
|
110
|
+
amount: attributes.amount.replace(currency.units[1].code, ""),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
|
|
115
|
+
case "redelegate":
|
|
116
|
+
if (
|
|
117
|
+
attributes.amount &&
|
|
118
|
+
attributes.amount.indexOf(currency.units[1].code) != -1 &&
|
|
119
|
+
attributes.destination_validator &&
|
|
120
|
+
attributes.source_validator
|
|
121
|
+
) {
|
|
122
|
+
op.type = "REDELEGATE";
|
|
123
|
+
op.value = new BigNumber(fees);
|
|
124
|
+
op.extra.validators.push({
|
|
125
|
+
address: attributes.destination_validator,
|
|
126
|
+
amount: attributes.amount.replace(currency.units[1].code, ""),
|
|
127
|
+
});
|
|
128
|
+
op.extra.sourceValidator = attributes.source_validator;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case "unbond":
|
|
133
|
+
if (
|
|
134
|
+
attributes.amount &&
|
|
135
|
+
attributes.amount.indexOf(currency.units[1].code) != -1 &&
|
|
136
|
+
attributes.validator
|
|
137
|
+
) {
|
|
138
|
+
op.type = "UNDELEGATE";
|
|
139
|
+
op.value = new BigNumber(fees);
|
|
140
|
+
op.extra.validators.push({
|
|
141
|
+
address: attributes.validator,
|
|
142
|
+
amount: attributes.amount.replace(currency.units[1].code, ""),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
146
147
|
|
|
147
148
|
if (!["IN", "OUT"].includes(op.type)) {
|
|
148
149
|
op.senders = [];
|