mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-25 05:17:56 +00:00
feat(frontend): align wUSDT Asset ID with SDK (1000)
This commit aligns the frontend wUSDT implementation with the SDK runtime constants, ensuring consistency across the entire stack. Changes: - Update ASSET_IDS.WUSDT from 2 → 1000 (matches SDK constants) - Add ASSET_CONFIGS with wUSDT configuration (6 decimals, min balance) - Update all asset queries in AccountBalance.tsx to use ASSET_IDS.WUSDT - Update pool queries for wHEZ/wUSDT and PEZ/wUSDT pools - Update USDTBridge.tsx burn transaction to use ASSET_IDS.WUSDT - Refactor usdt.ts to reference ASSET_CONFIGS instead of hardcoded values Asset ID Allocation Strategy: - 0-999: Reserved for protocol tokens (wHEZ, PEZ, etc.) - 1000+: Bridged/wrapped external assets (wUSDT, etc.) Technical Details: - wUSDT uses 6 decimals (USDT standard), not 12 like native HEZ - All frontend code now uses centralized ASSET_CONFIGS - ESLint passes with 0 errors (8 pre-existing warnings unrelated to changes) This is part of Phase 1 wUSDT infrastructure setup, working in parallel with SDK benchmarking builds currently running in background. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -89,15 +89,15 @@ export const AccountBalance: React.FC = () => {
|
||||
const { blake2AsU8a } = await import('@polkadot/util-crypto');
|
||||
const PALLET_ID = stringToU8a('py/ascon');
|
||||
|
||||
// Fetch wHEZ/wUSDT pool reserves (Asset 0 / Asset 2)
|
||||
const whezPoolId = api.createType('(u32, u32)', [0, 2]);
|
||||
// Fetch wHEZ/wUSDT pool reserves (Asset 0 / Asset 1000)
|
||||
const whezPoolId = api.createType('(u32, u32)', [0, 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 whezReserve1Query = await api.query.assets.account(2, whezPoolAccountId);
|
||||
const whezReserve1Query = await api.query.assets.account(ASSET_IDS.WUSDT, whezPoolAccountId);
|
||||
|
||||
if (whezReserve0Query.isSome && whezReserve1Query.isSome) {
|
||||
const reserve0Data = whezReserve0Query.unwrap();
|
||||
@@ -114,15 +114,15 @@ export const AccountBalance: React.FC = () => {
|
||||
if (import.meta.env.DEV) console.warn('⚠️ wHEZ/wUSDT pool has no reserves');
|
||||
}
|
||||
|
||||
// Fetch PEZ/wUSDT pool reserves (Asset 1 / Asset 2)
|
||||
const pezPoolId = api.createType('(u32, u32)', [1, 2]);
|
||||
// Fetch PEZ/wUSDT pool reserves (Asset 1 / Asset 1000)
|
||||
const pezPoolId = api.createType('(u32, u32)', [1, ASSET_IDS.WUSDT]);
|
||||
const pezPalletIdType = api.createType('[u8; 8]', PALLET_ID);
|
||||
const pezFullTuple = api.createType('([u8; 8], (u32, u32))', [pezPalletIdType, pezPoolId]);
|
||||
const pezAccountHash = blake2AsU8a(pezFullTuple.toU8a(), 256);
|
||||
const pezPoolAccountId = api.createType('AccountId32', pezAccountHash);
|
||||
|
||||
const pezReserve0Query = await api.query.assets.account(1, pezPoolAccountId);
|
||||
const pezReserve1Query = await api.query.assets.account(2, pezPoolAccountId);
|
||||
const pezReserve1Query = await api.query.assets.account(ASSET_IDS.WUSDT, pezPoolAccountId);
|
||||
|
||||
if (pezReserve0Query.isSome && pezReserve1Query.isSome) {
|
||||
const reserve0Data = pezReserve0Query.unwrap();
|
||||
@@ -262,9 +262,9 @@ export const AccountBalance: React.FC = () => {
|
||||
setPezBalance('0');
|
||||
}
|
||||
|
||||
// Fetch USDT balance (wUSDT - Asset ID: 2)
|
||||
// Fetch USDT balance (wUSDT - Asset ID: 1000)
|
||||
try {
|
||||
const usdtAssetBalance = await api.query.assets.account(2, selectedAccount.address);
|
||||
const usdtAssetBalance = await api.query.assets.account(ASSET_IDS.WUSDT, selectedAccount.address);
|
||||
|
||||
if (usdtAssetBalance.isSome) {
|
||||
const assetData = usdtAssetBalance.unwrap();
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
formatWUSDT,
|
||||
} from '@pezkuwi/lib/usdt';
|
||||
import { isMultisigMember } from '@pezkuwi/lib/multisig';
|
||||
import { ASSET_IDS } from '@pezkuwi/lib/wallet';
|
||||
|
||||
interface USDTBridgeProps {
|
||||
isOpen: boolean;
|
||||
@@ -115,7 +116,7 @@ export const USDTBridge: React.FC<USDTBridgeProps> = ({
|
||||
|
||||
// Burn wUSDT
|
||||
const amountBN = BigInt(Math.floor(amount * 1e6)); // 6 decimals
|
||||
const burnTx = api.tx.assets.burn(2, selectedAccount.address, amountBN.toString());
|
||||
const burnTx = api.tx.assets.burn(ASSET_IDS.WUSDT, selectedAccount.address, amountBN.toString());
|
||||
|
||||
await burnTx.signAndSend(selectedAccount.address, { signer: injector.signer }, ({ status }) => {
|
||||
if (status.isFinalized) {
|
||||
|
||||
Reference in New Issue
Block a user