graz 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +38 -38
- package/dist/index.mjs +2 -2
- package/package.json +2 -12
package/dist/index.d.mts
CHANGED
|
@@ -131,7 +131,6 @@ interface ChainConfig {
|
|
|
131
131
|
}
|
|
132
132
|
interface ParaGrazConfig extends ParaGrazConfig$1 {
|
|
133
133
|
connectorClass?: new (config: ParaGrazConfig, chains?: ChainInfo[] | null) => ParaGrazConnector;
|
|
134
|
-
connectorImportPath?: string;
|
|
135
134
|
}
|
|
136
135
|
interface WalletConnectStore {
|
|
137
136
|
options: SignClientTypes.Options | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -131,7 +131,6 @@ interface ChainConfig {
|
|
|
131
131
|
}
|
|
132
132
|
interface ParaGrazConfig extends ParaGrazConfig$1 {
|
|
133
133
|
connectorClass?: new (config: ParaGrazConfig, chains?: ChainInfo[] | null) => ParaGrazConnector;
|
|
134
|
-
connectorImportPath?: string;
|
|
135
134
|
}
|
|
136
135
|
interface WalletConnectStore {
|
|
137
136
|
options: SignClientTypes.Options | null;
|
package/dist/index.js
CHANGED
|
@@ -21,24 +21,24 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
21
21
|
|
|
22
22
|
var Ee__default = /*#__PURE__*/_interopDefault(Ee);
|
|
23
23
|
|
|
24
|
-
var Nt=Object.defineProperty,Bt=Object.defineProperties;var Lt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Be=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Le=(e,t,n)=>t in e?Nt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))Ut.call(t,n)&&Le(e,n,t[n]);if(Ne)for(var n of Ne(t))Gt.call(t,n)&&Le(e,n,t[n]);return e},U=(e,t)=>Bt(e,Lt(t));var l=(e,t,n)=>new Promise((a,i)=>{var o=c=>{try{r(n.next(c));}catch(f){i(f);}},s=c=>{try{r(n.throw(c));}catch(f){i(f);}},r=c=>c.done?a(c.value):Promise.resolve(c.value).then(o,s);r((n=n.apply(e,t)).next());});var Ue=(e,t,n)=>(t=e[Be("asyncIterator")])?t.call(e):(e=e[Be("iterator")](),t={},n=(a,i)=>(i=e[a])&&(t[a]=o=>new Promise((s,r,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(f=>s({value:f,done:c}),r)))),n("next"),n("return"),t);var ee="graz-reconnect-session";var Ge=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p.PARA="para",p))(Ge||{}),Fe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var zt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:middleware.createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},C=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,qt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>zt,jt)));var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var Ve={},He=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var m;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let r=(m=o.split("MetaMask/v")[1])==null?void 0:m.split(".")[0];if(!(Number(r)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,true}),enable:o=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(U(P({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,r)=>l(void 0,null,function*(){return t.signAmino(o,s,r)}),getKey:o=>l(void 0,null,function*(){return typeof Ve[o]!="undefined"?Ve[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,r)=>l(void 0,null,function*(){return t.signDirect(o,s,r)}),signArbitrary:(o,s,r)=>l(void 0,null,function*(){return t.signArbitrary(o,s,r)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{N(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Zt=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}=e;if(!t||!n||!a||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}},en=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Ye=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let T=(()=>{switch(S.algo){case "secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return amino.rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:en(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:T,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,T,M;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(T=g.gasPriceStep)==null?void 0:T.average,high_gas_price:(M=g.gasPriceStep)==null?void 0:M.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,T]=d;return e.getOfflineSigner(g).signDirect(S,Zt(T))},signAmino:(...d)=>{let[g,S,T]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,T)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let W=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!W)throw new Error(`Wallet not connected to account ${g}`);let O=(()=>{switch(W.algo){case "secp256k1":return amino.encodeSecp256k1Pubkey(W.pubkey);case "ed25519":return amino.encodeEd25519Pubkey(W.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:W.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:d=>{let g=()=>{N(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var me={},Ze=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=p=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(b=>b.id===e.id&&(!p||b.version===p))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var R;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(R=p.split("MetaMask/v")[1])==null?void 0:R.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield i()),true}),s=p=>l(void 0,null,function*(){(yield a())||(yield i());}),r=(p,A,b)=>l(void 0,null,function*(){let k=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:b}}}}),K=b.accountNumber,R=new Ee__default.default(K.low,K.high,K.unsigned);return {signature:k.signature,signed:U(P({},k.signed),{accountNumber:`${R.toString()}`,authInfoBytes:new Uint8Array(Object.values(k.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(k.signed.bodyBytes))})}}),c=(p,A,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:b}}}})}),f=p=>l(void 0,null,function*(){if(typeof me[p]!="undefined")return me[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,me[p]=A,me[p]}),m=p=>l(void 0,null,function*(){let A=yield f(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[A,b,k,K]=p;return yield c(A,b,k)}),g=(...p)=>l(void 0,null,function*(){var Q;let[A,b,k]=p,K=U(P({},k),{accountNumber:Ee__default.default.fromString(((Q=k.accountNumber)==null?void 0:Q.toString())||"0"),authInfoBytes:k.authInfoBytes,bodyBytes:k.bodyBytes});return yield r(A,b,K)}),T=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signAmino:(A,b)=>d(p,A,b)});return {enable:s,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signDirect:(A,b)=>g(p,A,b),signAmino:(A,b)=>d(p,A,b)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return T(p)}),getOfflineSignerOnlyAmino:T,init:o,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var et=()=>Ze({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var r;let s=()=>{N(),o();};return (r=window.okxwallet)==null||r.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var tn="para.reconnect",ie=null,tt=()=>{let e=()=>{let i=C.getState().paraConnector;if(!i)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return i},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let n=()=>ie||(ie=l(void 0,null,function*(){let i=C.getState().paraConnector;if(i)return i;try{let o;if(t.connectorClass)o=t.connectorClass;else if(t.connectorImportPath){if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import(t.connectorImportPath),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector from dynamic URL/path. Ensure it exports `ParaGrazConnector`.");o=f;}else {if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import('@getpara/graz-integration'),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");o=f;}let s=u.getState().chains,r=new o(t,s);if(C.setState(c=>U(P({},c),{paraConnector:r})),!r)throw new Error("Para connector initialization failed. Check config and dependencies.");return r}catch(o){throw ie=null,new Error("Para connector init failed. Check @getpara/graz-integration and ParaConfig.")}}),ie);return {enable:i=>l(void 0,null,function*(){let o=Array.isArray(i)?i:[i];try{let s=yield n();C.setState({paraConnector:s,status:"connecting"}),yield s.enable(o);let r=Object.fromEntries(yield Promise.all(o.map(c=>l(void 0,null,function*(){return [c,yield s.getKey(c)]}))));C.setState(c=>({accounts:P(P({},c.accounts||{}),r),activeChainIds:Array.from(new Set([...c.activeChainIds||[],...o])),status:"connected"})),u.setState(c=>({recentChainIds:Array.from(new Set([...c.recentChainIds||[],...o])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"})),typeof window!="undefined"&&window.sessionStorage.setItem(tn,"1");}catch(s){throw C.setState({paraConnector:null,status:"disconnected"}),new Error(`Para enable failed${s instanceof Error?`: ${s.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let i=e();try{yield i.disconnect(),yield i.getParaWebClient().logout();}catch(o){throw new Error("Para disconnect failed. Wallet may already be disconnected.")}finally{C.setState({paraConnector:null,status:"disconnected"});}}),getKey:i=>l(void 0,null,function*(){try{return yield e().getKey(i)}catch(o){throw new Error("Failed to get key. Check chain connection and Cosmos API key settings at developer.getpara.com.")}}),getOfflineSigner:i=>{try{return e().getOfflineSigner(i)}catch(o){throw new Error("Failed to get offline signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerOnlyAmino:i=>{try{return e().getOfflineSignerOnlyAmino(i)}catch(o){throw new Error("Failed to get Amino signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerAuto:i=>{try{return e().getOfflineSignerAuto(i)}catch(o){throw new Error("Failed to get auto signer. Check Para auth and Cosmos support in developer portal.")}},signAmino:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signAmino(i,o,s,r)}catch(c){throw new Error("Amino signing failed. User rejected or invalid transaction/signer.")}}),signDirect:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signDirect(i,o,s,r)}catch(c){throw new Error("Direct signing failed. User rejected or invalid transaction/signer.")}}),signArbitrary:(i,o,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(i,o,s)}catch(r){throw new Error("Arbitrary signing failed. User rejected or feature not supported.")}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ge=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let r=()=>{N(),s();};return window.addEventListener("station_wallet_change",r),()=>{window.removeEventListener("station_wallet_change",r);}},getKey:s=>l(void 0,null,function*(){let r=yield t.getKey(s);return P({isKeystone:false},r)}),getOfflineSigner:s=>{try{let r=t.getOfflineSignerOnlyAmino(s);return Object.assign(r,{signDirect:(m,d)=>{throw new Error("signDirect not supported by Station")}})}catch(r){throw console.error(r),r}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let r=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,m,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((m=c.gasPriceStep)==null?void 0:m.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(r);}catch(r){throw console.error(r),r}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,r,c,f)=>t.signAmino(s,r,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ye=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:r=>e.enable(r),getOfflineSigner:r=>{let c=e.getOfflineSigner(r);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Ee__default.default.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:r=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(r);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Ee__default.default.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:r=>l(void 0,null,function*(){let c=yield e.getKey(r);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:r=>{let c=()=>{N(),r();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...r)=>{let c=r[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...r)=>l(void 0,null,function*(){var m;let[c]=r;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(m=c.bech32Config)==null?void 0:m.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...r)=>l(void 0,null,function*(){var d;let{1:c,2:f}=r,m=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Ee__default.default.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}}),signAmino:(...r)=>l(void 0,null,function*(){let{1:c,2:f}=r;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var F=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},nt=()=>F()&&navigator.userAgent.toLowerCase().includes("android"),ot=()=>F()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Te=(e,t,n=new Error("Promise timed out"))=>{let a=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,a])};var z=e=>{var R,Q,oe;if(!((oe=(Q=(R=u.getState().walletConnect)==null?void 0:R.options)==null?void 0:Q.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",a=y=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(F()){if(nt()){let E=h(w.mobile.android,y,"android");window.open(E,"_self","noreferrer noopener");}if(ot()){let E=h(w.mobile.ios,y,"ios");window.open(E,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=C.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),C.setState({wcSignClients:y}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield h.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=y=>{try{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let E=h.session.getAll(),v=E.at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw o(v.topic),new Error("invalid session");try{let D=E.find(j=>{var X,Y;return (Y=(X=j.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${y}`)});if(!D)throw new Error("no session");return D}catch(D){if(!D.message.toLowerCase().includes("no matching key"))throw D}return v}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},r=y=>{try{return s(y)}catch(w){return}},c=y=>l(void 0,null,function*(){try{let w=y.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=C.getState(),h=w.get(t);if(h)return h;let E=yield signClient.SignClient.init(y.options);return w.set(t,E),C.setState({wcSignClients:w}),E}),m=y=>{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)return ()=>{};let E=v=>{let x=C.getState().accounts;if(v.params.event.name==="accountsChanged"&&x&&!Object.values(x).map(D=>D.bech32Address).includes(v.params.event.data[0])){let D=v.params.chainId.split(":")[1];D&&d([D]);}else y();};return h.events.on("session_delete",i),h.events.on("session_expire",i),h.events.on("session_event",E),()=>{h.events.off("session_delete",i),h.events.off("session_expire",i),h.events.off("session_event",E);}},d=y=>l(void 0,null,function*(){var Y;let w=typeof y=="string"?[y]:y,{wcSignClients:h,activeChainIds:E}=C.getState(),v=h.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:x,chains:D}=u.getState();if(!((Y=x==null?void 0:x.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new modal.WalletConnectModal(P({projectId:x.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},x.walletConnectModal)),X=r(w);if(!X){let{uri:L,approval:se}=yield Te(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?a(L):yield j.openModal({uri:L});let ae=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,Z)=>{se().then(De=>{let _e=De.sessionProperties;if(!_e)return Z(new Error("No session properties"));let Oe=JSON.parse(String(_e.keys));if(Oe.length===0)return Z(new Error("No accounts"));if(!Oe[0])return Z(new Error("No accounts"));let Ke={};return Oe.forEach(V=>{Ke[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),C.setState(V=>({accounts:P(P({},V.accounts||{}),Ke)})),be(De)}).catch(Z),$.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:true});})});try{let $=new AbortController,be=$.signal;j.subscribeModal(Z=>{Z.open||$.abort();}),yield ae(be);}catch($){if(j.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||j.closeModal(),Promise.resolve()}try{yield Te(l(void 0,null,function*(){var se;let L=Object.fromEntries(yield Promise.all((se=E||w)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield S(ae)]}))));C.setState({accounts:L});}),15e3,new Error("Connection timeout"));}catch(L){if(o(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),g=y=>l(void 0,null,function*(){let w=yield S(y);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=y=>l(void 0,null,function*(){let w=s([y]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let E=h.find(v=>v.chainId===y);if(!E)throw new Error(`No wallet connect key for chainId ${y}`);return U(P({},E),{pubKey:Buffer.from(String(E.pubKey),n)})}),T=(...y)=>l(void 0,null,function*(){var Y,L;let[w,h,E]=y,{accounts:v,wcSignClients:x}=C.getState(),D=x.get(t);if(!D)throw new Error("walletConnect.signClient is not defined");if(!v)throw new Error("account is not defined");let j=(Y=s([w]))==null?void 0:Y.topic;if(!j)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield D.request({topic:j,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:E.chainId,accountNumber:(L=E.accountNumber)==null?void 0:L.toString(),bodyBytes:E.bodyBytes?Buffer.from(E.bodyBytes).toString(n):null,authInfoBytes:E.authInfoBytes?Buffer.from(E.authInfoBytes).toString(n):null}}}})}),M=(...y)=>l(void 0,null,function*(){var D;let[w,h,E]=y,{signature:v,signed:x}=yield T(w,h,E);return {signed:{chainId:(D=x.chainId)!=null?D:"",accountNumber:x.accountNumber?BigInt(x.accountNumber):BigInt(0),authInfoBytes:x.authInfoBytes?new Uint8Array(Buffer.from(x.authInfoBytes,n)):new Uint8Array([]),bodyBytes:x.bodyBytes?new Uint8Array(Buffer.from(x.bodyBytes,n)):new Uint8Array([])},signature:v}}),W=(...y)=>l(void 0,null,function*(){var L;let[w,h,E,v]=y,{wcSignClients:x}=C.getState(),D=x.get(t),{accounts:j}=C.getState();if(!D)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let X=(L=s([w]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return a(),yield D.request({topic:X,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:E}}})}),O=(...y)=>l(void 0,null,function*(){let[w,h,E,v]=y;return yield W(w,h,E)}),p=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>M(y,w,h)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signAmino:(w,h)=>O(y,w,h)});return {enable:d,disable:y=>l(void 0,null,function*(){var E;let{wcSignClients:w}=C.getState(),h=w.get(t);if(y===void 0){let v=h==null?void 0:h.session.getAll();v!==void 0&&(yield Promise.all(v.map(x=>o(x.topic))));}else typeof y=="string"?yield o((E=s([y]))==null?void 0:E.topic):yield Promise.all(y.map(v=>{var x;return o((x=s([v]))==null?void 0:x.topic)}));(h==null?void 0:h.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>M(y,w,h),signAmino:(w,h)=>O(y,w,h)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield S(y)).isNanoLedger?A(y):p(y)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:M,subscription:m,init:f}};var it=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return z(e)};var rt=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":","");return o?`${r}://wc?${o}`:`${r}://wc`}};return z(e)};var st=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${r}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return z(e)};var at=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${r}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return z(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var G=(e=u.getState().walletType)=>{try{return _(e),!0}catch(t){return false}},N=()=>{window.sessionStorage.removeItem(ee),C.setState(ne);},_=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return pe();case "leap":return de();case "cosmostation":return ue();case "vectis":return ye();case "walletconnect":return z();case "wc_keplr_mobile":return st();case "wc_leap_mobile":return at();case "wc_cosmostation_mobile":return rt();case "wc_clot_mobile":return it();case "metamask_snap_leap":return et();case "metamask_snap_cosmos":return He();case "station":return ge();case "xdefi":return Ce();case "cosmiframe":return le();case "compass":return ce();case "initia":return Ye();case "okx":return fe();case "para":return tt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((a=t.setDefaultOptions)==null||a.call(t,n)),t},$i=()=>Object.fromEntries(Fe.map(e=>[e,G(e)])),ct=e=>e==="metamask_snap_leap",lt=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),re=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",ut=e=>e==="para";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:r,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(re(f)){let O=_("walletconnect"),{disable:p}=O;p&&p();}if(!G(f))throw new Error(`${f} is not available`);let d=_(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=r==null?void 0:r.map(O=>O.chainId);g.forEach(O=>{if(!(S!=null&&S.includes(O)))throw new Error(`Chain ${O} is not provided in GrazProvider`)}),C.setState(O=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return O.activeChainIds&&g.filter(b=>{var k;return !((k=O.activeChainIds)!=null&&k.includes(b))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:T}=C.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!re(f)){let O={};if(ct(f)){let p={};try{for(var n=Ue(g),a,i,o;a=!(i=yield n.next()).done;a=!1){let A=i.value;p[A]=yield d.getKey(A);}}catch(i){o=[i];}finally{try{a&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}O=p;}else if(lt()&&d.getKeys){let p=yield d.getKeys(g);g.forEach((A,b)=>{let k=p[b];k&&(O[A]=k);});}else O=Object.fromEntries(yield Promise.all(g.map(p=>l(void 0,null,function*(){return [p,yield d.getKey(p)]}))));C.setState(p=>({accounts:P(P({},p.accounts||{}),O)}));}u.setState(O=>({recentChainIds:[...O.recentChainIds||[],...g].filter((p,A,b)=>b.indexOf(p)===A)})),C.setState(O=>({activeChainIds:[...O.activeChainIds||[],...g].filter((p,A,b)=>b.indexOf(p)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ee,"Active");let M=g.map(O=>r.find(p=>p.chainId===O));return {accounts:C.getState().accounts,walletType:f,chains:M}}catch(s){throw console.error("connect ",s),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),s}}),Pe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(ee);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,n=()=>{if(re(u.getState().walletType)){let a=_("walletconnect"),{disable:i}=a;i&&i();}if(ut(u.getState().walletType)){let a=_("para"),{disable:i}=a;i&&i();}};if(t){let a=C.getState().accounts;t.forEach(o=>{a==null||delete a[o];}),Object.values(a||{}).length===0?(n(),C.setState(ne),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(C.setState(o=>{var s;return {activeChainIds:(s=o.activeChainIds)==null?void 0:s.filter(r=>!t.includes(r)),accounts:a}}),u.setState(o=>{var s;return {recentChainIds:(s=o.recentChainIds)==null?void 0:s.filter(r=>!t.includes(r))}}));}else n(),C.setState(ne),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:a}=u.getState();try{let o=G(n||void 0);if(t&&o&&n)return re(n)?void 0:yield te({chainId:t,walletType:n,autoReconnect:a})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),Pe();}}),pt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!G(n))throw new Error(`${n} is not available`);let i=_(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),r=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:r}});var ke=()=>{u.setState({recentChainIds:null});},rr=()=>u.getState().recentChainIds,sr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(a=>t.find(i=>i.chainId===a)))!=null?n:null},ar=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},xe=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield _(t).experimentalSuggestChain(e),e}),dt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield xe({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var mt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var ft=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:a,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,a,i,o)}),gt=m=>l(void 0,[m],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:a,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:r,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,a,i,o,s,r,c,f)}),yt=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,a,i)}),Ct=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,a,s,o)}),wt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),St=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return n.queryContractRaw(e,a)};var wr=e=>e,Sr=e=>e;var ht=e=>e?Object.keys(e).length===0:true;var Me=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},At=e=>globalThis.DOMException===void 0?new Me(e):new DOMException(e),It=e=>{let t=e.reason===void 0?At("This operation was aborted."):e.reason;return t instanceof Error?t:At(t)};function ve(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:i}={}){return new Promise((r,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let f=[],m=[],d=new Map,g=false,S=false,T=false,M=0,W=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{g=true,S=true,c(b);};i&&(i.aborted&&p(It(i)),i.addEventListener("abort",()=>{p(It(i));}));let A=()=>l(this,null,function*(){if(S)return;let b=yield O.next(),k=W;if(W++,b.done){if(T=true,M===0&&!S){if(!a&&m.length>0){p(new AggregateError(m));return}if(S=true,d.size===0){r(f);return}let K=[];for(let[R,Q]of f.entries())d.get(R)!==bt&&K.push(Q);r(K);}return}M++,l(this,null,function*(){try{let K=yield b.value;if(S)return;let R=yield t(K,k);R===bt&&d.set(k,R),f[k]=R,M--,yield A();}catch(K){if(a)p(K);else {m.push(K),M--;try{yield A();}catch(R){p(R);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield A();}catch(k){p(k);break}if(T||g)break}});})})}var bt=Symbol("skip");var q=({chainId:e,multiChain:t})=>{let n=u(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!a):return [a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!a):return n;default:return [n[0]]}},H=(e,t,n)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let o=yield ve(t,n,{concurrency:a});return Object.fromEntries(o.map((s,r)=>[t[r].chainId,s]))}return yield n(t[0])}),Ot=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var We=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:P({},(r==null?void 0:r.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},Re=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:P({},(r==null?void 0:r.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var jr=()=>u(shallow.useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),we=e=>{let n=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return reactQuery.useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>G(i)})};var J=e=>{let t=u(r=>r.walletType),n=C(r=>r.activeChainIds),a=q({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=C(r=>r.accounts),o=C(r=>r.status);return react.useEffect(()=>C.subscribe(r=>r.status,(r,c)=>{var f,m,d;if(r==="connected"){let{accounts:g,activeChainIds:S}=C.getState(),{chains:T}=u.getState(),{walletType:M}=u.getState();if(!g||!S||!T)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(m=e==null?void 0:e.onConnect)==null||m.call(e,{accounts:g,chains:S.map(W=>T.find(O=>O.chainId===W)),walletType:M,isReconnect:c==="reconnecting"});}r==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:react.useMemo(()=>i?Ot(!!(e!=null&&e.multiChain),a,r=>i[r.chainId]):void 0,[i,a,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:B,status:o}},dn=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),a=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=We({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),o=react.useMemo(()=>["USE_ALL_BALANCES",i,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,i]);return reactQuery.useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var T;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((T=d.bech32Config)!=null&&T.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!ht(i)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},is=e=>{let t=q({chainId:e.chainId}),{data:n}=J({chainId:e.chainId}),a=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=dn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,a,e.chainId],r=reactQuery.useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(m=>m.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?true:e.enabled)});return U(P({},r),{refetch:c=>l(void 0,null,function*(){return yield o(),r.refetch(c)})})},rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:te,onError:(s,r)=>e==null?void 0:e(s,r),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=we();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:Pe,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},as=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),a=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chain found");if(!G(s))throw new Error(`${s} is not available`);return yield H(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield pt({chainId:m.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!n&&!!a,refetchOnWindowFocus:false})},cs=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),{data:a}=We({chainId:t.map(s=>s.chainId),multiChain:true}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",a,t,i],[t,i,a]);return reactQuery.useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var S,T;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (T=s[d.chainId])==null?void 0:T.getBalanceStaked(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var ys=()=>C(e=>e.activeChainIds),mn=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let n=(a=u.getState().chains)==null?void 0:a.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},Cs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ss=({denom:e})=>{let t=mn();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(r=>r.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},hs=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},As=()=>({data:u(t=>t.recentChainIds),clear:ke}),Is=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let a=(i=u.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(a)return a}).filter(Boolean),clear:ke}},bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:xe,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},Os=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:dt,onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=we();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Ws=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=J(),i=a==null?void 0:a.bech32Address,o=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>ft(P({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=J(),i=a==null?void 0:a.bech32Address,o=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>gt(P({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ds=({codeId:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=J(),o=i==null?void 0:i.bech32Address,r=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m;if(!o)throw new Error("senderAddress is undefined");let f=U(P({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,codeId:e});return yt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,instantiateContract:r.mutate,instantiateContractAsync:r.mutateAsync,status:r.status}},_s=({contractAddress:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=J(),o=i==null?void 0:i.bech32Address,r=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m,d,g;if(!o)throw new Error("senderAddress is undefined");let f=U(P({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,executeContract:r.mutate,executeContractAsync:r.mutateAsync,status:r.status}},Ks=e=>{let{data:t}=Re();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return wt(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ns=e=>{let{data:t}=Re(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return St(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Vs(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var W,O;if(!(a!=null&&a.includes(m.chainId)))return null;if(!G(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return _(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return _(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return _(r).getOfflineSignerOnlyAmino(m.chainId);default:return _(r).getOfflineSignerAuto(m.chainId)}}),S=(W=u.getState().chainsConfig)==null?void 0:W[m.chainId],T={url:m.rpc,headers:P({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(T,g,e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}function Hs(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var O,p;if(!(a!=null&&a.includes(m.chainId)))return null;if(!G(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return _(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return _(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return _(r).getOfflineSignerOnlyAmino(m.chainId);default:return _(r).getOfflineSignerAuto(m.chainId)}}),S=(O=u.getState().chainsConfig)==null?void 0:O[m.chainId],T={url:m.rpc,headers:P({},(S==null?void 0:S.rpcHeaders)||{})},M=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(T,g,P({gasPrice:M},e!=null&&e.multiChain?(p=e.opts)==null?void 0:p[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}var _t=({children:e})=>{let[t,n]=react.useState(false);return react.useEffect(()=>{n(true);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var In=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(ee)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:a,iframeOptions:i,chains:o,pingInterval:s}=u(),{activeChainIds:r,wcSignClients:c}=C(),f=G(a||void 0);return react.useEffect(()=>{let m=()=>l(void 0,null,function*(){if(e&&f&&a&&(r!=null&&r[0])){let d=C.getState().lastPing;if(d&&Date.now()-d<s)return;let g=_(a);try{if(!(yield g.getKey(r[0])))throw new Error("No account found");C.setState({lastPing:Date.now()});return}catch(S){B({onError:n});}}});return window.addEventListener("focus",m),()=>{window.removeEventListener("focus",m);}},[e,f,a,o,r,s]),react.useEffect(()=>{if(!i||i.autoConnect===false||!i.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(i.allowedIframeParentOrigins).isReady().then(d=>{if(d)return te({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[i]),react.useEffect(()=>{if(a){if(!f)return;e&&r?B({onError:n}):!e&&t&&B({onError:n});}},[f]),react.useEffect(()=>{var m,d,g,S,T,M,W,O,p,A,b,k,K,R,Q,oe,y,w,h,E;if(a){if(!f)return;a==="cosmostation"&&((d=(m=ue()).subscription)==null||d.call(m,()=>{B({onError:n});})),a==="keplr"&&((S=(g=pe()).subscription)==null||S.call(g,()=>{B({onError:n});})),a==="leap"&&((M=(T=de()).subscription)==null||M.call(T,()=>{B({onError:n});})),a==="compass"&&((O=(W=ce()).subscription)==null||O.call(W,()=>{B({onError:n});})),a==="vectis"&&((A=(p=ye()).subscription)==null||A.call(p,()=>{B({onError:n});})),a==="walletconnect"&&c.has("walletconnect")&&((k=(b=z()).subscription)==null||k.call(b,()=>{B({onError:n});})),a==="station"&&((R=(K=ge()).subscription)==null||R.call(K,()=>{B({onError:n});})),a==="xdefi"&&((oe=(Q=Ce()).subscription)==null||oe.call(Q,()=>{B({onError:n});})),a==="cosmiframe"&&((w=(y=le()).subscription)==null||w.call(y,()=>{B({onError:n});})),a==="okx"&&((E=(h=fe()).subscription)==null||E.call(h,()=>{B({onError:n});}));}},[a,c,f]),null},Kt=()=>(In(),null);var Ta=({children:e,grazOptions:t})=>(react.useEffect(()=>{mt(t);},[t]),jsxRuntime.jsxs(_t,{children:[e,jsxRuntime.jsx(Kt,{})]}));
|
|
24
|
+
var Nt=Object.defineProperty,Bt=Object.defineProperties;var Lt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var Be=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Le=(e,t,o)=>t in e?Nt(e,t,{enumerable:true,configurable:true,writable:true,value:o}):e[t]=o,P=(e,t)=>{for(var o in t||(t={}))Ut.call(t,o)&&Le(e,o,t[o]);if(Ne)for(var o of Ne(t))Ft.call(t,o)&&Le(e,o,t[o]);return e},U=(e,t)=>Bt(e,Lt(t));var l=(e,t,o)=>new Promise((a,r)=>{var n=c=>{try{i(o.next(c));}catch(f){r(f);}},s=c=>{try{i(o.throw(c));}catch(f){r(f);}},i=c=>c.done?a(c.value):Promise.resolve(c.value).then(n,s);i((o=o.apply(e,t)).next());});var Ue=(e,t,o)=>(t=e[Be("asyncIterator")])?t.call(e):(e=e[Be("iterator")](),t={},o=(a,r)=>(r=e[a])&&(t[a]=n=>new Promise((s,i,c)=>(n=r.call(e,n),c=n.done,Promise.resolve(n.value).then(f=>s({value:f,done:c}),i)))),o("next"),o("return"),t);var ee="graz-reconnect-session";var Fe=(m=>(m.KEPLR="keplr",m.LEAP="leap",m.VECTIS="vectis",m.COSMOSTATION="cosmostation",m.WALLETCONNECT="walletconnect",m.WC_KEPLR_MOBILE="wc_keplr_mobile",m.WC_LEAP_MOBILE="wc_leap_mobile",m.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",m.WC_CLOT_MOBILE="wc_clot_mobile",m.METAMASK_SNAP_LEAP="metamask_snap_leap",m.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",m.STATION="station",m.XDEFI="xdefi",m.COSMIFRAME="cosmiframe",m.COMPASS="compass",m.INITIA="initia",m.OKX="okx",m.PARA="para",m))(Fe||{}),Ge=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var zt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:middleware.createJSONStorage(()=>sessionStorage)},$t={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},y=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,qt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>zt,$t)));var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var Ve={},He=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var p;let n=yield e.request({method:"web3_clientVersion"});if(!n.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let i=(p=n.split("MetaMask/v")[1])==null?void 0:p.split(".")[0];if(!(Number(i)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,true}),enable:n=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(U(P({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,s,i)=>l(void 0,null,function*(){return t.signAmino(n,s,i)}),getKey:n=>l(void 0,null,function*(){return typeof Ve[n]!="undefined"?Ve[n]:t.getKey(n)}),getOfflineSignerAuto:n=>l(void 0,null,function*(){return (yield t.getKey(n)).isNanoLedger?t.getOfflineSignerOnlyAmino(n):t.getOfflineSigner(n)}),getOfflineSignerOnlyAmino:n=>t.getOfflineSignerOnlyAmino(n),signDirect:(n,s,i)=>l(void 0,null,function*(){return t.signDirect(n,s,i)}),signArbitrary:(n,s,i)=>l(void 0,null,function*(){return t.signArbitrary(n,s,i)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:n=>{let s=()=>{N(),n();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Zt=e=>{let{bodyBytes:t,authInfoBytes:o,chainId:a,accountNumber:r}=e;if(!t||!o||!a||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:o,chainId:a,accountNumber:r}},en=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Ye=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let T=(()=>{switch(S.algo){case "secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return amino.rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:en(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:T,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,T,M;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(T=g.gasPriceStep)==null?void 0:T.average,high_gas_price:(M=g.gasPriceStep)==null?void 0:M.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,T]=d;return e.getOfflineSigner(g).signDirect(S,Zt(T))},signAmino:(...d)=>{let[g,S,T]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,T)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let W=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!W)throw new Error(`Wallet not connected to account ${g}`);let O=(()=>{switch(W.algo){case "secp256k1":return amino.encodeSecp256k1Pubkey(W.pubkey);case "ed25519":return amino.encodeEd25519Pubkey(W.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:W.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:d=>{let g=()=>{N(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var me={},Ze=e=>{let t=window.ethereum;if(t&&e){let o=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=m=>l(void 0,null,function*(){try{let A=yield o();return Object.values(A).find(b=>b.id===e.id&&(!m||b.version===m))}catch(A){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var D;let m=yield t.request({method:"web3_clientVersion"});if(!m.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(D=m.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield r()),true}),s=m=>l(void 0,null,function*(){(yield a())||(yield r());}),i=(m,A,b)=>l(void 0,null,function*(){let k=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:m,signerAddress:A,signDoc:b}}}}),K=b.accountNumber,D=new Ee__default.default(K.low,K.high,K.unsigned);return {signature:k.signature,signed:U(P({},k.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(k.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(k.signed.bodyBytes))})}}),c=(m,A,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:m,signerAddress:A,signDoc:b}}}})}),f=m=>l(void 0,null,function*(){if(typeof me[m]!="undefined")return me[m];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:m}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,me[m]=A,me[m]}),p=m=>l(void 0,null,function*(){let A=yield f(m);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...m)=>l(void 0,null,function*(){let[A,b,k,K]=m;return yield c(A,b,k)}),g=(...m)=>l(void 0,null,function*(){var j;let[A,b,k]=m,K=U(P({},k),{accountNumber:Ee__default.default.fromString(((j=k.accountNumber)==null?void 0:j.toString())||"0"),authInfoBytes:k.authInfoBytes,bodyBytes:k.bodyBytes});return yield i(A,b,K)}),T=m=>({getAccounts:()=>l(void 0,null,function*(){return [yield p(m)]}),signAmino:(A,b)=>d(m,A,b)});return {enable:s,experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:m[0]}}}});}),getKey:f,getOfflineSigner:m=>({getAccounts:()=>l(void 0,null,function*(){return [yield p(m)]}),signDirect:(A,b)=>g(m,A,b),signAmino:(A,b)=>d(m,A,b)}),getOfflineSignerAuto:m=>l(void 0,null,function*(){return T(m)}),getOfflineSignerOnlyAmino:T,init:n,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var et=()=>Ze({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:n=>{var i;let s=()=>{N(),n();};return (i=window.okxwallet)==null||i.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ie=null,tt=()=>{let e=()=>{let r=y.getState().paraConnector;if(!r)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return r},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let o=()=>ie||(ie=l(void 0,null,function*(){var n,s;let r=y.getState().paraConnector;if(r)return r;try{let i;if(t.connectorClass)i=t.connectorClass;else {if(typeof window=="undefined")throw new Error("Para connector requires client-side execution (SSR is unsupported).");let p=yield import('@getpara/graz-integration'),d=p==null?void 0:p.ParaGrazConnector;if(typeof d!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");i=d;}let c=u.getState().chains,f=new i(t,c);if(y.setState(p=>U(P({},p),{paraConnector:f})),!f)throw new Error("Para connector initialization failed. Check config and dependencies.");return f}catch(i){throw ie=null,(i==null?void 0:i.code)==="MODULE_NOT_FOUND"||((n=i==null?void 0:i.message)==null?void 0:n.includes("Cannot find module"))||((s=i==null?void 0:i.message)==null?void 0:s.includes("Failed to resolve"))?new Error("Para integration package not found. Install @getpara/graz-integration to use Para wallet: npm install @getpara/graz-integration"):new Error(`Para connector init failed: ${(i==null?void 0:i.message)||"Unknown error"}. Check @getpara/graz-integration and ParaConfig.`)}}),ie);return {enable:r=>l(void 0,null,function*(){var s,i;let n=Array.isArray(r)?r:[r];try{let c=yield o();y.setState({paraConnector:c,status:"connecting"}),yield c.enable(n);let f=Object.fromEntries(yield Promise.all(n.map(p=>l(void 0,null,function*(){return [p,yield c.getKey(p)]}))));y.setState(p=>({accounts:P(P({},p.accounts||{}),f),activeChainIds:Array.from(new Set([...p.activeChainIds||[],...n])),status:"connected"})),u.setState(p=>({recentChainIds:Array.from(new Set([...p.recentChainIds||[],...n])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"}));}catch(c){throw y.setState({paraConnector:null,status:"disconnected"}),((s=c==null?void 0:c.message)==null?void 0:s.includes("not found"))||((i=c==null?void 0:c.message)==null?void 0:i.includes("Cannot find"))?new Error("Para wallet connection failed: Required packages not installed. Install @getpara/graz-integration to enable Para wallet."):new Error(`Para enable failed${c instanceof Error?`: ${c.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let r=y.getState().paraConnector;if(!r){y.setState({paraConnector:null,status:"disconnected"});return}try{yield r.disconnect(),yield r.getParaWebClient().logout();}catch(n){throw new Error(`Para disconnect failed${n!=null&&n.message?`: ${n.message}`:". Wallet may already be disconnected."}`)}finally{y.setState({paraConnector:null,status:"disconnected"});}}),getKey:r=>l(void 0,null,function*(){try{return yield e().getKey(r)}catch(n){throw new Error(`Failed to get key${n!=null&&n.message?`: ${n.message}`:""}. Check chain connection and Cosmos API key settings at developer.getpara.com.`)}}),getOfflineSigner:r=>{try{return e().getOfflineSigner(r)}catch(n){throw new Error(`Failed to get offline signer${n!=null&&n.message?`: ${n.message}`:""}. Check Para auth and Cosmos support in developer portal.`)}},getOfflineSignerOnlyAmino:r=>{try{return e().getOfflineSignerOnlyAmino(r)}catch(n){throw new Error(`Failed to get Amino signer${n!=null&&n.message?`: ${n.message}`:""}. Check Para auth and Cosmos support in developer portal.`)}},getOfflineSignerAuto:r=>{try{return e().getOfflineSignerAuto(r)}catch(n){throw new Error(`Failed to get auto signer${n!=null&&n.message?`: ${n.message}`:""}. Check Para auth and Cosmos support in developer portal.`)}},signAmino:(r,n,s,i)=>l(void 0,null,function*(){try{return yield e().signAmino(r,n,s,i)}catch(c){throw new Error(`Amino signing failed${c!=null&&c.message?`: ${c.message}`:""}. User rejected or invalid transaction/signer.`)}}),signDirect:(r,n,s,i)=>l(void 0,null,function*(){try{return yield e().signDirect(r,n,s,i)}catch(c){throw new Error(`Direct signing failed${c!=null&&c.message?`: ${c.message}`:""}. User rejected or invalid transaction/signer.`)}}),signArbitrary:(r,n,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(r,n,s)}catch(i){throw new Error(`Arbitrary signing failed${i!=null&&i.message?`: ${i.message}`:""}. User rejected or feature not supported.`)}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ge=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let i=()=>{N(),s();};return window.addEventListener("station_wallet_change",i),()=>{window.removeEventListener("station_wallet_change",i);}},getKey:s=>l(void 0,null,function*(){let i=yield t.getKey(s);return P({isKeystone:false},i)}),getOfflineSigner:s=>{try{let i=t.getOfflineSignerOnlyAmino(s);return Object.assign(i,{signDirect:(p,d)=>{throw new Error("signDirect not supported by Station")}})}catch(i){throw console.error(i),i}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let i=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,p,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((p=c.gasPriceStep)==null?void 0:p.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(i);}catch(i){throw console.error(i),i}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,i,c,f)=>t.signAmino(s,i,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ye=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:i=>e.enable(i),getOfflineSigner:i=>{let c=e.getOfflineSigner(i);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,p)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Ee__default.default.fromString(((g=p.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:p.authInfoBytes,bodyBytes:p.bodyBytes,chainId:p.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:i=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(i);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,p)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Ee__default.default.fromString(((g=p.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:p.authInfoBytes,bodyBytes:p.bodyBytes,chainId:p.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:i=>l(void 0,null,function*(){let c=yield e.getKey(i);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:i=>{let c=()=>{N(),i();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...i)=>{let c=i[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...i)=>l(void 0,null,function*(){var p;let[c]=i;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(p=c.bech32Config)==null?void 0:p.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...i)=>l(void 0,null,function*(){var d;let{1:c,2:f}=i,p=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Ee__default.default.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:p.signature,signed:{authInfoBytes:p.signed.authInfoBytes,bodyBytes:p.signed.bodyBytes,chainId:p.signed.chainId,accountNumber:BigInt(p.signed.accountNumber.toString())}}}),signAmino:(...i)=>l(void 0,null,function*(){let{1:c,2:f}=i;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var G=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},nt=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),ot=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Te=(e,t,o=new Error("Promise timed out"))=>{let a=new Promise((r,n)=>{setTimeout(()=>{n(o);},t);});return Promise.race([e,a])};var z=e=>{var D,j,oe;if(!((oe=(j=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:j.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",o=(e==null?void 0:e.encoding)||"base64",a=C=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(G()){if(nt()){let E=h(w.mobile.android,C,"android");window.open(E,"_self","noreferrer noopener");}if(ot()){let E=h(w.mobile.ios,C,"ios");window.open(E,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:C}=y.getState();if(!C.get(t))throw new Error("walletConnect.signClient is not defined");C.delete(t),y.setState({wcSignClients:C}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},n=C=>l(void 0,null,function*(){let{wcSignClients:w}=y.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!C)throw new Error("No wallet connect session");yield h.disconnect({topic:C,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=C=>{try{let{wcSignClients:w}=y.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let E=h.session.getAll(),v=E.at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw n(v.topic),new Error("invalid session");try{let R=E.find($=>{var X,Y;return (Y=(X=$.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${C}`)});if(!R)throw new Error("no session");return R}catch(R){if(!R.message.toLowerCase().includes("no matching key"))throw R}return v}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},i=C=>{try{return s(C)}catch(w){return}},c=C=>l(void 0,null,function*(){try{let w=C.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield C.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:C}=u.getState();if(!(C!=null&&C.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=y.getState(),h=w.get(t);if(h)return h;let E=yield signClient.SignClient.init(C.options);return w.set(t,E),y.setState({wcSignClients:w}),E}),p=C=>{let{wcSignClients:w}=y.getState(),h=w.get(t);if(!h)return ()=>{};let E=v=>{let x=y.getState().accounts;if(v.params.event.name==="accountsChanged"&&x&&!Object.values(x).map(R=>R.bech32Address).includes(v.params.event.data[0])){let R=v.params.chainId.split(":")[1];R&&d([R]);}else C();};return h.events.on("session_delete",r),h.events.on("session_expire",r),h.events.on("session_event",E),()=>{h.events.off("session_delete",r),h.events.off("session_expire",r),h.events.off("session_event",E);}},d=C=>l(void 0,null,function*(){var Y;let w=typeof C=="string"?[C]:C,{wcSignClients:h,activeChainIds:E}=y.getState(),v=h.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:x,chains:R}=u.getState();if(!((Y=x==null?void 0:x.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let $=new modal.WalletConnectModal(P({projectId:x.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},x.walletConnectModal)),X=i(w);if(!X){let{uri:L,approval:se}=yield Te(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(Q=>`cosmos:${Q}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?a(L):yield $.openModal({uri:L});let ae=Q=>l(void 0,null,function*(){return Q.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,Z)=>{se().then(Re=>{let _e=Re.sessionProperties;if(!_e)return Z(new Error("No session properties"));let Oe=JSON.parse(String(_e.keys));if(Oe.length===0)return Z(new Error("No accounts"));if(!Oe[0])return Z(new Error("No accounts"));let Ke={};return Oe.forEach(V=>{Ke[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),y.setState(V=>({accounts:P(P({},V.accounts||{}),Ke)})),be(Re)}).catch(Z),Q.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:true});})});try{let Q=new AbortController,be=Q.signal;$.subscribeModal(Z=>{Z.open||Q.abort();}),yield ae(be);}catch(Q){if($.closeModal(),!Q.message.toLowerCase().includes("no matching key"))return Promise.reject(Q)}return e||$.closeModal(),Promise.resolve()}try{yield Te(l(void 0,null,function*(){var se;let L=Object.fromEntries(yield Promise.all((se=E||w)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield S(ae)]}))));y.setState({accounts:L});}),15e3,new Error("Connection timeout"));}catch(L){if(n(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),g=C=>l(void 0,null,function*(){let w=yield S(C);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=C=>l(void 0,null,function*(){let w=s([C]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let E=h.find(v=>v.chainId===C);if(!E)throw new Error(`No wallet connect key for chainId ${C}`);return U(P({},E),{pubKey:Buffer.from(String(E.pubKey),o)})}),T=(...C)=>l(void 0,null,function*(){var Y,L;let[w,h,E]=C,{accounts:v,wcSignClients:x}=y.getState(),R=x.get(t);if(!R)throw new Error("walletConnect.signClient is not defined");if(!v)throw new Error("account is not defined");let $=(Y=s([w]))==null?void 0:Y.topic;if(!$)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield R.request({topic:$,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:E.chainId,accountNumber:(L=E.accountNumber)==null?void 0:L.toString(),bodyBytes:E.bodyBytes?Buffer.from(E.bodyBytes).toString(o):null,authInfoBytes:E.authInfoBytes?Buffer.from(E.authInfoBytes).toString(o):null}}}})}),M=(...C)=>l(void 0,null,function*(){var R;let[w,h,E]=C,{signature:v,signed:x}=yield T(w,h,E);return {signed:{chainId:(R=x.chainId)!=null?R:"",accountNumber:x.accountNumber?BigInt(x.accountNumber):BigInt(0),authInfoBytes:x.authInfoBytes?new Uint8Array(Buffer.from(x.authInfoBytes,o)):new Uint8Array([]),bodyBytes:x.bodyBytes?new Uint8Array(Buffer.from(x.bodyBytes,o)):new Uint8Array([])},signature:v}}),W=(...C)=>l(void 0,null,function*(){var L;let[w,h,E,v]=C,{wcSignClients:x}=y.getState(),R=x.get(t),{accounts:$}=y.getState();if(!R)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let X=(L=s([w]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return a(),yield R.request({topic:X,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:E}}})}),O=(...C)=>l(void 0,null,function*(){let[w,h,E,v]=C;return yield W(w,h,E)}),m=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(C)]}),signDirect:(w,h)=>M(C,w,h)}),A=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(C)]}),signAmino:(w,h)=>O(C,w,h)});return {enable:d,disable:C=>l(void 0,null,function*(){var E;let{wcSignClients:w}=y.getState(),h=w.get(t);if(C===void 0){let v=h==null?void 0:h.session.getAll();v!==void 0&&(yield Promise.all(v.map(x=>n(x.topic))));}else typeof C=="string"?yield n((E=s([C]))==null?void 0:E.topic):yield Promise.all(C.map(v=>{var x;return n((x=s([v]))==null?void 0:x.topic)}));(h==null?void 0:h.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...C)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:C=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(C)]}),signDirect:(w,h)=>M(C,w,h),signAmino:(w,h)=>O(C,w,h)}),getOfflineSignerAuto:C=>l(void 0,null,function*(){return (yield S(C)).isNanoLedger?A(C):m(C)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:M,subscription:p,init:f}};var it=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(s){case "ios":return c?`${i}://wcV2?${c}`:`${i}://wcV2`;default:return c?`${i}://wc?uri=${c}`:`${i}://wc`}}};return z(e)};var rt=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":","");return n?`${i}://wc?${n}`:`${i}://wc`}};return z(e)};var st=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(s){case "ios":return c?`${i}://wcV2?${c}`:`${i}://wcV2`;case "android":return c?`${i}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${i}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${i}://wc?uri=${c}`:`${i}://wc`}}};return z(e)};var at=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(s){case "ios":return c?`${i}://wcV2?${c}`:`${i}://wcV2`;case "android":return c?`${i}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${i}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${i}://wc?uri=${c}`:`${i}://wc`}}};return z(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var F=(e=u.getState().walletType)=>{try{return _(e),!0}catch(t){return false}},N=()=>{window.sessionStorage.removeItem(ee),y.setState(ne);},_=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return pe();case "leap":return de();case "cosmostation":return ue();case "vectis":return ye();case "walletconnect":return z();case "wc_keplr_mobile":return st();case "wc_leap_mobile":return at();case "wc_cosmostation_mobile":return rt();case "wc_clot_mobile":return it();case "metamask_snap_leap":return et();case "metamask_snap_cosmos":return He();case "station":return ge();case "xdefi":return Ce();case "cosmiframe":return le();case "compass":return ce();case "initia":return Ye();case "okx":return fe();case "para":return tt();default:throw new Error("Unknown wallet type")}})(),o=u.getState().walletDefaultOptions;return o&&((a=t.setDefaultOptions)==null||a.call(t,o)),t},ji=()=>Object.fromEntries(Ge.map(e=>[e,F(e)])),ct=e=>e==="metamask_snap_leap",lt=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),re=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",ut=e=>e==="para";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:i,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(re(f)){let O=_("walletconnect"),{disable:m}=O;m&&m();}if(!F(f))throw new Error(`${f} is not available`);let d=_(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=i==null?void 0:i.map(O=>O.chainId);g.forEach(O=>{if(!(S!=null&&S.includes(O)))throw new Error(`Chain ${O} is not provided in GrazProvider`)}),y.setState(O=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return O.activeChainIds&&g.filter(b=>{var k;return !((k=O.activeChainIds)!=null&&k.includes(b))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:T}=y.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!re(f)){let O={};if(ct(f)){let m={};try{for(var o=Ue(g),a,r,n;a=!(r=yield o.next()).done;a=!1){let A=r.value;m[A]=yield d.getKey(A);}}catch(r){n=[r];}finally{try{a&&(r=o.return)&&(yield r.call(o));}finally{if(n)throw n[0]}}O=m;}else if(lt()&&d.getKeys){let m=yield d.getKeys(g);g.forEach((A,b)=>{let k=m[b];k&&(O[A]=k);});}else O=Object.fromEntries(yield Promise.all(g.map(m=>l(void 0,null,function*(){return [m,yield d.getKey(m)]}))));y.setState(m=>({accounts:P(P({},m.accounts||{}),O)}));}u.setState(O=>({recentChainIds:[...O.recentChainIds||[],...g].filter((m,A,b)=>b.indexOf(m)===A)})),y.setState(O=>({activeChainIds:[...O.activeChainIds||[],...g].filter((m,A,b)=>b.indexOf(m)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),y.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ee,"Active");let M=g.map(O=>i.find(m=>m.chainId===O));return {accounts:y.getState().accounts,walletType:f,chains:M}}catch(s){throw console.error("connect ",s),y.getState().accounts===null&&y.setState({status:"disconnected"}),y.getState().accounts&&y.getState().activeChainIds&&y.setState({status:"connected"}),s}}),Pe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(ee);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,o=()=>{if(re(u.getState().walletType)){let a=_("walletconnect"),{disable:r}=a;r&&r();}if(ut(u.getState().walletType)){let a=_("para"),{disable:r}=a;r&&r();}};if(t){let a=y.getState().accounts;t.forEach(n=>{a==null||delete a[n];}),Object.values(a||{}).length===0?(o(),y.setState(ne),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(y.setState(n=>{var s;return {activeChainIds:(s=n.activeChainIds)==null?void 0:s.filter(i=>!t.includes(i)),accounts:a}}),u.setState(n=>{var s;return {recentChainIds:(s=n.recentChainIds)==null?void 0:s.filter(i=>!t.includes(i))}}));}else o(),y.setState(ne),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:o,_reconnect:a}=u.getState();try{let n=F(o||void 0);if(t&&n&&o)return re(o)?void 0:yield te({chainId:t,walletType:o,autoReconnect:a})}catch(n){(r=e==null?void 0:e.onError)==null||r.call(e,n),Pe();}}),pt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),o=e.walletType||t;if(!F(o))throw new Error(`${o} is not available`);let r=_(o),n=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),i=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:s,offlineSignerAuto:i}});var ke=()=>{u.setState({recentChainIds:null});},ir=()=>u.getState().recentChainIds,rr=()=>{var o;let{recentChainIds:e,chains:t}=u.getState();return (o=e==null?void 0:e.map(a=>t.find(r=>r.chainId===a)))!=null?o:null},sr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(o=>o.chainId===e)},ar=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},xe=o=>l(void 0,[o],function*({chainInfo:e,walletType:t}){return yield _(t).experimentalSuggestChain(e),e}),dt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield xe({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var mt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var ft=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:o,amount:a,fee:r,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,o,a,r,n)}),gt=p=>l(void 0,[p],function*({signingClient:e,senderAddress:t,recipientAddress:o,transferAmount:a,sourcePort:r,sourceChannel:n,timeoutHeight:s,timeoutTimestamp:i,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,o,a,r,n,s,i,c,f)}),yt=i=>l(void 0,[i],function*({signingClient:e,senderAddress:t,msg:o,fee:a,options:r,label:n,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,o,n,a,r)}),Ct=i=>l(void 0,[i],function*({signingClient:e,senderAddress:t,msg:o,fee:a,contractAddress:r,funds:n,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,o,a,s,n)}),wt=(e,t,o)=>l(void 0,null,function*(){if(!o)throw new Error("CosmWasm client is not ready");return yield o.queryContractSmart(e,t)}),St=(e,t,o)=>{if(!o)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return o.queryContractRaw(e,a)};var Cr=e=>e,wr=e=>e;var ht=e=>e?Object.keys(e).length===0:true;var Me=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},At=e=>globalThis.DOMException===void 0?new Me(e):new DOMException(e),It=e=>{let t=e.reason===void 0?At("This operation was aborted."):e.reason;return t instanceof Error?t:At(t)};function ve(n,s){return l(this,arguments,function*(e,t,{concurrency:o=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:r}={}){return new Promise((i,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(o)||o===Number.POSITIVE_INFINITY)&&o>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${o}\` (${typeof o})`);let f=[],p=[],d=new Map,g=false,S=false,T=false,M=0,W=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),m=b=>{g=true,S=true,c(b);};r&&(r.aborted&&m(It(r)),r.addEventListener("abort",()=>{m(It(r));}));let A=()=>l(this,null,function*(){if(S)return;let b=yield O.next(),k=W;if(W++,b.done){if(T=true,M===0&&!S){if(!a&&p.length>0){m(new AggregateError(p));return}if(S=true,d.size===0){i(f);return}let K=[];for(let[D,j]of f.entries())d.get(D)!==bt&&K.push(j);i(K);}return}M++,l(this,null,function*(){try{let K=yield b.value;if(S)return;let D=yield t(K,k);D===bt&&d.set(k,D),f[k]=D,M--,yield A();}catch(K){if(a)m(K);else {p.push(K),M--;try{yield A();}catch(D){m(D);}}}});});l(this,null,function*(){for(let b=0;b<o;b++){try{yield A();}catch(k){m(k);break}if(T||g)break}});})})}var bt=Symbol("skip");var q=({chainId:e,multiChain:t})=>{let o=u(r=>r.chains);if(!o)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(r=>o.find(n=>n.chainId===r)).filter(Boolean);case(!t&&!!a):return [a.map(r=>o.find(n=>n.chainId===r)).filter(Boolean)[0]];case(!!t&&!a):return o;default:return [o[0]]}},H=(e,t,o)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let n=yield ve(t,o,{concurrency:a});return Object.fromEntries(n.map((s,i)=>[t[i].chainId,s]))}return yield o(t[0])}),Ot=(e,t,o)=>{if(e){let r=t.map(o);return Object.fromEntries(r.map((n,s)=>[t[s].chainId,n]))}return o(t[0])};var We=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:o,queryFn:r=>l(void 0,[r],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var p;let i=(p=u.getState().chainsConfig)==null?void 0:p[s.chainId],c={url:s.rpc,headers:P({},(i==null?void 0:i.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},De=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:o,queryFn:r=>l(void 0,[r],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var p;let i=(p=u.getState().chainsConfig)==null?void 0:p[s.chainId],c={url:s.rpc,headers:P({},(i==null?void 0:i.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var qr=()=>u(shallow.useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),we=e=>{let o=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery({queryKey:o,queryFn:({queryKey:[,r]})=>F(r)})};var J=e=>{let t=u(i=>i.walletType),o=y(i=>i.activeChainIds),a=q({chainId:e!=null&&e.chainId?e.chainId:o||void 0,multiChain:e==null?void 0:e.multiChain}),r=y(i=>i.accounts),n=y(i=>i.status);return react.useEffect(()=>y.subscribe(i=>i.status,(i,c)=>{var f,p,d;if(i==="connected"){let{accounts:g,activeChainIds:S}=y.getState(),{chains:T}=u.getState(),{walletType:M}=u.getState();if(!g||!S||!T)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(p=e==null?void 0:e.onConnect)==null||p.call(e,{accounts:g,chains:S.map(W=>T.find(O=>O.chainId===W)),walletType:M,isReconnect:c==="reconnecting"});}i==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:react.useMemo(()=>r?Ot(!!(e!=null&&e.multiChain),a,i=>r[i.chainId]):void 0,[r,a,e==null?void 0:e.multiChain]),isConnected:n==="connected",isConnecting:n==="connecting",isDisconnected:n==="disconnected",isReconnecting:n==="reconnecting",isLoading:n==="connecting"||n==="reconnecting",walletType:n==="connected"?t:void 0,reconnect:B,status:n}},pn=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=J(),a=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),{data:r}=We({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),n=react.useMemo(()=>["USE_ALL_BALANCES",r,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,i,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),i,d=>l(void 0,null,function*(){var T;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((T=d.bech32Config)!=null&&T.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!ht(r)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},os=e=>{let t=q({chainId:e.chainId}),{data:o}=J({chainId:e.chainId}),a=e.bech32Address||(o==null?void 0:o.bech32Address),{data:r,refetch:n}=pn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,a,e.chainId],i=reactQuery.useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(p=>p.denom===c),enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?true:e.enabled)});return U(P({},i),{refetch:c=>l(void 0,null,function*(){return yield n(),i.refetch(c)})})},is=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,o],mutationFn:te,onError:(s,i)=>e==null?void 0:e(s,i),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:n}=we();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status}},rs=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,o],mutationFn:Pe,onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return {disconnect:n=>r.mutate(n),disconnectAsync:n=>r.mutateAsync(n),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,status:r.status}},ss=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(n=>n.walletType),a=y.getState().status==="connected"&&y.getState().accounts&&u.getState()._reconnectConnector===o,r=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,o],[t,o]);return reactQuery.useQuery({queryKey:r,queryFn:i=>l(void 0,[i],function*({queryKey:[,n,s]}){if(n.length<1)throw new Error("No chain found");if(!F(s))throw new Error(`${s} is not available`);return yield H(!!(e!=null&&e.multiChain),n,p=>l(void 0,null,function*(){return yield pt({chainId:p.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!o&&!!a,refetchOnWindowFocus:false})},as=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=J(),{data:a}=We({chainId:t.map(s=>s.chainId),multiChain:true}),r=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),n=react.useMemo(()=>["USE_BALANCE_STAKED",a,t,r],[t,r,a]);return reactQuery.useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,i,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),i,d=>l(void 0,null,function*(){var S,T;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (T=s[d.chainId])==null?void 0:T.getBalanceStaked(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var gs=()=>y(e=>e.activeChainIds),dn=()=>{var e;return (e=y(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let o=(a=u.getState().chains)==null?void 0:a.find(r=>r.chainId===t);if(o)return o}).filter(Boolean)},ys=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(o=>o.chainId===e)},Cs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},ws=({denom:e})=>{let t=dn();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,r]})=>{var n;return (n=t==null?void 0:t.find(s=>s.currencies.find(i=>i.coinMinimalDenom===r)))==null?void 0:n.currencies.find(s=>s)}})},Ss=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",o=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:o,queryFn:i=>l(void 0,[i],function*({queryKey:[,n,s]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},hs=()=>({data:u(t=>t.recentChainIds),clear:ke}),As=()=>{var t;return {data:(t=u(o=>o.recentChainIds))==null?void 0:t.map(o=>{var r;let a=(r=u.getState().chains)==null?void 0:r.find(n=>n.chainId===o);if(a)return a}).filter(Boolean),clear:ke}},Is=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,o],mutationFn:xe,onError:(n,s)=>Promise.resolve(e==null?void 0:e(n,s.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(o==null?void 0:o(n))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},bs=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],mutationFn:dt,onError:(s,i)=>Promise.resolve(e==null?void 0:e(s,i)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:n}=we();return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var vs=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:a}=J(),r=a==null?void 0:a.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,o,r],mutationFn:s=>ft(P({senderAddress:r},s)),onError:(s,i)=>Promise.resolve(e==null?void 0:e(s,i)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},Ws=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:a}=J(),r=a==null?void 0:a.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,o,r],mutationFn:s=>gt(P({senderAddress:r},s)),onError:(s,i)=>Promise.resolve(e==null?void 0:e(s,i)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Ds=({codeId:e,onError:t,onLoading:o,onSuccess:a})=>{let{data:r}=J(),n=r==null?void 0:r.bech32Address,i=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,o,a,e,n],mutationFn:c=>{var p;if(!n)throw new Error("senderAddress is undefined");let f=U(P({},c),{fee:(p=c.fee)!=null?p:"auto",senderAddress:n,codeId:e});return yt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:o,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,instantiateContract:i.mutate,instantiateContractAsync:i.mutateAsync,status:i.status}},Rs=({contractAddress:e,onError:t,onLoading:o,onSuccess:a})=>{let{data:r}=J(),n=r==null?void 0:r.bech32Address,i=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,o,a,e,n],mutationFn:c=>{var p,d,g;if(!n)throw new Error("senderAddress is undefined");let f=U(P({},c),{fee:(p=c.fee)!=null?p:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:o,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,executeContract:i.mutate,executeContractAsync:i.mutateAsync,status:i.status}},_s=e=>{let{data:t}=De();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return wt(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ks=e=>{let{data:t}=De(),o=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:o,queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return St(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Qs(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(s=>s.walletType),a=y(s=>s.activeChainIds),r=y.getState().status==="connected"&&y.getState().accounts&&u.getState()._reconnectConnector===o,n=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,o,e,a],[a,e,t,o]);return reactQuery.useQuery({queryKey:n,queryFn:c=>l(this,[c],function*({queryKey:[,s,i]}){if(s.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),s,p=>l(this,null,function*(){var W,O;if(!(a!=null&&a.includes(p.chainId)))return null;if(!F(i))throw new Error(`${i} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return _(i).getOfflineSigner(p.chainId);case "offlineSignerAuto":return _(i).getOfflineSignerAuto(p.chainId);case "offlineSignerOnlyAmino":return _(i).getOfflineSignerOnlyAmino(p.chainId);default:return _(i).getOfflineSignerAuto(p.chainId)}}),S=(W=u.getState().chainsConfig)==null?void 0:W[p.chainId],T={url:p.rpc,headers:P({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(T,g,e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!o&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!r,refetchOnWindowFocus:false})}function Vs(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(s=>s.walletType),a=y(s=>s.activeChainIds),r=y.getState().status==="connected"&&y.getState().accounts&&u.getState()._reconnectConnector===o,n=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,o,e,a],[a,e,t,o]);return reactQuery.useQuery({queryKey:n,queryFn:c=>l(this,[c],function*({queryKey:[,s,i]}){if(s.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),s,p=>l(this,null,function*(){var O,m;if(!(a!=null&&a.includes(p.chainId)))return null;if(!F(i))throw new Error(`${i} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return _(i).getOfflineSigner(p.chainId);case "offlineSignerAuto":return _(i).getOfflineSignerAuto(p.chainId);case "offlineSignerOnlyAmino":return _(i).getOfflineSignerOnlyAmino(p.chainId);default:return _(i).getOfflineSignerAuto(p.chainId)}}),S=(O=u.getState().chainsConfig)==null?void 0:O[p.chainId],T={url:p.rpc,headers:P({},(S==null?void 0:S.rpcHeaders)||{})},M=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(T,g,P({gasPrice:M},e!=null&&e.multiChain?(m=e.opts)==null?void 0:m[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!o&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!r,refetchOnWindowFocus:false})}var _t=({children:e})=>{let[t,o]=react.useState(false);return react.useEffect(()=>{o(true);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var An=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(ee)==="Active",{_reconnect:t,_onReconnectFailed:o,_reconnectConnector:a,iframeOptions:r,chains:n,pingInterval:s}=u(),{activeChainIds:i,wcSignClients:c}=y(),f=F(a||void 0);return react.useEffect(()=>{let p=()=>l(void 0,null,function*(){if(e&&f&&a&&(i!=null&&i[0])){let d=y.getState().lastPing;if(d&&Date.now()-d<s)return;let g=_(a);try{if(!(yield g.getKey(i[0])))throw new Error("No account found");y.setState({lastPing:Date.now()});return}catch(S){B({onError:o});}}});return window.addEventListener("focus",p),()=>{window.removeEventListener("focus",p);}},[e,f,a,n,i,s]),react.useEffect(()=>{if(!r||r.autoConnect===false||!r.allowedIframeParentOrigins.length||!n)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(d=>{if(d)return te({chainId:n.map(g=>g.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(a){if(!f)return;e&&i?B({onError:o}):!e&&t&&B({onError:o});}},[f]),react.useEffect(()=>{var p,d,g,S,T,M,W,O,m,A,b,k,K,D,j,oe,C,w,h,E;if(a){if(!f)return;a==="cosmostation"&&((d=(p=ue()).subscription)==null||d.call(p,()=>{B({onError:o});})),a==="keplr"&&((S=(g=pe()).subscription)==null||S.call(g,()=>{B({onError:o});})),a==="leap"&&((M=(T=de()).subscription)==null||M.call(T,()=>{B({onError:o});})),a==="compass"&&((O=(W=ce()).subscription)==null||O.call(W,()=>{B({onError:o});})),a==="vectis"&&((A=(m=ye()).subscription)==null||A.call(m,()=>{B({onError:o});})),a==="walletconnect"&&c.has("walletconnect")&&((k=(b=z()).subscription)==null||k.call(b,()=>{B({onError:o});})),a==="station"&&((D=(K=ge()).subscription)==null||D.call(K,()=>{B({onError:o});})),a==="xdefi"&&((oe=(j=Ce()).subscription)==null||oe.call(j,()=>{B({onError:o});})),a==="cosmiframe"&&((w=(C=le()).subscription)==null||w.call(C,()=>{B({onError:o});})),a==="okx"&&((E=(h=fe()).subscription)==null||E.call(h,()=>{B({onError:o});}));}},[a,c,f]),null},Kt=()=>(An(),null);var Ea=({children:e,grazOptions:t})=>(react.useEffect(()=>{mt(t);},[t]),jsxRuntime.jsxs(_t,{children:[e,jsxRuntime.jsx(Kt,{})]}));
|
|
25
25
|
|
|
26
26
|
exports.GrazEvents = Kt;
|
|
27
|
-
exports.GrazProvider =
|
|
28
|
-
exports.WALLET_TYPES =
|
|
29
|
-
exports.WalletType =
|
|
30
|
-
exports.checkWallet =
|
|
27
|
+
exports.GrazProvider = Ea;
|
|
28
|
+
exports.WALLET_TYPES = Ge;
|
|
29
|
+
exports.WalletType = Fe;
|
|
30
|
+
exports.checkWallet = F;
|
|
31
31
|
exports.clearRecentChain = ke;
|
|
32
32
|
exports.clearSession = N;
|
|
33
33
|
exports.configureGraz = mt;
|
|
34
34
|
exports.connect = te;
|
|
35
|
-
exports.defineChainInfo =
|
|
36
|
-
exports.defineChains =
|
|
35
|
+
exports.defineChainInfo = wr;
|
|
36
|
+
exports.defineChains = Cr;
|
|
37
37
|
exports.disconnect = Pe;
|
|
38
38
|
exports.executeContract = Ct;
|
|
39
|
-
exports.getAvailableWallets =
|
|
40
|
-
exports.getChainInfo =
|
|
41
|
-
exports.getChainInfos =
|
|
39
|
+
exports.getAvailableWallets = ji;
|
|
40
|
+
exports.getChainInfo = sr;
|
|
41
|
+
exports.getChainInfos = ar;
|
|
42
42
|
exports.getCosmostation = ue;
|
|
43
43
|
exports.getKeplr = pe;
|
|
44
44
|
exports.getLeap = de;
|
|
@@ -48,8 +48,8 @@ exports.getOkx = fe;
|
|
|
48
48
|
exports.getPara = tt;
|
|
49
49
|
exports.getQueryRaw = St;
|
|
50
50
|
exports.getQuerySmart = wt;
|
|
51
|
-
exports.getRecentChainIds =
|
|
52
|
-
exports.getRecentChains =
|
|
51
|
+
exports.getRecentChainIds = ir;
|
|
52
|
+
exports.getRecentChains = rr;
|
|
53
53
|
exports.getVectis = ye;
|
|
54
54
|
exports.getWCCosmostation = rt;
|
|
55
55
|
exports.getWCKeplr = st;
|
|
@@ -67,32 +67,32 @@ exports.sendTokens = ft;
|
|
|
67
67
|
exports.suggestChain = xe;
|
|
68
68
|
exports.suggestChainAndConnect = dt;
|
|
69
69
|
exports.useAccount = J;
|
|
70
|
-
exports.useActiveChainCurrency =
|
|
71
|
-
exports.useActiveChainIds =
|
|
72
|
-
exports.useActiveChains =
|
|
73
|
-
exports.useActiveWalletType =
|
|
74
|
-
exports.useBalance =
|
|
75
|
-
exports.useBalanceStaked =
|
|
76
|
-
exports.useBalances =
|
|
77
|
-
exports.useChainInfo =
|
|
78
|
-
exports.useChainInfos =
|
|
70
|
+
exports.useActiveChainCurrency = ws;
|
|
71
|
+
exports.useActiveChainIds = gs;
|
|
72
|
+
exports.useActiveChains = dn;
|
|
73
|
+
exports.useActiveWalletType = qr;
|
|
74
|
+
exports.useBalance = os;
|
|
75
|
+
exports.useBalanceStaked = as;
|
|
76
|
+
exports.useBalances = pn;
|
|
77
|
+
exports.useChainInfo = ys;
|
|
78
|
+
exports.useChainInfos = Cs;
|
|
79
79
|
exports.useCheckWallet = we;
|
|
80
|
-
exports.useConnect =
|
|
81
|
-
exports.useCosmWasmClient =
|
|
82
|
-
exports.useCosmWasmSigningClient =
|
|
83
|
-
exports.useDisconnect =
|
|
84
|
-
exports.useExecuteContract =
|
|
85
|
-
exports.useGrazEvents =
|
|
80
|
+
exports.useConnect = is;
|
|
81
|
+
exports.useCosmWasmClient = De;
|
|
82
|
+
exports.useCosmWasmSigningClient = Vs;
|
|
83
|
+
exports.useDisconnect = rs;
|
|
84
|
+
exports.useExecuteContract = Rs;
|
|
85
|
+
exports.useGrazEvents = An;
|
|
86
86
|
exports.useInstantiateContract = Ds;
|
|
87
|
-
exports.useOfflineSigners =
|
|
88
|
-
exports.useQueryClientValidators =
|
|
89
|
-
exports.useQueryRaw =
|
|
90
|
-
exports.useQuerySmart =
|
|
91
|
-
exports.useRecentChainIds =
|
|
92
|
-
exports.useRecentChains =
|
|
93
|
-
exports.useSendIbcTokens =
|
|
94
|
-
exports.useSendTokens =
|
|
87
|
+
exports.useOfflineSigners = ss;
|
|
88
|
+
exports.useQueryClientValidators = Ss;
|
|
89
|
+
exports.useQueryRaw = Ks;
|
|
90
|
+
exports.useQuerySmart = _s;
|
|
91
|
+
exports.useRecentChainIds = hs;
|
|
92
|
+
exports.useRecentChains = As;
|
|
93
|
+
exports.useSendIbcTokens = Ws;
|
|
94
|
+
exports.useSendTokens = vs;
|
|
95
95
|
exports.useStargateClient = We;
|
|
96
|
-
exports.useStargateSigningClient =
|
|
97
|
-
exports.useSuggestChain =
|
|
98
|
-
exports.useSuggestChainAndConnect =
|
|
96
|
+
exports.useStargateSigningClient = Qs;
|
|
97
|
+
exports.useSuggestChain = Is;
|
|
98
|
+
exports.useSuggestChainAndConnect = bs;
|
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,6 @@ import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargat
|
|
|
15
15
|
import { useShallow } from 'zustand/shallow';
|
|
16
16
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
17
17
|
|
|
18
|
-
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var Be=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var Le=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Ue=(e,t,n)=>t in e?Bt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))Gt.call(t,n)&&Ue(e,n,t[n]);if(Be)for(var n of Be(t))Ft.call(t,n)&&Ue(e,n,t[n]);return e},G=(e,t)=>Lt(e,Ut(t));var l=(e,t,n)=>new Promise((a,i)=>{var o=c=>{try{r(n.next(c));}catch(f){i(f);}},s=c=>{try{r(n.throw(c));}catch(f){i(f);}},r=c=>c.done?a(c.value):Promise.resolve(c.value).then(o,s);r((n=n.apply(e,t)).next());});var Ge=(e,t,n)=>(t=e[Le("asyncIterator")])?t.call(e):(e=e[Le("iterator")](),t={},n=(a,i)=>(i=e[a])&&(t[a]=o=>new Promise((s,r,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(f=>s({value:f,done:c}),r)))),n("next"),n("return"),t);var te="graz-reconnect-session";var Fe=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p.PARA="para",p))(Fe||{}),ze=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},oe={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},jt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},C=create(subscribeWithSelector(persist(()=>oe,jt))),u=create(subscribeWithSelector(persist(()=>qt,Qt)));var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var He={},Xe=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var m;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let r=(m=o.split("MetaMask/v")[1])==null?void 0:m.split(".")[0];if(!(Number(r)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,true}),enable:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(G(k({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,r)=>l(void 0,null,function*(){return t.signAmino(o,s,r)}),getKey:o=>l(void 0,null,function*(){return typeof He[o]!="undefined"?He[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,r)=>l(void 0,null,function*(){return t.signDirect(o,s,r)}),signArbitrary:(o,s,r)=>l(void 0,null,function*(){return t.signArbitrary(o,s,r)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{B(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var en=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}=e;if(!t||!n||!a||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}},tn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Je=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let P=(()=>{switch(S.algo){case "secp256k1":return rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:tn(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:P,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,P,v;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(P=g.gasPriceStep)==null?void 0:P.average,high_gas_price:(v=g.gasPriceStep)==null?void 0:v.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,P]=d;return e.getOfflineSigner(g).signDirect(S,en(P))},signAmino:(...d)=>{let[g,S,P]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,P)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let R=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!R)throw new Error(`Wallet not connected to account ${g}`);let E=(()=>{switch(R.algo){case "secp256k1":return encodeSecp256k1Pubkey(R.pubkey);case "ed25519":return encodeEd25519Pubkey(R.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:R.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:E.value}}}),subscription:d=>{let g=()=>{B(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},et=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=p=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(O=>O.id===e.id&&(!p||O.version===p))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var D;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let O=(D=p.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(O)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield i()),true}),s=p=>l(void 0,null,function*(){(yield a())||(yield i());}),r=(p,A,O)=>l(void 0,null,function*(){let x=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:O}}}}),N=O.accountNumber,D=new Te(N.low,N.high,N.unsigned);return {signature:x.signature,signed:G(k({},x.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(x.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(x.signed.bodyBytes))})}}),c=(p,A,O)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:O}}}})}),f=p=>l(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[p]=A,fe[p]}),m=p=>l(void 0,null,function*(){let A=yield f(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[A,O,x,N]=p;return yield c(A,O,x)}),g=(...p)=>l(void 0,null,function*(){var $;let[A,O,x]=p,N=G(k({},x),{accountNumber:Te.fromString((($=x.accountNumber)==null?void 0:$.toString())||"0"),authInfoBytes:x.authInfoBytes,bodyBytes:x.bodyBytes});return yield r(A,O,N)}),P=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signAmino:(A,O)=>d(p,A,O)});return {enable:s,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signDirect:(A,O)=>g(p,A,O),signAmino:(A,O)=>d(p,A,O)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return P(p)}),getOfflineSignerOnlyAmino:P,init:o,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var tt=()=>et({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var r;let s=()=>{B(),o();};return (r=window.okxwallet)==null||r.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var nn="para.reconnect",re=null,nt=()=>{let e=()=>{let i=C.getState().paraConnector;if(!i)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return i},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let n=()=>re||(re=l(void 0,null,function*(){let i=C.getState().paraConnector;if(i)return i;try{let o;if(t.connectorClass)o=t.connectorClass;else if(t.connectorImportPath){if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import(t.connectorImportPath),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector from dynamic URL/path. Ensure it exports `ParaGrazConnector`.");o=f;}else {if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import('@getpara/graz-integration'),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");o=f;}let s=u.getState().chains,r=new o(t,s);if(C.setState(c=>G(k({},c),{paraConnector:r})),!r)throw new Error("Para connector initialization failed. Check config and dependencies.");return r}catch(o){throw re=null,new Error("Para connector init failed. Check @getpara/graz-integration and ParaConfig.")}}),re);return {enable:i=>l(void 0,null,function*(){let o=Array.isArray(i)?i:[i];try{let s=yield n();C.setState({paraConnector:s,status:"connecting"}),yield s.enable(o);let r=Object.fromEntries(yield Promise.all(o.map(c=>l(void 0,null,function*(){return [c,yield s.getKey(c)]}))));C.setState(c=>({accounts:k(k({},c.accounts||{}),r),activeChainIds:Array.from(new Set([...c.activeChainIds||[],...o])),status:"connected"})),u.setState(c=>({recentChainIds:Array.from(new Set([...c.recentChainIds||[],...o])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"})),typeof window!="undefined"&&window.sessionStorage.setItem(nn,"1");}catch(s){throw C.setState({paraConnector:null,status:"disconnected"}),new Error(`Para enable failed${s instanceof Error?`: ${s.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let i=e();try{yield i.disconnect(),yield i.getParaWebClient().logout();}catch(o){throw new Error("Para disconnect failed. Wallet may already be disconnected.")}finally{C.setState({paraConnector:null,status:"disconnected"});}}),getKey:i=>l(void 0,null,function*(){try{return yield e().getKey(i)}catch(o){throw new Error("Failed to get key. Check chain connection and Cosmos API key settings at developer.getpara.com.")}}),getOfflineSigner:i=>{try{return e().getOfflineSigner(i)}catch(o){throw new Error("Failed to get offline signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerOnlyAmino:i=>{try{return e().getOfflineSignerOnlyAmino(i)}catch(o){throw new Error("Failed to get Amino signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerAuto:i=>{try{return e().getOfflineSignerAuto(i)}catch(o){throw new Error("Failed to get auto signer. Check Para auth and Cosmos support in developer portal.")}},signAmino:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signAmino(i,o,s,r)}catch(c){throw new Error("Amino signing failed. User rejected or invalid transaction/signer.")}}),signDirect:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signDirect(i,o,s,r)}catch(c){throw new Error("Direct signing failed. User rejected or invalid transaction/signer.")}}),signArbitrary:(i,o,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(i,o,s)}catch(r){throw new Error("Arbitrary signing failed. User rejected or feature not supported.")}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ye=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let r=()=>{B(),s();};return window.addEventListener("station_wallet_change",r),()=>{window.removeEventListener("station_wallet_change",r);}},getKey:s=>l(void 0,null,function*(){let r=yield t.getKey(s);return k({isKeystone:false},r)}),getOfflineSigner:s=>{try{let r=t.getOfflineSignerOnlyAmino(s);return Object.assign(r,{signDirect:(m,d)=>{throw new Error("signDirect not supported by Station")}})}catch(r){throw console.error(r),r}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let r=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,m,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((m=c.gasPriceStep)==null?void 0:m.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(r);}catch(r){throw console.error(r),r}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,r,c,f)=>t.signAmino(s,r,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:r=>e.enable(r),getOfflineSigner:r=>{let c=e.getOfflineSigner(r);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:r=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(r);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:r=>l(void 0,null,function*(){let c=yield e.getKey(r);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:r=>{let c=()=>{B(),r();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...r)=>{let c=r[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...r)=>l(void 0,null,function*(){var m;let[c]=r;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(m=c.bech32Config)==null?void 0:m.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...r)=>l(void 0,null,function*(){var d;let{1:c,2:f}=r,m=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Te.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}}),signAmino:(...r)=>l(void 0,null,function*(){let{1:c,2:f}=r;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},ot=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),it=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Pe=(e,t,n=new Error("Promise timed out"))=>{let a=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,a])};var q=e=>{var D,$,ie;if(!((ie=($=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:$.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",a=y=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(z()){if(ot()){let T=h(w.mobile.android,y,"android");window.open(T,"_self","noreferrer noopener");}if(it()){let T=h(w.mobile.ios,y,"ios");window.open(T,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=C.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),C.setState({wcSignClients:y}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield h.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=y=>{try{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let T=h.session.getAll(),W=T.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let _=T.find(Q=>{var Y,J;return (J=(Y=Q.requiredNamespaces.cosmos)==null?void 0:Y.chains)==null?void 0:J.includes(`cosmos:${y}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return W}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},r=y=>{try{return s(y)}catch(w){return}},c=y=>l(void 0,null,function*(){try{let w=y.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=C.getState(),h=w.get(t);if(h)return h;let T=yield SignClient.init(y.options);return w.set(t,T),C.setState({wcSignClients:w}),T}),m=y=>{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)return ()=>{};let T=W=>{let M=C.getState().accounts;if(W.params.event.name==="accountsChanged"&&M&&!Object.values(M).map(_=>_.bech32Address).includes(W.params.event.data[0])){let _=W.params.chainId.split(":")[1];_&&d([_]);}else y();};return h.events.on("session_delete",i),h.events.on("session_expire",i),h.events.on("session_event",T),()=>{h.events.off("session_delete",i),h.events.off("session_expire",i),h.events.off("session_event",T);}},d=y=>l(void 0,null,function*(){var J;let w=typeof y=="string"?[y]:y,{wcSignClients:h,activeChainIds:T}=C.getState(),W=h.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:M,chains:_}=u.getState();if(!((J=M==null?void 0:M.options)!=null&&J.projectId))throw new Error("walletConnect.options.projectId is not defined");let Q=new WalletConnectModal(k({projectId:M.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},M.walletConnectModal)),Y=r(w);if(!Y){let{uri:U,approval:ae}=yield Pe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?a(U):yield Q.openModal({uri:U});let ce=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Oe,ee)=>{ae().then(_e=>{let Ke=_e.sessionProperties;if(!Ke)return ee(new Error("No session properties"));let Ee=JSON.parse(String(Ke.keys));if(Ee.length===0)return ee(new Error("No accounts"));if(!Ee[0])return ee(new Error("No accounts"));let Ne={};return Ee.forEach(H=>{Ne[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),C.setState(H=>({accounts:k(k({},H.accounts||{}),Ne)})),Oe(_e)}).catch(ee),V.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:true});})});try{let V=new AbortController,Oe=V.signal;Q.subscribeModal(ee=>{ee.open||V.abort();}),yield ce(Oe);}catch(V){if(Q.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||Q.closeModal(),Promise.resolve()}try{yield Pe(l(void 0,null,function*(){var ae;let U=Object.fromEntries(yield Promise.all((ae=T||w)==null?void 0:ae.map(ce=>l(void 0,null,function*(){return [ce,yield S(ce)]}))));C.setState({accounts:U});}),15e3,new Error("Connection timeout"));}catch(U){if(o(Y.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),g=y=>l(void 0,null,function*(){let w=yield S(y);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=y=>l(void 0,null,function*(){let w=s([y]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let T=h.find(W=>W.chainId===y);if(!T)throw new Error(`No wallet connect key for chainId ${y}`);return G(k({},T),{pubKey:Buffer.from(String(T.pubKey),n)})}),P=(...y)=>l(void 0,null,function*(){var J,U;let[w,h,T]=y,{accounts:W,wcSignClients:M}=C.getState(),_=M.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let Q=(J=s([w]))==null?void 0:J.topic;if(!Q)throw new Error("No wallet connect session");if(!T.bodyBytes)throw new Error("No bodyBytes");if(!T.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield _.request({topic:Q,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:T.chainId,accountNumber:(U=T.accountNumber)==null?void 0:U.toString(),bodyBytes:T.bodyBytes?Buffer.from(T.bodyBytes).toString(n):null,authInfoBytes:T.authInfoBytes?Buffer.from(T.authInfoBytes).toString(n):null}}}})}),v=(...y)=>l(void 0,null,function*(){var _;let[w,h,T]=y,{signature:W,signed:M}=yield P(w,h,T);return {signed:{chainId:(_=M.chainId)!=null?_:"",accountNumber:M.accountNumber?BigInt(M.accountNumber):BigInt(0),authInfoBytes:M.authInfoBytes?new Uint8Array(Buffer.from(M.authInfoBytes,n)):new Uint8Array([]),bodyBytes:M.bodyBytes?new Uint8Array(Buffer.from(M.bodyBytes,n)):new Uint8Array([])},signature:W}}),R=(...y)=>l(void 0,null,function*(){var U;let[w,h,T,W]=y,{wcSignClients:M}=C.getState(),_=M.get(t),{accounts:Q}=C.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let Y=(U=s([w]))==null?void 0:U.topic;if(!Y)throw new Error("No wallet connect session");return a(),yield _.request({topic:Y,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:T}}})}),E=(...y)=>l(void 0,null,function*(){let[w,h,T,W]=y;return yield R(w,h,T)}),p=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>v(y,w,h)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signAmino:(w,h)=>E(y,w,h)});return {enable:d,disable:y=>l(void 0,null,function*(){var T;let{wcSignClients:w}=C.getState(),h=w.get(t);if(y===void 0){let W=h==null?void 0:h.session.getAll();W!==void 0&&(yield Promise.all(W.map(M=>o(M.topic))));}else typeof y=="string"?yield o((T=s([y]))==null?void 0:T.topic):yield Promise.all(y.map(W=>{var M;return o((M=s([W]))==null?void 0:M.topic)}));(h==null?void 0:h.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>v(y,w,h),signAmino:(w,h)=>E(y,w,h)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield S(y)).isNanoLedger?A(y):p(y)}),getOfflineSignerOnlyAmino:A,signAmino:E,signDirect:v,subscription:m,init:f}};var rt=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var st=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":","");return o?`${r}://wc?${o}`:`${r}://wc`}};return q(e)};var at=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${r}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var ct=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${r}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var we=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var F=(e=u.getState().walletType)=>{try{return K(e),!0}catch(t){return false}},B=()=>{window.sessionStorage.removeItem(te),C.setState(oe);},K=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return de();case "leap":return me();case "cosmostation":return pe();case "vectis":return Ce();case "walletconnect":return q();case "wc_keplr_mobile":return at();case "wc_leap_mobile":return ct();case "wc_cosmostation_mobile":return st();case "wc_clot_mobile":return rt();case "metamask_snap_leap":return tt();case "metamask_snap_cosmos":return Xe();case "station":return ye();case "xdefi":return we();case "cosmiframe":return ue();case "compass":return le();case "initia":return Je();case "okx":return ge();case "para":return nt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((a=t.setDefaultOptions)==null||a.call(t,n)),t},Vi=()=>Object.fromEntries(ze.map(e=>[e,F(e)])),lt=e=>e==="metamask_snap_leap",ut=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),se=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",pt=e=>e==="para";var ne=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:r,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(se(f)){let E=K("walletconnect"),{disable:p}=E;p&&p();}if(!F(f))throw new Error(`${f} is not available`);let d=K(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=r==null?void 0:r.map(E=>E.chainId);g.forEach(E=>{if(!(S!=null&&S.includes(E)))throw new Error(`Chain ${E} is not provided in GrazProvider`)}),C.setState(E=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return E.activeChainIds&&g.filter(O=>{var x;return !((x=E.activeChainIds)!=null&&x.includes(O))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:P}=C.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!se(f)){let E={};if(lt(f)){let p={};try{for(var n=Ge(g),a,i,o;a=!(i=yield n.next()).done;a=!1){let A=i.value;p[A]=yield d.getKey(A);}}catch(i){o=[i];}finally{try{a&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}E=p;}else if(ut()&&d.getKeys){let p=yield d.getKeys(g);g.forEach((A,O)=>{let x=p[O];x&&(E[A]=x);});}else E=Object.fromEntries(yield Promise.all(g.map(p=>l(void 0,null,function*(){return [p,yield d.getKey(p)]}))));C.setState(p=>({accounts:k(k({},p.accounts||{}),E)}));}u.setState(E=>({recentChainIds:[...E.recentChainIds||[],...g].filter((p,A,O)=>O.indexOf(p)===A)})),C.setState(E=>({activeChainIds:[...E.activeChainIds||[],...g].filter((p,A,O)=>O.indexOf(p)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(te,"Active");let v=g.map(E=>r.find(p=>p.chainId===E));return {accounts:C.getState().accounts,walletType:f,chains:v}}catch(s){throw console.error("connect ",s),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),s}}),ke=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(te);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,n=()=>{if(se(u.getState().walletType)){let a=K("walletconnect"),{disable:i}=a;i&&i();}if(pt(u.getState().walletType)){let a=K("para"),{disable:i}=a;i&&i();}};if(t){let a=C.getState().accounts;t.forEach(o=>{a==null||delete a[o];}),Object.values(a||{}).length===0?(n(),C.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(C.setState(o=>{var s;return {activeChainIds:(s=o.activeChainIds)==null?void 0:s.filter(r=>!t.includes(r)),accounts:a}}),u.setState(o=>{var s;return {recentChainIds:(s=o.recentChainIds)==null?void 0:s.filter(r=>!t.includes(r))}}));}else n(),C.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:a}=u.getState();try{let o=F(n||void 0);if(t&&o&&n)return se(n)?void 0:yield ne({chainId:t,walletType:n,autoReconnect:a})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),ke();}}),dt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!F(n))throw new Error(`${n} is not available`);let i=K(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),r=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:r}});var xe=()=>{u.setState({recentChainIds:null});},sr=()=>u.getState().recentChainIds,ar=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(a=>t.find(i=>i.chainId===a)))!=null?n:null},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},lr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Me=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield K(t).experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield ne({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ft=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var gt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:a,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,a,i,o)}),yt=m=>l(void 0,[m],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:a,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:r,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,a,i,o,s,r,c,f)}),Ct=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,a,i)}),wt=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,a,s,o)}),St=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),ht=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return n.queryContractRaw(e,a)};var Sr=e=>e,hr=e=>e;var At=e=>e?Object.keys(e).length===0:true;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},It=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function We(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:i}={}){return new Promise((r,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let f=[],m=[],d=new Map,g=false,S=false,P=false,v=0,R=0,E=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=O=>{g=true,S=true,c(O);};i&&(i.aborted&&p(bt(i)),i.addEventListener("abort",()=>{p(bt(i));}));let A=()=>l(this,null,function*(){if(S)return;let O=yield E.next(),x=R;if(R++,O.done){if(P=true,v===0&&!S){if(!a&&m.length>0){p(new AggregateError(m));return}if(S=true,d.size===0){r(f);return}let N=[];for(let[D,$]of f.entries())d.get(D)!==Ot&&N.push($);r(N);}return}v++,l(this,null,function*(){try{let N=yield O.value;if(S)return;let D=yield t(N,x);D===Ot&&d.set(x,D),f[x]=D,v--,yield A();}catch(N){if(a)p(N);else {m.push(N),v--;try{yield A();}catch(D){p(D);}}}});});l(this,null,function*(){for(let O=0;O<n;O++){try{yield A();}catch(x){p(x);break}if(P||g)break}});})})}var Ot=Symbol("skip");var j=({chainId:e,multiChain:t})=>{let n=u(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!a):return [a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!a):return n;default:return [n[0]]}},X=(e,t,n)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let o=yield We(t,n,{concurrency:a});return Object.fromEntries(o.map((s,r)=>[t[r].chainId,s]))}return yield n(t[0])}),Et=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Re=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:k({},(r==null?void 0:r.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},De=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:k({},(r==null?void 0:r.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var Qr=()=>u(useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),Se=e=>{let n=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>F(i)})};var Z=e=>{let t=u(r=>r.walletType),n=C(r=>r.activeChainIds),a=j({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=C(r=>r.accounts),o=C(r=>r.status);return useEffect(()=>C.subscribe(r=>r.status,(r,c)=>{var f,m,d;if(r==="connected"){let{accounts:g,activeChainIds:S}=C.getState(),{chains:P}=u.getState(),{walletType:v}=u.getState();if(!g||!S||!P)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(m=e==null?void 0:e.onConnect)==null||m.call(e,{accounts:g,chains:S.map(R=>P.find(E=>E.chainId===R)),walletType:v,isReconnect:c==="reconnecting"});}r==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>i?Et(!!(e!=null&&e.multiChain),a,r=>i[r.chainId]):void 0,[i,a,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:L,status:o}},mn=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),a=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=Re({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),o=useMemo(()=>["USE_ALL_BALANCES",i,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,i]);return useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var P;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((P=d.bech32Config)!=null&&P.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!At(i)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},rs=e=>{let t=j({chainId:e.chainId}),{data:n}=Z({chainId:e.chainId}),a=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=mn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,a,e.chainId],r=useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(m=>m.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?true:e.enabled)});return G(k({},r),{refetch:c=>l(void 0,null,function*(){return yield o(),r.refetch(c)})})},ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:ne,onError:(s,r)=>e==null?void 0:e(s,r),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},as=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:ke,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},cs=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),a=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chain found");if(!F(s))throw new Error(`${s} is not available`);return yield X(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield dt({chainId:m.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!n&&!!a,refetchOnWindowFocus:false})},ls=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),{data:a}=Re({chainId:t.map(s=>s.chainId),multiChain:true}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",a,t,i],[t,i,a]);return useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var S,P;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (P=s[d.chainId])==null?void 0:P.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var Cs=()=>C(e=>e.activeChainIds),fn=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let n=(a=u.getState().chains)==null?void 0:a.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ss=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},hs=({denom:e})=>{let t=fn();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(r=>r.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},As=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},Is=()=>({data:u(t=>t.recentChainIds),clear:xe}),bs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let a=(i=u.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(a)return a}).filter(Boolean),clear:xe}},Os=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:Me,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},Es=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:mt,onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=Z(),i=a==null?void 0:a.bech32Address,o=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>gt(k({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=Z(),i=a==null?void 0:a.bech32Address,o=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>yt(k({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},_s=({codeId:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,r=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m;if(!o)throw new Error("senderAddress is undefined");let f=G(k({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,codeId:e});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,instantiateContract:r.mutate,instantiateContractAsync:r.mutateAsync,status:r.status}},Ks=({contractAddress:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,r=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m,d,g;if(!o)throw new Error("senderAddress is undefined");let f=G(k({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return wt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,executeContract:r.mutate,executeContractAsync:r.mutateAsync,status:r.status}},Ns=e=>{let{data:t}=De();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return St(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Bs=e=>{let{data:t}=De(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ht(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Hs(e){let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var R,E;if(!(a!=null&&a.includes(m.chainId)))return null;if(!F(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return K(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return K(r).getOfflineSignerOnlyAmino(m.chainId);default:return K(r).getOfflineSignerAuto(m.chainId)}}),S=(R=u.getState().chainsConfig)==null?void 0:R[m.chainId],P={url:m.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield SigningStargateClient.connectWithSigner(P,g,e!=null&&e.multiChain?(E=e.opts)==null?void 0:E[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}function Xs(e){let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var E,p;if(!(a!=null&&a.includes(m.chainId)))return null;if(!F(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return K(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return K(r).getOfflineSignerOnlyAmino(m.chainId);default:return K(r).getOfflineSignerAuto(m.chainId)}}),S=(E=u.getState().chainsConfig)==null?void 0:E[m.chainId],P={url:m.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})},v=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(P,g,k({gasPrice:v},e!=null&&e.multiChain?(p=e.opts)==null?void 0:p[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}var Kt=({children:e})=>{let[t,n]=useState(false);return useEffect(()=>{n(true);},[]),jsx(Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(te)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:a,iframeOptions:i,chains:o,pingInterval:s}=u(),{activeChainIds:r,wcSignClients:c}=C(),f=F(a||void 0);return useEffect(()=>{let m=()=>l(void 0,null,function*(){if(e&&f&&a&&(r!=null&&r[0])){let d=C.getState().lastPing;if(d&&Date.now()-d<s)return;let g=K(a);try{if(!(yield g.getKey(r[0])))throw new Error("No account found");C.setState({lastPing:Date.now()});return}catch(S){L({onError:n});}}});return window.addEventListener("focus",m),()=>{window.removeEventListener("focus",m);}},[e,f,a,o,r,s]),useEffect(()=>{if(!i||i.autoConnect===false||!i.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(i.allowedIframeParentOrigins).isReady().then(d=>{if(d)return ne({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[i]),useEffect(()=>{if(a){if(!f)return;e&&r?L({onError:n}):!e&&t&&L({onError:n});}},[f]),useEffect(()=>{var m,d,g,S,P,v,R,E,p,A,O,x,N,D,$,ie,y,w,h,T;if(a){if(!f)return;a==="cosmostation"&&((d=(m=pe()).subscription)==null||d.call(m,()=>{L({onError:n});})),a==="keplr"&&((S=(g=de()).subscription)==null||S.call(g,()=>{L({onError:n});})),a==="leap"&&((v=(P=me()).subscription)==null||v.call(P,()=>{L({onError:n});})),a==="compass"&&((E=(R=le()).subscription)==null||E.call(R,()=>{L({onError:n});})),a==="vectis"&&((A=(p=Ce()).subscription)==null||A.call(p,()=>{L({onError:n});})),a==="walletconnect"&&c.has("walletconnect")&&((x=(O=q()).subscription)==null||x.call(O,()=>{L({onError:n});})),a==="station"&&((D=(N=ye()).subscription)==null||D.call(N,()=>{L({onError:n});})),a==="xdefi"&&((ie=($=we()).subscription)==null||ie.call($,()=>{L({onError:n});})),a==="cosmiframe"&&((w=(y=ue()).subscription)==null||w.call(y,()=>{L({onError:n});})),a==="okx"&&((T=(h=ge()).subscription)==null||T.call(h,()=>{L({onError:n});}));}},[a,c,f]),null},Nt=()=>(bn(),null);var Pa=({children:e,grazOptions:t})=>(useEffect(()=>{ft(t);},[t]),jsxs(Kt,{children:[e,jsx(Nt,{})]}));
|
|
18
|
+
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var Be=Object.getOwnPropertySymbols;var Ft=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Le=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Ue=(e,t,o)=>t in e?Bt(e,t,{enumerable:true,configurable:true,writable:true,value:o}):e[t]=o,k=(e,t)=>{for(var o in t||(t={}))Ft.call(t,o)&&Ue(e,o,t[o]);if(Be)for(var o of Be(t))Gt.call(t,o)&&Ue(e,o,t[o]);return e},F=(e,t)=>Lt(e,Ut(t));var l=(e,t,o)=>new Promise((a,r)=>{var n=c=>{try{i(o.next(c));}catch(f){r(f);}},s=c=>{try{i(o.throw(c));}catch(f){r(f);}},i=c=>c.done?a(c.value):Promise.resolve(c.value).then(n,s);i((o=o.apply(e,t)).next());});var Fe=(e,t,o)=>(t=e[Le("asyncIterator")])?t.call(e):(e=e[Le("iterator")](),t={},o=(a,r)=>(r=e[a])&&(t[a]=n=>new Promise((s,i,c)=>(n=r.call(e,n),c=n.done,Promise.resolve(n.value).then(f=>s({value:f,done:c}),i)))),o("next"),o("return"),t);var te="graz-reconnect-session";var Ge=(m=>(m.KEPLR="keplr",m.LEAP="leap",m.VECTIS="vectis",m.COSMOSTATION="cosmostation",m.WALLETCONNECT="walletconnect",m.WC_KEPLR_MOBILE="wc_keplr_mobile",m.WC_LEAP_MOBILE="wc_leap_mobile",m.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",m.WC_CLOT_MOBILE="wc_clot_mobile",m.METAMASK_SNAP_LEAP="metamask_snap_leap",m.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",m.STATION="station",m.XDEFI="xdefi",m.COSMIFRAME="cosmiframe",m.COMPASS="compass",m.INITIA="initia",m.OKX="okx",m.PARA="para",m))(Ge||{}),ze=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},oe={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},$t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},y=create(subscribeWithSelector(persist(()=>oe,$t))),u=create(subscribeWithSelector(persist(()=>qt,jt)));var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var He={},Xe=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var p;let n=yield e.request({method:"web3_clientVersion"});if(!n.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let i=(p=n.split("MetaMask/v")[1])==null?void 0:p.split(".")[0];if(!(Number(i)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,true}),enable:n=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(F(k({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,s,i)=>l(void 0,null,function*(){return t.signAmino(n,s,i)}),getKey:n=>l(void 0,null,function*(){return typeof He[n]!="undefined"?He[n]:t.getKey(n)}),getOfflineSignerAuto:n=>l(void 0,null,function*(){return (yield t.getKey(n)).isNanoLedger?t.getOfflineSignerOnlyAmino(n):t.getOfflineSigner(n)}),getOfflineSignerOnlyAmino:n=>t.getOfflineSignerOnlyAmino(n),signDirect:(n,s,i)=>l(void 0,null,function*(){return t.signDirect(n,s,i)}),signArbitrary:(n,s,i)=>l(void 0,null,function*(){return t.signArbitrary(n,s,i)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:n=>{let s=()=>{B(),n();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var en=e=>{let{bodyBytes:t,authInfoBytes:o,chainId:a,accountNumber:r}=e;if(!t||!o||!a||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:o,chainId:a,accountNumber:r}},tn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Je=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let P=(()=>{switch(S.algo){case "secp256k1":return rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:tn(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:P,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,P,v;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(P=g.gasPriceStep)==null?void 0:P.average,high_gas_price:(v=g.gasPriceStep)==null?void 0:v.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,P]=d;return e.getOfflineSigner(g).signDirect(S,en(P))},signAmino:(...d)=>{let[g,S,P]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,P)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let D=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!D)throw new Error(`Wallet not connected to account ${g}`);let E=(()=>{switch(D.algo){case "secp256k1":return encodeSecp256k1Pubkey(D.pubkey);case "ed25519":return encodeEd25519Pubkey(D.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:D.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:E.value}}}),subscription:d=>{let g=()=>{B(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},et=e=>{let t=window.ethereum;if(t&&e){let o=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=m=>l(void 0,null,function*(){try{let A=yield o();return Object.values(A).find(O=>O.id===e.id&&(!m||O.version===m))}catch(A){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var R;let m=yield t.request({method:"web3_clientVersion"});if(!m.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let O=(R=m.split("MetaMask/v")[1])==null?void 0:R.split(".")[0];if(!(Number(O)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield r()),true}),s=m=>l(void 0,null,function*(){(yield a())||(yield r());}),i=(m,A,O)=>l(void 0,null,function*(){let x=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:m,signerAddress:A,signDoc:O}}}}),N=O.accountNumber,R=new Te(N.low,N.high,N.unsigned);return {signature:x.signature,signed:F(k({},x.signed),{accountNumber:`${R.toString()}`,authInfoBytes:new Uint8Array(Object.values(x.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(x.signed.bodyBytes))})}}),c=(m,A,O)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:m,signerAddress:A,signDoc:O}}}})}),f=m=>l(void 0,null,function*(){if(typeof fe[m]!="undefined")return fe[m];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:m}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[m]=A,fe[m]}),p=m=>l(void 0,null,function*(){let A=yield f(m);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...m)=>l(void 0,null,function*(){let[A,O,x,N]=m;return yield c(A,O,x)}),g=(...m)=>l(void 0,null,function*(){var Q;let[A,O,x]=m,N=F(k({},x),{accountNumber:Te.fromString(((Q=x.accountNumber)==null?void 0:Q.toString())||"0"),authInfoBytes:x.authInfoBytes,bodyBytes:x.bodyBytes});return yield i(A,O,N)}),P=m=>({getAccounts:()=>l(void 0,null,function*(){return [yield p(m)]}),signAmino:(A,O)=>d(m,A,O)});return {enable:s,experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:m[0]}}}});}),getKey:f,getOfflineSigner:m=>({getAccounts:()=>l(void 0,null,function*(){return [yield p(m)]}),signDirect:(A,O)=>g(m,A,O),signAmino:(A,O)=>d(m,A,O)}),getOfflineSignerAuto:m=>l(void 0,null,function*(){return P(m)}),getOfflineSignerOnlyAmino:P,init:n,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var tt=()=>et({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:n=>{var i;let s=()=>{B(),n();};return (i=window.okxwallet)==null||i.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var re=null,nt=()=>{let e=()=>{let r=y.getState().paraConnector;if(!r)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return r},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let o=()=>re||(re=l(void 0,null,function*(){var n,s;let r=y.getState().paraConnector;if(r)return r;try{let i;if(t.connectorClass)i=t.connectorClass;else {if(typeof window=="undefined")throw new Error("Para connector requires client-side execution (SSR is unsupported).");let p=yield import('@getpara/graz-integration'),d=p==null?void 0:p.ParaGrazConnector;if(typeof d!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");i=d;}let c=u.getState().chains,f=new i(t,c);if(y.setState(p=>F(k({},p),{paraConnector:f})),!f)throw new Error("Para connector initialization failed. Check config and dependencies.");return f}catch(i){throw re=null,(i==null?void 0:i.code)==="MODULE_NOT_FOUND"||((n=i==null?void 0:i.message)==null?void 0:n.includes("Cannot find module"))||((s=i==null?void 0:i.message)==null?void 0:s.includes("Failed to resolve"))?new Error("Para integration package not found. Install @getpara/graz-integration to use Para wallet: npm install @getpara/graz-integration"):new Error(`Para connector init failed: ${(i==null?void 0:i.message)||"Unknown error"}. Check @getpara/graz-integration and ParaConfig.`)}}),re);return {enable:r=>l(void 0,null,function*(){var s,i;let n=Array.isArray(r)?r:[r];try{let c=yield o();y.setState({paraConnector:c,status:"connecting"}),yield c.enable(n);let f=Object.fromEntries(yield Promise.all(n.map(p=>l(void 0,null,function*(){return [p,yield c.getKey(p)]}))));y.setState(p=>({accounts:k(k({},p.accounts||{}),f),activeChainIds:Array.from(new Set([...p.activeChainIds||[],...n])),status:"connected"})),u.setState(p=>({recentChainIds:Array.from(new Set([...p.recentChainIds||[],...n])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"}));}catch(c){throw y.setState({paraConnector:null,status:"disconnected"}),((s=c==null?void 0:c.message)==null?void 0:s.includes("not found"))||((i=c==null?void 0:c.message)==null?void 0:i.includes("Cannot find"))?new Error("Para wallet connection failed: Required packages not installed. Install @getpara/graz-integration to enable Para wallet."):new Error(`Para enable failed${c instanceof Error?`: ${c.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let r=y.getState().paraConnector;if(!r){y.setState({paraConnector:null,status:"disconnected"});return}try{yield r.disconnect(),yield r.getParaWebClient().logout();}catch(n){throw new Error(`Para disconnect failed${n!=null&&n.message?`: ${n.message}`:". Wallet may already be disconnected."}`)}finally{y.setState({paraConnector:null,status:"disconnected"});}}),getKey:r=>l(void 0,null,function*(){try{return yield e().getKey(r)}catch(n){throw new Error(`Failed to get key${n!=null&&n.message?`: ${n.message}`:""}. Check chain connection and Cosmos API key settings at developer.getpara.com.`)}}),getOfflineSigner:r=>{try{return e().getOfflineSigner(r)}catch(n){throw new Error(`Failed to get offline signer${n!=null&&n.message?`: ${n.message}`:""}. Check Para auth and Cosmos support in developer portal.`)}},getOfflineSignerOnlyAmino:r=>{try{return e().getOfflineSignerOnlyAmino(r)}catch(n){throw new Error(`Failed to get Amino signer${n!=null&&n.message?`: ${n.message}`:""}. Check Para auth and Cosmos support in developer portal.`)}},getOfflineSignerAuto:r=>{try{return e().getOfflineSignerAuto(r)}catch(n){throw new Error(`Failed to get auto signer${n!=null&&n.message?`: ${n.message}`:""}. Check Para auth and Cosmos support in developer portal.`)}},signAmino:(r,n,s,i)=>l(void 0,null,function*(){try{return yield e().signAmino(r,n,s,i)}catch(c){throw new Error(`Amino signing failed${c!=null&&c.message?`: ${c.message}`:""}. User rejected or invalid transaction/signer.`)}}),signDirect:(r,n,s,i)=>l(void 0,null,function*(){try{return yield e().signDirect(r,n,s,i)}catch(c){throw new Error(`Direct signing failed${c!=null&&c.message?`: ${c.message}`:""}. User rejected or invalid transaction/signer.`)}}),signArbitrary:(r,n,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(r,n,s)}catch(i){throw new Error(`Arbitrary signing failed${i!=null&&i.message?`: ${i.message}`:""}. User rejected or feature not supported.`)}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ye=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let i=()=>{B(),s();};return window.addEventListener("station_wallet_change",i),()=>{window.removeEventListener("station_wallet_change",i);}},getKey:s=>l(void 0,null,function*(){let i=yield t.getKey(s);return k({isKeystone:false},i)}),getOfflineSigner:s=>{try{let i=t.getOfflineSignerOnlyAmino(s);return Object.assign(i,{signDirect:(p,d)=>{throw new Error("signDirect not supported by Station")}})}catch(i){throw console.error(i),i}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let i=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,p,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((p=c.gasPriceStep)==null?void 0:p.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(i);}catch(i){throw console.error(i),i}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,i,c,f)=>t.signAmino(s,i,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:i=>e.enable(i),getOfflineSigner:i=>{let c=e.getOfflineSigner(i);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,p)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=p.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:p.authInfoBytes,bodyBytes:p.bodyBytes,chainId:p.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:i=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(i);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,p)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=p.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:p.authInfoBytes,bodyBytes:p.bodyBytes,chainId:p.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:i=>l(void 0,null,function*(){let c=yield e.getKey(i);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:i=>{let c=()=>{B(),i();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...i)=>{let c=i[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...i)=>l(void 0,null,function*(){var p;let[c]=i;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(p=c.bech32Config)==null?void 0:p.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...i)=>l(void 0,null,function*(){var d;let{1:c,2:f}=i,p=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Te.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:p.signature,signed:{authInfoBytes:p.signed.authInfoBytes,bodyBytes:p.signed.bodyBytes,chainId:p.signed.chainId,accountNumber:BigInt(p.signed.accountNumber.toString())}}}),signAmino:(...i)=>l(void 0,null,function*(){let{1:c,2:f}=i;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},ot=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),it=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Pe=(e,t,o=new Error("Promise timed out"))=>{let a=new Promise((r,n)=>{setTimeout(()=>{n(o);},t);});return Promise.race([e,a])};var q=e=>{var R,Q,ie;if(!((ie=(Q=(R=u.getState().walletConnect)==null?void 0:R.options)==null?void 0:Q.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",o=(e==null?void 0:e.encoding)||"base64",a=C=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(z()){if(ot()){let T=h(w.mobile.android,C,"android");window.open(T,"_self","noreferrer noopener");}if(it()){let T=h(w.mobile.ios,C,"ios");window.open(T,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:C}=y.getState();if(!C.get(t))throw new Error("walletConnect.signClient is not defined");C.delete(t),y.setState({wcSignClients:C}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},n=C=>l(void 0,null,function*(){let{wcSignClients:w}=y.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!C)throw new Error("No wallet connect session");yield h.disconnect({topic:C,reason:getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=C=>{try{let{wcSignClients:w}=y.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let T=h.session.getAll(),W=T.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw n(W.topic),new Error("invalid session");try{let _=T.find(j=>{var Y,J;return (J=(Y=j.requiredNamespaces.cosmos)==null?void 0:Y.chains)==null?void 0:J.includes(`cosmos:${C}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return W}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},i=C=>{try{return s(C)}catch(w){return}},c=C=>l(void 0,null,function*(){try{let w=C.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield C.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:C}=u.getState();if(!(C!=null&&C.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=y.getState(),h=w.get(t);if(h)return h;let T=yield SignClient.init(C.options);return w.set(t,T),y.setState({wcSignClients:w}),T}),p=C=>{let{wcSignClients:w}=y.getState(),h=w.get(t);if(!h)return ()=>{};let T=W=>{let M=y.getState().accounts;if(W.params.event.name==="accountsChanged"&&M&&!Object.values(M).map(_=>_.bech32Address).includes(W.params.event.data[0])){let _=W.params.chainId.split(":")[1];_&&d([_]);}else C();};return h.events.on("session_delete",r),h.events.on("session_expire",r),h.events.on("session_event",T),()=>{h.events.off("session_delete",r),h.events.off("session_expire",r),h.events.off("session_event",T);}},d=C=>l(void 0,null,function*(){var J;let w=typeof C=="string"?[C]:C,{wcSignClients:h,activeChainIds:T}=y.getState(),W=h.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:M,chains:_}=u.getState();if(!((J=M==null?void 0:M.options)!=null&&J.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new WalletConnectModal(k({projectId:M.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},M.walletConnectModal)),Y=i(w);if(!Y){let{uri:U,approval:ae}=yield Pe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?a(U):yield j.openModal({uri:U});let ce=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Oe,ee)=>{ae().then(_e=>{let Ke=_e.sessionProperties;if(!Ke)return ee(new Error("No session properties"));let Ee=JSON.parse(String(Ke.keys));if(Ee.length===0)return ee(new Error("No accounts"));if(!Ee[0])return ee(new Error("No accounts"));let Ne={};return Ee.forEach(H=>{Ne[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),y.setState(H=>({accounts:k(k({},H.accounts||{}),Ne)})),Oe(_e)}).catch(ee),V.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:true});})});try{let V=new AbortController,Oe=V.signal;j.subscribeModal(ee=>{ee.open||V.abort();}),yield ce(Oe);}catch(V){if(j.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||j.closeModal(),Promise.resolve()}try{yield Pe(l(void 0,null,function*(){var ae;let U=Object.fromEntries(yield Promise.all((ae=T||w)==null?void 0:ae.map(ce=>l(void 0,null,function*(){return [ce,yield S(ce)]}))));y.setState({accounts:U});}),15e3,new Error("Connection timeout"));}catch(U){if(n(Y.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),g=C=>l(void 0,null,function*(){let w=yield S(C);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=C=>l(void 0,null,function*(){let w=s([C]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let T=h.find(W=>W.chainId===C);if(!T)throw new Error(`No wallet connect key for chainId ${C}`);return F(k({},T),{pubKey:Buffer.from(String(T.pubKey),o)})}),P=(...C)=>l(void 0,null,function*(){var J,U;let[w,h,T]=C,{accounts:W,wcSignClients:M}=y.getState(),_=M.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let j=(J=s([w]))==null?void 0:J.topic;if(!j)throw new Error("No wallet connect session");if(!T.bodyBytes)throw new Error("No bodyBytes");if(!T.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield _.request({topic:j,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:T.chainId,accountNumber:(U=T.accountNumber)==null?void 0:U.toString(),bodyBytes:T.bodyBytes?Buffer.from(T.bodyBytes).toString(o):null,authInfoBytes:T.authInfoBytes?Buffer.from(T.authInfoBytes).toString(o):null}}}})}),v=(...C)=>l(void 0,null,function*(){var _;let[w,h,T]=C,{signature:W,signed:M}=yield P(w,h,T);return {signed:{chainId:(_=M.chainId)!=null?_:"",accountNumber:M.accountNumber?BigInt(M.accountNumber):BigInt(0),authInfoBytes:M.authInfoBytes?new Uint8Array(Buffer.from(M.authInfoBytes,o)):new Uint8Array([]),bodyBytes:M.bodyBytes?new Uint8Array(Buffer.from(M.bodyBytes,o)):new Uint8Array([])},signature:W}}),D=(...C)=>l(void 0,null,function*(){var U;let[w,h,T,W]=C,{wcSignClients:M}=y.getState(),_=M.get(t),{accounts:j}=y.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let Y=(U=s([w]))==null?void 0:U.topic;if(!Y)throw new Error("No wallet connect session");return a(),yield _.request({topic:Y,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:T}}})}),E=(...C)=>l(void 0,null,function*(){let[w,h,T,W]=C;return yield D(w,h,T)}),m=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(C)]}),signDirect:(w,h)=>v(C,w,h)}),A=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(C)]}),signAmino:(w,h)=>E(C,w,h)});return {enable:d,disable:C=>l(void 0,null,function*(){var T;let{wcSignClients:w}=y.getState(),h=w.get(t);if(C===void 0){let W=h==null?void 0:h.session.getAll();W!==void 0&&(yield Promise.all(W.map(M=>n(M.topic))));}else typeof C=="string"?yield n((T=s([C]))==null?void 0:T.topic):yield Promise.all(C.map(W=>{var M;return n((M=s([W]))==null?void 0:M.topic)}));(h==null?void 0:h.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...C)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:C=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(C)]}),signDirect:(w,h)=>v(C,w,h),signAmino:(w,h)=>E(C,w,h)}),getOfflineSignerAuto:C=>l(void 0,null,function*(){return (yield S(C)).isNanoLedger?A(C):m(C)}),getOfflineSignerOnlyAmino:A,signAmino:E,signDirect:v,subscription:p,init:f}};var rt=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(s){case "ios":return c?`${i}://wcV2?${c}`:`${i}://wcV2`;default:return c?`${i}://wc?uri=${c}`:`${i}://wc`}}};return q(e)};var st=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":","");return n?`${i}://wc?${n}`:`${i}://wc`}};return q(e)};var at=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(s){case "ios":return c?`${i}://wcV2?${c}`:`${i}://wcV2`;case "android":return c?`${i}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${i}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${i}://wc?uri=${c}`:`${i}://wc`}}};return q(e)};var ct=()=>{var t,o,a;if(!((a=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,n,s)=>{let i=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(s){case "ios":return c?`${i}://wcV2?${c}`:`${i}://wcV2`;case "android":return c?`${i}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${i}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${i}://wc?uri=${c}`:`${i}://wc`}}};return q(e)};var we=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var G=(e=u.getState().walletType)=>{try{return K(e),!0}catch(t){return false}},B=()=>{window.sessionStorage.removeItem(te),y.setState(oe);},K=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return de();case "leap":return me();case "cosmostation":return pe();case "vectis":return Ce();case "walletconnect":return q();case "wc_keplr_mobile":return at();case "wc_leap_mobile":return ct();case "wc_cosmostation_mobile":return st();case "wc_clot_mobile":return rt();case "metamask_snap_leap":return tt();case "metamask_snap_cosmos":return Xe();case "station":return ye();case "xdefi":return we();case "cosmiframe":return ue();case "compass":return le();case "initia":return Je();case "okx":return ge();case "para":return nt();default:throw new Error("Unknown wallet type")}})(),o=u.getState().walletDefaultOptions;return o&&((a=t.setDefaultOptions)==null||a.call(t,o)),t},Qi=()=>Object.fromEntries(ze.map(e=>[e,G(e)])),lt=e=>e==="metamask_snap_leap",ut=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),se=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",pt=e=>e==="para";var ne=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:i,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(se(f)){let E=K("walletconnect"),{disable:m}=E;m&&m();}if(!G(f))throw new Error(`${f} is not available`);let d=K(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=i==null?void 0:i.map(E=>E.chainId);g.forEach(E=>{if(!(S!=null&&S.includes(E)))throw new Error(`Chain ${E} is not provided in GrazProvider`)}),y.setState(E=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return E.activeChainIds&&g.filter(O=>{var x;return !((x=E.activeChainIds)!=null&&x.includes(O))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:P}=y.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!se(f)){let E={};if(lt(f)){let m={};try{for(var o=Fe(g),a,r,n;a=!(r=yield o.next()).done;a=!1){let A=r.value;m[A]=yield d.getKey(A);}}catch(r){n=[r];}finally{try{a&&(r=o.return)&&(yield r.call(o));}finally{if(n)throw n[0]}}E=m;}else if(ut()&&d.getKeys){let m=yield d.getKeys(g);g.forEach((A,O)=>{let x=m[O];x&&(E[A]=x);});}else E=Object.fromEntries(yield Promise.all(g.map(m=>l(void 0,null,function*(){return [m,yield d.getKey(m)]}))));y.setState(m=>({accounts:k(k({},m.accounts||{}),E)}));}u.setState(E=>({recentChainIds:[...E.recentChainIds||[],...g].filter((m,A,O)=>O.indexOf(m)===A)})),y.setState(E=>({activeChainIds:[...E.activeChainIds||[],...g].filter((m,A,O)=>O.indexOf(m)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),y.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(te,"Active");let v=g.map(E=>i.find(m=>m.chainId===E));return {accounts:y.getState().accounts,walletType:f,chains:v}}catch(s){throw console.error("connect ",s),y.getState().accounts===null&&y.setState({status:"disconnected"}),y.getState().accounts&&y.getState().activeChainIds&&y.setState({status:"connected"}),s}}),ke=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(te);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,o=()=>{if(se(u.getState().walletType)){let a=K("walletconnect"),{disable:r}=a;r&&r();}if(pt(u.getState().walletType)){let a=K("para"),{disable:r}=a;r&&r();}};if(t){let a=y.getState().accounts;t.forEach(n=>{a==null||delete a[n];}),Object.values(a||{}).length===0?(o(),y.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(y.setState(n=>{var s;return {activeChainIds:(s=n.activeChainIds)==null?void 0:s.filter(i=>!t.includes(i)),accounts:a}}),u.setState(n=>{var s;return {recentChainIds:(s=n.recentChainIds)==null?void 0:s.filter(i=>!t.includes(i))}}));}else o(),y.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:o,_reconnect:a}=u.getState();try{let n=G(o||void 0);if(t&&n&&o)return se(o)?void 0:yield ne({chainId:t,walletType:o,autoReconnect:a})}catch(n){(r=e==null?void 0:e.onError)==null||r.call(e,n),ke();}}),dt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),o=e.walletType||t;if(!G(o))throw new Error(`${o} is not available`);let r=K(o),n=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),i=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:s,offlineSignerAuto:i}});var xe=()=>{u.setState({recentChainIds:null});},rr=()=>u.getState().recentChainIds,sr=()=>{var o;let{recentChainIds:e,chains:t}=u.getState();return (o=e==null?void 0:e.map(a=>t.find(r=>r.chainId===a)))!=null?o:null},ar=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(o=>o.chainId===e)},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},Me=o=>l(void 0,[o],function*({chainInfo:e,walletType:t}){return yield K(t).experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield ne({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ft=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var gt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:o,amount:a,fee:r,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,o,a,r,n)}),yt=p=>l(void 0,[p],function*({signingClient:e,senderAddress:t,recipientAddress:o,transferAmount:a,sourcePort:r,sourceChannel:n,timeoutHeight:s,timeoutTimestamp:i,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,o,a,r,n,s,i,c,f)}),Ct=i=>l(void 0,[i],function*({signingClient:e,senderAddress:t,msg:o,fee:a,options:r,label:n,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,o,n,a,r)}),wt=i=>l(void 0,[i],function*({signingClient:e,senderAddress:t,msg:o,fee:a,contractAddress:r,funds:n,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,o,a,s,n)}),St=(e,t,o)=>l(void 0,null,function*(){if(!o)throw new Error("CosmWasm client is not ready");return yield o.queryContractSmart(e,t)}),ht=(e,t,o)=>{if(!o)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return o.queryContractRaw(e,a)};var wr=e=>e,Sr=e=>e;var At=e=>e?Object.keys(e).length===0:true;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},It=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function We(n,s){return l(this,arguments,function*(e,t,{concurrency:o=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:r}={}){return new Promise((i,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(o)||o===Number.POSITIVE_INFINITY)&&o>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${o}\` (${typeof o})`);let f=[],p=[],d=new Map,g=false,S=false,P=false,v=0,D=0,E=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),m=O=>{g=true,S=true,c(O);};r&&(r.aborted&&m(bt(r)),r.addEventListener("abort",()=>{m(bt(r));}));let A=()=>l(this,null,function*(){if(S)return;let O=yield E.next(),x=D;if(D++,O.done){if(P=true,v===0&&!S){if(!a&&p.length>0){m(new AggregateError(p));return}if(S=true,d.size===0){i(f);return}let N=[];for(let[R,Q]of f.entries())d.get(R)!==Ot&&N.push(Q);i(N);}return}v++,l(this,null,function*(){try{let N=yield O.value;if(S)return;let R=yield t(N,x);R===Ot&&d.set(x,R),f[x]=R,v--,yield A();}catch(N){if(a)m(N);else {p.push(N),v--;try{yield A();}catch(R){m(R);}}}});});l(this,null,function*(){for(let O=0;O<o;O++){try{yield A();}catch(x){m(x);break}if(P||g)break}});})})}var Ot=Symbol("skip");var $=({chainId:e,multiChain:t})=>{let o=u(r=>r.chains);if(!o)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(r=>o.find(n=>n.chainId===r)).filter(Boolean);case(!t&&!!a):return [a.map(r=>o.find(n=>n.chainId===r)).filter(Boolean)[0]];case(!!t&&!a):return o;default:return [o[0]]}},X=(e,t,o)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let n=yield We(t,o,{concurrency:a});return Object.fromEntries(n.map((s,i)=>[t[i].chainId,s]))}return yield o(t[0])}),Et=(e,t,o)=>{if(e){let r=t.map(o);return Object.fromEntries(r.map((n,s)=>[t[s].chainId,n]))}return o(t[0])};var De=e=>{let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:o,queryFn:r=>l(void 0,[r],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var p;let i=(p=u.getState().chainsConfig)==null?void 0:p[s.chainId],c={url:s.rpc,headers:k({},(i==null?void 0:i.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},Re=e=>{let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:o,queryFn:r=>l(void 0,[r],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var p;let i=(p=u.getState().chainsConfig)==null?void 0:p[s.chainId],c={url:s.rpc,headers:k({},(i==null?void 0:i.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var $r=()=>u(useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),Se=e=>{let o=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery({queryKey:o,queryFn:({queryKey:[,r]})=>G(r)})};var Z=e=>{let t=u(i=>i.walletType),o=y(i=>i.activeChainIds),a=$({chainId:e!=null&&e.chainId?e.chainId:o||void 0,multiChain:e==null?void 0:e.multiChain}),r=y(i=>i.accounts),n=y(i=>i.status);return useEffect(()=>y.subscribe(i=>i.status,(i,c)=>{var f,p,d;if(i==="connected"){let{accounts:g,activeChainIds:S}=y.getState(),{chains:P}=u.getState(),{walletType:v}=u.getState();if(!g||!S||!P)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(p=e==null?void 0:e.onConnect)==null||p.call(e,{accounts:g,chains:S.map(D=>P.find(E=>E.chainId===D)),walletType:v,isReconnect:c==="reconnecting"});}i==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>r?Et(!!(e!=null&&e.multiChain),a,i=>r[i.chainId]):void 0,[r,a,e==null?void 0:e.multiChain]),isConnected:n==="connected",isConnecting:n==="connecting",isDisconnected:n==="disconnected",isReconnecting:n==="reconnecting",isLoading:n==="connecting"||n==="reconnecting",walletType:n==="connected"?t:void 0,reconnect:L,status:n}},dn=e=>{let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=Z(),a=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),{data:r}=De({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),n=useMemo(()=>["USE_ALL_BALANCES",r,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,r]);return useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,i,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),i,d=>l(void 0,null,function*(){var P;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((P=d.bech32Config)!=null&&P.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!At(r)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},is=e=>{let t=$({chainId:e.chainId}),{data:o}=Z({chainId:e.chainId}),a=e.bech32Address||(o==null?void 0:o.bech32Address),{data:r,refetch:n}=dn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,a,e.chainId],i=useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(p=>p.denom===c),enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?true:e.enabled)});return F(k({},i),{refetch:c=>l(void 0,null,function*(){return yield n(),i.refetch(c)})})},rs=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=useMutation({mutationKey:["USE_CONNECT",e,t,o],mutationFn:ne,onError:(s,i)=>e==null?void 0:e(s,i),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:n}=Se();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status}},ss=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=useMutation({mutationKey:["USE_DISCONNECT",e,t,o],mutationFn:ke,onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return {disconnect:n=>r.mutate(n),disconnectAsync:n=>r.mutateAsync(n),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,status:r.status}},as=e=>{let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(n=>n.walletType),a=y.getState().status==="connected"&&y.getState().accounts&&u.getState()._reconnectConnector===o,r=useMemo(()=>["USE_OFFLINE_SIGNERS",t,o],[t,o]);return useQuery({queryKey:r,queryFn:i=>l(void 0,[i],function*({queryKey:[,n,s]}){if(n.length<1)throw new Error("No chain found");if(!G(s))throw new Error(`${s} is not available`);return yield X(!!(e!=null&&e.multiChain),n,p=>l(void 0,null,function*(){return yield dt({chainId:p.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!o&&!!a,refetchOnWindowFocus:false})},cs=e=>{let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=Z(),{data:a}=De({chainId:t.map(s=>s.chainId),multiChain:true}),r=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),n=useMemo(()=>["USE_BALANCE_STAKED",a,t,r],[t,r,a]);return useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,i,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),i,d=>l(void 0,null,function*(){var S,P;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (P=s[d.chainId])==null?void 0:P.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var ys=()=>y(e=>e.activeChainIds),mn=()=>{var e;return (e=y(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let o=(a=u.getState().chains)==null?void 0:a.find(r=>r.chainId===t);if(o)return o}).filter(Boolean)},Cs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(o=>o.chainId===e)},ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},Ss=({denom:e})=>{let t=mn();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,r]})=>{var n;return (n=t==null?void 0:t.find(s=>s.currencies.find(i=>i.coinMinimalDenom===r)))==null?void 0:n.currencies.find(s=>s)}})},hs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",o=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:o,queryFn:i=>l(void 0,[i],function*({queryKey:[,n,s]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},As=()=>({data:u(t=>t.recentChainIds),clear:xe}),Is=()=>{var t;return {data:(t=u(o=>o.recentChainIds))==null?void 0:t.map(o=>{var r;let a=(r=u.getState().chains)==null?void 0:r.find(n=>n.chainId===o);if(a)return a}).filter(Boolean),clear:xe}},bs=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,o],mutationFn:Me,onError:(n,s)=>Promise.resolve(e==null?void 0:e(n,s.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(o==null?void 0:o(n))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Os=({onError:e,onLoading:t,onSuccess:o}={})=>{let r=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],mutationFn:mt,onError:(s,i)=>Promise.resolve(e==null?void 0:e(s,i)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:n}=Se();return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Ws=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:a}=Z(),r=a==null?void 0:a.bech32Address,n=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,o,r],mutationFn:s=>gt(k({senderAddress:r},s)),onError:(s,i)=>Promise.resolve(e==null?void 0:e(s,i)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},Ds=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:a}=Z(),r=a==null?void 0:a.bech32Address,n=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,o,r],mutationFn:s=>yt(k({senderAddress:r},s)),onError:(s,i)=>Promise.resolve(e==null?void 0:e(s,i)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Rs=({codeId:e,onError:t,onLoading:o,onSuccess:a})=>{let{data:r}=Z(),n=r==null?void 0:r.bech32Address,i=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,o,a,e,n],mutationFn:c=>{var p;if(!n)throw new Error("senderAddress is undefined");let f=F(k({},c),{fee:(p=c.fee)!=null?p:"auto",senderAddress:n,codeId:e});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:o,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,instantiateContract:i.mutate,instantiateContractAsync:i.mutateAsync,status:i.status}},_s=({contractAddress:e,onError:t,onLoading:o,onSuccess:a})=>{let{data:r}=Z(),n=r==null?void 0:r.bech32Address,i=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,o,a,e,n],mutationFn:c=>{var p,d,g;if(!n)throw new Error("senderAddress is undefined");let f=F(k({},c),{fee:(p=c.fee)!=null?p:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return wt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:o,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,executeContract:i.mutate,executeContractAsync:i.mutateAsync,status:i.status}},Ks=e=>{let{data:t}=Re();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return St(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ns=e=>{let{data:t}=Re(),o=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:o,queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ht(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Vs(e){let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(s=>s.walletType),a=y(s=>s.activeChainIds),r=y.getState().status==="connected"&&y.getState().accounts&&u.getState()._reconnectConnector===o,n=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,o,e,a],[a,e,t,o]);return useQuery({queryKey:n,queryFn:c=>l(this,[c],function*({queryKey:[,s,i]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,p=>l(this,null,function*(){var D,E;if(!(a!=null&&a.includes(p.chainId)))return null;if(!G(i))throw new Error(`${i} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(i).getOfflineSigner(p.chainId);case "offlineSignerAuto":return K(i).getOfflineSignerAuto(p.chainId);case "offlineSignerOnlyAmino":return K(i).getOfflineSignerOnlyAmino(p.chainId);default:return K(i).getOfflineSignerAuto(p.chainId)}}),S=(D=u.getState().chainsConfig)==null?void 0:D[p.chainId],P={url:p.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield SigningStargateClient.connectWithSigner(P,g,e!=null&&e.multiChain?(E=e.opts)==null?void 0:E[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!o&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!r,refetchOnWindowFocus:false})}function Hs(e){let t=$({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(s=>s.walletType),a=y(s=>s.activeChainIds),r=y.getState().status==="connected"&&y.getState().accounts&&u.getState()._reconnectConnector===o,n=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,o,e,a],[a,e,t,o]);return useQuery({queryKey:n,queryFn:c=>l(this,[c],function*({queryKey:[,s,i]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,p=>l(this,null,function*(){var E,m;if(!(a!=null&&a.includes(p.chainId)))return null;if(!G(i))throw new Error(`${i} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(i).getOfflineSigner(p.chainId);case "offlineSignerAuto":return K(i).getOfflineSignerAuto(p.chainId);case "offlineSignerOnlyAmino":return K(i).getOfflineSignerOnlyAmino(p.chainId);default:return K(i).getOfflineSignerAuto(p.chainId)}}),S=(E=u.getState().chainsConfig)==null?void 0:E[p.chainId],P={url:p.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})},v=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(P,g,k({gasPrice:v},e!=null&&e.multiChain?(m=e.opts)==null?void 0:m[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!o&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!r,refetchOnWindowFocus:false})}var Kt=({children:e})=>{let[t,o]=useState(false);return useEffect(()=>{o(true);},[]),jsx(Fragment,{children:t?e:null})};var In=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(te)==="Active",{_reconnect:t,_onReconnectFailed:o,_reconnectConnector:a,iframeOptions:r,chains:n,pingInterval:s}=u(),{activeChainIds:i,wcSignClients:c}=y(),f=G(a||void 0);return useEffect(()=>{let p=()=>l(void 0,null,function*(){if(e&&f&&a&&(i!=null&&i[0])){let d=y.getState().lastPing;if(d&&Date.now()-d<s)return;let g=K(a);try{if(!(yield g.getKey(i[0])))throw new Error("No account found");y.setState({lastPing:Date.now()});return}catch(S){L({onError:o});}}});return window.addEventListener("focus",p),()=>{window.removeEventListener("focus",p);}},[e,f,a,n,i,s]),useEffect(()=>{if(!r||r.autoConnect===false||!r.allowedIframeParentOrigins.length||!n)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(d=>{if(d)return ne({chainId:n.map(g=>g.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(a){if(!f)return;e&&i?L({onError:o}):!e&&t&&L({onError:o});}},[f]),useEffect(()=>{var p,d,g,S,P,v,D,E,m,A,O,x,N,R,Q,ie,C,w,h,T;if(a){if(!f)return;a==="cosmostation"&&((d=(p=pe()).subscription)==null||d.call(p,()=>{L({onError:o});})),a==="keplr"&&((S=(g=de()).subscription)==null||S.call(g,()=>{L({onError:o});})),a==="leap"&&((v=(P=me()).subscription)==null||v.call(P,()=>{L({onError:o});})),a==="compass"&&((E=(D=le()).subscription)==null||E.call(D,()=>{L({onError:o});})),a==="vectis"&&((A=(m=Ce()).subscription)==null||A.call(m,()=>{L({onError:o});})),a==="walletconnect"&&c.has("walletconnect")&&((x=(O=q()).subscription)==null||x.call(O,()=>{L({onError:o});})),a==="station"&&((R=(N=ye()).subscription)==null||R.call(N,()=>{L({onError:o});})),a==="xdefi"&&((ie=(Q=we()).subscription)==null||ie.call(Q,()=>{L({onError:o});})),a==="cosmiframe"&&((w=(C=ue()).subscription)==null||w.call(C,()=>{L({onError:o});})),a==="okx"&&((T=(h=ge()).subscription)==null||T.call(h,()=>{L({onError:o});}));}},[a,c,f]),null},Nt=()=>(In(),null);var Ta=({children:e,grazOptions:t})=>(useEffect(()=>{ft(t);},[t]),jsxs(Kt,{children:[e,jsx(Nt,{})]}));
|
|
19
19
|
|
|
20
|
-
export { Nt as GrazEvents,
|
|
20
|
+
export { Nt as GrazEvents, Ta as GrazProvider, ze as WALLET_TYPES, Ge as WalletType, G as checkWallet, xe as clearRecentChain, B as clearSession, ft as configureGraz, ne as connect, Sr as defineChainInfo, wr as defineChains, ke as disconnect, wt as executeContract, Qi as getAvailableWallets, ar as getChainInfo, cr as getChainInfos, pe as getCosmostation, de as getKeplr, me as getLeap, tt as getMetamaskSnapLeap, dt as getOfflineSigners, ge as getOkx, nt as getPara, ht as getQueryRaw, St as getQuerySmart, rr as getRecentChainIds, sr as getRecentChains, Ce as getVectis, st as getWCCosmostation, at as getWCKeplr, ct as getWCLeap, K as getWallet, q as getWalletConnect, Ct as instantiateContract, ut as isLeapDappBrowser, lt as isLeapSnaps, pt as isPara, se as isWalletConnect, L as reconnect, yt as sendIbcTokens, gt as sendTokens, Me as suggestChain, mt as suggestChainAndConnect, Z as useAccount, Ss as useActiveChainCurrency, ys as useActiveChainIds, mn as useActiveChains, $r as useActiveWalletType, is as useBalance, cs as useBalanceStaked, dn as useBalances, Cs as useChainInfo, ws as useChainInfos, Se as useCheckWallet, rs as useConnect, Re as useCosmWasmClient, Hs as useCosmWasmSigningClient, ss as useDisconnect, _s as useExecuteContract, In as useGrazEvents, Rs as useInstantiateContract, as as useOfflineSigners, hs as useQueryClientValidators, Ns as useQueryRaw, Ks as useQuerySmart, As as useRecentChainIds, Is as useRecentChains, Ds as useSendIbcTokens, Ws as useSendTokens, De as useStargateClient, Vs as useStargateSigningClient, bs as useSuggestChain, Os as useSuggestChainAndConnect };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.7",
|
|
5
5
|
"author": "Nur Fikri <kikiding.space@gmail.com>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
@@ -40,9 +40,7 @@
|
|
|
40
40
|
"@cosmjs/cosmwasm-stargate": ">=0.32.4",
|
|
41
41
|
"@cosmjs/proto-signing": ">=0.32.4",
|
|
42
42
|
"@cosmjs/stargate": ">=0.32.4",
|
|
43
|
-
"@cosmjs/encoding": ">=0.32.4"
|
|
44
|
-
"@getpara/graz-connector": ">=2.0.0-alpha.51 <2.0.0-beta",
|
|
45
|
-
"@getpara/graz-integration": ">=2.0.0-alpha.51 <2.0.0-beta"
|
|
43
|
+
"@cosmjs/encoding": ">=0.32.4"
|
|
46
44
|
},
|
|
47
45
|
"dependencies": {
|
|
48
46
|
"@initia/initia-registry-types": "0.0.20",
|
|
@@ -71,14 +69,6 @@
|
|
|
71
69
|
"@getpara/graz-connector": ">=2.0.0-alpha.51 <2.0.0-beta",
|
|
72
70
|
"@getpara/graz-integration": ">=2.0.0-alpha.51 <2.0.0-beta"
|
|
73
71
|
},
|
|
74
|
-
"peerDependenciesMeta": {
|
|
75
|
-
"@getpara/graz-integration": {
|
|
76
|
-
"optional": true
|
|
77
|
-
},
|
|
78
|
-
"@getpara/graz-connector": {
|
|
79
|
-
"optional": true
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
72
|
"keywords": [
|
|
83
73
|
"graz",
|
|
84
74
|
"keplr-wallet",
|