From e02cb475a52a3c06e6834a1022b23894b386937e Mon Sep 17 00:00:00 2001 From: Sergey Zhuravlev Date: Fri, 8 Nov 2024 14:10:13 +0300 Subject: [PATCH] fix: integrated with new asset type from chains.json (#2601) --- .../entities/asset/ui/AssetBalance/AssetBalance.stories.tsx | 3 +++ src/renderer/entities/transaction/lib/common/constants.ts | 1 + src/renderer/shared/api/balances/service/balanceService.ts | 2 +- src/renderer/shared/core/types/asset.ts | 3 ++- src/renderer/shared/mocks/index.ts | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/entities/asset/ui/AssetBalance/AssetBalance.stories.tsx b/src/renderer/entities/asset/ui/AssetBalance/AssetBalance.stories.tsx index 0ff94945ba..5ed2cd444c 100644 --- a/src/renderer/entities/asset/ui/AssetBalance/AssetBalance.stories.tsx +++ b/src/renderer/entities/asset/ui/AssetBalance/AssetBalance.stories.tsx @@ -1,5 +1,7 @@ import { type Meta, type StoryFn } from '@storybook/react'; +import { AssetType } from '@/shared/core'; + import { AssetBalance } from './AssetBalance'; export default { @@ -13,6 +15,7 @@ const assetDot = { symbol: 'DOT', precision: 10, priceId: 'polkadot', + type: AssetType.NATIVE, icon: 'https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/chains/white/Polkadot.svg', name: 'Polkadot', }; diff --git a/src/renderer/entities/transaction/lib/common/constants.ts b/src/renderer/entities/transaction/lib/common/constants.ts index dfee25329c..e0333e46a3 100644 --- a/src/renderer/entities/transaction/lib/common/constants.ts +++ b/src/renderer/entities/transaction/lib/common/constants.ts @@ -13,6 +13,7 @@ export const CONTROLLER_ARG_NAME = 'controller'; export const DEST_WEIGHT_ARG_NAME = 'destWeight'; export const TransferType: Record = { + [AssetType.NATIVE]: TransactionType.TRANSFER, [AssetType.ORML]: TransactionType.ORML_TRANSFER, [AssetType.STATEMINE]: TransactionType.ASSET_TRANSFER, }; diff --git a/src/renderer/shared/api/balances/service/balanceService.ts b/src/renderer/shared/api/balances/service/balanceService.ts index d2dc8115b1..b248d8538b 100644 --- a/src/renderer/shared/api/balances/service/balanceService.ts +++ b/src/renderer/shared/api/balances/service/balanceService.ts @@ -51,7 +51,7 @@ function subscribeBalances( ormlAssets: Asset[]; }>( (acc, asset) => { - if (!asset.type) acc.nativeAsset = asset; + if (asset.type === AssetType.NATIVE) acc.nativeAsset = asset; if (asset.type === AssetType.STATEMINE) acc.statemineAssets.push(asset); if (asset.type === AssetType.ORML) acc.ormlAssets.push(asset); diff --git a/src/renderer/shared/core/types/asset.ts b/src/renderer/shared/core/types/asset.ts index 8a9cfa5b2c..851e8f6504 100644 --- a/src/renderer/shared/core/types/asset.ts +++ b/src/renderer/shared/core/types/asset.ts @@ -9,7 +9,7 @@ export type Asset = { precision: number; priceId?: string; icon: string; - type?: AssetType; + type: AssetType; typeExtras?: StatemineExtras | OrmlExtras; }; @@ -19,6 +19,7 @@ export const enum StakingType { } export const enum AssetType { + NATIVE = 'native', ORML = 'orml', STATEMINE = 'statemine', } diff --git a/src/renderer/shared/mocks/index.ts b/src/renderer/shared/mocks/index.ts index 091860fc97..9136ee65e0 100644 --- a/src/renderer/shared/mocks/index.ts +++ b/src/renderer/shared/mocks/index.ts @@ -3,6 +3,7 @@ import { createTestKeyring } from '@polkadot/keyring'; import { AccountType, type Asset, + AssetType, type BaseAccount, type Chain, type ChainAccount, @@ -30,6 +31,7 @@ export const dotAsset: Asset = { assetId: 0, symbol: 'DOT', precision: 10, + type: AssetType.NATIVE, icon: 'https://raw.githubusercontent.com/novasamatech/nova-spektr-utils/main/icons/v1/assets/white/Polkadot_(DOT).svg', name: 'Polkadot', };