graz 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/cli.js +7 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var C = require('fs/promises');
5
- var W = require('path');
5
+ var le = require('path');
6
6
  var cosmos = require('@keplr-wallet/cosmos');
7
7
  var cosmosDirectoryClient = require('cosmos-directory-client');
8
8
 
@@ -25,9 +25,9 @@ function _interopNamespace(e) {
25
25
  }
26
26
 
27
27
  var C__namespace = /*#__PURE__*/_interopNamespace(C);
28
- var W__namespace = /*#__PURE__*/_interopNamespace(W);
28
+ var le__namespace = /*#__PURE__*/_interopNamespace(le);
29
29
 
30
- var ee=Object.create;var v=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(e,n)=>()=>(e&&(n=e(e=0)),n);var ie=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var ae=(e,n,r,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ne(n))!re.call(e,o)&&o!==r&&v(e,o,{get:()=>n[o],enumerable:!(u=te(n,o))||u.enumerable});return e};var ce=(e,n,r)=>(r=e!=null?ee(oe(e)):{},ae(n||!e||!e.__esModule?v(r,"default",{value:e,enumerable:!0}):r,e));var A=(e,n,r)=>new Promise((u,o)=>{var f=s=>{try{t(r.next(s));}catch(a){o(a);}},N=s=>{try{t(r.throw(s));}catch(a){o(a);}},t=s=>s.done?u(s.value):Promise.resolve(s.value).then(f,N);t((r=r.apply(e,n)).next());});var T=se(()=>{});var q=ie((_e,U)=>{T();var k=Symbol("arg flag"),h=class e extends Error{constructor(n,r){super(n),this.name="ArgError",this.code=r,Object.setPrototypeOf(this,e.prototype);}};function P(e,{argv:n=process.argv.slice(2),permissive:r=!1,stopAtPositional:u=!1}={}){if(!e)throw new h("argument specification object is required","ARG_CONFIG_NO_SPEC");let o={_:[]},f={},N={};for(let t of Object.keys(e)){if(!t)throw new h("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(t[0]!=="-")throw new h(`argument key must start with '-' but found: '${t}'`,"ARG_CONFIG_NONOPT_KEY");if(t.length===1)throw new h(`argument key must have a name; singular '-' keys are not allowed: ${t}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[t]=="string"){f[t]=e[t];continue}let s=e[t],a=!1;if(Array.isArray(s)&&s.length===1&&typeof s[0]=="function"){let[d]=s;s=(m,p,i=[])=>(i.push(d(m,p,i[i.length-1])),i),a=d===Boolean||d[k]===!0;}else if(typeof s=="function")a=s===Boolean||s[k]===!0;else throw new h(`type missing or not a function or valid array type: ${t}`,"ARG_CONFIG_VAD_TYPE");if(t[1]!=="-"&&t.length>2)throw new h(`short argument keys (with a single hyphen) must have only one character: ${t}`,"ARG_CONFIG_SHORTOPT_TOOLONG");N[t]=[s,a];}for(let t=0,s=n.length;t<s;t++){let a=n[t];if(u&&o._.length>0){o._=o._.concat(n.slice(t));break}if(a==="--"){o._=o._.concat(n.slice(t+1));break}if(a.length>1&&a[0]==="-"){let d=a[1]==="-"||a.length===2?[a]:a.slice(1).split("").map(m=>`-${m}`);for(let m=0;m<d.length;m++){let p=d[m],[i,g]=p[1]==="-"?p.split(/=(.*)/,2):[p,void 0],c=i;for(;c in f;)c=f[c];if(!(c in N))if(r){o._.push(p);continue}else throw new h(`unknown or unexpected option: ${i}`,"ARG_UNKNOWN_OPTION");let[_,l]=N[c];if(!l&&m+1<d.length)throw new h(`option requires argument (but was followed by another short argument): ${i}`,"ARG_MISSING_REQUIRED_SHORTARG");if(l)o[c]=_(!0,c,o[c]);else if(g===void 0){if(n.length<t+2||n[t+1].length>1&&n[t+1][0]==="-"&&!(n[t+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(_===Number||typeof BigInt!="undefined"&&_===BigInt))){let E=i===c?"":` (alias for ${c})`;throw new h(`option requires argument: ${i}${E}`,"ARG_MISSING_REQUIRED_LONGARG")}o[c]=_(n[t+1],c,o[c]),++t;}else o[c]=_(g,c,o[c]);}}else o._.push(a);}return o}P.flag=e=>(e[k]=!0,e);P.COUNT=P.flag((e,n,r)=>(r||0)+1);P.ArgError=h;U.exports=P;});T();var Z=ce(q(),1);T();var L=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n;}},K=e=>globalThis.DOMException===void 0?new L(e):new DOMException(e),V=e=>{let n=e.reason===void 0?K("This operation was aborted."):e.reason;return n instanceof Error?n:K(n)};function F(f,N){return A(this,arguments,function*(e,n,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:u=!0,signal:o}={}){return new Promise((t,s)=>{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 a=[],d=[],m=new Map,p=!1,i=!1,g=!1,c=0,_=0,l=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),E=b=>{p=!0,i=!0,s(b);};o&&(o.aborted&&E(V(o)),o.addEventListener("abort",()=>{E(V(o));}));let x=()=>A(this,null,function*(){if(i)return;let b=yield l.next(),R=_;if(_++,b.done){if(g=!0,c===0&&!i){if(!u&&d.length>0){E(new AggregateError(d));return}if(i=!0,m.size===0){t(a);return}let y=[];for(let[w,$]of a.entries())m.get(w)!==Q&&y.push($);t(y);}return}c++,A(this,null,function*(){try{let y=yield b.value;if(i)return;let w=yield n(y,R);w===Q&&m.set(R,w),a[R]=w,c--,yield x();}catch(y){if(u)E(y);else {d.push(y),c--;try{yield x();}catch(w){E(w);}}}});});A(this,null,function*(){for(let b=0;b<r;b++){try{yield x();}catch(R){E(R);break}if(g||p)break}});})})}var Q=Symbol("skip");var ue=e=>/^\d+$/.test(e),D=e=>ue(e[0])?`_${e}`:e,X=`Usage: graz [options]
30
+ var de=Object.create;var ee=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var he=(e,n)=>()=>(e&&(n=e(e=0)),n);var _e=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Ee=(e,n,s,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of fe(n))!ge.call(e,o)&&o!==s&&ee(e,o,{get:()=>n[o],enumerable:!(f=ue(n,o))||f.enumerable});return e};var be=(e,n,s)=>(s=e!=null?de(pe(e)):{},Ee(n||!e||!e.__esModule?ee(s,"default",{value:e,enumerable:!0}):s,e));var A=(e,n,s)=>new Promise((f,o)=>{var p=i=>{try{t(s.next(i));}catch(c){o(c);}},b=i=>{try{t(s.throw(i));}catch(c){o(c);}},t=i=>i.done?f(i.value):Promise.resolve(i.value).then(p,b);t((s=s.apply(e,n)).next());});var T=he(()=>{});var oe=_e((Ce,ne)=>{T();var L=Symbol("arg flag"),_=class e extends Error{constructor(n,s){super(n),this.name="ArgError",this.code=s,Object.setPrototypeOf(this,e.prototype);}};function G(e,{argv:n=process.argv.slice(2),permissive:s=!1,stopAtPositional:f=!1}={}){if(!e)throw new _("argument specification object is required","ARG_CONFIG_NO_SPEC");let o={_:[]},p={},b={};for(let t of Object.keys(e)){if(!t)throw new _("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(t[0]!=="-")throw new _(`argument key must start with '-' but found: '${t}'`,"ARG_CONFIG_NONOPT_KEY");if(t.length===1)throw new _(`argument key must have a name; singular '-' keys are not allowed: ${t}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[t]=="string"){p[t]=e[t];continue}let i=e[t],c=!1;if(Array.isArray(i)&&i.length===1&&typeof i[0]=="function"){let[u]=i;i=(m,g,a=[])=>(a.push(u(m,g,a[a.length-1])),a),c=u===Boolean||u[L]===!0;}else if(typeof i=="function")c=i===Boolean||i[L]===!0;else throw new _(`type missing or not a function or valid array type: ${t}`,"ARG_CONFIG_VAD_TYPE");if(t[1]!=="-"&&t.length>2)throw new _(`short argument keys (with a single hyphen) must have only one character: ${t}`,"ARG_CONFIG_SHORTOPT_TOOLONG");b[t]=[i,c];}for(let t=0,i=n.length;t<i;t++){let c=n[t];if(f&&o._.length>0){o._=o._.concat(n.slice(t));break}if(c==="--"){o._=o._.concat(n.slice(t+1));break}if(c.length>1&&c[0]==="-"){let u=c[1]==="-"||c.length===2?[c]:c.slice(1).split("").map(m=>`-${m}`);for(let m=0;m<u.length;m++){let g=u[m],[a,h]=g[1]==="-"?g.split(/=(.*)/,2):[g,void 0],l=a;for(;l in p;)l=p[l];if(!(l in b))if(s){o._.push(g);continue}else throw new _(`unknown or unexpected option: ${a}`,"ARG_UNKNOWN_OPTION");let[E,r]=b[l];if(!r&&m+1<u.length)throw new _(`option requires argument (but was followed by another short argument): ${a}`,"ARG_MISSING_REQUIRED_SHORTARG");if(r)o[l]=E(!0,l,o[l]);else if(h===void 0){if(n.length<t+2||n[t+1].length>1&&n[t+1][0]==="-"&&!(n[t+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(E===Number||typeof BigInt!="undefined"&&E===BigInt))){let S=a===l?"":` (alias for ${l})`;throw new _(`option requires argument: ${a}${S}`,"ARG_MISSING_REQUIRED_LONGARG")}o[l]=E(n[t+1],l,o[l]),++t;}else o[l]=E(h,l,o[l]);}}else o._.push(c);}return o}G.flag=e=>(e[L]=!0,e);G.COUNT=G.flag((e,n,s)=>(s||0)+1);G.ArgError=_;ne.exports=G;});T();var me=be(oe(),1);T();var F=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n;}},se=e=>globalThis.DOMException===void 0?new F(e):new DOMException(e),re=e=>{let n=e.reason===void 0?se("This operation was aborted."):e.reason;return n instanceof Error?n:se(n)};function k(p,b){return A(this,arguments,function*(e,n,{concurrency:s=Number.POSITIVE_INFINITY,stopOnError:f=!0,signal:o}={}){return new Promise((t,i)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof n!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(s)||s===Number.POSITIVE_INFINITY)&&s>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${s}\` (${typeof s})`);let c=[],u=[],m=new Map,g=!1,a=!1,h=!1,l=0,E=0,r=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),S=N=>{g=!0,a=!0,i(N);};o&&(o.aborted&&S(re(o)),o.addEventListener("abort",()=>{S(re(o));}));let P=()=>A(this,null,function*(){if(a)return;let N=yield r.next(),R=E;if(E++,N.done){if(h=!0,l===0&&!a){if(!f&&u.length>0){S(new AggregateError(u));return}if(a=!0,m.size===0){t(c);return}let w=[];for(let[y,D]of c.entries())m.get(y)!==ie&&w.push(D);t(w);}return}l++,A(this,null,function*(){try{let w=yield N.value;if(a)return;let y=yield n(w,R);y===ie&&m.set(R,y),c[R]=y,l--,yield P();}catch(w){if(f)S(w);else {u.push(w),l--;try{yield P();}catch(y){S(y);}}}});});A(this,null,function*(){for(let N=0;N<s;N++){try{yield P();}catch(R){S(R);break}if(h||g)break}});})})}var ie=Symbol("skip");var Ae=e=>/^\d+$/.test(e),j=e=>Ae(e[0])?`_${e}`:e,ae=`Usage: graz [options]
31
31
 
32
32
  Options:
33
33
 
@@ -41,7 +41,7 @@ Generate options:
41
41
  --authz Generate only authz compatible chains
42
42
 
43
43
  https://github.com/graz-sh/graz
44
- `,I=(0, Z.default)({"--generate":Boolean,"-g":"--generate","--authz":Boolean,"--best":Boolean,"--mainnet":String,"--testnet":String,"-b":"--best","-M":"--mainnet","-T":"--testnet","--help":Boolean,"-h":"--help"}),fe=()=>A(void 0,null,function*(){if(I["--help"]){console.log(X);return}if(I["--generate"]){yield pe();return}console.log(X);}),pe=()=>A(void 0,null,function*(){console.log("\u23F3 Generating chain list from cosmos.directory..."),I["--authz"]&&console.log("\u270D\uFE0F Detected authz flag, generating only compatible chains..."),I["--best"]&&console.log("\u{1F481}\u200D\u2642\uFE0F Detected best flag, setting REST and RPC endpoints to best latency..."),(I["--mainnet"]||I["--testnet"])&&console.log("\u{1F419} Detected chain filtering flag, generating only given chain paths...");let[e,n]=yield Promise.all([J(cosmosDirectoryClient.createClient(),{filter:I["--mainnet"]}),J(cosmosDirectoryClient.createTestnetClient(),{filter:I["--testnet"]})]),[r,u]=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 */",j(e)).replace("/* REPLACE_TESTNET_CHAINS */",j(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(),f=u.replace("/* REPLACE_MAINNET_DEFS */",M(e,{mjs:!0})).replace("/* REPLACE_TESTNET_DEFS */",M(n,{mjs:!0,testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",j(e)).replace("/* REPLACE_TESTNET_CHAINS */",j(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"),f.replace('"../dist"','"../dist/index.mjs"'),{encoding:"utf-8"}),C__namespace.writeFile(G("index.ts"),f,{encoding:"utf-8"})]),console.log('\u2728 Generate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');}),G=(...e)=>W__namespace.resolve(__dirname,"../chains",...e),j=(e,{testnet:n=!1}={})=>Object.keys(e).map(r=>` ${D(r)}: ${D(r)},`).join(`
45
- `),M=(e,{mjs:n=!1,testnet:r=!1}={})=>Object.entries(e).map(([u,o])=>{let f=`${D(u)}`,N=JSON.stringify(o,null,2);return `${n?"export ":""}const ${f} = defineChainInfo(${N});
46
- `}).join(""),O=(e,{testnet:n=!1}={})=>Object.keys(e).map(r=>` ${D(r)},`).join(`
47
- `),J=(r,...u)=>A(void 0,[r,...u],function*(e,{filter:n=""}={}){let o=n?n.split(",").map(t=>({path:t})):yield e.fetchChains().then(t=>t.chains.map(({path:s})=>({path:s}))),f=yield F(o,t=>A(void 0,null,function*(){return e.fetchChain(t.path).then(s=>s.chain)}),{concurrency:4}),N={};return f.forEach(t=>{var s,a,d,m,p;try{if(I["--authz"]&&!((s=t.params)!=null&&s.authz))return;let i=I["--best"]?t.best_apis:t.apis;if(!i||!((a=i.rest)!=null&&a[0])||!((d=i.rpc)!=null&&d[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 g=t.assets[0],c={coinDenom:g.denom_units[g.denom_units.length-1].denom,coinMinimalDenom:g.denom_units[0].denom,coinDecimals:g.denom_units[g.denom_units.length-1].exponent,coinGeckoId:g.coingecko_id},_=(m=t.fees)==null?void 0:m.fee_tokens.map(l=>{var E,x,b,R,y,w,$,z,Y,H;return {coinDenom:((b=(x=(E=t.assets)==null?void 0:E.find(S=>S.denom===l.denom))==null?void 0:x.denom_units.at(-1))==null?void 0:b.denom)||l.denom,coinMinimalDenom:((w=(y=(R=t.assets)==null?void 0:R.find(S=>S.denom===l.denom))==null?void 0:y.denom_units[0])==null?void 0:w.denom)||l.denom,coinDecimals:Number((z=($=t.assets)==null?void 0:$.find(S=>S.denom===l.denom))==null?void 0:z.decimals),coinGeckoId:((H=(Y=t.assets)==null?void 0:Y.find(S=>S.denom===l.denom))==null?void 0:H.coingecko_id)||"",gasPriceStep:{low:Number(l.low_gas_price),average:Number(l.average_gas_price),high:Number(l.high_gas_price)}}});if(!_)throw new Error(`\u26A0\uFE0F ${t.name} has no fee currencies, skipping codegen...`);N[t.path]={chainId:t.chain_id,currencies:t.assets.map(l=>({coinDenom:l.denom_units[l.denom_units.length-1].denom,coinMinimalDenom:l.denom_units[0].denom,coinDecimals:l.denom_units[l.denom_units.length-1].exponent,coinGeckoId:l.coingecko_id})),rest:i.rest[0].address||"",rpc:i.rpc[0].address||"",bech32Config:cosmos.Bech32Address.defaultBech32Config(t.bech32_prefix),chainName:t.chain_name,feeCurrencies:_,stakeCurrency:c,bip44:{coinType:(p=t.slip44)!=null?p:0}};}catch(i){console.error(i instanceof Error?i.message:String(i));}}),N});fe();
44
+ `,I=(0, me.default)({"--generate":Boolean,"-g":"--generate","--authz":Boolean,"--best":Boolean,"--mainnet":String,"--testnet":String,"-b":"--best","-M":"--mainnet","-T":"--testnet","--help":Boolean,"-h":"--help"}),Ie=()=>A(void 0,null,function*(){if(I["--help"]){console.log(ae);return}if(I["--generate"]){yield Se();return}console.log(ae);}),Se=()=>A(void 0,null,function*(){console.log("\u23F3 Generating chain list from cosmos.directory..."),I["--authz"]&&console.log("\u270D\uFE0F Detected authz flag, generating only compatible chains..."),I["--best"]&&console.log("\u{1F481}\u200D\u2642\uFE0F Detected best flag, setting REST and RPC endpoints to best latency..."),(I["--mainnet"]||I["--testnet"])&&console.log("\u{1F419} Detected chain filtering flag, generating only given chain paths...");let[e,n]=yield Promise.all([ce(cosmosDirectoryClient.createClient(),{filter:I["--mainnet"]}),ce(cosmosDirectoryClient.createTestnetClient(),{filter:I["--testnet"]})]),[s,f]=yield Promise.all([C__namespace.readFile(O("index.js.stub"),{encoding:"utf-8"}),C__namespace.readFile(O("index.mjs.stub"),{encoding:"utf-8"})]),o=s.replace("/* REPLACE_MAINNET_DEFS */",$(e)).replace("/* REPLACE_TESTNET_DEFS */",$(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",M(e)).replace("/* REPLACE_TESTNET_CHAINS */",M(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",x(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",x(n,{testnet:!0})).replace("/* REPLACE_MAINNET_EXPORTS */",x(e)).replace("/* REPLACE_TESTNET_EXPORTS */",x(n,{testnet:!0})).replace(/"(.+)":/g,"$1:").trim(),p=f.replace("/* REPLACE_MAINNET_DEFS */",$(e,{mjs:!0})).replace("/* REPLACE_TESTNET_DEFS */",$(n,{mjs:!0,testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS */",M(e)).replace("/* REPLACE_TESTNET_CHAINS */",M(n,{testnet:!0})).replace("/* REPLACE_MAINNET_CHAINS_ARRAY */",x(e)).replace("/* REPLACE_TESTNET_CHAINS_ARRAY */",x(n,{testnet:!0})).replace(/"(.+)":/g,"$1:").trim();yield Promise.all([C__namespace.writeFile(O("index.js"),o,{encoding:"utf-8"}),C__namespace.writeFile(O("index.mjs"),p.replace('"../dist"','"../dist/index.mjs"'),{encoding:"utf-8"}),C__namespace.writeFile(O("index.ts"),p,{encoding:"utf-8"})]),console.log('\u2728 Generate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');}),O=(...e)=>le__namespace.resolve(__dirname,"../chains",...e),M=(e,{testnet:n=!1}={})=>Object.keys(e).map(s=>` ${j(s)}: ${j(s)},`).join(`
45
+ `),$=(e,{mjs:n=!1,testnet:s=!1}={})=>Object.entries(e).map(([f,o])=>{let p=`${j(f)}`,b=JSON.stringify(o,null,2);return `${n?"export ":""}const ${p} = defineChainInfo(${b});
46
+ `}).join(""),x=(e,{testnet:n=!1}={})=>Object.keys(e).map(s=>` ${j(s)},`).join(`
47
+ `),ce=(s,...f)=>A(void 0,[s,...f],function*(e,{filter:n=""}={}){let o=n?n.split(",").map(t=>({path:t})):yield e.fetchChains().then(t=>t.chains.map(({path:i})=>({path:i}))),p=yield k(o,t=>A(void 0,null,function*(){return e.fetchChain(t.path).then(i=>i.chain)}),{concurrency:4}),b={};return p.forEach(t=>{var i,c,u,m,g;try{if(I["--authz"]&&!((i=t.params)!=null&&i.authz))return;let a=I["--best"]?t.best_apis:t.apis;if(!a||!((c=a.rest)!=null&&c[0])||!((u=a.rpc)!=null&&u[0]))throw new Error(`\u26A0\uFE0F ${t.name} has no REST/RPC endpoints, skipping codegen...`);if(!t.assets)throw new Error(`\u26A0\uFE0F ${t.name} has no assets, skipping codegen...`);let h=t.assets[0],l={coinDenom:h.denom_units[h.denom_units.length-1].denom,coinMinimalDenom:h.denom_units[0].denom,coinDecimals:h.denom_units[h.denom_units.length-1].exponent,coinGeckoId:h.coingecko_id},E=(m=t.fees)==null?void 0:m.fee_tokens.map(r=>{var P,N,R,w,y,D,v,z,Y,H,B,U,q,K,V,Q,X,J,W,Z;return r.low_gas_price&&r.average_gas_price&&r.high_gas_price?{coinDenom:((R=(N=(P=t.assets)==null?void 0:P.find(d=>d.denom===r.denom))==null?void 0:N.denom_units.at(-1))==null?void 0:R.denom)||r.denom,coinMinimalDenom:((D=(y=(w=t.assets)==null?void 0:w.find(d=>d.denom===r.denom))==null?void 0:y.denom_units[0])==null?void 0:D.denom)||r.denom,coinDecimals:Number((z=(v=t.assets)==null?void 0:v.find(d=>d.denom===r.denom))==null?void 0:z.decimals),coinGeckoId:((H=(Y=t.assets)==null?void 0:Y.find(d=>d.denom===r.denom))==null?void 0:H.coingecko_id)||"",gasPriceStep:{low:Number(r.low_gas_price),average:Number(r.average_gas_price),high:Number(r.high_gas_price)}}:{coinDenom:((q=(U=(B=t.assets)==null?void 0:B.find(d=>d.denom===r.denom))==null?void 0:U.denom_units.at(-1))==null?void 0:q.denom)||r.denom,coinMinimalDenom:((Q=(V=(K=t.assets)==null?void 0:K.find(d=>d.denom===r.denom))==null?void 0:V.denom_units[0])==null?void 0:Q.denom)||r.denom,coinDecimals:Number((J=(X=t.assets)==null?void 0:X.find(d=>d.denom===r.denom))==null?void 0:J.decimals),coinGeckoId:((Z=(W=t.assets)==null?void 0:W.find(d=>d.denom===r.denom))==null?void 0:Z.coingecko_id)||""}});if(!E)throw new Error(`\u26A0\uFE0F ${t.name} has no fee currencies, skipping codegen...`);b[t.path]={chainId:t.chain_id,currencies:t.assets.map(r=>({coinDenom:r.denom_units[r.denom_units.length-1].denom,coinMinimalDenom:r.denom_units[0].denom,coinDecimals:r.denom_units[r.denom_units.length-1].exponent,coinGeckoId:r.coingecko_id})),rest:a.rest[0].address||"",rpc:a.rpc[0].address||"",bech32Config:cosmos.Bech32Address.defaultBech32Config(t.bech32_prefix),chainName:t.chain_name,feeCurrencies:E,stakeCurrency:l,bip44:{coinType:(g=t.slip44)!=null?g:0}};}catch(a){console.error(a instanceof Error?a.message:String(a));}}),b});Ie();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graz",
3
3
  "description": "React hooks for Cosmos",
4
- "version": "0.1.8",
4
+ "version": "0.1.9",
5
5
  "author": "Griko Nibras <griko@strange.love>",
6
6
  "repository": "https://github.com/graz-sh/graz.git",
7
7
  "homepage": "https://github.com/graz-sh/graz",