graz 0.0.38 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -158,7 +158,8 @@ declare const testnetChainsArray: ChainInfo[];
158
158
 
159
159
  declare enum WalletType {
160
160
  KEPLR = "keplr",
161
- LEAP = "leap"
161
+ LEAP = "leap",
162
+ COSMOSTATION = "cosmostation"
162
163
  }
163
164
  declare const WALLET_TYPES: WalletType[];
164
165
 
@@ -353,9 +354,24 @@ declare const getKeplr: () => Keplr;
353
354
  * }
354
355
  * ```
355
356
  *
356
- * @see https://docs.keplr.app
357
+ * @see https://docs.leapwallet.io/cosmos/for-dapps-connect-to-leap/add-leap-to-existing-keplr-integration
357
358
  */
358
359
  declare const getLeap: () => Keplr;
360
+ /**
361
+ * Function to return cosmostation object (which is {@link Keplr}) and throws and error if it does not exist on `window`.
362
+ *
363
+ * @example
364
+ * ```ts
365
+ * try {
366
+ * const cosmostation = getCosmostation();
367
+ * } catch (error: Error) {
368
+ * console.error(error.message);
369
+ * }
370
+ * ```
371
+ *
372
+ * @see https://docs.cosmostation.io/integration-extension/cosmos/integrate-keplr
373
+ */
374
+ declare const getCosmostation: () => Keplr;
359
375
  /**
360
376
  * Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
361
377
  * exist on `window` or unknown wallet type.
@@ -928,19 +944,6 @@ declare const useQuerySmart: <TData, TError>(address?: string, queryMsg?: Record
928
944
  */
929
945
  declare const useQueryRaw: <TError>(address?: string, key?: string) => UseQueryResult<Uint8Array | null, TError>;
930
946
 
931
- /**
932
- * graz hook which returns boolean whether Keplr Wallet is supported
933
- *
934
- * @example
935
- * ```ts
936
- * import { useCheckKeplr } from "graz";
937
- *
938
- * const { data: isSupported } = useCheckKeplr();
939
- * ```
940
- *
941
- * @deprecated prefer using {@link useCheckWallet}
942
- */
943
- declare const useCheckKeplr: () => UseQueryResult<boolean>;
944
947
  /**
945
948
  * graz query hook to check whether given {@link WalletType} or default configured wallet is supported
946
949
  *
@@ -990,4 +993,4 @@ declare const useGrazEvents: () => null;
990
993
  */
991
994
  declare const GrazEvents: FC;
992
995
 
993
- export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, Connector, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
996
+ export { AccountData, ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, Connector, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getCosmostation, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ye=Object.create;var D=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $e(t))!Ze.call(e,o)&&o!==n&&D(e,o,{get:()=>t[o],enumerable:!(r=Je(t,o))||r.enumerable});return e};var le=(e,t,n)=>(n=e!=null?Ye(Xe(e)):{},me(t||!e||!e.__esModule?D(n,"default",{value:e,enumerable:!0}):n,e)),tt=e=>me(D({},"__esModule",{value:!0}),e);var Xt={};et(Xt,{GrazEvents:()=>ue,GrazProvider:()=>$t,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>f,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>h,createClients:()=>w,createQueryClient:()=>q,createSigningClients:()=>b,defineChain:()=>wt,defineChainInfo:()=>bt,defineChains:()=>ie,disconnect:()=>I,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>ot,getBalanceStaked:()=>_,getBalances:()=>F,getKeplr:()=>Ce,getLeap:()=>fe,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>st,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>jt,mainnetChainsArray:()=>Dt,reconnect:()=>l,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>T,suggestChainAndConnect:()=>O,testnetChains:()=>kt,testnetChainsArray:()=>It,useAccount:()=>d,useActiveChain:()=>qt,useActiveChainCurrency:()=>Mt,useActiveChainValidators:()=>Qt,useBalance:()=>Bt,useBalanceStaked:()=>Ut,useBalances:()=>Fe,useCheckKeplr:()=>Tt,useCheckWallet:()=>A,useClients:()=>Ft,useConnect:()=>Rt,useDisconnect:()=>vt,useExecuteContract:()=>Lt,useGrazEvents:()=>Ne,useInstantiateContract:()=>Ht,useOfflineSigners:()=>_e,useQueryClient:()=>Wt,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>Nt,useSendTokens:()=>Pt,useSigners:()=>Gt,useSigningClients:()=>_t,useSuggestChain:()=>Kt,useSuggestChainAndConnect:()=>Ot});module.exports=tt(Xt);var xe=require("@cosmjs/stargate");var E="graz-reconnect-session";var de=le(require("zustand")),k=require("zustand/middleware");var v=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(v||{}),G=["keplr","leap"];var U={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},nt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,de.default)((0,k.subscribeWithSelector)((0,k.persist)(()=>U,nt)));var M=require("@cosmjs/cosmwasm-stargate"),Q=require("@cosmjs/stargate"),ye=require("@cosmjs/tendermint-rpc");var ge=require("@cosmjs/stargate"),C=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,n=new ge.QueryClient(t),r=e.map(o=>o(n));for(let o of r){(0,C.assert)((0,C.isNonNullObject)(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){(0,C.assert)((0,C.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=n[i]||{};n[i]={...a,...s}}}return n};var w=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,o,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),Q.SigningStargateClient.connect(n),ye.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:o,tendermint:i}},b=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[a,u]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,o),Q.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var f=(e=c.getState().walletType)=>{try{return x(e),!0}catch(t){return console.error(t),!1}},Ce=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},fe=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},x=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ce();case"leap":return fe();default:throw new Error("Unknown wallet type")}},ot=()=>Object.fromEntries(G.map(e=>[e,f(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),o=(e==null?void 0:e.walletType)||r,i=x(o),s=(e==null?void 0:e.chain)||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(j=>{let Ve=j._reconnect||!!j._reconnectConnector||!!s;return j.activeChain&&j.activeChain.chainId!==s.chainId?{status:"connecting"}:Ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?xe.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[pe,He,Le]=await Promise.all([i.getKey(s.chainId),w(s),b({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:pe,activeChain:s,clients:He,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:Le,status:"connected",walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),typeof window<"u"&&window.sessionStorage.setItem(E,"Active"),pe}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},I=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(E),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:n,_reconnect:r}=c.getState(),o=f(n||void 0);try{if(t&&o&&n)return await h({chain:t,walletType:n,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),I()}};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},st=()=>c.getState().recentChain,T=async e=>(await x().experimentalSuggestChain(e),e),O=async({chainInfo:e,rpcHeaders:t,gas:n,path:r,...o})=>{let i=await T(e);return{account:await h({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:n,path:r},...o}),chain:i}};var W=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var F=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return n[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},_=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},P=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:o})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,n,r,o)},N=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,n,r,o,i,s,a,u)},H=async({senderAddress:e,msg:t,fee:n,options:r,label:o,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,o,n,r)},L=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:o,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,n,i,o)},V=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};var Ae=require("@keplr-wallet/cosmos"),Se={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},rt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},it={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ct={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},at={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ut={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},he=[Se,rt,it,ct,at,ut],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Se,bip44:{coinType:118},bech32Config:Ae.Bech32Address.defaultBech32Config("axelar"),currencies:he,feeCurrencies:he};var we=require("@keplr-wallet/cosmos"),be={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ee=[be],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:be,bip44:{coinType:118},bech32Config:we.Bech32Address.defaultBech32Config("cosmos"),currencies:Ee,feeCurrencies:Ee};var De=require("@keplr-wallet/cosmos"),ke={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},pt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},mt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},lt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},dt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},gt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},yt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ct={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},ft={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},xt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ht={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},je=[ke,pt,mt,lt,dt,gt,yt,Ct,ft,xt,ht],X={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ke,bip44:{coinType:118},bech32Config:De.Bech32Address.defaultBech32Config("juno"),currencies:je,feeCurrencies:je};var Te=require("@keplr-wallet/cosmos"),Be={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},At={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Ie=[Be,At],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Be,bip44:{coinType:118},bech32Config:Te.Bech32Address.defaultBech32Config("osmo"),currencies:Ie,feeCurrencies:Ie};var ve=require("@keplr-wallet/cosmos"),Ge={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Re=[Ge],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ge,bip44:{coinType:118},bech32Config:ve.Bech32Address.defaultBech32Config("somm"),currencies:Re,feeCurrencies:Re};var qe=require("@keplr-wallet/cosmos"),Me={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Ue=[Me],te={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:qe.Bech32Address.defaultBech32Config("CRE"),currencies:Ue,feeCurrencies:Ue,stakeCurrency:Me,coinType:118};var Qe=require("@keplr-wallet/cosmos"),ne={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},St=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("juno"),currencies:St,feeCurrencies:[ne],coinType:118};var ze=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Et=[se],re={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("osmo"),currencies:Et,feeCurrencies:[se],coinType:118};var ie=e=>e,wt=e=>e,bt=e=>e,jt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),Dt=[J,$,X,Z,ee],kt=ie({crescent:te,juno:oe,osmosis:re}),It=[te,oe,re];var y=require("@tanstack/react-query"),Oe=require("react"),We=le(require("zustand/shallow"));var Ke=require("@tanstack/react-query");var Tt=()=>A("keplr"),A=e=>{let n=["USE_CHECK_WALLET",c(o=>e||o.walletType)];return(0,Ke.useQuery)(n,({queryKey:[,o]})=>f(o))};var d=({onConnect:e,onDisconnect:t}={})=>{let n=c(o=>o.account),r=c(o=>o.status);return(0,Oe.useEffect)(()=>c.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:!!n,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},Fe=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>F(i),{enabled:!!n})},Bt=(e,t)=>{let{data:n}=Fe(t);return(0,y.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!n})},Rt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,y.useMutation)(["USE_CONNECT",e,t,n],h,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=A();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status}},vt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,y.useMutation)(["USE_DISCONNECT",e,t,n],I,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},_e=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),We.default),Gt=()=>_e(),Ut=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>_(n),{enabled:!!n})};var S=require("@tanstack/react-query");var qt=()=>c(e=>e.activeChain),Mt=e=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),Qt=(e,t="BOND_STATUS_BONDED")=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Kt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,S.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],T,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},Ot=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,S.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],O,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=A();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var ce=require("@tanstack/react-query");var Pe=require("@tanstack/react-query");var Wt=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Pe.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Ft=e=>{let t=c(o=>o.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?w(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({clients:o})}})},_t=e=>{let t=c(o=>o.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?b(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({signingClients:o})}})};var g=require("@tanstack/react-query");var Pt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=d(),o=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_TOKENS",e,t,n,o],a=>P({senderAddress:o,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Nt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=d(),o=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,o],a=>N({senderAddress:o,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Ht=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=d(),i=o==null?void 0:o.bech32Address,u=(0,g.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return H(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:n,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},Lt=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=d(),i=o==null?void 0:o.bech32Address,u=(0,g.useMutation)(["USE_EXECUTE_CONTRACT",t,n,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return L(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:n,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},Vt=(e,t)=>(0,g.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:!!e&&!!t}),Yt=(e,t)=>(0,g.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:!!e&&!!t});var B=require("@tanstack/react-query");var ae=require("react");var Ne=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(E)==="Active",{activeChain:t,_reconnect:n,_onReconnectFailed:r}=c.getState();return(0,ae.useEffect)(()=>{e&&t?l({onError:r}):!e&&n&&l({onError:r})},[]),(0,ae.useEffect)(()=>(window.addEventListener("keplr_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void l({onError:r}))}),[]),null},ue=()=>(Ne(),null);var R=require("react/jsx-runtime"),Jt=new B.QueryClient({}),$t=({children:e,grazOptions:t,...n})=>(t&&W(t),(0,R.jsxs)(B.QueryClientProvider,{client:Jt,...n,children:[(0,R.jsx)(ue,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
1
+ "use strict";var Ye=Object.create;var D=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var o in t)D(e,o,{get:t[o],enumerable:!0})},me=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $e(t))!Ze.call(e,n)&&n!==o&&D(e,n,{get:()=>t[n],enumerable:!(s=Je(t,n))||s.enumerable});return e};var tt=(e,t,o)=>(o=e!=null?Ye(Xe(e)):{},me(t||!e||!e.__esModule?D(o,"default",{value:e,enumerable:!0}):o,e)),nt=e=>me(D({},"__esModule",{value:!0}),e);var Xt={};et(Xt,{GrazEvents:()=>ue,GrazProvider:()=>$t,WALLET_TYPES:()=>G,WalletType:()=>R,checkWallet:()=>f,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>h,createClients:()=>E,createQueryClient:()=>q,createSigningClients:()=>w,defineChain:()=>bt,defineChainInfo:()=>jt,defineChains:()=>ie,disconnect:()=>k,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>st,getBalanceStaked:()=>_,getBalances:()=>F,getCosmostation:()=>fe,getKeplr:()=>ye,getLeap:()=>Ce,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>rt,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>Dt,mainnetChainsArray:()=>Tt,reconnect:()=>l,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>I,suggestChainAndConnect:()=>Q,testnetChains:()=>kt,testnetChainsArray:()=>It,useAccount:()=>d,useActiveChain:()=>qt,useActiveChainCurrency:()=>Mt,useActiveChainValidators:()=>Ot,useBalance:()=>Bt,useBalanceStaked:()=>Ut,useBalances:()=>Fe,useCheckWallet:()=>b,useClients:()=>Ft,useConnect:()=>vt,useDisconnect:()=>Rt,useExecuteContract:()=>Lt,useGrazEvents:()=>Ne,useInstantiateContract:()=>Ht,useOfflineSigners:()=>_e,useQueryClient:()=>Wt,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>Nt,useSendTokens:()=>Pt,useSigners:()=>Gt,useSigningClients:()=>_t,useSuggestChain:()=>Kt,useSuggestChainAndConnect:()=>Qt});module.exports=nt(Xt);var xe=require("@cosmjs/stargate");var S="graz-reconnect-session";var le=require("zustand"),T=require("zustand/middleware");var R=(s=>(s.KEPLR="keplr",s.LEAP="leap",s.COSMOSTATION="cosmostation",s))(R||{}),G=["keplr","leap","cosmostation"];var U={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ot={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,le.create)((0,T.subscribeWithSelector)((0,T.persist)(()=>U,ot)));var M=require("@cosmjs/cosmwasm-stargate"),O=require("@cosmjs/stargate"),ge=require("@cosmjs/tendermint-rpc");var de=require("@cosmjs/stargate"),C=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,o=new de.QueryClient(t),s=e.map(n=>n(o));for(let n of s){(0,C.assert)((0,C.isNonNullObject)(n),"Extension must be a non-null object");for(let[i,r]of Object.entries(n)){(0,C.assert)((0,C.isNonNullObject)(r),`Module must be a non-null object. Found type ${typeof r} for module "${i}".`);let a=o[i]||{};o[i]={...a,...r}}}return o};var E=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[s,n,i]=await Promise.all([M.SigningCosmWasmClient.connect(o),O.SigningStargateClient.connect(o),ge.Tendermint34Client.connect(e)]);return{cosmWasm:s,stargate:n,tendermint:i}},w=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:s,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,r={url:t,headers:{...o||{}}},[a,u]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(r,s,n),O.SigningStargateClient.connectWithSigner(r,s,i)]);return{cosmWasm:a,stargate:u}};var f=(e=c.getState().walletType)=>{try{return x(e),!0}catch(t){return console.error(t),!1}},ye=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ce=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},fe=()=>{if(typeof window.cosmostation.providers.keplr<"u")return window.cosmostation.providers.keplr;throw c.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")},x=(e=c.getState().walletType)=>{switch(e){case"keplr":return ye();case"leap":return Ce();case"cosmostation":return fe();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(G.map(e=>[e,f(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:o,walletType:s}=c.getState(),n=(e==null?void 0:e.walletType)||s,i=x(n),r=(e==null?void 0:e.chain)||o||t;if(!r)throw new Error("No last known connected chain, connect action requires chain info");c.setState(j=>{let Ve=j._reconnect||!!j._reconnectConnector||!!r;return j.activeChain&&j.activeChain.chainId!==r.chainId?{status:"connecting"}:Ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(r.chainId);let a=i.getOfflineSigner(r.chainId),u=i.getOfflineSignerOnlyAmino(r.chainId),p=await i.getOfflineSignerAuto(r.chainId),m=r.gas?xe.GasPrice.fromString(`${r.gas.price}${r.gas.denom}`):void 0,[pe,He,Le]=await Promise.all([i.getKey(r.chainId),E(r),w({...r,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:pe,activeChain:r,clients:He,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:r,signingClients:Le,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(S,"Active"),pe}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},k=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(S),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:s}=c.getState(),n=f(o||void 0);try{if(t&&n&&o)return await h({chain:t,walletType:o,autoReconnect:s})}catch(r){(i=e==null?void 0:e.onError)==null||i.call(e,r),k()}};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},rt=()=>c.getState().recentChain,I=async e=>(await x().experimentalSuggestChain(e),e),Q=async({chainInfo:e,rpcHeaders:t,gas:o,path:s,...n})=>{let i=await I(e);return{account:await h({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:s},...n}),chain:i}};var W=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var F=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:s}=c.getState();return await Promise.all(t.currencies.map(async i=>{let r=i.coinMinimalDenom.startsWith("cw20:");return o[s].getBalance(e,r?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},_=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},P=async({senderAddress:e,recipientAddress:t,amount:o,fee:s,memo:n})=>{let{signingClients:i,defaultSigningClient:r}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[r].sendTokens(e,t,o,s,n)},N=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:s,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:r,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,s,n,i,r,a,u)},H=async({senderAddress:e,msg:t,fee:o,options:s,label:n,codeId:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.instantiate(e,i,t,n,o,s)},L=async({senderAddress:e,msg:t,fee:o,contractAddress:s,funds:n,memo:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.execute(e,s,t,o,i,n)},V=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let s=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,s)};var Ae=require("@keplr-wallet/cosmos"),Se={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},it={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ct={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},at={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ut={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},pt={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},he=[Se,it,ct,at,ut,pt],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Se,bip44:{coinType:118},bech32Config:Ae.Bech32Address.defaultBech32Config("axelar"),currencies:he,feeCurrencies:he};var we=require("@keplr-wallet/cosmos"),be={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ee=[be],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:be,bip44:{coinType:118},bech32Config:we.Bech32Address.defaultBech32Config("cosmos"),currencies:Ee,feeCurrencies:Ee};var De=require("@keplr-wallet/cosmos"),Te={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},mt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},lt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},dt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},gt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},yt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ct={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ft={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},xt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},ht={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},At={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},je=[Te,mt,lt,dt,gt,yt,Ct,ft,xt,ht,At],X={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Te,bip44:{coinType:118},bech32Config:De.Bech32Address.defaultBech32Config("juno"),currencies:je,feeCurrencies:je};var Ie=require("@keplr-wallet/cosmos"),Be={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},St={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ke=[Be,St],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Be,bip44:{coinType:118},bech32Config:Ie.Bech32Address.defaultBech32Config("osmo"),currencies:ke,feeCurrencies:ke};var Re=require("@keplr-wallet/cosmos"),Ge={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ve=[Ge],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ge,bip44:{coinType:118},bech32Config:Re.Bech32Address.defaultBech32Config("somm"),currencies:ve,feeCurrencies:ve};var qe=require("@keplr-wallet/cosmos"),Me={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Ue=[Me],te={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:qe.Bech32Address.defaultBech32Config("CRE"),currencies:Ue,feeCurrencies:Ue,stakeCurrency:Me,coinType:118};var Oe=require("@keplr-wallet/cosmos"),ne={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Et=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:Oe.Bech32Address.defaultBech32Config("juno"),currencies:Et,feeCurrencies:[ne],coinType:118};var ze=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},wt=[se],re={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("osmo"),currencies:wt,feeCurrencies:[se],coinType:118};var ie=e=>e,bt=e=>e,jt=e=>e,Dt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),Tt=[J,$,X,Z,ee],kt=ie({crescent:te,juno:oe,osmosis:re}),It=[te,oe,re];var y=require("@tanstack/react-query"),Qe=require("react"),We=tt(require("zustand/shallow"));var Ke=require("@tanstack/react-query");var b=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return(0,Ke.useQuery)(o,({queryKey:[,n]})=>f(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),s=c(n=>n.status);return(0,Qe.useEffect)(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let r=c.getState();e==null||e({account:r.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:!!o,isConnecting:s==="connecting",isDisconnected:s==="disconnected",isReconnecting:s==="reconnecting",isLoading:s==="connecting"||s==="reconnecting",reconnect:l,status:s}},Fe=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCES",o],({queryKey:[,i]})=>F(i),{enabled:!!o})},Bt=(e,t)=>{let{data:o}=Fe(t);return(0,y.useQuery)(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(r=>r.denom===e),{enabled:!!o})},vt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_CONNECT",e,t,o],h,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))}),{data:i}=b();return{connect:r=>n.mutate(r),connectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},Rt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_DISCONNECT",e,t,o],k,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},_e=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),We.default),Gt=()=>_e(),Ut=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>_(o),{enabled:!!o})};var A=require("@tanstack/react-query");var qt=()=>c(e=>e.activeChain),Mt=e=>(0,A.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,s]})=>K(s)),Ot=(e,t="BOND_STATUS_BONDED")=>(0,A.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Kt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,A.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],I,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},Qt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,A.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],Q,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:r=>t==null?void 0:t(r),onSuccess:r=>Promise.resolve(o==null?void 0:o(r))}),{data:i}=b();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};var ce=require("@tanstack/react-query");var Pe=require("@tanstack/react-query");var Wt=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Pe.useQuery)(t,({queryKey:[,...s]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Ft=e=>{let t=c(n=>n.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?E(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},_t=e=>{let t=c(n=>n.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?w(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};var g=require("@tanstack/react-query");var Pt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:s}=d(),n=s==null?void 0:s.bech32Address,r=(0,g.useMutation)(["USE_SEND_TOKENS",e,t,o,n],a=>P({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendTokens:r.mutate,sendTokensAsync:r.mutateAsync,status:r.status}},Nt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:s}=d(),n=s==null?void 0:s.bech32Address,r=(0,g.useMutation)(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>N({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendIbcTokens:r.mutate,sendIbcTokensAsync:r.mutateAsync,status:r.status}},Ht=({codeId:e,onError:t,onLoading:o,onSuccess:s})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_INSTANTIATE_CONTRACT",t,o,s,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return H(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(s==null?void 0:s(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},Lt=({contractAddress:e,onError:t,onLoading:o,onSuccess:s})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_EXECUTE_CONTRACT",t,o,s,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return L(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(s==null?void 0:s(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},Vt=(e,t)=>(0,g.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:!!e&&!!t}),Yt=(e,t)=>(0,g.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:!!e&&!!t});var B=require("@tanstack/react-query");var ae=require("react");var Ne=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(S)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:s,_reconnectConnector:n}=c();return(0,ae.useEffect)(()=>{e&&t?l({onError:s}):!e&&o&&l({onError:s})},[]),(0,ae.useEffect)(()=>{if(n&&(n==="cosmostation"&&window.cosmostation.cosmos.on("accountChanged",()=>void l({onError:s})),n==="keplr"||n==="leap"))return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:s})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:s}))}},[n]),null},ue=()=>(Ne(),null);var v=require("react/jsx-runtime"),Jt=new B.QueryClient({}),$t=({children:e,grazOptions:t,...o})=>(t&&W(t),(0,v.jsxs)(B.QueryClientProvider,{client:Jt,...o,children:[(0,v.jsx)(ue,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getCosmostation,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as g}from"./chunk-V3YUCPIG.mjs";import{GasPrice as Ue}from"@cosmjs/stargate";import De from"zustand";import{persist as ke,subscribeWithSelector as Ie}from"zustand/middleware";var z=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(z||{}),K=["keplr","leap"];var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Te={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=De(Ie(ke(()=>w,Te)));import{SigningCosmWasmClient as _}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as Re}from"@cosmjs/tendermint-rpc";import{QueryClient as Be}from"@cosmjs/stargate";import{assert as W,isNonNullObject as O}from"@cosmjs/utils";var F=(...e)=>{let{tendermint:t}=c.getState().clients,n=new Be(t),r=e.map(o=>o(n));for(let o of r){W(O(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){W(O(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=n[i]||{};n[i]={...a,...s}}}return n};var A=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,o,i]=await Promise.all([_.connect(n),P.connect(n),Re.connect(e)]);return{cosmWasm:r,stargate:o,tendermint:i}},S=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[a,u]=await Promise.all([_.connectWithSigner(s,r,o),P.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var y=(e=c.getState().walletType)=>{try{return C(e),!0}catch(t){return console.error(t),!1}},ve=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ge=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},C=(e=c.getState().walletType)=>{switch(e){case"keplr":return ve();case"leap":return Ge();default:throw new Error("Unknown wallet type")}},qt=()=>Object.fromEntries(K.map(e=>[e,y(e)]));var f=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),o=(e==null?void 0:e.walletType)||r,i=C(o),s=(e==null?void 0:e.chain)||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(h=>{let je=h._reconnect||!!h._reconnectConnector||!!s;return h.activeChain&&h.activeChain.chainId!==s.chainId?{status:"connecting"}:je?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?Ue.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[Q,we,be]=await Promise.all([i.getKey(s.chainId),A(s),S({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Q,activeChain:s,clients:we,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:be,status:"connected",walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),typeof window<"u"&&window.sessionStorage.setItem(g,"Active"),Q}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},b=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(g),c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:n,_reconnect:r}=c.getState(),o=y(n||void 0);try{if(t&&o&&n)return await f({chain:t,walletType:n,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),b()}};var N=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},Ht=()=>c.getState().recentChain,j=async e=>(await C().experimentalSuggestChain(e),e),L=async({chainInfo:e,rpcHeaders:t,gas:n,path:r,...o})=>{let i=await j(e);return{account:await f({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:n,path:r},...o}),chain:i}};var V=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Y=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return n[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},J=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},$=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:o})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,n,r,o)},X=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,n,r,o,i,s,a,u)},Z=async({senderAddress:e,msg:t,fee:n,options:r,label:o,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,o,n,r)},ee=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:o,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,n,i,o)},te=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};import{Bech32Address as qe}from"@keplr-wallet/cosmos";var se={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Qe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ze={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ke={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},We={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},oe=[se,Me,Qe,ze,Ke,We],D={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:se,bip44:{coinType:118},bech32Config:qe.defaultBech32Config("axelar"),currencies:oe,feeCurrencies:oe};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var ie={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},re=[ie],k={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as Fe}from"@keplr-wallet/cosmos";var ae={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},_e={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Pe={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ne={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},He={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Le={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ve={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ye={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Je={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},$e={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Xe={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ce=[ae,_e,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe],I={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as Ze}from"@keplr-wallet/cosmos";var pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},et={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,et],T={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Ze.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as tt}from"@keplr-wallet/cosmos";var le={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[le],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:tt.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var ge={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},de=[ge],R={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:nt.defaultBech32Config("CRE"),currencies:de,feeCurrencies:de,stakeCurrency:ge,coinType:118};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var v={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},st=[v],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:ot.defaultBech32Config("juno"),currencies:st,feeCurrencies:[v],coinType:118};import{Bech32Address as rt}from"@keplr-wallet/cosmos";var U={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},it=[U],q={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:rt.defaultBech32Config("osmo"),currencies:it,feeCurrencies:[U],coinType:118};var ye=e=>e,bn=e=>e,jn=e=>e,Dn=ye({axelar:D,cosmoshub:k,juno:I,osmosis:T,sommelier:B}),kn=[D,k,I,T,B],In=ye({crescent:R,juno:G,osmosis:q}),Tn=[R,G,q];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as at}from"react";import ut from"zustand/shallow";import{useQuery as ct}from"@tanstack/react-query";var Un=()=>x("keplr"),x=e=>{let n=["USE_CHECK_WALLET",c(o=>e||o.walletType)];return ct(n,({queryKey:[,o]})=>y(o))};var d=({onConnect:e,onDisconnect:t}={})=>{let n=c(o=>o.account),r=c(o=>o.status);return at(()=>c.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:!!n,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},pt=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",n],({queryKey:[,i]})=>Y(i),{enabled:!!n})},_n=(e,t)=>{let{data:n}=pt(t);return M(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!n})},Pn=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=Ce(["USE_CONNECT",e,t,n],f,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=x();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status}},Nn=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=Ce(["USE_DISCONNECT",e,t,n],b,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},mt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ut),Hn=()=>mt(),Ln=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>J(n),{enabled:!!n})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Zn=()=>c(e=>e.activeChain),eo=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>H(r)),to=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"}),no=()=>({data:c(t=>t.recentChain),clear:N}),oo=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=fe(["USE_SUGGEST_CHAIN",e,t,n],j,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},so=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],L,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=x();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:!!i,status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as lt}from"@tanstack/react-query";var ao=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return lt(t,({queryKey:[,...r]})=>F(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var go=e=>{let t=c(o=>o.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?A(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({clients:o})}})},yo=e=>{let t=c(o=>o.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?S(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({signingClients:o})}})};import{useMutation as E,useQuery as Ae}from"@tanstack/react-query";var So=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=d(),o=r==null?void 0:r.bech32Address,s=E(["USE_SEND_TOKENS",e,t,n,o],a=>$({senderAddress:o,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Eo=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=d(),o=r==null?void 0:r.bech32Address,s=E(["USE_SEND_IBC_TOKENS",e,t,n,o],a=>X({senderAddress:o,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},wo=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=d(),i=o==null?void 0:o.bech32Address,u=E(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return Z(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:n,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},bo=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=d(),i=o==null?void 0:o.bech32Address,u=E(["USE_EXECUTE_CONTRACT",t,n,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return ee(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:n,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},jo=(e,t)=>Ae(["USE_QUERY_SMART",e,t],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:!!e&&!!t}),Do=(e,t)=>Ae(["USE_QUERY_RAW",t,e],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:!!e&&!!t});import{QueryClient as gt,QueryClientProvider as yt}from"@tanstack/react-query";import{useEffect as Se}from"react";var dt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(g)==="Active",{activeChain:t,_reconnect:n,_onReconnectFailed:r}=c.getState();return Se(()=>{e&&t?l({onError:r}):!e&&n&&l({onError:r})},[]),Se(()=>(window.addEventListener("keplr_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void l({onError:r}))}),[]),null},Ee=()=>(dt(),null);import{jsx as ft,jsxs as xt}from"react/jsx-runtime";var Ct=new gt({}),Mo=({children:e,grazOptions:t,...n})=>(t&&V(t),xt(yt,{client:Ct,...n,children:[ft(Ee,{}),e]}));export{Ee as GrazEvents,Mo as GrazProvider,K as WALLET_TYPES,z as WalletType,y as checkWallet,N as clearRecentChain,V as configureGraz,f as connect,A as createClients,F as createQueryClient,S as createSigningClients,bn as defineChain,jn as defineChainInfo,ye as defineChains,b as disconnect,ee as executeContract,H as getActiveChainCurrency,qt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,ve as getKeplr,Ge as getLeap,ne as getQueryRaw,te as getQuerySmart,Ht as getRecentChain,C as getWallet,Z as instantiateContract,Dn as mainnetChains,kn as mainnetChainsArray,l as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,In as testnetChains,Tn as testnetChainsArray,d as useAccount,Zn as useActiveChain,eo as useActiveChainCurrency,to as useActiveChainValidators,_n as useBalance,Ln as useBalanceStaked,pt as useBalances,Un as useCheckKeplr,x as useCheckWallet,go as useClients,Pn as useConnect,Nn as useDisconnect,bo as useExecuteContract,dt as useGrazEvents,wo as useInstantiateContract,mt as useOfflineSigners,ao as useQueryClient,Do as useQueryRaw,jo as useQuerySmart,no as useRecentChain,Eo as useSendIbcTokens,So as useSendTokens,Hn as useSigners,yo as useSigningClients,oo as useSuggestChain,so as useSuggestChainAndConnect};
1
+ import{a as g}from"./chunk-V3YUCPIG.mjs";import{GasPrice as qe}from"@cosmjs/stargate";import{create as De}from"zustand";import{persist as Te,subscribeWithSelector as ke}from"zustand/middleware";var Q=(r=>(r.KEPLR="keplr",r.LEAP="leap",r.COSMOSTATION="cosmostation",r))(Q||{}),z=["keplr","leap","cosmostation"];var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Ie={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=De(ke(Te(()=>w,Ie)));import{SigningCosmWasmClient as _}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as ve}from"@cosmjs/tendermint-rpc";import{QueryClient as Be}from"@cosmjs/stargate";import{assert as K,isNonNullObject as W}from"@cosmjs/utils";var F=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Be(t),r=e.map(n=>n(o));for(let n of r){K(W(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){K(W(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var h=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([_.connect(o),P.connect(o),ve.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},A=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([_.connectWithSigner(s,r,n),P.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var y=(e=c.getState().walletType)=>{try{return C(e),!0}catch(t){return console.error(t),!1}},Re=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ge=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},Ue=()=>{if(typeof window.cosmostation.providers.keplr<"u")return window.cosmostation.providers.keplr;throw c.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")},C=(e=c.getState().walletType)=>{switch(e){case"keplr":return Re();case"leap":return Ge();case"cosmostation":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(z.map(e=>[e,y(e)]));var f=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=C(n),s=(e==null?void 0:e.chain)||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(x=>{let je=x._reconnect||!!x._reconnectConnector||!!s;return x.activeChain&&x.activeChain.chainId!==s.chainId?{status:"connecting"}:je?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?qe.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[O,we,be]=await Promise.all([i.getKey(s.chainId),h(s),A({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:O,activeChain:s,clients:we,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:be,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(g,"Active"),O}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},b=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(g),c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=y(o||void 0);try{if(t&&n&&o)return await f({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),b()}};var N=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Lt=()=>c.getState().recentChain,j=async e=>(await C().experimentalSuggestChain(e),e),L=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await j(e);return{account:await f({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var V=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Y=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return o[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},J=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},$=async({senderAddress:e,recipientAddress:t,amount:o,fee:r,memo:n})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,o,r,n)},X=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},Z=async({senderAddress:e,msg:t,fee:o,options:r,label:n,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,n,o,r)},ee=async({senderAddress:e,msg:t,fee:o,contractAddress:r,funds:n,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,o,i,n)},te=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,r)};import{Bech32Address as Me}from"@keplr-wallet/cosmos";var se={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Oe={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Qe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ze={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ke={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},We={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},oe=[se,Oe,Qe,ze,Ke,We],D={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:se,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("axelar"),currencies:oe,feeCurrencies:oe};import{Bech32Address as Fe}from"@keplr-wallet/cosmos";var ie={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},re=[ie],T={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as _e}from"@keplr-wallet/cosmos";var ae={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Pe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ne={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},He={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Le={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ve={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ye={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Je={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},$e={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Xe={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ze={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ce=[ae,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe,Ze],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:_e.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as et}from"@keplr-wallet/cosmos";var pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},tt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,tt],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:et.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var le={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[le],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var ge={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},de=[ge],v={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:ot.defaultBech32Config("CRE"),currencies:de,feeCurrencies:de,stakeCurrency:ge,coinType:118};import{Bech32Address as st}from"@keplr-wallet/cosmos";var R={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},rt=[R],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:R,bip44:{coinType:118},bech32Config:st.defaultBech32Config("juno"),currencies:rt,feeCurrencies:[R],coinType:118};import{Bech32Address as it}from"@keplr-wallet/cosmos";var U={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},ct=[U],q={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:it.defaultBech32Config("osmo"),currencies:ct,feeCurrencies:[U],coinType:118};var ye=e=>e,jn=e=>e,Dn=e=>e,Tn=ye({axelar:D,cosmoshub:T,juno:k,osmosis:I,sommelier:B}),kn=[D,T,k,I,B],In=ye({crescent:v,juno:G,osmosis:q}),Bn=[v,G,q];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as ut}from"react";import pt from"zustand/shallow";import{useQuery as at}from"@tanstack/react-query";var S=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return at(o,({queryKey:[,n]})=>y(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return ut(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},mt=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",o],({queryKey:[,i]})=>Y(i),{enabled:!!o})},_n=(e,t)=>{let{data:o}=mt(t);return M(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Pn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_CONNECT",e,t,o],f,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=S();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_DISCONNECT",e,t,o],b,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},lt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),pt),Hn=()=>lt(),Ln=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>J(o),{enabled:!!o})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Zn=()=>c(e=>e.activeChain),eo=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>H(r)),to=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),no=()=>({data:c(t=>t.recentChain),clear:N}),oo=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN",e,t,o],j,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],L,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=S();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as dt}from"@tanstack/react-query";var ao=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return dt(t,({queryKey:[,...r]})=>F(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var go=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?h(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},yo=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?A(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as E,useQuery as Ae}from"@tanstack/react-query";var So=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_TOKENS",e,t,o,n],a=>$({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>X({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},wo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return Z(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},bo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return ee(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},jo=(e,t)=>Ae(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:!!e&&!!t}),Do=(e,t)=>Ae(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:!!e&&!!t});import{QueryClient as yt,QueryClientProvider as Ct}from"@tanstack/react-query";import{useEffect as Se}from"react";var gt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(g)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return Se(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),Se(()=>{if(n&&(n==="cosmostation"&&window.cosmostation.cosmos.on("accountChanged",()=>void l({onError:r})),n==="keplr"||n==="leap"))return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},Ee=()=>(gt(),null);import{jsx as xt,jsxs as ht}from"react/jsx-runtime";var ft=new yt({}),Mo=({children:e,grazOptions:t,...o})=>(t&&V(t),ht(Ct,{client:ft,...o,children:[xt(Ee,{}),e]}));export{Ee as GrazEvents,Mo as GrazProvider,z as WALLET_TYPES,Q as WalletType,y as checkWallet,N as clearRecentChain,V as configureGraz,f as connect,h as createClients,F as createQueryClient,A as createSigningClients,jn as defineChain,Dn as defineChainInfo,ye as defineChains,b as disconnect,ee as executeContract,H as getActiveChainCurrency,Mt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,Ue as getCosmostation,Re as getKeplr,Ge as getLeap,ne as getQueryRaw,te as getQuerySmart,Lt as getRecentChain,C as getWallet,Z as instantiateContract,Tn as mainnetChains,kn as mainnetChainsArray,l as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,In as testnetChains,Bn as testnetChainsArray,d as useAccount,Zn as useActiveChain,eo as useActiveChainCurrency,to as useActiveChainValidators,_n as useBalance,Ln as useBalanceStaked,mt as useBalances,S as useCheckWallet,go as useClients,Pn as useConnect,Nn as useDisconnect,bo as useExecuteContract,gt as useGrazEvents,wo as useInstantiateContract,lt as useOfflineSigners,ao as useQueryClient,Do as useQueryRaw,jo as useQuerySmart,no as useRecentChain,Eo as useSendIbcTokens,So as useSendTokens,Hn as useSigners,yo as useSigningClients,oo as useSuggestChain,so as useSuggestChainAndConnect};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graz",
3
3
  "description": "React hooks for Cosmos",
4
- "version": "0.0.38",
4
+ "version": "0.0.40",
5
5
  "author": "Griko Nibras <griko@strangelove.ventures>",
6
6
  "repository": "https://github.com/strangelove-ventures/graz.git",
7
7
  "homepage": "https://github.com/strangelove-ventures/graz",