From db381c803deaa62f1147916f323d3a60b6bddd27 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Wed, 4 Feb 2026 13:52:47 +0300 Subject: [PATCH] fix: correct wHEZ asset ID from 0 to 2 tokenWrapper pallet on Asset Hub creates wHEZ as Asset ID 2, not 0. Asset IDs on Asset Hub: - Asset 1: PEZ - Asset 2: wHEZ (via tokenWrapper) - Asset 1000: wUSDT Updated: - shared/constants/index.ts: KNOWN_TOKENS - shared/lib/wallet.ts: ASSET_IDS.WHEZ default - AccountBalance.tsx: pool queries - InitializeHezPoolModal.tsx: balance query --- shared/constants/index.ts | 11 ++++++++--- shared/lib/wallet.ts | 11 ++++++----- web/src/components/AccountBalance.tsx | 4 ++-- web/src/components/dex/InitializeHezPoolModal.tsx | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/shared/constants/index.ts b/shared/constants/index.ts index 32fdc248..59fb739b 100644 --- a/shared/constants/index.ts +++ b/shared/constants/index.ts @@ -47,11 +47,16 @@ export const KURDISTAN_COLORS = { } as const; /** - * Known tokens on the Pezkuwi blockchain + * Known tokens on the Pezkuwi blockchain (Asset Hub) + * + * Asset IDs on Asset Hub: + * - Asset 1: PEZ (Pezkuwi Token) + * - Asset 2: wHEZ (Wrapped HEZ via tokenWrapper) + * - Asset 1000: wUSDT (Wrapped USDT) */ export const KNOWN_TOKENS: Record = { - 0: { - id: 0, + 2: { + id: 2, symbol: 'wHEZ', name: 'Wrapped HEZ', decimals: 12, diff --git a/shared/lib/wallet.ts b/shared/lib/wallet.ts index fe365eb3..67dc784f 100644 --- a/shared/lib/wallet.ts +++ b/shared/lib/wallet.ts @@ -32,16 +32,17 @@ export const CHAIN_CONFIG = { }; // ======================================== -// SUBSTRATE ASSET IDs (Assets Pallet) +// SUBSTRATE ASSET IDs (Assets Pallet on Asset Hub) // ======================================== // ⚠️ IMPORTANT: HEZ is the native token and does NOT have an Asset ID // Only wrapped/asset tokens are listed here // -// Asset ID Allocation: -// - 0-999: Reserved for protocol tokens (wHEZ, PEZ, etc.) -// - 1000+: Bridged/wrapped external assets (wUSDT, etc.) +// Asset ID Allocation on Asset Hub: +// - Asset 1: PEZ (Pezkuwi Token) +// - Asset 2: wHEZ (Wrapped HEZ via tokenWrapper pallet) +// - Asset 1000: wUSDT (Wrapped USDT) export const ASSET_IDS = { - WHEZ: parseInt(getEnv('VITE_ASSET_WHEZ', '0')), // Wrapped HEZ + WHEZ: parseInt(getEnv('VITE_ASSET_WHEZ', '2')), // Wrapped HEZ (tokenWrapper creates Asset 2) PEZ: parseInt(getEnv('VITE_ASSET_PEZ', '1')), // PEZ utility token WUSDT: parseInt(getEnv('VITE_ASSET_WUSDT', '1000')), // Wrapped USDT (6 decimals, Asset ID 1000) USDT: parseInt(getEnv('VITE_ASSET_USDT', '3')), diff --git a/web/src/components/AccountBalance.tsx b/web/src/components/AccountBalance.tsx index f771676f..db1c63ef 100644 --- a/web/src/components/AccountBalance.tsx +++ b/web/src/components/AccountBalance.tsx @@ -175,13 +175,13 @@ export const AccountBalance: React.FC = () => { // Only fetch HEZ from DEX if not already set if (hezPrice === 0) { - const whezPoolId = api.createType('(u32, u32)', [0, ASSET_IDS.WUSDT]); + const whezPoolId = api.createType('(u32, u32)', [ASSET_IDS.WHEZ, ASSET_IDS.WUSDT]); const whezPalletIdType = api.createType('[u8; 8]', PALLET_ID); const whezFullTuple = api.createType('([u8; 8], (u32, u32))', [whezPalletIdType, whezPoolId]); const whezAccountHash = blake2AsU8a(whezFullTuple.toU8a(), 256); const whezPoolAccountId = api.createType('AccountId32', whezAccountHash); - const whezReserve0Query = await api.query.assets.account(0, whezPoolAccountId); + const whezReserve0Query = await api.query.assets.account(ASSET_IDS.WHEZ, whezPoolAccountId); const whezReserve1Query = await api.query.assets.account(ASSET_IDS.WUSDT, whezPoolAccountId); if (whezReserve0Query.isSome && whezReserve1Query.isSome) { diff --git a/web/src/components/dex/InitializeHezPoolModal.tsx b/web/src/components/dex/InitializeHezPoolModal.tsx index 73e73f62..3512be15 100644 --- a/web/src/components/dex/InitializeHezPoolModal.tsx +++ b/web/src/components/dex/InitializeHezPoolModal.tsx @@ -85,8 +85,8 @@ export const InitializeHezPoolModal: React.FC = ({ const freeBalance = balance.data.free.toString(); setHezBalance(freeBalance); - // wHEZ balance (asset 0 on Asset Hub) - const whezData = await assetHubApi.query.assets.account(0, account); + // wHEZ balance (asset 2 on Asset Hub - tokenWrapper creates asset 2) + const whezData = await assetHubApi.query.assets.account(2, account); setWhezBalance(whezData.isSome ? whezData.unwrap().balance.toString() : '0'); } catch (error) { if (import.meta.env.DEV) console.error('Failed to fetch balances from Asset Hub:', error);