2025-03-04 17:53:05 +01:00
|
|
|
// Polyfills for Node.js built-ins
|
|
|
|
|
import { Buffer } from 'buffer';
|
|
|
|
|
import process from 'process';
|
|
|
|
|
import 'isomorphic-fetch';
|
|
|
|
|
|
|
|
|
|
window.Buffer = Buffer;
|
|
|
|
|
window.process = process;
|
|
|
|
|
window.global = window;
|
|
|
|
|
|
|
|
|
|
// For ethers.js
|
|
|
|
|
window.process.version = ''; // Fake Node.js version
|
|
|
|
|
window.process.env = window.process.env || {};
|
|
|
|
|
|
|
|
|
|
// Add any missing fetch polyfill
|
|
|
|
|
if (!window.fetch) {
|
|
|
|
|
console.warn('Fetch API is not available, using polyfill');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-24 15:48:07 +07:00
|
|
|
if (typeof window.crypto === 'undefined' || typeof window.crypto.getRandomValues !== 'function') {
|
|
|
|
|
throw new Error('crypto.getRandomValues is required for secure account and signature operations.');
|
2025-03-04 17:53:05 +01:00
|
|
|
}
|