polkadot-api 1.8.0 → 1.8.2
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/bin/cli.mjs +1 -1
- package/dist/esm/client.mjs +17 -9
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/compatibility.mjs +16 -2
- package/dist/esm/compatibility.mjs.map +1 -1
- package/dist/esm/storage.mjs.map +1 -1
- package/dist/esm/tx/create-tx.mjs +24 -28
- package/dist/esm/tx/create-tx.mjs.map +1 -1
- package/dist/esm/utils/optional-arg.mjs +1 -1
- package/dist/esm/utils/optional-arg.mjs.map +1 -1
- package/dist/index.js +57 -37
- package/dist/index.js.map +1 -1
- package/dist/umd/index.min.js +3 -3
- package/dist/umd/logs-provider.min.js +1 -1
- package/dist/umd/pjs-signer.min.js +1 -1
- package/dist/umd/polkadot-sdk-compat.min.js +1 -1
- package/dist/umd/ws-provider_web.min.js +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.papiLogsProvider={}))})(this,function(d){"use strict";var f=Object.defineProperty,_=(t,e,s)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,T=(t,e,s)=>_(t,typeof e!="symbol"?e+"":e,s);class ${constructor(...e){T(this,"first"),T(this,"last"),e.length!==0&&e.forEach(s=>this.push(s))}push(e){const s={value:e};this.last===void 0?(this.last=s,this.first=this.last):(this.last.next=s,this.last=s)}pop(){const e=this.first?.value;return this.first&&(this.first=this.first.next,this.first||(this.last=void 0)),e}peek(){return this.first?.value}}const x=">>",I="<<",b=t=>{const e=new Map;let s=-1;for(let c=0;c<t.length;c++){const[,l,u,h,a]=t[c].match(/^(\d*)-(.{24})-(.{2})-(.*)$/),o=Number(l);s=new Date(u).getTime();const n=e.get(o)??[];e.set(o,n),n.push({clientId:o,tick:s,type:h,msg:a})}return e},
|
|
1
|
+
(function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.papiLogsProvider={}))})(this,function(d){"use strict";var f=Object.defineProperty,_=(t,e,s)=>e in t?f(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,T=(t,e,s)=>_(t,typeof e!="symbol"?e+"":e,s);class ${constructor(...e){T(this,"first"),T(this,"last"),e.length!==0&&e.forEach(s=>this.push(s))}push(e){const s={value:e};this.last===void 0?(this.last=s,this.first=this.last):(this.last.next=s,this.last=s)}pop(){const e=this.first?.value;return this.first&&(this.first=this.first.next,this.first||(this.last=void 0)),e}peek(){return this.first?.value}}const x=">>",I="<<",b=t=>{const e=new Map;let s=-1;for(let c=0;c<t.length;c++){const[,l,u,h,a]=t[c].match(/^(\d*)-(.{24})-(.{2})-(.*)$/),o=Number(l);s=new Date(u).getTime();const n=e.get(o)??[];e.set(o,n),n.push({clientId:o,tick:s,type:h,msg:a})}return e},w=t=>{const e='TaggedTransactionQueue_validate_transaction","',s=t.lastIndexOf(e)+e.length+4,c=t.indexOf('"',s+1);return t.substring(s,c-64)},k={speed:1},O=(t,e={})=>{const{speed:s}={...k,...e};let c=1;const l=b(t[t.length-1]?t:t.slice(0,-1));return u=>{const h=c++,a=l.get(h),o=new $;let n=0,m=new Map;const v=async()=>{if(o.peek())for(;n<a.length&&g!==void 0;){const i=a[n];if(m.forEach((r,p)=>{i.msg=i.msg.replace(p,r)}),i.type===x){if(!o.peek()){g=setTimeout(v,100);break}const r=o.pop();if(i.msg.includes("TaggedTransactionQueue_validate_transaction")&&r?.includes("TaggedTransactionQueue_validate_transaction")&&(m.set(w(i.msg),w(r)),m.forEach((p,y)=>{i.msg=i.msg.replace(y,p)})),r!==i.msg)throw console.log(`recieved: "${r}"`),console.log(`expected: "${i.msg}"`),new Error("unexpected messaged was received")}else{u(i.msg);const r=a[n+1];r&&await new Promise(p=>setTimeout(p,(r.tick-i.tick)/s))}n++}};let g=setTimeout(v,200);return{send:i=>{o.push(i)},disconnect:()=>{clearTimeout(g),g=void 0}}}},P=(t,e)=>{let s=1,c,l="";const u=()=>{l=new Date().toISOString(),c=setTimeout(u,0)};return h=>{const a=s++;u();const o=e(n=>{t(`${a}-${l}-${I}-${n}`),h(n)});return{...o,send:n=>{t(`${a}-${l}-${x}-${n}`),o.send(n)},disconnect(){clearTimeout(c),o.disconnect()}}}};d.logsProvider=O,d.withLogsRecorder=P});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(R,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(R=typeof globalThis<"u"?globalThis:R||self,W(R.papiPjsSigner={}))})(this,function(R){"use strict";var W=Object.defineProperty,ot=(e,t,n)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t,n)=>(ot(e,typeof t!="symbol"?t+"":t,n),n),se={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 it(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|se[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=se[e[i]],h=se[e[i+1]];s[t+o++]=c<<4|h}return s}var ge=class extends Uint8Array{constructor(e){super(e),pe(this,"i",0),pe(this,"v"),this.v=new DataView(e)}},_=e=>t=>e(t instanceof ge?t:new ge(t instanceof Uint8Array?t.buffer:typeof t=="string"?it(t).buffer:t)),O=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function Z(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},oe=(e,t)=>n=>e(t(n)),ye=(e,t)=>n=>t(e(n)),me=([e,t],n,r)=>B(oe(e,n),ye(t,r));function ct(e,t){return _(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function at(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(at(e,n),ct(e,t))}var I=H(1,"getUint8","setUint8"),ee=H(2,"getUint16","setUint16"),M=H(4,"getUint32","setUint32"),we=H(8,"getBigUint64","setBigUint64");H(1,"getInt8","setInt8"),H(2,"getInt16","setInt16"),H(4,"getInt32","setInt32"),H(8,"getBigInt64","setBigInt64");var be=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},xe=e=>_(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(be,xe("getBigUint64")),B(be,xe("getBigInt64"));var Ee=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},Ae=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(Ee,Ae("getBigUint64")),B(Ee,Ae("getBigInt64")),me(I,e=>e?1:0,Boolean);var lt=[I[1],ee[1],M[1]],ut=_(e=>{const t=e[e.i],n=t&3;if(n<3)return lt[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=we[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(M[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(ee[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(I[1](e))<<i|s),s}),ht=1n<<56n,dt=1<<24,ft=256,vt=4294967295n,pt=64,gt=16384,yt=1<<30,mt=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<pt)return I[0](t);if(e<gt)return ee[0](t|1);if(e<yt)return M[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ht;)n.push(we[0](r)),r>>=64n;r>=dt&&(n.push(M[0](Number(r&vt))),r>>=32n);let s=Number(r);s>=ft&&(n.push(ee[0](s)),s>>=16),s&&n.push(I[0](s));const o=O(n);return o[0]=o.length-5<<2|3,o},T=B(mt,ut),wt=new TextEncoder,bt=e=>{const t=wt.encode(e);return O([T.enc(t.length),t])},xt=new TextDecoder,Et=_(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,xt.decode(n)}),U=B(bt,Et),At=()=>{},Bt=new Uint8Array(0),x=B(()=>Bt,At),Be=e=>e===void 0?t=>O([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ke=e=>_(t=>{const n=e===void 0?T.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),K=e=>B(Be(e),ke(e));K.enc=Be,K.dec=ke;var Ie=(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})=>O([I.enc(s(o)),e[o](i)])},Ue=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _(s=>{const o=I.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},q=(e,...t)=>B(Ie(Z(e,([n])=>n),...t),Ue(Z(e,([,n])=>n),...t));q.enc=Ie,q.dec=Ue;var Le=e=>_(t=>I[1](t)>0?e(t):void 0),Te=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,O([n,e(t)]))},S=e=>B(Te(e[0]),Le(e[1]));S.enc=Te,S.dec=Le;var _e=(...e)=>_(t=>e.map(n=>n(t))),Se=(...e)=>t=>O(e.map((n,r)=>n(t[r]))),X=(...e)=>B(Se(...e.map(([t])=>t)),_e(...e.map(([,t])=>t)));X.enc=Se,X.dec=_e;var Ce=e=>{const t=Object.keys(e);return oe(X.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Oe=e=>{const t=Object.keys(e);return ye(X.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},w=e=>B(Ce(Z(e,t=>t[0])),Oe(Z(e,t=>t[1])));w.enc=Ce,w.dec=Oe;var De=(e,t)=>t>=0?n=>O(n.map(e)):n=>O([T.enc(n.length),O(n.map(e))]),je=(e,t)=>_(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}),E=(e,t)=>B(De(e[0],t),je(e[1],t));E.enc=De,E.dec=je;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function He(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function ie(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Me(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ce(e){if(!Array.isArray(e))throw new Error("array expected")}function Pe(e,t){if(!He(!0,t))throw new Error(`${e}: array of strings expected`)}function It(e,t){if(!He(!1,t))throw new Error(`${e}: array of numbers expected`)}function Ut(...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 Lt(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Pe("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(ce(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(ce(s),s.map(o=>{ie("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function Tt(e=""){return ie("join",e),{encode:t=>(Pe("join.decode",t),t.join(e)),decode:t=>(ie("join.decode",t),t.split(e))}}function Ve(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(ce(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Me(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,h=!0;for(let p=r;p<i;p++){const d=o[p],u=t*c,a=u+d;if(!Number.isSafeInteger(a)||u/t!==c||a-d!==u)throw new Error("convertRadix: carry overflow");const y=a/n;c=a%n;const f=Math.floor(y);if(o[p]=f,!Number.isSafeInteger(f)||f*n+c!==a)throw new Error("convertRadix: carry overflow");if(h)f?h=!1:r=p;else continue}if(s.push(c),h)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function _t(e){Me(e);const t=2**8;return{encode:n=>{if(!kt(n))throw new Error("radix.encode input should be Uint8Array");return Ve(Array.from(n),t,e)},decode:n=>(It("radix.decode",n),Uint8Array.from(Ve(n,e,t)))}}const Ne=(e=>Ut(_t(58),Lt(e),Tt("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ae(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function St(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function $e(e,...t){if(!St(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Re(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 Ct(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 te=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),F=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Ke=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,D=F?e=>e:e=>Ke(e);function G(e){for(let t=0;t<e.length;t++)e[t]=Ke(e[t])}function Ot(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=Ot(e)),$e(e),e}class Dt{clone(){return this._cloneInto()}}function jt(e){const t=(r,s)=>e(s).update(Y(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ht=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 Mt extends Dt{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,ae(t),ae(n),ae(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 length must be undefined or 1.."+s);if(r.salt!==void 0&&r.salt.length!==o)throw new Error("salt must be undefined or "+o);if(r.personalization!==void 0&&r.personalization.length!==i)throw new Error("personalization must be undefined or "+i);this.buffer=new Uint8Array(t),this.buffer32=te(this.buffer)}update(t){Re(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=Y(t);const o=t.length,i=t.byteOffset,c=t.buffer;for(let h=0;h<o;){this.pos===n&&(F||G(s),this.compress(s,0,!1),F||G(s),this.pos=0);const p=Math.min(n-this.pos,o-h),d=i+h;if(p===n&&!(d%4)&&h+p<o){const u=new Uint32Array(c,d,Math.floor((o-h)/4));F||G(u);for(let a=0;h+n<o;a+=s.length,h+=n)this.length+=n,this.compress(u,a,!1);F||G(u);continue}r.set(t.subarray(h,h+p),this.pos),this.pos+=p,this.length+=p,h+=p}return this}digestInto(t){Re(this),Ct(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),F||G(r),this.compress(r,0,!0),F||G(r);const s=te(t);this.get().forEach((o,i)=>s[i]=D(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 ne=BigInt(2**32-1),le=BigInt(32);function qe(e,t=!1){return t?{h:Number(e&ne),l:Number(e>>le&ne)}:{h:Number(e>>le&ne)|0,l:Number(e&ne)|0}}function Pt(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}=qe(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const Vt=(e,t)=>BigInt(e>>>0)<<le|BigInt(t>>>0),Nt=(e,t,n)=>e>>>n,$t=(e,t,n)=>e<<32-n|t>>>n,Rt=(e,t,n)=>e>>>n|t<<32-n,Kt=(e,t,n)=>e<<32-n|t>>>n,qt=(e,t,n)=>e<<64-n|t>>>n-32,Ft=(e,t,n)=>e>>>n-32|t<<64-n,Xt=(e,t)=>t,Gt=(e,t)=>e,zt=(e,t,n)=>e<<n|t>>>32-n,Wt=(e,t,n)=>t<<n|e>>>32-n,Yt=(e,t,n)=>t<<n-32|e>>>64-n,Jt=(e,t,n)=>e<<n-32|t>>>64-n;function Qt(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const k={fromBig:qe,split:Pt,toBig:Vt,shrSH:Nt,shrSL:$t,rotrSH:Rt,rotrSL:Kt,rotrBH:qt,rotrBL:Ft,rotr32H:Xt,rotr32L:Gt,rotlSH:zt,rotlSL:Wt,rotlBH:Yt,rotlBL:Jt,add:Qt,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)},A=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),l=new Uint32Array(32);function P(e,t,n,r,s,o){const i=s[o],c=s[o+1];let h=l[2*e],p=l[2*e+1],d=l[2*t],u=l[2*t+1],a=l[2*n],y=l[2*n+1],f=l[2*r],v=l[2*r+1],b=k.add3L(h,d,i);p=k.add3H(b,p,u,c),h=b|0,{Dh:v,Dl:f}={Dh:v^p,Dl:f^h},{Dh:v,Dl:f}={Dh:k.rotr32H(v,f),Dl:k.rotr32L(v,f)},{h:y,l:a}=k.add(y,a,v,f),{Bh:u,Bl:d}={Bh:u^y,Bl:d^a},{Bh:u,Bl:d}={Bh:k.rotrSH(u,d,24),Bl:k.rotrSL(u,d,24)},l[2*e]=h,l[2*e+1]=p,l[2*t]=d,l[2*t+1]=u,l[2*n]=a,l[2*n+1]=y,l[2*r]=f,l[2*r+1]=v}function V(e,t,n,r,s,o){const i=s[o],c=s[o+1];let h=l[2*e],p=l[2*e+1],d=l[2*t],u=l[2*t+1],a=l[2*n],y=l[2*n+1],f=l[2*r],v=l[2*r+1],b=k.add3L(h,d,i);p=k.add3H(b,p,u,c),h=b|0,{Dh:v,Dl:f}={Dh:v^p,Dl:f^h},{Dh:v,Dl:f}={Dh:k.rotrSH(v,f,16),Dl:k.rotrSL(v,f,16)},{h:y,l:a}=k.add(y,a,v,f),{Bh:u,Bl:d}={Bh:u^y,Bl:d^a},{Bh:u,Bl:d}={Bh:k.rotrBH(u,d,63),Bl:k.rotrBL(u,d,63)},l[2*e]=h,l[2*e+1]=p,l[2*t]=d,l[2*t+1]=u,l[2*n]=a,l[2*n+1]=y,l[2*r]=f,l[2*r+1]=v}class Zt extends Mt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=A[0]|0,this.v0h=A[1]|0,this.v1l=A[2]|0,this.v1h=A[3]|0,this.v2l=A[4]|0,this.v2h=A[5]|0,this.v3l=A[6]|0,this.v3h=A[7]|0,this.v4l=A[8]|0,this.v4h=A[9]|0,this.v5l=A[10]|0,this.v5h=A[11]|0,this.v6l=A[12]|0,this.v6h=A[13]|0,this.v7l=A[14]|0,this.v7h=A[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=te(Y(t.salt));this.v4l^=D(r[0]),this.v4h^=D(r[1]),this.v5l^=D(r[2]),this.v5h^=D(r[3])}if(t.personalization){const r=te(Y(t.personalization));this.v6l^=D(r[0]),this.v6h^=D(r[1]),this.v7l^=D(r[2]),this.v7h^=D(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Y(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:h,v4l:p,v4h:d,v5l:u,v5h:a,v6l:y,v6h:f,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,h,p,d,u,a,y,f,v,b]}set(t,n,r,s,o,i,c,h,p,d,u,a,y,f,v,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=h|0,this.v4l=p|0,this.v4h=d|0,this.v5l=u|0,this.v5h=a|0,this.v6l=y|0,this.v6h=f|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((h,p)=>l[p]=h),l.set(A,16);let{h:s,l:o}=k.fromBig(BigInt(this.length));l[24]=A[8]^o,l[25]=A[9]^s,r&&(l[28]=~l[28],l[29]=~l[29]);let i=0;const c=Ht;for(let h=0;h<12;h++)P(0,4,8,12,t,n+2*c[i++]),V(0,4,8,12,t,n+2*c[i++]),P(1,5,9,13,t,n+2*c[i++]),V(1,5,9,13,t,n+2*c[i++]),P(2,6,10,14,t,n+2*c[i++]),V(2,6,10,14,t,n+2*c[i++]),P(3,7,11,15,t,n+2*c[i++]),V(3,7,11,15,t,n+2*c[i++]),P(0,5,10,15,t,n+2*c[i++]),V(0,5,10,15,t,n+2*c[i++]),P(1,6,11,12,t,n+2*c[i++]),V(1,6,11,12,t,n+2*c[i++]),P(2,7,8,13,t,n+2*c[i++]),V(2,7,8,13,t,n+2*c[i++]),P(3,4,9,14,t,n+2*c[i++]),V(3,4,9,14,t,n+2*c[i++]);this.v0l^=l[0]^l[16],this.v0h^=l[1]^l[17],this.v1l^=l[2]^l[18],this.v1h^=l[3]^l[19],this.v2l^=l[4]^l[20],this.v2h^=l[5]^l[21],this.v3l^=l[6]^l[22],this.v3h^=l[7]^l[23],this.v4l^=l[8]^l[24],this.v4h^=l[9]^l[25],this.v5l^=l[10]^l[26],this.v5h^=l[11]^l[27],this.v6l^=l[12]^l[28],this.v6h^=l[13]^l[29],this.v7l^=l[14]^l[30],this.v7h^=l[15]^l[31],l.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 ue=jt(e=>new Zt(e)),Fe=new TextEncoder().encode("SS58PRE"),he=2,en=e=>{try{const t=Ne.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-he),s=t.subarray(n.length+r.length),o=ue(Uint8Array.of(...Fe,...n,...r),{dkLen:64}).subarray(0,he);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:tn(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},tn=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},nn=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=ue(Uint8Array.of(...Fe,...t,...n),{dkLen:64}).subarray(0,he);return Ne.encode(Uint8Array.of(...t,...n,...r))}};function rn(e,t){return n=>{const r=en(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 sn=(e=42,t=32)=>me(K(t),rn(t),nn(e)),Xe="0123456789abcdef";function N(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Xe[r>>4]+Xe[r&15]}return t.join("")}const de={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,s=new Uint8Array(r);t&&(s[0]=0|de[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=de[e[i]],h=de[e[i+1]];s[t+o++]=c<<4|h}return s}const Ge=(...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},g=T,on=T,ze=e=>{const t=K.enc(e);return n=>t(J(n))},We=e=>{const t=K.dec(e);return n=>N(t(n))},Q=e=>B(ze(e),We(e));Q.enc=ze,Q.dec=We;const j=E(U),Ye=S(U),cn=q({bool:x,char:x,str:x,u8:x,u16:x,u32:x,u64:x,u128:x,u256:x,i8:x,i16:x,i32:x,i64:x,i128:x,i256:x}),Je=E(w({name:Ye,type:g,typeName:Ye,docs:j})),an=w({len:M,type:g}),ln=w({bitStoreType:g,bitOrderType:g}),un=E(w({name:U,fields:Je,index:I,docs:j})),hn=q({composite:Je,variant:un,sequence:g,array:an,tuple:E(g),primitive:cn,compact:g,bitSequence:ln}),dn=w({name:U,type:S(g)}),fn=E(dn),vn=w({id:g,path:j,params:fn,def:hn,docs:j}),Qe=E(vn),pn=q({Blake2128:x,Blake2256:x,Blake2128Concat:x,Twox128:x,Twox256:x,Twox64Concat:x,Identity:x}),gn=E(pn),yn=w({hashers:gn,key:g,value:g}),mn=w({name:U,modifier:I,type:q({plain:g,map:yn}),fallback:Q(),docs:j}),wn=S(w({prefix:U,items:E(mn)})),Ze={name:U,storage:wn,calls:S(g),events:S(g),constants:E(w({name:U,type:g,value:Q(),docs:j})),errors:S(g),index:I},bn={...Ze,docs:j},xn=new Uint8Array,et=e=>B(()=>xn,()=>e),En=w({type:g,version:I,signedExtensions:E(w({identifier:U,type:g,additionalSigned:g}))}),An=w({lookup:Qe,pallets:E(w({...Ze,docs:et([])})),extrinsic:En,type:g,apis:et([])}),Bn=w({name:U,methods:E(w({name:U,inputs:E(w({name:U,type:g})),output:g,docs:j})),docs:j}),kn=w({version:I,address:g,call:g,signature:g,extra:g,signedExtensions:E(w({identifier:U,type:g,additionalSigned:g}))}),In=w({lookup:Qe,pallets:E(w(bn)),extrinsic:kn,type:g,apis:E(Bn),outerEnums:w({call:g,event:g,error:g}),custom:E(X(U,w({type:g,value:Q()})))}),tt=()=>{throw new Error("Unsupported metadata version!")},L=B(tt,tt),re=w({magicNumber:M,metadata:q({v0:L,v1:L,v2:L,v3:L,v4:L,v5:L,v6:L,v7:L,v8:L,v9:L,v10:L,v11:L,v12:L,v13:L,v14:An,v15:In})}),fe=K(),Un=S(fe),Ln=X(T,fe),Tn=e=>{try{return re.dec(e)}catch{}try{return re.dec(Un.dec(e))}catch{}try{return re.dec(fe.dec(e))}catch{}try{return re.dec(Ln.dec(e)[1])}catch{}throw null},_n={dkLen:32},Sn=e=>ue(e,_n),nt=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",$={type:"void"},Cn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=d=>u=>{let a=n.get(u);if(a)return a;if(r.has(u)){const f={id:u};return n.set(u,f),f}r.add(u);const y=d(u);return a=n.get(u),a?Object.assign(a,y):(a={id:u,...y},n.set(u,a)),r.delete(u),a};let o=!0,i=!0;const c=s(d=>{const u=t(e[d]);if(u)return u;const{def:a,path:y,params:f}=e[d];if(a.tag==="composite"){if(a.value.length===0)return $;if(a.value.length===1){const v=c(a.value[0].type);return o&&y.at(-1)==="AccountId32"&&nt(v,32)?(o=!1,{type:"AccountId32"}):i&&y.at(-1)==="AccountId20"&&nt(v,20)?(i=!1,{type:"AccountId20"}):v}return h(a.value)}if(a.tag==="variant"){if(y.length===1&&y[0]==="Option"&&f.length===1&&f[0].name==="T"){const m=c(f[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(y.length===1&&y[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(a.value.length===0)return $;const v={},b={};return a.value.forEach(m=>{const C=m.name;if(b[C]=m.docs,m.fields.length===0){v[C]={...$,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[C]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[C]={...h(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(a.tag==="sequence")return{type:"sequence",value:c(a.value)};if(a.tag==="array"){const{len:v}=a.value,b=c(a.value.type);return!v||b.type==="void"?$:v>1?{type:"array",value:b,len:a.value.len}:b}if(a.tag==="tuple")return a.value.length===0?$:a.value.length>1?p(a.value.map(v=>c(v)),a.value.map(v=>e[v].docs)):c(a.value[0]);if(a.tag==="primitive")return{type:"primitive",value:a.value.tag};if(a.tag==="compact"){const v=c(a.value);return v.type==="void"?$:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:a.tag}}),h=d=>{let u=!0;const a={},y={};return d.forEach((f,v)=>{u=u&&!!f.name;const b=f.name||v,m=c(f.type);m.type!=="void"&&(a[b]=m,y[b]=f.docs)}),u?{type:"struct",value:a,innerDocs:y}:p(Object.values(a),Object.values(y))},p=(d,u)=>{if(d.every(a=>a.id===d[0].id)&&u.every(a=>!a.length)){const[a]=d;return a.type==="void"?$:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:u}};return c},On=e=>{const t=Cn(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?{...$,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})},Dn=oe(I.enc,e=>+!!e.signed<<7|e.version),ve=()=>new Error("Unkown signer"),jn=e=>{const{extrinsic:t}=e,n=On(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw ve()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw ve();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw ve()},Hn={Ed25519:0,Sr25519:1,Ecdsa:2},Mn=(e,t,n,r,s,o)=>{const[i,c]=jn(e),h=Ge(Dn({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),i===1||!o?n:new Uint8Array([Hn[o],...n]),...r,s);return Ge(T.enc(h.length),h)},z=(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},Pn=({additionalSigned:e})=>({genesisHash:N(e)}),Vn=({value:e})=>({nonce:z(T.dec(e),4)}),Nn=({additionalSigned:e})=>({transactionVersion:z(M.dec(e),4)}),$n=w({tip:T,asset:S(K(1/0))}).dec;var rt=Object.freeze({__proto__:null,ChargeAssetTxPayment:({value:e})=>{const{tip:t,asset:n}=$n(e);return{...n?{assetId:N(n)}:{},tip:z(t,16)}},ChargeTransactionPayment:({value:e})=>({tip:z(on.dec(e),16)}),CheckGenesis:Pn,CheckMetadataHash:({value:e,additionalSigned:t})=>e.length&&e[0]?{mode:1,metadataHash:N(t.length?t.slice(1):t)}:{},CheckMortality:({value:e,additionalSigned:t},n)=>({era:N(e),blockHash:N(t),blockNumber:z(n,4)}),CheckNonce:Vn,CheckSpecVersion:({additionalSigned:e})=>({specVersion:z(M.dec(e),4)}),CheckTxVersion:Nn});const Rn=sn().enc,Kn=e=>e.startsWith("0x")?J(e):Rn(e);function st(e,t,n){const r=i=>n({address:e,data:N(i),type:"bytes"}).then(({signature:c})=>J(c)),s=Kn(e);return{publicKey:s,signTx:async(i,c,h,p,d=Sn)=>{let u;try{const m=Tn(h);if(m.metadata.tag!=="v14"&&m.metadata.tag!=="v15")throw null;u=m.metadata.value}catch{throw new Error("Unsupported metadata version")}const a={};a.signedExtensions=[];const{version:y}=u.extrinsic,f=[];u.extrinsic.signedExtensions.map(({identifier:m})=>{const C=c[m];if(!C)throw new Error(`Missing ${m} signed-extension`);if(f.push(C.value),a.signedExtensions.push(m),!rt[m]){if(C.value.length===0&&C.additionalSigned.length===0)return;throw new Error(`PJS does not support this signed-extension: ${m}`)}Object.assign(a,rt[m](C,p))}),a.address=e,a.method=N(i),a.version=y,a.withSignedTransaction=!0;const v=await t(a),b=v.signedTransaction;return b?typeof b=="string"?J(b):b:Mn(u,s,J(v.signature),f,i)},signBytes:r}}const qn=new Set(["ed25519","sr25519","ecdsa","ethereum"]),Fn=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:u})=>qn.has(u)).map(u=>{const a=st(u.address,s,o);return{...u,polkadotSigner:a}});let c=i(await r.accounts.get());const h=new Set,p=r.accounts.subscribe(d=>{c=i(d),h.forEach(u=>{u(c)})});return{name:e,getAccounts:()=>c,subscribe:d=>(h.add(d),()=>{h.delete(d)}),disconnect:()=>{p()}}},Xn=()=>{const{injectedWeb3:e}=window;return e?Object.keys(e):[]};R.connectInjectedExtension=Fn,R.getInjectedExtensions=Xn,R.getPolkadotSignerFromPjs=st});
|
|
1
|
+
(function(R,W){typeof exports=="object"&&typeof module<"u"?W(exports):typeof define=="function"&&define.amd?define(["exports"],W):(R=typeof globalThis<"u"?globalThis:R||self,W(R.papiPjsSigner={}))})(this,function(R){"use strict";var W=Object.defineProperty,ot=(e,t,n)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t,n)=>(ot(e,typeof t!="symbol"?t+"":t,n),n),se={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 it(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|se[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=se[e[i]],h=se[e[i+1]];s[t+o++]=c<<4|h}return s}var ge=class extends Uint8Array{constructor(e){super(e),pe(this,"i",0),pe(this,"v"),this.v=new DataView(e)}},_=e=>t=>e(t instanceof ge?t:new ge(t instanceof Uint8Array?t.buffer:typeof t=="string"?it(t).buffer:t)),O=e=>{const t=e.length;let n=0;for(let s=0;s<t;s++)n+=e[s].length;const r=new Uint8Array(n);for(let s=0,o=0;s<t;s++){const i=e[s];r.set(i,o),o+=i.byteLength}return r};function Z(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},oe=(e,t)=>n=>e(t(n)),ye=(e,t)=>n=>t(e(n)),me=([e,t],n,r)=>B(oe(e,n),ye(t,r));function ct(e,t){return _(n=>{const r=n.v[t](n.i,!0);return n.i+=e,r})}function at(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(at(e,n),ct(e,t))}var I=H(1,"getUint8","setUint8"),ee=H(2,"getUint16","setUint16"),M=H(4,"getUint32","setUint32"),we=H(8,"getBigUint64","setBigUint64");H(1,"getInt8","setInt8"),H(2,"getInt16","setInt16"),H(4,"getInt32","setInt32"),H(8,"getBigInt64","setBigInt64");var be=e=>{const t=new Uint8Array(16),n=new DataView(t.buffer);return n.setBigInt64(0,e,!0),n.setBigInt64(8,e>>64n,!0),t},xe=e=>_(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(be,xe("getBigUint64")),B(be,xe("getBigInt64"));var Ee=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},Ae=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(Ee,Ae("getBigUint64")),B(Ee,Ae("getBigInt64")),me(I,e=>e?1:0,Boolean);var ut=[I[1],ee[1],M[1]],lt=_(e=>{const t=e[e.i],n=t&3;if(n<3)return ut[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=we[1](e)<<i|s,i+=64n;let c=r%8;return c>3&&(s=BigInt(M[1](e))<<i|s,i+=32n,c-=4),c>1&&(s=BigInt(ee[1](e))<<i|s,i+=16n,c-=2),c&&(s=BigInt(I[1](e))<<i|s),s}),ht=1n<<56n,dt=1<<24,ft=256,vt=4294967295n,pt=64,gt=16384,yt=1<<30,mt=e=>{if(e<0)throw new Error(`Wrong compact input (${e})`);const t=Number(e)<<2;if(e<pt)return I[0](t);if(e<gt)return ee[0](t|1);if(e<yt)return M[0](t|2);let n=[new Uint8Array(1)],r=BigInt(e);for(;r>=ht;)n.push(we[0](r)),r>>=64n;r>=dt&&(n.push(M[0](Number(r&vt))),r>>=32n);let s=Number(r);s>=ft&&(n.push(ee[0](s)),s>>=16),s&&n.push(I[0](s));const o=O(n);return o[0]=o.length-5<<2|3,o},T=B(mt,lt),wt=new TextEncoder,bt=e=>{const t=wt.encode(e);return O([T.enc(t.length),t])},xt=new TextDecoder,Et=_(e=>{let t=T.dec(e);const n=new DataView(e.buffer,e.i,t);return e.i+=t,xt.decode(n)}),U=B(bt,Et),At=()=>{},Bt=new Uint8Array(0),x=B(()=>Bt,At),Be=e=>e===void 0?t=>O([T.enc(t.length),t]):t=>t.length===e?t:t.slice(0,e),ke=e=>_(t=>{const n=e===void 0?T.dec(t):e!==1/0?e:t.byteLength-t.i,r=new Uint8Array(t.buffer.slice(t.i,t.i+n));return t.i+=n,r}),K=e=>B(Be(e),ke(e));K.enc=Be,K.dec=ke;var Ie=(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})=>O([I.enc(s(o)),e[o](i)])},Ue=(e,t)=>{const n=Object.keys(e),r=new Map(t?.map((s,o)=>[s,n[o]])??n.map((s,o)=>[o,s]));return _(s=>{const o=I.dec(s),i=r.get(o),c=e[i];return{tag:i,value:c(s)}})},q=(e,...t)=>B(Ie(Z(e,([n])=>n),...t),Ue(Z(e,([,n])=>n),...t));q.enc=Ie,q.dec=Ue;var Le=e=>_(t=>I[1](t)>0?e(t):void 0),Te=e=>t=>{const n=new Uint8Array(1);return t===void 0?n:(n[0]=1,O([n,e(t)]))},S=e=>B(Te(e[0]),Le(e[1]));S.enc=Te,S.dec=Le;var _e=(...e)=>_(t=>e.map(n=>n(t))),Se=(...e)=>t=>O(e.map((n,r)=>n(t[r]))),X=(...e)=>B(Se(...e.map(([t])=>t)),_e(...e.map(([,t])=>t)));X.enc=Se,X.dec=_e;var Ce=e=>{const t=Object.keys(e);return oe(X.enc(...Object.values(e)),n=>t.map(r=>n[r]))},Oe=e=>{const t=Object.keys(e);return ye(X.dec(...Object.values(e)),n=>Object.fromEntries(n.map((r,s)=>[t[s],r])))},w=e=>B(Ce(Z(e,t=>t[0])),Oe(Z(e,t=>t[1])));w.enc=Ce,w.dec=Oe;var De=(e,t)=>t>=0?n=>O(n.map(e)):n=>O([T.enc(n.length),O(n.map(e))]),je=(e,t)=>_(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}),E=(e,t)=>B(De(e[0],t),je(e[1],t));E.enc=De,E.dec=je;/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function He(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function ie(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Me(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ce(e){if(!Array.isArray(e))throw new Error("array expected")}function Pe(e,t){if(!He(!0,t))throw new Error(`${e}: array of strings expected`)}function It(e,t){if(!He(!1,t))throw new Error(`${e}: array of numbers expected`)}function Ut(...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 Lt(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Pe("alphabet",t);const r=new Map(t.map((s,o)=>[s,o]));return{encode:s=>(ce(s),s.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:s=>(ce(s),s.map(o=>{ie("alphabet.decode",o);const i=r.get(o);if(i===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);return i}))}}function Tt(e=""){return ie("join",e),{encode:t=>(Pe("join.decode",t),t.join(e)),decode:t=>(ie("join.decode",t),t.split(e))}}function Ve(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(ce(e),!e.length)return[];let r=0;const s=[],o=Array.from(e,c=>{if(Me(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),i=o.length;for(;;){let c=0,h=!0;for(let p=r;p<i;p++){const d=o[p],l=t*c,a=l+d;if(!Number.isSafeInteger(a)||l/t!==c||a-d!==l)throw new Error("convertRadix: carry overflow");const y=a/n;c=a%n;const f=Math.floor(y);if(o[p]=f,!Number.isSafeInteger(f)||f*n+c!==a)throw new Error("convertRadix: carry overflow");if(h)f?h=!1:r=p;else continue}if(s.push(c),h)break}for(let c=0;c<e.length-1&&e[c]===0;c++)s.push(0);return s.reverse()}function _t(e){Me(e);const t=2**8;return{encode:n=>{if(!kt(n))throw new Error("radix.encode input should be Uint8Array");return Ve(Array.from(n),t,e)},decode:n=>(It("radix.decode",n),Uint8Array.from(Ve(n,e,t)))}}const Ne=(e=>Ut(_t(58),Lt(e),Tt("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function ae(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function St(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function $e(e,...t){if(!St(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Re(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 Ct(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 te=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),F=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Ke=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,D=F?e=>e:e=>Ke(e);function G(e){for(let t=0;t<e.length;t++)e[t]=Ke(e[t])}function Ot(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=Ot(e)),$e(e),e}class Dt{clone(){return this._cloneInto()}}function jt(e){const t=(r,s)=>e(s).update(Y(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const Ht=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 Mt extends Dt{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,ae(t),ae(n),ae(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 length must be undefined or 1.."+s);if(r.salt!==void 0&&r.salt.length!==o)throw new Error("salt must be undefined or "+o);if(r.personalization!==void 0&&r.personalization.length!==i)throw new Error("personalization must be undefined or "+i);this.buffer=new Uint8Array(t),this.buffer32=te(this.buffer)}update(t){Re(this);const{blockLen:n,buffer:r,buffer32:s}=this;t=Y(t);const o=t.length,i=t.byteOffset,c=t.buffer;for(let h=0;h<o;){this.pos===n&&(F||G(s),this.compress(s,0,!1),F||G(s),this.pos=0);const p=Math.min(n-this.pos,o-h),d=i+h;if(p===n&&!(d%4)&&h+p<o){const l=new Uint32Array(c,d,Math.floor((o-h)/4));F||G(l);for(let a=0;h+n<o;a+=s.length,h+=n)this.length+=n,this.compress(l,a,!1);F||G(l);continue}r.set(t.subarray(h,h+p),this.pos),this.pos+=p,this.length+=p,h+=p}return this}digestInto(t){Re(this),Ct(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,this.buffer.subarray(n).fill(0),F||G(r),this.compress(r,0,!0),F||G(r);const s=te(t);this.get().forEach((o,i)=>s[i]=D(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 ne=BigInt(2**32-1),ue=BigInt(32);function qe(e,t=!1){return t?{h:Number(e&ne),l:Number(e>>ue&ne)}:{h:Number(e>>ue&ne)|0,l:Number(e&ne)|0}}function Pt(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}=qe(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const Vt=(e,t)=>BigInt(e>>>0)<<ue|BigInt(t>>>0),Nt=(e,t,n)=>e>>>n,$t=(e,t,n)=>e<<32-n|t>>>n,Rt=(e,t,n)=>e>>>n|t<<32-n,Kt=(e,t,n)=>e<<32-n|t>>>n,qt=(e,t,n)=>e<<64-n|t>>>n-32,Ft=(e,t,n)=>e>>>n-32|t<<64-n,Xt=(e,t)=>t,Gt=(e,t)=>e,zt=(e,t,n)=>e<<n|t>>>32-n,Wt=(e,t,n)=>t<<n|e>>>32-n,Yt=(e,t,n)=>t<<n-32|e>>>64-n,Jt=(e,t,n)=>e<<n-32|t>>>64-n;function Qt(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:s|0}}const k={fromBig:qe,split:Pt,toBig:Vt,shrSH:Nt,shrSL:$t,rotrSH:Rt,rotrSL:Kt,rotrBH:qt,rotrBL:Ft,rotr32H:Xt,rotr32L:Gt,rotlSH:zt,rotlSL:Wt,rotlBH:Yt,rotlBL:Jt,add:Qt,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)},A=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),u=new Uint32Array(32);function P(e,t,n,r,s,o){const i=s[o],c=s[o+1];let h=u[2*e],p=u[2*e+1],d=u[2*t],l=u[2*t+1],a=u[2*n],y=u[2*n+1],f=u[2*r],v=u[2*r+1],b=k.add3L(h,d,i);p=k.add3H(b,p,l,c),h=b|0,{Dh:v,Dl:f}={Dh:v^p,Dl:f^h},{Dh:v,Dl:f}={Dh:k.rotr32H(v,f),Dl:k.rotr32L(v,f)},{h:y,l:a}=k.add(y,a,v,f),{Bh:l,Bl:d}={Bh:l^y,Bl:d^a},{Bh:l,Bl:d}={Bh:k.rotrSH(l,d,24),Bl:k.rotrSL(l,d,24)},u[2*e]=h,u[2*e+1]=p,u[2*t]=d,u[2*t+1]=l,u[2*n]=a,u[2*n+1]=y,u[2*r]=f,u[2*r+1]=v}function V(e,t,n,r,s,o){const i=s[o],c=s[o+1];let h=u[2*e],p=u[2*e+1],d=u[2*t],l=u[2*t+1],a=u[2*n],y=u[2*n+1],f=u[2*r],v=u[2*r+1],b=k.add3L(h,d,i);p=k.add3H(b,p,l,c),h=b|0,{Dh:v,Dl:f}={Dh:v^p,Dl:f^h},{Dh:v,Dl:f}={Dh:k.rotrSH(v,f,16),Dl:k.rotrSL(v,f,16)},{h:y,l:a}=k.add(y,a,v,f),{Bh:l,Bl:d}={Bh:l^y,Bl:d^a},{Bh:l,Bl:d}={Bh:k.rotrBH(l,d,63),Bl:k.rotrBL(l,d,63)},u[2*e]=h,u[2*e+1]=p,u[2*t]=d,u[2*t+1]=l,u[2*n]=a,u[2*n+1]=y,u[2*r]=f,u[2*r+1]=v}class Zt extends Mt{constructor(t={}){super(128,t.dkLen===void 0?64:t.dkLen,t,64,16,16),this.v0l=A[0]|0,this.v0h=A[1]|0,this.v1l=A[2]|0,this.v1h=A[3]|0,this.v2l=A[4]|0,this.v2h=A[5]|0,this.v3l=A[6]|0,this.v3h=A[7]|0,this.v4l=A[8]|0,this.v4h=A[9]|0,this.v5l=A[10]|0,this.v5h=A[11]|0,this.v6l=A[12]|0,this.v6h=A[13]|0,this.v7l=A[14]|0,this.v7h=A[15]|0;const n=t.key?t.key.length:0;if(this.v0l^=this.outputLen|n<<8|65536|1<<24,t.salt){const r=te(Y(t.salt));this.v4l^=D(r[0]),this.v4h^=D(r[1]),this.v5l^=D(r[2]),this.v5h^=D(r[3])}if(t.personalization){const r=te(Y(t.personalization));this.v6l^=D(r[0]),this.v6h^=D(r[1]),this.v7l^=D(r[2]),this.v7h^=D(r[3])}if(t.key){const r=new Uint8Array(this.blockLen);r.set(Y(t.key)),this.update(r)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:s,v2l:o,v2h:i,v3l:c,v3h:h,v4l:p,v4h:d,v5l:l,v5h:a,v6l:y,v6h:f,v7l:v,v7h:b}=this;return[t,n,r,s,o,i,c,h,p,d,l,a,y,f,v,b]}set(t,n,r,s,o,i,c,h,p,d,l,a,y,f,v,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=h|0,this.v4l=p|0,this.v4h=d|0,this.v5l=l|0,this.v5h=a|0,this.v6l=y|0,this.v6h=f|0,this.v7l=v|0,this.v7h=b|0}compress(t,n,r){this.get().forEach((h,p)=>u[p]=h),u.set(A,16);let{h:s,l:o}=k.fromBig(BigInt(this.length));u[24]=A[8]^o,u[25]=A[9]^s,r&&(u[28]=~u[28],u[29]=~u[29]);let i=0;const c=Ht;for(let h=0;h<12;h++)P(0,4,8,12,t,n+2*c[i++]),V(0,4,8,12,t,n+2*c[i++]),P(1,5,9,13,t,n+2*c[i++]),V(1,5,9,13,t,n+2*c[i++]),P(2,6,10,14,t,n+2*c[i++]),V(2,6,10,14,t,n+2*c[i++]),P(3,7,11,15,t,n+2*c[i++]),V(3,7,11,15,t,n+2*c[i++]),P(0,5,10,15,t,n+2*c[i++]),V(0,5,10,15,t,n+2*c[i++]),P(1,6,11,12,t,n+2*c[i++]),V(1,6,11,12,t,n+2*c[i++]),P(2,7,8,13,t,n+2*c[i++]),V(2,7,8,13,t,n+2*c[i++]),P(3,4,9,14,t,n+2*c[i++]),V(3,4,9,14,t,n+2*c[i++]);this.v0l^=u[0]^u[16],this.v0h^=u[1]^u[17],this.v1l^=u[2]^u[18],this.v1h^=u[3]^u[19],this.v2l^=u[4]^u[20],this.v2h^=u[5]^u[21],this.v3l^=u[6]^u[22],this.v3h^=u[7]^u[23],this.v4l^=u[8]^u[24],this.v4h^=u[9]^u[25],this.v5l^=u[10]^u[26],this.v5h^=u[11]^u[27],this.v6l^=u[12]^u[28],this.v6h^=u[13]^u[29],this.v7l^=u[14]^u[30],this.v7h^=u[15]^u[31],u.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 le=jt(e=>new Zt(e)),Fe=new TextEncoder().encode("SS58PRE"),he=2,en=e=>{try{const t=Ne.decode(e),n=t.subarray(0,t[0]&64?2:1),r=t.subarray(n.length,t.length-he),s=t.subarray(n.length+r.length),o=le(Uint8Array.of(...Fe,...n,...r),{dkLen:64}).subarray(0,he);return s[0]===o[0]&&s[1]===o[1]?{isValid:!0,ss58Format:tn(n),publicKey:r.slice()}:{isValid:!1}}catch{return{isValid:!1}}},tn=e=>{const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return t.byteLength===1?t.getUint8(0):t.getUint16(0)},nn=e=>{const t=e<64?Uint8Array.of(e):Uint8Array.of((e&252)>>2|64,e>>8|(e&3)<<6);return n=>{const r=le(Uint8Array.of(...Fe,...t,...n),{dkLen:64}).subarray(0,he);return Ne.encode(Uint8Array.of(...t,...n,...r))}};function rn(e,t){return n=>{const r=en(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 sn=(e=42,t=32)=>me(K(t),rn(t),nn(e)),Xe="0123456789abcdef";function N(e){const t=new Array(e.length+1);t[0]="0x";for(let n=0;n<e.length;){const r=e[n++];t[n]=Xe[r>>4]+Xe[r&15]}return t.join("")}const de={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,s=new Uint8Array(r);t&&(s[0]=0|de[e[2]]);for(let o=0;o<r;){const i=n+o*2,c=de[e[i]],h=de[e[i+1]];s[t+o++]=c<<4|h}return s}const Ge=(...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},g=T,on=T,ze=e=>{const t=K.enc(e);return n=>t(J(n))},We=e=>{const t=K.dec(e);return n=>N(t(n))},Q=e=>B(ze(e),We(e));Q.enc=ze,Q.dec=We;const j=E(U),Ye=S(U),cn=q({bool:x,char:x,str:x,u8:x,u16:x,u32:x,u64:x,u128:x,u256:x,i8:x,i16:x,i32:x,i64:x,i128:x,i256:x}),Je=E(w({name:Ye,type:g,typeName:Ye,docs:j})),an=w({len:M,type:g}),un=w({bitStoreType:g,bitOrderType:g}),ln=E(w({name:U,fields:Je,index:I,docs:j})),hn=q({composite:Je,variant:ln,sequence:g,array:an,tuple:E(g),primitive:cn,compact:g,bitSequence:un}),dn=w({name:U,type:S(g)}),fn=E(dn),vn=w({id:g,path:j,params:fn,def:hn,docs:j}),Qe=E(vn),pn=q({Blake2128:x,Blake2256:x,Blake2128Concat:x,Twox128:x,Twox256:x,Twox64Concat:x,Identity:x}),gn=E(pn),yn=w({hashers:gn,key:g,value:g}),mn=w({name:U,modifier:I,type:q({plain:g,map:yn}),fallback:Q(),docs:j}),wn=S(w({prefix:U,items:E(mn)})),Ze={name:U,storage:wn,calls:S(g),events:S(g),constants:E(w({name:U,type:g,value:Q(),docs:j})),errors:S(g),index:I},bn={...Ze,docs:j},xn=new Uint8Array,et=e=>B(()=>xn,()=>e),En=w({type:g,version:I,signedExtensions:E(w({identifier:U,type:g,additionalSigned:g}))}),An=w({lookup:Qe,pallets:E(w({...Ze,docs:et([])})),extrinsic:En,type:g,apis:et([])}),Bn=w({name:U,methods:E(w({name:U,inputs:E(w({name:U,type:g})),output:g,docs:j})),docs:j}),kn=w({version:I,address:g,call:g,signature:g,extra:g,signedExtensions:E(w({identifier:U,type:g,additionalSigned:g}))}),In=w({lookup:Qe,pallets:E(w(bn)),extrinsic:kn,type:g,apis:E(Bn),outerEnums:w({call:g,event:g,error:g}),custom:E(X(U,w({type:g,value:Q()})))}),tt=()=>{throw new Error("Unsupported metadata version!")},L=B(tt,tt),re=w({magicNumber:M,metadata:q({v0:L,v1:L,v2:L,v3:L,v4:L,v5:L,v6:L,v7:L,v8:L,v9:L,v10:L,v11:L,v12:L,v13:L,v14:An,v15:In})}),fe=K(),Un=S(fe),Ln=X(T,fe),Tn=e=>{try{return re.dec(e)}catch{}try{return re.dec(Un.dec(e))}catch{}try{return re.dec(fe.dec(e))}catch{}try{return re.dec(Ln.dec(e)[1])}catch{}throw null},_n={dkLen:32},Sn=e=>le(e,_n),nt=(e,t)=>e.type==="array"&&e.len===t&&e.value.type==="primitive"&&e.value.value==="u8",$={type:"void"},Cn=(e,t=()=>null)=>{const n=new Map,r=new Set,s=d=>l=>{let a=n.get(l);if(a)return a;if(r.has(l)){const f={id:l};return n.set(l,f),f}r.add(l);const y=d(l);return a=n.get(l),a?Object.assign(a,y):(a={id:l,...y},n.set(l,a)),r.delete(l),a};let o=!0,i=!0;const c=s(d=>{const l=t(e[d]);if(l)return l;const{def:a,path:y,params:f}=e[d];if(a.tag==="composite"){if(a.value.length===0)return $;if(a.value.length===1){const v=c(a.value[0].type);return o&&y.at(-1)==="AccountId32"&&nt(v,32)?(o=!1,{type:"AccountId32"}):i&&y.at(-1)==="AccountId20"&&nt(v,20)?(i=!1,{type:"AccountId20"}):v}return h(a.value)}if(a.tag==="variant"){if(y.length===1&&y[0]==="Option"&&f.length===1&&f[0].name==="T"){const m=c(f[0].type);return m.type==="void"?{type:"primitive",value:"bool"}:{type:"option",value:m}}if(y.length===1&&y[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(a.value.length===0)return $;const v={},b={};return a.value.forEach(m=>{const C=m.name;if(b[C]=m.docs,m.fields.length===0){v[C]={...$,idx:m.index};return}if(m.fields.length===1&&!m.fields[0].name){v[C]={type:"lookupEntry",value:c(m.fields[0].type),idx:m.index};return}v[C]={...h(m.fields),idx:m.index}}),{type:"enum",value:v,innerDocs:b}}if(a.tag==="sequence")return{type:"sequence",value:c(a.value)};if(a.tag==="array"){const{len:v}=a.value,b=c(a.value.type);return!v||b.type==="void"?$:v>1?{type:"array",value:b,len:a.value.len}:b}if(a.tag==="tuple")return a.value.length===0?$:a.value.length>1?p(a.value.map(v=>c(v)),a.value.map(v=>e[v].docs)):c(a.value[0]);if(a.tag==="primitive")return{type:"primitive",value:a.value.tag};if(a.tag==="compact"){const v=c(a.value);return v.type==="void"?$:{type:"compact",isBig:Number(v.value.slice(1))>32,size:v.value}}return{type:a.tag}}),h=d=>{let l=!0;const a={},y={};return d.forEach((f,v)=>{l=l&&!!f.name;const b=f.name||v,m=c(f.type);m.type!=="void"&&(a[b]=m,y[b]=f.docs)}),l?{type:"struct",value:a,innerDocs:y}:p(Object.values(a),Object.values(y))},p=(d,l)=>{if(d.every(a=>a.id===d[0].id)&&l.every(a=>!a.length)){const[a]=d;return a.type==="void"?$:{type:"array",value:d[0],len:d.length}}return{type:"tuple",value:d,innerDocs:l}};return c},On=e=>{const t=Cn(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?{...$,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})},Dn=oe(I.enc,e=>+!!e.signed<<7|e.version),ve=()=>new Error("Unkown signer"),jn=e=>{const{extrinsic:t}=e,n=On(e);let r,s;if("address"in t)r=n(t.address),s=n(t.signature);else{const o=Object.fromEntries(e.lookup[t.type].params.filter(i=>i.type!=null).map(i=>[i.name,n(i.type)]));if(r=o.Address,s=o.Signature,!r||!s)throw ve()}if(r.type==="AccountId20"&&s.type==="array"&&s.len===65&&s.value.type==="primitive"&&s.value.value==="u8")return[1,[]];if(s.type!=="enum"||["Ecdsa","Ed25519","Sr25519"].some(o=>!(o in s.value)))throw ve();if(r.type==="enum"){const o=r.value.Id;if(o.type==="lookupEntry"&&o.value.type==="AccountId32")return[0,[o.idx]]}else if(r.type==="AccountId32")return[0,[]];throw ve()},Hn=(e,t,n,r,s,o)=>{const[i,c]=jn(e),h=Ge(Dn({signed:!0,version:4}),i===1?t:new Uint8Array([...c,...t]),n,...r,s);return Ge(T.enc(h.length),h)},z=(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},Mn=({additionalSigned:e})=>({genesisHash:N(e)}),Pn=({value:e})=>({nonce:z(T.dec(e),4)}),Vn=({additionalSigned:e})=>({transactionVersion:z(M.dec(e),4)}),Nn=w({tip:T,asset:S(K(1/0))}).dec;var rt=Object.freeze({__proto__:null,ChargeAssetTxPayment:({value:e})=>{const{tip:t,asset:n}=Nn(e);return{...n?{assetId:N(n)}:{},tip:z(t,16)}},ChargeTransactionPayment:({value:e})=>({tip:z(on.dec(e),16)}),CheckGenesis:Mn,CheckMetadataHash:({value:e,additionalSigned:t})=>e.length&&e[0]?{mode:1,metadataHash:N(t.length?t.slice(1):t)}:{},CheckMortality:({value:e,additionalSigned:t},n)=>({era:N(e),blockHash:N(t),blockNumber:z(n,4)}),CheckNonce:Pn,CheckSpecVersion:({additionalSigned:e})=>({specVersion:z(M.dec(e),4)}),CheckTxVersion:Vn});const $n=sn().enc,Rn=e=>e.startsWith("0x")?J(e):$n(e);function st(e,t,n){const r=i=>n({address:e,data:N(i),type:"bytes"}).then(({signature:c})=>J(c)),s=Rn(e);return{publicKey:s,signTx:async(i,c,h,p,d=Sn)=>{let l;try{const m=Tn(h);if(m.metadata.tag!=="v14"&&m.metadata.tag!=="v15")throw null;l=m.metadata.value}catch{throw new Error("Unsupported metadata version")}const a={};a.signedExtensions=[];const{version:y}=l.extrinsic,f=[];l.extrinsic.signedExtensions.map(({identifier:m})=>{const C=c[m];if(!C)throw new Error(`Missing ${m} signed-extension`);if(f.push(C.value),a.signedExtensions.push(m),!rt[m]){if(C.value.length===0&&C.additionalSigned.length===0)return;throw new Error(`PJS does not support this signed-extension: ${m}`)}Object.assign(a,rt[m](C,p))}),a.address=e,a.method=N(i),a.version=y,a.withSignedTransaction=!0;const v=await t(a),b=v.signedTransaction;return b?typeof b=="string"?J(b):b:Hn(l,s,J(v.signature),f,i)},signBytes:r}}const Kn=new Set(["ed25519","sr25519","ecdsa","ethereum"]),qn=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})=>Kn.has(l)).map(l=>{const a=st(l.address,s,o);return{...l,polkadotSigner:a}});let c=i(await r.accounts.get());const h=new Set,p=r.accounts.subscribe(d=>{c=i(d),h.forEach(l=>{l(c)})});return{name:e,getAccounts:()=>c,subscribe:d=>(h.add(d),()=>{h.delete(d)}),disconnect:()=>{p()}}},Fn=()=>{const{injectedWeb3:e}=window;return e?Object.keys(e):[]};R.connectInjectedExtension=qn,R.getInjectedExtensions=Fn,R.getPolkadotSignerFromPjs=st});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_,
|
|
1
|
+
(function(_,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(_=typeof globalThis<"u"?globalThis:_||self,O(_.papiPolkadotSdkCompat={}))})(this,function(_){"use strict";const O=p=>{let i=null;const{send:o,disconnect:c}=p(d=>{i?.(JSON.parse(d))});return d=>(i=d,{send(f){o(JSON.stringify(f))},disconnect(){i=null,c()}})},C=p=>{let i=null;const{send:o,disconnect:c}=p(d=>{i?.(JSON.stringify(d))});return d=>(i=d,{send(f){o(JSON.parse(f))},disconnect(){i=null,c()}})},g=(...p)=>i=>C(p.reduce((o,c)=>c(o),O(i))),S={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},D={broadcast:"",stop:""},B={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:S,chainSpec:B,transaction:D}).forEach(([p,i])=>{Object.keys(i).forEach(o=>{i[o]=`${p}_v1_${o}`})});var F=Object.freeze({__proto__:null,chainHead:S,chainSpec:B,transaction:D});const W=p=>i=>{const{send:o,disconnect:c}=p(i);return{send:f=>{switch(f.method){case B.chainName:return o({...f,method:"system_chain"});case B.genesisHash:return o({...f,method:"chain_getBlockHash",params:[0]});case B.properties:return o({...f,method:"system_properties"})}o(f)},disconnect:c}},z=p=>i=>{const o=new Set,c=new Map,d=new Map,{send:f,disconnect:u}=p(a=>{if("id"in a){i(a);const{id:t,result:e}=a;if(o.has(t)){o.delete(t),c.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:t}=a.params,e=c.get(t),n=d.get(t);if(e){const s=a.params.result,{event:r}=s;if(r==="initialized"&&s.finalizedBlockHashes.forEach(l=>{e.add(l)}),r==="newBlock"){const{parentBlockHash:l}=s;if(!e.has(l)){const h=n.get(l)??[];h.push(a),n.set(l,h);return}const k=s.blockHash;e.add(s.blockHash),i(a);const w=n.get(k);w&&(n.delete(k),w.forEach(h=>{e.add(h.params.result.blockHash),i(h)}));return}r==="stop"&&(e.delete(t),d.delete(t))}i(a)}});return{send:a=>{const t=a.params[0];switch(a.method){case S.follow:o.add(a.id);break;case S.unpin:const[e,n]=a.params;n.forEach(s=>{c.get(e)?.delete(s),d.get(e)?.delete(s)});break;case S.unfollow:c.delete(t),d.delete(t);break}f(a)},disconnect:u}},y=p=>({jsonrpc:"2.0",...p}),N=(p,i,o,c={})=>y({method:"chainHead_v1_followEvent",params:{subscription:p,result:{event:i,operationId:o,...c}}}),L="__INNER_RQ_DesV",Q=p=>{let i=0;const o=new Map,c=({id:b,error:a,result:t})=>{const e=o.get(b);return e&&(o.delete(b),a?e(!1,a):e(!0,t)),!e};let d=()=>{};return[b=>{const{send:a,disconnect:t}=p(e=>{c(e)&&b(e)});return d=a,{send:d,disconnect:()=>{o.clear(),t()}}},(b,a,t,e)=>{const n=L+i++;o.set(n,(s,r)=>{(s?t:e)(r)}),d(y({id:n,method:b,params:a}))}]},Z="__INNER_OP_DesV";let X=0;const R=p=>i=>{const[o,c]=Q(p),d=Y(c),f=new Map,u=new Map,{send:b,disconnect:a}=o(n=>{if("id"in n){const s=f.get(n.id);s&&(f.delete(n.id),n.result.result==="started"&&s(n.result.operationId))}else if(n.params){const{subscription:s,result:r}=n.params,{operationId:l}=r||{},k=u.get(s);k&&r.event==="stop"&&(k.forEach(h=>{h.cancel()}),u.delete(s));const w=k?.get(l);if(w)switch(r.event){case"operationInaccessible":case"operationError":w.cancel();break;case"operationStorageDone":if(w.isInnerDone)k.delete(l);else{w.isOutterDone=!0;return}}}i(n)}),t=(n,s,r)=>l=>{let k=()=>{};u.has(n)||u.set(n,new Map);const w=u.get(n),h={isOutterDone:!1,isInnerDone:!1,cancel:()=>{k()}};w.set(l,h);let H=0;const v=r.map(E=>d(E,s,I=>{i(N(n,"operationStorageItems",l,{items:I.map(([M,U])=>({key:M,value:U}))}))},I=>{k(),h.isOutterDone||b(y({method:"chainHead_v1_stopOperation",params:[l]})),i(N(n,"operationError",l,{error:typeof I=="string"?I:JSON.stringify(I)}))},()=>{++H===r.length&&(h.isOutterDone?(k(),i(N(n,"operationStorageDone",l))):h.isInnerDone=!0)}));k=()=>{w.delete(l),v.forEach(E=>E())}};return{send:n=>{switch(n.method){case S.storage:{const[s,r,l]=n.params,k=[],w=l.filter(H=>{const v=H.type==="descendantsValues";return v&&k.push(H.key),!v}),h=t(s,r,k);if(w.length)k.length&&f.set(n.id,h);else{const H=Z+X++;i(y({id:n.id,result:{result:"started",operationId:H}})),h(H),u.get(s).get(H).isOutterDone=!0;return}n.params[2]=w;break}case S.stopOperation:{const[s,r]=n.params,l=u.get(s)?.get(r);if(l&&(l.cancel(),l.isOutterDone))return;break}case S.unfollow:{const[s]=n.params;u.get(s)?.forEach(r=>r.cancel()),u.delete(s);break}}b(n)},disconnect:a}},Y=p=>(i,o,c,d,f)=>{let u=!0,b=!1,a=0;const t=s=>{u&&(u=!1,d(s))},e=1e3,n=s=>{p("state_getKeysPaged",[i,e,s||void 0,o],r=>{u&&(r.length>0&&(a++,p("state_queryStorageAt",[r,o],([{changes:l}])=>{u&&(a--,c(l),b&&!a&&f())},t)),r.length<e?(b=!0,a||f()):n(r.at(-1)))},t)};return n(),()=>{u=!1}},V=p=>i=>{const o=new Set,c=new Map,d=new Map,{send:f,disconnect:u}=p(a=>{if("id"in a){i(a);const{id:t,result:e}=a;if(o.has(t)){o.delete(t),c.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:t}=a.params,e=c.get(t),n=d.get(t);if(e){const s=a.params.result,{event:r}=s;if(r==="initialized"&&s.finalizedBlockHashes.forEach(l=>{e.add(l)}),r==="finalized"&&(s.prunedBlockHashes=s.prunedBlockHashes.filter(l=>{e.has(l)})),r==="newBlock"){e.add(s.blockHash);const l=s.blockHash,k=n.get(l);if(k){n.delete(l),i(a),Promise.resolve().then(()=>{i(k)});return}}if(r==="bestBlockChanged"){const l=s.bestBlockHash;if(!e.has(l)){d.get(t).set(l,a);return}}r==="stop"&&(e.delete(t),d.delete(t))}i(a)}});return{send:a=>{const t=a.params[0];switch(a.method){case S.follow:o.add(a.id);break;case S.unpin:const[e,n]=a.params;n.forEach(s=>{c.get(e)?.delete(s),d.get(e)?.delete(s)});break;case S.unfollow:c.delete(t),d.delete(t);break}f(a)},disconnect:u}},ee=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(p=>"operation"+p)),$=p=>ee.has(p.params?.result?.event),j=p=>i=>{const o=new Set,c=new Map,d=new Map,f=new Map,{send:u,disconnect:b}=p(t=>{if("id"in t){i(t);const{id:e,result:n}=t;if(o.has(e)){o.delete(e),d.set(n,new Set),f.set(n,new Map);return}const s=c.get(e);if(s!==void 0){c.delete(e);const r=t.result?.operationId;if(r!==void 0&&d.has(s)){const l=d.get(s);l.add(r);const k=f.get(s)?.get(r);k&&(k.forEach(i),f.get(s).delete(r),$(k.at(-1))&&l.delete(r))}}}else{const{subscription:e,result:n}=t.params,s=d.get(e);if(s){const{operationId:r}=t.params.result;if(r!==void 0)if(s.has(r))$(t)&&s.delete(r);else{const l=f.get(e),k=l.get(r)??[];k.push(t),l.set(r,k);return}else n?.event==="stop"&&(d.delete(e),f.delete(e))}i(t)}});return{send:t=>{const e=t.params[0];switch(t.method){case S.follow:o.add(t.id);break;case S.body:case S.call:case S.storage:c.set(t.id,e);break;case S.unfollow:d.delete(e),f.delete(e);break;case S.stopOperation:d.get(e)?.delete(t.params[1])}u(t)},disconnect:b}},m=p=>i=>p(o=>{const c=o.params?.result;if(!("id"in o)&&c){const{prunedBlockHashes:d,finalizedBlockHash:f,event:u}=c;u==="finalized"&&Array.isArray(d)?c.prunedBlockHashes=[...new Set(c.prunedBlockHashes)]:u==="initialized"&&f&&(c.finalizedBlockHashes=[c.finalizedBlockHash],delete c.finalizedBlockHash)}i(o)}),A=p=>i=>{const{send:o,disconnect:c}=p(i);return{send:f=>{const{method:u,params:b,id:a,...t}=f;u==S.unpin&&b&&Array.isArray(b[1])?b[1].forEach((e,n)=>{o({...t,id:n===0?a:`${a}-patched-${n}`,method:u,params:[b[0],e]})}):o(f)},disconnect:c}},G=p=>({jsonrpc:"2.0",...p}),[P]=D.stop.split("_"),T="unstable",q="rpc_methods",x="__INTERNAL_ID",J=p=>i=>{let o=!0,c=[],d=e=>{c.push(e)},f=({id:e,result:n,error:s})=>{if(e!==x||!o)return;if(!n){if(console.error(s),a<4){setTimeout(t,200);return}n={methods:[]}}const r=new Set(n.methods),l={};[S,B,D].forEach(w=>{Object.values(w).forEach(h=>{if(r.has(h))l[h]=h;else{const[H,,v]=h.split("_"),E=`${H}_${T}_${v}`;if(r.has(E))l[h]=E,r.delete(E),r.add(h);else if(l[h]=null,H===P){let I;const M=h==="stop"?"unwatch":"submitAndWatch";[P+"Watch",P].find(ne=>["v1",T].find(se=>r.has(I=`${ne}_${se}_${M}`)))&&(l[h]=I,r.add(h))}}})}),f=i;const k=({method:w,...h})=>{if(w===q){Promise.resolve().then(()=>{i(G({id:h.id,result:{methods:[...r]}}))});return}const H=l[w];H===null?Promise.resolve().then(()=>{i({error:{code:-32603,message:`Method not found: ${w}`},id:h.id})}):u({method:H||w,...h})};for(let w=0;o&&w<c.length;w++)k(c[w]);c=[],o&&(d=k)};const{send:u,disconnect:b}=p(e=>{f(e)});let a=0;const t=()=>{a++,u(G({id:x,method:q,params:[]}))};return t(),{send:e=>{d(e)},disconnect(){o=!1,d=f=()=>{},c=[],b()}}},K=p=>i=>{let o=0;const c=new Map,{send:d,disconnect:f}=p(u=>{c.has(u.id)&&(u.id=c.get(u.id)),i(u)});return{send:u=>{if("id"in u){const b=o++;c.set(b,u.id),u.id=b}d(u)},disconnect:f}},te=g(K,J,j,A,m,z,V,W,R);_.fixDescendantValues=R,_.fixPrematureBlocks=z,_.fixUnorderedBlocks=V,_.fixUnorderedEvents=j,_.fromParsed=C,_.methods=F,_.parsed=g,_.patchChainHeadEvents=m,_.toParsed=O,_.translate=J,_.unpinHash=A,_.withNumericIds=K,_.withPolkadotSdkCompat=te});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(v,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(v=typeof globalThis<"u"?globalThis:v||self,C(v.papiWsProviderWeb={}))})(this,function(v){"use strict";const C=o=>JSON.stringify({jsonrpc:"2.0",...o}),I=new Set(["v1","unstable"].map(o=>`chainHead_${o}_unfollow`)),_=o=>{let e={type:1,pending:[]};const r=t=>{if(e.type===0){const n=JSON.parse(t);if("id"in n)"result"in n&&e.onGoingRequests.get(n.id)?.type===0&&e.activeChainHeads.add(n.result),e.onGoingRequests.delete(n.id);else if("params"in n){const{subscription:l,result:i}=n.params;i?.event==="stop"&&e.activeChainHeads.delete(l)}}e.type!==2&&o(t)},s=t=>{if(e.type===2)return;if(e.type===1){e.pending.push(t);return}const n=JSON.parse(t);if(I.has(n.method)&&e.activeChainHeads.delete(n.params[0]),"id"in n){const{method:l,id:i}=n,E=l.startsWith("chainHead")?l.endsWith("follow")?{type:0,msg:t}:{type:1,id:i}:{type:2,msg:t};e.onGoingRequests.set(i,E)}e.connection.send(t)};return{send:s,disconnect:()=>{e.type!==2&&(e.type===0&&e.connection.disconnect(),e={type:2})},connect:t=>{if(e.type!==1)throw new Error("Nonesense");const{pending:n}=e,l=new Map,i=new Set;e={type:0,connection:t(r,()=>{e={type:1,pending:[]},i.forEach(c=>{r(C({params:{subscription:c,result:{event:"stop",internal:!0}}}))}),i.clear();for(const c of l.values())c.type===1?r(C({id:c.id,error:{code:-32603,message:"Internal error"},internal:!0})):s(c.msg);l.clear()}),onGoingRequests:l,activeChainHeads:i},n.forEach(s)}}},$=o=>e=>{let r=_(e);const s=()=>{o().then(t=>{if(r)r.connect((n,l)=>t(n,()=>{l(),s()}));else try{t(()=>{},()=>{}).disconnect()}catch{}},()=>{r&&setTimeout(s,0)})};return s(),{send:t=>{r?.send(t)},disconnect:()=>{r?.disconnect(),r=null}}};var u=(o=>(o[o.CONNECTING=0]="CONNECTING",o[o.CONNECTED=1]="CONNECTED",o[o.ERROR=2]="ERROR",o[o.CLOSE=3]="CLOSE",o))(u||{});const L={};["v1","unstable"].forEach(o=>{L[`chainHead_${o}_follow`]="follow",L[`chainHead_${o}_unfollow`]="unfollow"});const M=(o,e)=>{const r=new Set,s=new Map,t=new Set;return Object.assign(l=>{const{send:i,disconnect:E}=o(c=>{const f=JSON.parse(c);if("id"in f){const{id:d,result:m}=f,h=s.get(d);if(h){if(s.delete(d),r.has(m)){r.delete(m);return}t.add(m);const y=t.size+s.size;if(y>2)console.warn(`Too many chainHead follow subscriptions (${y})`);else if(f.error){console.warn(`chainHead follow failed on the ${y} sub`),e(),s.set(d,h),i(h);return}}}else{const{subscription:d,result:m}=f.params;m?.event==="stop"&&(t.has(d)?t.delete(d):r.add(d))}l(c)});return{send(c){const f=JSON.parse(c),d=L[f.method];d==="follow"?s.set(f.id,c):d==="unfollow"&&t.delete(f.params[0]),i(c)},disconnect:E}},{cleanup:()=>{r.clear(),s.clear(),t.clear()}})},b={type:u.ERROR,event:{type:"timeout"}},g=()=>{},G=o=>o.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),P=(o=>(...e)=>{let r=[],s=g,t=3500;const[n]=e;e.length===1&&typeof n=="object"&&!Array.isArray(n)?(r=G(n.endpoints),s=n.onStatusChanged??g,t=n.timeout??t):(typeof e[1]=="function"&&(s=e[1]),Array.isArray(n)?r=G(n):(r=[[n]],e[1]&&e[1]!==s&&(r[0][1]=e[1]),e[2]&&(s=e[2])));let l=0,i,E=null,c=g,f=g;const d=M($(async()=>{const[h,y]=E||r[l++%r.length];E=null;const p=new o(h,y),T=()=>{try{p.addEventListener("error",g,{once:!0}),p.close()}catch{}};return s(i={type:u.CONNECTING,uri:h,protocols:y}),await new Promise((H,S)=>{const R=()=>{w(),H()},O=a=>{w(),a==null&&T(),console.error(`Unable to connect to ${h}${y?", protocols: "+y:""}`),s(i={type:a?u.ERROR:u.CLOSE,event:a}),setTimeout(S,a?300:0,a)},N=t!==1/0?setTimeout(()=>{w(),T(),s(i=b),S(b.event)},t):void 0,w=()=>{clearTimeout(N),p.removeEventListener("error",O),p.removeEventListener("open",R)};p.addEventListener("open",R),p.addEventListener("error",O),c=()=>{O(null)}}),s(i={type:u.CONNECTED,uri:h,protocols:y}),(H,S)=>{const R=a=>{typeof a.data=="string"&&H(a.data)},O=a=>j=>{console.warn(`WS halt (${a})`),s(i={type:a,event:j}),S()},N=O(u.ERROR),w=O(u.CLOSE);return p.addEventListener("message",R),p.addEventListener("error",N),p.addEventListener("close",w),c=a=>{f(),c=g,p.removeEventListener("message",R),p.removeEventListener("error",N),p.removeEventListener("close",w),T(),a&&w({})},{send:a=>{p.send(a)},disconnect:c}}}),()=>{m()});f=d.cleanup,delete d.cleanup;const m=(...h)=>{i.type!==u.CLOSE&&(h.length&&(E=h),i.type!==u.ERROR&&c(!0))};return Object.assign(d,{switch:m,getStatus:()=>i})})(WebSocket);v.WsEvent=u,v.getWsProvider=P});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -192,24 +192,24 @@
|
|
|
192
192
|
},
|
|
193
193
|
"dependencies": {
|
|
194
194
|
"@rx-state/core": "^0.1.4",
|
|
195
|
-
"@polkadot-api/cli": "0.10.
|
|
195
|
+
"@polkadot-api/cli": "0.10.1",
|
|
196
196
|
"@polkadot-api/ink-contracts": "0.2.4",
|
|
197
197
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
198
|
-
"@polkadot-api/known-chains": "0.6.
|
|
198
|
+
"@polkadot-api/known-chains": "0.6.1",
|
|
199
199
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
200
200
|
"@polkadot-api/metadata-builders": "0.10.0",
|
|
201
201
|
"@polkadot-api/metadata-compatibility": "0.1.14",
|
|
202
202
|
"@polkadot-api/observable-client": "0.7.0",
|
|
203
203
|
"@polkadot-api/pjs-signer": "0.6.3",
|
|
204
|
+
"@polkadot-api/polkadot-sdk-compat": "2.3.1",
|
|
204
205
|
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
205
206
|
"@polkadot-api/signer": "0.1.13",
|
|
206
|
-
"@polkadot-api/polkadot-sdk-compat": "2.3.1",
|
|
207
207
|
"@polkadot-api/sm-provider": "0.1.7",
|
|
208
208
|
"@polkadot-api/smoldot": "0.3.8",
|
|
209
209
|
"@polkadot-api/substrate-bindings": "0.11.0",
|
|
210
|
+
"@polkadot-api/substrate-client": "0.3.0",
|
|
210
211
|
"@polkadot-api/utils": "0.1.2",
|
|
211
|
-
"@polkadot-api/ws-provider": "0.3.6"
|
|
212
|
-
"@polkadot-api/substrate-client": "0.3.0"
|
|
212
|
+
"@polkadot-api/ws-provider": "0.3.6"
|
|
213
213
|
},
|
|
214
214
|
"devDependencies": {
|
|
215
215
|
"rxjs": "^7.8.1",
|