edge-currency-accountbased 4.1.0 → 4.2.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/android/src/main/assets/edge-currency-accountbased/3145.chunk.js +4 -0
  3. package/android/src/main/assets/edge-currency-accountbased/5336.chunk.js +2 -2
  4. package/android/src/main/assets/edge-currency-accountbased/6757.chunk.js +1 -1
  5. package/android/src/main/assets/edge-currency-accountbased/845.chunk.js +2 -0
  6. package/android/src/main/assets/edge-currency-accountbased/cardano.chunk.js +2 -2
  7. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -2
  8. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +6 -6
  9. package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
  10. package/lib/algorand/algorandInfo.js +7 -0
  11. package/lib/algorand/algorandTestnetInfo.js +7 -0
  12. package/lib/cardano/CardanoEngine.js +12 -12
  13. package/lib/common/validateMemos.js +1 -1
  14. package/lib/ethereum/info/arbitrumInfo.js +5 -0
  15. package/lib/ethereum/info/avalancheInfo.js +5 -0
  16. package/lib/ethereum/info/baseInfo.js +5 -0
  17. package/lib/ethereum/info/binancesmartchainInfo.js +5 -0
  18. package/lib/ethereum/info/celoInfo.js +5 -0
  19. package/lib/ethereum/info/ethDevInfo.js +5 -0
  20. package/lib/ethereum/info/ethereumCommonInfo.js +17 -0
  21. package/lib/ethereum/info/ethereumInfo.js +13 -8
  22. package/lib/ethereum/info/ethereumclassicInfo.js +5 -0
  23. package/lib/ethereum/info/ethereumpowInfo.js +5 -0
  24. package/lib/ethereum/info/fantomInfo.js +5 -0
  25. package/lib/ethereum/info/filecoinFevmCalibrationInfo.js +1 -0
  26. package/lib/ethereum/info/filecoinFevmInfo.js +1 -0
  27. package/lib/ethereum/info/goerliInfo.js +5 -0
  28. package/lib/ethereum/info/kovanInfo.js +5 -0
  29. package/lib/ethereum/info/optimismInfo.js +5 -0
  30. package/lib/ethereum/info/polygonInfo.js +5 -0
  31. package/lib/ethereum/info/pulsechainInfo.js +5 -0
  32. package/lib/ethereum/info/rinkebyInfo.js +5 -0
  33. package/lib/ethereum/info/ropstenInfo.js +5 -0
  34. package/lib/ethereum/info/rskInfo.js +5 -0
  35. package/lib/ethereum/info/zksyncInfo.js +1 -0
  36. package/lib/ethereum/networkAdapters/EvmScanAdapter.js +129 -88
  37. package/lib/ethereum/networkAdapters/FilfoxAdapter.js +14 -3
  38. package/lib/solana/solanaInfo.js +7 -0
  39. package/package.json +2 -2
  40. package/android/src/main/assets/edge-currency-accountbased/2784.chunk.js +0 -2
  41. package/android/src/main/assets/edge-currency-accountbased/6642.chunk.js +0 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.2.0 (2024-04-09)
6
+
7
+ - added: Expose the modern `customFeeTemplate` fields on the relevant currency infos.
8
+ - changed: Improve unit tests.
9
+ - fixed: Correctly report `InsufficientFundsError` in the Cardano engine.
10
+
11
+ ## 4.1.1 (2024-03-26)
12
+
13
+ - fixed: (Filecoin FEVM) Incorrectly identifying all transactions as receives
14
+
5
15
  ## 4.1.0 (2024-03-25)
6
16
 
7
17
  - changed: Mark failed transactions processed from EVM scan networks with 'failed' confirmation status
@@ -0,0 +1,4 @@
1
+ var Ot=Object.defineProperty;var Lt=(ie,a,I)=>a in ie?Ot(ie,a,{enumerable:!0,configurable:!0,writable:!0,value:I}):ie[a]=I;var x=(ie,a,I)=>(Lt(ie,typeof a!="symbol"?a+"":a,I),I);(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[3145],{77235:function(ie,a,I){"use strict";var A=I(48764).Buffer,u=I(79656),E=I(79569),C=I(23061);function y(l){var D=Object.create(null);return l&&Object.keys(l).forEach(function(Y){if(Y!=="default"){var fe=Object.getOwnPropertyDescriptor(l,Y);Object.defineProperty(D,Y,fe.get?fe:{enumerable:!0,get:function(){return l[Y]}})}}),D.default=l,Object.freeze(D)}var s=y(u);s.utils.hmacSha256Sync=(l,...D)=>E.hmac(C.sha256,l,s.utils.concatBytes(...D)),s.utils.sha256Sync=(...l)=>C.sha256(s.utils.concatBytes(...l));const d=s.utils._normalizePrivateKey,w=32,i=32,m=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]),h=32;function F(l,D){for(let Y=0;Y<32;++Y)if(l[Y]!==D[Y])return l[Y]<D[Y]?-1:1;return 0}function M(l){return!(!(l instanceof Uint8Array)||l.length!==i||F(l,m)>=0)}function V(l){return l instanceof Uint8Array&&l.length===64&&F(l.subarray(0,32),m)<0&&F(l.subarray(32,64),m)<0}function K(l){return l instanceof Uint8Array&&l.length===w}function G(l){return l===void 0||l instanceof Uint8Array&&l.length===h}function k(l){if(typeof l!="string")throw new TypeError("hexToNumber: expected string, got "+typeof l);return BigInt(`0x${l}`)}function T(l){return k(s.utils.bytesToHex(l))}function N(l){let D;if(typeof l=="bigint")D=l;else if(typeof l=="number"&&Number.isSafeInteger(l)&&l>=0)D=BigInt(l);else if(typeof l=="string"){if(l.length!==64)throw new Error("Expected 32 bytes of private scalar");D=k(l)}else if(l instanceof Uint8Array){if(l.length!==32)throw new Error("Expected 32 bytes of private scalar");D=T(l)}else throw new TypeError("Expected valid private scalar");if(D<0)throw new Error("Expected private scalar >= 0");return D}const L=(l,D)=>{const Y=d(l),fe=N(D),be=s.utils._bigintTo32Bytes(s.utils.mod(Y+fe,s.CURVE.n));return s.utils.isValidPrivateKey(be)?be:null},q=(l,D)=>{const Y=d(l),fe=N(D),be=s.utils._bigintTo32Bytes(s.utils.mod(Y-fe,s.CURVE.n));return s.utils.isValidPrivateKey(be)?be:null},Z=l=>{const D=d(l),Y=s.utils._bigintTo32Bytes(s.CURVE.n-D);return s.utils.isValidPrivateKey(Y)?Y:null},re=(l,D,Y)=>{const fe=s.Point.fromHex(l),be=N(D),ge=s.Point.BASE.multiplyAndAddUnsafe(fe,be,1n);if(!ge)throw new Error("Tweaked point at infinity");return ge.toRawBytes(Y)},ye=(l,D,Y)=>{const fe=s.Point.fromHex(l),be=typeof D=="string"?D:s.utils.bytesToHex(D),ge=BigInt(`0x${be}`);return fe.multiply(ge).toRawBytes(Y)};function me(l,D){return l===void 0?D!==void 0?v(D):!0:!!l}function S(l){try{return l()}catch{return null}}function B(l,D){if(l.length===32!==D)return!1;try{return!!s.Point.fromHex(l)}catch{return!1}}function g(l){return B(l,!1)}function v(l){return B(l,!1)&&l.length===33}function P(l){return s.utils.isValidPrivateKey(l)}function U(l){return B(l,!0)}function $(l,D){if(!U(l))throw new Error("Expected Point");if(!M(D))throw new Error("Expected Tweak");return S(()=>{const Y=re(l,D,!0);return{parity:Y[0]%2===1?1:0,xOnlyPubkey:Y.slice(1)}})}function _(l){if(!g(l))throw new Error("Expected Point");return l.slice(1,33)}function se(l,D){if(!P(l))throw new Error("Expected Private");return S(()=>s.getPublicKey(l,me(D)))}function le(l){if(!P(l))throw new Error("Expected Private");return _(se(l))}function X(l,D){if(!g(l))throw new Error("Expected Point");return s.Point.fromHex(l).toRawBytes(me(D,l))}function ne(l,D,Y){if(!g(l))throw new Error("Expected Point");if(!M(D))throw new Error("Expected Tweak");return S(()=>ye(l,D,me(Y,l)))}function pe(l,D,Y){if(!g(l)||!g(D))throw new Error("Expected Point");return S(()=>{const fe=s.Point.fromHex(l),be=s.Point.fromHex(D);return fe.equals(be.negate())?null:fe.add(be).toRawBytes(me(Y,l))})}function O(l,D,Y){if(!g(l))throw new Error("Expected Point");if(!M(D))throw new Error("Expected Tweak");return S(()=>re(l,D,me(Y,l)))}function we(l,D){if(P(l)===!1)throw new Error("Expected Private");if(M(D)===!1)throw new Error("Expected Tweak");return S(()=>L(l,D))}function Ie(l,D){if(P(l)===!1)throw new Error("Expected Private");if(M(D)===!1)throw new Error("Expected Tweak");return S(()=>q(l,D))}function Se(l){if(P(l)===!1)throw new Error("Expected Private");return Z(l)}function Pe(l,D,Y){if(!P(D))throw new Error("Expected Private");if(!K(l))throw new Error("Expected Scalar");if(!G(Y))throw new Error("Expected Extra Data (32 bytes)");return s.signSync(l,D,{der:!1,extraEntropy:Y})}function Xe(l,D,Y=A.alloc(32,0)){if(!P(D))throw new Error("Expected Private");if(!K(l))throw new Error("Expected Scalar");if(!G(Y))throw new Error("Expected Extra Data (32 bytes)");return s.schnorr.signSync(l,D,Y)}function Me(l,D,Y,fe){if(!g(D))throw new Error("Expected Point");if(!V(Y))throw new Error("Expected Signature");if(!K(l))throw new Error("Expected Scalar");return s.verify(Y,l,D,{strict:fe})}function Ne(l,D,Y){if(!U(D))throw new Error("Expected Point");if(!V(Y))throw new Error("Expected Signature");if(!K(l))throw new Error("Expected Scalar");return s.schnorr.verifySync(Y,l,D)}a.isPoint=g,a.isPointCompressed=v,a.isPrivate=P,a.isXOnlyPoint=U,a.pointAdd=pe,a.pointAddScalar=O,a.pointCompress=X,a.pointFromScalar=se,a.pointMultiply=ne,a.privateAdd=we,a.privateNegate=Se,a.privateSub=Ie,a.sign=Pe,a.signSchnorr=Xe,a.verify=Me,a.verifySchnorr=Ne,a.xOnlyPointAddTweak=$,a.xOnlyPointFromPoint=_,a.xOnlyPointFromScalar=le},79656:function(ie,a,I){"use strict";/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(a,"__esModule",{value:!0}),a.utils=a.schnorr=a.verify=a.signSync=a.sign=a.getSharedSecret=a.recoverPublicKey=a.getPublicKey=a.Signature=a.Point=a.CURVE=void 0;const A=I(69159),u=BigInt(0),E=BigInt(1),C=BigInt(2),y=BigInt(3),s=BigInt(8),d=Object.freeze({a:u,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:E,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});a.CURVE=d;const w=(n,e)=>(n+e/C)/e,i={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(n){const{n:e}=d,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),f=-E*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),p=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),R=r,H=BigInt("0x100000000000000000000000000000000"),j=w(R*n,e),Q=w(-f*n,e);let W=O(n-j*r-Q*p,e),J=O(-j*f-Q*R,e);const te=W>H,oe=J>H;if(te&&(W=e-W),oe&&(J=e-J),W>H||J>H)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:te,k1:W,k2neg:oe,k2:J}}},m=32,h=32,F=32,M=m+1,V=2*m+1;function K(n){const{a:e,b:r}=d,f=O(n*n),p=O(f*n);return O(p+e*n+r)}const G=d.a===u;class k extends Error{constructor(e){super(e)}}function T(n){if(!(n instanceof N))throw new TypeError("JacobianPoint expected")}class N{constructor(e,r,f){this.x=e,this.y=r,this.z=f}static fromAffine(e){if(!(e instanceof Z))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Z.ZERO)?N.ZERO:new N(e.x,e.y,E)}static toAffineBatch(e){const r=Pe(e.map(f=>f.z));return e.map((f,p)=>f.toAffine(r[p]))}static normalizeZ(e){return N.toAffineBatch(e).map(N.fromAffine)}equals(e){T(e);const{x:r,y:f,z:p}=this,{x:R,y:H,z:j}=e,Q=O(p*p),W=O(j*j),J=O(r*W),te=O(R*Q),oe=O(O(f*j)*W),he=O(O(H*p)*Q);return J===te&&oe===he}negate(){return new N(this.x,O(-this.y),this.z)}double(){const{x:e,y:r,z:f}=this,p=O(e*e),R=O(r*r),H=O(R*R),j=e+R,Q=O(C*(O(j*j)-p-H)),W=O(y*p),J=O(W*W),te=O(J-C*Q),oe=O(W*(Q-te)-s*H),he=O(C*r*f);return new N(te,oe,he)}add(e){T(e);const{x:r,y:f,z:p}=this,{x:R,y:H,z:j}=e;if(R===u||H===u)return this;if(r===u||f===u)return e;const Q=O(p*p),W=O(j*j),J=O(r*W),te=O(R*Q),oe=O(O(f*j)*W),he=O(O(H*p)*Q),ue=O(te-J),xe=O(he-oe);if(ue===u)return xe===u?this.double():N.ZERO;const ve=O(ue*ue),Le=O(ue*ve),De=O(J*ve),je=O(xe*xe-Le-C*De),Ge=O(xe*(De-je)-oe*Le),Fe=O(p*j*ue);return new N(je,Ge,Fe)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const r=N.ZERO;if(typeof e=="bigint"&&e===u)return r;let f=pe(e);if(f===E)return this;if(!G){let te=r,oe=this;for(;f>u;)f&E&&(te=te.add(oe)),oe=oe.double(),f>>=E;return te}let{k1neg:p,k1:R,k2neg:H,k2:j}=i.splitScalar(f),Q=r,W=r,J=this;for(;R>u||j>u;)R&E&&(Q=Q.add(J)),j&E&&(W=W.add(J)),J=J.double(),R>>=E,j>>=E;return p&&(Q=Q.negate()),H&&(W=W.negate()),W=new N(O(W.x*i.beta),W.y,W.z),Q.add(W)}precomputeWindow(e){const r=G?128/e+1:256/e+1,f=[];let p=this,R=p;for(let H=0;H<r;H++){R=p,f.push(R);for(let j=1;j<2**(e-1);j++)R=R.add(p),f.push(R);p=R.double()}return f}wNAF(e,r){!r&&this.equals(N.BASE)&&(r=Z.BASE);const f=r&&r._WINDOW_SIZE||1;if(256%f)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let p=r&&q.get(r);p||(p=this.precomputeWindow(f),r&&f!==1&&(p=N.normalizeZ(p),q.set(r,p)));let R=N.ZERO,H=N.BASE;const j=1+(G?128/f:256/f),Q=2**(f-1),W=BigInt(2**f-1),J=2**f,te=BigInt(f);for(let oe=0;oe<j;oe++){const he=oe*Q;let ue=Number(e&W);e>>=te,ue>Q&&(ue-=J,e+=E);const xe=he,ve=he+Math.abs(ue)-1,Le=oe%2!==0,De=ue<0;ue===0?H=H.add(L(Le,p[xe])):R=R.add(L(De,p[ve]))}return{p:R,f:H}}multiply(e,r){let f=pe(e),p,R;if(G){const{k1neg:H,k1:j,k2neg:Q,k2:W}=i.splitScalar(f);let{p:J,f:te}=this.wNAF(j,r),{p:oe,f:he}=this.wNAF(W,r);J=L(H,J),oe=L(Q,oe),oe=new N(O(oe.x*i.beta),oe.y,oe.z),p=J.add(oe),R=te.add(he)}else{const{p:H,f:j}=this.wNAF(f,r);p=H,R=j}return N.normalizeZ([p,R])[0]}toAffine(e){const{x:r,y:f,z:p}=this,R=this.equals(N.ZERO);e==null&&(e=R?s:Se(p));const H=e,j=O(H*H),Q=O(j*H),W=O(r*j),J=O(f*Q),te=O(p*H);if(R)return Z.ZERO;if(te!==E)throw new Error("invZ was invalid");return new Z(W,J)}}N.BASE=new N(d.Gx,d.Gy,E),N.ZERO=new N(u,E,u);function L(n,e){const r=e.negate();return n?r:e}const q=new WeakMap;class Z{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,q.delete(this)}hasEvenY(){return this.y%C===u}static fromCompressedHex(e){const r=e.length===32,f=X(r?e:e.subarray(1));if(!fe(f))throw new Error("Point is not on curve");const p=K(f);let R=Ie(p);const H=(R&E)===E;r?H&&(R=O(-R)):(e[0]&1)===1!==H&&(R=O(-R));const j=new Z(f,R);return j.assertValidity(),j}static fromUncompressedHex(e){const r=X(e.subarray(1,m+1)),f=X(e.subarray(m+1,m*2+1)),p=new Z(r,f);return p.assertValidity(),p}static fromHex(e){const r=ne(e),f=r.length,p=r[0];if(f===m)return this.fromCompressedHex(r);if(f===M&&(p===2||p===3))return this.fromCompressedHex(r);if(f===V&&p===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-${M} compressed bytes or ${V} uncompressed bytes, not ${f}`)}static fromPrivateKey(e){return Z.BASE.multiply(ge(e))}static fromSignature(e,r,f){const{r:p,s:R}=Ke(r);if(![0,1,2,3].includes(f))throw new Error("Cannot recover: invalid recovery bit");const H=Me(ne(e)),{n:j}=d,Q=f===2||f===3?p+j:p,W=Se(Q,j),J=O(-H*W,j),te=O(R*W,j),oe=f&1?"03":"02",he=Z.fromHex(oe+U(Q)),ue=Z.BASE.multiplyAndAddUnsafe(he,J,te);if(!ue)throw new Error("Cannot recover signature: point at infinify");return ue.assertValidity(),ue}toRawBytes(e=!1){return le(this.toHex(e))}toHex(e=!1){const r=U(this.x);return e?`${this.hasEvenY()?"02":"03"}${r}`:`04${r}${U(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:r,y:f}=this;if(!fe(r)||!fe(f))throw new Error(e);const p=O(f*f),R=K(r);if(O(p-R)!==u)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Z(this.x,O(-this.y))}double(){return N.fromAffine(this).double().toAffine()}add(e){return N.fromAffine(this).add(N.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return N.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,r,f){const p=N.fromAffine(this),R=r===u||r===E||this!==Z.BASE?p.multiplyUnsafe(r):p.multiply(r),H=N.fromAffine(e).multiplyUnsafe(f),j=R.add(H);return j.equals(N.ZERO)?void 0:j.toAffine()}}a.Point=Z,Z.BASE=new Z(d.Gx,d.Gy),Z.ZERO=new Z(u,u);function re(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function ye(n){if(n.length<2||n[0]!==2)throw new Error(`Invalid signature integer tag: ${v(n)}`);const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:X(r),left:n.subarray(e+2)}}function me(n){if(n.length<2||n[0]!=48)throw new Error(`Invalid signature tag: ${v(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=ye(n.subarray(2)),{data:f,left:p}=ye(r);if(p.length)throw new Error(`Invalid signature: left bytes after parsing: ${v(p)}`);return{r:e,s:f}}class S{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){const r=e instanceof Uint8Array,f="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${f}: Expected string or Uint8Array`);const p=r?v(e):e;if(p.length!==128)throw new Error(`${f}: Expected 64-byte hex`);return new S(se(p.slice(0,64)),se(p.slice(64,128)))}static fromDER(e){const r=e instanceof Uint8Array;if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:f,s:p}=me(r?e:le(e));return new S(f,p)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:r}=this;if(!Y(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Y(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=d.n>>E;return this.s>e}normalizeS(){return this.hasHighS()?new S(this.r,O(-this.s,d.n)):this}toDERRawBytes(){return le(this.toDERHex())}toDERHex(){const e=re(_(this.s)),r=re(_(this.r)),f=e.length/2,p=r.length/2,R=_(f),H=_(p);return`30${_(p+f+4)}02${H}${r}02${R}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return le(this.toCompactHex())}toCompactHex(){return U(this.r)+U(this.s)}}a.Signature=S;function B(...n){if(!n.every(f=>f instanceof Uint8Array))throw new Error("Uint8Array list expected");if(n.length===1)return n[0];const e=n.reduce((f,p)=>f+p.length,0),r=new Uint8Array(e);for(let f=0,p=0;f<n.length;f++){const R=n[f];r.set(R,p),p+=R.length}return r}const g=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function v(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<n.length;r++)e+=g[n[r]];return e}const P=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function U(n){if(typeof n!="bigint")throw new Error("Expected bigint");if(!(u<=n&&n<P))throw new Error("Expected number 0 <= n < 2^256");return n.toString(16).padStart(64,"0")}function $(n){const e=le(U(n));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function _(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function se(n){if(typeof n!="string")throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function le(n){if(typeof n!="string")throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let r=0;r<e.length;r++){const f=r*2,p=n.slice(f,f+2),R=Number.parseInt(p,16);if(Number.isNaN(R)||R<0)throw new Error("Invalid byte sequence");e[r]=R}return e}function X(n){return se(v(n))}function ne(n){return n instanceof Uint8Array?Uint8Array.from(n):le(n)}function pe(n){if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)return BigInt(n);if(typeof n=="bigint"&&Y(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function O(n,e=d.P){const r=n%e;return r>=u?r:e+r}function we(n,e){const{P:r}=d;let f=n;for(;e-- >u;)f*=f,f%=r;return f}function Ie(n){const{P:e}=d,r=BigInt(6),f=BigInt(11),p=BigInt(22),R=BigInt(23),H=BigInt(44),j=BigInt(88),Q=n*n*n%e,W=Q*Q*n%e,J=we(W,y)*W%e,te=we(J,y)*W%e,oe=we(te,C)*Q%e,he=we(oe,f)*oe%e,ue=we(he,p)*he%e,xe=we(ue,H)*ue%e,ve=we(xe,j)*xe%e,Le=we(ve,H)*ue%e,De=we(Le,y)*W%e,je=we(De,R)*he%e,Ge=we(je,r)*Q%e,Fe=we(Ge,C);if(Fe*Fe%e!==n)throw new Error("Cannot find square root");return Fe}function Se(n,e=d.P){if(n===u||e<=u)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let r=O(n,e),f=e,p=u,R=E,H=E,j=u;for(;r!==u;){const W=f/r,J=f%r,te=p-H*W,oe=R-j*W;f=r,r=J,p=H,R=j,H=te,j=oe}if(f!==E)throw new Error("invert: does not exist");return O(p,e)}function Pe(n,e=d.P){const r=new Array(n.length),f=n.reduce((R,H,j)=>H===u?R:(r[j]=R,O(R*H,e)),E),p=Se(f,e);return n.reduceRight((R,H,j)=>H===u?R:(r[j]=O(R*r[j],e),O(R*H,e)),p),r}function Xe(n){const e=n.length*8-h*8,r=X(n);return e>0?r>>BigInt(e):r}function Me(n,e=!1){const r=Xe(n);if(e)return r;const{n:f}=d;return r>=f?r-f:r}let Ne,l;class D{constructor(e,r){if(this.hashLen=e,this.qByteLen=r,typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof r!="number"||r<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(...e){return a.utils.hmacSha256(this.k,...e)}hmacSync(...e){return l(this.k,...e)}checkSync(){if(typeof l!="function")throw new k("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(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),e.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const f=this.v.slice();r.push(f),e+=this.v.length}return B(...r)}generateSync(){this.checkSync(),this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const f=this.v.slice();r.push(f),e+=this.v.length}return B(...r)}}function Y(n){return u<n&&n<d.n}function fe(n){return u<n&&n<d.P}function be(n,e,r,f=!0){const{n:p}=d,R=Me(n,!0);if(!Y(R))return;const H=Se(R,p),j=Z.BASE.multiply(R),Q=O(j.x,p);if(Q===u)return;const W=O(H*O(e+r*Q,p),p);if(W===u)return;let J=new S(Q,W),te=(j.x===J.r?0:2)|Number(j.y&E);return f&&J.hasHighS()&&(J=J.normalizeS(),te^=1),{sig:J,recovery:te}}function ge(n){let e;if(typeof n=="bigint")e=n;else if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)e=BigInt(n);else if(typeof n=="string"){if(n.length!==2*h)throw new Error("Expected 32 bytes of private key");e=se(n)}else if(n instanceof Uint8Array){if(n.length!==h)throw new Error("Expected 32 bytes of private key");e=X(n)}else throw new TypeError("Expected valid private key");if(!Y(e))throw new Error("Expected private key: 0 < key < n");return e}function Be(n){return n instanceof Z?(n.assertValidity(),n):Z.fromHex(n)}function Ke(n){if(n instanceof S)return n.assertValidity(),n;try{return S.fromDER(n)}catch{return S.fromCompact(n)}}function Ce(n,e=!1){return Z.fromPrivateKey(n).toRawBytes(e)}a.getPublicKey=Ce;function at(n,e,r,f=!1){return Z.fromSignature(n,e,r).toRawBytes(f)}a.recoverPublicKey=at;function qe(n){const e=n instanceof Uint8Array,r=typeof n=="string",f=(e||r)&&n.length;return e?f===M||f===V:r?f===M*2||f===V*2:n instanceof Z}function ct(n,e,r=!1){if(qe(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!qe(e))throw new TypeError("getSharedSecret: second arg must be public key");const f=Be(e);return f.assertValidity(),f.multiply(ge(n)).toRawBytes(r)}a.getSharedSecret=ct;function Qe(n){const e=n.length>m?n.slice(0,m):n;return X(e)}function ft(n){const e=Qe(n),r=O(e,d.n);return Je(r<u?e:r)}function Je(n){return $(n)}function _e(n,e,r){if(n==null)throw new Error(`sign: expected valid message hash, not "${n}"`);const f=ne(n),p=ge(e),R=[Je(p),ft(f)];if(r!=null){r===!0&&(r=a.utils.randomBytes(m));const Q=ne(r);if(Q.length!==m)throw new Error(`sign: Expected ${m} bytes of extra data`);R.push(Q)}const H=B(...R),j=Qe(f);return{seed:H,m:j,d:p}}function et(n,e){const{sig:r,recovery:f}=n,{der:p,recovered:R}=Object.assign({canonical:!0,der:!0},e),H=p?r.toDERRawBytes():r.toCompactRawBytes();return R?[H,f]:H}async function ut(n,e,r={}){const{seed:f,m:p,d:R}=_e(n,e,r.extraEntropy),H=new D(F,h);await H.reseed(f);let j;for(;!(j=be(await H.generate(),p,R,r.canonical));)await H.reseed();return et(j,r)}a.sign=ut;function lt(n,e,r={}){const{seed:f,m:p,d:R}=_e(n,e,r.extraEntropy),H=new D(F,h);H.reseedSync(f);let j;for(;!(j=be(H.generateSync(),p,R,r.canonical));)H.reseedSync();return et(j,r)}a.signSync=lt;const bt={strict:!0};function yt(n,e,r,f=bt){let p;try{p=Ke(n),e=ne(e)}catch{return!1}const{r:R,s:H}=p;if(f.strict&&p.hasHighS())return!1;const j=Me(e);let Q;try{Q=Be(r)}catch{return!1}const{n:W}=d,J=Se(H,W),te=O(j*J,W),oe=O(R*J,W),he=Z.BASE.multiplyAndAddUnsafe(Q,te,oe);return he?O(he.x,W)===R:!1}a.verify=yt;function Ve(n){return O(X(n),d.n)}class ze{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromHex(e){const r=ne(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);const f=X(r.subarray(0,32)),p=X(r.subarray(32,64));return new ze(f,p)}assertValidity(){const{r:e,s:r}=this;if(!fe(e)||!Y(r))throw new Error("Invalid signature")}toHex(){return U(this.r)+U(this.s)}toRawBytes(){return le(this.toHex())}}function ht(n){return Z.fromPrivateKey(n).toRawX()}class tt{constructor(e,r,f=a.utils.randomBytes()){if(e==null)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=ne(e);const{x:p,scalar:R}=this.getScalar(ge(r));if(this.px=p,this.d=R,this.rand=ne(f),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const r=Z.fromPrivateKey(e),f=r.hasEvenY()?e:d.n-e;return{point:r,scalar:f,x:r.toRawX()}}initNonce(e,r){return $(e^X(r))}finalizeNonce(e){const r=O(X(e),d.n);if(r===u)throw new Error("sign: Creation of signature failed. k is zero");const{point:f,x:p,scalar:R}=this.getScalar(r);return{R:f,rx:p,k:R}}finalizeSig(e,r,f,p){return new ze(e.x,O(r+f*p,d.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:r,px:f,rand:p}=this,R=a.utils.taggedHash,H=this.initNonce(r,await R(Te.aux,p)),{R:j,rx:Q,k:W}=this.finalizeNonce(await R(Te.nonce,H,f,e)),J=Ve(await R(Te.challenge,Q,f,e)),te=this.finalizeSig(j,W,J,r);return await nt(te,e,f)||this.error(),te}calcSync(){const{m:e,d:r,px:f,rand:p}=this,R=a.utils.taggedHashSync,H=this.initNonce(r,R(Te.aux,p)),{R:j,rx:Q,k:W}=this.finalizeNonce(R(Te.nonce,H,f,e)),J=Ve(R(Te.challenge,Q,f,e)),te=this.finalizeSig(j,W,J,r);return ot(te,e,f)||this.error(),te}}async function dt(n,e,r){return new tt(n,e,r).calc()}function He(n,e,r){return new tt(n,e,r).calcSync()}function Oe(n,e,r){const f=n instanceof ze,p=f?n:ze.fromHex(n);return f&&p.assertValidity(),{...p,m:ne(e),P:Be(r)}}function rt(n,e,r,f){const p=Z.BASE.multiplyAndAddUnsafe(e,ge(r),O(-f,d.n));return!(!p||!p.hasEvenY()||p.x!==n)}async function nt(n,e,r){try{const{r:f,s:p,m:R,P:H}=Oe(n,e,r),j=Ve(await a.utils.taggedHash(Te.challenge,$(f),H.toRawX(),R));return rt(f,H,p,j)}catch{return!1}}function ot(n,e,r){try{const{r:f,s:p,m:R,P:H}=Oe(n,e,r),j=Ve(a.utils.taggedHashSync(Te.challenge,$(f),H.toRawX(),R));return rt(f,H,p,j)}catch(f){if(f instanceof k)throw f;return!1}}a.schnorr={Signature:ze,getPublicKey:ht,sign:dt,verify:nt,signSync:He,verifySync:ot},Z.BASE._setWindowSize(8);const Ee={node:A,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Te={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},$e={};a.utils={bytesToHex:v,hexToBytes:le,concatBytes:B,mod:O,invert:Se,isValidPrivateKey(n){try{return ge(n),!0}catch{return!1}},_bigintTo32Bytes:$,_normalizePrivateKey:ge,hashToPrivateKey:n=>{n=ne(n);const e=h+8;if(n.length<e||n.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const r=O(X(n),d.n-E)+E;return $(r)},randomBytes:(n=32)=>{if(Ee.web)return Ee.web.getRandomValues(new Uint8Array(n));if(Ee.node){const{randomBytes:e}=Ee.node;return Uint8Array.from(e(n))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>a.utils.hashToPrivateKey(a.utils.randomBytes(h+8)),precompute(n=8,e=Z.BASE){const r=e===Z.BASE?e:new Z(e.x,e.y);return r._setWindowSize(n),r.multiply(y),r},sha256:async(...n)=>{if(Ee.web){const e=await Ee.web.subtle.digest("SHA-256",B(...n));return new Uint8Array(e)}else if(Ee.node){const{createHash:e}=Ee.node,r=e("sha256");return n.forEach(f=>r.update(f)),Uint8Array.from(r.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(n,...e)=>{if(Ee.web){const r=await Ee.web.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),f=B(...e),p=await Ee.web.subtle.sign("HMAC",r,f);return new Uint8Array(p)}else if(Ee.node){const{createHmac:r}=Ee.node,f=r("sha256",n);return e.forEach(p=>f.update(p)),Uint8Array.from(f.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(n,...e)=>{let r=$e[n];if(r===void 0){const f=await a.utils.sha256(Uint8Array.from(n,p=>p.charCodeAt(0)));r=B(f,f),$e[n]=r}return a.utils.sha256(r,...e)},taggedHashSync:(n,...e)=>{if(typeof Ne!="function")throw new k("sha256Sync is undefined, you need to set it");let r=$e[n];if(r===void 0){const f=Ne(Uint8Array.from(n,p=>p.charCodeAt(0)));r=B(f,f),$e[n]=r}return Ne(r,...e)},_JacobianPoint:N},Object.defineProperties(a.utils,{sha256Sync:{configurable:!1,get(){return Ne},set(n){Ne||(Ne=n)}},hmacSha256Sync:{configurable:!1,get(){return l},set(n){l||(l=n)}}})},39187:function(ie,a){"use strict";/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(a,"__esModule",{value:!0}),a.bytes=a.stringToBytes=a.str=a.bytesToString=a.hex=a.utf8=a.bech32m=a.bech32=a.base58check=a.base58xmr=a.base58xrp=a.base58flickr=a.base58=a.base64urlnopad=a.base64url=a.base64=a.base32crockford=a.base32hex=a.base32=a.base16=a.utils=a.assertNumber=void 0;function I(S){if(!Number.isSafeInteger(S))throw new Error(`Wrong integer: ${S}`)}a.assertNumber=I;function A(...S){const B=(P,U)=>$=>P(U($)),g=Array.from(S).reverse().reduce((P,U)=>P?B(P,U.encode):U.encode,void 0),v=S.reduce((P,U)=>P?B(P,U.decode):U.decode,void 0);return{encode:g,decode:v}}function u(S){return{encode:B=>{if(!Array.isArray(B)||B.length&&typeof B[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return B.map(g=>{if(I(g),g<0||g>=S.length)throw new Error(`Digit index outside alphabet: ${g} (alphabet: ${S.length})`);return S[g]})},decode:B=>{if(!Array.isArray(B)||B.length&&typeof B[0]!="string")throw new Error("alphabet.decode input should be array of strings");return B.map(g=>{if(typeof g!="string")throw new Error(`alphabet.decode: not string element=${g}`);const v=S.indexOf(g);if(v===-1)throw new Error(`Unknown letter: "${g}". Allowed: ${S}`);return v})}}}function E(S=""){if(typeof S!="string")throw new Error("join separator should be string");return{encode:B=>{if(!Array.isArray(B)||B.length&&typeof B[0]!="string")throw new Error("join.encode input should be array of strings");for(let g of B)if(typeof g!="string")throw new Error(`join.encode: non-string input=${g}`);return B.join(S)},decode:B=>{if(typeof B!="string")throw new Error("join.decode input should be string");return B.split(S)}}}function C(S,B="="){if(I(S),typeof B!="string")throw new Error("padding chr should be string");return{encode(g){if(!Array.isArray(g)||g.length&&typeof g[0]!="string")throw new Error("padding.encode input should be array of strings");for(let v of g)if(typeof v!="string")throw new Error(`padding.encode: non-string input=${v}`);for(;g.length*S%8;)g.push(B);return g},decode(g){if(!Array.isArray(g)||g.length&&typeof g[0]!="string")throw new Error("padding.encode input should be array of strings");for(let P of g)if(typeof P!="string")throw new Error(`padding.decode: non-string input=${P}`);let v=g.length;if(v*S%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;v>0&&g[v-1]===B;v--)if(!((v-1)*S%8))throw new Error("Invalid padding: string has too much padding");return g.slice(0,v)}}}function y(S){if(typeof S!="function")throw new Error("normalize fn should be function");return{encode:B=>B,decode:B=>S(B)}}function s(S,B,g){if(B<2)throw new Error(`convertRadix: wrong from=${B}, base cannot be less than 2`);if(g<2)throw new Error(`convertRadix: wrong to=${g}, base cannot be less than 2`);if(!Array.isArray(S))throw new Error("convertRadix: data should be array");if(!S.length)return[];let v=0;const P=[],U=Array.from(S);for(U.forEach($=>{if(I($),$<0||$>=B)throw new Error(`Wrong integer: ${$}`)});;){let $=0,_=!0;for(let se=v;se<U.length;se++){const le=U[se],X=B*$+le;if(!Number.isSafeInteger(X)||B*$/B!==$||X-le!==B*$)throw new Error("convertRadix: carry overflow");$=X%g;const ne=Math.floor(X/g);if(U[se]=ne,!Number.isSafeInteger(ne)||ne*g+$!==X)throw new Error("convertRadix: carry overflow");if(_)ne?_=!1:v=se;else continue}if(P.push($),_)break}for(let $=0;$<S.length-1&&S[$]===0;$++)P.push(0);return P.reverse()}const d=(S,B)=>B?d(B,S%B):S,w=(S,B)=>S+(B-d(S,B));function i(S,B,g,v){if(!Array.isArray(S))throw new Error("convertRadix2: data should be array");if(B<=0||B>32)throw new Error(`convertRadix2: wrong from=${B}`);if(g<=0||g>32)throw new Error(`convertRadix2: wrong to=${g}`);if(w(B,g)>32)throw new Error(`convertRadix2: carry overflow from=${B} to=${g} carryBits=${w(B,g)}`);let P=0,U=0;const $=2**g-1,_=[];for(const se of S){if(I(se),se>=2**B)throw new Error(`convertRadix2: invalid data word=${se} from=${B}`);if(P=P<<B|se,U+B>32)throw new Error(`convertRadix2: carry overflow pos=${U} from=${B}`);for(U+=B;U>=g;U-=g)_.push((P>>U-g&$)>>>0);P&=2**U-1}if(P=P<<g-U&$,!v&&U>=B)throw new Error("Excess padding");if(!v&&P)throw new Error(`Non-zero padding: ${P}`);return v&&U>0&&_.push(P>>>0),_}function m(S){return I(S),{encode:B=>{if(!(B instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return s(Array.from(B),2**8,S)},decode:B=>{if(!Array.isArray(B)||B.length&&typeof B[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(s(B,S,2**8))}}}function h(S,B=!1){if(I(S),S<=0||S>32)throw new Error("radix2: bits should be in (0..32]");if(w(8,S)>32||w(S,8)>32)throw new Error("radix2: carry overflow");return{encode:g=>{if(!(g instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return i(Array.from(g),8,S,!B)},decode:g=>{if(!Array.isArray(g)||g.length&&typeof g[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(i(g,S,8,B))}}}function F(S){if(typeof S!="function")throw new Error("unsafeWrapper fn should be function");return function(...B){try{return S.apply(null,B)}catch{}}}function M(S,B){if(I(S),typeof B!="function")throw new Error("checksum fn should be function");return{encode(g){if(!(g instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const v=B(g).slice(0,S),P=new Uint8Array(g.length+S);return P.set(g),P.set(v,g.length),P},decode(g){if(!(g instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const v=g.slice(0,-S),P=B(v).slice(0,S),U=g.slice(-S);for(let $=0;$<S;$++)if(P[$]!==U[$])throw new Error("Invalid checksum");return v}}}a.utils={alphabet:u,chain:A,checksum:M,radix:m,radix2:h,join:E,padding:C},a.base16=A(h(4),u("0123456789ABCDEF"),E("")),a.base32=A(h(5),u("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),C(5),E("")),a.base32hex=A(h(5),u("0123456789ABCDEFGHIJKLMNOPQRSTUV"),C(5),E("")),a.base32crockford=A(h(5),u("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),E(""),y(S=>S.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),a.base64=A(h(6),u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),C(6),E("")),a.base64url=A(h(6),u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),C(6),E("")),a.base64urlnopad=A(h(6),u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),E(""));const V=S=>A(m(58),u(S),E(""));a.base58=V("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),a.base58flickr=V("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),a.base58xrp=V("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const K=[0,2,3,5,6,7,9,10,11];a.base58xmr={encode(S){let B="";for(let g=0;g<S.length;g+=8){const v=S.subarray(g,g+8);B+=a.base58.encode(v).padStart(K[v.length],"1")}return B},decode(S){let B=[];for(let g=0;g<S.length;g+=11){const v=S.slice(g,g+11),P=K.indexOf(v.length),U=a.base58.decode(v);for(let $=0;$<U.length-P;$++)if(U[$]!==0)throw new Error("base58xmr: wrong padding");B=B.concat(Array.from(U.slice(U.length-P)))}return Uint8Array.from(B)}};const G=S=>A(M(4,B=>S(S(B))),a.base58);a.base58check=G;const k=A(u("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),E("")),T=[996825010,642813549,513874426,1027748829,705979059];function N(S){const B=S>>25;let g=(S&33554431)<<5;for(let v=0;v<T.length;v++)(B>>v&1)===1&&(g^=T[v]);return g}function L(S,B,g=1){const v=S.length;let P=1;for(let U=0;U<v;U++){const $=S.charCodeAt(U);if($<33||$>126)throw new Error(`Invalid prefix (${S})`);P=N(P)^$>>5}P=N(P);for(let U=0;U<v;U++)P=N(P)^S.charCodeAt(U)&31;for(let U of B)P=N(P)^U;for(let U=0;U<6;U++)P=N(P);return P^=g,k.encode(i([P%2**30],30,5,!1))}function q(S){const B=S==="bech32"?1:734539939,g=h(5),v=g.decode,P=g.encode,U=F(v);function $(X,ne,pe=90){if(typeof X!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof X}`);if(!Array.isArray(ne)||ne.length&&typeof ne[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof ne}`);const O=X.length+7+ne.length;if(pe!==!1&&O>pe)throw new TypeError(`Length ${O} exceeds limit ${pe}`);const we=X.toLowerCase(),Ie=L(we,ne,B);return`${we}1${k.encode(ne)}${Ie}`}function _(X,ne=90){if(typeof X!="string")throw new Error(`bech32.decode input should be string, not ${typeof X}`);if(X.length<8||ne!==!1&&X.length>ne)throw new TypeError(`Wrong string length: ${X.length} (${X}). Expected (8..${ne})`);const pe=X.toLowerCase();if(X!==pe&&X!==X.toUpperCase())throw new Error("String must be lowercase or uppercase");X=pe;const O=X.lastIndexOf("1");if(O===0||O===-1)throw new Error('Letter "1" must be present between prefix and data only');const we=X.slice(0,O),Ie=X.slice(O+1);if(Ie.length<6)throw new Error("Data must be at least 6 characters long");const Se=k.decode(Ie).slice(0,-6),Pe=L(we,Se,B);if(!Ie.endsWith(Pe))throw new Error(`Invalid checksum in ${X}: expected "${Pe}"`);return{prefix:we,words:Se}}const se=F(_);function le(X){const{prefix:ne,words:pe}=_(X,!1);return{prefix:ne,words:pe,bytes:v(pe)}}return{encode:$,decode:_,decodeToBytes:le,decodeUnsafe:se,fromWords:v,fromWordsUnsafe:U,toWords:P}}a.bech32=q("bech32"),a.bech32m=q("bech32m"),a.utf8={encode:S=>new TextDecoder().decode(S),decode:S=>new TextEncoder().encode(S)},a.hex=A(h(4),u("0123456789abcdef"),E(""),y(S=>{if(typeof S!="string"||S.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof S} with length ${S.length}`);return S.toLowerCase()}));const Z={utf8:a.utf8,hex:a.hex,base16:a.base16,base32:a.base32,base64:a.base64,base64url:a.base64url,base58:a.base58,base58xmr:a.base58xmr},re="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",ye=(S,B)=>{if(typeof S!="string"||!Z.hasOwnProperty(S))throw new TypeError(re);if(!(B instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return Z[S].encode(B)};a.bytesToString=ye,a.str=a.bytesToString;const me=(S,B)=>{if(!Z.hasOwnProperty(S))throw new TypeError(re);if(typeof B!="string")throw new TypeError("stringToBytes() expects string");return Z[S].decode(B)};a.stringToBytes=me,a.bytes=a.stringToBytes},30855:function(ie,a,I){"use strict";var A=I(48764).Buffer;Object.defineProperty(a,"__esModule",{value:!0}),a.BIP32Factory=void 0;const u=I(3229),E=I(25795),C=I(39187),y=I(23061),s=I(2401),d=I(37174),w=(0,C.base58check)(y.sha256),i={encode:h=>w.encode(Uint8Array.from(h)),decode:h=>A.from(w.decode(h))};function m(h){(0,E.testEcc)(h);const F=s.BufferN(32),M=s.compile({wif:s.UInt8,bip32:{public:s.UInt32,private:s.UInt32}}),V={messagePrefix:`Bitcoin Signed Message:
2
+ `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},K=2147483648,G=Math.pow(2,31)-1;function k(g){return s.String(g)&&g.match(/^(m\/)?(\d+'?\/)*\d+'?$/)!==null}function T(g){return s.UInt32(g)&&g<=G}function N(g){return g.length===32?g:g.slice(1,33)}class L{constructor(v,P){this.__D=v,this.__Q=P,this.lowR=!1}get publicKey(){return this.__Q===void 0&&(this.__Q=A.from(h.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(v,P){if(!this.privateKey)throw new Error("Missing private key");if(P===void 0&&(P=this.lowR),P===!1)return A.from(h.sign(v,this.privateKey));{let U=A.from(h.sign(v,this.privateKey));const $=A.alloc(32,0);let _=0;for(;U[0]>127;)_++,$.writeUIntLE(_,0,6),U=A.from(h.sign(v,this.privateKey,$));return U}}signSchnorr(v){if(!this.privateKey)throw new Error("Missing private key");if(!h.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return A.from(h.signSchnorr(v,this.privateKey))}verify(v,P){return h.verify(v,this.publicKey,P)}verifySchnorr(v,P){if(!h.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return h.verifySchnorr(v,this.publicKey.subarray(1,33),P)}}class q extends L{constructor(v,P,U,$,_=0,se=0,le=0){super(v,P),this.chainCode=U,this.network=$,this.__DEPTH=_,this.__INDEX=se,this.__PARENT_FINGERPRINT=le,s(M,$)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return u.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return this.__D===void 0}neutered(){return S(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const v=this.network,P=this.isNeutered()?v.bip32.public:v.bip32.private,U=A.allocUnsafe(78);return U.writeUInt32BE(P,0),U.writeUInt8(this.depth,4),U.writeUInt32BE(this.parentFingerprint,5),U.writeUInt32BE(this.index,9),this.chainCode.copy(U,13),this.isNeutered()?this.publicKey.copy(U,45):(U.writeUInt8(0,45),this.privateKey.copy(U,46)),i.encode(U)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return d.encode(this.network.wif,this.privateKey,!0)}derive(v){s(s.UInt32,v);const P=v>=K,U=A.allocUnsafe(37);if(P){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");U[0]=0,this.privateKey.copy(U,1),U.writeUInt32BE(v,33)}else this.publicKey.copy(U,0),U.writeUInt32BE(v,33);const $=u.hmacSHA512(this.chainCode,U),_=$.slice(0,32),se=$.slice(32);if(!h.isPrivate(_))return this.derive(v+1);let le;if(this.isNeutered()){const X=A.from(h.pointAddScalar(this.publicKey,_,!0));if(X===null)return this.derive(v+1);le=S(X,se,this.network,this.depth+1,v,this.fingerprint.readUInt32BE(0))}else{const X=A.from(h.privateAdd(this.privateKey,_));if(X==null)return this.derive(v+1);le=ye(X,se,this.network,this.depth+1,v,this.fingerprint.readUInt32BE(0))}return le}deriveHardened(v){return s(T,v),this.derive(v+K)}derivePath(v){s(k,v);let P=v.split("/");if(P[0]==="m"){if(this.parentFingerprint)throw new TypeError("Expected master, got child");P=P.slice(1)}return P.reduce((U,$)=>{let _;return $.slice(-1)==="'"?(_=parseInt($.slice(0,-1),10),U.deriveHardened(_)):(_=parseInt($,10),U.derive(_))},this)}tweak(v){return this.privateKey?this.tweakFromPrivateKey(v):this.tweakFromPublicKey(v)}tweakFromPublicKey(v){const P=N(this.publicKey);if(!h.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const U=h.xOnlyPointAddTweak(P,v);if(!U||U.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const $=A.from([U.parity===0?2:3]),_=A.concat([$,U.xOnlyPubkey]);return new L(void 0,_)}tweakFromPrivateKey(v){const P=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1,U=(()=>{if(P){if(h.privateNegate)return h.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}else return this.privateKey})(),$=h.privateAdd(U,v);if(!$)throw new Error("Invalid tweaked private key!");return new L(A.from($),void 0)}}function Z(g,v){const P=i.decode(g);if(P.length!==78)throw new TypeError("Invalid buffer length");v=v||V;const U=P.readUInt32BE(0);if(U!==v.bip32.private&&U!==v.bip32.public)throw new TypeError("Invalid network version");const $=P[4],_=P.readUInt32BE(5);if($===0&&_!==0)throw new TypeError("Invalid parent fingerprint");const se=P.readUInt32BE(9);if($===0&&se!==0)throw new TypeError("Invalid index");const le=P.slice(13,45);let X;if(U===v.bip32.private){if(P.readUInt8(45)!==0)throw new TypeError("Invalid private key");const ne=P.slice(46,78);X=ye(ne,le,v,$,se,_)}else{const ne=P.slice(45,78);X=S(ne,le,v,$,se,_)}return X}function re(g,v,P){return ye(g,v,P)}function ye(g,v,P,U,$,_){if(s({privateKey:F,chainCode:F},{privateKey:g,chainCode:v}),P=P||V,!h.isPrivate(g))throw new TypeError("Private key not in range [1, n)");return new q(g,void 0,v,P,U,$,_)}function me(g,v,P){return S(g,v,P)}function S(g,v,P,U,$,_){if(s({publicKey:s.BufferN(33),chainCode:F},{publicKey:g,chainCode:v}),P=P||V,!h.isPoint(g))throw new TypeError("Point is not on the curve");return new q(void 0,g,v,P,U,$,_)}function B(g,v){if(s(s.Buffer,g),g.length<16)throw new TypeError("Seed should be at least 128 bits");if(g.length>64)throw new TypeError("Seed should be at most 512 bits");v=v||V;const P=u.hmacSHA512(A.from("Bitcoin seed","utf8"),g),U=P.slice(0,32),$=P.slice(32);return re(U,$,v)}return{fromSeed:B,fromBase58:Z,fromPublicKey:me,fromPrivateKey:re}}a.BIP32Factory=m},3229:function(ie,a,I){"use strict";var A=I(48764).Buffer;Object.defineProperty(a,"__esModule",{value:!0}),a.hmacSHA512=a.hash160=void 0;const u=I(79569),E=I(70830),C=I(23061),y=I(86262);function s(w){const i=(0,C.sha256)(Uint8Array.from(w));return A.from((0,E.ripemd160)(i))}a.hash160=s;function d(w,i){return A.from((0,u.hmac)(y.sha512,w,i))}a.hmacSHA512=d},81224:function(ie,a,I){"use strict";var A;A={value:!0},a.GA=A=void 0;var u=I(30855);A={enumerable:!0,get:function(){return u.BIP32Factory}},Object.defineProperty(a,"GA",{enumerable:!0,get:function(){return u.BIP32Factory}})},25795:function(ie,a,I){"use strict";var A=I(48764).Buffer;Object.defineProperty(a,"__esModule",{value:!0}),a.testEcc=void 0;const u=y=>A.from(y,"hex");function E(y){if(C(y.isPoint(u("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),C(!y.isPoint(u("030000000000000000000000000000000000000000000000000000000000000005"))),C(y.isPrivate(u("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),C(y.isPrivate(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),C(!y.isPrivate(u("0000000000000000000000000000000000000000000000000000000000000000"))),C(!y.isPrivate(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),C(!y.isPrivate(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),C(A.from(y.pointFromScalar(u("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(u("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),y.xOnlyPointAddTweak){C(y.xOnlyPointAddTweak(u("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let s=y.xOnlyPointAddTweak(u("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),u("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));C(A.from(s.xOnlyPubkey).equals(u("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&s.parity===1),s=y.xOnlyPointAddTweak(u("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),u("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}C(A.from(y.pointAddScalar(u("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),u("0000000000000000000000000000000000000000000000000000000000000003"))).equals(u("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),C(A.from(y.privateAdd(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),u("0000000000000000000000000000000000000000000000000000000000000002"))).equals(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),y.privateNegate&&(C(A.from(y.privateNegate(u("0000000000000000000000000000000000000000000000000000000000000001"))).equals(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),C(A.from(y.privateNegate(u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(u("0000000000000000000000000000000000000000000000000000000000000003"))),C(A.from(y.privateNegate(u("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(u("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),C(A.from(y.sign(u("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(u("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),C(y.verify(u("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),u("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),u("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),y.signSchnorr&&C(A.from(y.signSchnorr(u("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),u("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),u("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(u("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),y.verifySchnorr&&C(y.verifySchnorr(u("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),u("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),u("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}a.testEcc=E;function C(y){if(!y)throw new Error("ecc library invalid")}},48057:function(ie,a,I){ie.exports=I(8864)(I(9017))},9017:function(ie,a,I){const A=I(86266).ec,u=new A("secp256k1"),E=u.curve,C=E.n.constructor;function y(i,m){let h=new C(m);if(h.cmp(E.p)>=0)return null;h=h.toRed(E.red);let F=h.redSqr().redIMul(h).redIAdd(E.b).redSqrt();return i===3!==F.isOdd()&&(F=F.redNeg()),u.keyPair({pub:{x:h,y:F}})}function s(i,m,h){let F=new C(m),M=new C(h);if(F.cmp(E.p)>=0||M.cmp(E.p)>=0||(F=F.toRed(E.red),M=M.toRed(E.red),(i===6||i===7)&&M.isOdd()!==(i===7)))return null;const V=F.redSqr().redIMul(F);return M.redSqr().redISub(V.redIAdd(E.b)).isZero()?u.keyPair({pub:{x:F,y:M}}):null}function d(i){const m=i[0];switch(m){case 2:case 3:return i.length!==33?null:y(m,i.subarray(1,33));case 4:case 6:case 7:return i.length!==65?null:s(m,i.subarray(1,33),i.subarray(33,65));default:return null}}function w(i,m){const h=m.encode(null,i.length===33);for(let F=0;F<i.length;++F)i[F]=h[F]}ie.exports={contextRandomize(){return 0},privateKeyVerify(i){const m=new C(i);return m.cmp(E.n)<0&&!m.isZero()?0:1},privateKeyNegate(i){const m=new C(i),h=E.n.sub(m).umod(E.n).toArrayLike(Uint8Array,"be",32);return i.set(h),0},privateKeyTweakAdd(i,m){const h=new C(m);if(h.cmp(E.n)>=0||(h.iadd(new C(i)),h.cmp(E.n)>=0&&h.isub(E.n),h.isZero()))return 1;const F=h.toArrayLike(Uint8Array,"be",32);return i.set(F),0},privateKeyTweakMul(i,m){let h=new C(m);if(h.cmp(E.n)>=0||h.isZero())return 1;h.imul(new C(i)),h.cmp(E.n)>=0&&(h=h.umod(E.n));const F=h.toArrayLike(Uint8Array,"be",32);return i.set(F),0},publicKeyVerify(i){return d(i)===null?1:0},publicKeyCreate(i,m){const h=new C(m);if(h.cmp(E.n)>=0||h.isZero())return 1;const F=u.keyFromPrivate(m).getPublic();return w(i,F),0},publicKeyConvert(i,m){const h=d(m);if(h===null)return 1;const F=h.getPublic();return w(i,F),0},publicKeyNegate(i,m){const h=d(m);if(h===null)return 1;const F=h.getPublic();return F.y=F.y.redNeg(),w(i,F),0},publicKeyCombine(i,m){const h=new Array(m.length);for(let M=0;M<m.length;++M)if(h[M]=d(m[M]),h[M]===null)return 1;let F=h[0].getPublic();for(let M=1;M<h.length;++M)F=F.add(h[M].pub);return F.isInfinity()?2:(w(i,F),0)},publicKeyTweakAdd(i,m,h){const F=d(m);if(F===null)return 1;if(h=new C(h),h.cmp(E.n)>=0)return 2;const M=F.getPublic().add(E.g.mul(h));return M.isInfinity()?2:(w(i,M),0)},publicKeyTweakMul(i,m,h){const F=d(m);if(F===null)return 1;if(h=new C(h),h.cmp(E.n)>=0||h.isZero())return 2;const M=F.getPublic().mul(h);return w(i,M),0},signatureNormalize(i){const m=new C(i.subarray(0,32)),h=new C(i.subarray(32,64));return m.cmp(E.n)>=0||h.cmp(E.n)>=0?1:(h.cmp(u.nh)===1&&i.set(E.n.sub(h).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(i,m){const h=m.subarray(0,32),F=m.subarray(32,64);if(new C(h).cmp(E.n)>=0||new C(F).cmp(E.n)>=0)return 1;const{output:M}=i;let V=M.subarray(4,4+33);V[0]=0,V.set(h,1);let K=33,G=0;for(;K>1&&V[G]===0&&!(V[G+1]&128);--K,++G);if(V=V.subarray(G),V[0]&128||K>1&&V[0]===0&&!(V[1]&128))return 1;let k=M.subarray(6+33,6+33+33);k[0]=0,k.set(F,1);let T=33,N=0;for(;T>1&&k[N]===0&&!(k[N+1]&128);--T,++N);return k=k.subarray(N),k[0]&128||T>1&&k[0]===0&&!(k[1]&128)?1:(i.outputlen=6+K+T,M[0]=48,M[1]=i.outputlen-2,M[2]=2,M[3]=V.length,M.set(V,4),M[4+K]=2,M[5+K]=k.length,M.set(k,6+K),0)},signatureImport(i,m){if(m.length<8||m.length>72||m[0]!==48||m[1]!==m.length-2||m[2]!==2)return 1;const h=m[3];if(h===0||5+h>=m.length||m[4+h]!==2)return 1;const F=m[5+h];if(F===0||6+h+F!==m.length||m[4]&128||h>1&&m[4]===0&&!(m[5]&128)||m[h+6]&128||F>1&&m[h+6]===0&&!(m[h+7]&128))return 1;let M=m.subarray(4,4+h);if(M.length===33&&M[0]===0&&(M=M.subarray(1)),M.length>32)return 1;let V=m.subarray(6+h);if(V.length===33&&V[0]===0&&(V=V.slice(1)),V.length>32)throw new Error("S length is too long");let K=new C(M);K.cmp(E.n)>=0&&(K=new C(0));let G=new C(m.subarray(6+h));return G.cmp(E.n)>=0&&(G=new C(0)),i.set(K.toArrayLike(Uint8Array,"be",32),0),i.set(G.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(i,m,h,F,M){if(M){const G=M;M=k=>{const T=G(m,h,null,F,k);if(!(T instanceof Uint8Array&&T.length===32))throw new Error("This is the way");return new C(T)}}const V=new C(h);if(V.cmp(E.n)>=0||V.isZero())return 1;let K;try{K=u.sign(m,h,{canonical:!0,k:M,pers:F})}catch{return 1}return i.signature.set(K.r.toArrayLike(Uint8Array,"be",32),0),i.signature.set(K.s.toArrayLike(Uint8Array,"be",32),32),i.recid=K.recoveryParam,0},ecdsaVerify(i,m,h){const F={r:i.subarray(0,32),s:i.subarray(32,64)},M=new C(F.r),V=new C(F.s);if(M.cmp(E.n)>=0||V.cmp(E.n)>=0)return 1;if(V.cmp(u.nh)===1||M.isZero()||V.isZero())return 3;const K=d(h);if(K===null)return 2;const G=K.getPublic();return u.verify(m,F,G)?0:3},ecdsaRecover(i,m,h,F){const M={r:m.slice(0,32),s:m.slice(32,64)},V=new C(M.r),K=new C(M.s);if(V.cmp(E.n)>=0||K.cmp(E.n)>=0)return 1;if(V.isZero()||K.isZero())return 2;let G;try{G=u.recoverPubKey(F,M,h)}catch{return 2}return w(i,G),0},ecdh(i,m,h,F,M,V,K){const G=d(m);if(G===null)return 1;const k=new C(h);if(k.cmp(E.n)>=0||k.isZero())return 2;const T=G.getPublic().mul(k);if(M===void 0){const N=T.encode(null,!0),L=u.hash().update(N).digest();for(let q=0;q<32;++q)i[q]=L[q]}else{V||(V=new Uint8Array(32));const N=T.getX().toArray("be",32);for(let re=0;re<32;++re)V[re]=N[re];K||(K=new Uint8Array(32));const L=T.getY().toArray("be",32);for(let re=0;re<32;++re)K[re]=L[re];const q=M(V,K,F);if(!(q instanceof Uint8Array&&q.length===i.length))return 2;i.set(q)}return 0}}},8864:function(ie){const a={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 I(y,s){if(!y)throw new Error(s)}function A(y,s,d){if(I(s instanceof Uint8Array,`Expected ${y} to be an Uint8Array`),d!==void 0)if(Array.isArray(d)){const w=d.join(", "),i=`Expected ${y} to be an Uint8Array with length [${w}]`;I(d.includes(s.length),i)}else{const w=`Expected ${y} to be an Uint8Array with length ${d}`;I(s.length===d,w)}}function u(y){I(C(y)==="Boolean","Expected compressed to be a Boolean")}function E(y=d=>new Uint8Array(d),s){return typeof y=="function"&&(y=y(s)),A("output",y,s),y}function C(y){return Object.prototype.toString.call(y).slice(8,-1)}ie.exports=y=>({contextRandomize(s){switch(I(s===null||s instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),s!==null&&A("seed",s,32),y.contextRandomize(s)){case 1:throw new Error(a.CONTEXT_RANDOMIZE_UNKNOW)}},privateKeyVerify(s){return A("private key",s,32),y.privateKeyVerify(s)===0},privateKeyNegate(s){switch(A("private key",s,32),y.privateKeyNegate(s)){case 0:return s;case 1:throw new Error(a.IMPOSSIBLE_CASE)}},privateKeyTweakAdd(s,d){switch(A("private key",s,32),A("tweak",d,32),y.privateKeyTweakAdd(s,d)){case 0:return s;case 1:throw new Error(a.TWEAK_ADD)}},privateKeyTweakMul(s,d){switch(A("private key",s,32),A("tweak",d,32),y.privateKeyTweakMul(s,d)){case 0:return s;case 1:throw new Error(a.TWEAK_MUL)}},publicKeyVerify(s){return A("public key",s,[33,65]),y.publicKeyVerify(s)===0},publicKeyCreate(s,d=!0,w){switch(A("private key",s,32),u(d),w=E(w,d?33:65),y.publicKeyCreate(w,s)){case 0:return w;case 1:throw new Error(a.SECKEY_INVALID);case 2:throw new Error(a.PUBKEY_SERIALIZE)}},publicKeyConvert(s,d=!0,w){switch(A("public key",s,[33,65]),u(d),w=E(w,d?33:65),y.publicKeyConvert(w,s)){case 0:return w;case 1:throw new Error(a.PUBKEY_PARSE);case 2:throw new Error(a.PUBKEY_SERIALIZE)}},publicKeyNegate(s,d=!0,w){switch(A("public key",s,[33,65]),u(d),w=E(w,d?33:65),y.publicKeyNegate(w,s)){case 0:return w;case 1:throw new Error(a.PUBKEY_PARSE);case 2:throw new Error(a.IMPOSSIBLE_CASE);case 3:throw new Error(a.PUBKEY_SERIALIZE)}},publicKeyCombine(s,d=!0,w){I(Array.isArray(s),"Expected public keys to be an Array"),I(s.length>0,"Expected public keys array will have more than zero items");for(const i of s)A("public key",i,[33,65]);switch(u(d),w=E(w,d?33:65),y.publicKeyCombine(w,s)){case 0:return w;case 1:throw new Error(a.PUBKEY_PARSE);case 2:throw new Error(a.PUBKEY_COMBINE);case 3:throw new Error(a.PUBKEY_SERIALIZE)}},publicKeyTweakAdd(s,d,w=!0,i){switch(A("public key",s,[33,65]),A("tweak",d,32),u(w),i=E(i,w?33:65),y.publicKeyTweakAdd(i,s,d)){case 0:return i;case 1:throw new Error(a.PUBKEY_PARSE);case 2:throw new Error(a.TWEAK_ADD)}},publicKeyTweakMul(s,d,w=!0,i){switch(A("public key",s,[33,65]),A("tweak",d,32),u(w),i=E(i,w?33:65),y.publicKeyTweakMul(i,s,d)){case 0:return i;case 1:throw new Error(a.PUBKEY_PARSE);case 2:throw new Error(a.TWEAK_MUL)}},signatureNormalize(s){switch(A("signature",s,64),y.signatureNormalize(s)){case 0:return s;case 1:throw new Error(a.SIG_PARSE)}},signatureExport(s,d){A("signature",s,64),d=E(d,72);const w={output:d,outputlen:72};switch(y.signatureExport(w,s)){case 0:return d.slice(0,w.outputlen);case 1:throw new Error(a.SIG_PARSE);case 2:throw new Error(a.IMPOSSIBLE_CASE)}},signatureImport(s,d){switch(A("signature",s),d=E(d,64),y.signatureImport(d,s)){case 0:return d;case 1:throw new Error(a.SIG_PARSE);case 2:throw new Error(a.IMPOSSIBLE_CASE)}},ecdsaSign(s,d,w={},i){A("message",s,32),A("private key",d,32),I(C(w)==="Object","Expected options to be an Object"),w.data!==void 0&&A("options.data",w.data),w.noncefn!==void 0&&I(C(w.noncefn)==="Function","Expected options.noncefn to be a Function"),i=E(i,64);const m={signature:i,recid:null};switch(y.ecdsaSign(m,s,d,w.data,w.noncefn)){case 0:return m;case 1:throw new Error(a.SIGN);case 2:throw new Error(a.IMPOSSIBLE_CASE)}},ecdsaVerify(s,d,w){switch(A("signature",s,64),A("message",d,32),A("public key",w,[33,65]),y.ecdsaVerify(s,d,w)){case 0:return!0;case 3:return!1;case 1:throw new Error(a.SIG_PARSE);case 2:throw new Error(a.PUBKEY_PARSE)}},ecdsaRecover(s,d,w,i=!0,m){switch(A("signature",s,64),I(C(d)==="Number"&&d>=0&&d<=3,"Expected recovery id to be a Number within interval [0, 3]"),A("message",w,32),u(i),m=E(m,i?33:65),y.ecdsaRecover(m,s,d,w)){case 0:return m;case 1:throw new Error(a.SIG_PARSE);case 2:throw new Error(a.RECOVER);case 3:throw new Error(a.IMPOSSIBLE_CASE)}},ecdh(s,d,w={},i){switch(A("public key",s,[33,65]),A("private key",d,32),I(C(w)==="Object","Expected options to be an Object"),w.data!==void 0&&A("options.data",w.data),w.hashfn!==void 0?(I(C(w.hashfn)==="Function","Expected options.hashfn to be a Function"),w.xbuf!==void 0&&A("options.xbuf",w.xbuf,32),w.ybuf!==void 0&&A("options.ybuf",w.ybuf,32),A("output",i)):i=E(i,32),y.ecdh(i,s,d,w.data,w.hashfn,w.xbuf,w.ybuf)){case 0:return i;case 1:throw new Error(a.PUBKEY_PARSE);case 2:throw new Error(a.ECDH)}}})},44501:function(ie){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",I="0123456789ABCDEFGHIJKLMNOPQRSTUV",A="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function u(E,C){var y=E.indexOf(C);if(y===-1)throw new Error("Invalid character found: "+C);return y}ie.exports=function(C,y){var s;switch(y){case"RFC3548":case"RFC4648":s=a,C=C.replace(/=+$/,"");break;case"RFC4648-HEX":s=I,C=C.replace(/=+$/,"");break;case"Crockford":s=A,C=C.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+y)}for(var d=C.length,w=0,i=0,m=0,h=new Uint8Array(d*5/8|0),F=0;F<d;F++)i=i<<5|u(s,C[F]),w+=5,w>=8&&(h[m++]=i>>>w-8&255,w-=8);return h.buffer}},8442:function(ie,a,I){const A=I(99488);function u(T,N,L){const q=T[N]+T[L];let Z=T[N+1]+T[L+1];q>=4294967296&&Z++,T[N]=q,T[N+1]=Z}function E(T,N,L,q){let Z=T[N]+L;L<0&&(Z+=4294967296);let re=T[N+1]+q;Z>=4294967296&&re++,T[N]=Z,T[N+1]=re}function C(T,N){return T[N]^T[N+1]<<8^T[N+2]<<16^T[N+3]<<24}function y(T,N,L,q,Z,re){const ye=m[Z],me=m[Z+1],S=m[re],B=m[re+1];u(i,T,N),E(i,T,ye,me);let g=i[q]^i[T],v=i[q+1]^i[T+1];i[q]=v,i[q+1]=g,u(i,L,q),g=i[N]^i[L],v=i[N+1]^i[L+1],i[N]=g>>>24^v<<8,i[N+1]=v>>>24^g<<8,u(i,T,N),E(i,T,S,B),g=i[q]^i[T],v=i[q+1]^i[T+1],i[q]=g>>>16^v<<16,i[q+1]=v>>>16^g<<16,u(i,L,q),g=i[N]^i[L],v=i[N+1]^i[L+1],i[N]=v>>>31^g<<1,i[N+1]=g>>>31^v<<1}const s=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),d=[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],w=new Uint8Array(d.map(function(T){return T*2})),i=new Uint32Array(32),m=new Uint32Array(32);function h(T,N){let L=0;for(L=0;L<16;L++)i[L]=T.h[L],i[L+16]=s[L];for(i[24]=i[24]^T.t,i[25]=i[25]^T.t/4294967296,N&&(i[28]=~i[28],i[29]=~i[29]),L=0;L<32;L++)m[L]=C(T.b,4*L);for(L=0;L<12;L++)y(0,8,16,24,w[L*16+0],w[L*16+1]),y(2,10,18,26,w[L*16+2],w[L*16+3]),y(4,12,20,28,w[L*16+4],w[L*16+5]),y(6,14,22,30,w[L*16+6],w[L*16+7]),y(0,10,20,30,w[L*16+8],w[L*16+9]),y(2,12,22,24,w[L*16+10],w[L*16+11]),y(4,14,16,26,w[L*16+12],w[L*16+13]),y(6,8,18,28,w[L*16+14],w[L*16+15]);for(L=0;L<16;L++)T.h[L]=T.h[L]^i[L]^i[L+16]}const F=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 M(T,N,L,q){if(T===0||T>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(N&&N.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(L&&L.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(q&&q.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const Z={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:T};F.fill(0),F[0]=T,N&&(F[1]=N.length),F[2]=1,F[3]=1,L&&F.set(L,32),q&&F.set(q,48);for(let re=0;re<16;re++)Z.h[re]=s[re]^C(F,re*4);return N&&(V(Z,N),Z.c=128),Z}function V(T,N){for(let L=0;L<N.length;L++)T.c===128&&(T.t+=T.c,h(T,!1),T.c=0),T.b[T.c++]=N[L]}function K(T){for(T.t+=T.c;T.c<128;)T.b[T.c++]=0;h(T,!0);const N=new Uint8Array(T.outlen);for(let L=0;L<T.outlen;L++)N[L]=T.h[L>>2]>>8*(L&3);return N}function G(T,N,L,q,Z){L=L||64,T=A.normalizeInput(T),q&&(q=A.normalizeInput(q)),Z&&(Z=A.normalizeInput(Z));const re=M(L,N,q,Z);return V(re,T),K(re)}function k(T,N,L,q,Z){const re=G(T,N,L,q,Z);return A.toHex(re)}ie.exports={blake2b:G,blake2bHex:k,blake2bInit:M,blake2bUpdate:V,blake2bFinal:K}},45297:function(ie,a,I){const A=I(99488);function u(K,G){return K[G]^K[G+1]<<8^K[G+2]<<16^K[G+3]<<24}function E(K,G,k,T,N,L){d[K]=d[K]+d[G]+N,d[T]=C(d[T]^d[K],16),d[k]=d[k]+d[T],d[G]=C(d[G]^d[k],12),d[K]=d[K]+d[G]+L,d[T]=C(d[T]^d[K],8),d[k]=d[k]+d[T],d[G]=C(d[G]^d[k],7)}function C(K,G){return K>>>G^K<<32-G}const y=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=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]),d=new Uint32Array(16),w=new Uint32Array(16);function i(K,G){let k=0;for(k=0;k<8;k++)d[k]=K.h[k],d[k+8]=y[k];for(d[12]^=K.t,d[13]^=K.t/4294967296,G&&(d[14]=~d[14]),k=0;k<16;k++)w[k]=u(K.b,4*k);for(k=0;k<10;k++)E(0,4,8,12,w[s[k*16+0]],w[s[k*16+1]]),E(1,5,9,13,w[s[k*16+2]],w[s[k*16+3]]),E(2,6,10,14,w[s[k*16+4]],w[s[k*16+5]]),E(3,7,11,15,w[s[k*16+6]],w[s[k*16+7]]),E(0,5,10,15,w[s[k*16+8]],w[s[k*16+9]]),E(1,6,11,12,w[s[k*16+10]],w[s[k*16+11]]),E(2,7,8,13,w[s[k*16+12]],w[s[k*16+13]]),E(3,4,9,14,w[s[k*16+14]],w[s[k*16+15]]);for(k=0;k<8;k++)K.h[k]^=d[k]^d[k+8]}function m(K,G){if(!(K>0&&K<=32))throw new Error("Incorrect output length, should be in [1, 32]");const k=G?G.length:0;if(G&&!(k>0&&k<=32))throw new Error("Incorrect key length, should be in [1, 32]");const T={h:new Uint32Array(y),b:new Uint8Array(64),c:0,t:0,outlen:K};return T.h[0]^=16842752^k<<8^K,k>0&&(h(T,G),T.c=64),T}function h(K,G){for(let k=0;k<G.length;k++)K.c===64&&(K.t+=K.c,i(K,!1),K.c=0),K.b[K.c++]=G[k]}function F(K){for(K.t+=K.c;K.c<64;)K.b[K.c++]=0;i(K,!0);const G=new Uint8Array(K.outlen);for(let k=0;k<K.outlen;k++)G[k]=K.h[k>>2]>>8*(k&3)&255;return G}function M(K,G,k){k=k||32,K=A.normalizeInput(K);const T=m(k,G);return h(T,K),F(T)}function V(K,G,k){const T=M(K,G,k);return A.toHex(T)}ie.exports={blake2s:M,blake2sHex:V,blake2sInit:m,blake2sUpdate:h,blake2sFinal:F}},1191:function(ie,a,I){const A=I(8442),u=I(45297);ie.exports={blake2b:A.blake2b,blake2bHex:A.blake2bHex,blake2bInit:A.blake2bInit,blake2bUpdate:A.blake2bUpdate,blake2bFinal:A.blake2bFinal,blake2s:u.blake2s,blake2sHex:u.blake2sHex,blake2sInit:u.blake2sInit,blake2sUpdate:u.blake2sUpdate,blake2sFinal:u.blake2sFinal}},99488:function(ie){const a="Input must be an string, Buffer or Uint8Array";function I(y){let s;if(y instanceof Uint8Array)s=y;else if(typeof y=="string")s=new TextEncoder().encode(y);else throw new Error(a);return s}function A(y){return Array.prototype.map.call(y,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function u(y){return(4294967296+y).toString(16).substring(1)}function E(y,s,d){let w=`
3
+ `+y+" = ";for(let i=0;i<s.length;i+=2){if(d===32)w+=u(s[i]).toUpperCase(),w+=" ",w+=u(s[i+1]).toUpperCase();else if(d===64)w+=u(s[i+1]).toUpperCase(),w+=u(s[i]).toUpperCase();else throw new Error("Invalid size "+d);i%6===4?w+=`
4
+ `+new Array(y.length+4).join(" "):i<s.length-2&&(w+=" ")}console.log(w)}function C(y,s,d){let w=new Date().getTime();const i=new Uint8Array(s);for(let h=0;h<s;h++)i[h]=h%256;const m=new Date().getTime();console.log("Generated random input in "+(m-w)+"ms"),w=m;for(let h=0;h<d;h++){const F=y(i),M=new Date().getTime(),V=M-w;w=M,console.log("Hashed in "+V+"ms: "+F.substring(0,20)+"..."),console.log(Math.round(s/(1<<20)/(V/1e3)*100)/100+" MB PER SECOND")}}ie.exports={normalizeInput:I,toHex:A,debugPrint:E,testSpeed:C}},53533:function(ie,a,I){const A=I(89509).Buffer;ie.exports=class{constructor(E=A.from([])){this.buffer=E,this._bytesRead=0,this._bytesWrote=0}read(E){this._bytesRead+=E;const C=this.buffer.slice(0,E);return this.buffer=this.buffer.slice(E),C}write(E){E=A.from(E),this._bytesWrote+=E.length,this.buffer=A.concat([this.buffer,E])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},95548:function(ie,a,I){a.unsigned=I(16922),I(44927)},44927:function(ie,a,I){const A=I(13550),u=I(53533);ie.exports={encode:s,decode:d,write:y,read:E,readBn:C};function E(w){return C(w).toString()}function C(w){const i=new A(0);let m=0,h;for(;h=w.read(1)[0],i.ior(new A(h&127).shln(m)),m+=7,h>>7!==0;);return h&64&&i.setn(m),i.fromTwos(m)}function y(w,i){let m=new A(w);const h=m.isNeg();for(h&&(m=m.toTwos(m.bitLength()+8));;){const M=m.maskn(7).toNumber();if(m.ishrn(7),F(m)&&(M&64)!==0||m.isZero()&&(M&64)===0){i.write([M]);break}else i.write([M|128])}function F(M){return h&&M.toString(2).indexOf("0")<0}}function s(w){const i=new u;return y(w,i),i.buffer}function d(w){const i=new u(w);return E(i)}},16922:function(ie,a,I){const A=I(13550),u=I(53533);ie.exports={encode:s,decode:d,read:E,readBn:C,write:y};function E(w){return C(w).toString()}function C(w){const i=new A(0);let m=0,h;for(;h=w.read(1)[0],i.ior(new A(h&127).shln(m)),h>>7!==0;)m+=7;return i}function y(w,i){const m=new A(w);for(;;){const h=m.maskn(7).toNumber();if(m.ishrn(7),m.isZero()){i.write([h]);break}else i.write([h|128])}}function s(w){const i=new u;return y(w,i),i.buffer}function d(w){const i=new u(w);return E(i)}},23145:function(ie,a,I){"use strict";I.d(a,{kL:function(){return D},Zc:function(){return s},PY:function(){return d},rP:function(){return lt},Pc:function(){return R},BG:function(){return k},WU:function(){return ke},YW:function(){return he},w5:function(){return p}});var A=I(9669),u=I(13550),E;(function(o){o.ETH="10"})(E||(E={}));const C=255;var y;(function(o){o[o.ID=0]="ID",o[o.SECP256K1=1]="SECP256K1",o[o.ACTOR=2]="ACTOR",o[o.BLS=3]="BLS",o[o.DELEGATED=4]="DELEGATED"})(y||(y={}));var s;(function(o){o.Mainnet="mainnet",o.Calibration="calibration",o.Butterfly="butterfly"})(s||(s={}));var d;(function(o){o.Mainnet="f",o.Testnet="t"})(d||(d={}));const w=20,i=54,m=48,h=20,F=20,M=9,V=new u(2).pow(new u(63)).sub(new u(1));var K;(function(o){o[o.Zero=0]="Zero"})(K||(K={}));var G;(function(o){o[o.Transfer=0]="Transfer",o[o.InvokeEVM=3844450837]="InvokeEVM"})(G||(G={}));var k;(function(o){o[o.SECP256K1=1]="SECP256K1",o[o.BLS=3]="BLS"})(k||(k={}));var T;(function(o){o[o.System=0]="System",o[o.Init=1]="Init",o[o.Reward=2]="Reward",o[o.Cron=3]="Cron",o[o.StoragePower=4]="StoragePower",o[o.StorageMarket=5]="StorageMarket",o[o.VerifiedRegistry=6]="VerifiedRegistry",o[o.DataCap=7]="DataCap",o[o.EAM=10]="EAM"})(T||(T={}));var N;(function(o){o[o.Exec=2]="Exec",o[o.Exec4=3]="Exec4"})(N||(N={}));var L;(function(o){o[o.UpdateChannelState=2]="UpdateChannelState",o[o.Settle=3]="Settle",o[o.Collect=4]="Collect"})(L||(L={}));var q;(function(o){o.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",o.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",o.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",o.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",o.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",o.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",o.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",o.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",o.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",o.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",o.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",o.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",o.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",o.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",o.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",o.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(q||(q={}));var Z;(function(o){o.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",o.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",o.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",o.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",o.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",o.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",o.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",o.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",o.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",o.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",o.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",o.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",o.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",o.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",o.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",o.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(Z||(Z={}));var re=I(44501),ye=I(95548);const me="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",S="0123456789ABCDEFGHIJKLMNOPQRSTUV",B="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function g(o,t,c){c=c||{};let b,z;switch(t){case"RFC3548":case"RFC4648":b=me,z=!0;break;case"RFC4648-HEX":b=S,z=!0;break;case"Crockford":b=B,z=!1;break}if(!b)throw new Error(`Unknown base32 variant: ${t}`);const ee=c.padding!==void 0?c.padding:z,ae=v(o);let ce=0,de=0,Ae="";for(let Ue=0;Ue<ae.byteLength;Ue++)for(de=de<<8|ae.getUint8(Ue),ce+=8;ce>=5;)Ae+=b[de>>>ce-5&31],ce-=5;if(ce>0&&(Ae+=b[de<<5-ce&31]),ee)for(;Ae.length%8!==0;)Ae+="=";return Ae}function v(o){if(o instanceof Int8Array||o instanceof Uint8Array||o instanceof Uint8ClampedArray)return new DataView(o.buffer,o.byteOffset,o.byteLength);if(o instanceof ArrayBuffer)return new DataView(o);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class P extends Error{constructor(t){super(),this.message=`Invalid protocol indicator byte [${t}]`}}class U extends Error{constructor(t){super(),this.message="Unknown protocol indicator byte [${value}]"}}class $ extends Error{constructor(t){super(),this.message=`Invalid payload length [${t}]`}}class _ extends Error{constructor(t){super(),this.message=`Invalid namespace [${t}]`}}class se extends Error{constructor(t){super(),this.message=`Invalid network [${t}]`}}class le extends Error{constructor(){super(),this.message="Invalid subAddress."}}class X extends Error{constructor(t){super(),this.message=`${t} protocol not supported.`}}class ne extends Error{constructor(t,c){super(),this.message=`Invalid address (checksum not matching the payload). ${t} vs ${c}`}}class pe extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var O=I(1191),we=I(48764).Buffer;function Ie(o){const t=O.blake2bInit(4);return O.blake2bUpdate(t,o),we.from(O.blake2bFinal(t))}function Se(o){let t=0;for(;t<o.length;){const c=o[t];if(t++,c<128)break}return t==o.length?-1:t}const Pe=o=>Object.values(d).includes(o),Xe=o=>Object.values(Network).includes(o),Me=o=>o===s.Mainnet?d.Mainnet:d.Testnet,Ne=o=>o!==Network.Mainnet;var l=I(48764).Buffer;const it=class{constructor(t,c){x(this,"networkPrefix");x(this,"protocol");x(this,"getPayload",()=>this.payload);x(this,"getNetworkPrefix",()=>this.networkPrefix);x(this,"getProtocol",()=>this.protocol);x(this,"getChecksum",()=>Ie(this.toBytes()));this.networkPrefix=t,this.protocol=c}};let D=it;x(D,"fromString",t=>{const c=parseInt(t[1]);switch(c){case y.ID:return fe.fromString(t);case y.ACTOR:return ge.fromString(t);case y.SECP256K1:return be.fromString(t);case y.BLS:return Y.fromString(t);case y.DELEGATED:{const b=Be.fromString(t);return it.isFilEthAddress(b)?new Ke(b.getNetworkPrefix(),b.getSubAddress()):b}default:throw new U(c)}}),x(D,"fromBytes",(t,c)=>{const b=c[0];switch(b){case y.ID:return fe.fromBytes(t,c);case y.ACTOR:return ge.fromBytes(t,c);case y.SECP256K1:return be.fromBytes(t,c);case y.BLS:return Y.fromBytes(t,c);case y.DELEGATED:{const z=Be.fromBytes(t,c);return it.isFilEthAddress(z)?new Ke(z.getNetworkPrefix(),z.getSubAddress()):z}default:throw new U(b)}}),x(D,"fromEthAddress",(t,c)=>{if(typeof c=="string"){const z=c.startsWith("0x")?c.substring(2):c;c=l.from(z,"hex")}const b=l.alloc(12);if(b[0]=C,b.compare(c,0,12)==0){let z=12;for(;c[z]==0;)z+=1;return new fe(t,l.from(c.subarray(z)))}return new Ke(t,c)}),x(D,"isAddressId",t=>t.protocol==y.ID),x(D,"isAddressBls",t=>t.protocol==y.BLS),x(D,"isAddressSecp256k1",t=>t.protocol==y.SECP256K1),x(D,"isAddressDelegated",t=>t.protocol==y.DELEGATED),x(D,"isFilEthAddress",t=>t.protocol==y.DELEGATED&&"namespace"in t&&t.namespace==E.ETH),x(D,"isAddressActor",t=>t.protocol==y.ACTOR);class Y extends D{constructor(c,b){super(c,y.BLS);x(this,"payload");x(this,"toBytes",()=>l.concat([l.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+g(l.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(b.byteLength!==m)throw new $(b.byteLength);this.payload=b}static fromString(c){const b=c[0],z=c[1];if(!Pe(b))throw new se(b);if(parseInt(z)!=y.BLS)throw new P(parseInt(z));const ee=l.from(re(c.substring(2).toUpperCase(),"RFC4648")),ae=l.from(ee.subarray(0,-4)),ce=l.from(ee.subarray(-4)),de=new Y(b,ae);if(de.getChecksum().toString("hex")!==ce.toString("hex"))throw new ne(de.getChecksum().toString("hex"),ce.toString("hex"));return de}static fromBytes(c,b){if(b[0]!=y.BLS)throw new P(b[0]);const z=l.from(b.subarray(1));return new Y(c,z)}}class fe extends D{constructor(c,b){super(c,y.ID);x(this,"id");x(this,"payload");x(this,"toBytes",()=>l.concat([l.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>this.networkPrefix+this.protocol.toString()+ye.unsigned.decode(this.payload));x(this,"getId",()=>this.id);x(this,"toEthAddressHex",(c=!1)=>{const b=l.alloc(w);return b[0]=C,b.set(this.payload,w-this.payload.length),`${c?"0x":""}${b.toString("hex")}`});const z=typeof b=="string"?ye.unsigned.encode(b):b;if(z.length>M)throw new $(z.length);this.payload=z,this.id=this.toString().substring(2)}static fromString(c){const b=c[0],z=c[1];if(!Pe(b))throw new se(b);if(parseInt(z)!=y.ID)throw new P(parseInt(z));const ee=ye.unsigned.encode(c.substring(2));return new fe(b,ee)}static fromBytes(c,b){if(b[0]!=y.ID)throw new P(b[0]);const z=l.from(b.subarray(1));return new fe(c,z)}}class be extends D{constructor(c,b){super(c,y.SECP256K1);x(this,"payload");x(this,"toBytes",()=>l.concat([l.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+g(l.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(b.byteLength!==F)throw new $(b.byteLength);this.payload=b}static fromString(c){const b=c[0],z=c[1];if(!Pe(b))throw new se(b);if(parseInt(z)!=y.SECP256K1)throw new P(parseInt(z));const ee=l.from(re(c.substring(2).toUpperCase(),"RFC4648")),ae=l.from(ee.subarray(0,-4)),ce=l.from(ee.subarray(-4)),de=new be(b,ae);if(de.getChecksum().toString("hex")!==ce.toString("hex"))throw new ne(de.getChecksum().toString("hex"),ce.toString("hex"));return de}static fromBytes(c,b){if(b[0]!=y.SECP256K1)throw new P(b[0]);const z=l.from(b.subarray(1));return new be(c,z)}}class ge extends D{constructor(c,b){super(c,y.ACTOR);x(this,"payload");x(this,"toBytes",()=>l.concat([l.from(`0${this.protocol}`,"hex"),this.payload]));x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+g(l.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(b.byteLength!==h)throw new $(b.byteLength);this.payload=b}static fromString(c){const b=c[0],z=c[1];if(!Pe(b))throw new se(b);if(parseInt(z)!=y.ACTOR)throw new P(parseInt(z));const ee=l.from(re(c.substring(2).toUpperCase(),"RFC4648")),ae=l.from(ee.subarray(0,-4)),ce=l.from(ee.subarray(-4)),de=new ge(b,ae);if(de.getChecksum().toString("hex")!==ce.toString("hex"))throw new ne(de.getChecksum().toString("hex"),ce.toString("hex"));return de}static fromBytes(c,b){if(b[0]!=y.ACTOR)throw new P(b[0]);const z=l.from(b.subarray(1));return new ge(c,z)}}class Be extends D{constructor(c,b,z){super(c,y.DELEGATED);x(this,"payload");x(this,"namespace");x(this,"subAddress");x(this,"getNamespace",()=>this.namespace);x(this,"getSubAddress",()=>this.subAddress);x(this,"toBytes",()=>{const c=l.from(ye.unsigned.encode(this.namespace)),b=l.from(ye.unsigned.encode(this.protocol));return l.concat([b,c,this.subAddress])});x(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+g(l.concat([this.subAddress,c]),"RFC4648",{padding:!1}).toLowerCase()});if(new u(b).gt(V))throw new _(b);if(z.length===0||z.length>i)throw new le;this.namespace=b,this.subAddress=z,this.payload=l.from(this.toBytes().subarray(1))}static fromString(c){const b=c[0],z=c[1];if(!Pe(b))throw new se(b);if(parseInt(z)!=y.DELEGATED)throw new P(parseInt(z));const ee=c.substring(2,c.indexOf("f",2)),ae=c.substring(c.indexOf("f",2)+1),ce=l.from(re(ae.toUpperCase(),"RFC4648")),de=l.from(ce.subarray(0,-4)),Ae=l.from(ce.subarray(-4)),Ue=new Be(b,ee,de);if(Ue.getChecksum().toString("hex")!==Ae.toString("hex"))throw new ne(Ue.getChecksum().toString("hex"),Ae.toString("hex"));return Ue}static fromBytes(c,b){if(b[0]!=y.DELEGATED)throw new P(b[0]);const z=Se(l.from(b.subarray(1))),ee=ye.unsigned.decode(l.from(b.subarray(1,1+z))),ae=l.from(b.subarray(z+1));return new Be(c,ee,ae)}}class Ke extends Be{constructor(c,b){super(c,E.ETH,b);x(this,"toEthAddressHex",(c=!1)=>`${c?"0x":""}${this.subAddress.toString("hex")}`);if(b.length!==w)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(c,b){const z=Be.fromBytes(c,b);if(z.getNamespace()!==E.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(z.getNetworkPrefix(),z.getSubAddress())}static fromString(c){const b=Be.fromString(c);if(b.getNamespace()!==E.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(b.getNetworkPrefix(),b.getSubAddress())}}const Ce="2.0",at="Filecoin.MpoolGetNonce",qe="Filecoin.MpoolPush",ct="Filecoin.StateWaitMsg",Qe="Filecoin.GasEstimateMessageGas",ft="Filecoin.StateReadState",Je="Filecoin.StateListMiners",_e="Filecoin.StateMinerInfo",et="Filecoin.ClientQueryAsk",ut="Filecoin.WalletBalance";class lt{constructor(t,c){x(this,"fetcher");x(this,"network");x(this,"getNetwork",()=>this.network);x(this,"validateNetwork",(t,c="address")=>{const b=Me(this.network);if(typeof t=="string"&&(t=D.fromString(t)),t.getNetworkPrefix()!==b)throw new Error(`${c} belongs to ${t.getNetworkPrefix()} network while rpc allows ${b}`);return t});this.fetcher=A.create({baseURL:c.url,timeout:c.timeout,headers:{Authorization:`Bearer ${c.token}`}}),this.network=t}async getNonce(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:at,id:1,params:[t.toString()]})).data}catch(c){return this.handleError(c)}}async broadcastTransaction(t,c){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:qe,id:1,params:[{Message:t.toJSON(),Signature:c.toJSON()}]})).data}catch(b){return this.handleError(b)}}async getGasEstimation(t){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Qe,id:1,params:[t.toJSON(),{MaxFee:"0"},null]})).data}catch(c){return this.handleError(c)}}async readState(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ft,id:1,params:[t.toString(),null]})).data}catch(c){return this.handleError(c)}}async waitMsgState(t,c,b){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ct,id:1,params:[t,c,b,!1]})).data}catch(z){return this.handleError(z)}}async walletBalance(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ut,id:1,params:[t.toString()]})).data}catch(c){return this.handleError(c)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Je,id:1,params:[null]})).data}catch(t){return this.handleError(t)}}async getMinerInfo(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:_e,id:1,params:[t.toString(),null]})).data}catch(c){return this.handleError(c)}}async askForStorage(t,c){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:et,id:1,params:[c,t.toString()]})).data}catch(b){return this.handleError(b)}}handleError(t){if(A.isAxiosError(t)){if(t.response){if(t.response.data)return t.response.data;if(t.response.statusText)return{error:{message:`${t.response.status} - ${t.response.statusText}`}}}if(t.request)return{error:{message:"request made but no response received"}};if(t.message)return{error:{message:t.message}}}throw t}}class bt extends null{constructor(t){super(Network.Mainnet,t)}}class yt extends null{constructor(t){super(Network.Calibration,t)}}class Ve extends null{constructor(t){super(Network.Butterfly,t)}}var ze=I(2153),ht=I(81224),tt=I(77235),dt=I.t(tt,2),He=I(48057),Oe=I(48764).Buffer;const rt=Oe.from([1,113,160,228,2,32]),nt=32,ot=o=>{const t=o.split("/");return t[2].includes("'")?t[2].substring(0,t[2].length-1):t[2]};function Ee(o){const t=O.blake2bInit(nt);O.blake2bUpdate(t,o);const c=Oe.from(O.blake2bFinal(t));return Oe.concat([rt,c])}function Te(o){const t=O.blake2bInit(32);return O.blake2bUpdate(t,Ee(o)),Oe.from(O.blake2bFinal(t))}const $e=o=>{if(typeof o=="string")if(o.substring(o.length-1)==="=")o=Oe.from(o,"base64");else throw new pe;if(o.length!==32)throw new pe;return o},n=o=>{const t=O.blake2bInit(20);return O.blake2bUpdate(t,o),Oe.from(O.blake2bFinal(t))},e=o=>k.BLS===o||k.SECP256K1===o;var r=I(48764).Buffer;const f=ht.GA(dt),Ze=class{static recoverAccount(t,c,b,z){switch(c){case k.SECP256K1:{b=$e(b);const{publicKey:ee,address:ae}=Ze.getPublicSecp256k1FromPrivKey(t,b);return{type:c,privateKey:b,address:ae,publicKey:ee,path:z}}default:throw new Error("not supported yet")}}};let p=Ze;x(p,"generateMnemonic",()=>ze.generateMnemonic(256)),x(p,"mnemonicToSeed",(t,c)=>ze.mnemonicToSeedSync(t,c)),x(p,"deriveAccount",(t,c,b,z,ee)=>{const ae=Ze.mnemonicToSeed(t,z);return Ze.deriveAccountFromSeed(ae,c,b,ee)}),x(p,"deriveAccountFromSeed",(t,c,b,z)=>{switch(typeof t=="string"&&(t=r.from(t,"hex")),c){case k.SECP256K1:{const ee=f.fromSeed(t),{privateKey:ae}=ee.derivePath(b);if(!ae)throw new Error("privateKey not generated");z||(z=ot(b)==="1"?d.Testnet:d.Mainnet);const{publicKey:ce,address:de}=Ze.getPublicSecp256k1FromPrivKey(z,ae);return{type:c,privateKey:ae,publicKey:ce,address:de,path:b}}default:throw new Error("not supported yet")}}),x(p,"signTransaction",async(t,c)=>{const b=await c.serialize(),z=Te(b),{privateKey:ee,type:ae}=t;switch(ae){case k.SECP256K1:{const ce=He.ecdsaSign(z,ee);return new R(ae,r.concat([r.from(ce.signature),r.from([ce.recid])]))}default:throw new Error("not supported yet")}}),x(p,"verifySignature",async(t,c)=>{const b=await c.serialize(),z=Te(b);switch(t.getType()){case k.SECP256K1:{const ee=t.getData(),ae=He.ecdsaRecover(ee.subarray(0,-1),ee[64],z,!1),ce=n(ae);return c.from.getPayload().toString("hex")!==ce.toString("hex")?!1:He.ecdsaVerify(ee.subarray(0,-1),z,ae)}default:throw new Error("not supported yet")}}),x(p,"getPublicSecp256k1FromPrivKey",(t,c)=>{const b=He.publicKeyCreate(c),z=new Uint8Array(65);He.publicKeyConvert(b,!1,z);const ee=r.from(z),ae=n(z);return{publicKey:ee,address:new be(t,ae)}});const wt=class{constructor(t,c){x(this,"type");x(this,"data");x(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));x(this,"getType",()=>this.type);x(this,"getData",()=>this.data);x(this,"isSecp256k1",()=>this.type===k.SECP256K1);x(this,"isBls",()=>this.type===k.BLS);this.type=t,this.data=c}};let R=wt;x(R,"fromJSON",t=>{if(typeof t!="object"||t===null)throw new Error("input should be an object");if(!("Type"in t)||typeof t.Type!="number")throw new Error("'Type' should be a number");if(!e(t.Type))throw new Error("invalid signature type");if(!("Data"in t)||typeof t.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new wt(t.Type,r.from(t.Data,"base64"))});var H=I(48764).Buffer;const j=(o,t=10)=>{if(o.toString()==="0")return H.from("");const c=new u(o,t),b=c.toArrayLike(H,"be",c.byteLength()),z=H.from(c.isNeg()?"01":"00","hex");return H.concat([z,b])},Q=(o,t=10)=>{if(o.length===0)return"0";if(o[0]!=0&&o[0]!=1)throw new Error("invalid bigint");const c=o[0]===1?"-":"",b=new u(o.subarray(1));return c+b.toString(t)},W=o=>new Promise(t=>setTimeout(t,o)),J=async o=>{let t=o();for(;!t;)await W(50),t=o();return t};var te=I(48764).Buffer;let oe;I.e(8190).then(I.bind(I,88190)).then(o=>{oe=o}).catch(o=>{throw o});const We=class{constructor(t,c,b,z,ee,ae,ce,de,Ae,Ue){x(this,"version");x(this,"to");x(this,"from");x(this,"nonce");x(this,"value");x(this,"gasLimit");x(this,"gasFeeCap");x(this,"gasPremium");x(this,"method");x(this,"params");x(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}));x(this,"serialize",async()=>{const t=await J(()=>oe),c=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,j(this.value,10),this.gasLimit,j(this.gasFeeCap,10),j(this.gasPremium,10),this.method,te.from(this.params,"base64")];return te.from(t.encode(c))});x(this,"prepareToSend",async t=>{const c=await t.getNonce(this.from);if("error"in c)throw new Error(c.error.message);this.nonce=c.result;const b=await t.getGasEstimation(this);if("error"in b)throw new Error(b.error.message);return this.gasFeeCap=b.result.GasFeeCap,this.gasLimit=b.result.GasLimit,this.gasPremium=b.result.GasPremium,this});if(this.version=t,this.to=c,this.from=b,this.nonce=z,this.value=ee,this.gasLimit=ae,this.gasFeeCap=ce,this.gasPremium=de,this.method=Ae,this.params=Ue,ee===""||ee.includes("-"))throw new Error("value must not be empty or negative")}};let he=We;x(he,"getNew",(t,c,b,z,ee=te.alloc(0))=>new We(K.Zero,t,c,0,b.toAtto(),0,"0","0",z,ee.toString("base64"))),x(he,"fromCBOR",async(t,c)=>{typeof c=="string"&&(c=te.from(c,"hex"));const z=(await J(()=>oe)).decode(c);if(!(z instanceof Array))throw new Error("Decoded raw tx should be an array");if(z.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[ee,ae,ce,de,Ae,Ue,Ct,Tt,Rt,Ut]=z;if(ee!==K.Zero)throw new Error("Unsupported version");if(Ae[0]===1)throw new Error("Value cant be negative");const Nt=new u(te.from(Ae).toString("hex"),16).toString(10),Kt=new u(te.from(Ct).toString("hex"),16).toString(10),zt=new u(te.from(Tt).toString("hex"),16).toString(10);return new We(ee,D.fromBytes(t,ae),D.fromBytes(t,ce),de,Nt,Ue,Kt,zt,Rt,Ut.toString("base64"))}),x(he,"fromJSON",t=>{if(typeof t!="object"||t==null)throw new Error("tx should be an json object");if(!("To"in t)||typeof t.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in t)||typeof t.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in t)||typeof t.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in t)||typeof t.Value!="string"||t.Value===""||t.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in t)||typeof t.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in t)||typeof t.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in t)||typeof t.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in t)||typeof t.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in t)||typeof t.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new We(K.Zero,D.fromString(t.To),D.fromString(t.From),t.Nonce,t.Value,t.GasLimit,t.GasFeeCap,t.GasPremium,t.Method,t.Params)});const ue=(o,t)=>{const c=o.isNeg()?"-":"",b=o.abs().toString(),z=b.length-t,ee=xe(z>0?`${b.substring(0,z)}.${b.substring(z)}`:`0.${"".padStart(-1*z,"0")}${b}`);return`${c}${ee}`},xe=o=>{for(let t=o.length-1;t>=0;t--){if(o[t]==".")return o.substring(0,t);if(o[t]!="0"||t===1)return o.substring(0,t+1)}throw new Error("invalid value")},ve=18,Le=15,De=12,je=9,Ge=6,Fe=3,St=0,xt=new u(10).pow(new u(Fe)),At=new u(10).pow(new u(Ge)),Pt=new u(10).pow(new u(je)),Bt=new u(10).pow(new u(De)),kt=new u(10).pow(new u(Le)),It=new u(10).pow(new u(ve)),Re=class{constructor(t){x(this,"value");x(this,"add",t=>(this.value=this.value.add(t.value),this));x(this,"sub",t=>(this.value=this.value.sub(t.value),this));x(this,"gt",t=>this.value.gt(t.value));x(this,"gte",t=>this.value.gte(t.value));x(this,"lt",t=>this.value.lt(t.value));x(this,"lte",t=>this.value.lte(t.value));x(this,"isNegative",()=>this.value.isNeg());x(this,"isPositive",()=>!this.value.isNeg());x(this,"isZero",()=>this.value.isZero());x(this,"toWhole",()=>ue(this.value,ve));x(this,"toMilli",()=>ue(this.value,ve-Fe));x(this,"toMicro",()=>ue(this.value,ve-Ge));x(this,"toNano",()=>ue(this.value,ve-je));x(this,"toPico",()=>ue(this.value,ve-De));x(this,"toFemto",()=>ue(this.value,ve-Le));x(this,"toAtto",()=>ue(this.value,0));x(this,"serialize",()=>j(this.value.toString(10),10));this.value=t}};let ke=Re;x(ke,"zero",()=>new Re(new u("0"))),x(ke,"deserialize",t=>new Re(new u(Q(t,10),10))),x(ke,"fromAtto",t=>new Re(new u(t))),x(ke,"fromFemto",t=>new Re(new u(t).mul(xt))),x(ke,"fromPico",t=>new Re(new u(t).mul(At))),x(ke,"fromNano",t=>new Re(new u(t).mul(Pt))),x(ke,"fromMicro",t=>new Re(new u(t).mul(Bt))),x(ke,"fromMilli",t=>new Re(new u(t).mul(kt))),x(ke,"fromWhole",t=>new Re(new u(t).mul(It)));class gt{}x(gt,"send",null),x(gt,"getBalance",null);var Dt=I(48764).Buffer;class pt{}x(pt,"newTx",null),x(pt,"newExecTx",null);let mt;I.e(8190).then(I.bind(I,88190)).then(o=>{mt=o}).catch(o=>{throw o});let Et;I.e(9068).then(I.bind(I,59068)).then(o=>{Et=o}).catch(o=>{throw o});class Ft{constructor(t,c){x(this,"targetActorCid");x(this,"targetConstructorParams");x(this,"serialize",async()=>{const t=await waitFor(()=>mt),c=await waitFor(()=>Et);return t.encode([c.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=t,this.targetConstructorParams=c}}let vt;I.e(8190).then(I.bind(I,88190)).then(o=>{vt=o}).catch(o=>{throw o});class Mt{constructor(t,c){x(this,"from");x(this,"to");x(this,"serialize",async()=>(await waitFor(()=>vt)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=t,this.to=c}}const Ht=o=>{switch(o){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},st=class{constructor(t,c,b){x(this,"channelAddress");x(this,"from");x(this,"to");x(this,"getAddress",()=>this.channelAddress);x(this,"getTo",()=>this.to);x(this,"getFrom",()=>this.from);x(this,"settle",(t,c)=>{const{address:b}=c,z=Transaction.getNew(this.channelAddress,b,Token.zero(),PayChActorMethods.Settle);return st.sendTx(t,c,z)});x(this,"collect",(t,c)=>{const{address:b}=c,z=Transaction.getNew(this.channelAddress,b,Token.zero(),PayChActorMethods.Collect);return st.sendTx(t,c,z)});this.channelAddress=t,this.from=c,this.to=b}};let Ye=st;x(Ye,"create",null),x(Ye,"loadFromCid",null),x(Ye,"sendTx",null)}}]);