polkadot-api 1.6.0 → 1.6.1

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.
@@ -1 +1 @@
1
- (function(we,ge){typeof exports=="object"&&typeof module<"u"?ge(exports):typeof define=="function"&&define.amd?define(["exports"],ge):(we=typeof globalThis<"u"?globalThis:we||self,ge(we.papiInk={}))})(this,function(we){"use strict";const ge=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",ae={type:"void"},Cn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=u=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const p={id:d};return n.set(d,p),p}r.add(d);const l=u(d);return h=n.get(d),h?Object.assign(h,l):(h={id:d,...l},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const a=s(u=>{const d=t(e[u]);if(d)return d;const{def:h,path:l,params:p}=e[u];if(h.tag==="composite"){if(h.value.length===0)return ae;if(h.value.length===1){const g=a(h.value[0].type);return o&&l.at(-1)==="AccountId32"&&ge(g,32)?(o=!1,{type:"AccountId32"}):c&&l.at(-1)==="AccountId20"&&ge(g,20)?(c=!1,{type:"AccountId20"}):g}return f(h.value)}if(h.tag==="variant"){if(l.length===1&&l[0]==="Option"&&p.length===1&&p[0].name==="T"){const k=a(p[0].type);return k.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:k}}if(l.length===1&&l[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:a(p[0].type),ko:a(p[1].type)}};if(h.value.length===0)return ae;const g={},b={};return h.value.forEach(k=>{const _=k.name;if(b[_]=k.docs,k.fields.length===0){g[_]={...ae,idx:k.index};return}if(k.fields.length===1&&!k.fields[0].name){g[_]={type:"lookupEntry",value:a(k.fields[0].type),idx:k.index};return}g[_]={...f(k.fields),idx:k.index}}),{type:"enum",value:g,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:a(h.value)};if(h.tag==="array"){const{len:g}=h.value,b=a(h.value.type);return!g||b.type==="void"?ae:g>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?ae:h.value.length>1?i(h.value.map(g=>a(g)),h.value.map(g=>e[g].docs)):a(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const g=a(h.value);return g.type==="void"?ae:{type:"compact",isBig:Number(g.value.slice(1))>32}}return{type:h.tag}}),f=u=>{let d=!0;const h={},l={};return u.forEach((p,g)=>{d=d&&!!p.name;const b=p.name||g,k=a(p.type);k.type!=="void"&&(h[b]=k,l[b]=p.docs)}),d?{type:"struct",value:h,innerDocs:l}:i(Object.values(h),Object.values(l))},i=(u,d)=>{if(u.every(h=>h.id===u[0].id)&&d.every(h=>!h.length)){const[h]=u;return h.type==="void"?ae:{type:"array",value:u[0],len:u.length}}return{type:"tuple",value:u,innerDocs:d}};return a},Hn=e=>Cn(e);var Mn=Object.defineProperty,Vn=(e,t,n)=>t in e?Mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n)=>(Vn(e,typeof t!="symbol"?t+"":t,n),n),Ke={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function jn(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|Ke[e[2]]);for(let o=0;o<r;){const c=n+o*2,a=Ke[e[c]],f=Ke[e[c+1]];s[t+o++]=a<<4|f}return s}var ut=class extends Uint8Array{constructor(e){super(e),lt(this,"i",0),lt(this,"v"),this.v=new DataView(e)}},N=e=>t=>e(t instanceof ut?t:new ut(t instanceof Uint8Array?t.buffer:typeof t=="string"?jn(t).buffer:t)),X=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].byteLength;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const c=e[s];r.set(c,o),o+=c.byteLength}return r};function Le(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var We=N,x=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},ze=(e,t)=>n=>e(t(n)),Ue=(e,t)=>n=>t(e(n)),K=([e,t],n,r)=>x(ze(e,n),Ue(t,r));function Rn(e,t){return N(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Pn(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Z(e,t,n){return x(Pn(e,n),Rn(e,t))}var L=Z(1,"getUint8","setUint8"),me=Z(2,"getUint16","setUint16"),ee=Z(4,"getUint32","setUint32"),Se=Z(8,"getBigUint64","setBigUint64"),Nn=Z(1,"getInt8","setInt8"),qn=Z(2,"getInt16","setInt16"),Fn=Z(4,"getInt32","setInt32"),Xn=Z(8,"getBigInt64","setBigInt64"),ht=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},dt=e=>N(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),Kn=x(ht,dt("getBigUint64")),Wn=x(ht,dt("getBigInt64")),ft=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},yt=e=>N(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),zn=x(ft,yt("getBigUint64")),Gn=x(ft,yt("getBigInt64")),Ge=K(L,e=>e?1:0,Boolean),Yn=[L[1],me[1],ee[1]],Jn=N(e=>{const t=e[e.i],n=t&3;if(n<3)return Yn[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let f=0;f<o;f++)s=Se[1](e)<<c|s,c+=64n;let a=r%8;return a>3&&(s=BigInt(ee[1](e))<<c|s,c+=32n,a-=4),a>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,a-=2),a&&(s=BigInt(L[1](e))<<c|s),s}),Qn=1n<<56n,Zn=1<<24,er=256,tr=4294967295n,nr=64,rr=16384,sr=1<<30,or=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<nr)return L[0](t);if(e<rr)return me[0](t|1);if(e<sr)return ee[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Qn;)n.push(Se[0](r)),r>>=64n;r>=Zn&&(n.push(ee[0](Number(r&tr))),r>>=32n);let s=Number(r);s>=er&&(n.push(me[0](s)),s>>=16),s&&n.push(L[0](s));const o=X(n);return o[0]=o.length-5<<2|3,o},T=x(or,Jn),cr=new TextEncoder,ir=e=>{const t=cr.encode(e);return X([T.enc(t.length),t])},ar=new TextDecoder,lr=N(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,ar.decode(n)}),A=x(ir,lr),ur=()=>{},hr=new Uint8Array(0),v=x(()=>hr,ur),pt=e=>e===void 0?t=>X([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),gt=e=>N(t=>{const n=e===void 0?T.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),D=e=>x(pt(e),gt(e));D.enc=pt,D.dec=gt;var bt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>X([L.enc(s(o)),e[o](c)])},wt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return N(s=>{const o=L.dec(s),c=r.get(o),a=e[c];return{tag:c,value:a(s)}})},q=(e,...t)=>x(bt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));q.enc=bt,q.dec=wt;var mt=e=>N(t=>{const n=L.dec(t);if(n!==0)return e===Ge[1]?n===1:e(t)}),vt=e=>t=>{const n=new Uint8Array(1);return t===void 0?(n[0]=0,n):(n[0]=1,e===Ge[0]?(n[0]=t?1:2,n):X([n,e(t)]))},V=e=>x(vt(e[0]),mt(e[1]));V.enc=vt,V.dec=mt;var kt=(e,t)=>N(n=>{const r=L[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),Et=(e,t)=>({success:n,value:r})=>X([L[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>x(Et(e[0],t[0]),kt(e[1],t[1]));De.dec=kt,De.enc=Et;var xt=(...e)=>N(t=>e.map(n=>n(t))),Bt=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),F=(...e)=>x(Bt(...e.map(([t])=>t)),xt(...e.map(([,t])=>t)));F.enc=Bt,F.dec=xt;var It=e=>{const t=Object.keys(e);return ze(F.enc(...Object.values(e)),n=>t.map(r=>n[r]))},At=e=>{const t=Object.keys(e);return Ue(F.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},m=e=>x(It(Le(e,t=>t[0])),At(Le(e,t=>t[1])));m.enc=It,m.dec=At;var Ot=(e,t)=>t>=0?n=>X(n.map(e)):n=>X([T.enc(n.length),X(n.map(e))]),_t=(e,t)=>N(n=>{const r=t>=0?t:T.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),B=(e,t)=>x(Ot(e[0],t),_t(e[1],t));B.enc=Ot,B.dec=_t;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function dr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function fr(...e){const t=o=>o,n=(o,c)=>a=>o(c(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function yr(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function pr(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Lt(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(c=>{if(c<0||c>=t)throw new Error(`Wrong integer: ${c}`)});;){let c=0,a=!0;for(let f=r;f<o.length;f++){const i=o[f],u=t*c+i;if(!Number.isSafeInteger(u)||t*c/t!==c||u-i!==t*c)throw new Error("convertRadix: carry overflow");c=u%n;const d=Math.floor(u/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==u)throw new Error("convertRadix: carry overflow");if(a)d?a=!1:r=f;else continue}if(s.push(c),a)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function gr(e){return{encode:t=>{if(!dr(t))throw new Error("radix.encode input should be Uint8Array");return Lt(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Lt(t,e,2**8))}}}const Ut=(e=>fr(gr(58),yr(e),pr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function le(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function br(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function $e(e,...t){if(!br(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ve(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ye(e,t){$e(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wr=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),ue=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Te=(e,t)=>e<<32-t|e>>>t,C=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,St=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,W=C?e=>e:e=>St(e);function H(e){for(let t=0;t<e.length;t++)e[t]=St(e[t])}function mr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function z(e){return typeof e=="string"&&(e=mr(e)),$e(e),e}class Dt{clone(){return this._cloneInto()}}function vr(e){const t=r=>e().update(z(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function kr(e){const t=(r,s)=>e(s).update(z(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Er(e){const t=(r,s)=>e(s).update(z(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const xr=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class $t extends Dt{constructor(t,n,r={},s,o,c){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,le(t),le(n),le(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error(`key must be up 1..${s} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==o)throw new Error(`salt must be ${o} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error(`personalization must be ${c} byte long or undefined`);this.buffer32=ue(this.buffer=new Uint8Array(t))}update(t){ve(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=z(t);const o=t.length,c=t.byteOffset,a=t.buffer;for(let f=0;f<o;){this.pos===n&&(C||H(s),this.compress(s,0,!1),C||H(s),this.pos=0);const i=Math.min(n-this.pos,o-f),u=c+f;if(i===n&&!(u%4)&&f+i<o){const d=new Uint32Array(a,u,Math.floor((o-f)/4));C||H(d);for(let h=0;f+n<o;h+=s.length,f+=n)this.length+=n,this.compress(d,h,!1);C||H(d);continue}r.set(t.subarray(f,f+i),this.pos),this.pos+=i,this.length+=i,f+=i}return this}digestInto(t){ve(this),Ye(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),C||H(r),this.compress(r,0,!0),C||H(r);const s=ue(t);this.get().forEach((o,c)=>s[c]=W(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:c,pos:a}=this;return t||(t=new this.constructor({dkLen:c})),t.set(...this.get()),t.length=r,t.finished=s,t.destroyed=o,t.outputLen=c,t.buffer.set(n),t.pos=a,t}}const Ce=BigInt(2**32-1),Je=BigInt(32);function He(e,t=!1){return t?{h:Number(e&Ce),l:Number(e>>Je&Ce)}:{h:Number(e>>Je&Ce)|0,l:Number(e&Ce)|0}}function Tt(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:c}=He(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const Br=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),Ir=(e,t,n)=>e>>>n,Ar=(e,t,n)=>e<<32-n|t>>>n,Or=(e,t,n)=>e>>>n|t<<32-n,_r=(e,t,n)=>e<<32-n|t>>>n,Lr=(e,t,n)=>e<<64-n|t>>>n-32,Ur=(e,t,n)=>e>>>n-32|t<<64-n,Sr=(e,t)=>t,Dr=(e,t)=>e,Ct=(e,t,n)=>e<<n|t>>>32-n,Ht=(e,t,n)=>t<<n|e>>>32-n,Mt=(e,t,n)=>t<<n-32|e>>>64-n,Vt=(e,t,n)=>e<<n-32|t>>>64-n;function $r(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const M={fromBig:He,split:Tt,toBig:Br,shrSH:Ir,shrSL:Ar,rotrSH:Or,rotrSL:_r,rotrBH:Lr,rotrBL:Ur,rotr32H:Sr,rotr32L:Dr,rotlSH:Ct,rotlSL:Ht,rotlBH:Mt,rotlBL:Vt,add:$r,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,add5H:(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,add5L:(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},O=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),y=new Uint32Array(32);function te(e,t,n,r,s,o){const c=s[o],a=s[o+1];let f=y[2*e],i=y[2*e+1],u=y[2*t],d=y[2*t+1],h=y[2*n],l=y[2*n+1],p=y[2*r],g=y[2*r+1],b=M.add3L(f,u,c);i=M.add3H(b,i,d,a),f=b|0,{Dh:g,Dl:p}={Dh:g^i,Dl:p^f},{Dh:g,Dl:p}={Dh:M.rotr32H(g,p),Dl:M.rotr32L(g,p)},{h:l,l:h}=M.add(l,h,g,p),{Bh:d,Bl:u}={Bh:d^l,Bl:u^h},{Bh:d,Bl:u}={Bh:M.rotrSH(d,u,24),Bl:M.rotrSL(d,u,24)},y[2*e]=f,y[2*e+1]=i,y[2*t]=u,y[2*t+1]=d,y[2*n]=h,y[2*n+1]=l,y[2*r]=p,y[2*r+1]=g}function ne(e,t,n,r,s,o){const c=s[o],a=s[o+1];let f=y[2*e],i=y[2*e+1],u=y[2*t],d=y[2*t+1],h=y[2*n],l=y[2*n+1],p=y[2*r],g=y[2*r+1],b=M.add3L(f,u,c);i=M.add3H(b,i,d,a),f=b|0,{Dh:g,Dl:p}={Dh:g^i,Dl:p^f},{Dh:g,Dl:p}={Dh:M.rotrSH(g,p,16),Dl:M.rotrSL(g,p,16)},{h:l,l:h}=M.add(l,h,g,p),{Bh:d,Bl:u}={Bh:d^l,Bl:u^h},{Bh:d,Bl:u}={Bh:M.rotrBH(d,u,63),Bl:M.rotrBL(d,u,63)},y[2*e]=f,y[2*e+1]=i,y[2*t]=u,y[2*t+1]=d,y[2*n]=h,y[2*n+1]=l,y[2*r]=p,y[2*r+1]=g}class Tr extends $t{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=O[0]|0,this.v0h=O[1]|0,this.v1l=O[2]|0,this.v1h=O[3]|0,this.v2l=O[4]|0,this.v2h=O[5]|0,this.v3l=O[6]|0,this.v3h=O[7]|0,this.v4l=O[8]|0,this.v4h=O[9]|0,this.v5l=O[10]|0,this.v5h=O[11]|0,this.v6l=O[12]|0,this.v6h=O[13]|0,this.v7l=O[14]|0,this.v7h=O[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=ue(z(t.salt));this.v4l^=W(r[0]),this.v4h^=W(r[1]),this.v5l^=W(r[2]),this.v5h^=W(r[3])}if(t.personalization){const r=ue(z(t.personalization));this.v6l^=W(r[0]),this.v6h^=W(r[1]),this.v7l^=W(r[2]),this.v7h^=W(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(z(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:a,v3h:f,v4l:i,v4h:u,v5l:d,v5h:h,v6l:l,v6h:p,v7l:g,v7h:b}=this;return[t,n,r,s,o,c,a,f,i,u,d,h,l,p,g,b]}set(t,n,r,s,o,c,a,f,i,u,d,h,l,p,g,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=a|0,this.v3h=f|0,this.v4l=i|0,this.v4h=u|0,this.v5l=d|0,this.v5h=h|0,this.v6l=l|0,this.v6h=p|0,this.v7l=g|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,i)=>y[i]=f),y.set(O,16);let{h:s,l:o}=M.fromBig(BigInt(this.length));y[24]=O[8]^o,y[25]=O[9]^s,r&&(y[28]=~y[28],y[29]=~y[29]);let c=0;const a=xr;for(let f=0;f<12;f++)te(0,4,8,12,t,n+2*a[c++]),ne(0,4,8,12,t,n+2*a[c++]),te(1,5,9,13,t,n+2*a[c++]),ne(1,5,9,13,t,n+2*a[c++]),te(2,6,10,14,t,n+2*a[c++]),ne(2,6,10,14,t,n+2*a[c++]),te(3,7,11,15,t,n+2*a[c++]),ne(3,7,11,15,t,n+2*a[c++]),te(0,5,10,15,t,n+2*a[c++]),ne(0,5,10,15,t,n+2*a[c++]),te(1,6,11,12,t,n+2*a[c++]),ne(1,6,11,12,t,n+2*a[c++]),te(2,7,8,13,t,n+2*a[c++]),ne(2,7,8,13,t,n+2*a[c++]),te(3,4,9,14,t,n+2*a[c++]),ne(3,4,9,14,t,n+2*a[c++]);this.v0l^=y[0]^y[16],this.v0h^=y[1]^y[17],this.v1l^=y[2]^y[18],this.v1h^=y[3]^y[19],this.v2l^=y[4]^y[20],this.v2h^=y[5]^y[21],this.v3l^=y[6]^y[22],this.v3h^=y[7]^y[23],this.v4l^=y[8]^y[24],this.v4h^=y[9]^y[25],this.v5l^=y[10]^y[26],this.v5h^=y[11]^y[27],this.v6l^=y[12]^y[28],this.v6h^=y[13]^y[29],this.v7l^=y[14]^y[30],this.v7h^=y[15]^y[31],y.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Me=kr(e=>new Tr(e)),jt=new TextEncoder().encode("SS58PRE"),Qe=2,Rt=e=>{try{const t=Ut.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qe),s=t.subarray(n.length+r.length),o=Me(Uint8Array.of(...jt,...n,...r),{dkLen:64}).subarray(0,Qe);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Cr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Cr=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Pt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Me(Uint8Array.of(...jt,...t,...n),{dkLen:64}).subarray(0,Qe);return Ut.encode(Uint8Array.of(...t,...n,...r))}};function Hr(e,t){return n=>{const r=Rt(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const Ze=(e=42,t=32)=>K(D(t),Hr(t),Pt(e)),Nt="0123456789abcdef";function re(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Nt[r>>4]+Nt[r&15]}return t.join("")}const et={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Ve(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|et[e[2]]);for(let o=0;o<r;){const c=n+o*2,a=et[e[c]],f=et[e[c+1]];s[t+o++]=a<<4|f}return s}function qt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const be=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n};var Mr=Object.defineProperty,Ft=e=>{throw TypeError(e)},Vr=(e,t,n)=>t in e?Mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>Vr(e,typeof t!="symbol"?t+"":t,n),Xt=(e,t,n)=>t.has(e)||Ft("Cannot "+n),G=(e,t,n)=>(Xt(e,t,"read from private field"),n?n.call(e):t.get(e)),Ee=(e,t,n)=>t.has(e)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),he=(e,t,n,r)=>(Xt(e,t,"write to private field"),t.set(e,n),n),Y,xe,je,Re,Pe;const jr=new TextEncoder,Rr=new TextDecoder,Pr=F(T,D(1/0))[1];class de{constructor(t,n=!1){if(Ee(this,Y),Ee(this,xe,null),Ee(this,je,null),Ee(this,Re,null),Ee(this,Pe,null),ke(this,"asText",()=>G(this,Pe)??he(this,Pe,Rr.decode(G(this,Y)))),ke(this,"asHex",()=>G(this,je)||he(this,je,re(G(this,Y)))),ke(this,"asOpaqueHex",()=>G(this,Re)||he(this,Re,re(this.asBytes()))),ke(this,"asBytes",()=>G(this,Y)),ke(this,"asOpaqueBytes",()=>G(this,xe)||he(this,xe,be(T[0](G(this,Y).length),G(this,Y)))),n){try{const[r,s]=Pr(t);if(r===s.length){he(this,Y,s),he(this,xe,t);return}}catch{}throw new Error("Invalid opaque bytes")}else he(this,Y,t)}static fromText(t){return new this(jr.encode(t))}static fromHex(t){return new this(Ve(t))}static fromOpaqueHex(t){return new this(Ve(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Y=new WeakMap,xe=new WeakMap,je=new WeakMap,Re=new WeakMap,Pe=new WeakMap;const[Nr]=Ze();class Kt extends de{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Nr(t))}}const Wt=e=>{const t=D.enc(e);return n=>t(n.asBytes())},zt=e=>{const t=D.dec(e),n=e==null?de:Kt;return r=>n.fromBytes(t(r))},Be=e=>x(Wt(e),zt(e));Be.enc=Wt,Be.dec=zt;const w=T,qr=T,Fr=We(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:D(n).dec(e),bitsLen:t}}),Gt=x(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Fr),Xr=K(L,e=>e.charCodeAt(0),String.fromCharCode),Yt=e=>{const t=D.enc(e);return n=>t(Ve(n))},Jt=e=>{const t=D.dec(e);return n=>re(t(n))},se=e=>x(Yt(e),Jt(e));se.enc=Yt,se.dec=Jt;const Kr=new TextEncoder,Wr=new TextDecoder,zr=e=>K(D(e),t=>Kr.encode(t),t=>Wr.decode(t)),Qt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Zt=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},en=e=>x(Qt(()=>e().enc),Zt(()=>e().dec)),tt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Gr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),tn=(...e)=>{const t=q.enc(...e);return n=>t({tag:n.type,value:n.value})},nn=(...e)=>{const t=q.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},fe=(e,...t)=>x(tn(qt(e,([n])=>n),...t),nn(qt(e,([,n])=>n),...t));fe.enc=tn,fe.dec=nn;const rn=[],sn=[],on=[],Yr=BigInt(0),Ie=BigInt(1),Jr=BigInt(2),Qr=BigInt(7),Zr=BigInt(256),es=BigInt(113);for(let e=0,t=Ie,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],rn.push(2*(5*r+n)),sn.push((e+1)*(e+2)/2%64);let s=Yr;for(let o=0;o<7;o++)t=(t<<Ie^(t>>Qr)*es)%Zr,t&Jr&&(s^=Ie<<(Ie<<BigInt(o))-Ie);on.push(s)}const[ts,ns]=Tt(on,!0),cn=(e,t,n)=>n>32?Mt(e,t,n):Ct(e,t,n),an=(e,t,n)=>n>32?Vt(e,t,n):Ht(e,t,n);function rs(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const a=(c+8)%10,f=(c+2)%10,i=n[f],u=n[f+1],d=cn(i,u,1)^n[a],h=an(i,u,1)^n[a+1];for(let l=0;l<50;l+=10)e[c+l]^=d,e[c+l+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const a=sn[c],f=cn(s,o,a),i=an(s,o,a),u=rn[c];s=e[u],o=e[u+1],e[u]=f,e[u+1]=i}for(let c=0;c<50;c+=10){for(let a=0;a<10;a++)n[a]=e[c+a];for(let a=0;a<10;a++)e[c+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=ts[r],e[1]^=ns[r]}n.fill(0)}class nt extends Dt{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,le(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ue(this.state)}keccak(){C||H(this.state32),rs(this.state32,this.rounds),C||H(this.state32),this.posOut=0,this.pos=0}update(t){ve(this);const{blockLen:n,state:r}=this;t=z(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let a=0;a<c;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ve(this,!1),$e(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return le(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:c}=this;return t||(t=new nt(n,r,s,c,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=c,t.destroyed=this.destroyed,t}}const ss=((e,t,n)=>vr(()=>new nt(t,e,n)))(1,136,256/8),ln=e=>{const t=e.slice(2),n=re(ss(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},os=D(20)[1],un=x(e=>{const t=Ve(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=re(t);if(e===n||e===n.toUpperCase())return t;if(ln(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},We(e=>ln(re(os(e))))),hn=new TextEncoder,dn=new TextDecoder,cs=K(D(4),hn.encode.bind(hn),dn.decode.bind(dn)),rt=m({engine:cs,payload:se()}),is=fe({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:v},[4,5,6,8]),st=se(32),as=m({parentHash:st,number:w,stateRoot:st,extrinsicRoot:st,digests:B(is)}),J=B(A),fn=V(A),ls=q({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v}),yn=B(m({name:fn,type:w,typeName:fn,docs:J})),us=m({len:ee,type:w}),hs=m({bitStoreType:w,bitOrderType:w}),ds=B(m({name:A,fields:yn,index:L,docs:J})),fs=q({composite:yn,variant:ds,sequence:w,array:us,tuple:B(w),primitive:ls,compact:w,bitSequence:hs}),ys=m({name:A,type:V(w)}),ps=B(ys),gs=m({id:w,path:J,params:ps,def:fs,docs:J}),Ne=B(gs),bs=q({Blake2128:v,Blake2256:v,Blake2128Concat:v,Twox128:v,Twox256:v,Twox64Concat:v,Identity:v}),ws=B(bs),ms=m({hashers:ws,key:w,value:w}),vs=m({name:A,modifier:L,type:q({plain:w,map:ms}),fallback:se(),docs:J}),ks=V(m({prefix:A,items:B(vs)})),pn={name:A,storage:ks,calls:V(w),events:V(w),constants:B(m({name:A,type:w,value:se(),docs:J})),errors:V(w),index:L},Es={...pn,docs:J},xs=new Uint8Array,gn=e=>x(()=>xs,()=>e),Bs=m({type:w,version:L,signedExtensions:B(m({identifier:A,type:w,additionalSigned:w}))}),bn=m({lookup:Ne,pallets:B(m({...pn,docs:gn([])})),extrinsic:Bs,type:w,apis:gn([])}),Is=m({name:A,methods:B(m({name:A,inputs:B(m({name:A,type:w})),output:w,docs:J})),docs:J}),As=m({version:L,address:w,call:w,signature:w,extra:w,signedExtensions:B(m({identifier:A,type:w,additionalSigned:w}))}),wn=m({lookup:Ne,pallets:B(m(Es)),extrinsic:As,type:w,apis:B(Is),outerEnums:m({call:w,event:w,error:w}),custom:B(F(A,m({type:w,value:se()})))}),mn=()=>{throw new Error("Unsupported metadata version!")},j=x(mn,mn),Ae=m({magicNumber:ee,metadata:q({v0:j,v1:j,v2:j,v3:j,v4:j,v5:j,v6:j,v7:j,v8:j,v9:j,v10:j,v11:j,v12:j,v13:j,v14:bn,v15:wn})}),ot=D(),Os=V(ot),_s=F(T,ot),Ls=e=>{try{return Ae.dec(e)}catch{}try{return Ae.dec(Os.dec(e))}catch{}try{return Ae.dec(ot.dec(e))}catch{}try{return Ae.dec(_s.dec(e)[1])}catch{}throw null},Us={dkLen:32},Ss=e=>Me(e,Us),Ds={dkLen:16},vn=e=>Me(e,Ds),kn=e=>be(vn(e),e),Q=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function oe(e,t,n,r,s){return e=e+t+s|0,r=Te(r^e,16),n=n+r|0,t=Te(t^n,12),{a:e,b:t,c:n,d:r}}function ce(e,t,n,r,s){return e=e+t+s|0,r=Te(r^e,8),n=n+r|0,t=Te(t^n,7),{a:e,b:t,c:n,d:r}}function En(e,t,n,r,s,o,c,a,f,i,u,d,h,l,p,g,b,k,_,R){let I=0;for(let pe=0;pe<r;pe++)({a:s,b:f,c:h,d:b}=oe(s,f,h,b,n[t+e[I++]])),{a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[I++]]),{a:o,b:i,c:l,d:k}=oe(o,i,l,k,n[t+e[I++]]),{a:o,b:i,c:l,d:k}=ce(o,i,l,k,n[t+e[I++]]),{a:c,b:u,c:p,d:_}=oe(c,u,p,_,n[t+e[I++]]),{a:c,b:u,c:p,d:_}=ce(c,u,p,_,n[t+e[I++]]),{a,b:d,c:g,d:R}=oe(a,d,g,R,n[t+e[I++]]),{a,b:d,c:g,d:R}=ce(a,d,g,R,n[t+e[I++]]),{a:s,b:i,c:p,d:R}=oe(s,i,p,R,n[t+e[I++]]),{a:s,b:i,c:p,d:R}=ce(s,i,p,R,n[t+e[I++]]),{a:o,b:u,c:g,d:b}=oe(o,u,g,b,n[t+e[I++]]),{a:o,b:u,c:g,d:b}=ce(o,u,g,b,n[t+e[I++]]),{a:c,b:d,c:h,d:k}=oe(c,d,h,k,n[t+e[I++]]),{a:c,b:d,c:h,d:k}=ce(c,d,h,k,n[t+e[I++]]),{a,b:f,c:l,d:_}=oe(a,f,l,_,n[t+e[I++]]),{a,b:f,c:l,d:_}=ce(a,f,l,_,n[t+e[I++]]);return{v0:s,v1:o,v2:c,v3:a,v4:f,v5:i,v6:u,v7:d,v8:h,v9:l,v10:p,v11:g,v12:b,v13:k,v14:_,v15:R}}const xn=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class ct extends $t{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,le(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=z(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=ue(r),C||H(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new ct({dkLen:32},32).update(t.context).digest();this.IV=ue(r),C||H(this.IV),this.flags=n|64}else this.IV=Q.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=wr(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:a,l:f}=He(BigInt(t),!0),{v0:i,v1:u,v2:d,v3:h,v4:l,v5:p,v6:g,v7:b,v8:k,v9:_,v10:R,v11:I,v12:pe,v13:Fe,v14:Xe,v15:so}=En(xn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Q[0],Q[1],Q[2],Q[3],a,f,c,n);o[0]=i^k,o[1]=u^_,o[2]=d^R,o[3]=h^I,o[4]=l^pe,o[5]=p^Fe,o[6]=g^Xe,o[7]=b^so}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=1),(this.chunkPos===15||r)&&(s|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let c,a=this.chunksDone+1;(r||!(a&1))&&(c=this.stack.pop());a>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:c,chunkOut:a,stack:f,chunksDone:i}=this;return t.state.set(s.slice()),t.stack=f.map(u=>Uint32Array.from(u)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=i,t.posOut=c,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:c,l:a}=He(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:i,v2:u,v3:d,v4:h,v5:l,v6:p,v7:g,v8:b,v9:k,v10:_,v11:R,v12:I,v13:pe,v14:Fe,v15:Xe}=En(xn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Q[0],Q[1],Q[2],Q[3],a,c,n,r);o[0]=f^b,o[1]=i^k,o[2]=u^_,o[3]=d^R,o[4]=h^I,o[5]=l^pe,o[6]=p^Fe,o[7]=g^Xe,o[8]=t[0]^b,o[9]=t[1]^k,o[10]=t[2]^_,o[11]=t[3]^R,o[12]=t[4]^I,o[13]=t[5]^pe,o[14]=t[6]^Fe,o[15]=t[7]^Xe,C||(H(s),H(o)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,C||H(this.buffer32),this.compress(this.buffer32,0,!0),C||H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){ve(this,!1),$e(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return le(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const $s=Er(e=>new ct(e)),Ts={dkLen:32},Bn=e=>$s(e,Ts),Cs=e=>be(Bn(e),e),In=e=>e,ye=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),it=2n**64n-1n,$=(e,t)=>e<<t&it|e>>64n-t,E=(e,t)=>e*t&it,U=(e,t)=>e+t&it,S=11400714785074694791n,P=14029467366897019727n,An=1609587929392839161n,Oe=9650029242287828579n,On=2870177450012600261n;function ie(e,t=0n){let n=U(U(t,S),P),r=U(t,P),s=t,o=t-S,c=e.length,a=0,f=null;(function(){let l=0,p=l+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),a),a+=c;return}if(l<=p-32){const g=p-32;do{let b;b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),n=E($(U(n,E(b,P)),31n),S),l+=8,b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),r=E($(U(r,E(b,P)),31n),S),l+=8,b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),s=E($(U(s,E(b,P)),31n),S),l+=8,b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),o=E($(U(o,E(b,P)),31n),S),l+=8}while(l<=g)}l<p&&(f.set(e.subarray(l,p),a),a=p-l)}})(),e=f||e;let i,u=0;for(c>=32?(i=$(n,1n),i=U(i,$(r,7n)),i=U(i,$(s,12n)),i=U(i,$(o,18n)),n=E($(E(n,P),31n),S),i=i^n,i=U(E(i,S),Oe),r=E($(E(r,P),31n),S),i=i^r,i=U(E(i,S),Oe),s=E($(E(s,P),31n),S),i=i^s,i=U(E(i,S),Oe),o=E($(E(o,P),31n),S),i=i^o,i=U(E(i,S),Oe)):i=U(t,On),i=U(i,BigInt(c));u<=a-8;){let h=ye(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],e[u+5]<<8|e[u+4],e[u+7]<<8|e[u+6]);h=E($(E(h,P),31n),S),i=U(E($(i^h,27n),S),Oe),u+=8}if(u+4<=a){let h=E(ye(e[u+1]<<8|e[u],e[u+3]<<8|e[u+2],0,0),S);i=U(E($(i^h,23n),P),An),u+=4}for(;u<a;){const h=E(ye(e[u++],0,0,0),On);i=E($(i^h,11n),S)}let d=i>>33n;return i=E(i^d,P),d=i>>29n,i=E(i^d,An),d=i>>32n,i^=d,i}const at=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ie(e),!0),n.setBigUint64(8,ie(e,1n),!0),t},Hs=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ie(e),!0),n.setBigUint64(8,ie(e,1n),!0),n.setBigUint64(16,ie(e,2n),!0),n.setBigUint64(24,ie(e,3n),!0),t},_n=e=>be(Se.enc(ie(e)),e),Ln=new TextEncoder;var Ms=Object.freeze({__proto__:null,AccountId:Ze,Bin:Be,Binary:de,Blake2128:vn,Blake2128Concat:kn,Blake2256:Ss,Blake3256:Bn,Blake3256Concat:Cs,Bytes:D,Enum:tt,FixedSizeBinary:Kt,Hex:se,Identity:In,Option:V,Result:De,ScaleEnum:q,Self:en,Storage:e=>{const t=at(Ln.encode(e));return(n,r,...s)=>{const o=be(t,at(Ln.encode(n))),c=re(o),a=s.map(d=>d[1]).map(d=>{switch(d){case In:return 0;case _n:return 8;case kn:return 16;default:return null}}).filter(d=>d!==null),f=d=>{if(!d.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(a.length!==s.length)throw new Error("Impossible to decode this key");if(s.length===0)return[];const h=d.slice(c.length),l=new Array(s.length);for(let p=0,g=0;p<a.length;p++){const b=s[p][0];g+=a[p],l[p]=b.dec(h.slice(g*2)),g+=b.enc(l[p]).length}return l},i=s.map(([{enc:d},h])=>l=>h(d(l)));return{enc:(...d)=>re(be(o,...d.map((h,l)=>i[l](h)))),dec:r,keyDecoder:f}}},Struct:m,Tuple:F,Twox128:at,Twox256:Hs,Twox64Concat:_n,Variant:fe,Vector:B,_Enum:Gr,_void:v,bitSequence:Gt,blockHeader:as,bool:Ge,char:Xr,compact:T,compactBn:qr,compactNumber:w,createCodec:x,createDecoder:We,decAnyMetadata:Ls,enhanceCodec:K,enhanceDecoder:Ue,enhanceEncoder:ze,ethAccount:un,fixedStr:zr,fromBufferToBase58:Pt,getSs58AddressInfo:Rt,h64:ie,i128:Wn,i16:qn,i256:Gn,i32:Fn,i64:Xn,i8:Nn,metadata:Ae,selfDecoder:Zt,selfEncoder:Qt,str:A,u128:Kn,u16:me,u256:zn,u32:ee,u64:Se,u8:L,v14:bn,v14Lookup:Ne,v15:wn});const Vs=(e,t,n)=>(r,s,o,...c)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(o.has(a)){const i=t(()=>s.get(a),r,...c);return s.set(a,i),i}o.add(a);let f=e(r,s,o,...c);return o.delete(a),s.has(a)&&(f=n(f,s.get(a),r,...c)),s.set(a,f),f},js=Be(),Rs=x(T[0],Ue(T[1],BigInt)),Un=Vs((e,t,n,r)=>{if(e.type==="primitive")return Ms[e.value];if(e.type==="void")return v;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return un;if(e.type==="compact")return e.isBig?Rs:T;if(e.type==="bitSequence")return Gt;const s=l=>Un(l,t,n,r),o=(l,p)=>{const g=s(l);return p?B(g,p):B(g)},c=l=>F(...l.map(s)),a=l=>{const p=Object.fromEntries(Object.entries(l).map(([g,b])=>[g,s(b)]));return m(p)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return js;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Be(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return V(s(e.value));if(e.type==="result")return De(s(e.value.ok),s(e.value.ko));const f=Object.values(e.value).map(l=>{switch(l.type){case"void":return v;case"lookupEntry":return s(l.value);case"tuple":return c(l.value);case"struct":return a(l.value);case"array":return o(l.value,l.len)}}),i=Object.fromEntries(Object.keys(e.value).map((l,p)=>[l,f[p]])),u=Object.values(e.value).map(l=>l.idx),h=u.every((l,p)=>l===p)?fe(i):fe(i,u);return e.byteLength?Ns(h,e.byteLength):h},en,e=>e),Ps=(e,t=Ze())=>{const n=new Map,r=s=>Un(e(s),n,new Set,t);return s=>r(s)},Ns=(e,t)=>{const n=D(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},qs=e=>{const{metadata:t}=e,n=Ps(e),r=i=>{if("root"in i)return r(i.root.layout);if("leaf"in i)return n(i.leaf.ty);if("hash"in i)throw new Error("HashLayout not implemented");if("array"in i)return B(r(i.array.layout),i.array.len);if("struct"in i)return m(Object.fromEntries(i.struct.fields.map(d=>[d.name,r(d.layout)])));const u=Object.values(i.enum.variants);if(i.enum.name==="Option"&&u.length===2&&u[0].name==="None"&&u[1].name==="Some"){const d=u[1].fields.length===1?r(u[1].fields[0].layout):F(...u[1].fields.map(h=>r(h.layout)));return V(d)}return q(Object.fromEntries(Object.values(i.enum.variants).map(d=>[d.name,m(Object.fromEntries(d.fields.map(h=>[h.name,r(h.layout)])))])))},s=()=>r(t.storage),o=i=>{const u=de.fromHex(i.selector).asBytes(),d=m(Object.fromEntries(i.args.map(l=>[l.label,n(l.type.type)]))),h=F(D(4),d);return{call:K(h,l=>[u,l],([,l])=>l),value:n(i.returnType.type)}};return{buildConstructor:i=>{const u=t.spec.constructors.find(d=>d.label===i);if(!u)throw new Error(`Constructor ${i} not found`);return o(u)},buildMessage:i=>{const u=t.spec.messages.find(d=>d.label===i);if(!u)throw new Error(`Message ${i} not found`);return o(u)},buildStorageRoot:s,buildEvent:()=>fe(Object.fromEntries(t.spec.events.map(i=>[i.label,m(Object.fromEntries(i.args.map(u=>[u.label,n(u.type.type)])))])))}},Sn=e=>K(q(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),_e=(e,t)=>K(B(e,t),n=>n??[],n=>n),Dn=V(A),qe=_e(A),Fs=Sn({bool:v,char:v,str:v,u8:v,u16:v,u32:v,u64:v,u128:v,u256:v,i8:v,i16:v,i32:v,i64:v,i128:v,i256:v}),$n=_e(m({name:Dn,type:w,typeName:Dn,docs:qe})),Xs=m({len:ee,type:w}),Ks=m({bitStoreType:w,bitOrderType:w}),Ws=_e(m({name:A,fields:$n,index:L,docs:qe})),zs=Sn({composite:m({fields:$n}),variant:m({variants:Ws}),sequence:m({type:w}),array:Xs,tuple:B(w),primitive:Fs,compact:w,bitSequence:Ks}),Gs=m({name:A,type:V(w)}),Ys=_e(Gs),Js=m({id:w,path:qe,params:Ys,def:zs,docs:qe}),Qs=K(Js,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),Zs=_e(Qs),eo=e=>{const t=Zs.enc(e.types),n=Ne.dec(t),r=e.spec.environment.accountId.type,s=n.find(c=>c.id===r);s&&(s.path=["AccountId32"]);const o=Hn(n);return Object.assign(o,{metadata:e})},to=e=>{const t=eo(e.metadata),n=qs(t);return{constructor:Tn(n.buildConstructor),message:Tn(n.buildMessage),storage:no(t,n.buildStorageRoot),event:ro(n.buildEvent)}},Tn=e=>t=>{const n=e(t);return{encode:r=>de.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},no=(e,t)=>{const{metadata:n}=e,r=de.fromHex(n.storage.root.root_key);return{rootKey:Number(n.version)===4?de.fromBytes(r.asBytes().reverse()):r,decodeRoot:o=>t().dec(o.asBytes())}},ro=e=>{const t=n=>e().dec(n.data.asBytes());return{decode:t,filter:(n,r=[])=>r.map(s=>"event"in s?s.event:s).filter(s=>s.type==="Contracts"&&s.value.type==="ContractEmitted"&&s.value.value.contract===n).map(s=>{try{return t(s.value.value)}catch(o){throw console.error(`Contract ${n} emitted an incompatible event`,s.value.value),o}})}};we.getInkClient=to});
1
+ (function(we,ge){typeof exports=="object"&&typeof module<"u"?ge(exports):typeof define=="function"&&define.amd?define(["exports"],ge):(we=typeof globalThis<"u"?globalThis:we||self,ge(we.papiInk={}))})(this,function(we){"use strict";const ge=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",le={type:"void"},Hn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=h=>f=>{let d=n.get(f);if(d)return d;if(r.has(f)){const y={id:f};return n.set(f,y),y}r.add(f);const l=h(f);return d=n.get(f),d?Object.assign(d,l):(d={id:f,...l},n.set(f,d)),r.delete(f),d};let o=!0,c=!0;const a=s(h=>{const f=t(e[h]);if(f)return f;const{def:d,path:l,params:y}=e[h];if(d.tag==="composite"){if(d.value.length===0)return le;if(d.value.length===1){const p=a(d.value[0].type);return o&&l.at(-1)==="AccountId32"&&ge(p,32)?(o=!1,{type:"AccountId32"}):c&&l.at(-1)==="AccountId20"&&ge(p,20)?(c=!1,{type:"AccountId20"}):p}return u(d.value)}if(d.tag==="variant"){if(l.length===1&&l[0]==="Option"&&y.length===1&&y[0].name==="T"){const k=a(y[0].type);return k.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:k}}if(l.length===1&&l[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:a(y[0].type),ko:a(y[1].type)}};if(d.value.length===0)return le;const p={},b={};return d.value.forEach(k=>{const _=k.name;if(b[_]=k.docs,k.fields.length===0){p[_]={...le,idx:k.index};return}if(k.fields.length===1&&!k.fields[0].name){p[_]={type:"lookupEntry",value:a(k.fields[0].type),idx:k.index};return}p[_]={...u(k.fields),idx:k.index}}),{type:"enum",value:p,innerDocs:b}}if(d.tag==="sequence")return{type:"sequence",value:a(d.value)};if(d.tag==="array"){const{len:p}=d.value,b=a(d.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:d.value.len}:b}if(d.tag==="tuple")return d.value.length===0?le:d.value.length>1?i(d.value.map(p=>a(p)),d.value.map(p=>e[p].docs)):a(d.value[0]);if(d.tag==="primitive")return{type:"primitive",value:d.value.tag};if(d.tag==="compact"){const p=a(d.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32}}return{type:d.tag}}),u=h=>{let f=!0;const d={},l={};return h.forEach((y,p)=>{f=f&&!!y.name;const b=y.name||p,k=a(y.type);k.type!=="void"&&(d[b]=k,l[b]=y.docs)}),f?{type:"struct",value:d,innerDocs:l}:i(Object.values(d),Object.values(l))},i=(h,f)=>{if(h.every(d=>d.id===h[0].id)&&f.every(d=>!d.length)){const[d]=h;return d.type==="void"?le:{type:"array",value:h[0],len:h.length}}return{type:"tuple",value:h,innerDocs:f}};return a},Vn=e=>Hn(e);var Mn=Object.defineProperty,jn=(e,t,n)=>t in e?Mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n)=>(jn(e,typeof t!="symbol"?t+"":t,n),n),Ke={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Pn(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|Ke[e[2]]);for(let o=0;o<r;){const c=n+o*2,a=Ke[e[c]],u=Ke[e[c+1]];s[t+o++]=a<<4|u}return s}var ut=class extends Uint8Array{constructor(e){super(e),lt(this,"i",0),lt(this,"v"),this.v=new DataView(e)}},R=e=>t=>e(t instanceof ut?t:new ut(t instanceof Uint8Array?t.buffer:typeof t=="string"?Pn(t).buffer:t)),F=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].byteLength;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const c=e[s];r.set(c,o),o+=c.byteLength}return r};function Le(e,t){const n=Object.keys(e),r=n.length,s={};for(let o=0;o<r;o++){const c=n[o];s[c]=t(e[c],c)}return s}var ze=R,E=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},We=(e,t)=>n=>e(t(n)),Ue=(e,t)=>n=>t(e(n)),X=([e,t],n,r)=>E(We(e,n),Ue(t,r));function Nn(e,t){return R(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Rn(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function Z(e,t,n){return E(Rn(e,n),Nn(e,t))}var L=Z(1,"getUint8","setUint8"),me=Z(2,"getUint16","setUint16"),ee=Z(4,"getUint32","setUint32"),Se=Z(8,"getBigUint64","setBigUint64"),qn=Z(1,"getInt8","setInt8"),Fn=Z(2,"getInt16","setInt16"),Xn=Z(4,"getInt32","setInt32"),Kn=Z(8,"getBigInt64","setBigInt64"),ht=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},dt=e=>R(t=>{const{v:n,i:r}=t,s=n.getBigUint64(r,!0),o=n[e](r+8,!0);return t.i+=16,o<<64n|s}),zn=E(ht,dt("getBigUint64")),Wn=E(ht,dt("getBigInt64")),ft=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),n.setBigInt64(16,e>>128n,!0),n.setBigInt64(24,e>>192n,!0),t},yt=e=>R(t=>{let n=t.v.getBigUint64(t.i,!0);return t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<64n,t.i+=8,n|=t.v.getBigUint64(t.i,!0)<<128n,t.i+=8,n|=t.v[e](t.i,!0)<<192n,t.i+=8,n}),Gn=E(ft,yt("getBigUint64")),Yn=E(ft,yt("getBigInt64")),Ge=X(L,e=>e?1:0,Boolean),Jn=[L[1],me[1],ee[1]],Qn=R(e=>{const t=e[e.i],n=t&3;if(n<3)return Jn[n](e)>>>2;const r=(t>>>2)+4;e.i++;let s=0n;const o=r/8|0;let c=0n;for(let u=0;u<o;u++)s=Se[1](e)<<c|s,c+=64n;let a=r%8;return a>3&&(s=BigInt(ee[1](e))<<c|s,c+=32n,a-=4),a>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,a-=2),a&&(s=BigInt(L[1](e))<<c|s),s}),Zn=1n<<56n,er=1<<24,tr=256,nr=4294967295n,rr=64,sr=16384,or=1<<30,cr=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<rr)return L[0](t);if(e<sr)return me[0](t|1);if(e<or)return ee[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=Zn;)n.push(Se[0](r)),r>>=64n;r>=er&&(n.push(ee[0](Number(r&nr))),r>>=32n);let s=Number(r);s>=tr&&(n.push(me[0](s)),s>>=16),s&&n.push(L[0](s));const o=F(n);return o[0]=o.length-5<<2|3,o},T=E(cr,Qn),ir=new TextEncoder,ar=e=>{const t=ir.encode(e);return F([T.enc(t.length),t])},lr=new TextDecoder,ur=R(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,lr.decode(n)}),A=E(ar,ur),hr=()=>{},dr=new Uint8Array(0),m=E(()=>dr,hr),pt=e=>e===void 0?t=>F([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),gt=e=>R(t=>{const n=e===void 0?T.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),D=e=>E(pt(e),gt(e));D.enc=pt,D.dec=gt;var bt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,c)=>[n[c],o])??n.map((o,c)=>[o,c])),s=o=>r.get(o);return({tag:o,value:c})=>F([L.enc(s(o)),e[o](c)])},wt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return R(s=>{const o=L.dec(s),c=r.get(o),a=e[c];return{tag:c,value:a(s)}})},q=(e,...t)=>E(bt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));q.enc=bt,q.dec=wt;var mt=e=>R(t=>{const n=L.dec(t);if(n!==0)return e===Ge[1]?n===1:e(t)}),vt=e=>t=>{const n=new Uint8Array(1);return t===void 0?(n[0]=0,n):(n[0]=1,e===Ge[0]?(n[0]=t?1:2,n):F([n,e(t)]))},P=e=>E(vt(e[0]),mt(e[1]));P.enc=vt,P.dec=mt;var kt=(e,t)=>R(n=>{const r=L[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),xt=(e,t)=>({success:n,value:r})=>F([L[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>E(xt(e[0],t[0]),kt(e[1],t[1]));De.dec=kt,De.enc=xt;var Et=(...e)=>R(t=>e.map(n=>n(t))),Bt=(...e)=>t=>F(e.map((n,r)=>n(t[r]))),K=(...e)=>E(Bt(...e.map(([t])=>t)),Et(...e.map(([,t])=>t)));K.enc=Bt,K.dec=Et;var It=e=>{const t=Object.keys(e);return We(K.enc(...Object.values(e)),n=>t.map(r=>n[r]))},At=e=>{const t=Object.keys(e);return Ue(K.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>E(It(Le(e,t=>t[0])),At(Le(e,t=>t[1])));v.enc=It,v.dec=At;var Ot=(e,t)=>t>=0?n=>F(n.map(e)):n=>F([T.enc(n.length),F(n.map(e))]),_t=(e,t)=>R(n=>{const r=t>=0?t:T.dec(n),s=new Array(r);for(let o=0;o<r;o++)s[o]=e(n);return s}),B=(e,t)=>E(Ot(e[0],t),_t(e[1],t));B.enc=Ot,B.dec=_t;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function fr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function yr(...e){const t=o=>o,n=(o,c)=>a=>o(c(a)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function pr(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function gr(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Lt(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(c=>{if(c<0||c>=t)throw new Error(`Wrong integer: ${c}`)});;){let c=0,a=!0;for(let u=r;u<o.length;u++){const i=o[u],h=t*c+i;if(!Number.isSafeInteger(h)||t*c/t!==c||h-i!==t*c)throw new Error("convertRadix: carry overflow");c=h%n;const f=Math.floor(h/n);if(o[u]=f,!Number.isSafeInteger(f)||f*n+c!==h)throw new Error("convertRadix: carry overflow");if(a)f?a=!1:r=u;else continue}if(s.push(c),a)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function br(e){return{encode:t=>{if(!fr(t))throw new Error("radix.encode input should be Uint8Array");return Lt(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(Lt(t,e,2**8))}}}const Ut=(e=>yr(br(58),pr(e),gr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function wr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function $e(e,...t){if(!wr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ve(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ye(e,t){$e(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mr=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),he=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Te=(e,t)=>e<<32-t|e>>>t,C=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,St=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,z=C?e=>e:e=>St(e);function H(e){for(let t=0;t<e.length;t++)e[t]=St(e[t])}function vr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=vr(e)),$e(e),e}class Dt{clone(){return this._cloneInto()}}function kr(e){const t=r=>e().update(W(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function xr(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function Er(e){const t=(r,s)=>e(s).update(W(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Br=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3]);class $t extends Dt{constructor(t,n,r={},s,o,c){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ue(t),ue(n),ue(s),n<0||n>s)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>s))throw new Error(`key must be up 1..${s} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==o)throw new Error(`salt must be ${o} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==c)throw new Error(`personalization must be ${c} byte long or undefined`);this.buffer32=he(this.buffer=new Uint8Array(t))}update(t){ve(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=W(t);const o=t.length,c=t.byteOffset,a=t.buffer;for(let u=0;u<o;){this.pos===n&&(C||H(s),this.compress(s,0,!1),C||H(s),this.pos=0);const i=Math.min(n-this.pos,o-u),h=c+u;if(i===n&&!(h%4)&&u+i<o){const f=new Uint32Array(a,h,Math.floor((o-u)/4));C||H(f);for(let d=0;u+n<o;d+=s.length,u+=n)this.length+=n,this.compress(f,d,!1);C||H(f);continue}r.set(t.subarray(u,u+i),this.pos),this.pos+=i,this.length+=i,u+=i}return this}digestInto(t){ve(this),Ye(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),C||H(r),this.compress(r,0,!0),C||H(r);const s=he(t);this.get().forEach((o,c)=>s[c]=z(o))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:s,destroyed:o,outputLen:c,pos:a}=this;return t||(t=new this.constructor({dkLen:c})),t.set(...this.get()),t.length=r,t.finished=s,t.destroyed=o,t.outputLen=c,t.buffer.set(n),t.pos=a,t}}const Ce=BigInt(2**32-1),Je=BigInt(32);function He(e,t=!1){return t?{h:Number(e&Ce),l:Number(e>>Je&Ce)}:{h:Number(e>>Je&Ce)|0,l:Number(e&Ce)|0}}function Tt(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:c}=He(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const Ir=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),Ar=(e,t,n)=>e>>>n,Or=(e,t,n)=>e<<32-n|t>>>n,_r=(e,t,n)=>e>>>n|t<<32-n,Lr=(e,t,n)=>e<<32-n|t>>>n,Ur=(e,t,n)=>e<<64-n|t>>>n-32,Sr=(e,t,n)=>e>>>n-32|t<<64-n,Dr=(e,t)=>t,$r=(e,t)=>e,Ct=(e,t,n)=>e<<n|t>>>32-n,Ht=(e,t,n)=>t<<n|e>>>32-n,Vt=(e,t,n)=>t<<n-32|e>>>64-n,Mt=(e,t,n)=>e<<n-32|t>>>64-n;function Tr(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const V={fromBig:He,split:Tt,toBig:Ir,shrSH:Ar,shrSL:Or,rotrSH:_r,rotrSL:Lr,rotrBH:Ur,rotrBL:Sr,rotr32H:Dr,rotr32L:$r,rotlSH:Ct,rotlSL:Ht,rotlBH:Vt,rotlBL:Mt,add:Tr,add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,add5H:(e,t,n,r,s,o)=>t+n+r+s+o+(e/2**32|0)|0,add5L:(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0)},O=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function te(e,t,n,r,s,o){const c=s[o],a=s[o+1];let u=g[2*e],i=g[2*e+1],h=g[2*t],f=g[2*t+1],d=g[2*n],l=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(u,h,c);i=V.add3H(b,i,f,a),u=b|0,{Dh:p,Dl:y}={Dh:p^i,Dl:y^u},{Dh:p,Dl:y}={Dh:V.rotr32H(p,y),Dl:V.rotr32L(p,y)},{h:l,l:d}=V.add(l,d,p,y),{Bh:f,Bl:h}={Bh:f^l,Bl:h^d},{Bh:f,Bl:h}={Bh:V.rotrSH(f,h,24),Bl:V.rotrSL(f,h,24)},g[2*e]=u,g[2*e+1]=i,g[2*t]=h,g[2*t+1]=f,g[2*n]=d,g[2*n+1]=l,g[2*r]=y,g[2*r+1]=p}function ne(e,t,n,r,s,o){const c=s[o],a=s[o+1];let u=g[2*e],i=g[2*e+1],h=g[2*t],f=g[2*t+1],d=g[2*n],l=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(u,h,c);i=V.add3H(b,i,f,a),u=b|0,{Dh:p,Dl:y}={Dh:p^i,Dl:y^u},{Dh:p,Dl:y}={Dh:V.rotrSH(p,y,16),Dl:V.rotrSL(p,y,16)},{h:l,l:d}=V.add(l,d,p,y),{Bh:f,Bl:h}={Bh:f^l,Bl:h^d},{Bh:f,Bl:h}={Bh:V.rotrBH(f,h,63),Bl:V.rotrBL(f,h,63)},g[2*e]=u,g[2*e+1]=i,g[2*t]=h,g[2*t+1]=f,g[2*n]=d,g[2*n+1]=l,g[2*r]=y,g[2*r+1]=p}class Cr extends $t{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=O[0]|0,this.v0h=O[1]|0,this.v1l=O[2]|0,this.v1h=O[3]|0,this.v2l=O[4]|0,this.v2h=O[5]|0,this.v3l=O[6]|0,this.v3h=O[7]|0,this.v4l=O[8]|0,this.v4h=O[9]|0,this.v5l=O[10]|0,this.v5h=O[11]|0,this.v6l=O[12]|0,this.v6h=O[13]|0,this.v7l=O[14]|0,this.v7h=O[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=he(W(t.salt));this.v4l^=z(r[0]),this.v4h^=z(r[1]),this.v5l^=z(r[2]),this.v5h^=z(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=z(r[0]),this.v6h^=z(r[1]),this.v7l^=z(r[2]),this.v7h^=z(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(W(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:c,v3l:a,v3h:u,v4l:i,v4h:h,v5l:f,v5h:d,v6l:l,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,a,u,i,h,f,d,l,y,p,b]}set(t,n,r,s,o,c,a,u,i,h,f,d,l,y,p,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=s|0,this.v2l=o|0,this.v2h=c|0,this.v3l=a|0,this.v3h=u|0,this.v4l=i|0,this.v4h=h|0,this.v5l=f|0,this.v5h=d|0,this.v6l=l|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((u,i)=>g[i]=u),g.set(O,16);let{h:s,l:o}=V.fromBig(BigInt(this.length));g[24]=O[8]^o,g[25]=O[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const a=Br;for(let u=0;u<12;u++)te(0,4,8,12,t,n+2*a[c++]),ne(0,4,8,12,t,n+2*a[c++]),te(1,5,9,13,t,n+2*a[c++]),ne(1,5,9,13,t,n+2*a[c++]),te(2,6,10,14,t,n+2*a[c++]),ne(2,6,10,14,t,n+2*a[c++]),te(3,7,11,15,t,n+2*a[c++]),ne(3,7,11,15,t,n+2*a[c++]),te(0,5,10,15,t,n+2*a[c++]),ne(0,5,10,15,t,n+2*a[c++]),te(1,6,11,12,t,n+2*a[c++]),ne(1,6,11,12,t,n+2*a[c++]),te(2,7,8,13,t,n+2*a[c++]),ne(2,7,8,13,t,n+2*a[c++]),te(3,4,9,14,t,n+2*a[c++]),ne(3,4,9,14,t,n+2*a[c++]);this.v0l^=g[0]^g[16],this.v0h^=g[1]^g[17],this.v1l^=g[2]^g[18],this.v1h^=g[3]^g[19],this.v2l^=g[4]^g[20],this.v2h^=g[5]^g[21],this.v3l^=g[6]^g[22],this.v3h^=g[7]^g[23],this.v4l^=g[8]^g[24],this.v4h^=g[9]^g[25],this.v5l^=g[10]^g[26],this.v5h^=g[11]^g[27],this.v6l^=g[12]^g[28],this.v6h^=g[13]^g[29],this.v7l^=g[14]^g[30],this.v7h^=g[15]^g[31],g.fill(0)}destroy(){this.destroyed=!0,this.buffer32.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Ve=xr(e=>new Cr(e)),jt=new TextEncoder().encode("SS58PRE"),Qe=2,Pt=e=>{try{const t=Ut.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Qe),s=t.subarray(n.length+r.length),o=Ve(Uint8Array.of(...jt,...n,...r),{dkLen:64}).subarray(0,Qe);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:Hr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Hr=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Nt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=Ve(Uint8Array.of(...jt,...t,...n),{dkLen:64}).subarray(0,Qe);return Ut.encode(Uint8Array.of(...t,...n,...r))}};function Vr(e,t){return n=>{const r=Pt(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:s}=r;if(s.length!==e)throw new Error("Invalid public key length");return s}}const Ze=(e=42,t=32)=>X(D(t),Vr(t),Nt(e)),Rt="0123456789abcdef";function re(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Rt[r>>4]+Rt[r&15]}return t.join("")}const et={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function Me(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,s=new Uint8Array(r);t&&(s[0]=0|et[e[2]]);for(let o=0;o<r;){const c=n+o*2,a=et[e[c]],u=et[e[c+1]];s[t+o++]=a<<4|u}return s}function qt(e,t){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,t(r,n)]))}const be=(...e)=>{const t=e.reduce((r,s)=>r+s.byteLength,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.byteLength}return n};var Mr=Object.defineProperty,Ft=e=>{throw TypeError(e)},jr=(e,t,n)=>t in e?Mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>jr(e,typeof t!="symbol"?t+"":t,n),Xt=(e,t,n)=>t.has(e)||Ft("Cannot "+n),G=(e,t,n)=>(Xt(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),de=(e,t,n,r)=>(Xt(e,t,"write to private field"),t.set(e,n),n),Y,Ee,je,Pe,Ne;const Pr=new TextEncoder,Nr=new TextDecoder,Rr=K(T,D(1/0))[1];class se{constructor(t,n=!1){if(xe(this,Y),xe(this,Ee,null),xe(this,je,null),xe(this,Pe,null),xe(this,Ne,null),ke(this,"asText",()=>G(this,Ne)??de(this,Ne,Nr.decode(G(this,Y)))),ke(this,"asHex",()=>G(this,je)||de(this,je,re(G(this,Y)))),ke(this,"asOpaqueHex",()=>G(this,Pe)||de(this,Pe,re(this.asBytes()))),ke(this,"asBytes",()=>G(this,Y)),ke(this,"asOpaqueBytes",()=>G(this,Ee)||de(this,Ee,be(T[0](G(this,Y).length),G(this,Y)))),n){try{const[r,s]=Rr(t);if(r===s.length){de(this,Y,s),de(this,Ee,t);return}}catch{}throw new Error("Invalid opaque bytes")}else de(this,Y,t)}static fromText(t){return new this(Pr.encode(t))}static fromHex(t){return new this(Me(t))}static fromOpaqueHex(t){return new this(Me(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}Y=new WeakMap,Ee=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[qr]=Ze();class Kt extends se{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(qr(t))}}const zt=e=>{const t=D.enc(e);return n=>t(n.asBytes())},Wt=e=>{const t=D.dec(e),n=e==null?se:Kt;return r=>n.fromBytes(t(r))},Be=e=>E(zt(e),Wt(e));Be.enc=zt,Be.dec=Wt;const w=T,Fr=T,Xr=ze(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:D(n).dec(e),bitsLen:t}}),Gt=E(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=w.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Xr),Kr=X(L,e=>e.charCodeAt(0),String.fromCharCode),Yt=e=>{const t=D.enc(e);return n=>t(Me(n))},Jt=e=>{const t=D.dec(e);return n=>re(t(n))},oe=e=>E(Yt(e),Jt(e));oe.enc=Yt,oe.dec=Jt;const zr=new TextEncoder,Wr=new TextDecoder,Gr=e=>X(D(e),t=>zr.encode(t),t=>Wr.decode(t)),Qt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Zt=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},en=e=>E(Qt(()=>e().enc),Zt(()=>e().dec)),tt=Object.assign((e,t)=>({type:e,value:t}),{is(e,t){return e.type===t},as(e,t){if(t!==e.type)throw new Error(`Enum.as(enum, ${t}) used with actual type ${e.type}`);return e}}),Yr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),tn=(...e)=>{const t=q.enc(...e);return n=>t({tag:n.type,value:n.value})},nn=(...e)=>{const t=q.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},fe=(e,...t)=>E(tn(qt(e,([n])=>n),...t),nn(qt(e,([,n])=>n),...t));fe.enc=tn,fe.dec=nn;const rn=[],sn=[],on=[],Jr=BigInt(0),Ie=BigInt(1),Qr=BigInt(2),Zr=BigInt(7),es=BigInt(256),ts=BigInt(113);for(let e=0,t=Ie,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],rn.push(2*(5*r+n)),sn.push((e+1)*(e+2)/2%64);let s=Jr;for(let o=0;o<7;o++)t=(t<<Ie^(t>>Zr)*ts)%es,t&Qr&&(s^=Ie<<(Ie<<BigInt(o))-Ie);on.push(s)}const[ns,rs]=Tt(on,!0),cn=(e,t,n)=>n>32?Vt(e,t,n):Ct(e,t,n),an=(e,t,n)=>n>32?Mt(e,t,n):Ht(e,t,n);function ss(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let c=0;c<10;c++)n[c]=e[c]^e[c+10]^e[c+20]^e[c+30]^e[c+40];for(let c=0;c<10;c+=2){const a=(c+8)%10,u=(c+2)%10,i=n[u],h=n[u+1],f=cn(i,h,1)^n[a],d=an(i,h,1)^n[a+1];for(let l=0;l<50;l+=10)e[c+l]^=f,e[c+l+1]^=d}let s=e[2],o=e[3];for(let c=0;c<24;c++){const a=sn[c],u=cn(s,o,a),i=an(s,o,a),h=rn[c];s=e[h],o=e[h+1],e[h]=u,e[h+1]=i}for(let c=0;c<50;c+=10){for(let a=0;a<10;a++)n[a]=e[c+a];for(let a=0;a<10;a++)e[c+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=ns[r],e[1]^=rs[r]}n.fill(0)}class nt extends Dt{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ue(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=he(this.state)}keccak(){C||H(this.state32),ss(this.state32,this.rounds),C||H(this.state32),this.posOut=0,this.pos=0}update(t){ve(this);const{blockLen:n,state:r}=this;t=W(t);const s=t.length;for(let o=0;o<s;){const c=Math.min(n-this.pos,s-o);for(let a=0;a<c;a++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ve(this,!1),$e(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const c=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:c}=this;return t||(t=new nt(n,r,s,c,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=c,t.destroyed=this.destroyed,t}}const os=((e,t,n)=>kr(()=>new nt(t,e,n)))(1,136,256/8),ln=e=>{const t=e.slice(2),n=re(os(t)).slice(2),r=new Array(40);for(let s=0;s<40;s++){const o=parseInt(n[s],16),c=t[s];r[s]=o>7?c.toUpperCase():c}return`0x${r.join("")}`},cs=D(20)[1],un=E(e=>{const t=Me(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=re(t);if(e===n||e===n.toUpperCase())return t;if(ln(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},ze(e=>ln(re(cs(e))))),hn=new TextEncoder,dn=new TextDecoder,is=X(D(4),hn.encode.bind(hn),dn.decode.bind(dn)),rt=v({engine:is,payload:oe()}),as=fe({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:m},[4,5,6,8]),st=oe(32),ls=v({parentHash:st,number:w,stateRoot:st,extrinsicRoot:st,digests:B(as)}),J=B(A),fn=P(A),us=q({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m}),yn=B(v({name:fn,type:w,typeName:fn,docs:J})),hs=v({len:ee,type:w}),ds=v({bitStoreType:w,bitOrderType:w}),fs=B(v({name:A,fields:yn,index:L,docs:J})),ys=q({composite:yn,variant:fs,sequence:w,array:hs,tuple:B(w),primitive:us,compact:w,bitSequence:ds}),ps=v({name:A,type:P(w)}),gs=B(ps),bs=v({id:w,path:J,params:gs,def:ys,docs:J}),Re=B(bs),ws=q({Blake2128:m,Blake2256:m,Blake2128Concat:m,Twox128:m,Twox256:m,Twox64Concat:m,Identity:m}),ms=B(ws),vs=v({hashers:ms,key:w,value:w}),ks=v({name:A,modifier:L,type:q({plain:w,map:vs}),fallback:oe(),docs:J}),xs=P(v({prefix:A,items:B(ks)})),pn={name:A,storage:xs,calls:P(w),events:P(w),constants:B(v({name:A,type:w,value:oe(),docs:J})),errors:P(w),index:L},Es={...pn,docs:J},Bs=new Uint8Array,gn=e=>E(()=>Bs,()=>e),Is=v({type:w,version:L,signedExtensions:B(v({identifier:A,type:w,additionalSigned:w}))}),bn=v({lookup:Re,pallets:B(v({...pn,docs:gn([])})),extrinsic:Is,type:w,apis:gn([])}),As=v({name:A,methods:B(v({name:A,inputs:B(v({name:A,type:w})),output:w,docs:J})),docs:J}),Os=v({version:L,address:w,call:w,signature:w,extra:w,signedExtensions:B(v({identifier:A,type:w,additionalSigned:w}))}),wn=v({lookup:Re,pallets:B(v(Es)),extrinsic:Os,type:w,apis:B(As),outerEnums:v({call:w,event:w,error:w}),custom:B(K(A,v({type:w,value:oe()})))}),mn=()=>{throw new Error("Unsupported metadata version!")},M=E(mn,mn),Ae=v({magicNumber:ee,metadata:q({v0:M,v1:M,v2:M,v3:M,v4:M,v5:M,v6:M,v7:M,v8:M,v9:M,v10:M,v11:M,v12:M,v13:M,v14:bn,v15:wn})}),ot=D(),_s=P(ot),Ls=K(T,ot),Us=e=>{try{return Ae.dec(e)}catch{}try{return Ae.dec(_s.dec(e))}catch{}try{return Ae.dec(ot.dec(e))}catch{}try{return Ae.dec(Ls.dec(e)[1])}catch{}throw null},Ss={dkLen:32},Ds=e=>Ve(e,Ss),$s={dkLen:16},vn=e=>Ve(e,$s),kn=e=>be(vn(e),e),Q=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ce(e,t,n,r,s){return e=e+t+s|0,r=Te(r^e,16),n=n+r|0,t=Te(t^n,12),{a:e,b:t,c:n,d:r}}function ie(e,t,n,r,s){return e=e+t+s|0,r=Te(r^e,8),n=n+r|0,t=Te(t^n,7),{a:e,b:t,c:n,d:r}}function xn(e,t,n,r,s,o,c,a,u,i,h,f,d,l,y,p,b,k,_,j){let I=0;for(let pe=0;pe<r;pe++)({a:s,b:u,c:d,d:b}=ce(s,u,d,b,n[t+e[I++]])),{a:s,b:u,c:d,d:b}=ie(s,u,d,b,n[t+e[I++]]),{a:o,b:i,c:l,d:k}=ce(o,i,l,k,n[t+e[I++]]),{a:o,b:i,c:l,d:k}=ie(o,i,l,k,n[t+e[I++]]),{a:c,b:h,c:y,d:_}=ce(c,h,y,_,n[t+e[I++]]),{a:c,b:h,c:y,d:_}=ie(c,h,y,_,n[t+e[I++]]),{a,b:f,c:p,d:j}=ce(a,f,p,j,n[t+e[I++]]),{a,b:f,c:p,d:j}=ie(a,f,p,j,n[t+e[I++]]),{a:s,b:i,c:y,d:j}=ce(s,i,y,j,n[t+e[I++]]),{a:s,b:i,c:y,d:j}=ie(s,i,y,j,n[t+e[I++]]),{a:o,b:h,c:p,d:b}=ce(o,h,p,b,n[t+e[I++]]),{a:o,b:h,c:p,d:b}=ie(o,h,p,b,n[t+e[I++]]),{a:c,b:f,c:d,d:k}=ce(c,f,d,k,n[t+e[I++]]),{a:c,b:f,c:d,d:k}=ie(c,f,d,k,n[t+e[I++]]),{a,b:u,c:l,d:_}=ce(a,u,l,_,n[t+e[I++]]),{a,b:u,c:l,d:_}=ie(a,u,l,_,n[t+e[I++]]);return{v0:s,v1:o,v2:c,v3:a,v4:u,v5:i,v6:h,v7:f,v8:d,v9:l,v10:y,v11:p,v12:b,v13:k,v14:_,v15:j}}const En=(()=>{const e=Array.from({length:16},(r,s)=>s),t=r=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map(s=>r[s]),n=[];for(let r=0,s=e;r<7;r++,s=t(s))n.push(...s);return Uint8Array.from(n)})();class ct extends $t{constructor(t={},n=0){if(super(64,t.dkLen===void 0?32:t.dkLen,{},Number.MAX_SAFE_INTEGER,0,0),this.flags=0,this.chunkPos=0,this.chunksDone=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0,this.outputLen=t.dkLen===void 0?32:t.dkLen,ue(this.outputLen),t.key!==void 0&&t.context!==void 0)throw new Error("Blake3: only key or context can be specified at same time");if(t.key!==void 0){const r=W(t.key).slice();if(r.length!==32)throw new Error("Blake3: key should be 32 byte");this.IV=he(r),C||H(this.IV),this.flags=n|16}else if(t.context!==void 0){const r=new ct({dkLen:32},32).update(t.context).digest();this.IV=he(r),C||H(this.IV),this.flags=n|64}else this.IV=Q.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=mr(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:a,l:u}=He(BigInt(t),!0),{v0:i,v1:h,v2:f,v3:d,v4:l,v5:y,v6:p,v7:b,v8:k,v9:_,v10:j,v11:I,v12:pe,v13:Fe,v14:Xe,v15:co}=xn(En,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Q[0],Q[1],Q[2],Q[3],a,u,c,n);o[0]=i^k,o[1]=h^_,o[2]=f^j,o[3]=d^I,o[4]=l^pe,o[5]=y^Fe,o[6]=p^Xe,o[7]=b^co}compress(t,n=0,r=!1){let s=this.flags;if(this.chunkPos||(s|=1),(this.chunkPos===15||r)&&(s|=2),r||(this.pos=this.blockLen),this.b2Compress(this.chunksDone,s,t,n),this.chunkPos+=1,this.chunkPos===16||r){let o=this.state;this.state=this.IV.slice();for(let c,a=this.chunksDone+1;(r||!(a&1))&&(c=this.stack.pop());a>>=1)this.buffer32.set(c,0),this.buffer32.set(o,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|4,this.buffer32,0),o=this.state,this.state=this.IV.slice();this.chunksDone++,this.chunkPos=0,this.stack.push(o)}this.pos=0}_cloneInto(t){t=super._cloneInto(t);const{IV:n,flags:r,state:s,chunkPos:o,posOut:c,chunkOut:a,stack:u,chunksDone:i}=this;return t.state.set(s.slice()),t.stack=u.map(h=>Uint32Array.from(h)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=i,t.posOut=c,t.chunkOut=a,t.enableXOF=this.enableXOF,t.bufferOut32.set(this.bufferOut32),t}destroy(){this.destroyed=!0,this.state.fill(0),this.buffer32.fill(0),this.IV.fill(0),this.bufferOut32.fill(0);for(let t of this.stack)t.fill(0)}b2CompressOut(){const{state:t,pos:n,flags:r,buffer32:s,bufferOut32:o}=this,{h:c,l:a}=He(BigInt(this.chunkOut++));C||H(s);const{v0:u,v1:i,v2:h,v3:f,v4:d,v5:l,v6:y,v7:p,v8:b,v9:k,v10:_,v11:j,v12:I,v13:pe,v14:Fe,v15:Xe}=xn(En,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Q[0],Q[1],Q[2],Q[3],a,c,n,r);o[0]=u^b,o[1]=i^k,o[2]=h^_,o[3]=f^j,o[4]=d^I,o[5]=l^pe,o[6]=y^Fe,o[7]=p^Xe,o[8]=t[0]^b,o[9]=t[1]^k,o[10]=t[2]^_,o[11]=t[3]^j,o[12]=t[4]^I,o[13]=t[5]^pe,o[14]=t[6]^Fe,o[15]=t[7]^Xe,C||(H(s),H(o)),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,this.buffer.fill(0,this.pos);let t=this.flags|8;this.stack.length?(t|=4,C||H(this.buffer32),this.compress(this.buffer32,0,!0),C||H(this.buffer32),this.chunksDone=0,this.pos=this.blockLen):t|=(this.chunkPos?0:1)|2,this.flags=t,this.b2CompressOut()}writeInto(t){ve(this,!1),$e(t),this.finish();const{blockLen:n,bufferOut:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=n&&this.b2CompressOut();const c=Math.min(n-this.posOut,o-s);t.set(r.subarray(this.posOut,this.posOut+c),s),this.posOut+=c,s+=c}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible after digest call");return this.writeInto(t)}xof(t){return ue(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ye(t,this),this.finished)throw new Error("digest() was already called");return this.enableXOF=!1,this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}const Ts=Er(e=>new ct(e)),Cs={dkLen:32},Bn=e=>Ts(e,Cs),Hs=e=>be(Bn(e),e),In=e=>e,ye=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),it=2n**64n-1n,$=(e,t)=>e<<t&it|e>>64n-t,x=(e,t)=>e*t&it,U=(e,t)=>e+t&it,S=11400714785074694791n,N=14029467366897019727n,An=1609587929392839161n,Oe=9650029242287828579n,On=2870177450012600261n;function ae(e,t=0n){let n=U(U(t,S),N),r=U(t,N),s=t,o=t-S,c=e.length,a=0,u=null;(function(){let l=0,y=l+c;if(c){if(u=new Uint8Array(32),c<32){u.set(e.subarray(0,c),a),a+=c;return}if(l<=y-32){const p=y-32;do{let b;b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),n=x($(U(n,x(b,N)),31n),S),l+=8,b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),r=x($(U(r,x(b,N)),31n),S),l+=8,b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),s=x($(U(s,x(b,N)),31n),S),l+=8,b=ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],e[l+5]<<8|e[l+4],e[l+7]<<8|e[l+6]),o=x($(U(o,x(b,N)),31n),S),l+=8}while(l<=p)}l<y&&(u.set(e.subarray(l,y),a),a=y-l)}})(),e=u||e;let i,h=0;for(c>=32?(i=$(n,1n),i=U(i,$(r,7n)),i=U(i,$(s,12n)),i=U(i,$(o,18n)),n=x($(x(n,N),31n),S),i=i^n,i=U(x(i,S),Oe),r=x($(x(r,N),31n),S),i=i^r,i=U(x(i,S),Oe),s=x($(x(s,N),31n),S),i=i^s,i=U(x(i,S),Oe),o=x($(x(o,N),31n),S),i=i^o,i=U(x(i,S),Oe)):i=U(t,On),i=U(i,BigInt(c));h<=a-8;){let d=ye(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],e[h+5]<<8|e[h+4],e[h+7]<<8|e[h+6]);d=x($(x(d,N),31n),S),i=U(x($(i^d,27n),S),Oe),h+=8}if(h+4<=a){let d=x(ye(e[h+1]<<8|e[h],e[h+3]<<8|e[h+2],0,0),S);i=U(x($(i^d,23n),N),An),h+=4}for(;h<a;){const d=x(ye(e[h++],0,0,0),On);i=x($(i^d,11n),S)}let f=i>>33n;return i=x(i^f,N),f=i>>29n,i=x(i^f,An),f=i>>32n,i^=f,i}const at=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),t},Vs=e=>{const t=new Uint8Array(32),n=new DataView(t.buffer);return n.setBigUint64(0,ae(e),!0),n.setBigUint64(8,ae(e,1n),!0),n.setBigUint64(16,ae(e,2n),!0),n.setBigUint64(24,ae(e,3n),!0),t},_n=e=>be(Se.enc(ae(e)),e),Ln=new TextEncoder;var Ms=Object.freeze({__proto__:null,AccountId:Ze,Bin:Be,Binary:se,Blake2128:vn,Blake2128Concat:kn,Blake2256:Ds,Blake3256:Bn,Blake3256Concat:Hs,Bytes:D,Enum:tt,FixedSizeBinary:Kt,Hex:oe,Identity:In,Option:P,Result:De,ScaleEnum:q,Self:en,Storage:e=>{const t=at(Ln.encode(e));return(n,r,...s)=>{const o=be(t,at(Ln.encode(n))),c=re(o),a=s.map(f=>f[1]).map(f=>{switch(f){case In:return 0;case _n:return 8;case kn:return 16;default:return null}}).filter(f=>f!==null),u=f=>{if(!f.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(a.length!==s.length)throw new Error("Impossible to decode this key");if(s.length===0)return[];const d=f.slice(c.length),l=new Array(s.length);for(let y=0,p=0;y<a.length;y++){const b=s[y][0];p+=a[y],l[y]=b.dec(d.slice(p*2)),p+=b.enc(l[y]).length}return l},i=s.map(([{enc:f},d])=>l=>d(f(l)));return{enc:(...f)=>re(be(o,...f.map((d,l)=>i[l](d)))),dec:r,keyDecoder:u}}},Struct:v,Tuple:K,Twox128:at,Twox256:Vs,Twox64Concat:_n,Variant:fe,Vector:B,_Enum:Yr,_void:m,bitSequence:Gt,blockHeader:ls,bool:Ge,char:Kr,compact:T,compactBn:Fr,compactNumber:w,createCodec:E,createDecoder:ze,decAnyMetadata:Us,enhanceCodec:X,enhanceDecoder:Ue,enhanceEncoder:We,ethAccount:un,fixedStr:Gr,fromBufferToBase58:Nt,getSs58AddressInfo:Pt,h64:ae,i128:Wn,i16:Fn,i256:Yn,i32:Xn,i64:Kn,i8:qn,metadata:Ae,selfDecoder:Zt,selfEncoder:Qt,str:A,u128:zn,u16:me,u256:Gn,u32:ee,u64:Se,u8:L,v14:bn,v14Lookup:Re,v15:wn});const js=(e,t,n)=>(r,s,o,...c)=>{const{id:a}=r;if(s.has(a))return s.get(a);if(o.has(a)){const i=t(()=>s.get(a),r,...c);return s.set(a,i),i}o.add(a);let u=e(r,s,o,...c);return o.delete(a),s.has(a)&&(u=n(u,s.get(a),r,...c)),s.set(a,u),u},Ps=Be(),Ns=E(T[0],Ue(T[1],BigInt)),Un=js((e,t,n,r)=>{if(e.type==="primitive")return Ms[e.value];if(e.type==="void")return m;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return un;if(e.type==="compact")return e.isBig?Ns:T;if(e.type==="bitSequence")return Gt;const s=l=>Un(l,t,n,r),o=(l,y)=>{const p=s(l);return y?B(p,y):B(p)},c=l=>K(...l.map(s)),a=l=>{const y=Object.fromEntries(Object.entries(l).map(([p,b])=>[p,s(b)]));return v(y)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Ps;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Be(e.len):o(e.value,e.len);if(e.type==="sequence")return o(e.value);if(e.type==="tuple")return c(e.value);if(e.type==="struct")return a(e.value);if(e.type==="option")return P(s(e.value));if(e.type==="result")return De(s(e.value.ok),s(e.value.ko));const u=Object.values(e.value).map(l=>{switch(l.type){case"void":return m;case"lookupEntry":return s(l.value);case"tuple":return c(l.value);case"struct":return a(l.value);case"array":return o(l.value,l.len)}}),i=Object.fromEntries(Object.keys(e.value).map((l,y)=>[l,u[y]])),h=Object.values(e.value).map(l=>l.idx),d=h.every((l,y)=>l===y)?fe(i):fe(i,h);return e.byteLength?qs(d,e.byteLength):d},en,e=>e),Rs=(e,t=Ze())=>{const n=new Map,r=s=>Un(e(s),n,new Set,t);return s=>r(s)},qs=(e,t)=>{const n=D(t);return E(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Fs=e=>{const{metadata:t}=e,n=Rs(e),r=(u="")=>{const i=e.storage[u];if(!i)throw new Error(`Storage entry ${u||"{root}"} not found`);const h=i.key==null?m:n(i.key);return{key:Sn(h,i.keyPrefix),value:n(i.typeId)}},s=u=>{const i=v(Object.fromEntries(u.args.map(h=>[h.label,n(h.type.type)])));return{call:Sn(i,u.selector),value:n(u.returnType.type)}};return{buildConstructor:u=>{const i=t.spec.constructors.find(h=>h.label===u);if(!i)throw new Error(`Constructor ${u} not found`);return s(i)},buildMessage:u=>{const i=t.spec.messages.find(h=>h.label===u);if(!i)throw new Error(`Message ${u} not found`);return s(i)},buildStorage:r,buildEvent:()=>fe(Object.fromEntries(t.spec.events.map(u=>[u.label,v(Object.fromEntries(u.args.map(i=>[i.label,n(i.type.type)])))])))}},Sn=(e,t)=>{const n=se.fromHex(t).asBytes(),r=K(D(n.length),e);return X(r,s=>[n,s],([,s])=>s)},Dn=e=>X(q(e),t=>{if(typeof t=="string")return{tag:t,value:void 0};const[n,r]=Object.entries(t)[0];return{tag:n,value:r}},t=>({[t.tag]:t.value})),_e=(e,t)=>X(B(e,t),n=>n??[],n=>n),$n=P(A),qe=_e(A),Xs=Dn({bool:m,char:m,str:m,u8:m,u16:m,u32:m,u64:m,u128:m,u256:m,i8:m,i16:m,i32:m,i64:m,i128:m,i256:m}),Tn=_e(v({name:$n,type:w,typeName:$n,docs:qe})),Ks=v({len:ee,type:w}),zs=v({bitStoreType:w,bitOrderType:w}),Ws=_e(v({name:A,fields:Tn,index:L,docs:qe})),Gs=Dn({composite:v({fields:Tn}),variant:v({variants:Ws}),sequence:v({type:w}),array:Ks,tuple:B(w),primitive:Xs,compact:w,bitSequence:zs}),Ys=v({name:A,type:P(w)}),Js=_e(Ys),Qs=v({id:w,path:qe,params:Js,def:Gs,docs:qe}),Zs=X(Qs,e=>({id:e.id,path:e.type.path,params:e.type.params??[],def:e.type.def,docs:[]}),e=>({id:e.id,type:{def:e.def,path:e.path,params:e.params}})),eo=_e(Zs),to=e=>{const t=eo.enc(e.types),n=Re.dec(t),r=e.spec.environment.accountId.type,s=n.find(a=>a.id===r);s&&(s.path=["AccountId32"]);const o=no(e,n),c=Vn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function no(e,t){const n={},r=(s,o=[])=>{function c(u){const i=t.length;return t[i]={id:i,docs:[],def:u,params:[],path:[]},i}if("root"in s){const u=Number(e.version)===4?se.fromBytes(se.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,i=r(s.root.layout,o);if(s.root.ty!=null){let h=function(f,d){const l=e.types[f].type,y="composite"in l.def?new Map((l.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((l.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){h(y.get("len"),[...d,"len"]),h(y.get("elements"),d);return}else p.size===3&&p.has("K")&&p.has("V")?n[d.join(".")]={keyPrefix:u,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[d.join(".")]={keyPrefix:u,key:null,typeId:p.get("V")})};h(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:u,key:null,typeId:i}),null}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const u=r(s.array.layout,o);return u==null?null:c({tag:"array",value:{len:s.array.len,type:u}})}if("struct"in s){const u=s.struct.fields.map(i=>({name:i.name,type:r(i.layout,[...o,i.name]),typeName:void 0,docs:[]})).filter(i=>i.type!=null);return c({tag:"composite",value:u})}const a=Object.values(s.enum.variants).map((u,i)=>({name:u.name,fields:u.fields.map(h=>({name:h.name,type:r(h.layout,[...o,u.name,h.name]),typeName:void 0,docs:[]})).filter(h=>h.type!==null),index:i,docs:[]}));return c({tag:"variant",value:a})};return r(e.storage),n}const ro=e=>{const t=to(e.metadata),n=Fs(t);return{constructor:Cn(n.buildConstructor),message:Cn(n.buildMessage),storage:so(n.buildStorage),event:oo(n.buildEvent)}},Cn=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},so=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},oo=e=>{const t=n=>e().dec(n.data.asBytes());return{decode:t,filter:(n,r=[])=>r.map(s=>"event"in s?s.event:s).filter(s=>s.type==="Contracts"&&s.value.type==="ContractEmitted"&&s.value.value.contract===n).map(s=>{try{return t(s.value.value)}catch(o){throw console.error(`Contract ${n} emitted an incompatible event`,s.value.value),o}})}};we.getInkClient=ro});
@@ -1 +1 @@
1
- (function(_,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(_=typeof globalThis<"u"?globalThis:_||self,E(_.papiPolkadotSdkCompat={}))})(this,function(_){"use strict";const E=p=>{let i=null;const{send:o,disconnect:c}=p(d=>{i?.(JSON.parse(d))});return d=>(i=d,{send(f){o(JSON.stringify(f))},disconnect(){i=null,c()}})},C=p=>{let i=null;const{send:o,disconnect:c}=p(d=>{i?.(JSON.stringify(d))});return d=>(i=d,{send(f){o(JSON.parse(f))},disconnect(){i=null,c()}})},g=(...p)=>i=>C(p.reduce((o,c)=>c(o),E(i))),S={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},D={broadcast:"",stop:""},O={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:S,chainSpec:O,transaction:D}).forEach(([p,i])=>{Object.keys(i).forEach(o=>{i[o]=`${p}_v1_${o}`})});var F=Object.freeze({__proto__:null,chainHead:S,chainSpec:O,transaction:D});const W=p=>i=>{const{send:o,disconnect:c}=p(i);return{send:f=>{switch(f.method){case O.chainName:return o({...f,method:"system_chain"});case O.genesisHash:return o({...f,method:"chain_getBlockHash",params:[0]});case O.properties:return o({...f,method:"system_properties"})}o(f)},disconnect:c}},z=p=>i=>{const o=new Set,c=new Map,d=new Map,{send:f,disconnect:u}=p(a=>{if("id"in a){i(a);const{id:t,result:e}=a;if(o.has(t)){o.delete(t),c.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:t}=a.params,e=c.get(t),n=d.get(t);if(e){const s=a.params.result,{event:r}=s;if(r==="initialized"&&s.finalizedBlockHashes.forEach(l=>{e.add(l)}),r==="newBlock"){const{parentBlockHash:l}=s;if(!e.has(l)){const h=n.get(l)??[];h.push(a),n.set(l,h);return}const k=s.blockHash;e.add(s.blockHash),i(a);const w=n.get(k);w&&(n.delete(k),w.forEach(h=>{e.add(h.params.result.blockHash),i(h)}));return}r==="stop"&&(e.delete(t),d.delete(t))}i(a)}});return{send:a=>{const t=a.params[0];switch(a.method){case S.follow:o.add(a.id);break;case S.unpin:const[e,n]=a.params;n.forEach(s=>{c.get(e)?.delete(s),d.get(e)?.delete(s)});break;case S.unfollow:c.delete(t),d.delete(t);break}f(a)},disconnect:u}},y=p=>({jsonrpc:"2.0",...p}),N=(p,i,o,c={})=>y({method:"chainHead_v1_followEvent",params:{subscription:p,result:{event:i,operationId:o,...c}}}),L="__INNER_RQ_DesV",Q=p=>{let i=0;const o=new Map,c=({id:b,error:a,result:t})=>{const e=o.get(b);return e&&(o.delete(b),a?e(!1,a):e(!0,t)),!e};let d=()=>{};return[b=>{const{send:a,disconnect:t}=p(e=>{c(e)&&b(e)});return d=a,{send:d,disconnect:()=>{o.clear(),t()}}},(b,a,t,e)=>{const n=L+i++;o.set(n,(s,r)=>{(s?t:e)(r)}),d(y({id:n,method:b,params:a}))}]},Z="__INNER_OP_DesV";let X=0;const R=p=>i=>{const[o,c]=Q(p),d=Y(c),f=new Map,u=new Map,{send:b,disconnect:a}=o(n=>{if("id"in n){const s=f.get(n.id);s&&(f.delete(n.id),n.result.result==="started"&&s(n.result.operationId))}else if(n.params){const{subscription:s,result:r}=n.params,{operationId:l}=r||{},k=u.get(s);k&&r.event==="stop"&&(k.forEach(h=>{h.cancel()}),u.delete(s));const w=k?.get(l);if(w)switch(r.event){case"operationInaccessible":case"operationError":w.cancel();break;case"operationStorageDone":if(w.isInnerDone)k.delete(l);else{w.isOutterDone=!0;return}}}i(n)}),t=(n,s,r)=>l=>{let k=()=>{};u.has(n)||u.set(n,new Map);const w=u.get(n),h={isOutterDone:!1,isInnerDone:!1,cancel:()=>{k()}};w.set(l,h);let H=0;const B=r.map(v=>d(v,s,I=>{i(N(n,"operationStorageItems",l,{items:I.map(([M,U])=>({key:M,value:U}))}))},I=>{k(),h.isOutterDone||b(y({method:"chainHead_v1_stopOperation",params:[l]})),i(N(n,"operationError",l,{error:typeof I=="string"?I:JSON.stringify(I)}))},()=>{++H===r.length&&(h.isOutterDone?(k(),i(N(n,"operationStorageDone",l))):h.isInnerDone=!0)}));k=()=>{w.delete(l),B.forEach(v=>v())}};return{send:n=>{switch(n.method){case S.storage:{const[s,r,l]=n.params,k=[],w=l.filter(H=>{const B=H.type==="descendantsValues";return B&&k.push(H.key),!B}),h=t(s,r,k);if(w.length)k.length&&f.set(n.id,h);else{const H=Z+X++;i(y({id:n.id,result:{result:"started",operationId:H}})),h(H),u.get(s).get(H).isOutterDone=!0;return}n.params[2]=w;break}case S.stopOperation:{const[s,r]=n.params,l=u.get(s)?.get(r);if(l&&(l.cancel(),l.isOutterDone))return;break}case S.unfollow:{const[s]=n.params;u.get(s)?.forEach(r=>r.cancel()),u.delete(s);break}}b(n)},disconnect:a}},Y=p=>(i,o,c,d,f)=>{let u=!0,b=!1,a=0;const t=s=>{u&&(u=!1,d(s))},e=1e3,n=s=>{p("state_getKeysPaged",[i,e,s||void 0,o],r=>{u&&(r.length>0&&(a++,p("state_queryStorageAt",[r,o],([{changes:l}])=>{u&&(a--,c(l),b&&!a&&f())},t)),r.length<e?(b=!0,a||f()):n(r.at(-1)))},t)};return n(),()=>{u=!1}},V=p=>i=>{const o=new Set,c=new Map,d=new Map,{send:f,disconnect:u}=p(a=>{if("id"in a){i(a);const{id:t,result:e}=a;if(o.has(t)){o.delete(t),c.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:t}=a.params,e=c.get(t),n=d.get(t);if(e){const s=a.params.result,{event:r}=s;if(r==="initialized"&&s.finalizedBlockHashes.forEach(l=>{e.add(l)}),r==="finalized"&&(s.prunedBlockHashes=s.prunedBlockHashes.filter(l=>{e.has(l)})),r==="newBlock"){e.add(s.blockHash);const l=s.blockHash,k=n.get(l);if(k){n.delete(l),i(a),Promise.resolve().then(()=>{i(k)});return}}if(r==="bestBlockChanged"){const l=s.bestBlockHash;if(!e.has(l)){d.get(t).set(l,a);return}}r==="stop"&&(e.delete(t),d.delete(t))}i(a)}});return{send:a=>{const t=a.params[0];switch(a.method){case S.follow:o.add(a.id);break;case S.unpin:const[e,n]=a.params;n.forEach(s=>{c.get(e)?.delete(s),d.get(e)?.delete(s)});break;case S.unfollow:c.delete(t),d.delete(t);break}f(a)},disconnect:u}},ee=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(p=>"operation"+p)),$=p=>ee.has(p.params?.result?.event),j=p=>i=>{const o=new Set,c=new Map,d=new Map,f=new Map,{send:u,disconnect:b}=p(t=>{if("id"in t){i(t);const{id:e,result:n}=t;if(o.has(e)){o.delete(e),d.set(n,new Set),f.set(n,new Map);return}const s=c.get(e);if(s!==void 0){c.delete(e);const r=t.result?.operationId;if(r!==void 0&&d.has(s)){const l=d.get(s);l.add(r);const k=f.get(s)?.get(r);k&&(k.forEach(i),f.get(s).delete(r),$(k.at(-1))&&l.delete(r))}}}else{const{subscription:e,result:n}=t.params,s=d.get(e);if(s){const{operationId:r}=t.params.result;if(r!==void 0)if(s.has(r))$(t)&&s.delete(r);else{const l=f.get(e),k=l.get(r)??[];k.push(t),l.set(r,k);return}else n?.event==="stop"&&(d.delete(e),f.delete(e))}i(t)}});return{send:t=>{const e=t.params[0];switch(t.method){case S.follow:o.add(t.id);break;case S.body:case S.call:case S.storage:c.set(t.id,e);break;case S.unfollow:d.delete(e),f.delete(e);break;case S.stopOperation:d.get(e)?.delete(t.params[1])}u(t)},disconnect:b}},m=p=>i=>p(o=>{const c=o.params?.result;if(!("id"in o)&&c){const{prunedBlockHashes:d,finalizedBlockHash:f,event:u}=c;u==="finalized"&&Array.isArray(d)?c.prunedBlockHashes=[...new Set(c.prunedBlockHashes)]:u==="initialized"&&f&&(c.finalizedBlockHashes=[c.finalizedBlockHash],delete c.finalizedBlockHash)}i(o)}),A=p=>i=>{const{send:o,disconnect:c}=p(i);return{send:f=>{const{method:u,params:b,id:a,...t}=f;u==S.unpin&&b&&Array.isArray(b[1])?b[1].forEach((e,n)=>{o({...t,id:n===0?a:`${a}-patched-${n}`,method:u,params:[b[0],e]})}):o(f)},disconnect:c}},G=p=>({jsonrpc:"2.0",...p}),[P]=D.stop.split("_"),T="unstable",q="rpc_methods",x="__INTERNAL_ID",J=p=>i=>{let o=!0,c=[],d=e=>{c.push(e)},f=({id:e,result:n,error:s})=>{if(e!==x||!o)return;if(!n){if(console.error(s),a<4){setTimeout(t,200);return}n={methods:[]}}const r=new Set(n.methods),l={};[S,O,D].forEach(w=>{Object.values(w).forEach(h=>{if(r.has(h))l[h]=h;else{const[H,,B]=h.split("_"),v=`${H}_${T}_${B}`;if(r.has(v))l[h]=v,r.delete(v),r.add(h);else if(l[h]=null,H===P){let I;const M=h==="stop"?"unwatch":"submitAndWatch";[P+"Watch",P].find(ne=>["v1",T].find(se=>r.has(I=`${ne}_${se}_${M}`)))&&(l[h]=I,r.add(h))}}})}),f=i;const k=({method:w,...h})=>{if(w===q){Promise.resolve().then(()=>{i(G({id:h.id,result:{methods:[...r]}}))});return}const H=l[w];H===null?Promise.resolve().then(()=>{i({error:{code:-32603,message:`Method not found: ${w}`},id:h.id})}):u({method:H||w,...h})};for(let w=0;o&&w<c.length;w++)k(c[w]);c=[],o&&(d=k)};const{send:u,disconnect:b}=p(e=>{f(e)});let a=0;const t=()=>{a++,u(G({id:x,method:q,params:[]}))};return t(),{send:e=>{d(e)},disconnect(){o=!1,d=f=()=>{},c=[],b()}}},K=p=>i=>{let o=0;const c=new Map,{send:d,disconnect:f}=p(u=>{c.has(u.id)&&(u.id=c.get(u.id)),i(u)});return{send:u=>{if("id"in u){const b=o++;c.set(b,u.id),u.id=b}d(u)},disconnect:f}},te=g(J,j,A,m,z,V,W,R,K);_.fixDescendantValues=R,_.fixPrematureBlocks=z,_.fixUnorderedBlocks=V,_.fixUnorderedEvents=j,_.fromParsed=C,_.methods=F,_.parsed=g,_.patchChainHeadEvents=m,_.toParsed=E,_.translate=J,_.unpinHash=A,_.withNumericIds=K,_.withPolkadotSdkCompat=te});
1
+ (function(_,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(_=typeof globalThis<"u"?globalThis:_||self,E(_.papiPolkadotSdkCompat={}))})(this,function(_){"use strict";const E=p=>{let i=null;const{send:o,disconnect:c}=p(d=>{i?.(JSON.parse(d))});return d=>(i=d,{send(f){o(JSON.stringify(f))},disconnect(){i=null,c()}})},C=p=>{let i=null;const{send:o,disconnect:c}=p(d=>{i?.(JSON.stringify(d))});return d=>(i=d,{send(f){o(JSON.parse(f))},disconnect(){i=null,c()}})},g=(...p)=>i=>C(p.reduce((o,c)=>c(o),E(i))),S={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},D={broadcast:"",stop:""},O={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:S,chainSpec:O,transaction:D}).forEach(([p,i])=>{Object.keys(i).forEach(o=>{i[o]=`${p}_v1_${o}`})});var F=Object.freeze({__proto__:null,chainHead:S,chainSpec:O,transaction:D});const W=p=>i=>{const{send:o,disconnect:c}=p(i);return{send:f=>{switch(f.method){case O.chainName:return o({...f,method:"system_chain"});case O.genesisHash:return o({...f,method:"chain_getBlockHash",params:[0]});case O.properties:return o({...f,method:"system_properties"})}o(f)},disconnect:c}},z=p=>i=>{const o=new Set,c=new Map,d=new Map,{send:f,disconnect:u}=p(a=>{if("id"in a){i(a);const{id:t,result:e}=a;if(o.has(t)){o.delete(t),c.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:t}=a.params,e=c.get(t),n=d.get(t);if(e){const s=a.params.result,{event:r}=s;if(r==="initialized"&&s.finalizedBlockHashes.forEach(l=>{e.add(l)}),r==="newBlock"){const{parentBlockHash:l}=s;if(!e.has(l)){const h=n.get(l)??[];h.push(a),n.set(l,h);return}const k=s.blockHash;e.add(s.blockHash),i(a);const w=n.get(k);w&&(n.delete(k),w.forEach(h=>{e.add(h.params.result.blockHash),i(h)}));return}r==="stop"&&(e.delete(t),d.delete(t))}i(a)}});return{send:a=>{const t=a.params[0];switch(a.method){case S.follow:o.add(a.id);break;case S.unpin:const[e,n]=a.params;n.forEach(s=>{c.get(e)?.delete(s),d.get(e)?.delete(s)});break;case S.unfollow:c.delete(t),d.delete(t);break}f(a)},disconnect:u}},y=p=>({jsonrpc:"2.0",...p}),N=(p,i,o,c={})=>y({method:"chainHead_v1_followEvent",params:{subscription:p,result:{event:i,operationId:o,...c}}}),L="__INNER_RQ_DesV",Q=p=>{let i=0;const o=new Map,c=({id:b,error:a,result:t})=>{const e=o.get(b);return e&&(o.delete(b),a?e(!1,a):e(!0,t)),!e};let d=()=>{};return[b=>{const{send:a,disconnect:t}=p(e=>{c(e)&&b(e)});return d=a,{send:d,disconnect:()=>{o.clear(),t()}}},(b,a,t,e)=>{const n=L+i++;o.set(n,(s,r)=>{(s?t:e)(r)}),d(y({id:n,method:b,params:a}))}]},Z="__INNER_OP_DesV";let X=0;const R=p=>i=>{const[o,c]=Q(p),d=Y(c),f=new Map,u=new Map,{send:b,disconnect:a}=o(n=>{if("id"in n){const s=f.get(n.id);s&&(f.delete(n.id),n.result.result==="started"&&s(n.result.operationId))}else if(n.params){const{subscription:s,result:r}=n.params,{operationId:l}=r||{},k=u.get(s);k&&r.event==="stop"&&(k.forEach(h=>{h.cancel()}),u.delete(s));const w=k?.get(l);if(w)switch(r.event){case"operationInaccessible":case"operationError":w.cancel();break;case"operationStorageDone":if(w.isInnerDone)k.delete(l);else{w.isOutterDone=!0;return}}}i(n)}),t=(n,s,r)=>l=>{let k=()=>{};u.has(n)||u.set(n,new Map);const w=u.get(n),h={isOutterDone:!1,isInnerDone:!1,cancel:()=>{k()}};w.set(l,h);let H=0;const B=r.map(v=>d(v,s,I=>{i(N(n,"operationStorageItems",l,{items:I.map(([M,U])=>({key:M,value:U}))}))},I=>{k(),h.isOutterDone||b(y({method:"chainHead_v1_stopOperation",params:[l]})),i(N(n,"operationError",l,{error:typeof I=="string"?I:JSON.stringify(I)}))},()=>{++H===r.length&&(h.isOutterDone?(k(),i(N(n,"operationStorageDone",l))):h.isInnerDone=!0)}));k=()=>{w.delete(l),B.forEach(v=>v())}};return{send:n=>{switch(n.method){case S.storage:{const[s,r,l]=n.params,k=[],w=l.filter(H=>{const B=H.type==="descendantsValues";return B&&k.push(H.key),!B}),h=t(s,r,k);if(w.length)k.length&&f.set(n.id,h);else{const H=Z+X++;i(y({id:n.id,result:{result:"started",operationId:H}})),h(H),u.get(s).get(H).isOutterDone=!0;return}n.params[2]=w;break}case S.stopOperation:{const[s,r]=n.params,l=u.get(s)?.get(r);if(l&&(l.cancel(),l.isOutterDone))return;break}case S.unfollow:{const[s]=n.params;u.get(s)?.forEach(r=>r.cancel()),u.delete(s);break}}b(n)},disconnect:a}},Y=p=>(i,o,c,d,f)=>{let u=!0,b=!1,a=0;const t=s=>{u&&(u=!1,d(s))},e=1e3,n=s=>{p("state_getKeysPaged",[i,e,s||void 0,o],r=>{u&&(r.length>0&&(a++,p("state_queryStorageAt",[r,o],([{changes:l}])=>{u&&(a--,c(l),b&&!a&&f())},t)),r.length<e?(b=!0,a||f()):n(r.at(-1)))},t)};return n(),()=>{u=!1}},V=p=>i=>{const o=new Set,c=new Map,d=new Map,{send:f,disconnect:u}=p(a=>{if("id"in a){i(a);const{id:t,result:e}=a;if(o.has(t)){o.delete(t),c.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:t}=a.params,e=c.get(t),n=d.get(t);if(e){const s=a.params.result,{event:r}=s;if(r==="initialized"&&s.finalizedBlockHashes.forEach(l=>{e.add(l)}),r==="finalized"&&(s.prunedBlockHashes=s.prunedBlockHashes.filter(l=>{e.has(l)})),r==="newBlock"){e.add(s.blockHash);const l=s.blockHash,k=n.get(l);if(k){n.delete(l),i(a),Promise.resolve().then(()=>{i(k)});return}}if(r==="bestBlockChanged"){const l=s.bestBlockHash;if(!e.has(l)){d.get(t).set(l,a);return}}r==="stop"&&(e.delete(t),d.delete(t))}i(a)}});return{send:a=>{const t=a.params[0];switch(a.method){case S.follow:o.add(a.id);break;case S.unpin:const[e,n]=a.params;n.forEach(s=>{c.get(e)?.delete(s),d.get(e)?.delete(s)});break;case S.unfollow:c.delete(t),d.delete(t);break}f(a)},disconnect:u}},ee=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(p=>"operation"+p)),$=p=>ee.has(p.params?.result?.event),j=p=>i=>{const o=new Set,c=new Map,d=new Map,f=new Map,{send:u,disconnect:b}=p(t=>{if("id"in t){i(t);const{id:e,result:n}=t;if(o.has(e)){o.delete(e),d.set(n,new Set),f.set(n,new Map);return}const s=c.get(e);if(s!==void 0){c.delete(e);const r=t.result?.operationId;if(r!==void 0&&d.has(s)){const l=d.get(s);l.add(r);const k=f.get(s)?.get(r);k&&(k.forEach(i),f.get(s).delete(r),$(k.at(-1))&&l.delete(r))}}}else{const{subscription:e,result:n}=t.params,s=d.get(e);if(s){const{operationId:r}=t.params.result;if(r!==void 0)if(s.has(r))$(t)&&s.delete(r);else{const l=f.get(e),k=l.get(r)??[];k.push(t),l.set(r,k);return}else n?.event==="stop"&&(d.delete(e),f.delete(e))}i(t)}});return{send:t=>{const e=t.params[0];switch(t.method){case S.follow:o.add(t.id);break;case S.body:case S.call:case S.storage:c.set(t.id,e);break;case S.unfollow:d.delete(e),f.delete(e);break;case S.stopOperation:d.get(e)?.delete(t.params[1])}u(t)},disconnect:b}},m=p=>i=>p(o=>{const c=o.params?.result;if(!("id"in o)&&c){const{prunedBlockHashes:d,finalizedBlockHash:f,event:u}=c;u==="finalized"&&Array.isArray(d)?c.prunedBlockHashes=[...new Set(c.prunedBlockHashes)]:u==="initialized"&&f&&(c.finalizedBlockHashes=[c.finalizedBlockHash],delete c.finalizedBlockHash)}i(o)}),A=p=>i=>{const{send:o,disconnect:c}=p(i);return{send:f=>{const{method:u,params:b,id:a,...t}=f;u==S.unpin&&b&&Array.isArray(b[1])?b[1].forEach((e,n)=>{o({...t,id:n===0?a:`${a}-patched-${n}`,method:u,params:[b[0],e]})}):o(f)},disconnect:c}},G=p=>({jsonrpc:"2.0",...p}),[P]=D.stop.split("_"),T="unstable",q="rpc_methods",x="__INTERNAL_ID",J=p=>i=>{let o=!0,c=[],d=e=>{c.push(e)},f=({id:e,result:n,error:s})=>{if(e!==x||!o)return;if(!n){if(console.error(s),a<4){setTimeout(t,200);return}n={methods:[]}}const r=new Set(n.methods),l={};[S,O,D].forEach(w=>{Object.values(w).forEach(h=>{if(r.has(h))l[h]=h;else{const[H,,B]=h.split("_"),v=`${H}_${T}_${B}`;if(r.has(v))l[h]=v,r.delete(v),r.add(h);else if(l[h]=null,H===P){let I;const M=h==="stop"?"unwatch":"submitAndWatch";[P+"Watch",P].find(ne=>["v1",T].find(se=>r.has(I=`${ne}_${se}_${M}`)))&&(l[h]=I,r.add(h))}}})}),f=i;const k=({method:w,...h})=>{if(w===q){Promise.resolve().then(()=>{i(G({id:h.id,result:{methods:[...r]}}))});return}const H=l[w];H===null?Promise.resolve().then(()=>{i({error:{code:-32603,message:`Method not found: ${w}`},id:h.id})}):u({method:H||w,...h})};for(let w=0;o&&w<c.length;w++)k(c[w]);c=[],o&&(d=k)};const{send:u,disconnect:b}=p(e=>{f(e)});let a=0;const t=()=>{a++,u(G({id:x,method:q,params:[]}))};return t(),{send:e=>{d(e)},disconnect(){o=!1,d=f=()=>{},c=[],b()}}},K=p=>i=>{let o=0;const c=new Map,{send:d,disconnect:f}=p(u=>{c.has(u.id)&&(u.id=c.get(u.id)),i(u)});return{send:u=>{if("id"in u){const b=o++;c.set(b,u.id),u.id=b}d(u)},disconnect:f}},te=g(K,J,j,A,m,z,V,W,R);_.fixDescendantValues=R,_.fixPrematureBlocks=z,_.fixUnorderedBlocks=V,_.fixUnorderedEvents=j,_.fromParsed=C,_.methods=F,_.parsed=g,_.patchChainHeadEvents=m,_.toParsed=E,_.translate=J,_.unpinHash=A,_.withNumericIds=K,_.withPolkadotSdkCompat=te});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -191,24 +191,24 @@
191
191
  "rxjs": ">=7.8.0"
192
192
  },
193
193
  "dependencies": {
194
- "@polkadot-api/cli": "0.9.8",
195
- "@polkadot-api/json-rpc-provider": "0.0.4",
194
+ "@polkadot-api/cli": "0.9.9",
196
195
  "@polkadot-api/ink-contracts": "0.1.0",
196
+ "@polkadot-api/json-rpc-provider": "0.0.4",
197
197
  "@polkadot-api/logs-provider": "0.0.6",
198
- "@polkadot-api/polkadot-sdk-compat": "2.3.0",
199
- "@polkadot-api/metadata-builders": "0.8.2",
198
+ "@polkadot-api/polkadot-sdk-compat": "2.3.1",
200
199
  "@polkadot-api/metadata-compatibility": "0.1.9",
200
+ "@polkadot-api/metadata-builders": "0.8.2",
201
201
  "@polkadot-api/observable-client": "0.5.10",
202
202
  "@polkadot-api/pjs-signer": "0.5.0",
203
- "@polkadot-api/signer": "0.1.8",
204
203
  "@polkadot-api/polkadot-signer": "0.1.6",
204
+ "@polkadot-api/signer": "0.1.8",
205
205
  "@polkadot-api/sm-provider": "0.1.3",
206
206
  "@polkadot-api/substrate-bindings": "0.9.2",
207
207
  "@polkadot-api/substrate-client": "0.2.2",
208
- "@polkadot-api/utils": "0.1.2",
209
208
  "@polkadot-api/ws-provider": "0.3.2",
210
- "@polkadot-api/known-chains": "0.5.4",
211
- "@polkadot-api/smoldot": "0.3.3"
209
+ "@polkadot-api/utils": "0.1.2",
210
+ "@polkadot-api/smoldot": "0.3.3",
211
+ "@polkadot-api/known-chains": "0.5.4"
212
212
  },
213
213
  "devDependencies": {
214
214
  "rxjs": "^7.8.1",