graz 0.3.3 → 0.3.4-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/.gitkeep CHANGED
File without changes
package/dist/cli.js CHANGED
@@ -28,7 +28,7 @@ function _interopNamespace(e) {
28
28
  var C__namespace = /*#__PURE__*/_interopNamespace(C);
29
29
  var me__namespace = /*#__PURE__*/_interopNamespace(me);
30
30
 
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
+ 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(te(r,"default",{value:e,enumerable:true}),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=false,stopAtPositional:d=false}={}){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=false;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]===true;}else if(typeof i=="function")c=i===Boolean||i[F]===true;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(true,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]=true,e);x.COUNT=x.flag((e,n,r)=>(r||0)+1);x.ArgError=b;ne.exports=x;});T();var de=we(oe());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=true,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,_=false,a=false,E=false,l=0,w=0,s=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),I=N=>{_=true,a=true,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=true,l===0&&!a){if(!d&&u.length>0){I(new AggregateError(u));return}if(a=true,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]
32
32
 
33
33
  Options:
34
34
 
@@ -43,7 +43,7 @@ Generate options:
43
43
  --authz Generate only authz compatible chains
44
44
 
45
45
  https://github.com/graz-sh/graz
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(`
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:true})).replace("/* REPLACE_MAINNET_CHAINS */",D(e)).replace("/* REPLACE_TESTNET_CHAINS */",D(n,{testnet:true})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",O(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",O(n,{testnet:true})).replace("/* REPLACE_MAINNET_EXPORTS */",O(e)).replace("/* REPLACE_TESTNET_EXPORTS */",O(n,{testnet:true})).replace(/"(.+)":/g,"$1:").trim(),h=d.replace("/* REPLACE_MAINNET_DEFS */",M(e,{mjs:true})).replace("/* REPLACE_TESTNET_DEFS */",M(n,{mjs:true,testnet:true})).replace("/* REPLACE_MAINNET_CHAINS */",D(e)).replace("/* REPLACE_TESTNET_CHAINS */",D(n,{testnet:true})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",O(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",O(n,{testnet:true})).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=false}={})=>Object.keys(e).map(r=>` ${L(r)}: ${L(r)},`).join(`
47
+ `),M=(e,{mjs:n=false,testnet:r=false}={})=>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=false}={})=>Object.keys(e).map(r=>` ${L(r)},`).join(`
49
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)||void 0,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)||void 0}});if(!w)throw new Error(`\u26A0\uFE0F ${t.name} has no fee currencies, skipping codegen...`);m[t.path]={chainId:t.chain_id,currencies:t.assets.map(s=>({coinDenom:s.denom_units[s.denom_units.length-1].denom,coinMinimalDenom:s.denom_units[0].denom,coinDecimals:s.denom_units[s.denom_units.length-1].exponent,coinGeckoId:s.coingecko_id})),rest:a.rest[0].address||"",rpc:a.rpc[0].address||"",bech32Config:cosmos.Bech32Address.defaultBech32Config(t.bech32_prefix),chainName:t.chain_name,feeCurrencies:w,stakeCurrency:l,bip44:{coinType:(_=t.slip44)!=null?_:0}};}catch(a){console.error(a instanceof Error?a.message:String(a));}}),m});Pe();
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  /// <reference types="../types/global" />
2
2
  import { DirectSignResponse, OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
3
- import { Keplr, ChainInfo, KeplrSignOptions, KeplrIntereactionOptions, Key as Key$1, OfflineAminoSigner as OfflineAminoSigner$1, AppCurrency } from '@keplr-wallet/types';
3
+ import { Key as Key$1, Keplr, ChainInfo, KeplrSignOptions, KeplrIntereactionOptions, OfflineAminoSigner as OfflineAminoSigner$1, AppCurrency } from '@keplr-wallet/types';
4
4
  import { OfflineAminoSigner } from '@cosmjs/amino';
5
5
  import { SignClientTypes } from '@walletconnect/types';
6
6
  import { WalletConnectModalConfig } from '@walletconnect/modal';
7
+ import { ParaGrazConfig as ParaGrazConfig$1, ParaGrazConnector } from '@getpara/graz-connector';
7
8
  import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
8
9
  import { SigningCosmWasmClient, InstantiateOptions, CosmWasmClient, InstantiateResult, ExecuteResult, SigningCosmWasmClientOptions } from '@cosmjs/cosmwasm-stargate';
9
10
  import { SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, StargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
@@ -34,7 +35,8 @@ declare enum WalletType {
34
35
  COSMIFRAME = "cosmiframe",
35
36
  COMPASS = "compass",
36
37
  INITIA = "initia",
37
- OKX = "okx"
38
+ OKX = "okx",
39
+ PARA = "para"
38
40
  }
39
41
  declare const WALLET_TYPES: WalletType[];
40
42
  type Wallet = Pick<Keplr, "enable" | "getOfflineSignerOnlyAmino" | "signAmino"> & {
@@ -127,6 +129,10 @@ interface ChainConfig {
127
129
  denom: string;
128
130
  };
129
131
  }
132
+ interface ParaGrazConfig extends ParaGrazConfig$1 {
133
+ connectorClass?: new (config: ParaGrazConfig, chains?: ChainInfo[] | null) => ParaGrazConnector;
134
+ connectorImportPath?: string;
135
+ }
130
136
  interface WalletConnectStore {
131
137
  options: SignClientTypes.Options | null;
132
138
  walletConnectModal?: Pick<WalletConnectModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
@@ -147,6 +153,7 @@ interface IframeOptions {
147
153
  }
148
154
  interface GrazInternalStore {
149
155
  recentChainIds: string[] | null;
156
+ paraConfig: ParaGrazConfig | null | undefined;
150
157
  chains: ChainInfo[] | null;
151
158
  chainsConfig: Record<string, ChainConfig> | null;
152
159
  iframeOptions: IframeOptions | null;
@@ -172,6 +179,7 @@ interface ConfigureGrazArgs {
172
179
  defaultWallet?: WalletType;
173
180
  chains: ChainInfo[];
174
181
  chainsConfig?: Record<string, ChainConfig>;
182
+ paraConfig?: GrazInternalStore["paraConfig"];
175
183
  onNotFound?: () => void;
176
184
  onReconnectFailed?: () => void;
177
185
  walletConnect?: GrazInternalStore["walletConnect"];
@@ -274,6 +282,7 @@ declare const getAvailableWallets: () => Record<WalletType, boolean>;
274
282
  declare const isLeapSnaps: (type: WalletType) => boolean;
275
283
  declare const isLeapDappBrowser: () => boolean;
276
284
  declare const isWalletConnect: (type: WalletType) => boolean;
285
+ declare const isPara: (type: WalletType) => type is WalletType.PARA;
277
286
 
278
287
  /**
279
288
  * Function to return cosmostation object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
@@ -1104,4 +1113,4 @@ declare const useGrazEvents: () => null;
1104
1113
  */
1105
1114
  declare const GrazEvents: FC;
1106
1115
 
1107
- export { ConfigureGrazArgs, ConnectArgs, ConnectResult, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Key, KnownKeys, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SignAminoParams, SignDirectParams, SignDoc, SuggestChainAndConnectArgs, SuggestChainArgs, UseAccountArgs, UseAccountResult, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
1116
+ export { type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  /// <reference types="../types/global" />
2
2
  import { DirectSignResponse, OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
3
- import { Keplr, ChainInfo, KeplrSignOptions, KeplrIntereactionOptions, Key as Key$1, OfflineAminoSigner as OfflineAminoSigner$1, AppCurrency } from '@keplr-wallet/types';
3
+ import { Key as Key$1, Keplr, ChainInfo, KeplrSignOptions, KeplrIntereactionOptions, OfflineAminoSigner as OfflineAminoSigner$1, AppCurrency } from '@keplr-wallet/types';
4
4
  import { OfflineAminoSigner } from '@cosmjs/amino';
5
5
  import { SignClientTypes } from '@walletconnect/types';
6
6
  import { WalletConnectModalConfig } from '@walletconnect/modal';
7
+ import { ParaGrazConfig as ParaGrazConfig$1, ParaGrazConnector } from '@getpara/graz-connector';
7
8
  import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
8
9
  import { SigningCosmWasmClient, InstantiateOptions, CosmWasmClient, InstantiateResult, ExecuteResult, SigningCosmWasmClientOptions } from '@cosmjs/cosmwasm-stargate';
9
10
  import { SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, StargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
@@ -34,7 +35,8 @@ declare enum WalletType {
34
35
  COSMIFRAME = "cosmiframe",
35
36
  COMPASS = "compass",
36
37
  INITIA = "initia",
37
- OKX = "okx"
38
+ OKX = "okx",
39
+ PARA = "para"
38
40
  }
39
41
  declare const WALLET_TYPES: WalletType[];
40
42
  type Wallet = Pick<Keplr, "enable" | "getOfflineSignerOnlyAmino" | "signAmino"> & {
@@ -127,6 +129,10 @@ interface ChainConfig {
127
129
  denom: string;
128
130
  };
129
131
  }
132
+ interface ParaGrazConfig extends ParaGrazConfig$1 {
133
+ connectorClass?: new (config: ParaGrazConfig, chains?: ChainInfo[] | null) => ParaGrazConnector;
134
+ connectorImportPath?: string;
135
+ }
130
136
  interface WalletConnectStore {
131
137
  options: SignClientTypes.Options | null;
132
138
  walletConnectModal?: Pick<WalletConnectModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
@@ -147,6 +153,7 @@ interface IframeOptions {
147
153
  }
148
154
  interface GrazInternalStore {
149
155
  recentChainIds: string[] | null;
156
+ paraConfig: ParaGrazConfig | null | undefined;
150
157
  chains: ChainInfo[] | null;
151
158
  chainsConfig: Record<string, ChainConfig> | null;
152
159
  iframeOptions: IframeOptions | null;
@@ -172,6 +179,7 @@ interface ConfigureGrazArgs {
172
179
  defaultWallet?: WalletType;
173
180
  chains: ChainInfo[];
174
181
  chainsConfig?: Record<string, ChainConfig>;
182
+ paraConfig?: GrazInternalStore["paraConfig"];
175
183
  onNotFound?: () => void;
176
184
  onReconnectFailed?: () => void;
177
185
  walletConnect?: GrazInternalStore["walletConnect"];
@@ -274,6 +282,7 @@ declare const getAvailableWallets: () => Record<WalletType, boolean>;
274
282
  declare const isLeapSnaps: (type: WalletType) => boolean;
275
283
  declare const isLeapDappBrowser: () => boolean;
276
284
  declare const isWalletConnect: (type: WalletType) => boolean;
285
+ declare const isPara: (type: WalletType) => type is WalletType.PARA;
277
286
 
278
287
  /**
279
288
  * Function to return cosmostation object (which is {@link Wallet}) and throws and error if it does not exist on `window`.
@@ -1104,4 +1113,4 @@ declare const useGrazEvents: () => null;
1104
1113
  */
1105
1114
  declare const GrazEvents: FC;
1106
1115
 
1107
- export { ConfigureGrazArgs, ConnectArgs, ConnectResult, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Key, KnownKeys, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SignAminoParams, SignDirectParams, SignDoc, SuggestChainAndConnectArgs, SuggestChainArgs, UseAccountArgs, UseAccountResult, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
1116
+ export { type ConfigureGrazArgs, type ConnectArgs, type ConnectResult, type Dictionary, type ExecuteContractArgs, type ExecuteContractMutationArgs, GrazEvents, GrazProvider, type GrazProviderProps, type InstantiateContractArgs, type InstantiateContractMutationArgs, type Key, type KnownKeys, type Maybe, type OfflineSigners, type ReconnectArgs, type SendIbcTokensArgs, type SendTokensArgs, type SignAminoParams, type SignDirectParams, type SignDoc, type SuggestChainAndConnectArgs, type SuggestChainArgs, type UseAccountArgs, type UseAccountResult, type UseConnectChainArgs, type UseExecuteContractArgs, type UseInstantiateContractArgs, type UseSuggestChainAndConnectArgs, type UseSuggestChainArgs, WALLET_TYPES, type Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isLeapDappBrowser, isLeapSnaps, isPara, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var middleware = require('zustand/middleware');
5
5
  var cosmiframe = require('@dao-dao/cosmiframe');
6
6
  var snapper = require('@cosmsnap/snapper');
7
7
  var amino = require('@cosmjs/amino');
8
- var Oe = require('long');
8
+ var Ee = require('long');
9
9
  var encoding = require('@cosmjs/encoding');
10
10
  var signClient = require('@walletconnect/sign-client');
11
11
  var utils = require('@walletconnect/utils');
@@ -19,77 +19,78 @@ var jsxRuntime = require('react/jsx-runtime');
19
19
 
20
20
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
21
 
22
- var Oe__default = /*#__PURE__*/_interopDefault(Oe);
22
+ var Ee__default = /*#__PURE__*/_interopDefault(Ee);
23
23
 
24
- var Dt=Object.defineProperty,_t=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var Ke=Object.getOwnPropertySymbols;var Kt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable;var Ne=(e,t,n)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))Kt.call(t,n)&&Ne(e,n,t[n]);if(Ke)for(var n of Ke(t))Nt.call(t,n)&&Ne(e,n,t[n]);return e},F=(e,t)=>_t(e,Rt(t));var l=(e,t,n)=>new Promise((r,i)=>{var o=c=>{try{a(n.next(c));}catch(p){i(p);}},s=c=>{try{a(n.throw(c));}catch(p){i(p);}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());}),Be=(e,t,n)=>(t=e[Symbol.asyncIterator],n=(r,i)=>(i=e[r])&&(t[r]=o=>new Promise((s,a,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(p=>s({value:p,done:c}),a)))),t?t.call(e):(e=e[Symbol.iterator](),t={},n("next"),n("return"),t));var ee="graz-reconnect-session";var Le=(w=>(w.KEPLR="keplr",w.LEAP="leap",w.VECTIS="vectis",w.COSMOSTATION="cosmostation",w.WALLETCONNECT="walletconnect",w.WC_KEPLR_MOBILE="wc_keplr_mobile",w.WC_LEAP_MOBILE="wc_leap_mobile",w.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",w.WC_CLOT_MOBILE="wc_clot_mobile",w.METAMASK_SNAP_LEAP="metamask_snap_leap",w.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",w.STATION="station",w.XDEFI="xdefi",w.COSMIFRAME="cosmiframe",w.COMPASS="compass",w.INITIA="initia",w.OKX="okx",w))(Le||{}),Ue=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Lt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map},Ut={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing}),storage:middleware.createJSONStorage(()=>sessionStorage)},Ft={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},I=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,Ut))),m=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Lt,Ft)));var ae=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw m.getState()._notFoundFn(),new Error("window.leap is not defined")};var ce=()=>{let e=m.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 je={},$e=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var g;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(g=o.split("MetaMask/v")[1])==null?void 0:g.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:o=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(F(M({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,a)=>l(void 0,null,function*(){return t.signAmino(o,s,a)}),getKey:o=>l(void 0,null,function*(){return typeof je[o]!="undefined"?je[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,a)=>l(void 0,null,function*(){return t.signDirect(o,s,a)}),signArbitrary:(o,s,a)=>l(void 0,null,function*(){return t.signArbitrary(o,s,a)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw m.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var le=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{N(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw m.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Ht=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:r,accountNumber:i}=e;if(!t||!n||!r||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:r,accountNumber:i}},Xt=e=>`${e.slice(0,6)}...${e.slice(-6)}`,He=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:u=>l(void 0,null,function*(){let d=e.getOfflineSigner(u),[h]=yield d.getAccounts();if(!h)throw new Error("Wallet connection failed");let T=(()=>{switch(h.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(h.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:Xt(h.address),algo:h.algo,pubKey:h.pubkey,bech32Address:h.address,address:T,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:u=>{let d=e.getOfflineSigner(u),h=e.getOfflineSignerOnlyAmino(u);return {getAccounts:d.getAccounts.bind(d),signDirect:d.signDirect.bind(d),signAmino:h.signAmino.bind(h)}},getOfflineSignerAuto:u=>Promise.resolve(e.getOfflineSigner(u)),getOfflineSignerOnlyAmino:u=>e.getOfflineSignerOnlyAmino(u),experimentalSuggestChain:u=>e.requestAddInitiaLayer({chain_id:u.chainId,chain_name:u.chainName,bech32_prefix:"init",bech32_config:u.bech32Config,slip44:u.bip44.coinType,logo_URIs:{png:u.chainSymbolImageUrl},fees:{fee_tokens:u.feeCurrencies.map(d=>{var h,T,v;return {denom:d.coinDenom,amount:d.coinMinimalDenom,low_gas_price:(h=d.gasPriceStep)==null?void 0:h.low,average_gas_price:(T=d.gasPriceStep)==null?void 0:T.average,high_gas_price:(v=d.gasPriceStep)==null?void 0:v.high}})},apis:{rpc:[{address:u.rpc}],rest:[{address:u.rest}]}}),signDirect:(...u)=>{let[d,h,T]=u;return e.getOfflineSigner(d).signDirect(h,Ht(T))},signAmino:(...u)=>{let[d,h,T]=u;return e.getOfflineSignerOnlyAmino(d).signAmino(h,T)},signArbitrary:(u,d,h)=>l(void 0,null,function*(){let W=(yield e.getOfflineSigner(u).getAccounts()).find(A=>A.address===d);if(!W)throw new Error(`Wallet not connected to account ${d}`);let w=(()=>{switch(W.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(W.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(W.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(h),pub_key:{type:W.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:w.value}}}),subscription:u=>{let d=()=>{N(),u();};return window.addEventListener("initia_keystorechange",d),()=>{window.removeEventListener("initia_keystorechange",d);}}}}throw m.getState()._notFoundFn(),new Error("window.initia is not defined")};var ue=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw m.getState()._notFoundFn(),new Error("window.keplr is not defined")};var pe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw m.getState()._notFoundFn(),new Error("window.leap is not defined")};var me={},Ye=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),r=f=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(b=>b.id===e.id&&(!f||b.version===f))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var D;let f=yield t.request({method:"web3_clientVersion"});if(!f.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(D=f.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield r())||(yield i()),!0}),s=f=>l(void 0,null,function*(){(yield r())||(yield i());}),a=(f,A,b)=>l(void 0,null,function*(){let k=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:A,signDoc:b}}}}),R=b.accountNumber,D=new Oe__default.default(R.low,R.high,R.unsigned);return {signature:k.signature,signed:F(M({},k.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(k.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(k.signed.bodyBytes))})}}),c=(f,A,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:A,signDoc:b}}}})}),p=f=>l(void 0,null,function*(){if(typeof me[f]!="undefined")return me[f];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,me[f]=A,me[f]}),g=f=>l(void 0,null,function*(){let A=yield p(f);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),u=(...f)=>l(void 0,null,function*(){let[A,b,k,R]=f;return yield c(A,b,k)}),d=(...f)=>l(void 0,null,function*(){var j;let[A,b,k]=f,R=F(M({},k),{accountNumber:Oe__default.default.fromString(((j=k.accountNumber)==null?void 0:j.toString())||"0"),authInfoBytes:k.authInfoBytes,bodyBytes:k.bodyBytes});return yield a(A,b,R)}),T=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(f)]}),signAmino:(A,b)=>u(f,A,b)});return {enable:s,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(f)]}),signDirect:(A,b)=>d(f,A,b),signAmino:(A,b)=>u(f,A,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return T(f)}),getOfflineSignerOnlyAmino:T,init:o,signAmino:u,signDirect:d}}throw m.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Je=()=>Ye({id:"npm:@leapwallet/metamask-cosmos-snap"});var de=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var a;let s=()=>{N(),o();};return (a=window.okxwallet)==null||a.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw m.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var fe=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let a=()=>{N(),s();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:s=>l(void 0,null,function*(){let a=yield t.getKey(s);return M({isKeystone:!1},a)}),getOfflineSigner:s=>{try{let a=t.getOfflineSignerOnlyAmino(s);return Object.assign(a,{signDirect:(g,u)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var p,g,u;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((p=c.gasPriceStep)==null?void 0:p.average)||0,high:((g=c.gasPriceStep)==null?void 0:g.high)||0,low:((u=c.gasPriceStep)==null?void 0:u.low)||0}}})});yield t.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,a,c,p)=>t.signAmino(s,a,c)}}throw m.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=>{let c=e.getOfflineSigner(a);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(p,g)=>l(void 0,null,function*(){var d;let u=yield c.signDirect(p,{accountNumber:Oe__default.default.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),authInfoBytes:g.authInfoBytes,bodyBytes:g.bodyBytes,chainId:g.chainId||""});return {signature:u.signature,signed:{authInfoBytes:u.signed.authInfoBytes,bodyBytes:u.signed.bodyBytes,chainId:u.signed.chainId,accountNumber:BigInt(u.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:a=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(a);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(p,g)=>l(void 0,null,function*(){var d;let u=yield c.signDirect(p,{accountNumber:Oe__default.default.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),authInfoBytes:g.authInfoBytes,bodyBytes:g.bodyBytes,chainId:g.chainId||""});return {signature:u.signature,signed:{authInfoBytes:u.signed.authInfoBytes,bodyBytes:u.signed.bodyBytes,chainId:u.signed.chainId,accountNumber:BigInt(u.signed.accountNumber.toString())}}})}:c}),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);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:a=>{let c=()=>{N(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>{let c=a[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...a)=>l(void 0,null,function*(){var g;let[c]=a;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let p={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(g=c.bech32Config)==null?void 0:g.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([p])}),signDirect:(...a)=>l(void 0,null,function*(){var u;let{1:c,2:p}=a,g=yield e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Oe__default.default.fromString(((u=p.accountNumber)==null?void 0:u.toString())||"",!1),chainId:p.chainId||""});return {signature:g.signature,signed:{authInfoBytes:g.signed.authInfoBytes,bodyBytes:g.signed.bodyBytes,chainId:g.signed.chainId,accountNumber:BigInt(g.signed.accountNumber.toString())}}}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:p}=a;return e.signAmino(c,p)})}}throw m.getState()._notFoundFn(),new Error("window.vectis is not defined")};var q=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},Ze=()=>q()&&navigator.userAgent.toLowerCase().includes("android"),et=()=>q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Ee=(e,t,n=new Error("Promise timed out"))=>{let r=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,r])};var G=e=>{var D,j,oe;if(!((oe=(j=(D=m.getState().walletConnect)==null?void 0:D.options)==null?void 0:j.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",r=y=>{if(!e)return;let{appUrl:S,formatNativeUrl:C}=e;if(q()){if(Ze()){let E=C(S.mobile.android,y,"android");window.open(E,"_self","noreferrer noopener");}if(et()){let E=C(S.mobile.ios,y,"ios");window.open(E,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=I.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),I.setState({wcSignClients:y}),m.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=I.getState(),C=S.get(t);if(!C)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield C.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(C);}),s=y=>{try{let{wcSignClients:S}=I.getState(),C=S.get(t);if(!C)throw new Error("walletConnect.signClient is not defined");let E=C.session.getAll(),P=E.at(-1);if(!P)return;if(!(P.expiry*1e3>Date.now()+1e3))throw o(P.topic),new Error("invalid session");try{let _=E.find(Q=>{var X,Y;return (Y=(X=Q.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${y}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return P}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(C=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(C.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),p=()=>l(void 0,null,function*(){let{walletConnect:y}=m.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:S}=I.getState(),C=S.get(t);if(C)return C;let E=yield signClient.SignClient.init(y.options);return S.set(t,E),I.setState({wcSignClients:S}),E}),g=y=>{let{wcSignClients:S}=I.getState(),C=S.get(t);if(!C)return ()=>{};let E=P=>{let x=I.getState().accounts;if(P.params.event.name==="accountsChanged"&&x&&!Object.values(x).map(_=>_.bech32Address).includes(P.params.event.data[0])){let _=P.params.chainId.split(":")[1];_&&u([_]);}else y();};return C.events.on("session_delete",i),C.events.on("session_expire",i),C.events.on("session_event",E),()=>{C.events.off("session_delete",i),C.events.off("session_expire",i),C.events.off("session_event",E);}},u=y=>l(void 0,null,function*(){var Y;let S=typeof y=="string"?[y]:y,{wcSignClients:C,activeChainIds:E}=I.getState(),P=C.get(t);if(!P)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:x,chains:_}=m.getState();if(!((Y=x==null?void 0:x.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let Q=new modal.WalletConnectModal(M({projectId:x.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},x.walletConnectModal)),X=a(S);if(!X){let{uri:L,approval:re}=yield Ee(P.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?r(L):yield Q.openModal({uri:L});let se=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ie,Z)=>{re().then(De=>{let _e=De.sessionProperties;if(!_e)return Z(new Error("No session properties"));let be=JSON.parse(String(_e.keys));if(be.length===0)return Z(new Error("No accounts"));if(!be[0])return Z(new Error("No accounts"));let Re={};return be.forEach(V=>{Re[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),I.setState(V=>({accounts:M(M({},V.accounts||{}),Re)})),Ie(De)}).catch(Z),$.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Ie=$.signal;Q.subscribeModal(Z=>{Z.open||$.abort();}),yield se(Ie);}catch($){if(Q.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||Q.closeModal(),Promise.resolve()}try{yield Ee((()=>l(void 0,null,function*(){var re;let L=Object.fromEntries(yield Promise.all((re=E||S)==null?void 0:re.map(se=>l(void 0,null,function*(){return [se,yield h(se)]}))));I.setState({accounts:L});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),d=y=>l(void 0,null,function*(){let S=yield h(y);return {address:S.bech32Address,algo:S.algo,pubkey:S.pubKey}}),h=y=>l(void 0,null,function*(){let S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let C=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys));if(!C)throw new Error("No wallet connect key");if(C.length===0)throw new Error("No wallet connect session");let E=C.find(P=>P.chainId===y);if(!E)throw new Error(`No wallet connect key for chainId ${y}`);return F(M({},E),{pubKey:Buffer.from(String(E.pubKey),n)})}),T=(...y)=>l(void 0,null,function*(){var Y,L;let[S,C,E]=y,{accounts:P,wcSignClients:x}=I.getState(),_=x.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let Q=(Y=s([S]))==null?void 0:Y.topic;if(!Q)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");return r(),yield _.request({topic:Q,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:C,signDoc:{chainId:E.chainId,accountNumber:(L=E.accountNumber)==null?void 0:L.toString(),bodyBytes:E.bodyBytes?Buffer.from(E.bodyBytes).toString(n):null,authInfoBytes:E.authInfoBytes?Buffer.from(E.authInfoBytes).toString(n):null}}}})}),v=(...y)=>l(void 0,null,function*(){var _;let[S,C,E]=y,{signature:P,signed:x}=yield T(S,C,E);return {signed:{chainId:(_=x.chainId)!=null?_:"",accountNumber:x.accountNumber?BigInt(x.accountNumber):BigInt(0),authInfoBytes:x.authInfoBytes?new Uint8Array(Buffer.from(x.authInfoBytes,n)):new Uint8Array([]),bodyBytes:x.bodyBytes?new Uint8Array(Buffer.from(x.bodyBytes,n)):new Uint8Array([])},signature:P}}),W=(...y)=>l(void 0,null,function*(){var L;let[S,C,E,P]=y,{wcSignClients:x}=I.getState(),_=x.get(t),{accounts:Q}=I.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let X=(L=s([S]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return r(),yield _.request({topic:X,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:C,signDoc:E}}})}),w=(...y)=>l(void 0,null,function*(){let[S,C,E,P]=y;return yield W(S,C,E)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,C)=>v(y,S,C)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signAmino:(S,C)=>w(y,S,C)});return {enable:u,disable:y=>l(void 0,null,function*(){var E;let{wcSignClients:S}=I.getState(),C=S.get(t);if(y===void 0){let P=C==null?void 0:C.session.getAll();P!==void 0&&(yield Promise.all(P.map(x=>o(x.topic))));}else typeof y=="string"?yield o((E=s([y]))==null?void 0:E.topic):yield Promise.all(y.map(P=>{var x;return o((x=s([P]))==null?void 0:x.topic)}));(C==null?void 0:C.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:h,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,C)=>v(y,S,C),signAmino:(S,C)=>w(y,S,C)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield h(y)).isNanoLedger?A(y):f(y)}),getOfflineSignerOnlyAmino:A,signAmino:w,signDirect:v,subscription:g,init:p}};var tt=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.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:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return G(e)};var nt=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.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:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":","");return o?`${a}://wc?${o}`:`${a}://wc`}};return G(e)};var ot=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.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:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${a}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return G(e)};var it=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.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:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${a}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return G(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:i=>{let o=()=>{N(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw m.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var U=(e=m.getState().walletType)=>{try{return K(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(ee),I.setState(ne);},K=(e=m.getState().walletType)=>{var r;let t=(()=>{switch(e){case"keplr":return ue();case"leap":return pe();case"cosmostation":return le();case"vectis":return ge();case"walletconnect":return G();case"wc_keplr_mobile":return ot();case"wc_leap_mobile":return it();case"wc_cosmostation_mobile":return nt();case"wc_clot_mobile":return tt();case"metamask_snap_leap":return Je();case"metamask_snap_cosmos":return $e();case"station":return fe();case"xdefi":return ye();case"cosmiframe":return ce();case"compass":return ae();case"initia":return He();case"okx":return de();default:throw new Error("Unknown wallet type")}})(),n=m.getState().walletDefaultOptions;return n&&((r=t.setDefaultOptions)==null||r.call(t,n)),t},Ni=()=>Object.fromEntries(Ue.map(e=>[e,U(e)])),rt=e=>e==="metamask_snap_leap",st=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),ie=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:a,walletType:c}=m.getState(),p=(e==null?void 0:e.walletType)||c;if(ie(p)){let w=K("walletconnect"),{disable:f}=w;f&&f();}if(!U(p))throw new Error(`${p} is not available`);let u=K(p),d=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!d)throw new Error("No last known connected chain, connect action requires chain ids");let h=a==null?void 0:a.map(w=>w.chainId);d.forEach(w=>{if(!(h!=null&&h.includes(w)))throw new Error(`Chain ${w} is not provided in GrazProvider`)}),I.setState(w=>{let f=m.getState()._reconnect||!!m.getState()._reconnectConnector||!!d;return w.activeChainIds&&d.filter(b=>{var k;return !((k=w.activeChainIds)!=null&&k.includes(b))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:T}=I.getState();if(yield (t=u.init)==null?void 0:t.call(u),yield u.enable(d),!ie(p)){let w={};if(rt(p)){let f={};try{for(var n=Be(d),r,i,o;r=!(i=yield n.next()).done;r=!1){let A=i.value;f[A]=yield u.getKey(A);}}catch(i){o=[i];}finally{try{r&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}w=f;}else if(st()&&u.getKeys){let f=yield u.getKeys(d);d.forEach((A,b)=>{let k=f[b];k&&(w[A]=k);});}else w=Object.fromEntries(yield Promise.all(d.map(f=>l(void 0,null,function*(){return [f,yield u.getKey(f)]}))));I.setState(f=>({accounts:M(M({},f.accounts||{}),w)}));}m.setState(w=>({recentChainIds:[...w.recentChainIds||[],...d].filter((f,A,b)=>b.indexOf(f)===A)})),I.setState(w=>({activeChainIds:[...w.activeChainIds||[],...d].filter((f,A,b)=>b.indexOf(f)===A)})),m.setState({walletType:p,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:p}),I.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ee,"Active");let v=d.map(w=>a.find(f=>f.chainId===w));return {accounts:I.getState().accounts,walletType:p,chains:v}}catch(s){throw console.error("connect ",s),I.getState().accounts===null&&I.setState({status:"disconnected"}),I.getState().accounts&&I.getState().activeChainIds&&I.setState({status:"connected"}),s}}),Te=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(ee);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(ie(m.getState().walletType)){let n=K("walletconnect"),{disable:r}=n;r&&r();}if(t){let n=I.getState().accounts;t.forEach(i=>{n==null||delete n[i];}),Object.values(n||{}).length===0?(I.setState(ne),m.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(I.setState(i=>{var o;return {activeChainIds:(o=i.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),m.setState(i=>{var o;return {recentChainIds:(o=i.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else I.setState(ne),m.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:r}=m.getState();try{let o=U(n||void 0);if(t&&o&&n)return ie(n)?void 0:yield te({chainId:t,walletType:n,autoReconnect:r})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),Te();}}),at=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=m.getState(),n=e.walletType||t;if(!U(n))throw new Error(`${n} is not available`);let i=K(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),a=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var ke=()=>{m.setState({recentChainIds:null});},Hi=()=>m.getState().recentChainIds,Xi=()=>{var n;let{recentChainIds:e,chains:t}=m.getState();return (n=e==null?void 0:e.map(r=>t.find(i=>i.chainId===r)))!=null?n:null},Yi=({chainId:e})=>{var t;return (t=m.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Ji=({chainId:e})=>{var t;return (t=m.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Me=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield K(t).experimentalSuggestChain(e),e}),ct=e=>l(void 0,null,function*(){var r;let t=m.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(r=e.walletType)!=null?r:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var lt=e=>(m.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var ut=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:r,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,r,i,o)}),pt=g=>l(void 0,[g],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:r,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:p}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,r,i,o,s,a,c,p)}),mt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:r,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,r,i)}),dt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:r,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,r,s,o)}),ft=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),gt=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.queryContractRaw(e,r)};var cr=e=>e,lr=e=>e;var yt=e=>e?Object.keys(e).length===0:!0;var xe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},St=e=>globalThis.DOMException===void 0?new xe(e):new DOMException(e),wt=e=>{let t=e.reason===void 0?St("This operation was aborted."):e.reason;return t instanceof Error?t:St(t)};function ve(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let p=[],g=[],u=new Map,d=!1,h=!1,T=!1,v=0,W=0,w=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{d=!0,h=!0,c(b);};i&&(i.aborted&&f(wt(i)),i.addEventListener("abort",()=>{f(wt(i));}));let A=()=>l(this,null,function*(){if(h)return;let b=yield w.next(),k=W;if(W++,b.done){if(T=!0,v===0&&!h){if(!r&&g.length>0){f(new AggregateError(g));return}if(h=!0,u.size===0){a(p);return}let R=[];for(let[D,j]of p.entries())u.get(D)!==Ct&&R.push(j);a(R);}return}v++,l(this,null,function*(){try{let R=yield b.value;if(h)return;let D=yield t(R,k);D===Ct&&u.set(k,D),p[k]=D,v--,yield A();}catch(R){if(r)f(R);else {g.push(R),v--;try{yield A();}catch(D){f(D);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield A();}catch(k){f(k);break}if(T||d)break}});})})}var Ct=Symbol("skip");var z=({chainId:e,multiChain:t})=>{let n=m(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let r=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!r):return r.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!r):return [r.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!r):return n;default:return [n[0]]}},H=(e,t,n)=>l(void 0,null,function*(){let r=m.getState().multiChainFetchConcurrency;if(e){let o=yield ve(t,n,{concurrency:r});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),ht=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Pe=e=>{let t=z({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:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),r,s=>l(void 0,null,function*(){var g;let a=(g=m.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:M({},(a==null?void 0:a.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})},We=e=>{let t=z({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:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),r,s=>l(void 0,null,function*(){var g;let a=(g=m.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:M({},(a==null?void 0:a.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})};var Rr=()=>m(shallow.useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),Se=e=>{let n=["USE_CHECK_WALLET",m(i=>e||i.walletType)];return reactQuery.useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>U(i)})};var J=e=>{let t=m(a=>a.walletType),n=I(a=>a.activeChainIds),r=z({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=I(a=>a.accounts),o=I(a=>a.status);return react.useEffect(()=>I.subscribe(a=>a.status,(a,c)=>{var p,g,u;if(a==="connected"){let{accounts:d,activeChainIds:h}=I.getState(),{chains:T}=m.getState(),{walletType:v}=m.getState();if(!d||!h||!T)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(g=e==null?void 0:e.onConnect)==null||g.call(e,{accounts:d,chains:h.map(W=>T.find(w=>w.chainId===W)),walletType:v,isReconnect:c==="reconnecting"});}a==="disconnected"&&((u=e==null?void 0:e.onDisconnect)==null||u.call(e));}),[e]),{data:react.useMemo(()=>i?ht(!!(e!=null&&e.multiChain),r,a=>i[a.chainId]):void 0,[i,r,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:B,status:o}},an=e=>{let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=Pe({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!r}),o=react.useMemo(()=>["USE_ALL_BALANCES",i,t,r,e==null?void 0:e.chainId],[r,e==null?void 0:e.chainId,t,i]);return reactQuery.useQuery({queryKey:o,queryFn:p=>l(void 0,[p],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),a,u=>l(void 0,null,function*(){var T;let d=s==null?void 0:s[u.chainId];if(!d)throw new Error(`Client is not ready ${u.chainId}`);if(!((T=u.bech32Config)!=null&&T.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${u.chainId}`);return yield d.getAllBalances(encoding.toBech32(u.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!yt(i)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Vr=e=>{let t=z({chainId:e.chainId}),{data:n}=J({chainId:e.chainId}),r=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=an({chainId:t.map(c=>c.chainId),bech32Address:r,enabled:!!r&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,r,e.chainId],a=reactQuery.useQuery({queryKey:s,queryFn:({queryKey:[,c,p]})=>p==null?void 0:p.find(g=>g.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?!0:e.enabled)});return F(M({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},Hr=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:te,onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:Te,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},Yr=e=>{let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=m(i=>i.walletType),r=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(void 0,[s],function*({queryKey:[,i,o]}){if(i.length<1)throw new Error("No chain found");if(!U(o))throw new Error(`${o} is not available`);return yield H(!!(e!=null&&e.multiChain),i,p=>l(void 0,null,function*(){return yield at({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Jr=e=>{let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),{data:r}=Pe({chainId:t.map(s=>s.chainId),multiChain:!0}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",r,t,i],[t,i,r]);return reactQuery.useQuery({queryKey:o,queryFn:p=>l(void 0,[p],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),a,u=>l(void 0,null,function*(){var h,T;if(!s)throw new Error("Client is not ready");if(!((h=u.bech32Config)!=null&&h.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${u.chainId}`);return yield (T=s[u.chainId])==null?void 0:T.getBalanceStaked(encoding.toBech32(u.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!r,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var ss=()=>I(e=>e.activeChainIds),cn=()=>{var e;return (e=I(t=>t.activeChainIds))==null?void 0:e.map(t=>{var r;let n=(r=m.getState().chains)==null?void 0:r.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},as=({chainId:e})=>{var t;return (t=m().chains)==null?void 0:t.find(n=>n.chainId===e)},cs=({chainId:e})=>{var t;return (t=m().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ls=({denom:e})=>{let t=cn();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},us=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:n,queryFn:a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},ps=()=>({data:m(t=>t.recentChainIds),clear:ke}),ms=()=>{var t;return {data:(t=m(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let r=(i=m.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(r)return r}).filter(Boolean),clear:ke}},ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:Me,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:ct,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:o}=Se();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Is=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=J(),i=r==null?void 0:r.bech32Address,o=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>ut(M({senderAddress:i},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:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=J(),i=r==null?void 0:r.bech32Address,o=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>pt(M({senderAddress:i},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:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Os=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:i}=J(),o=i==null?void 0:i.bech32Address,a=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,r,e,o],mutationFn:c=>{var g;if(!o)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,codeId:e});return mt(p)},onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Es=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:i}=J(),o=i==null?void 0:i.bech32Address,a=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,r,e,o],mutationFn:c=>{var g,u,d;if(!o)throw new Error("senderAddress is undefined");let p=F(M({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,contractAddress:e,memo:(u=c.memo)!=null?u:"",funds:(d=c.funds)!=null?d:[]});return dt(p)},onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Ts=e=>{let{data:t}=We();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return ft(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ks=e=>{let{data:t}=We(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return gt(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Bs(e){let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=m(o=>o.walletType),r=I(o=>o.activeChainIds),i=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,r],[r,e,t,n]);return reactQuery.useQuery({queryKey:i,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var v,W;if(!(r!=null&&r.includes(p.chainId)))return null;if(!U(s))throw new Error(`${s} is not available`);let u=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return K(s).getOfflineSigner(p.chainId);case"offlineSignerAuto":return K(s).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return K(s).getOfflineSignerOnlyAmino(p.chainId);default:return K(s).getOfflineSignerAuto(p.chainId)}}))(),d=(v=m.getState().chainsConfig)==null?void 0:v[p.chainId],h={url:p.rpc,headers:M({},(d==null?void 0:d.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(h,u,e!=null&&e.multiChain?(W=e.opts)==null?void 0:W[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ls(e){let t=z({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=m(o=>o.walletType),r=I(o=>o.activeChainIds),i=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,r],[r,e,t,n]);return reactQuery.useQuery({queryKey:i,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var W,w;if(!(r!=null&&r.includes(p.chainId)))return null;if(!U(s))throw new Error(`${s} is not available`);let u=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return K(s).getOfflineSigner(p.chainId);case"offlineSignerAuto":return K(s).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return K(s).getOfflineSignerOnlyAmino(p.chainId);default:return K(s).getOfflineSignerAuto(p.chainId)}}))(),d=(W=m.getState().chainsConfig)==null?void 0:W[p.chainId],h={url:p.rpc,headers:M({},(d==null?void 0:d.rpcHeaders)||{})},T=d!=null&&d.gas?stargate.GasPrice.fromString(`${d.gas.price}${d.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(h,u,M({gasPrice:T},e!=null&&e.multiChain?(w=e.opts)==null?void 0:w[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Pt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var Sn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(ee)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:r,iframeOptions:i,chains:o,pingInterval:s}=m(),{activeChainIds:a,wcSignClients:c}=I(),p=U(r||void 0);return react.useEffect(()=>{let g=()=>l(void 0,null,function*(){if(e&&p&&r&&(a!=null&&a[0])){let u=I.getState().lastPing;if(u&&Date.now()-u<s)return;let d=K(r);try{if(!(yield d.getKey(a[0])))throw new Error("No account found");I.setState({lastPing:Date.now()});return}catch(h){B({onError:n});}}});return window.addEventListener("focus",g),()=>{window.removeEventListener("focus",g);}},[e,p,r,o,a,s]),react.useEffect(()=>{if(!i||i.autoConnect===!1||!i.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(i.allowedIframeParentOrigins).isReady().then(u=>{if(u)return te({chainId:o.map(d=>d.chainId),walletType:"cosmiframe"})});},[i]),react.useEffect(()=>{if(r){if(!p)return;e&&a?B({onError:n}):!e&&t&&B({onError:n});}},[p]),react.useEffect(()=>{var g,u,d,h,T,v,W,w,f,A,b,k,R,D,j,oe,y,S,C,E;if(r){if(!p)return;r==="cosmostation"&&((u=(g=le()).subscription)==null||u.call(g,()=>{B({onError:n});})),r==="keplr"&&((h=(d=ue()).subscription)==null||h.call(d,()=>{B({onError:n});})),r==="leap"&&((v=(T=pe()).subscription)==null||v.call(T,()=>{B({onError:n});})),r==="compass"&&((w=(W=ae()).subscription)==null||w.call(W,()=>{B({onError:n});})),r==="vectis"&&((A=(f=ge()).subscription)==null||A.call(f,()=>{B({onError:n});})),r==="walletconnect"&&c.has("walletconnect")&&((k=(b=G()).subscription)==null||k.call(b,()=>{B({onError:n});})),r==="station"&&((D=(R=fe()).subscription)==null||D.call(R,()=>{B({onError:n});})),r==="xdefi"&&((oe=(j=ye()).subscription)==null||oe.call(j,()=>{B({onError:n});})),r==="cosmiframe"&&((S=(y=ce()).subscription)==null||S.call(y,()=>{B({onError:n});})),r==="okx"&&((E=(C=de()).subscription)==null||E.call(C,()=>{B({onError:n});}));}},[r,c,p]),null},Wt=()=>(Sn(),null);var ya=({children:e,grazOptions:t})=>(react.useEffect(()=>{lt(t);},[t]),jsxRuntime.jsxs(Pt,{children:[e,jsxRuntime.jsx(Wt,{})]}));
24
+ var Nt=Object.defineProperty,Bt=Object.defineProperties;var Lt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Be=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Le=(e,t,n)=>t in e?Nt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))Ut.call(t,n)&&Le(e,n,t[n]);if(Ne)for(var n of Ne(t))Gt.call(t,n)&&Le(e,n,t[n]);return e},U=(e,t)=>Bt(e,Lt(t));var l=(e,t,n)=>new Promise((a,i)=>{var o=c=>{try{r(n.next(c));}catch(f){i(f);}},s=c=>{try{r(n.throw(c));}catch(f){i(f);}},r=c=>c.done?a(c.value):Promise.resolve(c.value).then(o,s);r((n=n.apply(e,t)).next());});var Ue=(e,t,n)=>(t=e[Be("asyncIterator")])?t.call(e):(e=e[Be("iterator")](),t={},n=(a,i)=>(i=e[a])&&(t[a]=o=>new Promise((s,r,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(f=>s({value:f,done:c}),r)))),n("next"),n("return"),t);var ee="graz-reconnect-session";var Ge=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p.PARA="para",p))(Ge||{}),Fe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var zt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:middleware.createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},C=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,qt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>zt,jt)));var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var 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 Ve={},He=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var m;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let r=(m=o.split("MetaMask/v")[1])==null?void 0:m.split(".")[0];if(!(Number(r)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,true}),enable:o=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(U(P({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,r)=>l(void 0,null,function*(){return t.signAmino(o,s,r)}),getKey:o=>l(void 0,null,function*(){return typeof Ve[o]!="undefined"?Ve[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,r)=>l(void 0,null,function*(){return t.signDirect(o,s,r)}),signArbitrary:(o,s,r)=>l(void 0,null,function*(){return t.signArbitrary(o,s,r)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{N(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Zt=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}=e;if(!t||!n||!a||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}},en=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Ye=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let T=(()=>{switch(S.algo){case "secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return amino.rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:en(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:T,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,T,M;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(T=g.gasPriceStep)==null?void 0:T.average,high_gas_price:(M=g.gasPriceStep)==null?void 0:M.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,T]=d;return e.getOfflineSigner(g).signDirect(S,Zt(T))},signAmino:(...d)=>{let[g,S,T]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,T)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let W=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!W)throw new Error(`Wallet not connected to account ${g}`);let O=(()=>{switch(W.algo){case "secp256k1":return amino.encodeSecp256k1Pubkey(W.pubkey);case "ed25519":return amino.encodeEd25519Pubkey(W.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:W.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:d=>{let g=()=>{N(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}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:i=>{let o=()=>{N(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var me={},Ze=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=p=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(b=>b.id===e.id&&(!p||b.version===p))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var R;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(R=p.split("MetaMask/v")[1])==null?void 0:R.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield i()),true}),s=p=>l(void 0,null,function*(){(yield a())||(yield i());}),r=(p,A,b)=>l(void 0,null,function*(){let k=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:b}}}}),K=b.accountNumber,R=new Ee__default.default(K.low,K.high,K.unsigned);return {signature:k.signature,signed:U(P({},k.signed),{accountNumber:`${R.toString()}`,authInfoBytes:new Uint8Array(Object.values(k.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(k.signed.bodyBytes))})}}),c=(p,A,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:b}}}})}),f=p=>l(void 0,null,function*(){if(typeof me[p]!="undefined")return me[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,me[p]=A,me[p]}),m=p=>l(void 0,null,function*(){let A=yield f(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[A,b,k,K]=p;return yield c(A,b,k)}),g=(...p)=>l(void 0,null,function*(){var Q;let[A,b,k]=p,K=U(P({},k),{accountNumber:Ee__default.default.fromString(((Q=k.accountNumber)==null?void 0:Q.toString())||"0"),authInfoBytes:k.authInfoBytes,bodyBytes:k.bodyBytes});return yield r(A,b,K)}),T=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signAmino:(A,b)=>d(p,A,b)});return {enable:s,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signDirect:(A,b)=>g(p,A,b),signAmino:(A,b)=>d(p,A,b)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return T(p)}),getOfflineSignerOnlyAmino:T,init:o,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var et=()=>Ze({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var r;let s=()=>{N(),o();};return (r=window.okxwallet)==null||r.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var tn="para.reconnect",ie=null,tt=()=>{let e=()=>{let i=C.getState().paraConnector;if(!i)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return i},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let n=()=>ie||(ie=l(void 0,null,function*(){let i=C.getState().paraConnector;if(i)return i;try{let o;if(t.connectorClass)o=t.connectorClass;else if(t.connectorImportPath){if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import(t.connectorImportPath),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector from dynamic URL/path. Ensure it exports `ParaGrazConnector`.");o=f;}else {if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import('@getpara/graz-integration'),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");o=f;}let s=u.getState().chains,r=new o(t,s);if(C.setState(c=>U(P({},c),{paraConnector:r})),!r)throw new Error("Para connector initialization failed. Check config and dependencies.");return r}catch(o){throw ie=null,new Error("Para connector init failed. Check @getpara/graz-integration and ParaConfig.")}}),ie);return {enable:i=>l(void 0,null,function*(){let o=Array.isArray(i)?i:[i];try{let s=yield n();C.setState({paraConnector:s,status:"connecting"}),yield s.enable(o);let r=Object.fromEntries(yield Promise.all(o.map(c=>l(void 0,null,function*(){return [c,yield s.getKey(c)]}))));C.setState(c=>({accounts:P(P({},c.accounts||{}),r),activeChainIds:Array.from(new Set([...c.activeChainIds||[],...o])),status:"connected"})),u.setState(c=>({recentChainIds:Array.from(new Set([...c.recentChainIds||[],...o])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"})),typeof window!="undefined"&&window.sessionStorage.setItem(tn,"1");}catch(s){throw C.setState({paraConnector:null,status:"disconnected"}),new Error(`Para enable failed${s instanceof Error?`: ${s.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let i=e();try{yield i.disconnect(),yield i.getParaWebClient().logout();}catch(o){throw new Error("Para disconnect failed. Wallet may already be disconnected.")}finally{C.setState({paraConnector:null,status:"disconnected"});}}),getKey:i=>l(void 0,null,function*(){try{return yield e().getKey(i)}catch(o){throw new Error("Failed to get key. Check chain connection and Cosmos API key settings at developer.getpara.com.")}}),getOfflineSigner:i=>{try{return e().getOfflineSigner(i)}catch(o){throw new Error("Failed to get offline signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerOnlyAmino:i=>{try{return e().getOfflineSignerOnlyAmino(i)}catch(o){throw new Error("Failed to get Amino signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerAuto:i=>{try{return e().getOfflineSignerAuto(i)}catch(o){throw new Error("Failed to get auto signer. Check Para auth and Cosmos support in developer portal.")}},signAmino:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signAmino(i,o,s,r)}catch(c){throw new Error("Amino signing failed. User rejected or invalid transaction/signer.")}}),signDirect:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signDirect(i,o,s,r)}catch(c){throw new Error("Direct signing failed. User rejected or invalid transaction/signer.")}}),signArbitrary:(i,o,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(i,o,s)}catch(r){throw new Error("Arbitrary signing failed. User rejected or feature not supported.")}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ge=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let r=()=>{N(),s();};return window.addEventListener("station_wallet_change",r),()=>{window.removeEventListener("station_wallet_change",r);}},getKey:s=>l(void 0,null,function*(){let r=yield t.getKey(s);return P({isKeystone:false},r)}),getOfflineSigner:s=>{try{let r=t.getOfflineSignerOnlyAmino(s);return Object.assign(r,{signDirect:(m,d)=>{throw new Error("signDirect not supported by Station")}})}catch(r){throw console.error(r),r}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let r=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,m,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((m=c.gasPriceStep)==null?void 0:m.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(r);}catch(r){throw console.error(r),r}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,r,c,f)=>t.signAmino(s,r,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ye=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:r=>e.enable(r),getOfflineSigner:r=>{let c=e.getOfflineSigner(r);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Ee__default.default.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:r=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(r);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Ee__default.default.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:r=>l(void 0,null,function*(){let c=yield e.getKey(r);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:r=>{let c=()=>{N(),r();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...r)=>{let c=r[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...r)=>l(void 0,null,function*(){var m;let[c]=r;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(m=c.bech32Config)==null?void 0:m.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...r)=>l(void 0,null,function*(){var d;let{1:c,2:f}=r,m=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Ee__default.default.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}}),signAmino:(...r)=>l(void 0,null,function*(){let{1:c,2:f}=r;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var F=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},nt=()=>F()&&navigator.userAgent.toLowerCase().includes("android"),ot=()=>F()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Te=(e,t,n=new Error("Promise timed out"))=>{let a=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,a])};var z=e=>{var R,Q,oe;if(!((oe=(Q=(R=u.getState().walletConnect)==null?void 0:R.options)==null?void 0:Q.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",a=y=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(F()){if(nt()){let E=h(w.mobile.android,y,"android");window.open(E,"_self","noreferrer noopener");}if(ot()){let E=h(w.mobile.ios,y,"ios");window.open(E,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=C.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),C.setState({wcSignClients:y}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield h.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=y=>{try{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let E=h.session.getAll(),v=E.at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw o(v.topic),new Error("invalid session");try{let D=E.find(j=>{var X,Y;return (Y=(X=j.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${y}`)});if(!D)throw new Error("no session");return D}catch(D){if(!D.message.toLowerCase().includes("no matching key"))throw D}return v}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},r=y=>{try{return s(y)}catch(w){return}},c=y=>l(void 0,null,function*(){try{let w=y.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=C.getState(),h=w.get(t);if(h)return h;let E=yield signClient.SignClient.init(y.options);return w.set(t,E),C.setState({wcSignClients:w}),E}),m=y=>{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)return ()=>{};let E=v=>{let x=C.getState().accounts;if(v.params.event.name==="accountsChanged"&&x&&!Object.values(x).map(D=>D.bech32Address).includes(v.params.event.data[0])){let D=v.params.chainId.split(":")[1];D&&d([D]);}else y();};return h.events.on("session_delete",i),h.events.on("session_expire",i),h.events.on("session_event",E),()=>{h.events.off("session_delete",i),h.events.off("session_expire",i),h.events.off("session_event",E);}},d=y=>l(void 0,null,function*(){var Y;let w=typeof y=="string"?[y]:y,{wcSignClients:h,activeChainIds:E}=C.getState(),v=h.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:x,chains:D}=u.getState();if(!((Y=x==null?void 0:x.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new modal.WalletConnectModal(P({projectId:x.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},x.walletConnectModal)),X=r(w);if(!X){let{uri:L,approval:se}=yield Te(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?a(L):yield j.openModal({uri:L});let ae=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,Z)=>{se().then(De=>{let _e=De.sessionProperties;if(!_e)return Z(new Error("No session properties"));let Oe=JSON.parse(String(_e.keys));if(Oe.length===0)return Z(new Error("No accounts"));if(!Oe[0])return Z(new Error("No accounts"));let Ke={};return Oe.forEach(V=>{Ke[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),C.setState(V=>({accounts:P(P({},V.accounts||{}),Ke)})),be(De)}).catch(Z),$.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:true});})});try{let $=new AbortController,be=$.signal;j.subscribeModal(Z=>{Z.open||$.abort();}),yield ae(be);}catch($){if(j.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||j.closeModal(),Promise.resolve()}try{yield Te(l(void 0,null,function*(){var se;let L=Object.fromEntries(yield Promise.all((se=E||w)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield S(ae)]}))));C.setState({accounts:L});}),15e3,new Error("Connection timeout"));}catch(L){if(o(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),g=y=>l(void 0,null,function*(){let w=yield S(y);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=y=>l(void 0,null,function*(){let w=s([y]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let E=h.find(v=>v.chainId===y);if(!E)throw new Error(`No wallet connect key for chainId ${y}`);return U(P({},E),{pubKey:Buffer.from(String(E.pubKey),n)})}),T=(...y)=>l(void 0,null,function*(){var Y,L;let[w,h,E]=y,{accounts:v,wcSignClients:x}=C.getState(),D=x.get(t);if(!D)throw new Error("walletConnect.signClient is not defined");if(!v)throw new Error("account is not defined");let j=(Y=s([w]))==null?void 0:Y.topic;if(!j)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield D.request({topic:j,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:E.chainId,accountNumber:(L=E.accountNumber)==null?void 0:L.toString(),bodyBytes:E.bodyBytes?Buffer.from(E.bodyBytes).toString(n):null,authInfoBytes:E.authInfoBytes?Buffer.from(E.authInfoBytes).toString(n):null}}}})}),M=(...y)=>l(void 0,null,function*(){var D;let[w,h,E]=y,{signature:v,signed:x}=yield T(w,h,E);return {signed:{chainId:(D=x.chainId)!=null?D:"",accountNumber:x.accountNumber?BigInt(x.accountNumber):BigInt(0),authInfoBytes:x.authInfoBytes?new Uint8Array(Buffer.from(x.authInfoBytes,n)):new Uint8Array([]),bodyBytes:x.bodyBytes?new Uint8Array(Buffer.from(x.bodyBytes,n)):new Uint8Array([])},signature:v}}),W=(...y)=>l(void 0,null,function*(){var L;let[w,h,E,v]=y,{wcSignClients:x}=C.getState(),D=x.get(t),{accounts:j}=C.getState();if(!D)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let X=(L=s([w]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return a(),yield D.request({topic:X,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:E}}})}),O=(...y)=>l(void 0,null,function*(){let[w,h,E,v]=y;return yield W(w,h,E)}),p=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>M(y,w,h)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signAmino:(w,h)=>O(y,w,h)});return {enable:d,disable:y=>l(void 0,null,function*(){var E;let{wcSignClients:w}=C.getState(),h=w.get(t);if(y===void 0){let v=h==null?void 0:h.session.getAll();v!==void 0&&(yield Promise.all(v.map(x=>o(x.topic))));}else typeof y=="string"?yield o((E=s([y]))==null?void 0:E.topic):yield Promise.all(y.map(v=>{var x;return o((x=s([v]))==null?void 0:x.topic)}));(h==null?void 0:h.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>M(y,w,h),signAmino:(w,h)=>O(y,w,h)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield S(y)).isNanoLedger?A(y):p(y)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:M,subscription:m,init:f}};var it=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return z(e)};var rt=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":","");return o?`${r}://wc?${o}`:`${r}://wc`}};return z(e)};var st=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${r}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return z(e)};var at=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!F())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${r}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return z(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let o=()=>{N(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var G=(e=u.getState().walletType)=>{try{return _(e),!0}catch(t){return false}},N=()=>{window.sessionStorage.removeItem(ee),C.setState(ne);},_=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return pe();case "leap":return de();case "cosmostation":return ue();case "vectis":return ye();case "walletconnect":return z();case "wc_keplr_mobile":return st();case "wc_leap_mobile":return at();case "wc_cosmostation_mobile":return rt();case "wc_clot_mobile":return it();case "metamask_snap_leap":return et();case "metamask_snap_cosmos":return He();case "station":return ge();case "xdefi":return Ce();case "cosmiframe":return le();case "compass":return ce();case "initia":return Ye();case "okx":return fe();case "para":return tt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((a=t.setDefaultOptions)==null||a.call(t,n)),t},$i=()=>Object.fromEntries(Fe.map(e=>[e,G(e)])),ct=e=>e==="metamask_snap_leap",lt=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),re=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",ut=e=>e==="para";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:r,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(re(f)){let O=_("walletconnect"),{disable:p}=O;p&&p();}if(!G(f))throw new Error(`${f} is not available`);let d=_(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=r==null?void 0:r.map(O=>O.chainId);g.forEach(O=>{if(!(S!=null&&S.includes(O)))throw new Error(`Chain ${O} is not provided in GrazProvider`)}),C.setState(O=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return O.activeChainIds&&g.filter(b=>{var k;return !((k=O.activeChainIds)!=null&&k.includes(b))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:T}=C.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!re(f)){let O={};if(ct(f)){let p={};try{for(var n=Ue(g),a,i,o;a=!(i=yield n.next()).done;a=!1){let A=i.value;p[A]=yield d.getKey(A);}}catch(i){o=[i];}finally{try{a&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}O=p;}else if(lt()&&d.getKeys){let p=yield d.getKeys(g);g.forEach((A,b)=>{let k=p[b];k&&(O[A]=k);});}else O=Object.fromEntries(yield Promise.all(g.map(p=>l(void 0,null,function*(){return [p,yield d.getKey(p)]}))));C.setState(p=>({accounts:P(P({},p.accounts||{}),O)}));}u.setState(O=>({recentChainIds:[...O.recentChainIds||[],...g].filter((p,A,b)=>b.indexOf(p)===A)})),C.setState(O=>({activeChainIds:[...O.activeChainIds||[],...g].filter((p,A,b)=>b.indexOf(p)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ee,"Active");let M=g.map(O=>r.find(p=>p.chainId===O));return {accounts:C.getState().accounts,walletType:f,chains:M}}catch(s){throw console.error("connect ",s),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),s}}),Pe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(ee);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,n=()=>{if(re(u.getState().walletType)){let a=_("walletconnect"),{disable:i}=a;i&&i();}if(ut(u.getState().walletType)){let a=_("para"),{disable:i}=a;i&&i();}};if(t){let a=C.getState().accounts;t.forEach(o=>{a==null||delete a[o];}),Object.values(a||{}).length===0?(n(),C.setState(ne),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(C.setState(o=>{var s;return {activeChainIds:(s=o.activeChainIds)==null?void 0:s.filter(r=>!t.includes(r)),accounts:a}}),u.setState(o=>{var s;return {recentChainIds:(s=o.recentChainIds)==null?void 0:s.filter(r=>!t.includes(r))}}));}else n(),C.setState(ne),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:a}=u.getState();try{let o=G(n||void 0);if(t&&o&&n)return re(n)?void 0:yield te({chainId:t,walletType:n,autoReconnect:a})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),Pe();}}),pt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!G(n))throw new Error(`${n} is not available`);let i=_(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),r=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:r}});var ke=()=>{u.setState({recentChainIds:null});},rr=()=>u.getState().recentChainIds,sr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(a=>t.find(i=>i.chainId===a)))!=null?n:null},ar=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},xe=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield _(t).experimentalSuggestChain(e),e}),dt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield xe({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var mt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var ft=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:a,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,a,i,o)}),gt=m=>l(void 0,[m],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:a,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:r,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,a,i,o,s,r,c,f)}),yt=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,a,i)}),Ct=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,a,s,o)}),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)}),St=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return n.queryContractRaw(e,a)};var wr=e=>e,Sr=e=>e;var ht=e=>e?Object.keys(e).length===0:true;var Me=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},At=e=>globalThis.DOMException===void 0?new Me(e):new DOMException(e),It=e=>{let t=e.reason===void 0?At("This operation was aborted."):e.reason;return t instanceof Error?t:At(t)};function ve(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:i}={}){return new Promise((r,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let f=[],m=[],d=new Map,g=false,S=false,T=false,M=0,W=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{g=true,S=true,c(b);};i&&(i.aborted&&p(It(i)),i.addEventListener("abort",()=>{p(It(i));}));let A=()=>l(this,null,function*(){if(S)return;let b=yield O.next(),k=W;if(W++,b.done){if(T=true,M===0&&!S){if(!a&&m.length>0){p(new AggregateError(m));return}if(S=true,d.size===0){r(f);return}let K=[];for(let[R,Q]of f.entries())d.get(R)!==bt&&K.push(Q);r(K);}return}M++,l(this,null,function*(){try{let K=yield b.value;if(S)return;let R=yield t(K,k);R===bt&&d.set(k,R),f[k]=R,M--,yield A();}catch(K){if(a)p(K);else {m.push(K),M--;try{yield A();}catch(R){p(R);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield A();}catch(k){p(k);break}if(T||g)break}});})})}var bt=Symbol("skip");var q=({chainId:e,multiChain:t})=>{let n=u(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!a):return [a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!a):return n;default:return [n[0]]}},H=(e,t,n)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let o=yield ve(t,n,{concurrency:a});return Object.fromEntries(o.map((s,r)=>[t[r].chainId,s]))}return yield n(t[0])}),Ot=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var We=e=>{let t=q({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:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:P({},(r==null?void 0:r.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},Re=e=>{let t=q({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:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:P({},(r==null?void 0:r.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var jr=()=>u(shallow.useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),we=e=>{let n=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return reactQuery.useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>G(i)})};var J=e=>{let t=u(r=>r.walletType),n=C(r=>r.activeChainIds),a=q({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=C(r=>r.accounts),o=C(r=>r.status);return react.useEffect(()=>C.subscribe(r=>r.status,(r,c)=>{var f,m,d;if(r==="connected"){let{accounts:g,activeChainIds:S}=C.getState(),{chains:T}=u.getState(),{walletType:M}=u.getState();if(!g||!S||!T)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(m=e==null?void 0:e.onConnect)==null||m.call(e,{accounts:g,chains:S.map(W=>T.find(O=>O.chainId===W)),walletType:M,isReconnect:c==="reconnecting"});}r==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:react.useMemo(()=>i?Ot(!!(e!=null&&e.multiChain),a,r=>i[r.chainId]):void 0,[i,a,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:B,status:o}},dn=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),a=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=We({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),o=react.useMemo(()=>["USE_ALL_BALANCES",i,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,i]);return reactQuery.useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var T;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((T=d.bech32Config)!=null&&T.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!ht(i)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},is=e=>{let t=q({chainId:e.chainId}),{data:n}=J({chainId:e.chainId}),a=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=dn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,a,e.chainId],r=reactQuery.useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(m=>m.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?true:e.enabled)});return U(P({},r),{refetch:c=>l(void 0,null,function*(){return yield o(),r.refetch(c)})})},rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:te,onError:(s,r)=>e==null?void 0:e(s,r),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=we();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:Pe,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},as=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),a=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chain found");if(!G(s))throw new Error(`${s} is not available`);return yield H(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield pt({chainId:m.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!n&&!!a,refetchOnWindowFocus:false})},cs=e=>{let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),{data:a}=We({chainId:t.map(s=>s.chainId),multiChain:true}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",a,t,i],[t,i,a]);return reactQuery.useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield H(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var S,T;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (T=s[d.chainId])==null?void 0:T.getBalanceStaked(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var ys=()=>C(e=>e.activeChainIds),mn=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let n=(a=u.getState().chains)==null?void 0:a.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},Cs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ss=({denom:e})=>{let t=mn();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(r=>r.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},hs=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},As=()=>({data:u(t=>t.recentChainIds),clear:ke}),Is=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let a=(i=u.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(a)return a}).filter(Boolean),clear:ke}},bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:xe,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},Os=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:dt,onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=we();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Ws=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=J(),i=a==null?void 0:a.bech32Address,o=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>ft(P({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=J(),i=a==null?void 0:a.bech32Address,o=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>gt(P({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Ds=({codeId:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=J(),o=i==null?void 0:i.bech32Address,r=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m;if(!o)throw new Error("senderAddress is undefined");let f=U(P({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,codeId:e});return yt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,instantiateContract:r.mutate,instantiateContractAsync:r.mutateAsync,status:r.status}},_s=({contractAddress:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=J(),o=i==null?void 0:i.bech32Address,r=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m,d,g;if(!o)throw new Error("senderAddress is undefined");let f=U(P({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,executeContract:r.mutate,executeContractAsync:r.mutateAsync,status:r.status}},Ks=e=>{let{data:t}=Re();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return wt(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ns=e=>{let{data:t}=Re(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return St(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Vs(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var W,O;if(!(a!=null&&a.includes(m.chainId)))return null;if(!G(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return _(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return _(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return _(r).getOfflineSignerOnlyAmino(m.chainId);default:return _(r).getOfflineSignerAuto(m.chainId)}}),S=(W=u.getState().chainsConfig)==null?void 0:W[m.chainId],T={url:m.rpc,headers:P({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(T,g,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:true)&&!!i,refetchOnWindowFocus:false})}function Hs(e){let t=q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield H(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var O,p;if(!(a!=null&&a.includes(m.chainId)))return null;if(!G(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return _(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return _(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return _(r).getOfflineSignerOnlyAmino(m.chainId);default:return _(r).getOfflineSignerAuto(m.chainId)}}),S=(O=u.getState().chainsConfig)==null?void 0:O[m.chainId],T={url:m.rpc,headers:P({},(S==null?void 0:S.rpcHeaders)||{})},M=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(T,g,P({gasPrice:M},e!=null&&e.multiChain?(p=e.opts)==null?void 0:p[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}var _t=({children:e})=>{let[t,n]=react.useState(false);return react.useEffect(()=>{n(true);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var In=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(ee)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:a,iframeOptions:i,chains:o,pingInterval:s}=u(),{activeChainIds:r,wcSignClients:c}=C(),f=G(a||void 0);return react.useEffect(()=>{let m=()=>l(void 0,null,function*(){if(e&&f&&a&&(r!=null&&r[0])){let d=C.getState().lastPing;if(d&&Date.now()-d<s)return;let g=_(a);try{if(!(yield g.getKey(r[0])))throw new Error("No account found");C.setState({lastPing:Date.now()});return}catch(S){B({onError:n});}}});return window.addEventListener("focus",m),()=>{window.removeEventListener("focus",m);}},[e,f,a,o,r,s]),react.useEffect(()=>{if(!i||i.autoConnect===false||!i.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(i.allowedIframeParentOrigins).isReady().then(d=>{if(d)return te({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[i]),react.useEffect(()=>{if(a){if(!f)return;e&&r?B({onError:n}):!e&&t&&B({onError:n});}},[f]),react.useEffect(()=>{var m,d,g,S,T,M,W,O,p,A,b,k,K,R,Q,oe,y,w,h,E;if(a){if(!f)return;a==="cosmostation"&&((d=(m=ue()).subscription)==null||d.call(m,()=>{B({onError:n});})),a==="keplr"&&((S=(g=pe()).subscription)==null||S.call(g,()=>{B({onError:n});})),a==="leap"&&((M=(T=de()).subscription)==null||M.call(T,()=>{B({onError:n});})),a==="compass"&&((O=(W=ce()).subscription)==null||O.call(W,()=>{B({onError:n});})),a==="vectis"&&((A=(p=ye()).subscription)==null||A.call(p,()=>{B({onError:n});})),a==="walletconnect"&&c.has("walletconnect")&&((k=(b=z()).subscription)==null||k.call(b,()=>{B({onError:n});})),a==="station"&&((R=(K=ge()).subscription)==null||R.call(K,()=>{B({onError:n});})),a==="xdefi"&&((oe=(Q=Ce()).subscription)==null||oe.call(Q,()=>{B({onError:n});})),a==="cosmiframe"&&((w=(y=le()).subscription)==null||w.call(y,()=>{B({onError:n});})),a==="okx"&&((E=(h=fe()).subscription)==null||E.call(h,()=>{B({onError:n});}));}},[a,c,f]),null},Kt=()=>(In(),null);var Ta=({children:e,grazOptions:t})=>(react.useEffect(()=>{mt(t);},[t]),jsxRuntime.jsxs(_t,{children:[e,jsxRuntime.jsx(Kt,{})]}));
25
25
 
26
- exports.GrazEvents = Wt;
27
- exports.GrazProvider = ya;
28
- exports.WALLET_TYPES = Ue;
29
- exports.WalletType = Le;
30
- exports.checkWallet = U;
26
+ exports.GrazEvents = Kt;
27
+ exports.GrazProvider = Ta;
28
+ exports.WALLET_TYPES = Fe;
29
+ exports.WalletType = Ge;
30
+ exports.checkWallet = G;
31
31
  exports.clearRecentChain = ke;
32
32
  exports.clearSession = N;
33
- exports.configureGraz = lt;
33
+ exports.configureGraz = mt;
34
34
  exports.connect = te;
35
- exports.defineChainInfo = lr;
36
- exports.defineChains = cr;
37
- exports.disconnect = Te;
38
- exports.executeContract = dt;
39
- exports.getAvailableWallets = Ni;
40
- exports.getChainInfo = Yi;
41
- exports.getChainInfos = Ji;
42
- exports.getCosmostation = le;
43
- exports.getKeplr = ue;
44
- exports.getLeap = pe;
45
- exports.getMetamaskSnapLeap = Je;
46
- exports.getOfflineSigners = at;
47
- exports.getQueryRaw = gt;
48
- exports.getQuerySmart = ft;
49
- exports.getRecentChainIds = Hi;
50
- exports.getRecentChains = Xi;
51
- exports.getVectis = ge;
52
- exports.getWCCosmostation = nt;
53
- exports.getWCKeplr = ot;
54
- exports.getWCLeap = it;
55
- exports.getWallet = K;
56
- exports.getWalletConnect = G;
57
- exports.instantiateContract = mt;
58
- exports.isLeapDappBrowser = st;
59
- exports.isLeapSnaps = rt;
60
- exports.isWalletConnect = ie;
35
+ exports.defineChainInfo = Sr;
36
+ exports.defineChains = wr;
37
+ exports.disconnect = Pe;
38
+ exports.executeContract = Ct;
39
+ exports.getAvailableWallets = $i;
40
+ exports.getChainInfo = ar;
41
+ exports.getChainInfos = cr;
42
+ exports.getCosmostation = ue;
43
+ exports.getKeplr = pe;
44
+ exports.getLeap = de;
45
+ exports.getMetamaskSnapLeap = et;
46
+ exports.getOfflineSigners = pt;
47
+ exports.getQueryRaw = St;
48
+ exports.getQuerySmart = wt;
49
+ exports.getRecentChainIds = rr;
50
+ exports.getRecentChains = sr;
51
+ exports.getVectis = ye;
52
+ exports.getWCCosmostation = rt;
53
+ exports.getWCKeplr = st;
54
+ exports.getWCLeap = at;
55
+ exports.getWallet = _;
56
+ exports.getWalletConnect = z;
57
+ exports.instantiateContract = yt;
58
+ exports.isLeapDappBrowser = lt;
59
+ exports.isLeapSnaps = ct;
60
+ exports.isPara = ut;
61
+ exports.isWalletConnect = re;
61
62
  exports.reconnect = B;
62
- exports.sendIbcTokens = pt;
63
- exports.sendTokens = ut;
64
- exports.suggestChain = Me;
65
- exports.suggestChainAndConnect = ct;
63
+ exports.sendIbcTokens = gt;
64
+ exports.sendTokens = ft;
65
+ exports.suggestChain = xe;
66
+ exports.suggestChainAndConnect = dt;
66
67
  exports.useAccount = J;
67
- exports.useActiveChainCurrency = ls;
68
- exports.useActiveChainIds = ss;
69
- exports.useActiveChains = cn;
70
- exports.useActiveWalletType = Rr;
71
- exports.useBalance = Vr;
72
- exports.useBalanceStaked = Jr;
73
- exports.useBalances = an;
74
- exports.useChainInfo = as;
75
- exports.useChainInfos = cs;
76
- exports.useCheckWallet = Se;
77
- exports.useConnect = Hr;
78
- exports.useCosmWasmClient = We;
79
- exports.useCosmWasmSigningClient = Ls;
80
- exports.useDisconnect = Xr;
81
- exports.useExecuteContract = Es;
82
- exports.useGrazEvents = Sn;
83
- exports.useInstantiateContract = Os;
84
- exports.useOfflineSigners = Yr;
85
- exports.useQueryClientValidators = us;
86
- exports.useQueryRaw = ks;
87
- exports.useQuerySmart = Ts;
88
- exports.useRecentChainIds = ps;
89
- exports.useRecentChains = ms;
90
- exports.useSendIbcTokens = bs;
91
- exports.useSendTokens = Is;
92
- exports.useStargateClient = Pe;
93
- exports.useStargateSigningClient = Bs;
94
- exports.useSuggestChain = ds;
95
- exports.useSuggestChainAndConnect = fs;
68
+ exports.useActiveChainCurrency = Ss;
69
+ exports.useActiveChainIds = ys;
70
+ exports.useActiveChains = mn;
71
+ exports.useActiveWalletType = jr;
72
+ exports.useBalance = is;
73
+ exports.useBalanceStaked = cs;
74
+ exports.useBalances = dn;
75
+ exports.useChainInfo = Cs;
76
+ exports.useChainInfos = ws;
77
+ exports.useCheckWallet = we;
78
+ exports.useConnect = rs;
79
+ exports.useCosmWasmClient = Re;
80
+ exports.useCosmWasmSigningClient = Hs;
81
+ exports.useDisconnect = ss;
82
+ exports.useExecuteContract = _s;
83
+ exports.useGrazEvents = In;
84
+ exports.useInstantiateContract = Ds;
85
+ exports.useOfflineSigners = as;
86
+ exports.useQueryClientValidators = hs;
87
+ exports.useQueryRaw = Ns;
88
+ exports.useQuerySmart = Ks;
89
+ exports.useRecentChainIds = As;
90
+ exports.useRecentChains = Is;
91
+ exports.useSendIbcTokens = Rs;
92
+ exports.useSendTokens = Ws;
93
+ exports.useStargateClient = We;
94
+ exports.useStargateSigningClient = Vs;
95
+ exports.useSuggestChain = bs;
96
+ exports.useSuggestChainAndConnect = Os;
package/dist/index.mjs CHANGED
@@ -2,8 +2,8 @@ import { create } from 'zustand';
2
2
  import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middleware';
3
3
  import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
4
4
  import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
5
- import { rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress, encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType } from '@cosmjs/amino';
6
- import Ee from 'long';
5
+ import { encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType, rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino';
6
+ import Te from 'long';
7
7
  import { fromBech32, toBech32 } from '@cosmjs/encoding';
8
8
  import { SignClient } from '@walletconnect/sign-client';
9
9
  import { getSdkError } from '@walletconnect/utils';
@@ -15,6 +15,6 @@ import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargat
15
15
  import { useShallow } from 'zustand/shallow';
16
16
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
17
17
 
18
- var _t=Object.defineProperty,Rt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var Be=(e,t,n)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))Nt.call(t,n)&&Be(e,n,t[n]);if(Ne)for(var n of Ne(t))Bt.call(t,n)&&Be(e,n,t[n]);return e},q=(e,t)=>Rt(e,Kt(t));var l=(e,t,n)=>new Promise((r,i)=>{var o=c=>{try{a(n.next(c));}catch(p){i(p);}},s=c=>{try{a(n.throw(c));}catch(p){i(p);}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());}),Le=(e,t,n)=>(t=e[Symbol.asyncIterator],n=(r,i)=>(i=e[r])&&(t[r]=o=>new Promise((s,a,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(p=>s({value:p,done:c}),a)))),t?t.call(e):(e=e[Symbol.iterator](),t={},n("next"),n("return"),t));var te="graz-reconnect-session";var Ue=(w=>(w.KEPLR="keplr",w.LEAP="leap",w.VECTIS="vectis",w.COSMOSTATION="cosmostation",w.WALLETCONNECT="walletconnect",w.WC_KEPLR_MOBILE="wc_keplr_mobile",w.WC_LEAP_MOBILE="wc_leap_mobile",w.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",w.WC_CLOT_MOBILE="wc_clot_mobile",w.METAMASK_SNAP_LEAP="metamask_snap_leap",w.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",w.STATION="station",w.XDEFI="xdefi",w.COSMIFRAME="cosmiframe",w.COMPASS="compass",w.INITIA="initia",w.OKX="okx",w))(Ue||{}),Fe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Ut={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},oe={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map},Ft={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing}),storage:createJSONStorage(()=>sessionStorage)},qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},I=create(subscribeWithSelector(persist(()=>oe,Ft))),m=create(subscribeWithSelector(persist(()=>Ut,qt)));var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw m.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=m.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 $e={},Ve=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var g;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(g=o.split("MetaMask/v")[1])==null?void 0:g.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:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(q(x({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,a)=>l(void 0,null,function*(){return t.signAmino(o,s,a)}),getKey:o=>l(void 0,null,function*(){return typeof $e[o]!="undefined"?$e[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,a)=>l(void 0,null,function*(){return t.signDirect(o,s,a)}),signArbitrary:(o,s,a)=>l(void 0,null,function*(){return t.signArbitrary(o,s,a)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw m.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{B(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw m.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var Xt=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:r,accountNumber:i}=e;if(!t||!n||!r||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:r,accountNumber:i}},Yt=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Xe=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:u=>l(void 0,null,function*(){let d=e.getOfflineSigner(u),[h]=yield d.getAccounts();if(!h)throw new Error("Wallet connection failed");let k=(()=>{switch(h.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(h.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:Yt(h.address),algo:h.algo,pubKey:h.pubkey,bech32Address:h.address,address:k,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:u=>{let d=e.getOfflineSigner(u),h=e.getOfflineSignerOnlyAmino(u);return {getAccounts:d.getAccounts.bind(d),signDirect:d.signDirect.bind(d),signAmino:h.signAmino.bind(h)}},getOfflineSignerAuto:u=>Promise.resolve(e.getOfflineSigner(u)),getOfflineSignerOnlyAmino:u=>e.getOfflineSignerOnlyAmino(u),experimentalSuggestChain:u=>e.requestAddInitiaLayer({chain_id:u.chainId,chain_name:u.chainName,bech32_prefix:"init",bech32_config:u.bech32Config,slip44:u.bip44.coinType,logo_URIs:{png:u.chainSymbolImageUrl},fees:{fee_tokens:u.feeCurrencies.map(d=>{var h,k,P;return {denom:d.coinDenom,amount:d.coinMinimalDenom,low_gas_price:(h=d.gasPriceStep)==null?void 0:h.low,average_gas_price:(k=d.gasPriceStep)==null?void 0:k.average,high_gas_price:(P=d.gasPriceStep)==null?void 0:P.high}})},apis:{rpc:[{address:u.rpc}],rest:[{address:u.rest}]}}),signDirect:(...u)=>{let[d,h,k]=u;return e.getOfflineSigner(d).signDirect(h,Xt(k))},signAmino:(...u)=>{let[d,h,k]=u;return e.getOfflineSignerOnlyAmino(d).signAmino(h,k)},signArbitrary:(u,d,h)=>l(void 0,null,function*(){let D=(yield e.getOfflineSigner(u).getAccounts()).find(A=>A.address===d);if(!D)throw new Error(`Wallet not connected to account ${d}`);let w=(()=>{switch(D.algo){case"secp256k1":return encodeSecp256k1Pubkey(D.pubkey);case"ed25519":return encodeEd25519Pubkey(D.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(h),pub_key:{type:D.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:w.value}}}),subscription:u=>{let d=()=>{B(),u();};return window.addEventListener("initia_keystorechange",d),()=>{window.removeEventListener("initia_keystorechange",d);}}}}throw m.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:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw m.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw m.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},Je=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),r=f=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(b=>b.id===e.id&&(!f||b.version===f))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var _;let f=yield t.request({method:"web3_clientVersion"});if(!f.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(_=f.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield r())||(yield i()),!0}),s=f=>l(void 0,null,function*(){(yield r())||(yield i());}),a=(f,A,b)=>l(void 0,null,function*(){let M=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:A,signDoc:b}}}}),K=b.accountNumber,_=new Ee(K.low,K.high,K.unsigned);return {signature:M.signature,signed:q(x({},M.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(M.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(M.signed.bodyBytes))})}}),c=(f,A,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:A,signDoc:b}}}})}),p=f=>l(void 0,null,function*(){if(typeof de[f]!="undefined")return de[f];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,de[f]=A,de[f]}),g=f=>l(void 0,null,function*(){let A=yield p(f);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),u=(...f)=>l(void 0,null,function*(){let[A,b,M,K]=f;return yield c(A,b,M)}),d=(...f)=>l(void 0,null,function*(){var $;let[A,b,M]=f,K=q(x({},M),{accountNumber:Ee.fromString((($=M.accountNumber)==null?void 0:$.toString())||"0"),authInfoBytes:M.authInfoBytes,bodyBytes:M.bodyBytes});return yield a(A,b,K)}),k=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(f)]}),signAmino:(A,b)=>u(f,A,b)});return {enable:s,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:p,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(f)]}),signDirect:(A,b)=>d(f,A,b),signAmino:(A,b)=>u(f,A,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return k(f)}),getOfflineSignerOnlyAmino:k,init:o,signAmino:u,signDirect:d}}throw m.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Ze=()=>Je({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var a;let s=()=>{B(),o();};return (a=window.okxwallet)==null||a.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw m.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ge=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let a=()=>{B(),s();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:s=>l(void 0,null,function*(){let a=yield t.getKey(s);return x({isKeystone:!1},a)}),getOfflineSigner:s=>{try{let a=t.getOfflineSignerOnlyAmino(s);return Object.assign(a,{signDirect:(g,u)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var p,g,u;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((p=c.gasPriceStep)==null?void 0:p.average)||0,high:((g=c.gasPriceStep)==null?void 0:g.high)||0,low:((u=c.gasPriceStep)==null?void 0:u.low)||0}}})});yield t.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,a,c,p)=>t.signAmino(s,a,c)}}throw m.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=>{let c=e.getOfflineSigner(a);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(p,g)=>l(void 0,null,function*(){var d;let u=yield c.signDirect(p,{accountNumber:Ee.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),authInfoBytes:g.authInfoBytes,bodyBytes:g.bodyBytes,chainId:g.chainId||""});return {signature:u.signature,signed:{authInfoBytes:u.signed.authInfoBytes,bodyBytes:u.signed.bodyBytes,chainId:u.signed.chainId,accountNumber:BigInt(u.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:a=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(a);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(p,g)=>l(void 0,null,function*(){var d;let u=yield c.signDirect(p,{accountNumber:Ee.fromString(((d=g.accountNumber)==null?void 0:d.toString())||"",!1),authInfoBytes:g.authInfoBytes,bodyBytes:g.bodyBytes,chainId:g.chainId||""});return {signature:u.signature,signed:{authInfoBytes:u.signed.authInfoBytes,bodyBytes:u.signed.bodyBytes,chainId:u.signed.chainId,accountNumber:BigInt(u.signed.accountNumber.toString())}}})}:c}),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{B(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>{let c=a[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...a)=>l(void 0,null,function*(){var g;let[c]=a;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let p={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(g=c.bech32Config)==null?void 0:g.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([p])}),signDirect:(...a)=>l(void 0,null,function*(){var u;let{1:c,2:p}=a,g=yield e.signDirect(c,{bodyBytes:p.bodyBytes||Uint8Array.from([]),authInfoBytes:p.authInfoBytes||Uint8Array.from([]),accountNumber:Ee.fromString(((u=p.accountNumber)==null?void 0:u.toString())||"",!1),chainId:p.chainId||""});return {signature:g.signature,signed:{authInfoBytes:g.signed.authInfoBytes,bodyBytes:g.signed.bodyBytes,chainId:g.signed.chainId,accountNumber:BigInt(g.signed.accountNumber.toString())}}}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:p}=a;return e.signAmino(c,p)})}}throw m.getState()._notFoundFn(),new Error("window.vectis is not defined")};var G=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},et=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),tt=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Te=(e,t,n=new Error("Promise timed out"))=>{let r=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,r])};var z=e=>{var _,$,ie;if(!((ie=($=(_=m.getState().walletConnect)==null?void 0:_.options)==null?void 0:$.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",r=y=>{if(!e)return;let{appUrl:S,formatNativeUrl:C}=e;if(G()){if(et()){let T=C(S.mobile.android,y,"android");window.open(T,"_self","noreferrer noopener");}if(tt()){let T=C(S.mobile.ios,y,"ios");window.open(T,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=I.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),I.setState({wcSignClients:y}),m.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=I.getState(),C=S.get(t);if(!C)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield C.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(C);}),s=y=>{try{let{wcSignClients:S}=I.getState(),C=S.get(t);if(!C)throw new Error("walletConnect.signClient is not defined");let T=C.session.getAll(),W=T.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let R=T.find(j=>{var Y,J;return (J=(Y=j.requiredNamespaces.cosmos)==null?void 0:Y.chains)==null?void 0:J.includes(`cosmos:${y}`)});if(!R)throw new Error("no session");return R}catch(R){if(!R.message.toLowerCase().includes("no matching key"))throw R}return W}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(C=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(C.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),p=()=>l(void 0,null,function*(){let{walletConnect:y}=m.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:S}=I.getState(),C=S.get(t);if(C)return C;let T=yield SignClient.init(y.options);return S.set(t,T),I.setState({wcSignClients:S}),T}),g=y=>{let{wcSignClients:S}=I.getState(),C=S.get(t);if(!C)return ()=>{};let T=W=>{let v=I.getState().accounts;if(W.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(R=>R.bech32Address).includes(W.params.event.data[0])){let R=W.params.chainId.split(":")[1];R&&u([R]);}else y();};return C.events.on("session_delete",i),C.events.on("session_expire",i),C.events.on("session_event",T),()=>{C.events.off("session_delete",i),C.events.off("session_expire",i),C.events.off("session_event",T);}},u=y=>l(void 0,null,function*(){var J;let S=typeof y=="string"?[y]:y,{wcSignClients:C,activeChainIds:T}=I.getState(),W=C.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:v,chains:R}=m.getState();if(!((J=v==null?void 0:v.options)!=null&&J.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new WalletConnectModal(x({projectId:v.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},v.walletConnectModal)),Y=a(S);if(!Y){let{uri:U,approval:se}=yield Te(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?r(U):yield j.openModal({uri:U});let ae=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,ee)=>{se().then(_e=>{let Re=_e.sessionProperties;if(!Re)return ee(new Error("No session properties"));let Oe=JSON.parse(String(Re.keys));if(Oe.length===0)return ee(new Error("No accounts"));if(!Oe[0])return ee(new Error("No accounts"));let Ke={};return Oe.forEach(H=>{Ke[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),I.setState(H=>({accounts:x(x({},H.accounts||{}),Ke)})),be(_e)}).catch(ee),V.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let V=new AbortController,be=V.signal;j.subscribeModal(ee=>{ee.open||V.abort();}),yield ae(be);}catch(V){if(j.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||j.closeModal(),Promise.resolve()}try{yield Te((()=>l(void 0,null,function*(){var se;let U=Object.fromEntries(yield Promise.all((se=T||S)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield h(ae)]}))));I.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(o(Y.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),d=y=>l(void 0,null,function*(){let S=yield h(y);return {address:S.bech32Address,algo:S.algo,pubkey:S.pubKey}}),h=y=>l(void 0,null,function*(){let S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let C=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys));if(!C)throw new Error("No wallet connect key");if(C.length===0)throw new Error("No wallet connect session");let T=C.find(W=>W.chainId===y);if(!T)throw new Error(`No wallet connect key for chainId ${y}`);return q(x({},T),{pubKey:Buffer.from(String(T.pubKey),n)})}),k=(...y)=>l(void 0,null,function*(){var J,U;let[S,C,T]=y,{accounts:W,wcSignClients:v}=I.getState(),R=v.get(t);if(!R)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let j=(J=s([S]))==null?void 0:J.topic;if(!j)throw new Error("No wallet connect session");if(!T.bodyBytes)throw new Error("No bodyBytes");if(!T.authInfoBytes)throw new Error("No authInfoBytes");return r(),yield R.request({topic:j,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:C,signDoc:{chainId:T.chainId,accountNumber:(U=T.accountNumber)==null?void 0:U.toString(),bodyBytes:T.bodyBytes?Buffer.from(T.bodyBytes).toString(n):null,authInfoBytes:T.authInfoBytes?Buffer.from(T.authInfoBytes).toString(n):null}}}})}),P=(...y)=>l(void 0,null,function*(){var R;let[S,C,T]=y,{signature:W,signed:v}=yield k(S,C,T);return {signed:{chainId:(R=v.chainId)!=null?R:"",accountNumber:v.accountNumber?BigInt(v.accountNumber):BigInt(0),authInfoBytes:v.authInfoBytes?new Uint8Array(Buffer.from(v.authInfoBytes,n)):new Uint8Array([]),bodyBytes:v.bodyBytes?new Uint8Array(Buffer.from(v.bodyBytes,n)):new Uint8Array([])},signature:W}}),D=(...y)=>l(void 0,null,function*(){var U;let[S,C,T,W]=y,{wcSignClients:v}=I.getState(),R=v.get(t),{accounts:j}=I.getState();if(!R)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let Y=(U=s([S]))==null?void 0:U.topic;if(!Y)throw new Error("No wallet connect session");return r(),yield R.request({topic:Y,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:C,signDoc:T}}})}),w=(...y)=>l(void 0,null,function*(){let[S,C,T,W]=y;return yield D(S,C,T)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,C)=>P(y,S,C)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signAmino:(S,C)=>w(y,S,C)});return {enable:u,disable:y=>l(void 0,null,function*(){var T;let{wcSignClients:S}=I.getState(),C=S.get(t);if(y===void 0){let W=C==null?void 0:C.session.getAll();W!==void 0&&(yield Promise.all(W.map(v=>o(v.topic))));}else typeof y=="string"?yield o((T=s([y]))==null?void 0:T.topic):yield Promise.all(y.map(W=>{var v;return o((v=s([W]))==null?void 0:v.topic)}));(C==null?void 0:C.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:h,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield d(y)]}),signDirect:(S,C)=>P(y,S,C),signAmino:(S,C)=>w(y,S,C)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield h(y)).isNanoLedger?A(y):f(y)}),getOfflineSignerOnlyAmino:A,signAmino:w,signDirect:P,subscription:g,init:p}};var nt=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return z(e)};var ot=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":","");return o?`${a}://wc?${o}`:`${a}://wc`}};return z(e)};var it=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${a}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return z(e)};var rt=()=>{var t,n,r;if(!((r=(n=(t=m.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&r.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,o,s)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${a}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return z(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:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw m.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var F=(e=m.getState().walletType)=>{try{return N(e),!0}catch(t){return !1}},B=()=>{window.sessionStorage.removeItem(te),I.setState(oe);},N=(e=m.getState().walletType)=>{var r;let t=(()=>{switch(e){case"keplr":return pe();case"leap":return me();case"cosmostation":return ue();case"vectis":return ye();case"walletconnect":return z();case"wc_keplr_mobile":return it();case"wc_leap_mobile":return rt();case"wc_cosmostation_mobile":return ot();case"wc_clot_mobile":return nt();case"metamask_snap_leap":return Ze();case"metamask_snap_cosmos":return Ve();case"station":return ge();case"xdefi":return Se();case"cosmiframe":return le();case"compass":return ce();case"initia":return Xe();case"okx":return fe();default:throw new Error("Unknown wallet type")}})(),n=m.getState().walletDefaultOptions;return n&&((r=t.setDefaultOptions)==null||r.call(t,n)),t},Bi=()=>Object.fromEntries(Fe.map(e=>[e,F(e)])),st=e=>e==="metamask_snap_leap",at=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),re=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var ne=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:a,walletType:c}=m.getState(),p=(e==null?void 0:e.walletType)||c;if(re(p)){let w=N("walletconnect"),{disable:f}=w;f&&f();}if(!F(p))throw new Error(`${p} is not available`);let u=N(p),d=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!d)throw new Error("No last known connected chain, connect action requires chain ids");let h=a==null?void 0:a.map(w=>w.chainId);d.forEach(w=>{if(!(h!=null&&h.includes(w)))throw new Error(`Chain ${w} is not provided in GrazProvider`)}),I.setState(w=>{let f=m.getState()._reconnect||!!m.getState()._reconnectConnector||!!d;return w.activeChainIds&&d.filter(b=>{var M;return !((M=w.activeChainIds)!=null&&M.includes(b))}).length>0?{status:"connecting"}:f?{status:"reconnecting"}:{status:"connecting"}});let{accounts:k}=I.getState();if(yield (t=u.init)==null?void 0:t.call(u),yield u.enable(d),!re(p)){let w={};if(st(p)){let f={};try{for(var n=Le(d),r,i,o;r=!(i=yield n.next()).done;r=!1){let A=i.value;f[A]=yield u.getKey(A);}}catch(i){o=[i];}finally{try{r&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}w=f;}else if(at()&&u.getKeys){let f=yield u.getKeys(d);d.forEach((A,b)=>{let M=f[b];M&&(w[A]=M);});}else w=Object.fromEntries(yield Promise.all(d.map(f=>l(void 0,null,function*(){return [f,yield u.getKey(f)]}))));I.setState(f=>({accounts:x(x({},f.accounts||{}),w)}));}m.setState(w=>({recentChainIds:[...w.recentChainIds||[],...d].filter((f,A,b)=>b.indexOf(f)===A)})),I.setState(w=>({activeChainIds:[...w.activeChainIds||[],...d].filter((f,A,b)=>b.indexOf(f)===A)})),m.setState({walletType:p,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:p}),I.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(te,"Active");let P=d.map(w=>a.find(f=>f.chainId===w));return {accounts:I.getState().accounts,walletType:p,chains:P}}catch(s){throw console.error("connect ",s),I.getState().accounts===null&&I.setState({status:"disconnected"}),I.getState().accounts&&I.getState().activeChainIds&&I.setState({status:"connected"}),s}}),ke=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(te);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(re(m.getState().walletType)){let n=N("walletconnect"),{disable:r}=n;r&&r();}if(t){let n=I.getState().accounts;t.forEach(i=>{n==null||delete n[i];}),Object.values(n||{}).length===0?(I.setState(oe),m.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(I.setState(i=>{var o;return {activeChainIds:(o=i.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),m.setState(i=>{var o;return {recentChainIds:(o=i.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else I.setState(oe),m.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:r}=m.getState();try{let o=F(n||void 0);if(t&&o&&n)return re(n)?void 0:yield ne({chainId:t,walletType:n,autoReconnect:r})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),ke();}}),ct=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=m.getState(),n=e.walletType||t;if(!F(n))throw new Error(`${n} is not available`);let i=N(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),a=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Me=()=>{m.setState({recentChainIds:null});},Xi=()=>m.getState().recentChainIds,Yi=()=>{var n;let{recentChainIds:e,chains:t}=m.getState();return (n=e==null?void 0:e.map(r=>t.find(i=>i.chainId===r)))!=null?n:null},Ji=({chainId:e})=>{var t;return (t=m.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Zi=({chainId:e})=>{var t;return (t=m.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},xe=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield N(t).experimentalSuggestChain(e),e}),lt=e=>l(void 0,null,function*(){var r;let t=m.getState().walletType;return yield xe({chainInfo:e.chainInfo,walletType:(r=e.walletType)!=null?r:t}),yield ne({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ut=e=>(m.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var pt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:r,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,r,i,o)}),mt=g=>l(void 0,[g],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:r,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:p}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,r,i,o,s,a,c,p)}),dt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:r,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,r,i)}),ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:r,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,r,s,o)}),gt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),yt=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.queryContractRaw(e,r)};var lr=e=>e,ur=e=>e;var St=e=>e?Object.keys(e).length===0:!0;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},wt=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),Ct=e=>{let t=e.reason===void 0?wt("This operation was aborted."):e.reason;return t instanceof Error?t:wt(t)};function Pe(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:r=!0,signal:i}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let p=[],g=[],u=new Map,d=!1,h=!1,k=!1,P=0,D=0,w=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{d=!0,h=!0,c(b);};i&&(i.aborted&&f(Ct(i)),i.addEventListener("abort",()=>{f(Ct(i));}));let A=()=>l(this,null,function*(){if(h)return;let b=yield w.next(),M=D;if(D++,b.done){if(k=!0,P===0&&!h){if(!r&&g.length>0){f(new AggregateError(g));return}if(h=!0,u.size===0){a(p);return}let K=[];for(let[_,$]of p.entries())u.get(_)!==ht&&K.push($);a(K);}return}P++,l(this,null,function*(){try{let K=yield b.value;if(h)return;let _=yield t(K,M);_===ht&&u.set(M,_),p[M]=_,P--,yield A();}catch(K){if(r)f(K);else {g.push(K),P--;try{yield A();}catch(_){f(_);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield A();}catch(M){f(M);break}if(k||d)break}});})})}var ht=Symbol("skip");var Q=({chainId:e,multiChain:t})=>{let n=m(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let r=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!r):return r.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!r):return [r.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!r):return n;default:return [n[0]]}},X=(e,t,n)=>l(void 0,null,function*(){let r=m.getState().multiChainFetchConcurrency;if(e){let o=yield Pe(t,n,{concurrency:r});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),At=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var We=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),r,s=>l(void 0,null,function*(){var g;let a=(g=m.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},De=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,r]}){if(r.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),r,s=>l(void 0,null,function*(){var g;let a=(g=m.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})};var Kr=()=>m(useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),we=e=>{let n=["USE_CHECK_WALLET",m(i=>e||i.walletType)];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>F(i)})};var Z=e=>{let t=m(a=>a.walletType),n=I(a=>a.activeChainIds),r=Q({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=I(a=>a.accounts),o=I(a=>a.status);return useEffect(()=>I.subscribe(a=>a.status,(a,c)=>{var p,g,u;if(a==="connected"){let{accounts:d,activeChainIds:h}=I.getState(),{chains:k}=m.getState(),{walletType:P}=m.getState();if(!d||!h||!k)return (p=e==null?void 0:e.onDisconnect)==null?void 0:p.call(e);(g=e==null?void 0:e.onConnect)==null||g.call(e,{accounts:d,chains:h.map(D=>k.find(w=>w.chainId===D)),walletType:P,isReconnect:c==="reconnecting"});}a==="disconnected"&&((u=e==null?void 0:e.onDisconnect)==null||u.call(e));}),[e]),{data:useMemo(()=>i?At(!!(e!=null&&e.multiChain),r,a=>i[a.chainId]):void 0,[i,r,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:L,status:o}},cn=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=We({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!r}),o=useMemo(()=>["USE_ALL_BALANCES",i,t,r,e==null?void 0:e.chainId],[r,e==null?void 0:e.chainId,t,i]);return useQuery({queryKey:o,queryFn:p=>l(void 0,[p],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),a,u=>l(void 0,null,function*(){var k;let d=s==null?void 0:s[u.chainId];if(!d)throw new Error(`Client is not ready ${u.chainId}`);if(!((k=u.bech32Config)!=null&&k.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${u.chainId}`);return yield d.getAllBalances(toBech32(u.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!St(i)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Hr=e=>{let t=Q({chainId:e.chainId}),{data:n}=Z({chainId:e.chainId}),r=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=cn({chainId:t.map(c=>c.chainId),bech32Address:r,enabled:!!r&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,r,e.chainId],a=useQuery({queryKey:s,queryFn:({queryKey:[,c,p]})=>p==null?void 0:p.find(g=>g.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?!0:e.enabled)});return q(x({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:ne,onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=we();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},Yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:ke,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},Jr=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=m(i=>i.walletType),r=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:r,queryFn:s=>l(void 0,[s],function*({queryKey:[,i,o]}){if(i.length<1)throw new Error("No chain found");if(!F(o))throw new Error(`${o} is not available`);return yield X(!!(e!=null&&e.multiChain),i,p=>l(void 0,null,function*(){return yield ct({chainId:p.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Zr=e=>{let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),{data:r}=We({chainId:t.map(s=>s.chainId),multiChain:!0}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",r,t,i],[t,i,r]);return useQuery({queryKey:o,queryFn:p=>l(void 0,[p],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),a,u=>l(void 0,null,function*(){var h,k;if(!s)throw new Error("Client is not ready");if(!((h=u.bech32Config)!=null&&h.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${u.chainId}`);return yield (k=s[u.chainId])==null?void 0:k.getBalanceStaked(toBech32(u.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!r,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var as=()=>I(e=>e.activeChainIds),ln=()=>{var e;return (e=I(t=>t.activeChainIds))==null?void 0:e.map(t=>{var r;let n=(r=m.getState().chains)==null?void 0:r.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},cs=({chainId:e})=>{var t;return (t=m().chains)==null?void 0:t.find(n=>n.chainId===e)},ls=({chainId:e})=>{var t;return (t=m().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},us=({denom:e})=>{let t=ln();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},ps=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:n,queryFn:a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},ms=()=>({data:m(t=>t.recentChainIds),clear:Me}),ds=()=>{var t;return {data:(t=m(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let r=(i=m.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(r)return r}).filter(Boolean),clear:Me}},fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:xe,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},gs=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:lt,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:o}=we();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=Z(),i=r==null?void 0:r.bech32Address,o=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>pt(x({senderAddress:i},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:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Os=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=Z(),i=r==null?void 0:r.bech32Address,o=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>mt(x({senderAddress:i},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:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Es=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,a=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,r,e,o],mutationFn:c=>{var g;if(!o)throw new Error("senderAddress is undefined");let p=q(x({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,codeId:e});return dt(p)},onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Ts=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,a=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,r,e,o],mutationFn:c=>{var g,u,d;if(!o)throw new Error("senderAddress is undefined");let p=q(x({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,contractAddress:e,memo:(u=c.memo)!=null?u:"",funds:(d=c.funds)!=null?d:[]});return ft(p)},onError:(c,p)=>Promise.resolve(t==null?void 0:t(c,p)),onMutate:n,onSuccess:c=>Promise.resolve(r==null?void 0:r(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ks=e=>{let{data:t}=De();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return gt(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ms=e=>{let{data:t}=De(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return yt(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Ls(e){let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=m(o=>o.walletType),r=I(o=>o.activeChainIds),i=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,r],[r,e,t,n]);return useQuery({queryKey:i,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var P,D;if(!(r!=null&&r.includes(p.chainId)))return null;if(!F(s))throw new Error(`${s} is not available`);let u=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return N(s).getOfflineSigner(p.chainId);case"offlineSignerAuto":return N(s).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return N(s).getOfflineSignerOnlyAmino(p.chainId);default:return N(s).getOfflineSignerAuto(p.chainId)}}))(),d=(P=m.getState().chainsConfig)==null?void 0:P[p.chainId],h={url:p.rpc,headers:x({},(d==null?void 0:d.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(h,u,e!=null&&e.multiChain?(D=e.opts)==null?void 0:D[p.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Us(e){let t=Q({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=m(o=>o.walletType),r=I(o=>o.activeChainIds),i=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,r],[r,e,t,n]);return useQuery({queryKey:i,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),o,p=>l(this,null,function*(){var D,w;if(!(r!=null&&r.includes(p.chainId)))return null;if(!F(s))throw new Error(`${s} is not available`);let u=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return N(s).getOfflineSigner(p.chainId);case"offlineSignerAuto":return N(s).getOfflineSignerAuto(p.chainId);case"offlineSignerOnlyAmino":return N(s).getOfflineSignerOnlyAmino(p.chainId);default:return N(s).getOfflineSignerAuto(p.chainId)}}))(),d=(D=m.getState().chainsConfig)==null?void 0:D[p.chainId],h={url:p.rpc,headers:x({},(d==null?void 0:d.rpcHeaders)||{})},k=d!=null&&d.gas?GasPrice.fromString(`${d.gas.price}${d.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(h,u,x({gasPrice:k},e!=null&&e.multiChain?(w=e.opts)==null?void 0:w[p.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Wt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var wn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(te)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:r,iframeOptions:i,chains:o,pingInterval:s}=m(),{activeChainIds:a,wcSignClients:c}=I(),p=F(r||void 0);return useEffect(()=>{let g=()=>l(void 0,null,function*(){if(e&&p&&r&&(a!=null&&a[0])){let u=I.getState().lastPing;if(u&&Date.now()-u<s)return;let d=N(r);try{if(!(yield d.getKey(a[0])))throw new Error("No account found");I.setState({lastPing:Date.now()});return}catch(h){L({onError:n});}}});return window.addEventListener("focus",g),()=>{window.removeEventListener("focus",g);}},[e,p,r,o,a,s]),useEffect(()=>{if(!i||i.autoConnect===!1||!i.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(i.allowedIframeParentOrigins).isReady().then(u=>{if(u)return ne({chainId:o.map(d=>d.chainId),walletType:"cosmiframe"})});},[i]),useEffect(()=>{if(r){if(!p)return;e&&a?L({onError:n}):!e&&t&&L({onError:n});}},[p]),useEffect(()=>{var g,u,d,h,k,P,D,w,f,A,b,M,K,_,$,ie,y,S,C,T;if(r){if(!p)return;r==="cosmostation"&&((u=(g=ue()).subscription)==null||u.call(g,()=>{L({onError:n});})),r==="keplr"&&((h=(d=pe()).subscription)==null||h.call(d,()=>{L({onError:n});})),r==="leap"&&((P=(k=me()).subscription)==null||P.call(k,()=>{L({onError:n});})),r==="compass"&&((w=(D=ce()).subscription)==null||w.call(D,()=>{L({onError:n});})),r==="vectis"&&((A=(f=ye()).subscription)==null||A.call(f,()=>{L({onError:n});})),r==="walletconnect"&&c.has("walletconnect")&&((M=(b=z()).subscription)==null||M.call(b,()=>{L({onError:n});})),r==="station"&&((_=(K=ge()).subscription)==null||_.call(K,()=>{L({onError:n});})),r==="xdefi"&&((ie=($=Se()).subscription)==null||ie.call($,()=>{L({onError:n});})),r==="cosmiframe"&&((S=(y=le()).subscription)==null||S.call(y,()=>{L({onError:n});})),r==="okx"&&((T=(C=fe()).subscription)==null||T.call(C,()=>{L({onError:n});}));}},[r,c,p]),null},Dt=()=>(wn(),null);var Sa=({children:e,grazOptions:t})=>(useEffect(()=>{ut(t);},[t]),jsxs(Wt,{children:[e,jsx(Dt,{})]}));
18
+ var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var Be=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var Le=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e);var Ue=(e,t,n)=>t in e?Bt(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))Gt.call(t,n)&&Ue(e,n,t[n]);if(Be)for(var n of Be(t))Ft.call(t,n)&&Ue(e,n,t[n]);return e},G=(e,t)=>Lt(e,Ut(t));var l=(e,t,n)=>new Promise((a,i)=>{var o=c=>{try{r(n.next(c));}catch(f){i(f);}},s=c=>{try{r(n.throw(c));}catch(f){i(f);}},r=c=>c.done?a(c.value):Promise.resolve(c.value).then(o,s);r((n=n.apply(e,t)).next());});var Ge=(e,t,n)=>(t=e[Le("asyncIterator")])?t.call(e):(e=e[Le("iterator")](),t={},n=(a,i)=>(i=e[a])&&(t[a]=o=>new Promise((s,r,c)=>(o=i.call(e,o),c=o.done,Promise.resolve(o.value).then(f=>s({value:f,done:c}),r)))),n("next"),n("return"),t);var te="graz-reconnect-session";var Fe=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p.PARA="para",p))(Fe||{}),ze=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","metamask_snap_cosmos","cosmiframe","compass","initia","okx","para"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,paraConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,pingInterval:36e5,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:false,_reconnectConnector:null},oe={accounts:null,activeChainIds:null,status:"disconnected",lastPing:null,wcSignClients:new Map,paraConnector:null},jt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds,lastPing:e.lastPing,status:e.status}),storage:createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},C=create(subscribeWithSelector(persist(()=>oe,jt))),u=create(subscribeWithSelector(persist(()=>qt,Qt)));var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var He={},Xe=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var m;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let r=(m=o.split("MetaMask/v")[1])==null?void 0:m.split(".")[0];if(!(Number(r)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,true}),enable:o=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>l(void 0,null,function*(){if(!o.bech32Config)throw new Error("Bech32Config is required");if(!o.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(G(k({},o),{stakeCurrency:o.stakeCurrency,bech32Config:o.bech32Config}));}),signAmino:(o,s,r)=>l(void 0,null,function*(){return t.signAmino(o,s,r)}),getKey:o=>l(void 0,null,function*(){return typeof He[o]!="undefined"?He[o]:t.getKey(o)}),getOfflineSignerAuto:o=>l(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,r)=>l(void 0,null,function*(){return t.signDirect(o,s,r)}),signArbitrary:(o,s,r)=>l(void 0,null,function*(){return t.signArbitrary(o,s,r)}),disable:o=>l(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{B(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var en=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}=e;if(!t||!n||!a||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:a,accountNumber:i}},tn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Je=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let g=e.getOfflineSigner(d),[S]=yield g.getAccounts();if(!S)throw new Error("Wallet connection failed");let P=(()=>{switch(S.algo){case "secp256k1":return rawSecp256k1PubkeyToRawAddress(S.pubkey);case "ed25519":return rawEd25519PubkeyToRawAddress(S.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:tn(S.address),algo:S.algo,pubKey:S.pubkey,bech32Address:S.address,address:P,isNanoLedger:false,isKeystone:false}}),getOfflineSigner:d=>{let g=e.getOfflineSigner(d),S=e.getOfflineSignerOnlyAmino(d);return {getAccounts:g.getAccounts.bind(g),signDirect:g.signDirect.bind(g),signAmino:S.signAmino.bind(S)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(g=>{var S,P,v;return {denom:g.coinDenom,amount:g.coinMinimalDenom,low_gas_price:(S=g.gasPriceStep)==null?void 0:S.low,average_gas_price:(P=g.gasPriceStep)==null?void 0:P.average,high_gas_price:(v=g.gasPriceStep)==null?void 0:v.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[g,S,P]=d;return e.getOfflineSigner(g).signDirect(S,en(P))},signAmino:(...d)=>{let[g,S,P]=d;return e.getOfflineSignerOnlyAmino(g).signAmino(S,P)},signArbitrary:(d,g,S)=>l(void 0,null,function*(){let R=(yield e.getOfflineSigner(d).getAccounts()).find(A=>A.address===g);if(!R)throw new Error(`Wallet not connected to account ${g}`);let E=(()=>{switch(R.algo){case "secp256k1":return encodeSecp256k1Pubkey(R.pubkey);case "ed25519":return encodeEd25519Pubkey(R.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(S),pub_key:{type:R.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:E.value}}}),subscription:d=>{let g=()=>{B(),d();};return window.addEventListener("initia_keystorechange",g),()=>{window.removeEventListener("initia_keystorechange",g);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},et=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),a=p=>l(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(O=>O.id===e.id&&(!p||O.version===p))}catch(A){return}}),i=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var D;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let O=(D=p.split("MetaMask/v")[1])==null?void 0:D.split(".")[0];if(!(Number(O)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield a())||(yield i()),true}),s=p=>l(void 0,null,function*(){(yield a())||(yield i());}),r=(p,A,O)=>l(void 0,null,function*(){let x=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:O}}}}),N=O.accountNumber,D=new Te(N.low,N.high,N.unsigned);return {signature:x.signature,signed:G(k({},x.signed),{accountNumber:`${D.toString()}`,authInfoBytes:new Uint8Array(Object.values(x.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(x.signed.bodyBytes))})}}),c=(p,A,O)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:O}}}})}),f=p=>l(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[p]=A,fe[p]}),m=p=>l(void 0,null,function*(){let A=yield f(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[A,O,x,N]=p;return yield c(A,O,x)}),g=(...p)=>l(void 0,null,function*(){var $;let[A,O,x]=p,N=G(k({},x),{accountNumber:Te.fromString((($=x.accountNumber)==null?void 0:$.toString())||"0"),authInfoBytes:x.authInfoBytes,bodyBytes:x.bodyBytes});return yield r(A,O,N)}),P=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signAmino:(A,O)=>d(p,A,O)});return {enable:s,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield m(p)]}),signDirect:(A,O)=>g(p,A,O),signAmino:(A,O)=>d(p,A,O)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return P(p)}),getOfflineSignerOnlyAmino:P,init:o,signAmino:d,signDirect:g}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var tt=()=>et({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var r;let s=()=>{B(),o();};return (r=window.okxwallet)==null||r.on("accountsChanged",s),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var nn="para.reconnect",re=null,nt=()=>{let e=()=>{let i=C.getState().paraConnector;if(!i)throw new Error("Para connector not initialized. Call connect() first or check paraConfig in GrazProvider.");return i},t=u.getState().paraConfig;if(!t||!t.paraWeb)throw new Error("Missing Para config. Provide paraConfig with 'paraWeb' to GrazProvider.");let n=()=>re||(re=l(void 0,null,function*(){let i=C.getState().paraConnector;if(i)return i;try{let o;if(t.connectorClass)o=t.connectorClass;else if(t.connectorImportPath){if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import(t.connectorImportPath),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector from dynamic URL/path. Ensure it exports `ParaGrazConnector`.");o=f;}else {if(typeof window=="undefined")throw new Error("Connector import path requires client-side execution (SSR is unsupported).");let c=yield import('@getpara/graz-integration'),f=c==null?void 0:c.ParaGrazConnector;if(typeof f!="function")throw new Error("Invalid ParaGrazConnector in @getpara/graz-integration. Check the package/export.");o=f;}let s=u.getState().chains,r=new o(t,s);if(C.setState(c=>G(k({},c),{paraConnector:r})),!r)throw new Error("Para connector initialization failed. Check config and dependencies.");return r}catch(o){throw re=null,new Error("Para connector init failed. Check @getpara/graz-integration and ParaConfig.")}}),re);return {enable:i=>l(void 0,null,function*(){let o=Array.isArray(i)?i:[i];try{let s=yield n();C.setState({paraConnector:s,status:"connecting"}),yield s.enable(o);let r=Object.fromEntries(yield Promise.all(o.map(c=>l(void 0,null,function*(){return [c,yield s.getKey(c)]}))));C.setState(c=>({accounts:k(k({},c.accounts||{}),r),activeChainIds:Array.from(new Set([...c.activeChainIds||[],...o])),status:"connected"})),u.setState(c=>({recentChainIds:Array.from(new Set([...c.recentChainIds||[],...o])),walletType:"para",_reconnect:!1,_reconnectConnector:"para"})),typeof window!="undefined"&&window.sessionStorage.setItem(nn,"1");}catch(s){throw C.setState({paraConnector:null,status:"disconnected"}),new Error(`Para enable failed${s instanceof Error?`: ${s.message}`:""}`)}}),disable:()=>l(void 0,null,function*(){let i=e();try{yield i.disconnect(),yield i.getParaWebClient().logout();}catch(o){throw new Error("Para disconnect failed. Wallet may already be disconnected.")}finally{C.setState({paraConnector:null,status:"disconnected"});}}),getKey:i=>l(void 0,null,function*(){try{return yield e().getKey(i)}catch(o){throw new Error("Failed to get key. Check chain connection and Cosmos API key settings at developer.getpara.com.")}}),getOfflineSigner:i=>{try{return e().getOfflineSigner(i)}catch(o){throw new Error("Failed to get offline signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerOnlyAmino:i=>{try{return e().getOfflineSignerOnlyAmino(i)}catch(o){throw new Error("Failed to get Amino signer. Check Para auth and Cosmos support in developer portal.")}},getOfflineSignerAuto:i=>{try{return e().getOfflineSignerAuto(i)}catch(o){throw new Error("Failed to get auto signer. Check Para auth and Cosmos support in developer portal.")}},signAmino:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signAmino(i,o,s,r)}catch(c){throw new Error("Amino signing failed. User rejected or invalid transaction/signer.")}}),signDirect:(i,o,s,r)=>l(void 0,null,function*(){try{return yield e().signDirect(i,o,s,r)}catch(c){throw new Error("Direct signing failed. User rejected or invalid transaction/signer.")}}),signArbitrary:(i,o,s)=>l(void 0,null,function*(){try{return yield e().signArbitrary(i,o,s)}catch(r){throw new Error("Arbitrary signing failed. User rejected or feature not supported.")}}),experimentalSuggestChain:()=>l(void 0,null,function*(){throw new Error("Chain suggestion not supported. Configure chains in Para wallet settings.")})}};var ye=()=>{var e;if(typeof((e=window.station)==null?void 0:e.keplr)!="undefined"){let t=window.station.keplr;return {subscription:s=>{let r=()=>{B(),s();};return window.addEventListener("station_wallet_change",r),()=>{window.removeEventListener("station_wallet_change",r);}},getKey:s=>l(void 0,null,function*(){let r=yield t.getKey(s);return k({isKeystone:false},r)}),getOfflineSigner:s=>{try{let r=t.getOfflineSignerOnlyAmino(s);return Object.assign(r,{signDirect:(m,d)=>{throw new Error("signDirect not supported by Station")}})}catch(r){throw console.error(r),r}},experimentalSuggestChain:s=>l(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let r=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(c=>({coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(c=>{var f,m,d;return {coinDecimals:c.coinDecimals,coinDenom:c.coinDenom,coinImageUrl:c.coinImageUrl||"",coinMinimalDenom:c.coinMinimalDenom,gasPriceStep:{average:((f=c.gasPriceStep)==null?void 0:f.average)||0,high:((m=c.gasPriceStep)==null?void 0:m.high)||0,low:((d=c.gasPriceStep)==null?void 0:d.low)||0}}})});yield t.experimentalSuggestChain(r);}catch(r){throw console.error(r),r}}),enable:s=>t.enable(s),disable:s=>t.disable(s),getOfflineSignerAuto:s=>t.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:t.signDirect,signAmino:(s,r,c,f)=>t.signAmino(s,r,c)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:r=>e.enable(r),getOfflineSigner:r=>{let c=e.getOfflineSigner(r);return {getAccounts:c.getAccounts,signAmino:c.signAmino,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}},getOfflineSignerAuto:r=>l(void 0,null,function*(){let c=yield e.getOfflineSignerAuto(r);return "signAmino"in c?c:"signDirect"in c?{getAccounts:c.getAccounts,signDirect:(f,m)=>l(void 0,null,function*(){var g;let d=yield c.signDirect(f,{accountNumber:Te.fromString(((g=m.accountNumber)==null?void 0:g.toString())||"",false),authInfoBytes:m.authInfoBytes,bodyBytes:m.bodyBytes,chainId:m.chainId||""});return {signature:d.signature,signed:{authInfoBytes:d.signed.authInfoBytes,bodyBytes:d.signed.bodyBytes,chainId:d.signed.chainId,accountNumber:BigInt(d.signed.accountNumber.toString())}}})}:c}),getKey:r=>l(void 0,null,function*(){let c=yield e.getKey(r);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:false,isNanoLedger:c.isNanoLedger}}),subscription:r=>{let c=()=>{B(),r();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...r)=>{let c=r[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...r)=>l(void 0,null,function*(){var m;let[c]=r;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(m=c.bech32Config)==null?void 0:m.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...r)=>l(void 0,null,function*(){var d;let{1:c,2:f}=r,m=yield e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:Te.fromString(((d=f.accountNumber)==null?void 0:d.toString())||"",false),chainId:f.chainId||""});return {signature:m.signature,signed:{authInfoBytes:m.signed.authInfoBytes,bodyBytes:m.signed.bodyBytes,chainId:m.signed.chainId,accountNumber:BigInt(m.signed.accountNumber.toString())}}}),signAmino:(...r)=>l(void 0,null,function*(){let{1:c,2:f}=r;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return false},ot=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),it=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Pe=(e,t,n=new Error("Promise timed out"))=>{let a=new Promise((i,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,a])};var q=e=>{var D,$,ie;if(!((ie=($=(D=u.getState().walletConnect)==null?void 0:D.options)==null?void 0:$.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",a=y=>{if(!e)return;let{appUrl:w,formatNativeUrl:h}=e;if(z()){if(ot()){let T=h(w.mobile.android,y,"android");window.open(T,"_self","noreferrer noopener");}if(it()){let T=h(w.mobile.ios,y,"ios");window.open(T,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:y}=C.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),C.setState({wcSignClients:y}),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield h.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(h);}),s=y=>{try{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)throw new Error("walletConnect.signClient is not defined");let T=h.session.getAll(),W=T.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let _=T.find(Q=>{var Y,J;return (J=(Y=Q.requiredNamespaces.cosmos)==null?void 0:Y.chains)==null?void 0:J.includes(`cosmos:${y}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return W}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}},r=y=>{try{return s(y)}catch(w){return}},c=y=>l(void 0,null,function*(){try{let w=y.core.pairing.pairings.getAll({active:!1});if(!w.length)return;yield Promise.all(w.map(h=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(h.topic,{code:7001,message:"clear pairing"});})));}catch(w){if(!w.message.toLowerCase().includes("no matching key"))throw w}}),f=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:w}=C.getState(),h=w.get(t);if(h)return h;let T=yield SignClient.init(y.options);return w.set(t,T),C.setState({wcSignClients:w}),T}),m=y=>{let{wcSignClients:w}=C.getState(),h=w.get(t);if(!h)return ()=>{};let T=W=>{let M=C.getState().accounts;if(W.params.event.name==="accountsChanged"&&M&&!Object.values(M).map(_=>_.bech32Address).includes(W.params.event.data[0])){let _=W.params.chainId.split(":")[1];_&&d([_]);}else y();};return h.events.on("session_delete",i),h.events.on("session_expire",i),h.events.on("session_event",T),()=>{h.events.off("session_delete",i),h.events.off("session_expire",i),h.events.off("session_event",T);}},d=y=>l(void 0,null,function*(){var J;let w=typeof y=="string"?[y]:y,{wcSignClients:h,activeChainIds:T}=C.getState(),W=h.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:M,chains:_}=u.getState();if(!((J=M==null?void 0:M.options)!=null&&J.projectId))throw new Error("walletConnect.options.projectId is not defined");let Q=new WalletConnectModal(k({projectId:M.options.projectId,enableExplorer:false,explorerRecommendedWalletIds:"NONE"},M.walletConnectModal)),Y=r(w);if(!Y){let{uri:U,approval:ae}=yield Pe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?a(U):yield Q.openModal({uri:U});let ce=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Oe,ee)=>{ae().then(_e=>{let Ke=_e.sessionProperties;if(!Ke)return ee(new Error("No session properties"));let Ee=JSON.parse(String(Ke.keys));if(Ee.length===0)return ee(new Error("No accounts"));if(!Ee[0])return ee(new Error("No accounts"));let Ne={};return Ee.forEach(H=>{Ne[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),C.setState(H=>({accounts:k(k({},H.accounts||{}),Ne)})),Oe(_e)}).catch(ee),V.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:true});})});try{let V=new AbortController,Oe=V.signal;Q.subscribeModal(ee=>{ee.open||V.abort();}),yield ce(Oe);}catch(V){if(Q.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||Q.closeModal(),Promise.resolve()}try{yield Pe(l(void 0,null,function*(){var ae;let U=Object.fromEntries(yield Promise.all((ae=T||w)==null?void 0:ae.map(ce=>l(void 0,null,function*(){return [ce,yield S(ce)]}))));C.setState({accounts:U});}),15e3,new Error("Connection timeout"));}catch(U){if(o(Y.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),g=y=>l(void 0,null,function*(){let w=yield S(y);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),S=y=>l(void 0,null,function*(){let w=s([y]);if(!(w!=null&&w.topic))throw new Error("No wallet connect session");let h=w.sessionProperties&&JSON.parse(String(w.sessionProperties.keys));if(!h)throw new Error("No wallet connect key");if(h.length===0)throw new Error("No wallet connect session");let T=h.find(W=>W.chainId===y);if(!T)throw new Error(`No wallet connect key for chainId ${y}`);return G(k({},T),{pubKey:Buffer.from(String(T.pubKey),n)})}),P=(...y)=>l(void 0,null,function*(){var J,U;let[w,h,T]=y,{accounts:W,wcSignClients:M}=C.getState(),_=M.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let Q=(J=s([w]))==null?void 0:J.topic;if(!Q)throw new Error("No wallet connect session");if(!T.bodyBytes)throw new Error("No bodyBytes");if(!T.authInfoBytes)throw new Error("No authInfoBytes");return a(),yield _.request({topic:Q,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:{chainId:T.chainId,accountNumber:(U=T.accountNumber)==null?void 0:U.toString(),bodyBytes:T.bodyBytes?Buffer.from(T.bodyBytes).toString(n):null,authInfoBytes:T.authInfoBytes?Buffer.from(T.authInfoBytes).toString(n):null}}}})}),v=(...y)=>l(void 0,null,function*(){var _;let[w,h,T]=y,{signature:W,signed:M}=yield P(w,h,T);return {signed:{chainId:(_=M.chainId)!=null?_:"",accountNumber:M.accountNumber?BigInt(M.accountNumber):BigInt(0),authInfoBytes:M.authInfoBytes?new Uint8Array(Buffer.from(M.authInfoBytes,n)):new Uint8Array([]),bodyBytes:M.bodyBytes?new Uint8Array(Buffer.from(M.bodyBytes,n)):new Uint8Array([])},signature:W}}),R=(...y)=>l(void 0,null,function*(){var U;let[w,h,T,W]=y,{wcSignClients:M}=C.getState(),_=M.get(t),{accounts:Q}=C.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let Y=(U=s([w]))==null?void 0:U.topic;if(!Y)throw new Error("No wallet connect session");return a(),yield _.request({topic:Y,chainId:`cosmos:${w}`,request:{method:"cosmos_signDirect",params:{signerAddress:h,signDoc:T}}})}),E=(...y)=>l(void 0,null,function*(){let[w,h,T,W]=y;return yield R(w,h,T)}),p=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>v(y,w,h)}),A=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signAmino:(w,h)=>E(y,w,h)});return {enable:d,disable:y=>l(void 0,null,function*(){var T;let{wcSignClients:w}=C.getState(),h=w.get(t);if(y===void 0){let W=h==null?void 0:h.session.getAll();W!==void 0&&(yield Promise.all(W.map(M=>o(M.topic))));}else typeof y=="string"?yield o((T=s([y]))==null?void 0:T.topic):yield Promise.all(y.map(W=>{var M;return o((M=s([W]))==null?void 0:M.topic)}));(h==null?void 0:h.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(y)]}),signDirect:(w,h)=>v(y,w,h),signAmino:(w,h)=>E(y,w,h)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield S(y)).isNanoLedger?A(y):p(y)}),getOfflineSignerOnlyAmino:A,signAmino:E,signDirect:v,subscription:m,init:f}};var rt=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var st=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":","");return o?`${r}://wc?${o}`:`${r}://wc`}};return q(e)};var at=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${r}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var ct=()=>{var t,n,a;if(!((a=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&a.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,o,s)=>{let r=i.replaceAll("/","").replaceAll(":",""),c=o&&encodeURIComponent(o);switch(s){case "ios":return c?`${r}://wcV2?${c}`:`${r}://wcV2`;case "android":return c?`${r}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${r}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${r}://wc?uri=${c}`:`${r}://wc`}}};return q(e)};var we=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let o=()=>{B(),i();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var F=(e=u.getState().walletType)=>{try{return K(e),!0}catch(t){return false}},B=()=>{window.sessionStorage.removeItem(te),C.setState(oe);},K=(e=u.getState().walletType)=>{var a;let t=(()=>{switch(e){case "keplr":return de();case "leap":return me();case "cosmostation":return pe();case "vectis":return Ce();case "walletconnect":return q();case "wc_keplr_mobile":return at();case "wc_leap_mobile":return ct();case "wc_cosmostation_mobile":return st();case "wc_clot_mobile":return rt();case "metamask_snap_leap":return tt();case "metamask_snap_cosmos":return Xe();case "station":return ye();case "xdefi":return we();case "cosmiframe":return ue();case "compass":return le();case "initia":return Je();case "okx":return ge();case "para":return nt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((a=t.setDefaultOptions)==null||a.call(t,n)),t},Vi=()=>Object.fromEntries(ze.map(e=>[e,F(e)])),lt=e=>e==="metamask_snap_leap",ut=()=>!!(navigator!=null&&navigator.userAgent)&&/LeapCosmos/i.test(navigator.userAgent),se=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile",pt=e=>e==="para";var ne=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:s,chains:r,walletType:c}=u.getState(),f=(e==null?void 0:e.walletType)||c;if(se(f)){let E=K("walletconnect"),{disable:p}=E;p&&p();}if(!F(f))throw new Error(`${f} is not available`);let d=K(f),g=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||s;if(!g)throw new Error("No last known connected chain, connect action requires chain ids");let S=r==null?void 0:r.map(E=>E.chainId);g.forEach(E=>{if(!(S!=null&&S.includes(E)))throw new Error(`Chain ${E} is not provided in GrazProvider`)}),C.setState(E=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!g;return E.activeChainIds&&g.filter(O=>{var x;return !((x=E.activeChainIds)!=null&&x.includes(O))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:P}=C.getState();if(yield (t=d.init)==null?void 0:t.call(d),yield d.enable(g),!se(f)){let E={};if(lt(f)){let p={};try{for(var n=Ge(g),a,i,o;a=!(i=yield n.next()).done;a=!1){let A=i.value;p[A]=yield d.getKey(A);}}catch(i){o=[i];}finally{try{a&&(i=n.return)&&(yield i.call(n));}finally{if(o)throw o[0]}}E=p;}else if(ut()&&d.getKeys){let p=yield d.getKeys(g);g.forEach((A,O)=>{let x=p[O];x&&(E[A]=x);});}else E=Object.fromEntries(yield Promise.all(g.map(p=>l(void 0,null,function*(){return [p,yield d.getKey(p)]}))));C.setState(p=>({accounts:k(k({},p.accounts||{}),E)}));}u.setState(E=>({recentChainIds:[...E.recentChainIds||[],...g].filter((p,A,O)=>O.indexOf(p)===A)})),C.setState(E=>({activeChainIds:[...E.activeChainIds||[],...g].filter((p,A,O)=>O.indexOf(p)===A)})),u.setState({walletType:f,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:f}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(te,"Active");let v=g.map(E=>r.find(p=>p.chainId===E));return {accounts:C.getState().accounts,walletType:f,chains:v}}catch(s){throw console.error("connect ",s),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),s}}),ke=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(te);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId,n=()=>{if(se(u.getState().walletType)){let a=K("walletconnect"),{disable:i}=a;i&&i();}if(pt(u.getState().walletType)){let a=K("para"),{disable:i}=a;i&&i();}};if(t){let a=C.getState().accounts;t.forEach(o=>{a==null||delete a[o];}),Object.values(a||{}).length===0?(n(),C.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null})):(C.setState(o=>{var s;return {activeChainIds:(s=o.activeChainIds)==null?void 0:s.filter(r=>!t.includes(r)),accounts:a}}),u.setState(o=>{var s;return {recentChainIds:(s=o.recentChainIds)==null?void 0:s.filter(r=>!t.includes(r))}}));}else n(),C.setState(oe),u.setState({_reconnect:false,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:n,_reconnect:a}=u.getState();try{let o=F(n||void 0);if(t&&o&&n)return se(n)?void 0:yield ne({chainId:t,walletType:n,autoReconnect:a})}catch(o){(i=e==null?void 0:e.onError)==null||i.call(e,o),ke();}}),dt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!F(n))throw new Error(`${n} is not available`);let i=K(n),o=i.getOfflineSigner(e.chainId),s=i.getOfflineSignerOnlyAmino(e.chainId),r=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:r}});var xe=()=>{u.setState({recentChainIds:null});},sr=()=>u.getState().recentChainIds,ar=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(a=>t.find(i=>i.chainId===a)))!=null?n:null},cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},lr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Me=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield K(t).experimentalSuggestChain(e),e}),mt=e=>l(void 0,null,function*(){var a;let t=u.getState().walletType;return yield Me({chainInfo:e.chainInfo,walletType:(a=e.walletType)!=null?a:t}),yield ne({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ft=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,paraConfig:e.paraConfig||t.paraConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,pingInterval:e.pingInteval||t.pingInterval,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?true:e.autoReconnect||t._reconnect})),e);var gt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:a,fee:i,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,a,i,o)}),yt=m=>l(void 0,[m],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:a,sourcePort:i,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:r,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,a,i,o,s,r,c,f)}),Ct=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,options:i,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,a,i)}),wt=r=>l(void 0,[r],function*({signingClient:e,senderAddress:t,msg:n,fee:a,contractAddress:i,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,n,a,s,o)}),St=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),ht=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let a=new TextEncoder().encode(t);return n.queryContractRaw(e,a)};var Sr=e=>e,hr=e=>e;var At=e=>e?Object.keys(e).length===0:true;var ve=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},It=e=>globalThis.DOMException===void 0?new ve(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function We(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:a=true,signal:i}={}){return new Promise((r,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let f=[],m=[],d=new Map,g=false,S=false,P=false,v=0,R=0,E=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=O=>{g=true,S=true,c(O);};i&&(i.aborted&&p(bt(i)),i.addEventListener("abort",()=>{p(bt(i));}));let A=()=>l(this,null,function*(){if(S)return;let O=yield E.next(),x=R;if(R++,O.done){if(P=true,v===0&&!S){if(!a&&m.length>0){p(new AggregateError(m));return}if(S=true,d.size===0){r(f);return}let N=[];for(let[D,$]of f.entries())d.get(D)!==Ot&&N.push($);r(N);}return}v++,l(this,null,function*(){try{let N=yield O.value;if(S)return;let D=yield t(N,x);D===Ot&&d.set(x,D),f[x]=D,v--,yield A();}catch(N){if(a)p(N);else {m.push(N),v--;try{yield A();}catch(D){p(D);}}}});});l(this,null,function*(){for(let O=0;O<n;O++){try{yield A();}catch(x){p(x);break}if(P||g)break}});})})}var Ot=Symbol("skip");var j=({chainId:e,multiChain:t})=>{let n=u(i=>i.chains);if(!n)throw new Error("No chains found in GrazProvider");let a=typeof e=="string"?[e]:e;switch(true){case(!!t&&!!a):return a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean);case(!t&&!!a):return [a.map(i=>n.find(o=>o.chainId===i)).filter(Boolean)[0]];case(!!t&&!a):return n;default:return [n[0]]}},X=(e,t,n)=>l(void 0,null,function*(){let a=u.getState().multiChainFetchConcurrency;if(e){let o=yield We(t,n,{concurrency:a});return Object.fromEntries(o.map((s,r)=>[t[r].chainId,s]))}return yield n(t[0])}),Et=(e,t,n)=>{if(e){let i=t.map(n);return Object.fromEntries(i.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Re=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:k({},(r==null?void 0:r.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})},De=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:i=>l(void 0,[i],function*({queryKey:[,a]}){if(a.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),a,s=>l(void 0,null,function*(){var m;let r=(m=u.getState().chainsConfig)==null?void 0:m[s.chainId],c={url:s.rpc,headers:k({},(r==null?void 0:r.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true),refetchOnWindowFocus:false})};var Qr=()=>u(useShallow(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCosmiframe:e.walletType==="cosmiframe"}))),Se=e=>{let n=["USE_CHECK_WALLET",u(i=>e||i.walletType)];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>F(i)})};var Z=e=>{let t=u(r=>r.walletType),n=C(r=>r.activeChainIds),a=j({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),i=C(r=>r.accounts),o=C(r=>r.status);return useEffect(()=>C.subscribe(r=>r.status,(r,c)=>{var f,m,d;if(r==="connected"){let{accounts:g,activeChainIds:S}=C.getState(),{chains:P}=u.getState(),{walletType:v}=u.getState();if(!g||!S||!P)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(m=e==null?void 0:e.onConnect)==null||m.call(e,{accounts:g,chains:S.map(R=>P.find(E=>E.chainId===R)),walletType:v,isReconnect:c==="reconnecting"});}r==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>i?Et(!!(e!=null&&e.multiChain),a,r=>i[r.chainId]):void 0,[i,a,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:L,status:o}},mn=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),a=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:i}=Re({chainId:t.map(s=>s.chainId),multiChain:true,enabled:((e==null?void 0:e.enabled)===void 0?true:e.enabled)&&!!a}),o=useMemo(()=>["USE_ALL_BALANCES",i,t,a,e==null?void 0:e.chainId],[a,e==null?void 0:e.chainId,t,i]);return useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var P;let g=s==null?void 0:s[d.chainId];if(!g)throw new Error(`Client is not ready ${d.chainId}`);if(!((P=d.bech32Config)!=null&&P.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield g.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!a&&!!t&&t.length>0&&!At(i)&&((e==null?void 0:e.enabled)===void 0?true:e.enabled),refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})},rs=e=>{let t=j({chainId:e.chainId}),{data:n}=Z({chainId:e.chainId}),a=e.bech32Address||(n==null?void 0:n.bech32Address),{data:i,refetch:o}=mn({chainId:t.map(c=>c.chainId),bech32Address:a,enabled:!!a&&(e.enabled===void 0?true:e.enabled)}),s=["USE_BALANCE",e.denom,i,t,a,e.chainId],r=useQuery({queryKey:s,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(m=>m.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?true:e.enabled)});return G(k({},r),{refetch:c=>l(void 0,null,function*(){return yield o(),r.refetch(c)})})},ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_CONNECT",e,t,n],mutationFn:ne,onError:(s,r)=>e==null?void 0:e(s,r),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {connect:s=>i.mutate(s),connectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status}},as=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_DISCONNECT",e,t,n],mutationFn:ke,onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>i.mutate(o),disconnectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},cs=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),a=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chain found");if(!F(s))throw new Error(`${s} is not available`);return yield X(!!(e!=null&&e.multiChain),o,m=>l(void 0,null,function*(){return yield dt({chainId:m.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!n&&!!a,refetchOnWindowFocus:false})},ls=e=>{let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Z(),{data:a}=Re({chainId:t.map(s=>s.chainId),multiChain:true}),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",a,t,i],[t,i,a]);return useQuery({queryKey:o,queryFn:f=>l(void 0,[f],function*({queryKey:[,s,r,c]}){if(!c)throw new Error("address is not defined");return yield X(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){var S,P;if(!s)throw new Error("Client is not ready");if(!((S=d.bech32Config)!=null&&S.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (P=s[d.chainId])==null?void 0:P.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!a,refetchOnMount:false,refetchOnReconnect:true,refetchOnWindowFocus:false})};var Cs=()=>C(e=>e.activeChainIds),fn=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var a;let n=(a=u.getState().chains)==null?void 0:a.find(i=>i.chainId===t);if(n)return n}).filter(Boolean)},ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ss=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},hs=({denom:e})=>{let t=fn();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(r=>r.coinMinimalDenom===i)))==null?void 0:o.currencies.find(s=>s)}})},As=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),enabled:typeof e.queryClient!="undefined"})},Is=()=>({data:u(t=>t.recentChainIds),clear:xe}),bs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var i;let a=(i=u.getState().chains)==null?void 0:i.find(o=>o.chainId===n);if(a)return a}).filter(Boolean),clear:xe}},Os=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,n],mutationFn:Me,onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},Es=({onError:e,onLoading:t,onSuccess:n}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],mutationFn:mt,onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!o,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};var Rs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=Z(),i=a==null?void 0:a.bech32Address,o=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,n,i],mutationFn:s=>gt(k({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:a}=Z(),i=a==null?void 0:a.bech32Address,o=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,n,i],mutationFn:s=>yt(k({senderAddress:i},s)),onError:(s,r)=>Promise.resolve(e==null?void 0:e(s,r)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isPending,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},_s=({codeId:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,r=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m;if(!o)throw new Error("senderAddress is undefined");let f=G(k({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,codeId:e});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,instantiateContract:r.mutate,instantiateContractAsync:r.mutateAsync,status:r.status}},Ks=({contractAddress:e,onError:t,onLoading:n,onSuccess:a})=>{let{data:i}=Z(),o=i==null?void 0:i.bech32Address,r=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,n,a,e,o],mutationFn:c=>{var m,d,g;if(!o)throw new Error("senderAddress is undefined");let f=G(k({},c),{fee:(m=c.fee)!=null?m:"auto",senderAddress:o,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(g=c.funds)!=null?g:[]});return wt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:n,onSuccess:c=>Promise.resolve(a==null?void 0:a(c))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,executeContract:r.mutate,executeContractAsync:r.mutateAsync,status:r.status}},Ns=e=>{let{data:t}=De();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,a]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return St(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Bs=e=>{let{data:t}=De(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:n,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ht(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Hs(e){let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var R,E;if(!(a!=null&&a.includes(m.chainId)))return null;if(!F(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return K(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return K(r).getOfflineSignerOnlyAmino(m.chainId);default:return K(r).getOfflineSignerAuto(m.chainId)}}),S=(R=u.getState().chainsConfig)==null?void 0:R[m.chainId],P={url:m.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===true&&e.opts,yield SigningStargateClient.connectWithSigner(P,g,e!=null&&e.multiChain?(E=e.opts)==null?void 0:E[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}function Xs(e){let t=j({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(s=>s.walletType),a=C(s=>s.activeChainIds),i=C.getState().status==="connected"&&C.getState().accounts&&u.getState()._reconnectConnector===n,o=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,a],[a,e,t,n]);return useQuery({queryKey:o,queryFn:c=>l(this,[c],function*({queryKey:[,s,r]}){if(s.length<1)throw new Error("No chains found");return yield X(!!(e!=null&&e.multiChain),s,m=>l(this,null,function*(){var E,p;if(!(a!=null&&a.includes(m.chainId)))return null;if(!F(r))throw new Error(`${r} is not available`);let g=yield l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case "offlineSigner":return K(r).getOfflineSigner(m.chainId);case "offlineSignerAuto":return K(r).getOfflineSignerAuto(m.chainId);case "offlineSignerOnlyAmino":return K(r).getOfflineSignerOnlyAmino(m.chainId);default:return K(r).getOfflineSignerAuto(m.chainId)}}),S=(E=u.getState().chainsConfig)==null?void 0:E[m.chainId],P={url:m.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})},v=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(P,g,k({gasPrice:v},e!=null&&e.multiChain?(p=e.opts)==null?void 0:p[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:true)&&!!i,refetchOnWindowFocus:false})}var Kt=({children:e})=>{let[t,n]=useState(false);return useEffect(()=>{n(true);},[]),jsx(Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(te)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:a,iframeOptions:i,chains:o,pingInterval:s}=u(),{activeChainIds:r,wcSignClients:c}=C(),f=F(a||void 0);return useEffect(()=>{let m=()=>l(void 0,null,function*(){if(e&&f&&a&&(r!=null&&r[0])){let d=C.getState().lastPing;if(d&&Date.now()-d<s)return;let g=K(a);try{if(!(yield g.getKey(r[0])))throw new Error("No account found");C.setState({lastPing:Date.now()});return}catch(S){L({onError:n});}}});return window.addEventListener("focus",m),()=>{window.removeEventListener("focus",m);}},[e,f,a,o,r,s]),useEffect(()=>{if(!i||i.autoConnect===false||!i.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(i.allowedIframeParentOrigins).isReady().then(d=>{if(d)return ne({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[i]),useEffect(()=>{if(a){if(!f)return;e&&r?L({onError:n}):!e&&t&&L({onError:n});}},[f]),useEffect(()=>{var m,d,g,S,P,v,R,E,p,A,O,x,N,D,$,ie,y,w,h,T;if(a){if(!f)return;a==="cosmostation"&&((d=(m=pe()).subscription)==null||d.call(m,()=>{L({onError:n});})),a==="keplr"&&((S=(g=de()).subscription)==null||S.call(g,()=>{L({onError:n});})),a==="leap"&&((v=(P=me()).subscription)==null||v.call(P,()=>{L({onError:n});})),a==="compass"&&((E=(R=le()).subscription)==null||E.call(R,()=>{L({onError:n});})),a==="vectis"&&((A=(p=Ce()).subscription)==null||A.call(p,()=>{L({onError:n});})),a==="walletconnect"&&c.has("walletconnect")&&((x=(O=q()).subscription)==null||x.call(O,()=>{L({onError:n});})),a==="station"&&((D=(N=ye()).subscription)==null||D.call(N,()=>{L({onError:n});})),a==="xdefi"&&((ie=($=we()).subscription)==null||ie.call($,()=>{L({onError:n});})),a==="cosmiframe"&&((w=(y=ue()).subscription)==null||w.call(y,()=>{L({onError:n});})),a==="okx"&&((T=(h=ge()).subscription)==null||T.call(h,()=>{L({onError:n});}));}},[a,c,f]),null},Nt=()=>(bn(),null);var Pa=({children:e,grazOptions:t})=>(useEffect(()=>{ft(t);},[t]),jsxs(Kt,{children:[e,jsx(Nt,{})]}));
19
19
 
20
- export { Dt as GrazEvents, Sa as GrazProvider, Fe as WALLET_TYPES, Ue as WalletType, F as checkWallet, Me as clearRecentChain, B as clearSession, ut as configureGraz, ne as connect, ur as defineChainInfo, lr as defineChains, ke as disconnect, ft as executeContract, Bi as getAvailableWallets, Ji as getChainInfo, Zi as getChainInfos, ue as getCosmostation, pe as getKeplr, me as getLeap, Ze as getMetamaskSnapLeap, ct as getOfflineSigners, yt as getQueryRaw, gt as getQuerySmart, Xi as getRecentChainIds, Yi as getRecentChains, ye as getVectis, ot as getWCCosmostation, it as getWCKeplr, rt as getWCLeap, N as getWallet, z as getWalletConnect, dt as instantiateContract, at as isLeapDappBrowser, st as isLeapSnaps, re as isWalletConnect, L as reconnect, mt as sendIbcTokens, pt as sendTokens, xe as suggestChain, lt as suggestChainAndConnect, Z as useAccount, us as useActiveChainCurrency, as as useActiveChainIds, ln as useActiveChains, Kr as useActiveWalletType, Hr as useBalance, Zr as useBalanceStaked, cn as useBalances, cs as useChainInfo, ls as useChainInfos, we as useCheckWallet, Xr as useConnect, De as useCosmWasmClient, Us as useCosmWasmSigningClient, Yr as useDisconnect, Ts as useExecuteContract, wn as useGrazEvents, Es as useInstantiateContract, Jr as useOfflineSigners, ps as useQueryClientValidators, Ms as useQueryRaw, ks as useQuerySmart, ms as useRecentChainIds, ds as useRecentChains, Os as useSendIbcTokens, bs as useSendTokens, We as useStargateClient, Ls as useStargateSigningClient, fs as useSuggestChain, gs as useSuggestChainAndConnect };
20
+ export { Nt as GrazEvents, Pa as GrazProvider, ze as WALLET_TYPES, Fe as WalletType, F as checkWallet, xe as clearRecentChain, B as clearSession, ft as configureGraz, ne as connect, hr as defineChainInfo, Sr as defineChains, ke as disconnect, wt as executeContract, Vi as getAvailableWallets, cr as getChainInfo, lr as getChainInfos, pe as getCosmostation, de as getKeplr, me as getLeap, tt as getMetamaskSnapLeap, dt as getOfflineSigners, ht as getQueryRaw, St as getQuerySmart, sr as getRecentChainIds, ar as getRecentChains, Ce as getVectis, st as getWCCosmostation, at as getWCKeplr, ct as getWCLeap, K as getWallet, q as getWalletConnect, Ct as instantiateContract, ut as isLeapDappBrowser, lt as isLeapSnaps, pt as isPara, se as isWalletConnect, L as reconnect, yt as sendIbcTokens, gt as sendTokens, Me as suggestChain, mt as suggestChainAndConnect, Z as useAccount, hs as useActiveChainCurrency, Cs as useActiveChainIds, fn as useActiveChains, Qr as useActiveWalletType, rs as useBalance, ls as useBalanceStaked, mn as useBalances, ws as useChainInfo, Ss as useChainInfos, Se as useCheckWallet, ss as useConnect, De as useCosmWasmClient, Xs as useCosmWasmSigningClient, as as useDisconnect, Ks as useExecuteContract, bn as useGrazEvents, _s as useInstantiateContract, cs as useOfflineSigners, As as useQueryClientValidators, Bs as useQueryRaw, Ns as useQuerySmart, Is as useRecentChainIds, bs as useRecentChains, Ds as useSendIbcTokens, Rs as useSendTokens, Re as useStargateClient, Hs as useStargateSigningClient, Os as useSuggestChain, Es as useSuggestChainAndConnect };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graz",
3
3
  "description": "React hooks for Cosmos",
4
- "version": "0.3.3",
4
+ "version": "0.3.4-alpha.0",
5
5
  "author": "Nur Fikri <kikiding.space@gmail.com>",
6
6
  "repository": "https://github.com/graz-sh/graz.git",
7
7
  "homepage": "https://github.com/graz-sh/graz",
@@ -33,6 +33,14 @@
33
33
  "env.d.ts"
34
34
  ],
35
35
  "sideEffects": false,
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "clean": "rm -rf dist/*",
39
+ "cli": "node dist/cli.js",
40
+ "dev": "tsup --watch",
41
+ "lint": "eslint --fix \"src/**/*.{ts,tsx}\"",
42
+ "prepublishOnly": "pnpm build"
43
+ },
36
44
  "peerDependencies": {
37
45
  "@tanstack/react-query": ">=5.62.0",
38
46
  "react": ">=17",
@@ -40,9 +48,12 @@
40
48
  "@cosmjs/cosmwasm-stargate": ">=0.32.4",
41
49
  "@cosmjs/proto-signing": ">=0.32.4",
42
50
  "@cosmjs/stargate": ">=0.32.4",
43
- "@cosmjs/encoding": ">=0.32.4"
51
+ "@cosmjs/encoding": ">=0.32.4",
52
+ "@getpara/graz-connector": ">=2.0.0-alpha.51 <2.0.0-beta",
53
+ "@getpara/graz-integration": ">=2.0.0-alpha.51 <2.0.0-beta"
44
54
  },
45
55
  "dependencies": {
56
+ "@initia/initia-registry-types": "0.0.20",
46
57
  "@keplr-wallet/types": "0.12.156",
47
58
  "@cosmsnap/snapper": "0.2.7",
48
59
  "@dao-dao/cosmiframe": "1.0.0",
@@ -55,16 +66,26 @@
55
66
  "@walletconnect/modal": "2.7.0",
56
67
  "cosmos-directory-client": "0.0.6",
57
68
  "long": "4",
69
+ "starknet": "^6",
58
70
  "zustand": "5.0.4"
59
71
  },
60
72
  "devDependencies": {
61
- "@initia/initia-registry-types": "0.0.20",
62
73
  "@types/node": "^18.17.15",
63
74
  "@types/react": "^18.2.21",
64
75
  "@types/react-dom": "^18.2.7",
65
76
  "arg": "^5.0.2",
66
77
  "react": "^18.2.0",
67
- "typescript": "^5.4.0"
78
+ "typescript": "^5.4.0",
79
+ "@getpara/graz-connector": ">=2.0.0-alpha.51 <2.0.0-beta",
80
+ "@getpara/graz-integration": ">=2.0.0-alpha.51 <2.0.0-beta"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "@getpara/graz-integration": {
84
+ "optional": true
85
+ },
86
+ "@getpara/graz-connector": {
87
+ "optional": true
88
+ }
68
89
  },
69
90
  "keywords": [
70
91
  "graz",
@@ -74,12 +95,5 @@
74
95
  "graz-sh",
75
96
  "use-keplr"
76
97
  ],
77
- "license": "MIT",
78
- "scripts": {
79
- "build": "tsup",
80
- "clean": "rm -rf dist/*",
81
- "cli": "node dist/cli.js",
82
- "dev": "tsup --watch",
83
- "lint": "eslint --fix \"src/**/*.{ts,tsx}\""
84
- }
85
- }
98
+ "license": "MIT"
99
+ }