Skip to content

Commit

Permalink
chore(token-definitions): import state from token-definitions package
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed May 7, 2024
1 parent e775695 commit 9b60ede
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 32 deletions.
6 changes: 4 additions & 2 deletions packages/suite/src/actions/suite/__tests__/initAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
initBlockchainThunk,
periodicFetchFiatRatesThunk,
preloadFeeInfoThunk,
initTokenDefinitionsThunk,
periodicCheckTokenDefinitionsThunk,
initStakeDataThunk,
periodicCheckStakeDataThunk,
} from '@suite-common/wallet-core';
Expand All @@ -35,6 +33,10 @@ import type { AppState } from 'src/types/suite';
import { extraDependencies } from 'src/support/extraDependencies';

import { appChanged } from '../suiteActions';
import {
initTokenDefinitionsThunk,
periodicCheckTokenDefinitionsThunk,
} from '@suite-common/token-definitions';

const deviceReducer = prepareDeviceReducer(extraDependencies);
const analyticsReducer = prepareAnalyticsReducer(extraDependencies);
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/actions/suite/initAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as trezorConnectActions from '@suite-common/connect-init';
import {
initBlockchainThunk,
initDevices,
periodicCheckTokenDefinitionsThunk,
periodicFetchFiatRatesThunk,
periodicCheckStakeDataThunk,
} from '@suite-common/wallet-core';
Expand All @@ -17,6 +16,7 @@ import { selectLocalCurrency } from 'src/reducers/wallet/settingsReducer';

import { SUITE } from './constants';
import { onSuiteReady } from './suiteActions';
import { periodicCheckTokenDefinitionsThunk } from '@suite-common/token-definitions';

export const init = () => async (dispatch: Dispatch, getState: GetState) => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { setFlag } from 'src/actions/suite/suiteActions';
import { selectSuiteFlags } from '../../../../reducers/suite/suiteReducer';
import { Account } from '@suite-common/wallet-types';
import { selectPoolStatsApyData } from '@suite-common/wallet-core';
import { isSupportedNetworkSymbol } from '@suite-common/wallet-core/src/stake/stakeTypes';
import { isSupportedNetworkSymbol } from '@suite-common/wallet-core';

const StyledCard = styled(Card)`
padding: ${spacingsPx.lg} ${spacingsPx.xxl} ${spacingsPx.lg} ${spacingsPx.md};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { Account } from '@suite-common/wallet-types';
import { AccountItemsGroup } from './AccountItemsGroup';
import { AccountItem } from './AccountItem';
import { useSelector } from 'src/hooks/suite';
import { selectCoinDefinitions } from '@suite-common/wallet-core';
import { getNetworkFeatures } from '@suite-common/wallet-config';
import { isTokenDefinitionKnown } from '@suite-common/token-definitions';
import { isSupportedNetworkSymbol } from '@suite-common/wallet-core/src/stake/stakeTypes';
import { isTokenDefinitionKnown, selectCoinDefinitions } from '@suite-common/token-definitions';
import { isSupportedNetworkSymbol } from '@suite-common/wallet-core';

interface AccountSectionProps {
account: Account;
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/middlewares/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
prepareFiatRatesMiddleware,
prepareBlockchainMiddleware,
prepareStakeMiddleware,
prepareTokenDefinitionsMiddleware,
} from '@suite-common/wallet-core';

import { prepareDiscoveryMiddleware } from './discoveryMiddleware';
Expand All @@ -14,6 +13,7 @@ import coinmarketSavingsMiddleware from './coinmarketSavingsMiddleware';
import pollingMiddleware from './pollingMiddleware';
import { coinjoinMiddleware } from './coinjoinMiddleware';
import { extraDependencies } from 'src/support/extraDependencies';
import { prepareTokenDefinitionsMiddleware } from '@suite-common/token-definitions';

export default [
prepareBlockchainMiddleware(extraDependencies),
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/reducers/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
prepareTransactionsReducer,
prepareBlockchainReducer,
prepareDiscoveryReducer,
prepareTokenDefinitionsReducer,
prepareStakeReducer,
prepareSendFormReducer,
feesReducer,
Expand All @@ -24,6 +23,7 @@ import formDraftReducer from './formDraftReducer';
import cardanoStakingReducer from './cardanoStakingReducer';
import pollingReducer from './pollingReducer';
import { coinjoinReducer } from './coinjoinReducer';
import { prepareTokenDefinitionsReducer } from '@suite-common/token-definitions';

export const transactionsReducer = prepareTransactionsReducer(extraDependencies);
export const accountsReducer = prepareAccountsReducer(extraDependencies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
import { useBitcoinAmountUnit } from 'src/hooks/wallet/useBitcoinAmountUnit';
import { hasNetworkTypeTradableTokens } from 'src/utils/wallet/coinmarket/commonUtils';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { selectCoinDefinitions, updateFiatRatesThunk } from '@suite-common/wallet-core';
import { updateFiatRatesThunk } from '@suite-common/wallet-core';
import { Timestamp, TokenAddress } from '@suite-common/wallet-types';
import { FiatCurrencyCode } from '@suite-common/suite-config';
import { selectCoinDefinitions } from '@suite-common/token-definitions';

const Option = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
validateMin,
} from 'src/utils/suite/validation';
import { networkToCryptoSymbol } from 'src/utils/wallet/coinmarket/cryptoSymbolUtils';
import { selectCoinDefinitions } from '@suite-common/wallet-core';
import { hasNetworkTypeTradableTokens } from 'src/utils/wallet/coinmarket/commonUtils';
import { selectCoinDefinitions } from '@suite-common/token-definitions';

const Option = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { useSendFormContext } from 'src/hooks/wallet';
import { Account } from 'src/types/wallet';
import { Output } from '@suite-common/wallet-types';
import { useDispatch, useSelector } from 'src/hooks/suite';
import {
selectCoinDefinitions,
updateFiatRatesThunk,
selectFiatRates,
} from '@suite-common/wallet-core';
import { updateFiatRatesThunk, selectFiatRates } from '@suite-common/wallet-core';
import BigNumber from 'bignumber.js';
import { Timestamp, TokenAddress } from '@suite-common/wallet-types';
import { TooltipSymbol, Translation } from 'src/components/suite';
Expand All @@ -24,7 +20,11 @@ import {
import { getShortFingerprint } from '@suite-common/wallet-utils';
import { selectLocalCurrency } from 'src/reducers/wallet/settingsReducer';
import { FiatCurrencyCode } from '@suite-common/suite-config';
import { TokenDefinitions, isTokenDefinitionKnown } from '@suite-common/token-definitions';
import {
TokenDefinitions,
isTokenDefinitionKnown,
selectCoinDefinitions,
} from '@suite-common/token-definitions';

const UnrecognizedTokensHeading = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {
} from 'src/components/suite';
import { Account } from 'src/types/wallet';
import { useSelector } from 'src/hooks/suite';
import { selectCoinDefinitions, selectFiatRates } from '@suite-common/wallet-core';
import { selectFiatRates } from '@suite-common/wallet-core';
import { NoRatesTooltip } from 'src/components/suite/Ticker/NoRatesTooltip';
import { TokenInfo } from '@trezor/blockchain-link-types';
import { spacingsPx, typography } from '@trezor/theme';
import { NetworkSymbol, getNetworkFeatures } from '@suite-common/wallet-config';
import { enhanceTokensWithRates, sortTokensWithRates } from 'src/utils/wallet/tokenUtils';
import { Rate } from '@suite-common/wallet-types';
import { selectLocalCurrency } from 'src/reducers/wallet/settingsReducer';
import { isTokenDefinitionKnown } from '@suite-common/token-definitions';
import { isTokenDefinitionKnown, selectCoinDefinitions } from '@suite-common/token-definitions';
import { LastUpdateTooltip } from 'src/components/suite/Ticker/LastUpdateTooltip';

const Wrapper = styled(Card)<{ $fiatRateHidden?: boolean }>`
Expand Down
4 changes: 4 additions & 0 deletions suite-common/token-definitions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export * from './types';
export * from './utils';
export * from './constants';
export * from './tokenDefinitionsSelectors';
export * from './tokenDefinitionsReducer';
export * from './tokenDefinitionsThunks';
export * from './tokenDefinitionsMiddleware';
5 changes: 1 addition & 4 deletions suite-common/wallet-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ export * from './device/deviceActions';
export * from './device/deviceThunks';
export * from './device/deviceReducer';
export * from './device/deviceConstants';
export * from '@suite-common/token-definitions/src/tokenDefinitionsSelectors';
export * from '@suite-common/token-definitions/src/tokenDefinitionsReducer';
export * from '@suite-common/token-definitions/src/tokenDefinitionsThunks';
export * from '@suite-common/token-definitions/src/tokenDefinitionsMiddleware';
export * from './stake/stakeActions';
export * from './stake/stakeReducer';
export * from './stake/stakeSelectors';
export * from './stake/stakeMiddleware';
export * from './stake/stakeThunks';
export * from './stake/stakeTypes';
1 change: 1 addition & 0 deletions suite-native/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@suite-common/message-system": "workspace:*",
"@suite-common/redux-utils": "workspace:*",
"@suite-common/suite-constants": "workspace:*",
"@suite-common/token-definitions": "workspace:*",
"@suite-common/wallet-core": "workspace:*",
"@suite-native/accounts": "workspace:*",
"@suite-native/alerts": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion suite-native/app/src/initActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { connectInitThunk } from '@suite-common/connect-init';
import {
createImportedDeviceThunk,
initBlockchainThunk,
periodicCheckTokenDefinitionsThunk,
periodicFetchFiatRatesThunk,
} from '@suite-common/wallet-core';
import { initAnalyticsThunk } from '@suite-native/analytics';
import { selectFiatCurrencyCode } from '@suite-native/module-settings';
import { initMessageSystemThunk } from '@suite-common/message-system';
import { wipeDisconnectedDevicesDataThunk } from '@suite-native/device';
import { setIsAppReady, setIsConnectInitialized } from '@suite-native/state/src/appSlice';
import { periodicCheckTokenDefinitionsThunk } from '@suite-common/token-definitions';

let isAlreadyInitialized = false;

Expand Down
10 changes: 5 additions & 5 deletions suite-native/discovery/src/discoverySelectors.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { pipe, A, D } from '@mobily/ts-belt';

import { TokenDefinitionsRootState } from '@suite-common/token-definitions';
import { NetworkSymbol } from '@suite-common/wallet-config';
import {
DeviceRootState,
TokenDefinitionsRootState,
selectValidTokensByDeviceStateAndNetworkSymbol,
} from '@suite-common/wallet-core';
} from '@suite-common/token-definitions';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { DeviceRootState } from '@suite-common/wallet-core';
import {
AccountsRootState,
selectAccountsByDeviceStateAndNetworkSymbol,
selectDeviceAccounts,
} from '@suite-common/wallet-core/src/accounts/accountsReducer';
} from '@suite-common/wallet-core';
import { TokenSymbol, TokenAddress } from '@suite-common/wallet-types';

export const selectDiscoveryAccountsAnalytics = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
AccountsRootState,
selectAccountsByNetworkAndDeviceState,
PORTFOLIO_TRACKER_DEVICE_STATE,
selectFilterKnownTokens,
FiatRatesRootState,
} from '@suite-common/wallet-core';
import { Box, Button, Divider, VStack } from '@suite-native/atoms';
Expand All @@ -27,7 +26,10 @@ import { analytics, EventType } from '@suite-native/analytics';
import { TokenAddress, TokenInfoBranded, TokenSymbol } from '@suite-common/wallet-types';
import { selectAnyOfTokensHasFiatRates } from '@suite-native/ethereum-tokens';
import { SettingsSliceRootState } from '@suite-native/module-settings';
import { TokenDefinitionsRootState } from '@suite-common/token-definitions';
import {
selectFilterKnownTokens,
TokenDefinitionsRootState,
} from '@suite-common/token-definitions';

import { importAccountThunk } from '../accountsImportThunks';
import { AccountImportOverview } from './AccountImportOverview';
Expand Down
1 change: 1 addition & 0 deletions suite-native/state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@suite-common/redux-utils": "workspace:*",
"@suite-common/test-utils": "workspace:*",
"@suite-common/toast-notifications": "workspace:*",
"@suite-common/token-definitions": "workspace:*",
"@suite-common/wallet-core": "workspace:*",
"@suite-native/accounts": "workspace:*",
"@suite-native/blockchain": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion suite-native/state/src/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
prepareDeviceReducer,
prepareDiscoveryReducer,
prepareFiatRatesReducer,
prepareTokenDefinitionsReducer,
prepareTransactionsReducer,
} from '@suite-common/wallet-core';
import { appSettingsReducer, appSettingsPersistWhitelist } from '@suite-native/module-settings';
Expand All @@ -26,6 +25,7 @@ import { notificationsReducer } from '@suite-common/toast-notifications';
import { graphReducer, graphPersistWhitelist } from '@suite-native/graph';
import { discoveryConfigPersistWhitelist, discoveryConfigReducer } from '@suite-native/discovery';
import { featureFlagsPersistedKeys, featureFlagsReducer } from '@suite-native/feature-flags';
import { prepareTokenDefinitionsReducer } from '@suite-common/token-definitions';

import { extraDependencies } from './extraDependencies';
import { appReducer } from './appSlice';
Expand Down
3 changes: 3 additions & 0 deletions suite-native/state/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
{
"path": "../../suite-common/toast-notifications"
},
{
"path": "../../suite-common/token-definitions"
},
{
"path": "../../suite-common/wallet-core"
},
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9895,6 +9895,7 @@ __metadata:
"@suite-common/redux-utils": "workspace:*"
"@suite-common/test-utils": "workspace:*"
"@suite-common/toast-notifications": "workspace:*"
"@suite-common/token-definitions": "workspace:*"
"@suite-common/wallet-core": "workspace:*"
"@suite-native/accounts": "workspace:*"
"@suite-native/blockchain": "workspace:*"
Expand Down

0 comments on commit 9b60ede

Please sign in to comment.