graz 0.1.19 → 0.1.21
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/cli.js +9 -7
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +62 -61
- package/dist/index.mjs +5 -4
- package/package.json +3 -2
- package/types/global.d.ts +6 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var C = require('fs/promises');
|
|
5
|
-
var
|
|
5
|
+
var me = require('path');
|
|
6
|
+
var url = require('url');
|
|
6
7
|
var cosmos = require('@keplr-wallet/cosmos');
|
|
7
8
|
var cosmosDirectoryClient = require('cosmos-directory-client');
|
|
8
9
|
|
|
@@ -25,9 +26,9 @@ function _interopNamespace(e) {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
var C__namespace = /*#__PURE__*/_interopNamespace(C);
|
|
28
|
-
var
|
|
29
|
+
var me__namespace = /*#__PURE__*/_interopNamespace(me);
|
|
29
30
|
|
|
30
|
-
var
|
|
31
|
+
var fe=Object.create;var te=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var _e=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ee=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var be=(e,n,r,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ue(n))!he.call(e,o)&&o!==r&&te(e,o,{get:()=>n[o],enumerable:!(d=pe(n,o))||d.enumerable});return e};var we=(e,n,r)=>(r=e!=null?fe(ge(e)):{},be(n||!e||!e.__esModule?te(r,"default",{value:e,enumerable:!0}):r,e));var S=(e,n,r)=>new Promise((d,o)=>{var h=i=>{try{t(r.next(i));}catch(c){o(c);}},m=i=>{try{t(r.throw(i));}catch(c){o(c);}},t=i=>i.done?d(i.value):Promise.resolve(i.value).then(h,m);t((r=r.apply(e,n)).next());});var Ne,$,T=_e(()=>{Ne=()=>typeof document=="undefined"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,$=Ne();});var oe=Ee((je,ne)=>{T();var F=Symbol("arg flag"),b=class e extends Error{constructor(n,r){super(n),this.name="ArgError",this.code=r,Object.setPrototypeOf(this,e.prototype);}};function x(e,{argv:n=process.argv.slice(2),permissive:r=!1,stopAtPositional:d=!1}={}){if(!e)throw new b("argument specification object is required","ARG_CONFIG_NO_SPEC");let o={_:[]},h={},m={};for(let t of Object.keys(e)){if(!t)throw new b("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(t[0]!=="-")throw new b(`argument key must start with '-' but found: '${t}'`,"ARG_CONFIG_NONOPT_KEY");if(t.length===1)throw new b(`argument key must have a name; singular '-' keys are not allowed: ${t}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[t]=="string"){h[t]=e[t];continue}let i=e[t],c=!1;if(Array.isArray(i)&&i.length===1&&typeof i[0]=="function"){let[u]=i;i=(f,_,a=[])=>(a.push(u(f,_,a[a.length-1])),a),c=u===Boolean||u[F]===!0;}else if(typeof i=="function")c=i===Boolean||i[F]===!0;else throw new b(`type missing or not a function or valid array type: ${t}`,"ARG_CONFIG_VAD_TYPE");if(t[1]!=="-"&&t.length>2)throw new b(`short argument keys (with a single hyphen) must have only one character: ${t}`,"ARG_CONFIG_SHORTOPT_TOOLONG");m[t]=[i,c];}for(let t=0,i=n.length;t<i;t++){let c=n[t];if(d&&o._.length>0){o._=o._.concat(n.slice(t));break}if(c==="--"){o._=o._.concat(n.slice(t+1));break}if(c.length>1&&c[0]==="-"){let u=c[1]==="-"||c.length===2?[c]:c.slice(1).split("").map(f=>`-${f}`);for(let f=0;f<u.length;f++){let _=u[f],[a,E]=_[1]==="-"?_.split(/=(.*)/,2):[_,void 0],l=a;for(;l in h;)l=h[l];if(!(l in m))if(r){o._.push(_);continue}else throw new b(`unknown or unexpected option: ${a}`,"ARG_UNKNOWN_OPTION");let[w,s]=m[l];if(!s&&f+1<u.length)throw new b(`option requires argument (but was followed by another short argument): ${a}`,"ARG_MISSING_REQUIRED_SHORTARG");if(s)o[l]=w(!0,l,o[l]);else if(E===void 0){if(n.length<t+2||n[t+1].length>1&&n[t+1][0]==="-"&&!(n[t+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(w===Number||typeof BigInt!="undefined"&&w===BigInt))){let I=a===l?"":` (alias for ${l})`;throw new b(`option requires argument: ${a}${I}`,"ARG_MISSING_REQUIRED_LONGARG")}o[l]=w(n[t+1],l,o[l]),++t;}else o[l]=w(E,l,o[l]);}}else o._.push(c);}return o}x.flag=e=>(e[F]=!0,e);x.COUNT=x.flag((e,n,r)=>(r||0)+1);x.ArgError=b;ne.exports=x;});T();var de=we(oe(),1);T();var k=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n;}},re=e=>globalThis.DOMException===void 0?new k(e):new DOMException(e),se=e=>{let n=e.reason===void 0?re("This operation was aborted."):e.reason;return n instanceof Error?n:re(n)};function v(h,m){return S(this,arguments,function*(e,n,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:d=!0,signal:o}={}){return new Promise((t,i)=>{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 n!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(r)||r===Number.POSITIVE_INFINITY)&&r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let c=[],u=[],f=new Map,_=!1,a=!1,E=!1,l=0,w=0,s=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),I=N=>{_=!0,a=!0,i(N);};o&&(o.aborted&&I(se(o)),o.addEventListener("abort",()=>{I(se(o));}));let P=()=>S(this,null,function*(){if(a)return;let N=yield s.next(),R=w;if(w++,N.done){if(E=!0,l===0&&!a){if(!d&&u.length>0){I(new AggregateError(u));return}if(a=!0,f.size===0){t(c);return}let y=[];for(let[A,j]of c.entries())f.get(A)!==ie&&y.push(j);t(y);}return}l++,S(this,null,function*(){try{let y=yield N.value;if(a)return;let A=yield n(y,R);A===ie&&f.set(R,A),c[R]=A,l--,yield P();}catch(y){if(d)I(y);else {u.push(y),l--;try{yield P();}catch(A){I(A);}}}});});S(this,null,function*(){for(let N=0;N<r;N++){try{yield P();}catch(R){I(R);break}if(E||_)break}});})})}var ie=Symbol("skip");var Te=me.dirname(url.fileURLToPath($)),Ce=e=>/^\d+$/.test(e),L=e=>Ce(e[0])?`_${e}`:e,ae=`Usage: graz [options]
|
|
31
32
|
|
|
32
33
|
Options:
|
|
33
34
|
|
|
@@ -36,12 +37,13 @@ Options:
|
|
|
36
37
|
|
|
37
38
|
Generate options:
|
|
38
39
|
-b, --best Set REST and RPC endpoint to best available nodes instead or first listed ones
|
|
40
|
+
-e, --endpoint <url> Specify the endpoint URL to fetch chain information
|
|
39
41
|
-M, --mainnet Generate given mainnet chain paths seperated by commas (e.g. "axelar,cosmoshub,juno")
|
|
40
42
|
-T, --testnet Generate given testnet chain paths seperated by commas (e.g. "atlantic,bitcannadev,cheqdtestnet")
|
|
41
43
|
--authz Generate only authz compatible chains
|
|
42
44
|
|
|
43
45
|
https://github.com/graz-sh/graz
|
|
44
|
-
`,
|
|
45
|
-
`)
|
|
46
|
-
`}).join(""),
|
|
47
|
-
`),
|
|
46
|
+
`,g=(0, de.default)({"--generate":Boolean,"-g":"--generate","--authz":Boolean,"--best":Boolean,"--mainnet":String,"--testnet":String,"-b":"--best","-M":"--mainnet","-T":"--testnet","--help":Boolean,"-h":"--help","--endpoint":String,"-e":"--endpoint"}),Pe=()=>S(void 0,null,function*(){if(g["--help"]){console.log(ae);return}if(g["--generate"]){yield Oe();return}console.log(ae);}),Oe=()=>S(void 0,null,function*(){console.log("\u23F3 Generating chain list..."),g["--authz"]&&console.log("\u270D\uFE0F Detected authz flag, generating only compatible chains..."),g["--best"]&&console.log("\u{1F481}\u200D\u2642\uFE0F Detected best flag, setting REST and RPC endpoints to best latency..."),(g["--mainnet"]||g["--testnet"])&&console.log("\u{1F419} Detected chain filtering flag, generating only given chain paths...");let e,n;if(g["--endpoint"]){console.log("\u{1F310} Fetching chain information from specified endpoint");try{let m=yield fetch(g["--endpoint"]);if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);let t=yield m.json();e=ce(t.mainnet,g["--mainnet"]),n=ce(t.testnet,g["--testnet"]);}catch(m){console.error(`\u274C Failed to fetch chain information: ${m.message}`),process.exit(1);}}else [e,n]=yield Promise.all([le(cosmosDirectoryClient.createClient(),{filter:g["--mainnet"]}),le(cosmosDirectoryClient.createTestnetClient(),{filter:g["--testnet"]})]);let[r,d]=yield Promise.all([C__namespace.readFile(G("index.js.stub"),{encoding:"utf-8"}),C__namespace.readFile(G("index.mjs.stub"),{encoding:"utf-8"})]),o=r.replace("/* REPLACE_MAINNET_DEFS */",M(e)).replace("/* REPLACE_TESTNET_DEFS */",M(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",D(e)).replace("/* REPLACE_TESTNET_CHAINS */",D(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",O(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",O(n,{testnet:!0})).replace("/* REPLACE_MAINNET_EXPORTS */",O(e)).replace("/* REPLACE_TESTNET_EXPORTS */",O(n,{testnet:!0})).replace(/"(.+)":/g,"$1:").trim(),h=d.replace("/* REPLACE_MAINNET_DEFS */",M(e,{mjs:!0})).replace("/* REPLACE_TESTNET_DEFS */",M(n,{mjs:!0,testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",D(e)).replace("/* REPLACE_TESTNET_CHAINS */",D(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",O(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",O(n,{testnet:!0})).replace(/"(.+)":/g,"$1:").trim();yield Promise.all([C__namespace.writeFile(G("index.js"),o,{encoding:"utf-8"}),C__namespace.writeFile(G("index.mjs"),h.replace('"../dist"','"../dist/index.mjs"'),{encoding:"utf-8"}),C__namespace.writeFile(G("index.ts"),h,{encoding:"utf-8"})]),console.log('\u2728 Generate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');}),ce=(e,n)=>{if(!n)return e;let r=new Set(n.split(","));return Object.fromEntries(Object.entries(e).filter(([d])=>r.has(d)))},G=(...e)=>me__namespace.resolve(Te,"../chains",...e),D=(e,{testnet:n=!1}={})=>Object.keys(e).map(r=>` ${L(r)}: ${L(r)},`).join(`
|
|
47
|
+
`),M=(e,{mjs:n=!1,testnet:r=!1}={})=>Object.entries(e).map(([d,o])=>{let h=`${L(d)}`,m=JSON.stringify(o,null,2);return `${n?"export ":""}const ${h} = defineChainInfo(${m});
|
|
48
|
+
`}).join(""),O=(e,{testnet:n=!1}={})=>Object.keys(e).map(r=>` ${L(r)},`).join(`
|
|
49
|
+
`),le=(r,...d)=>S(void 0,[r,...d],function*(e,{filter:n=""}={}){let o=n?n.split(",").map(t=>({path:t})):yield e.fetchChains().then(t=>t.chains.map(({path:i})=>({path:i}))),h=yield v(o,t=>S(void 0,null,function*(){return e.fetchChain(t.path).then(i=>i.chain)}),{concurrency:4}),m={};return h.forEach(t=>{var i,c,u,f,_;try{if(g["--authz"]&&!((i=t.params)!=null&&i.authz))return;let a=g["--best"]?t.best_apis:t.apis;if(!a||!((c=a.rest)!=null&&c[0])||!((u=a.rpc)!=null&&u[0]))throw new Error(`\u26A0\uFE0F ${t.name} has no REST/RPC endpoints, skipping codegen...`);if(!t.assets)throw new Error(`\u26A0\uFE0F ${t.name} has no assets, skipping codegen...`);let E=t.assets[0],l={coinDenom:E.denom_units[E.denom_units.length-1].denom,coinMinimalDenom:E.denom_units[0].denom,coinDecimals:E.denom_units[E.denom_units.length-1].exponent,coinGeckoId:E.coingecko_id},w=(f=t.fees)==null?void 0:f.fee_tokens.map(s=>{var P,N,R,y,A,j,z,H,Y,U,B,q,K,V,Q,X,J,W,Z,ee;return s.low_gas_price&&s.average_gas_price&&s.high_gas_price?{coinDenom:((R=(N=(P=t.assets)==null?void 0:P.find(p=>p.denom===s.denom))==null?void 0:N.denom_units.at(-1))==null?void 0:R.denom)||s.denom,coinMinimalDenom:((j=(A=(y=t.assets)==null?void 0:y.find(p=>p.denom===s.denom))==null?void 0:A.denom_units[0])==null?void 0:j.denom)||s.denom,coinDecimals:Number((H=(z=t.assets)==null?void 0:z.find(p=>p.denom===s.denom))==null?void 0:H.decimals),coinGeckoId:((U=(Y=t.assets)==null?void 0:Y.find(p=>p.denom===s.denom))==null?void 0:U.coingecko_id)||"",gasPriceStep:{low:Number(s.low_gas_price),average:Number(s.average_gas_price),high:Number(s.high_gas_price)}}:{coinDenom:((K=(q=(B=t.assets)==null?void 0:B.find(p=>p.denom===s.denom))==null?void 0:q.denom_units.at(-1))==null?void 0:K.denom)||s.denom,coinMinimalDenom:((X=(Q=(V=t.assets)==null?void 0:V.find(p=>p.denom===s.denom))==null?void 0:Q.denom_units[0])==null?void 0:X.denom)||s.denom,coinDecimals:Number((W=(J=t.assets)==null?void 0:J.find(p=>p.denom===s.denom))==null?void 0:W.decimals),coinGeckoId:((ee=(Z=t.assets)==null?void 0:Z.find(p=>p.denom===s.denom))==null?void 0:ee.coingecko_id)||""}});if(!w)throw new Error(`\u26A0\uFE0F ${t.name} has no fee currencies, skipping codegen...`);m[t.path]={chainId:t.chain_id,currencies:t.assets.map(s=>({coinDenom:s.denom_units[s.denom_units.length-1].denom,coinMinimalDenom:s.denom_units[0].denom,coinDecimals:s.denom_units[s.denom_units.length-1].exponent,coinGeckoId:s.coingecko_id})),rest:a.rest[0].address||"",rpc:a.rpc[0].address||"",bech32Config:cosmos.Bech32Address.defaultBech32Config(t.bech32_prefix),chainName:t.chain_name,feeCurrencies:w,stakeCurrency:l,bip44:{coinType:(_=t.slip44)!=null?_:0}};}catch(a){console.error(a instanceof Error?a.message:String(a));}}),m});Pe();
|
package/dist/index.d.mts
CHANGED
|
@@ -34,7 +34,8 @@ declare enum WalletType {
|
|
|
34
34
|
XDEFI = "xdefi",
|
|
35
35
|
CAPSULE = "capsule",
|
|
36
36
|
COSMIFRAME = "cosmiframe",
|
|
37
|
-
COMPASS = "compass"
|
|
37
|
+
COMPASS = "compass",
|
|
38
|
+
INITIA = "initia"
|
|
38
39
|
}
|
|
39
40
|
declare const WALLET_TYPES: WalletType[];
|
|
40
41
|
type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,8 @@ declare enum WalletType {
|
|
|
34
34
|
XDEFI = "xdefi",
|
|
35
35
|
CAPSULE = "capsule",
|
|
36
36
|
COSMIFRAME = "cosmiframe",
|
|
37
|
-
COMPASS = "compass"
|
|
37
|
+
COMPASS = "compass",
|
|
38
|
+
INITIA = "initia"
|
|
38
39
|
}
|
|
39
40
|
declare const WALLET_TYPES: WalletType[];
|
|
40
41
|
type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var zustand = require('zustand');
|
|
4
4
|
var middleware = require('zustand/middleware');
|
|
5
|
+
var amino = require('@cosmjs/amino');
|
|
5
6
|
var encoding = require('@cosmjs/encoding');
|
|
6
7
|
var cosmiframe = require('@dao-dao/cosmiframe');
|
|
7
8
|
var snapper = require('@cosmsnap/snapper');
|
|
8
|
-
var
|
|
9
|
+
var sn = require('long');
|
|
9
10
|
var signClient = require('@walletconnect/sign-client');
|
|
10
11
|
var utils = require('@walletconnect/utils');
|
|
11
12
|
var reactQuery = require('@tanstack/react-query');
|
|
@@ -18,80 +19,80 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
18
19
|
|
|
19
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
|
|
21
|
-
var
|
|
22
|
+
var sn__default = /*#__PURE__*/_interopDefault(sn);
|
|
22
23
|
|
|
23
|
-
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(se)for(var n of se(t))ze.call(t,n)&&qe(e,n,t[n]);return e},U=(e,t)=>Lt(e,Ut(t));var Qe=(e,t)=>{var n={};for(var i in e)Ge.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&se)for(var i of se(e))t.indexOf(i)<0&&ze.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{s(n.next(c));}catch(p){r(p);}},a=c=>{try{s(n.throw(c));}catch(p){r(p);}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,a);s((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var je=(C=>(C.KEPLR="keplr",C.LEAP="leap",C.VECTIS="vectis",C.COSMOSTATION="cosmostation",C.WALLETCONNECT="walletconnect",C.WC_KEPLR_MOBILE="wc_keplr_mobile",C.WC_LEAP_MOBILE="wc_leap_mobile",C.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",C.WC_CLOT_MOBILE="wc_clot_mobile",C.METAMASK_SNAP_LEAP="metamask_snap_leap",C.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",C.STATION="station",C.XDEFI="xdefi",C.CAPSULE="capsule",C.COSMIFRAME="cosmiframe",C.COMPASS="compass",C))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Gt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},zt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},m=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,Gt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>qt,zt)));var ae=()=>{var E,O;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((O=u.getState().capsuleConfig)!=null&&O.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var A,C;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(A=u.getState().capsuleConfig)==null?void 0:A.apiKey,env:(C=u.getState().capsuleConfig)==null?void 0:C.env});return m.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,A=m.getState().capsuleClient;A||(A=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var W;let d=m.getState().capsuleClient,{chains:g}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!g)throw new Error("Chains are not set");yield d.enable();let A=(W=u.getState().capsuleState)==null?void 0:W.chainId;if(!A)throw new Error("Chain ids are not set");let C=Object.fromEntries(yield Promise.all(A.map(f=>l(void 0,null,function*(){let w=yield d.getAccount(f);return [f,{address:encoding.fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));m.setState(f=>({accounts:b(b({},f.accounts||{}),C)})),u.setState(f=>({recentChainIds:[...f.recentChainIds||[],...A].filter((w,M,P)=>P.indexOf(w)===M)})),m.setState(f=>({activeChainIds:[...f.activeChainIds||[],...A].filter((w,M,P)=>P.indexOf(w)===M)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let A=yield g.getAccount(d);return {address:encoding.fromBech32(A.address).data,bech32Address:A.address,algo:A.algo,name:A.username||"",pubKey:A.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[g,A,C]=d,W=m.getState().capsuleClient;if(!W)throw new Error("Capsule client is not initialized");return W.signDirect(g,A,{bodyBytes:C.bodyBytes,authInfoBytes:C.authInfoBytes,chainId:C.chainId,accountNumber:C.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,A,C,W]=d,f=m.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,A,C,W)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.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.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 et={},tt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var S;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 s=(S=o.split("MetaMask/v")[1])==null?void 0:S.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:o=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,a,s)=>l(void 0,null,function*(){return t.signAmino(o,a,s)}),getKey:o=>l(void 0,null,function*(){return typeof et[o]!="undefined"?et[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,a,s)=>l(void 0,null,function*(){return t.signDirect(o,a,s)}),signArbitrary:(o,a,s)=>l(void 0,null,function*(){return t.signArbitrary(o,a,s)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{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=>{var s;let a=()=>{F(),o();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}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:r=>{let o=()=>{F(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},nt=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=f=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(M=>M.id===e.id&&(!f||M.version===f))}catch(w){return}}),r=()=>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 f=yield t.request({method:"web3_clientVersion"});if(!f.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 M=(D=f.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(M)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),a=f=>l(void 0,null,function*(){(yield i())||(yield r());}),s=(f,w,M)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:M}}}}),_=M.accountNumber,D=new Ht__default.default(_.low,_.high,_.unsigned);return {signature:P.signature,signed:U(b({},P.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(f,w,M)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:w,signDoc:M}}}})}),p=f=>l(void 0,null,function*(){if(typeof de[f]!="undefined")return de[f];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,de[f]=w,de[f]}),S=f=>l(void 0,null,function*(){let w=yield p(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,M,P,_]=f;return yield c(w,M,P)}),O=(...f)=>l(void 0,null,function*(){let[w,M,P]=f;return yield s(w,M,P)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signAmino:(w,M)=>E(f,w,M)});return {enable:a,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signDirect:(w,M)=>O(f,w,M),signAmino:(w,M)=>E(f,w,M)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return g(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:O}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ot=()=>nt({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let a=()=>{F(),o();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:o=>l(void 0,null,function*(){let a=yield e.getKey(o);return b({isKeystone:!1},a)}),getOfflineSigner:o=>{try{let a=e.getOfflineSignerOnlyAmino(o);return Object.assign(a,{signDirect:(p,S)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let a=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(s=>{var c,p,S;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((S=s.gasPriceStep)==null?void 0:S.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,a,s,c)=>e.signAmino(o,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ge=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{F(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>e.getOfflineSignerAmino(...s),experimentalSuggestChain:(...s)=>l(void 0,null,function*(){let[c]=s,p=U(b({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([p])}),signDirect:(...s)=>l(void 0,null,function*(){var S;let{1:c,2:p}=s;return e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Ht__default.default.fromString(((S=p.accountNumber)==null?void 0:S.toString())||"",!1),chainId:p.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,it=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),rt=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var Q=e=>{var D,X,ne;if(!((ne=(X=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:X.projectId)!=null&&ne.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",i=y=>{if(!e)return;let{appUrl:h,formatNativeUrl:I}=e;if(z()){if(it())if(!y)window.open(h.mobile.android,"_self","noreferrer noopener");else {let x=I(h.mobile.android,y,"android");window.open(x,"_self","noreferrer noopener");}if(rt())if(!y)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let x=I(h.mobile.ios,y,"ios");window.open(x,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=m.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),m.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield I.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(I);}),a=y=>{try{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let x=I.session.getAll().at(-1);if(!x)return;if(!(x.expiry*1e3>Date.now()+1e3))throw o(x.topic),new Error("invalid session");try{let v=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(B=>`cosmos:${B}`),events:["chainChanged","accountsChanged"]}}});if(!v.length)throw new Error("no session");return v.at(-1)}catch(v){if(!v.message.toLowerCase().includes("no matching key"))throw v}return x}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},s=y=>{try{return a(y)}catch(h){return}},c=y=>l(void 0,null,function*(){try{let h=y.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),p=()=>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:h}=m.getState(),I=h.get(t);if(I)return I;let x=yield signClient.SignClient.init(y.options);return h.set(t,x),m.setState({wcSignClients:h}),x}),S=y=>{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)return ()=>{};let x=k=>{let v=m.getState().accounts;if(k.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(B=>B.bech32Address).includes(k.params.event.data[0])){let B=k.params.chainId.split(":")[1];B&&E([B]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",x),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",x);}},E=y=>l(void 0,null,function*(){var ie;let h=typeof y=="string"?[y]:y,{wcSignClients:I}=m.getState(),x=I.get(t);if(!x)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:v}=u.getState();if(!((ie=k==null?void 0:k.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:B}=yield import('@web3modal/standalone'),$=new B(b({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),J=s(h);if(!J){let{uri:L,approval:Z}=yield Me(x.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map(j=>`cosmos:${j}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield $.openModal({uri:L});let Nt=j=>l(void 0,null,function*(){return j.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,ee)=>{Z().then(Be=>{let Le=Be.sessionProperties;if(!Le)return ee(new Error("No session properties"));let be=JSON.parse(String(Le.keys));if(be.length===0)return ee(new Error("No accounts"));let Ue=be[0];if(!Ue)return ee(new Error("No accounts"));let Fe={};return h.forEach(re=>{Fe[re]=U(b({},Ue),{bech32Address:encoding.toBech32(v.find(Kt=>Kt.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(be[0].bech32Address).data)});}),m.setState(re=>({accounts:b(b({},re.accounts||{}),Fe)})),Te(Be)}).catch(ee),j.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let j=new AbortController,Te=j.signal;$.subscribeModal(ee=>{ee.open||j.abort();}),yield Nt(Te);}catch(j){if($.closeModal(),!j.message.toLowerCase().includes("no matching key"))return Promise.reject(j)}return e||$.closeModal(),Promise.resolve()}try{yield Me((()=>l(void 0,null,function*(){let L=Object.fromEntries(yield Promise.all(h.map(Z=>l(void 0,null,function*(){return [Z,yield d(Z)]}))));m.setState({accounts:L});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(J.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),O=y=>l(void 0,null,function*(){var v;let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let x=(v=a([y]))==null?void 0:v.topic;if(!x)throw new Error("No wallet connect session");let k=yield I.request({topic:x,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!k[0])throw new Error("No wallet connect account");return {address:k[0].address,algo:k[0].algo,pubkey:new Uint8Array(Buffer.from(k[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let h=a([y]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let I=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var L,Z;let[h,I,x]=y,{accounts:k,wcSignClients:v}=m.getState(),B=v.get(t);if(!B)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let $=(L=a([h]))==null?void 0:L.topic;if(!$)throw new Error("No wallet connect session");if(!x.bodyBytes)throw new Error("No bodyBytes");if(!x.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:U(b({},x),{bodyBytes:Buffer.from(x.bodyBytes).toString(n),authInfoBytes:Buffer.from(x.authInfoBytes).toString(n),accountNumber:(Z=x.accountNumber)==null?void 0:Z.toString()})}}};return i(),yield B.request(J)}),A=(...y)=>l(void 0,null,function*(){let[h,I,x]=y,{signature:k,signed:v}=yield g(h,I,x);return {signed:{chainId:v.chainId,accountNumber:Ht__default.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,n))},signature:k}}),C=(...y)=>l(void 0,null,function*(){var L;let[h,I,x,k]=y,{wcSignClients:v}=m.getState(),B=v.get(t),{accounts:$}=m.getState();if(!B)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(L=a([h]))==null?void 0:L.topic;if(!J)throw new Error("No wallet connect session");return i(),yield B.request({topic:J,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:x}}})}),W=(...y)=>l(void 0,null,function*(){let[h,I,x,k]=y;return yield C(h,I,x)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signAmino:(h,I)=>W(y,h,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var x;let{wcSignClients:h}=m.getState(),I=h.get(t);if(y===void 0){let k=I==null?void 0:I.session.getAll();k!==void 0&&(yield Promise.all(k.map(v=>o(v.topic))));}else typeof y=="string"?yield o((x=a([y]))==null?void 0:x.topic):yield Promise.all(y.map(k=>{var v;return o((v=a([k]))==null?void 0:v.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I),signAmino:(h,I)=>W(y,h,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:W,signDirect:A,subscription:S,init:p}};var st=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.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:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var at=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.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:(r,o,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return Q(e)};var ct=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.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:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var lt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.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:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var N=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},F=()=>{window.sessionStorage.removeItem(H),m.setState(te);},R=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return pe();case"leap":return me();case"cosmostation":return ue();case"vectis":return ge();case"walletconnect":return Q();case"wc_keplr_mobile":return ct();case"wc_leap_mobile":return lt();case"wc_cosmostation_mobile":return at();case"wc_clot_mobile":return st();case"metamask_snap_leap":return ot();case"metamask_snap_cosmos":return tt();case"station":return fe();case"xdefi":return Ce();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},Ri=()=>Object.fromEntries($e.map(e=>[e,N(e)])),xe=e=>e==="capsule",ut=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var V=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!N(o))throw new Error(`${o} is not available`);let s=R(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let p=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(p!=null&&p.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),m.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(C=>{var W;return !((W=d.activeChainIds)!=null&&W.includes(C))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=m.getState();if(yield (t=s.init)==null?void 0:t.call(s),xe(o)&&m.getState().capsuleClient&&Object.values(m.getState().accounts||[]).length>0){let d=c.map(C=>i.find(W=>W.chainId===C)),g=m.getState().accounts;m.setState({status:"connecting"});let A=Object.fromEntries(yield Promise.all(c.map(C=>l(void 0,null,function*(){return [C,yield s.getKey(C)]}))));return m.setState(C=>({accounts:b(b({},C.accounts||{}),A)})),u.setState(C=>({recentChainIds:[...C.recentChainIds||[],...c].filter((W,f,w)=>w.indexOf(W)===f)})),m.setState(C=>({activeChainIds:[...C.activeChainIds||[],...c].filter((W,f,w)=>w.indexOf(W)===f)})),m.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield s.enable(c),xe(o)){let d=c.map(A=>i.find(C=>C.chainId===A)),g=m.getState().accounts;return m.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!ut(o)){let d=Object.fromEntries(yield Promise.all(c.map(g=>l(void 0,null,function*(){return [g,yield s.getKey(g)]}))));m.setState(g=>({accounts:b(b({},g.accounts||{}),d)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),m.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:m.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),m.getState().accounts===null&&m.setState({status:"disconnected"}),m.getState().accounts&&m.getState().activeChainIds&&m.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=m.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(m.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(m.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(a=>!t.includes(a))}}));}else m.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},q=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=N(n||void 0);if(t&&o&&n)return yield V({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),oe();}}),pt=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(!N(n))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:a,offlineSignerAuto:s}});var We=()=>{u.setState({recentChainIds:null});},Qi=()=>u.getState().recentChainIds,ji=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},$i=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Hi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ve=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=R(t);return t==="capsule"?yield V({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield ve({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield V({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var dt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,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,i,r,o)}),gt=S=>l(void 0,[S],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){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,i,r,o,a,s,c,p)}),Ct=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,o,i,r)}),yt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,a,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 i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var ir=e=>e,rr=e=>e;var ye=e=>e?Object.keys(e).length===0:!0;var ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},wt=e=>globalThis.DOMException===void 0?new ke(e):new DOMException(e),At=e=>{let t=e.reason===void 0?wt("This operation was aborted."):e.reason;return t instanceof Error?t:wt(t)};function Pe(o,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((s,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 p=[],S=[],E=new Map,O=!1,d=!1,g=!1,A=0,C=0,W=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=M=>{O=!0,d=!0,c(M);};r&&(r.aborted&&f(At(r)),r.addEventListener("abort",()=>{f(At(r));}));let w=()=>l(this,null,function*(){if(d)return;let M=yield W.next(),P=C;if(C++,M.done){if(g=!0,A===0&&!d){if(!i&&S.length>0){f(new AggregateError(S));return}if(d=!0,E.size===0){s(p);return}let _=[];for(let[D,X]of p.entries())E.get(D)!==It&&_.push(X);s(_);}return}A++,l(this,null,function*(){try{let _=yield M.value;if(d)return;let D=yield t(_,P);D===It&&E.set(P,D),p[P]=D,A--,yield w();}catch(_){if(i)f(_);else {S.push(_),A--;try{yield w();}catch(D){f(D);}}}});});l(this,null,function*(){for(let M=0;M<n;M++){try{yield w();}catch(P){f(P);break}if(g||O)break}});})})}var It=Symbol("skip");var K=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},G=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Pe(t,n,{concurrency:i});return Object.fromEntries(o.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),Et=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,a)=>[t[a].chainId,o]))}return n(t[0])};var _e=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:b({},(s==null?void 0:s.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ne=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:b({},(s==null?void 0:s.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Se=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=K({chainId:t,multiChain:n}),o=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield G(!!n,s,S=>l(void 0,null,function*(){var A;let E=(A=u.getState().chainsConfig)==null?void 0:A[S.chainId],O={url:S.rpc,headers:b({},(E==null?void 0:E.rpcHeaders)||{})};return yield (a==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(O)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var Pr=()=>u(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",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),he=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>N(r))};var Y=e=>{let t=u(s=>s.walletType),n=m(s=>s.activeChainIds),i=K({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=m(s=>s.accounts),o=m(s=>s.status);return react.useEffect(()=>m.subscribe(s=>s.status,(s,c)=>{var p,S,E;if(s==="connected"){let{accounts:O,activeChainIds:d}=m.getState(),{chains:g}=u.getState(),{walletType:A}=u.getState();if(!O||!d||!g)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(S=e==null?void 0:e.onConnect)==null||S.call(e,{accounts:O,chains:d.map(C=>g.find(W=>W.chainId===C)),walletType:A,isReconnect:c==="reconnecting"});}s==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:react.useMemo(()=>r?Et(!!(e!=null&&e.multiChain),i,s=>r[s.chainId]):void 0,[r,i,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:q,status:o}},un=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=_e({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=react.useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){let O=a==null?void 0:a[E.chainId];if(!O)throw new Error(`Client is not ready ${E.chainId}`);return yield O.getAllBalances(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!ye(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Qr=e=>{let t=K({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=un({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,i,e.chainId],s=reactQuery.useQuery(a,({queryKey:[,c,p]})=>p==null?void 0:p.find(S=>S.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return U(b({},s),{refetch:c=>l(void 0,null,function*(){return yield o(),s.refetch(c)})})},jr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],V,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=he();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},$r=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],oe,{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=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Hr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!N(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,p=>l(void 0,null,function*(){return yield pt({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Vr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=_e({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return reactQuery.useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){var d;if(!a)throw new Error("Client is not ready");return yield (d=a[E.chainId])==null?void 0:d.getBalanceStaked(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var ns=()=>{let e=u(i=>i.capsuleState),t=m(i=>i.capsuleClient),n=ae();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var ls=()=>m(e=>e.activeChainIds),pn=()=>{var e;return (e=m(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},us=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ms=({denom:e})=>{let t=pn();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:o.currencies.find(a=>a)})},ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,s=>l(void 0,[s],function*({queryKey:[,o,a]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},fs=()=>({data:u(t=>t.recentChainIds),clear:We}),gs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:We}},Cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mt,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=he();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Ts=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],a=>ft(b({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],a=>gt(b({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ms=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var S;if(!o)throw new Error("senderAddress is undefined");let p=U(b({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,codeId:e});return Ct(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},xs=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var S,E,O;if(!o)throw new Error("senderAddress is undefined");let p=U(b({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(O=c.funds)!=null?O:[]});return yt(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Ws=e=>{let{data:t}=Ne();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{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})},vs=e=>{let{data:t}=Ne(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{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 Gs(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var A,C;if(!(i!=null&&i.includes(p.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(p.chainId);default:return R(a).getOfflineSignerAuto(p.chainId)}}))(),O=(A=u.getState().chainsConfig)==null?void 0:A[p.chainId],d={url:p.rpc,headers:b({},(O==null?void 0:O.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(C=e.opts)==null?void 0:C[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function zs(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var C,W;if(!(i!=null&&i.includes(p.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(p.chainId);default:return R(a).getOfflineSignerAuto(p.chainId)}}))(),O=(C=u.getState().chainsConfig)==null?void 0:C[p.chainId],d={url:p.rpc,headers:b({},(O==null?void 0:O.rpcHeaders)||{})},g=O!=null&&O.gas?stargate.GasPrice.fromString(`${O.gas.price}${O.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(d,E,b({gasPrice:g},e!=null&&e.multiChain?(W=e.opts)==null?void 0:W[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Qs(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=m(a=>a.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Se({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,S=>l(this,null,function*(){var A;if(!(i!=null&&i.includes(S.chainId)))return null;if(!N(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let O=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(S.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(S.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(S.chainId);default:return R(s).getOfflineSignerAuto(S.chainId)}}))(),d=e.multiChain?o[S.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(d,O,e.multiChain?(A=e.opts)==null?void 0:A[S.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function js(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=m(s=>s.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Se({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=Se({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:p=>l(this,[p],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return null;if(!N(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(E.chainId);default:return R(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],A=g!=null&&g.gas?stargate.GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,C=e.multiChain?a==null?void 0:a[E.chainId]:o;if(!C)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(C,d,b({gasPrice:A},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!ye(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Rt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var yn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:a,wcSignClients:s}=m(),c=N(i||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(S=>{if(S)return V({chainId:o.map(E=>E.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(i){if(!c)return;e&&a?q({onError:n}):!e&&t&&q({onError:n});}},[c]),react.useEffect(()=>{var p,S,E,O,d,g,A,C,W,f,w,M,P,_,D,X,ne,y;if(i){if(!c)return;i==="cosmostation"&&((S=(p=ue()).subscription)==null||S.call(p,()=>{q({onError:n});})),i==="keplr"&&((O=(E=pe()).subscription)==null||O.call(E,()=>{q({onError:n});})),i==="leap"&&((g=(d=me()).subscription)==null||g.call(d,()=>{q({onError:n});})),i==="compass"&&((C=(A=ce()).subscription)==null||C.call(A,()=>{q({onError:n});})),i==="vectis"&&((f=(W=ge()).subscription)==null||f.call(W,()=>{q({onError:n});})),i==="walletconnect"&&s.has("walletconnect")&&((M=(w=Q()).subscription)==null||M.call(w,()=>{q({onError:n});})),i==="station"&&((_=(P=fe()).subscription)==null||_.call(P,()=>{q({onError:n});})),i==="xdefi"&&((X=(D=Ce()).subscription)==null||X.call(D,()=>{q({onError:n});})),i==="cosmiframe"&&((y=(ne=le()).subscription)==null||y.call(ne,()=>{q({onError:n});}));}},[i,s,c]),null},Dt=()=>(yn(),null);var wn=new reactQuery.QueryClient({}),Aa=i=>{var r=i,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return dt(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,U(b({client:wn},n),{children:jsxRuntime.jsxs(Rt,{children:[e,jsxRuntime.jsx(Dt,{})]})}),"graz-provider")};
|
|
24
|
+
var Ft=Object.defineProperty,qt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(se)for(var n of se(t))ze.call(t,n)&&qe(e,n,t[n]);return e},F=(e,t)=>qt(e,Gt(t));var Qe=(e,t)=>{var n={};for(var o in e)Ge.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&se)for(var o of se(e))t.indexOf(o)<0&&ze.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(m){r(m);}},s=l=>{try{a(n.throw(l));}catch(m){r(m);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(O=>(O.KEPLR="keplr",O.LEAP="leap",O.VECTIS="vectis",O.COSMOSTATION="cosmostation",O.WALLETCONNECT="walletconnect",O.WC_KEPLR_MOBILE="wc_keplr_mobile",O.WC_LEAP_MOBILE="wc_leap_mobile",O.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",O.WC_CLOT_MOBILE="wc_clot_mobile",O.METAMASK_SNAP_LEAP="metamask_snap_leap",O.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",O.STATION="station",O.XDEFI="xdefi",O.CAPSULE="capsule",O.COSMIFRAME="cosmiframe",O.COMPASS="compass",O.INITIA="initia",O))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia"];var Qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},jt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},$t={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},d=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,jt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Qt,$t)));var ae=()=>{var C,g;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((g=u.getState().capsuleConfig)!=null&&g.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return d.setState({capsuleClient:S}),S});return {init:e,enable:p=>c(void 0,null,function*(){let S=typeof p=="string"?[p]:p,h=d.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var y;let p=d.getState().capsuleClient,{chains:S}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield p.enable();let h=(y=u.getState().capsuleState)==null?void 0:y.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(A=>c(void 0,null,function*(){let T=yield p.getAccount(A);return [A,{address:encoding.fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));d.setState(A=>({accounts:x(x({},A.accounts||{}),O)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...h].filter((T,P,D)=>D.indexOf(T)===P)})),d.setState(A=>({activeChainIds:[...A.activeChainIds||[],...h].filter((T,P,D)=>D.indexOf(T)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(p);return {address:encoding.fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)},signDirect:(...p)=>c(void 0,null,function*(){let[S,h,O]=p,y=d.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signDirect(S,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>c(void 0,null,function*(){let[S,h,O,y]=p,A=d.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(S,h,O,y)}),signArbitrary:(p,S,h)=>c(void 0,null,function*(){let O=d.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let y=yield O.getAccount(p);if(!y)throw new Error(`Wallet not connected to account ${S}`);let A=(()=>{switch(y.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(y.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(p,S,h),pub_key:{type:y.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(p)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.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.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 tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var I;let i=yield e.request({method:"web3_clientVersion"});if(!i.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 a=(I=i.split("MetaMask/v")[1])==null?void 0:I.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:i=>c(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof tt[i]!="undefined"?tt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{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:i=>{let s=()=>{N(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var on=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},rn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:f=>c(void 0,null,function*(){let C=e.getOfflineSigner(f),[g]=yield C.getAccounts();if(!g)throw new Error("Wallet connection failed");let p=(()=>{switch(g.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(g.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(g.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:rn(g.address),algo:g.algo,pubKey:g.pubkey,bech32Address:g.address,address:p,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let C=e.getOfflineSigner(f),g=e.getOfflineSignerOnlyAmino(f);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:g.signAmino.bind(g)}},getOfflineSignerAuto:f=>Promise.resolve(e.getOfflineSigner(f)),getOfflineSignerOnlyAmino:f=>e.getOfflineSignerOnlyAmino(f),experimentalSuggestChain:f=>e.requestAddInitiaLayer({chain_id:f.chainId,chain_name:f.chainName,bech32_prefix:"init",bech32_config:f.bech32Config,slip44:f.bip44.coinType,logo_URIs:{png:f.chainSymbolImageUrl},fees:{fee_tokens:f.feeCurrencies.map(C=>{var g,p,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(g=C.gasPriceStep)==null?void 0:g.low,average_gas_price:(p=C.gasPriceStep)==null?void 0:p.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[C,g,p]=f;return e.getOfflineSigner(C).signDirect(g,on(p))},signAmino:(...f)=>{let[C,g,p]=f;return e.getOfflineSignerOnlyAmino(C).signAmino(g,p)},signArbitrary:(f,C,g)=>c(void 0,null,function*(){let h=(yield e.getOfflineSigner(f).getAccounts()).find(A=>A.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let O=(()=>{switch(h.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(g),pub_key:{type:h.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:f=>{let C=()=>{N(),f();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}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:r=>{let i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},rt=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(T=>T.id===e.id&&(!y||T.version===y))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var _;let y=yield t.request({method:"web3_clientVersion"});if(!y.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 T=(_=y.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=y=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(y,A,T)=>c(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:A,signDoc:T}}}}),D=T.accountNumber,_=new sn__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:F(x({},P.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),l=(y,A,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:A,signDoc:T}}}})}),m=y=>c(void 0,null,function*(){if(typeof de[y]!="undefined")return de[y];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,de[y]=A,de[y]}),I=y=>c(void 0,null,function*(){let A=yield m(y);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),f=(...y)=>c(void 0,null,function*(){let[A,T,P,D]=y;return yield l(A,T,P)}),C=(...y)=>c(void 0,null,function*(){let[A,T,P]=y;return yield a(A,T,P)}),p=y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signAmino:(A,T)=>f(y,A,T)});return {enable:s,experimentalSuggestChain:(...y)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:y[0]}}}});}),getKey:m,getOfflineSigner:y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signDirect:(A,T)=>C(y,A,T),signAmino:(A,T)=>f(y,A,T)}),getOfflineSignerAuto:y=>c(void 0,null,function*(){return p(y)}),getOfflineSignerOnlyAmino:p,init:i,signAmino:f,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{N(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return x({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(m,I)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,m,I;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((I=a.gasPriceStep)==null?void 0:I.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ge=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:encoding.fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{N(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,m=F(x({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>c(void 0,null,function*(){var I;let{1:l,2:m}=a;return e.signDirect(l,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:sn__default.default.fromString(((I=m.accountNumber)==null?void 0:I.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:m}=a;return e.signAmino(l,m)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,at=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var Q=e=>{var _,X,ne;if(!((ne=(X=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:X.projectId)!=null&&ne.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",o=w=>{if(!e)return;let{appUrl:E,formatNativeUrl:b}=e;if(z()){if(at())if(!w)window.open(E.mobile.android,"_self","noreferrer noopener");else {let k=b(E.mobile.android,w,"android");window.open(k,"_self","noreferrer noopener");}if(ct())if(!w)window.open(E.mobile.ios,"_self","noreferrer noopener");else {let k=b(E.mobile.ios,w,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:w}=d.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),d.setState({wcSignClients:w}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=w=>c(void 0,null,function*(){let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:utils.getSdkError("USER_DISCONNECTED")}),yield l(b);}),s=w=>{try{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=b.session.getAll().at(-1);if(!k)return;if(!(k.expiry*1e3>Date.now()+1e3))throw i(k.topic),new Error("invalid session");try{let v=b.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!v.length)throw new Error("no session");return v.at(-1)}catch(v){if(!v.message.toLowerCase().includes("no matching key"))throw v}return k}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}},a=w=>{try{return s(w)}catch(E){return}},l=w=>c(void 0,null,function*(){try{let E=w.core.pairing.pairings.getAll({active:!1});if(!E.length)return;yield Promise.all(E.map(b=>c(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}}),m=()=>c(void 0,null,function*(){let{walletConnect:w}=u.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:E}=d.getState(),b=E.get(t);if(b)return b;let k=yield signClient.SignClient.init(w.options);return E.set(t,k),d.setState({wcSignClients:E}),k}),I=w=>{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)return ()=>{};let k=W=>{let v=d.getState().accounts;if(W.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(L=>L.bech32Address).includes(W.params.event.data[0])){let L=W.params.chainId.split(":")[1];L&&f([L]);}else w();};return b.events.on("session_delete",r),b.events.on("session_expire",r),b.events.on("session_event",k),()=>{b.events.off("session_delete",r),b.events.off("session_expire",r),b.events.off("session_event",k);}},f=w=>c(void 0,null,function*(){var oe;let E=typeof w=="string"?[w]:w,{wcSignClients:b}=d.getState(),k=b.get(t);if(!k)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:v}=u.getState();if(!((oe=W==null?void 0:W.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:L}=yield import('@web3modal/standalone'),$=new L(x({projectId:W.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.web3Modal)),J=a(E);if(!J){let{uri:U,approval:Z}=yield Me(k.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:E.map(j=>`cosmos:${j}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?o(U):yield $.openModal({uri:U});let Lt=j=>c(void 0,null,function*(){return j.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,ee)=>{Z().then(Be=>{let Le=Be.sessionProperties;if(!Le)return ee(new Error("No session properties"));let Te=JSON.parse(String(Le.keys));if(Te.length===0)return ee(new Error("No accounts"));let Ue=Te[0];if(!Ue)return ee(new Error("No accounts"));let Fe={};return E.forEach(re=>{Fe[re]=F(x({},Ue),{bech32Address:encoding.toBech32(v.find(Ut=>Ut.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Te[0].bech32Address).data)});}),d.setState(re=>({accounts:x(x({},re.accounts||{}),Fe)})),be(Be)}).catch(ee),j.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let j=new AbortController,be=j.signal;$.subscribeModal(ee=>{ee.open||j.abort();}),yield Lt(be);}catch(j){if($.closeModal(),!j.message.toLowerCase().includes("no matching key"))return Promise.reject(j)}return e||$.closeModal(),Promise.resolve()}try{yield Me((()=>c(void 0,null,function*(){let U=Object.fromEntries(yield Promise.all(E.map(Z=>c(void 0,null,function*(){return [Z,yield g(Z)]}))));d.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(i(J.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),C=w=>c(void 0,null,function*(){var v;let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=(v=s([w]))==null?void 0:v.topic;if(!k)throw new Error("No wallet connect session");let W=yield b.request({topic:k,chainId:`cosmos:${w}`,request:{method:"cosmos_getAccounts",params:{}}});if(!W[0])throw new Error("No wallet connect account");return {address:W[0].address,algo:W[0].algo,pubkey:new Uint8Array(Buffer.from(W[0].pubkey,n))}}),g=w=>c(void 0,null,function*(){let E=s([w]);if(!(E!=null&&E.topic))throw new Error("No wallet connect session");let b=E.sessionProperties&&JSON.parse(String(E.sessionProperties.keys))[0];if(!b)throw new Error("No wallet connect key");return b}),p=(...w)=>c(void 0,null,function*(){var U,Z;let[E,b,k]=w,{accounts:W,wcSignClients:v}=d.getState(),L=v.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let $=(U=s([E]))==null?void 0:U.topic;if(!$)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:F(x({},k),{bodyBytes:Buffer.from(k.bodyBytes).toString(n),authInfoBytes:Buffer.from(k.authInfoBytes).toString(n),accountNumber:(Z=k.accountNumber)==null?void 0:Z.toString()})}}};return o(),yield L.request(J)}),S=(...w)=>c(void 0,null,function*(){let[E,b,k]=w,{signature:W,signed:v}=yield p(E,b,k);return {signed:{chainId:v.chainId,accountNumber:sn__default.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,n))},signature:W}}),h=(...w)=>c(void 0,null,function*(){var U;let[E,b,k,W]=w,{wcSignClients:v}=d.getState(),L=v.get(t),{accounts:$}=d.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(U=s([E]))==null?void 0:U.topic;if(!J)throw new Error("No wallet connect session");return o(),yield L.request({topic:J,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:k}}})}),O=(...w)=>c(void 0,null,function*(){let[E,b,k,W]=w;return yield h(E,b,k)}),y=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b)}),A=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signAmino:(E,b)=>O(w,E,b)});return {enable:f,disable:w=>c(void 0,null,function*(){var k;let{wcSignClients:E}=d.getState(),b=E.get(t);if(w===void 0){let W=b==null?void 0:b.session.getAll();W!==void 0&&(yield Promise.all(W.map(v=>i(v.topic))));}else typeof w=="string"?yield i((k=s([w]))==null?void 0:k.topic):yield Promise.all(w.map(W=>{var v;return i((v=s([W]))==null?void 0:v.topic)}));(b==null?void 0:b.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...w)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:g,getOfflineSigner:w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b),signAmino:(E,b)=>O(w,E,b)}),getOfflineSignerAuto:w=>c(void 0,null,function*(){return (yield g(w)).isNanoLedger?A(w):y(w)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:S,subscription:I,init:m}};var lt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.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:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.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:(r,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return Q(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.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:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.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:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var ye=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(V),d.setState(te);},R=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return pe();case"leap":return me();case"cosmostation":return ue();case"vectis":return ge();case"walletconnect":return Q();case"wc_keplr_mobile":return pt();case"wc_leap_mobile":return mt();case"wc_cosmostation_mobile":return ut();case"wc_clot_mobile":return lt();case"metamask_snap_leap":return st();case"metamask_snap_cosmos":return nt();case"station":return fe();case"xdefi":return ye();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();case"initia":return ot();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},Zo=()=>Object.fromEntries($e.map(e=>[e,K(e)])),xe=e=>e==="capsule",dt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var H=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!K(i))throw new Error(`${i} is not available`);let a=R(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let m=o==null?void 0:o.map(g=>g.chainId);l.forEach(g=>{if(!(m!=null&&m.includes(g)))throw new Error(`Chain ${g} is not provided in GrazProvider`)}),d.setState(g=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return g.activeChainIds&&l.filter(h=>{var O;return !((O=g.activeChainIds)!=null&&O.includes(h))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:I}=d.getState();if(yield (t=a.init)==null?void 0:t.call(a),xe(i)&&d.getState().capsuleClient&&Object.values(d.getState().accounts||[]).length>0){let g=l.map(h=>o.find(O=>O.chainId===h)),p=d.getState().accounts;d.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(l.map(h=>c(void 0,null,function*(){return [h,yield a.getKey(h)]}))));return d.setState(h=>({accounts:x(x({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState(h=>({activeChainIds:[...h.activeChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState({status:"connected"}),{accounts:p,walletType:i,chains:g}}if(yield a.enable(l),xe(i)){let g=l.map(S=>o.find(h=>h.chainId===S)),p=d.getState().accounts;return d.setState({status:"connecting"}),{accounts:p,walletType:i,chains:g}}if(!dt(i)){let g=Object.fromEntries(yield Promise.all(l.map(p=>c(void 0,null,function*(){return [p,yield a.getKey(p)]}))));d.setState(p=>({accounts:x(x({},p.accounts||{}),g)}));}u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),d.setState(g=>({activeChainIds:[...g.activeChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let f=l.map(g=>o.find(p=>p.chainId===g));return {accounts:d.getState().accounts,walletType:i,chains:f}}catch(n){throw console.error("connect ",n),d.getState().accounts===null&&d.setState({status:"disconnected"}),d.getState().accounts&&d.getState().activeChainIds&&d.setState({status:"connected"}),n}}),ie=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=d.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(d.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(d.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else d.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},q=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=K(n||void 0);if(t&&i&&n)return yield H({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),ie();}}),ft=e=>c(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(!K(n))throw new Error(`${n} is not available`);let r=R(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var ke=()=>{u.setState({recentChainIds:null});},pr=()=>u.getState().recentChainIds,mr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},dr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},fr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ve=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=R(t);return t==="capsule"?yield H({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),gt=e=>c(void 0,null,function*(){var o;let t=u.getState().walletType;return yield ve({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield H({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var yt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var St=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),Ct=I=>c(void 0,[I],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:m}){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,o,r,i,s,a,l,m)}),ht=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),At=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),It=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var Er=e=>e,br=e=>e;var Se=e=>e?Object.keys(e).length===0:!0;var We=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),Et=e=>{let t=e.reason===void 0?Ot("This operation was aborted."):e.reason;return t instanceof Error?t:Ot(t)};function Pe(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{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 m=[],I=[],f=new Map,C=!1,g=!1,p=!1,S=0,h=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=T=>{C=!0,g=!0,l(T);};r&&(r.aborted&&y(Et(r)),r.addEventListener("abort",()=>{y(Et(r));}));let A=()=>c(this,null,function*(){if(g)return;let T=yield O.next(),P=h;if(h++,T.done){if(p=!0,S===0&&!g){if(!o&&I.length>0){y(new AggregateError(I));return}if(g=!0,f.size===0){a(m);return}let D=[];for(let[_,X]of m.entries())f.get(_)!==bt&&D.push(X);a(D);}return}S++,c(this,null,function*(){try{let D=yield T.value;if(g)return;let _=yield t(D,P);_===bt&&f.set(P,_),m[P]=_,S--,yield A();}catch(D){if(o)y(D);else {I.push(D),S--;try{yield A();}catch(_){y(_);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield A();}catch(P){y(P);break}if(p||C)break}});})})}var bt=Symbol("skip");var B=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},G=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Pe(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Tt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var _e=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ne=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ce=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=B({chainId:t,multiChain:n}),i=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,I=>c(void 0,null,function*(){var S;let f=(S=u.getState().chainsConfig)==null?void 0:S[I.chainId],C={url:I.rpc,headers:x({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var Jr=()=>u(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",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),he=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>K(r))};var Y=e=>{let t=u(a=>a.walletType),n=d(a=>a.activeChainIds),o=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=d(a=>a.accounts),i=d(a=>a.status);return react.useEffect(()=>d.subscribe(a=>a.status,(a,l)=>{var m,I,f;if(a==="connected"){let{accounts:C,activeChainIds:g}=d.getState(),{chains:p}=u.getState(),{walletType:S}=u.getState();if(!C||!g||!p)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(I=e==null?void 0:e.onConnect)==null||I.call(e,{accounts:C,chains:g.map(h=>p.find(O=>O.chainId===h)),walletType:S,isReconnect:l==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:react.useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:q,status:i}},An=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=_e({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=react.useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){let C=s==null?void 0:s[f.chainId];if(!C)throw new Error(`Client is not ready ${f.chainId}`);return yield C.getAllBalances(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!Se(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ps=e=>{let t=B({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=An({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,l,m]})=>m==null?void 0:m.find(I=>I.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(x({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},ms=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],H,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=he();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],ie,{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=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},fs=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!K(i))throw new Error(`${i} is not available`);return yield G(!!(e!=null&&e.multiChain),r,m=>c(void 0,null,function*(){return yield ft({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},gs=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:o}=_e({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=react.useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return reactQuery.useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){var g;if(!s)throw new Error("Client is not ready");return yield (g=s[f.chainId])==null?void 0:g.getBalanceStaked(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Is=()=>{let e=u(o=>o.capsuleState),t=d(o=>o.capsuleClient),n=ae();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ie();}}};var ks=()=>d(e=>e.activeChainIds),In=()=>{var e;return (e=d(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},vs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ps=({denom:e})=>{let t=In();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Rs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ds=()=>({data:u(t=>t.recentChainIds),clear:ke}),_s=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:ke}},Ns=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ks=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],gt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=he();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Qs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>St(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},js=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>Ct(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},$s=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var I;if(!i)throw new Error("senderAddress is undefined");let m=F(x({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,codeId:e});return ht(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Vs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var I,f,C;if(!i)throw new Error("senderAddress is undefined");let m=F(x({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,contractAddress:e,memo:(f=l.memo)!=null?f:"",funds:(C=l.funds)!=null?C:[]});return wt(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Hs=e=>{let{data:t}=Ne();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return At(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ys=e=>{let{data:t}=Ne(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return It(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function la(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var S,h;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[m.chainId],g={url:m.rpc,headers:x({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(g,f,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ua(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],g={url:m.rpc,headers:x({},(C==null?void 0:C.rpcHeaders)||{})},p=C!=null&&C.gas?stargate.GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(g,f,x({gasPrice:p},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function pa(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=d(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ce({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,I=>c(this,null,function*(){var S;if(!(o!=null&&o.includes(I.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let C=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(I.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(I.chainId);default:return R(a).getOfflineSignerAuto(I.chainId)}}))(),g=e.multiChain?i[I.chainId]:i;return yield stargate.SigningStargateClient.createWithSigner(g,C,e.multiChain?(S=e.opts)==null?void 0:S[I.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=d(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ce({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>c(this,[m],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,f=>c(this,null,function*(){var y,A;if(!(o!=null&&o.includes(f.chainId)))return null;if(!K(l))throw new Error(`${l} is not available`);let g=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(l).getOfflineSigner(f.chainId);case"offlineSignerAuto":return R(l).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return R(l).getOfflineSignerOnlyAmino(f.chainId);default:return R(l).getOfflineSignerAuto(f.chainId)}}))(),p=(y=u.getState().chainsConfig)==null?void 0:y[f.chainId],S=p!=null&&p.gas?stargate.GasPrice.fromString(`${p.gas.price}${p.gas.denom}`):void 0,h=e.multiChain?s==null?void 0:s[f.chainId]:i;if(!h)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(h,g,x({gasPrice:S},e.multiChain?(A=e.opts)==null?void 0:A[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Se(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Nt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var xn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=d(),l=K(o||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(I=>{if(I)return H({chainId:i.map(f=>f.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(o){if(!l)return;e&&s?q({onError:n}):!e&&t&&q({onError:n});}},[l]),react.useEffect(()=>{var m,I,f,C,g,p,S,h,O,y,A,T,P,D,_,X,ne,w;if(o){if(!l)return;o==="cosmostation"&&((I=(m=ue()).subscription)==null||I.call(m,()=>{q({onError:n});})),o==="keplr"&&((C=(f=pe()).subscription)==null||C.call(f,()=>{q({onError:n});})),o==="leap"&&((p=(g=me()).subscription)==null||p.call(g,()=>{q({onError:n});})),o==="compass"&&((h=(S=ce()).subscription)==null||h.call(S,()=>{q({onError:n});})),o==="vectis"&&((y=(O=ge()).subscription)==null||y.call(O,()=>{q({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((T=(A=Q()).subscription)==null||T.call(A,()=>{q({onError:n});})),o==="station"&&((D=(P=fe()).subscription)==null||D.call(P,()=>{q({onError:n});})),o==="xdefi"&&((X=(_=ye()).subscription)==null||X.call(_,()=>{q({onError:n});})),o==="cosmiframe"&&((w=(ne=le()).subscription)==null||w.call(ne,()=>{q({onError:n});}));}},[o,a,l]),null},Kt=()=>(xn(),null);var Wn=new reactQuery.QueryClient({}),Fa=o=>{var r=o,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return yt(t),jsxRuntime.jsxs(reactQuery.QueryClientProvider,F(x({client:Wn},n),{children:[e,jsxRuntime.jsx(Nt,{children:jsxRuntime.jsx(Kt,{})})]}),"graz-provider")};
|
|
24
25
|
|
|
25
|
-
exports.GrazEvents =
|
|
26
|
-
exports.GrazProvider =
|
|
26
|
+
exports.GrazEvents = Kt;
|
|
27
|
+
exports.GrazProvider = Fa;
|
|
27
28
|
exports.WALLET_TYPES = $e;
|
|
28
29
|
exports.WalletType = je;
|
|
29
|
-
exports.checkWallet =
|
|
30
|
-
exports.clearRecentChain =
|
|
31
|
-
exports.clearSession =
|
|
32
|
-
exports.configureGraz =
|
|
33
|
-
exports.connect =
|
|
34
|
-
exports.defineChainInfo =
|
|
35
|
-
exports.defineChains =
|
|
36
|
-
exports.disconnect =
|
|
37
|
-
exports.executeContract =
|
|
38
|
-
exports.getAvailableWallets =
|
|
39
|
-
exports.getChainInfo =
|
|
40
|
-
exports.getChainInfos =
|
|
30
|
+
exports.checkWallet = K;
|
|
31
|
+
exports.clearRecentChain = ke;
|
|
32
|
+
exports.clearSession = N;
|
|
33
|
+
exports.configureGraz = yt;
|
|
34
|
+
exports.connect = H;
|
|
35
|
+
exports.defineChainInfo = br;
|
|
36
|
+
exports.defineChains = Er;
|
|
37
|
+
exports.disconnect = ie;
|
|
38
|
+
exports.executeContract = wt;
|
|
39
|
+
exports.getAvailableWallets = Zo;
|
|
40
|
+
exports.getChainInfo = dr;
|
|
41
|
+
exports.getChainInfos = fr;
|
|
41
42
|
exports.getCosmostation = ue;
|
|
42
43
|
exports.getKeplr = pe;
|
|
43
44
|
exports.getLeap = me;
|
|
44
|
-
exports.getMetamaskSnapLeap =
|
|
45
|
-
exports.getOfflineSigners =
|
|
46
|
-
exports.getQueryRaw =
|
|
47
|
-
exports.getQuerySmart =
|
|
48
|
-
exports.getRecentChainIds =
|
|
49
|
-
exports.getRecentChains =
|
|
45
|
+
exports.getMetamaskSnapLeap = st;
|
|
46
|
+
exports.getOfflineSigners = ft;
|
|
47
|
+
exports.getQueryRaw = It;
|
|
48
|
+
exports.getQuerySmart = At;
|
|
49
|
+
exports.getRecentChainIds = pr;
|
|
50
|
+
exports.getRecentChains = mr;
|
|
50
51
|
exports.getVectis = ge;
|
|
51
|
-
exports.getWCCosmostation =
|
|
52
|
-
exports.getWCKeplr =
|
|
53
|
-
exports.getWCLeap =
|
|
52
|
+
exports.getWCCosmostation = ut;
|
|
53
|
+
exports.getWCKeplr = pt;
|
|
54
|
+
exports.getWCLeap = mt;
|
|
54
55
|
exports.getWallet = R;
|
|
55
56
|
exports.getWalletConnect = Q;
|
|
56
|
-
exports.instantiateContract =
|
|
57
|
+
exports.instantiateContract = ht;
|
|
57
58
|
exports.isCapsule = xe;
|
|
58
|
-
exports.isWalletConnect =
|
|
59
|
+
exports.isWalletConnect = dt;
|
|
59
60
|
exports.reconnect = q;
|
|
60
|
-
exports.sendIbcTokens =
|
|
61
|
-
exports.sendTokens =
|
|
61
|
+
exports.sendIbcTokens = Ct;
|
|
62
|
+
exports.sendTokens = St;
|
|
62
63
|
exports.suggestChain = ve;
|
|
63
|
-
exports.suggestChainAndConnect =
|
|
64
|
+
exports.suggestChainAndConnect = gt;
|
|
64
65
|
exports.useAccount = Y;
|
|
65
|
-
exports.useActiveChainCurrency =
|
|
66
|
-
exports.useActiveChainIds =
|
|
67
|
-
exports.useActiveChains =
|
|
68
|
-
exports.useActiveWalletType =
|
|
69
|
-
exports.useBalance =
|
|
70
|
-
exports.useBalanceStaked =
|
|
71
|
-
exports.useBalances =
|
|
72
|
-
exports.useCapsule =
|
|
73
|
-
exports.useChainInfo =
|
|
74
|
-
exports.useChainInfos =
|
|
66
|
+
exports.useActiveChainCurrency = Ps;
|
|
67
|
+
exports.useActiveChainIds = ks;
|
|
68
|
+
exports.useActiveChains = In;
|
|
69
|
+
exports.useActiveWalletType = Jr;
|
|
70
|
+
exports.useBalance = ps;
|
|
71
|
+
exports.useBalanceStaked = gs;
|
|
72
|
+
exports.useBalances = An;
|
|
73
|
+
exports.useCapsule = Is;
|
|
74
|
+
exports.useChainInfo = vs;
|
|
75
|
+
exports.useChainInfos = Ws;
|
|
75
76
|
exports.useCheckWallet = he;
|
|
76
|
-
exports.useConnect =
|
|
77
|
+
exports.useConnect = ms;
|
|
77
78
|
exports.useCosmWasmClient = Ne;
|
|
78
|
-
exports.useCosmWasmSigningClient =
|
|
79
|
-
exports.useCosmWasmTmSigningClient =
|
|
80
|
-
exports.useDisconnect =
|
|
81
|
-
exports.useExecuteContract =
|
|
82
|
-
exports.useGrazEvents =
|
|
83
|
-
exports.useInstantiateContract =
|
|
84
|
-
exports.useOfflineSigners =
|
|
85
|
-
exports.useQueryClientValidators =
|
|
86
|
-
exports.useQueryRaw =
|
|
87
|
-
exports.useQuerySmart =
|
|
88
|
-
exports.useRecentChainIds =
|
|
89
|
-
exports.useRecentChains =
|
|
90
|
-
exports.useSendIbcTokens =
|
|
91
|
-
exports.useSendTokens =
|
|
79
|
+
exports.useCosmWasmSigningClient = ua;
|
|
80
|
+
exports.useCosmWasmTmSigningClient = ma;
|
|
81
|
+
exports.useDisconnect = ds;
|
|
82
|
+
exports.useExecuteContract = Vs;
|
|
83
|
+
exports.useGrazEvents = xn;
|
|
84
|
+
exports.useInstantiateContract = $s;
|
|
85
|
+
exports.useOfflineSigners = fs;
|
|
86
|
+
exports.useQueryClientValidators = Rs;
|
|
87
|
+
exports.useQueryRaw = Ys;
|
|
88
|
+
exports.useQuerySmart = Hs;
|
|
89
|
+
exports.useRecentChainIds = Ds;
|
|
90
|
+
exports.useRecentChains = _s;
|
|
91
|
+
exports.useSendIbcTokens = js;
|
|
92
|
+
exports.useSendTokens = Qs;
|
|
92
93
|
exports.useStargateClient = _e;
|
|
93
|
-
exports.useStargateSigningClient =
|
|
94
|
-
exports.useStargateTmSigningClient =
|
|
95
|
-
exports.useSuggestChain =
|
|
96
|
-
exports.useSuggestChainAndConnect =
|
|
97
|
-
exports.useTendermintClient =
|
|
94
|
+
exports.useStargateSigningClient = la;
|
|
95
|
+
exports.useStargateTmSigningClient = pa;
|
|
96
|
+
exports.useSuggestChain = Ns;
|
|
97
|
+
exports.useSuggestChainAndConnect = Ks;
|
|
98
|
+
exports.useTendermintClient = Ce;
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middleware';
|
|
3
|
+
import { encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType, rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino';
|
|
3
4
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
4
5
|
import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
|
|
5
6
|
import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
|
|
6
|
-
import
|
|
7
|
+
import an from 'long';
|
|
7
8
|
import { SignClient } from '@walletconnect/sign-client';
|
|
8
9
|
import { getSdkError } from '@walletconnect/utils';
|
|
9
10
|
import { QueryClient, useQuery, useMutation, QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -12,8 +13,8 @@ import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate
|
|
|
12
13
|
import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargate';
|
|
13
14
|
import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
|
|
14
15
|
import { shallow } from 'zustand/shallow';
|
|
15
|
-
import {
|
|
16
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
16
17
|
|
|
17
|
-
var Lt=Object.defineProperty,Ut=Object.defineProperties;var Ft=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},F=(e,t)=>Ut(e,Ft(t));var je=(e,t)=>{var n={};for(var i in e)ze.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&ae)for(var i of ae(e))t.indexOf(i)<0&&Qe.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{s(n.next(c));}catch(p){r(p);}},a=c=>{try{s(n.throw(c));}catch(p){r(p);}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,a);s((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var $e=(C=>(C.KEPLR="keplr",C.LEAP="leap",C.VECTIS="vectis",C.COSMOSTATION="cosmostation",C.WALLETCONNECT="walletconnect",C.WC_KEPLR_MOBILE="wc_keplr_mobile",C.WC_LEAP_MOBILE="wc_leap_mobile",C.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",C.WC_CLOT_MOBILE="wc_clot_mobile",C.METAMASK_SNAP_LEAP="metamask_snap_leap",C.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",C.STATION="station",C.XDEFI="xdefi",C.CAPSULE="capsule",C.COSMIFRAME="cosmiframe",C.COMPASS="compass",C))($e||{}),He=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass"];var Gt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},zt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},m=create(subscribeWithSelector(persist(()=>ne,zt))),u=create(subscribeWithSelector(persist(()=>Gt,Qt)));var ce=()=>{var E,O;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((O=u.getState().capsuleConfig)!=null&&O.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var A,C;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(A=u.getState().capsuleConfig)==null?void 0:A.apiKey,env:(C=u.getState().capsuleConfig)==null?void 0:C.env});return m.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,A=m.getState().capsuleClient;A||(A=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var v;let d=m.getState().capsuleClient,{chains:g}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!g)throw new Error("Chains are not set");yield d.enable();let A=(v=u.getState().capsuleState)==null?void 0:v.chainId;if(!A)throw new Error("Chain ids are not set");let C=Object.fromEntries(yield Promise.all(A.map(f=>l(void 0,null,function*(){let w=yield d.getAccount(f);return [f,{address:fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));m.setState(f=>({accounts:M(M({},f.accounts||{}),C)})),u.setState(f=>({recentChainIds:[...f.recentChainIds||[],...A].filter((w,x,R)=>R.indexOf(w)===x)})),m.setState(f=>({activeChainIds:[...f.activeChainIds||[],...A].filter((w,x,R)=>R.indexOf(w)===x)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let A=yield g.getAccount(d);return {address:fromBech32(A.address).data,bech32Address:A.address,algo:A.algo,name:A.username||"",pubKey:A.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[g,A,C]=d,v=m.getState().capsuleClient;if(!v)throw new Error("Capsule client is not initialized");return v.signDirect(g,A,{bodyBytes:C.bodyBytes,authInfoBytes:C.authInfoBytes,chainId:C.chainId,accountNumber:C.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,A,C,v]=d,f=m.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,A,C,v)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=m.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}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 tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var S;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 s=(S=o.split("MetaMask/v")[1])==null?void 0:S.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,a,s)=>l(void 0,null,function*(){return t.signAmino(o,a,s)}),getKey:o=>l(void 0,null,function*(){return typeof tt[o]!="undefined"?tt[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,a,s)=>l(void 0,null,function*(){return t.signDirect(o,a,s)}),signArbitrary:(o,a,s)=>l(void 0,null,function*(){return t.signArbitrary(o,a,s)}),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=>{var s;let a=()=>{q(),o();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},ot=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=f=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(x=>x.id===e.id&&(!f||x.version===f))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var _;let f=yield t.request({method:"web3_clientVersion"});if(!f.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 x=(_=f.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(x)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),a=f=>l(void 0,null,function*(){(yield i())||(yield r());}),s=(f,w,x)=>l(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:x}}}}),N=x.accountNumber,_=new Vt(N.low,N.high,N.unsigned);return {signature:R.signature,signed:F(M({},R.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),c=(f,w,x)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:w,signDoc:x}}}})}),p=f=>l(void 0,null,function*(){if(typeof fe[f]!="undefined")return fe[f];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,fe[f]=w,fe[f]}),S=f=>l(void 0,null,function*(){let w=yield p(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,x,R,N]=f;return yield c(w,x,R)}),O=(...f)=>l(void 0,null,function*(){let[w,x,R]=f;return yield s(w,x,R)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signAmino:(w,x)=>E(f,w,x)});return {enable:a,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(f)]}),signDirect:(w,x)=>O(f,w,x),signAmino:(w,x)=>E(f,w,x)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return g(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:O}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var it=()=>ot({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let a=()=>{q(),o();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:o=>l(void 0,null,function*(){let a=yield e.getKey(o);return M({isKeystone:!1},a)}),getOfflineSigner:o=>{try{let a=e.getOfflineSignerOnlyAmino(o);return Object.assign(a,{signDirect:(p,S)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let a=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(s=>{var c,p,S;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((p=s.gasPriceStep)==null?void 0:p.high)||0,low:((S=s.gasPriceStep)==null?void 0:S.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,a,s,c)=>e.signAmino(o,a,s)}}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:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{q(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>e.getOfflineSignerAmino(...s),experimentalSuggestChain:(...s)=>l(void 0,null,function*(){let[c]=s,p=F(M({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([p])}),signDirect:(...s)=>l(void 0,null,function*(){var S;let{1:c,2:p}=s;return e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Vt.fromString(((S=p.accountNumber)==null?void 0:S.toString())||"",!1),chainId:p.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:p}=s;return e.signAmino(c,p)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,rt=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),st=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var xe=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var j=e=>{var _,J,oe;if(!((oe=(J=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:J.projectId)!=null&&oe.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",i=y=>{if(!e)return;let{appUrl:h,formatNativeUrl:I}=e;if(Q()){if(rt())if(!y)window.open(h.mobile.android,"_self","noreferrer noopener");else {let W=I(h.mobile.android,y,"android");window.open(W,"_self","noreferrer noopener");}if(st())if(!y)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let W=I(h.mobile.ios,y,"ios");window.open(W,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=m.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),m.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield I.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(I);}),a=y=>{try{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=I.session.getAll().at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let k=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!k.length)throw new Error("no session");return k.at(-1)}catch(k){if(!k.message.toLowerCase().includes("no matching key"))throw k}return W}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},s=y=>{try{return a(y)}catch(h){return}},c=y=>l(void 0,null,function*(){try{let h=y.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),p=()=>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:h}=m.getState(),I=h.get(t);if(I)return I;let W=yield SignClient.init(y.options);return h.set(t,W),m.setState({wcSignClients:h}),W}),S=y=>{let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)return ()=>{};let W=P=>{let k=m.getState().accounts;if(P.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(L=>L.bech32Address).includes(P.params.event.data[0])){let L=P.params.chainId.split(":")[1];L&&E([L]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",W),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",W);}},E=y=>l(void 0,null,function*(){var re;let h=typeof y=="string"?[y]:y,{wcSignClients:I}=m.getState(),W=I.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:k}=u.getState();if(!((re=P==null?void 0:P.options)!=null&&re.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:L}=yield import('@web3modal/standalone'),H=new L(M({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=s(h);if(!Z){let{uri:U,approval:ee}=yield xe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?i(U):yield H.openModal({uri:U});let Kt=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,te)=>{ee().then(Le=>{let Ue=Le.sessionProperties;if(!Ue)return te(new Error("No session properties"));let Me=JSON.parse(String(Ue.keys));if(Me.length===0)return te(new Error("No accounts"));let Fe=Me[0];if(!Fe)return te(new Error("No accounts"));let qe={};return h.forEach(se=>{qe[se]=F(M({},Fe),{bech32Address:toBech32(k.find(Bt=>Bt.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Me[0].bech32Address).data)});}),m.setState(se=>({accounts:M(M({},se.accounts||{}),qe)})),be(Le)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,be=$.signal;H.subscribeModal(te=>{te.open||$.abort();}),yield Kt(be);}catch($){if(H.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||H.closeModal(),Promise.resolve()}try{yield xe((()=>l(void 0,null,function*(){let U=Object.fromEntries(yield Promise.all(h.map(ee=>l(void 0,null,function*(){return [ee,yield d(ee)]}))));m.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(o(Z.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),O=y=>l(void 0,null,function*(){var k;let{wcSignClients:h}=m.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=(k=a([y]))==null?void 0:k.topic;if(!W)throw new Error("No wallet connect session");let P=yield I.request({topic:W,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!P[0])throw new Error("No wallet connect account");return {address:P[0].address,algo:P[0].algo,pubkey:new Uint8Array(Buffer.from(P[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let h=a([y]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let I=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var U,ee;let[h,I,W]=y,{accounts:P,wcSignClients:k}=m.getState(),L=k.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let H=(U=a([h]))==null?void 0:U.topic;if(!H)throw new Error("No wallet connect session");if(!W.bodyBytes)throw new Error("No bodyBytes");if(!W.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:H,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:F(M({},W),{bodyBytes:Buffer.from(W.bodyBytes).toString(n),authInfoBytes:Buffer.from(W.authInfoBytes).toString(n),accountNumber:(ee=W.accountNumber)==null?void 0:ee.toString()})}}};return i(),yield L.request(Z)}),A=(...y)=>l(void 0,null,function*(){let[h,I,W]=y,{signature:P,signed:k}=yield g(h,I,W);return {signed:{chainId:k.chainId,accountNumber:Vt.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:P}}),C=(...y)=>l(void 0,null,function*(){var U;let[h,I,W,P]=y,{wcSignClients:k}=m.getState(),L=k.get(t),{accounts:H}=m.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let Z=(U=a([h]))==null?void 0:U.topic;if(!Z)throw new Error("No wallet connect session");return i(),yield L.request({topic:Z,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:W}}})}),v=(...y)=>l(void 0,null,function*(){let[h,I,W,P]=y;return yield C(h,I,W)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signAmino:(h,I)=>v(y,h,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var W;let{wcSignClients:h}=m.getState(),I=h.get(t);if(y===void 0){let P=I==null?void 0:I.session.getAll();P!==void 0&&(yield Promise.all(P.map(k=>o(k.topic))));}else typeof y=="string"?yield o((W=a([y]))==null?void 0:W.topic):yield Promise.all(y.map(P=>{var k;return o((k=a([P]))==null?void 0:k.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield O(y)]}),signDirect:(h,I)=>A(y,h,I),signAmino:(h,I)=>v(y,h,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:v,signDirect:A,subscription:S,init:p}};var at=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ct=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,o,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var lt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ut=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,o,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(a){case"ios":return `${s}://wcV2?${c}`;case"android":return `${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${s}://wc?uri=${c}`}}};return j(e)};var ye=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{q(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},q=()=>{window.sessionStorage.removeItem(V),m.setState(ne);},D=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return Ce();case"walletconnect":return j();case"wc_keplr_mobile":return lt();case"wc_leap_mobile":return ut();case"wc_cosmostation_mobile":return ct();case"wc_clot_mobile":return at();case"metamask_snap_leap":return it();case"metamask_snap_cosmos":return nt();case"station":return ge();case"xdefi":return ye();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},Di=()=>Object.fromEntries(He.map(e=>[e,K(e)])),We=e=>e==="capsule",pt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!K(o))throw new Error(`${o} is not available`);let s=D(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let p=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(p!=null&&p.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),m.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(C=>{var v;return !((v=d.activeChainIds)!=null&&v.includes(C))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:S}=m.getState();if(yield (t=s.init)==null?void 0:t.call(s),We(o)&&m.getState().capsuleClient&&Object.values(m.getState().accounts||[]).length>0){let d=c.map(C=>i.find(v=>v.chainId===C)),g=m.getState().accounts;m.setState({status:"connecting"});let A=Object.fromEntries(yield Promise.all(c.map(C=>l(void 0,null,function*(){return [C,yield s.getKey(C)]}))));return m.setState(C=>({accounts:M(M({},C.accounts||{}),A)})),u.setState(C=>({recentChainIds:[...C.recentChainIds||[],...c].filter((v,f,w)=>w.indexOf(v)===f)})),m.setState(C=>({activeChainIds:[...C.activeChainIds||[],...c].filter((v,f,w)=>w.indexOf(v)===f)})),m.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield s.enable(c),We(o)){let d=c.map(A=>i.find(C=>C.chainId===A)),g=m.getState().accounts;return m.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!pt(o)){let d=Object.fromEntries(yield Promise.all(c.map(g=>l(void 0,null,function*(){return [g,yield s.getKey(g)]}))));m.setState(g=>({accounts:M(M({},g.accounts||{}),d)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),m.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,A,C)=>C.indexOf(g)===A)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),m.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:m.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),m.getState().accounts===null&&m.setState({status:"disconnected"}),m.getState().accounts&&m.getState().activeChainIds&&m.setState({status:"connected"}),n}}),ie=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=m.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(m.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(m.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(a=>!t.includes(a))}}));}else m.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},G=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=K(n||void 0);if(t&&o&&n)return yield Y({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ie();}}),mt=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(!K(n))throw new Error(`${n} is not available`);let r=D(n),o=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:a,offlineSignerAuto:s}});var ve=()=>{u.setState({recentChainIds:null});},ji=()=>u.getState().recentChainIds,$i=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},Hi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Vi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ke=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),dt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield ke({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield Y({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,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var gt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,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,i,r,o)}),Ct=S=>l(void 0,[S],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:p}){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,i,r,o,a,s,c,p)}),yt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,o,i,r)}),St=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,a,o)}),ht=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),wt=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var rr=e=>e,sr=e=>e;var Se=e=>e?Object.keys(e).length===0:!0;var Pe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},At=e=>globalThis.DOMException===void 0?new Pe(e):new DOMException(e),It=e=>{let t=e.reason===void 0?At("This operation was aborted."):e.reason;return t instanceof Error?t:At(t)};function Re(o,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((s,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 p=[],S=[],E=new Map,O=!1,d=!1,g=!1,A=0,C=0,v=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=x=>{O=!0,d=!0,c(x);};r&&(r.aborted&&f(It(r)),r.addEventListener("abort",()=>{f(It(r));}));let w=()=>l(this,null,function*(){if(d)return;let x=yield v.next(),R=C;if(C++,x.done){if(g=!0,A===0&&!d){if(!i&&S.length>0){f(new AggregateError(S));return}if(d=!0,E.size===0){s(p);return}let N=[];for(let[_,J]of p.entries())E.get(_)!==Et&&N.push(J);s(N);}return}A++,l(this,null,function*(){try{let N=yield x.value;if(d)return;let _=yield t(N,R);_===Et&&E.set(R,_),p[R]=_,A--,yield w();}catch(N){if(i)f(N);else {S.push(N),A--;try{yield w();}catch(_){f(_);}}}});});l(this,null,function*(){for(let x=0;x<n;x++){try{yield w();}catch(R){f(R);break}if(g||O)break}});})})}var Et=Symbol("skip");var B=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},z=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Re(t,n,{concurrency:i});return Object.fromEntries(o.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),Ot=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,a)=>[t[a].chainId,o]))}return n(t[0])};var Ne=e=>{let t=B({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:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ke=e=>{let t=B({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:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,a=>l(void 0,null,function*(){var S;let s=(S=u.getState().chainsConfig)==null?void 0:S[a.chainId],c={url:a.rpc,headers:M({},(s==null?void 0:s.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=B({chainId:t,multiChain:n}),o=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield z(!!n,s,S=>l(void 0,null,function*(){var A;let E=(A=u.getState().chainsConfig)==null?void 0:A[S.chainId],O={url:S.rpc,headers:M({},(E==null?void 0:E.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(O)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var Rr=()=>u(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",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),we=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>K(r))};var X=e=>{let t=u(s=>s.walletType),n=m(s=>s.activeChainIds),i=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=m(s=>s.accounts),o=m(s=>s.status);return useEffect(()=>m.subscribe(s=>s.status,(s,c)=>{var p,S,E;if(s==="connected"){let{accounts:O,activeChainIds:d}=m.getState(),{chains:g}=u.getState(),{walletType:A}=u.getState();if(!O||!d||!g)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(S=e==null?void 0:e.onConnect)==null||S.call(e,{accounts:O,chains:d.map(C=>g.find(v=>v.chainId===C)),walletType:A,isReconnect:c==="reconnecting"});}s==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:useMemo(()=>r?Ot(!!(e!=null&&e.multiChain),i,s=>r[s.chainId]):void 0,[r,i,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:G,status:o}},pn=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){let O=a==null?void 0:a[E.chainId];if(!O)throw new Error(`Client is not ready ${E.chainId}`);return yield O.getAllBalances(toBech32(E.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!Se(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},jr=e=>{let t=B({chainId:e.chainId}),{data:n}=X({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=pn({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,i,e.chainId],s=useQuery(a,({queryKey:[,c,p]})=>p==null?void 0:p.find(S=>S.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(M({},s),{refetch:c=>l(void 0,null,function*(){return yield o(),s.refetch(c)})})},$r=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=we();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Hr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],ie,{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=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Vr=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!K(o))throw new Error(`${o} is not available`);return yield z(!!(e!=null&&e.multiChain),r,p=>l(void 0,null,function*(){return yield mt({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Yr=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),{data:i}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return useQuery(o,p=>l(void 0,[p],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),s,E=>l(void 0,null,function*(){var d;if(!a)throw new Error("Client is not ready");return yield (d=a[E.chainId])==null?void 0:d.getBalanceStaked(toBech32(E.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var os=()=>{let e=u(i=>i.capsuleState),t=m(i=>i.capsuleClient),n=ce();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ie();}}};var us=()=>m(e=>e.activeChainIds),mn=()=>{var e;return (e=m(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ms=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ds=({denom:e})=>{let t=mn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:o.currencies.find(a=>a)})},fs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,s=>l(void 0,[s],function*({queryKey:[,o,a]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},gs=()=>({data:u(t=>t.recentChainIds),clear:ve}),Cs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:ve}},ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],ke,{onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],dt,{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:o}=we();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=X(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],a=>gt(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Ms=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=X(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],a=>Ct(M({senderAddress:r},a)),{onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},xs=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=X(),o=r==null?void 0:r.bech32Address,s=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var S;if(!o)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,codeId:e});return yt(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Ws=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=X(),o=r==null?void 0:r.bech32Address,s=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var S,E,O;if(!o)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(S=c.fee)!=null?S:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(O=c.funds)!=null?O:[]});return St(p)},{onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},vs=e=>{let{data:t}=Ke();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return ht(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ks=e=>{let{data:t}=Ke(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return wt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function zs(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var A,C;if(!(i!=null&&i.includes(p.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(p.chainId);default:return D(a).getOfflineSignerAuto(p.chainId)}}))(),O=(A=u.getState().chainsConfig)==null?void 0:A[p.chainId],d={url:p.rpc,headers:M({},(O==null?void 0:O.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(C=e.opts)==null?void 0:C[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Qs(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=m(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var C,v;if(!(i!=null&&i.includes(p.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(p.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(p.chainId);default:return D(a).getOfflineSignerAuto(p.chainId)}}))(),O=(C=u.getState().chainsConfig)==null?void 0:C[p.chainId],d={url:p.rpc,headers:M({},(O==null?void 0:O.rpcHeaders)||{})},g=O!=null&&O.gas?GasPrice.fromString(`${O.gas.price}${O.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(d,E,M({gasPrice:g},e!=null&&e.multiChain?(v=e.opts)==null?void 0:v[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function js(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=m(a=>a.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,a,S=>l(this,null,function*(){var A;if(!(i!=null&&i.includes(S.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);if(!o)throw new Error("No tendermint client found");let O=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(S.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(S.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(S.chainId);default:return D(s).getOfflineSignerAuto(S.chainId)}}))(),d=e.multiChain?o[S.chainId]:o;return yield SigningStargateClient.createWithSigner(d,O,e.multiChain?(A=e.opts)==null?void 0:A[S.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function $s(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=m(s=>s.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:p=>l(this,[p],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,s,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return null;if(!K(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return D(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return D(c).getOfflineSignerOnlyAmino(E.chainId);default:return D(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],A=g!=null&&g.gas?GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,C=e.multiChain?a==null?void 0:a[E.chainId]:o;if(!C)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(C,d,M({gasPrice:A},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!Se(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Dt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var Sn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:a,wcSignClients:s}=m(),c=K(i||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(S=>{if(S)return Y({chainId:o.map(E=>E.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(i){if(!c)return;e&&a?G({onError:n}):!e&&t&&G({onError:n});}},[c]),useEffect(()=>{var p,S,E,O,d,g,A,C,v,f,w,x,R,N,_,J,oe,y;if(i){if(!c)return;i==="cosmostation"&&((S=(p=pe()).subscription)==null||S.call(p,()=>{G({onError:n});})),i==="keplr"&&((O=(E=me()).subscription)==null||O.call(E,()=>{G({onError:n});})),i==="leap"&&((g=(d=de()).subscription)==null||g.call(d,()=>{G({onError:n});})),i==="compass"&&((C=(A=le()).subscription)==null||C.call(A,()=>{G({onError:n});})),i==="vectis"&&((f=(v=Ce()).subscription)==null||f.call(v,()=>{G({onError:n});})),i==="walletconnect"&&s.has("walletconnect")&&((x=(w=j()).subscription)==null||x.call(w,()=>{G({onError:n});})),i==="station"&&((N=(R=ge()).subscription)==null||N.call(R,()=>{G({onError:n});})),i==="xdefi"&&((J=(_=ye()).subscription)==null||J.call(_,()=>{G({onError:n});})),i==="cosmiframe"&&((y=(oe=ue()).subscription)==null||y.call(oe,()=>{G({onError:n});}));}},[i,s,c]),null},_t=()=>(Sn(),null);var An=new QueryClient({}),Ia=i=>{var r=i,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return ft(t),jsx(QueryClientProvider,F(M({client:An},n),{children:jsxs(Dt,{children:[e,jsx(_t,{})]})}),"graz-provider")};
|
|
18
|
+
var qt=Object.defineProperty,Gt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},q=(e,t)=>Gt(e,zt(t));var je=(e,t)=>{var n={};for(var o in e)ze.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&ae)for(var o of ae(e))t.indexOf(o)<0&&Qe.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(m){r(m);}},s=l=>{try{a(n.throw(l));}catch(m){r(m);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var $e=(O=>(O.KEPLR="keplr",O.LEAP="leap",O.VECTIS="vectis",O.COSMOSTATION="cosmostation",O.WALLETCONNECT="walletconnect",O.WC_KEPLR_MOBILE="wc_keplr_mobile",O.WC_LEAP_MOBILE="wc_leap_mobile",O.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",O.WC_CLOT_MOBILE="wc_clot_mobile",O.METAMASK_SNAP_LEAP="metamask_snap_leap",O.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",O.STATION="station",O.XDEFI="xdefi",O.CAPSULE="capsule",O.COSMIFRAME="cosmiframe",O.COMPASS="compass",O.INITIA="initia",O))($e||{}),Ve=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia"];var jt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},$t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Vt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},d=create(subscribeWithSelector(persist(()=>ne,$t))),u=create(subscribeWithSelector(persist(()=>jt,Vt)));var ce=()=>{var C,g;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((g=u.getState().capsuleConfig)!=null&&g.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return d.setState({capsuleClient:S}),S});return {init:e,enable:p=>c(void 0,null,function*(){let S=typeof p=="string"?[p]:p,h=d.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var y;let p=d.getState().capsuleClient,{chains:S}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield p.enable();let h=(y=u.getState().capsuleState)==null?void 0:y.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(A=>c(void 0,null,function*(){let T=yield p.getAccount(A);return [A,{address:fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));d.setState(A=>({accounts:k(k({},A.accounts||{}),O)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...h].filter((T,R,_)=>_.indexOf(T)===R)})),d.setState(A=>({activeChainIds:[...A.activeChainIds||[],...h].filter((T,R,_)=>_.indexOf(T)===R)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(p);return {address:fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)},signDirect:(...p)=>c(void 0,null,function*(){let[S,h,O]=p,y=d.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signDirect(S,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>c(void 0,null,function*(){let[S,h,O,y]=p,A=d.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(S,h,O,y)}),signArbitrary:(p,S,h)=>c(void 0,null,function*(){let O=d.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let y=yield O.getAccount(p);if(!y)throw new Error(`Wallet not connected to account ${S}`);let A=(()=>{switch(y.algo){case"secp256k1":return encodeSecp256k1Pubkey(y.pubkey);case"ed25519":return encodeEd25519Pubkey(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(p,S,h),pub_key:{type:y.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(p)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}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 nt={},it=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var I;let i=yield e.request({method:"web3_clientVersion"});if(!i.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 a=(I=i.split("MetaMask/v")[1])==null?void 0:I.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:i=>c(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof nt[i]!="undefined"?nt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};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:i=>{let s=()=>{K(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var rn=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},sn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,rt=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:f=>c(void 0,null,function*(){let C=e.getOfflineSigner(f),[g]=yield C.getAccounts();if(!g)throw new Error("Wallet connection failed");let p=(()=>{switch(g.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(g.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(g.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:sn(g.address),algo:g.algo,pubKey:g.pubkey,bech32Address:g.address,address:p,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let C=e.getOfflineSigner(f),g=e.getOfflineSignerOnlyAmino(f);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:g.signAmino.bind(g)}},getOfflineSignerAuto:f=>Promise.resolve(e.getOfflineSigner(f)),getOfflineSignerOnlyAmino:f=>e.getOfflineSignerOnlyAmino(f),experimentalSuggestChain:f=>e.requestAddInitiaLayer({chain_id:f.chainId,chain_name:f.chainName,bech32_prefix:"init",bech32_config:f.bech32Config,slip44:f.bip44.coinType,logo_URIs:{png:f.chainSymbolImageUrl},fees:{fee_tokens:f.feeCurrencies.map(C=>{var g,p,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(g=C.gasPriceStep)==null?void 0:g.low,average_gas_price:(p=C.gasPriceStep)==null?void 0:p.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[C,g,p]=f;return e.getOfflineSigner(C).signDirect(g,rn(p))},signAmino:(...f)=>{let[C,g,p]=f;return e.getOfflineSignerOnlyAmino(C).signAmino(g,p)},signArbitrary:(f,C,g)=>c(void 0,null,function*(){let h=(yield e.getOfflineSigner(f).getAccounts()).find(A=>A.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let O=(()=>{switch(h.algo){case"secp256k1":return encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(g),pub_key:{type:h.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:O.value}}}),subscription:f=>{let C=()=>{K(),f();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},st=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(T=>T.id===e.id&&(!y||T.version===y))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var N;let y=yield t.request({method:"web3_clientVersion"});if(!y.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 T=(N=y.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=y=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(y,A,T)=>c(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:A,signDoc:T}}}}),_=T.accountNumber,N=new an(_.low,_.high,_.unsigned);return {signature:R.signature,signed:q(k({},R.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),l=(y,A,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:A,signDoc:T}}}})}),m=y=>c(void 0,null,function*(){if(typeof fe[y]!="undefined")return fe[y];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[y]=A,fe[y]}),I=y=>c(void 0,null,function*(){let A=yield m(y);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),f=(...y)=>c(void 0,null,function*(){let[A,T,R,_]=y;return yield l(A,T,R)}),C=(...y)=>c(void 0,null,function*(){let[A,T,R]=y;return yield a(A,T,R)}),p=y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signAmino:(A,T)=>f(y,A,T)});return {enable:s,experimentalSuggestChain:(...y)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:y[0]}}}});}),getKey:m,getOfflineSigner:y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signDirect:(A,T)=>C(y,A,T),signAmino:(A,T)=>f(y,A,T)}),getOfflineSignerAuto:y=>c(void 0,null,function*(){return p(y)}),getOfflineSignerOnlyAmino:p,init:i,signAmino:f,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var at=()=>st({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{K(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return k({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(m,I)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,m,I;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((I=a.gasPriceStep)==null?void 0:I.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ye=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{K(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,m=q(k({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>c(void 0,null,function*(){var I;let{1:l,2:m}=a;return e.signDirect(l,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:an.fromString(((I=m.accountNumber)==null?void 0:I.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:m}=a;return e.signAmino(l,m)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,ct=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),lt=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var xe=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var j=e=>{var N,J,ie;if(!((ie=(J=(N=u.getState().walletConnect)==null?void 0:N.options)==null?void 0:J.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",o=w=>{if(!e)return;let{appUrl:E,formatNativeUrl:b}=e;if(Q()){if(ct())if(!w)window.open(E.mobile.android,"_self","noreferrer noopener");else {let v=b(E.mobile.android,w,"android");window.open(v,"_self","noreferrer noopener");}if(lt())if(!w)window.open(E.mobile.ios,"_self","noreferrer noopener");else {let v=b(E.mobile.ios,w,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:w}=d.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),d.setState({wcSignClients:w}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=w=>c(void 0,null,function*(){let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:getSdkError("USER_DISCONNECTED")}),yield l(b);}),s=w=>{try{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let v=b.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw i(v.topic),new Error("invalid session");try{let W=b.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return v}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}},a=w=>{try{return s(w)}catch(E){return}},l=w=>c(void 0,null,function*(){try{let E=w.core.pairing.pairings.getAll({active:!1});if(!E.length)return;yield Promise.all(E.map(b=>c(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}}),m=()=>c(void 0,null,function*(){let{walletConnect:w}=u.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:E}=d.getState(),b=E.get(t);if(b)return b;let v=yield SignClient.init(w.options);return E.set(t,v),d.setState({wcSignClients:E}),v}),I=w=>{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)return ()=>{};let v=P=>{let W=d.getState().accounts;if(P.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(U=>U.bech32Address).includes(P.params.event.data[0])){let U=P.params.chainId.split(":")[1];U&&f([U]);}else w();};return b.events.on("session_delete",r),b.events.on("session_expire",r),b.events.on("session_event",v),()=>{b.events.off("session_delete",r),b.events.off("session_expire",r),b.events.off("session_event",v);}},f=w=>c(void 0,null,function*(){var re;let E=typeof w=="string"?[w]:w,{wcSignClients:b}=d.getState(),v=b.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:W}=u.getState();if(!((re=P==null?void 0:P.options)!=null&&re.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),V=new U(k({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=a(E);if(!Z){let{uri:F,approval:ee}=yield xe(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:E.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!F)throw new Error("No wallet connect uri");e?o(F):yield V.openModal({uri:F});let Ut=$=>c(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,te)=>{ee().then(Le=>{let Ue=Le.sessionProperties;if(!Ue)return te(new Error("No session properties"));let Me=JSON.parse(String(Ue.keys));if(Me.length===0)return te(new Error("No accounts"));let Fe=Me[0];if(!Fe)return te(new Error("No accounts"));let qe={};return E.forEach(se=>{qe[se]=q(k({},Fe),{bech32Address:toBech32(W.find(Ft=>Ft.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Me[0].bech32Address).data)});}),d.setState(se=>({accounts:k(k({},se.accounts||{}),qe)})),Te(Le)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Te=$.signal;V.subscribeModal(te=>{te.open||$.abort();}),yield Ut(Te);}catch($){if(V.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||V.closeModal(),Promise.resolve()}try{yield xe((()=>c(void 0,null,function*(){let F=Object.fromEntries(yield Promise.all(E.map(ee=>c(void 0,null,function*(){return [ee,yield g(ee)]}))));d.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(i(Z.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),C=w=>c(void 0,null,function*(){var W;let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let v=(W=s([w]))==null?void 0:W.topic;if(!v)throw new Error("No wallet connect session");let P=yield b.request({topic:v,chainId:`cosmos:${w}`,request:{method:"cosmos_getAccounts",params:{}}});if(!P[0])throw new Error("No wallet connect account");return {address:P[0].address,algo:P[0].algo,pubkey:new Uint8Array(Buffer.from(P[0].pubkey,n))}}),g=w=>c(void 0,null,function*(){let E=s([w]);if(!(E!=null&&E.topic))throw new Error("No wallet connect session");let b=E.sessionProperties&&JSON.parse(String(E.sessionProperties.keys))[0];if(!b)throw new Error("No wallet connect key");return b}),p=(...w)=>c(void 0,null,function*(){var F,ee;let[E,b,v]=w,{accounts:P,wcSignClients:W}=d.getState(),U=W.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let V=(F=s([E]))==null?void 0:F.topic;if(!V)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:V,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:q(k({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(ee=v.accountNumber)==null?void 0:ee.toString()})}}};return o(),yield U.request(Z)}),S=(...w)=>c(void 0,null,function*(){let[E,b,v]=w,{signature:P,signed:W}=yield p(E,b,v);return {signed:{chainId:W.chainId,accountNumber:an.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:P}}),h=(...w)=>c(void 0,null,function*(){var F;let[E,b,v,P]=w,{wcSignClients:W}=d.getState(),U=W.get(t),{accounts:V}=d.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!V)throw new Error("account is not defined");let Z=(F=s([E]))==null?void 0:F.topic;if(!Z)throw new Error("No wallet connect session");return o(),yield U.request({topic:Z,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:v}}})}),O=(...w)=>c(void 0,null,function*(){let[E,b,v,P]=w;return yield h(E,b,v)}),y=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b)}),A=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signAmino:(E,b)=>O(w,E,b)});return {enable:f,disable:w=>c(void 0,null,function*(){var v;let{wcSignClients:E}=d.getState(),b=E.get(t);if(w===void 0){let P=b==null?void 0:b.session.getAll();P!==void 0&&(yield Promise.all(P.map(W=>i(W.topic))));}else typeof w=="string"?yield i((v=s([w]))==null?void 0:v.topic):yield Promise.all(w.map(P=>{var W;return i((W=s([P]))==null?void 0:W.topic)}));(b==null?void 0:b.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...w)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:g,getOfflineSigner:w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b),signAmino:(E,b)=>O(w,E,b)}),getOfflineSignerAuto:w=>c(void 0,null,function*(){return (yield g(w)).isNanoLedger?A(w):y(w)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:S,subscription:I,init:m}};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return j(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var dt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var Se=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},K=()=>{window.sessionStorage.removeItem(H),d.setState(ne);},D=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return ye();case"walletconnect":return j();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return at();case"metamask_snap_cosmos":return it();case"station":return ge();case"xdefi":return Se();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return rt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},er=()=>Object.fromEntries(Ve.map(e=>[e,B(e)])),ke=e=>e==="capsule",ft=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!B(i))throw new Error(`${i} is not available`);let a=D(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let m=o==null?void 0:o.map(g=>g.chainId);l.forEach(g=>{if(!(m!=null&&m.includes(g)))throw new Error(`Chain ${g} is not provided in GrazProvider`)}),d.setState(g=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return g.activeChainIds&&l.filter(h=>{var O;return !((O=g.activeChainIds)!=null&&O.includes(h))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:I}=d.getState();if(yield (t=a.init)==null?void 0:t.call(a),ke(i)&&d.getState().capsuleClient&&Object.values(d.getState().accounts||[]).length>0){let g=l.map(h=>o.find(O=>O.chainId===h)),p=d.getState().accounts;d.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(l.map(h=>c(void 0,null,function*(){return [h,yield a.getKey(h)]}))));return d.setState(h=>({accounts:k(k({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState(h=>({activeChainIds:[...h.activeChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState({status:"connected"}),{accounts:p,walletType:i,chains:g}}if(yield a.enable(l),ke(i)){let g=l.map(S=>o.find(h=>h.chainId===S)),p=d.getState().accounts;return d.setState({status:"connecting"}),{accounts:p,walletType:i,chains:g}}if(!ft(i)){let g=Object.fromEntries(yield Promise.all(l.map(p=>c(void 0,null,function*(){return [p,yield a.getKey(p)]}))));d.setState(p=>({accounts:k(k({},p.accounts||{}),g)}));}u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),d.setState(g=>({activeChainIds:[...g.activeChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let f=l.map(g=>o.find(p=>p.chainId===g));return {accounts:d.getState().accounts,walletType:i,chains:f}}catch(n){throw console.error("connect ",n),d.getState().accounts===null&&d.setState({status:"disconnected"}),d.getState().accounts&&d.getState().activeChainIds&&d.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=d.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(d.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(d.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else d.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},G=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=B(n||void 0);if(t&&i&&n)return yield Y({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),oe();}}),gt=e=>c(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(!B(n))throw new Error(`${n} is not available`);let r=D(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var ve=()=>{u.setState({recentChainIds:null});},mr=()=>u.getState().recentChainIds,dr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},fr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},We=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),yt=e=>c(void 0,null,function*(){var o;let t=u.getState().walletType;return yield We({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var St=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Ct=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),ht=I=>c(void 0,[I],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:m}){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,o,r,i,s,a,l,m)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),At=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),It=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ot=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var br=e=>e,Tr=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var Pe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Et=e=>globalThis.DOMException===void 0?new Pe(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?Et("This operation was aborted."):e.reason;return t instanceof Error?t:Et(t)};function Re(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{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 m=[],I=[],f=new Map,C=!1,g=!1,p=!1,S=0,h=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=T=>{C=!0,g=!0,l(T);};r&&(r.aborted&&y(bt(r)),r.addEventListener("abort",()=>{y(bt(r));}));let A=()=>c(this,null,function*(){if(g)return;let T=yield O.next(),R=h;if(h++,T.done){if(p=!0,S===0&&!g){if(!o&&I.length>0){y(new AggregateError(I));return}if(g=!0,f.size===0){a(m);return}let _=[];for(let[N,J]of m.entries())f.get(N)!==Tt&&_.push(J);a(_);}return}S++,c(this,null,function*(){try{let _=yield T.value;if(g)return;let N=yield t(_,R);N===Tt&&f.set(R,N),m[R]=N,S--,yield A();}catch(_){if(o)y(_);else {I.push(_),S--;try{yield A();}catch(N){y(N);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield A();}catch(R){y(R);break}if(p||C)break}});})})}var Tt=Symbol("skip");var L=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},z=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Re(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Mt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var Ne=e=>{let t=L({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:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ke=e=>{let t=L({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:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=L({chainId:t,multiChain:n}),i=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield z(!!n,a,I=>c(void 0,null,function*(){var S;let f=(S=u.getState().chainsConfig)==null?void 0:S[I.chainId],C={url:I.rpc,headers:k({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var Zr=()=>u(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",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),we=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>B(r))};var X=e=>{let t=u(a=>a.walletType),n=d(a=>a.activeChainIds),o=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=d(a=>a.accounts),i=d(a=>a.status);return useEffect(()=>d.subscribe(a=>a.status,(a,l)=>{var m,I,f;if(a==="connected"){let{accounts:C,activeChainIds:g}=d.getState(),{chains:p}=u.getState(),{walletType:S}=u.getState();if(!C||!g||!p)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(I=e==null?void 0:e.onConnect)==null||I.call(e,{accounts:C,chains:g.map(h=>p.find(O=>O.chainId===h)),walletType:S,isReconnect:l==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:useMemo(()=>r?Mt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:G,status:i}},In=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){let C=s==null?void 0:s[f.chainId];if(!C)throw new Error(`Client is not ready ${f.chainId}`);return yield C.getAllBalances(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!Ce(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ms=e=>{let t=L({chainId:e.chainId}),{data:n}=X({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=In({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=useQuery(s,({queryKey:[,l,m]})=>m==null?void 0:m.find(I=>I.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(k({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=we();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],oe,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},gs=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!B(i))throw new Error(`${i} is not available`);return yield z(!!(e!=null&&e.multiChain),r,m=>c(void 0,null,function*(){return yield gt({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},ys=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),{data:o}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){var g;if(!s)throw new Error("Client is not ready");return yield (g=s[f.chainId])==null?void 0:g.getBalanceStaked(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Os=()=>{let e=u(o=>o.capsuleState),t=d(o=>o.capsuleClient),n=ce();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var vs=()=>d(e=>e.activeChainIds),On=()=>{var e;return (e=d(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.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)},Ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Rs=({denom:e})=>{let t=On();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},_s=()=>({data:u(t=>t.recentChainIds),clear:ve}),Ns=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:ve}},Ks=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],yt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=we();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var js=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=X(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>Ct(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},$s=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=X(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>ht(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Vs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var I;if(!i)throw new Error("senderAddress is undefined");let m=q(k({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,codeId:e});return wt(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Hs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var I,f,C;if(!i)throw new Error("senderAddress is undefined");let m=q(k({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,contractAddress:e,memo:(f=l.memo)!=null?f:"",funds:(C=l.funds)!=null?C:[]});return At(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Ys=e=>{let{data:t}=Ke();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return It(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Xs=e=>{let{data:t}=Ke(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ot(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ua(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var S,h;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(m.chainId);default:return D(s).getOfflineSignerAuto(m.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[m.chainId],g={url:m.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(g,f,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function pa(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(m.chainId);default:return D(s).getOfflineSignerAuto(m.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],g={url:m.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})},p=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(g,f,k({gasPrice:p},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=d(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,s,I=>c(this,null,function*(){var S;if(!(o!=null&&o.includes(I.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let C=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(I.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(I.chainId);default:return D(a).getOfflineSignerAuto(I.chainId)}}))(),g=e.multiChain?i[I.chainId]:i;return yield SigningStargateClient.createWithSigner(g,C,e.multiChain?(S=e.opts)==null?void 0:S[I.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=d(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>c(this,[m],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,a,f=>c(this,null,function*(){var y,A;if(!(o!=null&&o.includes(f.chainId)))return null;if(!B(l))throw new Error(`${l} is not available`);let g=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(l).getOfflineSigner(f.chainId);case"offlineSignerAuto":return D(l).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return D(l).getOfflineSignerOnlyAmino(f.chainId);default:return D(l).getOfflineSignerAuto(f.chainId)}}))(),p=(y=u.getState().chainsConfig)==null?void 0:y[f.chainId],S=p!=null&&p.gas?GasPrice.fromString(`${p.gas.price}${p.gas.denom}`):void 0,h=e.multiChain?s==null?void 0:s[f.chainId]:i;if(!h)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(h,g,k({gasPrice:S},e.multiChain?(A=e.opts)==null?void 0:A[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Ce(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Kt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var kn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=d(),l=B(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(I=>{if(I)return Y({chainId:i.map(f=>f.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!l)return;e&&s?G({onError:n}):!e&&t&&G({onError:n});}},[l]),useEffect(()=>{var m,I,f,C,g,p,S,h,O,y,A,T,R,_,N,J,ie,w;if(o){if(!l)return;o==="cosmostation"&&((I=(m=pe()).subscription)==null||I.call(m,()=>{G({onError:n});})),o==="keplr"&&((C=(f=me()).subscription)==null||C.call(f,()=>{G({onError:n});})),o==="leap"&&((p=(g=de()).subscription)==null||p.call(g,()=>{G({onError:n});})),o==="compass"&&((h=(S=le()).subscription)==null||h.call(S,()=>{G({onError:n});})),o==="vectis"&&((y=(O=ye()).subscription)==null||y.call(O,()=>{G({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((T=(A=j()).subscription)==null||T.call(A,()=>{G({onError:n});})),o==="station"&&((_=(R=ge()).subscription)==null||_.call(R,()=>{G({onError:n});})),o==="xdefi"&&((J=(N=Se()).subscription)==null||J.call(N,()=>{G({onError:n});})),o==="cosmiframe"&&((w=(ie=ue()).subscription)==null||w.call(ie,()=>{G({onError:n});}));}},[o,a,l]),null},Bt=()=>(kn(),null);var Pn=new QueryClient({}),qa=o=>{var r=o,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return St(t),jsxs(QueryClientProvider,q(k({client:Pn},n),{children:[e,jsx(Kt,{children:jsx(Bt,{})})]}),"graz-provider")};
|
|
18
19
|
|
|
19
|
-
export {
|
|
20
|
+
export { Bt as GrazEvents, qa as GrazProvider, Ve as WALLET_TYPES, $e as WalletType, B as checkWallet, ve as clearRecentChain, K as clearSession, St as configureGraz, Y as connect, Tr as defineChainInfo, br as defineChains, oe as disconnect, At as executeContract, er as getAvailableWallets, fr as getChainInfo, gr as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, at as getMetamaskSnapLeap, gt as getOfflineSigners, Ot as getQueryRaw, It as getQuerySmart, mr as getRecentChainIds, dr as getRecentChains, ye as getVectis, pt as getWCCosmostation, mt as getWCKeplr, dt as getWCLeap, D as getWallet, j as getWalletConnect, wt as instantiateContract, ke as isCapsule, ft as isWalletConnect, G as reconnect, ht as sendIbcTokens, Ct as sendTokens, We as suggestChain, yt as suggestChainAndConnect, X as useAccount, Rs as useActiveChainCurrency, vs as useActiveChainIds, On as useActiveChains, Zr as useActiveWalletType, ms as useBalance, ys as useBalanceStaked, In as useBalances, Os as useCapsule, Ws as useChainInfo, Ps as useChainInfos, we as useCheckWallet, ds as useConnect, Ke as useCosmWasmClient, pa as useCosmWasmSigningClient, da as useCosmWasmTmSigningClient, fs as useDisconnect, Hs as useExecuteContract, kn as useGrazEvents, Vs as useInstantiateContract, gs as useOfflineSigners, Ds as useQueryClientValidators, Xs as useQueryRaw, Ys as useQuerySmart, _s as useRecentChainIds, Ns as useRecentChains, $s as useSendIbcTokens, js as useSendTokens, Ne as useStargateClient, ua as useStargateSigningClient, ma as useStargateTmSigningClient, Ks as useSuggestChain, Bs as useSuggestChainAndConnect, he as useTendermintClient };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.21",
|
|
5
5
|
"author": "Griko Nibras <griko@strange.love>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@cosmjs/proto-signing": "*",
|
|
41
41
|
"@cosmjs/stargate": "*",
|
|
42
42
|
"@cosmjs/tendermint-rpc": "*",
|
|
43
|
-
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.
|
|
43
|
+
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
|
|
44
44
|
"react": ">=17"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"zustand": "^4.5.2"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
+
"@initia/initia-registry-types": "^0.0.20",
|
|
64
65
|
"@types/node": "^18.17.15",
|
|
65
66
|
"@types/react": "^18.2.21",
|
|
66
67
|
"@types/react-dom": "^18.2.7",
|
package/types/global.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type Station from "@terra-money/station-connector";
|
|
2
2
|
|
|
3
|
+
import type { InitiaWallet } from "../src/actions/wallet/initia";
|
|
4
|
+
|
|
3
5
|
type KeplrWindow = import("@keplr-wallet/types").Window;
|
|
4
6
|
type VectisWindow = import("@vectis/extension-client").VectisWindow;
|
|
5
7
|
|
|
@@ -17,10 +19,13 @@ declare global {
|
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
ethereum?: import("@metamask/providers").MetaMaskInpageProvider;
|
|
20
|
-
okxwallet?: import("@metamask/providers").BaseProvider
|
|
22
|
+
okxwallet?: import("@metamask/providers").BaseProvider & {
|
|
23
|
+
keplr: KeplrWindow["keplr"];
|
|
24
|
+
};
|
|
21
25
|
station?: Station;
|
|
22
26
|
xfi?: {
|
|
23
27
|
keplr: KeplrWindow["keplr"];
|
|
24
28
|
};
|
|
29
|
+
initia?: InitiaWallet;
|
|
25
30
|
}
|
|
26
31
|
}
|