graz 0.2.6 → 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.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middleware';
|
|
3
|
-
import { encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType, rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino';
|
|
4
|
-
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
5
3
|
import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
|
|
6
4
|
import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
|
|
7
|
-
import
|
|
5
|
+
import { rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress, encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType } from '@cosmjs/amino';
|
|
6
|
+
import Oe from 'long';
|
|
7
|
+
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
8
8
|
import { SignClient } from '@walletconnect/sign-client';
|
|
9
9
|
import { getSdkError } from '@walletconnect/utils';
|
|
10
10
|
import { WalletConnectModal } from '@walletconnect/modal';
|
|
@@ -12,10 +12,9 @@ import { useQuery, useMutation } from '@tanstack/react-query';
|
|
|
12
12
|
import { useMemo, useEffect, useState } from 'react';
|
|
13
13
|
import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
14
14
|
import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargate';
|
|
15
|
-
import {
|
|
16
|
-
import { shallow } from 'zustand/shallow';
|
|
15
|
+
import { useShallow } from 'zustand/shallow';
|
|
17
16
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
18
17
|
|
|
19
|
-
var Ft=Object.defineProperty,qt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var ze=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Qe=(e,t,i)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t)=>{for(var i in t||(t={}))zt.call(t,i)&&Qe(e,i,t[i]);if(ze)for(var i of ze(t))Qt.call(t,i)&&Qe(e,i,t[i]);return e},$=(e,t)=>qt(e,Gt(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());}),je=(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 J="graz-reconnect-session";var $e=(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))($e||{}),Ve=["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 $t={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},ie={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Vt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Ht={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=create(subscribeWithSelector(persist(()=>ie,Vt))),p=create(subscribeWithSelector(persist(()=>$t,Ht)));var le=()=>{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 C=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,A=new C({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:C=>l(void 0,null,function*(){let A=typeof C=="string"?[C]:C,T=g.getState().capsuleClient;T||(T=yield e()),p.setState({capsuleState:{showModal:!0,chainId:A}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var u;let C=g.getState().capsuleClient,{chains:A}=p.getState();if(!C)throw new Error("Capsule client is not initialized");if(!A)throw new Error("Chains are not set");yield C.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 S=yield C.getAccount(y);return [y,{address:fromBech32(S.address).data,bech32Address:S.address,algo:S.algo,name:S.username||"",pubKey:S.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(y=>({accounts:P(P({},y.accounts||{}),O)})),p.setState(y=>({recentChainIds:[...y.recentChainIds||[],...T].filter((S,k,R)=>R.indexOf(S)===k)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...T].filter((S,k,R)=>R.indexOf(S)===k)})),p.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active"),p.setState({capsuleState:null});}),getKey:C=>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(C);return {address:fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:C=>l(void 0,null,function*(){let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSignerDirect(C)}),getOfflineSignerDirect:C=>{let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSignerDirect(C)},signDirect:(...C)=>l(void 0,null,function*(){let[A,T,O]=C,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:(...C)=>l(void 0,null,function*(){let[A,T,O,u]=C,y=g.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signAmino(A,T,O,u)}),signArbitrary:(C,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(C);if(!u)throw new Error(`Wallet not connected to account ${A}`);let y=(()=>{switch(u.algo){case"secp256k1":return encodeSecp256k1Pubkey(u.pubkey);case"ed25519":return encodeEd25519Pubkey(u.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(C,A,T),pub_key:{type:u.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:y.value}}}),experimentalSuggestChain:(...C)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:C=>{let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSigner(C)},getOfflineSignerAmino:C=>{let A=g.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.getOfflineSignerAmino(C)}}};var ue=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:o=>{let n=()=>{B(),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 pe=()=>{let e=p.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var nt={},it=()=>{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 isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:n=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain($(P({},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 nt[n]!="undefined"?nt[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 me=()=>{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=()=>{B(),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 sn=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}},an=e=>`${e.slice(0,6)}...${e.slice(-6)}`,rt=()=>{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 C=(()=>{switch(E.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(E.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(E.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:an(E.address),algo:E.algo,pubKey:E.pubkey,bech32Address:E.address,address:C,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,C,A;return {denom:f.coinDenom,amount:f.coinMinimalDenom,low_gas_price:(E=f.gasPriceStep)==null?void 0:E.low,average_gas_price:(C=f.gasPriceStep)==null?void 0:C.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,C]=d;return e.getOfflineSigner(f).signDirect(E,sn(C))},signAmino:(...d)=>{let[f,E,C]=d;return e.getOfflineSignerOnlyAmino(f).signAmino(E,C)},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 encodeSecp256k1Pubkey(T.pubkey);case"ed25519":return 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"?pubkeyType.secp256k1:pubkeyType.ed25519,value:O.value}}}),subscription:d=>{let f=()=>{B(),d();};return window.addEventListener("initia_keystorechange",f),()=>{window.removeEventListener("initia_keystorechange",f);}}}}throw p.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:o=>{let n=()=>{B(),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 fe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:o=>{let n=()=>{B(),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 ge={},st=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(S=>S.id===e.id&&(!u||S.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 N;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 S=(N=u.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(S)>=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,S)=>l(void 0,null,function*(){let k=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:u,signerAddress:y,signDoc:S}}}}),R=S.accountNumber,N=new ut(R.low,R.high,R.unsigned);return {signature:k.signature,signed:$(P({},k.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(k.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(k.signed.bodyBytes))})}}),c=(u,y,S)=>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:S}}}})}),m=u=>l(void 0,null,function*(){if(typeof ge[u]!="undefined")return ge[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,ge[u]=y,ge[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,S,k,R]=u;return yield c(y,S,k)}),f=(...u)=>l(void 0,null,function*(){let[y,S,k]=u;return yield s(y,S,k)}),C=u=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(u)]}),signAmino:(y,S)=>d(u,y,S)});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,S)=>f(u,y,S),signAmino:(y,S)=>d(u,y,S)}),getOfflineSignerAuto:u=>l(void 0,null,function*(){return C(u)}),getOfflineSignerOnlyAmino:C,init:n,signAmino:d,signDirect:f}}throw p.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var at=()=>st({id:"npm:@leapwallet/metamask-cosmos-snap"});var ye=()=>{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=()=>{B(),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 Ce=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{B(),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 P({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 Se=()=>{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: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=()=>{B(),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:ut.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 z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},ct=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),lt=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ve=(e,t,i=new Error("Promise timed out"))=>{let r=new Promise((o,n)=>{setTimeout(()=>{n(i);},t);});return Promise.race([e,r])};var Q=e=>{var N,te,oe;if(!((oe=(te=(N=p.getState().walletConnect)==null?void 0:N.options)==null?void 0:te.projectId)!=null&&oe.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(z()){if(ct()){let v=b(I.mobile.android,w,"android");window.open(v,"_self","noreferrer noopener");}if(lt()){let v=b(I.mobile.ios,w,"ios");window.open(v,"_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: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 v=b.session.getAll(),D=v.at(-1);if(!D)return;if(!(D.expiry*1e3>Date.now()+1e3))throw n(D.topic),new Error("invalid session");try{let _=v.find(j=>{var X,Y;return (Y=(X=j.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${w}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return D}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 v=yield SignClient.init(w.options);return I.set(t,v),g.setState({wcSignClients:I}),v}),h=w=>{let{wcSignClients:I}=g.getState(),b=I.get(t);if(!b)return ()=>{};let v=D=>{let W=g.getState().accounts;if(D.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(_=>_.bech32Address).includes(D.params.event.data[0])){let _=D.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",v),()=>{b.events.off("session_delete",o),b.events.off("session_expire",o),b.events.off("session_event",v);}},d=w=>l(void 0,null,function*(){var Y;let I=typeof w=="string"?[w]:w,{wcSignClients:b,activeChainIds:v}=g.getState(),D=b.get(t);if(!D)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:_}=p.getState();if(!((Y=W==null?void 0:W.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new WalletConnectModal(P({projectId:W.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.walletConnectModal)),X=s(I);if(!X){let{uri:q,approval:ae}=yield ve(D.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:I.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!q)throw new Error("No wallet connect uri");e?r(q):yield j.openModal({uri:q});let ce=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Me,ne)=>{ae().then(Fe=>{let qe=Fe.sessionProperties;if(!qe)return ne(new Error("No session properties"));let ke=JSON.parse(String(qe.keys));if(ke.length===0)return ne(new Error("No accounts"));if(!ke[0])return ne(new Error("No accounts"));let Ge={};return ke.forEach(H=>{Ge[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),g.setState(H=>({accounts:P(P({},H.accounts||{}),Ge)})),Me(Fe)}).catch(ne),V.addEventListener("abort",()=>{ne(new Error("User closed wallet connect"));},{once:!0});})});try{let V=new AbortController,Me=V.signal;j.subscribeModal(ne=>{ne.open||V.abort();}),yield ce(Me);}catch(V){if(j.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||j.closeModal(),Promise.resolve()}try{yield ve((()=>l(void 0,null,function*(){var ae;let q=Object.fromEntries(yield Promise.all((ae=v||I)==null?void 0:ae.map(ce=>l(void 0,null,function*(){return [ce,yield E(ce)]}))));g.setState({accounts:q});}))(),15e3,new Error("Connection timeout"));}catch(q){if(n(X.topic),!q.message.toLowerCase().includes("no matching key"))throw q}}),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 v=b.find(D=>D.chainId===w);if(!v)throw new Error(`No wallet connect key for chainId ${w}`);return $(P({},v),{pubKey:Buffer.from(String(v.pubKey),i)})}),C=(...w)=>l(void 0,null,function*(){var Y,q;let[I,b,v]=w,{accounts:D,wcSignClients:W}=g.getState(),_=W.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!D)throw new Error("account is not defined");let j=(Y=a([I]))==null?void 0:Y.topic;if(!j)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");return r(),yield _.request({topic:j,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:{chainId:v.chainId,accountNumber:(q=v.accountNumber)==null?void 0:q.toString(),bodyBytes:v.bodyBytes?Buffer.from(v.bodyBytes).toString(i):null,authInfoBytes:v.authInfoBytes?Buffer.from(v.authInfoBytes).toString(i):null}}}})}),A=(...w)=>l(void 0,null,function*(){var _;let[I,b,v]=w,{signature:D,signed:W}=yield C(I,b,v);return {signed:{chainId:(_=W.chainId)!=null?_:"",accountNumber:W.accountNumber?ut.fromString(W.accountNumber):new ut(0),authInfoBytes:W.authInfoBytes?new Uint8Array(Buffer.from(W.authInfoBytes,i)):new Uint8Array([]),bodyBytes:W.bodyBytes?new Uint8Array(Buffer.from(W.bodyBytes,i)):new Uint8Array([])},signature:D}}),T=(...w)=>l(void 0,null,function*(){var q;let[I,b,v,D]=w,{wcSignClients:W}=g.getState(),_=W.get(t),{accounts:j}=g.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let X=(q=a([I]))==null?void 0:q.topic;if(!X)throw new Error("No wallet connect session");return r(),yield _.request({topic:X,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:v}}})}),O=(...w)=>l(void 0,null,function*(){let[I,b,v,D]=w;return yield T(I,b,v)}),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 v;let{wcSignClients:I}=g.getState(),b=I.get(t);if(w===void 0){let D=b==null?void 0:b.session.getAll();D!==void 0&&(yield Promise.all(D.map(W=>n(W.topic))));}else typeof w=="string"?yield n((v=a([w]))==null?void 0:v.topic):yield Promise.all(w.map(D=>{var W;return n((W=a([D]))==null?void 0:W.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 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(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(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 Q(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(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(o,n,a)=>{let s=o.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return Q(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(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(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 Q(e)};var ft=()=>{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(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(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 Q(e)};var he=()=>{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=()=>{B(),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 L=(e=p.getState().walletType)=>{try{return K(e),!0}catch(t){return !1}},B=()=>{window.sessionStorage.removeItem(J),g.setState(ie);},K=(e=p.getState().walletType)=>{var r;let t=(()=>{switch(e){case"keplr":return de();case"leap":return fe();case"cosmostation":return me();case"vectis":return Se();case"walletconnect":return Q();case"wc_keplr_mobile":return dt();case"wc_leap_mobile":return ft();case"wc_cosmostation_mobile":return mt();case"wc_clot_mobile":return pt();case"metamask_snap_leap":return at();case"metamask_snap_cosmos":return it();case"station":return Ce();case"xdefi":return he();case"capsule":return le();case"cosmiframe":return pe();case"compass":return ue();case"initia":return rt();case"okx":return ye();default:throw new Error("Unknown wallet type")}})(),i=p.getState().walletDefaultOptions;return i&&((r=t.setDefaultOptions)==null||r.call(t,i)),t},or=()=>Object.fromEntries(Ve.map(e=>[e,L(e)])),Pe=e=>e==="capsule",gt=e=>e==="metamask_snap_leap",yt=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),re=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Z=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(re(m)){let O=K("walletconnect"),{disable:u}=O;u&&u();}if(!L(m))throw new Error(`${m} is not available`);let d=K(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(S=>{var k;return !((k=O.activeChainIds)!=null&&k.includes(S))}).length>0?{status:"connecting"}:u?{status:"reconnecting"}:{status:"connecting"}});let{accounts:C}=g.getState();if(yield (t=d.init)==null?void 0:t.call(d),Pe(m)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let O=f.map(S=>s.find(k=>k.chainId===S)),u=g.getState().accounts;g.setState({status:"connecting"});let y=Object.fromEntries(yield Promise.all(f.map(S=>l(void 0,null,function*(){return [S,yield d.getKey(S)]}))));return g.setState(S=>({accounts:P(P({},S.accounts||{}),y)})),p.setState(S=>({recentChainIds:[...S.recentChainIds||[],...f].filter((k,R,N)=>N.indexOf(k)===R)})),g.setState(S=>({activeChainIds:[...S.activeChainIds||[],...f].filter((k,R,N)=>N.indexOf(k)===R)})),g.setState({status:"connected"}),{accounts:u,walletType:m,chains:O}}if(yield d.enable(f),Pe(m)){let O=f.map(y=>s.find(S=>S.chainId===y)),u=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:u,walletType:m,chains:O}}if(!re(m)){let O={};if(gt(m)){let u={};try{for(var i=je(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(yt()&&d.getKeys){let u=yield d.getKeys(f);f.forEach((y,S)=>{let k=u[S];k&&(O[y]=k);});}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:P(P({},u.accounts||{}),O)}));}p.setState(O=>({recentChainIds:[...O.recentChainIds||[],...f].filter((u,y,S)=>S.indexOf(u)===y)})),g.setState(O=>({activeChainIds:[...O.activeChainIds||[],...f].filter((u,y,S)=>S.indexOf(u)===y)})),p.setState({walletType:m,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:m}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"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}}),se=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(J);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(re(p.getState().walletType)){let i=K("walletconnect"),{disable:r}=i;r&&r();}if(t){let i=g.getState().accounts;t.forEach(o=>{i==null||delete i[o];}),Object.values(i||{}).length===0?(g.setState(ie),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(ie),p.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},U=e=>l(void 0,null,function*(){var o;let{recentChainIds:t,_reconnectConnector:i,_reconnect:r}=p.getState();try{let n=L(i||void 0);if(t&&n&&i)return re(i)?void 0:yield Z({chainId:t,walletType:i,autoReconnect:r})}catch(n){(o=e==null?void 0:e.onError)==null||o.call(e,n),se();}}),Ct=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(!L(i))throw new Error(`${i} is not available`);let o=K(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 We=()=>{p.setState({recentChainIds:null});},yr=()=>p.getState().recentChainIds,Cr=()=>{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)},hr=({chainId:e})=>{var t;return (t=p.getState().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Re=i=>l(void 0,[i],function*({chainInfo:e,walletType:t}){let r=K(t);return t==="capsule"?yield Z({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 Re({chainInfo:e.chainInfo,walletType:(r=e.walletType)!=null?r:t}),yield Z({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ht=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 wt=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)}),At=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)}),It=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)}),Et=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)}),Ot=(e,t,i)=>l(void 0,null,function*(){if(!i)throw new Error("CosmWasm client is not ready");return yield i.queryContractSmart(e,t)}),bt=(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 kr=e=>e,vr=e=>e;var we=e=>e?Object.keys(e).length===0:!0;var Ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Tt=e=>globalThis.DOMException===void 0?new Ke(e):new DOMException(e),xt=e=>{let t=e.reason===void 0?Tt("This operation was aborted."):e.reason;return t instanceof Error?t:Tt(t)};function De(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,C=!1,A=0,T=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),u=S=>{f=!0,E=!0,c(S);};o&&(o.aborted&&u(xt(o)),o.addEventListener("abort",()=>{u(xt(o));}));let y=()=>l(this,null,function*(){if(E)return;let S=yield O.next(),k=T;if(T++,S.done){if(C=!0,A===0&&!E){if(!r&&h.length>0){u(new AggregateError(h));return}if(E=!0,d.size===0){s(m);return}let R=[];for(let[N,te]of m.entries())d.get(N)!==Mt&&R.push(te);s(R);}return}A++,l(this,null,function*(){try{let R=yield S.value;if(E)return;let N=yield t(R,k);N===Mt&&d.set(k,N),m[k]=N,A--,yield y();}catch(R){if(r)u(R);else {h.push(R),A--;try{yield y();}catch(N){u(N);}}}});});l(this,null,function*(){for(let S=0;S<i;S++){try{yield y();}catch(k){u(k);break}if(C||f)break}});})})}var Mt=Symbol("skip");var F=({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]]}},G=(e,t,i)=>l(void 0,null,function*(){let r=p.getState().multiChainFetchConcurrency;if(e){let n=yield De(t,i,{concurrency:r});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield i(t[0])}),kt=(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 Be=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:i,queryFn:o=>l(void 0,[o],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield G(!!(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:P({},(s==null?void 0:s.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Le=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:i,queryFn:o=>l(void 0,[o],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield G(!!(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:P({},(s==null?void 0:s.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ae=({type:e,chainId:t,multiChain:i,enabled:r})=>{let o=F({chainId:t,multiChain:i}),n=useMemo(()=>["USE_TENDERMINT_CLIENT",e,o],[e,o]);return 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 G(!!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:P({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(f)}))}),enabled:!!o&&o.length>0&&(r!==void 0?!!r:!0),refetchOnWindowFocus:!1})};var is=()=>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),Ie=e=>{let i=["USE_CHECK_WALLET",p(o=>e||o.walletType)];return useQuery({queryKey:i,queryFn:({queryKey:[,o]})=>L(o)})};var ee=e=>{let t=p(s=>s.walletType),i=g(s=>s.activeChainIds),r=F({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 useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var m,h,d;if(s==="connected"){let{accounts:f,activeChainIds:E}=g.getState(),{chains:C}=p.getState(),{walletType:A}=p.getState();if(!f||!E||!C)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=>C.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:useMemo(()=>o?kt(!!(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:U,status:n}},An=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),r=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),{data:o}=Be({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!r}),n=useMemo(()=>["USE_ALL_BALANCES",o,t,r,e==null?void 0:e.chainId],[r,e==null?void 0:e.chainId,t,o]);return 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 G(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var C;let f=a==null?void 0:a[d.chainId];if(!f)throw new Error(`Client is not ready ${d.chainId}`);if(!((C=d.bech32Config)!=null&&C.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield f.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!we(o)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ys=e=>{let t=F({chainId:e.chainId}),{data:i}=ee({chainId:e.chainId}),r=e.bech32Address||(i==null?void 0:i.bech32Address),{data:o,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,o,t,r,e.chainId],s=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 $(P({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},Cs=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=useMutation({mutationKey:["USE_CONNECT",e,t,i],mutationFn:Z,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=Ie();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=useMutation({mutationKey:["USE_DISCONNECT",e,t,i],mutationFn:se,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}},hs=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=p(o=>o.walletType),r=useMemo(()=>["USE_OFFLINE_SIGNERS",t,i],[t,i]);return useQuery({queryKey:r,queryFn:a=>l(void 0,[a],function*({queryKey:[,o,n]}){if(o.length<1)throw new Error("No chain found");if(!L(n))throw new Error(`${n} is not available`);return yield G(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield Ct({chainId:m.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!i,refetchOnWindowFocus:!1})},ws=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),{data:r}=Be({chainId:t.map(a=>a.chainId),multiChain:!0}),o=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),n=useMemo(()=>["USE_BALANCE_STAKED",r,t,o],[t,o,r]);return 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 G(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var E,C;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 (C=a[d.chainId])==null?void 0:C.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!o&&!!t&&t.length>0&&!!r,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var xs=()=>{let e=p(r=>r.capsuleState),t=g(r=>r.capsuleClient),i=le();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:()=>{se();}}};var Ks=()=>g(e=>e.activeChainIds),In=()=>{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)},Ds=({chainId:e})=>{var t;return (t=p().chains)==null?void 0:t.find(i=>i.chainId===e)},Ns=({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=In();return 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)}})},Bs=e=>{var o;let t=(o=e.status)!=null?o:"BOND_STATUS_BONDED",i=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return 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"})},Ls=()=>({data:p(t=>t.recentChainIds),clear:We}),Us=()=>{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:We}},Fs=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,i],mutationFn:Re,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}},qs=({onError:e,onLoading:t,onSuccess:i}={})=>{let o=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}=Ie();return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,isSupported:!!n,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var Xs=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:r}=ee(),o=r==null?void 0:r.bech32Address,n=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,i,o],mutationFn:a=>wt(P({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}},Ys=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:r}=ee(),o=r==null?void 0:r.bech32Address,n=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,i,o],mutationFn:a=>At(P({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}},Js=({codeId:e,onError:t,onLoading:i,onSuccess:r})=>{let{data:o}=ee(),n=o==null?void 0:o.bech32Address,s=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,i,r,e,n],mutationFn:c=>{var h;if(!n)throw new Error("senderAddress is undefined");let m=$(P({},c),{fee:(h=c.fee)!=null?h:"auto",senderAddress:n,codeId:e});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,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Zs=({contractAddress:e,onError:t,onLoading:i,onSuccess:r})=>{let{data:o}=ee(),n=o==null?void 0:o.bech32Address,s=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=$(P({},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 Et(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}},ea=e=>{let{data:t}=Le();return 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 Ot(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ta=e=>{let{data:t}=Le(),i=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:i,queryFn:({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return bt(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function fa(e){let t=F({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=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]);return useQuery({queryKey:o,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),n,m=>l(this,null,function*(){var A,T;if(!(r!=null&&r.includes(m.chainId)))return null;if(!L(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 K(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return K(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return K(a).getOfflineSignerOnlyAmino(m.chainId);default:return K(a).getOfflineSignerAuto(m.chainId)}}))(),f=(A=p.getState().chainsConfig)==null?void 0:A[m.chainId],E={url:m.rpc,headers:P({},(f==null?void 0:f.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield 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 ga(e){let t=F({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=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]);return useQuery({queryKey:o,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),n,m=>l(this,null,function*(){var T,O;if(!(r!=null&&r.includes(m.chainId)))return null;if(!L(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 K(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return K(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return K(a).getOfflineSignerOnlyAmino(m.chainId);default:return K(a).getOfflineSignerAuto(m.chainId)}}))(),f=(T=p.getState().chainsConfig)==null?void 0:T[m.chainId],E={url:m.rpc,headers:P({},(f==null?void 0:f.rpcHeaders)||{})},C=f!=null&&f.gas?GasPrice.fromString(`${f.gas.price}${f.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(E,d,P({gasPrice:C},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 ya(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),i=p(a=>a.walletType),r=g(a=>a.activeChainIds),o=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]),{data:n}=Ae({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,h=>l(this,null,function*(){var A;if(!(r!=null&&r.includes(h.chainId)))return null;if(!L(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 K(s).getOfflineSigner(h.chainId);case"offlineSignerAuto":return K(s).getOfflineSignerAuto(h.chainId);case"offlineSignerOnlyAmino":return K(s).getOfflineSignerOnlyAmino(h.chainId);default:return K(s).getOfflineSignerAuto(h.chainId)}}))(),E=e.multiChain?n[h.chainId]:n;return yield 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 Ca(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),i=p(s=>s.walletType),r=g(s=>s.activeChainIds),o=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,i,e,r],[r,e,t,i]),{data:n}=Ae({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=Ae({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:o,queryFn:m=>l(this,[m],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,d=>l(this,null,function*(){var u,y;if(!(r!=null&&r.includes(d.chainId)))return null;if(!L(c))throw new Error(`${c} is not available`);let E=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return K(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return K(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return K(c).getOfflineSignerOnlyAmino(d.chainId);default:return K(c).getOfflineSignerAuto(d.chainId)}}))(),C=(u=p.getState().chainsConfig)==null?void 0:u[d.chainId],A=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.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 SigningCosmWasmClient.createWithSigner(T,E,P({gasPrice:A},e.multiChain?(y=e.opts)==null?void 0:y[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!i&&(!!n||!we(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Lt=({children:e})=>{let[t,i]=useState(!1);return useEffect(()=>{i(!0);},[]),jsx(Fragment,{children:t?e:null})};var Mn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(J)==="Active",{_reconnect:t,_onReconnectFailed:i,_reconnectConnector:r,iframeOptions:o,chains:n}=p(),{activeChainIds:a,wcSignClients:s}=g(),c=L(r||void 0);return useEffect(()=>{if(!o||o.autoConnect===!1||!o.allowedIframeParentOrigins.length||!n)return;new Cosmiframe(o.allowedIframeParentOrigins).isReady().then(h=>{if(h)return Z({chainId:n.map(d=>d.chainId),walletType:"cosmiframe"})});},[o]),useEffect(()=>{if(r){if(!c)return;e&&a?U({onError:i}):!e&&t&&U({onError:i});}},[c]),useEffect(()=>{var m,h,d,f,E,C,A,T,O,u,y,S,k,R,N,te,oe,w,I,b;if(r){if(!c)return;r==="cosmostation"&&((h=(m=me()).subscription)==null||h.call(m,()=>{U({onError:i});})),r==="keplr"&&((f=(d=de()).subscription)==null||f.call(d,()=>{U({onError:i});})),r==="leap"&&((C=(E=fe()).subscription)==null||C.call(E,()=>{U({onError:i});})),r==="compass"&&((T=(A=ue()).subscription)==null||T.call(A,()=>{U({onError:i});})),r==="vectis"&&((u=(O=Se()).subscription)==null||u.call(O,()=>{U({onError:i});})),r==="walletconnect"&&s.has("walletconnect")&&((S=(y=Q()).subscription)==null||S.call(y,()=>{U({onError:i});})),r==="station"&&((R=(k=Ce()).subscription)==null||R.call(k,()=>{U({onError:i});})),r==="xdefi"&&((te=(N=he()).subscription)==null||te.call(N,()=>{U({onError:i});})),r==="cosmiframe"&&((w=(oe=pe()).subscription)==null||w.call(oe,()=>{U({onError:i});})),r==="okx"&&((b=(I=ye()).subscription)==null||b.call(I,()=>{U({onError:i});}));}},[r,s,c]),null},Ut=()=>(Mn(),null);var $a=({children:e,grazOptions:t})=>(useEffect(()=>{ht(t);},[t]),jsxs(Lt,{children:[e,jsx(Ut,{})]}));
|
|
18
|
+
var Rt=Object.defineProperty,Dt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var Be=(e,t,o)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,x=(e,t)=>{for(var o in t||(t={}))Nt.call(t,o)&&Be(e,o,t[o]);if(Ne)for(var o of Ne(t))Bt.call(t,o)&&Be(e,o,t[o]);return e},q=(e,t)=>Dt(e,Kt(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());}),Le=(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 te="graz-reconnect-session";var Ue=(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))(Ue||{}),Fe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Ut={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},oe={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map},Ft={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},I=create(subscribeWithSelector(persist(()=>oe,Ft))),u=create(subscribeWithSelector(persist(()=>Ut,qt)));var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let n=()=>{N(),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 le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var $e={},Ve=()=>{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 isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:n=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(q(x({},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 $e[n]!="undefined"?$e[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 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 u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Xt=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}},Yt=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Xe=()=>{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 k=(()=>{switch(A.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(A.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(A.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:Yt(A.address),algo:A.algo,pubKey:A.pubkey,bech32Address:A.address,address:k,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,k,W;return {denom:d.coinDenom,amount:d.coinMinimalDenom,low_gas_price:(A=d.gasPriceStep)==null?void 0:A.low,average_gas_price:(k=d.gasPriceStep)==null?void 0:k.average,high_gas_price:(W=d.gasPriceStep)==null?void 0:W.high}})},apis:{rpc:[{address:m.rpc}],rest:[{address:m.rest}]}}),signDirect:(...m)=>{let[d,A,k]=m;return e.getOfflineSigner(d).signDirect(A,Xt(k))},signAmino:(...m)=>{let[d,A,k]=m;return e.getOfflineSignerOnlyAmino(d).signAmino(A,k)},signArbitrary:(m,d,A)=>l(void 0,null,function*(){let _=(yield e.getOfflineSigner(m).getAccounts()).find(h=>h.address===d);if(!_)throw new Error(`Wallet not connected to account ${d}`);let C=(()=>{switch(_.algo){case"secp256k1":return encodeSecp256k1Pubkey(_.pubkey);case"ed25519":return encodeEd25519Pubkey(_.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(A),pub_key:{type:_.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:C.value}}}),subscription:m=>{let d=()=>{N(),m();};return window.addEventListener("initia_keystorechange",d),()=>{window.removeEventListener("initia_keystorechange",d);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let n=()=>{N(),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 me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let n=()=>{N(),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 de={},Je=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 R;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=(R=f.split("MetaMask/v")[1])==null?void 0:R.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield 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 M=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:h,signDoc:b}}}}),K=b.accountNumber,R=new Oe(K.low,K.high,K.unsigned);return {signature:M.signature,signed:q(x({},M.signed),{accountNumber:`${R.toString()}`,authInfoBytes:new Uint8Array(Object.values(M.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(M.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 de[f]!="undefined")return de[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,de[f]=h,de[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,M,K]=f;return yield c(h,b,M)}),d=(...f)=>l(void 0,null,function*(){var $;let[h,b,M]=f,K=q(x({},M),{accountNumber:Oe.fromString((($=M.accountNumber)==null?void 0:$.toString())||"0"),authInfoBytes:M.authInfoBytes,bodyBytes:M.bodyBytes});return yield s(h,b,K)}),k=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 k(f)}),getOfflineSignerOnlyAmino:k,init:n,signAmino:m,signDirect:d}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Ze=()=>Je({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 u.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 x({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 ye=()=>{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:Oe.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:Oe.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: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 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:Oe.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 G=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},et=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),tt=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Ee=(e,t,o=new Error("Promise timed out"))=>{let r=new Promise((i,n)=>{setTimeout(()=>{n(o);},t);});return Promise.race([e,r])};var z=e=>{var R,$,ie;if(!((ie=($=(R=u.getState().walletConnect)==null?void 0:R.options)==null?void 0:$.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",o=(e==null?void 0:e.encoding)||"base64",r=y=>{if(!e)return;let{appUrl:S,formatNativeUrl:w}=e;if(G()){if(et()){let T=w(S.mobile.android,y,"android");window.open(T,"_self","noreferrer noopener");}if(tt()){let T=w(S.mobile.ios,y,"ios");window.open(T,"_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: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 T=w.session.getAll(),P=T.at(-1);if(!P)return;if(!(P.expiry*1e3>Date.now()+1e3))throw n(P.topic),new Error("invalid session");try{let D=T.find(j=>{var Y,J;return (J=(Y=j.requiredNamespaces.cosmos)==null?void 0:Y.chains)==null?void 0:J.includes(`cosmos:${y}`)});if(!D)throw new Error("no session");return D}catch(D){if(!D.message.toLowerCase().includes("no matching key"))throw D}return P}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 T=yield SignClient.init(y.options);return S.set(t,T),I.setState({wcSignClients:S}),T}),g=y=>{let{wcSignClients:S}=I.getState(),w=S.get(t);if(!w)return ()=>{};let T=P=>{let v=I.getState().accounts;if(P.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(D=>D.bech32Address).includes(P.params.event.data[0])){let D=P.params.chainId.split(":")[1];D&&m([D]);}else y();};return w.events.on("session_delete",i),w.events.on("session_expire",i),w.events.on("session_event",T),()=>{w.events.off("session_delete",i),w.events.off("session_expire",i),w.events.off("session_event",T);}},m=y=>l(void 0,null,function*(){var J;let S=typeof y=="string"?[y]:y,{wcSignClients:w,activeChainIds:T}=I.getState(),P=w.get(t);if(!P)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:v,chains:D}=u.getState();if(!((J=v==null?void 0:v.options)!=null&&J.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new WalletConnectModal(x({projectId:v.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},v.walletConnectModal)),Y=s(S);if(!Y){let{uri:U,approval:se}=yield Ee(P.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?r(U):yield j.openModal({uri:U});let ae=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ie,ee)=>{se().then(Re=>{let De=Re.sessionProperties;if(!De)return ee(new Error("No session properties"));let be=JSON.parse(String(De.keys));if(be.length===0)return ee(new Error("No accounts"));if(!be[0])return ee(new Error("No accounts"));let Ke={};return be.forEach(H=>{Ke[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),I.setState(H=>({accounts:x(x({},H.accounts||{}),Ke)})),Ie(Re)}).catch(ee),V.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let V=new AbortController,Ie=V.signal;j.subscribeModal(ee=>{ee.open||V.abort();}),yield ae(Ie);}catch(V){if(j.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||j.closeModal(),Promise.resolve()}try{yield Ee((()=>l(void 0,null,function*(){var se;let U=Object.fromEntries(yield Promise.all((se=T||S)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield A(ae)]}))));I.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(n(Y.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),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 T=w.find(P=>P.chainId===y);if(!T)throw new Error(`No wallet connect key for chainId ${y}`);return q(x({},T),{pubKey:Buffer.from(String(T.pubKey),o)})}),k=(...y)=>l(void 0,null,function*(){var J,U;let[S,w,T]=y,{accounts:P,wcSignClients:v}=I.getState(),D=v.get(t);if(!D)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let j=(J=a([S]))==null?void 0:J.topic;if(!j)throw new Error("No wallet connect session");if(!T.bodyBytes)throw new Error("No bodyBytes");if(!T.authInfoBytes)throw new Error("No authInfoBytes");return r(),yield D.request({topic:j,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:w,signDoc:{chainId:T.chainId,accountNumber:(U=T.accountNumber)==null?void 0:U.toString(),bodyBytes:T.bodyBytes?Buffer.from(T.bodyBytes).toString(o):null,authInfoBytes:T.authInfoBytes?Buffer.from(T.authInfoBytes).toString(o):null}}}})}),W=(...y)=>l(void 0,null,function*(){var D;let[S,w,T]=y,{signature:P,signed:v}=yield k(S,w,T);return {signed:{chainId:(D=v.chainId)!=null?D:"",accountNumber:v.accountNumber?BigInt(v.accountNumber):BigInt(0),authInfoBytes:v.authInfoBytes?new Uint8Array(Buffer.from(v.authInfoBytes,o)):new Uint8Array([]),bodyBytes:v.bodyBytes?new Uint8Array(Buffer.from(v.bodyBytes,o)):new Uint8Array([])},signature:P}}),_=(...y)=>l(void 0,null,function*(){var U;let[S,w,T,P]=y,{wcSignClients:v}=I.getState(),D=v.get(t),{accounts:j}=I.getState();if(!D)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let Y=(U=a([S]))==null?void 0:U.topic;if(!Y)throw new Error("No wallet connect session");return r(),yield D.request({topic:Y,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:w,signDoc:T}}})}),C=(...y)=>l(void 0,null,function*(){let[S,w,T,P]=y;return yield _(S,w,T)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,w)=>W(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 T;let{wcSignClients:S}=I.getState(),w=S.get(t);if(y===void 0){let P=w==null?void 0:w.session.getAll();P!==void 0&&(yield Promise.all(P.map(v=>n(v.topic))));}else typeof y=="string"?yield n((T=a([y]))==null?void 0:T.topic):yield Promise.all(y.map(P=>{var v;return n((v=a([P]))==null?void 0:v.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)=>W(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:W,subscription:g,init:p}};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(!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:(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 z(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(!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:(i,n,a)=>{let s=i.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return z(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(!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:(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 z(e)};var rt=()=>{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(!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:(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 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:i=>{let n=()=>{N(),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 F=(e=u.getState().walletType)=>{try{return B(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(te),I.setState(oe);},B=(e=u.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 it();case"wc_leap_mobile":return rt();case"wc_cosmostation_mobile":return ot();case"wc_clot_mobile":return nt();case"metamask_snap_leap":return Ze();case"metamask_snap_cosmos":return Ve();case"station":return ge();case"xdefi":return Se();case"cosmiframe":return le();case"compass":return ce();case"initia":return Xe();case"okx":return fe();default:throw new Error("Unknown wallet type")}})(),o=u.getState().walletDefaultOptions;return o&&((r=t.setDefaultOptions)==null||r.call(t,o)),t},Bi=()=>Object.fromEntries(Fe.map(e=>[e,F(e)])),st=e=>e==="metamask_snap_leap",at=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),re=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var ne=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(re(p)){let C=B("walletconnect"),{disable:f}=C;f&&f();}if(!F(p))throw new Error(`${p} is not available`);let m=B(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 M;return !((M=C.activeChainIds)!=null&&M.includes(b))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:k}=I.getState();if(yield (t=m.init)==null?void 0:t.call(m),yield m.enable(d),!re(p)){let C={};if(st(p)){let f={};try{for(var o=Le(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(at()&&m.getKeys){let f=yield m.getKeys(d);d.forEach((h,b)=>{let M=f[b];M&&(C[h]=M);});}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:x(x({},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(te,"Active");let W=d.map(C=>s.find(f=>f.chainId===C));return {accounts:I.getState().accounts,walletType:p,chains:W}}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}}),Te=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(te);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(re(u.getState().walletType)){let o=B("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(oe),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(oe),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:o,_reconnect:r}=u.getState();try{let n=F(o||void 0);if(t&&n&&o)return re(o)?void 0:yield ne({chainId:t,walletType:o,autoReconnect:r})}catch(n){(i=e==null?void 0:e.onError)==null||i.call(e,n),Te();}}),ct=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),o=e.walletType||t;if(!F(o))throw new Error(`${o} is not available`);let i=B(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 ke=()=>{u.setState({recentChainIds:null});},Xi=()=>u.getState().recentChainIds,Yi=()=>{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},Ji=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(o=>o.chainId===e)},Zi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},Me=o=>l(void 0,[o],function*({chainInfo:e,walletType:t}){return yield B(t).experimentalSuggestChain(e),e}),lt=e=>l(void 0,null,function*(){var r;let t=u.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(r=e.walletType)!=null?r:t}),yield ne({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ut=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 pt=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)}),mt=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)}),dt=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)}),ft=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)}),gt=(e,t,o)=>l(void 0,null,function*(){if(!o)throw new Error("CosmWasm client is not ready");return yield o.queryContractSmart(e,t)}),yt=(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 lr=e=>e,ur=e=>e;var St=e=>e?Object.keys(e).length===0:!0;var xe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ct=e=>globalThis.DOMException===void 0?new xe(e):new DOMException(e),wt=e=>{let t=e.reason===void 0?Ct("This operation was aborted."):e.reason;return t instanceof Error?t:Ct(t)};function ve(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,k=!1,W=0,_=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(wt(i)),i.addEventListener("abort",()=>{f(wt(i));}));let h=()=>l(this,null,function*(){if(A)return;let b=yield C.next(),M=_;if(_++,b.done){if(k=!0,W===0&&!A){if(!r&&g.length>0){f(new AggregateError(g));return}if(A=!0,m.size===0){s(p);return}let K=[];for(let[R,$]of p.entries())m.get(R)!==ht&&K.push($);s(K);}return}W++,l(this,null,function*(){try{let K=yield b.value;if(A)return;let R=yield t(K,M);R===ht&&m.set(M,R),p[M]=R,W--,yield h();}catch(K){if(r)f(K);else {g.push(K),W--;try{yield h();}catch(R){f(R);}}}});});l(this,null,function*(){for(let b=0;b<o;b++){try{yield h();}catch(M){f(M);break}if(k||d)break}});})})}var ht=Symbol("skip");var Q=({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]]}},X=(e,t,o)=>l(void 0,null,function*(){let r=u.getState().multiChainFetchConcurrency;if(e){let n=yield ve(t,o,{concurrency:r});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield o(t[0])}),At=(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 We=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:o,queryFn:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield X(!!(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:x({},(s==null?void 0:s.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Pe=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:o,queryFn:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield X(!!(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:x({},(s==null?void 0:s.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})};var Kr=()=>u(useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),Ce=e=>{let o=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return useQuery({queryKey:o,queryFn:({queryKey:[,i]})=>F(i)})};var Z=e=>{let t=u(s=>s.walletType),o=I(s=>s.activeChainIds),r=Q({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 useEffect(()=>I.subscribe(s=>s.status,(s,c)=>{var p,g,m;if(s==="connected"){let{accounts:d,activeChainIds:A}=I.getState(),{chains:k}=u.getState(),{walletType:W}=u.getState();if(!d||!A||!k)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(_=>k.find(C=>C.chainId===_)),walletType:W,isReconnect:c==="reconnecting"});}s==="disconnected"&&((m=e==null?void 0:e.onDisconnect)==null||m.call(e));}),[e]),{data:useMemo(()=>i?At(!!(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:L,status:n}},cn=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=Z(),r=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),{data:i}=We({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!r}),n=useMemo(()=>["USE_ALL_BALANCES",i,t,r,e==null?void 0:e.chainId],[r,e==null?void 0:e.chainId,t,i]);return 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 X(!!(e!=null&&e.multiChain),s,m=>l(void 0,null,function*(){var k;let d=a==null?void 0:a[m.chainId];if(!d)throw new Error(`Client is not ready ${m.chainId}`);if(!((k=m.bech32Config)!=null&&k.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${m.chainId}`);return yield d.getAllBalances(toBech32(m.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!St(i)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Hr=e=>{let t=Q({chainId:e.chainId}),{data:o}=Z({chainId:e.chainId}),r=e.bech32Address||(o==null?void 0:o.bech32Address),{data:i,refetch:n}=cn({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=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 q(x({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},Xr=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=useMutation({mutationKey:["USE_CONNECT",e,t,o],mutationFn:ne,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))}),{data:n}=Ce();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}},Yr=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=useMutation({mutationKey:["USE_DISCONNECT",e,t,o],mutationFn:Te,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}},Jr=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),o=u(i=>i.walletType),r=useMemo(()=>["USE_OFFLINE_SIGNERS",t,o],[t,o]);return useQuery({queryKey:r,queryFn:a=>l(void 0,[a],function*({queryKey:[,i,n]}){if(i.length<1)throw new Error("No chain found");if(!F(n))throw new Error(`${n} is not available`);return yield X(!!(e!=null&&e.multiChain),i,p=>l(void 0,null,function*(){return yield ct({chainId:p.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!o,refetchOnWindowFocus:!1})},Zr=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:o}=Z(),{data:r}=We({chainId:t.map(a=>a.chainId),multiChain:!0}),i=(e==null?void 0:e.bech32Address)||(o==null?void 0:o.bech32Address),n=useMemo(()=>["USE_BALANCE_STAKED",r,t,i],[t,i,r]);return 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 X(!!(e!=null&&e.multiChain),s,m=>l(void 0,null,function*(){var A,k;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 (k=a[m.chainId])==null?void 0:k.getBalanceStaked(toBech32(m.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!r,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var as=()=>I(e=>e.activeChainIds),ln=()=>{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)},cs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(o=>o.chainId===e)},ls=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(o=>e==null?void 0:e.includes(o.chainId))},us=({denom:e})=>{let t=ln();return 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)}})},ps=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",o=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return 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"})},ms=()=>({data:u(t=>t.recentChainIds),clear:ke}),ds=()=>{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:ke}},fs=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,o],mutationFn:Me,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}},gs=({onError:e,onLoading:t,onSuccess:o}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],mutationFn:lt,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}=Ce();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!n,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var bs=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=Z(),i=r==null?void 0:r.bech32Address,n=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,o,i],mutationFn:a=>pt(x({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}},Os=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=Z(),i=r==null?void 0:r.bech32Address,n=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,o,i],mutationFn:a=>mt(x({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}},Es=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:i}=Z(),n=i==null?void 0:i.bech32Address,s=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,o,r,e,n],mutationFn:c=>{var g;if(!n)throw new Error("senderAddress is undefined");let p=q(x({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:n,codeId:e});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,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Ts=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:i}=Z(),n=i==null?void 0:i.bech32Address,s=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=q(x({},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 ft(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}},ks=e=>{let{data:t}=Pe();return 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 gt(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ms=e=>{let{data:t}=Pe(),o=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:o,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return yt(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Ls(e){let t=Q({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=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,o,e,r],[r,e,t,o]);return useQuery({queryKey:i,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),n,p=>l(this,null,function*(){var W,_;if(!(r!=null&&r.includes(p.chainId)))return null;if(!F(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 B(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return B(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return B(a).getOfflineSignerOnlyAmino(p.chainId);default:return B(a).getOfflineSignerAuto(p.chainId)}}))(),d=(W=u.getState().chainsConfig)==null?void 0:W[p.chainId],A={url:p.rpc,headers:x({},(d==null?void 0:d.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(A,m,e!=null&&e.multiChain?(_=e.opts)==null?void 0:_[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 Us(e){let t=Q({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=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,o,e,r],[r,e,t,o]);return useQuery({queryKey:i,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),n,p=>l(this,null,function*(){var _,C;if(!(r!=null&&r.includes(p.chainId)))return null;if(!F(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 B(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return B(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return B(a).getOfflineSignerOnlyAmino(p.chainId);default:return B(a).getOfflineSignerAuto(p.chainId)}}))(),d=(_=u.getState().chainsConfig)==null?void 0:_[p.chainId],A={url:p.rpc,headers:x({},(d==null?void 0:d.rpcHeaders)||{})},k=d!=null&&d.gas?GasPrice.fromString(`${d.gas.price}${d.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(A,m,x({gasPrice:k},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 Pt=({children:e})=>{let[t,o]=useState(!1);return useEffect(()=>{o(!0);},[]),jsx(Fragment,{children:t?e:null})};var Cn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(te)==="Active",{_reconnect:t,_onReconnectFailed:o,_reconnectConnector:r,iframeOptions:i,chains:n}=u(),{activeChainIds:a,wcSignClients:s}=I(),c=F(r||void 0);return useEffect(()=>{if(!i||i.autoConnect===!1||!i.allowedIframeParentOrigins.length||!n)return;new Cosmiframe(i.allowedIframeParentOrigins).isReady().then(g=>{if(g)return ne({chainId:n.map(m=>m.chainId),walletType:"cosmiframe"})});},[i]),useEffect(()=>{if(r){if(!c)return;e&&a?L({onError:o}):!e&&t&&L({onError:o});}},[c]),useEffect(()=>{var p,g,m,d,A,k,W,_,C,f,h,b,M,K,R,$,ie,y,S,w;if(r){if(!c)return;r==="cosmostation"&&((g=(p=ue()).subscription)==null||g.call(p,()=>{L({onError:o});})),r==="keplr"&&((d=(m=pe()).subscription)==null||d.call(m,()=>{L({onError:o});})),r==="leap"&&((k=(A=me()).subscription)==null||k.call(A,()=>{L({onError:o});})),r==="compass"&&((_=(W=ce()).subscription)==null||_.call(W,()=>{L({onError:o});})),r==="vectis"&&((f=(C=ye()).subscription)==null||f.call(C,()=>{L({onError:o});})),r==="walletconnect"&&s.has("walletconnect")&&((b=(h=z()).subscription)==null||b.call(h,()=>{L({onError:o});})),r==="station"&&((K=(M=ge()).subscription)==null||K.call(M,()=>{L({onError:o});})),r==="xdefi"&&(($=(R=Se()).subscription)==null||$.call(R,()=>{L({onError:o});})),r==="cosmiframe"&&((y=(ie=le()).subscription)==null||y.call(ie,()=>{L({onError:o});})),r==="okx"&&((w=(S=fe()).subscription)==null||w.call(S,()=>{L({onError:o});}));}},[r,s,c]),null},_t=()=>(Cn(),null);var ya=({children:e,grazOptions:t})=>(useEffect(()=>{ut(t);},[t]),jsxs(Pt,{children:[e,jsx(_t,{})]}));
|
|
20
19
|
|
|
21
|
-
export {
|
|
20
|
+
export { _t as GrazEvents, ya as GrazProvider, Fe as WALLET_TYPES, Ue as WalletType, F as checkWallet, ke as clearRecentChain, N as clearSession, ut as configureGraz, ne as connect, ur as defineChainInfo, lr as defineChains, Te as disconnect, ft as executeContract, Bi as getAvailableWallets, Ji as getChainInfo, Zi as getChainInfos, ue as getCosmostation, pe as getKeplr, me as getLeap, Ze as getMetamaskSnapLeap, ct as getOfflineSigners, yt as getQueryRaw, gt as getQuerySmart, Xi as getRecentChainIds, Yi as getRecentChains, ye as getVectis, ot as getWCCosmostation, it as getWCKeplr, rt as getWCLeap, B as getWallet, z as getWalletConnect, dt as instantiateContract, at as isLeapDappBrowser, st as isLeapSnaps, re as isWalletConnect, L as reconnect, mt as sendIbcTokens, pt as sendTokens, Me as suggestChain, lt as suggestChainAndConnect, Z as useAccount, us as useActiveChainCurrency, as as useActiveChainIds, ln as useActiveChains, Kr as useActiveWalletType, Hr as useBalance, Zr as useBalanceStaked, cn as useBalances, cs as useChainInfo, ls as useChainInfos, Ce as useCheckWallet, Xr as useConnect, Pe as useCosmWasmClient, Us as useCosmWasmSigningClient, Yr as useDisconnect, Ts as useExecuteContract, Cn as useGrazEvents, Es as useInstantiateContract, Jr as useOfflineSigners, ps as useQueryClientValidators, Ms as useQueryRaw, ks as useQuerySmart, ms as useRecentChainIds, ds as useRecentChains, Os as useSendIbcTokens, bs as useSendTokens, We as useStargateClient, Ls as useStargateSigningClient, fs as useSuggestChain, gs as useSuggestChainAndConnect };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"author": "
|
|
4
|
+
"version": "0.3.0-alpha.0",
|
|
5
|
+
"author": "Nur Fikri <kikiding.space@gmail.com>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
8
8
|
"bugs": "https://github.com/graz-sh/graz/issues",
|
|
@@ -33,18 +33,23 @@
|
|
|
33
33
|
"env.d.ts"
|
|
34
34
|
],
|
|
35
35
|
"sideEffects": false,
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup",
|
|
38
|
+
"clean": "rm -rf dist/*",
|
|
39
|
+
"cli": "node dist/cli.js",
|
|
40
|
+
"dev": "tsup --watch",
|
|
41
|
+
"lint": "eslint --fix \"src/**/*.{ts,tsx}\"",
|
|
42
|
+
"prepublishOnly": "pnpm build"
|
|
43
|
+
},
|
|
36
44
|
"peerDependencies": {
|
|
37
|
-
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
|
|
38
45
|
"@tanstack/react-query": ">=5.62.0",
|
|
39
|
-
"react": ">=17"
|
|
46
|
+
"react": ">=17",
|
|
47
|
+
"@cosmjs/amino": ">=0.32.4",
|
|
48
|
+
"@cosmjs/cosmwasm-stargate": ">=0.32.4",
|
|
49
|
+
"@cosmjs/proto-signing": ">=0.32.4",
|
|
50
|
+
"@cosmjs/stargate": ">=0.32.4"
|
|
40
51
|
},
|
|
41
52
|
"dependencies": {
|
|
42
|
-
"@cosmjs/amino": "0.31.3",
|
|
43
|
-
"@cosmjs/cosmwasm-stargate": "0.31.3",
|
|
44
|
-
"@cosmjs/launchpad": "0.27.1",
|
|
45
|
-
"@cosmjs/proto-signing": "0.31.3",
|
|
46
|
-
"@cosmjs/stargate": "0.31.3",
|
|
47
|
-
"@cosmjs/tendermint-rpc": "0.31.3",
|
|
48
53
|
"@keplr-wallet/types": "0.12.156",
|
|
49
54
|
"@cosmsnap/snapper": "0.1.29",
|
|
50
55
|
"@dao-dao/cosmiframe": "0.1.0",
|
|
@@ -52,13 +57,13 @@
|
|
|
52
57
|
"@metamask/providers": "12.0.0",
|
|
53
58
|
"@terra-money/station-connector": "1.1.0",
|
|
54
59
|
"@vectis/extension-client": "^0.7.2",
|
|
55
|
-
"@walletconnect/sign-client": "2.
|
|
56
|
-
"@walletconnect/types": "2.
|
|
57
|
-
"@walletconnect/utils": "2.
|
|
60
|
+
"@walletconnect/sign-client": "2.20.2",
|
|
61
|
+
"@walletconnect/types": "2.20.2",
|
|
62
|
+
"@walletconnect/utils": "2.20.2",
|
|
58
63
|
"@walletconnect/modal": "2.7.0",
|
|
59
64
|
"cosmos-directory-client": "0.0.6",
|
|
60
65
|
"long": "4",
|
|
61
|
-
"zustand": "
|
|
66
|
+
"zustand": "5.0.4"
|
|
62
67
|
},
|
|
63
68
|
"devDependencies": {
|
|
64
69
|
"@initia/initia-registry-types": "0.0.20",
|
|
@@ -67,7 +72,7 @@
|
|
|
67
72
|
"@types/react-dom": "^18.2.7",
|
|
68
73
|
"arg": "^5.0.2",
|
|
69
74
|
"react": "^18.2.0",
|
|
70
|
-
"typescript": "^5.
|
|
75
|
+
"typescript": "^5.4.0"
|
|
71
76
|
},
|
|
72
77
|
"keywords": [
|
|
73
78
|
"graz",
|
|
@@ -77,12 +82,5 @@
|
|
|
77
82
|
"graz-sh",
|
|
78
83
|
"use-keplr"
|
|
79
84
|
],
|
|
80
|
-
"license": "MIT"
|
|
81
|
-
|
|
82
|
-
"build": "tsup",
|
|
83
|
-
"clean": "rm -rf dist/*",
|
|
84
|
-
"cli": "node dist/cli.js",
|
|
85
|
-
"dev": "tsup --watch",
|
|
86
|
-
"lint": "eslint --fix \"src/**/*.{ts,tsx}\""
|
|
87
|
-
}
|
|
88
|
-
}
|
|
85
|
+
"license": "MIT"
|
|
86
|
+
}
|