graz 0.0.23 → 0.0.24

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
@@ -13,7 +13,6 @@ import { QueryValidatorsResponse } from 'cosmjs-types/cosmos/staking/v1beta1/que
13
13
 
14
14
  declare type Dictionary<T = string> = Record<string, T>;
15
15
  declare type Maybe<T> = T | undefined;
16
- declare type WalletType = "keplr";
17
16
 
18
17
  interface ChainInfoWithPath extends ChainInfo {
19
18
  path: string;
@@ -145,6 +144,12 @@ declare const testnetChains: {
145
144
  */
146
145
  declare const testnetChainsArray: ChainInfo[];
147
146
 
147
+ declare enum WalletType {
148
+ KEPLR = "keplr",
149
+ LEAP = "leap"
150
+ }
151
+ declare const WALLET_TYPES: WalletType[];
152
+
148
153
  declare type ConnectArgs = Maybe<GrazChain & {
149
154
  signerOpts?: SigningCosmWasmClientOptions;
150
155
  walletType?: WalletType;
@@ -269,6 +274,21 @@ declare function checkWallet(type?: WalletType): boolean;
269
274
  * @see https://docs.keplr.app
270
275
  */
271
276
  declare function getKeplr(): Keplr;
277
+ /**
278
+ * Function to return Leap object (which is {@link Keplr}) and throws and error if it does not exist on `window`.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * try {
283
+ * const leap = getLeap();
284
+ * } catch (error: Error) {
285
+ * console.error(error.message);
286
+ * }
287
+ * ```
288
+ *
289
+ * @see https://docs.keplr.app
290
+ */
291
+ declare function getLeap(): Keplr;
272
292
  /**
273
293
  * Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
274
294
  * exist on `window` or unknown wallet type.
@@ -282,6 +302,7 @@ declare function getKeplr(): Keplr;
282
302
  * @see {@link getKeplr}
283
303
  */
284
304
  declare function getWallet(type?: WalletType): Keplr;
305
+ declare function getAvailableWallets(): Record<WalletType, boolean>;
285
306
 
286
307
  interface GrazAdapter {
287
308
  name: string;
@@ -796,4 +817,4 @@ declare function useGrazEvents(): null;
796
817
  */
797
818
  declare function GrazEvents(): null;
798
819
 
799
- export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, Dictionary, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, Maybe, SendIbcTokensArgs, SendTokensArgs, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, getActiveChainCurrency, getBalances, getKeplr, getRecentChain, getStakedBalances, getWallet, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useGrazEvents, useOfflineSigners, useQueryClient, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useStakedBalances, useSuggestChain, useSuggestChainAndConnect };
820
+ export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, Dictionary, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, Maybe, SendIbcTokensArgs, SendTokensArgs, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, getActiveChainCurrency, getAvailableWallets, getBalances, getKeplr, getLeap, getRecentChain, getStakedBalances, getWallet, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useGrazEvents, useOfflineSigners, useQueryClient, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useStakedBalances, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var ot=Object.create;var I=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var ut=(e,t)=>()=>(e&&(t=e(e=0)),t);var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),at=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of st(t))!ct.call(e,o)&&o!==n&&I(e,o,{get:()=>t[o],enumerable:!(c=rt(t,o))||c.enumerable});return e};var B=(e,t,n)=>(n=e!=null?ot(it(e)):{},me(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e)),pt=e=>me(I({},"__esModule",{value:!0}),e);var a,r=ut(()=>{"use strict";a=B(require("react"))});var fe=w(C=>{"use strict";r();Object.defineProperty(C,"__esModule",{value:!0});C.arrayContentStartsWith=C.arrayContentEquals=void 0;function lt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}C.arrayContentEquals=lt;function ft(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}C.arrayContentStartsWith=ft});var ye=w(f=>{"use strict";r();Object.defineProperty(f,"__esModule",{value:!0});f.assertDefinedAndNotNull=f.assertDefined=f.assert=void 0;function yt(e,t){if(!e)throw new Error(t||"condition is not truthy")}f.assert=yt;function dt(e,t){if(e===void 0)throw new Error(t??"value is undefined")}f.assertDefined=dt;function gt(e,t){if(e==null)throw new Error(t??"value is undefined or null")}f.assertDefinedAndNotNull=gt});var de=w(G=>{"use strict";r();Object.defineProperty(G,"__esModule",{value:!0});G.sleep=void 0;async function Ct(e){return new Promise(t=>setTimeout(t,e))}G.sleep=Ct});var Ce=w(h=>{"use strict";r();Object.defineProperty(h,"__esModule",{value:!0});h.isUint8Array=h.isNonNullObject=void 0;function ge(e){return typeof e=="object"&&e!==null}h.isNonNullObject=ge;function ht(e){return!(!ge(e)||Object.prototype.toString.call(e)!=="[object Uint8Array]"||typeof Buffer<"u"&&typeof Buffer.isBuffer<"u"&&Buffer.isBuffer(e))}h.isUint8Array=ht});var Se=w(m=>{"use strict";r();Object.defineProperty(m,"__esModule",{value:!0});m.isUint8Array=m.isNonNullObject=m.sleep=m.assertDefinedAndNotNull=m.assertDefined=m.assert=m.arrayContentStartsWith=m.arrayContentEquals=void 0;var he=fe();Object.defineProperty(m,"arrayContentEquals",{enumerable:!0,get:function(){return he.arrayContentEquals}});Object.defineProperty(m,"arrayContentStartsWith",{enumerable:!0,get:function(){return he.arrayContentStartsWith}});var z=ye();Object.defineProperty(m,"assert",{enumerable:!0,get:function(){return z.assert}});Object.defineProperty(m,"assertDefined",{enumerable:!0,get:function(){return z.assertDefined}});Object.defineProperty(m,"assertDefinedAndNotNull",{enumerable:!0,get:function(){return z.assertDefinedAndNotNull}});var xt=de();Object.defineProperty(m,"sleep",{enumerable:!0,get:function(){return xt.sleep}});var xe=Ce();Object.defineProperty(m,"isNonNullObject",{enumerable:!0,get:function(){return xe.isNonNullObject}});Object.defineProperty(m,"isUint8Array",{enumerable:!0,get:function(){return xe.isUint8Array}})});var ln={};at(ln,{GrazEvents:()=>ue,GrazProvider:()=>mn,checkWallet:()=>K,clearRecentChain:()=>F,configureGraz:()=>H,connect:()=>A,createClients:()=>D,createQueryClient:()=>N,createSigningClients:()=>k,defineChain:()=>Mt,defineChainInfo:()=>Kt,defineChains:()=>Pt,disconnect:()=>W,getActiveChainCurrency:()=>R,getBalances:()=>L,getKeplr:()=>Ee,getRecentChain:()=>St,getStakedBalances:()=>V,getWallet:()=>S,mainnetChains:()=>Wt,mainnetChainsArray:()=>Ft,reconnect:()=>d,sendIbcTokens:()=>$,sendTokens:()=>J,suggestChain:()=>T,suggestChainAndConnect:()=>_,testnetChains:()=>Rt,testnetChainsArray:()=>_t,useAccount:()=>E,useActiveChain:()=>Yt,useActiveChainCurrency:()=>Zt,useActiveChainValidators:()=>en,useBalance:()=>Lt,useBalances:()=>Ve,useCheckKeplr:()=>Ht,useCheckWallet:()=>b,useClients:()=>sn,useConnect:()=>Vt,useDisconnect:()=>Jt,useGrazEvents:()=>Ye,useOfflineSigners:()=>Je,useQueryClient:()=>rn,useRecentChain:()=>tn,useSendIbcTokens:()=>an,useSendTokens:()=>un,useSigners:()=>$t,useSigningClients:()=>cn,useStakedBalances:()=>Xt,useSuggestChain:()=>nn,useSuggestChainAndConnect:()=>on});module.exports=pt(ln);r();r();var je=require("@cosmjs/stargate");r();var le=B(require("zustand")),v=require("zustand/middleware"),O={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,_reconnect:!1},mt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},u=(0,le.default)((0,v.subscribeWithSelector)((0,v.persist)(()=>O,mt)));r();var P=require("@cosmjs/cosmwasm-stargate"),M=require("@cosmjs/stargate"),be=require("@cosmjs/tendermint-rpc");r();var Ae=require("@cosmjs/stargate"),x=B(Se());function N(...e){let{tendermint:t}=u.getState().clients,n=new Ae.QueryClient(t),c=e.map(o=>o(n));for(let o of c){(0,x.assert)((0,x.isNonNullObject)(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){(0,x.assert)((0,x.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let p=n[i]||{};n[i]={...p,...s}}}return n}async function D({rpc:e,rpcHeaders:t}){let n={url:e,headers:{...t||{}}},[c,o,i]=await Promise.all([P.SigningCosmWasmClient.connect(n),M.SigningStargateClient.connect(n),be.Tendermint34Client.connect(e)]);return{cosmWasm:c,stargate:o,tendermint:i}}async function k(e){let{rpc:t,rpcHeaders:n,offlineSignerAuto:c,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[p,l]=await Promise.all([P.SigningCosmWasmClient.connectWithSigner(s,c,o),M.SigningStargateClient.connectWithSigner(s,c,i)]);return{cosmWasm:p,stargate:l}}r();function K(e=u.getState().walletType){try{return S(e),!0}catch(t){return console.error(t),!1}}function Ee(){if(typeof window.keplr<"u")return window.keplr;throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")}function S(e=u.getState().walletType){switch(e){case"keplr":return Ee();default:throw new Error("Unknown wallet type")}}async function A(e){try{let{defaultChain:t,recentChain:n,walletType:c}=u.getState(),o=(e==null?void 0:e.walletType)||c,i=S(o),s=e||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");u.setState(Q=>{let nt=Q._reconnect;return Q.activeChain&&Q.activeChain.chainId!==s.chainId?{status:"connecting"}:nt?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let p=i.getOfflineSigner(s.chainId),l=i.getOfflineSignerOnlyAmino(s.chainId),y=await i.getOfflineSignerAuto(s.chainId),Ze=s.gas?je.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[pe,et,tt]=await Promise.all([i.getKey(s.chainId),D(s),k({...s,offlineSignerAuto:y,cosmWasmSignerOptions:{gasPrice:Ze,...(e==null?void 0:e.signerOpts)||{}}})]);return u.setState({account:pe,activeChain:s,clients:et,offlineSigner:p,offlineSignerAmino:l,offlineSignerAuto:y,recentChain:s,signingClients:tt,status:"connected",walletType:o,_reconnect:!0}),pe}catch(t){throw u.getState().account===null&&u.setState({status:"disconnected"}),t}}async function W(e=!1){return u.setState(t=>({...O,recentChain:e?null:t.recentChain})),Promise.resolve()}function d(){let{activeChain:e}=u.getState();e&&A(e)}r();function F(){u.setState({recentChain:null})}function R(e){let{activeChain:t}=u.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)}function St(){return u.getState().recentChain}async function T(e){return await S().experimentalSuggestChain(e),e}async function _(e){let t=await T(e);return{account:await A(e),chain:t}}r();function H(e={}){return u.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}r();async function L(e){let{activeChain:t,signingClients:n}=u.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:c}=u.getState();return await Promise.all(t.currencies.map(async i=>n[c].getBalance(e,i.coinMinimalDenom)))}async function V(e){let{clients:t}=u.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)}async function J({senderAddress:e,recipientAddress:t,amount:n,fee:c,memo:o}){let{signingClients:i,defaultSigningClient:s}=u.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,c,o)}async function $({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:c,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:p,memo:l}){let{signingClients:y}=u.getState();if(!(y!=null&&y.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return y.stargate.sendIbcTokens(e,t,n,c,o,i,s,p,l)}r();r();var De=require("@keplr-wallet/cosmos"),ke={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},At={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},bt={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Et={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},jt={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},wt={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},we=[ke,At,bt,Et,jt,wt],X={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:ke,bip44:{coinType:118},bech32Config:De.Bech32Address.defaultBech32Config("axelar"),currencies:we,feeCurrencies:we};r();var Be=require("@keplr-wallet/cosmos"),ve={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ie=[ve],q={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ve,bip44:{coinType:118},bech32Config:Be.Bech32Address.defaultBech32Config("cosmos"),currencies:Ie,feeCurrencies:Ie};r();var Te=require("@keplr-wallet/cosmos"),qe={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Dt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},kt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},It={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Bt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},vt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Gt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Tt={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},qt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Ut={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Qt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},Ge=[qe,Dt,kt,It,Bt,vt,Gt,Tt,qt,Ut,Qt],Y={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:qe,bip44:{coinType:118},bech32Config:Te.Bech32Address.defaultBech32Config("juno"),currencies:Ge,feeCurrencies:Ge};r();var Qe=require("@keplr-wallet/cosmos"),Oe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ot={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Ue=[Oe,Ot],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Oe,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Ue,feeCurrencies:Ue};r();var Ne=require("@keplr-wallet/cosmos"),Pe={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ze=[Pe],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Pe,bip44:{coinType:118},bech32Config:Ne.Bech32Address.defaultBech32Config("somm"),currencies:ze,feeCurrencies:ze};r();var Ke=require("@keplr-wallet/cosmos"),We={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Me=[We],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:Ke.Bech32Address.defaultBech32Config("CRE"),currencies:Me,feeCurrencies:Me,stakeCurrency:We,coinType:118};r();var Fe=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"},zt=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:Fe.Bech32Address.defaultBech32Config("juno"),currencies:zt,feeCurrencies:[ne],coinType:118};r();var Re=require("@keplr-wallet/cosmos"),re={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Nt=[re],se={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:re,bip44:{coinType:118},bech32Config:Re.Bech32Address.defaultBech32Config("osmo"),currencies:Nt,feeCurrencies:[re],coinType:118};function Pt(e){return e}function Mt(e){return e}function Kt(e){return e}var Wt={axelar:X,cosmos:q,cosmoshub:q,juno:Y,osmosis:Z,sommelier:ee},Ft=[X,q,Y,Z,ee],Rt={crescent:te,juno:oe,osmosis:se},_t=[te,oe,se];r();var g=require("@tanstack/react-query"),He=require("react"),Le=B(require("zustand/shallow"));r();var _e=require("@tanstack/react-query");function Ht(){return b("keplr")}function b(e){let t=u(o=>e||o.walletType);return(0,_e.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>K(o))}function E({onConnect:e,onDisconnect:t}={}){let n=u(o=>o.account),c=u(o=>o.status);return(0,He.useEffect)(()=>u.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=u.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:c==="connecting",isDisconnected:c==="disconnected",isReconnecting:c==="reconnecting",reconnect:d,status:c}}function Ve(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return(0,g.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>L(i),{enabled:Boolean(n)})}function Lt(e,t){let{data:n}=Ve(t);return(0,g.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})}function Vt({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,g.useMutation)(["USE_CONNECT",e,t,n],A,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}}function Jt({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,g.useMutation)(["USE_DISCONNECT",e,t,n],W,{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}}function Je(){return u(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Le.default)}function $t(){return Je()}function Xt(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return(0,g.useQuery)(["USE_STAKED_BALANCES",n],({queryKey:[,i]})=>V(n),{enabled:Boolean(n)})}r();var j=require("@tanstack/react-query");function Yt(){return u(e=>e.activeChain)}function Zt(e){return(0,j.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,c]})=>R(c))}function en(e,t="BOND_STATUS_BONDED"){return(0,j.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"})}function tn(){return{data:u(t=>t.recentChain),clear:F}}function nn({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,j.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}}function on({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,j.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],_,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}}r();var ie=require("@tanstack/react-query");r();var $e=require("@tanstack/react-query");function rn(...e){let t=["USE_QUERY_CLIENT",...e];return(0,$e.useQuery)(t,({queryKey:[,...c]})=>N(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})}function sn(e){let t=u(o=>o.clients);return(0,ie.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?D(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}function cn(e){let t=u(o=>o.signingClients);return(0,ie.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?k(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}r();var ce=require("@tanstack/react-query");function un({onError:e,onLoading:t,onSuccess:n}={}){let{data:c}=E(),o=c==null?void 0:c.bech32Address,s=(0,ce.useMutation)(["USE_SEND_TOKENS",e,t,n,o],p=>J({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}}function an({onError:e,onLoading:t,onSuccess:n}={}){let{data:c}=E(),o=c==null?void 0:c.bech32Address,s=(0,ce.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,o],p=>$({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}}r();var U=require("@tanstack/react-query");r();var Xe=require("react");function Ye(){return(0,Xe.useEffect)(()=>{let{_reconnect:e}=u.getState();return e&&d(),window.addEventListener("keplr_keystorechange",d),()=>{window.removeEventListener("keplr_keystorechange",d)}},[]),null}function ue(){return Ye(),null}var ae=require("react/jsx-runtime"),pn=new U.QueryClient({});function mn({children:e,grazOptions:t,...n}){return t&&H(t),(0,ae.jsxs)(U.QueryClientProvider,{client:pn,...n,children:[(0,ae.jsx)(ue,{}),e]})}0&&(module.exports={GrazEvents,GrazProvider,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,getActiveChainCurrency,getBalances,getKeplr,getRecentChain,getStakedBalances,getWallet,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useGrazEvents,useOfflineSigners,useQueryClient,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useStakedBalances,useSuggestChain,useSuggestChainAndConnect});
1
+ "use strict";var it=Object.create;var I=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var mt=(e,t)=>()=>(e&&(t=e(e=0)),t);var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lt=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},fe=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ut(t))!pt.call(e,o)&&o!==n&&I(e,o,{get:()=>t[o],enumerable:!(c=ct(t,o))||c.enumerable});return e};var B=(e,t,n)=>(n=e!=null?it(at(e)):{},fe(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e)),ft=e=>fe(I({},"__esModule",{value:!0}),e);var a,r=mt(()=>{"use strict";a=B(require("react"))});var de=w(C=>{"use strict";r();Object.defineProperty(C,"__esModule",{value:!0});C.arrayContentStartsWith=C.arrayContentEquals=void 0;function dt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}C.arrayContentEquals=dt;function gt(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}C.arrayContentStartsWith=gt});var ge=w(f=>{"use strict";r();Object.defineProperty(f,"__esModule",{value:!0});f.assertDefinedAndNotNull=f.assertDefined=f.assert=void 0;function Ct(e,t){if(!e)throw new Error(t||"condition is not truthy")}f.assert=Ct;function ht(e,t){if(e===void 0)throw new Error(t??"value is undefined")}f.assertDefined=ht;function xt(e,t){if(e==null)throw new Error(t??"value is undefined or null")}f.assertDefinedAndNotNull=xt});var Ce=w(v=>{"use strict";r();Object.defineProperty(v,"__esModule",{value:!0});v.sleep=void 0;async function St(e){return new Promise(t=>setTimeout(t,e))}v.sleep=St});var xe=w(h=>{"use strict";r();Object.defineProperty(h,"__esModule",{value:!0});h.isUint8Array=h.isNonNullObject=void 0;function he(e){return typeof e=="object"&&e!==null}h.isNonNullObject=he;function At(e){return!(!he(e)||Object.prototype.toString.call(e)!=="[object Uint8Array]"||typeof Buffer<"u"&&typeof Buffer.isBuffer<"u"&&Buffer.isBuffer(e))}h.isUint8Array=At});var be=w(m=>{"use strict";r();Object.defineProperty(m,"__esModule",{value:!0});m.isUint8Array=m.isNonNullObject=m.sleep=m.assertDefinedAndNotNull=m.assertDefined=m.assert=m.arrayContentStartsWith=m.arrayContentEquals=void 0;var Se=de();Object.defineProperty(m,"arrayContentEquals",{enumerable:!0,get:function(){return Se.arrayContentEquals}});Object.defineProperty(m,"arrayContentStartsWith",{enumerable:!0,get:function(){return Se.arrayContentStartsWith}});var K=ge();Object.defineProperty(m,"assert",{enumerable:!0,get:function(){return K.assert}});Object.defineProperty(m,"assertDefined",{enumerable:!0,get:function(){return K.assertDefined}});Object.defineProperty(m,"assertDefinedAndNotNull",{enumerable:!0,get:function(){return K.assertDefinedAndNotNull}});var bt=Ce();Object.defineProperty(m,"sleep",{enumerable:!0,get:function(){return bt.sleep}});var Ae=xe();Object.defineProperty(m,"isNonNullObject",{enumerable:!0,get:function(){return Ae.isNonNullObject}});Object.defineProperty(m,"isUint8Array",{enumerable:!0,get:function(){return Ae.isUint8Array}})});var gn={};lt(gn,{GrazEvents:()=>pe,GrazProvider:()=>dn,WALLET_TYPES:()=>P,WalletType:()=>z,checkWallet:()=>G,clearRecentChain:()=>_,configureGraz:()=>V,connect:()=>A,createClients:()=>D,createQueryClient:()=>W,createSigningClients:()=>k,defineChain:()=>Ft,defineChainInfo:()=>_t,defineChains:()=>Rt,disconnect:()=>F,getActiveChainCurrency:()=>H,getAvailableWallets:()=>Et,getBalances:()=>J,getKeplr:()=>we,getLeap:()=>De,getRecentChain:()=>jt,getStakedBalances:()=>Y,getWallet:()=>S,mainnetChains:()=>Ht,mainnetChainsArray:()=>Lt,reconnect:()=>d,sendIbcTokens:()=>X,sendTokens:()=>$,suggestChain:()=>q,suggestChainAndConnect:()=>L,testnetChains:()=>Vt,testnetChainsArray:()=>Jt,useAccount:()=>E,useActiveChain:()=>nn,useActiveChainCurrency:()=>on,useActiveChainValidators:()=>rn,useBalance:()=>$t,useBalances:()=>$e,useCheckKeplr:()=>Yt,useCheckWallet:()=>b,useClients:()=>pn,useConnect:()=>Xt,useDisconnect:()=>Zt,useGrazEvents:()=>tt,useOfflineSigners:()=>Xe,useQueryClient:()=>an,useRecentChain:()=>sn,useSendIbcTokens:()=>fn,useSendTokens:()=>ln,useSigners:()=>en,useSigningClients:()=>mn,useStakedBalances:()=>tn,useSuggestChain:()=>cn,useSuggestChainAndConnect:()=>un});module.exports=ft(gn);r();r();var ke=require("@cosmjs/stargate");r();var ye=B(require("zustand")),T=require("zustand/middleware");r();var z=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(z||{}),P=["keplr","leap"];var N={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,_reconnect:!1},yt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},u=(0,ye.default)((0,T.subscribeWithSelector)((0,T.persist)(()=>N,yt)));r();var M=require("@cosmjs/cosmwasm-stargate"),R=require("@cosmjs/stargate"),je=require("@cosmjs/tendermint-rpc");r();var Ee=require("@cosmjs/stargate"),x=B(be());function W(...e){let{tendermint:t}=u.getState().clients,n=new Ee.QueryClient(t),c=e.map(o=>o(n));for(let o of c){(0,x.assert)((0,x.isNonNullObject)(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){(0,x.assert)((0,x.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let p=n[i]||{};n[i]={...p,...s}}}return n}async function D({rpc:e,rpcHeaders:t}){let n={url:e,headers:{...t||{}}},[c,o,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),R.SigningStargateClient.connect(n),je.Tendermint34Client.connect(e)]);return{cosmWasm:c,stargate:o,tendermint:i}}async function k(e){let{rpc:t,rpcHeaders:n,offlineSignerAuto:c,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[p,l]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,c,o),R.SigningStargateClient.connectWithSigner(s,c,i)]);return{cosmWasm:p,stargate:l}}r();function G(e=u.getState().walletType){try{return S(e),!0}catch(t){return console.error(t),!1}}function we(){if(typeof window.keplr<"u")return window.keplr;throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")}function De(){if(typeof window.leap<"u")return window.leap;throw u.getState()._notFoundFn(),new Error("window.leap is not defined")}function S(e=u.getState().walletType){switch(e){case"keplr":return we();case"leap":return De();default:throw new Error("Unknown wallet type")}}function Et(){return Object.fromEntries(P.map(e=>[e,G(e)]))}async function A(e){try{let{defaultChain:t,recentChain:n,walletType:c}=u.getState(),o=(e==null?void 0:e.walletType)||c,i=S(o),s=e||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");u.setState(O=>{let st=O._reconnect;return O.activeChain&&O.activeChain.chainId!==s.chainId?{status:"connecting"}:st?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let p=i.getOfflineSigner(s.chainId),l=i.getOfflineSignerOnlyAmino(s.chainId),y=await i.getOfflineSignerAuto(s.chainId),nt=s.gas?ke.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[le,ot,rt]=await Promise.all([i.getKey(s.chainId),D(s),k({...s,offlineSignerAuto:y,cosmWasmSignerOptions:{gasPrice:nt,...(e==null?void 0:e.signerOpts)||{}}})]);return u.setState({account:le,activeChain:s,clients:ot,offlineSigner:p,offlineSignerAmino:l,offlineSignerAuto:y,recentChain:s,signingClients:rt,status:"connected",walletType:o,_reconnect:!0}),le}catch(t){throw u.getState().account===null&&u.setState({status:"disconnected"}),t}}async function F(e=!1){return u.setState(t=>({...N,recentChain:e?null:t.recentChain})),Promise.resolve()}function d(){let{activeChain:e}=u.getState();e&&A(e)}r();function _(){u.setState({recentChain:null})}function H(e){let{activeChain:t}=u.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)}function jt(){return u.getState().recentChain}async function q(e){return await S().experimentalSuggestChain(e),e}async function L(e){let t=await q(e);return{account:await A(e),chain:t}}r();function V(e={}){return u.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}r();async function J(e){let{activeChain:t,signingClients:n}=u.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:c}=u.getState();return await Promise.all(t.currencies.map(async i=>n[c].getBalance(e,i.coinMinimalDenom)))}async function Y(e){let{clients:t}=u.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)}async function $({senderAddress:e,recipientAddress:t,amount:n,fee:c,memo:o}){let{signingClients:i,defaultSigningClient:s}=u.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,c,o)}async function X({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:c,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:p,memo:l}){let{signingClients:y}=u.getState();if(!(y!=null&&y.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return y.stargate.sendIbcTokens(e,t,n,c,o,i,s,p,l)}r();r();var Be=require("@keplr-wallet/cosmos"),Te={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},wt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Dt={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},kt={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},It={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Bt={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Ie=[Te,wt,Dt,kt,It,Bt],Z={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Te,bip44:{coinType:118},bech32Config:Be.Bech32Address.defaultBech32Config("axelar"),currencies:Ie,feeCurrencies:Ie};r();var Ge=require("@keplr-wallet/cosmos"),qe={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ve=[qe],U={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:qe,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("cosmos"),currencies:ve,feeCurrencies:ve};r();var Qe=require("@keplr-wallet/cosmos"),Oe={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Tt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},vt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Gt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},qt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ut={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Qt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ot={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},zt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Pt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Nt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},Ue=[Oe,Tt,vt,Gt,qt,Ut,Qt,Ot,zt,Pt,Nt],ee={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Oe,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("juno"),currencies:Ue,feeCurrencies:Ue};r();var Pe=require("@keplr-wallet/cosmos"),Ne={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Kt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ze=[Ne,Kt],te={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Ne,bip44:{coinType:118},bech32Config:Pe.Bech32Address.defaultBech32Config("osmo"),currencies:ze,feeCurrencies:ze};r();var We=require("@keplr-wallet/cosmos"),Me={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Ke=[Me],ne={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Me,bip44:{coinType:118},bech32Config:We.Bech32Address.defaultBech32Config("somm"),currencies:Ke,feeCurrencies:Ke};r();var Fe=require("@keplr-wallet/cosmos"),_e={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Re=[_e],oe={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:Fe.Bech32Address.defaultBech32Config("CRE"),currencies:Re,feeCurrencies:Re,stakeCurrency:_e,coinType:118};r();var He=require("@keplr-wallet/cosmos"),re={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Wt=[re],se={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:re,bip44:{coinType:118},bech32Config:He.Bech32Address.defaultBech32Config("juno"),currencies:Wt,feeCurrencies:[re],coinType:118};r();var Le=require("@keplr-wallet/cosmos"),ie={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Mt=[ie],ce={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:ie,bip44:{coinType:118},bech32Config:Le.Bech32Address.defaultBech32Config("osmo"),currencies:Mt,feeCurrencies:[ie],coinType:118};function Rt(e){return e}function Ft(e){return e}function _t(e){return e}var Ht={axelar:Z,cosmos:U,cosmoshub:U,juno:ee,osmosis:te,sommelier:ne},Lt=[Z,U,ee,te,ne],Vt={crescent:oe,juno:se,osmosis:ce},Jt=[oe,se,ce];r();var g=require("@tanstack/react-query"),Je=require("react"),Ye=B(require("zustand/shallow"));r();var Ve=require("@tanstack/react-query");function Yt(){return b("keplr")}function b(e){let t=u(o=>e||o.walletType);return(0,Ve.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>G(o))}function E({onConnect:e,onDisconnect:t}={}){let n=u(o=>o.account),c=u(o=>o.status);return(0,Je.useEffect)(()=>u.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=u.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:c==="connecting",isDisconnected:c==="disconnected",isReconnecting:c==="reconnecting",reconnect:d,status:c}}function $e(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return(0,g.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>J(i),{enabled:Boolean(n)})}function $t(e,t){let{data:n}=$e(t);return(0,g.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})}function Xt({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,g.useMutation)(["USE_CONNECT",e,t,n],A,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}}function Zt({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,g.useMutation)(["USE_DISCONNECT",e,t,n],F,{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}}function Xe(){return u(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ye.default)}function en(){return Xe()}function tn(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return(0,g.useQuery)(["USE_STAKED_BALANCES",n],({queryKey:[,i]})=>Y(n),{enabled:Boolean(n)})}r();var j=require("@tanstack/react-query");function nn(){return u(e=>e.activeChain)}function on(e){return(0,j.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,c]})=>H(c))}function rn(e,t="BOND_STATUS_BONDED"){return(0,j.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"})}function sn(){return{data:u(t=>t.recentChain),clear:_}}function cn({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,j.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],q,{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}}function un({onError:e,onLoading:t,onSuccess:n}={}){let o=(0,j.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],L,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}}r();var ue=require("@tanstack/react-query");r();var Ze=require("@tanstack/react-query");function an(...e){let t=["USE_QUERY_CLIENT",...e];return(0,Ze.useQuery)(t,({queryKey:[,...c]})=>W(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})}function pn(e){let t=u(o=>o.clients);return(0,ue.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?D(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}function mn(e){let t=u(o=>o.signingClients);return(0,ue.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?k(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}r();var ae=require("@tanstack/react-query");function ln({onError:e,onLoading:t,onSuccess:n}={}){let{data:c}=E(),o=c==null?void 0:c.bech32Address,s=(0,ae.useMutation)(["USE_SEND_TOKENS",e,t,n,o],p=>$({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}}function fn({onError:e,onLoading:t,onSuccess:n}={}){let{data:c}=E(),o=c==null?void 0:c.bech32Address,s=(0,ae.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,o],p=>X({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}}r();var Q=require("@tanstack/react-query");r();var et=require("react");function tt(){return(0,et.useEffect)(()=>{let{_reconnect:e}=u.getState();return e&&d(),window.addEventListener("keplr_keystorechange",d),()=>{window.removeEventListener("keplr_keystorechange",d)}},[]),null}function pe(){return tt(),null}var me=require("react/jsx-runtime"),yn=new Q.QueryClient({});function dn({children:e,grazOptions:t,...n}){return t&&V(t),(0,me.jsxs)(Q.QueryClientProvider,{client:yn,...n,children:[(0,me.jsx)(pe,{}),e]})}0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,getActiveChainCurrency,getAvailableWallets,getBalances,getKeplr,getLeap,getRecentChain,getStakedBalances,getWallet,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useGrazEvents,useOfflineSigners,useQueryClient,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useStakedBalances,useSuggestChain,useSuggestChainAndConnect});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as x,b as Te,c as r}from"./chunk-6M3A6KFX.mjs";var F=x(d=>{"use strict";r();Object.defineProperty(d,"__esModule",{value:!0});d.arrayContentStartsWith=d.arrayContentEquals=void 0;function ze(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}d.arrayContentEquals=ze;function Ne(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}d.arrayContentStartsWith=Ne});var _=x(f=>{"use strict";r();Object.defineProperty(f,"__esModule",{value:!0});f.assertDefinedAndNotNull=f.assertDefined=f.assert=void 0;function Pe(e,t){if(!e)throw new Error(t||"condition is not truthy")}f.assert=Pe;function Me(e,t){if(e===void 0)throw new Error(t??"value is undefined")}f.assertDefined=Me;function Ke(e,t){if(e==null)throw new Error(t??"value is undefined or null")}f.assertDefinedAndNotNull=Ke});var R=x(j=>{"use strict";r();Object.defineProperty(j,"__esModule",{value:!0});j.sleep=void 0;async function We(e){return new Promise(t=>setTimeout(t,e))}j.sleep=We});var L=x(g=>{"use strict";r();Object.defineProperty(g,"__esModule",{value:!0});g.isUint8Array=g.isNonNullObject=void 0;function H(e){return typeof e=="object"&&e!==null}g.isNonNullObject=H;function Fe(e){return!(!H(e)||Object.prototype.toString.call(e)!=="[object Uint8Array]"||typeof Buffer<"u"&&typeof Buffer.isBuffer<"u"&&Buffer.isBuffer(e))}g.isUint8Array=Fe});var $=x(m=>{"use strict";r();Object.defineProperty(m,"__esModule",{value:!0});m.isUint8Array=m.isNonNullObject=m.sleep=m.assertDefinedAndNotNull=m.assertDefined=m.assert=m.arrayContentStartsWith=m.arrayContentEquals=void 0;var V=F();Object.defineProperty(m,"arrayContentEquals",{enumerable:!0,get:function(){return V.arrayContentEquals}});Object.defineProperty(m,"arrayContentStartsWith",{enumerable:!0,get:function(){return V.arrayContentStartsWith}});var v=_();Object.defineProperty(m,"assert",{enumerable:!0,get:function(){return v.assert}});Object.defineProperty(m,"assertDefined",{enumerable:!0,get:function(){return v.assertDefined}});Object.defineProperty(m,"assertDefinedAndNotNull",{enumerable:!0,get:function(){return v.assertDefinedAndNotNull}});var _e=R();Object.defineProperty(m,"sleep",{enumerable:!0,get:function(){return _e.sleep}});var J=L();Object.defineProperty(m,"isNonNullObject",{enumerable:!0,get:function(){return J.isNonNullObject}});Object.defineProperty(m,"isUint8Array",{enumerable:!0,get:function(){return J.isUint8Array}})});r();r();import{GasPrice as Ve}from"@cosmjs/stargate";r();import qe from"zustand";import{persist as Ue,subscribeWithSelector as Qe}from"zustand/middleware";var B={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,_reconnect:!1},Oe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=qe(Qe(Ue(()=>B,Oe)));r();import{SigningCosmWasmClient as Y}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as Z}from"@cosmjs/stargate";import{Tendermint34Client as He}from"@cosmjs/tendermint-rpc";r();var C=Te($());import{QueryClient as Re}from"@cosmjs/stargate";function X(...e){let{tendermint:t}=c.getState().clients,n=new Re(t),u=e.map(o=>o(n));for(let o of u){(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 p=n[i]||{};n[i]={...p,...s}}}return n}async function w({rpc:e,rpcHeaders:t}){let n={url:e,headers:{...t||{}}},[u,o,i]=await Promise.all([Y.connect(n),Z.connect(n),He.connect(e)]);return{cosmWasm:u,stargate:o,tendermint:i}}async function D(e){let{rpc:t,rpcHeaders:n,offlineSignerAuto:u,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[p,l]=await Promise.all([Y.connectWithSigner(s,u,o),Z.connectWithSigner(s,u,i)]);return{cosmWasm:p,stargate:l}}r();function ee(e=c.getState().walletType){try{return S(e),!0}catch(t){return console.error(t),!1}}function Le(){if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")}function S(e=c.getState().walletType){switch(e){case"keplr":return Le();default:throw new Error("Unknown wallet type")}}async function A(e){try{let{defaultChain:t,recentChain:n,walletType:u}=c.getState(),o=(e==null?void 0:e.walletType)||u,i=S(o),s=e||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(I=>{let Ge=I._reconnect;return I.activeChain&&I.activeChain.chainId!==s.chainId?{status:"connecting"}:Ge?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let p=i.getOfflineSigner(s.chainId),l=i.getOfflineSignerOnlyAmino(s.chainId),y=await i.getOfflineSignerAuto(s.chainId),Ie=s.gas?Ve.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[W,Be,ve]=await Promise.all([i.getKey(s.chainId),w(s),D({...s,offlineSignerAuto:y,cosmWasmSignerOptions:{gasPrice:Ie,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:W,activeChain:s,clients:Be,offlineSigner:p,offlineSignerAmino:l,offlineSignerAuto:y,recentChain:s,signingClients:ve,status:"connected",walletType:o,_reconnect:!0}),W}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}}async function te(e=!1){return c.setState(t=>({...B,recentChain:e?null:t.recentChain})),Promise.resolve()}function h(){let{activeChain:e}=c.getState();e&&A(e)}r();function ne(){c.setState({recentChain:null})}function oe(e){let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)}function un(){return c.getState().recentChain}async function G(e){return await S().experimentalSuggestChain(e),e}async function re(e){let t=await G(e);return{account:await A(e),chain:t}}r();function se(e={}){return c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}r();async function ie(e){let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:u}=c.getState();return await Promise.all(t.currencies.map(async i=>n[u].getBalance(e,i.coinMinimalDenom)))}async function ce(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 function ue({senderAddress:e,recipientAddress:t,amount:n,fee:u,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,u,o)}async function ae({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:u,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:p,memo:l}){let{signingClients:y}=c.getState();if(!(y!=null&&y.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return y.stargate.sendIbcTokens(e,t,n,u,o,i,s,p,l)}r();r();import{Bech32Address as Je}from"@keplr-wallet/cosmos";var me={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},$e={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Xe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ye={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ze={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},et={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},pe=[me,$e,Xe,Ye,Ze,et],T={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:me,bip44:{coinType:118},bech32Config:Je.defaultBech32Config("axelar"),currencies:pe,feeCurrencies:pe};r();import{Bech32Address as tt}from"@keplr-wallet/cosmos";var fe={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},le=[fe],k={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:fe,bip44:{coinType:118},bech32Config:tt.defaultBech32Config("cosmos"),currencies:le,feeCurrencies:le};r();import{Bech32Address as nt}from"@keplr-wallet/cosmos";var de={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},ot={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},rt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},st={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},it={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},ct={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},ut={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},at={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},pt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},mt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},lt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ye=[de,ot,rt,st,it,ct,ut,at,pt,mt,lt],q={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:de,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("juno"),currencies:ye,feeCurrencies:ye};r();import{Bech32Address as ft}from"@keplr-wallet/cosmos";var Ce={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},yt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ge=[Ce,yt],U={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Ce,bip44:{coinType:118},bech32Config:ft.defaultBech32Config("osmo"),currencies:ge,feeCurrencies:ge};r();import{Bech32Address as dt}from"@keplr-wallet/cosmos";var xe={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},he=[xe],Q={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:xe,bip44:{coinType:118},bech32Config:dt.defaultBech32Config("somm"),currencies:he,feeCurrencies:he};r();import{Bech32Address as gt}from"@keplr-wallet/cosmos";var Ae={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Se=[Ae],O={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:gt.defaultBech32Config("CRE"),currencies:Se,feeCurrencies:Se,stakeCurrency:Ae,coinType:118};r();import{Bech32Address as Ct}from"@keplr-wallet/cosmos";var z={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},ht=[z],N={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:z,bip44:{coinType:118},bech32Config:Ct.defaultBech32Config("juno"),currencies:ht,feeCurrencies:[z],coinType:118};r();import{Bech32Address as xt}from"@keplr-wallet/cosmos";var P={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},St=[P],M={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:P,bip44:{coinType:118},bech32Config:xt.defaultBech32Config("osmo"),currencies:St,feeCurrencies:[P],coinType:118};function Pn(e){return e}function Mn(e){return e}function Kn(e){return e}var Wn={axelar:T,cosmos:k,cosmoshub:k,juno:q,osmosis:U,sommelier:Q},Fn=[T,k,q,U,Q],_n={crescent:O,juno:N,osmosis:M},Rn=[O,N,M];r();import{useMutation as be,useQuery as K}from"@tanstack/react-query";import{useEffect as bt}from"react";import Et from"zustand/shallow";r();import{useQuery as At}from"@tanstack/react-query";function $n(){return b("keplr")}function b(e){let t=c(o=>e||o.walletType);return At(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>ee(o))}function E({onConnect:e,onDisconnect:t}={}){let n=c(o=>o.account),u=c(o=>o.status);return bt(()=>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:Boolean(n),isConnecting:u==="connecting",isDisconnected:u==="disconnected",isReconnecting:u==="reconnecting",reconnect:h,status:u}}function jt(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_BALANCES",n],({queryKey:[,i]})=>ie(i),{enabled:Boolean(n)})}function so(e,t){let{data:n}=jt(t);return K(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})}function io({onError:e,onLoading:t,onSuccess:n}={}){let o=be(["USE_CONNECT",e,t,n],A,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}}function co({onError:e,onLoading:t,onSuccess:n}={}){let o=be(["USE_DISCONNECT",e,t,n],te,{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}}function wt(){return c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Et)}function uo(){return wt()}function ao(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_STAKED_BALANCES",n],({queryKey:[,i]})=>ce(n),{enabled:Boolean(n)})}r();import{useMutation as Ee,useQuery as je}from"@tanstack/react-query";function go(){return c(e=>e.activeChain)}function Co(e){return je(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,u]})=>oe(u))}function ho(e,t="BOND_STATUS_BONDED"){return je(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"})}function xo(){return{data:c(t=>t.recentChain),clear:ne}}function So({onError:e,onLoading:t,onSuccess:n}={}){let o=Ee(["USE_SUGGEST_CHAIN",e,t,n],G,{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}}function Ao({onError:e,onLoading:t,onSuccess:n}={}){let o=Ee(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],re,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}}r();import{useQuery as we}from"@tanstack/react-query";r();import{useQuery as Dt}from"@tanstack/react-query";function wo(...e){let t=["USE_QUERY_CLIENT",...e];return Dt(t,({queryKey:[,...u]})=>X(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})}function vo(e){let t=c(o=>o.clients);return we(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?w(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}function Go(e){let t=c(o=>o.signingClients);return we(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?D(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}r();import{useMutation as De}from"@tanstack/react-query";function zo({onError:e,onLoading:t,onSuccess:n}={}){let{data:u}=E(),o=u==null?void 0:u.bech32Address,s=De(["USE_SEND_TOKENS",e,t,n,o],p=>ue({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}}function No({onError:e,onLoading:t,onSuccess:n}={}){let{data:u}=E(),o=u==null?void 0:u.bech32Address,s=De(["USE_SEND_IBC_TOKENS",e,t,n,o],p=>ae({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}}r();import{QueryClient as Bt,QueryClientProvider as vt}from"@tanstack/react-query";r();import{useEffect as kt}from"react";function It(){return kt(()=>{let{_reconnect:e}=c.getState();return e&&h(),window.addEventListener("keplr_keystorechange",h),()=>{window.removeEventListener("keplr_keystorechange",h)}},[]),null}function ke(){return It(),null}import{jsx as Tt,jsxs as qt}from"react/jsx-runtime";var Gt=new Bt({});function Lo({children:e,grazOptions:t,...n}){return t&&se(t),qt(vt,{client:Gt,...n,children:[Tt(ke,{}),e]})}export{ke as GrazEvents,Lo as GrazProvider,ee as checkWallet,ne as clearRecentChain,se as configureGraz,A as connect,w as createClients,X as createQueryClient,D as createSigningClients,Mn as defineChain,Kn as defineChainInfo,Pn as defineChains,te as disconnect,oe as getActiveChainCurrency,ie as getBalances,Le as getKeplr,un as getRecentChain,ce as getStakedBalances,S as getWallet,Wn as mainnetChains,Fn as mainnetChainsArray,h as reconnect,ae as sendIbcTokens,ue as sendTokens,G as suggestChain,re as suggestChainAndConnect,_n as testnetChains,Rn as testnetChainsArray,E as useAccount,go as useActiveChain,Co as useActiveChainCurrency,ho as useActiveChainValidators,so as useBalance,jt as useBalances,$n as useCheckKeplr,b as useCheckWallet,vo as useClients,io as useConnect,co as useDisconnect,It as useGrazEvents,wt as useOfflineSigners,wo as useQueryClient,xo as useRecentChain,No as useSendIbcTokens,zo as useSendTokens,uo as useSigners,Go as useSigningClients,ao as useStakedBalances,So as useSuggestChain,Ao as useSuggestChainAndConnect};
1
+ import{a as x,b as Ue,c as r}from"./chunk-6M3A6KFX.mjs";var H=x(d=>{"use strict";r();Object.defineProperty(d,"__esModule",{value:!0});d.arrayContentStartsWith=d.arrayContentEquals=void 0;function Ne(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}d.arrayContentEquals=Ne;function Ke(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}d.arrayContentStartsWith=Ke});var L=x(f=>{"use strict";r();Object.defineProperty(f,"__esModule",{value:!0});f.assertDefinedAndNotNull=f.assertDefined=f.assert=void 0;function We(e,t){if(!e)throw new Error(t||"condition is not truthy")}f.assert=We;function Me(e,t){if(e===void 0)throw new Error(t??"value is undefined")}f.assertDefined=Me;function Re(e,t){if(e==null)throw new Error(t??"value is undefined or null")}f.assertDefinedAndNotNull=Re});var V=x(j=>{"use strict";r();Object.defineProperty(j,"__esModule",{value:!0});j.sleep=void 0;async function Fe(e){return new Promise(t=>setTimeout(t,e))}j.sleep=Fe});var Y=x(g=>{"use strict";r();Object.defineProperty(g,"__esModule",{value:!0});g.isUint8Array=g.isNonNullObject=void 0;function J(e){return typeof e=="object"&&e!==null}g.isNonNullObject=J;function _e(e){return!(!J(e)||Object.prototype.toString.call(e)!=="[object Uint8Array]"||typeof Buffer<"u"&&typeof Buffer.isBuffer<"u"&&Buffer.isBuffer(e))}g.isUint8Array=_e});var Z=x(m=>{"use strict";r();Object.defineProperty(m,"__esModule",{value:!0});m.isUint8Array=m.isNonNullObject=m.sleep=m.assertDefinedAndNotNull=m.assertDefined=m.assert=m.arrayContentStartsWith=m.arrayContentEquals=void 0;var $=H();Object.defineProperty(m,"arrayContentEquals",{enumerable:!0,get:function(){return $.arrayContentEquals}});Object.defineProperty(m,"arrayContentStartsWith",{enumerable:!0,get:function(){return $.arrayContentStartsWith}});var T=L();Object.defineProperty(m,"assert",{enumerable:!0,get:function(){return T.assert}});Object.defineProperty(m,"assertDefined",{enumerable:!0,get:function(){return T.assertDefined}});Object.defineProperty(m,"assertDefinedAndNotNull",{enumerable:!0,get:function(){return T.assertDefinedAndNotNull}});var He=V();Object.defineProperty(m,"sleep",{enumerable:!0,get:function(){return He.sleep}});var X=Y();Object.defineProperty(m,"isNonNullObject",{enumerable:!0,get:function(){return X.isNonNullObject}});Object.defineProperty(m,"isUint8Array",{enumerable:!0,get:function(){return X.isUint8Array}})});r();r();import{GasPrice as $e}from"@cosmjs/stargate";r();import Qe from"zustand";import{persist as Oe,subscribeWithSelector as ze}from"zustand/middleware";r();var F=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(F||{}),_=["keplr","leap"];var B={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,_reconnect:!1},Pe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=Qe(ze(Oe(()=>B,Pe)));r();import{SigningCosmWasmClient as te}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as ne}from"@cosmjs/stargate";import{Tendermint34Client as Ve}from"@cosmjs/tendermint-rpc";r();var C=Ue(Z());import{QueryClient as Le}from"@cosmjs/stargate";function ee(...e){let{tendermint:t}=c.getState().clients,n=new Le(t),u=e.map(o=>o(n));for(let o of u){(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 p=n[i]||{};n[i]={...p,...s}}}return n}async function w({rpc:e,rpcHeaders:t}){let n={url:e,headers:{...t||{}}},[u,o,i]=await Promise.all([te.connect(n),ne.connect(n),Ve.connect(e)]);return{cosmWasm:u,stargate:o,tendermint:i}}async function D(e){let{rpc:t,rpcHeaders:n,offlineSignerAuto:u,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[p,l]=await Promise.all([te.connectWithSigner(s,u,o),ne.connectWithSigner(s,u,i)]);return{cosmWasm:p,stargate:l}}r();function v(e=c.getState().walletType){try{return S(e),!0}catch(t){return console.error(t),!1}}function Je(){if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")}function Ye(){if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")}function S(e=c.getState().walletType){switch(e){case"keplr":return Je();case"leap":return Ye();default:throw new Error("Unknown wallet type")}}function on(){return Object.fromEntries(_.map(e=>[e,v(e)]))}async function A(e){try{let{defaultChain:t,recentChain:n,walletType:u}=c.getState(),o=(e==null?void 0:e.walletType)||u,i=S(o),s=e||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(I=>{let qe=I._reconnect;return I.activeChain&&I.activeChain.chainId!==s.chainId?{status:"connecting"}:qe?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let p=i.getOfflineSigner(s.chainId),l=i.getOfflineSignerOnlyAmino(s.chainId),y=await i.getOfflineSignerAuto(s.chainId),Te=s.gas?$e.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[R,ve,Ge]=await Promise.all([i.getKey(s.chainId),w(s),D({...s,offlineSignerAuto:y,cosmWasmSignerOptions:{gasPrice:Te,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:R,activeChain:s,clients:ve,offlineSigner:p,offlineSignerAmino:l,offlineSignerAuto:y,recentChain:s,signingClients:Ge,status:"connected",walletType:o,_reconnect:!0}),R}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}}async function oe(e=!1){return c.setState(t=>({...B,recentChain:e?null:t.recentChain})),Promise.resolve()}function h(){let{activeChain:e}=c.getState();e&&A(e)}r();function re(){c.setState({recentChain:null})}function se(e){let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)}function yn(){return c.getState().recentChain}async function G(e){return await S().experimentalSuggestChain(e),e}async function ie(e){let t=await G(e);return{account:await A(e),chain:t}}r();function ce(e={}){return c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}r();async function ue(e){let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:u}=c.getState();return await Promise.all(t.currencies.map(async i=>n[u].getBalance(e,i.coinMinimalDenom)))}async function ae(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 function pe({senderAddress:e,recipientAddress:t,amount:n,fee:u,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,u,o)}async function me({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:u,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:p,memo:l}){let{signingClients:y}=c.getState();if(!(y!=null&&y.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return y.stargate.sendIbcTokens(e,t,n,u,o,i,s,p,l)}r();r();import{Bech32Address as Xe}from"@keplr-wallet/cosmos";var fe={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ze={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},et={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},tt={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},nt={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ot={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},le=[fe,Ze,et,tt,nt,ot],q={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:fe,bip44:{coinType:118},bech32Config:Xe.defaultBech32Config("axelar"),currencies:le,feeCurrencies:le};r();import{Bech32Address as rt}from"@keplr-wallet/cosmos";var de={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ye=[de],k={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:de,bip44:{coinType:118},bech32Config:rt.defaultBech32Config("cosmos"),currencies:ye,feeCurrencies:ye};r();import{Bech32Address as st}from"@keplr-wallet/cosmos";var Ce={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},it={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ct={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},ut={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},at={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},pt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},mt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},lt={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"},yt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},dt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ge=[Ce,it,ct,ut,at,pt,mt,lt,ft,yt,dt],U={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Ce,bip44:{coinType:118},bech32Config:st.defaultBech32Config("juno"),currencies:ge,feeCurrencies:ge};r();import{Bech32Address as gt}from"@keplr-wallet/cosmos";var xe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ct={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},he=[xe,Ct],Q={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:xe,bip44:{coinType:118},bech32Config:gt.defaultBech32Config("osmo"),currencies:he,feeCurrencies:he};r();import{Bech32Address as ht}from"@keplr-wallet/cosmos";var Ae={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Se=[Ae],O={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ae,bip44:{coinType:118},bech32Config:ht.defaultBech32Config("somm"),currencies:Se,feeCurrencies:Se};r();import{Bech32Address as xt}from"@keplr-wallet/cosmos";var Ee={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},be=[Ee],z={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:xt.defaultBech32Config("CRE"),currencies:be,feeCurrencies:be,stakeCurrency:Ee,coinType:118};r();import{Bech32Address as St}from"@keplr-wallet/cosmos";var P={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},At=[P],N={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:P,bip44:{coinType:118},bech32Config:St.defaultBech32Config("juno"),currencies:At,feeCurrencies:[P],coinType:118};r();import{Bech32Address as bt}from"@keplr-wallet/cosmos";var K={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Et=[K],W={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:K,bip44:{coinType:118},bech32Config:bt.defaultBech32Config("osmo"),currencies:Et,feeCurrencies:[K],coinType:118};function _n(e){return e}function Hn(e){return e}function Ln(e){return e}var Vn={axelar:q,cosmos:k,cosmoshub:k,juno:U,osmosis:Q,sommelier:O},Jn=[q,k,U,Q,O],Yn={crescent:z,juno:N,osmosis:W},$n=[z,N,W];r();import{useMutation as je,useQuery as M}from"@tanstack/react-query";import{useEffect as wt}from"react";import Dt from"zustand/shallow";r();import{useQuery as jt}from"@tanstack/react-query";function no(){return b("keplr")}function b(e){let t=c(o=>e||o.walletType);return jt(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>v(o))}function E({onConnect:e,onDisconnect:t}={}){let n=c(o=>o.account),u=c(o=>o.status);return wt(()=>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:Boolean(n),isConnecting:u==="connecting",isDisconnected:u==="disconnected",isReconnecting:u==="reconnecting",reconnect:h,status:u}}function kt(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",n],({queryKey:[,i]})=>ue(i),{enabled:Boolean(n)})}function mo(e,t){let{data:n}=kt(t);return M(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})}function lo({onError:e,onLoading:t,onSuccess:n}={}){let o=je(["USE_CONNECT",e,t,n],A,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}}function fo({onError:e,onLoading:t,onSuccess:n}={}){let o=je(["USE_DISCONNECT",e,t,n],oe,{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}}function It(){return c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Dt)}function yo(){return It()}function go(e){let{data:t}=E(),n=e||(t==null?void 0:t.bech32Address);return M(["USE_STAKED_BALANCES",n],({queryKey:[,i]})=>ae(n),{enabled:Boolean(n)})}r();import{useMutation as we,useQuery as De}from"@tanstack/react-query";function bo(){return c(e=>e.activeChain)}function Eo(e){return De(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,u]})=>se(u))}function jo(e,t="BOND_STATUS_BONDED"){return De(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"})}function wo(){return{data:c(t=>t.recentChain),clear:re}}function Do({onError:e,onLoading:t,onSuccess:n}={}){let o=we(["USE_SUGGEST_CHAIN",e,t,n],G,{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}}function ko({onError:e,onLoading:t,onSuccess:n}={}){let o=we(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ie,{onError:(s,p)=>Promise.resolve(e==null?void 0:e(s,p)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=b();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}}r();import{useQuery as ke}from"@tanstack/react-query";r();import{useQuery as Bt}from"@tanstack/react-query";function vo(...e){let t=["USE_QUERY_CLIENT",...e];return Bt(t,({queryKey:[,...u]})=>ee(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})}function Oo(e){let t=c(o=>o.clients);return ke(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?w(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}function zo(e){let t=c(o=>o.signingClients);return ke(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?D(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})}r();import{useMutation as Ie}from"@tanstack/react-query";function Ro({onError:e,onLoading:t,onSuccess:n}={}){let{data:u}=E(),o=u==null?void 0:u.bech32Address,s=Ie(["USE_SEND_TOKENS",e,t,n,o],p=>pe({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}}function Fo({onError:e,onLoading:t,onSuccess:n}={}){let{data:u}=E(),o=u==null?void 0:u.bech32Address,s=Ie(["USE_SEND_IBC_TOKENS",e,t,n,o],p=>me({senderAddress:o,...p}),{onError:(p,l)=>Promise.resolve(e==null?void 0:e(p,l)),onMutate:t,onSuccess:p=>Promise.resolve(n==null?void 0:n(p))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}}r();import{QueryClient as Gt,QueryClientProvider as qt}from"@tanstack/react-query";r();import{useEffect as Tt}from"react";function vt(){return Tt(()=>{let{_reconnect:e}=c.getState();return e&&h(),window.addEventListener("keplr_keystorechange",h),()=>{window.removeEventListener("keplr_keystorechange",h)}},[]),null}function Be(){return vt(),null}import{jsx as Qt,jsxs as Ot}from"react/jsx-runtime";var Ut=new Gt({});function Zo({children:e,grazOptions:t,...n}){return t&&ce(t),Ot(qt,{client:Ut,...n,children:[Qt(Be,{}),e]})}export{Be as GrazEvents,Zo as GrazProvider,_ as WALLET_TYPES,F as WalletType,v as checkWallet,re as clearRecentChain,ce as configureGraz,A as connect,w as createClients,ee as createQueryClient,D as createSigningClients,Hn as defineChain,Ln as defineChainInfo,_n as defineChains,oe as disconnect,se as getActiveChainCurrency,on as getAvailableWallets,ue as getBalances,Je as getKeplr,Ye as getLeap,yn as getRecentChain,ae as getStakedBalances,S as getWallet,Vn as mainnetChains,Jn as mainnetChainsArray,h as reconnect,me as sendIbcTokens,pe as sendTokens,G as suggestChain,ie as suggestChainAndConnect,Yn as testnetChains,$n as testnetChainsArray,E as useAccount,bo as useActiveChain,Eo as useActiveChainCurrency,jo as useActiveChainValidators,mo as useBalance,kt as useBalances,no as useCheckKeplr,b as useCheckWallet,Oo as useClients,lo as useConnect,fo as useDisconnect,vt as useGrazEvents,It as useOfflineSigners,vo as useQueryClient,wo as useRecentChain,Fo as useSendIbcTokens,Ro as useSendTokens,yo as useSigners,zo as useSigningClients,go as useStakedBalances,Do as useSuggestChain,ko 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.23",
4
+ "version": "0.0.24",
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",
@@ -72,6 +72,7 @@
72
72
  "scripts": {
73
73
  "build": "tsup",
74
74
  "cli": "node cli.mjs",
75
- "dev": "tsup --watch"
75
+ "dev": "tsup --watch",
76
+ "lint": "eslint --fix \"src/**/*.{ts,tsx}\""
76
77
  }
77
78
  }