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