graz 0.2.5 → 0.3.0-alpha.0
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/.gitkeep +0 -0
- package/dist/index.d.mts +46 -91
- package/dist/index.d.ts +46 -91
- package/dist/index.js +75 -81
- package/dist/index.mjs +6 -7
- package/package.json +22 -24
package/dist/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var zustand = require('zustand');
|
|
4
4
|
var middleware = require('zustand/middleware');
|
|
5
|
-
var amino = require('@cosmjs/amino');
|
|
6
|
-
var encoding = require('@cosmjs/encoding');
|
|
7
5
|
var cosmiframe = require('@dao-dao/cosmiframe');
|
|
8
6
|
var snapper = require('@cosmsnap/snapper');
|
|
9
|
-
var
|
|
7
|
+
var amino = require('@cosmjs/amino');
|
|
8
|
+
var be = require('long');
|
|
9
|
+
var encoding = require('@cosmjs/encoding');
|
|
10
10
|
var signClient = require('@walletconnect/sign-client');
|
|
11
11
|
var utils = require('@walletconnect/utils');
|
|
12
12
|
var modal = require('@walletconnect/modal');
|
|
@@ -14,88 +14,82 @@ var reactQuery = require('@tanstack/react-query');
|
|
|
14
14
|
var react = require('react');
|
|
15
15
|
var cosmwasmStargate = require('@cosmjs/cosmwasm-stargate');
|
|
16
16
|
var stargate = require('@cosmjs/stargate');
|
|
17
|
-
var tendermintRpc = require('@cosmjs/tendermint-rpc');
|
|
18
17
|
var shallow = require('zustand/shallow');
|
|
19
18
|
var jsxRuntime = require('react/jsx-runtime');
|
|
20
19
|
|
|
21
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
21
|
|
|
23
|
-
var
|
|
22
|
+
var be__default = /*#__PURE__*/_interopDefault(be);
|
|
24
23
|
|
|
25
|
-
var Ut=Object.defineProperty,Ft=Object.defineProperties;var qt=Object.getOwnPropertyDescriptors;var Ge=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var ze=(e,t,i)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,v=(e,t)=>{for(var i in t||(t={}))Gt.call(t,i)&&ze(e,i,t[i]);if(Ge)for(var i of Ge(t))zt.call(t,i)&&ze(e,i,t[i]);return e},j=(e,t)=>Ft(e,qt(t));var l=(e,t,i)=>new Promise((r,o)=>{var n=c=>{try{s(i.next(c));}catch(m){o(m);}},a=c=>{try{s(i.throw(c));}catch(m){o(m);}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,a);s((i=i.apply(e,t)).next());}),Qe=(e,t,i)=>(t=e[Symbol.asyncIterator],i=(r,o)=>(o=e[r])&&(t[r]=n=>new Promise((a,s,c)=>(n=o.call(e,n),c=n.done,Promise.resolve(n.value).then(m=>a({value:m,done:c}),s)))),t?t.call(e):(e=e[Symbol.iterator](),t={},i("next"),i("return"),t));var Y="graz-reconnect-session";var je=(u=>(u.KEPLR="keplr",u.LEAP="leap",u.VECTIS="vectis",u.COSMOSTATION="cosmostation",u.WALLETCONNECT="walletconnect",u.WC_KEPLR_MOBILE="wc_keplr_mobile",u.WC_LEAP_MOBILE="wc_leap_mobile",u.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",u.WC_CLOT_MOBILE="wc_clot_mobile",u.METAMASK_SNAP_LEAP="metamask_snap_leap",u.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",u.STATION="station",u.XDEFI="xdefi",u.CAPSULE="capsule",u.COSMIFRAME="cosmiframe",u.COMPASS="compass",u.INITIA="initia",u.OKX="okx",u))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var jt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},$t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},Vt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,$t))),p=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>jt,Vt)));var ae=()=>{var f,E;if(!((f=p.getState().capsuleConfig)!=null&&f.apiKey)||!((E=p.getState().capsuleConfig)!=null&&E.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var T,O;let S=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,A=new S({apiKey:(T=p.getState().capsuleConfig)==null?void 0:T.apiKey,env:(O=p.getState().capsuleConfig)==null?void 0:O.env});return g.setState({capsuleClient:A}),A});return {init:e,enable:S=>l(void 0,null,function*(){let A=typeof S=="string"?[S]:S,T=g.getState().capsuleClient;T||(T=yield e()),p.setState({capsuleState:{showModal:!0,chainId:A}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var u;let S=g.getState().capsuleClient,{chains:A}=p.getState();if(!S)throw new Error("Capsule client is not initialized");if(!A)throw new Error("Chains are not set");yield S.enable();let T=(u=p.getState().capsuleState)==null?void 0:u.chainId;if(!T)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(T.map(y=>l(void 0,null,function*(){let C=yield S.getAccount(y);return [y,{address:encoding.fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(y=>({accounts:v(v({},y.accounts||{}),O)})),p.setState(y=>({recentChainIds:[...y.recentChainIds||[],...T].filter((C,M,W)=>W.indexOf(C)===M)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...T].filter((C,M,W)=>W.indexOf(C)===M)})),p.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(Y,"Active"),p.setState({capsuleState:null});}),getKey:S=>l(void 0,null,function*(){let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");let T=yield A.getAccount(S);return {address:encoding.fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:S=>l(void 0,null,function*(){let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSignerDirect(S)}),getOfflineSignerDirect:S=>{let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSignerDirect(S)},signDirect:(...S)=>l(void 0,null,function*(){let[A,T,O]=S,u=g.getState().capsuleClient;if(!u)throw new Error("Capsule client is not initialized");return u.signDirect(A,T,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...S)=>l(void 0,null,function*(){let[A,T,O,u]=S,y=g.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signAmino(A,T,O,u)}),signArbitrary:(S,A,T)=>l(void 0,null,function*(){let O=g.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let u=yield O.getAccount(S);if(!u)throw new Error(`Wallet not connected to account ${A}`);let y=(()=>{switch(u.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(u.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(u.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(S,A,T),pub_key:{type:u.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:y.value}}}),experimentalSuggestChain:(...S)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:S=>{let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSigner(S)},getOfflineSignerAmino:S=>{let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSignerAmino(S)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:o=>{let n=()=>{N(),o();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:o=>{e.defaultOptions=o;}})}throw p.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=p.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 tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var h;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 s=(h=n.split("MetaMask/v")[1])==null?void 0:h.split(".")[0];if(!(Number(s)>=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,!0}),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(j(v({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,a,s)=>l(void 0,null,function*(){return t.signAmino(n,a,s)}),getKey:n=>l(void 0,null,function*(){return typeof tt[n]!="undefined"?tt[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,a,s)=>l(void 0,null,function*(){return t.signDirect(n,a,s)}),signArbitrary:(n,a,s)=>l(void 0,null,function*(){return t.signArbitrary(n,a,s)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw p.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 a=()=>{N(),n();};return window.addEventListener("cosmostation_keystorechange",a),()=>{window.removeEventListener("cosmostation_keystorechange",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw p.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var rn=e=>{let{bodyBytes:t,authInfoBytes:i,chainId:r,accountNumber:o}=e;if(!t||!i||!r||!o)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:i,chainId:r,accountNumber:o}},sn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{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 f=e.getOfflineSigner(d),[E]=yield f.getAccounts();if(!E)throw new Error("Wallet connection failed");let S=(()=>{switch(E.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(E.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(E.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:sn(E.address),algo:E.algo,pubKey:E.pubkey,bech32Address:E.address,address:S,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let f=e.getOfflineSigner(d),E=e.getOfflineSignerOnlyAmino(d);return {getAccounts:f.getAccounts.bind(f),signDirect:f.signDirect.bind(f),signAmino:E.signAmino.bind(E)}},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(f=>{var E,S,A;return {denom:f.coinDenom,amount:f.coinMinimalDenom,low_gas_price:(E=f.gasPriceStep)==null?void 0:E.low,average_gas_price:(S=f.gasPriceStep)==null?void 0:S.average,high_gas_price:(A=f.gasPriceStep)==null?void 0:A.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[f,E,S]=d;return e.getOfflineSigner(f).signDirect(E,rn(S))},signAmino:(...d)=>{let[f,E,S]=d;return e.getOfflineSignerOnlyAmino(f).signAmino(E,S)},signArbitrary:(d,f,E)=>l(void 0,null,function*(){let T=(yield e.getOfflineSigner(d).getAccounts()).find(y=>y.address===f);if(!T)throw new Error(`Wallet not connected to account ${f}`);let O=(()=>{switch(T.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(T.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(T.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(E),pub_key:{type:T.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:d=>{let f=()=>{N(),d();};return window.addEventListener("initia_keystorechange",f),()=>{window.removeEventListener("initia_keystorechange",f);}}}}throw p.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:o=>{let n=()=>{N(),o();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:o=>{e.defaultOptions=o;}})}throw p.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:o=>{let n=()=>{N(),o();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:o=>{e.defaultOptions=o;}})}throw p.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},rt=e=>{let t=window.ethereum;if(t&&e){let i=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),r=u=>l(void 0,null,function*(){try{let y=yield i();return Object.values(y).find(C=>C.id===e.id&&(!u||C.version===u))}catch(y){return}}),o=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var K;let u=yield t.request({method:"web3_clientVersion"});if(!u.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 C=(K=u.split("MetaMask/v")[1])==null?void 0:K.split(".")[0];if(!(Number(C)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield r())||(yield o()),!0}),a=u=>l(void 0,null,function*(){(yield r())||(yield o());}),s=(u,y,C)=>l(void 0,null,function*(){let M=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:u,signerAddress:y,signDoc:C}}}}),W=C.accountNumber,K=new lt__default.default(W.low,W.high,W.unsigned);return {signature:M.signature,signed:j(v({},M.signed),{accountNumber:`${K.toString()}`,authInfoBytes:new Uint8Array(Object.values(M.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(M.signed.bodyBytes))})}}),c=(u,y,C)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:u,signerAddress:y,signDoc:C}}}})}),m=u=>l(void 0,null,function*(){if(typeof de[u]!="undefined")return de[u];let y=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:u}}}});if(!y)throw new Error("No response from Metamask");return y.pubKey=Uint8Array.from(Object.values(y.pubkey)),delete y.pubkey,de[u]=y,de[u]}),h=u=>l(void 0,null,function*(){let y=yield m(u);return {address:y.bech32Address,algo:y.algo,pubkey:y.pubKey}}),d=(...u)=>l(void 0,null,function*(){let[y,C,M,W]=u;return yield c(y,C,M)}),f=(...u)=>l(void 0,null,function*(){let[y,C,M]=u;return yield s(y,C,M)}),S=u=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(u)]}),signAmino:(y,C)=>d(u,y,C)});return {enable:a,experimentalSuggestChain:(...u)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:u[0]}}}});}),getKey:m,getOfflineSigner:u=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(u)]}),signDirect:(y,C)=>f(u,y,C),signAmino:(y,C)=>d(u,y,C)}),getOfflineSignerAuto:u=>l(void 0,null,function*(){return S(u)}),getOfflineSignerOnlyAmino:S,init:n,signAmino:d,signDirect:f}}throw p.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({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 s;let a=()=>{N(),n();};return (s=window.okxwallet)==null||s.on("accountsChanged",a),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw p.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{N(),n();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:n=>l(void 0,null,function*(){let a=yield e.getKey(n);return v({isKeystone:!1},a)}),getOfflineSigner:n=>{try{let a=e.getOfflineSignerOnlyAmino(n);return Object.assign(a,{signDirect:(m,h)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:n=>l(void 0,null,function*(){try{if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(n,{bech32Config:n.bech32Config,chainSymbolImageUrl:n.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:n.stakeCurrency.coinDecimals,coinDenom:n.stakeCurrency.coinDenom,coinImageUrl:n.stakeCurrency.coinImageUrl||"",coinMinimalDenom:n.stakeCurrency.coinMinimalDenom},currencies:n.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:n.feeCurrencies.map(s=>{var c,m,h;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((m=s.gasPriceStep)==null?void 0:m.high)||0,low:((h=s.gasPriceStep)==null?void 0:h.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:n=>e.enable(n),disable:n=>e.disable(n),getOfflineSignerAuto:n=>e.getOfflineSignerAuto(n),getOfflineSignerOnlyAmino:n=>e.getOfflineSignerOnlyAmino(n),signDirect:()=>e.signDirect(),signAmino:(n,a,s,c)=>e.signAmino(n,a,s)}}throw p.getState()._notFoundFn(),new Error("window.station is not defined")};var ye=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{N(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>{let c=s[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...s)=>l(void 0,null,function*(){var h;let[c]=s;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let m={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(h=c.bech32Config)==null?void 0:h.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([m])}),signDirect:(...s)=>l(void 0,null,function*(){var h;let{1:c,2:m}=s;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:lt__default.default.fromString(((h=m.accountNumber)==null?void 0:h.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:m}=s;return e.signAmino(c,m)})}}throw p.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 !1},at=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,i=new Error("Promise timed out"))=>{let r=new Promise((o,n)=>{setTimeout(()=>{n(i);},t);});return Promise.race([e,r])};var z=e=>{var K,ee,ie;if(!((ie=(ee=(K=p.getState().walletConnect)==null?void 0:K.options)==null?void 0:ee.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",i=(e==null?void 0:e.encoding)||"base64",r=w=>{if(!e)return;let{appUrl:I,formatNativeUrl:b}=e;if(G()){if(at()){let k=b(I.mobile.android,w,"android");window.open(k,"_self","noreferrer noopener");}if(ct()){let k=b(I.mobile.ios,w,"ios");window.open(k,"_self","noreferrer noopener");}}},o=()=>{let{wcSignClients:w}=g.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),g.setState({wcSignClients:w}),p.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},n=w=>l(void 0,null,function*(){let{wcSignClients:I}=g.getState(),b=I.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(b);}),a=w=>{try{let{wcSignClients:I}=g.getState(),b=I.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=b.session.getAll(),R=k.at(-1);if(!R)return;if(!(R.expiry*1e3>Date.now()+1e3))throw n(R.topic),new Error("invalid session");try{let _=k.find(Q=>{var H,X;return (X=(H=Q.requiredNamespaces.cosmos)==null?void 0:H.chains)==null?void 0:X.includes(`cosmos:${w}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return R}catch(I){if(!I.message.toLowerCase().includes("no matching key"))throw I}},s=w=>{try{return a(w)}catch(I){return}},c=w=>l(void 0,null,function*(){try{let I=w.core.pairing.pairings.getAll({active:!1});if(!I.length)return;yield Promise.all(I.map(b=>l(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(I){if(!I.message.toLowerCase().includes("no matching key"))throw I}}),m=()=>l(void 0,null,function*(){let{walletConnect:w}=p.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:I}=g.getState(),b=I.get(t);if(b)return b;let k=yield signClient.SignClient.init(w.options);return I.set(t,k),g.setState({wcSignClients:I}),k}),h=w=>{let{wcSignClients:I}=g.getState(),b=I.get(t);if(!b)return ()=>{};let k=R=>{let P=g.getState().accounts;if(R.params.event.name==="accountsChanged"&&P&&!Object.values(P).map(_=>_.bech32Address).includes(R.params.event.data[0])){let _=R.params.chainId.split(":")[1];_&&d([_]);}else w();};return b.events.on("session_delete",o),b.events.on("session_expire",o),b.events.on("session_event",k),()=>{b.events.off("session_delete",o),b.events.off("session_expire",o),b.events.off("session_event",k);}},d=w=>l(void 0,null,function*(){var X;let I=typeof w=="string"?[w]:w,{wcSignClients:b,activeChainIds:k}=g.getState(),R=b.get(t);if(!R)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:_}=p.getState();if(!((X=P==null?void 0:P.options)!=null&&X.projectId))throw new Error("walletConnect.options.projectId is not defined");let Q=new modal.WalletConnectModal(v({projectId:P.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.walletConnectModal)),H=s(I);if(!H){let{uri:F,approval:re}=yield Me(R.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:I.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!F)throw new Error("No wallet connect uri");e?r(F):yield Q.openModal({uri:F});let se=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,te)=>{re().then(Ue=>{let Fe=Ue.sessionProperties;if(!Fe)return te(new Error("No session properties"));let xe=JSON.parse(String(Fe.keys));if(xe.length===0)return te(new Error("No accounts"));if(!xe[0])return te(new Error("No accounts"));let qe={};return xe.forEach(V=>{qe[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),g.setState(V=>({accounts:v(v({},V.accounts||{}),qe)})),Te(Ue)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Te=$.signal;Q.subscribeModal(te=>{te.open||$.abort();}),yield se(Te);}catch($){if(Q.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||Q.closeModal(),Promise.resolve()}try{yield Me((()=>l(void 0,null,function*(){var re;let F=Object.fromEntries(yield Promise.all((re=k||I)==null?void 0:re.map(se=>l(void 0,null,function*(){return [se,yield E(se)]}))));g.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(n(H.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),f=w=>l(void 0,null,function*(){let I=yield E(w);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),E=w=>l(void 0,null,function*(){let I=a([w]);if(!(I!=null&&I.topic))throw new Error("No wallet connect session");let b=I.sessionProperties&&JSON.parse(String(I.sessionProperties.keys));if(!b)throw new Error("No wallet connect key");if(b.length===0)throw new Error("No wallet connect session");let k=b.find(R=>R.chainId===w);if(!k)throw new Error(`No wallet connect key for chainId ${w}`);return j(v({},k),{pubKey:Buffer.from(String(k.pubKey),i)})}),S=(...w)=>l(void 0,null,function*(){var X,F;let[I,b,k]=w,{accounts:R,wcSignClients:P}=g.getState(),_=P.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let Q=(X=a([I]))==null?void 0:X.topic;if(!Q)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");return r(),yield _.request({topic:Q,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:{chainId:k.chainId,accountNumber:(F=k.accountNumber)==null?void 0:F.toString(),bodyBytes:k.bodyBytes?Buffer.from(k.bodyBytes).toString(i):null,authInfoBytes:k.authInfoBytes?Buffer.from(k.authInfoBytes).toString(i):null}}}})}),A=(...w)=>l(void 0,null,function*(){var _;let[I,b,k]=w,{signature:R,signed:P}=yield S(I,b,k);return {signed:{chainId:(_=P.chainId)!=null?_:"",accountNumber:P.accountNumber?lt__default.default.fromString(P.accountNumber):new lt__default.default(0),authInfoBytes:P.authInfoBytes?new Uint8Array(Buffer.from(P.authInfoBytes,i)):new Uint8Array([]),bodyBytes:P.bodyBytes?new Uint8Array(Buffer.from(P.bodyBytes,i)):new Uint8Array([])},signature:R}}),T=(...w)=>l(void 0,null,function*(){var F;let[I,b,k,R]=w,{wcSignClients:P}=g.getState(),_=P.get(t),{accounts:Q}=g.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let H=(F=a([I]))==null?void 0:F.topic;if(!H)throw new Error("No wallet connect session");return r(),yield _.request({topic:H,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:k}}})}),O=(...w)=>l(void 0,null,function*(){let[I,b,k,R]=w;return yield T(I,b,k)}),u=w=>({getAccounts:()=>l(void 0,null,function*(){return [yield f(w)]}),signDirect:(I,b)=>A(w,I,b)}),y=w=>({getAccounts:()=>l(void 0,null,function*(){return [yield f(w)]}),signAmino:(I,b)=>O(w,I,b)});return {enable:d,disable:w=>l(void 0,null,function*(){var k;let{wcSignClients:I}=g.getState(),b=I.get(t);if(w===void 0){let R=b==null?void 0:b.session.getAll();R!==void 0&&(yield Promise.all(R.map(P=>n(P.topic))));}else typeof w=="string"?yield n((k=a([w]))==null?void 0:k.topic):yield Promise.all(w.map(R=>{var P;return n((P=a([R]))==null?void 0:P.topic)}));(b==null?void 0:b.session.getAll().length)===0&&o();}),experimentalSuggestChain:(...w)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:E,getOfflineSigner:w=>({getAccounts:()=>l(void 0,null,function*(){return [yield f(w)]}),signDirect:(I,b)=>A(w,I,b),signAmino:(I,b)=>O(w,I,b)}),getOfflineSignerAuto:w=>l(void 0,null,function*(){return (yield E(w)).isNanoLedger?y(w):u(w)}),getOfflineSignerOnlyAmino:y,signAmino:O,signDirect:A,subscription:h,init:m}};var ut=()=>{var t,i,r;if(!((r=(i=(t=p.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&r.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:(o,n,a)=>{let s=o.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return z(e)};var pt=()=>{var t,i,r;if(!((r=(i=(t=p.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&r.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:(o,n,a)=>{let s=o.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return z(e)};var mt=()=>{var t,i,r;if(!((r=(i=(t=p.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&r.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:(o,n,a)=>{let s=o.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${s}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return z(e)};var dt=()=>{var t,i,r;if(!((r=(i=(t=p.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&r.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:(o,n,a)=>{let s=o.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${s}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return z(e)};var Se=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:o=>{let n=()=>{N(),o();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw p.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=p.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(Y),g.setState(ne);},D=(e=p.getState().walletType)=>{var r;let t=(()=>{switch(e){case"keplr":return pe();case"leap":return me();case"cosmostation":return ue();case"vectis":return ye();case"walletconnect":return z();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return st();case"metamask_snap_cosmos":return nt();case"station":return ge();case"xdefi":return Se();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();case"initia":return ot();case"okx":return fe();default:throw new Error("Unknown wallet type")}})(),i=p.getState().walletDefaultOptions;return i&&((r=t.setDefaultOptions)==null||r.call(t,i)),t},ir=()=>Object.fromEntries($e.map(e=>[e,B(e)])),ke=e=>e==="capsule",ft=e=>e==="metamask_snap_leap",gt=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),ve=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var J=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:a,chains:s,walletType:c}=p.getState(),m=(e==null?void 0:e.walletType)||c;if(!B(m))throw new Error(`${m} is not available`);let d=D(m),f=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||a;if(!f)throw new Error("No last known connected chain, connect action requires chain ids");let E=s==null?void 0:s.map(O=>O.chainId);f.forEach(O=>{if(!(E!=null&&E.includes(O)))throw new Error(`Chain ${O} is not provided in GrazProvider`)}),g.setState(O=>{let u=p.getState()._reconnect||!!p.getState()._reconnectConnector||!!f;return O.activeChainIds&&f.filter(C=>{var M;return !((M=O.activeChainIds)!=null&&M.includes(C))}).length>0?{status:"connecting"}:u?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=g.getState();if(yield (t=d.init)==null?void 0:t.call(d),ke(m)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let O=f.map(C=>s.find(M=>M.chainId===C)),u=g.getState().accounts;g.setState({status:"connecting"});let y=Object.fromEntries(yield Promise.all(f.map(C=>l(void 0,null,function*(){return [C,yield d.getKey(C)]}))));return g.setState(C=>({accounts:v(v({},C.accounts||{}),y)})),p.setState(C=>({recentChainIds:[...C.recentChainIds||[],...f].filter((M,W,K)=>K.indexOf(M)===W)})),g.setState(C=>({activeChainIds:[...C.activeChainIds||[],...f].filter((M,W,K)=>K.indexOf(M)===W)})),g.setState({status:"connected"}),{accounts:u,walletType:m,chains:O}}if(yield d.enable(f),ke(m)){let O=f.map(y=>s.find(C=>C.chainId===y)),u=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:u,walletType:m,chains:O}}if(!ve(m)){let O={};if(ft(m)){let u={};try{for(var i=Qe(f),r,o,n;r=!(o=yield i.next()).done;r=!1){let y=o.value;u[y]=yield d.getKey(y);}}catch(o){n=[o];}finally{try{r&&(o=i.return)&&(yield o.call(i));}finally{if(n)throw n[0]}}O=u;}else if(gt()&&d.getKeys){let u=yield d.getKeys(f);f.forEach((y,C)=>{let M=u[C];M&&(O[y]=M);});}else O=Object.fromEntries(yield Promise.all(f.map(u=>l(void 0,null,function*(){return [u,yield d.getKey(u)]}))));g.setState(u=>({accounts:v(v({},u.accounts||{}),O)}));}p.setState(O=>({recentChainIds:[...O.recentChainIds||[],...f].filter((u,y,C)=>C.indexOf(u)===y)})),g.setState(O=>({activeChainIds:[...O.activeChainIds||[],...f].filter((u,y,C)=>C.indexOf(u)===y)})),p.setState({walletType:m,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:m}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(Y,"Active");let A=f.map(O=>s.find(u=>u.chainId===O));return {accounts:g.getState().accounts,walletType:m,chains:A}}catch(a){throw console.error("connect ",a),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.setState({status:"connected"}),a}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(Y);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let i=g.getState().accounts;t.forEach(o=>{i==null||delete i[o];}),Object.values(i||{}).length===0?(g.setState(ne),p.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(o=>{var n;return {activeChainIds:(n=o.activeChainIds)==null?void 0:n.filter(a=>!t.includes(a)),accounts:i}}),p.setState(o=>{var n;return {recentChainIds:(n=o.recentChainIds)==null?void 0:n.filter(a=>!t.includes(a))}}));}else g.setState(ne),p.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var o;let{recentChainIds:t,_reconnectConnector:i,_reconnect:r}=p.getState();try{let n=B(i||void 0);if(t&&n&&i)return ve(i)?void 0:yield J({chainId:t,walletType:i,autoReconnect:r})}catch(n){(o=e==null?void 0:e.onError)==null||o.call(e,n),oe();}}),yt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=p.getState(),i=e.walletType||t;if(!B(i))throw new Error(`${i} is not available`);let o=D(i),n=o.getOfflineSigner(e.chainId),a=o.getOfflineSignerOnlyAmino(e.chainId),s=yield o.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:a,offlineSignerAuto:s}});var Pe=()=>{p.setState({recentChainIds:null});},gr=()=>p.getState().recentChainIds,yr=()=>{var i;let{recentChainIds:e,chains:t}=p.getState();return (i=e==null?void 0:e.map(r=>t.find(o=>o.chainId===r)))!=null?i:null},Sr=({chainId:e})=>{var t;return (t=p.getState().chains)==null?void 0:t.find(i=>i.chainId===e)},Cr=({chainId:e})=>{var t;return (t=p.getState().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},We=i=>l(void 0,[i],function*({chainInfo:e,walletType:t}){let r=D(t);return t==="capsule"?yield J({chainId:e.chainId,walletType:t}):yield r.experimentalSuggestChain(e),e}),St=e=>l(void 0,null,function*(){var r;let t=p.getState().walletType;return yield We({chainInfo:e.chainInfo,walletType:(r=e.walletType)!=null?r:t}),yield J({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var Ct=e=>(p.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var ht=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:i,amount:r,fee:o,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,i,r,o,n)}),wt=h=>l(void 0,[h],function*({signingClient:e,senderAddress:t,recipientAddress:i,transferAmount:r,sourcePort:o,sourceChannel:n,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,i,r,o,n,a,s,c,m)}),At=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:r,options:o,label:n,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,i,n,r,o)}),It=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:r,contractAddress:o,funds:n,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,o,i,r,a,n)}),Et=(e,t,i)=>l(void 0,null,function*(){if(!i)throw new Error("CosmWasm client is not ready");return yield i.queryContractSmart(e,t)}),Ot=(e,t,i)=>{if(!i)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return i.queryContractRaw(e,r)};var Mr=e=>e,kr=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var Re=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},bt=e=>globalThis.DOMException===void 0?new Re(e):new DOMException(e),Tt=e=>{let t=e.reason===void 0?bt("This operation was aborted."):e.reason;return t instanceof Error?t:bt(t)};function Ke(n,a){return l(this,arguments,function*(e,t,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:o}={}){return new Promise((s,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(i)||i===Number.POSITIVE_INFINITY)&&i>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`);let m=[],h=[],d=new Map,f=!1,E=!1,S=!1,A=0,T=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),u=C=>{f=!0,E=!0,c(C);};o&&(o.aborted&&u(Tt(o)),o.addEventListener("abort",()=>{u(Tt(o));}));let y=()=>l(this,null,function*(){if(E)return;let C=yield O.next(),M=T;if(T++,C.done){if(S=!0,A===0&&!E){if(!r&&h.length>0){u(new AggregateError(h));return}if(E=!0,d.size===0){s(m);return}let W=[];for(let[K,ee]of m.entries())d.get(K)!==xt&&W.push(ee);s(W);}return}A++,l(this,null,function*(){try{let W=yield C.value;if(E)return;let K=yield t(W,M);K===xt&&d.set(M,K),m[M]=K,A--,yield y();}catch(W){if(r)u(W);else {h.push(W),A--;try{yield y();}catch(K){u(K);}}}});});l(this,null,function*(){for(let C=0;C<i;C++){try{yield y();}catch(M){u(M);break}if(S||f)break}});})})}var xt=Symbol("skip");var U=({chainId:e,multiChain:t})=>{let i=p(o=>o.chains);if(!i)throw new Error("No chains found in GrazProvider");let r=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!r):return r.map(o=>i.find(n=>n.chainId===o)).filter(Boolean);case(!t&&!!r):return [r.map(o=>i.find(n=>n.chainId===o)).filter(Boolean)[0]];case(!!t&&!r):return i;default:return [i[0]]}},q=(e,t,i)=>l(void 0,null,function*(){let r=p.getState().multiChainFetchConcurrency;if(e){let n=yield Ke(t,i,{concurrency:r});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield i(t[0])}),Mt=(e,t,i)=>{if(e){let o=t.map(i);return Object.fromEntries(o.map((n,a)=>[t[a].chainId,n]))}return i(t[0])};var Ne=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:i,queryFn:o=>l(void 0,[o],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),r,a=>l(void 0,null,function*(){var h;let s=(h=p.getState().chainsConfig)==null?void 0:h[a.chainId],c={url:a.rpc,headers:v({},(s==null?void 0:s.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Be=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:i,queryFn:o=>l(void 0,[o],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),r,a=>l(void 0,null,function*(){var h;let s=(h=p.getState().chainsConfig)==null?void 0:h[a.chainId],c={url:a.rpc,headers:v({},(s==null?void 0:s.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:i,enabled:r})=>{let o=U({chainId:t,multiChain:i}),n=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,o],[e,o]);return reactQuery.useQuery({queryKey:n,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield q(!!i,s,h=>l(void 0,null,function*(){var A;let d=(A=p.getState().chainsConfig)==null?void 0:A[h.chainId],f={url:h.rpc,headers:v({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(f)}))}),enabled:!!o&&o.length>0&&(r!==void 0?!!r:!0),refetchOnWindowFocus:!1})};var ns=()=>p(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",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),we=e=>{let i=["USE_CHECK_WALLET",p(o=>e||o.walletType)];return reactQuery.useQuery({queryKey:i,queryFn:({queryKey:[,o]})=>B(o)})};var Z=e=>{let t=p(s=>s.walletType),i=g(s=>s.activeChainIds),r=U({chainId:e!=null&&e.chainId?e.chainId:i||void 0,multiChain:e==null?void 0:e.multiChain}),o=g(s=>s.accounts),n=g(s=>s.status);return react.useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var m,h,d;if(s==="connected"){let{accounts:f,activeChainIds:E}=g.getState(),{chains:S}=p.getState(),{walletType:A}=p.getState();if(!f||!E||!S)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(h=e==null?void 0:e.onConnect)==null||h.call(e,{accounts:f,chains:E.map(T=>S.find(O=>O.chainId===T)),walletType:A,isReconnect:c==="reconnecting"});}s==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:react.useMemo(()=>o?Mt(!!(e!=null&&e.multiChain),r,s=>o[s.chainId]):void 0,[o,r,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}},wn=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=Z(),r=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),{data:o}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!r}),n=react.useMemo(()=>["USE_ALL_BALANCES",o,t,r,e==null?void 0:e.chainId],[r,e==null?void 0:e.chainId,t,o]);return reactQuery.useQuery({queryKey:n,queryFn:m=>l(void 0,[m],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var S;let f=a==null?void 0:a[d.chainId];if(!f)throw new Error(`Client is not ready ${d.chainId}`);if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield f.getAllBalances(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!Ce(o)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},gs=e=>{let t=U({chainId:e.chainId}),{data:i}=Z({chainId:e.chainId}),r=e.bech32Address||(i==null?void 0:i.bech32Address),{data:o,refetch:n}=wn({chainId:t.map(c=>c.chainId),bech32Address:r,enabled:!!r&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,o,t,r,e.chainId],s=reactQuery.useQuery({queryKey:a,queryFn:({queryKey:[,c,m]})=>m==null?void 0:m.find(h=>h.denom===c),enabled:!!e.denom&&!!o&&!!(o!=null&&o.length)&&(e.enabled===void 0?!0:e.enabled)});return j(v({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},ys=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,i],mutationFn:J,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=we();return {connect:a=>o.mutate(a),connectAsync:a=>o.mutateAsync(a),error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,isSupported:!!n,status:o.status}},Ss=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,i],mutationFn:oe,onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(i==null?void 0:i(void 0))});return {disconnect:n=>o.mutate(n),disconnectAsync:n=>o.mutateAsync(n),error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,status:o.status}},Cs=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=p(o=>o.walletType),r=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,i],[t,i]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(void 0,[a],function*({queryKey:[,o,n]}){if(o.length<1)throw new Error("No chain found");if(!B(n))throw new Error(`${n} is not available`);return yield q(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield yt({chainId:m.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!i,refetchOnWindowFocus:!1})},hs=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=Z(),{data:r}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0}),o=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),n=react.useMemo(()=>["USE_BALANCE_STAKED",r,t,o],[t,o,r]);return reactQuery.useQuery({queryKey:n,queryFn:m=>l(void 0,[m],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var E,S;if(!a)throw new Error("Client is not ready");if(!((E=d.bech32Config)!=null&&E.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (S=a[d.chainId])==null?void 0:S.getBalanceStaked(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!o&&!!t&&t.length>0&&!!r,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Ts=()=>{let e=p(r=>r.capsuleState),t=g(r=>r.capsuleClient),i=ae();return {setModalState:r=>{p.setState(o=>{var n;return {capsuleState:{showModal:r,chainId:(n=o.capsuleState)==null?void 0:n.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:i.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var Rs=()=>g(e=>e.activeChainIds),An=()=>{var e;return (e=g(t=>t.activeChainIds))==null?void 0:e.map(t=>{var r;let i=(r=p.getState().chains)==null?void 0:r.find(o=>o.chainId===t);if(i)return i}).filter(Boolean)},Ks=({chainId:e})=>{var t;return (t=p().chains)==null?void 0:t.find(i=>i.chainId===e)},Ds=({chainId:e})=>{var t;return (t=p().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},_s=({denom:e})=>{let t=An();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,o]})=>{var n;return (n=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===o)))==null?void 0:n.currencies.find(a=>a)}})},Ns=e=>{var o;let t=(o=e.status)!=null?o:"BOND_STATUS_BONDED",i=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,n,a]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(a)}),enabled:typeof e.queryClient!="undefined"})},Bs=()=>({data:p(t=>t.recentChainIds),clear:Pe}),Ls=()=>{var t;return {data:(t=p(i=>i.recentChainIds))==null?void 0:t.map(i=>{var o;let r=(o=p.getState().chains)==null?void 0:o.find(n=>n.chainId===i);if(r)return r}).filter(Boolean),clear:Pe}},Us=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,i],mutationFn:We,onError:(n,a)=>Promise.resolve(e==null?void 0:e(n,a.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(i==null?void 0:i(n))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},Fs=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,i],mutationFn:St,onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=we();return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,isSupported:!!n,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var Hs=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:r}=Z(),o=r==null?void 0:r.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,i,o],mutationFn:a=>ht(v({senderAddress:o},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},Xs=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:r}=Z(),o=r==null?void 0:r.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,i,o],mutationFn:a=>wt(v({senderAddress:o},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Ys=({codeId:e,onError:t,onLoading:i,onSuccess:r})=>{let{data:o}=Z(),n=o==null?void 0:o.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,i,r,e,n],mutationFn:c=>{var h;if(!n)throw new Error("senderAddress is undefined");let m=j(v({},c),{fee:(h=c.fee)!=null?h:"auto",senderAddress:n,codeId:e});return At(m)},onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:i,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Js=({contractAddress:e,onError:t,onLoading:i,onSuccess:r})=>{let{data:o}=Z(),n=o==null?void 0:o.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,i,r,e,n],mutationFn:c=>{var h,d,f;if(!n)throw new Error("senderAddress is undefined");let m=j(v({},c),{fee:(h=c.fee)!=null?h:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(f=c.funds)!=null?f:[]});return It(m)},onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:i,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Zs=e=>{let{data:t}=Be();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return Et(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ea=e=>{let{data:t}=Be(),i=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:i,queryFn:({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ot(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function da(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=p(n=>n.walletType),r=g(n=>n.activeChainIds),o=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]);return reactQuery.useQuery({queryKey:o,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),n,m=>l(this,null,function*(){var A,T;if(!(r!=null&&r.includes(m.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(m.chainId);default:return D(a).getOfflineSignerAuto(m.chainId)}}))(),f=(A=p.getState().chainsConfig)==null?void 0:A[m.chainId],E={url:m.rpc,headers:v({},(f==null?void 0:f.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(E,d,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function fa(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=p(n=>n.walletType),r=g(n=>n.activeChainIds),o=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]);return reactQuery.useQuery({queryKey:o,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),n,m=>l(this,null,function*(){var T,O;if(!(r!=null&&r.includes(m.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(m.chainId);default:return D(a).getOfflineSignerAuto(m.chainId)}}))(),f=(T=p.getState().chainsConfig)==null?void 0:T[m.chainId],E={url:m.rpc,headers:v({},(f==null?void 0:f.rpcHeaders)||{})},S=f!=null&&f.gas?stargate.GasPrice.fromString(`${f.gas.price}${f.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(E,d,v({gasPrice:S},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ga(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),i=p(a=>a.walletType),r=g(a=>a.activeChainIds),o=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]),{data:n}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,h=>l(this,null,function*(){var A;if(!(r!=null&&r.includes(h.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);if(!n)throw new Error("No tendermint client found");let f=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(h.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(h.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(h.chainId);default:return D(s).getOfflineSignerAuto(h.chainId)}}))(),E=e.multiChain?n[h.chainId]:n;return yield stargate.SigningStargateClient.createWithSigner(E,f,e.multiChain?(A=e.opts)==null?void 0:A[h.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&!!n&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ya(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),i=p(s=>s.walletType),r=g(s=>s.activeChainIds),o=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]),{data:n}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:o,queryFn:m=>l(this,[m],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,d=>l(this,null,function*(){var u,y;if(!(r!=null&&r.includes(d.chainId)))return null;if(!B(c))throw new Error(`${c} is not available`);let E=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return D(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return D(c).getOfflineSignerOnlyAmino(d.chainId);default:return D(c).getOfflineSignerAuto(d.chainId)}}))(),S=(u=p.getState().chainsConfig)==null?void 0:u[d.chainId],A=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0,T=e.multiChain?a==null?void 0:a[d.chainId]:n;if(!T)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(T,E,v({gasPrice:A},e.multiChain?(y=e.opts)==null?void 0:y[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!i&&(!!n||!Ce(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Bt=({children:e})=>{let[t,i]=react.useState(!1);return react.useEffect(()=>{i(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var xn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(Y)==="Active",{_reconnect:t,_onReconnectFailed:i,_reconnectConnector:r,iframeOptions:o,chains:n}=p(),{activeChainIds:a,wcSignClients:s}=g(),c=B(r||void 0);return react.useEffect(()=>{if(!o||o.autoConnect===!1||!o.allowedIframeParentOrigins.length||!n)return;new cosmiframe.Cosmiframe(o.allowedIframeParentOrigins).isReady().then(h=>{if(h)return J({chainId:n.map(d=>d.chainId),walletType:"cosmiframe"})});},[o]),react.useEffect(()=>{if(r){if(!c)return;e&&a?L({onError:i}):!e&&t&&L({onError:i});}},[c]),react.useEffect(()=>{var m,h,d,f,E,S,A,T,O,u,y,C,M,W,K,ee,ie,w,I,b;if(r){if(!c)return;r==="cosmostation"&&((h=(m=ue()).subscription)==null||h.call(m,()=>{L({onError:i});})),r==="keplr"&&((f=(d=pe()).subscription)==null||f.call(d,()=>{L({onError:i});})),r==="leap"&&((S=(E=me()).subscription)==null||S.call(E,()=>{L({onError:i});})),r==="compass"&&((T=(A=ce()).subscription)==null||T.call(A,()=>{L({onError:i});})),r==="vectis"&&((u=(O=ye()).subscription)==null||u.call(O,()=>{L({onError:i});})),r==="walletconnect"&&s.has("walletconnect")&&((C=(y=z()).subscription)==null||C.call(y,()=>{L({onError:i});})),r==="station"&&((W=(M=ge()).subscription)==null||W.call(M,()=>{L({onError:i});})),r==="xdefi"&&((ee=(K=Se()).subscription)==null||ee.call(K,()=>{L({onError:i});})),r==="cosmiframe"&&((w=(ie=le()).subscription)==null||w.call(ie,()=>{L({onError:i});})),r==="okx"&&((b=(I=fe()).subscription)==null||b.call(I,()=>{L({onError:i});}));}},[r,s,c]),null},Lt=()=>(xn(),null);var ja=({children:e,grazOptions:t})=>(react.useEffect(()=>{Ct(t);},[t]),jsxRuntime.jsxs(Bt,{children:[e,jsxRuntime.jsx(Lt,{})]}));
|
|
24
|
+
var _t=Object.defineProperty,Rt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var Ke=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable;var Ne=(e,t,o)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,M=(e,t)=>{for(var o in t||(t={}))Kt.call(t,o)&&Ne(e,o,t[o]);if(Ke)for(var o of Ke(t))Nt.call(t,o)&&Ne(e,o,t[o]);return e},F=(e,t)=>Rt(e,Dt(t));var l=(e,t,o)=>new Promise((r,i)=>{var n=c=>{try{s(o.next(c));}catch(p){i(p);}},a=c=>{try{s(o.throw(c));}catch(p){i(p);}},s=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,a);s((o=o.apply(e,t)).next());}),Be=(e,t,o)=>(t=e[Symbol.asyncIterator],o=(r,i)=>(i=e[r])&&(t[r]=n=>new Promise((a,s,c)=>(n=i.call(e,n),c=n.done,Promise.resolve(n.value).then(p=>a({value:p,done:c}),s)))),t?t.call(e):(e=e[Symbol.iterator](),t={},o("next"),o("return"),t));var ee="graz-reconnect-session";var Le=(C=>(C.KEPLR="keplr",C.LEAP="leap",C.VECTIS="vectis",C.COSMOSTATION="cosmostation",C.WALLETCONNECT="walletconnect",C.WC_KEPLR_MOBILE="wc_keplr_mobile",C.WC_LEAP_MOBILE="wc_leap_mobile",C.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",C.WC_CLOT_MOBILE="wc_clot_mobile",C.METAMASK_SNAP_LEAP="metamask_snap_leap",C.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",C.STATION="station",C.XDEFI="xdefi",C.COSMIFRAME="cosmiframe",C.COMPASS="compass",C.INITIA="initia",C.OKX="okx",C))(Le||{}),Ue=["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"];var Lt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map},Ut={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},Ft={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},I=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,Ut))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Lt,Ft)));var ae=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let n=()=>{K(),i();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ce=()=>{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 je={},$e=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var g;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 s=(g=n.split("MetaMask/v")[1])==null?void 0:g.split(".")[0];if(!(Number(s)>=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,!0}),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(F(M({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,a,s)=>l(void 0,null,function*(){return t.signAmino(n,a,s)}),getKey:n=>l(void 0,null,function*(){return typeof je[n]!="undefined"?je[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,a,s)=>l(void 0,null,function*(){return t.signDirect(n,a,s)}),signArbitrary:(n,a,s)=>l(void 0,null,function*(){return t.signArbitrary(n,a,s)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var le=()=>{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 a=()=>{K(),n();};return window.addEventListener("cosmostation_keystorechange",a),()=>{window.removeEventListener("cosmostation_keystorechange",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Ht=e=>{let{bodyBytes:t,authInfoBytes:o,chainId:r,accountNumber:i}=e;if(!t||!o||!r||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:o,chainId:r,accountNumber:i}},Xt=e=>`${e.slice(0,6)}...${e.slice(-6)}`,He=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:m=>l(void 0,null,function*(){let d=e.getOfflineSigner(m),[A]=yield d.getAccounts();if(!A)throw new Error("Wallet connection failed");let T=(()=>{switch(A.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(A.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(A.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:Xt(A.address),algo:A.algo,pubKey:A.pubkey,bech32Address:A.address,address:T,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:m=>{let d=e.getOfflineSigner(m),A=e.getOfflineSignerOnlyAmino(m);return {getAccounts:d.getAccounts.bind(d),signDirect:d.signDirect.bind(d),signAmino:A.signAmino.bind(A)}},getOfflineSignerAuto:m=>Promise.resolve(e.getOfflineSigner(m)),getOfflineSignerOnlyAmino:m=>e.getOfflineSignerOnlyAmino(m),experimentalSuggestChain:m=>e.requestAddInitiaLayer({chain_id:m.chainId,chain_name:m.chainName,bech32_prefix:"init",bech32_config:m.bech32Config,slip44:m.bip44.coinType,logo_URIs:{png:m.chainSymbolImageUrl},fees:{fee_tokens:m.feeCurrencies.map(d=>{var A,T,v;return {denom:d.coinDenom,amount:d.coinMinimalDenom,low_gas_price:(A=d.gasPriceStep)==null?void 0:A.low,average_gas_price:(T=d.gasPriceStep)==null?void 0:T.average,high_gas_price:(v=d.gasPriceStep)==null?void 0:v.high}})},apis:{rpc:[{address:m.rpc}],rest:[{address:m.rest}]}}),signDirect:(...m)=>{let[d,A,T]=m;return e.getOfflineSigner(d).signDirect(A,Ht(T))},signAmino:(...m)=>{let[d,A,T]=m;return e.getOfflineSignerOnlyAmino(d).signAmino(A,T)},signArbitrary:(m,d,A)=>l(void 0,null,function*(){let P=(yield e.getOfflineSigner(m).getAccounts()).find(h=>h.address===d);if(!P)throw new Error(`Wallet not connected to account ${d}`);let C=(()=>{switch(P.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(P.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(P.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(A),pub_key:{type:P.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:C.value}}}),subscription:m=>{let d=()=>{K(),m();};return window.addEventListener("initia_keystorechange",d),()=>{window.removeEventListener("initia_keystorechange",d);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var ue=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let n=()=>{K(),i();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var pe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let n=()=>{K(),i();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var me={},Ye=e=>{let t=window.ethereum;if(t&&e){let o=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),r=f=>l(void 0,null,function*(){try{let h=yield o();return Object.values(h).find(b=>b.id===e.id&&(!f||b.version===f))}catch(h){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var _;let f=yield t.request({method:"web3_clientVersion"});if(!f.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=(_=f.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield r())||(yield i()),!0}),a=f=>l(void 0,null,function*(){(yield r())||(yield i());}),s=(f,h,b)=>l(void 0,null,function*(){let k=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:h,signDoc:b}}}}),D=b.accountNumber,_=new be__default.default(D.low,D.high,D.unsigned);return {signature:k.signature,signed:F(M({},k.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(k.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(k.signed.bodyBytes))})}}),c=(f,h,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:h,signDoc:b}}}})}),p=f=>l(void 0,null,function*(){if(typeof me[f]!="undefined")return me[f];let h=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!h)throw new Error("No response from Metamask");return h.pubKey=Uint8Array.from(Object.values(h.pubkey)),delete h.pubkey,me[f]=h,me[f]}),g=f=>l(void 0,null,function*(){let h=yield p(f);return {address:h.bech32Address,algo:h.algo,pubkey:h.pubKey}}),m=(...f)=>l(void 0,null,function*(){let[h,b,k,D]=f;return yield c(h,b,k)}),d=(...f)=>l(void 0,null,function*(){var j;let[h,b,k]=f,D=F(M({},k),{accountNumber:be__default.default.fromString(((j=k.accountNumber)==null?void 0:j.toString())||"0"),authInfoBytes:k.authInfoBytes,bodyBytes:k.bodyBytes});return yield s(h,b,D)}),T=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(f)]}),signAmino:(h,b)=>m(f,h,b)});return {enable:a,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(f)]}),signDirect:(h,b)=>d(f,h,b),signAmino:(h,b)=>m(f,h,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return T(f)}),getOfflineSignerOnlyAmino:T,init:n,signAmino:m,signDirect:d}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Je=()=>Ye({id:"npm:@leapwallet/metamask-cosmos-snap"});var de=()=>{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 s;let a=()=>{K(),n();};return (s=window.okxwallet)==null||s.on("accountsChanged",a),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{K(),n();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:n=>l(void 0,null,function*(){let a=yield e.getKey(n);return M({isKeystone:!1},a)}),getOfflineSigner:n=>{try{let a=e.getOfflineSignerOnlyAmino(n);return Object.assign(a,{signDirect:(p,g)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:n=>l(void 0,null,function*(){try{if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(n,{bech32Config:n.bech32Config,chainSymbolImageUrl:n.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:n.stakeCurrency.coinDecimals,coinDenom:n.stakeCurrency.coinDenom,coinImageUrl:n.stakeCurrency.coinImageUrl||"",coinMinimalDenom:n.stakeCurrency.coinMinimalDenom},currencies:n.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:n.feeCurrencies.map(s=>{var c,p,g;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((g=s.gasPriceStep)==null?void 0:g.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:n=>e.enable(n),disable:n=>e.disable(n),getOfflineSignerAuto:n=>e.getOfflineSignerAuto(n),getOfflineSignerOnlyAmino:n=>e.getOfflineSignerOnlyAmino(n),signDirect:()=>e.signDirect(),signAmino:(n,a,s,c)=>e.signAmino(n,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ge=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>{let c=e.getOfflineSigner(s);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(p,g)=>l(void 0,null,function*(){var d;let m=yield c.signDirect(p,{accountNumber:be__default.default.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),authInfoBytes:g.authInfoBytes,bodyBytes:g.bodyBytes,chainId:g.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:s=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(s);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(p,g)=>l(void 0,null,function*(){var d;let m=yield c.signDirect(p,{accountNumber:be__default.default.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),authInfoBytes:g.authInfoBytes,bodyBytes:g.bodyBytes,chainId:g.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}})}:c}),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{K(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>{let c=s[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...s)=>l(void 0,null,function*(){var g;let[c]=s;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let p={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(g=c.bech32Config)==null?void 0:g.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([p])}),signDirect:(...s)=>l(void 0,null,function*(){var m;let{1:c,2:p}=s,g=yield e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:be__default.default.fromString(((m=p.accountNumber)==null?void 0:m.toString())||"",!1),chainId:p.chainId||""});return {signature:g.signature,signed:{authInfoBytes:g.signed.authInfoBytes,bodyBytes:g.signed.bodyBytes,chainId:g.signed.chainId,accountNumber:BigInt(g.signed.accountNumber.toString())}}}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var q=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},Ze=()=>q()&&navigator.userAgent.toLowerCase().includes("android"),et=()=>q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Oe=(e,t,o=new Error("Promise timed out"))=>{let r=new Promise((i,n)=>{setTimeout(()=>{n(o);},t);});return Promise.race([e,r])};var G=e=>{var _,j,oe;if(!((oe=(j=(_=u.getState().walletConnect)==null?void 0:_.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",r=y=>{if(!e)return;let{appUrl:S,formatNativeUrl:w}=e;if(q()){if(Ze()){let E=w(S.mobile.android,y,"android");window.open(E,"_self","noreferrer noopener");}if(et()){let E=w(S.mobile.ios,y,"ios");window.open(E,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=I.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),I.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},n=y=>l(void 0,null,function*(){let{wcSignClients:S}=I.getState(),w=S.get(t);if(!w)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield w.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(w);}),a=y=>{try{let{wcSignClients:S}=I.getState(),w=S.get(t);if(!w)throw new Error("walletConnect.signClient is not defined");let E=w.session.getAll(),W=E.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw n(W.topic),new Error("invalid session");try{let R=E.find(Q=>{var X,Y;return (Y=(X=Q.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${y}`)});if(!R)throw new Error("no session");return R}catch(R){if(!R.message.toLowerCase().includes("no matching key"))throw R}return W}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},s=y=>{try{return a(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(w=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(w.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),p=()=>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:S}=I.getState(),w=S.get(t);if(w)return w;let E=yield signClient.SignClient.init(y.options);return S.set(t,E),I.setState({wcSignClients:S}),E}),g=y=>{let{wcSignClients:S}=I.getState(),w=S.get(t);if(!w)return ()=>{};let E=W=>{let x=I.getState().accounts;if(W.params.event.name==="accountsChanged"&&x&&!Object.values(x).map(R=>R.bech32Address).includes(W.params.event.data[0])){let R=W.params.chainId.split(":")[1];R&&m([R]);}else y();};return w.events.on("session_delete",i),w.events.on("session_expire",i),w.events.on("session_event",E),()=>{w.events.off("session_delete",i),w.events.off("session_expire",i),w.events.off("session_event",E);}},m=y=>l(void 0,null,function*(){var Y;let S=typeof y=="string"?[y]:y,{wcSignClients:w,activeChainIds:E}=I.getState(),W=w.get(t);if(!W)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 Q=new modal.WalletConnectModal(M({projectId:x.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},x.walletConnectModal)),X=s(S);if(!X){let{uri:L,approval:re}=yield Oe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?r(L):yield Q.openModal({uri:L});let se=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ae,Z)=>{re().then(_e=>{let Re=_e.sessionProperties;if(!Re)return Z(new Error("No session properties"));let Ie=JSON.parse(String(Re.keys));if(Ie.length===0)return Z(new Error("No accounts"));if(!Ie[0])return Z(new Error("No accounts"));let De={};return Ie.forEach(V=>{De[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),I.setState(V=>({accounts:M(M({},V.accounts||{}),De)})),Ae(_e)}).catch(Z),$.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Ae=$.signal;Q.subscribeModal(Z=>{Z.open||$.abort();}),yield se(Ae);}catch($){if(Q.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||Q.closeModal(),Promise.resolve()}try{yield Oe((()=>l(void 0,null,function*(){var re;let L=Object.fromEntries(yield Promise.all((re=E||S)==null?void 0:re.map(se=>l(void 0,null,function*(){return [se,yield A(se)]}))));I.setState({accounts:L});}))(),15e3,new Error("Connection timeout"));}catch(L){if(n(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),d=y=>l(void 0,null,function*(){let S=yield A(y);return {address:S.bech32Address,algo:S.algo,pubkey:S.pubKey}}),A=y=>l(void 0,null,function*(){let S=a([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let w=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys));if(!w)throw new Error("No wallet connect key");if(w.length===0)throw new Error("No wallet connect session");let E=w.find(W=>W.chainId===y);if(!E)throw new Error(`No wallet connect key for chainId ${y}`);return F(M({},E),{pubKey:Buffer.from(String(E.pubKey),o)})}),T=(...y)=>l(void 0,null,function*(){var Y,L;let[S,w,E]=y,{accounts:W,wcSignClients:x}=I.getState(),R=x.get(t);if(!R)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let Q=(Y=a([S]))==null?void 0:Y.topic;if(!Q)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");return r(),yield R.request({topic:Q,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:w,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}}}})}),v=(...y)=>l(void 0,null,function*(){var R;let[S,w,E]=y,{signature:W,signed:x}=yield T(S,w,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:W}}),P=(...y)=>l(void 0,null,function*(){var L;let[S,w,E,W]=y,{wcSignClients:x}=I.getState(),R=x.get(t),{accounts:Q}=I.getState();if(!R)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let X=(L=a([S]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return r(),yield R.request({topic:X,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:w,signDoc:E}}})}),C=(...y)=>l(void 0,null,function*(){let[S,w,E,W]=y;return yield P(S,w,E)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,w)=>v(y,S,w)}),h=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signAmino:(S,w)=>C(y,S,w)});return {enable:m,disable:y=>l(void 0,null,function*(){var E;let{wcSignClients:S}=I.getState(),w=S.get(t);if(y===void 0){let W=w==null?void 0:w.session.getAll();W!==void 0&&(yield Promise.all(W.map(x=>n(x.topic))));}else typeof y=="string"?yield n((E=a([y]))==null?void 0:E.topic):yield Promise.all(y.map(W=>{var x;return n((x=a([W]))==null?void 0:x.topic)}));(w==null?void 0:w.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:A,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,w)=>v(y,S,w),signAmino:(S,w)=>C(y,S,w)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield A(y)).isNanoLedger?h(y):f(y)}),getOfflineSignerOnlyAmino:h,signAmino:C,signDirect:v,subscription:g,init:p}};var tt=()=>{var t,o,r;if(!((r=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!q())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,n,a)=>{let s=i.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return G(e)};var nt=()=>{var t,o,r;if(!((r=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!q())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,n,a)=>{let s=i.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return G(e)};var ot=()=>{var t,o,r;if(!((r=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!q())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,n,a)=>{let s=i.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${s}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return G(e)};var it=()=>{var t,o,r;if(!((r=(o=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:o.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!q())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,n,a)=>{let s=i.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${s}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return G(e)};var ye=()=>{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 n=()=>{K(),i();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var U=(e=u.getState().walletType)=>{try{return N(e),!0}catch(t){return !1}},K=()=>{window.sessionStorage.removeItem(ee),I.setState(ne);},N=(e=u.getState().walletType)=>{var r;let t=(()=>{switch(e){case"keplr":return ue();case"leap":return pe();case"cosmostation":return le();case"vectis":return ge();case"walletconnect":return G();case"wc_keplr_mobile":return ot();case"wc_leap_mobile":return it();case"wc_cosmostation_mobile":return nt();case"wc_clot_mobile":return tt();case"metamask_snap_leap":return Je();case"metamask_snap_cosmos":return $e();case"station":return fe();case"xdefi":return ye();case"cosmiframe":return ce();case"compass":return ae();case"initia":return He();case"okx":return de();default:throw new Error("Unknown wallet type")}})(),o=u.getState().walletDefaultOptions;return o&&((r=t.setDefaultOptions)==null||r.call(t,o)),t},Ni=()=>Object.fromEntries(Ue.map(e=>[e,U(e)])),rt=e=>e==="metamask_snap_leap",st=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),ie=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:a,chains:s,walletType:c}=u.getState(),p=(e==null?void 0:e.walletType)||c;if(ie(p)){let C=N("walletconnect"),{disable:f}=C;f&&f();}if(!U(p))throw new Error(`${p} is not available`);let m=N(p),d=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||a;if(!d)throw new Error("No last known connected chain, connect action requires chain ids");let A=s==null?void 0:s.map(C=>C.chainId);d.forEach(C=>{if(!(A!=null&&A.includes(C)))throw new Error(`Chain ${C} is not provided in GrazProvider`)}),I.setState(C=>{let f=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!d;return C.activeChainIds&&d.filter(b=>{var k;return !((k=C.activeChainIds)!=null&&k.includes(b))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:T}=I.getState();if(yield (t=m.init)==null?void 0:t.call(m),yield m.enable(d),!ie(p)){let C={};if(rt(p)){let f={};try{for(var o=Be(d),r,i,n;r=!(i=yield o.next()).done;r=!1){let h=i.value;f[h]=yield m.getKey(h);}}catch(i){n=[i];}finally{try{r&&(i=o.return)&&(yield i.call(o));}finally{if(n)throw n[0]}}C=f;}else if(st()&&m.getKeys){let f=yield m.getKeys(d);d.forEach((h,b)=>{let k=f[b];k&&(C[h]=k);});}else C=Object.fromEntries(yield Promise.all(d.map(f=>l(void 0,null,function*(){return [f,yield m.getKey(f)]}))));I.setState(f=>({accounts:M(M({},f.accounts||{}),C)}));}u.setState(C=>({recentChainIds:[...C.recentChainIds||[],...d].filter((f,h,b)=>b.indexOf(f)===h)})),I.setState(C=>({activeChainIds:[...C.activeChainIds||[],...d].filter((f,h,b)=>b.indexOf(f)===h)})),u.setState({walletType:p,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:p}),I.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ee,"Active");let v=d.map(C=>s.find(f=>f.chainId===C));return {accounts:I.getState().accounts,walletType:p,chains:v}}catch(a){throw console.error("connect ",a),I.getState().accounts===null&&I.setState({status:"disconnected"}),I.getState().accounts&&I.getState().activeChainIds&&I.setState({status:"connected"}),a}}),Ee=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;if(ie(u.getState().walletType)){let o=N("walletconnect"),{disable:r}=o;r&&r();}if(t){let o=I.getState().accounts;t.forEach(i=>{o==null||delete o[i];}),Object.values(o||{}).length===0?(I.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(I.setState(i=>{var n;return {activeChainIds:(n=i.activeChainIds)==null?void 0:n.filter(a=>!t.includes(a)),accounts:o}}),u.setState(i=>{var n;return {recentChainIds:(n=i.recentChainIds)==null?void 0:n.filter(a=>!t.includes(a))}}));}else I.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:o,_reconnect:r}=u.getState();try{let n=U(o||void 0);if(t&&n&&o)return ie(o)?void 0:yield te({chainId:t,walletType:o,autoReconnect:r})}catch(n){(i=e==null?void 0:e.onError)==null||i.call(e,n),Ee();}}),at=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(!U(o))throw new Error(`${o} is not available`);let i=N(o),n=i.getOfflineSigner(e.chainId),a=i.getOfflineSignerOnlyAmino(e.chainId),s=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:a,offlineSignerAuto:s}});var Te=()=>{u.setState({recentChainIds:null});},Hi=()=>u.getState().recentChainIds,Xi=()=>{var o;let{recentChainIds:e,chains:t}=u.getState();return (o=e==null?void 0:e.map(r=>t.find(i=>i.chainId===r)))!=null?o:null},Yi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(o=>o.chainId===e)},Ji=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},ke=o=>l(void 0,[o],function*({chainInfo:e,walletType:t}){return yield N(t).experimentalSuggestChain(e),e}),ct=e=>l(void 0,null,function*(){var r;let t=u.getState().walletType;return yield ke({chainInfo:e.chainInfo,walletType:(r=e.walletType)!=null?r:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var lt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var ut=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:o,amount:r,fee:i,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,r,i,n)}),pt=g=>l(void 0,[g],function*({signingClient:e,senderAddress:t,recipientAddress:o,transferAmount:r,sourcePort:i,sourceChannel:n,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){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,r,i,n,a,s,c,p)}),mt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:o,fee:r,options:i,label:n,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,o,n,r,i)}),dt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:o,fee:r,contractAddress:i,funds:n,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,o,r,a,n)}),ft=(e,t,o)=>l(void 0,null,function*(){if(!o)throw new Error("CosmWasm client is not ready");return yield o.queryContractSmart(e,t)}),gt=(e,t,o)=>{if(!o)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.queryContractRaw(e,r)};var cr=e=>e,lr=e=>e;var yt=e=>e?Object.keys(e).length===0:!0;var Me=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},St=e=>globalThis.DOMException===void 0?new Me(e):new DOMException(e),Ct=e=>{let t=e.reason===void 0?St("This operation was aborted."):e.reason;return t instanceof Error?t:St(t)};function xe(n,a){return l(this,arguments,function*(e,t,{concurrency:o=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((s,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 p=[],g=[],m=new Map,d=!1,A=!1,T=!1,v=0,P=0,C=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{d=!0,A=!0,c(b);};i&&(i.aborted&&f(Ct(i)),i.addEventListener("abort",()=>{f(Ct(i));}));let h=()=>l(this,null,function*(){if(A)return;let b=yield C.next(),k=P;if(P++,b.done){if(T=!0,v===0&&!A){if(!r&&g.length>0){f(new AggregateError(g));return}if(A=!0,m.size===0){s(p);return}let D=[];for(let[_,j]of p.entries())m.get(_)!==wt&&D.push(j);s(D);}return}v++,l(this,null,function*(){try{let D=yield b.value;if(A)return;let _=yield t(D,k);_===wt&&m.set(k,_),p[k]=_,v--,yield h();}catch(D){if(r)f(D);else {g.push(D),v--;try{yield h();}catch(_){f(_);}}}});});l(this,null,function*(){for(let b=0;b<o;b++){try{yield h();}catch(k){f(k);break}if(T||d)break}});})})}var wt=Symbol("skip");var z=({chainId:e,multiChain:t})=>{let o=u(i=>i.chains);if(!o)throw new Error("No chains found in GrazProvider");let r=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!r):return r.map(i=>o.find(n=>n.chainId===i)).filter(Boolean);case(!t&&!!r):return [r.map(i=>o.find(n=>n.chainId===i)).filter(Boolean)[0]];case(!!t&&!r):return o;default:return [o[0]]}},H=(e,t,o)=>l(void 0,null,function*(){let r=u.getState().multiChainFetchConcurrency;if(e){let n=yield xe(t,o,{concurrency:r});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield o(t[0])}),ht=(e,t,o)=>{if(e){let i=t.map(o);return Object.fromEntries(i.map((n,a)=>[t[a].chainId,n]))}return o(t[0])};var ve=e=>{let t=z({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:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),r,a=>l(void 0,null,function*(){var g;let s=(g=u.getState().chainsConfig)==null?void 0:g[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},We=e=>{let t=z({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:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),r,a=>l(void 0,null,function*(){var g;let s=(g=u.getState().chainsConfig)==null?void 0:g[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})};var Dr=()=>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"}))),Se=e=>{let o=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return reactQuery.useQuery({queryKey:o,queryFn:({queryKey:[,i]})=>U(i)})};var J=e=>{let t=u(s=>s.walletType),o=I(s=>s.activeChainIds),r=z({chainId:e!=null&&e.chainId?e.chainId:o||void 0,multiChain:e==null?void 0:e.multiChain}),i=I(s=>s.accounts),n=I(s=>s.status);return react.useEffect(()=>I.subscribe(s=>s.status,(s,c)=>{var p,g,m;if(s==="connected"){let{accounts:d,activeChainIds:A}=I.getState(),{chains:T}=u.getState(),{walletType:v}=u.getState();if(!d||!A||!T)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(g=e==null?void 0:e.onConnect)==null||g.call(e,{accounts:d,chains:A.map(P=>T.find(C=>C.chainId===P)),walletType:v,isReconnect:c==="reconnecting"});}s==="disconnected"&&((m=e==null?void 0:e.onDisconnect)==null||m.call(e));}),[e]),{data:react.useMemo(()=>i?ht(!!(e!=null&&e.multiChain),r,s=>i[s.chainId]):void 0,[i,r,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}},an=e=>{let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=J(),r=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),{data:i}=ve({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!r}),n=react.useMemo(()=>["USE_ALL_BALANCES",i,t,r,e==null?void 0:e.chainId],[r,e==null?void 0:e.chainId,t,i]);return reactQuery.useQuery({queryKey:n,queryFn:p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),s,m=>l(void 0,null,function*(){var T;let d=a==null?void 0:a[m.chainId];if(!d)throw new Error(`Client is not ready ${m.chainId}`);if(!((T=m.bech32Config)!=null&&T.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${m.chainId}`);return yield d.getAllBalances(encoding.toBech32(m.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!yt(i)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Vr=e=>{let t=z({chainId:e.chainId}),{data:o}=J({chainId:e.chainId}),r=e.bech32Address||(o==null?void 0:o.bech32Address),{data:i,refetch:n}=an({chainId:t.map(c=>c.chainId),bech32Address:r,enabled:!!r&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,i,t,r,e.chainId],s=reactQuery.useQuery({queryKey:a,queryFn:({queryKey:[,c,p]})=>p==null?void 0:p.find(g=>g.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?!0:e.enabled)});return F(M({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},Hr=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,o],mutationFn:te,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))}),{data:n}=Se();return {connect:a=>i.mutate(a),connectAsync:a=>i.mutateAsync(a),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!n,status:i.status}},Xr=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,o],mutationFn:Ee,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=>i.mutate(n),disconnectAsync:n=>i.mutateAsync(n),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},Yr=e=>{let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(i=>i.walletType),r=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,o],[t,o]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(void 0,[a],function*({queryKey:[,i,n]}){if(i.length<1)throw new Error("No chain found");if(!U(n))throw new Error(`${n} is not available`);return yield H(!!(e!=null&&e.multiChain),i,p=>l(void 0,null,function*(){return yield at({chainId:p.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!o,refetchOnWindowFocus:!1})},Jr=e=>{let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=J(),{data:r}=ve({chainId:t.map(a=>a.chainId),multiChain:!0}),i=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),n=react.useMemo(()=>["USE_BALANCE_STAKED",r,t,i],[t,i,r]);return reactQuery.useQuery({queryKey:n,queryFn:p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),s,m=>l(void 0,null,function*(){var A,T;if(!a)throw new Error("Client is not ready");if(!((A=m.bech32Config)!=null&&A.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${m.chainId}`);return yield (T=a[m.chainId])==null?void 0:T.getBalanceStaked(encoding.toBech32(m.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!r,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var ss=()=>I(e=>e.activeChainIds),cn=()=>{var e;return (e=I(t=>t.activeChainIds))==null?void 0:e.map(t=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===t);if(o)return o}).filter(Boolean)},as=({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))},ls=({denom:e})=>{let t=cn();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var n;return (n=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===i)))==null?void 0:n.currencies.find(a=>a)}})},us=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",o=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:o,queryFn:s=>l(void 0,[s],function*({queryKey:[,n,a]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(a)}),enabled:typeof e.queryClient!="undefined"})},ps=()=>({data:u(t=>t.recentChainIds),clear:Te}),ms=()=>{var t;return {data:(t=u(o=>o.recentChainIds))==null?void 0:t.map(o=>{var i;let r=(i=u.getState().chains)==null?void 0:i.find(n=>n.chainId===o);if(r)return r}).filter(Boolean),clear:Te}},ds=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,o],mutationFn:ke,onError:(n,a)=>Promise.resolve(e==null?void 0:e(n,a.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(o==null?void 0:o(n))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},fs=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],mutationFn:ct,onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(o==null?void 0:o(a))}),{data:n}=Se();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!n,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Is=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=J(),i=r==null?void 0:r.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,o,i],mutationFn:a=>ut(M({senderAddress:i},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},bs=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=J(),i=r==null?void 0:r.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,o,i],mutationFn:a=>pt(M({senderAddress:i},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Os=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:i}=J(),n=i==null?void 0:i.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,o,r,e,n],mutationFn:c=>{var g;if(!n)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:n,codeId:e});return mt(p)},onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:o,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Es=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:i}=J(),n=i==null?void 0:i.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,o,r,e,n],mutationFn:c=>{var g,m,d;if(!n)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:n,contractAddress:e,memo:(m=c.memo)!=null?m:"",funds:(d=c.funds)!=null?d:[]});return dt(p)},onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:o,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Ts=e=>{let{data:t}=We();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return ft(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ks=e=>{let{data:t}=We(),o=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:o,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return gt(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Bs(e){let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(n=>n.walletType),r=I(n=>n.activeChainIds),i=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,o,e,r],[r,e,t,o]);return reactQuery.useQuery({queryKey:i,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),n,p=>l(this,null,function*(){var v,P;if(!(r!=null&&r.includes(p.chainId)))return null;if(!U(a))throw new Error(`${a} is not available`);let m=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return N(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return N(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return N(a).getOfflineSignerOnlyAmino(p.chainId);default:return N(a).getOfflineSignerAuto(p.chainId)}}))(),d=(v=u.getState().chainsConfig)==null?void 0:v[p.chainId],A={url:p.rpc,headers:M({},(d==null?void 0:d.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(A,m,e!=null&&e.multiChain?(P=e.opts)==null?void 0:P[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!o&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ls(e){let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(n=>n.walletType),r=I(n=>n.activeChainIds),i=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,o,e,r],[r,e,t,o]);return reactQuery.useQuery({queryKey:i,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),n,p=>l(this,null,function*(){var P,C;if(!(r!=null&&r.includes(p.chainId)))return null;if(!U(a))throw new Error(`${a} is not available`);let m=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return N(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return N(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return N(a).getOfflineSignerOnlyAmino(p.chainId);default:return N(a).getOfflineSignerAuto(p.chainId)}}))(),d=(P=u.getState().chainsConfig)==null?void 0:P[p.chainId],A={url:p.rpc,headers:M({},(d==null?void 0:d.rpcHeaders)||{})},T=d!=null&&d.gas?stargate.GasPrice.fromString(`${d.gas.price}${d.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(A,m,M({gasPrice:T},e!=null&&e.multiChain?(C=e.opts)==null?void 0:C[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!o&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Wt=({children:e})=>{let[t,o]=react.useState(!1);return react.useEffect(()=>{o(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var Sn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(ee)==="Active",{_reconnect:t,_onReconnectFailed:o,_reconnectConnector:r,iframeOptions:i,chains:n}=u(),{activeChainIds:a,wcSignClients:s}=I(),c=U(r||void 0);return react.useEffect(()=>{if(!i||i.autoConnect===!1||!i.allowedIframeParentOrigins.length||!n)return;new cosmiframe.Cosmiframe(i.allowedIframeParentOrigins).isReady().then(g=>{if(g)return te({chainId:n.map(m=>m.chainId),walletType:"cosmiframe"})});},[i]),react.useEffect(()=>{if(r){if(!c)return;e&&a?B({onError:o}):!e&&t&&B({onError:o});}},[c]),react.useEffect(()=>{var p,g,m,d,A,T,v,P,C,f,h,b,k,D,_,j,oe,y,S,w;if(r){if(!c)return;r==="cosmostation"&&((g=(p=le()).subscription)==null||g.call(p,()=>{B({onError:o});})),r==="keplr"&&((d=(m=ue()).subscription)==null||d.call(m,()=>{B({onError:o});})),r==="leap"&&((T=(A=pe()).subscription)==null||T.call(A,()=>{B({onError:o});})),r==="compass"&&((P=(v=ae()).subscription)==null||P.call(v,()=>{B({onError:o});})),r==="vectis"&&((f=(C=ge()).subscription)==null||f.call(C,()=>{B({onError:o});})),r==="walletconnect"&&s.has("walletconnect")&&((b=(h=G()).subscription)==null||b.call(h,()=>{B({onError:o});})),r==="station"&&((D=(k=fe()).subscription)==null||D.call(k,()=>{B({onError:o});})),r==="xdefi"&&((j=(_=ye()).subscription)==null||j.call(_,()=>{B({onError:o});})),r==="cosmiframe"&&((y=(oe=ce()).subscription)==null||y.call(oe,()=>{B({onError:o});})),r==="okx"&&((w=(S=de()).subscription)==null||w.call(S,()=>{B({onError:o});}));}},[r,s,c]),null},Pt=()=>(Sn(),null);var ga=({children:e,grazOptions:t})=>(react.useEffect(()=>{lt(t);},[t]),jsxRuntime.jsxs(Wt,{children:[e,jsxRuntime.jsx(Pt,{})]}));
|
|
26
25
|
|
|
27
|
-
exports.GrazEvents =
|
|
28
|
-
exports.GrazProvider =
|
|
29
|
-
exports.WALLET_TYPES =
|
|
30
|
-
exports.WalletType =
|
|
31
|
-
exports.checkWallet =
|
|
32
|
-
exports.clearRecentChain =
|
|
33
|
-
exports.clearSession =
|
|
34
|
-
exports.configureGraz =
|
|
35
|
-
exports.connect =
|
|
36
|
-
exports.defineChainInfo =
|
|
37
|
-
exports.defineChains =
|
|
38
|
-
exports.disconnect =
|
|
39
|
-
exports.executeContract =
|
|
40
|
-
exports.getAvailableWallets =
|
|
41
|
-
exports.getChainInfo =
|
|
42
|
-
exports.getChainInfos =
|
|
43
|
-
exports.getCosmostation =
|
|
44
|
-
exports.getKeplr =
|
|
45
|
-
exports.getLeap =
|
|
46
|
-
exports.getMetamaskSnapLeap =
|
|
47
|
-
exports.getOfflineSigners =
|
|
48
|
-
exports.getQueryRaw =
|
|
49
|
-
exports.getQuerySmart =
|
|
50
|
-
exports.getRecentChainIds =
|
|
51
|
-
exports.getRecentChains =
|
|
52
|
-
exports.getVectis =
|
|
53
|
-
exports.getWCCosmostation =
|
|
54
|
-
exports.getWCKeplr =
|
|
55
|
-
exports.getWCLeap =
|
|
56
|
-
exports.getWallet =
|
|
57
|
-
exports.getWalletConnect =
|
|
58
|
-
exports.instantiateContract =
|
|
59
|
-
exports.
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
65
|
-
exports.
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
72
|
-
exports.
|
|
73
|
-
exports.
|
|
74
|
-
exports.
|
|
75
|
-
exports.
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
78
|
-
exports.
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
81
|
-
exports.
|
|
82
|
-
exports.
|
|
83
|
-
exports.
|
|
84
|
-
exports.
|
|
85
|
-
exports.
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
94
|
-
exports.
|
|
95
|
-
exports.
|
|
96
|
-
exports.
|
|
97
|
-
exports.useStargateSigningClient = da;
|
|
98
|
-
exports.useStargateTmSigningClient = ga;
|
|
99
|
-
exports.useSuggestChain = Us;
|
|
100
|
-
exports.useSuggestChainAndConnect = Fs;
|
|
101
|
-
exports.useTendermintClient = he;
|
|
26
|
+
exports.GrazEvents = Pt;
|
|
27
|
+
exports.GrazProvider = ga;
|
|
28
|
+
exports.WALLET_TYPES = Ue;
|
|
29
|
+
exports.WalletType = Le;
|
|
30
|
+
exports.checkWallet = U;
|
|
31
|
+
exports.clearRecentChain = Te;
|
|
32
|
+
exports.clearSession = K;
|
|
33
|
+
exports.configureGraz = lt;
|
|
34
|
+
exports.connect = te;
|
|
35
|
+
exports.defineChainInfo = lr;
|
|
36
|
+
exports.defineChains = cr;
|
|
37
|
+
exports.disconnect = Ee;
|
|
38
|
+
exports.executeContract = dt;
|
|
39
|
+
exports.getAvailableWallets = Ni;
|
|
40
|
+
exports.getChainInfo = Yi;
|
|
41
|
+
exports.getChainInfos = Ji;
|
|
42
|
+
exports.getCosmostation = le;
|
|
43
|
+
exports.getKeplr = ue;
|
|
44
|
+
exports.getLeap = pe;
|
|
45
|
+
exports.getMetamaskSnapLeap = Je;
|
|
46
|
+
exports.getOfflineSigners = at;
|
|
47
|
+
exports.getQueryRaw = gt;
|
|
48
|
+
exports.getQuerySmart = ft;
|
|
49
|
+
exports.getRecentChainIds = Hi;
|
|
50
|
+
exports.getRecentChains = Xi;
|
|
51
|
+
exports.getVectis = ge;
|
|
52
|
+
exports.getWCCosmostation = nt;
|
|
53
|
+
exports.getWCKeplr = ot;
|
|
54
|
+
exports.getWCLeap = it;
|
|
55
|
+
exports.getWallet = N;
|
|
56
|
+
exports.getWalletConnect = G;
|
|
57
|
+
exports.instantiateContract = mt;
|
|
58
|
+
exports.isLeapDappBrowser = st;
|
|
59
|
+
exports.isLeapSnaps = rt;
|
|
60
|
+
exports.isWalletConnect = ie;
|
|
61
|
+
exports.reconnect = B;
|
|
62
|
+
exports.sendIbcTokens = pt;
|
|
63
|
+
exports.sendTokens = ut;
|
|
64
|
+
exports.suggestChain = ke;
|
|
65
|
+
exports.suggestChainAndConnect = ct;
|
|
66
|
+
exports.useAccount = J;
|
|
67
|
+
exports.useActiveChainCurrency = ls;
|
|
68
|
+
exports.useActiveChainIds = ss;
|
|
69
|
+
exports.useActiveChains = cn;
|
|
70
|
+
exports.useActiveWalletType = Dr;
|
|
71
|
+
exports.useBalance = Vr;
|
|
72
|
+
exports.useBalanceStaked = Jr;
|
|
73
|
+
exports.useBalances = an;
|
|
74
|
+
exports.useChainInfo = as;
|
|
75
|
+
exports.useChainInfos = cs;
|
|
76
|
+
exports.useCheckWallet = Se;
|
|
77
|
+
exports.useConnect = Hr;
|
|
78
|
+
exports.useCosmWasmClient = We;
|
|
79
|
+
exports.useCosmWasmSigningClient = Ls;
|
|
80
|
+
exports.useDisconnect = Xr;
|
|
81
|
+
exports.useExecuteContract = Es;
|
|
82
|
+
exports.useGrazEvents = Sn;
|
|
83
|
+
exports.useInstantiateContract = Os;
|
|
84
|
+
exports.useOfflineSigners = Yr;
|
|
85
|
+
exports.useQueryClientValidators = us;
|
|
86
|
+
exports.useQueryRaw = ks;
|
|
87
|
+
exports.useQuerySmart = Ts;
|
|
88
|
+
exports.useRecentChainIds = ps;
|
|
89
|
+
exports.useRecentChains = ms;
|
|
90
|
+
exports.useSendIbcTokens = bs;
|
|
91
|
+
exports.useSendTokens = Is;
|
|
92
|
+
exports.useStargateClient = ve;
|
|
93
|
+
exports.useStargateSigningClient = Bs;
|
|
94
|
+
exports.useSuggestChain = ds;
|
|
95
|
+
exports.useSuggestChainAndConnect = fs;
|