graz 0.3.4-alpha.1 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.gitkeep +0 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +1 -1
- package/package.json +10 -11
package/dist/.gitkeep
CHANGED
|
File without changes
|
package/dist/index.d.mts
CHANGED
|
@@ -364,6 +364,24 @@ declare const getMetamaskSnapLeap: () => Wallet;
|
|
|
364
364
|
*/
|
|
365
365
|
declare const getVectis: () => Wallet;
|
|
366
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Function to return okxwallet object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* try {
|
|
373
|
+
* const okxWallet = getOkx();
|
|
374
|
+
* } catch (error: Error) {
|
|
375
|
+
* console.error(error.message);
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* @see https://www.okx.com/web3/build/docs/sdks/chains/cosmos/provider
|
|
380
|
+
*/
|
|
381
|
+
declare const getOkx: () => Wallet;
|
|
382
|
+
|
|
383
|
+
declare const getPara: () => Wallet;
|
|
384
|
+
|
|
367
385
|
interface GetWalletConnectParams {
|
|
368
386
|
encoding: BufferEncoding;
|
|
369
387
|
walletType: WalletType.WC_KEPLR_MOBILE | WalletType.WC_LEAP_MOBILE | WalletType.WC_COSMOSTATION_MOBILE | WalletType.WC_CLOT_MOBILE;
|
|
@@ -1113,4 +1131,4 @@ declare const useGrazEvents: () => null;
|
|
|
1113
1131
|
*/
|
|
1114
1132
|
declare const GrazEvents: FC;
|
|
1115
1133
|
|
|
1116
|
-
export { type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
|
1134
|
+
export { type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getOkx, getPara, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.d.ts
CHANGED
|
@@ -364,6 +364,24 @@ declare const getMetamaskSnapLeap: () => Wallet;
|
|
|
364
364
|
*/
|
|
365
365
|
declare const getVectis: () => Wallet;
|
|
366
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Function to return okxwallet object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* try {
|
|
373
|
+
* const okxWallet = getOkx();
|
|
374
|
+
* } catch (error: Error) {
|
|
375
|
+
* console.error(error.message);
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* @see https://www.okx.com/web3/build/docs/sdks/chains/cosmos/provider
|
|
380
|
+
*/
|
|
381
|
+
declare const getOkx: () => Wallet;
|
|
382
|
+
|
|
383
|
+
declare const getPara: () => Wallet;
|
|
384
|
+
|
|
367
385
|
interface GetWalletConnectParams {
|
|
368
386
|
encoding: BufferEncoding;
|
|
369
387
|
walletType: WalletType.WC_KEPLR_MOBILE | WalletType.WC_LEAP_MOBILE | WalletType.WC_COSMOSTATION_MOBILE | WalletType.WC_CLOT_MOBILE;
|
|
@@ -1113,4 +1131,4 @@ declare const useGrazEvents: () => null;
|
|
|
1113
1131
|
*/
|
|
1114
1132
|
declare const GrazEvents: FC;
|
|
1115
1133
|
|
|
1116
|
-
export { type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
|
1134
|
+
export { type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getOkx, getPara, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,8 @@ exports.getKeplr = pe;
|
|
|
44
44
|
exports.getLeap = de;
|
|
45
45
|
exports.getMetamaskSnapLeap = et;
|
|
46
46
|
exports.getOfflineSigners = pt;
|
|
47
|
+
exports.getOkx = fe;
|
|
48
|
+
exports.getPara = tt;
|
|
47
49
|
exports.getQueryRaw = St;
|
|
48
50
|
exports.getQuerySmart = wt;
|
|
49
51
|
exports.getRecentChainIds = rr;
|
package/dist/index.mjs
CHANGED
|
@@ -17,4 +17,4 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
17
17
|
|
|
18
18
|
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var Be=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var Le=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Ue=(e,t,n)=>t in e?Bt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))Gt.call(t,n)&&Ue(e,n,t[n]);if(Be)for(var n of Be(t))Ft.call(t,n)&&Ue(e,n,t[n]);return e},G=(e,t)=>Lt(e,Ut(t));var l=(e,t,n)=>new Promise((a,i)=>{var o=c=>{try{r(n.next(c));}catch(f){i(f);}},s=c=>{try{r(n.throw(c));}catch(f){i(f);}},r=c=>c.done?a(c.value):Promise.resolve(c.value).then(o,s);r((n=n.apply(e,t)).next());});var Ge=(e,t,n)=>(t=e[Le("asyncIterator")])?t.call(e):(e=e[Le("iterator")](),t={},n=(a,i)=>(i=e[a])&&(t[a]=o=>new Promise((s,r,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(f=>s({value:f,done:c}),r)))),n("next"),n("return"),t);var te="graz-reconnect-session";var Fe=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p.PARA="para",p))(Fe||{}),ze=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},oe={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},jt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},C=create(subscribeWithSelector(persist(()=>oe,jt))),u=create(subscribeWithSelector(persist(()=>qt,Qt)));var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var He={},Xe=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var m;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let r=(m=o.split("MetaMask/v")[1])==null?void 0:m.split(".")[0];if(!(Number(r)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,true}),enable:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(G(k({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,r)=>l(void 0,null,function*(){return t.signAmino(o,s,r)}),getKey:o=>l(void 0,null,function*(){return typeof He[o]!="undefined"?He[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,r)=>l(void 0,null,function*(){return t.signDirect(o,s,r)}),signArbitrary:(o,s,r)=>l(void 0,null,function*(){return t.signArbitrary(o,s,r)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{B(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var en=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}=e;if(!t||!n||!a||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}},tn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Je=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let P=(()=>{switch(S.algo){case "secp256k1":return rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:tn(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:P,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,P,v;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(P=g.gasPriceStep)==null?void 0:P.average,high_gas_price:(v=g.gasPriceStep)==null?void 0:v.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,P]=d;return e.getOfflineSigner(g).signDirect(S,en(P))},signAmino:(...d)=>{let[g,S,P]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,P)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let R=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!R)throw new Error(`Wallet not connected to account ${g}`);let E=(()=>{switch(R.algo){case "secp256k1":return encodeSecp256k1Pubkey(R.pubkey);case "ed25519":return encodeEd25519Pubkey(R.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:R.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:E.value}}}),subscription:d=>{let g=()=>{B(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},et=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=p=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(O=>O.id===e.id&&(!p||O.version===p))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var D;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let O=(D=p.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(O)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield i()),true}),s=p=>l(void 0,null,function*(){(yield a())||(yield i());}),r=(p,A,O)=>l(void 0,null,function*(){let x=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:O}}}}),N=O.accountNumber,D=new Te(N.low,N.high,N.unsigned);return {signature:x.signature,signed:G(k({},x.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(x.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(x.signed.bodyBytes))})}}),c=(p,A,O)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:O}}}})}),f=p=>l(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[p]=A,fe[p]}),m=p=>l(void 0,null,function*(){let A=yield f(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[A,O,x,N]=p;return yield c(A,O,x)}),g=(...p)=>l(void 0,null,function*(){var $;let[A,O,x]=p,N=G(k({},x),{accountNumber:Te.fromString((($=x.accountNumber)==null?void 0:$.toString())||"0"),authInfoBytes:x.authInfoBytes,bodyBytes:x.bodyBytes});return yield r(A,O,N)}),P=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signAmino:(A,O)=>d(p,A,O)});return {enable:s,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signDirect:(A,O)=>g(p,A,O),signAmino:(A,O)=>d(p,A,O)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return P(p)}),getOfflineSignerOnlyAmino:P,init:o,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var tt=()=>et({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var r;let s=()=>{B(),o();};return (r=window.okxwallet)==null||r.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var nn="para.reconnect",re=null,nt=()=>{let e=()=>{let i=C.getState().paraConnector;if(!i)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return i},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let n=()=>re||(re=l(void 0,null,function*(){let i=C.getState().paraConnector;if(i)return i;try{let o;if(t.connectorClass)o=t.connectorClass;else if(t.connectorImportPath){if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import(t.connectorImportPath),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector from dynamic URL/path. Ensure it exports `ParaGrazConnector`.");o=f;}else {if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import('@getpara/graz-integration'),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");o=f;}let s=u.getState().chains,r=new o(t,s);if(C.setState(c=>G(k({},c),{paraConnector:r})),!r)throw new Error("Para connector initialization failed. Check config and dependencies.");return r}catch(o){throw re=null,new Error("Para connector init failed. Check @getpara/graz-integration and ParaConfig.")}}),re);return {enable:i=>l(void 0,null,function*(){let o=Array.isArray(i)?i:[i];try{let s=yield n();C.setState({paraConnector:s,status:"connecting"}),yield s.enable(o);let r=Object.fromEntries(yield Promise.all(o.map(c=>l(void 0,null,function*(){return [c,yield s.getKey(c)]}))));C.setState(c=>({accounts:k(k({},c.accounts||{}),r),activeChainIds:Array.from(new Set([...c.activeChainIds||[],...o])),status:"connected"})),u.setState(c=>({recentChainIds:Array.from(new Set([...c.recentChainIds||[],...o])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"})),typeof window!="undefined"&&window.sessionStorage.setItem(nn,"1");}catch(s){throw C.setState({paraConnector:null,status:"disconnected"}),new Error(`Para enable failed${s instanceof Error?`: ${s.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let i=e();try{yield i.disconnect(),yield i.getParaWebClient().logout();}catch(o){throw new Error("Para disconnect failed. Wallet may already be disconnected.")}finally{C.setState({paraConnector:null,status:"disconnected"});}}),getKey:i=>l(void 0,null,function*(){try{return yield e().getKey(i)}catch(o){throw new Error("Failed to get key. Check chain connection and Cosmos API key settings at developer.getpara.com.")}}),getOfflineSigner:i=>{try{return e().getOfflineSigner(i)}catch(o){throw new Error("Failed to get offline signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerOnlyAmino:i=>{try{return e().getOfflineSignerOnlyAmino(i)}catch(o){throw new Error("Failed to get Amino signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerAuto:i=>{try{return e().getOfflineSignerAuto(i)}catch(o){throw new Error("Failed to get auto signer. Check Para auth and Cosmos support in developer portal.")}},signAmino:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signAmino(i,o,s,r)}catch(c){throw new Error("Amino signing failed. User rejected or invalid transaction/signer.")}}),signDirect:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signDirect(i,o,s,r)}catch(c){throw new Error("Direct signing failed. User rejected or invalid transaction/signer.")}}),signArbitrary:(i,o,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(i,o,s)}catch(r){throw new Error("Arbitrary signing failed. User rejected or feature not supported.")}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ye=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let r=()=>{B(),s();};return window.addEventListener("station_wallet_change",r),()=>{window.removeEventListener("station_wallet_change",r);}},getKey:s=>l(void 0,null,function*(){let r=yield t.getKey(s);return k({isKeystone:false},r)}),getOfflineSigner:s=>{try{let r=t.getOfflineSignerOnlyAmino(s);return Object.assign(r,{signDirect:(m,d)=>{throw new Error("signDirect not supported by Station")}})}catch(r){throw console.error(r),r}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let r=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,m,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((m=c.gasPriceStep)==null?void 0:m.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(r);}catch(r){throw console.error(r),r}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,r,c,f)=>t.signAmino(s,r,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:r=>e.enable(r),getOfflineSigner:r=>{let c=e.getOfflineSigner(r);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:r=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(r);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:r=>l(void 0,null,function*(){let c=yield e.getKey(r);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:r=>{let c=()=>{B(),r();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...r)=>{let c=r[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...r)=>l(void 0,null,function*(){var m;let[c]=r;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(m=c.bech32Config)==null?void 0:m.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...r)=>l(void 0,null,function*(){var d;let{1:c,2:f}=r,m=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Te.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}}),signAmino:(...r)=>l(void 0,null,function*(){let{1:c,2:f}=r;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},ot=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),it=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Pe=(e,t,n=new Error("Promise timed out"))=>{let a=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,a])};var q=e=>{var D,$,ie;if(!((ie=($=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:$.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",a=y=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(z()){if(ot()){let T=h(w.mobile.android,y,"android");window.open(T,"_self","noreferrer noopener");}if(it()){let T=h(w.mobile.ios,y,"ios");window.open(T,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=C.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),C.setState({wcSignClients:y}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield h.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=y=>{try{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let T=h.session.getAll(),W=T.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let _=T.find(Q=>{var Y,J;return (J=(Y=Q.requiredNamespaces.cosmos)==null?void 0:Y.chains)==null?void 0:J.includes(`cosmos:${y}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return W}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},r=y=>{try{return s(y)}catch(w){return}},c=y=>l(void 0,null,function*(){try{let w=y.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=C.getState(),h=w.get(t);if(h)return h;let T=yield SignClient.init(y.options);return w.set(t,T),C.setState({wcSignClients:w}),T}),m=y=>{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)return ()=>{};let T=W=>{let M=C.getState().accounts;if(W.params.event.name==="accountsChanged"&&M&&!Object.values(M).map(_=>_.bech32Address).includes(W.params.event.data[0])){let _=W.params.chainId.split(":")[1];_&&d([_]);}else y();};return h.events.on("session_delete",i),h.events.on("session_expire",i),h.events.on("session_event",T),()=>{h.events.off("session_delete",i),h.events.off("session_expire",i),h.events.off("session_event",T);}},d=y=>l(void 0,null,function*(){var J;let w=typeof y=="string"?[y]:y,{wcSignClients:h,activeChainIds:T}=C.getState(),W=h.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:M,chains:_}=u.getState();if(!((J=M==null?void 0:M.options)!=null&&J.projectId))throw new Error("walletConnect.options.projectId is not defined");let Q=new WalletConnectModal(k({projectId:M.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},M.walletConnectModal)),Y=r(w);if(!Y){let{uri:U,approval:ae}=yield Pe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?a(U):yield Q.openModal({uri:U});let ce=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Oe,ee)=>{ae().then(_e=>{let Ke=_e.sessionProperties;if(!Ke)return ee(new Error("No session properties"));let Ee=JSON.parse(String(Ke.keys));if(Ee.length===0)return ee(new Error("No accounts"));if(!Ee[0])return ee(new Error("No accounts"));let Ne={};return Ee.forEach(H=>{Ne[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),C.setState(H=>({accounts:k(k({},H.accounts||{}),Ne)})),Oe(_e)}).catch(ee),V.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:true});})});try{let V=new AbortController,Oe=V.signal;Q.subscribeModal(ee=>{ee.open||V.abort();}),yield ce(Oe);}catch(V){if(Q.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||Q.closeModal(),Promise.resolve()}try{yield Pe(l(void 0,null,function*(){var ae;let U=Object.fromEntries(yield Promise.all((ae=T||w)==null?void 0:ae.map(ce=>l(void 0,null,function*(){return [ce,yield S(ce)]}))));C.setState({accounts:U});}),15e3,new Error("Connection timeout"));}catch(U){if(o(Y.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),g=y=>l(void 0,null,function*(){let w=yield S(y);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=y=>l(void 0,null,function*(){let w=s([y]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let T=h.find(W=>W.chainId===y);if(!T)throw new Error(`No wallet connect key for chainId ${y}`);return G(k({},T),{pubKey:Buffer.from(String(T.pubKey),n)})}),P=(...y)=>l(void 0,null,function*(){var J,U;let[w,h,T]=y,{accounts:W,wcSignClients:M}=C.getState(),_=M.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let Q=(J=s([w]))==null?void 0:J.topic;if(!Q)throw new Error("No wallet connect session");if(!T.bodyBytes)throw new Error("No bodyBytes");if(!T.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield _.request({topic:Q,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:T.chainId,accountNumber:(U=T.accountNumber)==null?void 0:U.toString(),bodyBytes:T.bodyBytes?Buffer.from(T.bodyBytes).toString(n):null,authInfoBytes:T.authInfoBytes?Buffer.from(T.authInfoBytes).toString(n):null}}}})}),v=(...y)=>l(void 0,null,function*(){var _;let[w,h,T]=y,{signature:W,signed:M}=yield P(w,h,T);return {signed:{chainId:(_=M.chainId)!=null?_:"",accountNumber:M.accountNumber?BigInt(M.accountNumber):BigInt(0),authInfoBytes:M.authInfoBytes?new Uint8Array(Buffer.from(M.authInfoBytes,n)):new Uint8Array([]),bodyBytes:M.bodyBytes?new Uint8Array(Buffer.from(M.bodyBytes,n)):new Uint8Array([])},signature:W}}),R=(...y)=>l(void 0,null,function*(){var U;let[w,h,T,W]=y,{wcSignClients:M}=C.getState(),_=M.get(t),{accounts:Q}=C.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let Y=(U=s([w]))==null?void 0:U.topic;if(!Y)throw new Error("No wallet connect session");return a(),yield _.request({topic:Y,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:T}}})}),E=(...y)=>l(void 0,null,function*(){let[w,h,T,W]=y;return yield R(w,h,T)}),p=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>v(y,w,h)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signAmino:(w,h)=>E(y,w,h)});return {enable:d,disable:y=>l(void 0,null,function*(){var T;let{wcSignClients:w}=C.getState(),h=w.get(t);if(y===void 0){let W=h==null?void 0:h.session.getAll();W!==void 0&&(yield Promise.all(W.map(M=>o(M.topic))));}else typeof y=="string"?yield o((T=s([y]))==null?void 0:T.topic):yield Promise.all(y.map(W=>{var M;return o((M=s([W]))==null?void 0:M.topic)}));(h==null?void 0:h.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>v(y,w,h),signAmino:(w,h)=>E(y,w,h)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield S(y)).isNanoLedger?A(y):p(y)}),getOfflineSignerOnlyAmino:A,signAmino:E,signDirect:v,subscription:m,init:f}};var rt=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var st=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":","");return o?`${r}://wc?${o}`:`${r}://wc`}};return q(e)};var at=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${r}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var ct=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${r}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var we=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var F=(e=u.getState().walletType)=>{try{return K(e),!0}catch(t){return false}},B=()=>{window.sessionStorage.removeItem(te),C.setState(oe);},K=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return de();case "leap":return me();case "cosmostation":return pe();case "vectis":return Ce();case "walletconnect":return q();case "wc_keplr_mobile":return at();case "wc_leap_mobile":return ct();case "wc_cosmostation_mobile":return st();case "wc_clot_mobile":return rt();case "metamask_snap_leap":return tt();case "metamask_snap_cosmos":return Xe();case "station":return ye();case "xdefi":return we();case "cosmiframe":return ue();case "compass":return le();case "initia":return Je();case "okx":return ge();case "para":return nt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((a=t.setDefaultOptions)==null||a.call(t,n)),t},Vi=()=>Object.fromEntries(ze.map(e=>[e,F(e)])),lt=e=>e==="metamask_snap_leap",ut=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),se=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",pt=e=>e==="para";var ne=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:r,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(se(f)){let E=K("walletconnect"),{disable:p}=E;p&&p();}if(!F(f))throw new Error(`${f} is not available`);let d=K(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=r==null?void 0:r.map(E=>E.chainId);g.forEach(E=>{if(!(S!=null&&S.includes(E)))throw new Error(`Chain ${E} is not provided in GrazProvider`)}),C.setState(E=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return E.activeChainIds&&g.filter(O=>{var x;return !((x=E.activeChainIds)!=null&&x.includes(O))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:P}=C.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!se(f)){let E={};if(lt(f)){let p={};try{for(var n=Ge(g),a,i,o;a=!(i=yield n.next()).done;a=!1){let A=i.value;p[A]=yield d.getKey(A);}}catch(i){o=[i];}finally{try{a&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}E=p;}else if(ut()&&d.getKeys){let p=yield d.getKeys(g);g.forEach((A,O)=>{let x=p[O];x&&(E[A]=x);});}else E=Object.fromEntries(yield Promise.all(g.map(p=>l(void 0,null,function*(){return [p,yield d.getKey(p)]}))));C.setState(p=>({accounts:k(k({},p.accounts||{}),E)}));}u.setState(E=>({recentChainIds:[...E.recentChainIds||[],...g].filter((p,A,O)=>O.indexOf(p)===A)})),C.setState(E=>({activeChainIds:[...E.activeChainIds||[],...g].filter((p,A,O)=>O.indexOf(p)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(te,"Active");let v=g.map(E=>r.find(p=>p.chainId===E));return {accounts:C.getState().accounts,walletType:f,chains:v}}catch(s){throw console.error("connect ",s),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),s}}),ke=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(te);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,n=()=>{if(se(u.getState().walletType)){let a=K("walletconnect"),{disable:i}=a;i&&i();}if(pt(u.getState().walletType)){let a=K("para"),{disable:i}=a;i&&i();}};if(t){let a=C.getState().accounts;t.forEach(o=>{a==null||delete a[o];}),Object.values(a||{}).length===0?(n(),C.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(C.setState(o=>{var s;return {activeChainIds:(s=o.activeChainIds)==null?void 0:s.filter(r=>!t.includes(r)),accounts:a}}),u.setState(o=>{var s;return {recentChainIds:(s=o.recentChainIds)==null?void 0:s.filter(r=>!t.includes(r))}}));}else n(),C.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:a}=u.getState();try{let o=F(n||void 0);if(t&&o&&n)return se(n)?void 0:yield ne({chainId:t,walletType:n,autoReconnect:a})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),ke();}}),dt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!F(n))throw new Error(`${n} is not available`);let i=K(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),r=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:r}});var xe=()=>{u.setState({recentChainIds:null});},sr=()=>u.getState().recentChainIds,ar=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(a=>t.find(i=>i.chainId===a)))!=null?n:null},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},lr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Me=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield K(t).experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield ne({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ft=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var gt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:a,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,a,i,o)}),yt=m=>l(void 0,[m],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:a,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:r,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,a,i,o,s,r,c,f)}),Ct=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,a,i)}),wt=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,a,s,o)}),St=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),ht=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return n.queryContractRaw(e,a)};var Sr=e=>e,hr=e=>e;var At=e=>e?Object.keys(e).length===0:true;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},It=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function We(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:i}={}){return new Promise((r,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let f=[],m=[],d=new Map,g=false,S=false,P=false,v=0,R=0,E=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=O=>{g=true,S=true,c(O);};i&&(i.aborted&&p(bt(i)),i.addEventListener("abort",()=>{p(bt(i));}));let A=()=>l(this,null,function*(){if(S)return;let O=yield E.next(),x=R;if(R++,O.done){if(P=true,v===0&&!S){if(!a&&m.length>0){p(new AggregateError(m));return}if(S=true,d.size===0){r(f);return}let N=[];for(let[D,$]of f.entries())d.get(D)!==Ot&&N.push($);r(N);}return}v++,l(this,null,function*(){try{let N=yield O.value;if(S)return;let D=yield t(N,x);D===Ot&&d.set(x,D),f[x]=D,v--,yield A();}catch(N){if(a)p(N);else {m.push(N),v--;try{yield A();}catch(D){p(D);}}}});});l(this,null,function*(){for(let O=0;O<n;O++){try{yield A();}catch(x){p(x);break}if(P||g)break}});})})}var Ot=Symbol("skip");var j=({chainId:e,multiChain:t})=>{let n=u(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!a):return [a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!a):return n;default:return [n[0]]}},X=(e,t,n)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let o=yield We(t,n,{concurrency:a});return Object.fromEntries(o.map((s,r)=>[t[r].chainId,s]))}return yield n(t[0])}),Et=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Re=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:k({},(r==null?void 0:r.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},De=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:k({},(r==null?void 0:r.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var Qr=()=>u(useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),Se=e=>{let n=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>F(i)})};var Z=e=>{let t=u(r=>r.walletType),n=C(r=>r.activeChainIds),a=j({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=C(r=>r.accounts),o=C(r=>r.status);return useEffect(()=>C.subscribe(r=>r.status,(r,c)=>{var f,m,d;if(r==="connected"){let{accounts:g,activeChainIds:S}=C.getState(),{chains:P}=u.getState(),{walletType:v}=u.getState();if(!g||!S||!P)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(m=e==null?void 0:e.onConnect)==null||m.call(e,{accounts:g,chains:S.map(R=>P.find(E=>E.chainId===R)),walletType:v,isReconnect:c==="reconnecting"});}r==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>i?Et(!!(e!=null&&e.multiChain),a,r=>i[r.chainId]):void 0,[i,a,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:L,status:o}},mn=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),a=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=Re({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),o=useMemo(()=>["USE_ALL_BALANCES",i,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,i]);return useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var P;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((P=d.bech32Config)!=null&&P.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!At(i)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},rs=e=>{let t=j({chainId:e.chainId}),{data:n}=Z({chainId:e.chainId}),a=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=mn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,a,e.chainId],r=useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(m=>m.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?true:e.enabled)});return G(k({},r),{refetch:c=>l(void 0,null,function*(){return yield o(),r.refetch(c)})})},ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:ne,onError:(s,r)=>e==null?void 0:e(s,r),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},as=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:ke,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},cs=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),a=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chain found");if(!F(s))throw new Error(`${s} is not available`);return yield X(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield dt({chainId:m.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!n&&!!a,refetchOnWindowFocus:false})},ls=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),{data:a}=Re({chainId:t.map(s=>s.chainId),multiChain:true}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",a,t,i],[t,i,a]);return useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var S,P;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (P=s[d.chainId])==null?void 0:P.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var Cs=()=>C(e=>e.activeChainIds),fn=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let n=(a=u.getState().chains)==null?void 0:a.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ss=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},hs=({denom:e})=>{let t=fn();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(r=>r.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},As=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},Is=()=>({data:u(t=>t.recentChainIds),clear:xe}),bs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let a=(i=u.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(a)return a}).filter(Boolean),clear:xe}},Os=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:Me,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},Es=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:mt,onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=Z(),i=a==null?void 0:a.bech32Address,o=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>gt(k({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=Z(),i=a==null?void 0:a.bech32Address,o=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>yt(k({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},_s=({codeId:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,r=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m;if(!o)throw new Error("senderAddress is undefined");let f=G(k({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,codeId:e});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,instantiateContract:r.mutate,instantiateContractAsync:r.mutateAsync,status:r.status}},Ks=({contractAddress:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,r=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m,d,g;if(!o)throw new Error("senderAddress is undefined");let f=G(k({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return wt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,executeContract:r.mutate,executeContractAsync:r.mutateAsync,status:r.status}},Ns=e=>{let{data:t}=De();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return St(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Bs=e=>{let{data:t}=De(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ht(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Hs(e){let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var R,E;if(!(a!=null&&a.includes(m.chainId)))return null;if(!F(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return K(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return K(r).getOfflineSignerOnlyAmino(m.chainId);default:return K(r).getOfflineSignerAuto(m.chainId)}}),S=(R=u.getState().chainsConfig)==null?void 0:R[m.chainId],P={url:m.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield SigningStargateClient.connectWithSigner(P,g,e!=null&&e.multiChain?(E=e.opts)==null?void 0:E[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}function Xs(e){let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var E,p;if(!(a!=null&&a.includes(m.chainId)))return null;if(!F(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return K(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return K(r).getOfflineSignerOnlyAmino(m.chainId);default:return K(r).getOfflineSignerAuto(m.chainId)}}),S=(E=u.getState().chainsConfig)==null?void 0:E[m.chainId],P={url:m.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})},v=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(P,g,k({gasPrice:v},e!=null&&e.multiChain?(p=e.opts)==null?void 0:p[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}var Kt=({children:e})=>{let[t,n]=useState(false);return useEffect(()=>{n(true);},[]),jsx(Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(te)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:a,iframeOptions:i,chains:o,pingInterval:s}=u(),{activeChainIds:r,wcSignClients:c}=C(),f=F(a||void 0);return useEffect(()=>{let m=()=>l(void 0,null,function*(){if(e&&f&&a&&(r!=null&&r[0])){let d=C.getState().lastPing;if(d&&Date.now()-d<s)return;let g=K(a);try{if(!(yield g.getKey(r[0])))throw new Error("No account found");C.setState({lastPing:Date.now()});return}catch(S){L({onError:n});}}});return window.addEventListener("focus",m),()=>{window.removeEventListener("focus",m);}},[e,f,a,o,r,s]),useEffect(()=>{if(!i||i.autoConnect===false||!i.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(i.allowedIframeParentOrigins).isReady().then(d=>{if(d)return ne({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[i]),useEffect(()=>{if(a){if(!f)return;e&&r?L({onError:n}):!e&&t&&L({onError:n});}},[f]),useEffect(()=>{var m,d,g,S,P,v,R,E,p,A,O,x,N,D,$,ie,y,w,h,T;if(a){if(!f)return;a==="cosmostation"&&((d=(m=pe()).subscription)==null||d.call(m,()=>{L({onError:n});})),a==="keplr"&&((S=(g=de()).subscription)==null||S.call(g,()=>{L({onError:n});})),a==="leap"&&((v=(P=me()).subscription)==null||v.call(P,()=>{L({onError:n});})),a==="compass"&&((E=(R=le()).subscription)==null||E.call(R,()=>{L({onError:n});})),a==="vectis"&&((A=(p=Ce()).subscription)==null||A.call(p,()=>{L({onError:n});})),a==="walletconnect"&&c.has("walletconnect")&&((x=(O=q()).subscription)==null||x.call(O,()=>{L({onError:n});})),a==="station"&&((D=(N=ye()).subscription)==null||D.call(N,()=>{L({onError:n});})),a==="xdefi"&&((ie=($=we()).subscription)==null||ie.call($,()=>{L({onError:n});})),a==="cosmiframe"&&((w=(y=ue()).subscription)==null||w.call(y,()=>{L({onError:n});})),a==="okx"&&((T=(h=ge()).subscription)==null||T.call(h,()=>{L({onError:n});}));}},[a,c,f]),null},Nt=()=>(bn(),null);var Pa=({children:e,grazOptions:t})=>(useEffect(()=>{ft(t);},[t]),jsxs(Kt,{children:[e,jsx(Nt,{})]}));
|
|
19
19
|
|
|
20
|
-
export { Nt as GrazEvents, Pa as GrazProvider, ze as WALLET_TYPES, Fe as WalletType, F as checkWallet, xe as clearRecentChain, B as clearSession, ft as configureGraz, ne as connect, hr as defineChainInfo, Sr as defineChains, ke as disconnect, wt as executeContract, Vi as getAvailableWallets, cr as getChainInfo, lr as getChainInfos, pe as getCosmostation, de as getKeplr, me as getLeap, tt as getMetamaskSnapLeap, dt as getOfflineSigners, ht as getQueryRaw, St as getQuerySmart, sr as getRecentChainIds, ar as getRecentChains, Ce as getVectis, st as getWCCosmostation, at as getWCKeplr, ct as getWCLeap, K as getWallet, q as getWalletConnect, Ct as instantiateContract, ut as isLeapDappBrowser, lt as isLeapSnaps, pt as isPara, se as isWalletConnect, L as reconnect, yt as sendIbcTokens, gt as sendTokens, Me as suggestChain, mt as suggestChainAndConnect, Z as useAccount, hs as useActiveChainCurrency, Cs as useActiveChainIds, fn as useActiveChains, Qr as useActiveWalletType, rs as useBalance, ls as useBalanceStaked, mn as useBalances, ws as useChainInfo, Ss as useChainInfos, Se as useCheckWallet, ss as useConnect, De as useCosmWasmClient, Xs as useCosmWasmSigningClient, as as useDisconnect, Ks as useExecuteContract, bn as useGrazEvents, _s as useInstantiateContract, cs as useOfflineSigners, As as useQueryClientValidators, Bs as useQueryRaw, Ns as useQuerySmart, Is as useRecentChainIds, bs as useRecentChains, Ds as useSendIbcTokens, Rs as useSendTokens, Re as useStargateClient, Hs as useStargateSigningClient, Os as useSuggestChain, Es as useSuggestChainAndConnect };
|
|
20
|
+
export { Nt as GrazEvents, Pa as GrazProvider, ze as WALLET_TYPES, Fe as WalletType, F as checkWallet, xe as clearRecentChain, B as clearSession, ft as configureGraz, ne as connect, hr as defineChainInfo, Sr as defineChains, ke as disconnect, wt as executeContract, Vi as getAvailableWallets, cr as getChainInfo, lr as getChainInfos, pe as getCosmostation, de as getKeplr, me as getLeap, tt as getMetamaskSnapLeap, dt as getOfflineSigners, ge as getOkx, nt as getPara, ht as getQueryRaw, St as getQuerySmart, sr as getRecentChainIds, ar as getRecentChains, Ce as getVectis, st as getWCCosmostation, at as getWCKeplr, ct as getWCLeap, K as getWallet, q as getWalletConnect, Ct as instantiateContract, ut as isLeapDappBrowser, lt as isLeapSnaps, pt as isPara, se as isWalletConnect, L as reconnect, yt as sendIbcTokens, gt as sendTokens, Me as suggestChain, mt as suggestChainAndConnect, Z as useAccount, hs as useActiveChainCurrency, Cs as useActiveChainIds, fn as useActiveChains, Qr as useActiveWalletType, rs as useBalance, ls as useBalanceStaked, mn as useBalances, ws as useChainInfo, Ss as useChainInfos, Se as useCheckWallet, ss as useConnect, De as useCosmWasmClient, Xs as useCosmWasmSigningClient, as as useDisconnect, Ks as useExecuteContract, bn as useGrazEvents, _s as useInstantiateContract, cs as useOfflineSigners, As as useQueryClientValidators, Bs as useQueryRaw, Ns as useQuerySmart, Is as useRecentChainIds, bs as useRecentChains, Ds as useSendIbcTokens, Rs as useSendTokens, Re as useStargateClient, Hs as useStargateSigningClient, Os as useSuggestChain, Es as useSuggestChainAndConnect };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.5",
|
|
5
5
|
"author": "Nur Fikri <kikiding.space@gmail.com>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
@@ -33,14 +33,6 @@
|
|
|
33
33
|
"env.d.ts"
|
|
34
34
|
],
|
|
35
35
|
"sideEffects": false,
|
|
36
|
-
"scripts": {
|
|
37
|
-
"build": "tsup",
|
|
38
|
-
"clean": "rm -rf dist/*",
|
|
39
|
-
"cli": "node dist/cli.js",
|
|
40
|
-
"dev": "tsup --watch",
|
|
41
|
-
"lint": "eslint --fix \"src/**/*.{ts,tsx}\"",
|
|
42
|
-
"prepublishOnly": "pnpm build"
|
|
43
|
-
},
|
|
44
36
|
"peerDependencies": {
|
|
45
37
|
"@tanstack/react-query": ">=5.62.0",
|
|
46
38
|
"react": ">=17",
|
|
@@ -95,5 +87,12 @@
|
|
|
95
87
|
"graz-sh",
|
|
96
88
|
"use-keplr"
|
|
97
89
|
],
|
|
98
|
-
"license": "MIT"
|
|
99
|
-
|
|
90
|
+
"license": "MIT",
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "tsup",
|
|
93
|
+
"clean": "rm -rf dist/*",
|
|
94
|
+
"cli": "node dist/cli.js",
|
|
95
|
+
"dev": "tsup --watch",
|
|
96
|
+
"lint": "eslint --fix \"src/**/*.{ts,tsx}\""
|
|
97
|
+
}
|
|
98
|
+
}
|