graz 0.1.20 → 0.1.22

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 CHANGED
@@ -2,7 +2,8 @@
2
2
  'use strict';
3
3
 
4
4
  var C = require('fs/promises');
5
- var le = require('path');
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 le__namespace = /*#__PURE__*/_interopNamespace(le);
29
+ var me__namespace = /*#__PURE__*/_interopNamespace(me);
29
30
 
30
- var de=Object.create;var ee=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var he=(e,n)=>()=>(e&&(n=e(e=0)),n);var _e=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Ee=(e,n,s,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of fe(n))!ge.call(e,o)&&o!==s&&ee(e,o,{get:()=>n[o],enumerable:!(f=ue(n,o))||f.enumerable});return e};var be=(e,n,s)=>(s=e!=null?de(pe(e)):{},Ee(n||!e||!e.__esModule?ee(s,"default",{value:e,enumerable:!0}):s,e));var A=(e,n,s)=>new Promise((f,o)=>{var p=i=>{try{t(s.next(i));}catch(c){o(c);}},b=i=>{try{t(s.throw(i));}catch(c){o(c);}},t=i=>i.done?f(i.value):Promise.resolve(i.value).then(p,b);t((s=s.apply(e,n)).next());});var T=he(()=>{});var oe=_e((Ce,ne)=>{T();var L=Symbol("arg flag"),_=class e extends Error{constructor(n,s){super(n),this.name="ArgError",this.code=s,Object.setPrototypeOf(this,e.prototype);}};function G(e,{argv:n=process.argv.slice(2),permissive:s=!1,stopAtPositional:f=!1}={}){if(!e)throw new _("argument specification object is required","ARG_CONFIG_NO_SPEC");let o={_:[]},p={},b={};for(let t of Object.keys(e)){if(!t)throw new _("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(t[0]!=="-")throw new _(`argument key must start with '-' but found: '${t}'`,"ARG_CONFIG_NONOPT_KEY");if(t.length===1)throw new _(`argument key must have a name; singular '-' keys are not allowed: ${t}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[t]=="string"){p[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=(m,g,a=[])=>(a.push(u(m,g,a[a.length-1])),a),c=u===Boolean||u[L]===!0;}else if(typeof i=="function")c=i===Boolean||i[L]===!0;else throw new _(`type missing or not a function or valid array type: ${t}`,"ARG_CONFIG_VAD_TYPE");if(t[1]!=="-"&&t.length>2)throw new _(`short argument keys (with a single hyphen) must have only one character: ${t}`,"ARG_CONFIG_SHORTOPT_TOOLONG");b[t]=[i,c];}for(let t=0,i=n.length;t<i;t++){let c=n[t];if(f&&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(m=>`-${m}`);for(let m=0;m<u.length;m++){let g=u[m],[a,h]=g[1]==="-"?g.split(/=(.*)/,2):[g,void 0],l=a;for(;l in p;)l=p[l];if(!(l in b))if(s){o._.push(g);continue}else throw new _(`unknown or unexpected option: ${a}`,"ARG_UNKNOWN_OPTION");let[E,r]=b[l];if(!r&&m+1<u.length)throw new _(`option requires argument (but was followed by another short argument): ${a}`,"ARG_MISSING_REQUIRED_SHORTARG");if(r)o[l]=E(!0,l,o[l]);else if(h===void 0){if(n.length<t+2||n[t+1].length>1&&n[t+1][0]==="-"&&!(n[t+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(E===Number||typeof BigInt!="undefined"&&E===BigInt))){let S=a===l?"":` (alias for ${l})`;throw new _(`option requires argument: ${a}${S}`,"ARG_MISSING_REQUIRED_LONGARG")}o[l]=E(n[t+1],l,o[l]),++t;}else o[l]=E(h,l,o[l]);}}else o._.push(c);}return o}G.flag=e=>(e[L]=!0,e);G.COUNT=G.flag((e,n,s)=>(s||0)+1);G.ArgError=_;ne.exports=G;});T();var me=be(oe(),1);T();var F=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n;}},se=e=>globalThis.DOMException===void 0?new F(e):new DOMException(e),re=e=>{let n=e.reason===void 0?se("This operation was aborted."):e.reason;return n instanceof Error?n:se(n)};function k(p,b){return A(this,arguments,function*(e,n,{concurrency:s=Number.POSITIVE_INFINITY,stopOnError:f=!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(s)||s===Number.POSITIVE_INFINITY)&&s>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${s}\` (${typeof s})`);let c=[],u=[],m=new Map,g=!1,a=!1,h=!1,l=0,E=0,r=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),S=N=>{g=!0,a=!0,i(N);};o&&(o.aborted&&S(re(o)),o.addEventListener("abort",()=>{S(re(o));}));let P=()=>A(this,null,function*(){if(a)return;let N=yield r.next(),R=E;if(E++,N.done){if(h=!0,l===0&&!a){if(!f&&u.length>0){S(new AggregateError(u));return}if(a=!0,m.size===0){t(c);return}let w=[];for(let[y,D]of c.entries())m.get(y)!==ie&&w.push(D);t(w);}return}l++,A(this,null,function*(){try{let w=yield N.value;if(a)return;let y=yield n(w,R);y===ie&&m.set(R,y),c[R]=y,l--,yield P();}catch(w){if(f)S(w);else {u.push(w),l--;try{yield P();}catch(y){S(y);}}}});});A(this,null,function*(){for(let N=0;N<s;N++){try{yield P();}catch(R){S(R);break}if(h||g)break}});})})}var ie=Symbol("skip");var Ae=e=>/^\d+$/.test(e),j=e=>Ae(e[0])?`_${e}`:e,ae=`Usage: graz [options]
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
- `,I=(0, me.default)({"--generate":Boolean,"-g":"--generate","--authz":Boolean,"--best":Boolean,"--mainnet":String,"--testnet":String,"-b":"--best","-M":"--mainnet","-T":"--testnet","--help":Boolean,"-h":"--help"}),Ie=()=>A(void 0,null,function*(){if(I["--help"]){console.log(ae);return}if(I["--generate"]){yield Se();return}console.log(ae);}),Se=()=>A(void 0,null,function*(){console.log("\u23F3 Generating chain list from cosmos.directory..."),I["--authz"]&&console.log("\u270D\uFE0F Detected authz flag, generating only compatible chains..."),I["--best"]&&console.log("\u{1F481}\u200D\u2642\uFE0F Detected best flag, setting REST and RPC endpoints to best latency..."),(I["--mainnet"]||I["--testnet"])&&console.log("\u{1F419} Detected chain filtering flag, generating only given chain paths...");let[e,n]=yield Promise.all([ce(cosmosDirectoryClient.createClient(),{filter:I["--mainnet"]}),ce(cosmosDirectoryClient.createTestnetClient(),{filter:I["--testnet"]})]),[s,f]=yield Promise.all([C__namespace.readFile(O("index.js.stub"),{encoding:"utf-8"}),C__namespace.readFile(O("index.mjs.stub"),{encoding:"utf-8"})]),o=s.replace("/* REPLACE_MAINNET_DEFS */",$(e)).replace("/* REPLACE_TESTNET_DEFS */",$(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",M(e)).replace("/* REPLACE_TESTNET_CHAINS */",M(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",x(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",x(n,{testnet:!0})).replace("/* REPLACE_MAINNET_EXPORTS */",x(e)).replace("/* REPLACE_TESTNET_EXPORTS */",x(n,{testnet:!0})).replace(/"(.+)":/g,"$1:").trim(),p=f.replace("/* REPLACE_MAINNET_DEFS */",$(e,{mjs:!0})).replace("/* REPLACE_TESTNET_DEFS */",$(n,{mjs:!0,testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",M(e)).replace("/* REPLACE_TESTNET_CHAINS */",M(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",x(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",x(n,{testnet:!0})).replace(/"(.+)":/g,"$1:").trim();yield Promise.all([C__namespace.writeFile(O("index.js"),o,{encoding:"utf-8"}),C__namespace.writeFile(O("index.mjs"),p.replace('"../dist"','"../dist/index.mjs"'),{encoding:"utf-8"}),C__namespace.writeFile(O("index.ts"),p,{encoding:"utf-8"})]),console.log('\u2728 Generate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');}),O=(...e)=>le__namespace.resolve(__dirname,"../chains",...e),M=(e,{testnet:n=!1}={})=>Object.keys(e).map(s=>` ${j(s)}: ${j(s)},`).join(`
45
- `),$=(e,{mjs:n=!1,testnet:s=!1}={})=>Object.entries(e).map(([f,o])=>{let p=`${j(f)}`,b=JSON.stringify(o,null,2);return `${n?"export ":""}const ${p} = defineChainInfo(${b});
46
- `}).join(""),x=(e,{testnet:n=!1}={})=>Object.keys(e).map(s=>` ${j(s)},`).join(`
47
- `),ce=(s,...f)=>A(void 0,[s,...f],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}))),p=yield k(o,t=>A(void 0,null,function*(){return e.fetchChain(t.path).then(i=>i.chain)}),{concurrency:4}),b={};return p.forEach(t=>{var i,c,u,m,g;try{if(I["--authz"]&&!((i=t.params)!=null&&i.authz))return;let a=I["--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 h=t.assets[0],l={coinDenom:h.denom_units[h.denom_units.length-1].denom,coinMinimalDenom:h.denom_units[0].denom,coinDecimals:h.denom_units[h.denom_units.length-1].exponent,coinGeckoId:h.coingecko_id},E=(m=t.fees)==null?void 0:m.fee_tokens.map(r=>{var P,N,R,w,y,D,v,z,Y,H,B,U,q,K,V,Q,X,J,W,Z;return r.low_gas_price&&r.average_gas_price&&r.high_gas_price?{coinDenom:((R=(N=(P=t.assets)==null?void 0:P.find(d=>d.denom===r.denom))==null?void 0:N.denom_units.at(-1))==null?void 0:R.denom)||r.denom,coinMinimalDenom:((D=(y=(w=t.assets)==null?void 0:w.find(d=>d.denom===r.denom))==null?void 0:y.denom_units[0])==null?void 0:D.denom)||r.denom,coinDecimals:Number((z=(v=t.assets)==null?void 0:v.find(d=>d.denom===r.denom))==null?void 0:z.decimals),coinGeckoId:((H=(Y=t.assets)==null?void 0:Y.find(d=>d.denom===r.denom))==null?void 0:H.coingecko_id)||"",gasPriceStep:{low:Number(r.low_gas_price),average:Number(r.average_gas_price),high:Number(r.high_gas_price)}}:{coinDenom:((q=(U=(B=t.assets)==null?void 0:B.find(d=>d.denom===r.denom))==null?void 0:U.denom_units.at(-1))==null?void 0:q.denom)||r.denom,coinMinimalDenom:((Q=(V=(K=t.assets)==null?void 0:K.find(d=>d.denom===r.denom))==null?void 0:V.denom_units[0])==null?void 0:Q.denom)||r.denom,coinDecimals:Number((J=(X=t.assets)==null?void 0:X.find(d=>d.denom===r.denom))==null?void 0:J.decimals),coinGeckoId:((Z=(W=t.assets)==null?void 0:W.find(d=>d.denom===r.denom))==null?void 0:Z.coingecko_id)||""}});if(!E)throw new Error(`\u26A0\uFE0F ${t.name} has no fee currencies, skipping codegen...`);b[t.path]={chainId:t.chain_id,currencies:t.assets.map(r=>({coinDenom:r.denom_units[r.denom_units.length-1].denom,coinMinimalDenom:r.denom_units[0].denom,coinDecimals:r.denom_units[r.denom_units.length-1].exponent,coinGeckoId:r.coingecko_id})),rest:a.rest[0].address||"",rpc:a.rpc[0].address||"",bech32Config:cosmos.Bech32Address.defaultBech32Config(t.bech32_prefix),chainName:t.chain_name,feeCurrencies:E,stakeCurrency:l,bip44:{coinType:(g=t.slip44)!=null?g:0}};}catch(a){console.error(a instanceof Error?a.message:String(a));}}),b});Ie();
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.js CHANGED
@@ -2,11 +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 amino = require('@cosmjs/amino');
9
- var nn = require('long');
9
+ var sn = require('long');
10
10
  var signClient = require('@walletconnect/sign-client');
11
11
  var utils = require('@walletconnect/utils');
12
12
  var reactQuery = require('@tanstack/react-query');
@@ -19,80 +19,80 @@ var jsxRuntime = require('react/jsx-runtime');
19
19
 
20
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
21
 
22
- var nn__default = /*#__PURE__*/_interopDefault(nn);
22
+ var sn__default = /*#__PURE__*/_interopDefault(sn);
23
23
 
24
- var Ut=Object.defineProperty,Ft=Object.defineProperties;var qt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(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)=>Ft(e,qt(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 l=(e,t,n)=>new Promise((o,r)=>{var i=c=>{try{s(n.next(c));}catch(m){r(m);}},a=c=>{try{s(n.throw(c));}catch(m){r(m);}},s=c=>c.done?o(c.value):Promise.resolve(c.value).then(i,a);s((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(b=>(b.KEPLR="keplr",b.LEAP="leap",b.VECTIS="vectis",b.COSMOSTATION="cosmostation",b.WALLETCONNECT="walletconnect",b.WC_KEPLR_MOBILE="wc_keplr_mobile",b.WC_LEAP_MOBILE="wc_leap_mobile",b.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",b.WC_CLOT_MOBILE="wc_clot_mobile",b.METAMASK_SNAP_LEAP="metamask_snap_leap",b.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",b.STATION="station",b.XDEFI="xdefi",b.CAPSULE="capsule",b.COSMIFRAME="cosmiframe",b.COMPASS="compass",b.INITIA="initia",b))(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 zt={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},Qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,Qt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>zt,jt)));var ae=()=>{var d,S;if(!((d=u.getState().capsuleConfig)!=null&&d.apiKey)||!((S=u.getState().capsuleConfig)!=null&&S.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,f=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return g.setState({capsuleClient:f}),f});return {init:e,enable:p=>l(void 0,null,function*(){let f=typeof p=="string"?[p]:p,h=g.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:f}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var b;let p=g.getState().capsuleClient,{chains:f}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!f)throw new Error("Chains are not set");yield p.enable();let h=(b=u.getState().capsuleState)==null?void 0:b.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(y=>l(void 0,null,function*(){let I=yield p.getAccount(y);return [y,{address:encoding.fromBech32(I.address).data,bech32Address:I.address,algo:I.algo,name:I.username||"",pubKey:I.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(y=>({accounts:M(M({},y.accounts||{}),O)})),u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...h].filter((I,x,P)=>P.indexOf(I)===x)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...h].filter((I,x,P)=>P.indexOf(I)===x)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:p=>l(void 0,null,function*(){let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");let h=yield f.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=>l(void 0,null,function*(){let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(p)},signDirect:(...p)=>l(void 0,null,function*(){let[f,h,O]=p,b=g.getState().capsuleClient;if(!b)throw new Error("Capsule client is not initialized");return b.signDirect(f,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>l(void 0,null,function*(){let[f,h,O,b]=p,y=g.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signAmino(f,h,O,b)}),experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.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 et={},tt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var w;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 s=(w=i.split("MetaMask/v")[1])==null?void 0:w.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:i=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>l(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,a,s)=>l(void 0,null,function*(){return t.signAmino(i,a,s)}),getKey:i=>l(void 0,null,function*(){return typeof et[i]!="undefined"?et[i]:t.getKey(i)}),getOfflineSignerAuto:i=>l(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,a,s)=>l(void 0,null,function*(){return t.signDirect(i,a,s)}),signArbitrary:(i,a,s)=>l(void 0,null,function*(){return t.signArbitrary(i,a,s)}),disable:i=>l(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=>{var s;let a=()=>{N(),i();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var en=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}},tn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,it=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let S=e.getOfflineSigner(d),[p]=yield S.getAccounts();if(!p)throw new Error("Wallet connection failed");let f=(()=>{switch(p.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(p.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:tn(p.address),algo:p.algo,pubKey:p.pubkey,bech32Address:p.address,address:f,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let S=e.getOfflineSigner(d),p=e.getOfflineSignerOnlyAmino(d);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:p.signAmino.bind(p)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(S=>{var p,f,h;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(p=S.gasPriceStep)==null?void 0:p.low,average_gas_price:(f=S.gasPriceStep)==null?void 0:f.average,high_gas_price:(h=S.gasPriceStep)==null?void 0:h.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[S,p,f]=d;return e.getOfflineSigner(S).signDirect(p,en(f))},signAmino:(...d)=>{let[S,p,f]=d;return e.getOfflineSignerOnlyAmino(S).signAmino(p,f)},signArbitrary:(d,S,p)=>l(void 0,null,function*(){let O=(yield e.getOfflineSigner(d).getAccounts()).find(I=>I.address===S);if(!O)throw new Error(`Wallet not connected to account ${S}`);let b=(()=>{switch(O.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(O.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(O.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(p),pub_key:{type:O.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:b.value}}}),subscription:d=>{let S=()=>{N(),d();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}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={},ot=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>l(void 0,null,function*(){try{let I=yield n();return Object.values(I).find(x=>x.id===e.id&&(!y||x.version===y))}catch(I){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>l(void 0,null,function*(){var D;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 x=(D=y.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(x)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),a=y=>l(void 0,null,function*(){(yield o())||(yield r());}),s=(y,I,x)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:I,signDoc:x}}}}),_=x.accountNumber,D=new nn__default.default(_.low,_.high,_.unsigned);return {signature:P.signature,signed:F(M({},P.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(y,I,x)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:I,signDoc:x}}}})}),m=y=>l(void 0,null,function*(){if(typeof de[y]!="undefined")return de[y];let I=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!I)throw new Error("No response from Metamask");return I.pubKey=Uint8Array.from(Object.values(I.pubkey)),delete I.pubkey,de[y]=I,de[y]}),w=y=>l(void 0,null,function*(){let I=yield m(y);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),d=(...y)=>l(void 0,null,function*(){let[I,x,P,_]=y;return yield c(I,x,P)}),S=(...y)=>l(void 0,null,function*(){let[I,x,P]=y;return yield s(I,x,P)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(y)]}),signAmino:(I,x)=>d(y,I,x)});return {enable:a,experimentalSuggestChain:(...y)=>l(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:()=>l(void 0,null,function*(){return [yield w(y)]}),signDirect:(I,x)=>S(y,I,x),signAmino:(I,x)=>d(y,I,x)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return f(y)}),getOfflineSignerOnlyAmino:f,init:i,signAmino:d,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var rt=()=>ot({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let a=()=>{N(),i();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:i=>l(void 0,null,function*(){let a=yield e.getKey(i);return M({isKeystone:!1},a)}),getOfflineSigner:i=>{try{let a=e.getOfflineSignerOnlyAmino(i);return Object.assign(a,{signDirect:(m,w)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:i=>l(void 0,null,function*(){try{let a=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(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(s=>{var c,m,w;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:((m=s.gasPriceStep)==null?void 0:m.high)||0,low:((w=s.gasPriceStep)==null?void 0:w.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),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,a,s,c)=>e.signAmino(i,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=()=>{N(),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,m=F(M({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...s)=>l(void 0,null,function*(){var w;let{1:c,2:m}=s;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:nn__default.default.fromString(((w=m.accountNumber)==null?void 0:w.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:m}=s;return e.signAmino(c,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,st=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),at=()=>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 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",o=C=>{if(!e)return;let{appUrl:A,formatNativeUrl:E}=e;if(z()){if(st())if(!C)window.open(A.mobile.android,"_self","noreferrer noopener");else {let v=E(A.mobile.android,C,"android");window.open(v,"_self","noreferrer noopener");}if(at())if(!C)window.open(A.mobile.ios,"_self","noreferrer noopener");else {let v=E(A.mobile.ios,C,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:C}=g.getState();if(!C.get(t))throw new Error("walletConnect.signClient is not defined");C.delete(t),g.setState({wcSignClients:C}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=C=>l(void 0,null,function*(){let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!C)throw new Error("No wallet connect session");yield E.disconnect({topic:C,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(E);}),a=C=>{try{let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let v=E.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw i(v.topic),new Error("invalid session");try{let k=E.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:C.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 v}catch(A){if(!A.message.toLowerCase().includes("no matching key"))throw A}},s=C=>{try{return a(C)}catch(A){return}},c=C=>l(void 0,null,function*(){try{let A=C.core.pairing.pairings.getAll({active:!1});if(!A.length)return;yield Promise.all(A.map(E=>l(void 0,null,function*(){yield C.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(A){if(!A.message.toLowerCase().includes("no matching key"))throw A}}),m=()=>l(void 0,null,function*(){let{walletConnect:C}=u.getState();if(!(C!=null&&C.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:A}=g.getState(),E=A.get(t);if(E)return E;let v=yield signClient.SignClient.init(C.options);return A.set(t,v),g.setState({wcSignClients:A}),v}),w=C=>{let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)return ()=>{};let v=W=>{let k=g.getState().accounts;if(W.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(L=>L.bech32Address).includes(W.params.event.data[0])){let L=W.params.chainId.split(":")[1];L&&d([L]);}else C();};return E.events.on("session_delete",r),E.events.on("session_expire",r),E.events.on("session_event",v),()=>{E.events.off("session_delete",r),E.events.off("session_expire",r),E.events.off("session_event",v);}},d=C=>l(void 0,null,function*(){var oe;let A=typeof C=="string"?[C]:C,{wcSignClients:E}=g.getState(),v=E.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:k}=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(M({projectId:W.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.web3Modal)),J=s(A);if(!J){let{uri:U,approval:Z}=yield Me(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:A.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 Bt=j=>l(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 A.forEach(re=>{Fe[re]=F(M({},Ue),{bech32Address:encoding.toBech32(k.find(Lt=>Lt.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Te[0].bech32Address).data)});}),g.setState(re=>({accounts:M(M({},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 Bt(be);}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 U=Object.fromEntries(yield Promise.all(A.map(Z=>l(void 0,null,function*(){return [Z,yield p(Z)]}))));g.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(i(J.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),S=C=>l(void 0,null,function*(){var k;let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let v=(k=a([C]))==null?void 0:k.topic;if(!v)throw new Error("No wallet connect session");let W=yield E.request({topic:v,chainId:`cosmos:${C}`,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))}}),p=C=>l(void 0,null,function*(){let A=a([C]);if(!(A!=null&&A.topic))throw new Error("No wallet connect session");let E=A.sessionProperties&&JSON.parse(String(A.sessionProperties.keys))[0];if(!E)throw new Error("No wallet connect key");return E}),f=(...C)=>l(void 0,null,function*(){var U,Z;let[A,E,v]=C,{accounts:W,wcSignClients:k}=g.getState(),L=k.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let $=(U=a([A]))==null?void 0:U.topic;if(!$)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${A}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:F(M({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(Z=v.accountNumber)==null?void 0:Z.toString()})}}};return o(),yield L.request(J)}),h=(...C)=>l(void 0,null,function*(){let[A,E,v]=C,{signature:W,signed:k}=yield f(A,E,v);return {signed:{chainId:k.chainId,accountNumber:nn__default.default.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:W}}),O=(...C)=>l(void 0,null,function*(){var U;let[A,E,v,W]=C,{wcSignClients:k}=g.getState(),L=k.get(t),{accounts:$}=g.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(U=a([A]))==null?void 0:U.topic;if(!J)throw new Error("No wallet connect session");return o(),yield L.request({topic:J,chainId:`cosmos:${A}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:v}}})}),b=(...C)=>l(void 0,null,function*(){let[A,E,v,W]=C;return yield O(A,E,v)}),y=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(C)]}),signDirect:(A,E)=>h(C,A,E)}),I=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(C)]}),signAmino:(A,E)=>b(C,A,E)});return {enable:d,disable:C=>l(void 0,null,function*(){var v;let{wcSignClients:A}=g.getState(),E=A.get(t);if(C===void 0){let W=E==null?void 0:E.session.getAll();W!==void 0&&(yield Promise.all(W.map(k=>i(k.topic))));}else typeof C=="string"?yield i((v=a([C]))==null?void 0:v.topic):yield Promise.all(C.map(W=>{var k;return i((k=a([W]))==null?void 0:k.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...C)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:p,getOfflineSigner:C=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(C)]}),signDirect:(A,E)=>h(C,A,E),signAmino:(A,E)=>b(C,A,E)}),getOfflineSignerAuto:C=>l(void 0,null,function*(){return (yield p(C)).isNanoLedger?I(C):y(C)}),getOfflineSignerOnlyAmino:I,signAmino:b,signDirect:h,subscription:w,init:m}};var ct=()=>{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,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return Q(e)};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 Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,i,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};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 Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,i,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);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 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 Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,i,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);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 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),g.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 ut();case"wc_leap_mobile":return pt();case"wc_cosmostation_mobile":return lt();case"wc_clot_mobile":return ct();case"metamask_snap_leap":return rt();case"metamask_snap_cosmos":return tt();case"station":return fe();case"xdefi":return ye();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();case"initia":return it();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},Vo=()=>Object.fromEntries($e.map(e=>[e,K(e)])),xe=e=>e==="capsule",mt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var H=e=>l(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 s=R(i),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 m=o==null?void 0:o.map(p=>p.chainId);c.forEach(p=>{if(!(m!=null&&m.includes(p)))throw new Error(`Chain ${p} is not provided in GrazProvider`)}),g.setState(p=>{let f=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return p.activeChainIds&&c.filter(O=>{var b;return !((b=p.activeChainIds)!=null&&b.includes(O))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:w}=g.getState();if(yield (t=s.init)==null?void 0:t.call(s),xe(i)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let p=c.map(O=>o.find(b=>b.chainId===O)),f=g.getState().accounts;g.setState({status:"connecting"});let h=Object.fromEntries(yield Promise.all(c.map(O=>l(void 0,null,function*(){return [O,yield s.getKey(O)]}))));return g.setState(O=>({accounts:M(M({},O.accounts||{}),h)})),u.setState(O=>({recentChainIds:[...O.recentChainIds||[],...c].filter((b,y,I)=>I.indexOf(b)===y)})),g.setState(O=>({activeChainIds:[...O.activeChainIds||[],...c].filter((b,y,I)=>I.indexOf(b)===y)})),g.setState({status:"connected"}),{accounts:f,walletType:i,chains:p}}if(yield s.enable(c),xe(i)){let p=c.map(h=>o.find(O=>O.chainId===h)),f=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:f,walletType:i,chains:p}}if(!mt(i)){let p=Object.fromEntries(yield Promise.all(c.map(f=>l(void 0,null,function*(){return [f,yield s.getKey(f)]}))));g.setState(f=>({accounts:M(M({},f.accounts||{}),p)}));}u.setState(p=>({recentChainIds:[...p.recentChainIds||[],...c].filter((f,h,O)=>O.indexOf(f)===h)})),g.setState(p=>({activeChainIds:[...p.activeChainIds||[],...c].filter((f,h,O)=>O.indexOf(f)===h)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let d=c.map(p=>o.find(f=>f.chainId===p));return {accounts:g.getState().accounts,walletType:i,chains:d}}catch(n){throw console.error("connect ",n),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.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=g.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(g.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(a=>!t.includes(a))}}));}else g.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: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();}}),dt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!K(n))throw new Error(`${n} is not available`);let r=R(n),i=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:a,offlineSignerAuto:s}});var ve=()=>{u.setState({recentChainIds:null});},sr=()=>u.getState().recentChainIds,ar=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},lr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ke=n=>l(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}),ft=e=>l(void 0,null,function*(){var o;let t=u.getState().walletType;return yield ke({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield H({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var gt=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 yt=a=>l(void 0,[a],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)}),St=w=>l(void 0,[w],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:a,timeoutTimestamp:s,fee:c,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,a,s,c,m)}),Ct=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,i,o,r)}),ht=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,a,i)}),wt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),At=(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 hr=e=>e,wr=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;}},It=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),Ot=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function Pe(i,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!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 m=[],w=[],d=new Map,S=!1,p=!1,f=!1,h=0,O=0,b=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=x=>{S=!0,p=!0,c(x);};r&&(r.aborted&&y(Ot(r)),r.addEventListener("abort",()=>{y(Ot(r));}));let I=()=>l(this,null,function*(){if(p)return;let x=yield b.next(),P=O;if(O++,x.done){if(f=!0,h===0&&!p){if(!o&&w.length>0){y(new AggregateError(w));return}if(p=!0,d.size===0){s(m);return}let _=[];for(let[D,X]of m.entries())d.get(D)!==Et&&_.push(X);s(_);}return}h++,l(this,null,function*(){try{let _=yield x.value;if(p)return;let D=yield t(_,P);D===Et&&d.set(P,D),m[P]=D,h--,yield I();}catch(_){if(o)y(_);else {w.push(_),h--;try{yield I();}catch(D){y(D);}}}});});l(this,null,function*(){for(let x=0;x<n;x++){try{yield I();}catch(P){y(P);break}if(f||S)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 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)=>l(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Pe(t,n,{concurrency:o});return Object.fromEntries(i.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),bt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,a)=>[t[a].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=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:M({},(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=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=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:M({},(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})},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:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield G(!!n,s,w=>l(void 0,null,function*(){var h;let d=(h=u.getState().chainsConfig)==null?void 0:h[w.chainId],S={url:w.rpc,headers:M({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(S)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var $r=()=>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(s=>s.walletType),n=g(s=>s.activeChainIds),o=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=g(s=>s.accounts),i=g(s=>s.status);return react.useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var m,w,d;if(s==="connected"){let{accounts:S,activeChainIds:p}=g.getState(),{chains:f}=u.getState(),{walletType:h}=u.getState();if(!S||!p||!f)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(w=e==null?void 0:e.onConnect)==null||w.call(e,{accounts:S,chains:p.map(O=>f.find(b=>b.chainId===O)),walletType:h,isReconnect:c==="reconnecting"});}s==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:react.useMemo(()=>r?bt(!!(e!=null&&e.multiChain),o,s=>r[s.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}},Cn=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(a=>a.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=>l(void 0,[m],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){let S=a==null?void 0:a[d.chainId];if(!S)throw new Error(`Client is not ready ${d.chainId}`);return yield S.getAllBalances(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).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})},ss=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}=Cn({chainId:t.map(c=>c.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,o,e.chainId],s=reactQuery.useQuery(a,({queryKey:[,c,m]})=>m==null?void 0:m.find(w=>w.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 i(),s.refetch(c)})})},as=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],H,{onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(n==null?void 0:n(a))}),{data:i}=he();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},cs=({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}},ls=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:a=>l(void 0,[a],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=>l(void 0,null,function*(){return yield dt({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},us=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(a=>a.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=>l(void 0,[m],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var p;if(!a)throw new Error("Client is not ready");return yield (p=a[d.chainId])==null?void 0:p.getBalanceStaked(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Ss=()=>{let e=u(o=>o.capsuleState),t=g(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 Es=()=>g(e=>e.activeChainIds),hn=()=>{var e;return (e=g(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)},bs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ts=({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=hn();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:i.currencies.find(a=>a)})},xs=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:[,i,a]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},vs=()=>({data:u(t=>t.recentChainIds),clear:ve}),ks=()=>{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}},Ws=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ke,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a.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}},Ps=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ft,{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:i}=he();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Us=({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],a=>yt(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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},Fs=({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],a=>St(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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},qs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],c=>{var w;if(!i)throw new Error("senderAddress is undefined");let m=F(M({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:i,codeId:e});return Ct(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Gs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,s=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],c=>{var w,d,S;if(!i)throw new Error("senderAddress is undefined");let m=F(M({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:i,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(S=c.funds)!=null?S:[]});return ht(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},zs=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 wt(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Qs=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 At(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function oa(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=g(i=>i.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,i,a]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>l(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(m.chainId);default:return R(a).getOfflineSignerAuto(m.chainId)}}))(),S=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],p={url:m.rpc,headers:M({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(p,d,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 ra(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=g(i=>i.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,i,a]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>l(this,null,function*(){var O,b;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(m.chainId);default:return R(a).getOfflineSignerAuto(m.chainId)}}))(),S=(O=u.getState().chainsConfig)==null?void 0:O[m.chainId],p={url:m.rpc,headers:M({},(S==null?void 0:S.rpcHeaders)||{})},f=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(p,d,M({gasPrice:f},e!=null&&e.multiChain?(b=e.opts)==null?void 0:b[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 sa(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=g(a=>a.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:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,w=>l(this,null,function*(){var h;if(!(o!=null&&o.includes(w.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);if(!i)throw new Error("No tendermint client found");let S=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(w.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(w.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(w.chainId);default:return R(s).getOfflineSignerAuto(w.chainId)}}))(),p=e.multiChain?i[w.chainId]:i;return yield stargate.SigningStargateClient.createWithSigner(p,S,e.multiChain?(h=e.opts)==null?void 0:h[w.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function aa(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=g(s=>s.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:a}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,d=>l(this,null,function*(){var y,I;if(!(o!=null&&o.includes(d.chainId)))return null;if(!K(c))throw new Error(`${c} is not available`);let p=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(d.chainId);default:return R(c).getOfflineSignerAuto(d.chainId)}}))(),f=(y=u.getState().chainsConfig)==null?void 0:y[d.chainId],h=f!=null&&f.gas?stargate.GasPrice.fromString(`${f.gas.price}${f.gas.denom}`):void 0,O=e.multiChain?a==null?void 0:a[d.chainId]:i;if(!O)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(O,p,M({gasPrice:h},e.multiChain?(I=e.opts)==null?void 0:I[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Se(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var _t=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:a,wcSignClients:s}=g(),c=K(o||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(w=>{if(w)return H({chainId:i.map(d=>d.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(o){if(!c)return;e&&a?q({onError:n}):!e&&t&&q({onError:n});}},[c]),react.useEffect(()=>{var m,w,d,S,p,f,h,O,b,y,I,x,P,_,D,X,ne,C;if(o){if(!c)return;o==="cosmostation"&&((w=(m=ue()).subscription)==null||w.call(m,()=>{q({onError:n});})),o==="keplr"&&((S=(d=pe()).subscription)==null||S.call(d,()=>{q({onError:n});})),o==="leap"&&((f=(p=me()).subscription)==null||f.call(p,()=>{q({onError:n});})),o==="compass"&&((O=(h=ce()).subscription)==null||O.call(h,()=>{q({onError:n});})),o==="vectis"&&((y=(b=ge()).subscription)==null||y.call(b,()=>{q({onError:n});})),o==="walletconnect"&&s.has("walletconnect")&&((x=(I=Q()).subscription)==null||x.call(I,()=>{q({onError:n});})),o==="station"&&((_=(P=fe()).subscription)==null||_.call(P,()=>{q({onError:n});})),o==="xdefi"&&((X=(D=ye()).subscription)==null||X.call(D,()=>{q({onError:n});})),o==="cosmiframe"&&((C=(ne=le()).subscription)==null||C.call(ne,()=>{q({onError:n});}));}},[o,s,c]),null},Nt=()=>(bn(),null);var xn=new reactQuery.QueryClient({}),Na=o=>{var r=o,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return gt(t),jsxRuntime.jsxs(reactQuery.QueryClientProvider,F(M({client:xn},n),{children:[e,jsxRuntime.jsx(_t,{children:jsxRuntime.jsx(Nt,{})})]}),"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},er=()=>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});},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))},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 br=e=>e,Tr=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 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.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})},ms=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)})})},ds=({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}},fs=({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}},gs=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})},ys=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 Os=()=>{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 vs=()=>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)},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=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)})},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,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:ke}),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:ke}},Ks=({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}},Bs=({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 js=({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}},$s=({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}},Vs=({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}},Hs=({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}},Ys=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})},Xs=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 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_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 pa(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 ma(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 da(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 Pn=new reactQuery.QueryClient({}),Ga=o=>{var r=o,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return react.useEffect(()=>{yt(t);},[]),jsxRuntime.jsx(reactQuery.QueryClientProvider,F(x({client:Pn},n),{children:jsxRuntime.jsxs(Nt,{children:[e,jsxRuntime.jsx(Kt,{})]})}),"graz-provider")};
25
25
 
26
- exports.GrazEvents = Nt;
27
- exports.GrazProvider = Na;
26
+ exports.GrazEvents = Kt;
27
+ exports.GrazProvider = Ga;
28
28
  exports.WALLET_TYPES = $e;
29
29
  exports.WalletType = je;
30
30
  exports.checkWallet = K;
31
- exports.clearRecentChain = ve;
31
+ exports.clearRecentChain = ke;
32
32
  exports.clearSession = N;
33
- exports.configureGraz = gt;
33
+ exports.configureGraz = yt;
34
34
  exports.connect = H;
35
- exports.defineChainInfo = wr;
36
- exports.defineChains = hr;
35
+ exports.defineChainInfo = Tr;
36
+ exports.defineChains = br;
37
37
  exports.disconnect = ie;
38
- exports.executeContract = ht;
39
- exports.getAvailableWallets = Vo;
40
- exports.getChainInfo = cr;
41
- exports.getChainInfos = lr;
38
+ exports.executeContract = wt;
39
+ exports.getAvailableWallets = er;
40
+ exports.getChainInfo = fr;
41
+ exports.getChainInfos = gr;
42
42
  exports.getCosmostation = ue;
43
43
  exports.getKeplr = pe;
44
44
  exports.getLeap = me;
45
- exports.getMetamaskSnapLeap = rt;
46
- exports.getOfflineSigners = dt;
47
- exports.getQueryRaw = At;
48
- exports.getQuerySmart = wt;
49
- exports.getRecentChainIds = sr;
50
- exports.getRecentChains = ar;
45
+ exports.getMetamaskSnapLeap = st;
46
+ exports.getOfflineSigners = ft;
47
+ exports.getQueryRaw = It;
48
+ exports.getQuerySmart = At;
49
+ exports.getRecentChainIds = mr;
50
+ exports.getRecentChains = dr;
51
51
  exports.getVectis = ge;
52
- exports.getWCCosmostation = lt;
53
- exports.getWCKeplr = ut;
54
- exports.getWCLeap = pt;
52
+ exports.getWCCosmostation = ut;
53
+ exports.getWCKeplr = pt;
54
+ exports.getWCLeap = mt;
55
55
  exports.getWallet = R;
56
56
  exports.getWalletConnect = Q;
57
- exports.instantiateContract = Ct;
57
+ exports.instantiateContract = ht;
58
58
  exports.isCapsule = xe;
59
- exports.isWalletConnect = mt;
59
+ exports.isWalletConnect = dt;
60
60
  exports.reconnect = q;
61
- exports.sendIbcTokens = St;
62
- exports.sendTokens = yt;
63
- exports.suggestChain = ke;
64
- exports.suggestChainAndConnect = ft;
61
+ exports.sendIbcTokens = Ct;
62
+ exports.sendTokens = St;
63
+ exports.suggestChain = ve;
64
+ exports.suggestChainAndConnect = gt;
65
65
  exports.useAccount = Y;
66
- exports.useActiveChainCurrency = Ms;
67
- exports.useActiveChainIds = Es;
68
- exports.useActiveChains = hn;
69
- exports.useActiveWalletType = $r;
70
- exports.useBalance = ss;
71
- exports.useBalanceStaked = us;
72
- exports.useBalances = Cn;
73
- exports.useCapsule = Ss;
74
- exports.useChainInfo = bs;
75
- exports.useChainInfos = Ts;
66
+ exports.useActiveChainCurrency = Rs;
67
+ exports.useActiveChainIds = vs;
68
+ exports.useActiveChains = In;
69
+ exports.useActiveWalletType = Zr;
70
+ exports.useBalance = ms;
71
+ exports.useBalanceStaked = ys;
72
+ exports.useBalances = An;
73
+ exports.useCapsule = Os;
74
+ exports.useChainInfo = Ws;
75
+ exports.useChainInfos = Ps;
76
76
  exports.useCheckWallet = he;
77
- exports.useConnect = as;
77
+ exports.useConnect = ds;
78
78
  exports.useCosmWasmClient = Ne;
79
- exports.useCosmWasmSigningClient = ra;
80
- exports.useCosmWasmTmSigningClient = aa;
81
- exports.useDisconnect = cs;
82
- exports.useExecuteContract = Gs;
83
- exports.useGrazEvents = bn;
84
- exports.useInstantiateContract = qs;
85
- exports.useOfflineSigners = ls;
86
- exports.useQueryClientValidators = xs;
87
- exports.useQueryRaw = Qs;
88
- exports.useQuerySmart = zs;
89
- exports.useRecentChainIds = vs;
90
- exports.useRecentChains = ks;
91
- exports.useSendIbcTokens = Fs;
92
- exports.useSendTokens = Us;
79
+ exports.useCosmWasmSigningClient = pa;
80
+ exports.useCosmWasmTmSigningClient = da;
81
+ exports.useDisconnect = fs;
82
+ exports.useExecuteContract = Hs;
83
+ exports.useGrazEvents = xn;
84
+ exports.useInstantiateContract = Vs;
85
+ exports.useOfflineSigners = gs;
86
+ exports.useQueryClientValidators = Ds;
87
+ exports.useQueryRaw = Xs;
88
+ exports.useQuerySmart = Ys;
89
+ exports.useRecentChainIds = _s;
90
+ exports.useRecentChains = Ns;
91
+ exports.useSendIbcTokens = $s;
92
+ exports.useSendTokens = js;
93
93
  exports.useStargateClient = _e;
94
- exports.useStargateSigningClient = oa;
95
- exports.useStargateTmSigningClient = sa;
96
- exports.useSuggestChain = Ws;
97
- exports.useSuggestChainAndConnect = Ps;
94
+ exports.useStargateSigningClient = ua;
95
+ exports.useStargateTmSigningClient = ma;
96
+ exports.useSuggestChain = Ks;
97
+ exports.useSuggestChainAndConnect = Bs;
98
98
  exports.useTendermintClient = Ce;
package/dist/index.mjs CHANGED
@@ -1,10 +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 { rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress, encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType } from '@cosmjs/amino';
7
- import on from 'long';
7
+ import an from 'long';
8
8
  import { SignClient } from '@walletconnect/sign-client';
9
9
  import { getSdkError } from '@walletconnect/utils';
10
10
  import { QueryClient, useQuery, useMutation, QueryClientProvider } from '@tanstack/react-query';
@@ -13,8 +13,8 @@ import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate
13
13
  import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargate';
14
14
  import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
15
15
  import { shallow } from 'zustand/shallow';
16
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
16
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
17
17
 
18
- var Ft=Object.defineProperty,qt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(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={}))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)=>qt(e,Gt(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 l=(e,t,n)=>new Promise((o,r)=>{var i=c=>{try{s(n.next(c));}catch(m){r(m);}},a=c=>{try{s(n.throw(c));}catch(m){r(m);}},s=c=>c.done?o(c.value):Promise.resolve(c.value).then(i,a);s((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var $e=(b=>(b.KEPLR="keplr",b.LEAP="leap",b.VECTIS="vectis",b.COSMOSTATION="cosmostation",b.WALLETCONNECT="walletconnect",b.WC_KEPLR_MOBILE="wc_keplr_mobile",b.WC_LEAP_MOBILE="wc_leap_mobile",b.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",b.WC_CLOT_MOBILE="wc_clot_mobile",b.METAMASK_SNAP_LEAP="metamask_snap_leap",b.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",b.STATION="station",b.XDEFI="xdefi",b.CAPSULE="capsule",b.COSMIFRAME="cosmiframe",b.COMPASS="compass",b.INITIA="initia",b))($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 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},ne={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:createJSONStorage(()=>sessionStorage)},$t={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=create(subscribeWithSelector(persist(()=>ne,jt))),u=create(subscribeWithSelector(persist(()=>Qt,$t)));var ce=()=>{var d,S;if(!((d=u.getState().capsuleConfig)!=null&&d.apiKey)||!((S=u.getState().capsuleConfig)!=null&&S.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,f=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return g.setState({capsuleClient:f}),f});return {init:e,enable:p=>l(void 0,null,function*(){let f=typeof p=="string"?[p]:p,h=g.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:f}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var b;let p=g.getState().capsuleClient,{chains:f}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!f)throw new Error("Chains are not set");yield p.enable();let h=(b=u.getState().capsuleState)==null?void 0:b.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(y=>l(void 0,null,function*(){let I=yield p.getAccount(y);return [y,{address:fromBech32(I.address).data,bech32Address:I.address,algo:I.algo,name:I.username||"",pubKey:I.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(y=>({accounts:x(x({},y.accounts||{}),O)})),u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...h].filter((I,v,R)=>R.indexOf(I)===v)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...h].filter((I,v,R)=>R.indexOf(I)===v)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:p=>l(void 0,null,function*(){let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");let h=yield f.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=>l(void 0,null,function*(){let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSignerDirect(p)},signDirect:(...p)=>l(void 0,null,function*(){let[f,h,O]=p,b=g.getState().capsuleClient;if(!b)throw new Error("Capsule client is not initialized");return b.signDirect(f,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>l(void 0,null,function*(){let[f,h,O,b]=p,y=g.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signAmino(f,h,O,b)}),experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let f=g.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.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 tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var w;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 s=(w=i.split("MetaMask/v")[1])==null?void 0:w.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:i=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>l(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,a,s)=>l(void 0,null,function*(){return t.signAmino(i,a,s)}),getKey:i=>l(void 0,null,function*(){return typeof tt[i]!="undefined"?tt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>l(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,a,s)=>l(void 0,null,function*(){return t.signDirect(i,a,s)}),signArbitrary:(i,a,s)=>l(void 0,null,function*(){return t.signArbitrary(i,a,s)}),disable:i=>l(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=>{var s;let a=()=>{K(),i();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",a),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",a);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var tn=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}},nn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let S=e.getOfflineSigner(d),[p]=yield S.getAccounts();if(!p)throw new Error("Wallet connection failed");let f=(()=>{switch(p.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(p.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:nn(p.address),algo:p.algo,pubKey:p.pubkey,bech32Address:p.address,address:f,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let S=e.getOfflineSigner(d),p=e.getOfflineSignerOnlyAmino(d);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:p.signAmino.bind(p)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(S=>{var p,f,h;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(p=S.gasPriceStep)==null?void 0:p.low,average_gas_price:(f=S.gasPriceStep)==null?void 0:f.average,high_gas_price:(h=S.gasPriceStep)==null?void 0:h.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[S,p,f]=d;return e.getOfflineSigner(S).signDirect(p,tn(f))},signAmino:(...d)=>{let[S,p,f]=d;return e.getOfflineSignerOnlyAmino(S).signAmino(p,f)},signArbitrary:(d,S,p)=>l(void 0,null,function*(){let O=(yield e.getOfflineSigner(d).getAccounts()).find(I=>I.address===S);if(!O)throw new Error(`Wallet not connected to account ${S}`);let b=(()=>{switch(O.algo){case"secp256k1":return encodeSecp256k1Pubkey(O.pubkey);case"ed25519":return encodeEd25519Pubkey(O.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(p),pub_key:{type:O.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:b.value}}}),subscription:d=>{let S=()=>{K(),d();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}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={},rt=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>l(void 0,null,function*(){try{let I=yield n();return Object.values(I).find(v=>v.id===e.id&&(!y||v.version===y))}catch(I){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>l(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 v=(_=y.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(v)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),a=y=>l(void 0,null,function*(){(yield o())||(yield r());}),s=(y,I,v)=>l(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:I,signDoc:v}}}}),N=v.accountNumber,_=new on(N.low,N.high,N.unsigned);return {signature:R.signature,signed:q(x({},R.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),c=(y,I,v)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:I,signDoc:v}}}})}),m=y=>l(void 0,null,function*(){if(typeof fe[y]!="undefined")return fe[y];let I=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!I)throw new Error("No response from Metamask");return I.pubKey=Uint8Array.from(Object.values(I.pubkey)),delete I.pubkey,fe[y]=I,fe[y]}),w=y=>l(void 0,null,function*(){let I=yield m(y);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),d=(...y)=>l(void 0,null,function*(){let[I,v,R,N]=y;return yield c(I,v,R)}),S=(...y)=>l(void 0,null,function*(){let[I,v,R]=y;return yield s(I,v,R)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(y)]}),signAmino:(I,v)=>d(y,I,v)});return {enable:a,experimentalSuggestChain:(...y)=>l(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:()=>l(void 0,null,function*(){return [yield w(y)]}),signDirect:(I,v)=>S(y,I,v),signAmino:(I,v)=>d(y,I,v)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return f(y)}),getOfflineSignerOnlyAmino:f,init:i,signAmino:d,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let a=()=>{K(),i();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:i=>l(void 0,null,function*(){let a=yield e.getKey(i);return x({isKeystone:!1},a)}),getOfflineSigner:i=>{try{let a=e.getOfflineSignerOnlyAmino(i);return Object.assign(a,{signDirect:(m,w)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:i=>l(void 0,null,function*(){try{let a=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(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(s=>{var c,m,w;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:((m=s.gasPriceStep)==null?void 0:m.high)||0,low:((w=s.gasPriceStep)==null?void 0:w.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),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,a,s,c)=>e.signAmino(i,a,s)}}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: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=()=>{K(),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,m=q(x({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...s)=>l(void 0,null,function*(){var w;let{1:c,2:m}=s;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:on.fromString(((w=m.accountNumber)==null?void 0:w.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:m}=s;return e.signAmino(c,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,at=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>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 _,J,ie;if(!((ie=(J=(_=u.getState().walletConnect)==null?void 0:_.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=C=>{if(!e)return;let{appUrl:A,formatNativeUrl:E}=e;if(Q()){if(at())if(!C)window.open(A.mobile.android,"_self","noreferrer noopener");else {let k=E(A.mobile.android,C,"android");window.open(k,"_self","noreferrer noopener");}if(ct())if(!C)window.open(A.mobile.ios,"_self","noreferrer noopener");else {let k=E(A.mobile.ios,C,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:C}=g.getState();if(!C.get(t))throw new Error("walletConnect.signClient is not defined");C.delete(t),g.setState({wcSignClients:C}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=C=>l(void 0,null,function*(){let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!C)throw new Error("No wallet connect session");yield E.disconnect({topic:C,reason:getSdkError("USER_DISCONNECTED")}),yield c(E);}),a=C=>{try{let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let k=E.session.getAll().at(-1);if(!k)return;if(!(k.expiry*1e3>Date.now()+1e3))throw i(k.topic),new Error("invalid session");try{let W=E.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:C.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 k}catch(A){if(!A.message.toLowerCase().includes("no matching key"))throw A}},s=C=>{try{return a(C)}catch(A){return}},c=C=>l(void 0,null,function*(){try{let A=C.core.pairing.pairings.getAll({active:!1});if(!A.length)return;yield Promise.all(A.map(E=>l(void 0,null,function*(){yield C.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(A){if(!A.message.toLowerCase().includes("no matching key"))throw A}}),m=()=>l(void 0,null,function*(){let{walletConnect:C}=u.getState();if(!(C!=null&&C.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:A}=g.getState(),E=A.get(t);if(E)return E;let k=yield SignClient.init(C.options);return A.set(t,k),g.setState({wcSignClients:A}),k}),w=C=>{let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)return ()=>{};let k=P=>{let W=g.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&&d([U]);}else C();};return E.events.on("session_delete",r),E.events.on("session_expire",r),E.events.on("session_event",k),()=>{E.events.off("session_delete",r),E.events.off("session_expire",r),E.events.off("session_event",k);}},d=C=>l(void 0,null,function*(){var re;let A=typeof C=="string"?[C]:C,{wcSignClients:E}=g.getState(),k=E.get(t);if(!k)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(x({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=s(A);if(!Z){let{uri:F,approval:ee}=yield xe(k.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:A.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 Lt=$=>l(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 A.forEach(se=>{qe[se]=q(x({},Fe),{bech32Address:toBech32(W.find(Ut=>Ut.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Me[0].bech32Address).data)});}),g.setState(se=>({accounts:x(x({},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 Lt(Te);}catch($){if(V.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||V.closeModal(),Promise.resolve()}try{yield xe((()=>l(void 0,null,function*(){let F=Object.fromEntries(yield Promise.all(A.map(ee=>l(void 0,null,function*(){return [ee,yield p(ee)]}))));g.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(i(Z.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),S=C=>l(void 0,null,function*(){var W;let{wcSignClients:A}=g.getState(),E=A.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let k=(W=a([C]))==null?void 0:W.topic;if(!k)throw new Error("No wallet connect session");let P=yield E.request({topic:k,chainId:`cosmos:${C}`,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))}}),p=C=>l(void 0,null,function*(){let A=a([C]);if(!(A!=null&&A.topic))throw new Error("No wallet connect session");let E=A.sessionProperties&&JSON.parse(String(A.sessionProperties.keys))[0];if(!E)throw new Error("No wallet connect key");return E}),f=(...C)=>l(void 0,null,function*(){var F,ee;let[A,E,k]=C,{accounts:P,wcSignClients:W}=g.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=a([A]))==null?void 0:F.topic;if(!V)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:V,chainId:`cosmos:${A}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:q(x({},k),{bodyBytes:Buffer.from(k.bodyBytes).toString(n),authInfoBytes:Buffer.from(k.authInfoBytes).toString(n),accountNumber:(ee=k.accountNumber)==null?void 0:ee.toString()})}}};return o(),yield U.request(Z)}),h=(...C)=>l(void 0,null,function*(){let[A,E,k]=C,{signature:P,signed:W}=yield f(A,E,k);return {signed:{chainId:W.chainId,accountNumber:on.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:P}}),O=(...C)=>l(void 0,null,function*(){var F;let[A,E,k,P]=C,{wcSignClients:W}=g.getState(),U=W.get(t),{accounts:V}=g.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!V)throw new Error("account is not defined");let Z=(F=a([A]))==null?void 0:F.topic;if(!Z)throw new Error("No wallet connect session");return o(),yield U.request({topic:Z,chainId:`cosmos:${A}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:k}}})}),b=(...C)=>l(void 0,null,function*(){let[A,E,k,P]=C;return yield O(A,E,k)}),y=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(C)]}),signDirect:(A,E)=>h(C,A,E)}),I=C=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(C)]}),signAmino:(A,E)=>b(C,A,E)});return {enable:d,disable:C=>l(void 0,null,function*(){var k;let{wcSignClients:A}=g.getState(),E=A.get(t);if(C===void 0){let P=E==null?void 0:E.session.getAll();P!==void 0&&(yield Promise.all(P.map(W=>i(W.topic))));}else typeof C=="string"?yield i((k=a([C]))==null?void 0:k.topic):yield Promise.all(C.map(P=>{var W;return i((W=a([P]))==null?void 0:W.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...C)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:p,getOfflineSigner:C=>({getAccounts:()=>l(void 0,null,function*(){return [yield S(C)]}),signDirect:(A,E)=>h(C,A,E),signAmino:(A,E)=>b(C,A,E)}),getOfflineSignerAuto:C=>l(void 0,null,function*(){return (yield p(C)).isNanoLedger?I(C):y(C)}),getOfflineSignerOnlyAmino:I,signAmino:b,signDirect:h,subscription:w,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(!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,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);switch(a){case"ios":return `${s}://wcV2?${c}`;default:return `${s}://wc?uri=${c}`}}};return j(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(!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,a)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};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 Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,i,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);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 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 Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,i,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(i);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 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),g.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 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 ge();case"xdefi":return Se();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();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},Ho=()=>Object.fromEntries(Ve.map(e=>[e,B(e)])),ve=e=>e==="capsule",dt=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:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!B(i))throw new Error(`${i} is not available`);let s=D(i),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 m=o==null?void 0:o.map(p=>p.chainId);c.forEach(p=>{if(!(m!=null&&m.includes(p)))throw new Error(`Chain ${p} is not provided in GrazProvider`)}),g.setState(p=>{let f=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return p.activeChainIds&&c.filter(O=>{var b;return !((b=p.activeChainIds)!=null&&b.includes(O))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:w}=g.getState();if(yield (t=s.init)==null?void 0:t.call(s),ve(i)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let p=c.map(O=>o.find(b=>b.chainId===O)),f=g.getState().accounts;g.setState({status:"connecting"});let h=Object.fromEntries(yield Promise.all(c.map(O=>l(void 0,null,function*(){return [O,yield s.getKey(O)]}))));return g.setState(O=>({accounts:x(x({},O.accounts||{}),h)})),u.setState(O=>({recentChainIds:[...O.recentChainIds||[],...c].filter((b,y,I)=>I.indexOf(b)===y)})),g.setState(O=>({activeChainIds:[...O.activeChainIds||[],...c].filter((b,y,I)=>I.indexOf(b)===y)})),g.setState({status:"connected"}),{accounts:f,walletType:i,chains:p}}if(yield s.enable(c),ve(i)){let p=c.map(h=>o.find(O=>O.chainId===h)),f=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:f,walletType:i,chains:p}}if(!dt(i)){let p=Object.fromEntries(yield Promise.all(c.map(f=>l(void 0,null,function*(){return [f,yield s.getKey(f)]}))));g.setState(f=>({accounts:x(x({},f.accounts||{}),p)}));}u.setState(p=>({recentChainIds:[...p.recentChainIds||[],...c].filter((f,h,O)=>O.indexOf(f)===h)})),g.setState(p=>({activeChainIds:[...p.activeChainIds||[],...c].filter((f,h,O)=>O.indexOf(f)===h)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let d=c.map(p=>o.find(f=>f.chainId===p));return {accounts:g.getState().accounts,walletType:i,chains:d}}catch(n){throw console.error("connect ",n),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.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=g.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(g.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(a=>!t.includes(a)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(a=>!t.includes(a))}}));}else g.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: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();}}),ft=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(!B(n))throw new Error(`${n} is not available`);let r=D(n),i=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:a,offlineSignerAuto:s}});var ke=()=>{u.setState({recentChainIds:null});},ar=()=>u.getState().recentChainIds,cr=()=>{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},lr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},ur=({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=>l(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}),gt=e=>l(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 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=a=>l(void 0,[a],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=w=>l(void 0,[w],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:a,timeoutTimestamp:s,fee:c,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,a,s,c,m)}),ht=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,n,i,o,r)}),wt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,a,i)}),At=(e,t,n)=>l(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 wr=e=>e,Ar=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;}},Ot=e=>globalThis.DOMException===void 0?new Pe(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 Re(i,a){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!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 m=[],w=[],d=new Map,S=!1,p=!1,f=!1,h=0,O=0,b=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=v=>{S=!0,p=!0,c(v);};r&&(r.aborted&&y(Et(r)),r.addEventListener("abort",()=>{y(Et(r));}));let I=()=>l(this,null,function*(){if(p)return;let v=yield b.next(),R=O;if(O++,v.done){if(f=!0,h===0&&!p){if(!o&&w.length>0){y(new AggregateError(w));return}if(p=!0,d.size===0){s(m);return}let N=[];for(let[_,J]of m.entries())d.get(_)!==bt&&N.push(J);s(N);}return}h++,l(this,null,function*(){try{let N=yield v.value;if(p)return;let _=yield t(N,R);_===bt&&d.set(R,_),m[R]=_,h--,yield I();}catch(N){if(o)y(N);else {w.push(N),h--;try{yield I();}catch(_){y(_);}}}});});l(this,null,function*(){for(let v=0;v<n;v++){try{yield I();}catch(R){y(R);break}if(f||S)break}});})})}var bt=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)=>l(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Re(t,n,{concurrency:o});return Object.fromEntries(i.map((a,s)=>[t[s].chainId,a]))}return yield n(t[0])}),Tt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,a)=>[t[a].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=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:x({},(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=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=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:x({},(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:o})=>{let r=L({chainId:t,multiChain:n}),i=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:i,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,w=>l(void 0,null,function*(){var h;let d=(h=u.getState().chainsConfig)==null?void 0:h[w.chainId],S={url:w.rpc,headers:x({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(S)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var Vr=()=>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(s=>s.walletType),n=g(s=>s.activeChainIds),o=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=g(s=>s.accounts),i=g(s=>s.status);return useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var m,w,d;if(s==="connected"){let{accounts:S,activeChainIds:p}=g.getState(),{chains:f}=u.getState(),{walletType:h}=u.getState();if(!S||!p||!f)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(w=e==null?void 0:e.onConnect)==null||w.call(e,{accounts:S,chains:p.map(O=>f.find(b=>b.chainId===O)),walletType:h,isReconnect:c==="reconnecting"});}s==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),o,s=>r[s.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}},hn=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(a=>a.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=>l(void 0,[m],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){let S=a==null?void 0:a[d.chainId];if(!S)throw new Error(`Client is not ready ${d.chainId}`);return yield S.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).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})},as=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}=hn({chainId:t.map(c=>c.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,o,e.chainId],s=useQuery(a,({queryKey:[,c,m]})=>m==null?void 0:m.find(w=>w.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(x({},s),{refetch:c=>l(void 0,null,function*(){return yield i(),s.refetch(c)})})},cs=({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:i}=we();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},ls=({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}},us=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:a=>l(void 0,[a],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=>l(void 0,null,function*(){return yield ft({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},ps=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(a=>a.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=>l(void 0,[m],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var p;if(!a)throw new Error("Client is not ready");return yield (p=a[d.chainId])==null?void 0:p.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Cs=()=>{let e=u(o=>o.capsuleState),t=g(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 bs=()=>g(e=>e.activeChainIds),wn=()=>{var e;return (e=g(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)},Ts=({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))},xs=({denom:e})=>{let t=wn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:i.currencies.find(a=>a)})},vs=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:[,i,a]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(a)}),{enabled:typeof e.queryClient!="undefined"})},ks=()=>({data:u(t=>t.recentChainIds),clear:ke}),Ws=()=>{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}},Ps=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a.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}},Rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],gt,{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:i}=we();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Fs=({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],a=>St(x({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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},qs=({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],a=>Ct(x({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:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Gs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,s=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],c=>{var w;if(!i)throw new Error("senderAddress is undefined");let m=q(x({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:i,codeId:e});return ht(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},zs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,s=useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],c=>{var w,d,S;if(!i)throw new Error("senderAddress is undefined");let m=q(x({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:i,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(S=c.funds)!=null?S:[]});return wt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Qs=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 At(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},js=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 It(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ra(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=g(i=>i.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,i,a]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>l(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(m.chainId);default:return D(a).getOfflineSignerAuto(m.chainId)}}))(),S=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],p={url:m.rpc,headers:x({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(p,d,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 sa(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=g(i=>i.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,i,a]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>l(this,null,function*(){var O,b;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(m.chainId);default:return D(a).getOfflineSignerAuto(m.chainId)}}))(),S=(O=u.getState().chainsConfig)==null?void 0:O[m.chainId],p={url:m.rpc,headers:x({},(S==null?void 0:S.rpcHeaders)||{})},f=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(p,d,x({gasPrice:f},e!=null&&e.multiChain?(b=e.opts)==null?void 0:b[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 aa(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=g(a=>a.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:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,a,w=>l(this,null,function*(){var h;if(!(o!=null&&o.includes(w.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);if(!i)throw new Error("No tendermint client found");let S=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(w.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(w.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(w.chainId);default:return D(s).getOfflineSignerAuto(w.chainId)}}))(),p=e.multiChain?i[w.chainId]:i;return yield SigningStargateClient.createWithSigner(p,S,e.multiChain?(h=e.opts)==null?void 0:h[w.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ca(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=g(s=>s.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:a}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,s,d=>l(this,null,function*(){var y,I;if(!(o!=null&&o.includes(d.chainId)))return null;if(!B(c))throw new Error(`${c} is not available`);let p=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return D(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return D(c).getOfflineSignerOnlyAmino(d.chainId);default:return D(c).getOfflineSignerAuto(d.chainId)}}))(),f=(y=u.getState().chainsConfig)==null?void 0:y[d.chainId],h=f!=null&&f.gas?GasPrice.fromString(`${f.gas.price}${f.gas.denom}`):void 0,O=e.multiChain?a==null?void 0:a[d.chainId]:i;if(!O)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(O,p,x({gasPrice:h},e.multiChain?(I=e.opts)==null?void 0:I[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Ce(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Nt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var Tn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:a,wcSignClients:s}=g(),c=B(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(w=>{if(w)return Y({chainId:i.map(d=>d.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!c)return;e&&a?G({onError:n}):!e&&t&&G({onError:n});}},[c]),useEffect(()=>{var m,w,d,S,p,f,h,O,b,y,I,v,R,N,_,J,ie,C;if(o){if(!c)return;o==="cosmostation"&&((w=(m=pe()).subscription)==null||w.call(m,()=>{G({onError:n});})),o==="keplr"&&((S=(d=me()).subscription)==null||S.call(d,()=>{G({onError:n});})),o==="leap"&&((f=(p=de()).subscription)==null||f.call(p,()=>{G({onError:n});})),o==="compass"&&((O=(h=le()).subscription)==null||O.call(h,()=>{G({onError:n});})),o==="vectis"&&((y=(b=ye()).subscription)==null||y.call(b,()=>{G({onError:n});})),o==="walletconnect"&&s.has("walletconnect")&&((v=(I=j()).subscription)==null||v.call(I,()=>{G({onError:n});})),o==="station"&&((N=(R=ge()).subscription)==null||N.call(R,()=>{G({onError:n});})),o==="xdefi"&&((J=(_=Se()).subscription)==null||J.call(_,()=>{G({onError:n});})),o==="cosmiframe"&&((C=(ie=ue()).subscription)==null||C.call(ie,()=>{G({onError:n});}));}},[o,s,c]),null},Kt=()=>(Tn(),null);var vn=new QueryClient({}),Ka=o=>{var r=o,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return yt(t),jsxs(QueryClientProvider,q(x({client:vn},n),{children:[e,jsx(Nt,{children:jsx(Kt,{})})]}),"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},tr=()=>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});},dr=()=>u.getState().recentChainIds,fr=()=>{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},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},yr=({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 Tr=e=>e,Mr=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 es=()=>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})},ds=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)})})},fs=({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}},gs=({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}},ys=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})},Ss=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 Es=()=>{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 Ws=()=>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)},Ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Rs=({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=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)})},_s=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"})},Ns=()=>({data:u(t=>t.recentChainIds),clear:ve}),Ks=()=>{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}},Bs=({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}},Ls=({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 $s=({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}},Vs=({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}},Hs=({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}},Ys=({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}},Xs=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})},Js=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 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_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 ma(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 da(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 fa(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 Rn=new QueryClient({}),za=o=>{var r=o,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return useEffect(()=>{St(t);},[]),jsx(QueryClientProvider,q(k({client:Rn},n),{children:jsxs(Kt,{children:[e,jsx(Bt,{})]})}),"graz-provider")};
19
19
 
20
- export { Kt as GrazEvents, Ka as GrazProvider, Ve as WALLET_TYPES, $e as WalletType, B as checkWallet, ke as clearRecentChain, K as clearSession, yt as configureGraz, Y as connect, Ar as defineChainInfo, wr as defineChains, oe as disconnect, wt as executeContract, Ho as getAvailableWallets, lr as getChainInfo, ur as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, st as getMetamaskSnapLeap, ft as getOfflineSigners, It as getQueryRaw, At as getQuerySmart, ar as getRecentChainIds, cr as getRecentChains, ye as getVectis, ut as getWCCosmostation, pt as getWCKeplr, mt as getWCLeap, D as getWallet, j as getWalletConnect, ht as instantiateContract, ve as isCapsule, dt as isWalletConnect, G as reconnect, Ct as sendIbcTokens, St as sendTokens, We as suggestChain, gt as suggestChainAndConnect, X as useAccount, xs as useActiveChainCurrency, bs as useActiveChainIds, wn as useActiveChains, Vr as useActiveWalletType, as as useBalance, ps as useBalanceStaked, hn as useBalances, Cs as useCapsule, Ts as useChainInfo, Ms as useChainInfos, we as useCheckWallet, cs as useConnect, Ke as useCosmWasmClient, sa as useCosmWasmSigningClient, ca as useCosmWasmTmSigningClient, ls as useDisconnect, zs as useExecuteContract, Tn as useGrazEvents, Gs as useInstantiateContract, us as useOfflineSigners, vs as useQueryClientValidators, js as useQueryRaw, Qs as useQuerySmart, ks as useRecentChainIds, Ws as useRecentChains, qs as useSendIbcTokens, Fs as useSendTokens, Ne as useStargateClient, ra as useStargateSigningClient, aa as useStargateTmSigningClient, Ps as useSuggestChain, Rs as useSuggestChainAndConnect, he as useTendermintClient };
20
+ export { Bt as GrazEvents, za as GrazProvider, Ve as WALLET_TYPES, $e as WalletType, B as checkWallet, ve as clearRecentChain, K as clearSession, St as configureGraz, Y as connect, Mr as defineChainInfo, Tr as defineChains, oe as disconnect, At as executeContract, tr as getAvailableWallets, gr as getChainInfo, yr as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, at as getMetamaskSnapLeap, gt as getOfflineSigners, Ot as getQueryRaw, It as getQuerySmart, dr as getRecentChainIds, fr 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, Ds as useActiveChainCurrency, Ws as useActiveChainIds, On as useActiveChains, es as useActiveWalletType, ds as useBalance, Ss as useBalanceStaked, In as useBalances, Es as useCapsule, Ps as useChainInfo, Rs as useChainInfos, we as useCheckWallet, fs as useConnect, Ke as useCosmWasmClient, ma as useCosmWasmSigningClient, fa as useCosmWasmTmSigningClient, gs as useDisconnect, Ys as useExecuteContract, kn as useGrazEvents, Hs as useInstantiateContract, ys as useOfflineSigners, _s as useQueryClientValidators, Js as useQueryRaw, Xs as useQuerySmart, Ns as useRecentChainIds, Ks as useRecentChains, Vs as useSendIbcTokens, $s as useSendTokens, Ne as useStargateClient, pa as useStargateSigningClient, da as useStargateTmSigningClient, Bs as useSuggestChain, Ls 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.20",
4
+ "version": "0.1.22",
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.39",
43
+ "@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
44
44
  "react": ">=17"
45
45
  },
46
46
  "dependencies": {