diff --git a/package.json b/package.json
index 8c7a426..62d4d71 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pezkuwi-telegram-miniapp",
- "version": "1.0.233",
+ "version": "1.0.235",
"type": "module",
"description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards",
"author": "Pezkuwichain Team",
@@ -13,7 +13,7 @@
"build:patch": "node scripts/bump-version.mjs patch && tsc && vite build",
"build:no-bump": "tsc && vite build",
"preview": "vite preview",
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 30",
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint . --ext ts,tsx --fix",
"format": "prettier --write \"src/**/*.{ts,tsx,css}\"",
"typecheck": "tsc --noEmit",
diff --git a/src/components/p2p/DepositWithdrawModal.tsx b/src/components/p2p/DepositWithdrawModal.tsx
index 6dff4b9..8874f4d 100644
--- a/src/components/p2p/DepositWithdrawModal.tsx
+++ b/src/components/p2p/DepositWithdrawModal.tsx
@@ -79,6 +79,9 @@ export function DepositWithdrawModal({
const handleDeposit = async () => {
if (!sessionToken || !depositAmount || !assetHubApi || !keypair) return;
+ // Capture the guaranteed-non-null API so the narrowing survives inside the
+ // async signAndSend callback below (TS loses it across the closure boundary).
+ const api = assetHubApi;
const amount = parseFloat(depositAmount);
if (isNaN(amount) || amount <= 0) {
@@ -120,7 +123,7 @@ export function DepositWithdrawModal({
async (result: any) => {
if (result.dispatchError) {
if (result.dispatchError.isModule) {
- const decoded = assetHubApi!.registry.findMetaError(result.dispatchError.asModule);
+ const decoded = api.registry.findMetaError(result.dispatchError.asModule);
reject(new Error(`${decoded.section}.${decoded.name}`));
} else {
reject(new Error(result.dispatchError.toString()));
@@ -130,7 +133,7 @@ export function DepositWithdrawModal({
if (result.status.isFinalized) {
try {
// Get block number from finalized block hash for fast verification
- const header = await assetHubApi!.rpc.chain.getHeader(result.status.asFinalized);
+ const header = await api.rpc.chain.getHeader(result.status.asFinalized);
resolve({
txHash: result.txHash.toHex(),
blockNumber: header.number.toNumber(),
diff --git a/src/components/wallet/FundFeesModal.tsx b/src/components/wallet/FundFeesModal.tsx
index 470f6c7..cc29c63 100644
--- a/src/components/wallet/FundFeesModal.tsx
+++ b/src/components/wallet/FundFeesModal.tsx
@@ -424,9 +424,7 @@ export function FundFeesModal({ isOpen, onClose }: Props) {
}`}
/>
{chain.name}
-
- {t(chain.description as any)}
-
+ {t(chain.description)}
))}
@@ -505,7 +503,7 @@ export function FundFeesModal({ isOpen, onClose }: Props) {
targetChain === 'asset-hub' ? 'text-blue-400' : 'text-purple-400'
}`}
>
- {t('fees.minRecommended', { description: t(selectedChain.description as any) })}
+ {t('fees.minRecommended', { description: t(selectedChain.description) })}
diff --git a/src/components/wallet/HEZStakingModal.tsx b/src/components/wallet/HEZStakingModal.tsx
index b5a2e5f..b681acc 100644
--- a/src/components/wallet/HEZStakingModal.tsx
+++ b/src/components/wallet/HEZStakingModal.tsx
@@ -133,6 +133,10 @@ export function HEZStakingModal({ isOpen, onClose }: HEZStakingModalProps) {
} finally {
setIsLoading(false);
}
+ // `t` is intentionally omitted: it is only used for error messages and its
+ // identity changes only on language switch — including it would re-run the
+ // blockchain fetch (extra RPC calls) on every language change.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [assetHubApi, address]);
useEffect(() => {
diff --git a/src/components/wallet/LPStakingModal.tsx b/src/components/wallet/LPStakingModal.tsx
index d036c88..153ff90 100644
--- a/src/components/wallet/LPStakingModal.tsx
+++ b/src/components/wallet/LPStakingModal.tsx
@@ -179,6 +179,10 @@ export function LPStakingModal({ isOpen, onClose }: LPStakingModalProps) {
};
fetchPools();
+ // `t` is intentionally omitted: it is only used for error messages and its
+ // identity changes only on language switch — including it would re-run the
+ // blockchain fetch (extra RPC calls) on every language change.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [assetHubApi, isOpen, address, selectedPool]);
const formatAmount = (amount: string, decimals: number = 12): string => {
diff --git a/src/components/wallet/PoolsModal.tsx b/src/components/wallet/PoolsModal.tsx
index 90c649a..cde404e 100644
--- a/src/components/wallet/PoolsModal.tsx
+++ b/src/components/wallet/PoolsModal.tsx
@@ -50,6 +50,26 @@ const formatAssetLocation = (id: number) => {
return { parents: 0, interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: id }] } };
};
+// Minimal shapes for the dynamic @pezkuwi/api results we read here. These
+// pallets/runtime-calls are not in the base typings, so we describe just the
+// fields actually used and cast via `as unknown as`.
+type AccountInfoResult = { data: { free: { toString(): string } } };
+type AssetAccountResult = {
+ isSome: boolean;
+ unwrap(): { balance: { toString(): string } };
+};
+type QuoteResult = { isNone: boolean; unwrap(): { toString(): string } };
+type AssetConversionCall = {
+ assetConversionApi: {
+ quotePriceExactTokensForTokens: (
+ asset0: ReturnType,
+ asset1: ReturnType,
+ amount: string,
+ includeFee: boolean
+ ) => Promise;
+ };
+};
+
export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
const { assetHubApi, keypair } = useWallet();
const { hapticImpact, hapticNotification } = useTelegram();
@@ -104,17 +124,17 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
// Fetch HEZ balance from Asset Hub (native token)
const hezAccount = (await withTimeout(
- (assetHubApi.query.system as any).account(keypair.address),
+ assetHubApi.query.system.account(keypair.address),
10000
- )) as any;
+ )) as unknown as AccountInfoResult;
if (isCancelled) return;
const hezFree = hezAccount.data.free.toString();
setBalances((prev) => ({ ...prev, HEZ: (parseInt(hezFree) / 1e12).toFixed(4) }));
const pezResult = (await withTimeout(
- (assetHubApi.query.assets as any).account(1, keypair.address),
+ assetHubApi.query.assets.account(1, keypair.address),
10000
- )) as any;
+ )) as unknown as AssetAccountResult;
if (isCancelled) return;
if (pezResult.isSome) {
setBalances((prev) => ({
@@ -126,9 +146,9 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
}
const usdtResult = (await withTimeout(
- (assetHubApi.query.assets as any).account(1000, keypair.address),
+ assetHubApi.query.assets.account(1000, keypair.address),
10000
- )) as any;
+ )) as unknown as AssetAccountResult;
if (isCancelled) return;
if (usdtResult.isSome) {
setBalances((prev) => ({
@@ -175,7 +195,9 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
const oneUnit = BigInt(Math.pow(10, token0.decimals));
const quote = await withTimeout(
- (assetHubApi.call as any).assetConversionApi.quotePriceExactTokensForTokens(
+ (
+ assetHubApi.call as unknown as AssetConversionCall
+ ).assetConversionApi.quotePriceExactTokensForTokens(
formatAssetLocation(asset0),
formatAssetLocation(asset1),
oneUnit.toString(),
@@ -184,11 +206,8 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
10000
);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- if (quote && !(quote as any).isNone) {
- price =
- Number(BigInt((quote as any).unwrap().toString())) /
- Math.pow(10, token1.decimals);
+ if (quote && !quote.isNone) {
+ price = Number(BigInt(quote.unwrap().toString())) / Math.pow(10, token1.decimals);
// Estimate reserves from LP supply
const lpAsset = await withTimeout(
@@ -283,6 +302,10 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
return () => {
isCancelled = true;
};
+ // `t` is intentionally omitted: it is only used for error messages and its
+ // identity changes only on language switch — including it would re-run the
+ // blockchain fetch (extra RPC calls) on every language change.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen, assetHubApi, keypair]);
// Auto-calculate amount1 based on pool price
@@ -326,28 +349,36 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
keypair.address
);
+ // Minimal shape of the signAndSend result fields we read. `asModule`
+ // is typed from the registry call so it stays type-safe.
+ type TxResult = {
+ status: { isFinalized: boolean };
+ dispatchError?: {
+ isModule: boolean;
+ asModule: Parameters[0];
+ toString(): string;
+ };
+ };
+
// Wait for transaction to be finalized
await new Promise((resolve, reject) => {
- tx.signAndSend(
- keypair,
- ({ status, dispatchError }: { status: any; dispatchError: any }) => {
- if (status.isFinalized) {
- if (dispatchError) {
- let errorMsg = t('pools.addFailed');
- if (dispatchError.isModule) {
- const decoded = assetHubApi.registry.findMetaError(dispatchError.asModule);
- errorMsg = `${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`;
- } else if (dispatchError.toString) {
- errorMsg = dispatchError.toString();
- }
- console.error('Add liquidity error:', errorMsg);
- reject(new Error(errorMsg));
- } else {
- resolve();
+ tx.signAndSend(keypair, ({ status, dispatchError }: TxResult) => {
+ if (status.isFinalized) {
+ if (dispatchError) {
+ let errorMsg = t('pools.addFailed');
+ if (dispatchError.isModule) {
+ const decoded = assetHubApi.registry.findMetaError(dispatchError.asModule);
+ errorMsg = `${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`;
+ } else if (dispatchError.toString) {
+ errorMsg = dispatchError.toString();
}
+ console.error('Add liquidity error:', errorMsg);
+ reject(new Error(errorMsg));
+ } else {
+ resolve();
}
}
- ).catch(reject);
+ }).catch(reject);
});
setSuccessMessage(
@@ -420,28 +451,36 @@ export function PoolsModal({ isOpen, onClose }: PoolsModalProps) {
keypair.address
);
+ // Minimal shape of the signAndSend result fields we read. `asModule`
+ // is typed from the registry call so it stays type-safe.
+ type TxResult = {
+ status: { isFinalized: boolean };
+ dispatchError?: {
+ isModule: boolean;
+ asModule: Parameters[0];
+ toString(): string;
+ };
+ };
+
// Wait for transaction to be finalized
await new Promise((resolve, reject) => {
- tx.signAndSend(
- keypair,
- ({ status, dispatchError }: { status: any; dispatchError: any }) => {
- if (status.isFinalized) {
- if (dispatchError) {
- let errorMsg = t('pools.removeFailed');
- if (dispatchError.isModule) {
- const decoded = assetHubApi.registry.findMetaError(dispatchError.asModule);
- errorMsg = `${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`;
- } else if (dispatchError.toString) {
- errorMsg = dispatchError.toString();
- }
- console.error('Remove liquidity error:', errorMsg);
- reject(new Error(errorMsg));
- } else {
- resolve();
+ tx.signAndSend(keypair, ({ status, dispatchError }: TxResult) => {
+ if (status.isFinalized) {
+ if (dispatchError) {
+ let errorMsg = t('pools.removeFailed');
+ if (dispatchError.isModule) {
+ const decoded = assetHubApi.registry.findMetaError(dispatchError.asModule);
+ errorMsg = `${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`;
+ } else if (dispatchError.toString) {
+ errorMsg = dispatchError.toString();
}
+ console.error('Remove liquidity error:', errorMsg);
+ reject(new Error(errorMsg));
+ } else {
+ resolve();
}
}
- ).catch(reject);
+ }).catch(reject);
});
setSuccessMessage(t('pools.removedLiquidity', { amount: lpAmountToRemove }));
diff --git a/src/components/wallet/SwapModal.tsx b/src/components/wallet/SwapModal.tsx
index 66e5bc3..403df85 100644
--- a/src/components/wallet/SwapModal.tsx
+++ b/src/components/wallet/SwapModal.tsx
@@ -74,10 +74,25 @@ export function SwapModal({ isOpen, onClose }: SwapModalProps) {
const hezFree = hezAccount.data.free.toString();
const hezBalance = (parseInt(hezFree) / 1e12).toFixed(4);
- // Helper to extract balance from asset query result
- const getAssetBalance = (result: any, decimals: number, fractionDigits: number): string => {
+ // Helper to extract balance from an asset storage query result. The
+ // shape is the subset of the @pezkuwi/api Option/Codec result we read.
+ type AssetQueryResult = {
+ isEmpty: boolean;
+ isSome?: boolean;
+ unwrap?: () => { toJSON(): unknown };
+ toJSON(): unknown;
+ };
+ const getAssetBalance = (
+ result: AssetQueryResult | null,
+ decimals: number,
+ fractionDigits: number
+ ): string => {
if (!result || result.isEmpty) return '0'.padEnd(fractionDigits + 2, '0');
- const data = result.isSome ? result.unwrap().toJSON() : result.toJSON();
+ const data = (
+ result.isSome && result.unwrap ? result.unwrap().toJSON() : result.toJSON()
+ ) as {
+ balance?: { toString(): string };
+ } | null;
if (data && data.balance) {
return (parseInt(data.balance.toString()) / Math.pow(10, decimals)).toFixed(
fractionDigits
@@ -155,8 +170,21 @@ export function SwapModal({ isOpen, onClose }: SwapModalProps) {
const decimals2 = getDecimals(asset2);
const oneUnit = BigInt(Math.pow(10, decimals1));
+ // assetConversionApi is a runtime API not present in the base
+ // @pezkuwi/api typings; describe just the call we use.
+ type QuoteResult = { isNone: boolean; unwrap(): { toString(): string } };
+ type AssetConversionCall = {
+ assetConversionApi: {
+ quotePriceExactTokensForTokens: (
+ asset1: ReturnType,
+ asset2: ReturnType,
+ amount: string,
+ includeFee: boolean
+ ) => Promise;
+ };
+ };
const quote = await (
- assetHubApi.call as any
+ assetHubApi.call as unknown as AssetConversionCall
).assetConversionApi.quotePriceExactTokensForTokens(
formatAssetLocation(asset1),
formatAssetLocation(asset2),
@@ -257,28 +285,38 @@ export function SwapModal({ isOpen, onClose }: SwapModalProps) {
true
);
+ // Minimal shape of the signAndSend result fields we read (the full
+ // @pezkuwi/api ISubmittableResult is unavailable because `tx` above is
+ // produced from an untyped runtime extrinsic).
+ type SwapDispatchError = {
+ isModule: boolean;
+ asModule: Parameters[0];
+ toString(): string;
+ };
+ type SwapTxResult = {
+ status: { isFinalized: boolean };
+ dispatchError?: SwapDispatchError;
+ };
+
// Wait for transaction to be finalized
await new Promise((resolve, reject) => {
- tx.signAndSend(
- keypair,
- ({ status, dispatchError }: { status: any; dispatchError: any }) => {
- if (status.isFinalized) {
- if (dispatchError) {
- let errorMsg = t('swap.swapFailed');
- if (dispatchError.isModule) {
- const decoded = assetHubApi.registry.findMetaError(dispatchError.asModule);
- errorMsg = `${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`;
- } else if (dispatchError.toString) {
- errorMsg = dispatchError.toString();
- }
- console.error('Swap error:', errorMsg);
- reject(new Error(errorMsg));
- } else {
- resolve();
+ tx.signAndSend(keypair, ({ status, dispatchError }: SwapTxResult) => {
+ if (status.isFinalized) {
+ if (dispatchError) {
+ let errorMsg = t('swap.swapFailed');
+ if (dispatchError.isModule) {
+ const decoded = assetHubApi.registry.findMetaError(dispatchError.asModule);
+ errorMsg = `${decoded.section}.${decoded.name}: ${decoded.docs.join(' ')}`;
+ } else if (dispatchError.toString) {
+ errorMsg = dispatchError.toString();
}
+ console.error('Swap error:', errorMsg);
+ reject(new Error(errorMsg));
+ } else {
+ resolve();
}
}
- ).catch(reject);
+ }).catch(reject);
});
setSuccess(true);
diff --git a/src/components/wallet/WalletDashboard.tsx b/src/components/wallet/WalletDashboard.tsx
index 0849e7e..7abc57b 100644
--- a/src/components/wallet/WalletDashboard.tsx
+++ b/src/components/wallet/WalletDashboard.tsx
@@ -1103,14 +1103,23 @@ function SendTab({ onBack }: { onBack: () => void }) {
let tx;
if (selectedToken === 'HEZ') {
- // HEZ transfer on main chain
+ // HEZ transfer on main chain (api guaranteed by the guard above, but
+ // narrow again here so TS knows it is non-null in this branch).
+ if (!api) {
+ setError(t('send.mainnetApiNotReady'));
+ return;
+ }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- tx = (api!.tx.balances as any).transferKeepAlive(toAddress, amountInSmallestUnit);
+ tx = (api.tx.balances as any).transferKeepAlive(toAddress, amountInSmallestUnit);
} else {
// Asset transfer on Asset Hub (PEZ: asset ID 1, USDT: asset ID 1000)
+ if (!assetHubApi) {
+ setError(t('send.assetHubApiNotReady'));
+ return;
+ }
const assetId = tokenInfo?.assetId ?? 1;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- tx = (assetHubApi!.tx.assets as any).transfer(assetId, toAddress, amountInSmallestUnit);
+ tx = (assetHubApi.tx.assets as any).transfer(assetId, toAddress, amountInSmallestUnit);
}
const hash = await tx.signAndSend(keypair);
diff --git a/src/lib/referral.ts b/src/lib/referral.ts
index 8e8db78..982833b 100644
--- a/src/lib/referral.ts
+++ b/src/lib/referral.ts
@@ -73,7 +73,9 @@ export async function getPendingReferral(api: ApiPromise, address: string): Prom
try {
// Check if referral pallet exists
if (!isReferralPalletAvailable(api)) {
- console.log('Referral pallet not available on this chain');
+ if (import.meta.env.DEV) {
+ console.warn('Referral pallet not available on this chain');
+ }
return null;
}
diff --git a/src/lib/scores.ts b/src/lib/scores.ts
index 2d4c33b..a3855df 100644
--- a/src/lib/scores.ts
+++ b/src/lib/scores.ts
@@ -306,27 +306,33 @@ const TIKI_NAME_SCORES: Record = {
* Storage: tiki.userTikis(address) -> Vec
*/
export async function fetchUserTikis(peopleApi: ApiPromise, address: string): Promise {
+ // The `tiki` pallet is not part of the base @pezkuwi/api typings, so we
+ // describe just the storage entries we read here.
+ type TikiStorageResult = { isEmpty: boolean; toJSON(): unknown };
+ type TikiQuery = {
+ userTikis?: (address: string) => Promise;
+ userRoles?: (address: string) => Promise;
+ };
+ type TikiEntry = string | { name?: string; role?: string };
+
try {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- if (!(peopleApi?.query as any)?.tiki) {
+ const tikiQuery = (peopleApi?.query as { tiki?: TikiQuery } | undefined)?.tiki;
+ if (!tikiQuery) {
return [];
}
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- let result = await (peopleApi.query.tiki as any).userTikis?.(address);
+ let result = await tikiQuery.userTikis?.(address);
// Fallback to userRoles if userTikis doesn't exist
- if (!result && (peopleApi.query.tiki as any).userRoles) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- result = await (peopleApi.query.tiki as any).userRoles?.(address);
+ if (!result && tikiQuery.userRoles) {
+ result = await tikiQuery.userRoles?.(address);
}
if (!result || result.isEmpty) {
return [];
}
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const tikis = result.toJSON() as any[];
+ const tikis = result.toJSON() as TikiEntry[];
return tikis.map((tiki, index) => {
const name = typeof tiki === 'string' ? tiki : tiki.name || tiki.role || 'Unknown';
diff --git a/src/main.tsx b/src/main.tsx
index 64cc83e..42d6521 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -9,13 +9,16 @@ import { LanguageProvider } from './i18n';
import App from './App';
import './index.css';
-// Suppress console logs in production
+// Suppress non-critical console output in production. This is the one place
+// that legitimately overrides console.log/debug/info — warn/error are kept for
+// critical issues. The no-console rule is disabled only for these assignments.
if (import.meta.env.PROD) {
const noop = () => {};
- console.log = noop;
- console.debug = noop;
- console.info = noop;
- // Keep console.warn and console.error for critical issues
+ const suppressed: Array<'log' | 'debug' | 'info'> = ['log', 'debug', 'info'];
+ for (const method of suppressed) {
+ // eslint-disable-next-line no-console
+ console[method] = noop;
+ }
}
// Initialize Telegram WebApp