polkadot-api 1.7.6 → 1.7.7

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(me,ge){typeof exports=="object"&&typeof module<"u"?ge(exports):typeof define=="function"&&define.amd?define(["exports"],ge):(me=typeof globalThis<"u"?globalThis:me||self,ge(me.papiInk={}))})(this,function(me){"use strict";const ge=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",le={type:"void"},Cn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=l=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const y={id:d};return n.set(d,y),y}r.add(d);const u=l(d);return h=n.get(d),h?Object.assign(h,u):(h={id:d,...u},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const i=s(l=>{const d=t(e[l]);if(d)return d;const{def:h,path:u,params:y}=e[l];if(h.tag==="composite"){if(h.value.length===0)return le;if(h.value.length===1){const p=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&ge(p,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&ge(p,20)?(c=!1,{type:"AccountId20"}):p}return f(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&y.length===1&&y[0].name==="T"){const E=i(y[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(u.length===1&&u[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:i(y[0].type),ko:i(y[1].type)}};if(h.value.length===0)return le;const p={},b={};return h.value.forEach(E=>{const _=E.name;if(b[_]=E.docs,E.fields.length===0){p[_]={...le,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){p[_]={type:"lookupEntry",value:i(E.fields[0].type),idx:E.index};return}p[_]={...f(E.fields),idx:E.index}}),{type:"enum",value:p,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:p}=h.value,b=i(h.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?le:h.value.length>1?a(h.value.map(p=>i(p)),h.value.map(p=>e[p].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=i(h.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag}}),f=l=>{let d=!0;const h={},u={};return l.forEach((y,p)=>{d=d&&!!y.name;const b=y.name||p,E=i(y.type);E.type!=="void"&&(h[b]=E,u[b]=y.docs)}),d?{type:"struct",value:h,innerDocs:u}:a(Object.values(h),Object.values(u))},a=(l,d)=>{if(l.every(h=>h.id===l[0].id)&&d.every(h=>!h.length)){const[h]=l;return h.type==="void"?le:{type:"array",value:l[0],len:l.length}}return{type:"tuple",value:l,innerDocs:d}};return i},Hn=e=>Cn(e);var Vn=Object.defineProperty,Mn=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,at=(e,t,n)=>(Mn(e,typeof t!="symbol"?t+"":t,n),n),ze={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|ze[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=ze[e[c]],f=ze[e[c+1]];s[t+o++]=i<<4|f}return s}var lt=class extends Uint8Array{constructor(e){super(e),at(this,"i",0),at(this,"v"),this.v=new DataView(e)}},q=e=>t=>e(t instanceof lt?t:new lt(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].length;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 Ke=q,x=(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)),R=([e,t],n,r)=>x(We(e,n),Ue(t,r));function Pn(e,t){return q(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function Nn(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(Nn(e,n),Pn(e,t))}var L=Z(1,"getUint8","setUint8"),we=Z(2,"getUint16","setUint16"),ee=Z(4,"getUint32","setUint32"),Se=Z(8,"getBigUint64","setBigUint64"),qn=Z(1,"getInt8","setInt8"),Rn=Z(2,"getInt16","setInt16"),Fn=Z(4,"getInt32","setInt32"),Xn=Z(8,"getBigInt64","setBigInt64"),ut=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},ht=e=>q(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=x(ut,ht("getBigUint64")),Kn=x(ut,ht("getBigInt64")),dt=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},ft=e=>q(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}),Wn=x(dt,ft("getBigUint64")),Gn=x(dt,ft("getBigInt64")),Yn=R(L,e=>e?1:0,Boolean),Jn=[L[1],we[1],ee[1]],Qn=q(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 f=0;f<o;f++)s=Se[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(ee[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(we[1](e))<<c|s,c+=16n,i-=2),i&&(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 we[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(we[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(cr,Qn),ir=new TextEncoder,ar=e=>{const t=ir.encode(e);return X([T.enc(t.length),t])},lr=new TextDecoder,ur=q(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,lr.decode(n)}),A=x(ar,ur),hr=()=>{},dr=new Uint8Array(0),w=x(()=>dr,hr),yt=e=>e===void 0?t=>X([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),pt=e=>q(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}),$=e=>x(yt(e),pt(e));$.enc=yt,$.dec=pt;var gt=(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)])},bt=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return q(s=>{const o=L.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},F=(e,...t)=>x(gt(Le(e,([n])=>n),...t),bt(Le(e,([,n])=>n),...t));F.enc=gt,F.dec=bt;var mt=e=>q(t=>L[1](t)>0?e(t):void 0),wt=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,X([n,e(t)]))},P=e=>x(wt(e[0]),mt(e[1]));P.enc=wt,P.dec=mt;var vt=(e,t)=>q(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)]),$e=(e,t)=>x(Et(e[0],t[0]),vt(e[1],t[1]));$e.dec=vt,$e.enc=Et;var kt=(...e)=>q(t=>e.map(n=>n(t))),xt=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),z=(...e)=>x(xt(...e.map(([t])=>t)),kt(...e.map(([,t])=>t)));z.enc=xt,z.dec=kt;var Bt=e=>{const t=Object.keys(e);return We(z.enc(...Object.values(e)),n=>t.map(r=>n[r]))},It=e=>{const t=Object.keys(e);return Ue(z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>x(Bt(Le(e,t=>t[0])),It(Le(e,t=>t[1])));v.enc=Bt,v.dec=It;var At=(e,t)=>t>=0?n=>X(n.map(e)):n=>X([T.enc(n.length),X(n.map(e))]),Ot=(e,t)=>q(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(At(e[0],t),Ot(e[1],t));B.enc=At,B.dec=Ot;/*! 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)=>i=>o(c(i)),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 _t(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,i=!0;for(let f=r;f<o.length;f++){const a=o[f],l=t*c+a;if(!Number.isSafeInteger(l)||t*c/t!==c||l-a!==t*c)throw new Error("convertRadix: carry overflow");c=l%n;const d=Math.floor(l/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==l)throw new Error("convertRadix: carry overflow");if(i)d?i=!1:r=f;else continue}if(s.push(c),i)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 _t(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(_t(t,e,2**8))}}}const Lt=(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 mr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function De(e,...t){if(!mr(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 Ge(e,t){De(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),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,Ut=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,K=C?e=>e:e=>Ut(e);function H(e){for(let t=0;t<e.length;t++)e[t]=Ut(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)),De(e),e}class St{clone(){return this._cloneInto()}}function Er(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 kr(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 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}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 St{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,i=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 a=Math.min(n-this.pos,o-f),l=c+f;if(a===n&&!(l%4)&&f+a<o){const d=new Uint32Array(i,l,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+a),this.pos),this.pos+=a,this.length+=a,f+=a}return this}digestInto(t){ve(this),Ge(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]=K(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:i}=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=i,t}}const Ce=BigInt(2**32-1),Ye=BigInt(32);function He(e,t=!1){return t?{h:Number(e&Ce),l:Number(e>>Ye&Ce)}:{h:Number(e>>Ye&Ce)|0,l:Number(e&Ce)|0}}function Dt(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)<<Ye|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,$r=(e,t)=>t,Dr=(e,t)=>e,Tt=(e,t,n)=>e<<n|t>>>32-n,Ct=(e,t,n)=>t<<n|e>>>32-n,Ht=(e,t,n)=>t<<n-32|e>>>64-n,Vt=(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:Dt,toBig:Ir,shrSH:Ar,shrSL:Or,rotrSH:_r,rotrSL:Lr,rotrBH:Ur,rotrBL:Sr,rotr32H:$r,rotr32L:Dr,rotlSH:Tt,rotlSL:Ct,rotlBH:Ht,rotlBL:Vt,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],i=s[o+1];let f=g[2*e],a=g[2*e+1],l=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,l,c);a=V.add3H(b,a,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^a,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotr32H(p,y),Dl:V.rotr32L(p,y)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:l}={Bh:d^u,Bl:l^h},{Bh:d,Bl:l}={Bh:V.rotrSH(d,l,24),Bl:V.rotrSL(d,l,24)},g[2*e]=f,g[2*e+1]=a,g[2*t]=l,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}function ne(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],a=g[2*e+1],l=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,l,c);a=V.add3H(b,a,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^a,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotrSH(p,y,16),Dl:V.rotrSL(p,y,16)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:l}={Bh:d^u,Bl:l^h},{Bh:d,Bl:l}={Bh:V.rotrBH(d,l,63),Bl:V.rotrBL(d,l,63)},g[2*e]=f,g[2*e+1]=a,g[2*t]=l,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,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^=K(r[0]),this.v4h^=K(r[1]),this.v5l^=K(r[2]),this.v5h^=K(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=K(r[0]),this.v6h^=K(r[1]),this.v7l^=K(r[2]),this.v7h^=K(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:i,v3h:f,v4l:a,v4h:l,v5l:d,v5h:h,v6l:u,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,i,f,a,l,d,h,u,y,p,b]}set(t,n,r,s,o,c,i,f,a,l,d,h,u,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=i|0,this.v3h=f|0,this.v4l=a|0,this.v4h=l|0,this.v5l=d|0,this.v5h=h|0,this.v6l=u|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,a)=>g[a]=f),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 i=Br;for(let f=0;f<12;f++)te(0,4,8,12,t,n+2*i[c++]),ne(0,4,8,12,t,n+2*i[c++]),te(1,5,9,13,t,n+2*i[c++]),ne(1,5,9,13,t,n+2*i[c++]),te(2,6,10,14,t,n+2*i[c++]),ne(2,6,10,14,t,n+2*i[c++]),te(3,7,11,15,t,n+2*i[c++]),ne(3,7,11,15,t,n+2*i[c++]),te(0,5,10,15,t,n+2*i[c++]),ne(0,5,10,15,t,n+2*i[c++]),te(1,6,11,12,t,n+2*i[c++]),ne(1,6,11,12,t,n+2*i[c++]),te(2,7,8,13,t,n+2*i[c++]),ne(2,7,8,13,t,n+2*i[c++]),te(3,4,9,14,t,n+2*i[c++]),ne(3,4,9,14,t,n+2*i[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=kr(e=>new Cr(e)),Mt=new TextEncoder().encode("SS58PRE"),Je=2,jt=e=>{try{const t=Lt.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-Je),s=t.subarray(n.length+r.length),o=Ve(Uint8Array.of(...Mt,...n,...r),{dkLen:64}).subarray(0,Je);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)},Pt=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(...Mt,...t,...n),{dkLen:64}).subarray(0,Je);return Lt.encode(Uint8Array.of(...t,...n,...r))}};function Vr(e,t){return n=>{const r=jt(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 Qe=(e=42,t=32)=>R($(t),Vr(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 Ze={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|Ze[e[2]]);for(let o=0;o<r;){const c=n+o*2,i=Ze[e[c]],f=Ze[e[c+1]];s[t+o++]=i<<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,Rt=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,Ee=(e,t,n)=>jr(e,typeof t!="symbol"?t+"":t,n),Ft=(e,t,n)=>t.has(e)||Rt("Cannot "+n),G=(e,t,n)=>(Ft(e,t,"read from private field"),n?n.call(e):t.get(e)),ke=(e,t,n)=>t.has(e)?Rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),de=(e,t,n,r)=>(Ft(e,t,"write to private field"),t.set(e,n),n),Y,xe,je,Pe,Ne;const Pr=new TextEncoder,Nr=new TextDecoder,qr=z(T,$(1/0))[1];class se{constructor(t,n=!1){if(ke(this,Y),ke(this,xe,null),ke(this,je,null),ke(this,Pe,null),ke(this,Ne,null),Ee(this,"asText",()=>G(this,Ne)??de(this,Ne,Nr.decode(G(this,Y)))),Ee(this,"asHex",()=>G(this,je)||de(this,je,re(G(this,Y)))),Ee(this,"asOpaqueHex",()=>G(this,Pe)||de(this,Pe,re(this.asBytes()))),Ee(this,"asBytes",()=>G(this,Y)),Ee(this,"asOpaqueBytes",()=>G(this,xe)||de(this,xe,be(T[0](G(this,Y).length),G(this,Y)))),n){try{const[r,s]=qr(t);if(r===s.length){de(this,Y,s),de(this,xe,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,xe=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[Rr]=Qe();class Xt extends se{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Rr(t))}}const zt=e=>{const t=$.enc(e);return n=>t(n.asBytes())},Kt=e=>{const t=$.dec(e),n=e==null?se:Xt;return r=>n.fromBytes(t(r))},Be=e=>x(zt(e),Kt(e));Be.enc=zt,Be.dec=Kt;const m=T,Fr=T,Xr=Ke(e=>{const t=m.dec(e),n=Math.ceil(t/8);return{bytes:$(n).dec(e),bitsLen:t}}),Wt=x(e=>{if(e.bitsLen>e.bytes.length*8)throw new Error(`Not enough bytes. (bitsLen:${e.bitsLen}, bytesLen:${e.bytes.length})`);const t=m.enc(e.bitsLen),n=new Uint8Array(e.bytes.length+t.length);return n.set(t,0),n.set(e.bytes,t.length),n},Xr),zr=R(L,e=>e.charCodeAt(0),String.fromCharCode),Gt=e=>{const t=$.enc(e);return n=>t(Me(n))},Yt=e=>{const t=$.dec(e);return n=>re(t(n))},oe=e=>x(Gt(e),Yt(e));oe.enc=Gt,oe.dec=Yt;const Kr=new TextEncoder,Wr=new TextDecoder,Gr=e=>R($(e),t=>Kr.encode(t),t=>Wr.decode(t)),Jt=e=>{let t=n=>{const r=e();return t=r,r(n)};return n=>t(n)},Qt=e=>{let t=n=>{const r=e(),s=r;return t=r,s(n)};return n=>t(n)},Zt=e=>x(Jt(()=>e().enc),Qt(()=>e().dec)),et=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=>et(t,n)}}),en=(...e)=>{const t=F.enc(...e);return n=>t({tag:n.type,value:n.value})},tn=(...e)=>{const t=F.dec(...e);return n=>{const{tag:r,value:s}=t(n);return et(r,s)}},fe=(e,...t)=>x(en(qt(e,([n])=>n),...t),tn(qt(e,([,n])=>n),...t));fe.enc=en,fe.dec=tn;const nn=[],rn=[],sn=[],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],nn.push(2*(5*r+n)),rn.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);sn.push(s)}const[ns,rs]=Dt(sn,!0),on=(e,t,n)=>n>32?Ht(e,t,n):Tt(e,t,n),cn=(e,t,n)=>n>32?Vt(e,t,n):Ct(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 i=(c+8)%10,f=(c+2)%10,a=n[f],l=n[f+1],d=on(a,l,1)^n[i],h=cn(a,l,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=d,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=rn[c],f=on(s,o,i),a=cn(s,o,i),l=nn[c];s=e[l],o=e[l+1],e[l]=f,e[l+1]=a}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=ns[r],e[1]^=rs[r]}n.fill(0)}class tt extends St{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 i=0;i<c;i++)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),De(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(Ge(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 tt(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)=>Er(()=>new tt(t,e,n)))(1,136,256/8),an=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=$(20)[1],ln=x(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(an(n)!==e)throw new Error(`Invalid checksum found on EthAddress(${e})`);return t},Ke(e=>an(re(cs(e))))),un=new TextEncoder,hn=new TextDecoder,is=R($(4),un.encode.bind(un),hn.decode.bind(hn)),nt=v({engine:is,payload:oe()}),as=fe({consensus:nt,seal:nt,preRuntime:nt,runtimeUpdated:w},[4,5,6,8]),rt=oe(32),ls=v({parentHash:rt,number:m,stateRoot:rt,extrinsicRoot:rt,digests:B(as)}),J=B(A),dn=P(A),us=F({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),fn=B(v({name:dn,type:m,typeName:dn,docs:J})),hs=v({len:ee,type:m}),ds=v({bitStoreType:m,bitOrderType:m}),fs=B(v({name:A,fields:fn,index:L,docs:J})),ys=F({composite:fn,variant:fs,sequence:m,array:hs,tuple:B(m),primitive:us,compact:m,bitSequence:ds}),ps=v({name:A,type:P(m)}),gs=B(ps),bs=v({id:m,path:J,params:gs,def:ys,docs:J}),qe=B(bs),ms=F({Blake2128:w,Blake2256:w,Blake2128Concat:w,Twox128:w,Twox256:w,Twox64Concat:w,Identity:w}),ws=B(ms),vs=v({hashers:ws,key:m,value:m}),Es=v({name:A,modifier:L,type:F({plain:m,map:vs}),fallback:oe(),docs:J}),ks=P(v({prefix:A,items:B(Es)})),yn={name:A,storage:ks,calls:P(m),events:P(m),constants:B(v({name:A,type:m,value:oe(),docs:J})),errors:P(m),index:L},xs={...yn,docs:J},Bs=new Uint8Array,pn=e=>x(()=>Bs,()=>e),Is=v({type:m,version:L,signedExtensions:B(v({identifier:A,type:m,additionalSigned:m}))}),gn=v({lookup:qe,pallets:B(v({...yn,docs:pn([])})),extrinsic:Is,type:m,apis:pn([])}),As=v({name:A,methods:B(v({name:A,inputs:B(v({name:A,type:m})),output:m,docs:J})),docs:J}),Os=v({version:L,address:m,call:m,signature:m,extra:m,signedExtensions:B(v({identifier:A,type:m,additionalSigned:m}))}),bn=v({lookup:qe,pallets:B(v(xs)),extrinsic:Os,type:m,apis:B(As),outerEnums:v({call:m,event:m,error:m}),custom:B(z(A,v({type:m,value:oe()})))}),mn=()=>{throw new Error("Unsupported metadata version!")},M=x(mn,mn),Ae=v({magicNumber:ee,metadata:F({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:gn,v15:bn})}),st=$(),_s=P(st),Ls=z(T,st),Us=e=>{try{return Ae.dec(e)}catch{}try{return Ae.dec(_s.dec(e))}catch{}try{return Ae.dec(st.dec(e))}catch{}try{return Ae.dec(Ls.dec(e)[1])}catch{}throw null},Ss={dkLen:32},$s=e=>Ve(e,Ss),Ds={dkLen:16},wn=e=>Ve(e,Ds),vn=e=>be(wn(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 En(e,t,n,r,s,o,c,i,f,a,l,d,h,u,y,p,b,E,_,j){let I=0;for(let pe=0;pe<r;pe++)({a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[I++]])),{a:s,b:f,c:h,d:b}=ie(s,f,h,b,n[t+e[I++]]),{a:o,b:a,c:u,d:E}=ce(o,a,u,E,n[t+e[I++]]),{a:o,b:a,c:u,d:E}=ie(o,a,u,E,n[t+e[I++]]),{a:c,b:l,c:y,d:_}=ce(c,l,y,_,n[t+e[I++]]),{a:c,b:l,c:y,d:_}=ie(c,l,y,_,n[t+e[I++]]),{a:i,b:d,c:p,d:j}=ce(i,d,p,j,n[t+e[I++]]),{a:i,b:d,c:p,d:j}=ie(i,d,p,j,n[t+e[I++]]),{a:s,b:a,c:y,d:j}=ce(s,a,y,j,n[t+e[I++]]),{a:s,b:a,c:y,d:j}=ie(s,a,y,j,n[t+e[I++]]),{a:o,b:l,c:p,d:b}=ce(o,l,p,b,n[t+e[I++]]),{a:o,b:l,c:p,d:b}=ie(o,l,p,b,n[t+e[I++]]),{a:c,b:d,c:h,d:E}=ce(c,d,h,E,n[t+e[I++]]),{a:c,b:d,c:h,d:E}=ie(c,d,h,E,n[t+e[I++]]),{a:i,b:f,c:u,d:_}=ce(i,f,u,_,n[t+e[I++]]),{a:i,b:f,c:u,d:_}=ie(i,f,u,_,n[t+e[I++]]);return{v0:s,v1:o,v2:c,v3:i,v4:f,v5:a,v6:l,v7:d,v8:h,v9:u,v10:y,v11:p,v12:b,v13:E,v14:_,v15:j}}const kn=(()=>{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 ot 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 ot({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=wr(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:f}=He(BigInt(t),!0),{v0:a,v1:l,v2:d,v3:h,v4:u,v5:y,v6:p,v7:b,v8:E,v9:_,v10:j,v11:I,v12:pe,v13:Fe,v14:Xe,v15:ao}=En(kn,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],i,f,c,n);o[0]=a^E,o[1]=l^_,o[2]=d^j,o[3]=h^I,o[4]=u^pe,o[5]=y^Fe,o[6]=p^Xe,o[7]=b^ao}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,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=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:i,stack:f,chunksDone:a}=this;return t.state.set(s.slice()),t.stack=f.map(l=>Uint32Array.from(l)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=a,t.posOut=c,t.chunkOut=i,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:i}=He(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:a,v2:l,v3:d,v4:h,v5:u,v6:y,v7:p,v8:b,v9:E,v10:_,v11:j,v12:I,v13:pe,v14:Fe,v15:Xe}=En(kn,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],i,c,n,r);o[0]=f^b,o[1]=a^E,o[2]=l^_,o[3]=d^j,o[4]=h^I,o[5]=u^pe,o[6]=y^Fe,o[7]=p^Xe,o[8]=t[0]^b,o[9]=t[1]^E,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),De(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(Ge(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=xr(e=>new ot(e)),Cs={dkLen:32},xn=e=>Ts(e,Cs),Hs=e=>be(xn(e),e),Bn=e=>e,ye=(e,t,n,r)=>new DataView(new Uint16Array([e,t,n,r]).buffer).getBigUint64(0,!0),ct=2n**64n-1n,D=(e,t)=>e<<t&ct|e>>64n-t,k=(e,t)=>e*t&ct,U=(e,t)=>e+t&ct,S=11400714785074694791n,N=14029467366897019727n,In=1609587929392839161n,Oe=9650029242287828579n,An=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,i=0,f=null;(function(){let u=0,y=u+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),i),i+=c;return}if(u<=y-32){const p=y-32;do{let b;b=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]),n=k(D(U(n,k(b,N)),31n),S),u+=8,b=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]),r=k(D(U(r,k(b,N)),31n),S),u+=8,b=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]),s=k(D(U(s,k(b,N)),31n),S),u+=8,b=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]),o=k(D(U(o,k(b,N)),31n),S),u+=8}while(u<=p)}u<y&&(f.set(e.subarray(u,y),i),i=y-u)}})(),e=f||e;let a,l=0;for(c>=32?(a=D(n,1n),a=U(a,D(r,7n)),a=U(a,D(s,12n)),a=U(a,D(o,18n)),n=k(D(k(n,N),31n),S),a=a^n,a=U(k(a,S),Oe),r=k(D(k(r,N),31n),S),a=a^r,a=U(k(a,S),Oe),s=k(D(k(s,N),31n),S),a=a^s,a=U(k(a,S),Oe),o=k(D(k(o,N),31n),S),a=a^o,a=U(k(a,S),Oe)):a=U(t,An),a=U(a,BigInt(c));l<=i-8;){let h=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]);h=k(D(k(h,N),31n),S),a=U(k(D(a^h,27n),S),Oe),l+=8}if(l+4<=i){let h=k(ye(e[l+1]<<8|e[l],e[l+3]<<8|e[l+2],0,0),S);a=U(k(D(a^h,23n),N),In),l+=4}for(;l<i;){const h=k(ye(e[l++],0,0,0),An);a=k(D(a^h,11n),S)}let d=a>>33n;return a=k(a^d,N),d=a>>29n,a=k(a^d,In),d=a>>32n,a^=d,a}const it=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},On=e=>be(Se.enc(ae(e)),e),_n=new TextEncoder;var Ms=Object.freeze({__proto__:null,AccountId:Qe,Bin:Be,Binary:se,Blake2128:wn,Blake2128Concat:vn,Blake2256:$s,Blake3256:xn,Blake3256Concat:Hs,Bytes:$,Enum:et,FixedSizeBinary:Xt,Hex:oe,Identity:Bn,Option:P,Result:$e,ScaleEnum:F,Self:Zt,Storage:e=>{const t=it(_n.encode(e));return(n,r,...s)=>{const o=be(t,it(_n.encode(n))),c=re(o),i=s.map(d=>d[1]).map(d=>{switch(d){case Bn:return 0;case On:return 8;case vn: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(i.length!==s.length)throw new Error("Impossible to decode this key");if(s.length===0)return[];const h=d.slice(c.length),u=new Array(s.length);for(let y=0,p=0;y<i.length;y++){const b=s[y][0];p+=i[y],u[y]=b.dec(h.slice(p*2)),p+=b.enc(u[y]).length}return u},a=s.map(([{enc:d},h])=>u=>h(d(u)));return{enc:(...d)=>re(be(o,...d.map((h,u)=>a[u](h)))),dec:r,keyDecoder:f}}},Struct:v,Tuple:z,Twox128:it,Twox256:Vs,Twox64Concat:On,Variant:fe,Vector:B,_Enum:Yr,_void:w,bitSequence:Wt,blockHeader:ls,bool:Yn,char:zr,compact:T,compactBn:Fr,compactNumber:m,createCodec:x,createDecoder:Ke,decAnyMetadata:Us,enhanceCodec:R,enhanceDecoder:Ue,enhanceEncoder:We,ethAccount:ln,fixedStr:Gr,fromBufferToBase58:Pt,getSs58AddressInfo:jt,h64:ae,i128:Kn,i16:Rn,i256:Gn,i32:Fn,i64:Xn,i8:qn,metadata:Ae,selfDecoder:Qt,selfEncoder:Jt,str:A,u128:zn,u16:we,u256:Wn,u32:ee,u64:Se,u8:L,v14:gn,v14Lookup:qe,v15:bn});const js=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const a=t(()=>s.get(i),r,...c);return s.set(i,a),a}o.add(i);let f=e(r,s,o,...c);return o.delete(i),s.has(i)&&(f=n(f,s.get(i),r,...c)),s.set(i,f),f},Ps=Be(),Ns=x(T[0],Ue(T[1],BigInt)),Ln=js((e,t,n,r)=>{if(e.type==="primitive")return Ms[e.value];if(e.type==="void")return w;if(e.type==="AccountId32")return r;if(e.type==="AccountId20")return ln;if(e.type==="compact")return e.isBig?Ns:T;if(e.type==="bitSequence")return Wt;const s=u=>Ln(u,t,n,r),o=(u,y)=>{const p=s(u);return y?B(p,y):B(p)},c=u=>z(...u.map(s)),i=u=>{const y=Object.fromEntries(Object.entries(u).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 i(e.value);if(e.type==="option")return P(s(e.value));if(e.type==="result")return $e(s(e.value.ok),s(e.value.ko));const f=Object.values(e.value).map(u=>{switch(u.type){case"void":return w;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),a=Object.fromEntries(Object.keys(e.value).map((u,y)=>[u,f[y]])),l=Object.values(e.value).map(u=>u.idx),h=l.every((u,y)=>u===y)?fe(a):fe(a,l);return e.byteLength?Rs(h,e.byteLength):h},Zt,e=>e),qs=(e,t=Qe())=>{const n=new Map,r=s=>Ln(e(s),n,new Set,t);return s=>r(s)},Rs=(e,t)=>{const n=$(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Fs=e=>{const{metadata:t}=e,n=qs(e),r=(l="")=>{const d=e.storage[l];if(!d)throw new Error(`Storage entry ${l||"{root}"} not found`);const h=d.key==null?w:n(d.key);return{key:Un(h,d.keyPrefix),value:n(d.typeId)}},s=l=>{const d=v(Object.fromEntries(l.args.map(h=>[h.label,n(h.type.type)])));return{call:Un(d,l.selector),value:n(l.returnType.type)}},o=l=>{const d=t.spec.constructors.find(h=>h.label===l);if(!d)throw new Error(`Constructor ${l} not found`);return s(d)},c=l=>{const d=t.spec.messages.find(h=>h.label===l);if(!d)throw new Error(`Message ${l} not found`);return s(d)},i=l=>v(Object.fromEntries(l.args.map(d=>[d.label,n(d.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>fe(Object.fromEntries(t.spec.events.map(l=>[l.label,i(l)]))),buildEvent:l=>{const d=t.spec.events,h=(y,p)=>R(y,b=>b.value,b=>({type:p,value:b}));if(l){const y=d.find(p=>p.signature_topic===l);return y?h(i(y),y.label):null}const u=d.filter(y=>y.signature_topic===l);return u.length?Xs(u.map(y=>h(i(y),y.label))):null}}},Un=(e,t)=>{const n=se.fromHex(t).asBytes(),r=z($(n.length),e);return R(r,s=>[n,s],([,s])=>s)},Xs=e=>x(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),Sn=e=>R(F(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)=>R(B(e,t),n=>n??[],n=>n),$n=P(A),Re=_e(A),zs=Sn({bool:w,char:w,str:w,u8:w,u16:w,u32:w,u64:w,u128:w,u256:w,i8:w,i16:w,i32:w,i64:w,i128:w,i256:w}),Dn=_e(v({name:$n,type:m,typeName:$n,docs:Re})),Ks=v({len:ee,type:m}),Ws=v({bitStoreType:m,bitOrderType:m}),Gs=_e(v({name:A,fields:Dn,index:L,docs:Re})),Ys=Sn({composite:v({fields:Dn}),variant:v({variants:Gs}),sequence:v({type:m}),array:Ks,tuple:B(m),primitive:zs,compact:m,bitSequence:Ws}),Js=v({name:A,type:P(m)}),Qs=_e(Js),Zs=v({id:m,path:Re,params:Qs,def:Ys,docs:Re}),eo=R(Zs,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}})),to=_e(eo),no=e=>{const t=to.enc(e.types),n=qe.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=ro(e,n),c=Hn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function ro(e,t){const n={},r=(s,o=[])=>{function c(f){const a=t.length;return t[a]={id:a,docs:[],def:f,params:[],path:[]},a}if("root"in s){const f=Number(e.version)===4?se.fromBytes(se.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,a=r(s.root.layout,o);if(s.root.ty!=null){let l=function(d,h){const u=e.types[d].type,y="composite"in u.def?new Map((u.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((u.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){l(y.get("len"),[...h,"len"]),l(y.get("elements"),h);return}else p.size===3&&p.has("K")&&p.has("V")?n[h.join(".")]={keyPrefix:f,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[h.join(".")]={keyPrefix:f,key:null,typeId:p.get("V")})};l(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:f,key:null,typeId:a}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const f=r(s.array.layout,o);return f==null?null:c({tag:"array",value:{len:s.array.len,type:f}})}if("struct"in s){const f=s.struct.fields.map(a=>({name:a.name,type:r(a.layout,[...o,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!=null);return c({tag:"composite",value:f})}const i=Object.values(s.enum.variants).map((f,a)=>({name:f.name,fields:f.fields.map(l=>({name:l.name,type:r(l.layout,[...o,f.name,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!==null),index:a,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const so=e=>{const t=no(e.metadata),n=Fs(t);return{constructor:Tn(n.buildConstructor),message:Tn(n.buildMessage),storage:oo(n.buildStorage),event:Number(t.metadata.version)===4?co(n.buildEvents):io(t,n.buildEvent)}},Tn=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},oo=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},co=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},io=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>i.map(a=>"event"in a?a:{event:a,topics:a.topics}).filter(a=>a.event.type==="Contracts"&&a.event.value.type==="ContractEmitted"&&a.event.value.value.contract===c).map(a=>{const l=a.topics.map(h=>h.asHex()),d=l.find(h=>n.has(h));try{return s(a.event.value.value,d)}catch{return console.error(`Contract ${c} emitted an incompatible event`,{event:a.event.value.value.data.asHex(),eventTopics:l,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(a=>a!==null)}};me.getInkClient=so});
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"},Vn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=a=>d=>{let h=n.get(d);if(h)return h;if(r.has(d)){const y={id:d};return n.set(d,y),y}r.add(d);const u=a(d);return h=n.get(d),h?Object.assign(h,u):(h={id:d,...u},n.set(d,h)),r.delete(d),h};let o=!0,c=!0;const i=s(a=>{const d=t(e[a]);if(d)return d;const{def:h,path:u,params:y}=e[a];if(h.tag==="composite"){if(h.value.length===0)return le;if(h.value.length===1){const p=i(h.value[0].type);return o&&u.at(-1)==="AccountId32"&&ge(p,32)?(o=!1,{type:"AccountId32"}):c&&u.at(-1)==="AccountId20"&&ge(p,20)?(c=!1,{type:"AccountId20"}):p}return f(h.value)}if(h.tag==="variant"){if(u.length===1&&u[0]==="Option"&&y.length===1&&y[0].name==="T"){const E=i(y[0].type);return E.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:E}}if(u.length===1&&u[0]==="Result"&&y.length===2&&y[0].name==="T"&&y[1].name==="E")return{type:"result",value:{ok:i(y[0].type),ko:i(y[1].type)}};if(h.value.length===0)return le;const p={},b={};return h.value.forEach(E=>{const I=E.name;if(b[I]=E.docs,E.fields.length===0){p[I]={...le,idx:E.index};return}if(E.fields.length===1&&!E.fields[0].name){p[I]={type:"lookupEntry",value:i(E.fields[0].type),idx:E.index};return}p[I]={...f(E.fields),idx:E.index}}),{type:"enum",value:p,innerDocs:b}}if(h.tag==="sequence")return{type:"sequence",value:i(h.value)};if(h.tag==="array"){const{len:p}=h.value,b=i(h.value.type);return!p||b.type==="void"?le:p>1?{type:"array",value:b,len:h.value.len}:b}if(h.tag==="tuple")return h.value.length===0?le:h.value.length>1?l(h.value.map(p=>i(p)),h.value.map(p=>e[p].docs)):i(h.value[0]);if(h.tag==="primitive")return{type:"primitive",value:h.value.tag};if(h.tag==="compact"){const p=i(h.value);return p.type==="void"?le:{type:"compact",isBig:Number(p.value.slice(1))>32,size:p.value}}return{type:h.tag}}),f=a=>{let d=!0;const h={},u={};return a.forEach((y,p)=>{d=d&&!!y.name;const b=y.name||p,E=i(y.type);E.type!=="void"&&(h[b]=E,u[b]=y.docs)}),d?{type:"struct",value:h,innerDocs:u}:l(Object.values(h),Object.values(u))},l=(a,d)=>{if(a.every(h=>h.id===a[0].id)&&d.every(h=>!h.length)){const[h]=a;return h.type==="void"?le:{type:"array",value:a[0],len:a.length}}return{type:"tuple",value:a,innerDocs:d}};return i},Mn=e=>Vn(e);var jn=Object.defineProperty,Pn=(e,t,n)=>t in e?jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n)=>(Pn(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 Nn(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,i=Ke[e[c]],f=Ke[e[c+1]];s[t+o++]=i<<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)}},q=e=>t=>e(t instanceof ut?t:new ut(t instanceof Uint8Array?t.buffer:typeof t=="string"?Nn(t).buffer:t)),X=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;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=q,x=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},Ge=(e,t)=>n=>e(t(n)),Se=(e,t)=>n=>t(e(n)),R=([e,t],n,r)=>x(Ge(e,n),Se(t,r));function qn(e,t){return q(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 ee(e,t,n){return x(Rn(e,n),qn(e,t))}var U=ee(1,"getUint8","setUint8"),me=ee(2,"getUint16","setUint16"),te=ee(4,"getUint32","setUint32"),$e=ee(8,"getBigUint64","setBigUint64"),Fn=ee(1,"getInt8","setInt8"),Xn=ee(2,"getInt16","setInt16"),zn=ee(4,"getInt32","setInt32"),Kn=ee(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=>q(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}),Wn=x(ht,dt("getBigUint64")),Gn=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=>q(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}),Yn=x(ft,yt("getBigUint64")),Jn=x(ft,yt("getBigInt64")),Qn=R(U,e=>e?1:0,Boolean),Zn=[U[1],me[1],te[1]],er=q(e=>{const t=e[e.i],n=t&3;if(n<3)return Zn[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=$e[1](e)<<c|s,c+=64n;let i=r%8;return i>3&&(s=BigInt(te[1](e))<<c|s,c+=32n,i-=4),i>1&&(s=BigInt(me[1](e))<<c|s,c+=16n,i-=2),i&&(s=BigInt(U[1](e))<<c|s),s}),tr=1n<<56n,nr=1<<24,rr=256,sr=4294967295n,or=64,cr=16384,ir=1<<30,ar=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<or)return U[0](t);if(e<cr)return me[0](t|1);if(e<ir)return te[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=tr;)n.push($e[0](r)),r>>=64n;r>=nr&&(n.push(te[0](Number(r&sr))),r>>=32n);let s=Number(r);s>=rr&&(n.push(me[0](s)),s>>=16),s&&n.push(U[0](s));const o=X(n);return o[0]=o.length-5<<2|3,o},T=x(ar,er),lr=new TextEncoder,ur=e=>{const t=lr.encode(e);return X([T.enc(t.length),t])},hr=new TextDecoder,dr=q(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,hr.decode(n)}),O=x(ur,dr),fr=()=>{},yr=new Uint8Array(0),m=x(()=>yr,fr),pt=e=>e===void 0?t=>X([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),gt=e=>q(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}),$=e=>x(pt(e),gt(e));$.enc=pt,$.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([U.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 q(s=>{const o=U.dec(s),c=r.get(o),i=e[c];return{tag:c,value:i(s)}})},F=(e,...t)=>x(bt(Le(e,([n])=>n),...t),wt(Le(e,([,n])=>n),...t));F.enc=bt,F.dec=wt;var mt=e=>q(t=>U[1](t)>0?e(t):void 0),vt=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,X([n,e(t)]))},P=e=>x(vt(e[0]),mt(e[1]));P.enc=vt,P.dec=mt;var Et=(e,t)=>q(n=>{const r=U[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),kt=(e,t)=>({success:n,value:r})=>X([U[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>x(kt(e[0],t[0]),Et(e[1],t[1]));De.dec=Et,De.enc=kt;var xt=(...e)=>q(t=>e.map(n=>n(t))),Bt=(...e)=>t=>X(e.map((n,r)=>n(t[r]))),z=(...e)=>x(Bt(...e.map(([t])=>t)),xt(...e.map(([,t])=>t)));z.enc=Bt,z.dec=xt;var It=e=>{const t=Object.keys(e);return Ge(z.enc(...Object.values(e)),n=>t.map(r=>n[r]))},At=e=>{const t=Object.keys(e);return Se(z.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},v=e=>x(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=>X(n.map(e)):n=>X([T.enc(n.length),X(n.map(e))]),_t=(e,t)=>q(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 pr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function gr(...e){const t=o=>o,n=(o,c)=>i=>o(c(i)),r=e.map(o=>o.encode).reduceRight(n,t),s=e.map(o=>o.decode).reduce(n,t);return{encode:r,decode:s}}function br(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 wr(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 Ut(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,i=!0;for(let f=r;f<o.length;f++){const l=o[f],a=t*c+l;if(!Number.isSafeInteger(a)||t*c/t!==c||a-l!==t*c)throw new Error("convertRadix: carry overflow");c=a%n;const d=Math.floor(a/n);if(o[f]=d,!Number.isSafeInteger(d)||d*n+c!==a)throw new Error("convertRadix: carry overflow");if(i)d?i=!1:r=f;else continue}if(s.push(c),i)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function mr(e){return{encode:t=>{if(!pr(t))throw new Error("radix.encode input should be Uint8Array");return Ut(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(Ut(t,e,2**8))}}}const Lt=(e=>gr(mr(58),br(e),wr("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function vr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Te(e,...t){if(!vr(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){Te(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 Er=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),he=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Ce=(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,K=C?e=>e:e=>St(e);function H(e){for(let t=0;t<e.length;t++)e[t]=St(e[t])}function kr(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=kr(e)),Te(e),e}class $t{clone(){return this._cloneInto()}}function xr(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 Br(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 Ir(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 Ar=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 Dt extends $t{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,i=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 l=Math.min(n-this.pos,o-f),a=c+f;if(l===n&&!(a%4)&&f+l<o){const d=new Uint32Array(i,a,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+l),this.pos),this.pos+=l,this.length+=l,f+=l}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]=K(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:i}=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=i,t}}const He=BigInt(2**32-1),Je=BigInt(32);function Ve(e,t=!1){return t?{h:Number(e&He),l:Number(e>>Je&He)}:{h:Number(e>>Je&He)|0,l:Number(e&He)|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}=Ve(e[s],t);[n[s],r[s]]=[o,c]}return[n,r]}const Or=(e,t)=>BigInt(e>>>0)<<Je|BigInt(t>>>0),_r=(e,t,n)=>e>>>n,Ur=(e,t,n)=>e<<32-n|t>>>n,Lr=(e,t,n)=>e>>>n|t<<32-n,Sr=(e,t,n)=>e<<32-n|t>>>n,$r=(e,t,n)=>e<<64-n|t>>>n-32,Dr=(e,t,n)=>e>>>n-32|t<<64-n,Tr=(e,t)=>t,Cr=(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 Hr(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:Ve,split:Tt,toBig:Or,shrSH:_r,shrSL:Ur,rotrSH:Lr,rotrSL:Sr,rotrBH:$r,rotrBL:Dr,rotr32H:Tr,rotr32L:Cr,rotlSH:Ct,rotlSL:Ht,rotlBH:Vt,rotlBL:Mt,add:Hr,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)},_=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),g=new Uint32Array(32);function ne(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,a,c);l=V.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotr32H(p,y),Dl:V.rotr32L(p,y)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:V.rotrSH(d,a,24),Bl:V.rotrSL(d,a,24)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}function re(e,t,n,r,s,o){const c=s[o],i=s[o+1];let f=g[2*e],l=g[2*e+1],a=g[2*t],d=g[2*t+1],h=g[2*n],u=g[2*n+1],y=g[2*r],p=g[2*r+1],b=V.add3L(f,a,c);l=V.add3H(b,l,d,i),f=b|0,{Dh:p,Dl:y}={Dh:p^l,Dl:y^f},{Dh:p,Dl:y}={Dh:V.rotrSH(p,y,16),Dl:V.rotrSL(p,y,16)},{h:u,l:h}=V.add(u,h,p,y),{Bh:d,Bl:a}={Bh:d^u,Bl:a^h},{Bh:d,Bl:a}={Bh:V.rotrBH(d,a,63),Bl:V.rotrBL(d,a,63)},g[2*e]=f,g[2*e+1]=l,g[2*t]=a,g[2*t+1]=d,g[2*n]=h,g[2*n+1]=u,g[2*r]=y,g[2*r+1]=p}class Vr extends Dt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=_[0]|0,this.v0h=_[1]|0,this.v1l=_[2]|0,this.v1h=_[3]|0,this.v2l=_[4]|0,this.v2h=_[5]|0,this.v3l=_[6]|0,this.v3h=_[7]|0,this.v4l=_[8]|0,this.v4h=_[9]|0,this.v5l=_[10]|0,this.v5h=_[11]|0,this.v6l=_[12]|0,this.v6h=_[13]|0,this.v7l=_[14]|0,this.v7h=_[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^=K(r[0]),this.v4h^=K(r[1]),this.v5l^=K(r[2]),this.v5h^=K(r[3])}if(t.personalization){const r=he(W(t.personalization));this.v6l^=K(r[0]),this.v6h^=K(r[1]),this.v7l^=K(r[2]),this.v7h^=K(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:i,v3h:f,v4l:l,v4h:a,v5l:d,v5h:h,v6l:u,v6h:y,v7l:p,v7h:b}=this;return[t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b]}set(t,n,r,s,o,c,i,f,l,a,d,h,u,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=i|0,this.v3h=f|0,this.v4l=l|0,this.v4h=a|0,this.v5l=d|0,this.v5h=h|0,this.v6l=u|0,this.v6h=y|0,this.v7l=p|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((f,l)=>g[l]=f),g.set(_,16);let{h:s,l:o}=V.fromBig(BigInt(this.length));g[24]=_[8]^o,g[25]=_[9]^s,r&&(g[28]=~g[28],g[29]=~g[29]);let c=0;const i=Ar;for(let f=0;f<12;f++)ne(0,4,8,12,t,n+2*i[c++]),re(0,4,8,12,t,n+2*i[c++]),ne(1,5,9,13,t,n+2*i[c++]),re(1,5,9,13,t,n+2*i[c++]),ne(2,6,10,14,t,n+2*i[c++]),re(2,6,10,14,t,n+2*i[c++]),ne(3,7,11,15,t,n+2*i[c++]),re(3,7,11,15,t,n+2*i[c++]),ne(0,5,10,15,t,n+2*i[c++]),re(0,5,10,15,t,n+2*i[c++]),ne(1,6,11,12,t,n+2*i[c++]),re(1,6,11,12,t,n+2*i[c++]),ne(2,7,8,13,t,n+2*i[c++]),re(2,7,8,13,t,n+2*i[c++]),ne(3,4,9,14,t,n+2*i[c++]),re(3,4,9,14,t,n+2*i[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 Me=Br(e=>new Vr(e)),jt=new TextEncoder().encode("SS58PRE"),Qe=2,Pt=e=>{try{const t=Lt.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:Mr(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Mr=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=Me(Uint8Array.of(...jt,...t,...n),{dkLen:64}).subarray(0,Qe);return Lt.encode(Uint8Array.of(...t,...n,...r))}};function jr(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)=>R($(t),jr(t),Nt(e)),qt="0123456789abcdef";function G(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=qt[r>>4]+qt[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 Ee(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,i=et[e[c]],f=et[e[c+1]];s[t+o++]=i<<4|f}return s}function Rt(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 Pr=Object.defineProperty,Ft=e=>{throw TypeError(e)},Nr=(e,t,n)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ke=(e,t,n)=>Nr(e,typeof t!="symbol"?t+"":t,n),Xt=(e,t,n)=>t.has(e)||Ft("Cannot "+n),Y=(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),J,Be,je,Pe,Ne;const qr=new TextEncoder,Rr=new TextDecoder,Fr=z(T,$(1/0))[1];class se{constructor(t,n=!1){if(xe(this,J),xe(this,Be,null),xe(this,je,null),xe(this,Pe,null),xe(this,Ne,null),ke(this,"asText",()=>Y(this,Ne)??de(this,Ne,Rr.decode(Y(this,J)))),ke(this,"asHex",()=>Y(this,je)||de(this,je,G(Y(this,J)))),ke(this,"asOpaqueHex",()=>Y(this,Pe)||de(this,Pe,G(this.asBytes()))),ke(this,"asBytes",()=>Y(this,J)),ke(this,"asOpaqueBytes",()=>Y(this,Be)||de(this,Be,be(T[0](Y(this,J).length),Y(this,J)))),n){try{const[r,s]=Fr(t);if(r===s.length){de(this,J,s),de(this,Be,t);return}}catch{}throw new Error("Invalid opaque bytes")}else de(this,J,t)}static fromText(t){return new this(qr.encode(t))}static fromHex(t){return new this(Ee(t))}static fromOpaqueHex(t){return new this(Ee(t),!0)}static fromBytes(t){return new this(t)}static fromOpaqueBytes(t){return new this(t,!0)}}J=new WeakMap,Be=new WeakMap,je=new WeakMap,Pe=new WeakMap,Ne=new WeakMap;const[Xr]=Ze();class zt extends se{constructor(t){super(t)}static fromArray(t){return new this(new Uint8Array(t))}static fromAccountId32(t){return new this(Xr(t))}}const Kt=e=>{const t=$.enc(e);return n=>t(n.asBytes())},Wt=e=>{const t=$.dec(e),n=e==null?se:zt;return r=>n.fromBytes(t(r))},Ie=e=>x(Kt(e),Wt(e));Ie.enc=Kt,Ie.dec=Wt;const w=T,zr=T,Kr=We(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:$(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},Kr),Wr=R(U,e=>e.charCodeAt(0),String.fromCharCode),Yt=e=>{const t=$.enc(e);return n=>t(Ee(n))},Jt=e=>{const t=$.dec(e);return n=>G(t(n))},oe=e=>x(Yt(e),Jt(e));oe.enc=Yt,oe.dec=Jt;const Gr=new TextEncoder,Yr=new TextDecoder,Jr=e=>R($(e),t=>Gr.encode(t),t=>Yr.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}}),Qr=new Proxy({},{get(e,t){return n=>tt(t,n)}}),tn=(...e)=>{const t=F.enc(...e);return n=>t({tag:n.type,value:n.value})},nn=(...e)=>{const t=F.dec(...e);return n=>{const{tag:r,value:s}=t(n);return tt(r,s)}},fe=(e,...t)=>x(tn(Rt(e,([n])=>n),...t),nn(Rt(e,([,n])=>n),...t));fe.enc=tn,fe.dec=nn;const rn=[],sn=[],on=[],Zr=BigInt(0),Ae=BigInt(1),es=BigInt(2),ts=BigInt(7),ns=BigInt(256),rs=BigInt(113);for(let e=0,t=Ae,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=Zr;for(let o=0;o<7;o++)t=(t<<Ae^(t>>ts)*rs)%ns,t&es&&(s^=Ae<<(Ae<<BigInt(o))-Ae);on.push(s)}const[ss,os]=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 cs(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 i=(c+8)%10,f=(c+2)%10,l=n[f],a=n[f+1],d=cn(l,a,1)^n[i],h=an(l,a,1)^n[i+1];for(let u=0;u<50;u+=10)e[c+u]^=d,e[c+u+1]^=h}let s=e[2],o=e[3];for(let c=0;c<24;c++){const i=sn[c],f=cn(s,o,i),l=an(s,o,i),a=rn[c];s=e[a],o=e[a+1],e[a]=f,e[a+1]=l}for(let c=0;c<50;c+=10){for(let i=0;i<10;i++)n[i]=e[c+i];for(let i=0;i<10;i++)e[c+i]^=~n[(i+2)%10]&n[(i+4)%10]}e[0]^=ss[r],e[1]^=os[r]}n.fill(0)}class nt extends $t{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),cs(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 i=0;i<c;i++)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),Te(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 is=((e,t,n)=>xr(()=>new nt(t,e,n)))(1,136,256/8),ln=e=>{const t=e.slice(2),n=G(is(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("")}`},as=$(20)[1],un=x(e=>{const t=Ee(e);if(t.length!==20)throw new Error(`Invalid length found on EthAddress(${e})`);const n=G(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(G(as(e))))),hn=new TextEncoder,dn=new TextDecoder,ls=R($(4),hn.encode.bind(hn),dn.decode.bind(dn)),rt=v({engine:ls,payload:oe()}),us=fe({consensus:rt,seal:rt,preRuntime:rt,runtimeUpdated:m},[4,5,6,8]),st=oe(32),hs=v({parentHash:st,number:w,stateRoot:st,extrinsicRoot:st,digests:B(us)}),Q=B(O),fn=P(O),ds=F({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:Q})),fs=v({len:te,type:w}),ys=v({bitStoreType:w,bitOrderType:w}),ps=B(v({name:O,fields:yn,index:U,docs:Q})),gs=F({composite:yn,variant:ps,sequence:w,array:fs,tuple:B(w),primitive:ds,compact:w,bitSequence:ys}),bs=v({name:O,type:P(w)}),ws=B(bs),ms=v({id:w,path:Q,params:ws,def:gs,docs:Q}),qe=B(ms),vs=F({Blake2128:m,Blake2256:m,Blake2128Concat:m,Twox128:m,Twox256:m,Twox64Concat:m,Identity:m}),Es=B(vs),ks=v({hashers:Es,key:w,value:w}),xs=v({name:O,modifier:U,type:F({plain:w,map:ks}),fallback:oe(),docs:Q}),Bs=P(v({prefix:O,items:B(xs)})),pn={name:O,storage:Bs,calls:P(w),events:P(w),constants:B(v({name:O,type:w,value:oe(),docs:Q})),errors:P(w),index:U},Is={...pn,docs:Q},As=new Uint8Array,gn=e=>x(()=>As,()=>e),Os=v({type:w,version:U,signedExtensions:B(v({identifier:O,type:w,additionalSigned:w}))}),bn=v({lookup:qe,pallets:B(v({...pn,docs:gn([])})),extrinsic:Os,type:w,apis:gn([])}),_s=v({name:O,methods:B(v({name:O,inputs:B(v({name:O,type:w})),output:w,docs:Q})),docs:Q}),Us=v({version:U,address:w,call:w,signature:w,extra:w,signedExtensions:B(v({identifier:O,type:w,additionalSigned:w}))}),wn=v({lookup:qe,pallets:B(v(Is)),extrinsic:Us,type:w,apis:B(_s),outerEnums:v({call:w,event:w,error:w}),custom:B(z(O,v({type:w,value:oe()})))}),mn=()=>{throw new Error("Unsupported metadata version!")},M=x(mn,mn),Oe=v({magicNumber:te,metadata:F({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=$(),Ls=P(ot),Ss=z(T,ot),$s=e=>{try{return Oe.dec(e)}catch{}try{return Oe.dec(Ls.dec(e))}catch{}try{return Oe.dec(ot.dec(e))}catch{}try{return Oe.dec(Ss.dec(e)[1])}catch{}throw null},Ds={dkLen:32},vn=e=>Me(e,Ds),Ts={dkLen:16},ct=e=>Me(e,Ts),En=e=>be(ct(e),e),Z=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);function ce(e,t,n,r,s){return e=e+t+s|0,r=Ce(r^e,16),n=n+r|0,t=Ce(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=Ce(r^e,8),n=n+r|0,t=Ce(t^n,7),{a:e,b:t,c:n,d:r}}function kn(e,t,n,r,s,o,c,i,f,l,a,d,h,u,y,p,b,E,I,j){let A=0;for(let pe=0;pe<r;pe++)({a:s,b:f,c:h,d:b}=ce(s,f,h,b,n[t+e[A++]])),{a:s,b:f,c:h,d:b}=ie(s,f,h,b,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ce(o,l,u,E,n[t+e[A++]]),{a:o,b:l,c:u,d:E}=ie(o,l,u,E,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ce(c,a,y,I,n[t+e[A++]]),{a:c,b:a,c:y,d:I}=ie(c,a,y,I,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ce(i,d,p,j,n[t+e[A++]]),{a:i,b:d,c:p,d:j}=ie(i,d,p,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ce(s,l,y,j,n[t+e[A++]]),{a:s,b:l,c:y,d:j}=ie(s,l,y,j,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ce(o,a,p,b,n[t+e[A++]]),{a:o,b:a,c:p,d:b}=ie(o,a,p,b,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ce(c,d,h,E,n[t+e[A++]]),{a:c,b:d,c:h,d:E}=ie(c,d,h,E,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ce(i,f,u,I,n[t+e[A++]]),{a:i,b:f,c:u,d:I}=ie(i,f,u,I,n[t+e[A++]]);return{v0:s,v1:o,v2:c,v3:i,v4:f,v5:l,v6:a,v7:d,v8:h,v9:u,v10:y,v11:p,v12:b,v13:E,v14:I,v15:j}}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 it extends Dt{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 it({dkLen:32},32).update(t.context).digest();this.IV=he(r),C||H(this.IV),this.flags=n|64}else this.IV=Z.slice(),this.flags=n;this.state=this.IV.slice(),this.bufferOut=Er(this.bufferOut32)}get(){return[]}set(){}b2Compress(t,n,r,s=0){const{state:o,pos:c}=this,{h:i,l:f}=Ve(BigInt(t),!0),{v0:l,v1:a,v2:d,v3:h,v4:u,v5:y,v6:p,v7:b,v8:E,v9:I,v10:j,v11:A,v12:pe,v13:Xe,v14:ze,v15:lo}=kn(xn,s,r,7,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],Z[0],Z[1],Z[2],Z[3],i,f,c,n);o[0]=l^E,o[1]=a^I,o[2]=d^j,o[3]=h^A,o[4]=u^pe,o[5]=y^Xe,o[6]=p^ze,o[7]=b^lo}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,i=this.chunksDone+1;(r||!(i&1))&&(c=this.stack.pop());i>>=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:i,stack:f,chunksDone:l}=this;return t.state.set(s.slice()),t.stack=f.map(a=>Uint32Array.from(a)),t.IV.set(n),t.flags=r,t.chunkPos=o,t.chunksDone=l,t.posOut=c,t.chunkOut=i,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:i}=Ve(BigInt(this.chunkOut++));C||H(s);const{v0:f,v1:l,v2:a,v3:d,v4:h,v5:u,v6:y,v7:p,v8:b,v9:E,v10:I,v11:j,v12:A,v13:pe,v14:Xe,v15:ze}=kn(xn,0,s,7,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],Z[0],Z[1],Z[2],Z[3],i,c,n,r);o[0]=f^b,o[1]=l^E,o[2]=a^I,o[3]=d^j,o[4]=h^A,o[5]=u^pe,o[6]=y^Xe,o[7]=p^ze,o[8]=t[0]^b,o[9]=t[1]^E,o[10]=t[2]^I,o[11]=t[3]^j,o[12]=t[4]^A,o[13]=t[5]^pe,o[14]=t[6]^Xe,o[15]=t[7]^ze,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),Te(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 Cs=Ir(e=>new it(e)),Hs={dkLen:32},Bn=e=>Cs(e,Hs),Vs=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),at=2n**64n-1n,D=(e,t)=>e<<t&at|e>>64n-t,k=(e,t)=>e*t&at,L=(e,t)=>e+t&at,S=11400714785074694791n,N=14029467366897019727n,An=1609587929392839161n,_e=9650029242287828579n,On=2870177450012600261n;function ae(e,t=0n){let n=L(L(t,S),N),r=L(t,N),s=t,o=t-S,c=e.length,i=0,f=null;(function(){let u=0,y=u+c;if(c){if(f=new Uint8Array(32),c<32){f.set(e.subarray(0,c),i),i+=c;return}if(u<=y-32){const p=y-32;do{let b;b=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]),n=k(D(L(n,k(b,N)),31n),S),u+=8,b=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]),r=k(D(L(r,k(b,N)),31n),S),u+=8,b=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]),s=k(D(L(s,k(b,N)),31n),S),u+=8,b=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]),o=k(D(L(o,k(b,N)),31n),S),u+=8}while(u<=p)}u<y&&(f.set(e.subarray(u,y),i),i=y-u)}})(),e=f||e;let l,a=0;for(c>=32?(l=D(n,1n),l=L(l,D(r,7n)),l=L(l,D(s,12n)),l=L(l,D(o,18n)),n=k(D(k(n,N),31n),S),l=l^n,l=L(k(l,S),_e),r=k(D(k(r,N),31n),S),l=l^r,l=L(k(l,S),_e),s=k(D(k(s,N),31n),S),l=l^s,l=L(k(l,S),_e),o=k(D(k(o,N),31n),S),l=l^o,l=L(k(l,S),_e)):l=L(t,On),l=L(l,BigInt(c));a<=i-8;){let h=ye(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],e[a+5]<<8|e[a+4],e[a+7]<<8|e[a+6]);h=k(D(k(h,N),31n),S),l=L(k(D(l^h,27n),S),_e),a+=8}if(a+4<=i){let h=k(ye(e[a+1]<<8|e[a],e[a+3]<<8|e[a+2],0,0),S);l=L(k(D(l^h,23n),N),An),a+=4}for(;a<i;){const h=k(ye(e[a++],0,0,0),On);l=k(D(l^h,11n),S)}let d=l>>33n;return l=k(l^d,N),d=l>>29n,l=k(l^d,An),d=l>>32n,l^=d,l}const Re=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},_n=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},Un=e=>be($e.enc(ae(e)),e),Ln=new TextEncoder,Ms=new Map([[In,0],[Un,8],[En,16],[ct,-16],[vn,-32],[Re,-16],[_n,-32]]);var js=Object.freeze({__proto__:null,AccountId:Ze,Bin:Ie,Binary:se,Blake2128:ct,Blake2128Concat:En,Blake2256:vn,Blake3256:Bn,Blake3256Concat:Vs,Bytes:$,Enum:tt,FixedSizeBinary:zt,Hex:oe,Identity:In,Option:P,Result:De,ScaleEnum:F,Self:en,Storage:e=>{const t=Re(Ln.encode(e));return(n,r,...s)=>{const o=be(t,Re(Ln.encode(n))),c=G(o),i=a=>{if(!a.startsWith(c))throw new Error(`key does not match this storage (${e}.${n})`);if(s.length===0)return[];const d=Ee(a.slice(c.length)),h=new Array(s.length);for(let u=0,y=0;u<s.length;u++){const[p,b]=s[u],E=Ms.get(b);if(E==null)throw new Error("Unknown hasher");if(E<0){const I=E*-1;h[u]=G(d.slice(y,y+I)),y+=I}else y+=E,h[u]=p.dec(d.slice(y)),y+=p.enc(h[u]).length}return h},f=s.map(([{enc:a},d])=>h=>d(a(h)));return{enc:(...a)=>G(be(o,...a.map((d,h)=>f[h](d)))),dec:r,keyDecoder:i}}},Struct:v,Tuple:z,Twox128:Re,Twox256:_n,Twox64Concat:Un,Variant:fe,Vector:B,_Enum:Qr,_void:m,bitSequence:Gt,blockHeader:hs,bool:Qn,char:Wr,compact:T,compactBn:zr,compactNumber:w,createCodec:x,createDecoder:We,decAnyMetadata:$s,enhanceCodec:R,enhanceDecoder:Se,enhanceEncoder:Ge,ethAccount:un,fixedStr:Jr,fromBufferToBase58:Nt,getSs58AddressInfo:Pt,h64:ae,i128:Gn,i16:Xn,i256:Jn,i32:zn,i64:Kn,i8:Fn,metadata:Oe,selfDecoder:Zt,selfEncoder:Qt,str:O,u128:Wn,u16:me,u256:Yn,u32:te,u64:$e,u8:U,v14:bn,v14Lookup:qe,v15:wn});const Ps=(e,t,n)=>(r,s,o,...c)=>{const{id:i}=r;if(s.has(i))return s.get(i);if(o.has(i)){const l=t(()=>s.get(i),r,...c);return s.set(i,l),l}o.add(i);let f=e(r,s,o,...c);return o.delete(i),s.has(i)&&(f=n(f,s.get(i),r,...c)),s.set(i,f),f},Ns=Ie(),qs=x(T[0],Se(T[1],BigInt)),Sn=Ps((e,t,n,r)=>{if(e.type==="primitive")return js[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?qs:T;if(e.type==="bitSequence")return Gt;const s=u=>Sn(u,t,n,r),o=(u,y)=>{const p=s(u);return y?B(p,y):B(p)},c=u=>z(...u.map(s)),i=u=>{const y=Object.fromEntries(Object.entries(u).map(([p,b])=>[p,s(b)]));return v(y)};if(e.type==="sequence"&&e.value.type==="primitive"&&e.value.value==="u8")return Ns;if(e.type==="array")return e.value.type==="primitive"&&e.value.value==="u8"?Ie(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 i(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 f=Object.values(e.value).map(u=>{switch(u.type){case"void":return m;case"lookupEntry":return s(u.value);case"tuple":return c(u.value);case"struct":return i(u.value);case"array":return o(u.value,u.len)}}),l=Object.fromEntries(Object.keys(e.value).map((u,y)=>[u,f[y]])),a=Object.values(e.value).map(u=>u.idx),h=a.every((u,y)=>u===y)?fe(l):fe(l,a);return e.byteLength?Fs(h,e.byteLength):h},en,e=>e),Rs=(e,t=Ze())=>{const n=new Map,r=s=>Sn(e(s),n,new Set,t);return s=>r(s)},Fs=(e,t)=>{const n=$(t);return x(r=>n.enc(e.enc(r)),r=>e.dec(n.dec(r)))},Xs=e=>{const{metadata:t}=e,n=Rs(e),r=(a="")=>{const d=e.storage[a];if(!d)throw new Error(`Storage entry ${a||"{root}"} not found`);const h=d.key==null?m:n(d.key);return{key:$n(h,d.keyPrefix),value:n(d.typeId)}},s=a=>{const d=v(Object.fromEntries(a.args.map(h=>[h.label,n(h.type.type)])));return{call:$n(d,a.selector),value:n(a.returnType.type)}},o=a=>{const d=t.spec.constructors.find(h=>h.label===a);if(!d)throw new Error(`Constructor ${a} not found`);return s(d)},c=a=>{const d=t.spec.messages.find(h=>h.label===a);if(!d)throw new Error(`Message ${a} not found`);return s(d)},i=a=>v(Object.fromEntries(a.args.map(d=>[d.label,n(d.type.type)])));return{buildConstructor:o,buildMessage:c,buildStorage:r,buildEvents:()=>fe(Object.fromEntries(t.spec.events.map(a=>[a.label,i(a)]))),buildEvent:a=>{const d=t.spec.events,h=(y,p)=>R(y,b=>b.value,b=>({type:p,value:b}));if(a){const y=d.find(p=>p.signature_topic===a);return y?h(i(y),y.label):null}const u=d.filter(y=>y.signature_topic===a);return u.length?zs(u.map(y=>h(i(y),y.label))):null}}},$n=(e,t)=>{const n=se.fromHex(t).asBytes(),r=z($(n.length),e);return R(r,s=>[n,s],([,s])=>s)},zs=e=>x(t=>{for(const n of e)try{n.enc(t)}catch{}throw new Error("Unable to encode")},t=>{for(const n of e)try{n.dec(t)}catch{}throw new Error("Unable to decode")}),Dn=e=>R(F(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})),Ue=(e,t)=>R(B(e,t),n=>n??[],n=>n),Tn=P(O),Fe=Ue(O),Ks=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}),Cn=Ue(v({name:Tn,type:w,typeName:Tn,docs:Fe})),Ws=v({len:te,type:w}),Gs=v({bitStoreType:w,bitOrderType:w}),Ys=Ue(v({name:O,fields:Cn,index:U,docs:Fe})),Js=Dn({composite:v({fields:Cn}),variant:v({variants:Ys}),sequence:v({type:w}),array:Ws,tuple:B(w),primitive:Ks,compact:w,bitSequence:Gs}),Qs=v({name:O,type:P(w)}),Zs=Ue(Qs),eo=v({id:w,path:Fe,params:Zs,def:Js,docs:Fe}),to=R(eo,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}})),no=Ue(to),ro=e=>{const t=no.enc(e.types),n=qe.dec(t),r=e.spec.environment.accountId.type,s=n.find(i=>i.id===r);s&&(s.path=["AccountId32"]);const o=so(e,n),c=Mn(n);return Object.assign(c,{metadata:e,lookup:n,storage:o})};function so(e,t){const n={},r=(s,o=[])=>{function c(f){const l=t.length;return t[l]={id:l,docs:[],def:f,params:[],path:[]},l}if("root"in s){const f=Number(e.version)===4?se.fromBytes(se.fromHex(s.root.root_key).asBytes().reverse()).asHex():s.root.root_key,l=r(s.root.layout,o);if(s.root.ty!=null){let a=function(d,h){const u=e.types[d].type,y="composite"in u.def?new Map((u.def.composite.fields??[]).map(b=>[b.name,b.type])):null,p=new Map((u.params??[]).map(b=>[b.name,b.type]));if(p.size===2&&p.has("V")&&y&&y.size===2&&y.has("len")&&y.has("elements")){a(y.get("len"),[...h,"len"]),a(y.get("elements"),h);return}else p.size===3&&p.has("K")&&p.has("V")?n[h.join(".")]={keyPrefix:f,key:p.get("K"),typeId:p.get("V")}:p.size===2&&p.has("V")&&(n[h.join(".")]={keyPrefix:f,key:null,typeId:p.get("V")})};a(s.root.ty,o)}return n[o.join(".")]||(n[o.join(".")]={keyPrefix:f,key:null,typeId:l}),c({tag:"composite",value:[]})}if("leaf"in s)return s.leaf.ty;if("hash"in s)throw new Error("HashLayout not implemented");if("array"in s){const f=r(s.array.layout,o);return f==null?null:c({tag:"array",value:{len:s.array.len,type:f}})}if("struct"in s){const f=s.struct.fields.map(l=>({name:l.name,type:r(l.layout,[...o,l.name]),typeName:void 0,docs:[]})).filter(l=>l.type!=null);return c({tag:"composite",value:f})}const i=Object.values(s.enum.variants).map((f,l)=>({name:f.name,fields:f.fields.map(a=>({name:a.name,type:r(a.layout,[...o,f.name,a.name]),typeName:void 0,docs:[]})).filter(a=>a.type!==null),index:l,docs:[]}));return c({tag:"variant",value:i})};return r(e.storage),n}const oo=e=>{const t=ro(e.metadata),n=Xs(t);return{constructor:Hn(n.buildConstructor),message:Hn(n.buildMessage),storage:co(n.buildStorage),event:Number(t.metadata.version)===4?io(n.buildEvents):ao(t,n.buildEvent)}},Hn=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.call.enc(r||{})),decode:r=>n.value.dec(r.data.asBytes())}},co=e=>t=>{const n=e(t);return{encode:r=>se.fromBytes(n.key.enc(r)),decode:r=>n.value.dec(r.asBytes())}},io=e=>{const t=r=>e().dec(r.data.asBytes());return{decode:t,filter:(r,s=[])=>s.map(c=>"event"in c?c.event:c).filter(c=>c.type==="Contracts"&&c.value.type==="ContractEmitted"&&c.value.value.contract===r).map(c=>{try{return t(c.value.value)}catch(i){throw console.error(`Contract ${r} emitted an incompatible event`,c.value.value),i}})}},ao=(e,t)=>{const n=new Set(e.metadata.spec.events.map(c=>c.signature_topic).filter(c=>c!=null)),r=e.metadata.spec.events.some(c=>c.signature_topic==null),s=(c,i)=>{if(i!=null){if(!n.has(i))throw new Error(`Event with signature topic ${c} not found`);return t(i).dec(c.data.asBytes())}if(!r)throw new Error("Event signature topic required");return t(void 0).dec(c.data.asBytes())};return{decode:s,filter:(c,i=[])=>i.map(l=>"event"in l?l:{event:l,topics:l.topics}).filter(l=>l.event.type==="Contracts"&&l.event.value.type==="ContractEmitted"&&l.event.value.value.contract===c).map(l=>{const a=l.topics.map(h=>h.asHex()),d=a.find(h=>n.has(h));try{return s(l.event.value.value,d)}catch{return console.error(`Contract ${c} emitted an incompatible event`,{event:l.event.value.value.data.asHex(),eventTopics:a,metadataEventTopics:[...n],hasAnonymousEvents:r}),null}}).filter(l=>l!==null)}};we.getInkClient=oo});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -191,28 +191,28 @@
191
191
  "rxjs": ">=7.8.0"
192
192
  },
193
193
  "dependencies": {
194
- "@polkadot-api/cli": "0.9.20",
195
- "@polkadot-api/ink-contracts": "0.2.1",
196
194
  "@polkadot-api/json-rpc-provider": "0.0.4",
195
+ "@polkadot-api/cli": "0.9.21",
197
196
  "@polkadot-api/logs-provider": "0.0.6",
198
197
  "@polkadot-api/polkadot-sdk-compat": "2.3.1",
199
- "@polkadot-api/metadata-builders": "0.9.1",
200
- "@polkadot-api/metadata-compatibility": "0.1.11",
201
- "@polkadot-api/observable-client": "0.6.2",
202
- "@polkadot-api/pjs-signer": "0.6.0",
198
+ "@polkadot-api/metadata-builders": "0.9.2",
199
+ "@polkadot-api/metadata-compatibility": "0.1.12",
200
+ "@polkadot-api/pjs-signer": "0.6.1",
201
+ "@polkadot-api/observable-client": "0.6.3",
203
202
  "@polkadot-api/polkadot-signer": "0.1.6",
203
+ "@polkadot-api/signer": "0.1.11",
204
204
  "@polkadot-api/sm-provider": "0.1.7",
205
- "@polkadot-api/signer": "0.1.10",
206
- "@polkadot-api/substrate-bindings": "0.9.3",
205
+ "@polkadot-api/substrate-bindings": "0.9.4",
207
206
  "@polkadot-api/substrate-client": "0.3.0",
208
- "@polkadot-api/ws-provider": "0.3.6",
209
207
  "@polkadot-api/utils": "0.1.2",
210
- "@polkadot-api/known-chains": "0.5.7",
208
+ "@polkadot-api/ink-contracts": "0.2.2",
209
+ "@polkadot-api/ws-provider": "0.3.6",
210
+ "@polkadot-api/known-chains": "0.5.8",
211
211
  "@polkadot-api/smoldot": "0.3.7"
212
212
  },
213
213
  "devDependencies": {
214
214
  "rxjs": "^7.8.1",
215
- "@polkadot-api/codegen": "0.12.8"
215
+ "@polkadot-api/codegen": "0.12.9"
216
216
  },
217
217
  "scripts": {
218
218
  "build-core": "tsc --noEmit && rollup -c",