mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-12 21:21:02 +00:00
fix: suppress API/INIT and REGISTRY warnings in production
Added warning suppression at main.tsx entry point to catch Polkadot.js warnings before any API imports load.
This commit is contained in:
@@ -1,20 +1,26 @@
|
|||||||
import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';
|
// Suppress noisy Polkadot.js API warnings in production
|
||||||
import { ApiPromise, WsProvider } from '@pezkuwi/api';
|
// Must be at the very top before any imports that might trigger warnings
|
||||||
|
if (typeof window !== 'undefined' && !import.meta.env.DEV) {
|
||||||
// Suppress noisy API warnings in production (RPC methods not decorated, unknown signed extensions)
|
|
||||||
if (!import.meta.env.DEV) {
|
|
||||||
const originalWarn = console.warn;
|
const originalWarn = console.warn;
|
||||||
|
const suppressedPatterns = [
|
||||||
|
'RPC methods not decorated',
|
||||||
|
'Unknown signed extensions',
|
||||||
|
'API/INIT:',
|
||||||
|
'REGISTRY:',
|
||||||
|
'StorageWeightReclaim',
|
||||||
|
];
|
||||||
|
|
||||||
console.warn = (...args: unknown[]) => {
|
console.warn = (...args: unknown[]) => {
|
||||||
const msg = args[0];
|
const msg = String(args[0] || '');
|
||||||
if (typeof msg === 'string' && (
|
if (suppressedPatterns.some(pattern => msg.includes(pattern))) {
|
||||||
msg.includes('RPC methods not decorated') ||
|
|
||||||
msg.includes('Unknown signed extensions')
|
|
||||||
)) {
|
|
||||||
return; // Suppress these specific warnings
|
return; // Suppress these specific warnings
|
||||||
}
|
}
|
||||||
originalWarn.apply(console, args);
|
originalWarn.apply(console, args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';
|
||||||
|
import { ApiPromise, WsProvider } from '@pezkuwi/api';
|
||||||
import { web3Accounts, web3Enable } from '@pezkuwi/extension-dapp';
|
import { web3Accounts, web3Enable } from '@pezkuwi/extension-dapp';
|
||||||
import type { InjectedAccountWithMeta } from '@pezkuwi/extension-inject/types';
|
import type { InjectedAccountWithMeta } from '@pezkuwi/extension-inject/types';
|
||||||
import { DEFAULT_ENDPOINT } from '../../../shared/blockchain/pezkuwi';
|
import { DEFAULT_ENDPOINT } from '../../../shared/blockchain/pezkuwi';
|
||||||
|
|||||||
@@ -1,3 +1,24 @@
|
|||||||
|
// Suppress noisy Polkadot.js API warnings in production
|
||||||
|
// Must be at the very top before any imports
|
||||||
|
if (typeof window !== 'undefined' && import.meta.env.PROD) {
|
||||||
|
const originalWarn = console.warn;
|
||||||
|
const suppressedPatterns = [
|
||||||
|
'RPC methods not decorated',
|
||||||
|
'Unknown signed extensions',
|
||||||
|
'API/INIT:',
|
||||||
|
'REGISTRY:',
|
||||||
|
'StorageWeightReclaim',
|
||||||
|
];
|
||||||
|
|
||||||
|
console.warn = (...args: unknown[]) => {
|
||||||
|
const msg = String(args[0] || '');
|
||||||
|
if (suppressedPatterns.some(pattern => msg.includes(pattern))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
originalWarn.apply(console, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import App from './App.tsx'
|
import App from './App.tsx'
|
||||||
import './index.css'
|
import './index.css'
|
||||||
|
|||||||
Reference in New Issue
Block a user