edge-currency-accountbased 2.7.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/android/src/main/assets/edge-currency-accountbased/4013.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/5336.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
- package/lib/filecoin/FilecoinEngine.js +101 -34
- package/lib/filecoin/FilecoinTools.js +9 -2
- package/lib/filecoin/Filfox.js +52 -3
- package/lib/filecoin/calibrationInfo.js +89 -0
- package/lib/filecoin/filecoinInfo.js +1 -0
- package/lib/filecoin/filecoinTypes.js +1 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 2.8.0 (2023-10-23)
|
|
6
|
+
|
|
7
|
+
- added: Filecoin Testnet (Calibration)
|
|
8
|
+
- changed: Improved Filecoin transaction syncing
|
|
9
|
+
- fixed: Missing Filecoin transactions caused by external messages for the account (e.g. FILForwarder)
|
|
10
|
+
|
|
5
11
|
## 2.7.2 (2023-10-20)
|
|
6
12
|
|
|
7
13
|
- added: Add deprecated `memoType` to zcashInfo for backwards compatibility
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var Oe=Object.defineProperty;var Ke=(Q,t,A)=>t in Q?Oe(Q,t,{enumerable:!0,configurable:!0,writable:!0,value:A}):Q[t]=A;var F=(Q,t,A)=>(Ke(Q,typeof t!="symbol"?t+"":t,A),A);(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4013],{77235:function(Q,t,A){"use strict";var x=A(48764).Buffer,n=A(79656),p=A(42514),L=A(53583);function b(P){var W=Object.create(null);return P&&Object.keys(P).forEach(function(tt){if(tt!=="default"){var dt=Object.getOwnPropertyDescriptor(P,tt);Object.defineProperty(W,tt,dt.get?dt:{enumerable:!0,get:function(){return P[tt]}})}}),W.default=P,Object.freeze(W)}var e=b(n);e.utils.hmacSha256Sync=(P,...W)=>p.hmac(L.sha256,P,e.utils.concatBytes(...W)),e.utils.sha256Sync=(...P)=>L.sha256(e.utils.concatBytes(...P));const r=e.utils._normalizePrivateKey,c=32,s=32,h=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),i=32;function B(P,W){for(let tt=0;tt<32;++tt)if(P[tt]!==W[tt])return P[tt]<W[tt]?-1:1;return 0}function H(P){return!(!(P instanceof Uint8Array)||P.length!==s||B(P,h)>=0)}function j(P){return P instanceof Uint8Array&&P.length===64&&B(P.subarray(0,32),h)<0&&B(P.subarray(32,64),h)<0}function k(P){return P instanceof Uint8Array&&P.length===c}function U(P){return P===void 0||P instanceof Uint8Array&&P.length===i}function g(P){if(typeof P!="string")throw new TypeError("hexToNumber: expected string, got "+typeof P);return BigInt(`0x${P}`)}function v(P){return g(e.utils.bytesToHex(P))}function C(P){let W;if(typeof P=="bigint")W=P;else if(typeof P=="number"&&Number.isSafeInteger(P)&&P>=0)W=BigInt(P);else if(typeof P=="string"){if(P.length!==64)throw new Error("Expected 32 bytes of private scalar");W=g(P)}else if(P instanceof Uint8Array){if(P.length!==32)throw new Error("Expected 32 bytes of private scalar");W=v(P)}else throw new TypeError("Expected valid private scalar");if(W<0)throw new Error("Expected private scalar >= 0");return W}const N=(P,W)=>{const tt=r(P),dt=C(W),pt=e.utils._bigintTo32Bytes(e.utils.mod(tt+dt,e.CURVE.n));return e.utils.isValidPrivateKey(pt)?pt:null},M=(P,W)=>{const tt=r(P),dt=C(W),pt=e.utils._bigintTo32Bytes(e.utils.mod(tt-dt,e.CURVE.n));return e.utils.isValidPrivateKey(pt)?pt:null},f=P=>{const W=r(P),tt=e.utils._bigintTo32Bytes(e.CURVE.n-W);return e.utils.isValidPrivateKey(tt)?tt:null},I=(P,W,tt)=>{const dt=e.Point.fromHex(P),pt=C(W),mt=e.Point.BASE.multiplyAndAddUnsafe(dt,pt,1n);if(!mt)throw new Error("Tweaked point at infinity");return mt.toRawBytes(tt)},_=(P,W,tt)=>{const dt=e.Point.fromHex(P),pt=typeof W=="string"?W:e.utils.bytesToHex(W),mt=BigInt(`0x${pt}`);return dt.multiply(mt).toRawBytes(tt)};function O(P,W){return P===void 0?W!==void 0?T(W):!0:!!P}function l(P){try{return P()}catch{return null}}function y(P,W){if(P.length===32!==W)return!1;try{return!!e.Point.fromHex(P)}catch{return!1}}function E(P){return y(P,!1)}function T(P){return y(P,!1)&&P.length===33}function K(P){return e.utils.isValidPrivateKey(P)}function z(P){return y(P,!0)}function Z(P,W){if(!z(P))throw new Error("Expected Point");if(!H(W))throw new Error("Expected Tweak");return l(()=>{const tt=I(P,W,!0);return{parity:tt[0]%2===1?1:0,xOnlyPubkey:tt.slice(1)}})}function J(P){if(!E(P))throw new Error("Expected Point");return P.slice(1,33)}function st(P,W){if(!K(P))throw new Error("Expected Private");return l(()=>e.getPublicKey(P,O(W)))}function ut(P){if(!K(P))throw new Error("Expected Private");return J(st(P))}function q(P,W){if(!E(P))throw new Error("Expected Point");return e.Point.fromHex(P).toRawBytes(O(W,P))}function nt(P,W,tt){if(!E(P))throw new Error("Expected Point");if(!H(W))throw new Error("Expected Tweak");return l(()=>_(P,W,O(tt,P)))}function ht(P,W,tt){if(!E(P)||!E(W))throw new Error("Expected Point");return l(()=>{const dt=e.Point.fromHex(P),pt=e.Point.fromHex(W);return dt.equals(pt.negate())?null:dt.add(pt).toRawBytes(O(tt,P))})}function G(P,W,tt){if(!E(P))throw new Error("Expected Point");if(!H(W))throw new Error("Expected Tweak");return l(()=>I(P,W,O(tt,P)))}function gt(P,W){if(K(P)===!1)throw new Error("Expected Private");if(H(W)===!1)throw new Error("Expected Tweak");return l(()=>N(P,W))}function At(P,W){if(K(P)===!1)throw new Error("Expected Private");if(H(W)===!1)throw new Error("Expected Tweak");return l(()=>M(P,W))}function Et(P){if(K(P)===!1)throw new Error("Expected Private");return f(P)}function xt(P,W,tt){if(!K(W))throw new Error("Expected Private");if(!k(P))throw new Error("Expected Scalar");if(!U(tt))throw new Error("Expected Extra Data (32 bytes)");return e.signSync(P,W,{der:!1,extraEntropy:tt})}function Yt(P,W,tt=x.alloc(32,0)){if(!K(W))throw new Error("Expected Private");if(!k(P))throw new Error("Expected Scalar");if(!U(tt))throw new Error("Expected Extra Data (32 bytes)");return e.schnorr.signSync(P,W,tt)}function Ft(P,W,tt,dt){if(!E(W))throw new Error("Expected Point");if(!j(tt))throw new Error("Expected Signature");if(!k(P))throw new Error("Expected Scalar");return e.verify(tt,P,W,{strict:dt})}function Tt(P,W,tt){if(!z(W))throw new Error("Expected Point");if(!j(tt))throw new Error("Expected Signature");if(!k(P))throw new Error("Expected Scalar");return e.schnorr.verifySync(tt,P,W)}t.isPoint=E,t.isPointCompressed=T,t.isPrivate=K,t.isXOnlyPoint=z,t.pointAdd=ht,t.pointAddScalar=G,t.pointCompress=q,t.pointFromScalar=st,t.pointMultiply=nt,t.privateAdd=gt,t.privateNegate=Et,t.privateSub=At,t.sign=xt,t.signSchnorr=Yt,t.verify=Ft,t.verifySchnorr=Tt,t.xOnlyPointAddTweak=Z,t.xOnlyPointFromPoint=J,t.xOnlyPointFromScalar=ut},7973:function(Q,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.output=t.exists=t.hash=t.bytes=t.bool=t.number=void 0;function A(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}t.number=A;function x(r){if(typeof r!="boolean")throw new Error(`Expected boolean, not ${r}`)}t.bool=x;function n(r,...c){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(c.length>0&&!c.includes(r.length))throw new Error(`Expected Uint8Array of length ${c}, not of length=${r.length}`)}t.bytes=n;function p(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");A(r.outputLen),A(r.blockLen)}t.hash=p;function L(r,c=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(c&&r.finished)throw new Error("Hash#digest() has already been called")}t.exists=L;function b(r,c){n(r);const s=c.outputLen;if(r.length<s)throw new Error(`digestInto() expects output buffer of length at least ${s}`)}t.output=b;const e={number:A,bool:x,bytes:n,hash:p,exists:L,output:b};t.default=e},23449:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SHA2=void 0;const x=A(7973),n=A(82450);function p(b,e,r,c){if(typeof b.setBigUint64=="function")return b.setBigUint64(e,r,c);const s=BigInt(32),h=BigInt(4294967295),i=Number(r>>s&h),B=Number(r&h),H=c?4:0,j=c?0:4;b.setUint32(e+H,i,c),b.setUint32(e+j,B,c)}class L extends n.Hash{constructor(e,r,c,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=c,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,n.createView)(this.buffer)}update(e){(0,x.exists)(this);const{view:r,buffer:c,blockLen:s}=this;e=(0,n.toBytes)(e);const h=e.length;for(let i=0;i<h;){const B=Math.min(s-this.pos,h-i);if(B===s){const H=(0,n.createView)(e);for(;s<=h-i;i+=s)this.process(H,i);continue}c.set(e.subarray(i,i+B),this.pos),this.pos+=B,i+=B,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,x.exists)(this),(0,x.output)(e,this),this.finished=!0;const{buffer:r,view:c,blockLen:s,isLE:h}=this;let{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(c,0),i=0);for(let U=i;U<s;U++)r[U]=0;p(c,s-8,BigInt(this.length*8),h),this.process(c,0);const B=(0,n.createView)(e),H=this.outputLen;if(H%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const j=H/4,k=this.get();if(j>k.length)throw new Error("_sha2: outputLen bigger than state");for(let U=0;U<j;U++)B.setUint32(4*U,k[U],h)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const c=e.slice(0,r);return this.destroy(),c}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:c,length:s,finished:h,destroyed:i,pos:B}=this;return e.length=s,e.pos=B,e.finished=h,e.destroyed=i,s%r&&e.buffer.set(c),e}}t.SHA2=L},99610:function(Q,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0},42514:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const x=A(7973),n=A(82450);class p extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,x.hash)(e);const c=(0,n.toBytes)(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,h=new Uint8Array(s);h.set(c.length>s?e.create().update(c).digest():c);for(let i=0;i<h.length;i++)h[i]^=54;this.iHash.update(h),this.oHash=e.create();for(let i=0;i<h.length;i++)h[i]^=106;this.oHash.update(h),h.fill(0)}update(e){return(0,x.exists)(this),this.iHash.update(e),this}digestInto(e){(0,x.exists)(this),(0,x.bytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:c,finished:s,destroyed:h,blockLen:i,outputLen:B}=this;return e=e,e.finished=s,e.destroyed=h,e.blockLen=i,e.outputLen=B,e.oHash=r._cloneInto(e.oHash),e.iHash=c._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=p;const L=(b,e,r)=>new p(b,e).update(r).digest();t.hmac=L,t.hmac.create=(b,e)=>new p(b,e)},53583:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=void 0;const x=A(23449),n=A(82450),p=(h,i,B)=>h&i^~h&B,L=(h,i,B)=>h&i^h&B^i&B,b=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),r=new Uint32Array(64);class c extends x.SHA2{constructor(){super(64,32,8,!1),this.A=e[0]|0,this.B=e[1]|0,this.C=e[2]|0,this.D=e[3]|0,this.E=e[4]|0,this.F=e[5]|0,this.G=e[6]|0,this.H=e[7]|0}get(){const{A:i,B,C:H,D:j,E:k,F:U,G:g,H:v}=this;return[i,B,H,j,k,U,g,v]}set(i,B,H,j,k,U,g,v){this.A=i|0,this.B=B|0,this.C=H|0,this.D=j|0,this.E=k|0,this.F=U|0,this.G=g|0,this.H=v|0}process(i,B){for(let M=0;M<16;M++,B+=4)r[M]=i.getUint32(B,!1);for(let M=16;M<64;M++){const f=r[M-15],I=r[M-2],_=(0,n.rotr)(f,7)^(0,n.rotr)(f,18)^f>>>3,O=(0,n.rotr)(I,17)^(0,n.rotr)(I,19)^I>>>10;r[M]=O+r[M-7]+_+r[M-16]|0}let{A:H,B:j,C:k,D:U,E:g,F:v,G:C,H:N}=this;for(let M=0;M<64;M++){const f=(0,n.rotr)(g,6)^(0,n.rotr)(g,11)^(0,n.rotr)(g,25),I=N+f+p(g,v,C)+b[M]+r[M]|0,O=((0,n.rotr)(H,2)^(0,n.rotr)(H,13)^(0,n.rotr)(H,22))+L(H,j,k)|0;N=C,C=v,v=g,g=U+I|0,U=k,k=j,j=H,H=I+O|0}H=H+this.A|0,j=j+this.B|0,k=k+this.C|0,U=U+this.D|0,g=g+this.E|0,v=v+this.F|0,C=C+this.G|0,N=N+this.H|0,this.set(H,j,k,U,g,v,C,N)}roundClean(){r.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class s extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}t.sha256=(0,n.wrapConstructor)(()=>new c),t.sha224=(0,n.wrapConstructor)(()=>new s)},82450:function(Q,t,A){"use strict";/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.checkOpts=t.Hash=t.concatBytes=t.toBytes=t.utf8ToBytes=t.asyncLoop=t.nextTick=t.hexToBytes=t.bytesToHex=t.isLE=t.rotr=t.createView=t.u32=t.u8=void 0;const x=A(99610),n=f=>f instanceof Uint8Array,p=f=>new Uint8Array(f.buffer,f.byteOffset,f.byteLength);t.u8=p;const L=f=>new Uint32Array(f.buffer,f.byteOffset,Math.floor(f.byteLength/4));t.u32=L;const b=f=>new DataView(f.buffer,f.byteOffset,f.byteLength);t.createView=b;const e=(f,I)=>f<<32-I|f>>>I;if(t.rotr=e,t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,!t.isLE)throw new Error("Non little-endian hardware is not supported");const r=Array.from({length:256},(f,I)=>I.toString(16).padStart(2,"0"));function c(f){if(!n(f))throw new Error("Uint8Array expected");let I="";for(let _=0;_<f.length;_++)I+=r[f[_]];return I}t.bytesToHex=c;function s(f){if(typeof f!="string")throw new Error("hex string expected, got "+typeof f);const I=f.length;if(I%2)throw new Error("padded hex string expected, got unpadded hex of length "+I);const _=new Uint8Array(I/2);for(let O=0;O<_.length;O++){const l=O*2,y=f.slice(l,l+2),E=Number.parseInt(y,16);if(Number.isNaN(E)||E<0)throw new Error("Invalid byte sequence");_[O]=E}return _}t.hexToBytes=s;const h=async()=>{};t.nextTick=h;async function i(f,I,_){let O=Date.now();for(let l=0;l<f;l++){_(l);const y=Date.now()-O;y>=0&&y<I||(await(0,t.nextTick)(),O+=y)}}t.asyncLoop=i;function B(f){if(typeof f!="string")throw new Error(`utf8ToBytes expected string, got ${typeof f}`);return new Uint8Array(new TextEncoder().encode(f))}t.utf8ToBytes=B;function H(f){if(typeof f=="string"&&(f=B(f)),!n(f))throw new Error(`expected Uint8Array, got ${typeof f}`);return f}t.toBytes=H;function j(...f){const I=new Uint8Array(f.reduce((O,l)=>O+l.length,0));let _=0;return f.forEach(O=>{if(!n(O))throw new Error("Uint8Array expected");I.set(O,_),_+=O.length}),I}t.concatBytes=j;class k{clone(){return this._cloneInto()}}t.Hash=k;const U={}.toString;function g(f,I){if(I!==void 0&&U.call(I)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(f,I)}t.checkOpts=g;function v(f){const I=O=>f().update(H(O)).digest(),_=f();return I.outputLen=_.outputLen,I.blockLen=_.blockLen,I.create=()=>f(),I}t.wrapConstructor=v;function C(f){const I=(O,l)=>f(l).update(H(O)).digest(),_=f({});return I.outputLen=_.outputLen,I.blockLen=_.blockLen,I.create=O=>f(O),I}t.wrapConstructorWithOpts=C;function N(f){const I=(O,l)=>f(l).update(H(O)).digest(),_=f({});return I.outputLen=_.outputLen,I.blockLen=_.blockLen,I.create=O=>f(O),I}t.wrapXOFConstructorWithOpts=N;function M(f=32){if(x.crypto&&typeof x.crypto.getRandomValues=="function")return x.crypto.getRandomValues(new Uint8Array(f));throw new Error("crypto.getRandomValues must be defined")}t.randomBytes=M},79656:function(Q,t,A){"use strict";/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.schnorr=t.verify=t.signSync=t.sign=t.getSharedSecret=t.recoverPublicKey=t.getPublicKey=t.Signature=t.Point=t.CURVE=void 0;const x=A(69159),n=BigInt(0),p=BigInt(1),L=BigInt(2),b=BigInt(3),e=BigInt(8),r=Object.freeze({a:n,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:p,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});t.CURVE=r;const c=(d,o)=>(d+o/L)/o,s={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(d){const{n:o}=r,u=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),S=-p*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),D=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),$=u,Y=BigInt("0x100000000000000000000000000000000"),X=c($*d,o),rt=c(-S*d,o);let et=G(d-X*u-rt*D,o),ot=G(-X*S-rt*$,o);const at=et>Y,ct=ot>Y;if(at&&(et=o-et),ct&&(ot=o-ot),et>Y||ot>Y)throw new Error("splitScalarEndo: Endomorphism failed, k="+d);return{k1neg:at,k1:et,k2neg:ct,k2:ot}}},h=32,i=32,B=32,H=h+1,j=2*h+1;function k(d){const{a:o,b:u}=r,S=G(d*d),D=G(S*d);return G(D+o*d+u)}const U=r.a===n;class g extends Error{constructor(o){super(o)}}function v(d){if(!(d instanceof C))throw new TypeError("JacobianPoint expected")}class C{constructor(o,u,S){this.x=o,this.y=u,this.z=S}static fromAffine(o){if(!(o instanceof f))throw new TypeError("JacobianPoint#fromAffine: expected Point");return o.equals(f.ZERO)?C.ZERO:new C(o.x,o.y,p)}static toAffineBatch(o){const u=xt(o.map(S=>S.z));return o.map((S,D)=>S.toAffine(u[D]))}static normalizeZ(o){return C.toAffineBatch(o).map(C.fromAffine)}equals(o){v(o);const{x:u,y:S,z:D}=this,{x:$,y:Y,z:X}=o,rt=G(D*D),et=G(X*X),ot=G(u*et),at=G($*rt),ct=G(G(S*X)*et),wt=G(G(Y*D)*rt);return ot===at&&ct===wt}negate(){return new C(this.x,G(-this.y),this.z)}double(){const{x:o,y:u,z:S}=this,D=G(o*o),$=G(u*u),Y=G($*$),X=o+$,rt=G(L*(G(X*X)-D-Y)),et=G(b*D),ot=G(et*et),at=G(ot-L*rt),ct=G(et*(rt-at)-e*Y),wt=G(L*u*S);return new C(at,ct,wt)}add(o){v(o);const{x:u,y:S,z:D}=this,{x:$,y:Y,z:X}=o;if($===n||Y===n)return this;if(u===n||S===n)return o;const rt=G(D*D),et=G(X*X),ot=G(u*et),at=G($*rt),ct=G(G(S*X)*et),wt=G(G(Y*D)*rt),bt=G(at-ot),Bt=G(wt-ct);if(bt===n)return Bt===n?this.double():C.ZERO;const St=G(bt*bt),Kt=G(bt*St),Dt=G(ot*St),jt=G(Bt*Bt-Kt-L*Dt),$t=G(Bt*(Dt-jt)-ct*Kt),zt=G(D*X*bt);return new C(jt,$t,zt)}subtract(o){return this.add(o.negate())}multiplyUnsafe(o){const u=C.ZERO;if(typeof o=="bigint"&&o===n)return u;let S=ht(o);if(S===p)return this;if(!U){let at=u,ct=this;for(;S>n;)S&p&&(at=at.add(ct)),ct=ct.double(),S>>=p;return at}let{k1neg:D,k1:$,k2neg:Y,k2:X}=s.splitScalar(S),rt=u,et=u,ot=this;for(;$>n||X>n;)$&p&&(rt=rt.add(ot)),X&p&&(et=et.add(ot)),ot=ot.double(),$>>=p,X>>=p;return D&&(rt=rt.negate()),Y&&(et=et.negate()),et=new C(G(et.x*s.beta),et.y,et.z),rt.add(et)}precomputeWindow(o){const u=U?128/o+1:256/o+1,S=[];let D=this,$=D;for(let Y=0;Y<u;Y++){$=D,S.push($);for(let X=1;X<2**(o-1);X++)$=$.add(D),S.push($);D=$.double()}return S}wNAF(o,u){!u&&this.equals(C.BASE)&&(u=f.BASE);const S=u&&u._WINDOW_SIZE||1;if(256%S)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let D=u&&M.get(u);D||(D=this.precomputeWindow(S),u&&S!==1&&(D=C.normalizeZ(D),M.set(u,D)));let $=C.ZERO,Y=C.BASE;const X=1+(U?128/S:256/S),rt=2**(S-1),et=BigInt(2**S-1),ot=2**S,at=BigInt(S);for(let ct=0;ct<X;ct++){const wt=ct*rt;let bt=Number(o&et);o>>=at,bt>rt&&(bt-=ot,o+=p);const Bt=wt,St=wt+Math.abs(bt)-1,Kt=ct%2!==0,Dt=bt<0;bt===0?Y=Y.add(N(Kt,D[Bt])):$=$.add(N(Dt,D[St]))}return{p:$,f:Y}}multiply(o,u){let S=ht(o),D,$;if(U){const{k1neg:Y,k1:X,k2neg:rt,k2:et}=s.splitScalar(S);let{p:ot,f:at}=this.wNAF(X,u),{p:ct,f:wt}=this.wNAF(et,u);ot=N(Y,ot),ct=N(rt,ct),ct=new C(G(ct.x*s.beta),ct.y,ct.z),D=ot.add(ct),$=at.add(wt)}else{const{p:Y,f:X}=this.wNAF(S,u);D=Y,$=X}return C.normalizeZ([D,$])[0]}toAffine(o){const{x:u,y:S,z:D}=this,$=this.equals(C.ZERO);o==null&&(o=$?e:Et(D));const Y=o,X=G(Y*Y),rt=G(X*Y),et=G(u*X),ot=G(S*rt),at=G(D*Y);if($)return f.ZERO;if(at!==p)throw new Error("invZ was invalid");return new f(et,ot)}}C.BASE=new C(r.Gx,r.Gy,p),C.ZERO=new C(n,p,n);function N(d,o){const u=o.negate();return d?u:o}const M=new WeakMap;class f{constructor(o,u){this.x=o,this.y=u}_setWindowSize(o){this._WINDOW_SIZE=o,M.delete(this)}hasEvenY(){return this.y%L===n}static fromCompressedHex(o){const u=o.length===32,S=q(u?o:o.subarray(1));if(!dt(S))throw new Error("Point is not on curve");const D=k(S);let $=At(D);const Y=($&p)===p;u?Y&&($=G(-$)):(o[0]&1)===1!==Y&&($=G(-$));const X=new f(S,$);return X.assertValidity(),X}static fromUncompressedHex(o){const u=q(o.subarray(1,h+1)),S=q(o.subarray(h+1,h*2+1)),D=new f(u,S);return D.assertValidity(),D}static fromHex(o){const u=nt(o),S=u.length,D=u[0];if(S===h)return this.fromCompressedHex(u);if(S===H&&(D===2||D===3))return this.fromCompressedHex(u);if(S===j&&D===4)return this.fromUncompressedHex(u);throw new Error(`Point.fromHex: received invalid point. Expected 32-${H} compressed bytes or ${j} uncompressed bytes, not ${S}`)}static fromPrivateKey(o){return f.BASE.multiply(mt(o))}static fromSignature(o,u,S){const{r:D,s:$}=Rt(u);if(![0,1,2,3].includes(S))throw new Error("Cannot recover: invalid recovery bit");const Y=Ft(nt(o)),{n:X}=r,rt=S===2||S===3?D+X:D,et=Et(rt,X),ot=G(-Y*et,X),at=G($*et,X),ct=S&1?"03":"02",wt=f.fromHex(ct+z(rt)),bt=f.BASE.multiplyAndAddUnsafe(wt,ot,at);if(!bt)throw new Error("Cannot recover signature: point at infinify");return bt.assertValidity(),bt}toRawBytes(o=!1){return ut(this.toHex(o))}toHex(o=!1){const u=z(this.x);return o?`${this.hasEvenY()?"02":"03"}${u}`:`04${u}${z(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const o="Point is not on elliptic curve",{x:u,y:S}=this;if(!dt(u)||!dt(S))throw new Error(o);const D=G(S*S),$=k(u);if(G(D-$)!==n)throw new Error(o)}equals(o){return this.x===o.x&&this.y===o.y}negate(){return new f(this.x,G(-this.y))}double(){return C.fromAffine(this).double().toAffine()}add(o){return C.fromAffine(this).add(C.fromAffine(o)).toAffine()}subtract(o){return this.add(o.negate())}multiply(o){return C.fromAffine(this).multiply(o,this).toAffine()}multiplyAndAddUnsafe(o,u,S){const D=C.fromAffine(this),$=u===n||u===p||this!==f.BASE?D.multiplyUnsafe(u):D.multiply(u),Y=C.fromAffine(o).multiplyUnsafe(S),X=$.add(Y);return X.equals(C.ZERO)?void 0:X.toAffine()}}t.Point=f,f.BASE=new f(r.Gx,r.Gy),f.ZERO=new f(n,n);function I(d){return Number.parseInt(d[0],16)>=8?"00"+d:d}function _(d){if(d.length<2||d[0]!==2)throw new Error(`Invalid signature integer tag: ${T(d)}`);const o=d[1],u=d.subarray(2,o+2);if(!o||u.length!==o)throw new Error("Invalid signature integer: wrong length");if(u[0]===0&&u[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:q(u),left:d.subarray(o+2)}}function O(d){if(d.length<2||d[0]!=48)throw new Error(`Invalid signature tag: ${T(d)}`);if(d[1]!==d.length-2)throw new Error("Invalid signature: incorrect length");const{data:o,left:u}=_(d.subarray(2)),{data:S,left:D}=_(u);if(D.length)throw new Error(`Invalid signature: left bytes after parsing: ${T(D)}`);return{r:o,s:S}}class l{constructor(o,u){this.r=o,this.s=u,this.assertValidity()}static fromCompact(o){const u=o instanceof Uint8Array,S="Signature.fromCompact";if(typeof o!="string"&&!u)throw new TypeError(`${S}: Expected string or Uint8Array`);const D=u?T(o):o;if(D.length!==128)throw new Error(`${S}: Expected 64-byte hex`);return new l(st(D.slice(0,64)),st(D.slice(64,128)))}static fromDER(o){const u=o instanceof Uint8Array;if(typeof o!="string"&&!u)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:S,s:D}=O(u?o:ut(o));return new l(S,D)}static fromHex(o){return this.fromDER(o)}assertValidity(){const{r:o,s:u}=this;if(!tt(o))throw new Error("Invalid Signature: r must be 0 < r < n");if(!tt(u))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const o=r.n>>p;return this.s>o}normalizeS(){return this.hasHighS()?new l(this.r,G(-this.s,r.n)):this}toDERRawBytes(){return ut(this.toDERHex())}toDERHex(){const o=I(J(this.s)),u=I(J(this.r)),S=o.length/2,D=u.length/2,$=J(S),Y=J(D);return`30${J(D+S+4)}02${Y}${u}02${$}${o}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return ut(this.toCompactHex())}toCompactHex(){return z(this.r)+z(this.s)}}t.Signature=l;function y(...d){if(!d.every(S=>S instanceof Uint8Array))throw new Error("Uint8Array list expected");if(d.length===1)return d[0];const o=d.reduce((S,D)=>S+D.length,0),u=new Uint8Array(o);for(let S=0,D=0;S<d.length;S++){const $=d[S];u.set($,D),D+=$.length}return u}const E=Array.from({length:256},(d,o)=>o.toString(16).padStart(2,"0"));function T(d){if(!(d instanceof Uint8Array))throw new Error("Expected Uint8Array");let o="";for(let u=0;u<d.length;u++)o+=E[d[u]];return o}const K=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function z(d){if(typeof d!="bigint")throw new Error("Expected bigint");if(!(n<=d&&d<K))throw new Error("Expected number 0 <= n < 2^256");return d.toString(16).padStart(64,"0")}function Z(d){const o=ut(z(d));if(o.length!==32)throw new Error("Error: expected 32 bytes");return o}function J(d){const o=d.toString(16);return o.length&1?`0${o}`:o}function st(d){if(typeof d!="string")throw new TypeError("hexToNumber: expected string, got "+typeof d);return BigInt(`0x${d}`)}function ut(d){if(typeof d!="string")throw new TypeError("hexToBytes: expected string, got "+typeof d);if(d.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+d.length);const o=new Uint8Array(d.length/2);for(let u=0;u<o.length;u++){const S=u*2,D=d.slice(S,S+2),$=Number.parseInt(D,16);if(Number.isNaN($)||$<0)throw new Error("Invalid byte sequence");o[u]=$}return o}function q(d){return st(T(d))}function nt(d){return d instanceof Uint8Array?Uint8Array.from(d):ut(d)}function ht(d){if(typeof d=="number"&&Number.isSafeInteger(d)&&d>0)return BigInt(d);if(typeof d=="bigint"&&tt(d))return d;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function G(d,o=r.P){const u=d%o;return u>=n?u:o+u}function gt(d,o){const{P:u}=r;let S=d;for(;o-- >n;)S*=S,S%=u;return S}function At(d){const{P:o}=r,u=BigInt(6),S=BigInt(11),D=BigInt(22),$=BigInt(23),Y=BigInt(44),X=BigInt(88),rt=d*d*d%o,et=rt*rt*d%o,ot=gt(et,b)*et%o,at=gt(ot,b)*et%o,ct=gt(at,L)*rt%o,wt=gt(ct,S)*ct%o,bt=gt(wt,D)*wt%o,Bt=gt(bt,Y)*bt%o,St=gt(Bt,X)*Bt%o,Kt=gt(St,Y)*bt%o,Dt=gt(Kt,b)*et%o,jt=gt(Dt,$)*wt%o,$t=gt(jt,u)*rt%o,zt=gt($t,L);if(zt*zt%o!==d)throw new Error("Cannot find square root");return zt}function Et(d,o=r.P){if(d===n||o<=n)throw new Error(`invert: expected positive integers, got n=${d} mod=${o}`);let u=G(d,o),S=o,D=n,$=p,Y=p,X=n;for(;u!==n;){const et=S/u,ot=S%u,at=D-Y*et,ct=$-X*et;S=u,u=ot,D=Y,$=X,Y=at,X=ct}if(S!==p)throw new Error("invert: does not exist");return G(D,o)}function xt(d,o=r.P){const u=new Array(d.length),S=d.reduce(($,Y,X)=>Y===n?$:(u[X]=$,G($*Y,o)),p),D=Et(S,o);return d.reduceRight(($,Y,X)=>Y===n?$:(u[X]=G($*u[X],o),G($*Y,o)),D),u}function Yt(d){const o=d.length*8-i*8,u=q(d);return o>0?u>>BigInt(o):u}function Ft(d,o=!1){const u=Yt(d);if(o)return u;const{n:S}=r;return u>=S?u-S:u}let Tt,P;class W{constructor(o,u){if(this.hashLen=o,this.qByteLen=u,typeof o!="number"||o<2)throw new Error("hashLen must be a number");if(typeof u!="number"||u<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(o).fill(1),this.k=new Uint8Array(o).fill(0),this.counter=0}hmac(...o){return t.utils.hmacSha256(this.k,...o)}hmacSync(...o){return P(this.k,...o)}checkSync(){if(typeof P!="function")throw new g("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(o=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),o),this.v=await this.hmac(this.v),o.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),o),this.v=await this.hmac(this.v))}reseedSync(o=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),o),this.v=this.hmacSync(this.v),o.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),o),this.v=this.hmacSync(this.v))}async generate(){this.incr();let o=0;const u=[];for(;o<this.qByteLen;){this.v=await this.hmac(this.v);const S=this.v.slice();u.push(S),o+=this.v.length}return y(...u)}generateSync(){this.checkSync(),this.incr();let o=0;const u=[];for(;o<this.qByteLen;){this.v=this.hmacSync(this.v);const S=this.v.slice();u.push(S),o+=this.v.length}return y(...u)}}function tt(d){return n<d&&d<r.n}function dt(d){return n<d&&d<r.P}function pt(d,o,u,S=!0){const{n:D}=r,$=Ft(d,!0);if(!tt($))return;const Y=Et($,D),X=f.BASE.multiply($),rt=G(X.x,D);if(rt===n)return;const et=G(Y*G(o+u*rt,D),D);if(et===n)return;let ot=new l(rt,et),at=(X.x===ot.r?0:2)|Number(X.y&p);return S&&ot.hasHighS()&&(ot=ot.normalizeS(),at^=1),{sig:ot,recovery:at}}function mt(d){let o;if(typeof d=="bigint")o=d;else if(typeof d=="number"&&Number.isSafeInteger(d)&&d>0)o=BigInt(d);else if(typeof d=="string"){if(d.length!==2*i)throw new Error("Expected 32 bytes of private key");o=st(d)}else if(d instanceof Uint8Array){if(d.length!==i)throw new Error("Expected 32 bytes of private key");o=q(d)}else throw new TypeError("Expected valid private key");if(!tt(o))throw new Error("Expected private key: 0 < key < n");return o}function Ct(d){return d instanceof f?(d.assertValidity(),d):f.fromHex(d)}function Rt(d){if(d instanceof l)return d.assertValidity(),d;try{return l.fromDER(d)}catch{return l.fromCompact(d)}}function kt(d,o=!1){return f.fromPrivateKey(d).toRawBytes(o)}t.getPublicKey=kt;function ae(d,o,u,S=!1){return f.fromSignature(d,o,u).toRawBytes(S)}t.recoverPublicKey=ae;function Xt(d){const o=d instanceof Uint8Array,u=typeof d=="string",S=(o||u)&&d.length;return o?S===H||S===j:u?S===H*2||S===j*2:d instanceof f}function ce(d,o,u=!1){if(Xt(d))throw new TypeError("getSharedSecret: first arg must be private key");if(!Xt(o))throw new TypeError("getSharedSecret: second arg must be public key");const S=Ct(o);return S.assertValidity(),S.multiply(mt(d)).toRawBytes(u)}t.getSharedSecret=ce;function qt(d){const o=d.length>h?d.slice(0,h):d;return q(o)}function fe(d){const o=qt(d),u=G(o,r.n);return Qt(u<n?o:u)}function Qt(d){return Z(d)}function Jt(d,o,u){if(d==null)throw new Error(`sign: expected valid message hash, not "${d}"`);const S=nt(d),D=mt(o),$=[Qt(D),fe(S)];if(u!=null){u===!0&&(u=t.utils.randomBytes(h));const rt=nt(u);if(rt.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);$.push(rt)}const Y=y(...$),X=qt(S);return{seed:Y,m:X,d:D}}function te(d,o){const{sig:u,recovery:S}=d,{der:D,recovered:$}=Object.assign({canonical:!0,der:!0},o),Y=D?u.toDERRawBytes():u.toCompactRawBytes();return $?[Y,S]:Y}async function ue(d,o,u={}){const{seed:S,m:D,d:$}=Jt(d,o,u.extraEntropy),Y=new W(B,i);await Y.reseed(S);let X;for(;!(X=pt(await Y.generate(),D,$,u.canonical));)await Y.reseed();return te(X,u)}t.sign=ue;function he(d,o,u={}){const{seed:S,m:D,d:$}=Jt(d,o,u.extraEntropy),Y=new W(B,i);Y.reseedSync(S);let X;for(;!(X=pt(Y.generateSync(),D,$,u.canonical));)Y.reseedSync();return te(X,u)}t.signSync=he;const we={strict:!0};function ye(d,o,u,S=we){let D;try{D=Rt(d),o=nt(o)}catch{return!1}const{r:$,s:Y}=D;if(S.strict&&D.hasHighS())return!1;const X=Ft(o);let rt;try{rt=Ct(u)}catch{return!1}const{n:et}=r,ot=Et(Y,et),at=G(X*ot,et),ct=G($*ot,et),wt=f.BASE.multiplyAndAddUnsafe(rt,at,ct);return wt?G(wt.x,et)===$:!1}t.verify=ye;function Vt(d){return G(q(d),r.n)}class Nt{constructor(o,u){this.r=o,this.s=u,this.assertValidity()}static fromHex(o){const u=nt(o);if(u.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${u.length}`);const S=q(u.subarray(0,32)),D=q(u.subarray(32,64));return new Nt(S,D)}assertValidity(){const{r:o,s:u}=this;if(!dt(o)||!tt(u))throw new Error("Invalid signature")}toHex(){return z(this.r)+z(this.s)}toRawBytes(){return ut(this.toHex())}}function le(d){return f.fromPrivateKey(d).toRawX()}class ee{constructor(o,u,S=t.utils.randomBytes()){if(o==null)throw new TypeError(`sign: Expected valid message, not "${o}"`);this.m=nt(o);const{x:D,scalar:$}=this.getScalar(mt(u));if(this.px=D,this.d=$,this.rand=nt(S),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(o){const u=f.fromPrivateKey(o),S=u.hasEvenY()?o:r.n-o;return{point:u,scalar:S,x:u.toRawX()}}initNonce(o,u){return Z(o^q(u))}finalizeNonce(o){const u=G(q(o),r.n);if(u===n)throw new Error("sign: Creation of signature failed. k is zero");const{point:S,x:D,scalar:$}=this.getScalar(u);return{R:S,rx:D,k:$}}finalizeSig(o,u,S,D){return new Nt(o.x,G(u+S*D,r.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:o,d:u,px:S,rand:D}=this,$=t.utils.taggedHash,Y=this.initNonce(u,await $(Ut.aux,D)),{R:X,rx:rt,k:et}=this.finalizeNonce(await $(Ut.nonce,Y,S,o)),ot=Vt(await $(Ut.challenge,rt,S,o)),at=this.finalizeSig(X,et,ot,u);return await ne(at,o,S)||this.error(),at}calcSync(){const{m:o,d:u,px:S,rand:D}=this,$=t.utils.taggedHashSync,Y=this.initNonce(u,$(Ut.aux,D)),{R:X,rx:rt,k:et}=this.finalizeNonce($(Ut.nonce,Y,S,o)),ot=Vt($(Ut.challenge,rt,S,o)),at=this.finalizeSig(X,et,ot,u);return oe(at,o,S)||this.error(),at}}async function de(d,o,u){return new ee(d,o,u).calc()}function Mt(d,o,u){return new ee(d,o,u).calcSync()}function Ot(d,o,u){const S=d instanceof Nt,D=S?d:Nt.fromHex(d);return S&&D.assertValidity(),{...D,m:nt(o),P:Ct(u)}}function re(d,o,u,S){const D=f.BASE.multiplyAndAddUnsafe(o,mt(u),G(-S,r.n));return!(!D||!D.hasEvenY()||D.x!==d)}async function ne(d,o,u){try{const{r:S,s:D,m:$,P:Y}=Ot(d,o,u),X=Vt(await t.utils.taggedHash(Ut.challenge,Z(S),Y.toRawX(),$));return re(S,Y,D,X)}catch{return!1}}function oe(d,o,u){try{const{r:S,s:D,m:$,P:Y}=Ot(d,o,u),X=Vt(t.utils.taggedHashSync(Ut.challenge,Z(S),Y.toRawX(),$));return re(S,Y,D,X)}catch(S){if(S instanceof g)throw S;return!1}}t.schnorr={Signature:Nt,getPublicKey:le,sign:de,verify:ne,signSync:Mt,verifySync:oe},f.BASE._setWindowSize(8);const vt={node:x,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Ut={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},_t={};t.utils={bytesToHex:T,hexToBytes:ut,concatBytes:y,mod:G,invert:Et,isValidPrivateKey(d){try{return mt(d),!0}catch{return!1}},_bigintTo32Bytes:Z,_normalizePrivateKey:mt,hashToPrivateKey:d=>{d=nt(d);const o=i+8;if(d.length<o||d.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const u=G(q(d),r.n-p)+p;return Z(u)},randomBytes:(d=32)=>{if(vt.web)return vt.web.getRandomValues(new Uint8Array(d));if(vt.node){const{randomBytes:o}=vt.node;return Uint8Array.from(o(d))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>t.utils.hashToPrivateKey(t.utils.randomBytes(i+8)),precompute(d=8,o=f.BASE){const u=o===f.BASE?o:new f(o.x,o.y);return u._setWindowSize(d),u.multiply(b),u},sha256:async(...d)=>{if(vt.web){const o=await vt.web.subtle.digest("SHA-256",y(...d));return new Uint8Array(o)}else if(vt.node){const{createHash:o}=vt.node,u=o("sha256");return d.forEach(S=>u.update(S)),Uint8Array.from(u.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(d,...o)=>{if(vt.web){const u=await vt.web.subtle.importKey("raw",d,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),S=y(...o),D=await vt.web.subtle.sign("HMAC",u,S);return new Uint8Array(D)}else if(vt.node){const{createHmac:u}=vt.node,S=u("sha256",d);return o.forEach(D=>S.update(D)),Uint8Array.from(S.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(d,...o)=>{let u=_t[d];if(u===void 0){const S=await t.utils.sha256(Uint8Array.from(d,D=>D.charCodeAt(0)));u=y(S,S),_t[d]=u}return t.utils.sha256(u,...o)},taggedHashSync:(d,...o)=>{if(typeof Tt!="function")throw new g("sha256Sync is undefined, you need to set it");let u=_t[d];if(u===void 0){const S=Tt(Uint8Array.from(d,D=>D.charCodeAt(0)));u=y(S,S),_t[d]=u}return Tt(u,...o)},_JacobianPoint:C},Object.defineProperties(t.utils,{sha256Sync:{configurable:!1,get(){return Tt},set(d){Tt||(Tt=d)}},hmacSha256Sync:{configurable:!1,get(){return P},set(d){P||(P=d)}}})},39187:function(Q,t){"use strict";/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(t,"__esModule",{value:!0}),t.bytes=t.stringToBytes=t.str=t.bytesToString=t.hex=t.utf8=t.bech32m=t.bech32=t.base58check=t.base58xmr=t.base58xrp=t.base58flickr=t.base58=t.base64url=t.base64=t.base32crockford=t.base32hex=t.base32=t.base16=t.utils=t.assertNumber=void 0;function A(l){if(!Number.isSafeInteger(l))throw new Error(`Wrong integer: ${l}`)}t.assertNumber=A;function x(...l){const y=(K,z)=>Z=>K(z(Z)),E=Array.from(l).reverse().reduce((K,z)=>K?y(K,z.encode):z.encode,void 0),T=l.reduce((K,z)=>K?y(K,z.decode):z.decode,void 0);return{encode:E,decode:T}}function n(l){return{encode:y=>{if(!Array.isArray(y)||y.length&&typeof y[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return y.map(E=>{if(A(E),E<0||E>=l.length)throw new Error(`Digit index outside alphabet: ${E} (alphabet: ${l.length})`);return l[E]})},decode:y=>{if(!Array.isArray(y)||y.length&&typeof y[0]!="string")throw new Error("alphabet.decode input should be array of strings");return y.map(E=>{if(typeof E!="string")throw new Error(`alphabet.decode: not string element=${E}`);const T=l.indexOf(E);if(T===-1)throw new Error(`Unknown letter: "${E}". Allowed: ${l}`);return T})}}}function p(l=""){if(typeof l!="string")throw new Error("join separator should be string");return{encode:y=>{if(!Array.isArray(y)||y.length&&typeof y[0]!="string")throw new Error("join.encode input should be array of strings");for(let E of y)if(typeof E!="string")throw new Error(`join.encode: non-string input=${E}`);return y.join(l)},decode:y=>{if(typeof y!="string")throw new Error("join.decode input should be string");return y.split(l)}}}function L(l,y="="){if(A(l),typeof y!="string")throw new Error("padding chr should be string");return{encode(E){if(!Array.isArray(E)||E.length&&typeof E[0]!="string")throw new Error("padding.encode input should be array of strings");for(let T of E)if(typeof T!="string")throw new Error(`padding.encode: non-string input=${T}`);for(;E.length*l%8;)E.push(y);return E},decode(E){if(!Array.isArray(E)||E.length&&typeof E[0]!="string")throw new Error("padding.encode input should be array of strings");for(let K of E)if(typeof K!="string")throw new Error(`padding.decode: non-string input=${K}`);let T=E.length;if(T*l%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;T>0&&E[T-1]===y;T--)if(!((T-1)*l%8))throw new Error("Invalid padding: string has too much padding");return E.slice(0,T)}}}function b(l){if(typeof l!="function")throw new Error("normalize fn should be function");return{encode:y=>y,decode:y=>l(y)}}function e(l,y,E){if(y<2)throw new Error(`convertRadix: wrong from=${y}, base cannot be less than 2`);if(E<2)throw new Error(`convertRadix: wrong to=${E}, base cannot be less than 2`);if(!Array.isArray(l))throw new Error("convertRadix: data should be array");if(!l.length)return[];let T=0;const K=[],z=Array.from(l);for(z.forEach(Z=>{if(A(Z),Z<0||Z>=y)throw new Error(`Wrong integer: ${Z}`)});;){let Z=0,J=!0;for(let st=T;st<z.length;st++){const ut=z[st],q=y*Z+ut;if(!Number.isSafeInteger(q)||y*Z/y!==Z||q-ut!==y*Z)throw new Error("convertRadix: carry overflow");if(Z=q%E,z[st]=Math.floor(q/E),!Number.isSafeInteger(z[st])||z[st]*E+Z!==q)throw new Error("convertRadix: carry overflow");if(J)z[st]?J=!1:T=st;else continue}if(K.push(Z),J)break}for(let Z=0;Z<l.length-1&&l[Z]===0;Z++)K.push(0);return K.reverse()}const r=(l,y)=>y?r(y,l%y):l,c=(l,y)=>l+(y-r(l,y));function s(l,y,E,T){if(!Array.isArray(l))throw new Error("convertRadix2: data should be array");if(y<=0||y>32)throw new Error(`convertRadix2: wrong from=${y}`);if(E<=0||E>32)throw new Error(`convertRadix2: wrong to=${E}`);if(c(y,E)>32)throw new Error(`convertRadix2: carry overflow from=${y} to=${E} carryBits=${c(y,E)}`);let K=0,z=0;const Z=2**E-1,J=[];for(const st of l){if(A(st),st>=2**y)throw new Error(`convertRadix2: invalid data word=${st} from=${y}`);if(K=K<<y|st,z+y>32)throw new Error(`convertRadix2: carry overflow pos=${z} from=${y}`);for(z+=y;z>=E;z-=E)J.push((K>>z-E&Z)>>>0);K&=2**z-1}if(K=K<<E-z&Z,!T&&z>=y)throw new Error("Excess padding");if(!T&&K)throw new Error(`Non-zero padding: ${K}`);return T&&z>0&&J.push(K>>>0),J}function h(l){return A(l),{encode:y=>{if(!(y instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return e(Array.from(y),2**8,l)},decode:y=>{if(!Array.isArray(y)||y.length&&typeof y[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(e(y,l,2**8))}}}function i(l,y=!1){if(A(l),l<=0||l>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,l)>32||c(l,8)>32)throw new Error("radix2: carry overflow");return{encode:E=>{if(!(E instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return s(Array.from(E),8,l,!y)},decode:E=>{if(!Array.isArray(E)||E.length&&typeof E[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(s(E,l,8,y))}}}function B(l){if(typeof l!="function")throw new Error("unsafeWrapper fn should be function");return function(...y){try{return l.apply(null,y)}catch{}}}function H(l,y){if(A(l),typeof y!="function")throw new Error("checksum fn should be function");return{encode(E){if(!(E instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const T=y(E).slice(0,l),K=new Uint8Array(E.length+l);return K.set(E),K.set(T,E.length),K},decode(E){if(!(E instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const T=E.slice(0,-l),K=y(T).slice(0,l),z=E.slice(-l);for(let Z=0;Z<l;Z++)if(K[Z]!==z[Z])throw new Error("Invalid checksum");return T}}}t.utils={alphabet:n,chain:x,checksum:H,radix:h,radix2:i,join:p,padding:L},t.base16=x(i(4),n("0123456789ABCDEF"),p("")),t.base32=x(i(5),n("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),L(5),p("")),t.base32hex=x(i(5),n("0123456789ABCDEFGHIJKLMNOPQRSTUV"),L(5),p("")),t.base32crockford=x(i(5),n("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),p(""),b(l=>l.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),t.base64=x(i(6),n("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),L(6),p("")),t.base64url=x(i(6),n("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),L(6),p(""));const j=l=>x(h(58),n(l),p(""));t.base58=j("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.base58flickr=j("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),t.base58xrp=j("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const k=[0,2,3,5,6,7,9,10,11];t.base58xmr={encode(l){let y="";for(let E=0;E<l.length;E+=8){const T=l.subarray(E,E+8);y+=t.base58.encode(T).padStart(k[T.length],"1")}return y},decode(l){let y=[];for(let E=0;E<l.length;E+=11){const T=l.slice(E,E+11),K=k.indexOf(T.length),z=t.base58.decode(T);for(let Z=0;Z<z.length-K;Z++)if(z[Z]!==0)throw new Error("base58xmr: wrong padding");y=y.concat(Array.from(z.slice(z.length-K)))}return Uint8Array.from(y)}};const U=l=>x(H(4,y=>l(l(y))),t.base58);t.base58check=U;const g=x(n("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),p("")),v=[996825010,642813549,513874426,1027748829,705979059];function C(l){const y=l>>25;let E=(l&33554431)<<5;for(let T=0;T<v.length;T++)(y>>T&1)===1&&(E^=v[T]);return E}function N(l,y,E=1){const T=l.length;let K=1;for(let z=0;z<T;z++){const Z=l.charCodeAt(z);if(Z<33||Z>126)throw new Error(`Invalid prefix (${l})`);K=C(K)^Z>>5}K=C(K);for(let z=0;z<T;z++)K=C(K)^l.charCodeAt(z)&31;for(let z of y)K=C(K)^z;for(let z=0;z<6;z++)K=C(K);return K^=E,g.encode(s([K%2**30],30,5,!1))}function M(l){const y=l==="bech32"?1:734539939,E=i(5),T=E.decode,K=E.encode,z=B(T);function Z(q,nt,ht=90){if(typeof q!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof q}`);if(!Array.isArray(nt)||nt.length&&typeof nt[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof nt}`);const G=q.length+7+nt.length;if(ht!==!1&&G>ht)throw new TypeError(`Length ${G} exceeds limit ${ht}`);return q=q.toLowerCase(),`${q}1${g.encode(nt)}${N(q,nt,y)}`}function J(q,nt=90){if(typeof q!="string")throw new Error(`bech32.decode input should be string, not ${typeof q}`);if(q.length<8||nt!==!1&&q.length>nt)throw new TypeError(`Wrong string length: ${q.length} (${q}). Expected (8..${nt})`);const ht=q.toLowerCase();if(q!==ht&&q!==q.toUpperCase())throw new Error("String must be lowercase or uppercase");q=ht;const G=q.lastIndexOf("1");if(G===0||G===-1)throw new Error('Letter "1" must be present between prefix and data only');const gt=q.slice(0,G),At=q.slice(G+1);if(At.length<6)throw new Error("Data must be at least 6 characters long");const Et=g.decode(At).slice(0,-6),xt=N(gt,Et,y);if(!At.endsWith(xt))throw new Error(`Invalid checksum in ${q}: expected "${xt}"`);return{prefix:gt,words:Et}}const st=B(J);function ut(q){const{prefix:nt,words:ht}=J(q,!1);return{prefix:nt,words:ht,bytes:T(ht)}}return{encode:Z,decode:J,decodeToBytes:ut,decodeUnsafe:st,fromWords:T,fromWordsUnsafe:z,toWords:K}}t.bech32=M("bech32"),t.bech32m=M("bech32m"),t.utf8={encode:l=>new TextDecoder().decode(l),decode:l=>new TextEncoder().encode(l)},t.hex=x(i(4),n("0123456789abcdef"),p(""),b(l=>{if(typeof l!="string"||l.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof l} with length ${l.length}`);return l.toLowerCase()}));const f={utf8:t.utf8,hex:t.hex,base16:t.base16,base32:t.base32,base64:t.base64,base64url:t.base64url,base58:t.base58,base58xmr:t.base58xmr},I=`Invalid encoding type. Available types: ${Object.keys(f).join(", ")}`,_=(l,y)=>{if(typeof l!="string"||!f.hasOwnProperty(l))throw new TypeError(I);if(!(y instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return f[l].encode(y)};t.bytesToString=_,t.str=t.bytesToString;const O=(l,y)=>{if(!f.hasOwnProperty(l))throw new TypeError(I);if(typeof y!="string")throw new TypeError("stringToBytes() expects string");return f[l].decode(y)};t.stringToBytes=O,t.bytes=t.stringToBytes},67871:function(Q,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.output=t.exists=t.hash=t.bytes=t.bool=t.number=void 0;function A(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}t.number=A;function x(r){if(typeof r!="boolean")throw new Error(`Expected boolean, not ${r}`)}t.bool=x;function n(r,...c){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(c.length>0&&!c.includes(r.length))throw new Error(`Expected Uint8Array of length ${c}, not of length=${r.length}`)}t.bytes=n;function p(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");A(r.outputLen),A(r.blockLen)}t.hash=p;function L(r,c=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(c&&r.finished)throw new Error("Hash#digest() has already been called")}t.exists=L;function b(r,c){n(r);const s=c.outputLen;if(r.length<s)throw new Error(`digestInto() expects output buffer of length at least ${s}`)}t.output=b;const e={number:A,bool:x,bytes:n,hash:p,exists:L,output:b};t.default=e},51203:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SHA2=void 0;const x=A(67871),n=A(12465);function p(b,e,r,c){if(typeof b.setBigUint64=="function")return b.setBigUint64(e,r,c);const s=BigInt(32),h=BigInt(4294967295),i=Number(r>>s&h),B=Number(r&h),H=c?4:0,j=c?0:4;b.setUint32(e+H,i,c),b.setUint32(e+j,B,c)}class L extends n.Hash{constructor(e,r,c,s){super(),this.blockLen=e,this.outputLen=r,this.padOffset=c,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,n.createView)(this.buffer)}update(e){(0,x.exists)(this);const{view:r,buffer:c,blockLen:s}=this;e=(0,n.toBytes)(e);const h=e.length;for(let i=0;i<h;){const B=Math.min(s-this.pos,h-i);if(B===s){const H=(0,n.createView)(e);for(;s<=h-i;i+=s)this.process(H,i);continue}c.set(e.subarray(i,i+B),this.pos),this.pos+=B,i+=B,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,x.exists)(this),(0,x.output)(e,this),this.finished=!0;const{buffer:r,view:c,blockLen:s,isLE:h}=this;let{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(c,0),i=0);for(let U=i;U<s;U++)r[U]=0;p(c,s-8,BigInt(this.length*8),h),this.process(c,0);const B=(0,n.createView)(e),H=this.outputLen;if(H%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const j=H/4,k=this.get();if(j>k.length)throw new Error("_sha2: outputLen bigger than state");for(let U=0;U<j;U++)B.setUint32(4*U,k[U],h)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const c=e.slice(0,r);return this.destroy(),c}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:c,length:s,finished:h,destroyed:i,pos:B}=this;return e.length=s,e.pos=B,e.finished=h,e.destroyed=i,s%r&&e.buffer.set(c),e}}t.SHA2=L},98860:function(Q,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.add5L=t.add5H=t.add4H=t.add4L=t.add3H=t.add3L=t.add=t.rotlBL=t.rotlBH=t.rotlSL=t.rotlSH=t.rotr32L=t.rotr32H=t.rotrBL=t.rotrBH=t.rotrSL=t.rotrSH=t.shrSL=t.shrSH=t.toBig=t.split=t.fromBig=void 0;const A=BigInt(2**32-1),x=BigInt(32);function n(O,l=!1){return l?{h:Number(O&A),l:Number(O>>x&A)}:{h:Number(O>>x&A)|0,l:Number(O&A)|0}}t.fromBig=n;function p(O,l=!1){let y=new Uint32Array(O.length),E=new Uint32Array(O.length);for(let T=0;T<O.length;T++){const{h:K,l:z}=n(O[T],l);[y[T],E[T]]=[K,z]}return[y,E]}t.split=p;const L=(O,l)=>BigInt(O>>>0)<<x|BigInt(l>>>0);t.toBig=L;const b=(O,l,y)=>O>>>y;t.shrSH=b;const e=(O,l,y)=>O<<32-y|l>>>y;t.shrSL=e;const r=(O,l,y)=>O>>>y|l<<32-y;t.rotrSH=r;const c=(O,l,y)=>O<<32-y|l>>>y;t.rotrSL=c;const s=(O,l,y)=>O<<64-y|l>>>y-32;t.rotrBH=s;const h=(O,l,y)=>O>>>y-32|l<<64-y;t.rotrBL=h;const i=(O,l)=>l;t.rotr32H=i;const B=(O,l)=>O;t.rotr32L=B;const H=(O,l,y)=>O<<y|l>>>32-y;t.rotlSH=H;const j=(O,l,y)=>l<<y|O>>>32-y;t.rotlSL=j;const k=(O,l,y)=>l<<y-32|O>>>64-y;t.rotlBH=k;const U=(O,l,y)=>O<<y-32|l>>>64-y;t.rotlBL=U;function g(O,l,y,E){const T=(l>>>0)+(E>>>0);return{h:O+y+(T/2**32|0)|0,l:T|0}}t.add=g;const v=(O,l,y)=>(O>>>0)+(l>>>0)+(y>>>0);t.add3L=v;const C=(O,l,y,E)=>l+y+E+(O/2**32|0)|0;t.add3H=C;const N=(O,l,y,E)=>(O>>>0)+(l>>>0)+(y>>>0)+(E>>>0);t.add4L=N;const M=(O,l,y,E,T)=>l+y+E+T+(O/2**32|0)|0;t.add4H=M;const f=(O,l,y,E,T)=>(O>>>0)+(l>>>0)+(y>>>0)+(E>>>0)+(T>>>0);t.add5L=f;const I=(O,l,y,E,T,K)=>l+y+E+T+K+(O/2**32|0)|0;t.add5H=I;const _={fromBig:n,split:p,toBig:L,shrSH:b,shrSL:e,rotrSH:r,rotrSL:c,rotrBH:s,rotrBL:h,rotr32H:i,rotr32L:B,rotlSH:H,rotlSL:j,rotlBH:k,rotlBL:U,add:g,add3L:v,add3H:C,add4L:N,add4H:M,add5H:I,add5L:f};t.default=_},11181:function(Q,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0},37958:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const x=A(67871),n=A(12465);class p extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,x.hash)(e);const c=(0,n.toBytes)(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,h=new Uint8Array(s);h.set(c.length>s?e.create().update(c).digest():c);for(let i=0;i<h.length;i++)h[i]^=54;this.iHash.update(h),this.oHash=e.create();for(let i=0;i<h.length;i++)h[i]^=106;this.oHash.update(h),h.fill(0)}update(e){return(0,x.exists)(this),this.iHash.update(e),this}digestInto(e){(0,x.exists)(this),(0,x.bytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:c,finished:s,destroyed:h,blockLen:i,outputLen:B}=this;return e=e,e.finished=s,e.destroyed=h,e.blockLen=i,e.outputLen=B,e.oHash=r._cloneInto(e.oHash),e.iHash=c._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=p;const L=(b,e,r)=>new p(b,e).update(r).digest();t.hmac=L,t.hmac.create=(b,e)=>new p(b,e)},69427:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0;const x=A(51203),n=A(12465),p=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),L=Uint8Array.from({length:16},(g,v)=>v),b=L.map(g=>(9*g+5)%16);let e=[L],r=[b];for(let g=0;g<4;g++)for(let v of[e,r])v.push(v[g].map(C=>p[C]));const c=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(g=>new Uint8Array(g)),s=e.map((g,v)=>g.map(C=>c[v][C])),h=r.map((g,v)=>g.map(C=>c[v][C])),i=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),B=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),H=(g,v)=>g<<v|g>>>32-v;function j(g,v,C,N){return g===0?v^C^N:g===1?v&C|~v&N:g===2?(v|~C)^N:g===3?v&N|C&~N:v^(C|~N)}const k=new Uint32Array(16);class U extends x.SHA2{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:v,h1:C,h2:N,h3:M,h4:f}=this;return[v,C,N,M,f]}set(v,C,N,M,f){this.h0=v|0,this.h1=C|0,this.h2=N|0,this.h3=M|0,this.h4=f|0}process(v,C){for(let K=0;K<16;K++,C+=4)k[K]=v.getUint32(C,!0);let N=this.h0|0,M=N,f=this.h1|0,I=f,_=this.h2|0,O=_,l=this.h3|0,y=l,E=this.h4|0,T=E;for(let K=0;K<5;K++){const z=4-K,Z=i[K],J=B[K],st=e[K],ut=r[K],q=s[K],nt=h[K];for(let ht=0;ht<16;ht++){const G=H(N+j(K,f,_,l)+k[st[ht]]+Z,q[ht])+E|0;N=E,E=l,l=H(_,10)|0,_=f,f=G}for(let ht=0;ht<16;ht++){const G=H(M+j(z,I,O,y)+k[ut[ht]]+J,nt[ht])+T|0;M=T,T=y,y=H(O,10)|0,O=I,I=G}}this.set(this.h1+_+y|0,this.h2+l+T|0,this.h3+E+M|0,this.h4+N+I|0,this.h0+f+O|0)}roundClean(){k.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}t.RIPEMD160=U,t.ripemd160=(0,n.wrapConstructor)(()=>new U)},33184:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=void 0;const x=A(51203),n=A(12465),p=(h,i,B)=>h&i^~h&B,L=(h,i,B)=>h&i^h&B^i&B,b=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),r=new Uint32Array(64);class c extends x.SHA2{constructor(){super(64,32,8,!1),this.A=e[0]|0,this.B=e[1]|0,this.C=e[2]|0,this.D=e[3]|0,this.E=e[4]|0,this.F=e[5]|0,this.G=e[6]|0,this.H=e[7]|0}get(){const{A:i,B,C:H,D:j,E:k,F:U,G:g,H:v}=this;return[i,B,H,j,k,U,g,v]}set(i,B,H,j,k,U,g,v){this.A=i|0,this.B=B|0,this.C=H|0,this.D=j|0,this.E=k|0,this.F=U|0,this.G=g|0,this.H=v|0}process(i,B){for(let M=0;M<16;M++,B+=4)r[M]=i.getUint32(B,!1);for(let M=16;M<64;M++){const f=r[M-15],I=r[M-2],_=(0,n.rotr)(f,7)^(0,n.rotr)(f,18)^f>>>3,O=(0,n.rotr)(I,17)^(0,n.rotr)(I,19)^I>>>10;r[M]=O+r[M-7]+_+r[M-16]|0}let{A:H,B:j,C:k,D:U,E:g,F:v,G:C,H:N}=this;for(let M=0;M<64;M++){const f=(0,n.rotr)(g,6)^(0,n.rotr)(g,11)^(0,n.rotr)(g,25),I=N+f+p(g,v,C)+b[M]+r[M]|0,O=((0,n.rotr)(H,2)^(0,n.rotr)(H,13)^(0,n.rotr)(H,22))+L(H,j,k)|0;N=C,C=v,v=g,g=U+I|0,U=k,k=j,j=H,H=I+O|0}H=H+this.A|0,j=j+this.B|0,k=k+this.C|0,U=U+this.D|0,g=g+this.E|0,v=v+this.F|0,C=C+this.G|0,N=N+this.H|0,this.set(H,j,k,U,g,v,C,N)}roundClean(){r.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class s extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}t.sha256=(0,n.wrapConstructor)(()=>new c),t.sha224=(0,n.wrapConstructor)(()=>new s)},55422:function(Q,t,A){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha384=t.sha512_256=t.sha512_224=t.sha512=t.SHA512=void 0;const x=A(51203),n=A(98860),p=A(12465),[L,b]=(()=>n.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(B=>BigInt(B))))(),e=new Uint32Array(80),r=new Uint32Array(80);class c extends x.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:H,Al:j,Bh:k,Bl:U,Ch:g,Cl:v,Dh:C,Dl:N,Eh:M,El:f,Fh:I,Fl:_,Gh:O,Gl:l,Hh:y,Hl:E}=this;return[H,j,k,U,g,v,C,N,M,f,I,_,O,l,y,E]}set(H,j,k,U,g,v,C,N,M,f,I,_,O,l,y,E){this.Ah=H|0,this.Al=j|0,this.Bh=k|0,this.Bl=U|0,this.Ch=g|0,this.Cl=v|0,this.Dh=C|0,this.Dl=N|0,this.Eh=M|0,this.El=f|0,this.Fh=I|0,this.Fl=_|0,this.Gh=O|0,this.Gl=l|0,this.Hh=y|0,this.Hl=E|0}process(H,j){for(let z=0;z<16;z++,j+=4)e[z]=H.getUint32(j),r[z]=H.getUint32(j+=4);for(let z=16;z<80;z++){const Z=e[z-15]|0,J=r[z-15]|0,st=n.default.rotrSH(Z,J,1)^n.default.rotrSH(Z,J,8)^n.default.shrSH(Z,J,7),ut=n.default.rotrSL(Z,J,1)^n.default.rotrSL(Z,J,8)^n.default.shrSL(Z,J,7),q=e[z-2]|0,nt=r[z-2]|0,ht=n.default.rotrSH(q,nt,19)^n.default.rotrBH(q,nt,61)^n.default.shrSH(q,nt,6),G=n.default.rotrSL(q,nt,19)^n.default.rotrBL(q,nt,61)^n.default.shrSL(q,nt,6),gt=n.default.add4L(ut,G,r[z-7],r[z-16]),At=n.default.add4H(gt,st,ht,e[z-7],e[z-16]);e[z]=At|0,r[z]=gt|0}let{Ah:k,Al:U,Bh:g,Bl:v,Ch:C,Cl:N,Dh:M,Dl:f,Eh:I,El:_,Fh:O,Fl:l,Gh:y,Gl:E,Hh:T,Hl:K}=this;for(let z=0;z<80;z++){const Z=n.default.rotrSH(I,_,14)^n.default.rotrSH(I,_,18)^n.default.rotrBH(I,_,41),J=n.default.rotrSL(I,_,14)^n.default.rotrSL(I,_,18)^n.default.rotrBL(I,_,41),st=I&O^~I&y,ut=_&l^~_&E,q=n.default.add5L(K,J,ut,b[z],r[z]),nt=n.default.add5H(q,T,Z,st,L[z],e[z]),ht=q|0,G=n.default.rotrSH(k,U,28)^n.default.rotrBH(k,U,34)^n.default.rotrBH(k,U,39),gt=n.default.rotrSL(k,U,28)^n.default.rotrBL(k,U,34)^n.default.rotrBL(k,U,39),At=k&g^k&C^g&C,Et=U&v^U&N^v&N;T=y|0,K=E|0,y=O|0,E=l|0,O=I|0,l=_|0,{h:I,l:_}=n.default.add(M|0,f|0,nt|0,ht|0),M=C|0,f=N|0,C=g|0,N=v|0,g=k|0,v=U|0;const xt=n.default.add3L(ht,gt,Et);k=n.default.add3H(xt,nt,G,At),U=xt|0}({h:k,l:U}=n.default.add(this.Ah|0,this.Al|0,k|0,U|0)),{h:g,l:v}=n.default.add(this.Bh|0,this.Bl|0,g|0,v|0),{h:C,l:N}=n.default.add(this.Ch|0,this.Cl|0,C|0,N|0),{h:M,l:f}=n.default.add(this.Dh|0,this.Dl|0,M|0,f|0),{h:I,l:_}=n.default.add(this.Eh|0,this.El|0,I|0,_|0),{h:O,l}=n.default.add(this.Fh|0,this.Fl|0,O|0,l|0),{h:y,l:E}=n.default.add(this.Gh|0,this.Gl|0,y|0,E|0),{h:T,l:K}=n.default.add(this.Hh|0,this.Hl|0,T|0,K|0),this.set(k,U,g,v,C,N,M,f,I,_,O,l,y,E,T,K)}roundClean(){e.fill(0),r.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=c;class s extends c{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class h extends c{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class i extends c{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}t.sha512=(0,p.wrapConstructor)(()=>new c),t.sha512_224=(0,p.wrapConstructor)(()=>new s),t.sha512_256=(0,p.wrapConstructor)(()=>new h),t.sha384=(0,p.wrapConstructor)(()=>new i)},12465:function(Q,t,A){"use strict";/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(t,"__esModule",{value:!0}),t.randomBytes=t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.checkOpts=t.Hash=t.concatBytes=t.toBytes=t.utf8ToBytes=t.asyncLoop=t.nextTick=t.hexToBytes=t.bytesToHex=t.isLE=t.rotr=t.createView=t.u32=t.u8=void 0;const x=A(11181),n=f=>f instanceof Uint8Array,p=f=>new Uint8Array(f.buffer,f.byteOffset,f.byteLength);t.u8=p;const L=f=>new Uint32Array(f.buffer,f.byteOffset,Math.floor(f.byteLength/4));t.u32=L;const b=f=>new DataView(f.buffer,f.byteOffset,f.byteLength);t.createView=b;const e=(f,I)=>f<<32-I|f>>>I;if(t.rotr=e,t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,!t.isLE)throw new Error("Non little-endian hardware is not supported");const r=Array.from({length:256},(f,I)=>I.toString(16).padStart(2,"0"));function c(f){if(!n(f))throw new Error("Uint8Array expected");let I="";for(let _=0;_<f.length;_++)I+=r[f[_]];return I}t.bytesToHex=c;function s(f){if(typeof f!="string")throw new Error("hex string expected, got "+typeof f);const I=f.length;if(I%2)throw new Error("padded hex string expected, got unpadded hex of length "+I);const _=new Uint8Array(I/2);for(let O=0;O<_.length;O++){const l=O*2,y=f.slice(l,l+2),E=Number.parseInt(y,16);if(Number.isNaN(E)||E<0)throw new Error("Invalid byte sequence");_[O]=E}return _}t.hexToBytes=s;const h=async()=>{};t.nextTick=h;async function i(f,I,_){let O=Date.now();for(let l=0;l<f;l++){_(l);const y=Date.now()-O;y>=0&&y<I||(await(0,t.nextTick)(),O+=y)}}t.asyncLoop=i;function B(f){if(typeof f!="string")throw new Error(`utf8ToBytes expected string, got ${typeof f}`);return new Uint8Array(new TextEncoder().encode(f))}t.utf8ToBytes=B;function H(f){if(typeof f=="string"&&(f=B(f)),!n(f))throw new Error(`expected Uint8Array, got ${typeof f}`);return f}t.toBytes=H;function j(...f){const I=new Uint8Array(f.reduce((O,l)=>O+l.length,0));let _=0;return f.forEach(O=>{if(!n(O))throw new Error("Uint8Array expected");I.set(O,_),_+=O.length}),I}t.concatBytes=j;class k{clone(){return this._cloneInto()}}t.Hash=k;const U={}.toString;function g(f,I){if(I!==void 0&&U.call(I)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(f,I)}t.checkOpts=g;function v(f){const I=O=>f().update(H(O)).digest(),_=f();return I.outputLen=_.outputLen,I.blockLen=_.blockLen,I.create=()=>f(),I}t.wrapConstructor=v;function C(f){const I=(O,l)=>f(l).update(H(O)).digest(),_=f({});return I.outputLen=_.outputLen,I.blockLen=_.blockLen,I.create=O=>f(O),I}t.wrapConstructorWithOpts=C;function N(f){const I=(O,l)=>f(l).update(H(O)).digest(),_=f({});return I.outputLen=_.outputLen,I.blockLen=_.blockLen,I.create=O=>f(O),I}t.wrapXOFConstructorWithOpts=N;function M(f=32){if(x.crypto&&typeof x.crypto.getRandomValues=="function")return x.crypto.getRandomValues(new Uint8Array(f));throw new Error("crypto.getRandomValues must be defined")}t.randomBytes=M},30855:function(Q,t,A){"use strict";var x=A(48764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.BIP32Factory=void 0;const n=A(3229),p=A(25795),L=A(39187),b=A(33184),e=A(2401),r=A(37174),c=(0,L.base58check)(b.sha256),s={encode:i=>c.encode(Uint8Array.from(i)),decode:i=>x.from(c.decode(i))};function h(i){(0,p.testEcc)(i);const B=e.BufferN(32),H=e.compile({wif:e.UInt8,bip32:{public:e.UInt32,private:e.UInt32}}),j={messagePrefix:`Bitcoin Signed Message:
|
|
2
2
|
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},k=2147483648,U=Math.pow(2,31)-1;function g(E){return e.String(E)&&E.match(/^(m\/)?(\d+'?\/)*\d+'?$/)!==null}function v(E){return e.UInt32(E)&&E<=U}function C(E){return E.length===32?E:E.slice(1,33)}class N{constructor(T,K){this.__D=T,this.__Q=K,this.lowR=!1}get publicKey(){return this.__Q===void 0&&(this.__Q=x.from(i.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(T,K){if(!this.privateKey)throw new Error("Missing private key");if(K===void 0&&(K=this.lowR),K===!1)return x.from(i.sign(T,this.privateKey));{let z=x.from(i.sign(T,this.privateKey));const Z=x.alloc(32,0);let J=0;for(;z[0]>127;)J++,Z.writeUIntLE(J,0,6),z=x.from(i.sign(T,this.privateKey,Z));return z}}signSchnorr(T){if(!this.privateKey)throw new Error("Missing private key");if(!i.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return x.from(i.signSchnorr(T,this.privateKey))}verify(T,K){return i.verify(T,this.publicKey,K)}verifySchnorr(T,K){if(!i.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return i.verifySchnorr(T,this.publicKey.subarray(1,33),K)}}class M extends N{constructor(T,K,z,Z,J=0,st=0,ut=0){super(T,K),this.chainCode=z,this.network=Z,this.__DEPTH=J,this.__INDEX=st,this.__PARENT_FINGERPRINT=ut,e(H,Z)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return n.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return this.__D===void 0}neutered(){return l(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const T=this.network,K=this.isNeutered()?T.bip32.public:T.bip32.private,z=x.allocUnsafe(78);return z.writeUInt32BE(K,0),z.writeUInt8(this.depth,4),z.writeUInt32BE(this.parentFingerprint,5),z.writeUInt32BE(this.index,9),this.chainCode.copy(z,13),this.isNeutered()?this.publicKey.copy(z,45):(z.writeUInt8(0,45),this.privateKey.copy(z,46)),s.encode(z)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return r.encode(this.network.wif,this.privateKey,!0)}derive(T){e(e.UInt32,T);const K=T>=k,z=x.allocUnsafe(37);if(K){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");z[0]=0,this.privateKey.copy(z,1),z.writeUInt32BE(T,33)}else this.publicKey.copy(z,0),z.writeUInt32BE(T,33);const Z=n.hmacSHA512(this.chainCode,z),J=Z.slice(0,32),st=Z.slice(32);if(!i.isPrivate(J))return this.derive(T+1);let ut;if(this.isNeutered()){const q=x.from(i.pointAddScalar(this.publicKey,J,!0));if(q===null)return this.derive(T+1);ut=l(q,st,this.network,this.depth+1,T,this.fingerprint.readUInt32BE(0))}else{const q=x.from(i.privateAdd(this.privateKey,J));if(q==null)return this.derive(T+1);ut=_(q,st,this.network,this.depth+1,T,this.fingerprint.readUInt32BE(0))}return ut}deriveHardened(T){return e(v,T),this.derive(T+k)}derivePath(T){e(g,T);let K=T.split("/");if(K[0]==="m"){if(this.parentFingerprint)throw new TypeError("Expected master, got child");K=K.slice(1)}return K.reduce((z,Z)=>{let J;return Z.slice(-1)==="'"?(J=parseInt(Z.slice(0,-1),10),z.deriveHardened(J)):(J=parseInt(Z,10),z.derive(J))},this)}tweak(T){return this.privateKey?this.tweakFromPrivateKey(T):this.tweakFromPublicKey(T)}tweakFromPublicKey(T){const K=C(this.publicKey);if(!i.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const z=i.xOnlyPointAddTweak(K,T);if(!z||z.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const Z=x.from([z.parity===0?2:3]),J=x.concat([Z,z.xOnlyPubkey]);return new N(void 0,J)}tweakFromPrivateKey(T){const K=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1,z=(()=>{if(K){if(i.privateNegate)return i.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}else return this.privateKey})(),Z=i.privateAdd(z,T);if(!Z)throw new Error("Invalid tweaked private key!");return new N(x.from(Z),void 0)}}function f(E,T){const K=s.decode(E);if(K.length!==78)throw new TypeError("Invalid buffer length");T=T||j;const z=K.readUInt32BE(0);if(z!==T.bip32.private&&z!==T.bip32.public)throw new TypeError("Invalid network version");const Z=K[4],J=K.readUInt32BE(5);if(Z===0&&J!==0)throw new TypeError("Invalid parent fingerprint");const st=K.readUInt32BE(9);if(Z===0&&st!==0)throw new TypeError("Invalid index");const ut=K.slice(13,45);let q;if(z===T.bip32.private){if(K.readUInt8(45)!==0)throw new TypeError("Invalid private key");const nt=K.slice(46,78);q=_(nt,ut,T,Z,st,J)}else{const nt=K.slice(45,78);q=l(nt,ut,T,Z,st,J)}return q}function I(E,T,K){return _(E,T,K)}function _(E,T,K,z,Z,J){if(e({privateKey:B,chainCode:B},{privateKey:E,chainCode:T}),K=K||j,!i.isPrivate(E))throw new TypeError("Private key not in range [1, n)");return new M(E,void 0,T,K,z,Z,J)}function O(E,T,K){return l(E,T,K)}function l(E,T,K,z,Z,J){if(e({publicKey:e.BufferN(33),chainCode:B},{publicKey:E,chainCode:T}),K=K||j,!i.isPoint(E))throw new TypeError("Point is not on the curve");return new M(void 0,E,T,K,z,Z,J)}function y(E,T){if(e(e.Buffer,E),E.length<16)throw new TypeError("Seed should be at least 128 bits");if(E.length>64)throw new TypeError("Seed should be at most 512 bits");T=T||j;const K=n.hmacSHA512(x.from("Bitcoin seed","utf8"),E),z=K.slice(0,32),Z=K.slice(32);return I(z,Z,T)}return{fromSeed:y,fromBase58:f,fromPublicKey:O,fromPrivateKey:I}}t.BIP32Factory=h},3229:function(Q,t,A){"use strict";var x=A(48764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.hmacSHA512=t.hash160=void 0;const n=A(37958),p=A(69427),L=A(33184),b=A(55422);function e(c){const s=(0,L.sha256)(Uint8Array.from(c));return x.from((0,p.ripemd160)(s))}t.hash160=e;function r(c,s){return x.from((0,n.hmac)(b.sha512,c,s))}t.hmacSHA512=r},81224:function(Q,t,A){"use strict";var x;x={value:!0},t.GA=x=void 0;var n=A(30855);x={enumerable:!0,get:function(){return n.BIP32Factory}},Object.defineProperty(t,"GA",{enumerable:!0,get:function(){return n.BIP32Factory}})},25795:function(Q,t,A){"use strict";var x=A(48764).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.testEcc=void 0;const n=b=>x.from(b,"hex");function p(b){if(L(b.isPoint(n("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),L(!b.isPoint(n("030000000000000000000000000000000000000000000000000000000000000005"))),L(b.isPrivate(n("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),L(b.isPrivate(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),L(!b.isPrivate(n("0000000000000000000000000000000000000000000000000000000000000000"))),L(!b.isPrivate(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),L(!b.isPrivate(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),L(x.from(b.pointFromScalar(n("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(n("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),b.xOnlyPointAddTweak){L(b.xOnlyPointAddTweak(n("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let e=b.xOnlyPointAddTweak(n("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),n("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));L(x.from(e.xOnlyPubkey).equals(n("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&e.parity===1),e=b.xOnlyPointAddTweak(n("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),n("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}L(x.from(b.pointAddScalar(n("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),n("0000000000000000000000000000000000000000000000000000000000000003"))).equals(n("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),L(x.from(b.privateAdd(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),n("0000000000000000000000000000000000000000000000000000000000000002"))).equals(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),b.privateNegate&&(L(x.from(b.privateNegate(n("0000000000000000000000000000000000000000000000000000000000000001"))).equals(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),L(x.from(b.privateNegate(n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(n("0000000000000000000000000000000000000000000000000000000000000003"))),L(x.from(b.privateNegate(n("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(n("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),L(x.from(b.sign(n("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),n("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(n("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),L(b.verify(n("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),n("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),n("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),b.signSchnorr&&L(x.from(b.signSchnorr(n("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),n("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),n("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(n("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),b.verifySchnorr&&L(b.verifySchnorr(n("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),n("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),n("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}t.testEcc=p;function L(b){if(!b)throw new Error("ecc library invalid")}},48057:function(Q,t,A){Q.exports=A(8864)(A(9017))},9017:function(Q,t,A){const x=A(86266).ec,n=new x("secp256k1"),p=n.curve,L=p.n.constructor;function b(s,h){let i=new L(h);if(i.cmp(p.p)>=0)return null;i=i.toRed(p.red);let B=i.redSqr().redIMul(i).redIAdd(p.b).redSqrt();return s===3!==B.isOdd()&&(B=B.redNeg()),n.keyPair({pub:{x:i,y:B}})}function e(s,h,i){let B=new L(h),H=new L(i);if(B.cmp(p.p)>=0||H.cmp(p.p)>=0||(B=B.toRed(p.red),H=H.toRed(p.red),(s===6||s===7)&&H.isOdd()!==(s===7)))return null;const j=B.redSqr().redIMul(B);return H.redSqr().redISub(j.redIAdd(p.b)).isZero()?n.keyPair({pub:{x:B,y:H}}):null}function r(s){const h=s[0];switch(h){case 2:case 3:return s.length!==33?null:b(h,s.subarray(1,33));case 4:case 6:case 7:return s.length!==65?null:e(h,s.subarray(1,33),s.subarray(33,65));default:return null}}function c(s,h){const i=h.encode(null,s.length===33);for(let B=0;B<s.length;++B)s[B]=i[B]}Q.exports={contextRandomize(){return 0},privateKeyVerify(s){const h=new L(s);return h.cmp(p.n)<0&&!h.isZero()?0:1},privateKeyNegate(s){const h=new L(s),i=p.n.sub(h).umod(p.n).toArrayLike(Uint8Array,"be",32);return s.set(i),0},privateKeyTweakAdd(s,h){const i=new L(h);if(i.cmp(p.n)>=0||(i.iadd(new L(s)),i.cmp(p.n)>=0&&i.isub(p.n),i.isZero()))return 1;const B=i.toArrayLike(Uint8Array,"be",32);return s.set(B),0},privateKeyTweakMul(s,h){let i=new L(h);if(i.cmp(p.n)>=0||i.isZero())return 1;i.imul(new L(s)),i.cmp(p.n)>=0&&(i=i.umod(p.n));const B=i.toArrayLike(Uint8Array,"be",32);return s.set(B),0},publicKeyVerify(s){return r(s)===null?1:0},publicKeyCreate(s,h){const i=new L(h);if(i.cmp(p.n)>=0||i.isZero())return 1;const B=n.keyFromPrivate(h).getPublic();return c(s,B),0},publicKeyConvert(s,h){const i=r(h);if(i===null)return 1;const B=i.getPublic();return c(s,B),0},publicKeyNegate(s,h){const i=r(h);if(i===null)return 1;const B=i.getPublic();return B.y=B.y.redNeg(),c(s,B),0},publicKeyCombine(s,h){const i=new Array(h.length);for(let H=0;H<h.length;++H)if(i[H]=r(h[H]),i[H]===null)return 1;let B=i[0].getPublic();for(let H=1;H<i.length;++H)B=B.add(i[H].pub);return B.isInfinity()?2:(c(s,B),0)},publicKeyTweakAdd(s,h,i){const B=r(h);if(B===null)return 1;if(i=new L(i),i.cmp(p.n)>=0)return 2;const H=B.getPublic().add(p.g.mul(i));return H.isInfinity()?2:(c(s,H),0)},publicKeyTweakMul(s,h,i){const B=r(h);if(B===null)return 1;if(i=new L(i),i.cmp(p.n)>=0||i.isZero())return 2;const H=B.getPublic().mul(i);return c(s,H),0},signatureNormalize(s){const h=new L(s.subarray(0,32)),i=new L(s.subarray(32,64));return h.cmp(p.n)>=0||i.cmp(p.n)>=0?1:(i.cmp(n.nh)===1&&s.set(p.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(s,h){const i=h.subarray(0,32),B=h.subarray(32,64);if(new L(i).cmp(p.n)>=0||new L(B).cmp(p.n)>=0)return 1;const{output:H}=s;let j=H.subarray(4,4+33);j[0]=0,j.set(i,1);let k=33,U=0;for(;k>1&&j[U]===0&&!(j[U+1]&128);--k,++U);if(j=j.subarray(U),j[0]&128||k>1&&j[0]===0&&!(j[1]&128))return 1;let g=H.subarray(6+33,6+33+33);g[0]=0,g.set(B,1);let v=33,C=0;for(;v>1&&g[C]===0&&!(g[C+1]&128);--v,++C);return g=g.subarray(C),g[0]&128||v>1&&g[0]===0&&!(g[1]&128)?1:(s.outputlen=6+k+v,H[0]=48,H[1]=s.outputlen-2,H[2]=2,H[3]=j.length,H.set(j,4),H[4+k]=2,H[5+k]=g.length,H.set(g,6+k),0)},signatureImport(s,h){if(h.length<8||h.length>72||h[0]!==48||h[1]!==h.length-2||h[2]!==2)return 1;const i=h[3];if(i===0||5+i>=h.length||h[4+i]!==2)return 1;const B=h[5+i];if(B===0||6+i+B!==h.length||h[4]&128||i>1&&h[4]===0&&!(h[5]&128)||h[i+6]&128||B>1&&h[i+6]===0&&!(h[i+7]&128))return 1;let H=h.subarray(4,4+i);if(H.length===33&&H[0]===0&&(H=H.subarray(1)),H.length>32)return 1;let j=h.subarray(6+i);if(j.length===33&&j[0]===0&&(j=j.slice(1)),j.length>32)throw new Error("S length is too long");let k=new L(H);k.cmp(p.n)>=0&&(k=new L(0));let U=new L(h.subarray(6+i));return U.cmp(p.n)>=0&&(U=new L(0)),s.set(k.toArrayLike(Uint8Array,"be",32),0),s.set(U.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(s,h,i,B,H){if(H){const U=H;H=g=>{const v=U(h,i,null,B,g);if(!(v instanceof Uint8Array&&v.length===32))throw new Error("This is the way");return new L(v)}}const j=new L(i);if(j.cmp(p.n)>=0||j.isZero())return 1;let k;try{k=n.sign(h,i,{canonical:!0,k:H,pers:B})}catch{return 1}return s.signature.set(k.r.toArrayLike(Uint8Array,"be",32),0),s.signature.set(k.s.toArrayLike(Uint8Array,"be",32),32),s.recid=k.recoveryParam,0},ecdsaVerify(s,h,i){const B={r:s.subarray(0,32),s:s.subarray(32,64)},H=new L(B.r),j=new L(B.s);if(H.cmp(p.n)>=0||j.cmp(p.n)>=0)return 1;if(j.cmp(n.nh)===1||H.isZero()||j.isZero())return 3;const k=r(i);if(k===null)return 2;const U=k.getPublic();return n.verify(h,B,U)?0:3},ecdsaRecover(s,h,i,B){const H={r:h.slice(0,32),s:h.slice(32,64)},j=new L(H.r),k=new L(H.s);if(j.cmp(p.n)>=0||k.cmp(p.n)>=0)return 1;if(j.isZero()||k.isZero())return 2;let U;try{U=n.recoverPubKey(B,H,i)}catch{return 2}return c(s,U),0},ecdh(s,h,i,B,H,j,k){const U=r(h);if(U===null)return 1;const g=new L(i);if(g.cmp(p.n)>=0||g.isZero())return 2;const v=U.getPublic().mul(g);if(H===void 0){const C=v.encode(null,!0),N=n.hash().update(C).digest();for(let M=0;M<32;++M)s[M]=N[M]}else{j||(j=new Uint8Array(32));const C=v.getX().toArray("be",32);for(let I=0;I<32;++I)j[I]=C[I];k||(k=new Uint8Array(32));const N=v.getY().toArray("be",32);for(let I=0;I<32;++I)k[I]=N[I];const M=H(j,k,B);if(!(M instanceof Uint8Array&&M.length===s.length))return 2;s.set(M)}return 0}}},8864:function(Q){const t={IMPOSSIBLE_CASE:"Impossible case. Please create issue.",TWEAK_ADD:"The tweak was out of range or the resulted private key is invalid",TWEAK_MUL:"The tweak was out of range or equal to zero",CONTEXT_RANDOMIZE_UNKNOW:"Unknow error on context randomization",SECKEY_INVALID:"Private Key is invalid",PUBKEY_PARSE:"Public Key could not be parsed",PUBKEY_SERIALIZE:"Public Key serialization error",PUBKEY_COMBINE:"The sum of the public keys is not valid",SIG_PARSE:"Signature could not be parsed",SIGN:"The nonce generation function failed, or the private key was invalid",RECOVER:"Public key could not be recover",ECDH:"Scalar was invalid (zero or overflow)"};function A(b,e){if(!b)throw new Error(e)}function x(b,e,r){if(A(e instanceof Uint8Array,`Expected ${b} to be an Uint8Array`),r!==void 0)if(Array.isArray(r)){const c=r.join(", "),s=`Expected ${b} to be an Uint8Array with length [${c}]`;A(r.includes(e.length),s)}else{const c=`Expected ${b} to be an Uint8Array with length ${r}`;A(e.length===r,c)}}function n(b){A(L(b)==="Boolean","Expected compressed to be a Boolean")}function p(b=r=>new Uint8Array(r),e){return typeof b=="function"&&(b=b(e)),x("output",b,e),b}function L(b){return Object.prototype.toString.call(b).slice(8,-1)}Q.exports=b=>({contextRandomize(e){switch(A(e===null||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),e!==null&&x("seed",e,32),b.contextRandomize(e)){case 1:throw new Error(t.CONTEXT_RANDOMIZE_UNKNOW)}},privateKeyVerify(e){return x("private key",e,32),b.privateKeyVerify(e)===0},privateKeyNegate(e){switch(x("private key",e,32),b.privateKeyNegate(e)){case 0:return e;case 1:throw new Error(t.IMPOSSIBLE_CASE)}},privateKeyTweakAdd(e,r){switch(x("private key",e,32),x("tweak",r,32),b.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t.TWEAK_ADD)}},privateKeyTweakMul(e,r){switch(x("private key",e,32),x("tweak",r,32),b.privateKeyTweakMul(e,r)){case 0:return e;case 1:throw new Error(t.TWEAK_MUL)}},publicKeyVerify(e){return x("public key",e,[33,65]),b.publicKeyVerify(e)===0},publicKeyCreate(e,r=!0,c){switch(x("private key",e,32),n(r),c=p(c,r?33:65),b.publicKeyCreate(c,e)){case 0:return c;case 1:throw new Error(t.SECKEY_INVALID);case 2:throw new Error(t.PUBKEY_SERIALIZE)}},publicKeyConvert(e,r=!0,c){switch(x("public key",e,[33,65]),n(r),c=p(c,r?33:65),b.publicKeyConvert(c,e)){case 0:return c;case 1:throw new Error(t.PUBKEY_PARSE);case 2:throw new Error(t.PUBKEY_SERIALIZE)}},publicKeyNegate(e,r=!0,c){switch(x("public key",e,[33,65]),n(r),c=p(c,r?33:65),b.publicKeyNegate(c,e)){case 0:return c;case 1:throw new Error(t.PUBKEY_PARSE);case 2:throw new Error(t.IMPOSSIBLE_CASE);case 3:throw new Error(t.PUBKEY_SERIALIZE)}},publicKeyCombine(e,r=!0,c){A(Array.isArray(e),"Expected public keys to be an Array"),A(e.length>0,"Expected public keys array will have more than zero items");for(const s of e)x("public key",s,[33,65]);switch(n(r),c=p(c,r?33:65),b.publicKeyCombine(c,e)){case 0:return c;case 1:throw new Error(t.PUBKEY_PARSE);case 2:throw new Error(t.PUBKEY_COMBINE);case 3:throw new Error(t.PUBKEY_SERIALIZE)}},publicKeyTweakAdd(e,r,c=!0,s){switch(x("public key",e,[33,65]),x("tweak",r,32),n(c),s=p(s,c?33:65),b.publicKeyTweakAdd(s,e,r)){case 0:return s;case 1:throw new Error(t.PUBKEY_PARSE);case 2:throw new Error(t.TWEAK_ADD)}},publicKeyTweakMul(e,r,c=!0,s){switch(x("public key",e,[33,65]),x("tweak",r,32),n(c),s=p(s,c?33:65),b.publicKeyTweakMul(s,e,r)){case 0:return s;case 1:throw new Error(t.PUBKEY_PARSE);case 2:throw new Error(t.TWEAK_MUL)}},signatureNormalize(e){switch(x("signature",e,64),b.signatureNormalize(e)){case 0:return e;case 1:throw new Error(t.SIG_PARSE)}},signatureExport(e,r){x("signature",e,64),r=p(r,72);const c={output:r,outputlen:72};switch(b.signatureExport(c,e)){case 0:return r.slice(0,c.outputlen);case 1:throw new Error(t.SIG_PARSE);case 2:throw new Error(t.IMPOSSIBLE_CASE)}},signatureImport(e,r){switch(x("signature",e),r=p(r,64),b.signatureImport(r,e)){case 0:return r;case 1:throw new Error(t.SIG_PARSE);case 2:throw new Error(t.IMPOSSIBLE_CASE)}},ecdsaSign(e,r,c={},s){x("message",e,32),x("private key",r,32),A(L(c)==="Object","Expected options to be an Object"),c.data!==void 0&&x("options.data",c.data),c.noncefn!==void 0&&A(L(c.noncefn)==="Function","Expected options.noncefn to be a Function"),s=p(s,64);const h={signature:s,recid:null};switch(b.ecdsaSign(h,e,r,c.data,c.noncefn)){case 0:return h;case 1:throw new Error(t.SIGN);case 2:throw new Error(t.IMPOSSIBLE_CASE)}},ecdsaVerify(e,r,c){switch(x("signature",e,64),x("message",r,32),x("public key",c,[33,65]),b.ecdsaVerify(e,r,c)){case 0:return!0;case 3:return!1;case 1:throw new Error(t.SIG_PARSE);case 2:throw new Error(t.PUBKEY_PARSE)}},ecdsaRecover(e,r,c,s=!0,h){switch(x("signature",e,64),A(L(r)==="Number"&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),x("message",c,32),n(s),h=p(h,s?33:65),b.ecdsaRecover(h,e,r,c)){case 0:return h;case 1:throw new Error(t.SIG_PARSE);case 2:throw new Error(t.RECOVER);case 3:throw new Error(t.IMPOSSIBLE_CASE)}},ecdh(e,r,c={},s){switch(x("public key",e,[33,65]),x("private key",r,32),A(L(c)==="Object","Expected options to be an Object"),c.data!==void 0&&x("options.data",c.data),c.hashfn!==void 0?(A(L(c.hashfn)==="Function","Expected options.hashfn to be a Function"),c.xbuf!==void 0&&x("options.xbuf",c.xbuf,32),c.ybuf!==void 0&&x("options.ybuf",c.ybuf,32),x("output",s)):s=p(s,32),b.ecdh(s,e,r,c.data,c.hashfn,c.xbuf,c.ybuf)){case 0:return s;case 1:throw new Error(t.PUBKEY_PARSE);case 2:throw new Error(t.ECDH)}}})},58162:function(Q,t,A){"use strict";var x=A(89509).Buffer;function n(p){if(p.length>=255)throw new TypeError("Alphabet too long");for(var L=new Uint8Array(256),b=0;b<L.length;b++)L[b]=255;for(var e=0;e<p.length;e++){var r=p.charAt(e),c=r.charCodeAt(0);if(L[c]!==255)throw new TypeError(r+" is ambiguous");L[c]=e}var s=p.length,h=p.charAt(0),i=Math.log(s)/Math.log(256),B=Math.log(256)/Math.log(s);function H(U){if((Array.isArray(U)||U instanceof Uint8Array)&&(U=x.from(U)),!x.isBuffer(U))throw new TypeError("Expected Buffer");if(U.length===0)return"";for(var g=0,v=0,C=0,N=U.length;C!==N&&U[C]===0;)C++,g++;for(var M=(N-C)*B+1>>>0,f=new Uint8Array(M);C!==N;){for(var I=U[C],_=0,O=M-1;(I!==0||_<v)&&O!==-1;O--,_++)I+=256*f[O]>>>0,f[O]=I%s>>>0,I=I/s>>>0;if(I!==0)throw new Error("Non-zero carry");v=_,C++}for(var l=M-v;l!==M&&f[l]===0;)l++;for(var y=h.repeat(g);l<M;++l)y+=p.charAt(f[l]);return y}function j(U){if(typeof U!="string")throw new TypeError("Expected String");if(U.length===0)return x.alloc(0);for(var g=0,v=0,C=0;U[g]===h;)v++,g++;for(var N=(U.length-g)*i+1>>>0,M=new Uint8Array(N);U[g];){var f=L[U.charCodeAt(g)];if(f===255)return;for(var I=0,_=N-1;(f!==0||I<C)&&_!==-1;_--,I++)f+=s*M[_]>>>0,M[_]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");C=I,g++}for(var O=N-C;O!==N&&M[O]===0;)O++;var l=x.allocUnsafe(v+(N-O));l.fill(0,0,v);for(var y=v;O!==N;)l[y++]=M[O++];return l}function k(U){var g=j(U);if(g)return g;throw new Error("Non-base"+s+" character")}return{encode:H,decodeUnsafe:j,decode:k}}Q.exports=n},44501:function(Q){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",A="0123456789ABCDEFGHIJKLMNOPQRSTUV",x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function n(p,L){var b=p.indexOf(L);if(b===-1)throw new Error("Invalid character found: "+L);return b}Q.exports=function(L,b){var e;switch(b){case"RFC3548":case"RFC4648":e=t,L=L.replace(/=+$/,"");break;case"RFC4648-HEX":e=A,L=L.replace(/=+$/,"");break;case"Crockford":e=x,L=L.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+b)}for(var r=L.length,c=0,s=0,h=0,i=new Uint8Array(r*5/8|0),B=0;B<r;B++)s=s<<5|n(e,L[B]),c+=5,c>=8&&(i[h++]=s>>>c-8&255,c-=8);return i.buffer}},8442:function(Q,t,A){const x=A(99488);function n(v,C,N){const M=v[C]+v[N];let f=v[C+1]+v[N+1];M>=4294967296&&f++,v[C]=M,v[C+1]=f}function p(v,C,N,M){let f=v[C]+N;N<0&&(f+=4294967296);let I=v[C+1]+M;f>=4294967296&&I++,v[C]=f,v[C+1]=I}function L(v,C){return v[C]^v[C+1]<<8^v[C+2]<<16^v[C+3]<<24}function b(v,C,N,M,f,I){const _=h[f],O=h[f+1],l=h[I],y=h[I+1];n(s,v,C),p(s,v,_,O);let E=s[M]^s[v],T=s[M+1]^s[v+1];s[M]=T,s[M+1]=E,n(s,N,M),E=s[C]^s[N],T=s[C+1]^s[N+1],s[C]=E>>>24^T<<8,s[C+1]=T>>>24^E<<8,n(s,v,C),p(s,v,l,y),E=s[M]^s[v],T=s[M+1]^s[v+1],s[M]=E>>>16^T<<16,s[M+1]=T>>>16^E<<16,n(s,N,M),E=s[C]^s[N],T=s[C+1]^s[N+1],s[C]=T>>>31^E<<1,s[C+1]=E>>>31^T<<1}const e=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),r=[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],c=new Uint8Array(r.map(function(v){return v*2})),s=new Uint32Array(32),h=new Uint32Array(32);function i(v,C){let N=0;for(N=0;N<16;N++)s[N]=v.h[N],s[N+16]=e[N];for(s[24]=s[24]^v.t,s[25]=s[25]^v.t/4294967296,C&&(s[28]=~s[28],s[29]=~s[29]),N=0;N<32;N++)h[N]=L(v.b,4*N);for(N=0;N<12;N++)b(0,8,16,24,c[N*16+0],c[N*16+1]),b(2,10,18,26,c[N*16+2],c[N*16+3]),b(4,12,20,28,c[N*16+4],c[N*16+5]),b(6,14,22,30,c[N*16+6],c[N*16+7]),b(0,10,20,30,c[N*16+8],c[N*16+9]),b(2,12,22,24,c[N*16+10],c[N*16+11]),b(4,14,16,26,c[N*16+12],c[N*16+13]),b(6,8,18,28,c[N*16+14],c[N*16+15]);for(N=0;N<16;N++)v.h[N]=v.h[N]^s[N]^s[N+16]}const B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function H(v,C,N,M){if(v===0||v>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(C&&C.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(N&&N.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(M&&M.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const f={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:v};B.fill(0),B[0]=v,C&&(B[1]=C.length),B[2]=1,B[3]=1,N&&B.set(N,32),M&&B.set(M,48);for(let I=0;I<16;I++)f.h[I]=e[I]^L(B,I*4);return C&&(j(f,C),f.c=128),f}function j(v,C){for(let N=0;N<C.length;N++)v.c===128&&(v.t+=v.c,i(v,!1),v.c=0),v.b[v.c++]=C[N]}function k(v){for(v.t+=v.c;v.c<128;)v.b[v.c++]=0;i(v,!0);const C=new Uint8Array(v.outlen);for(let N=0;N<v.outlen;N++)C[N]=v.h[N>>2]>>8*(N&3);return C}function U(v,C,N,M,f){N=N||64,v=x.normalizeInput(v),M&&(M=x.normalizeInput(M)),f&&(f=x.normalizeInput(f));const I=H(N,C,M,f);return j(I,v),k(I)}function g(v,C,N,M,f){const I=U(v,C,N,M,f);return x.toHex(I)}Q.exports={blake2b:U,blake2bHex:g,blake2bInit:H,blake2bUpdate:j,blake2bFinal:k}},45297:function(Q,t,A){const x=A(99488);function n(k,U){return k[U]^k[U+1]<<8^k[U+2]<<16^k[U+3]<<24}function p(k,U,g,v,C,N){r[k]=r[k]+r[U]+C,r[v]=L(r[v]^r[k],16),r[g]=r[g]+r[v],r[U]=L(r[U]^r[g],12),r[k]=r[k]+r[U]+N,r[v]=L(r[v]^r[k],8),r[g]=r[g]+r[v],r[U]=L(r[U]^r[g],7)}function L(k,U){return k>>>U^k<<32-U}const b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e=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]),r=new Uint32Array(16),c=new Uint32Array(16);function s(k,U){let g=0;for(g=0;g<8;g++)r[g]=k.h[g],r[g+8]=b[g];for(r[12]^=k.t,r[13]^=k.t/4294967296,U&&(r[14]=~r[14]),g=0;g<16;g++)c[g]=n(k.b,4*g);for(g=0;g<10;g++)p(0,4,8,12,c[e[g*16+0]],c[e[g*16+1]]),p(1,5,9,13,c[e[g*16+2]],c[e[g*16+3]]),p(2,6,10,14,c[e[g*16+4]],c[e[g*16+5]]),p(3,7,11,15,c[e[g*16+6]],c[e[g*16+7]]),p(0,5,10,15,c[e[g*16+8]],c[e[g*16+9]]),p(1,6,11,12,c[e[g*16+10]],c[e[g*16+11]]),p(2,7,8,13,c[e[g*16+12]],c[e[g*16+13]]),p(3,4,9,14,c[e[g*16+14]],c[e[g*16+15]]);for(g=0;g<8;g++)k.h[g]^=r[g]^r[g+8]}function h(k,U){if(!(k>0&&k<=32))throw new Error("Incorrect output length, should be in [1, 32]");const g=U?U.length:0;if(U&&!(g>0&&g<=32))throw new Error("Incorrect key length, should be in [1, 32]");const v={h:new Uint32Array(b),b:new Uint8Array(64),c:0,t:0,outlen:k};return v.h[0]^=16842752^g<<8^k,g>0&&(i(v,U),v.c=64),v}function i(k,U){for(let g=0;g<U.length;g++)k.c===64&&(k.t+=k.c,s(k,!1),k.c=0),k.b[k.c++]=U[g]}function B(k){for(k.t+=k.c;k.c<64;)k.b[k.c++]=0;s(k,!0);const U=new Uint8Array(k.outlen);for(let g=0;g<k.outlen;g++)U[g]=k.h[g>>2]>>8*(g&3)&255;return U}function H(k,U,g){g=g||32,k=x.normalizeInput(k);const v=h(g,U);return i(v,k),B(v)}function j(k,U,g){const v=H(k,U,g);return x.toHex(v)}Q.exports={blake2s:H,blake2sHex:j,blake2sInit:h,blake2sUpdate:i,blake2sFinal:B}},1191:function(Q,t,A){const x=A(8442),n=A(45297);Q.exports={blake2b:x.blake2b,blake2bHex:x.blake2bHex,blake2bInit:x.blake2bInit,blake2bUpdate:x.blake2bUpdate,blake2bFinal:x.blake2bFinal,blake2s:n.blake2s,blake2sHex:n.blake2sHex,blake2sInit:n.blake2sInit,blake2sUpdate:n.blake2sUpdate,blake2sFinal:n.blake2sFinal}},99488:function(Q){const t="Input must be an string, Buffer or Uint8Array";function A(b){let e;if(b instanceof Uint8Array)e=b;else if(typeof b=="string")e=new TextEncoder().encode(b);else throw new Error(t);return e}function x(b){return Array.prototype.map.call(b,function(e){return(e<16?"0":"")+e.toString(16)}).join("")}function n(b){return(4294967296+b).toString(16).substring(1)}function p(b,e,r){let c=`
|
|
3
3
|
`+b+" = ";for(let s=0;s<e.length;s+=2){if(r===32)c+=n(e[s]).toUpperCase(),c+=" ",c+=n(e[s+1]).toUpperCase();else if(r===64)c+=n(e[s+1]).toUpperCase(),c+=n(e[s]).toUpperCase();else throw new Error("Invalid size "+r);s%6===4?c+=`
|
|
4
|
-
`+new Array(b.length+4).join(" "):s<e.length-2&&(c+=" ")}console.log(c)}function L(b,e,r){let c=new Date().getTime();const s=new Uint8Array(e);for(let i=0;i<e;i++)s[i]=i%256;const h=new Date().getTime();console.log("Generated random input in "+(h-c)+"ms"),c=h;for(let i=0;i<r;i++){const B=b(s),H=new Date().getTime(),j=H-c;c=H,console.log("Hashed in "+j+"ms: "+B.substring(0,20)+"..."),console.log(Math.round(e/(1<<20)/(j/1e3)*100)/100+" MB PER SECOND")}}Q.exports={normalizeInput:A,toHex:x,debugPrint:p,testSpeed:L}},77191:function(Q,t,A){var x=A(58162),n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Q.exports=x(n)},53310:function(Q,t,A){"use strict";var x=A(77191),n=A(89509).Buffer;Q.exports=function(p){function L(c){var s=p(c);return x.encode(n.concat([c,s],c.length+4))}function b(c){var s=c.slice(0,-4),h=c.slice(-4),i=p(s);if(!(h[0]^i[0]|h[1]^i[1]|h[2]^i[2]|h[3]^i[3]))return s}function e(c){var s=x.decodeUnsafe(c);if(!!s)return b(s)}function r(c){var s=x.decode(c),h=b(s,p);if(!h)throw new Error("Invalid checksum");return h}return{encode:L,decode:r,decodeUnsafe:e}}},58334:function(Q,t,A){"use strict";var x=A(23482),n=A(53310);function p(L){var b=x("sha256").update(L).digest();return x("sha256").update(b).digest()}Q.exports=n(p)},53533:function(Q,t,A){const x=A(89509).Buffer;Q.exports=class{constructor(p=x.from([])){this.buffer=p,this._bytesRead=0,this._bytesWrote=0}read(p){this._bytesRead+=p;const L=this.buffer.slice(0,p);return this.buffer=this.buffer.slice(p),L}write(p){p=x.from(p),this._bytesWrote+=p.length,this.buffer=x.concat([this.buffer,p])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},58355:function(Q,t,A){"use strict";var x=A(35717),n=A(51031),p=A(71027),L=A(89509).Buffer,b=A(78028),e=A(79785),r=A(89072),c=L.alloc(128);function s(h,i){p.call(this,"digest"),typeof i=="string"&&(i=L.from(i));var B=h==="sha512"||h==="sha384"?128:64;if(this._alg=h,this._key=i,i.length>B){var H=h==="rmd160"?new e:r(h);i=H.update(i).digest()}else i.length<B&&(i=L.concat([i,c],B));for(var j=this._ipad=L.allocUnsafe(B),k=this._opad=L.allocUnsafe(B),U=0;U<B;U++)j[U]=i[U]^54,k[U]=i[U]^92;this._hash=h==="rmd160"?new e:r(h),this._hash.update(j)}x(s,p),s.prototype._update=function(h){this._hash.update(h)},s.prototype._final=function(){var h=this._hash.digest(),i=this._alg==="rmd160"?new e:r(this._alg);return i.update(this._opad).update(h).digest()},Q.exports=function(i,B){return i=i.toLowerCase(),i==="rmd160"||i==="ripemd160"?new s("rmd160",B):i==="md5"?new n(b,B):new s(i,B)}},51031:function(Q,t,A){"use strict";var x=A(35717),n=A(89509).Buffer,p=A(71027),L=n.alloc(128),b=64;function e(r,c){p.call(this,"digest"),typeof c=="string"&&(c=n.from(c)),this._alg=r,this._key=c,c.length>b?c=r(c):c.length<b&&(c=n.concat([c,L],b));for(var s=this._ipad=n.allocUnsafe(b),h=this._opad=n.allocUnsafe(b),i=0;i<b;i++)s[i]=c[i]^54,h[i]=c[i]^92;this._hash=[s]}x(e,p),e.prototype._update=function(r){this._hash.push(r)},e.prototype._final=function(){var r=this._alg(n.concat(this._hash));return this._alg(n.concat([this._opad,r]))},Q.exports=e},95548:function(Q,t,A){t.unsigned=A(16922),A(44927)},44927:function(Q,t,A){const x=A(13550),n=A(53533);Q.exports={encode:e,decode:r,write:b,read:p,readBn:L};function p(c){return L(c).toString()}function L(c){const s=new x(0);let h=0,i;for(;i=c.read(1)[0],s.ior(new x(i&127).shln(h)),h+=7,i>>7!==0;);return i&64&&s.setn(h),s.fromTwos(h)}function b(c,s){let h=new x(c);const i=h.isNeg();for(i&&(h=h.toTwos(h.bitLength()+8));;){const H=h.maskn(7).toNumber();if(h.ishrn(7),B(h)&&(H&64)!==0||h.isZero()&&(H&64)===0){s.write([H]);break}else s.write([H|128])}function B(H){return i&&H.toString(2).indexOf("0")<0}}function e(c){const s=new n;return b(c,s),s.buffer}function r(c){const s=new n(c);return p(s)}},16922:function(Q,t,A){const x=A(13550),n=A(53533);Q.exports={encode:e,decode:r,read:p,readBn:L,write:b};function p(c){return L(c).toString()}function L(c){const s=new x(0);let h=0,i;for(;i=c.read(1)[0],s.ior(new x(i&127).shln(h)),i>>7!==0;)h+=7;return s}function b(c,s){const h=new x(c);for(;;){const i=h.maskn(7).toNumber();if(h.ishrn(7),h.isZero()){s.write([i]);break}else s.write([i|128])}}function e(c){const s=new n;return b(c,s),s.buffer}function r(c){const s=new n(c);return p(s)}},23145:function(Q,t,A){"use strict";A.d(t,{kL:function(){return W},Zc:function(){return e},rP:function(){return he},Pc:function(){return $},BG:function(){return g},WU:function(){return It},YW:function(){return wt},w5:function(){return D}});var x=A(9669),n=A(13550),p;(function(w){w.ETH="10"})(p||(p={}));const L=255;var b;(function(w){w[w.ID=0]="ID",w[w.SECP256K1=1]="SECP256K1",w[w.ACTOR=2]="ACTOR",w[w.BLS=3]="BLS",w[w.DELEGATED=4]="DELEGATED"})(b||(b={}));var e;(function(w){w.Mainnet="mainnet",w.Calibration="calibration",w.Butterfly="butterfly"})(e||(e={}));var r;(function(w){w.Mainnet="f",w.Testnet="t"})(r||(r={}));const c=20,s=54,h=48,i=20,B=20,H=9,j=new n(2).pow(new n(63)).sub(new n(1));var k;(function(w){w[w.Zero=0]="Zero"})(k||(k={}));var U;(function(w){w[w.Transfer=0]="Transfer",w[w.InvokeEVM=3844450837]="InvokeEVM"})(U||(U={}));var g;(function(w){w[w.SECP256K1=1]="SECP256K1",w[w.BLS=3]="BLS"})(g||(g={}));var v;(function(w){w[w.System=0]="System",w[w.Init=1]="Init",w[w.Reward=2]="Reward",w[w.Cron=3]="Cron",w[w.StoragePower=4]="StoragePower",w[w.StorageMarket=5]="StorageMarket",w[w.VerifiedRegistry=6]="VerifiedRegistry",w[w.DataCap=7]="DataCap",w[w.EAM=10]="EAM"})(v||(v={}));var C;(function(w){w[w.Exec=2]="Exec",w[w.Exec4=3]="Exec4"})(C||(C={}));var N;(function(w){w[w.UpdateChannelState=2]="UpdateChannelState",w[w.Settle=3]="Settle",w[w.Collect=4]="Collect"})(N||(N={}));var M;(function(w){w.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",w.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",w.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",w.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",w.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",w.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",w.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",w.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",w.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",w.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",w.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",w.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",w.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",w.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",w.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",w.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(M||(M={}));var f;(function(w){w.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",w.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",w.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",w.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",w.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",w.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",w.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",w.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",w.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",w.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",w.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",w.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",w.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",w.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",w.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",w.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(f||(f={}));var I=A(44501),_=A(95548);const O="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",l="0123456789ABCDEFGHIJKLMNOPQRSTUV",y="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function E(w,a,m){m=m||{};let R,V;switch(a){case"RFC3548":case"RFC4648":R=O,V=!0;break;case"RFC4648-HEX":R=l,V=!0;break;case"Crockford":R=y,V=!1;break}if(!R)throw new Error(`Unknown base32 variant: ${a}`);const it=m.padding!==void 0?m.padding:V,ft=T(w);let lt=0,yt=0,Pt="";for(let Lt=0;Lt<ft.byteLength;Lt++)for(yt=yt<<8|ft.getUint8(Lt),lt+=8;lt>=5;)Pt+=R[yt>>>lt-5&31],lt-=5;if(lt>0&&(Pt+=R[yt<<5-lt&31]),it)for(;Pt.length%8!==0;)Pt+="=";return Pt}function T(w){if(w instanceof Int8Array||w instanceof Uint8Array||w instanceof Uint8ClampedArray)return new DataView(w.buffer,w.byteOffset,w.byteLength);if(w instanceof ArrayBuffer)return new DataView(w);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class K extends Error{constructor(a){super(),this.message=`Invalid protocol indicator byte [${a}]`}}class z extends Error{constructor(a){super(),this.message="Unknown protocol indicator byte [${value}]"}}class Z extends Error{constructor(a){super(),this.message=`Invalid payload length [${a}]`}}class J extends Error{constructor(a){super(),this.message=`Invalid namespace [${a}]`}}class st extends Error{constructor(a){super(),this.message=`Invalid network [${a}]`}}class ut extends Error{constructor(){super(),this.message="Invalid subAddress."}}class q extends Error{constructor(a){super(),this.message=`${a} protocol not supported.`}}class nt extends Error{constructor(a,m){super(),this.message=`Invalid address (checksum not matching the payload). ${a} vs ${m}`}}class ht extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var G=A(1191),gt=A(48764).Buffer;function At(w){const a=G.blake2bInit(4);return G.blake2bUpdate(a,w),gt.from(G.blake2bFinal(a))}function Et(w){let a=0;for(;a<w.length;){const m=w[a];if(a++,m<128)break}return a==w.length?-1:a}const xt=w=>Object.values(r).includes(w),Yt=w=>Object.values(Network).includes(w),Ft=w=>w===e.Mainnet?r.Mainnet:r.Testnet,Tt=w=>w!==Network.Mainnet;var P=A(48764).Buffer;const ie=class{constructor(a,m){F(this,"networkPrefix");F(this,"protocol");F(this,"getPayload",()=>this.payload);F(this,"getNetworkPrefix",()=>this.networkPrefix);F(this,"getProtocol",()=>this.protocol);F(this,"getChecksum",()=>At(this.toBytes()));this.networkPrefix=a,this.protocol=m}};let W=ie;F(W,"fromString",a=>{const m=parseInt(a[1]);switch(m){case b.ID:return dt.fromString(a);case b.ACTOR:return mt.fromString(a);case b.SECP256K1:return pt.fromString(a);case b.BLS:return tt.fromString(a);case b.DELEGATED:{const R=Ct.fromString(a);return ie.isFilEthAddress(R)?new Rt(R.getNetworkPrefix(),R.getSubAddress()):R}default:throw new z(m)}}),F(W,"fromBytes",(a,m)=>{const R=m[0];switch(R){case b.ID:return dt.fromBytes(a,m);case b.ACTOR:return mt.fromBytes(a,m);case b.SECP256K1:return pt.fromBytes(a,m);case b.BLS:return tt.fromBytes(a,m);case b.DELEGATED:{const V=Ct.fromBytes(a,m);return ie.isFilEthAddress(V)?new Rt(V.getNetworkPrefix(),V.getSubAddress()):V}default:throw new z(R)}}),F(W,"fromEthAddress",(a,m)=>{if(typeof m=="string"){const V=m.startsWith("0x")?m.substring(2):m;m=P.from(V,"hex")}const R=P.alloc(12);if(R[0]=L,R.compare(m,0,12)==0){let V=12;for(;m[V]==0;)V+=1;return new dt(a,P.from(m.subarray(V)))}return new Rt(a,m)}),F(W,"isAddressId",a=>a.protocol==b.ID),F(W,"isAddressBls",a=>a.protocol==b.BLS),F(W,"isAddressSecp256k1",a=>a.protocol==b.SECP256K1),F(W,"isAddressDelegated",a=>a.protocol==b.DELEGATED),F(W,"isFilEthAddress",a=>a.protocol==b.DELEGATED&&"namespace"in a&&a.namespace==p.ETH),F(W,"isAddressActor",a=>a.protocol==b.ACTOR);class tt extends W{constructor(m,R){super(m,b.BLS);F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+E(P.concat([this.payload,m]),"RFC4648",{padding:!1}).toLowerCase()});if(R.byteLength!==h)throw new Z(R.byteLength);this.payload=R}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.BLS)throw new K(parseInt(V));const it=P.from(I(m.substring(2).toUpperCase(),"RFC4648")),ft=P.from(it.subarray(0,-4)),lt=P.from(it.subarray(-4)),yt=new tt(R,ft);if(yt.getChecksum().toString("hex")!==lt.toString("hex"))throw new nt(yt.getChecksum().toString("hex"),lt.toString("hex"));return yt}static fromBytes(m,R){if(R[0]!=b.BLS)throw new K(R[0]);const V=P.from(R.subarray(1));return new tt(m,V)}}class dt extends W{constructor(m,R){super(m,b.ID);F(this,"id");F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>this.networkPrefix+this.protocol.toString()+_.unsigned.decode(this.payload));F(this,"getId",()=>this.id);F(this,"toEthAddressHex",(m=!1)=>{const R=P.alloc(c);return R[0]=L,R.set(this.payload,c-this.payload.length),`${m?"0x":""}${R.toString("hex")}`});const V=typeof R=="string"?_.unsigned.encode(R):R;if(V.length>H)throw new Z(V.length);this.payload=V,this.id=this.toString().substring(2)}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.ID)throw new K(parseInt(V));const it=_.unsigned.encode(m.substring(2));return new dt(R,it)}static fromBytes(m,R){if(R[0]!=b.ID)throw new K(R[0]);const V=P.from(R.subarray(1));return new dt(m,V)}}class pt extends W{constructor(m,R){super(m,b.SECP256K1);F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+E(P.concat([this.payload,m]),"RFC4648",{padding:!1}).toLowerCase()});if(R.byteLength!==B)throw new Z(R.byteLength);this.payload=R}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.SECP256K1)throw new K(parseInt(V));const it=P.from(I(m.substring(2).toUpperCase(),"RFC4648")),ft=P.from(it.subarray(0,-4)),lt=P.from(it.subarray(-4)),yt=new pt(R,ft);if(yt.getChecksum().toString("hex")!==lt.toString("hex"))throw new nt(yt.getChecksum().toString("hex"),lt.toString("hex"));return yt}static fromBytes(m,R){if(R[0]!=b.SECP256K1)throw new K(R[0]);const V=P.from(R.subarray(1));return new pt(m,V)}}class mt extends W{constructor(m,R){super(m,b.ACTOR);F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+E(P.concat([this.payload,m]),"RFC4648",{padding:!1}).toLowerCase()});if(R.byteLength!==i)throw new Z(R.byteLength);this.payload=R}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.ACTOR)throw new K(parseInt(V));const it=P.from(I(m.substring(2).toUpperCase(),"RFC4648")),ft=P.from(it.subarray(0,-4)),lt=P.from(it.subarray(-4)),yt=new mt(R,ft);if(yt.getChecksum().toString("hex")!==lt.toString("hex"))throw new nt(yt.getChecksum().toString("hex"),lt.toString("hex"));return yt}static fromBytes(m,R){if(R[0]!=b.ACTOR)throw new K(R[0]);const V=P.from(R.subarray(1));return new mt(m,V)}}class Ct extends W{constructor(m,R,V){super(m,b.DELEGATED);F(this,"payload");F(this,"namespace");F(this,"subAddress");F(this,"getNamespace",()=>this.namespace);F(this,"getSubAddress",()=>this.subAddress);F(this,"toBytes",()=>{const m=P.from(_.unsigned.encode(this.namespace)),R=P.from(_.unsigned.encode(this.protocol));return P.concat([R,m,this.subAddress])});F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+E(P.concat([this.subAddress,m]),"RFC4648",{padding:!1}).toLowerCase()});if(new n(R).gt(j))throw new J(R);if(V.length===0||V.length>s)throw new ut;this.namespace=R,this.subAddress=V,this.payload=P.from(this.toBytes().subarray(1))}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.DELEGATED)throw new K(parseInt(V));const it=m.substring(2,m.indexOf("f",2)),ft=m.substring(m.indexOf("f",2)+1),lt=P.from(I(ft.toUpperCase(),"RFC4648")),yt=P.from(lt.subarray(0,-4)),Pt=P.from(lt.subarray(-4)),Lt=new Ct(R,it,yt);if(Lt.getChecksum().toString("hex")!==Pt.toString("hex"))throw new nt(Lt.getChecksum().toString("hex"),Pt.toString("hex"));return Lt}static fromBytes(m,R){if(R[0]!=b.DELEGATED)throw new K(R[0]);const V=Et(P.from(R.subarray(1))),it=_.unsigned.decode(P.from(R.subarray(1,1+V))),ft=P.from(R.subarray(V+1));return new Ct(m,it,ft)}}class Rt extends Ct{constructor(m,R){super(m,p.ETH,R);F(this,"toEthAddressHex",(m=!1)=>`${m?"0x":""}${this.subAddress.toString("hex")}`);if(R.length!==c)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(m,R){const V=Ct.fromBytes(m,R);if(V.getNamespace()!==p.ETH)throw new Error("invalid filecoin address for ethereum space");return new Rt(V.getNetworkPrefix(),V.getSubAddress())}static fromString(m){const R=Ct.fromString(m);if(R.getNamespace()!==p.ETH)throw new Error("invalid filecoin address for ethereum space");return new Rt(R.getNetworkPrefix(),R.getSubAddress())}}const kt="2.0",ae="Filecoin.MpoolGetNonce",Xt="Filecoin.MpoolPush",ce="Filecoin.StateWaitMsg",qt="Filecoin.GasEstimateMessageGas",fe="Filecoin.StateReadState",Qt="Filecoin.StateListMiners",Jt="Filecoin.StateMinerInfo",te="Filecoin.ClientQueryAsk",ue="Filecoin.WalletBalance";class he{constructor(a,m){F(this,"fetcher");F(this,"network");F(this,"getNetwork",()=>this.network);F(this,"validateNetwork",(a,m="address")=>{const R=Ft(this.network);if(typeof a=="string"&&(a=W.fromString(a)),a.getNetworkPrefix()!==R)throw new Error(`${m} belongs to ${a.getNetworkPrefix()} network while rpc allows ${R}`);return a});this.fetcher=x.create({baseURL:m.url,timeout:m.timeout,headers:{Authorization:`Bearer ${m.token}`}}),this.network=a}async getNonce(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:ae,id:1,params:[a.toString()]})).data}catch(m){return this.handleError(m)}}async broadcastTransaction(a,m){this.validateNetwork(a.to,"receiver"),this.validateNetwork(a.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:kt,method:Xt,id:1,params:[{Message:a.toJSON(),Signature:m.toJSON()}]})).data}catch(R){return this.handleError(R)}}async getGasEstimation(a){this.validateNetwork(a.to,"receiver"),this.validateNetwork(a.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:kt,method:qt,id:1,params:[a.toJSON(),{MaxFee:"0"},null]})).data}catch(m){return this.handleError(m)}}async readState(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:fe,id:1,params:[a.toString(),null]})).data}catch(m){return this.handleError(m)}}async waitMsgState(a,m,R){try{return(await this.fetcher.post("",{jsonrpc:kt,method:ce,id:1,params:[a,m,R,!1]})).data}catch(V){return this.handleError(V)}}async walletBalance(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:ue,id:1,params:[a.toString()]})).data}catch(m){return this.handleError(m)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:kt,method:Qt,id:1,params:[null]})).data}catch(a){return this.handleError(a)}}async getMinerInfo(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:Jt,id:1,params:[a.toString(),null]})).data}catch(m){return this.handleError(m)}}async askForStorage(a,m){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:te,id:1,params:[m,a.toString()]})).data}catch(R){return this.handleError(R)}}handleError(a){if(x.isAxiosError(a)){if(a.response){if(a.response.data)return a.response.data;if(a.response.statusText)return{error:{message:`${a.response.status} - ${a.response.statusText}`}}}if(a.request)return{error:{message:"request made but no response received"}};if(a.message)return{error:{message:a.message}}}throw a}}class we extends null{constructor(a){super(Network.Mainnet,a)}}class ye extends null{constructor(a){super(Network.Calibration,a)}}class Vt extends null{constructor(a){super(Network.Butterfly,a)}}var Nt=A(2153),le=A(81224),ee=A(77235),de=A.t(ee,2),Mt=A(48057),Ot=A(48764).Buffer;const re=Ot.from([1,113,160,228,2,32]),ne=32,oe=w=>{const a=w.split("/");return a[2].includes("'")?a[2].substring(0,a[2].length-1):a[2]};function vt(w){const a=G.blake2bInit(ne);G.blake2bUpdate(a,w);const m=Ot.from(G.blake2bFinal(a));return Ot.concat([re,m])}function Ut(w){const a=G.blake2bInit(32);return G.blake2bUpdate(a,vt(w)),Ot.from(G.blake2bFinal(a))}const _t=w=>{if(typeof w=="string")if(w.substring(w.length-1)==="=")w=Ot.from(w,"base64");else throw new ht;if(w.length!==32)throw new ht;return w},d=w=>{const a=G.blake2bInit(20);return G.blake2bUpdate(a,w),Ot.from(G.blake2bFinal(a))},o=w=>g.BLS===w||g.SECP256K1===w;var u=A(48764).Buffer;const S=le.GA(de),Gt=class{static recoverAccount(a,m,R,V){switch(m){case g.SECP256K1:{R=_t(R);const{publicKey:it,address:ft}=Gt.getPublicSecp256k1FromPrivKey(a,R);return{type:m,privateKey:R,address:ft,publicKey:it,path:V}}default:throw new Error("not supported yet")}}};let D=Gt;F(D,"generateMnemonic",()=>Nt.generateMnemonic(256)),F(D,"mnemonicToSeed",(a,m)=>Nt.mnemonicToSeedSync(a,m)),F(D,"deriveAccount",(a,m,R,V,it)=>{const ft=Gt.mnemonicToSeed(a,V);return Gt.deriveAccountFromSeed(ft,m,R,it)}),F(D,"deriveAccountFromSeed",(a,m,R,V)=>{switch(typeof a=="string"&&(a=u.from(a,"hex")),m){case g.SECP256K1:{const it=S.fromSeed(a),{privateKey:ft}=it.derivePath(R);if(!ft)throw new Error("privateKey not generated");V||(V=oe(R)==="1"?r.Testnet:r.Mainnet);const{publicKey:lt,address:yt}=Gt.getPublicSecp256k1FromPrivKey(V,ft);return{type:m,privateKey:ft,publicKey:lt,address:yt,path:R}}default:throw new Error("not supported yet")}}),F(D,"signTransaction",async(a,m)=>{const R=await m.serialize(),V=Ut(R),{privateKey:it,type:ft}=a;switch(ft){case g.SECP256K1:{const lt=Mt.ecdsaSign(V,it);return new $(ft,u.concat([u.from(lt.signature),u.from([lt.recid])]))}default:throw new Error("not supported yet")}}),F(D,"verifySignature",async(a,m)=>{const R=await m.serialize(),V=Ut(R);switch(a.getType()){case g.SECP256K1:{const it=a.getData(),ft=Mt.ecdsaRecover(it.subarray(0,-1),it[64],V,!1),lt=d(ft);return m.from.getPayload().toString("hex")!==lt.toString("hex")?!1:Mt.ecdsaVerify(it.subarray(0,-1),V,ft)}default:throw new Error("not supported yet")}}),F(D,"getPublicSecp256k1FromPrivKey",(a,m)=>{const R=Mt.publicKeyCreate(m),V=new Uint8Array(65);Mt.publicKeyConvert(R,!1,V);const it=u.from(V),ft=d(V);return{publicKey:it,address:new pt(a,ft)}});const be=class{constructor(a,m){F(this,"type");F(this,"data");F(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));F(this,"getType",()=>this.type);F(this,"getData",()=>this.data);F(this,"isSecp256k1",()=>this.type===g.SECP256K1);F(this,"isBls",()=>this.type===g.BLS);this.type=a,this.data=m}};let $=be;F($,"fromJSON",a=>{if(typeof a!="object"||a===null)throw new Error("input should be an object");if(!("Type"in a)||typeof a.Type!="number")throw new Error("'Type' should be a number");if(!o(a.Type))throw new Error("invalid signature type");if(!("Data"in a)||typeof a.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new be(a.Type,u.from(a.Data,"base64"))});var Y=A(48764).Buffer;const X=(w,a=10)=>{if(w.toString()==="0")return Y.from("");const m=new n(w,a),R=m.toArrayLike(Y,"be",m.byteLength()),V=Y.from(m.isNeg()?"01":"00","hex");return Y.concat([V,R])},rt=(w,a=10)=>{if(w.length===0)return"0";if(w[0]!=0&&w[0]!=1)throw new Error("invalid bigint");const m=w[0]===1?"-":"",R=new n(w.subarray(1));return m+R.toString(a)},et=w=>new Promise(a=>setTimeout(a,w)),ot=async w=>{let a=w();for(;!a;)await et(50),a=w();return a};var at=A(48764).Buffer;let ct;A.e(8190).then(A.bind(A,88190)).then(w=>{ct=w}).catch(w=>{throw w});const Zt=class{constructor(a,m,R,V,it,ft,lt,yt,Pt,Lt){F(this,"version");F(this,"to");F(this,"from");F(this,"nonce");F(this,"value");F(this,"gasLimit");F(this,"gasFeeCap");F(this,"gasPremium");F(this,"method");F(this,"params");F(this,"toJSON",()=>({To:this.to.toString(),From:this.from.toString(),Nonce:this.nonce,Value:this.value,Params:this.params,GasFeeCap:this.gasFeeCap,GasPremium:this.gasPremium,GasLimit:this.gasLimit,Method:this.method}));F(this,"serialize",async()=>{const a=await ot(()=>ct),m=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,X(this.value,10),this.gasLimit,X(this.gasFeeCap,10),X(this.gasPremium,10),this.method,at.from(this.params,"base64")];return at.from(a.encode(m))});F(this,"prepareToSend",async a=>{const m=await a.getNonce(this.from);if("error"in m)throw new Error(m.error.message);this.nonce=m.result;const R=await a.getGasEstimation(this);if("error"in R)throw new Error(R.error.message);return this.gasFeeCap=R.result.GasFeeCap,this.gasLimit=R.result.GasLimit,this.gasPremium=R.result.GasPremium,this});if(this.version=a,this.to=m,this.from=R,this.nonce=V,this.value=it,this.gasLimit=ft,this.gasFeeCap=lt,this.gasPremium=yt,this.method=Pt,this.params=Lt,it===""||it.includes("-"))throw new Error("value must not be empty or negative")}};let wt=Zt;F(wt,"getNew",(a,m,R,V,it=at.alloc(0))=>new Zt(k.Zero,a,m,0,R.toAtto(),0,"0","0",V,it.toString("base64"))),F(wt,"fromCBOR",async(a,m)=>{typeof m=="string"&&(m=at.from(m,"hex"));const V=(await ot(()=>ct)).decode(m);if(!(V instanceof Array))throw new Error("Decoded raw tx should be an array");if(V.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[it,ft,lt,yt,Pt,Lt,ke,Ue,He,Le]=V;if(it!==k.Zero)throw new Error("Unsupported version");if(Pt[0]===1)throw new Error("Value cant be negative");const Te=new n(at.from(Pt).toString("hex"),16).toString(10),Re=new n(at.from(ke).toString("hex"),16).toString(10),Ne=new n(at.from(Ue).toString("hex"),16).toString(10);return new Zt(it,W.fromBytes(a,ft),W.fromBytes(a,lt),yt,Te,Lt,Re,Ne,He,Le.toString("base64"))}),F(wt,"fromJSON",a=>{if(typeof a!="object"||a==null)throw new Error("tx should be an json object");if(!("To"in a)||typeof a.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in a)||typeof a.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in a)||typeof a.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in a)||typeof a.Value!="string"||a.Value===""||a.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in a)||typeof a.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in a)||typeof a.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in a)||typeof a.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in a)||typeof a.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in a)||typeof a.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new Zt(k.Zero,W.fromString(a.To),W.fromString(a.From),a.Nonce,a.Value,a.GasLimit,a.GasFeeCap,a.GasPremium,a.Method,a.Params)});const bt=(w,a)=>{const m=w.isNeg()?"-":"",R=w.abs().toString(),V=R.length-a,it=Bt(V>0?`${R.substring(0,V)}.${R.substring(V)}`:`0.${"".padStart(-1*V,"0")}${R}`);return`${m}${it}`},Bt=w=>{for(let a=w.length-1;a>=0;a--){if(w[a]==".")return w.substring(0,a);if(w[a]!="0"||a===1)return w.substring(0,a+1)}throw new Error("invalid value")},St=18,Kt=15,Dt=12,jt=9,$t=6,zt=3,ve=0,Se=new n(10).pow(new n(zt)),Ae=new n(10).pow(new n($t)),Be=new n(10).pow(new n(jt)),Pe=new n(10).pow(new n(Dt)),Ce=new n(10).pow(new n(Kt)),Ie=new n(10).pow(new n(St)),Ht=class{constructor(a){F(this,"value");F(this,"add",a=>(this.value=this.value.add(a.value),this));F(this,"sub",a=>(this.value=this.value.sub(a.value),this));F(this,"gt",a=>this.value.gt(a.value));F(this,"gte",a=>this.value.gte(a.value));F(this,"lt",a=>this.value.lt(a.value));F(this,"lte",a=>this.value.lte(a.value));F(this,"isNegative",()=>this.value.isNeg());F(this,"isPositive",()=>!this.value.isNeg());F(this,"isZero",()=>this.value.isZero());F(this,"toWhole",()=>bt(this.value,St));F(this,"toMilli",()=>bt(this.value,St-zt));F(this,"toMicro",()=>bt(this.value,St-$t));F(this,"toNano",()=>bt(this.value,St-jt));F(this,"toPico",()=>bt(this.value,St-Dt));F(this,"toFemto",()=>bt(this.value,St-Kt));F(this,"toAtto",()=>bt(this.value,0));F(this,"serialize",()=>X(this.value.toString(10),10));this.value=a}};let It=Ht;F(It,"zero",()=>new Ht(new n("0"))),F(It,"deserialize",a=>new Ht(new n(rt(a,10),10))),F(It,"fromAtto",a=>new Ht(new n(a))),F(It,"fromFemto",a=>new Ht(new n(a).mul(Se))),F(It,"fromPico",a=>new Ht(new n(a).mul(Ae))),F(It,"fromNano",a=>new Ht(new n(a).mul(Be))),F(It,"fromMicro",a=>new Ht(new n(a).mul(Pe))),F(It,"fromMilli",a=>new Ht(new n(a).mul(Ce))),F(It,"fromWhole",a=>new Ht(new n(a).mul(Ie)));class ge{}F(ge,"send",null),F(ge,"getBalance",null);var De=A(48764).Buffer;class pe{}F(pe,"newTx",null),F(pe,"newExecTx",null);let me;A.e(8190).then(A.bind(A,88190)).then(w=>{me=w}).catch(w=>{throw w});let Ee;A.e(9068).then(A.bind(A,59068)).then(w=>{Ee=w}).catch(w=>{throw w});class ze{constructor(a,m){F(this,"targetActorCid");F(this,"targetConstructorParams");F(this,"serialize",async()=>{const a=await waitFor(()=>me),m=await waitFor(()=>Ee);return a.encode([m.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=a,this.targetConstructorParams=m}}let xe;A.e(8190).then(A.bind(A,88190)).then(w=>{xe=w}).catch(w=>{throw w});class Fe{constructor(a,m){F(this,"from");F(this,"to");F(this,"serialize",async()=>(await waitFor(()=>xe)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=a,this.to=m}}const Me=w=>{switch(w){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},se=class{constructor(a,m,R){F(this,"channelAddress");F(this,"from");F(this,"to");F(this,"getAddress",()=>this.channelAddress);F(this,"getTo",()=>this.to);F(this,"getFrom",()=>this.from);F(this,"settle",(a,m)=>{const{address:R}=m,V=Transaction.getNew(this.channelAddress,R,Token.zero(),PayChActorMethods.Settle);return se.sendTx(a,m,V)});F(this,"collect",(a,m)=>{const{address:R}=m,V=Transaction.getNew(this.channelAddress,R,Token.zero(),PayChActorMethods.Collect);return se.sendTx(a,m,V)});this.channelAddress=a,this.from=m,this.to=R}};let Wt=se;F(Wt,"create",null),F(Wt,"loadFromCid",null),F(Wt,"sendTx",null)}}]);
|
|
4
|
+
`+new Array(b.length+4).join(" "):s<e.length-2&&(c+=" ")}console.log(c)}function L(b,e,r){let c=new Date().getTime();const s=new Uint8Array(e);for(let i=0;i<e;i++)s[i]=i%256;const h=new Date().getTime();console.log("Generated random input in "+(h-c)+"ms"),c=h;for(let i=0;i<r;i++){const B=b(s),H=new Date().getTime(),j=H-c;c=H,console.log("Hashed in "+j+"ms: "+B.substring(0,20)+"..."),console.log(Math.round(e/(1<<20)/(j/1e3)*100)/100+" MB PER SECOND")}}Q.exports={normalizeInput:A,toHex:x,debugPrint:p,testSpeed:L}},77191:function(Q,t,A){var x=A(58162),n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Q.exports=x(n)},53310:function(Q,t,A){"use strict";var x=A(77191),n=A(89509).Buffer;Q.exports=function(p){function L(c){var s=p(c);return x.encode(n.concat([c,s],c.length+4))}function b(c){var s=c.slice(0,-4),h=c.slice(-4),i=p(s);if(!(h[0]^i[0]|h[1]^i[1]|h[2]^i[2]|h[3]^i[3]))return s}function e(c){var s=x.decodeUnsafe(c);if(!!s)return b(s)}function r(c){var s=x.decode(c),h=b(s,p);if(!h)throw new Error("Invalid checksum");return h}return{encode:L,decode:r,decodeUnsafe:e}}},58334:function(Q,t,A){"use strict";var x=A(23482),n=A(53310);function p(L){var b=x("sha256").update(L).digest();return x("sha256").update(b).digest()}Q.exports=n(p)},53533:function(Q,t,A){const x=A(89509).Buffer;Q.exports=class{constructor(p=x.from([])){this.buffer=p,this._bytesRead=0,this._bytesWrote=0}read(p){this._bytesRead+=p;const L=this.buffer.slice(0,p);return this.buffer=this.buffer.slice(p),L}write(p){p=x.from(p),this._bytesWrote+=p.length,this.buffer=x.concat([this.buffer,p])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},58355:function(Q,t,A){"use strict";var x=A(35717),n=A(51031),p=A(71027),L=A(89509).Buffer,b=A(78028),e=A(79785),r=A(89072),c=L.alloc(128);function s(h,i){p.call(this,"digest"),typeof i=="string"&&(i=L.from(i));var B=h==="sha512"||h==="sha384"?128:64;if(this._alg=h,this._key=i,i.length>B){var H=h==="rmd160"?new e:r(h);i=H.update(i).digest()}else i.length<B&&(i=L.concat([i,c],B));for(var j=this._ipad=L.allocUnsafe(B),k=this._opad=L.allocUnsafe(B),U=0;U<B;U++)j[U]=i[U]^54,k[U]=i[U]^92;this._hash=h==="rmd160"?new e:r(h),this._hash.update(j)}x(s,p),s.prototype._update=function(h){this._hash.update(h)},s.prototype._final=function(){var h=this._hash.digest(),i=this._alg==="rmd160"?new e:r(this._alg);return i.update(this._opad).update(h).digest()},Q.exports=function(i,B){return i=i.toLowerCase(),i==="rmd160"||i==="ripemd160"?new s("rmd160",B):i==="md5"?new n(b,B):new s(i,B)}},51031:function(Q,t,A){"use strict";var x=A(35717),n=A(89509).Buffer,p=A(71027),L=n.alloc(128),b=64;function e(r,c){p.call(this,"digest"),typeof c=="string"&&(c=n.from(c)),this._alg=r,this._key=c,c.length>b?c=r(c):c.length<b&&(c=n.concat([c,L],b));for(var s=this._ipad=n.allocUnsafe(b),h=this._opad=n.allocUnsafe(b),i=0;i<b;i++)s[i]=c[i]^54,h[i]=c[i]^92;this._hash=[s]}x(e,p),e.prototype._update=function(r){this._hash.push(r)},e.prototype._final=function(){var r=this._alg(n.concat(this._hash));return this._alg(n.concat([this._opad,r]))},Q.exports=e},95548:function(Q,t,A){t.unsigned=A(16922),A(44927)},44927:function(Q,t,A){const x=A(13550),n=A(53533);Q.exports={encode:e,decode:r,write:b,read:p,readBn:L};function p(c){return L(c).toString()}function L(c){const s=new x(0);let h=0,i;for(;i=c.read(1)[0],s.ior(new x(i&127).shln(h)),h+=7,i>>7!==0;);return i&64&&s.setn(h),s.fromTwos(h)}function b(c,s){let h=new x(c);const i=h.isNeg();for(i&&(h=h.toTwos(h.bitLength()+8));;){const H=h.maskn(7).toNumber();if(h.ishrn(7),B(h)&&(H&64)!==0||h.isZero()&&(H&64)===0){s.write([H]);break}else s.write([H|128])}function B(H){return i&&H.toString(2).indexOf("0")<0}}function e(c){const s=new n;return b(c,s),s.buffer}function r(c){const s=new n(c);return p(s)}},16922:function(Q,t,A){const x=A(13550),n=A(53533);Q.exports={encode:e,decode:r,read:p,readBn:L,write:b};function p(c){return L(c).toString()}function L(c){const s=new x(0);let h=0,i;for(;i=c.read(1)[0],s.ior(new x(i&127).shln(h)),i>>7!==0;)h+=7;return s}function b(c,s){const h=new x(c);for(;;){const i=h.maskn(7).toNumber();if(h.ishrn(7),h.isZero()){s.write([i]);break}else s.write([i|128])}}function e(c){const s=new n;return b(c,s),s.buffer}function r(c){const s=new n(c);return p(s)}},23145:function(Q,t,A){"use strict";A.d(t,{kL:function(){return W},Zc:function(){return e},PY:function(){return r},rP:function(){return he},Pc:function(){return $},BG:function(){return g},WU:function(){return It},YW:function(){return wt},w5:function(){return D}});var x=A(9669),n=A(13550),p;(function(w){w.ETH="10"})(p||(p={}));const L=255;var b;(function(w){w[w.ID=0]="ID",w[w.SECP256K1=1]="SECP256K1",w[w.ACTOR=2]="ACTOR",w[w.BLS=3]="BLS",w[w.DELEGATED=4]="DELEGATED"})(b||(b={}));var e;(function(w){w.Mainnet="mainnet",w.Calibration="calibration",w.Butterfly="butterfly"})(e||(e={}));var r;(function(w){w.Mainnet="f",w.Testnet="t"})(r||(r={}));const c=20,s=54,h=48,i=20,B=20,H=9,j=new n(2).pow(new n(63)).sub(new n(1));var k;(function(w){w[w.Zero=0]="Zero"})(k||(k={}));var U;(function(w){w[w.Transfer=0]="Transfer",w[w.InvokeEVM=3844450837]="InvokeEVM"})(U||(U={}));var g;(function(w){w[w.SECP256K1=1]="SECP256K1",w[w.BLS=3]="BLS"})(g||(g={}));var v;(function(w){w[w.System=0]="System",w[w.Init=1]="Init",w[w.Reward=2]="Reward",w[w.Cron=3]="Cron",w[w.StoragePower=4]="StoragePower",w[w.StorageMarket=5]="StorageMarket",w[w.VerifiedRegistry=6]="VerifiedRegistry",w[w.DataCap=7]="DataCap",w[w.EAM=10]="EAM"})(v||(v={}));var C;(function(w){w[w.Exec=2]="Exec",w[w.Exec4=3]="Exec4"})(C||(C={}));var N;(function(w){w[w.UpdateChannelState=2]="UpdateChannelState",w[w.Settle=3]="Settle",w[w.Collect=4]="Collect"})(N||(N={}));var M;(function(w){w.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",w.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",w.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",w.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",w.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",w.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",w.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",w.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",w.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",w.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",w.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",w.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",w.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",w.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",w.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",w.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(M||(M={}));var f;(function(w){w.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",w.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",w.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",w.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",w.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",w.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",w.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",w.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",w.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",w.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",w.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",w.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",w.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",w.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",w.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",w.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(f||(f={}));var I=A(44501),_=A(95548);const O="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",l="0123456789ABCDEFGHIJKLMNOPQRSTUV",y="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function E(w,a,m){m=m||{};let R,V;switch(a){case"RFC3548":case"RFC4648":R=O,V=!0;break;case"RFC4648-HEX":R=l,V=!0;break;case"Crockford":R=y,V=!1;break}if(!R)throw new Error(`Unknown base32 variant: ${a}`);const it=m.padding!==void 0?m.padding:V,ft=T(w);let lt=0,yt=0,Pt="";for(let Lt=0;Lt<ft.byteLength;Lt++)for(yt=yt<<8|ft.getUint8(Lt),lt+=8;lt>=5;)Pt+=R[yt>>>lt-5&31],lt-=5;if(lt>0&&(Pt+=R[yt<<5-lt&31]),it)for(;Pt.length%8!==0;)Pt+="=";return Pt}function T(w){if(w instanceof Int8Array||w instanceof Uint8Array||w instanceof Uint8ClampedArray)return new DataView(w.buffer,w.byteOffset,w.byteLength);if(w instanceof ArrayBuffer)return new DataView(w);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class K extends Error{constructor(a){super(),this.message=`Invalid protocol indicator byte [${a}]`}}class z extends Error{constructor(a){super(),this.message="Unknown protocol indicator byte [${value}]"}}class Z extends Error{constructor(a){super(),this.message=`Invalid payload length [${a}]`}}class J extends Error{constructor(a){super(),this.message=`Invalid namespace [${a}]`}}class st extends Error{constructor(a){super(),this.message=`Invalid network [${a}]`}}class ut extends Error{constructor(){super(),this.message="Invalid subAddress."}}class q extends Error{constructor(a){super(),this.message=`${a} protocol not supported.`}}class nt extends Error{constructor(a,m){super(),this.message=`Invalid address (checksum not matching the payload). ${a} vs ${m}`}}class ht extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var G=A(1191),gt=A(48764).Buffer;function At(w){const a=G.blake2bInit(4);return G.blake2bUpdate(a,w),gt.from(G.blake2bFinal(a))}function Et(w){let a=0;for(;a<w.length;){const m=w[a];if(a++,m<128)break}return a==w.length?-1:a}const xt=w=>Object.values(r).includes(w),Yt=w=>Object.values(Network).includes(w),Ft=w=>w===e.Mainnet?r.Mainnet:r.Testnet,Tt=w=>w!==Network.Mainnet;var P=A(48764).Buffer;const ie=class{constructor(a,m){F(this,"networkPrefix");F(this,"protocol");F(this,"getPayload",()=>this.payload);F(this,"getNetworkPrefix",()=>this.networkPrefix);F(this,"getProtocol",()=>this.protocol);F(this,"getChecksum",()=>At(this.toBytes()));this.networkPrefix=a,this.protocol=m}};let W=ie;F(W,"fromString",a=>{const m=parseInt(a[1]);switch(m){case b.ID:return dt.fromString(a);case b.ACTOR:return mt.fromString(a);case b.SECP256K1:return pt.fromString(a);case b.BLS:return tt.fromString(a);case b.DELEGATED:{const R=Ct.fromString(a);return ie.isFilEthAddress(R)?new Rt(R.getNetworkPrefix(),R.getSubAddress()):R}default:throw new z(m)}}),F(W,"fromBytes",(a,m)=>{const R=m[0];switch(R){case b.ID:return dt.fromBytes(a,m);case b.ACTOR:return mt.fromBytes(a,m);case b.SECP256K1:return pt.fromBytes(a,m);case b.BLS:return tt.fromBytes(a,m);case b.DELEGATED:{const V=Ct.fromBytes(a,m);return ie.isFilEthAddress(V)?new Rt(V.getNetworkPrefix(),V.getSubAddress()):V}default:throw new z(R)}}),F(W,"fromEthAddress",(a,m)=>{if(typeof m=="string"){const V=m.startsWith("0x")?m.substring(2):m;m=P.from(V,"hex")}const R=P.alloc(12);if(R[0]=L,R.compare(m,0,12)==0){let V=12;for(;m[V]==0;)V+=1;return new dt(a,P.from(m.subarray(V)))}return new Rt(a,m)}),F(W,"isAddressId",a=>a.protocol==b.ID),F(W,"isAddressBls",a=>a.protocol==b.BLS),F(W,"isAddressSecp256k1",a=>a.protocol==b.SECP256K1),F(W,"isAddressDelegated",a=>a.protocol==b.DELEGATED),F(W,"isFilEthAddress",a=>a.protocol==b.DELEGATED&&"namespace"in a&&a.namespace==p.ETH),F(W,"isAddressActor",a=>a.protocol==b.ACTOR);class tt extends W{constructor(m,R){super(m,b.BLS);F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+E(P.concat([this.payload,m]),"RFC4648",{padding:!1}).toLowerCase()});if(R.byteLength!==h)throw new Z(R.byteLength);this.payload=R}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.BLS)throw new K(parseInt(V));const it=P.from(I(m.substring(2).toUpperCase(),"RFC4648")),ft=P.from(it.subarray(0,-4)),lt=P.from(it.subarray(-4)),yt=new tt(R,ft);if(yt.getChecksum().toString("hex")!==lt.toString("hex"))throw new nt(yt.getChecksum().toString("hex"),lt.toString("hex"));return yt}static fromBytes(m,R){if(R[0]!=b.BLS)throw new K(R[0]);const V=P.from(R.subarray(1));return new tt(m,V)}}class dt extends W{constructor(m,R){super(m,b.ID);F(this,"id");F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>this.networkPrefix+this.protocol.toString()+_.unsigned.decode(this.payload));F(this,"getId",()=>this.id);F(this,"toEthAddressHex",(m=!1)=>{const R=P.alloc(c);return R[0]=L,R.set(this.payload,c-this.payload.length),`${m?"0x":""}${R.toString("hex")}`});const V=typeof R=="string"?_.unsigned.encode(R):R;if(V.length>H)throw new Z(V.length);this.payload=V,this.id=this.toString().substring(2)}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.ID)throw new K(parseInt(V));const it=_.unsigned.encode(m.substring(2));return new dt(R,it)}static fromBytes(m,R){if(R[0]!=b.ID)throw new K(R[0]);const V=P.from(R.subarray(1));return new dt(m,V)}}class pt extends W{constructor(m,R){super(m,b.SECP256K1);F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+E(P.concat([this.payload,m]),"RFC4648",{padding:!1}).toLowerCase()});if(R.byteLength!==B)throw new Z(R.byteLength);this.payload=R}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.SECP256K1)throw new K(parseInt(V));const it=P.from(I(m.substring(2).toUpperCase(),"RFC4648")),ft=P.from(it.subarray(0,-4)),lt=P.from(it.subarray(-4)),yt=new pt(R,ft);if(yt.getChecksum().toString("hex")!==lt.toString("hex"))throw new nt(yt.getChecksum().toString("hex"),lt.toString("hex"));return yt}static fromBytes(m,R){if(R[0]!=b.SECP256K1)throw new K(R[0]);const V=P.from(R.subarray(1));return new pt(m,V)}}class mt extends W{constructor(m,R){super(m,b.ACTOR);F(this,"payload");F(this,"toBytes",()=>P.concat([P.from(`0${this.protocol}`,"hex"),this.payload]));F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+E(P.concat([this.payload,m]),"RFC4648",{padding:!1}).toLowerCase()});if(R.byteLength!==i)throw new Z(R.byteLength);this.payload=R}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.ACTOR)throw new K(parseInt(V));const it=P.from(I(m.substring(2).toUpperCase(),"RFC4648")),ft=P.from(it.subarray(0,-4)),lt=P.from(it.subarray(-4)),yt=new mt(R,ft);if(yt.getChecksum().toString("hex")!==lt.toString("hex"))throw new nt(yt.getChecksum().toString("hex"),lt.toString("hex"));return yt}static fromBytes(m,R){if(R[0]!=b.ACTOR)throw new K(R[0]);const V=P.from(R.subarray(1));return new mt(m,V)}}class Ct extends W{constructor(m,R,V){super(m,b.DELEGATED);F(this,"payload");F(this,"namespace");F(this,"subAddress");F(this,"getNamespace",()=>this.namespace);F(this,"getSubAddress",()=>this.subAddress);F(this,"toBytes",()=>{const m=P.from(_.unsigned.encode(this.namespace)),R=P.from(_.unsigned.encode(this.protocol));return P.concat([R,m,this.subAddress])});F(this,"toString",()=>{const m=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+E(P.concat([this.subAddress,m]),"RFC4648",{padding:!1}).toLowerCase()});if(new n(R).gt(j))throw new J(R);if(V.length===0||V.length>s)throw new ut;this.namespace=R,this.subAddress=V,this.payload=P.from(this.toBytes().subarray(1))}static fromString(m){const R=m[0],V=m[1];if(!xt(R))throw new st(R);if(parseInt(V)!=b.DELEGATED)throw new K(parseInt(V));const it=m.substring(2,m.indexOf("f",2)),ft=m.substring(m.indexOf("f",2)+1),lt=P.from(I(ft.toUpperCase(),"RFC4648")),yt=P.from(lt.subarray(0,-4)),Pt=P.from(lt.subarray(-4)),Lt=new Ct(R,it,yt);if(Lt.getChecksum().toString("hex")!==Pt.toString("hex"))throw new nt(Lt.getChecksum().toString("hex"),Pt.toString("hex"));return Lt}static fromBytes(m,R){if(R[0]!=b.DELEGATED)throw new K(R[0]);const V=Et(P.from(R.subarray(1))),it=_.unsigned.decode(P.from(R.subarray(1,1+V))),ft=P.from(R.subarray(V+1));return new Ct(m,it,ft)}}class Rt extends Ct{constructor(m,R){super(m,p.ETH,R);F(this,"toEthAddressHex",(m=!1)=>`${m?"0x":""}${this.subAddress.toString("hex")}`);if(R.length!==c)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(m,R){const V=Ct.fromBytes(m,R);if(V.getNamespace()!==p.ETH)throw new Error("invalid filecoin address for ethereum space");return new Rt(V.getNetworkPrefix(),V.getSubAddress())}static fromString(m){const R=Ct.fromString(m);if(R.getNamespace()!==p.ETH)throw new Error("invalid filecoin address for ethereum space");return new Rt(R.getNetworkPrefix(),R.getSubAddress())}}const kt="2.0",ae="Filecoin.MpoolGetNonce",Xt="Filecoin.MpoolPush",ce="Filecoin.StateWaitMsg",qt="Filecoin.GasEstimateMessageGas",fe="Filecoin.StateReadState",Qt="Filecoin.StateListMiners",Jt="Filecoin.StateMinerInfo",te="Filecoin.ClientQueryAsk",ue="Filecoin.WalletBalance";class he{constructor(a,m){F(this,"fetcher");F(this,"network");F(this,"getNetwork",()=>this.network);F(this,"validateNetwork",(a,m="address")=>{const R=Ft(this.network);if(typeof a=="string"&&(a=W.fromString(a)),a.getNetworkPrefix()!==R)throw new Error(`${m} belongs to ${a.getNetworkPrefix()} network while rpc allows ${R}`);return a});this.fetcher=x.create({baseURL:m.url,timeout:m.timeout,headers:{Authorization:`Bearer ${m.token}`}}),this.network=a}async getNonce(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:ae,id:1,params:[a.toString()]})).data}catch(m){return this.handleError(m)}}async broadcastTransaction(a,m){this.validateNetwork(a.to,"receiver"),this.validateNetwork(a.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:kt,method:Xt,id:1,params:[{Message:a.toJSON(),Signature:m.toJSON()}]})).data}catch(R){return this.handleError(R)}}async getGasEstimation(a){this.validateNetwork(a.to,"receiver"),this.validateNetwork(a.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:kt,method:qt,id:1,params:[a.toJSON(),{MaxFee:"0"},null]})).data}catch(m){return this.handleError(m)}}async readState(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:fe,id:1,params:[a.toString(),null]})).data}catch(m){return this.handleError(m)}}async waitMsgState(a,m,R){try{return(await this.fetcher.post("",{jsonrpc:kt,method:ce,id:1,params:[a,m,R,!1]})).data}catch(V){return this.handleError(V)}}async walletBalance(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:ue,id:1,params:[a.toString()]})).data}catch(m){return this.handleError(m)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:kt,method:Qt,id:1,params:[null]})).data}catch(a){return this.handleError(a)}}async getMinerInfo(a){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:Jt,id:1,params:[a.toString(),null]})).data}catch(m){return this.handleError(m)}}async askForStorage(a,m){a=this.validateNetwork(a);try{return(await this.fetcher.post("",{jsonrpc:kt,method:te,id:1,params:[m,a.toString()]})).data}catch(R){return this.handleError(R)}}handleError(a){if(x.isAxiosError(a)){if(a.response){if(a.response.data)return a.response.data;if(a.response.statusText)return{error:{message:`${a.response.status} - ${a.response.statusText}`}}}if(a.request)return{error:{message:"request made but no response received"}};if(a.message)return{error:{message:a.message}}}throw a}}class we extends null{constructor(a){super(Network.Mainnet,a)}}class ye extends null{constructor(a){super(Network.Calibration,a)}}class Vt extends null{constructor(a){super(Network.Butterfly,a)}}var Nt=A(2153),le=A(81224),ee=A(77235),de=A.t(ee,2),Mt=A(48057),Ot=A(48764).Buffer;const re=Ot.from([1,113,160,228,2,32]),ne=32,oe=w=>{const a=w.split("/");return a[2].includes("'")?a[2].substring(0,a[2].length-1):a[2]};function vt(w){const a=G.blake2bInit(ne);G.blake2bUpdate(a,w);const m=Ot.from(G.blake2bFinal(a));return Ot.concat([re,m])}function Ut(w){const a=G.blake2bInit(32);return G.blake2bUpdate(a,vt(w)),Ot.from(G.blake2bFinal(a))}const _t=w=>{if(typeof w=="string")if(w.substring(w.length-1)==="=")w=Ot.from(w,"base64");else throw new ht;if(w.length!==32)throw new ht;return w},d=w=>{const a=G.blake2bInit(20);return G.blake2bUpdate(a,w),Ot.from(G.blake2bFinal(a))},o=w=>g.BLS===w||g.SECP256K1===w;var u=A(48764).Buffer;const S=le.GA(de),Gt=class{static recoverAccount(a,m,R,V){switch(m){case g.SECP256K1:{R=_t(R);const{publicKey:it,address:ft}=Gt.getPublicSecp256k1FromPrivKey(a,R);return{type:m,privateKey:R,address:ft,publicKey:it,path:V}}default:throw new Error("not supported yet")}}};let D=Gt;F(D,"generateMnemonic",()=>Nt.generateMnemonic(256)),F(D,"mnemonicToSeed",(a,m)=>Nt.mnemonicToSeedSync(a,m)),F(D,"deriveAccount",(a,m,R,V,it)=>{const ft=Gt.mnemonicToSeed(a,V);return Gt.deriveAccountFromSeed(ft,m,R,it)}),F(D,"deriveAccountFromSeed",(a,m,R,V)=>{switch(typeof a=="string"&&(a=u.from(a,"hex")),m){case g.SECP256K1:{const it=S.fromSeed(a),{privateKey:ft}=it.derivePath(R);if(!ft)throw new Error("privateKey not generated");V||(V=oe(R)==="1"?r.Testnet:r.Mainnet);const{publicKey:lt,address:yt}=Gt.getPublicSecp256k1FromPrivKey(V,ft);return{type:m,privateKey:ft,publicKey:lt,address:yt,path:R}}default:throw new Error("not supported yet")}}),F(D,"signTransaction",async(a,m)=>{const R=await m.serialize(),V=Ut(R),{privateKey:it,type:ft}=a;switch(ft){case g.SECP256K1:{const lt=Mt.ecdsaSign(V,it);return new $(ft,u.concat([u.from(lt.signature),u.from([lt.recid])]))}default:throw new Error("not supported yet")}}),F(D,"verifySignature",async(a,m)=>{const R=await m.serialize(),V=Ut(R);switch(a.getType()){case g.SECP256K1:{const it=a.getData(),ft=Mt.ecdsaRecover(it.subarray(0,-1),it[64],V,!1),lt=d(ft);return m.from.getPayload().toString("hex")!==lt.toString("hex")?!1:Mt.ecdsaVerify(it.subarray(0,-1),V,ft)}default:throw new Error("not supported yet")}}),F(D,"getPublicSecp256k1FromPrivKey",(a,m)=>{const R=Mt.publicKeyCreate(m),V=new Uint8Array(65);Mt.publicKeyConvert(R,!1,V);const it=u.from(V),ft=d(V);return{publicKey:it,address:new pt(a,ft)}});const be=class{constructor(a,m){F(this,"type");F(this,"data");F(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));F(this,"getType",()=>this.type);F(this,"getData",()=>this.data);F(this,"isSecp256k1",()=>this.type===g.SECP256K1);F(this,"isBls",()=>this.type===g.BLS);this.type=a,this.data=m}};let $=be;F($,"fromJSON",a=>{if(typeof a!="object"||a===null)throw new Error("input should be an object");if(!("Type"in a)||typeof a.Type!="number")throw new Error("'Type' should be a number");if(!o(a.Type))throw new Error("invalid signature type");if(!("Data"in a)||typeof a.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new be(a.Type,u.from(a.Data,"base64"))});var Y=A(48764).Buffer;const X=(w,a=10)=>{if(w.toString()==="0")return Y.from("");const m=new n(w,a),R=m.toArrayLike(Y,"be",m.byteLength()),V=Y.from(m.isNeg()?"01":"00","hex");return Y.concat([V,R])},rt=(w,a=10)=>{if(w.length===0)return"0";if(w[0]!=0&&w[0]!=1)throw new Error("invalid bigint");const m=w[0]===1?"-":"",R=new n(w.subarray(1));return m+R.toString(a)},et=w=>new Promise(a=>setTimeout(a,w)),ot=async w=>{let a=w();for(;!a;)await et(50),a=w();return a};var at=A(48764).Buffer;let ct;A.e(8190).then(A.bind(A,88190)).then(w=>{ct=w}).catch(w=>{throw w});const Zt=class{constructor(a,m,R,V,it,ft,lt,yt,Pt,Lt){F(this,"version");F(this,"to");F(this,"from");F(this,"nonce");F(this,"value");F(this,"gasLimit");F(this,"gasFeeCap");F(this,"gasPremium");F(this,"method");F(this,"params");F(this,"toJSON",()=>({To:this.to.toString(),From:this.from.toString(),Nonce:this.nonce,Value:this.value,Params:this.params,GasFeeCap:this.gasFeeCap,GasPremium:this.gasPremium,GasLimit:this.gasLimit,Method:this.method}));F(this,"serialize",async()=>{const a=await ot(()=>ct),m=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,X(this.value,10),this.gasLimit,X(this.gasFeeCap,10),X(this.gasPremium,10),this.method,at.from(this.params,"base64")];return at.from(a.encode(m))});F(this,"prepareToSend",async a=>{const m=await a.getNonce(this.from);if("error"in m)throw new Error(m.error.message);this.nonce=m.result;const R=await a.getGasEstimation(this);if("error"in R)throw new Error(R.error.message);return this.gasFeeCap=R.result.GasFeeCap,this.gasLimit=R.result.GasLimit,this.gasPremium=R.result.GasPremium,this});if(this.version=a,this.to=m,this.from=R,this.nonce=V,this.value=it,this.gasLimit=ft,this.gasFeeCap=lt,this.gasPremium=yt,this.method=Pt,this.params=Lt,it===""||it.includes("-"))throw new Error("value must not be empty or negative")}};let wt=Zt;F(wt,"getNew",(a,m,R,V,it=at.alloc(0))=>new Zt(k.Zero,a,m,0,R.toAtto(),0,"0","0",V,it.toString("base64"))),F(wt,"fromCBOR",async(a,m)=>{typeof m=="string"&&(m=at.from(m,"hex"));const V=(await ot(()=>ct)).decode(m);if(!(V instanceof Array))throw new Error("Decoded raw tx should be an array");if(V.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[it,ft,lt,yt,Pt,Lt,ke,Ue,He,Le]=V;if(it!==k.Zero)throw new Error("Unsupported version");if(Pt[0]===1)throw new Error("Value cant be negative");const Te=new n(at.from(Pt).toString("hex"),16).toString(10),Re=new n(at.from(ke).toString("hex"),16).toString(10),Ne=new n(at.from(Ue).toString("hex"),16).toString(10);return new Zt(it,W.fromBytes(a,ft),W.fromBytes(a,lt),yt,Te,Lt,Re,Ne,He,Le.toString("base64"))}),F(wt,"fromJSON",a=>{if(typeof a!="object"||a==null)throw new Error("tx should be an json object");if(!("To"in a)||typeof a.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in a)||typeof a.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in a)||typeof a.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in a)||typeof a.Value!="string"||a.Value===""||a.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in a)||typeof a.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in a)||typeof a.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in a)||typeof a.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in a)||typeof a.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in a)||typeof a.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new Zt(k.Zero,W.fromString(a.To),W.fromString(a.From),a.Nonce,a.Value,a.GasLimit,a.GasFeeCap,a.GasPremium,a.Method,a.Params)});const bt=(w,a)=>{const m=w.isNeg()?"-":"",R=w.abs().toString(),V=R.length-a,it=Bt(V>0?`${R.substring(0,V)}.${R.substring(V)}`:`0.${"".padStart(-1*V,"0")}${R}`);return`${m}${it}`},Bt=w=>{for(let a=w.length-1;a>=0;a--){if(w[a]==".")return w.substring(0,a);if(w[a]!="0"||a===1)return w.substring(0,a+1)}throw new Error("invalid value")},St=18,Kt=15,Dt=12,jt=9,$t=6,zt=3,ve=0,Se=new n(10).pow(new n(zt)),Ae=new n(10).pow(new n($t)),Be=new n(10).pow(new n(jt)),Pe=new n(10).pow(new n(Dt)),Ce=new n(10).pow(new n(Kt)),Ie=new n(10).pow(new n(St)),Ht=class{constructor(a){F(this,"value");F(this,"add",a=>(this.value=this.value.add(a.value),this));F(this,"sub",a=>(this.value=this.value.sub(a.value),this));F(this,"gt",a=>this.value.gt(a.value));F(this,"gte",a=>this.value.gte(a.value));F(this,"lt",a=>this.value.lt(a.value));F(this,"lte",a=>this.value.lte(a.value));F(this,"isNegative",()=>this.value.isNeg());F(this,"isPositive",()=>!this.value.isNeg());F(this,"isZero",()=>this.value.isZero());F(this,"toWhole",()=>bt(this.value,St));F(this,"toMilli",()=>bt(this.value,St-zt));F(this,"toMicro",()=>bt(this.value,St-$t));F(this,"toNano",()=>bt(this.value,St-jt));F(this,"toPico",()=>bt(this.value,St-Dt));F(this,"toFemto",()=>bt(this.value,St-Kt));F(this,"toAtto",()=>bt(this.value,0));F(this,"serialize",()=>X(this.value.toString(10),10));this.value=a}};let It=Ht;F(It,"zero",()=>new Ht(new n("0"))),F(It,"deserialize",a=>new Ht(new n(rt(a,10),10))),F(It,"fromAtto",a=>new Ht(new n(a))),F(It,"fromFemto",a=>new Ht(new n(a).mul(Se))),F(It,"fromPico",a=>new Ht(new n(a).mul(Ae))),F(It,"fromNano",a=>new Ht(new n(a).mul(Be))),F(It,"fromMicro",a=>new Ht(new n(a).mul(Pe))),F(It,"fromMilli",a=>new Ht(new n(a).mul(Ce))),F(It,"fromWhole",a=>new Ht(new n(a).mul(Ie)));class ge{}F(ge,"send",null),F(ge,"getBalance",null);var De=A(48764).Buffer;class pe{}F(pe,"newTx",null),F(pe,"newExecTx",null);let me;A.e(8190).then(A.bind(A,88190)).then(w=>{me=w}).catch(w=>{throw w});let Ee;A.e(9068).then(A.bind(A,59068)).then(w=>{Ee=w}).catch(w=>{throw w});class ze{constructor(a,m){F(this,"targetActorCid");F(this,"targetConstructorParams");F(this,"serialize",async()=>{const a=await waitFor(()=>me),m=await waitFor(()=>Ee);return a.encode([m.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=a,this.targetConstructorParams=m}}let xe;A.e(8190).then(A.bind(A,88190)).then(w=>{xe=w}).catch(w=>{throw w});class Fe{constructor(a,m){F(this,"from");F(this,"to");F(this,"serialize",async()=>(await waitFor(()=>xe)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=a,this.to=m}}const Me=w=>{switch(w){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},se=class{constructor(a,m,R){F(this,"channelAddress");F(this,"from");F(this,"to");F(this,"getAddress",()=>this.channelAddress);F(this,"getTo",()=>this.to);F(this,"getFrom",()=>this.from);F(this,"settle",(a,m)=>{const{address:R}=m,V=Transaction.getNew(this.channelAddress,R,Token.zero(),PayChActorMethods.Settle);return se.sendTx(a,m,V)});F(this,"collect",(a,m)=>{const{address:R}=m,V=Transaction.getNew(this.channelAddress,R,Token.zero(),PayChActorMethods.Collect);return se.sendTx(a,m,V)});this.channelAddress=a,this.from=m,this.to=R}};let Wt=se;F(Wt,"create",null),F(Wt,"loadFromCid",null),F(Wt,"sendTx",null)}}]);
|