/** * Polyfill crypto.getRandomValues for React Native environments. * * This runs once at SDK import time, before tweetnacl, @solana/web3.js, * uuid, jayson, or any other dependency tries to use crypto. * * Must be imported as the very first line in src/index.ts. */ import { getRandomValues } from 'expo-crypto'; if (typeof global !== 'undefined') { if (typeof global.crypto !== 'object') { (global as any).crypto = {}; } if (typeof global.crypto.getRandomValues !== 'function') { (global.crypto as any).getRandomValues = getRandomValues; } } // Also polyfill `self` so tweetnacl's init finds crypto via self.crypto if (typeof self === 'undefined' && typeof globalThis !== 'undefined') { (globalThis as any).self = globalThis; }