graz 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +144 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -241,6 +241,37 @@ 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;
|
|
255
|
+
imageData: string;
|
|
256
|
+
twitterId: string;
|
|
257
|
+
discordId: string;
|
|
258
|
+
telegramId: string;
|
|
259
|
+
keybaseId: string;
|
|
260
|
+
pgpPublicKey: string;
|
|
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
|
+
|
|
244
275
|
declare const getBalances: (bech32Address: string) => Promise<Coin[]>;
|
|
245
276
|
declare const getBalanceStaked: (bech32Address: string) => Promise<Coin | null>;
|
|
246
277
|
interface SendTokensArgs {
|
|
@@ -746,6 +777,111 @@ declare const useClients: (args?: CreateClientArgs) => UseQueryResult<GrazStore[
|
|
|
746
777
|
*/
|
|
747
778
|
declare const useSigningClients: (args?: CreateSigningClientArgs) => UseQueryResult<GrazStore["signingClients"]>;
|
|
748
779
|
|
|
780
|
+
/**
|
|
781
|
+
* graz query hook to retrieve an ibc domain from given address.
|
|
782
|
+
*
|
|
783
|
+
* @param address - Optional, if address undefined this hook won't run
|
|
784
|
+
* @param isTestnet - Optional for pointing to testnet
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```ts
|
|
788
|
+
* import { useAddressToIbcDomain } from "graz";
|
|
789
|
+
*
|
|
790
|
+
* // basic example
|
|
791
|
+
* const { data, isFetching, refetch, ... } = useAddressToIbcDomain({
|
|
792
|
+
* address: "cosmos1g3jjhgkyf36pjhe7u5cw8j9u6cgl8x929ej430",
|
|
793
|
+
* });
|
|
794
|
+
*
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
declare const useAddressToIbcDomain: ({ address, isTestnet, }: {
|
|
798
|
+
address?: string | undefined;
|
|
799
|
+
isTestnet?: boolean | undefined;
|
|
800
|
+
}) => UseQueryResult<AddressToIbcDomainReturnValue | null>;
|
|
801
|
+
/**
|
|
802
|
+
* graz query hook to retrieve an addresses from given ibc domain.
|
|
803
|
+
*
|
|
804
|
+
* @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
|
|
805
|
+
* @param isTestnet - Optional for pointing to testnet
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* ```ts
|
|
809
|
+
* import { useIbcDomainToAddresses } from "graz";
|
|
810
|
+
*
|
|
811
|
+
* // basic example
|
|
812
|
+
* const { data, isFetching, refetch, ... } = useIbcDomainToAddresses({
|
|
813
|
+
* ibcDomain: "kikiding.cosmos",
|
|
814
|
+
* });
|
|
815
|
+
*
|
|
816
|
+
* ```
|
|
817
|
+
*/
|
|
818
|
+
declare const useIbcDomainToAddresses: ({ ibcDomain, isTestnet, }: {
|
|
819
|
+
ibcDomain?: string | undefined;
|
|
820
|
+
isTestnet?: boolean | undefined;
|
|
821
|
+
}) => UseQueryResult<string[] | null>;
|
|
822
|
+
/**
|
|
823
|
+
* graz query hook to retrieve an address from given ibc domain and prefix.
|
|
824
|
+
*
|
|
825
|
+
* @param ibcDomain - Optional ibc domain, if ibc domain undefined this hook won't run
|
|
826
|
+
* @param prefix - Optional string or bech32 prefix of the destination chain, for instance "cosmos", "somm", etc
|
|
827
|
+
* @param isTestnet - Optional for pointing to testnet
|
|
828
|
+
*
|
|
829
|
+
* @example
|
|
830
|
+
* ```ts
|
|
831
|
+
* import { useIbcDomainToChainAddress } from "graz";
|
|
832
|
+
*
|
|
833
|
+
* // basic example
|
|
834
|
+
* const { data, isFetching, refetch, ... } = useIbcDomainToChainAddress({
|
|
835
|
+
* ibcDomain: "kikiding.cosmos",
|
|
836
|
+
* prefix: "osmo"
|
|
837
|
+
* });
|
|
838
|
+
*
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
declare const useIbcDomainToChainAddress: ({ ibcDomain, prefix, isTestnet, }: {
|
|
842
|
+
ibcDomain?: string | undefined;
|
|
843
|
+
prefix?: ChainPrefix | undefined;
|
|
844
|
+
isTestnet?: boolean | undefined;
|
|
845
|
+
}) => UseQueryResult<string | null>;
|
|
846
|
+
declare const useIbcDomainDetails: ({ ibcDomain, isTestnet }: {
|
|
847
|
+
ibcDomain?: string | undefined;
|
|
848
|
+
isTestnet?: boolean | undefined;
|
|
849
|
+
}) => UseQueryResult<DomainDetails | null, unknown>;
|
|
850
|
+
declare type UseResolveToChainAddressArgs = MutationEventArgs<ResolveToChainAddressArgs, string>;
|
|
851
|
+
/**
|
|
852
|
+
* graz mutation hook to resolve an Ibc domain or an address to bech32 address from given string
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* ```ts
|
|
856
|
+
* import { useResolveToChainAddress } from "graz";
|
|
857
|
+
*
|
|
858
|
+
* // basic example
|
|
859
|
+
* const { resolveToChainAddress } = useResolveToChainAddress();
|
|
860
|
+
*
|
|
861
|
+
* // with event arguments
|
|
862
|
+
* useResolveToChainAddress({
|
|
863
|
+
* onError: (err, args) => { ... },
|
|
864
|
+
* onLoading: () => { ... },
|
|
865
|
+
* onSuccess: ({ account, address }) => { ... },
|
|
866
|
+
* });
|
|
867
|
+
*
|
|
868
|
+
* // resolveToChainAddress usage
|
|
869
|
+
* resolveToChainAddress({
|
|
870
|
+
* value: "kikiding.cosmos",
|
|
871
|
+
* prefix: "osmo"
|
|
872
|
+
* ...
|
|
873
|
+
* });
|
|
874
|
+
* ```
|
|
875
|
+
*/
|
|
876
|
+
declare const useResolveToChainAddress: ({ onError, onLoading, onSuccess }?: UseResolveToChainAddressArgs) => {
|
|
877
|
+
error: unknown;
|
|
878
|
+
isLoading: boolean;
|
|
879
|
+
isSuccess: boolean;
|
|
880
|
+
resolveToChainAddress: _tanstack_react_query.UseMutateFunction<string, unknown, ResolveToChainAddressArgs, unknown>;
|
|
881
|
+
resolveToChainAddressAsync: _tanstack_react_query.UseMutateAsyncFunction<string, unknown, ResolveToChainAddressArgs, unknown>;
|
|
882
|
+
status: "error" | "idle" | "loading" | "success";
|
|
883
|
+
};
|
|
884
|
+
|
|
749
885
|
/**
|
|
750
886
|
* graz mutation hook to send tokens. Note: if `senderAddress` undefined, it will use current connected account address.
|
|
751
887
|
*
|
|
@@ -815,7 +951,10 @@ declare type UseInstantiateContractArgs<Message extends Record<string, unknown>>
|
|
|
815
951
|
* })
|
|
816
952
|
*
|
|
817
953
|
* const instantiateMessage = { foo: 'bar' };
|
|
818
|
-
* instantiateMyContract(
|
|
954
|
+
* instantiateMyContract({
|
|
955
|
+
* msg: instatiateMessage,
|
|
956
|
+
* label: "test"
|
|
957
|
+
* });
|
|
819
958
|
* ```
|
|
820
959
|
*/
|
|
821
960
|
declare const useInstantiateContract: <Message extends Record<string, unknown>>({ codeId, onError, onLoading, onSuccess, }: UseInstantiateContractArgs<Message>) => {
|
|
@@ -847,7 +986,9 @@ declare type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
|
|
|
847
986
|
*
|
|
848
987
|
* const contractAddress = "cosmosfoobarbaz";
|
|
849
988
|
* const { executeContract } = useExecuteContract<ExecuteMessage>({ contractAddress });
|
|
850
|
-
* executeContract({
|
|
989
|
+
* executeContract({ msg: {
|
|
990
|
+
* foo: "bar"
|
|
991
|
+
* }}, {
|
|
851
992
|
* onSuccess: (data: GreetResponse) => console.log('Got message:', data.message);
|
|
852
993
|
* });
|
|
853
994
|
* ```
|
|
@@ -940,4 +1081,4 @@ declare const useGrazEvents: () => null;
|
|
|
940
1081
|
*/
|
|
941
1082
|
declare const GrazEvents: FC;
|
|
942
1083
|
|
|
943
|
-
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 };
|
|
1084
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,n)},V=async(e,t)=>{let{signingClients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{signingClients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing 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})},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})};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};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});
|
|
1
|
+
"use strict";var rt=Object.create;var j=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=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 at(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(ct(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:()=>cn,useOfflineSigners:()=>Xe,useQueryClient:()=>$t,useQueryRaw:()=>mn,useQuerySmart:()=>pn,useRecentChain:()=>Vt,useResolveToChainAddress:()=>on,useSendIbcTokens:()=>an,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},a=(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}=a.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[r,i]of Object.entries(s)){(0,h.assert)((0,h.isNonNullObject)(i),`Module must be a non-null object. Found type ${typeof i} for module "${r}".`);let u=n[r]||{};n[r]={...u,...i}}}return n};var w=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[o,s,r]=await Promise.all([Q.SigningCosmWasmClient.connect(n),P.SigningStargateClient.connect(n),Se.Tendermint34Client.connect(e)]);return{cosmWasm:o,stargate:s,tendermint:r}},D=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:o,cosmWasmSignerOptions:s={},stargateSignerOptions:r={}}=e,i={url:t,headers:{...n||{}}},[u,p]=await Promise.all([Q.SigningCosmWasmClient.connectWithSigner(i,o,s),P.SigningStargateClient.connectWithSigner(i,o,r)]);return{cosmWasm:u,stargate:p}};var T=(e=a.getState().walletType)=>{try{return A(e),!0}catch(t){return console.error(t),!1}},Ee=()=>{if(typeof window.keplr<"u")return window.keplr;throw a.getState()._notFoundFn(),new Error("window.keplr is not defined")},be=()=>{if(typeof window.leap<"u")return window.leap;throw a.getState()._notFoundFn(),new Error("window.leap is not defined")},A=(e=a.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}=a.getState(),s=(e==null?void 0:e.walletType)||o,r=A(s),i=e||n||t;if(!i)throw new Error("No last known connected chain, connect action requires chain info");a.setState(U=>{let ot=U._reconnect;return U.activeChain&&U.activeChain.chainId!==i.chainId?{status:"connecting"}:ot?{status:"reconnecting"}:{status:"connecting"}}),await r.enable(i.chainId);let u=r.getOfflineSigner(i.chainId),p=r.getOfflineSignerOnlyAmino(i.chainId),m=await r.getOfflineSignerAuto(i.chainId),l=i.gas?we.GasPrice.fromString(`${i.gas.price}${i.gas.denom}`):void 0,[Ce,nt,st]=await Promise.all([r.getKey(i.chainId),w(i),D({...i,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return a.setState({account:Ce,activeChain:i,clients:nt,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:i,signingClients:st,status:"connected",walletType:s,_reconnect:!0}),Ce}catch(t){throw a.getState().account===null&&a.setState({status:"disconnected"}),t}},O=async(e=!1)=>(a.setState(t=>({...M,recentChain:e?null:t.recentChain})),Promise.resolve()),C=()=>{let{activeChain:e}=a.getState();e&&S(e)};var z=()=>{a.setState({recentChain:null})},W=e=>{let{activeChain:t}=a.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},dt=()=>a.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={})=>(a.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 r=await v(e,t,n);if(!r)throw new Error("ibc domain not found");return r}if(!Ie(e,t))throw new Error("Address is not valid");return e};var Y=async e=>{let{activeChain:t,signingClients:n}=a.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:o}=a.getState();return await Promise.all(t.currencies.map(async r=>n[o].getBalance(e,r.coinMinimalDenom)))},J=async e=>{let{clients:t}=a.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:r,defaultSigningClient:i}=a.getState();if(!r)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return r[i].sendTokens(e,t,n,o,s)},X=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:o,sourceChannel:s,timeoutHeight:r,timeoutTimestamp:i,fee:u,memo:p})=>{let{signingClients:m}=a.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,r,i,u,p)},Z=async({senderAddress:e,msg:t,fee:n,options:o,label:s,codeId:r})=>{let{signingClients:i}=a.getState();if(!(i!=null&&i.cosmWasm))throw new Error("CosmWasm signing client is not ready");return i.cosmWasm.instantiate(e,r,t,s,n,o)},ee=async({senderAddress:e,msg:t,fee:n,contractAddress:o})=>{let{signingClients:s}=a.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,o,t,n)},te=async(e,t)=>{let{signingClients:n}=a.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{signingClients:n}=a.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing 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],ae={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"),ce={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Bt=[ce],ue={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ce,bip44:{coinType:118},bech32Config:He.Bech32Address.defaultBech32Config("juno"),currencies:Bt,feeCurrencies:[ce],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:ae,juno:ue,osmosis:me}),Qt=[ae,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=a(s=>e||s.walletType);return(0,Ve.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>T(s))};var d=({onConnect:e,onDisconnect:t}={})=>{let n=a(s=>s.account),o=a(s=>s.status);return(0,Ye.useEffect)(()=>a.subscribe(s=>s.status,(s,r)=>{if(s==="connected"){let i=a.getState();e==null||e({account:i.account,isReconnect:r==="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:[,r]})=>Y(r),{enabled:Boolean(n)})},Ot=(e,t)=>{let{data:n}=$e(t);return(0,f.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,r]})=>r==null?void 0:r.find(i=>i.denom===e),{enabled:Boolean(n)})},zt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,f.useMutation)(["USE_CONNECT",e,t,n],S,{onError:(i,u)=>Promise.resolve(e==null?void 0:e(i,u)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))}),{data:r}=E();return{connect:i=>s.mutate(i),connectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(r),status:s.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=(0,f.useMutation)(["USE_DISCONNECT",e,t,n],O,{onError:r=>Promise.resolve(e==null?void 0:e(r,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:r=>s.mutate(r),disconnectAsync:r=>s.mutateAsync(r),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},Xe=()=>a(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:[,r]})=>J(n),{enabled:Boolean(n)})};var b=require("@tanstack/react-query");var Nt=()=>a(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,r]})=>s.staking.validators(r),{enabled:typeof e<"u"}),Vt=()=>({data:a(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:(r,i)=>Promise.resolve(e==null?void 0:e(r,i)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))});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:(i,u)=>Promise.resolve(e==null?void 0:e(i,u)),onMutate:i=>t==null?void 0:t(i),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))}),{data:r}=E();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(r),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=a(s=>s.clients);return(0,ge.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,s,r]})=>s!=null&&s.rpc?w(s):r,{refetchOnMount:!1,refetchOnWindowFocus:!1})},Zt=e=>{let t=a(s=>s.signingClients);return(0,ge.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,r]})=>s!=null&&s.rpc?D(s):r,{refetchOnMount:!1,refetchOnWindowFocus:!1})};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:(r,i)=>Promise.resolve(e==null?void 0:e(r,i)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))});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,i=(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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},an=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=d(),s=o==null?void 0:o.bech32Address,i=(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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},cn=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=d(),r=s==null?void 0:s.bech32Address,p=(0,y.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,o,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: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(),r=s==null?void 0:s.bech32Address,p=(0,y.useMutation)(["USE_EXECUTE_CONTRACT",t,n,o,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,contractAddress:e};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}=a.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});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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),r=e.map(n=>n(s));for(let n of r){K(W(n),"Extension must be a non-null object");for(let[i,o]of Object.entries(n)){K(W(o),`Module must be a non-null object. Found type ${typeof o} for module "${i}".`);let u=s[i]||{};s[i]={...u,...o}}}return s};var x=async({rpc:e,rpcHeaders:t})=>{let s={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([F.connect(s),P.connect(s),Be.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},h=async e=>{let{rpc:t,rpcHeaders:s,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,o={url:t,headers:{...s||{}}},[u,p]=await Promise.all([F.connectWithSigner(o,r,n),P.connectWithSigner(o,r,i)]);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:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=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 i.enable(o.chainId);let u=i.getOfflineSigner(o.chainId),p=i.getOfflineSignerOnlyAmino(o.chainId),m=await i.getOfflineSignerAuto(o.chainId),l=o.gas?qe.fromString(`${o.gas.price}${o.gas.denom}`):void 0,[R,Ee,we]=await Promise.all([i.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:r}=c.getState();return await Promise.all(t.currencies.map(async i=>s[r].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:s,fee:r,memo:n})=>{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,s,r,n)},X=async({senderAddress:e,recipientAddress:t,transferAmount:s,sourcePort:r,sourceChannel:n,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,s,r,n,i,o,u,p)},Z=async({senderAddress:e,msg:t,fee:s,options:r,label:n,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,n,s,r)},ee=async({senderAddress:e,msg:t,fee:s,contractAddress:r})=>{let{signingClients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing client is not ready");return n.cosmWasm.execute(e,r,t,s)},te=async(e,t)=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return await s.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");let r=new TextEncoder().encode(t);return s.cosmWasm.queryContractRaw(e,r)};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),r=c(n=>n.status);return ct(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let o=c.getState();e==null||e({account:o.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:s,isConnected:Boolean(s),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:d,status:r}},ut=e=>{let{data:t}=g(),s=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",s],({queryKey:[,i]})=>Y(i),{enabled:Boolean(s)})},Fn=(e,t)=>{let{data:s}=ut(t);return M(["USE_BALANCE",s,e,t],({queryKey:[,i]})=>i==null?void 0:i.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:i}=f();return{connect:o=>n.mutate(o),connectAsync:o=>n.mutateAsync(o),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:s}={})=>{let n=Ce(["USE_DISCONNECT",e,t,s],N,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(s==null?void 0:s(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},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:[,i]})=>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:[,r]})=>H(r)),es=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{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:(i,o)=>Promise.resolve(e==null?void 0:e(i,o)),onMutate:t,onSuccess:i=>Promise.resolve(s==null?void 0:s(i))});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:i}=f();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),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:[,...r]})=>O(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var ls=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?x(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})},gs=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?h(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1})};import{useMutation as S,useQuery as Ae}from"@tanstack/react-query";var hs=({onError:e,onLoading:t,onSuccess:s}={})=>{let{data:r}=g(),n=r==null?void 0:r.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:r}=g(),n=r==null?void 0:r.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:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=S(["USE_INSTANTIATE_CONTRACT",t,s,r,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:s,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}},Es=({contractAddress:e,onError:t,onLoading:s,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=S(["USE_EXECUTE_CONTRACT",t,s,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:s,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}},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};
|
|
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},a=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}=a.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[r,i]of Object.entries(s)){z(W(i),`Module must be a non-null object. Found type ${typeof i} for module "${r}".`);let u=n[r]||{};n[r]={...u,...i}}}return n};var x=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[o,s,r]=await Promise.all([F.connect(n),N.connect(n),Me.connect(e)]);return{cosmWasm:o,stargate:s,tendermint:r}},h=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:o,cosmWasmSignerOptions:s={},stargateSignerOptions:r={}}=e,i={url:t,headers:{...n||{}}},[u,p]=await Promise.all([F.connectWithSigner(i,o,s),N.connectWithSigner(i,o,r)]);return{cosmWasm:u,stargate:p}};var D=(e=a.getState().walletType)=>{try{return y(e),!0}catch(t){return console.error(t),!1}},Ke=()=>{if(typeof window.keplr<"u")return window.keplr;throw a.getState()._notFoundFn(),new Error("window.keplr is not defined")},Qe=()=>{if(typeof window.leap<"u")return window.leap;throw a.getState()._notFoundFn(),new Error("window.leap is not defined")},y=(e=a.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}=a.getState(),s=(e==null?void 0:e.walletType)||o,r=y(s),i=e||n||t;if(!i)throw new Error("No last known connected chain, connect action requires chain info");a.setState(b=>{let ve=b._reconnect;return b.activeChain&&b.activeChain.chainId!==i.chainId?{status:"connecting"}:ve?{status:"reconnecting"}:{status:"connecting"}}),await r.enable(i.chainId);let u=r.getOfflineSigner(i.chainId),p=r.getOfflineSignerOnlyAmino(i.chainId),m=await r.getOfflineSignerAuto(i.chainId),l=i.gas?Pe.fromString(`${i.gas.price}${i.gas.denom}`):void 0,[Q,Te,ke]=await Promise.all([r.getKey(i.chainId),x(i),h({...i,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return a.setState({account:Q,activeChain:i,clients:Te,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:i,signingClients:ke,status:"connected",walletType:s,_reconnect:!0}),Q}catch(t){throw a.getState().account===null&&a.setState({status:"disconnected"}),t}},H=async(e=!1)=>(a.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),d=()=>{let{activeChain:e}=a.getState();e&&C(e)};var L=()=>{a.setState({recentChain:null})},V=e=>{let{activeChain:t}=a.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},rn=()=>a.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={})=>(a.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 r=await I(e,t,n);if(!r)throw new Error("ibc domain not found");return r}if(!He(e,t))throw new Error("Address is not valid");return e};var te=async e=>{let{activeChain:t,signingClients:n}=a.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:o}=a.getState();return await Promise.all(t.currencies.map(async r=>n[o].getBalance(e,r.coinMinimalDenom)))},ne=async e=>{let{clients:t}=a.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:r,defaultSigningClient:i}=a.getState();if(!r)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return r[i].sendTokens(e,t,n,o,s)},oe=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:o,sourceChannel:s,timeoutHeight:r,timeoutTimestamp:i,fee:u,memo:p})=>{let{signingClients:m}=a.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,r,i,u,p)},re=async({senderAddress:e,msg:t,fee:n,options:o,label:s,codeId:r})=>{let{signingClients:i}=a.getState();if(!(i!=null&&i.cosmWasm))throw new Error("CosmWasm signing client is not ready");return i.cosmWasm.instantiate(e,r,t,s,n,o)},ie=async({senderAddress:e,msg:t,fee:n,contractAddress:o})=>{let{signingClients:s}=a.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,o,t,n)},ae=async(e,t)=>{let{signingClients:n}=a.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},ce=(e,t)=>{let{signingClients:n}=a.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm signing 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"},at={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},ct={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,at,ct,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=a(s=>e||s.walletType);return ht(["USE_CHECK_WALLET",t],({queryKey:[,s]})=>D(s))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=a(s=>s.account),o=a(s=>s.status);return At(()=>a.subscribe(s=>s.status,(s,r)=>{if(s==="connected"){let i=a.getState();e==null||e({account:i.account,isReconnect:r==="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:[,r]})=>te(r),{enabled:Boolean(n)})},rs=(e,t)=>{let{data:n}=Et(t);return K(["USE_BALANCE",n,e,t],({queryKey:[,r]})=>r==null?void 0:r.find(i=>i.denom===e),{enabled:Boolean(n)})},is=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Ee(["USE_CONNECT",e,t,n],C,{onError:(i,u)=>Promise.resolve(e==null?void 0:e(i,u)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))}),{data:r}=f();return{connect:i=>s.mutate(i),connectAsync:i=>s.mutateAsync(i),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(r),status:s.status}},as=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=Ee(["USE_DISCONNECT",e,t,n],H,{onError:r=>Promise.resolve(e==null?void 0:e(r,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:r=>s.mutate(r),disconnectAsync:r=>s.mutateAsync(r),error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,status:s.status}},bt=()=>a(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),St),cs=()=>bt(),us=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return K(["USE_BALANCE_STAKED",n],({queryKey:[,r]})=>ne(n),{enabled:Boolean(n)})};import{useMutation as be,useQuery as we}from"@tanstack/react-query";var ys=()=>a(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,r]})=>s.staking.validators(r),{enabled:typeof e<"u"}),xs=()=>({data:a(t=>t.recentChain),clear:L}),hs=({onError:e,onLoading:t,onSuccess:n}={})=>{let s=be(["USE_SUGGEST_CHAIN",e,t,n],j,{onError:(r,i)=>Promise.resolve(e==null?void 0:e(r,i)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))});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:(i,u)=>Promise.resolve(e==null?void 0:e(i,u)),onMutate:i=>t==null?void 0:t(i),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))}),{data:r}=f();return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,isSupported:Boolean(r),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=a(s=>s.clients);return De(["USE_CLIENTS",e,t],({queryKey:[,s,r]})=>s!=null&&s.rpc?x(s):r,{refetchOnMount:!1,refetchOnWindowFocus:!1})},vs=e=>{let t=a(s=>s.signingClients);return De(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,s,r]})=>s!=null&&s.rpc?h(s):r,{refetchOnMount:!1,refetchOnWindowFocus:!1})};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:(r,i)=>Promise.resolve(e==null?void 0:e(r,i)),onMutate:t,onSuccess:r=>Promise.resolve(n==null?void 0:n(r))});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,i=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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},Ns=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=g(),s=o==null?void 0:o.bech32Address,i=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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Hs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:s}=g(),r=s==null?void 0:s.bech32Address,p=E(["USE_INSTANTIATE_CONTRACT",t,n,o,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,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(),r=s==null?void 0:s.bech32Address,p=E(["USE_EXECUTE_CONTRACT",t,n,o,e,r],m=>{if(!r)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:r,contractAddress:e};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 ae(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 ce(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}=a.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,ce as getQueryRaw,ae 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,as 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,cs as useSigners,vs as useSigningClients,hs as useSuggestChain,As as useSuggestChainAndConnect,He as validateAddress};
|
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.
|
|
4
|
+
"version": "0.0.29",
|
|
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,7 +43,9 @@
|
|
|
43
43
|
"@keplr-wallet/types": "^0",
|
|
44
44
|
"@tanstack/react-query": "^4",
|
|
45
45
|
"arg": "^5",
|
|
46
|
+
"bech32": "2.0.0",
|
|
46
47
|
"cosmos-directory-client": "0.0.6",
|
|
48
|
+
"ibc-domains-sdk": "1.0.2",
|
|
47
49
|
"zustand": "^4"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|