graz 0.0.34 → 0.0.35

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/cli.mjs CHANGED
@@ -9,6 +9,17 @@ import { fileURLToPath } from "url";
9
9
 
10
10
  import pmap from "./compiled/p-map/index.mjs";
11
11
 
12
+ function isNumber(char) {
13
+ return /^\d+$/.test(char);
14
+ }
15
+
16
+ function chainNaming(name) {
17
+ if (isNumber(name[0])) {
18
+ return `_${name}`;
19
+ }
20
+ return name;
21
+ }
22
+
12
23
  const HELP_MESSAGE = `Usage: graz [options]
13
24
 
14
25
  Options:
@@ -119,7 +130,7 @@ function chainsDir(...args) {
119
130
  */
120
131
  function makeChainMap(record, { testnet = false } = {}) {
121
132
  return Object.keys(record)
122
- .map((k) => ` ${k}: ${k}${testnet ? "Testnet" : ""},`)
133
+ .map((k) => ` ${chainNaming(k)}: ${chainNaming(k)},`)
123
134
  .join("\n");
124
135
  }
125
136
 
@@ -130,7 +141,7 @@ function makeChainMap(record, { testnet = false } = {}) {
130
141
  function makeDefs(record, { mjs = false, testnet = false } = {}) {
131
142
  return Object.entries(record)
132
143
  .map(([k, v]) => {
133
- const jsVariable = `${k}${testnet ? "Testnet" : ""}`;
144
+ const jsVariable = `${chainNaming(k)}`;
134
145
  const jsChainInfo = JSON.stringify(v, null, 2);
135
146
  return `${mjs ? "export " : ""}const ${jsVariable} = defineChainInfo(${jsChainInfo});\n`;
136
147
  })
@@ -143,7 +154,7 @@ function makeDefs(record, { mjs = false, testnet = false } = {}) {
143
154
  */
144
155
  function makeExports(record, { testnet = false } = {}) {
145
156
  return Object.keys(record)
146
- .map((k) => ` ${k}${testnet ? "Testnet" : ""},`)
157
+ .map((k) => ` ${chainNaming(k)},`)
147
158
  .join("\n");
148
159
  }
149
160
 
package/dist/index.d.ts CHANGED
@@ -241,37 +241,6 @@ interface ConfigureGrazArgs {
241
241
  }
242
242
  declare const configureGraz: (args?: ConfigureGrazArgs) => ConfigureGrazArgs;
243
243
 
244
- interface AddressToIbcDomainReturnValue {
245
- domain: string;
246
- domainFull: string;
247
- }
248
- /**
249
- * @see https://docs.ibc.domains/convert_address.html#relevant-bech32-prefixes
250
- */
251
- declare type KnownChainPrefix = "agoric" | "chihuahua" | "gravity" | "lum" | "sent" | "akash" | "comdex" | "iaa" | "micro" | "sif" | "axelar" | "cosmos" | "inj" | "osmo" | "somm" | "bcna" | "cro" | "ixo" | "panacea" | "star" | "bitsong" | "desmos" | "juno" | "persistence" | "stars" | "bostrom" | "dig" | "ki" | "regen" | "terra" | "certik" | "emoney" | "kujira" | "rebus" | "umee" | "cheqd" | "evmos" | "like" | "secret" | "vdl";
252
- declare type ChainPrefix = (string & {}) | KnownChainPrefix;
253
- interface DomainDetails {
254
- expiration: string | null;
255
- imageData: string | null;
256
- twitterId: string | null;
257
- discordId: string | null;
258
- telegramId: string | null;
259
- keybaseId: string | null;
260
- pgpPublicKey: string | null;
261
- }
262
- declare const isIbcDomainPostfix: (value: string) => boolean;
263
- declare const validateAddress: (address: string, prefix: ChainPrefix) => boolean;
264
- declare const getIbcDomainByAdress: (address: string, isTestnet?: boolean) => Promise<AddressToIbcDomainReturnValue | null>;
265
- declare const getAddressesByIbcDomain: (ibcDomain: string, isTestnet?: boolean) => Promise<string[] | null>;
266
- declare const getChainAddressByIbcDomain: (ibcDomain: string, prefix: ChainPrefix, isTestnet?: boolean) => Promise<string | null>;
267
- declare const getIbcDomainDetails: (ibcDomain: string, isTestnet?: boolean) => Promise<DomainDetails | null>;
268
- interface ResolveToChainAddressArgs {
269
- value: string;
270
- prefix: ChainPrefix;
271
- isTestnet?: boolean;
272
- }
273
- declare const resolveToChainAddress: ({ value, prefix, isTestnet }: ResolveToChainAddressArgs) => Promise<string>;
274
-
275
244
  declare const getBalances: (bech32Address: string) => Promise<Coin[]>;
276
245
  declare const getBalanceStaked: (bech32Address: string) => Promise<Coin | null>;
277
246
  interface SendTokensArgs {
@@ -781,128 +750,6 @@ declare const useClients: (args?: CreateClientArgs) => UseQueryResult<GrazStore[
781
750
  */
782
751
  declare const useSigningClients: (args?: CreateSigningClientArgs) => UseQueryResult<GrazStore["signingClients"]>;
783
752
 
784
- /**
785
- * graz query hook to retrieve an ibc domain from given address.
786
- *
787
- * @param address - Optional, if address undefined this hook won't run
788
- * @param isTestnet - Optional for pointing to testnet
789
- *
790
- * @example
791
- * ```ts
792
- * import { useAddressToIbcDomain } from "graz";
793
- *
794
- * // basic example
795
- * const { data, isFetching, refetch, ... } = useAddressToIbcDomain({
796
- * address: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
797
- * });
798
- *
799
- * ```
800
- */
801
- declare const useAddressToIbcDomain: ({ address, isTestnet, }: {
802
- address?: string | undefined;
803
- isTestnet?: boolean | undefined;
804
- }) => UseQueryResult<AddressToIbcDomainReturnValue | null>;
805
- /**
806
- * graz query hook to retrieve an addresses from given ibc domain.
807
- *
808
- * @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
809
- * @param isTestnet - Optional for pointing to testnet
810
- *
811
- * @example
812
- * ```ts
813
- * import { useIbcDomainToAddresses } from "graz";
814
- *
815
- * // basic example
816
- * const { data, isFetching, refetch, ... } = useIbcDomainToAddresses({
817
- * ibcDomain: "kikiding.cosmos",
818
- * });
819
- *
820
- * ```
821
- */
822
- declare const useIbcDomainToAddresses: ({ ibcDomain, isTestnet, }: {
823
- ibcDomain?: string | undefined;
824
- isTestnet?: boolean | undefined;
825
- }) => UseQueryResult<string[] | null>;
826
- /**
827
- * graz query hook to retrieve an address from given ibc domain and prefix.
828
- *
829
- * @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
830
- * @param prefix - Optional string or bech32 prefix of the destination chain, for instance "cosmos", "somm", etc
831
- * @param isTestnet - Optional for pointing to testnet
832
- *
833
- * @example
834
- * ```ts
835
- * import { useIbcDomainToChainAddress } from "graz";
836
- *
837
- * // basic example
838
- * const { data, isFetching, refetch, ... } = useIbcDomainToChainAddress({
839
- * ibcDomain: "kikiding.cosmos",
840
- * prefix: "osmo"
841
- * });
842
- *
843
- * ```
844
- */
845
- declare const useIbcDomainToChainAddress: ({ ibcDomain, prefix, isTestnet, }: {
846
- ibcDomain?: string | undefined;
847
- prefix?: ChainPrefix | undefined;
848
- isTestnet?: boolean | undefined;
849
- }) => UseQueryResult<string | null>;
850
- /**
851
- * graz query hook to retrieve a ibc domain details from given ibc domain.
852
- *
853
- * @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
854
- * @param isTestnet - Optional for pointing to testnet
855
- *
856
- * @example
857
- * ```ts
858
- * import { useIbcDomainDetails } from "graz";
859
- *
860
- * // basic example
861
- * const { data, isFetching, refetch, ... } = useIbcDomainDetails({
862
- * ibcDomain: "kikiding.cosmos",
863
- * });
864
- *
865
- * ```
866
- */
867
- declare const useIbcDomainDetails: ({ ibcDomain, isTestnet }: {
868
- ibcDomain?: string | undefined;
869
- isTestnet?: boolean | undefined;
870
- }) => UseQueryResult<DomainDetails | null, unknown>;
871
- declare type UseResolveToChainAddressArgs = MutationEventArgs<ResolveToChainAddressArgs, string>;
872
- /**
873
- * graz mutation hook to resolve an Ibc domain or an address to bech32 address from given string
874
- *
875
- * @example
876
- * ```ts
877
- * import { useResolveToChainAddress } from "graz";
878
- *
879
- * // basic example
880
- * const { resolveToChainAddress } = useResolveToChainAddress();
881
- *
882
- * // with event arguments
883
- * useResolveToChainAddress({
884
- * onError: (err, args) => { ... },
885
- * onLoading: () => { ... },
886
- * onSuccess: ({ account, address }) => { ... },
887
- * });
888
- *
889
- * // resolveToChainAddress usage
890
- * resolveToChainAddress({
891
- * value: "kikiding.cosmos",
892
- * prefix: "osmo"
893
- * ...
894
- * });
895
- * ```
896
- */
897
- declare const useResolveToChainAddress: ({ onError, onLoading, onSuccess }?: UseResolveToChainAddressArgs) => {
898
- error: unknown;
899
- isLoading: boolean;
900
- isSuccess: boolean;
901
- resolveToChainAddress: _tanstack_react_query.UseMutateFunction<string, unknown, ResolveToChainAddressArgs, unknown>;
902
- resolveToChainAddressAsync: _tanstack_react_query.UseMutateAsyncFunction<string, unknown, ResolveToChainAddressArgs, unknown>;
903
- status: "error" | "idle" | "loading" | "success";
904
- };
905
-
906
753
  /**
907
754
  * graz mutation hook to send tokens. Note: if `senderAddress` undefined, it will use current connected account address.
908
755
  *
@@ -1102,4 +949,4 @@ declare const useGrazEvents: () => null;
1102
949
  */
1103
950
  declare const GrazEvents: FC;
1104
951
 
1105
- export { AddressToIbcDomainReturnValue, ChainInfoWithPath, ChainPrefix, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, DomainDetails, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, KnownChainPrefix, Maybe, ResolveToChainAddressArgs, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseResolveToChainAddressArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAddressesByIbcDomain, getAvailableWallets, getBalanceStaked, getBalances, getChainAddressByIbcDomain, getIbcDomainByAdress, getIbcDomainDetails, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, isIbcDomainPostfix, mainnetChains, mainnetChainsArray, reconnect, resolveToChainAddress, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useAddressToIbcDomain, useBalance, useBalanceStaked, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useIbcDomainDetails, useIbcDomainToAddresses, useIbcDomainToChainAddress, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useResolveToChainAddress, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect, validateAddress };
952
+ export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateQueryClient, CreateSigningClientArgs, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazAdapter, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, SendIbcTokensArgs, SendTokensArgs, SuggestChainAndConnectArgs, UseAccountArgs, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseQueryClient, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createQueryClient, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, executeContract, getActiveChainCurrency, getAvailableWallets, getBalanceStaked, getBalances, getKeplr, getLeap, getQueryRaw, getQuerySmart, getRecentChain, getWallet, instantiateContract, mainnetChains, mainnetChainsArray, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useActiveChainCurrency, useActiveChainValidators, useBalance, useBalanceStaked, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClient, useQueryRaw, useQuerySmart, useRecentChain, useSendIbcTokens, useSendTokens, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var rt=Object.create;var j=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var pt=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},fe=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ct(t))!ut.call(e,s)&&s!==n&&j(e,s,{get:()=>t[s],enumerable:!(o=it(t,s))||o.enumerable});return e};var xe=(e,t,n)=>(n=e!=null?rt(at(e)):{},fe(t||!e||!e.__esModule?j(n,"default",{value:e,enumerable:!0}):n,e)),mt=e=>fe(j({},"__esModule",{value:!0}),e);var dn={};pt(dn,{GrazEvents:()=>de,GrazProvider:()=>gn,WALLET_TYPES:()=>G,WalletType:()=>R,checkWallet:()=>T,clearRecentChain:()=>z,configureGraz:()=>F,connect:()=>S,createClients:()=>w,createQueryClient:()=>K,createSigningClients:()=>D,defineChain:()=>Ut,defineChainInfo:()=>Rt,defineChains:()=>le,disconnect:()=>O,executeContract:()=>ee,getActiveChainCurrency:()=>W,getAddressesByIbcDomain:()=>H,getAvailableWallets:()=>gt,getBalanceStaked:()=>J,getBalances:()=>Y,getChainAddressByIbcDomain:()=>v,getIbcDomainByAdress:()=>N,getIbcDomainDetails:()=>L,getKeplr:()=>Ee,getLeap:()=>be,getQueryRaw:()=>ne,getQuerySmart:()=>te,getRecentChain:()=>dt,getWallet:()=>A,instantiateContract:()=>Z,isIbcDomainPostfix:()=>je,mainnetChains:()=>Gt,mainnetChainsArray:()=>Mt,reconnect:()=>C,resolveToChainAddress:()=>V,sendIbcTokens:()=>X,sendTokens:()=>$,suggestChain:()=>k,suggestChainAndConnect:()=>_,testnetChains:()=>Kt,testnetChainsArray:()=>Qt,useAccount:()=>d,useActiveChain:()=>Nt,useActiveChainCurrency:()=>Ht,useActiveChainValidators:()=>Lt,useAddressToIbcDomain:()=>en,useBalance:()=>Ot,useBalanceStaked:()=>Ft,useBalances:()=>$e,useCheckKeplr:()=>Pt,useCheckWallet:()=>E,useClients:()=>Xt,useConnect:()=>zt,useDisconnect:()=>Wt,useExecuteContract:()=>un,useGrazEvents:()=>tt,useIbcDomainDetails:()=>sn,useIbcDomainToAddresses:()=>tn,useIbcDomainToChainAddress:()=>nn,useInstantiateContract:()=>an,useOfflineSigners:()=>Xe,useQueryClient:()=>$t,useQueryRaw:()=>mn,useQuerySmart:()=>pn,useRecentChain:()=>Vt,useResolveToChainAddress:()=>on,useSendIbcTokens:()=>cn,useSendTokens:()=>rn,useSigners:()=>_t,useSigningClients:()=>Zt,useSuggestChain:()=>Yt,useSuggestChainAndConnect:()=>Jt,validateAddress:()=>Ie});module.exports=mt(dn);var we=require("@cosmjs/stargate");var he=xe(require("zustand")),I=require("zustand/middleware");var R=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(R||{}),G=["keplr","leap"];var M={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},lt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=(0,he.default)((0,I.subscribeWithSelector)((0,I.persist)(()=>M,lt)));var Q=require("@cosmjs/cosmwasm-stargate"),P=require("@cosmjs/stargate"),Se=require("@cosmjs/tendermint-rpc");var Ae=require("@cosmjs/stargate"),h=require("@cosmjs/utils");var K=(...e)=>{let{tendermint:t}=c.getState().clients,n=new Ae.QueryClient(t),o=e.map(s=>s(n));for(let s of o){(0,h.assert)((0,h.isNonNullObject)(s),"Extension must be a non-null object");for(let[i,r]of Object.entries(s)){(0,h.assert)((0,h.isNonNullObject)(r),`Module must be a non-null object. Found type ${typeof r} for module "${i}".`);let u=n[i]||{};n[i]={...u,...r}}}return n};var w=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[o,s,i]=await Promise.all([Q.SigningCosmWasmClient.connect(n),P.SigningStargateClient.connect(n),Se.Tendermint34Client.connect(e)]);return{cosmWasm:o,stargate:s,tendermint:i}},D=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:o,cosmWasmSignerOptions:s={},stargateSignerOptions:i={}}=e,r={url:t,headers:{...n||{}}},[u,p]=await Promise.all([Q.SigningCosmWasmClient.connectWithSigner(r,o,s),P.SigningStargateClient.connectWithSigner(r,o,i)]);return{cosmWasm:u,stargate:p}};var T=(e=c.getState().walletType)=>{try{return A(e),!0}catch(t){return console.error(t),!1}},Ee=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},be=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},A=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ee();case"leap":return be();default:throw new Error("Unknown wallet type")}},gt=()=>Object.fromEntries(G.map(e=>[e,T(e)]));var S=async e=>{try{let{defaultChain:t,recentChain:n,walletType:o}=c.getState(),s=(e==null?void 0:e.walletType)||o,i=A(s),r=e||n||t;if(!r)throw new Error("No last known connected chain, connect action requires chain info");c.setState(U=>{let ot=U._reconnect;return U.activeChain&&U.activeChain.chainId!==r.chainId?{status:"connecting"}:ot?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(r.chainId);let u=i.getOfflineSigner(r.chainId),p=i.getOfflineSignerOnlyAmino(r.chainId),m=await i.getOfflineSignerAuto(r.chainId),l=r.gas?we.GasPrice.fromString(`${r.gas.price}${r.gas.denom}`):void 0,[Ce,nt,st]=await Promise.all([i.getKey(r.chainId),w(r),D({...r,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Ce,activeChain:r,clients:nt,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:r,signingClients:st,status:"connected",walletType:s,_reconnect:!0}),Ce}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},O=async(e=!1)=>(c.setState(t=>({...M,recentChain:e?null:t.recentChain})),Promise.resolve()),C=()=>{let{activeChain:e}=c.getState();e&&S(e)};var z=()=>{c.setState({recentChain:null})},W=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},dt=()=>c.getState().recentChain,k=async e=>(await A().experimentalSuggestChain(e),e),_=async({chainInfo:e,...t})=>{let n=await k(e);return{account:await S({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:n}};var F=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);var De=require("bech32"),g=require("ibc-domains-sdk"),je=e=>e.endsWith(".cosmos"),Ie=(e,t)=>{if(!e)return!1;try{return De.bech32.decode(e).prefix===t}catch{return!1}},N=async(e,t)=>{let n=await(0,g.resolvePrimaryDomainByAddress)(e,t);if(n.error)throw new Error(n.error);if(n.value===null)return null;let o=n.value;return{domain:o.domain,domainFull:o.domain_full}},H=async(e,t)=>{let n=await(0,g.resolveDomainIntoAddresses)(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},v=async(e,t,n)=>{let o=await(0,g.resolveDomainIntoChainAddress)(e,t,n);if(o.error)throw new Error(o.error);return o.value===null?null:o.value},L=async(e,t)=>{let n=await(0,g.resolveDomainDetails)(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},V=async({value:e,prefix:t,isTestnet:n})=>{if(e.trim()==="")throw new Error("value can't be an empty string");if(je(e)){let i=await v(e,t,n);if(!i)throw new Error("ibc domain not found");return i}if(!Ie(e,t))throw new Error("Address is not valid");return e};var Y=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:o}=c.getState();return await Promise.all(t.currencies.map(async i=>n[o].getBalance(e,i.coinMinimalDenom)))},J=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},$=async({senderAddress:e,recipientAddress:t,amount:n,fee:o,memo:s})=>{let{signingClients:i,defaultSigningClient:r}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[r].sendTokens(e,t,n,o,s)},X=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:o,sourceChannel:s,timeoutHeight:i,timeoutTimestamp:r,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,o,s,i,r,u,p)},Z=async({senderAddress:e,msg:t,fee:n,options:o,label:s,codeId:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.instantiate(e,i,t,s,n,o)},ee=async({senderAddress:e,msg:t,fee:n,contractAddress:o,funds:s,memo:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.execute(e,o,t,n,i,s)},te=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,o)};var ke=require("@keplr-wallet/cosmos"),ve={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},yt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Ct={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ft={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},xt={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ht={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Te=[ve,yt,Ct,ft,xt,ht],se={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:ve,bip44:{coinType:118},bech32Config:ke.Bech32Address.defaultBech32Config("axelar"),currencies:Te,feeCurrencies:Te};var qe=require("@keplr-wallet/cosmos"),Ue={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Be=[Ue],B={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:qe.Bech32Address.defaultBech32Config("cosmos"),currencies:Be,feeCurrencies:Be};var Ge=require("@keplr-wallet/cosmos"),Me={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},At={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},St={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Et={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"},wt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Dt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},jt={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},It={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Tt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},kt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},Re=[Me,At,St,Et,bt,wt,Dt,jt,It,Tt,kt],oe={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Me,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("juno"),currencies:Re,feeCurrencies:Re};var Qe=require("@keplr-wallet/cosmos"),Pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},vt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Ke=[Pe,vt],re={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Pe,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Ke,feeCurrencies:Ke};var ze=require("@keplr-wallet/cosmos"),We={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Oe=[We],ie={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:We,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("somm"),currencies:Oe,feeCurrencies:Oe};var Fe=require("@keplr-wallet/cosmos"),Ne={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},_e=[Ne],ce={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:_e,feeCurrencies:_e,stakeCurrency:Ne,coinType:118};var He=require("@keplr-wallet/cosmos"),ae={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Bt=[ae],ue={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ae,bip44:{coinType:118},bech32Config:He.Bech32Address.defaultBech32Config("juno"),currencies:Bt,feeCurrencies:[ae],coinType:118};var Le=require("@keplr-wallet/cosmos"),pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},qt=[pe],me={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Le.Bech32Address.defaultBech32Config("osmo"),currencies:qt,feeCurrencies:[pe],coinType:118};var le=e=>e,Ut=e=>e,Rt=e=>e,Gt=le({axelar:se,cosmos:B,cosmoshub:B,juno:oe,osmosis:re,sommelier:ie}),Mt=[se,B,oe,re,ie],Kt=le({crescent:ce,juno:ue,osmosis:me}),Qt=[ce,ue,me];var f=require("@tanstack/react-query"),Ye=require("react"),Je=xe(require("zustand/shallow"));var Ve=require("@tanstack/react-query");var Pt=()=>E("keplr"),E=e=>{let t=c(s=>e||s.walletType);return(0,Ve.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>T(s))};var d=({onConnect:e,onDisconnect:t}={})=>{let n=c(s=>s.account),o=c(s=>s.status);return(0,Ye.useEffect)(()=>c.subscribe(s=>s.status,(s,i)=>{if(s==="connected"){let r=c.getState();e==null||e({account:r.account,isReconnect:i==="reconnecting"})}s==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",reconnect:C,status:o}},$e=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return(0,f.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>Y(i),{enabled:Boolean(n)})},Ot=(e,t)=>{let{data:n}=$e(t);return(0,f.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(r=>r.denom===e),{enabled:Boolean(n)})},zt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,f.useMutation)(["USE_CONNECT",e,t,n],S,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=E();return{connect:r=>s.mutate(r),connectAsync:r=>s.mutateAsync(r),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,f.useMutation)(["USE_DISCONNECT",e,t,n],O,{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=>s.mutate(i),disconnectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},Xe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Je.default),_t=()=>Xe(),Ft=e=>{let{data:t}=d(),n=e||(t==null?void 0:t.bech32Address);return(0,f.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>J(n),{enabled:Boolean(n)})};var b=require("@tanstack/react-query");var Nt=()=>c(e=>e.activeChain),Ht=e=>(0,b.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,o]})=>W(o)),Lt=(e,t="BOND_STATUS_BONDED")=>(0,b.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,s,i]})=>s.staking.validators(i),{enabled:typeof e<"u"}),Vt=()=>({data:c(t=>t.recentChain),clear:z}),Yt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,b.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],k,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,suggest:s.mutate,suggestAsync:s.mutateAsync,status:s.status}},Jt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,b.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],_,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:r=>t==null?void 0:t(r),onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=E();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status,suggestAndConnect:s.mutate,suggestAndConnectAsync:s.mutateAsync}};var ge=require("@tanstack/react-query");var Ze=require("@tanstack/react-query");var $t=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Ze.useQuery)(t,({queryKey:[,...o]})=>K(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Xt=e=>{let t=c(s=>s.clients);return(0,ge.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?w(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({clients:s})}})},Zt=e=>{let t=c(s=>s.signingClients);return(0,ge.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?D(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({signingClients:s})}})};var x=require("@tanstack/react-query");var en=({address:e,isTestnet:t})=>(0,x.useQuery)(["USE_ADRESS_TO_IBC_DOMAIN",e,t],()=>N(e,t),{enabled:Boolean(e)}),tn=({ibcDomain:e,isTestnet:t})=>(0,x.useQuery)(["USE_IBC_DOMAIN_TO_ADDRESSES",e,t],()=>H(e,t),{enabled:Boolean(e)}),nn=({ibcDomain:e,prefix:t,isTestnet:n})=>(0,x.useQuery)(["USE_IBC_DOMAIN_TO_CHAIN_ADDRESS",t,e,n],()=>v(e,t,n),{enabled:Boolean(e&&t)}),sn=({ibcDomain:e,isTestnet:t})=>(0,x.useQuery)(["USE_IBC_DOMAIN_DETAILS",e,t],()=>L(e,t),{enabled:Boolean(e)}),on=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,x.useMutation)(["USE_RESOLVE_TO_CHAIN_ADDRESS",e,t,n],V,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,resolveToChainAddress:s.mutate,resolveToChainAddressAsync:s.mutateAsync,status:s.status}};var y=require("@tanstack/react-query");var rn=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=d(),s=o==null?void 0:o.bech32Address,r=(0,y.useMutation)(["USE_SEND_TOKENS",e,t,n,s],u=>$({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendTokens:r.mutate,sendTokensAsync:r.mutateAsync,status:r.status}},cn=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=d(),s=o==null?void 0:o.bech32Address,r=(0,y.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,s],u=>X({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendIbcTokens:r.mutate,sendIbcTokensAsync:r.mutateAsync,status:r.status}},an=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=d(),i=s==null?void 0:s.bech32Address,p=(0,y.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return Z(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},un=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=d(),i=s==null?void 0:s.bech32Address,p=(0,y.useMutation)(["USE_EXECUTE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},pn=(e,t)=>(0,y.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:Boolean(e)&&Boolean(t)}),mn=(e,t)=>(0,y.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)});var q=require("@tanstack/react-query");var et=require("react");var tt=()=>((0,et.useEffect)(()=>{let{_reconnect:e}=c.getState();return e&&C(),window.addEventListener("keplr_keystorechange",C),()=>{window.removeEventListener("keplr_keystorechange",C)}},[]),null),de=()=>(tt(),null);var ye=require("react/jsx-runtime"),ln=new q.QueryClient({}),gn=({children:e,grazOptions:t,...n})=>(t&&F(t),(0,ye.jsxs)(q.QueryClientProvider,{client:ln,...n,children:[(0,ye.jsx)(de,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAddressesByIbcDomain,getAvailableWallets,getBalanceStaked,getBalances,getChainAddressByIbcDomain,getIbcDomainByAdress,getIbcDomainDetails,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,isIbcDomainPostfix,mainnetChains,mainnetChainsArray,reconnect,resolveToChainAddress,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useAddressToIbcDomain,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useIbcDomainDetails,useIbcDomainToAddresses,useIbcDomainToChainAddress,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useResolveToChainAddress,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect,validateAddress});
1
+ "use strict";var Ye=Object.create;var b=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},pe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $e(t))!Ze.call(e,s)&&s!==n&&b(e,s,{get:()=>t[s],enumerable:!(r=Je(t,s))||r.enumerable});return e};var me=(e,t,n)=>(n=e!=null?Ye(Xe(e)):{},pe(t||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e)),tt=e=>pe(b({},"__esModule",{value:!0}),e);var Xt={};et(Xt,{GrazEvents:()=>ce,GrazProvider:()=>$t,WALLET_TYPES:()=>U,WalletType:()=>G,checkWallet:()=>D,clearRecentChain:()=>z,configureGraz:()=>O,connect:()=>h,createClients:()=>E,createQueryClient:()=>v,createSigningClients:()=>w,defineChain:()=>wt,defineChainInfo:()=>bt,defineChains:()=>re,disconnect:()=>Q,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>st,getBalanceStaked:()=>P,getBalances:()=>F,getKeplr:()=>ye,getLeap:()=>Ce,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>ot,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>jt,mainnetChainsArray:()=>Dt,reconnect:()=>y,sendIbcTokens:()=>_,sendTokens:()=>N,suggestChain:()=>k,suggestChainAndConnect:()=>W,testnetChains:()=>kt,testnetChainsArray:()=>It,useAccount:()=>g,useActiveChain:()=>Mt,useActiveChainCurrency:()=>Rt,useActiveChainValidators:()=>Qt,useBalance:()=>Bt,useBalanceStaked:()=>vt,useBalances:()=>Oe,useCheckKeplr:()=>Tt,useCheckWallet:()=>A,useClients:()=>Ft,useConnect:()=>Gt,useDisconnect:()=>Ut,useExecuteContract:()=>Lt,useGrazEvents:()=>_e,useInstantiateContract:()=>Ht,useOfflineSigners:()=>Fe,useQueryClient:()=>Ot,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>_t,useSendTokens:()=>Nt,useSigners:()=>qt,useSigningClients:()=>Pt,useSuggestChain:()=>Kt,useSuggestChainAndConnect:()=>Wt});module.exports=tt(Xt);var fe=require("@cosmjs/stargate");var le=me(require("zustand")),j=require("zustand/middleware");var G=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(G||{}),U=["keplr","leap"];var q={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},nt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=(0,le.default)((0,j.subscribeWithSelector)((0,j.persist)(()=>q,nt)));var M=require("@cosmjs/cosmwasm-stargate"),R=require("@cosmjs/stargate"),de=require("@cosmjs/tendermint-rpc");var ge=require("@cosmjs/stargate"),f=require("@cosmjs/utils");var v=(...e)=>{let{tendermint:t}=c.getState().clients,n=new ge.QueryClient(t),r=e.map(s=>s(n));for(let s of r){(0,f.assert)((0,f.isNonNullObject)(s),"Extension must be a non-null object");for(let[i,o]of Object.entries(s)){(0,f.assert)((0,f.isNonNullObject)(o),`Module must be a non-null object. Found type ${typeof o} for module "${i}".`);let u=n[i]||{};n[i]={...u,...o}}}return n};var E=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,s,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),R.SigningStargateClient.connect(n),de.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:s,tendermint:i}},w=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:s={},stargateSignerOptions:i={}}=e,o={url:t,headers:{...n||{}}},[u,p]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(o,r,s),R.SigningStargateClient.connectWithSigner(o,r,i)]);return{cosmWasm:u,stargate:p}};var D=(e=c.getState().walletType)=>{try{return x(e),!0}catch(t){return console.error(t),!1}},ye=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ce=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},x=(e=c.getState().walletType)=>{switch(e){case"keplr":return ye();case"leap":return Ce();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(U.map(e=>[e,D(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),s=(e==null?void 0:e.walletType)||r,i=x(s),o=e||n||t;if(!o)throw new Error("No last known connected chain, connect action requires chain info");c.setState(B=>{let Ve=B._reconnect;return B.activeChain&&B.activeChain.chainId!==o.chainId?{status:"connecting"}:Ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(o.chainId);let u=i.getOfflineSigner(o.chainId),p=i.getOfflineSignerOnlyAmino(o.chainId),m=await i.getOfflineSignerAuto(o.chainId),l=o.gas?fe.GasPrice.fromString(`${o.gas.price}${o.gas.denom}`):void 0,[ue,He,Le]=await Promise.all([i.getKey(o.chainId),E(o),w({...o,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:ue,activeChain:o,clients:He,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:o,signingClients:Le,status:"connected",walletType:s,_reconnect:!0}),ue}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},Q=async(e=!1)=>(c.setState(t=>({...q,recentChain:e?null:t.recentChain})),Promise.resolve()),y=()=>{let{activeChain:e}=c.getState();e&&h(e)};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},ot=()=>c.getState().recentChain,k=async e=>(await x().experimentalSuggestChain(e),e),W=async({chainInfo:e,...t})=>{let n=await k(e);return{account:await h({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:n}};var O=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);var F=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>n[r].getBalance(e,i.coinMinimalDenom)))},P=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},N=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:s})=>{let{signingClients:i,defaultSigningClient:o}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[o].sendTokens(e,t,n,r,s)},_=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:s,timeoutHeight:i,timeoutTimestamp:o,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,r,s,i,o,u,p)},H=async({senderAddress:e,msg:t,fee:n,options:r,label:s,codeId:i})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.instantiate(e,i,t,s,n,r)},L=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:s,memo:i})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.execute(e,r,t,n,i,s)},V=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};var he=require("@keplr-wallet/cosmos"),Ae={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},rt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},it={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ct={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},at={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ut={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},xe=[Ae,rt,it,ct,at,ut],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ae,bip44:{coinType:118},bech32Config:he.Bech32Address.defaultBech32Config("axelar"),currencies:xe,feeCurrencies:xe};var Ee=require("@keplr-wallet/cosmos"),we={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Se=[we],I={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:we,bip44:{coinType:118},bech32Config:Ee.Bech32Address.defaultBech32Config("cosmos"),currencies:Se,feeCurrencies:Se};var je=require("@keplr-wallet/cosmos"),De={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},pt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},mt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},lt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},gt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},dt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},yt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ct={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},ft={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},xt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ht={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},be=[De,pt,mt,lt,gt,dt,yt,Ct,ft,xt,ht],$={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:De,bip44:{coinType:118},bech32Config:je.Bech32Address.defaultBech32Config("juno"),currencies:be,feeCurrencies:be};var Ie=require("@keplr-wallet/cosmos"),Te={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},At={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ke=[Te,At],X={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Te,bip44:{coinType:118},bech32Config:Ie.Bech32Address.defaultBech32Config("osmo"),currencies:ke,feeCurrencies:ke};var Ge=require("@keplr-wallet/cosmos"),Ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Be=[Ue],Z={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("somm"),currencies:Be,feeCurrencies:Be};var ve=require("@keplr-wallet/cosmos"),Me={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},qe=[Me],ee={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:ve.Bech32Address.defaultBech32Config("CRE"),currencies:qe,feeCurrencies:qe,stakeCurrency:Me,coinType:118};var Re=require("@keplr-wallet/cosmos"),te={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},St=[te],ne={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:te,bip44:{coinType:118},bech32Config:Re.Bech32Address.defaultBech32Config("juno"),currencies:St,feeCurrencies:[te],coinType:118};var Qe=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Et=[se],oe={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Et,feeCurrencies:[se],coinType:118};var re=e=>e,wt=e=>e,bt=e=>e,jt=re({axelar:J,cosmos:I,cosmoshub:I,juno:$,osmosis:X,sommelier:Z}),Dt=[J,I,$,X,Z],kt=re({crescent:ee,juno:ne,osmosis:oe}),It=[ee,ne,oe];var C=require("@tanstack/react-query"),Ke=require("react"),We=me(require("zustand/shallow"));var ze=require("@tanstack/react-query");var Tt=()=>A("keplr"),A=e=>{let t=c(s=>e||s.walletType);return(0,ze.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>D(s))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(s=>s.account),r=c(s=>s.status);return(0,Ke.useEffect)(()=>c.subscribe(s=>s.status,(s,i)=>{if(s==="connected"){let o=c.getState();e==null||e({account:o.account,isReconnect:i==="reconnecting"})}s==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:y,status:r}},Oe=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>F(i),{enabled:Boolean(n)})},Bt=(e,t)=>{let{data:n}=Oe(t);return(0,C.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(o=>o.denom===e),{enabled:Boolean(n)})},Gt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,C.useMutation)(["USE_CONNECT",e,t,n],h,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:t,onSuccess:o=>Promise.resolve(n==null?void 0:n(o))}),{data:i}=A();return{connect:o=>s.mutate(o),connectAsync:o=>s.mutateAsync(o),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status}},Ut=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,C.useMutation)(["USE_DISCONNECT",e,t,n],Q,{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=>s.mutate(i),disconnectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},Fe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),We.default),qt=()=>Fe(),vt=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>P(n),{enabled:Boolean(n)})};var S=require("@tanstack/react-query");var Mt=()=>c(e=>e.activeChain),Rt=e=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),Qt=(e,t="BOND_STATUS_BONDED")=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,s,i]})=>s.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Kt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,S.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],k,{onError:(i,o)=>Promise.resolve(e==null?void 0:e(i,o)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,suggest:s.mutate,suggestAsync:s.mutateAsync,status:s.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,S.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],W,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:o=>t==null?void 0:t(o),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))}),{data:i}=A();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status,suggestAndConnect:s.mutate,suggestAndConnectAsync:s.mutateAsync}};var ie=require("@tanstack/react-query");var Pe=require("@tanstack/react-query");var Ot=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Pe.useQuery)(t,({queryKey:[,...r]})=>v(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Ft=e=>{let t=c(s=>s.clients);return(0,ie.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?E(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({clients:s})}})},Pt=e=>{let t=c(s=>s.signingClients);return(0,ie.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?w(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({signingClients:s})}})};var d=require("@tanstack/react-query");var Nt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),s=r==null?void 0:r.bech32Address,o=(0,d.useMutation)(["USE_SEND_TOKENS",e,t,n,s],u=>N({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},_t=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),s=r==null?void 0:r.bech32Address,o=(0,d.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,s],u=>_({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ht=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=(0,d.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return H(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Lt=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=(0,d.useMutation)(["USE_EXECUTE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return L(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Vt=(e,t)=>(0,d.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Yt=(e,t)=>(0,d.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:Boolean(e)&&Boolean(t)});var T=require("@tanstack/react-query");var Ne=require("react");var _e=()=>((0,Ne.useEffect)(()=>{let{_reconnect:e}=c.getState();return e&&y(),window.addEventListener("keplr_keystorechange",y),()=>{window.removeEventListener("keplr_keystorechange",y)}},[]),null),ce=()=>(_e(),null);var ae=require("react/jsx-runtime"),Jt=new T.QueryClient({}),$t=({children:e,grazOptions:t,...n})=>(t&&O(t),(0,ae.jsxs)(T.QueryClientProvider,{client:Jt,...n,children:[(0,ae.jsx)(ce,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{GasPrice as Pe}from"@cosmjs/stargate";import Be from"zustand";import{persist as qe,subscribeWithSelector as Ue}from"zustand/middleware";var P=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(P||{}),O=["keplr","leap"];var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},Re={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=Be(Ue(qe(()=>w,Re)));import{SigningCosmWasmClient as F}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as N}from"@cosmjs/stargate";import{Tendermint34Client as Me}from"@cosmjs/tendermint-rpc";import{QueryClient as Ge}from"@cosmjs/stargate";import{assert as z,isNonNullObject as W}from"@cosmjs/utils";var _=(...e)=>{let{tendermint:t}=c.getState().clients,n=new Ge(t),o=e.map(s=>s(n));for(let s of o){z(W(s),"Extension must be a non-null object");for(let[i,r]of Object.entries(s)){z(W(r),`Module must be a non-null object. Found type ${typeof r} for module "${i}".`);let u=n[i]||{};n[i]={...u,...r}}}return n};var x=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[o,s,i]=await Promise.all([F.connect(n),N.connect(n),Me.connect(e)]);return{cosmWasm:o,stargate:s,tendermint:i}},h=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:o,cosmWasmSignerOptions:s={},stargateSignerOptions:i={}}=e,r={url:t,headers:{...n||{}}},[u,p]=await Promise.all([F.connectWithSigner(r,o,s),N.connectWithSigner(r,o,i)]);return{cosmWasm:u,stargate:p}};var D=(e=c.getState().walletType)=>{try{return y(e),!0}catch(t){return console.error(t),!1}},Ke=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Qe=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},y=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ke();case"leap":return Qe();default:throw new Error("Unknown wallet type")}},Yt=()=>Object.fromEntries(O.map(e=>[e,D(e)]));var C=async e=>{try{let{defaultChain:t,recentChain:n,walletType:o}=c.getState(),s=(e==null?void 0:e.walletType)||o,i=y(s),r=e||n||t;if(!r)throw new Error("No last known connected chain, connect action requires chain info");c.setState(b=>{let ve=b._reconnect;return b.activeChain&&b.activeChain.chainId!==r.chainId?{status:"connecting"}:ve?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(r.chainId);let u=i.getOfflineSigner(r.chainId),p=i.getOfflineSignerOnlyAmino(r.chainId),m=await i.getOfflineSignerAuto(r.chainId),l=r.gas?Pe.fromString(`${r.gas.price}${r.gas.denom}`):void 0,[Q,Te,ke]=await Promise.all([i.getKey(r.chainId),x(r),h({...r,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Q,activeChain:r,clients:Te,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:r,signingClients:ke,status:"connected",walletType:s,_reconnect:!0}),Q}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},H=async(e=!1)=>(c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),d=()=>{let{activeChain:e}=c.getState();e&&C(e)};var L=()=>{c.setState({recentChain:null})},V=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},rn=()=>c.getState().recentChain,j=async e=>(await y().experimentalSuggestChain(e),e),Y=async({chainInfo:e,...t})=>{let n=await j(e);return{account:await C({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:n}};var J=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);import{bech32 as Oe}from"bech32";import{resolveDomainDetails as ze,resolveDomainIntoAddresses as We,resolveDomainIntoChainAddress as _e,resolvePrimaryDomainByAddress as Fe}from"ibc-domains-sdk";var Ne=e=>e.endsWith(".cosmos"),He=(e,t)=>{if(!e)return!1;try{return Oe.decode(e).prefix===t}catch{return!1}},$=async(e,t)=>{let n=await Fe(e,t);if(n.error)throw new Error(n.error);if(n.value===null)return null;let o=n.value;return{domain:o.domain,domainFull:o.domain_full}},X=async(e,t)=>{let n=await We(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},I=async(e,t,n)=>{let o=await _e(e,t,n);if(o.error)throw new Error(o.error);return o.value===null?null:o.value},Z=async(e,t)=>{let n=await ze(e,t);if(n.error)throw new Error(n.error);return n.value===null?null:n.value},ee=async({value:e,prefix:t,isTestnet:n})=>{if(e.trim()==="")throw new Error("value can't be an empty string");if(Ne(e)){let i=await I(e,t,n);if(!i)throw new Error("ibc domain not found");return i}if(!He(e,t))throw new Error("Address is not valid");return e};var te=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:o}=c.getState();return await Promise.all(t.currencies.map(async i=>n[o].getBalance(e,i.coinMinimalDenom)))},ne=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},se=async({senderAddress:e,recipientAddress:t,amount:n,fee:o,memo:s})=>{let{signingClients:i,defaultSigningClient:r}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[r].sendTokens(e,t,n,o,s)},oe=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:o,sourceChannel:s,timeoutHeight:i,timeoutTimestamp:r,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,o,s,i,r,u,p)},re=async({senderAddress:e,msg:t,fee:n,options:o,label:s,codeId:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.instantiate(e,i,t,s,n,o)},ie=async({senderAddress:e,msg:t,fee:n,contractAddress:o,funds:s,memo:i})=>{let{signingClients:r}=c.getState();if(!(r!=null&&r.cosmWasm))throw new Error("CosmWasm signing client is not ready");return r.cosmWasm.execute(e,o,t,n,i,s)},ce=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ae=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,o)};import{Bech32Address as Le}from"@keplr-wallet/cosmos";var pe={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ve={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Ye={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Je={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},$e={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Xe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},ue=[pe,Ve,Ye,Je,$e,Xe],T={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Le.defaultBech32Config("axelar"),currencies:ue,feeCurrencies:ue};import{Bech32Address as Ze}from"@keplr-wallet/cosmos";var le={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},me=[le],A={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:le,bip44:{coinType:118},bech32Config:Ze.defaultBech32Config("cosmos"),currencies:me,feeCurrencies:me};import{Bech32Address as et}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"},tt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},nt={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"},ot={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},rt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},it={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ct={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},at={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"},pt={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ge=[de,tt,nt,st,ot,rt,it,ct,at,ut,pt],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:de,bip44:{coinType:118},bech32Config:et.defaultBech32Config("juno"),currencies:ge,feeCurrencies:ge};import{Bech32Address as mt}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"},lt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ye=[Ce,lt],v={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Ce,bip44:{coinType:118},bech32Config:mt.defaultBech32Config("osmo"),currencies:ye,feeCurrencies:ye};import{Bech32Address as gt}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"},fe=[xe],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:xe,bip44:{coinType:118},bech32Config:gt.defaultBech32Config("somm"),currencies:fe,feeCurrencies:fe};import{Bech32Address as dt}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"},he=[Ae],q={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:dt.defaultBech32Config("CRE"),currencies:he,feeCurrencies:he,stakeCurrency:Ae,coinType:118};import{Bech32Address as yt}from"@keplr-wallet/cosmos";var U={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ct=[U],R={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:yt.defaultBech32Config("juno"),currencies:Ct,feeCurrencies:[U],coinType:118};import{Bech32Address as ft}from"@keplr-wallet/cosmos";var G={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},xt=[G],M={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:ft.defaultBech32Config("osmo"),currencies:xt,feeCurrencies:[G],coinType:118};var Se=e=>e,On=e=>e,zn=e=>e,Wn=Se({axelar:T,cosmos:A,cosmoshub:A,juno:k,osmosis:v,sommelier:B}),_n=[T,A,k,v,B],Fn=Se({crescent:q,juno:R,osmosis:M}),Nn=[q,R,M];import{useMutation as Ee,useQuery as K}from"@tanstack/react-query";import{useEffect as At}from"react";import St from"zustand/shallow";import{useQuery as ht}from"@tanstack/react-query";var Jn=()=>f("keplr"),f=e=>{let t=c(s=>e||s.walletType);return ht(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>D(s))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(s=>s.account),o=c(s=>s.status);return At(()=>c.subscribe(s=>s.status,(s,i)=>{if(s==="connected"){let r=c.getState();e==null||e({account:r.account,isReconnect:i==="reconnecting"})}s==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",reconnect:d,status:o}},Et=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_BALANCES",n],({queryKey:[,i]})=>te(i),{enabled:Boolean(n)})},rs=(e,t)=>{let{data:n}=Et(t);return K(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(r=>r.denom===e),{enabled:Boolean(n)})},is=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Ee(["USE_CONNECT",e,t,n],C,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=f();return{connect:r=>s.mutate(r),connectAsync:r=>s.mutateAsync(r),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status}},cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Ee(["USE_DISCONNECT",e,t,n],H,{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=>s.mutate(i),disconnectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},bt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),St),as=()=>bt(),us=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>ne(n),{enabled:Boolean(n)})};import{useMutation as be,useQuery as we}from"@tanstack/react-query";var ys=()=>c(e=>e.activeChain),Cs=e=>we(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,o]})=>V(o)),fs=(e,t="BOND_STATUS_BONDED")=>we(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,s,i]})=>s.staking.validators(i),{enabled:typeof e<"u"}),xs=()=>({data:c(t=>t.recentChain),clear:L}),hs=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=be(["USE_SUGGEST_CHAIN",e,t,n],j,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,suggest:s.mutate,suggestAsync:s.mutateAsync,status:s.status}},As=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=be(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],Y,{onError:(r,u)=>Promise.resolve(e==null?void 0:e(r,u)),onMutate:r=>t==null?void 0:t(r),onSuccess:r=>Promise.resolve(n==null?void 0:n(r))}),{data:i}=f();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(i),status:s.status,suggestAndConnect:s.mutate,suggestAndConnectAsync:s.mutateAsync}};import{useQuery as De}from"@tanstack/react-query";import{useQuery as wt}from"@tanstack/react-query";var ws=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return wt(t,({queryKey:[,...o]})=>_(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var ks=e=>{let t=c(s=>s.clients);return De(["USE_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?x(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({clients:s})}})},vs=e=>{let t=c(s=>s.signingClients);return De(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,i]})=>s!=null&&s.rpc?h(s):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:s=>{c.setState({signingClients:s})}})};import{useMutation as Dt,useQuery as S}from"@tanstack/react-query";var Gs=({address:e,isTestnet:t})=>S(["USE_ADRESS_TO_IBC_DOMAIN",e,t],()=>$(e,t),{enabled:Boolean(e)}),Ms=({ibcDomain:e,isTestnet:t})=>S(["USE_IBC_DOMAIN_TO_ADDRESSES",e,t],()=>X(e,t),{enabled:Boolean(e)}),Ks=({ibcDomain:e,prefix:t,isTestnet:n})=>S(["USE_IBC_DOMAIN_TO_CHAIN_ADDRESS",t,e,n],()=>I(e,t,n),{enabled:Boolean(e&&t)}),Qs=({ibcDomain:e,isTestnet:t})=>S(["USE_IBC_DOMAIN_DETAILS",e,t],()=>Z(e,t),{enabled:Boolean(e)}),Ps=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Dt(["USE_RESOLVE_TO_CHAIN_ADDRESS",e,t,n],ee,{onError:(i,r)=>Promise.resolve(e==null?void 0:e(i,r)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,resolveToChainAddress:s.mutate,resolveToChainAddressAsync:s.mutateAsync,status:s.status}};import{useMutation as E,useQuery as je}from"@tanstack/react-query";var Fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=g(),s=o==null?void 0:o.bech32Address,r=E(["USE_SEND_TOKENS",e,t,n,s],u=>se({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendTokens:r.mutate,sendTokensAsync:r.mutateAsync,status:r.status}},Ns=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=g(),s=o==null?void 0:o.bech32Address,r=E(["USE_SEND_IBC_TOKENS",e,t,n,s],u=>oe({senderAddress:s,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,sendIbcTokens:r.mutate,sendIbcTokensAsync:r.mutateAsync,status:r.status}},Hs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=E(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return re(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Ls=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=g(),i=s==null?void 0:s.bech32Address,p=E(["USE_EXECUTE_CONTRACT",t,n,o,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return ie(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(o==null?void 0:o(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Vs=(e,t)=>je(["USE_QUERY_SMART",e,t],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return ce(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Ys=(e,t)=>je(["USE_QUERY_RAW",t,e],({queryKey:[,s]})=>{if(!e||!t)throw new Error("address or key undefined");return ae(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as Tt,QueryClientProvider as kt}from"@tanstack/react-query";import{useEffect as jt}from"react";var It=()=>(jt(()=>{let{_reconnect:e}=c.getState();return e&&d(),window.addEventListener("keplr_keystorechange",d),()=>{window.removeEventListener("keplr_keystorechange",d)}},[]),null),Ie=()=>(It(),null);import{jsx as Bt,jsxs as qt}from"react/jsx-runtime";var vt=new Tt({}),oo=({children:e,grazOptions:t,...n})=>(t&&J(t),qt(kt,{client:vt,...n,children:[Bt(Ie,{}),e]}));export{Ie as GrazEvents,oo as GrazProvider,O as WALLET_TYPES,P as WalletType,D as checkWallet,L as clearRecentChain,J as configureGraz,C as connect,x as createClients,_ as createQueryClient,h as createSigningClients,On as defineChain,zn as defineChainInfo,Se as defineChains,H as disconnect,ie as executeContract,V as getActiveChainCurrency,X as getAddressesByIbcDomain,Yt as getAvailableWallets,ne as getBalanceStaked,te as getBalances,I as getChainAddressByIbcDomain,$ as getIbcDomainByAdress,Z as getIbcDomainDetails,Ke as getKeplr,Qe as getLeap,ae as getQueryRaw,ce as getQuerySmart,rn as getRecentChain,y as getWallet,re as instantiateContract,Ne as isIbcDomainPostfix,Wn as mainnetChains,_n as mainnetChainsArray,d as reconnect,ee as resolveToChainAddress,oe as sendIbcTokens,se as sendTokens,j as suggestChain,Y as suggestChainAndConnect,Fn as testnetChains,Nn as testnetChainsArray,g as useAccount,ys as useActiveChain,Cs as useActiveChainCurrency,fs as useActiveChainValidators,Gs as useAddressToIbcDomain,rs as useBalance,us as useBalanceStaked,Et as useBalances,Jn as useCheckKeplr,f as useCheckWallet,ks as useClients,is as useConnect,cs as useDisconnect,Ls as useExecuteContract,It as useGrazEvents,Qs as useIbcDomainDetails,Ms as useIbcDomainToAddresses,Ks as useIbcDomainToChainAddress,Hs as useInstantiateContract,bt as useOfflineSigners,ws as useQueryClient,Ys as useQueryRaw,Vs as useQuerySmart,xs as useRecentChain,Ps as useResolveToChainAddress,Ns as useSendIbcTokens,Fs as useSendTokens,as as useSigners,vs as useSigningClients,hs as useSuggestChain,As as useSuggestChainAndConnect,He as validateAddress};
1
+ import{GasPrice as qe}from"@cosmjs/stargate";import je from"zustand";import{persist as De,subscribeWithSelector as ke}from"zustand/middleware";var Q=(s=>(s.KEPLR="keplr",s.LEAP="leap",s))(Q||{}),z=["keplr","leap"];var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},Ie={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},c=je(ke(De(()=>w,Ie)));import{SigningCosmWasmClient as F}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as Be}from"@cosmjs/tendermint-rpc";import{QueryClient as Te}from"@cosmjs/stargate";import{assert as K,isNonNullObject as W}from"@cosmjs/utils";var O=(...e)=>{let{tendermint:t}=c.getState().clients,s=new Te(t),i=e.map(n=>n(s));for(let n of i){K(W(n),"Extension must be a non-null object");for(let[r,o]of Object.entries(n)){K(W(o),`Module must be a non-null object. Found type ${typeof o} for module "${r}".`);let u=s[r]||{};s[r]={...u,...o}}}return s};var x=async({rpc:e,rpcHeaders:t})=>{let s={url:e,headers:{...t||{}}},[i,n,r]=await Promise.all([F.connect(s),P.connect(s),Be.connect(e)]);return{cosmWasm:i,stargate:n,tendermint:r}},h=async e=>{let{rpc:t,rpcHeaders:s,offlineSignerAuto:i,cosmWasmSignerOptions:n={},stargateSignerOptions:r={}}=e,o={url:t,headers:{...s||{}}},[u,p]=await Promise.all([F.connectWithSigner(o,i,n),P.connectWithSigner(o,i,r)]);return{cosmWasm:u,stargate:p}};var b=(e=c.getState().walletType)=>{try{return y(e),!0}catch(t){return console.error(t),!1}},Ge=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ue=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},y=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ge();case"leap":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(z.map(e=>[e,b(e)]));var C=async e=>{try{let{defaultChain:t,recentChain:s,walletType:i}=c.getState(),n=(e==null?void 0:e.walletType)||i,r=y(n),o=e||s||t;if(!o)throw new Error("No last known connected chain, connect action requires chain info");c.setState(E=>{let be=E._reconnect;return E.activeChain&&E.activeChain.chainId!==o.chainId?{status:"connecting"}:be?{status:"reconnecting"}:{status:"connecting"}}),await r.enable(o.chainId);let u=r.getOfflineSigner(o.chainId),p=r.getOfflineSignerOnlyAmino(o.chainId),m=await r.getOfflineSignerAuto(o.chainId),l=o.gas?qe.fromString(`${o.gas.price}${o.gas.denom}`):void 0,[R,Ee,we]=await Promise.all([r.getKey(o.chainId),x(o),h({...o,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:R,activeChain:o,clients:Ee,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:o,signingClients:we,status:"connected",walletType:n,_reconnect:!0}),R}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},N=async(e=!1)=>(c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),d=()=>{let{activeChain:e}=c.getState();e&&C(e)};var _=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(s=>s.coinMinimalDenom===e)},_t=()=>c.getState().recentChain,j=async e=>(await y().experimentalSuggestChain(e),e),L=async({chainInfo:e,...t})=>{let s=await j(e);return{account:await C({chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,...t}),chain:s}};var V=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e);var Y=async e=>{let{activeChain:t,signingClients:s}=c.getState();if(!t||!s)throw new Error("No connected account detected");let{defaultSigningClient:i}=c.getState();return await Promise.all(t.currencies.map(async r=>s[i].getBalance(e,r.coinMinimalDenom)))},J=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},$=async({senderAddress:e,recipientAddress:t,amount:s,fee:i,memo:n})=>{let{signingClients:r,defaultSigningClient:o}=c.getState();if(!r)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return r[o].sendTokens(e,t,s,i,n)},X=async({senderAddress:e,recipientAddress:t,transferAmount:s,sourcePort:i,sourceChannel:n,timeoutHeight:r,timeoutTimestamp:o,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,s,i,n,r,o,u,p)},Z=async({senderAddress:e,msg:t,fee:s,options:i,label:n,codeId:r})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.instantiate(e,r,t,n,s,i)},ee=async({senderAddress:e,msg:t,fee:s,contractAddress:i,funds:n,memo:r})=>{let{signingClients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm signing client is not ready");return o.cosmWasm.execute(e,i,t,s,r,n)},te=async(e,t)=>{let{clients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm client is not ready");return await s.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return s.cosmWasm.queryContractRaw(e,i)};import{Bech32Address as ve}from"@keplr-wallet/cosmos";var oe={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Re={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Qe={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"},Ke={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},se=[oe,Me,Re,Qe,ze,Ke],D={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:oe,bip44:{coinType:118},bech32Config:ve.defaultBech32Config("axelar"),currencies:se,feeCurrencies:se};import{Bech32Address as We}from"@keplr-wallet/cosmos";var ie={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},re=[ie],A={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:We.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var ae={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Fe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Pe={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ne={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},_e={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},He={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Le={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ve={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ye={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Je={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},$e={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ce=[ae,Fe,Pe,Ne,_e,He,Le,Ve,Ye,Je,$e],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as Xe}from"@keplr-wallet/cosmos";var pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,Ze],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Xe.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as et}from"@keplr-wallet/cosmos";var le={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[le],T={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:et.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as tt}from"@keplr-wallet/cosmos";var de={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ge=[de],B={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:tt.defaultBech32Config("CRE"),currencies:ge,feeCurrencies:ge,stakeCurrency:de,coinType:118};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var G={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},st=[G],U={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("juno"),currencies:st,feeCurrencies:[G],coinType:118};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},rt=[q],v={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:ot.defaultBech32Config("osmo"),currencies:rt,feeCurrencies:[q],coinType:118};var ye=e=>e,wn=e=>e,bn=e=>e,jn=ye({axelar:D,cosmos:A,cosmoshub:A,juno:k,osmosis:I,sommelier:T}),Dn=[D,A,k,I,T],kn=ye({crescent:B,juno:U,osmosis:v}),In=[B,U,v];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as ct}from"react";import at from"zustand/shallow";import{useQuery as it}from"@tanstack/react-query";var qn=()=>f("keplr"),f=e=>{let t=c(n=>e||n.walletType);return it(["USE_CHECK_WALLET",t],({queryKey:[,n]})=>b(n))};var g=({onConnect:e,onDisconnect:t}={})=>{let s=c(n=>n.account),i=c(n=>n.status);return ct(()=>c.subscribe(n=>n.status,(n,r)=>{if(n==="connected"){let o=c.getState();e==null||e({account:o.account,isReconnect:r==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:s,isConnected:Boolean(s),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:d,status:i}},ut=e=>{let{data:t}=g(),s=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",s],({queryKey:[,r]})=>Y(r),{enabled:Boolean(s)})},Fn=(e,t)=>{let{data:s}=ut(t);return M(["USE_BALANCE",s,e,t],({queryKey:[,r]})=>r==null?void 0:r.find(o=>o.denom===e),{enabled:Boolean(s)})},Pn=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=Ce(["USE_CONNECT",e,t,s],C,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:t,onSuccess:o=>Promise.resolve(s==null?void 0:s(o))}),{data:r}=f();return{connect:o=>n.mutate(o),connectAsync:o=>n.mutateAsync(o),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(r),status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=Ce(["USE_DISCONNECT",e,t,s],N,{onError:r=>Promise.resolve(e==null?void 0:e(r,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(s==null?void 0:s(void 0))});return{disconnect:r=>n.mutate(r),disconnectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},pt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),at),_n=()=>pt(),Hn=e=>{let{data:t}=g(),s=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",s],({queryKey:[,r]})=>J(s),{enabled:Boolean(s)})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Xn=()=>c(e=>e.activeChain),Zn=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,i]})=>H(i)),es=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,r]})=>n.staking.validators(r),{enabled:typeof e<"u"}),ts=()=>({data:c(t=>t.recentChain),clear:_}),ns=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=fe(["USE_SUGGEST_CHAIN",e,t,s],j,{onError:(r,o)=>Promise.resolve(e==null?void 0:e(r,o)),onMutate:t,onSuccess:r=>Promise.resolve(s==null?void 0:s(r))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},ss=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,s],L,{onError:(o,u)=>Promise.resolve(e==null?void 0:e(o,u)),onMutate:o=>t==null?void 0:t(o),onSuccess:o=>Promise.resolve(s==null?void 0:s(o))}),{data:r}=f();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(r),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as mt}from"@tanstack/react-query";var cs=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return mt(t,({queryKey:[,...i]})=>O(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var ls=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?x(n):r,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},gs=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?h(n):r,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as S,useQuery as Ae}from"@tanstack/react-query";var hs=({onError:e,onLoading:t,onSuccess:s}={})=>{let{data:i}=g(),n=i==null?void 0:i.bech32Address,o=S(["USE_SEND_TOKENS",e,t,s,n],u=>$({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(s==null?void 0:s(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},As=({onError:e,onLoading:t,onSuccess:s}={})=>{let{data:i}=g(),n=i==null?void 0:i.bech32Address,o=S(["USE_SEND_IBC_TOKENS",e,t,s,n],u=>X({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(s==null?void 0:s(u))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ss=({codeId:e,onError:t,onLoading:s,onSuccess:i})=>{let{data:n}=g(),r=n==null?void 0:n.bech32Address,p=S(["USE_INSTANTIATE_CONTRACT",t,s,i,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,codeId:e};return Z(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:s,onSuccess:m=>Promise.resolve(i==null?void 0:i(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Es=({contractAddress:e,onError:t,onLoading:s,onSuccess:i})=>{let{data:n}=g(),r=n==null?void 0:n.bech32Address,p=S(["USE_EXECUTE_CONTRACT",t,s,i,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:s,onSuccess:m=>Promise.resolve(i==null?void 0:i(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},ws=(e,t)=>Ae(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:Boolean(e)&&Boolean(t)}),bs=(e,t)=>Ae(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as dt,QueryClientProvider as yt}from"@tanstack/react-query";import{useEffect as lt}from"react";var gt=()=>(lt(()=>{let{_reconnect:e}=c.getState();return e&&d(),window.addEventListener("keplr_keystorechange",d),()=>{window.removeEventListener("keplr_keystorechange",d)}},[]),null),Se=()=>(gt(),null);import{jsx as ft,jsxs as xt}from"react/jsx-runtime";var Ct=new dt({}),qs=({children:e,grazOptions:t,...s})=>(t&&V(t),xt(yt,{client:Ct,...s,children:[ft(Se,{}),e]}));export{Se as GrazEvents,qs as GrazProvider,z as WALLET_TYPES,Q as WalletType,b as checkWallet,_ as clearRecentChain,V as configureGraz,C as connect,x as createClients,O as createQueryClient,h as createSigningClients,wn as defineChain,bn as defineChainInfo,ye as defineChains,N as disconnect,ee as executeContract,H as getActiveChainCurrency,Mt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,Ge as getKeplr,Ue as getLeap,ne as getQueryRaw,te as getQuerySmart,_t as getRecentChain,y as getWallet,Z as instantiateContract,jn as mainnetChains,Dn as mainnetChainsArray,d as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,kn as testnetChains,In as testnetChainsArray,g as useAccount,Xn as useActiveChain,Zn as useActiveChainCurrency,es as useActiveChainValidators,Fn as useBalance,Hn as useBalanceStaked,ut as useBalances,qn as useCheckKeplr,f as useCheckWallet,ls as useClients,Pn as useConnect,Nn as useDisconnect,Es as useExecuteContract,gt as useGrazEvents,Ss as useInstantiateContract,pt as useOfflineSigners,cs as useQueryClient,bs as useQueryRaw,ws as useQuerySmart,ts as useRecentChain,As as useSendIbcTokens,hs as useSendTokens,_n as useSigners,gs as useSigningClients,ns as useSuggestChain,ss 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.34",
4
+ "version": "0.0.35",
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",
@@ -43,9 +43,7 @@
43
43
  "@keplr-wallet/types": "^0",
44
44
  "@tanstack/react-query": "^4",
45
45
  "arg": "^5",
46
- "bech32": "2.0.0",
47
46
  "cosmos-directory-client": "0.0.6",
48
- "ibc-domains-sdk": "1.0.2",
49
47
  "zustand": "^4"
50
48
  },
51
49
  "devDependencies": {