polkadot-api 1.6.7 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/compatibility.mjs.map +1 -1
- package/dist/esm/tx/submit-fns.mjs +1 -1
- package/dist/esm/tx/submit-fns.mjs.map +1 -1
- package/dist/esm/tx/tx.mjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/umd/index.min.js +2 -2
- package/dist/umd/ink.min.js +1 -1
- package/dist/umd/pjs-signer.min.js +1 -1
- package/package.json +9 -9
package/dist/umd/ink.min.js
CHANGED
|
@@ -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",le={type:"void"},Cn=(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,size:p.value}}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},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,a=ze[e[c]],u=ze[e[c+1]];s[t+o++]=a<<4|u}return s}var lt=class extends Uint8Array{constructor(e){super(e),at(this,"i",0),at(this,"v"),this.v=new DataView(e)}},R=e=>t=>e(t instanceof lt?t:new lt(t instanceof Uint8Array?t.buffer:typeof t=="string"?jn(t).buffer:t)),F=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=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 Pn(e,t){return R(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 E(Nn(e,n),Pn(e,t))}var L=Z(1,"getUint8","setUint8"),me=Z(2,"getUint16","setUint16"),ee=Z(4,"getUint32","setUint32"),Se=Z(8,"getBigUint64","setBigUint64"),Rn=Z(1,"getInt8","setInt8"),qn=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=>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(ut,ht("getBigUint64")),Kn=E(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=>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}),Wn=E(dt,ft("getBigUint64")),Gn=E(dt,ft("getBigInt64")),Yn=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),yt=e=>e===void 0?t=>F([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),pt=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(yt(e),pt(e));D.enc=yt,D.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})=>F([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 R(s=>{const o=L.dec(s),c=r.get(o),a=e[c];return{tag:c,value:a(s)}})},q=(e,...t)=>E(gt(Le(e,([n])=>n),...t),bt(Le(e,([,n])=>n),...t));q.enc=gt,q.dec=bt;var wt=e=>R(t=>L[1](t)>0?e(t):void 0),mt=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,F([n,e(t)]))},P=e=>E(mt(e[0]),wt(e[1]));P.enc=mt,P.dec=wt;var vt=(e,t)=>R(n=>{const r=L[1](n)===0,o=(r?e:t)(n);return{success:r,value:o}}),kt=(e,t)=>({success:n,value:r})=>F([L[0](n?0:1),(n?e:t)(r)]),De=(e,t)=>E(kt(e[0],t[0]),vt(e[1],t[1]));De.dec=vt,De.enc=kt;var xt=(...e)=>R(t=>e.map(n=>n(t))),Et=(...e)=>t=>F(e.map((n,r)=>n(t[r]))),z=(...e)=>E(Et(...e.map(([t])=>t)),xt(...e.map(([,t])=>t)));z.enc=Et,z.dec=xt;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=>E(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=>F(n.map(e)):n=>F([T.enc(n.length),F(n.map(e))]),Ot=(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(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)=>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 _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,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 _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 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 Ge(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,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)),$e(e),e}class St{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 Dt 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,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),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: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),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 $t(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,Dr=(e,t)=>t,$r=(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:$t,toBig:Ir,shrSH:Ar,shrSL:Or,rotrSH:_r,rotrSL:Lr,rotrBH:Ur,rotrBL:Sr,rotr32H:Dr,rotr32L:$r,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],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 Dt{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: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)),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)=>X(D(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,a=Ze[e[c]],u=Ze[e[c+1]];s[t+o++]=a<<4|u}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 Mr=Object.defineProperty,qt=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),Ft=(e,t,n)=>t.has(e)||qt("Cannot "+n),G=(e,t,n)=>(Ft(e,t,"read from private field"),n?n.call(e):t.get(e)),xe=(e,t,n)=>t.has(e)?qt("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,Ee,je,Pe,Ne;const Pr=new TextEncoder,Nr=new TextDecoder,Rr=z(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]=Qe();class Xt 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())},Kt=e=>{const t=D.dec(e),n=e==null?se:Xt;return r=>n.fromBytes(t(r))},Be=e=>E(zt(e),Kt(e));Be.enc=zt,Be.dec=Kt;const w=T,Fr=T,Xr=Ke(e=>{const t=w.dec(e),n=Math.ceil(t/8);return{bytes:D(n).dec(e),bitsLen:t}}),Wt=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),zr=X(L,e=>e.charCodeAt(0),String.fromCharCode),Gt=e=>{const t=D.enc(e);return n=>t(Me(n))},Yt=e=>{const t=D.dec(e);return n=>re(t(n))},oe=e=>E(Gt(e),Yt(e));oe.enc=Gt,oe.dec=Yt;const Kr=new TextEncoder,Wr=new TextDecoder,Gr=e=>X(D(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=>E(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=q.enc(...e);return n=>t({tag:n.type,value:n.value})},tn=(...e)=>{const t=q.dec(...e);return n=>{const{tag:r,value:s}=t(n);return et(r,s)}},fe=(e,...t)=>E(en(Rt(e,([n])=>n),...t),tn(Rt(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]=$t(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 a=(c+8)%10,u=(c+2)%10,i=n[u],h=n[u+1],f=on(i,h,1)^n[a],d=cn(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=rn[c],u=on(s,o,a),i=cn(s,o,a),h=nn[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 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 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(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)=>kr(()=>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=D(20)[1],ln=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(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=X(D(4),un.encode.bind(un),hn.decode.bind(hn)),nt=v({engine:is,payload:oe()}),as=fe({consensus:nt,seal:nt,preRuntime:nt,runtimeUpdated:m},[4,5,6,8]),rt=oe(32),ls=v({parentHash:rt,number:w,stateRoot:rt,extrinsicRoot:rt,digests:B(as)}),J=B(A),dn=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}),fn=B(v({name:dn,type:w,typeName:dn,docs:J})),hs=v({len:ee,type:w}),ds=v({bitStoreType:w,bitOrderType:w}),fs=B(v({name:A,fields:fn,index:L,docs:J})),ys=q({composite:fn,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)})),yn={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={...yn,docs:J},Bs=new Uint8Array,pn=e=>E(()=>Bs,()=>e),Is=v({type:w,version:L,signedExtensions:B(v({identifier:A,type:w,additionalSigned:w}))}),gn=v({lookup:Re,pallets:B(v({...yn,docs:pn([])})),extrinsic:Is,type:w,apis:pn([])}),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}))}),bn=v({lookup:Re,pallets:B(v(Es)),extrinsic:Os,type:w,apis:B(As),outerEnums:v({call:w,event:w,error:w}),custom:B(z(A,v({type:w,value:oe()})))}),wn=()=>{throw new Error("Unsupported metadata version!")},M=E(wn,wn),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:gn,v15:bn})}),st=D(),_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},Ds=e=>Ve(e,Ss),$s={dkLen:16},mn=e=>Ve(e,$s),vn=e=>be(mn(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 kn(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 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 ot 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 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=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}=kn(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,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}=kn(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]=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(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=Er(e=>new ot(e)),Cs={dkLen:32},En=e=>Ts(e,Cs),Hs=e=>be(En(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,$=(e,t)=>e<<t&ct|e>>64n-t,x=(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,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,An),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),In),h+=4}for(;h<a;){const d=x(ye(e[h++],0,0,0),An);i=x($(i^d,11n),S)}let f=i>>33n;return i=x(i^f,N),f=i>>29n,i=x(i^f,In),f=i>>32n,i^=f,i}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:mn,Blake2128Concat:vn,Blake2256:Ds,Blake3256:En,Blake3256Concat:Hs,Bytes:D,Enum:et,FixedSizeBinary:Xt,Hex:oe,Identity:Bn,Option:P,Result:De,ScaleEnum:q,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),a=s.map(f=>f[1]).map(f=>{switch(f){case Bn:return 0;case On:return 8;case vn: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:z,Twox128:it,Twox256:Vs,Twox64Concat:On,Variant:fe,Vector:B,_Enum:Yr,_void:m,bitSequence:Wt,blockHeader:ls,bool:Yn,char:zr,compact:T,compactBn:Fr,compactNumber:w,createCodec:E,createDecoder:Ke,decAnyMetadata:Us,enhanceCodec:X,enhanceDecoder:Ue,enhanceEncoder:We,ethAccount:ln,fixedStr:Gr,fromBufferToBase58:Pt,getSs58AddressInfo:jt,h64:ae,i128:Kn,i16:qn,i256:Gn,i32:Fn,i64:Xn,i8:Rn,metadata:Ae,selfDecoder:Qt,selfEncoder:Jt,str:A,u128:zn,u16:me,u256:Wn,u32:ee,u64:Se,u8:L,v14:gn,v14Lookup:Re,v15:bn});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)),Ln=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 ln;if(e.type==="compact")return e.isBig?Ns:T;if(e.type==="bitSequence")return Wt;const s=l=>Ln(l,t,n,r),o=(l,y)=>{const p=s(l);return y?B(p,y):B(p)},c=l=>z(...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},Zt,e=>e),Rs=(e,t=Qe())=>{const n=new Map,r=s=>Ln(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:Un(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:Un(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)])))])))}},Un=(e,t)=>{const n=se.fromHex(t).asBytes(),r=z(D(n.length),e);return X(r,s=>[n,s],([,s])=>s)},Sn=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),Dn=P(A),qe=_e(A),Xs=Sn({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}),$n=_e(v({name:Dn,type:w,typeName:Dn,docs:qe})),zs=v({len:ee,type:w}),Ks=v({bitStoreType:w,bitOrderType:w}),Ws=_e(v({name:A,fields:$n,index:L,docs:qe})),Gs=Sn({composite:v({fields:$n}),variant:v({variants:Ws}),sequence:v({type:w}),array:zs,tuple:B(w),primitive:Xs,compact:w,bitSequence:Ks}),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=Hn(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:Tn(n.buildConstructor),message:Tn(n.buildMessage),storage:so(n.buildStorage),event:oo(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())}},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
|
+
(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 +1 @@
|
|
|
1
|
-
(function(X,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(X=typeof globalThis<"u"?globalThis:X||self,z(X.papiPjsSigner={}))})(this,function(X){"use strict";var z=Object.defineProperty,Ze=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fe=(e,t,n)=>(Ze(e,typeof t!="symbol"?t+"":t,n),n),oe={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 et(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|oe[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=oe[e[s]],h=oe[e[s+1]];o[t+i++]=c<<4|h}return o}var pe=class extends Uint8Array{constructor(e){super(e),fe(this,"i",0),fe(this,"v"),this.v=new DataView(e)}},_=e=>t=>e(t instanceof pe?t:new pe(t instanceof Uint8Array?t.buffer:typeof t=="string"?et(t).buffer:t)),D=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].length;const r=new Uint8Array(n);for(let o=0,i=0;o<t;o++){const s=e[o];r.set(s,i),i+=s.byteLength}return r};function Z(e,t){const n=Object.keys(e),r=n.length,o={};for(let i=0;i<r;i++){const s=n[i];o[s]=t(e[s],s)}return o}var B=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},se=(e,t)=>n=>e(t(n)),ve=(e,t)=>n=>t(e(n)),ye=([e,t],n,r)=>B(se(e,n),ve(t,r));function tt(e,t){return _(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function nt(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function H(e,t,n){return B(nt(e,n),tt(e,t))}var I=H(1,"getUint8","setUint8"),ee=H(2,"getUint16","setUint16"),M=H(4,"getUint32","setUint32"),ge=H(8,"getBigUint64","setBigUint64");H(1,"getInt8","setInt8"),H(2,"getInt16","setInt16"),H(4,"getInt32","setInt32"),H(8,"getBigInt64","setBigInt64");var we=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},me=e=>_(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),i=n[e](r+8,!0);return t.i+=16,i<<64n|o});B(we,me("getBigUint64")),B(we,me("getBigInt64"));var be=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},Ee=e=>_(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});B(be,Ee("getBigUint64")),B(be,Ee("getBigInt64")),ye(I,e=>e?1:0,Boolean);var rt=[I[1],ee[1],M[1]],ot=_(e=>{const t=e[e.i],n=t&3;if(n<3)return rt[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const i=r/8|0;let s=0n;for(let h=0;h<i;h++)o=ge[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(M[1](e))<<s|o,s+=32n,c-=4),c>1&&(o=BigInt(ee[1](e))<<s|o,s+=16n,c-=2),c&&(o=BigInt(I[1](e))<<s|o),o}),st=1n<<56n,it=1<<24,ct=256,at=4294967295n,lt=64,ut=16384,ht=1<<30,dt=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<lt)return I[0](t);if(e<ut)return ee[0](t|1);if(e<ht)return M[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=st;)n.push(ge[0](r)),r>>=64n;r>=it&&(n.push(M[0](Number(r&at))),r>>=32n);let o=Number(r);o>=ct&&(n.push(ee[0](o)),o>>=16),o&&n.push(I[0](o));const i=D(n);return i[0]=i.length-5<<2|3,i},T=B(dt,ot),ft=new TextEncoder,pt=e=>{const t=ft.encode(e);return D([T.enc(t.length),t])},vt=new TextDecoder,yt=_(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,vt.decode(n)}),U=B(pt,yt),gt=()=>{},wt=new Uint8Array(0),E=B(()=>wt,gt),xe=e=>e===void 0?t=>D([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Ae=e=>_(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}),R=e=>B(xe(e),Ae(e));R.enc=xe,R.dec=Ae;var Be=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[n[s],i])??n.map((i,s)=>[i,s])),o=i=>r.get(i);return({tag:i,value:s})=>D([I.enc(o(i)),e[i](s)])},ke=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return _(o=>{const i=I.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},K=(e,...t)=>B(Be(Z(e,([n])=>n),...t),ke(Z(e,([,n])=>n),...t));K.enc=Be,K.dec=ke;var Ie=e=>_(t=>I[1](t)>0?e(t):void 0),Ue=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,D([n,e(t)]))},C=e=>B(Ue(e[0]),Ie(e[1]));C.enc=Ue,C.dec=Ie;var Le=(...e)=>_(t=>e.map(n=>n(t))),Te=(...e)=>t=>D(e.map((n,r)=>n(t[r]))),F=(...e)=>B(Te(...e.map(([t])=>t)),Le(...e.map(([,t])=>t)));F.enc=Te,F.dec=Le;var _e=e=>{const t=Object.keys(e);return se(F.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ce=e=>{const t=Object.keys(e);return ve(F.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},m=e=>B(_e(Z(e,t=>t[0])),Ce(Z(e,t=>t[1])));m.enc=_e,m.dec=Ce;var Se=(e,t)=>t>=0?n=>D(n.map(e)):n=>D([T.enc(n.length),D(n.map(e))]),De=(e,t)=>_(n=>{const r=t>=0?t:T.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),x=(e,t)=>B(Se(e[0],t),De(e[1],t));x.enc=Se,x.dec=De;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function bt(...e){const t=i=>i,n=(i,s)=>c=>i(s(c)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function Et(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 xt(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 Oe(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 o=[],i=Array.from(e);for(i.forEach(s=>{if(s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let h=r;h<i.length;h++){const y=i[h],d=t*s+y;if(!Number.isSafeInteger(d)||t*s/t!==s||d-y!==t*s)throw new Error("convertRadix: carry overflow");s=d%n;const u=Math.floor(d/n);if(i[h]=u,!Number.isSafeInteger(u)||u*n+s!==d)throw new Error("convertRadix: carry overflow");if(c)u?c=!1:r=h;else continue}if(o.push(s),c)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}function At(e){return{encode:t=>{if(!mt(t))throw new Error("radix.encode input should be Uint8Array");return Oe(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(Oe(t,e,2**8))}}}const je=(e=>bt(At(58),Et(e),xt("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ie(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Bt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function He(e,...t){if(!Bt(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 Me(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 kt(e,t){He(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 te=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),q=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,$e=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,O=q?e=>e:e=>$e(e);function G(e){for(let t=0;t<e.length;t++)e[t]=$e(e[t])}function It(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Y(e){return typeof e=="string"&&(e=It(e)),He(e),e}class Ut{clone(){return this._cloneInto()}}function Lt(e){const t=(r,o)=>e(o).update(Y(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Tt=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 Ut{constructor(t,n,r={},o,i,s){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ie(t),ie(n),ie(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error(`key must be up 1..${o} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==i)throw new Error(`salt must be ${i} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error(`personalization must be ${s} byte long or undefined`);this.buffer32=te(this.buffer=new Uint8Array(t))}update(t){Me(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=Y(t);const i=t.length,s=t.byteOffset,c=t.buffer;for(let h=0;h<i;){this.pos===n&&(q||G(o),this.compress(o,0,!1),q||G(o),this.pos=0);const y=Math.min(n-this.pos,i-h),d=s+h;if(y===n&&!(d%4)&&h+y<i){const u=new Uint32Array(c,d,Math.floor((i-h)/4));q||G(u);for(let l=0;h+n<i;l+=o.length,h+=n)this.length+=n,this.compress(u,l,!1);q||G(u);continue}r.set(t.subarray(h,h+y),this.pos),this.pos+=y,this.length+=y,h+=y}return this}digestInto(t){Me(this),kt(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),q||G(r),this.compress(r,0,!0),q||G(r);const o=te(t);this.get().forEach((i,s)=>o[s]=O(i))}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:o,destroyed:i,outputLen:s,pos:c}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=i,t.outputLen=s,t.buffer.set(n),t.pos=c,t}}const ne=BigInt(2**32-1),ce=BigInt(32);function Pe(e,t=!1){return t?{h:Number(e&ne),l:Number(e>>ce&ne)}:{h:Number(e>>ce&ne)|0,l:Number(e&ne)|0}}function Ct(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=Pe(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const St=(e,t)=>BigInt(e>>>0)<<ce|BigInt(t>>>0),Dt=(e,t,n)=>e>>>n,Ot=(e,t,n)=>e<<32-n|t>>>n,jt=(e,t,n)=>e>>>n|t<<32-n,Ht=(e,t,n)=>e<<32-n|t>>>n,Mt=(e,t,n)=>e<<64-n|t>>>n-32,$t=(e,t,n)=>e>>>n-32|t<<64-n,Pt=(e,t)=>t,Vt=(e,t)=>e,Nt=(e,t,n)=>e<<n|t>>>32-n,Rt=(e,t,n)=>t<<n|e>>>32-n,Kt=(e,t,n)=>t<<n-32|e>>>64-n,qt=(e,t,n)=>e<<n-32|t>>>64-n;function Xt(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const k={fromBig:Pe,split:Ct,toBig:St,shrSH:Dt,shrSL:Ot,rotrSH:jt,rotrSL:Ht,rotrBH:Mt,rotrBL:$t,rotr32H:Pt,rotr32L:Vt,rotlSH:Nt,rotlSL:Rt,rotlBH:Kt,rotlBL:qt,add:Xt,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,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},A=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),a=new Uint32Array(32);function $(e,t,n,r,o,i){const s=o[i],c=o[i+1];let h=a[2*e],y=a[2*e+1],d=a[2*t],u=a[2*t+1],l=a[2*n],g=a[2*n+1],p=a[2*r],f=a[2*r+1],b=k.add3L(h,d,s);y=k.add3H(b,y,u,c),h=b|0,{Dh:f,Dl:p}={Dh:f^y,Dl:p^h},{Dh:f,Dl:p}={Dh:k.rotr32H(f,p),Dl:k.rotr32L(f,p)},{h:g,l}=k.add(g,l,f,p),{Bh:u,Bl:d}={Bh:u^g,Bl:d^l},{Bh:u,Bl:d}={Bh:k.rotrSH(u,d,24),Bl:k.rotrSL(u,d,24)},a[2*e]=h,a[2*e+1]=y,a[2*t]=d,a[2*t+1]=u,a[2*n]=l,a[2*n+1]=g,a[2*r]=p,a[2*r+1]=f}function P(e,t,n,r,o,i){const s=o[i],c=o[i+1];let h=a[2*e],y=a[2*e+1],d=a[2*t],u=a[2*t+1],l=a[2*n],g=a[2*n+1],p=a[2*r],f=a[2*r+1],b=k.add3L(h,d,s);y=k.add3H(b,y,u,c),h=b|0,{Dh:f,Dl:p}={Dh:f^y,Dl:p^h},{Dh:f,Dl:p}={Dh:k.rotrSH(f,p,16),Dl:k.rotrSL(f,p,16)},{h:g,l}=k.add(g,l,f,p),{Bh:u,Bl:d}={Bh:u^g,Bl:d^l},{Bh:u,Bl:d}={Bh:k.rotrBH(u,d,63),Bl:k.rotrBL(u,d,63)},a[2*e]=h,a[2*e+1]=y,a[2*t]=d,a[2*t+1]=u,a[2*n]=l,a[2*n+1]=g,a[2*r]=p,a[2*r+1]=f}class Ft extends _t{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=A[0]|0,this.v0h=A[1]|0,this.v1l=A[2]|0,this.v1h=A[3]|0,this.v2l=A[4]|0,this.v2h=A[5]|0,this.v3l=A[6]|0,this.v3h=A[7]|0,this.v4l=A[8]|0,this.v4h=A[9]|0,this.v5l=A[10]|0,this.v5h=A[11]|0,this.v6l=A[12]|0,this.v6h=A[13]|0,this.v7l=A[14]|0,this.v7h=A[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=te(Y(t.salt));this.v4l^=O(r[0]),this.v4h^=O(r[1]),this.v5l^=O(r[2]),this.v5h^=O(r[3])}if(t.personalization){const r=te(Y(t.personalization));this.v6l^=O(r[0]),this.v6h^=O(r[1]),this.v7l^=O(r[2]),this.v7h^=O(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Y(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:c,v3h:h,v4l:y,v4h:d,v5l:u,v5h:l,v6l:g,v6h:p,v7l:f,v7h:b}=this;return[t,n,r,o,i,s,c,h,y,d,u,l,g,p,f,b]}set(t,n,r,o,i,s,c,h,y,d,u,l,g,p,f,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=c|0,this.v3h=h|0,this.v4l=y|0,this.v4h=d|0,this.v5l=u|0,this.v5h=l|0,this.v6l=g|0,this.v6h=p|0,this.v7l=f|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((h,y)=>a[y]=h),a.set(A,16);let{h:o,l:i}=k.fromBig(BigInt(this.length));a[24]=A[8]^i,a[25]=A[9]^o,r&&(a[28]=~a[28],a[29]=~a[29]);let s=0;const c=Tt;for(let h=0;h<12;h++)$(0,4,8,12,t,n+2*c[s++]),P(0,4,8,12,t,n+2*c[s++]),$(1,5,9,13,t,n+2*c[s++]),P(1,5,9,13,t,n+2*c[s++]),$(2,6,10,14,t,n+2*c[s++]),P(2,6,10,14,t,n+2*c[s++]),$(3,7,11,15,t,n+2*c[s++]),P(3,7,11,15,t,n+2*c[s++]),$(0,5,10,15,t,n+2*c[s++]),P(0,5,10,15,t,n+2*c[s++]),$(1,6,11,12,t,n+2*c[s++]),P(1,6,11,12,t,n+2*c[s++]),$(2,7,8,13,t,n+2*c[s++]),P(2,7,8,13,t,n+2*c[s++]),$(3,4,9,14,t,n+2*c[s++]),P(3,4,9,14,t,n+2*c[s++]);this.v0l^=a[0]^a[16],this.v0h^=a[1]^a[17],this.v1l^=a[2]^a[18],this.v1h^=a[3]^a[19],this.v2l^=a[4]^a[20],this.v2h^=a[5]^a[21],this.v3l^=a[6]^a[22],this.v3h^=a[7]^a[23],this.v4l^=a[8]^a[24],this.v4h^=a[9]^a[25],this.v5l^=a[10]^a[26],this.v5h^=a[11]^a[27],this.v6l^=a[12]^a[28],this.v6h^=a[13]^a[29],this.v7l^=a[14]^a[30],this.v7h^=a[15]^a[31],a.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 ae=Lt(e=>new Ft(e)),Ve=new TextEncoder().encode("SS58PRE"),le=2,Gt=e=>{try{const t=je.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-le),o=t.subarray(n.length+r.length),i=ae(Uint8Array.of(...Ve,...n,...r),{dkLen:64}).subarray(0,le);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:Wt(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},Wt=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},zt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=ae(Uint8Array.of(...Ve,...t,...n),{dkLen:64}).subarray(0,le);return je.encode(Uint8Array.of(...t,...n,...r))}};function Yt(e,t){return n=>{const r=Gt(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const Jt=(e=42,t=32)=>ye(R(t),Yt(t),zt(e)),Ne="0123456789abcdef";function V(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Ne[r>>4]+Ne[r&15]}return t.join("")}const ue={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 J(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|ue[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=ue[e[s]],h=ue[e[s+1]];o[t+i++]=c<<4|h}return o}const Re=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.byteLength}return n},v=T,Qt=T,Ke=e=>{const t=R.enc(e);return n=>t(J(n))},qe=e=>{const t=R.dec(e);return n=>V(t(n))},Q=e=>B(Ke(e),qe(e));Q.enc=Ke,Q.dec=qe;const j=x(U),Xe=C(U),Zt=K({bool:E,char:E,str:E,u8:E,u16:E,u32:E,u64:E,u128:E,u256:E,i8:E,i16:E,i32:E,i64:E,i128:E,i256:E}),Fe=x(m({name:Xe,type:v,typeName:Xe,docs:j})),en=m({len:M,type:v}),tn=m({bitStoreType:v,bitOrderType:v}),nn=x(m({name:U,fields:Fe,index:I,docs:j})),rn=K({composite:Fe,variant:nn,sequence:v,array:en,tuple:x(v),primitive:Zt,compact:v,bitSequence:tn}),on=m({name:U,type:C(v)}),sn=x(on),cn=m({id:v,path:j,params:sn,def:rn,docs:j}),Ge=x(cn),an=K({Blake2128:E,Blake2256:E,Blake2128Concat:E,Twox128:E,Twox256:E,Twox64Concat:E,Identity:E}),ln=x(an),un=m({hashers:ln,key:v,value:v}),hn=m({name:U,modifier:I,type:K({plain:v,map:un}),fallback:Q(),docs:j}),dn=C(m({prefix:U,items:x(hn)})),We={name:U,storage:dn,calls:C(v),events:C(v),constants:x(m({name:U,type:v,value:Q(),docs:j})),errors:C(v),index:I},fn={...We,docs:j},pn=new Uint8Array,ze=e=>B(()=>pn,()=>e),vn=m({type:v,version:I,signedExtensions:x(m({identifier:U,type:v,additionalSigned:v}))}),yn=m({lookup:Ge,pallets:x(m({...We,docs:ze([])})),extrinsic:vn,type:v,apis:ze([])}),gn=m({name:U,methods:x(m({name:U,inputs:x(m({name:U,type:v})),output:v,docs:j})),docs:j}),wn=m({version:I,address:v,call:v,signature:v,extra:v,signedExtensions:x(m({identifier:U,type:v,additionalSigned:v}))}),mn=m({lookup:Ge,pallets:x(m(fn)),extrinsic:wn,type:v,apis:x(gn),outerEnums:m({call:v,event:v,error:v}),custom:x(F(U,m({type:v,value:Q()})))}),Ye=()=>{throw new Error("Unsupported metadata version!")},L=B(Ye,Ye),re=m({magicNumber:M,metadata:K({v0:L,v1:L,v2:L,v3:L,v4:L,v5:L,v6:L,v7:L,v8:L,v9:L,v10:L,v11:L,v12:L,v13:L,v14:yn,v15:mn})}),he=R(),bn=C(he),En=F(T,he),xn=e=>{try{return re.dec(e)}catch{}try{return re.dec(bn.dec(e))}catch{}try{return re.dec(he.dec(e))}catch{}try{return re.dec(En.dec(e)[1])}catch{}throw null},An={dkLen:32},Bn=e=>ae(e,An),Je=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",N={type:"void"},kn=(e,t=()=>null)=>{const n=new Map,r=new Set,o=d=>u=>{let l=n.get(u);if(l)return l;if(r.has(u)){const p={id:u};return n.set(u,p),p}r.add(u);const g=d(u);return l=n.get(u),l?Object.assign(l,g):(l={id:u,...g},n.set(u,l)),r.delete(u),l};let i=!0,s=!0;const c=o(d=>{const u=t(e[d]);if(u)return u;const{def:l,path:g,params:p}=e[d];if(l.tag==="composite"){if(l.value.length===0)return N;if(l.value.length===1){const f=c(l.value[0].type);return i&&g.at(-1)==="AccountId32"&&Je(f,32)?(i=!1,{type:"AccountId32"}):s&&g.at(-1)==="AccountId20"&&Je(f,20)?(s=!1,{type:"AccountId20"}):f}return h(l.value)}if(l.tag==="variant"){if(g.length===1&&g[0]==="Option"&&p.length===1&&p[0].name==="T"){const w=c(p[0].type);return w.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:w}}if(g.length===1&&g[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(l.value.length===0)return N;const f={},b={};return l.value.forEach(w=>{const S=w.name;if(b[S]=w.docs,w.fields.length===0){f[S]={...N,idx:w.index};return}if(w.fields.length===1&&!w.fields[0].name){f[S]={type:"lookupEntry",value:c(w.fields[0].type),idx:w.index};return}f[S]={...h(w.fields),idx:w.index}}),{type:"enum",value:f,innerDocs:b}}if(l.tag==="sequence")return{type:"sequence",value:c(l.value)};if(l.tag==="array"){const{len:f}=l.value,b=c(l.value.type);return!f||b.type==="void"?N:f>1?{type:"array",value:b,len:l.value.len}:b}if(l.tag==="tuple")return l.value.length===0?N:l.value.length>1?y(l.value.map(f=>c(f)),l.value.map(f=>e[f].docs)):c(l.value[0]);if(l.tag==="primitive")return{type:"primitive",value:l.value.tag};if(l.tag==="compact"){const f=c(l.value);return f.type==="void"?N:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:l.tag}}),h=d=>{let u=!0;const l={},g={};return d.forEach((p,f)=>{u=u&&!!p.name;const b=p.name||f,w=c(p.type);w.type!=="void"&&(l[b]=w,g[b]=p.docs)}),u?{type:"struct",value:l,innerDocs:g}:y(Object.values(l),Object.values(g))},y=(d,u)=>{if(d.every(l=>l.id===d[0].id)&&u.every(l=>!l.length)){const[l]=d;return l.type==="void"?N:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:u}};return c},In=e=>{const t=kn(e.lookup,({def:o})=>{if(o.tag==="composite"){const i=n(o);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...N,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const s=t(o.value[0].type),c=t(o.value[1].type);return s.type==="primitive"&&s.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(s=>s.name==="Call")?.type??null})},W=(e,t)=>{let n=e.toString(16);n=(n.length%2?"0":"")+n;const r=Math.max(0,(t||0)-n.length/2);return"0x"+"00".repeat(r)+n},Un=({additionalSigned:e})=>({genesisHash:V(e)}),Ln=({value:e})=>({nonce:W(T.dec(e),4)}),Tn=({additionalSigned:e})=>({transactionVersion:W(M.dec(e),4)}),_n=m({tip:T,asset:C(R(1/0))}).dec;var Qe=Object.freeze({__proto__:null,ChargeAssetTxPayment:({value:e})=>{const{tip:t,asset:n}=_n(e);return{...n?{assetId:V(n)}:{},tip:W(t,16)}},ChargeTransactionPayment:({value:e})=>({tip:W(Qt.dec(e),16)}),CheckGenesis:Un,CheckMetadataHash:({value:e,additionalSigned:t})=>e.length&&e[0]?{mode:1,metadataHash:V(t.length?t.slice(1):t)}:{},CheckMortality:({value:e,additionalSigned:t},n)=>({era:V(e),blockHash:V(t),blockNumber:W(n,4)}),CheckNonce:Ln,CheckSpecVersion:({additionalSigned:e})=>({specVersion:W(M.dec(e),4)}),CheckTxVersion:Tn});const Cn=se(I.enc,e=>+!!e.signed<<7|e.version),de=()=>new Error("Unkown signer"),Sn=e=>{const{extrinsic:t}=e,n=In(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const i=Object.fromEntries(e.lookup[t.type].params.filter(s=>s.type!=null).map(s=>[s.name,n(s.type)]));if(r=i.Address,o=i.Signature,!r||!o)throw de()}if(r.type==="AccountId20"&&o.type==="array"&&o.len===65&&o.value.type==="primitive"&&o.value.value==="u8")return[1,[]];if(o.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(i=>!(i in o.value)))throw de();if(r.type==="enum"){const i=r.value.Id;if(i.type==="lookupEntry"&&i.value.type==="AccountId32")return[0,[i.idx]]}else if(r.type==="AccountId32")return[0,[]];throw de()},Dn={Ed25519:0,Sr25519:1,Ecdsa:2},On=(e,t,n,r,o,i)=>{const[s,c]=Sn(e),h=Re(Cn({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([Dn[i],...n]),...r,o);return Re(T.enc(h.length),h)},jn=Jt().enc,Hn=e=>e.startsWith("0x")?J(e):jn(e);function Mn(e,t,n){const r=s=>n({address:e,data:V(s),type:"bytes"}).then(({signature:c})=>J(c)),o=Hn(e);return{publicKey:o,signTx:async(s,c,h,y,d=Bn)=>{let u;try{const w=xn(h);if(w.metadata.tag!=="v14"&&w.metadata.tag!=="v15")throw null;u=w.metadata.value}catch{throw new Error("Unsupported metadata version")}const l={};l.signedExtensions=[];const{version:g}=u.extrinsic,p=[];u.extrinsic.signedExtensions.map(({identifier:w})=>{const S=c[w];if(!S)throw new Error(`Missing ${w} signed-extension`);if(p.push(S.value),l.signedExtensions.push(w),!Qe[w]){if(S.value.length===0&&S.additionalSigned.length===0)return;throw new Error(`PJS does not support this signed-extension: ${w}`)}Object.assign(l,Qe[w](S,y))}),l.address=e,l.method=V(s),l.version=g,l.withSignedTransaction=!0;const f=await t(l),b=f.signedTransaction;return b?typeof b=="string"?J(b):b:On(u,o,J(f.signature),p,s)},signBytes:r}}const $n=new Set(["ed25519","sr25519","ecdsa","ethereum"]),Pn=async(e,t)=>{let n=window.injectedWeb3?.[e];if(!n)throw new Error(`Unavailable extension: "${e}"`);const r=await n.enable(t),o=r.signer.signPayload.bind(r.signer),i=r.signer.signRaw.bind(r.signer),s=d=>d.filter(({type:u})=>$n.has(u)).map(u=>{const l=Mn(u.address,o,i);return{...u,polkadotSigner:l}});let c=s(await r.accounts.get());const h=new Set,y=r.accounts.subscribe(d=>{c=s(d),h.forEach(u=>{u(c)})});return{name:e,getAccounts:()=>c,subscribe:d=>(h.add(d),()=>{h.delete(d)}),disconnect:()=>{y()}}},Vn=()=>{const{injectedWeb3:e}=window;return e?Object.keys(e):[]};X.connectInjectedExtension=Pn,X.getInjectedExtensions=Vn});
|
|
1
|
+
(function(R,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(R=typeof globalThis<"u"?globalThis:R||self,z(R.papiPjsSigner={}))})(this,function(R){"use strict";var z=Object.defineProperty,et=(e,t,n)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fe=(e,t,n)=>(et(e,typeof t!="symbol"?t+"":t,n),n),oe={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 tt(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|oe[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=oe[e[s]],h=oe[e[s+1]];o[t+i++]=c<<4|h}return o}var pe=class extends Uint8Array{constructor(e){super(e),fe(this,"i",0),fe(this,"v"),this.v=new DataView(e)}},_=e=>t=>e(t instanceof pe?t:new pe(t instanceof Uint8Array?t.buffer:typeof t=="string"?tt(t).buffer:t)),j=e=>{const t=e.length;let n=0;for(let o=0;o<t;o++)n+=e[o].length;const r=new Uint8Array(n);for(let o=0,i=0;o<t;o++){const s=e[o];r.set(s,i),i+=s.byteLength}return r};function Z(e,t){const n=Object.keys(e),r=n.length,o={};for(let i=0;i<r;i++){const s=n[i];o[s]=t(e[s],s)}return o}var B=(e,t)=>{const n=[e,t];return n.enc=e,n.dec=t,n},se=(e,t)=>n=>e(t(n)),ve=(e,t)=>n=>t(e(n)),ye=([e,t],n,r)=>B(se(e,n),ve(t,r));function nt(e,t){return _(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function rt(e,t){return n=>{const r=new Uint8Array(e);return new DataView(r.buffer)[t](0,n,!0),r}}function H(e,t,n){return B(rt(e,n),nt(e,t))}var I=H(1,"getUint8","setUint8"),ee=H(2,"getUint16","setUint16"),M=H(4,"getUint32","setUint32"),ge=H(8,"getBigUint64","setBigUint64");H(1,"getInt8","setInt8"),H(2,"getInt16","setInt16"),H(4,"getInt32","setInt32"),H(8,"getBigInt64","setBigInt64");var we=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},me=e=>_(t=>{const{v:n,i:r}=t,o=n.getBigUint64(r,!0),i=n[e](r+8,!0);return t.i+=16,i<<64n|o});B(we,me("getBigUint64")),B(we,me("getBigInt64"));var be=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},Ee=e=>_(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});B(be,Ee("getBigUint64")),B(be,Ee("getBigInt64")),ye(I,e=>e?1:0,Boolean);var ot=[I[1],ee[1],M[1]],st=_(e=>{const t=e[e.i],n=t&3;if(n<3)return ot[n](e)>>>2;const r=(t>>>2)+4;e.i++;let o=0n;const i=r/8|0;let s=0n;for(let h=0;h<i;h++)o=ge[1](e)<<s|o,s+=64n;let c=r%8;return c>3&&(o=BigInt(M[1](e))<<s|o,s+=32n,c-=4),c>1&&(o=BigInt(ee[1](e))<<s|o,s+=16n,c-=2),c&&(o=BigInt(I[1](e))<<s|o),o}),it=1n<<56n,ct=1<<24,at=256,lt=4294967295n,ut=64,ht=16384,dt=1<<30,ft=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<ut)return I[0](t);if(e<ht)return ee[0](t|1);if(e<dt)return M[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=it;)n.push(ge[0](r)),r>>=64n;r>=ct&&(n.push(M[0](Number(r<))),r>>=32n);let o=Number(r);o>=at&&(n.push(ee[0](o)),o>>=16),o&&n.push(I[0](o));const i=j(n);return i[0]=i.length-5<<2|3,i},T=B(ft,st),pt=new TextEncoder,vt=e=>{const t=pt.encode(e);return j([T.enc(t.length),t])},yt=new TextDecoder,gt=_(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,yt.decode(n)}),U=B(vt,gt),wt=()=>{},mt=new Uint8Array(0),E=B(()=>mt,wt),xe=e=>e===void 0?t=>j([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),Ae=e=>_(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}),K=e=>B(xe(e),Ae(e));K.enc=xe,K.dec=Ae;var Be=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((i,s)=>[n[s],i])??n.map((i,s)=>[i,s])),o=i=>r.get(i);return({tag:i,value:s})=>j([I.enc(o(i)),e[i](s)])},ke=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((o,i)=>[o,n[i]])??n.map((o,i)=>[i,o]));return _(o=>{const i=I.dec(o),s=r.get(i),c=e[s];return{tag:s,value:c(o)}})},q=(e,...t)=>B(Be(Z(e,([n])=>n),...t),ke(Z(e,([,n])=>n),...t));q.enc=Be,q.dec=ke;var Ie=e=>_(t=>I[1](t)>0?e(t):void 0),Ue=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,j([n,e(t)]))},C=e=>B(Ue(e[0]),Ie(e[1]));C.enc=Ue,C.dec=Ie;var Le=(...e)=>_(t=>e.map(n=>n(t))),Te=(...e)=>t=>j(e.map((n,r)=>n(t[r]))),X=(...e)=>B(Te(...e.map(([t])=>t)),Le(...e.map(([,t])=>t)));X.enc=Te,X.dec=Le;var _e=e=>{const t=Object.keys(e);return se(X.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Ce=e=>{const t=Object.keys(e);return ve(X.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,o)=>[t[o],r])))},m=e=>B(_e(Z(e,t=>t[0])),Ce(Z(e,t=>t[1])));m.enc=_e,m.dec=Ce;var Se=(e,t)=>t>=0?n=>j(n.map(e)):n=>j([T.enc(n.length),j(n.map(e))]),je=(e,t)=>_(n=>{const r=t>=0?t:T.dec(n),o=new Array(r);for(let i=0;i<r;i++)o[i]=e(n);return o}),x=(e,t)=>B(Se(e[0],t),je(e[1],t));x.enc=Se,x.dec=je;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Et(...e){const t=i=>i,n=(i,s)=>c=>i(s(c)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function xt(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 At(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 De(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 o=[],i=Array.from(e);for(i.forEach(s=>{if(s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let h=r;h<i.length;h++){const y=i[h],d=t*s+y;if(!Number.isSafeInteger(d)||t*s/t!==s||d-y!==t*s)throw new Error("convertRadix: carry overflow");s=d%n;const u=Math.floor(d/n);if(i[h]=u,!Number.isSafeInteger(u)||u*n+s!==d)throw new Error("convertRadix: carry overflow");if(c)u?c=!1:r=h;else continue}if(o.push(s),c)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}function Bt(e){return{encode:t=>{if(!bt(t))throw new Error("radix.encode input should be Uint8Array");return De(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(De(t,e,2**8))}}}const Oe=(e=>Et(Bt(58),xt(e),At("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ie(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function kt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function He(e,...t){if(!kt(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 Me(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 It(e,t){He(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 te=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),F=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Pe=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,D=F?e=>e:e=>Pe(e);function G(e){for(let t=0;t<e.length;t++)e[t]=Pe(e[t])}function Ut(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Y(e){return typeof e=="string"&&(e=Ut(e)),He(e),e}class Lt{clone(){return this._cloneInto()}}function Tt(e){const t=(r,o)=>e(o).update(Y(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const _t=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 Ct extends Lt{constructor(t,n,r={},o,i,s){if(super(),this.blockLen=t,this.outputLen=n,this.length=0,this.pos=0,this.finished=!1,this.destroyed=!1,ie(t),ie(n),ie(o),n<0||n>o)throw new Error("outputLen bigger than keyLen");if(r.key!==void 0&&(r.key.length<1||r.key.length>o))throw new Error(`key must be up 1..${o} byte long or undefined`);if(r.salt!==void 0&&r.salt.length!==i)throw new Error(`salt must be ${i} byte long or undefined`);if(r.personalization!==void 0&&r.personalization.length!==s)throw new Error(`personalization must be ${s} byte long or undefined`);this.buffer32=te(this.buffer=new Uint8Array(t))}update(t){Me(this);const{blockLen:n,buffer:r,buffer32:o}=this;t=Y(t);const i=t.length,s=t.byteOffset,c=t.buffer;for(let h=0;h<i;){this.pos===n&&(F||G(o),this.compress(o,0,!1),F||G(o),this.pos=0);const y=Math.min(n-this.pos,i-h),d=s+h;if(y===n&&!(d%4)&&h+y<i){const u=new Uint32Array(c,d,Math.floor((i-h)/4));F||G(u);for(let l=0;h+n<i;l+=o.length,h+=n)this.length+=n,this.compress(u,l,!1);F||G(u);continue}r.set(t.subarray(h,h+y),this.pos),this.pos+=y,this.length+=y,h+=y}return this}digestInto(t){Me(this),It(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),F||G(r),this.compress(r,0,!0),F||G(r);const o=te(t);this.get().forEach((i,s)=>o[s]=D(i))}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:o,destroyed:i,outputLen:s,pos:c}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.length=r,t.finished=o,t.destroyed=i,t.outputLen=s,t.buffer.set(n),t.pos=c,t}}const ne=BigInt(2**32-1),ce=BigInt(32);function $e(e,t=!1){return t?{h:Number(e&ne),l:Number(e>>ce&ne)}:{h:Number(e>>ce&ne)|0,l:Number(e&ne)|0}}function St(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=$e(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const jt=(e,t)=>BigInt(e>>>0)<<ce|BigInt(t>>>0),Dt=(e,t,n)=>e>>>n,Ot=(e,t,n)=>e<<32-n|t>>>n,Ht=(e,t,n)=>e>>>n|t<<32-n,Mt=(e,t,n)=>e<<32-n|t>>>n,Pt=(e,t,n)=>e<<64-n|t>>>n-32,$t=(e,t,n)=>e>>>n-32|t<<64-n,Vt=(e,t)=>t,Nt=(e,t)=>e,Rt=(e,t,n)=>e<<n|t>>>32-n,Kt=(e,t,n)=>t<<n|e>>>32-n,qt=(e,t,n)=>t<<n-32|e>>>64-n,Ft=(e,t,n)=>e<<n-32|t>>>64-n;function Xt(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const k={fromBig:$e,split:St,toBig:jt,shrSH:Dt,shrSL:Ot,rotrSH:Ht,rotrSL:Mt,rotrBH:Pt,rotrBL:$t,rotr32H:Vt,rotr32L:Nt,rotlSH:Rt,rotlSL:Kt,rotlBH:qt,rotlBL:Ft,add:Xt,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,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},A=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),a=new Uint32Array(32);function P(e,t,n,r,o,i){const s=o[i],c=o[i+1];let h=a[2*e],y=a[2*e+1],d=a[2*t],u=a[2*t+1],l=a[2*n],g=a[2*n+1],p=a[2*r],f=a[2*r+1],b=k.add3L(h,d,s);y=k.add3H(b,y,u,c),h=b|0,{Dh:f,Dl:p}={Dh:f^y,Dl:p^h},{Dh:f,Dl:p}={Dh:k.rotr32H(f,p),Dl:k.rotr32L(f,p)},{h:g,l}=k.add(g,l,f,p),{Bh:u,Bl:d}={Bh:u^g,Bl:d^l},{Bh:u,Bl:d}={Bh:k.rotrSH(u,d,24),Bl:k.rotrSL(u,d,24)},a[2*e]=h,a[2*e+1]=y,a[2*t]=d,a[2*t+1]=u,a[2*n]=l,a[2*n+1]=g,a[2*r]=p,a[2*r+1]=f}function $(e,t,n,r,o,i){const s=o[i],c=o[i+1];let h=a[2*e],y=a[2*e+1],d=a[2*t],u=a[2*t+1],l=a[2*n],g=a[2*n+1],p=a[2*r],f=a[2*r+1],b=k.add3L(h,d,s);y=k.add3H(b,y,u,c),h=b|0,{Dh:f,Dl:p}={Dh:f^y,Dl:p^h},{Dh:f,Dl:p}={Dh:k.rotrSH(f,p,16),Dl:k.rotrSL(f,p,16)},{h:g,l}=k.add(g,l,f,p),{Bh:u,Bl:d}={Bh:u^g,Bl:d^l},{Bh:u,Bl:d}={Bh:k.rotrBH(u,d,63),Bl:k.rotrBL(u,d,63)},a[2*e]=h,a[2*e+1]=y,a[2*t]=d,a[2*t+1]=u,a[2*n]=l,a[2*n+1]=g,a[2*r]=p,a[2*r+1]=f}class Gt extends Ct{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=A[0]|0,this.v0h=A[1]|0,this.v1l=A[2]|0,this.v1h=A[3]|0,this.v2l=A[4]|0,this.v2h=A[5]|0,this.v3l=A[6]|0,this.v3h=A[7]|0,this.v4l=A[8]|0,this.v4h=A[9]|0,this.v5l=A[10]|0,this.v5h=A[11]|0,this.v6l=A[12]|0,this.v6h=A[13]|0,this.v7l=A[14]|0,this.v7h=A[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=te(Y(t.salt));this.v4l^=D(r[0]),this.v4h^=D(r[1]),this.v5l^=D(r[2]),this.v5h^=D(r[3])}if(t.personalization){const r=te(Y(t.personalization));this.v6l^=D(r[0]),this.v6h^=D(r[1]),this.v7l^=D(r[2]),this.v7h^=D(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Y(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:c,v3h:h,v4l:y,v4h:d,v5l:u,v5h:l,v6l:g,v6h:p,v7l:f,v7h:b}=this;return[t,n,r,o,i,s,c,h,y,d,u,l,g,p,f,b]}set(t,n,r,o,i,s,c,h,y,d,u,l,g,p,f,b){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=c|0,this.v3h=h|0,this.v4l=y|0,this.v4h=d|0,this.v5l=u|0,this.v5h=l|0,this.v6l=g|0,this.v6h=p|0,this.v7l=f|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((h,y)=>a[y]=h),a.set(A,16);let{h:o,l:i}=k.fromBig(BigInt(this.length));a[24]=A[8]^i,a[25]=A[9]^o,r&&(a[28]=~a[28],a[29]=~a[29]);let s=0;const c=_t;for(let h=0;h<12;h++)P(0,4,8,12,t,n+2*c[s++]),$(0,4,8,12,t,n+2*c[s++]),P(1,5,9,13,t,n+2*c[s++]),$(1,5,9,13,t,n+2*c[s++]),P(2,6,10,14,t,n+2*c[s++]),$(2,6,10,14,t,n+2*c[s++]),P(3,7,11,15,t,n+2*c[s++]),$(3,7,11,15,t,n+2*c[s++]),P(0,5,10,15,t,n+2*c[s++]),$(0,5,10,15,t,n+2*c[s++]),P(1,6,11,12,t,n+2*c[s++]),$(1,6,11,12,t,n+2*c[s++]),P(2,7,8,13,t,n+2*c[s++]),$(2,7,8,13,t,n+2*c[s++]),P(3,4,9,14,t,n+2*c[s++]),$(3,4,9,14,t,n+2*c[s++]);this.v0l^=a[0]^a[16],this.v0h^=a[1]^a[17],this.v1l^=a[2]^a[18],this.v1h^=a[3]^a[19],this.v2l^=a[4]^a[20],this.v2h^=a[5]^a[21],this.v3l^=a[6]^a[22],this.v3h^=a[7]^a[23],this.v4l^=a[8]^a[24],this.v4h^=a[9]^a[25],this.v5l^=a[10]^a[26],this.v5h^=a[11]^a[27],this.v6l^=a[12]^a[28],this.v6h^=a[13]^a[29],this.v7l^=a[14]^a[30],this.v7h^=a[15]^a[31],a.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 ae=Tt(e=>new Gt(e)),Ve=new TextEncoder().encode("SS58PRE"),le=2,Wt=e=>{try{const t=Oe.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-le),o=t.subarray(n.length+r.length),i=ae(Uint8Array.of(...Ve,...n,...r),{dkLen:64}).subarray(0,le);return o[0]===i[0]&&o[1]===i[1]?{isValid:!0,ss58Format:zt(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},zt=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},Yt=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=ae(Uint8Array.of(...Ve,...t,...n),{dkLen:64}).subarray(0,le);return Oe.encode(Uint8Array.of(...t,...n,...r))}};function Jt(e,t){return n=>{const r=Wt(n);if(!r.isValid)throw new Error("Invalid checksum");const{publicKey:o}=r;if(o.length!==e)throw new Error("Invalid public key length");return o}}const Qt=(e=42,t=32)=>ye(K(t),Jt(t),Yt(e)),Ne="0123456789abcdef";function V(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Ne[r>>4]+Ne[r&15]}return t.join("")}const ue={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 J(e){const t=e.length%2,n=(e[1]==="x"?2:0)+t,r=(e.length-n)/2+t,o=new Uint8Array(r);t&&(o[0]=0|ue[e[2]]);for(let i=0;i<r;){const s=n+i*2,c=ue[e[s]],h=ue[e[s+1]];o[t+i++]=c<<4|h}return o}const Re=(...e)=>{const t=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.byteLength}return n},v=T,Zt=T,Ke=e=>{const t=K.enc(e);return n=>t(J(n))},qe=e=>{const t=K.dec(e);return n=>V(t(n))},Q=e=>B(Ke(e),qe(e));Q.enc=Ke,Q.dec=qe;const O=x(U),Fe=C(U),en=q({bool:E,char:E,str:E,u8:E,u16:E,u32:E,u64:E,u128:E,u256:E,i8:E,i16:E,i32:E,i64:E,i128:E,i256:E}),Xe=x(m({name:Fe,type:v,typeName:Fe,docs:O})),tn=m({len:M,type:v}),nn=m({bitStoreType:v,bitOrderType:v}),rn=x(m({name:U,fields:Xe,index:I,docs:O})),on=q({composite:Xe,variant:rn,sequence:v,array:tn,tuple:x(v),primitive:en,compact:v,bitSequence:nn}),sn=m({name:U,type:C(v)}),cn=x(sn),an=m({id:v,path:O,params:cn,def:on,docs:O}),Ge=x(an),ln=q({Blake2128:E,Blake2256:E,Blake2128Concat:E,Twox128:E,Twox256:E,Twox64Concat:E,Identity:E}),un=x(ln),hn=m({hashers:un,key:v,value:v}),dn=m({name:U,modifier:I,type:q({plain:v,map:hn}),fallback:Q(),docs:O}),fn=C(m({prefix:U,items:x(dn)})),We={name:U,storage:fn,calls:C(v),events:C(v),constants:x(m({name:U,type:v,value:Q(),docs:O})),errors:C(v),index:I},pn={...We,docs:O},vn=new Uint8Array,ze=e=>B(()=>vn,()=>e),yn=m({type:v,version:I,signedExtensions:x(m({identifier:U,type:v,additionalSigned:v}))}),gn=m({lookup:Ge,pallets:x(m({...We,docs:ze([])})),extrinsic:yn,type:v,apis:ze([])}),wn=m({name:U,methods:x(m({name:U,inputs:x(m({name:U,type:v})),output:v,docs:O})),docs:O}),mn=m({version:I,address:v,call:v,signature:v,extra:v,signedExtensions:x(m({identifier:U,type:v,additionalSigned:v}))}),bn=m({lookup:Ge,pallets:x(m(pn)),extrinsic:mn,type:v,apis:x(wn),outerEnums:m({call:v,event:v,error:v}),custom:x(X(U,m({type:v,value:Q()})))}),Ye=()=>{throw new Error("Unsupported metadata version!")},L=B(Ye,Ye),re=m({magicNumber:M,metadata:q({v0:L,v1:L,v2:L,v3:L,v4:L,v5:L,v6:L,v7:L,v8:L,v9:L,v10:L,v11:L,v12:L,v13:L,v14:gn,v15:bn})}),he=K(),En=C(he),xn=X(T,he),An=e=>{try{return re.dec(e)}catch{}try{return re.dec(En.dec(e))}catch{}try{return re.dec(he.dec(e))}catch{}try{return re.dec(xn.dec(e)[1])}catch{}throw null},Bn={dkLen:32},kn=e=>ae(e,Bn),Je=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",N={type:"void"},In=(e,t=()=>null)=>{const n=new Map,r=new Set,o=d=>u=>{let l=n.get(u);if(l)return l;if(r.has(u)){const p={id:u};return n.set(u,p),p}r.add(u);const g=d(u);return l=n.get(u),l?Object.assign(l,g):(l={id:u,...g},n.set(u,l)),r.delete(u),l};let i=!0,s=!0;const c=o(d=>{const u=t(e[d]);if(u)return u;const{def:l,path:g,params:p}=e[d];if(l.tag==="composite"){if(l.value.length===0)return N;if(l.value.length===1){const f=c(l.value[0].type);return i&&g.at(-1)==="AccountId32"&&Je(f,32)?(i=!1,{type:"AccountId32"}):s&&g.at(-1)==="AccountId20"&&Je(f,20)?(s=!1,{type:"AccountId20"}):f}return h(l.value)}if(l.tag==="variant"){if(g.length===1&&g[0]==="Option"&&p.length===1&&p[0].name==="T"){const w=c(p[0].type);return w.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:w}}if(g.length===1&&g[0]==="Result"&&p.length===2&&p[0].name==="T"&&p[1].name==="E")return{type:"result",value:{ok:c(p[0].type),ko:c(p[1].type)}};if(l.value.length===0)return N;const f={},b={};return l.value.forEach(w=>{const S=w.name;if(b[S]=w.docs,w.fields.length===0){f[S]={...N,idx:w.index};return}if(w.fields.length===1&&!w.fields[0].name){f[S]={type:"lookupEntry",value:c(w.fields[0].type),idx:w.index};return}f[S]={...h(w.fields),idx:w.index}}),{type:"enum",value:f,innerDocs:b}}if(l.tag==="sequence")return{type:"sequence",value:c(l.value)};if(l.tag==="array"){const{len:f}=l.value,b=c(l.value.type);return!f||b.type==="void"?N:f>1?{type:"array",value:b,len:l.value.len}:b}if(l.tag==="tuple")return l.value.length===0?N:l.value.length>1?y(l.value.map(f=>c(f)),l.value.map(f=>e[f].docs)):c(l.value[0]);if(l.tag==="primitive")return{type:"primitive",value:l.value.tag};if(l.tag==="compact"){const f=c(l.value);return f.type==="void"?N:{type:"compact",isBig:Number(f.value.slice(1))>32,size:f.value}}return{type:l.tag}}),h=d=>{let u=!0;const l={},g={};return d.forEach((p,f)=>{u=u&&!!p.name;const b=p.name||f,w=c(p.type);w.type!=="void"&&(l[b]=w,g[b]=p.docs)}),u?{type:"struct",value:l,innerDocs:g}:y(Object.values(l),Object.values(g))},y=(d,u)=>{if(d.every(l=>l.id===d[0].id)&&u.every(l=>!l.length)){const[l]=d;return l.type==="void"?N:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:u}};return c},Un=e=>{const t=In(e.lookup,({def:o})=>{if(o.tag==="composite"){const i=n(o);if(i)return{type:"enum",innerDocs:{},value:Object.fromEntries(e.pallets.map(s=>[s.name,s.errors==null?{...N,idx:s.index}:{type:"lookupEntry",value:t(s.errors),idx:s.index}])),byteLength:i}}return null});function n(o){if(!(o.value.length===2&&o.value[0].name==="index"&&o.value[1].name==="error"))return null;const s=t(o.value[0].type),c=t(o.value[1].type);return s.type==="primitive"&&s.value==="u8"&&c.type==="array"&&c.value.type==="primitive"&&c.value.value==="u8"?1+c.len:null}return Object.assign(t,{metadata:e,call:"outerEnums"in e?e.outerEnums.call:e.lookup[e.extrinsic?.type]?.params.find(s=>s.name==="Call")?.type??null})},Ln=se(I.enc,e=>+!!e.signed<<7|e.version),de=()=>new Error("Unkown signer"),Tn=e=>{const{extrinsic:t}=e,n=Un(e);let r,o;if("address"in t)r=n(t.address),o=n(t.signature);else{const i=Object.fromEntries(e.lookup[t.type].params.filter(s=>s.type!=null).map(s=>[s.name,n(s.type)]));if(r=i.Address,o=i.Signature,!r||!o)throw de()}if(r.type==="AccountId20"&&o.type==="array"&&o.len===65&&o.value.type==="primitive"&&o.value.value==="u8")return[1,[]];if(o.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(i=>!(i in o.value)))throw de();if(r.type==="enum"){const i=r.value.Id;if(i.type==="lookupEntry"&&i.value.type==="AccountId32")return[0,[i.idx]]}else if(r.type==="AccountId32")return[0,[]];throw de()},_n={Ed25519:0,Sr25519:1,Ecdsa:2},Cn=(e,t,n,r,o,i)=>{const[s,c]=Tn(e),h=Re(Ln({signed:!0,version:4}),s===1?t:new Uint8Array([...c,...t]),s===1||!i?n:new Uint8Array([_n[i],...n]),...r,o);return Re(T.enc(h.length),h)},W=(e,t)=>{let n=e.toString(16);n=(n.length%2?"0":"")+n;const r=Math.max(0,(t||0)-n.length/2);return"0x"+"00".repeat(r)+n},Sn=({additionalSigned:e})=>({genesisHash:V(e)}),jn=({value:e})=>({nonce:W(T.dec(e),4)}),Dn=({additionalSigned:e})=>({transactionVersion:W(M.dec(e),4)}),On=m({tip:T,asset:C(K(1/0))}).dec;var Qe=Object.freeze({__proto__:null,ChargeAssetTxPayment:({value:e})=>{const{tip:t,asset:n}=On(e);return{...n?{assetId:V(n)}:{},tip:W(t,16)}},ChargeTransactionPayment:({value:e})=>({tip:W(Zt.dec(e),16)}),CheckGenesis:Sn,CheckMetadataHash:({value:e,additionalSigned:t})=>e.length&&e[0]?{mode:1,metadataHash:V(t.length?t.slice(1):t)}:{},CheckMortality:({value:e,additionalSigned:t},n)=>({era:V(e),blockHash:V(t),blockNumber:W(n,4)}),CheckNonce:jn,CheckSpecVersion:({additionalSigned:e})=>({specVersion:W(M.dec(e),4)}),CheckTxVersion:Dn});const Hn=Qt().enc,Mn=e=>e.startsWith("0x")?J(e):Hn(e);function Ze(e,t,n){const r=s=>n({address:e,data:V(s),type:"bytes"}).then(({signature:c})=>J(c)),o=Mn(e);return{publicKey:o,signTx:async(s,c,h,y,d=kn)=>{let u;try{const w=An(h);if(w.metadata.tag!=="v14"&&w.metadata.tag!=="v15")throw null;u=w.metadata.value}catch{throw new Error("Unsupported metadata version")}const l={};l.signedExtensions=[];const{version:g}=u.extrinsic,p=[];u.extrinsic.signedExtensions.map(({identifier:w})=>{const S=c[w];if(!S)throw new Error(`Missing ${w} signed-extension`);if(p.push(S.value),l.signedExtensions.push(w),!Qe[w]){if(S.value.length===0&&S.additionalSigned.length===0)return;throw new Error(`PJS does not support this signed-extension: ${w}`)}Object.assign(l,Qe[w](S,y))}),l.address=e,l.method=V(s),l.version=g,l.withSignedTransaction=!0;const f=await t(l),b=f.signedTransaction;return b?typeof b=="string"?J(b):b:Cn(u,o,J(f.signature),p,s)},signBytes:r}}const Pn=new Set(["ed25519","sr25519","ecdsa","ethereum"]),$n=async(e,t)=>{let n=window.injectedWeb3?.[e];if(!n)throw new Error(`Unavailable extension: "${e}"`);const r=await n.enable(t),o=r.signer.signPayload.bind(r.signer),i=r.signer.signRaw.bind(r.signer),s=d=>d.filter(({type:u})=>Pn.has(u)).map(u=>{const l=Ze(u.address,o,i);return{...u,polkadotSigner:l}});let c=s(await r.accounts.get());const h=new Set,y=r.accounts.subscribe(d=>{c=s(d),h.forEach(u=>{u(c)})});return{name:e,getAccounts:()=>c,subscribe:d=>(h.add(d),()=>{h.delete(d)}),disconnect:()=>{y()}}},Vn=()=>{const{injectedWeb3:e}=window;return e?Object.keys(e):[]};R.connectInjectedExtension=$n,R.getInjectedExtensions=Vn,R.getPolkadotSignerFromPjs=Ze});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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.
|
|
195
|
-
"@polkadot-api/ink-contracts": "0.
|
|
194
|
+
"@polkadot-api/cli": "0.9.14",
|
|
195
|
+
"@polkadot-api/ink-contracts": "0.2.0",
|
|
196
196
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
197
197
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
198
198
|
"@polkadot-api/polkadot-sdk-compat": "2.3.1",
|
|
199
199
|
"@polkadot-api/metadata-builders": "0.9.1",
|
|
200
200
|
"@polkadot-api/metadata-compatibility": "0.1.11",
|
|
201
|
-
"@polkadot-api/observable-client": "0.
|
|
202
|
-
"@polkadot-api/pjs-signer": "0.
|
|
201
|
+
"@polkadot-api/observable-client": "0.6.0",
|
|
202
|
+
"@polkadot-api/pjs-signer": "0.6.0",
|
|
203
203
|
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
204
|
-
"@polkadot-api/signer": "0.1.10",
|
|
205
204
|
"@polkadot-api/sm-provider": "0.1.3",
|
|
205
|
+
"@polkadot-api/signer": "0.1.10",
|
|
206
206
|
"@polkadot-api/substrate-bindings": "0.9.3",
|
|
207
|
-
"@polkadot-api/substrate-client": "0.2.2",
|
|
208
207
|
"@polkadot-api/utils": "0.1.2",
|
|
208
|
+
"@polkadot-api/substrate-client": "0.3.0",
|
|
209
209
|
"@polkadot-api/ws-provider": "0.3.4",
|
|
210
|
-
"@polkadot-api/
|
|
211
|
-
"@polkadot-api/
|
|
210
|
+
"@polkadot-api/smoldot": "0.3.3",
|
|
211
|
+
"@polkadot-api/known-chains": "0.5.6"
|
|
212
212
|
},
|
|
213
213
|
"devDependencies": {
|
|
214
214
|
"rxjs": "^7.8.1",
|