import { Keplr } from "@keplr-wallet/types" ; export const getKeplrFromWindow = async ( ) => { if ( window . keplr ) { return window . keplr ; } if ( document . readyState === "complete" ) { return window . keplr ; } return new Promise ( ( resolve ) => { const documentStateChange = ( event ) => { if ( event . target && ( event . target as Document ) . readyState === "complete" ) { resolve ( window . keplr ) ; document . removeEventListener ( "readystatechange" , documentStateChange ) ; } } ; document . addEventListener ( "readystatechange" , documentStateChange ) ; } ) ; } ;