@orderly.network/core 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +279 -0
- package/dist/index.d.ts +279 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var cr=Object.create;var Bt=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var yt=(c,n)=>()=>(c&&(n=c(c=0)),n);var ae=(c,n)=>()=>(n||c((n={exports:{}}).exports,n),n.exports),pr=(c,n)=>{for(var s in n)Bt(c,s,{get:n[s],enumerable:!0})},ce=(c,n,s,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of lr(n))!hr.call(c,d)&&d!==s&&Bt(c,d,{get:()=>n[d],enumerable:!(u=ur(n,d))||u.enumerable});return c};var Ot=(c,n,s)=>(s=c!=null?cr(dr(c)):{},ce(n||!c||!c.__esModule?Bt(s,"default",{value:c,enumerable:!0}):s,c)),yr=c=>ce(Bt({},"__esModule",{value:!0}),c);var B=yt(()=>{"use strict"});function fr(c,n){this.fun=c,this.array=n}function ue(c){var n=Math.floor((Date.now()-tt.now())*.001),s=tt.now()*.001,u=Math.floor(s)+n,d=Math.floor(s%1*1e9);return c&&(u=u-c[0],d=d-c[1],d<0&&(u--,d+=Dt)),[u,d]}var Nr,tt,Mt,Dt,le=yt(()=>{"use strict";B();v();b();fr.prototype.run=function(){this.fun.apply(null,this.array)};Nr={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},tt={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};tt.now===void 0&&(Mt=Date.now(),tt.timing&&tt.timing.navigationStart&&(Mt=tt.timing.navigationStart),tt.now=()=>Date.now()-Mt);Dt=1e9;ue.bigint=function(c){var n=ue(c);return typeof BigInt>"u"?n[0]*Dt+n[1]:BigInt(n[0]*Dt)+BigInt(n[1])}});var b=yt(()=>{"use strict";le()});function gr(){if(de)return ft;de=!0,ft.byteLength=f,ft.toByteArray=A,ft.fromByteArray=T;for(var c=[],n=[],s=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=u.length;d<p;++d)c[d]=u[d],n[u.charCodeAt(d)]=d;n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;function o(y){var m=y.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var x=y.indexOf("=");x===-1&&(x=m);var S=x===m?0:4-x%4;return[x,S]}function f(y){var m=o(y),x=m[0],S=m[1];return(x+S)*3/4-S}function I(y,m,x){return(m+x)*3/4-x}function A(y){var m,x=o(y),S=x[0],U=x[1],C=new s(I(y,S,U)),P=0,k=U>0?S-4:S,N;for(N=0;N<k;N+=4)m=n[y.charCodeAt(N)]<<18|n[y.charCodeAt(N+1)]<<12|n[y.charCodeAt(N+2)]<<6|n[y.charCodeAt(N+3)],C[P++]=m>>16&255,C[P++]=m>>8&255,C[P++]=m&255;return U===2&&(m=n[y.charCodeAt(N)]<<2|n[y.charCodeAt(N+1)]>>4,C[P++]=m&255),U===1&&(m=n[y.charCodeAt(N)]<<10|n[y.charCodeAt(N+1)]<<4|n[y.charCodeAt(N+2)]>>2,C[P++]=m>>8&255,C[P++]=m&255),C}function g(y){return c[y>>18&63]+c[y>>12&63]+c[y>>6&63]+c[y&63]}function E(y,m,x){for(var S,U=[],C=m;C<x;C+=3)S=(y[C]<<16&16711680)+(y[C+1]<<8&65280)+(y[C+2]&255),U.push(g(S));return U.join("")}function T(y){for(var m,x=y.length,S=x%3,U=[],C=16383,P=0,k=x-S;P<k;P+=C)U.push(E(y,P,P+C>k?k:P+C));return S===1?(m=y[x-1],U.push(c[m>>2]+c[m<<4&63]+"==")):S===2&&(m=(y[x-2]<<8)+y[x-1],U.push(c[m>>10]+c[m>>4&63]+c[m<<2&63]+"=")),U.join("")}return ft}function mr(){if(he)return bt;he=!0;return bt.read=function(c,n,s,u,d){var p,o,f=d*8-u-1,I=(1<<f)-1,A=I>>1,g=-7,E=s?d-1:0,T=s?-1:1,y=c[n+E];for(E+=T,p=y&(1<<-g)-1,y>>=-g,g+=f;g>0;p=p*256+c[n+E],E+=T,g-=8);for(o=p&(1<<-g)-1,p>>=-g,g+=u;g>0;o=o*256+c[n+E],E+=T,g-=8);if(p===0)p=1-A;else{if(p===I)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,u),p=p-A}return(y?-1:1)*o*Math.pow(2,p-u)},bt.write=function(c,n,s,u,d,p){var o,f,I,A=p*8-d-1,g=(1<<A)-1,E=g>>1,T=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=u?0:p-1,m=u?1:-1,x=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(f=isNaN(n)?1:0,o=g):(o=Math.floor(Math.log(n)/Math.LN2),n*(I=Math.pow(2,-o))<1&&(o--,I*=2),o+E>=1?n+=T/I:n+=T*Math.pow(2,1-E),n*I>=2&&(o++,I/=2),o+E>=g?(f=0,o=g):o+E>=1?(f=(n*I-1)*Math.pow(2,d),o=o+E):(f=n*Math.pow(2,E-1)*Math.pow(2,d),o=0));d>=8;c[s+y]=f&255,y+=m,f/=256,d-=8);for(o=o<<d|f,A+=d;A>0;c[s+y]=o&255,y+=m,o/=256,A-=8);c[s+y-m]|=x*128},bt}function wr(){if(pe)return et;pe=!0;let c=gr(),n=mr(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;et.Buffer=o,et.SlowBuffer=U,et.INSPECT_MAX_BYTES=50;let u=2147483647;et.kMaxLength=u,o.TYPED_ARRAY_SUPPORT=d(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function d(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function p(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,o.prototype),t}function o(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(r)}return f(r,t,e)}o.poolSize=8192;function f(r,t,e){if(typeof r=="string")return E(r,t);if(ArrayBuffer.isView(r))return y(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(q(r,ArrayBuffer)||r&&q(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(r,SharedArrayBuffer)||r&&q(r.buffer,SharedArrayBuffer)))return m(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return o.from(i,t,e);let a=x(r);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return o.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}o.from=function(r,t,e){return f(r,t,e)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function I(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function A(r,t,e){return I(r),r<=0?p(r):t!==void 0?typeof e=="string"?p(r).fill(t,e):p(r).fill(t):p(r)}o.alloc=function(r,t,e){return A(r,t,e)};function g(r){return I(r),p(r<0?0:S(r)|0)}o.allocUnsafe=function(r){return g(r)},o.allocUnsafeSlow=function(r){return g(r)};function E(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=C(r,t)|0,i=p(e),a=i.write(r,t);return a!==e&&(i=i.slice(0,a)),i}function T(r){let t=r.length<0?0:S(r.length)|0,e=p(t);for(let i=0;i<t;i+=1)e[i]=r[i]&255;return e}function y(r){if(q(r,Uint8Array)){let t=new Uint8Array(r);return m(t.buffer,t.byteOffset,t.byteLength)}return T(r)}function m(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let i;return t===void 0&&e===void 0?i=new Uint8Array(r):e===void 0?i=new Uint8Array(r,t):i=new Uint8Array(r,t,e),Object.setPrototypeOf(i,o.prototype),i}function x(r){if(o.isBuffer(r)){let t=S(r.length)|0,e=p(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Rt(r.length)?p(0):T(r);if(r.type==="Buffer"&&Array.isArray(r.data))return T(r.data)}function S(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function U(r){return+r!=r&&(r=0),o.alloc(+r)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,e){if(q(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),q(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let i=t.length,a=e.length;for(let l=0,h=Math.min(i,a);l<h;++l)if(t[l]!==e[l]){i=t[l],a=e[l];break}return i<a?-1:a<i?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);let i;if(e===void 0)for(e=0,i=0;i<t.length;++i)e+=t[i].length;let a=o.allocUnsafe(e),l=0;for(i=0;i<t.length;++i){let h=t[i];if(q(h,Uint8Array))l+h.length>a.length?(o.isBuffer(h)||(h=o.from(h)),h.copy(a,l)):Uint8Array.prototype.set.call(a,h,l);else if(o.isBuffer(h))h.copy(a,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=h.length}return a};function C(r,t){if(o.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||q(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&e===0)return 0;let a=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Nt(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return se(r).length;default:if(a)return i?-1:Nt(r).length;t=(""+t).toLowerCase(),a=!0}}o.byteLength=C;function P(r,t,e){let i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Qe(this,t,e);case"utf8":case"utf-8":return Jt(this,t,e);case"ascii":return Je(this,t,e);case"latin1":case"binary":return Ze(this,t,e);case"base64":return Xe(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tr(this,t,e);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}o.prototype._isBuffer=!0;function k(r,t,e){let i=r[t];r[t]=r[e],r[e]=i}o.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)k(this,e,e+1);return this},o.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)k(this,e,e+3),k(this,e+1,e+2);return this},o.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)k(this,e,e+7),k(this,e+1,e+6),k(this,e+2,e+5),k(this,e+3,e+4);return this},o.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Jt(this,0,t):P.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){let t="",e=et.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(t,e,i,a,l){if(q(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),i===void 0&&(i=t?t.length:0),a===void 0&&(a=0),l===void 0&&(l=this.length),e<0||i>t.length||a<0||l>this.length)throw new RangeError("out of range index");if(a>=l&&e>=i)return 0;if(a>=l)return-1;if(e>=i)return 1;if(e>>>=0,i>>>=0,a>>>=0,l>>>=0,this===t)return 0;let h=l-a,_=i-e,M=Math.min(h,_),R=this.slice(a,l),D=t.slice(e,i);for(let K=0;K<M;++K)if(R[K]!==D[K]){h=R[K],_=D[K];break}return h<_?-1:_<h?1:0};function N(r,t,e,i,a){if(r.length===0)return-1;if(typeof e=="string"?(i=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Rt(e)&&(e=a?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(a)return-1;e=r.length-1}else if(e<0)if(a)e=0;else return-1;if(typeof t=="string"&&(t=o.from(t,i)),o.isBuffer(t))return t.length===0?-1:j(r,t,e,i,a);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):j(r,[t],e,i,a);throw new TypeError("val must be string, number or Buffer")}function j(r,t,e,i,a){let l=1,h=r.length,_=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||t.length<2)return-1;l=2,h/=2,_/=2,e/=2}function M(D,K){return l===1?D[K]:D.readUInt16BE(K*l)}let R;if(a){let D=-1;for(R=e;R<h;R++)if(M(r,R)===M(t,D===-1?0:R-D)){if(D===-1&&(D=R),R-D+1===_)return D*l}else D!==-1&&(R-=R-D),D=-1}else for(e+_>h&&(e=h-_),R=e;R>=0;R--){let D=!0;for(let K=0;K<_;K++)if(M(r,R+K)!==M(t,K)){D=!1;break}if(D)return R}return-1}o.prototype.includes=function(t,e,i){return this.indexOf(t,e,i)!==-1},o.prototype.indexOf=function(t,e,i){return N(this,t,e,i,!0)},o.prototype.lastIndexOf=function(t,e,i){return N(this,t,e,i,!1)};function G(r,t,e,i){e=Number(e)||0;let a=r.length-e;i?(i=Number(i),i>a&&(i=a)):i=a;let l=t.length;i>l/2&&(i=l/2);let h;for(h=0;h<i;++h){let _=parseInt(t.substr(h*2,2),16);if(Rt(_))return h;r[e+h]=_}return h}function st(r,t,e,i){return At(Nt(t,r.length-e),r,e,i)}function Ye(r,t,e,i){return At(ir(t),r,e,i)}function Ge(r,t,e,i){return At(se(t),r,e,i)}function qe(r,t,e,i){return At(or(t,r.length-e),r,e,i)}o.prototype.write=function(t,e,i,a){if(e===void 0)a="utf8",i=this.length,e=0;else if(i===void 0&&typeof e=="string")a=e,i=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(i)?(i=i>>>0,a===void 0&&(a="utf8")):(a=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-e;if((i===void 0||i>l)&&(i=l),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");let h=!1;for(;;)switch(a){case"hex":return G(this,t,e,i);case"utf8":case"utf-8":return st(this,t,e,i);case"ascii":case"latin1":case"binary":return Ye(this,t,e,i);case"base64":return Ge(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qe(this,t,e,i);default:if(h)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),h=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(r,t,e){return t===0&&e===r.length?c.fromByteArray(r):c.fromByteArray(r.slice(t,e))}function Jt(r,t,e){e=Math.min(r.length,e);let i=[],a=t;for(;a<e;){let l=r[a],h=null,_=l>239?4:l>223?3:l>191?2:1;if(a+_<=e){let M,R,D,K;switch(_){case 1:l<128&&(h=l);break;case 2:M=r[a+1],(M&192)===128&&(K=(l&31)<<6|M&63,K>127&&(h=K));break;case 3:M=r[a+1],R=r[a+2],(M&192)===128&&(R&192)===128&&(K=(l&15)<<12|(M&63)<<6|R&63,K>2047&&(K<55296||K>57343)&&(h=K));break;case 4:M=r[a+1],R=r[a+2],D=r[a+3],(M&192)===128&&(R&192)===128&&(D&192)===128&&(K=(l&15)<<18|(M&63)<<12|(R&63)<<6|D&63,K>65535&&K<1114112&&(h=K))}}h===null?(h=65533,_=1):h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|h&1023),i.push(h),a+=_}return He(i)}let Zt=4096;function He(r){let t=r.length;if(t<=Zt)return String.fromCharCode.apply(String,r);let e="",i=0;for(;i<t;)e+=String.fromCharCode.apply(String,r.slice(i,i+=Zt));return e}function Je(r,t,e){let i="";e=Math.min(r.length,e);for(let a=t;a<e;++a)i+=String.fromCharCode(r[a]&127);return i}function Ze(r,t,e){let i="";e=Math.min(r.length,e);for(let a=t;a<e;++a)i+=String.fromCharCode(r[a]);return i}function Qe(r,t,e){let i=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>i)&&(e=i);let a="";for(let l=t;l<e;++l)a+=sr[r[l]];return a}function tr(r,t,e){let i=r.slice(t,e),a="";for(let l=0;l<i.length-1;l+=2)a+=String.fromCharCode(i[l]+i[l+1]*256);return a}o.prototype.slice=function(t,e){let i=this.length;t=~~t,e=e===void 0?i:~~e,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),e<t&&(e=t);let a=this.subarray(t,e);return Object.setPrototypeOf(a,o.prototype),a};function F(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=this[t],l=1,h=0;for(;++h<e&&(l*=256);)a+=this[t+h]*l;return a},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=this[t+--e],l=1;for(;e>0&&(l*=256);)a+=this[t+--e]*l;return a},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,l=this[++t]+this[++t]*2**8+this[++t]*2**16+i*2**24;return BigInt(a)+(BigInt(l)<<BigInt(32))}),o.prototype.readBigUInt64BE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],l=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+i;return(BigInt(a)<<BigInt(32))+BigInt(l)}),o.prototype.readIntLE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=this[t],l=1,h=0;for(;++h<e&&(l*=256);)a+=this[t+h]*l;return l*=128,a>=l&&(a-=Math.pow(2,8*e)),a},o.prototype.readIntBE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=e,l=1,h=this[t+--a];for(;a>0&&(l*=256);)h+=this[t+--a]*l;return l*=128,h>=l&&(h-=Math.pow(2,8*e)),h},o.prototype.readInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){t=t>>>0,e||F(t,2,this.length);let i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i},o.prototype.readInt16BE=function(t,e){t=t>>>0,e||F(t,2,this.length);let i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i},o.prototype.readInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(i<<24);return(BigInt(a)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),o.prototype.readBigInt64BE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(a)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+i)}),o.prototype.readFloatLE=function(t,e){return t=t>>>0,e||F(t,4,this.length),n.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t=t>>>0,e||F(t,4,this.length),n.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||F(t,8,this.length),n.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||F(t,8,this.length),n.read(this,t,!1,52,8)};function Y(r,t,e,i,a,l){if(!o.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<l)throw new RangeError('"value" argument is out of bounds');if(e+i>r.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,i,a){if(t=+t,e=e>>>0,i=i>>>0,!a){let _=Math.pow(2,8*i)-1;Y(this,t,e,i,_,0)}let l=1,h=0;for(this[e]=t&255;++h<i&&(l*=256);)this[e+h]=t/l&255;return e+i},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,i,a){if(t=+t,e=e>>>0,i=i>>>0,!a){let _=Math.pow(2,8*i)-1;Y(this,t,e,i,_,0)}let l=i-1,h=1;for(this[e+l]=t&255;--l>=0&&(h*=256);)this[e+l]=t/h&255;return e+i},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,1,255,0),this[e]=t&255,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Qt(r,t,e,i,a){oe(t,i,a,r,e,7);let l=Number(t&BigInt(4294967295));r[e++]=l,l=l>>8,r[e++]=l,l=l>>8,r[e++]=l,l=l>>8,r[e++]=l;let h=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=h,h=h>>8,r[e++]=h,h=h>>8,r[e++]=h,h=h>>8,r[e++]=h,e}function te(r,t,e,i,a){oe(t,i,a,r,e,7);let l=Number(t&BigInt(4294967295));r[e+7]=l,l=l>>8,r[e+6]=l,l=l>>8,r[e+5]=l,l=l>>8,r[e+4]=l;let h=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=h,h=h>>8,r[e+2]=h,h=h>>8,r[e+1]=h,h=h>>8,r[e]=h,e+8}o.prototype.writeBigUInt64LE=Z(function(t,e=0){return Qt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Z(function(t,e=0){return te(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,i,a){if(t=+t,e=e>>>0,!a){let M=Math.pow(2,8*i-1);Y(this,t,e,i,M-1,-M)}let l=0,h=1,_=0;for(this[e]=t&255;++l<i&&(h*=256);)t<0&&_===0&&this[e+l-1]!==0&&(_=1),this[e+l]=(t/h>>0)-_&255;return e+i},o.prototype.writeIntBE=function(t,e,i,a){if(t=+t,e=e>>>0,!a){let M=Math.pow(2,8*i-1);Y(this,t,e,i,M-1,-M)}let l=i-1,h=1,_=0;for(this[e+l]=t&255;--l>=0&&(h*=256);)t<0&&_===0&&this[e+l+1]!==0&&(_=1),this[e+l]=(t/h>>0)-_&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},o.prototype.writeInt16LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},o.prototype.writeInt32LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},o.prototype.writeBigInt64LE=Z(function(t,e=0){return Qt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Z(function(t,e=0){return te(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ee(r,t,e,i,a,l){if(e+i>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function re(r,t,e,i,a){return t=+t,e=e>>>0,a||ee(r,t,e,4),n.write(r,t,e,i,23,4),e+4}o.prototype.writeFloatLE=function(t,e,i){return re(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return re(this,t,e,!1,i)};function ne(r,t,e,i,a){return t=+t,e=e>>>0,a||ee(r,t,e,8),n.write(r,t,e,i,52,8),e+8}o.prototype.writeDoubleLE=function(t,e,i){return ne(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return ne(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,a){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),!a&&a!==0&&(a=this.length),e>=t.length&&(e=t.length),e||(e=0),a>0&&a<i&&(a=i),a===i||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),t.length-e<a-i&&(a=t.length-e+i);let l=a-i;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,i,a):Uint8Array.prototype.set.call(t,this.subarray(i,a),e),l},o.prototype.fill=function(t,e,i,a){if(typeof t=="string"){if(typeof e=="string"?(a=e,e=0,i=this.length):typeof i=="string"&&(a=i,i=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!o.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(t.length===1){let h=t.charCodeAt(0);(a==="utf8"&&h<128||a==="latin1")&&(t=h)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;e=e>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);let l;if(typeof t=="number")for(l=e;l<i;++l)this[l]=t;else{let h=o.isBuffer(t)?t:o.from(t,a),_=h.length;if(_===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(l=0;l<i-e;++l)this[l+e]=h[l%_]}return this};let at={};function kt(r,t,e){at[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(a){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:a,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}kt("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),kt("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError),kt("ERR_OUT_OF_RANGE",function(r,t,e){let i=`The value of "${r}" is out of range.`,a=e;return Number.isInteger(e)&&Math.abs(e)>2**32?a=ie(String(e)):typeof e=="bigint"&&(a=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(a=ie(a)),a+="n"),i+=` It must be ${t}. Received ${a}`,i},RangeError);function ie(r){let t="",e=r.length,i=r[0]==="-"?1:0;for(;e>=i+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function er(r,t,e){ct(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&pt(t,r.length-(e+1))}function oe(r,t,e,i,a,l){if(r>e||r<t){let h=typeof t=="bigint"?"n":"",_;throw l>3?t===0||t===BigInt(0)?_=`>= 0${h} and < 2${h} ** ${(l+1)*8}${h}`:_=`>= -(2${h} ** ${(l+1)*8-1}${h}) and < 2 ** ${(l+1)*8-1}${h}`:_=`>= ${t}${h} and <= ${e}${h}`,new at.ERR_OUT_OF_RANGE("value",_,r)}er(i,a,l)}function ct(r,t){if(typeof r!="number")throw new at.ERR_INVALID_ARG_TYPE(t,"number",r)}function pt(r,t,e){throw Math.floor(r)!==r?(ct(r,e),new at.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new at.ERR_BUFFER_OUT_OF_BOUNDS:new at.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}let rr=/[^+/0-9A-Za-z-_]/g;function nr(r){if(r=r.split("=")[0],r=r.trim().replace(rr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Nt(r,t){t=t||1/0;let e,i=r.length,a=null,l=[];for(let h=0;h<i;++h){if(e=r.charCodeAt(h),e>55295&&e<57344){if(!a){if(e>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(h+1===i){(t-=3)>-1&&l.push(239,191,189);continue}a=e;continue}if(e<56320){(t-=3)>-1&&l.push(239,191,189),a=e;continue}e=(a-55296<<10|e-56320)+65536}else a&&(t-=3)>-1&&l.push(239,191,189);if(a=null,e<128){if((t-=1)<0)break;l.push(e)}else if(e<2048){if((t-=2)<0)break;l.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;l.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;l.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return l}function ir(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function or(r,t){let e,i,a,l=[];for(let h=0;h<r.length&&!((t-=2)<0);++h)e=r.charCodeAt(h),i=e>>8,a=e%256,l.push(a),l.push(i);return l}function se(r){return c.toByteArray(nr(r))}function At(r,t,e,i){let a;for(a=0;a<i&&!(a+e>=t.length||a>=r.length);++a)t[a+e]=r[a];return a}function q(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Rt(r){return r!==r}let sr=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let i=e*16;for(let a=0;a<16;++a)t[i+a]=r[e]+r[a]}return t}();function Z(r){return typeof BigInt>"u"?ar:r}function ar(){throw new Error("BigInt not supported")}return et}var ft,de,bt,he,et,pe,rt,O,$r,Fr,Lt=yt(()=>{"use strict";B();v();b();ft={},de=!1;bt={},he=!1;et={},pe=!1;rt=wr();rt.Buffer;rt.SlowBuffer;rt.INSPECT_MAX_BYTES;rt.kMaxLength;O=rt.Buffer,$r=rt.INSPECT_MAX_BYTES,Fr=rt.kMaxLength});var v=yt(()=>{"use strict";Lt()});var fe=ae((qr,ye)=>{"use strict";B();v();b();function Ir(c){if(c.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),s=0;s<n.length;s++)n[s]=255;for(var u=0;u<c.length;u++){var d=c.charAt(u),p=d.charCodeAt(0);if(n[p]!==255)throw new TypeError(d+" is ambiguous");n[p]=u}var o=c.length,f=c.charAt(0),I=Math.log(o)/Math.log(256),A=Math.log(256)/Math.log(o);function g(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var m=0,x=0,S=0,U=y.length;S!==U&&y[S]===0;)S++,m++;for(var C=(U-S)*A+1>>>0,P=new Uint8Array(C);S!==U;){for(var k=y[S],N=0,j=C-1;(k!==0||N<x)&&j!==-1;j--,N++)k+=256*P[j]>>>0,P[j]=k%o>>>0,k=k/o>>>0;if(k!==0)throw new Error("Non-zero carry");x=N,S++}for(var G=C-x;G!==C&&P[G]===0;)G++;for(var st=f.repeat(m);G<C;++G)st+=c.charAt(P[G]);return st}function E(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var m=0,x=0,S=0;y[m]===f;)x++,m++;for(var U=(y.length-m)*I+1>>>0,C=new Uint8Array(U);y[m];){var P=n[y.charCodeAt(m)];if(P===255)return;for(var k=0,N=U-1;(P!==0||k<S)&&N!==-1;N--,k++)P+=o*C[N]>>>0,C[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");S=k,m++}for(var j=U-S;j!==U&&C[j]===0;)j++;for(var G=new Uint8Array(x+(U-j)),st=x;j!==U;)G[st++]=C[j++];return G}function T(y){var m=E(y);if(m)return m;throw new Error("Non-base"+o+" character")}return{encode:g,decodeUnsafe:E,decode:T}}ye.exports=Ir});var me=ae((Zr,ge)=>{"use strict";B();v();b();var Er=fe(),Ar="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ge.exports=Er(Ar)});var Pr={};pr(Pr,{Account:()=>Et,BaseConfigStore:()=>qt,BaseContractManager:()=>Tt,BaseKeyStore:()=>wt,BaseOrderlyKeyPair:()=>H,BaseSigner:()=>J,EtherAdapter:()=>Pt,EventEmitter:()=>ze.default,LocalStorageStore:()=>dt,MemoryConfigStore:()=>It,MockKeyStore:()=>ht,SimpleDI:()=>je,Web3WalletAdapter:()=>Ut,getDefaultSigner:()=>Fe,getMockSigner:()=>$e});module.exports=yr(Pr);B();v();b();B();v();b();B();v();b();var mt=Ot(me());B();v();b();var V=2n**255n-19n,ut=2n**252n+27742317777372353535851937790883648493n,$t=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Ft=0x6666666666666666666666666666666666666666666666666666666666666658n,vt={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:V,n:ut,h:8,Gx:$t,Gy:Ft},z=(c="")=>{throw new Error(c)},Be=c=>typeof c=="string",_t=(c,n)=>!(c instanceof Uint8Array)||typeof n=="number"&&n>0&&c.length!==n?z("Uint8Array expected"):c,lt=c=>new Uint8Array(c),Ct=(c,n)=>_t(Be(c)?Wt(c):lt(c),n),w=(c,n=V)=>{let s=c%n;return s>=0n?s:n+s},we=c=>c instanceof Q?c:z("Point expected"),Ie,Q=class c{constructor(n,s,u,d){this.ex=n,this.ey=s,this.ez=u,this.et=d}static fromAffine(n){return new c(n.x,n.y,1n,w(n.x*n.y))}static fromHex(n,s=!0){let{d:u}=vt;n=Ct(n,32);let d=n.slice();d[31]=n[31]&-129;let p=xe(d);p===0n||(s&&!(0n<p&&p<V)&&z("bad y coord 1"),!s&&!(0n<p&&p<2n**256n)&&z("bad y coord 2"));let o=w(p*p),f=w(o-1n),I=w(u*o+1n),{isValid:A,value:g}=br(f,I);A||z("bad y coordinate 3");let E=(g&1n)===1n;return(n[31]&128)!==0!==E&&(g=w(-g)),new c(g,p,1n,w(g*p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(n){let{ex:s,ey:u,ez:d}=this,{ex:p,ey:o,ez:f}=we(n),I=w(s*f),A=w(p*d),g=w(u*f),E=w(o*d);return I===A&&g===E}is0(){return this.equals(xt)}negate(){return new c(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){let{ex:n,ey:s,ez:u}=this,{a:d}=vt,p=w(n*n),o=w(s*s),f=w(2n*w(u*u)),I=w(d*p),A=n+s,g=w(w(A*A)-p-o),E=I+o,T=E-f,y=I-o,m=w(g*T),x=w(E*y),S=w(g*y),U=w(T*E);return new c(m,x,U,S)}add(n){let{ex:s,ey:u,ez:d,et:p}=this,{ex:o,ey:f,ez:I,et:A}=we(n),{a:g,d:E}=vt,T=w(s*o),y=w(u*f),m=w(p*E*A),x=w(d*I),S=w((s+u)*(o+f)-T-y),U=w(x-m),C=w(x+m),P=w(y-g*T),k=w(S*U),N=w(C*P),j=w(S*P),G=w(U*C);return new c(k,N,G,j)}mul(n,s=!0){if(n===0n)return s===!0?z("cannot multiply by 0"):xt;if(typeof n=="bigint"&&0n<n&&n<ut||z("invalid scalar, must be < L"),!s&&this.is0()||n===1n)return this;if(this.equals(it))return Cr(n).p;let u=xt,d=it;for(let p=this;n>0n;p=p.double(),n>>=1n)n&1n?u=u.add(p):s&&(d=d.add(p));return u}multiply(n){return this.mul(n)}clearCofactor(){return this.mul(BigInt(vt.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let n=this.mul(ut/2n,!1).double();return ut%2n&&(n=n.add(this)),n.is0()}toAffine(){let{ex:n,ey:s,ez:u}=this;if(this.is0())return{x:0n,y:0n};let d=Se(u);return w(u*d)!==1n&&z("invalid inverse"),{x:w(n*d),y:w(s*d)}}toRawBytes(){let{x:n,y:s}=this.toAffine(),u=ve(s);return u[31]|=n&1n?128:0,u}toHex(){return jt(this.toRawBytes())}};Q.BASE=new Q($t,Ft,1n,w($t*Ft));Q.ZERO=new Q(0n,1n,1n,0n);var{BASE:it,ZERO:xt}=Q,be=(c,n)=>c.toString(16).padStart(n,"0"),jt=c=>Array.from(c).map(n=>be(n,2)).join(""),Wt=c=>{let n=c.length;(!Be(c)||n%2)&&z("hex invalid 1");let s=lt(n/2);for(let u=0;u<s.length;u++){let d=u*2,p=c.slice(d,d+2),o=Number.parseInt(p,16);(Number.isNaN(o)||o<0)&&z("hex invalid 2"),s[u]=o}return s},ve=c=>Wt(be(c,32*2)).reverse(),xe=c=>BigInt("0x"+jt(lt(_t(c)).reverse())),St=(...c)=>{let n=lt(c.reduce((u,d)=>u+_t(d).length,0)),s=0;return c.forEach(u=>{n.set(u,s),s+=u.length}),n},Se=(c,n=V)=>{(c===0n||n<=0n)&&z("no inverse n="+c+" mod="+n);let s=w(c,n),u=n,d=0n,p=1n,o=1n,f=0n;for(;s!==0n;){let I=u/s,A=u%s,g=d-o*I,E=p-f*I;u=s,s=A,d=o,p=f,o=g,f=E}return u===1n?w(d,n):z("no inverse")},X=(c,n)=>{let s=c;for(;n-- >0n;)s*=s,s%=V;return s},Br=c=>{let s=c*c%V*c%V,u=X(s,2n)*s%V,d=X(u,1n)*c%V,p=X(d,5n)*d%V,o=X(p,10n)*p%V,f=X(o,20n)*o%V,I=X(f,40n)*f%V,A=X(I,80n)*I%V,g=X(A,80n)*I%V,E=X(g,10n)*p%V;return{pow_p_5_8:X(E,2n)*c%V,b2:s}},Ee=19681161376707505956807079304988542015446066515923890162744021073123829784752n,br=(c,n)=>{let s=w(n*n*n),u=w(s*s*n),d=Br(c*u).pow_p_5_8,p=w(c*s*d),o=w(n*p*p),f=p,I=w(p*Ee),A=o===c,g=o===w(-c),E=o===w(-c*Ee);return A&&(p=f),(g||E)&&(p=I),(w(p)&1n)===1n&&(p=w(-p)),{isValid:A||g,value:p}},Vt=c=>w(xe(c),ut),gt,zt=(...c)=>Gt.sha512Async(...c),_e=(...c)=>typeof gt=="function"?gt(...c):z("etc.sha512Sync not set"),Ce=c=>{let n=c.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let s=c.slice(32,64),u=Vt(n),d=it.mul(u),p=d.toRawBytes();return{head:n,prefix:s,scalar:u,point:d,pointBytes:p}},Yt=c=>zt(Ct(c,32)).then(Ce),vr=c=>Ce(_e(Ct(c,32))),Te=c=>Yt(c).then(n=>n.pointBytes);function xr(c,n){return c?zt(n.hashable).then(n.finish):n.finish(_e(n.hashable))}var Sr=(c,n,s)=>{let{pointBytes:u,scalar:d}=c,p=Vt(n),o=it.mul(p).toRawBytes();return{hashable:St(o,u,s),finish:A=>{let g=w(p+Vt(A)*d,ut);return _t(St(o,ve(g)),64)}}},Ue=async(c,n)=>{let s=Ct(c),u=await Yt(n),d=await zt(u.prefix,s);return xr(!0,Sr(u,d,s))};var Ae=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Gt={bytesToHex:jt,hexToBytes:Wt,concatBytes:St,mod:w,invert:Se,randomBytes:c=>{let n=Ae();return n||z("crypto.getRandomValues must be defined"),n.getRandomValues(lt(c))},sha512Async:async(...c)=>{let n=Ae();n||z("crypto.subtle or etc.sha512Async must be defined");let s=St(...c);return lt(await n.subtle.digest("SHA-512",s.buffer))},sha512Sync:void 0};Object.defineProperties(Gt,{sha512Sync:{configurable:!1,get(){return gt},set(c){gt||(gt=c)}}});var Pe={getExtendedPublicKeyAsync:Yt,getExtendedPublicKey:vr,randomPrivateKey:()=>Gt.randomBytes(32),precompute(c=8,n=it){return n.multiply(3n),n}},nt=8,_r=()=>{let c=[],n=256/nt+1,s=it,u=s;for(let d=0;d<n;d++){u=s,c.push(u);for(let p=1;p<2**(nt-1);p++)u=u.add(s),c.push(u);s=u.double()}return c},Cr=c=>{let n=Ie||(Ie=_r()),s=(g,E)=>{let T=E.negate();return g?T:E},u=xt,d=it,p=1+256/nt,o=2**(nt-1),f=BigInt(2**nt-1),I=2**nt,A=BigInt(nt);for(let g=0;g<p;g++){let E=g*o,T=Number(c&f);c>>=A,T>o&&(T-=I,c+=1n);let y=E,m=E+Math.abs(T)-1,x=g%2!==0,S=T<0;T===0?d=d.add(s(x,n[y])):u=u.add(s(S,n[m]))}return{p:u,f:d}};var H=class c{static generateKey(){let n,s;do n=Pe.randomPrivateKey(),s=(0,mt.encode)(n);while(s.length!==44);return new c(s)}constructor(n){this.secretKey=n;let s=(0,mt.decode)(n);this.privateKey=O.from(s).toString("hex")}async sign(n){return await Ue(n,this.privateKey)}async getPublicKey(){let n=await Te(this.privateKey);return`ed25519:${(0,mt.encode)(n)}`}toString(){return this.privateKey}};var wt=class{constructor(n="testnet"){this.networkId=n}get keyPrefix(){return`orderly_${this.networkId}_`}},dt=class extends wt{getOrderlyKey(n){let s;if(n)s=this.getItem(n,"orderlyKey");else{let u=this.getAddress();if(!u)return null;s=this.getItem(u,"orderlyKey")}return s?new H(s):null}getAccountId(n){return this.getItem(n,"accountId")}setAccountId(n,s){this.setItem(n,{accountId:s})}getAddress(){return localStorage.getItem(`${this.keyPrefix}address`)}setAddress(n){localStorage.setItem(`${this.keyPrefix}address`,n)}generateKey(){return H.generateKey()}setKey(n,s){this.setItem(n,{orderlyKey:s.secretKey})}cleanAllKey(n){localStorage.removeItem(`${this.keyPrefix}${n}`),localStorage.removeItem(`${this.keyPrefix}address`)}cleanKey(n,s){let u=this.getItem(n);delete u[s],localStorage.setItem(`${this.keyPrefix}${n}`,JSON.stringify(u))}setItem(n,s){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);d?d=JSON.parse(d):d={},localStorage.setItem(u,JSON.stringify({...d,...s}))}getItem(n,s){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);return d?d=JSON.parse(d):d={},typeof s>"u"?d:d[s]}},ht=class{constructor(n){this.secretKey=n}generateKey(){return new H(this.secretKey)}getOrderlyKey(){return new H(this.secretKey)}getAccountId(){return""}setAccountId(n){}getAddress(){return""}setAddress(n){}setKey(n,s){}cleanAllKey(){}cleanKey(n){}};B();v();b();B();v();b();B();v();b();var ot={EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Registration:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"timestamp",type:"uint64"},{name:"registrationNonce",type:"uint256"}],Withdraw:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"receiver",type:"address"},{name:"token",type:"string"},{name:"amount",type:"uint256"},{name:"withdrawNonce",type:"uint64"},{name:"timestamp",type:"uint64"}],AddOrderlyKey:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"orderlyKey",type:"string"},{name:"scope",type:"string"},{name:"timestamp",type:"uint64"},{name:"expiration",type:"uint64"}],SettlePnl:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"settleNonce",type:"uint64"},{name:"timestamp",type:"uint64"}]},Ke="0x004d88aa993fd2100d6c8beb6cdb6bc04f565b44",ke="0x0C554dDb6a9010Ed1FD7e50d92559A06655dA482",Ne="0x8794E7260517B1766fc7b55cAfcd56e6bf08600e";var Re=function(c){return c.replace(/\+/g,"-").replace(/\//g,"_")};function Ur(){return"0x8794E7260517B1766fc7b55cAfcd56e6bf08600e"}function Oe(c,n){return{name:"Orderly",version:"1",chainId:c,verifyingContract:n?Ur():"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}function Me(c){let{chainId:n,registrationNonce:s}=c,u=Date.now(),d="Registration",p={brokerId:"woofi_dex",chainId:n,timestamp:u,registrationNonce:s},o={EIP712Domain:ot.EIP712Domain,[d]:ot[d]};return[p,{domain:Oe(n),message:p,primaryType:d,types:o}]}function De(c){let{publicKey:n,chainId:s,primaryType:u,expiration:d=365}=c,p=Date.now(),o={brokerId:"woofi_dex",orderlyKey:n,scope:"read,trading",chainId:s,timestamp:p,expiration:p+1e3*60*60*24*d},f={EIP712Domain:ot.EIP712Domain,[u]:ot[u]},I={domain:Oe(s),message:o,primaryType:u,types:f};return[o,I]}function Le(c){let{chainId:n,settlePnlNonce:s,domain:u}=c,d="SettlePnl",p=new Date().getTime(),o={EIP712Domain:ot.EIP712Domain,[d]:ot[d]},f={brokerId:"woofi_dex",chainId:n,timestamp:p,settleNonce:s};return[f,{domain:u,message:f,primaryType:d,types:o}]}Lt();var J=class{constructor(n){this.keyStore=n}async sign(n){let s=Date.now().toString(),u=[s,n.method.toUpperCase(),n.url].join("");n.data&&Object.keys(n.data).length&&(u+=JSON.stringify(n.data));let{signature:d,publicKey:p}=await this.signText(u);return{"orderly-key":p,"orderly-timestamp":s,"orderly-signature":d}}async signText(n){let s=this.keyStore.getOrderlyKey();if(!s)throw new Error("orderlyKeyPair is not defined");let u=O.from(n),d=await s.sign(u),p=O.from(d).toString("base64");return{signature:Re(p),publicKey:await s.getPublicKey()}}};var ze=Ot(require("eventemitter3"));B();v();b();B();v();b();var It=class{constructor(){this._restore()}_restore(){this.map=new Map([["apiBaseUrl","https://testnet-api-evm.orderly.org"],["klineDataUrl","https://testnet-api-evm.orderly.org"],["publicWsUrl","wss://testnet-ws-evm.orderly.org"],["publicWebsocketKey","OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY"],["privateWsUrl","wss://testnet-ws-private-evm.orderly.org"],["env","dev-evm"]])}get(n){return this.map.get(n)}set(n,s){this.map.set(n,s)}clear(){}},qt=class extends It{constructor(s){super();this.configMap=s}_restore(){let s=Object.entries(this.configMap);this.map=new Map(s)}};var $e=c=>{let n=new ht(c||"AFmQSju4FhDwG93cMdKogcnKx7SWmViDtDv5PVzfvRDF");return new J(n)},Fe=()=>{if(typeof window>"u")throw new Error("the default signer only supports browsers.");let c=new dt("");return new J(c)};B();v();b();var Tt=class{constructor(n){this.configStore=n}getContractInfoByEnv(){return{usdcAddress:Ke,vaultAddress:ke,verifyContractAddress:Ne}}};B();v();b();B();v();b();var Xt=class{constructor(n=[],s={}){this.providers=n;this.services=s;this.injectProperties={}}register(...n){this.providers.push(...n),n.forEach(s=>{let u=s;u instanceof Function&&(u=new s),this.add(u)})}registerByName(n,s){let u=s;u instanceof Function&&(u=new s),this.addByName(n,u)}get(n){return this.services[n]}getAll(){return Object.assign({},this.services)}add(n){return this.addByName(n.constructor.name,n)}addByName(n,s){return this.services[n]=s,this.services[n.toLowerCase()]=s,this.injectIntoProperties(s,n),this.get(n)}inject(n,s,u){n&&u&&(n[s]=u)}injectIntoProperties(n,s=n.constructor.name){this.getInjectProperty(s.toLowerCase()).forEach(u=>{this.inject(u.target,u.propertyKey,n)})}getInjectProperty(n){return this.injectProperties[n]||(this.injectProperties[n]=[]),this.injectProperties[n]}},Ve=Xt;var Ht=class c{static getContainer(){return c.container||(c.container=new Ve),c.container}static register(...n){this.getContainer().register(...n)}static registerByName(n,s){this.getContainer().registerByName(n,s)}static get(n){return this.getContainer().get(n)}static getAll(){return this.getContainer().getAll()}constructor(){}},je=Ht;B();v();b();var W=require("@orderly.network/types");var We=Ot(require("eventemitter3")),Et=class{constructor(n,s,u,d){this.configStore=n;this.keyStore=s;this.contractManger=u;this.getWalletAdapter=d;this._ee=new We.default;this._state={status:W.AccountStatusEnum.NotConnected,balance:"",checking:!1,leverage:Number.NaN};this._bindEvents()}login(n){if(!n)throw new Error("address is required")}logout(){}async setAddress(n,s){if(!n)throw new Error("address is required");console.log("setAddress",n,s),this.keyStore.setAddress(n);let u={...this.stateValue,status:W.AccountStatusEnum.Connected,address:n};return this._ee.emit("change:status",u),s&&(this.walletClient=this.getWalletAdapter({...s,address:n})),await this._checkAccount(n)}get stateValue(){return this._state}get accountId(){return this.stateValue.accountId}get address(){return this.stateValue.address}get chainId(){return this.walletClient?.chainId}set position(n){let s={...this.stateValue,positon:n};this._ee.emit("change:status",s)}set orders(n){let s={...this.stateValue,orders:n};this._ee.emit("change:status",s)}_bindEvents(){this._ee.addListener("change:status",n=>{console.log("change:status",n),this._state=n})}async _checkAccount(n){console.log("check account is esist",n);let s;try{let u=await this._checkAccountExist(n);if(console.log("accountInfo:",u),u&&u.account_id)console.log("account is exist"),this.keyStore.setAccountId(n,u.account_id),s={...this.stateValue,status:W.AccountStatusEnum.SignedIn,accountId:u.account_id,userId:u.user_id},this._ee.emit("change:status",s);else return s={...this.stateValue,status:W.AccountStatusEnum.NotSignedIn},this._ee.emit("change:status",s),W.AccountStatusEnum.NotSignedIn;let d=this.keyStore.getOrderlyKey();if(console.log("orderlyKey:::::::",d),s={...this.stateValue,status:W.AccountStatusEnum.DisabledTrading},!d)return console.log("orderlyKey is null"),this._ee.emit("change:status",s),W.AccountStatusEnum.DisabledTrading;let p=await d.getPublicKey(),o=await this._checkOrderlyKeyState(u.account_id,p);if(console.log("orderlyKeyStatus:",o),o&&o.orderly_key&&o.key_status==="ACTIVE"){let f=Date.now(),I=o.expiration;if(f>I)return this.keyStore.cleanKey(n,"orderlyKey"),W.AccountStatusEnum.DisabledTrading;let A={...this.stateValue,status:W.AccountStatusEnum.EnableTrading};return this._ee.emit("change:status",A),W.AccountStatusEnum.EnableTrading}return this.keyStore.cleanKey(n,"orderlyKey"),W.AccountStatusEnum.NotConnected}catch(u){console.log("\u68C0\u67E5\u8D26\u6237\u72B6\u6001\u9519\u8BEF:",u)}return W.AccountStatusEnum.NotSignedIn}async _checkAccountExist(n){let s=await this._simpleFetch(`/v1/get_account?address=${n}&broker_id=woofi_dex`);return s.success?s.data:null}async createAccount(){let n=await this._getRegisterationNonce(),s=this.stateValue.address;if(!s)throw new Error("address is undefined");let[u,d]=Me({registrationNonce:n,chainId:this.walletClient.chainId}),p=await this.walletClient.send("eth_signTypedData_v4",[s,JSON.stringify(d)]),o=await this._simpleFetch("/v1/register_account",{method:"POST",body:JSON.stringify({signature:p,message:u,userAddress:s}),headers:{"Content-Type":"application/json"}});if(o.success){this.keyStore.setAccountId(s,o.data.account_id);let f={...this.stateValue,status:W.AccountStatusEnum.DisabledTrading,accountId:o.data.account_id,userId:o.data.user_id};return this._ee.emit("change:status",f),o}}async createOrderlyKey(n){if(this.stateValue.accountId===void 0)throw new Error("account id is undefined");if(this.walletClient===void 0)throw new Error("walletClient is undefined");let s="AddOrderlyKey",u=this.keyStore.generateKey(),d=await u.getPublicKey(),[p,o]=De({publicKey:d,chainId:this.walletClient.chainId,primaryType:s,expiration:n}),f=this.stateValue.address;if(!f)throw new Error("address is undefined");let I=await this.walletClient.send("eth_signTypedData_v4",[f,JSON.stringify(o)]),A=await this._simpleFetch("/v1/orderly_key",{method:"POST",body:JSON.stringify({signature:I,message:p,userAddress:f}),headers:{"X-Account-Id":this.stateValue.accountId,"Content-Type":"application/json"}});if(A.success){this.keyStore.setKey(f,u);let g={...this.stateValue,status:W.AccountStatusEnum.EnableTrading};return this._ee.emit("change:status",g),A}else throw new Error(A.message)}async settlement(){let n=await this._getSettleNonce(),s=this.stateValue.address,u=this.getDomain(!0),d="/v1/settle_pnl",[p,o]=Le({settlePnlNonce:n,chainId:this.walletClient.chainId,domain:u}),I={signature:await this.walletClient.send("eth_signTypedData_v4",[s,JSON.stringify(o)]),message:p,userAddress:s,verifyingContract:u.verifyingContract},A={method:"POST",url:d,data:I},g=await this.signer.sign(A),E=await this._simpleFetch(d,{method:"POST",body:JSON.stringify(I),headers:{"Content-Type":"application/json","orderly-account-id":this.stateValue.accountId,...g}});if(E.success)return E;throw new Error(E.message)}async disconnect(){let n={...this.stateValue,status:W.AccountStatusEnum.NotConnected,accountId:void 0,userId:void 0,address:void 0};this._ee.emit("change:status",n)}async _checkOrderlyKeyState(n,s){let u=await this._simpleFetch(`/v1/get_orderly_key?account_id=${n}&orderly_key=${s}`);if(u.success)return u.data;throw new Error(u.message)}get signer(){return this._singer||(this._singer=new J(this.keyStore)),this._singer}get wallet(){return this.walletClient}async _getRegisterationNonce(){let n=await this._simpleFetch("/v1/registration_nonce",{headers:{"orderly-account-id":this.stateValue.accountId}});if(console.log("getRegisterationNonce:",n),n.success)return n.data?.registration_nonce;throw new Error(n.message)}async _getSettleNonce(){let n=Date.now().toString(),u=[n,"GET","/v1/settle_nonce"].join(""),d=this.signer,{publicKey:p,signature:o}=await d.signText(u),f=await this._simpleFetch("/v1/settle_nonce",{headers:{"orderly-account-id":this.stateValue.accountId,"orderly-key":p,"orderly-timestamp":n,"orderly-signature":o}});if(f.success)return f.data?.settle_nonce;throw new Error(f.message)}async _simpleFetch(n,s={}){let u=`${this.configStore.get("apiBaseUrl")}${n}`;return fetch(u,s).then(d=>d.json())}getDomain(n){return{name:"Orderly",version:"1",chainId:this.walletClient.chainId,verifyingContract:n?this.contractManger.getContractInfoByEnv().verifyContractAddress:"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}get on(){return this._ee.on.bind(this._ee)}get once(){return this._ee.once.bind(this._ee)}get off(){return this._ee.off.bind(this._ee)}};Et.instanceName="account";B();v();b();B();v();b();var Ut=class{constructor(n){this.web3=n}async getBalance(n){return await this.web3.eth.getBalance(n)}async deposit(n,s,u){return await this.web3.eth.sendTransaction({from:n,to:s,value:u})}async send(n,s){}};B();v();b();var Kt=require("ethers"),Pt=class{constructor(n){console.log("EtherAdapter constructor",n),this._chainId=parseInt(n.chain.id,16),this.provider=new Kt.BrowserProvider(n.provider,"any"),this._address=n.address}getBalance(n){throw new Error("Method not implemented.")}deposit(n,s,u){throw new Error("Method not implemented.")}get chainId(){return this._chainId}get addresses(){return this._address}async send(n,s){return await this.provider?.send(n,s)}async verify(n,s){let{domain:u,types:d,message:p}=n,o=Kt.ethers.verifyTypedData(u,d,p,s);console.log("recovered",o)}};0&&(module.exports={Account,BaseConfigStore,BaseContractManager,BaseKeyStore,BaseOrderlyKeyPair,BaseSigner,EtherAdapter,EventEmitter,LocalStorageStore,MemoryConfigStore,MockKeyStore,SimpleDI,Web3WalletAdapter,getDefaultSigner,getMockSigner});
|
|
1
|
+
"use strict";var ar=Object.create;var Bt=Object.defineProperty;var cr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var lr=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var yt=(c,n)=>()=>(c&&(n=c(c=0)),n);var se=(c,n)=>()=>(n||c((n={exports:{}}).exports,n),n.exports),hr=(c,n)=>{for(var s in n)Bt(c,s,{get:n[s],enumerable:!0})},ae=(c,n,s,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of ur(n))!dr.call(c,d)&&d!==s&&Bt(c,d,{get:()=>n[d],enumerable:!(u=cr(n,d))||u.enumerable});return c};var Rt=(c,n,s)=>(s=c!=null?ar(lr(c)):{},ae(n||!c||!c.__esModule?Bt(s,"default",{value:c,enumerable:!0}):s,c)),pr=c=>ae(Bt({},"__esModule",{value:!0}),c);var b=yt(()=>{"use strict"});function yr(c,n){this.fun=c,this.array=n}function ce(c){var n=Math.floor((Date.now()-tt.now())*.001),s=tt.now()*.001,u=Math.floor(s)+n,d=Math.floor(s%1*1e9);return c&&(u=u-c[0],d=d-c[1],d<0&&(u--,d+=Mt)),[u,d]}var Kr,tt,Ot,Mt,ue=yt(()=>{"use strict";b();x();v();yr.prototype.run=function(){this.fun.apply(null,this.array)};Kr={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},tt={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};tt.now===void 0&&(Ot=Date.now(),tt.timing&&tt.timing.navigationStart&&(Ot=tt.timing.navigationStart),tt.now=()=>Date.now()-Ot);Mt=1e9;ce.bigint=function(c){var n=ce(c);return typeof BigInt>"u"?n[0]*Mt+n[1]:BigInt(n[0]*Mt)+BigInt(n[1])}});var v=yt(()=>{"use strict";ue()});function fr(){if(le)return ft;le=!0,ft.byteLength=f,ft.toByteArray=A,ft.fromByteArray=U;for(var c=[],n=[],s=typeof Uint8Array<"u"?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=u.length;d<p;++d)c[d]=u[d],n[u.charCodeAt(d)]=d;n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;function o(y){var m=y.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=y.indexOf("=");B===-1&&(B=m);var S=B===m?0:4-B%4;return[B,S]}function f(y){var m=o(y),B=m[0],S=m[1];return(B+S)*3/4-S}function I(y,m,B){return(m+B)*3/4-B}function A(y){var m,B=o(y),S=B[0],T=B[1],C=new s(I(y,S,T)),P=0,K=T>0?S-4:S,N;for(N=0;N<K;N+=4)m=n[y.charCodeAt(N)]<<18|n[y.charCodeAt(N+1)]<<12|n[y.charCodeAt(N+2)]<<6|n[y.charCodeAt(N+3)],C[P++]=m>>16&255,C[P++]=m>>8&255,C[P++]=m&255;return T===2&&(m=n[y.charCodeAt(N)]<<2|n[y.charCodeAt(N+1)]>>4,C[P++]=m&255),T===1&&(m=n[y.charCodeAt(N)]<<10|n[y.charCodeAt(N+1)]<<4|n[y.charCodeAt(N+2)]>>2,C[P++]=m>>8&255,C[P++]=m&255),C}function g(y){return c[y>>18&63]+c[y>>12&63]+c[y>>6&63]+c[y&63]}function E(y,m,B){for(var S,T=[],C=m;C<B;C+=3)S=(y[C]<<16&16711680)+(y[C+1]<<8&65280)+(y[C+2]&255),T.push(g(S));return T.join("")}function U(y){for(var m,B=y.length,S=B%3,T=[],C=16383,P=0,K=B-S;P<K;P+=C)T.push(E(y,P,P+C>K?K:P+C));return S===1?(m=y[B-1],T.push(c[m>>2]+c[m<<4&63]+"==")):S===2&&(m=(y[B-2]<<8)+y[B-1],T.push(c[m>>10]+c[m>>4&63]+c[m<<2&63]+"=")),T.join("")}return ft}function gr(){if(de)return bt;de=!0;return bt.read=function(c,n,s,u,d){var p,o,f=d*8-u-1,I=(1<<f)-1,A=I>>1,g=-7,E=s?d-1:0,U=s?-1:1,y=c[n+E];for(E+=U,p=y&(1<<-g)-1,y>>=-g,g+=f;g>0;p=p*256+c[n+E],E+=U,g-=8);for(o=p&(1<<-g)-1,p>>=-g,g+=u;g>0;o=o*256+c[n+E],E+=U,g-=8);if(p===0)p=1-A;else{if(p===I)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,u),p=p-A}return(y?-1:1)*o*Math.pow(2,p-u)},bt.write=function(c,n,s,u,d,p){var o,f,I,A=p*8-d-1,g=(1<<A)-1,E=g>>1,U=d===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=u?0:p-1,m=u?1:-1,B=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(f=isNaN(n)?1:0,o=g):(o=Math.floor(Math.log(n)/Math.LN2),n*(I=Math.pow(2,-o))<1&&(o--,I*=2),o+E>=1?n+=U/I:n+=U*Math.pow(2,1-E),n*I>=2&&(o++,I/=2),o+E>=g?(f=0,o=g):o+E>=1?(f=(n*I-1)*Math.pow(2,d),o=o+E):(f=n*Math.pow(2,E-1)*Math.pow(2,d),o=0));d>=8;c[s+y]=f&255,y+=m,f/=256,d-=8);for(o=o<<d|f,A+=d;A>0;c[s+y]=o&255,y+=m,o/=256,A-=8);c[s+y-m]|=B*128},bt}function mr(){if(he)return et;he=!0;let c=fr(),n=gr(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;et.Buffer=o,et.SlowBuffer=T,et.INSPECT_MAX_BYTES=50;let u=2147483647;et.kMaxLength=u,o.TYPED_ARRAY_SUPPORT=d(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function d(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function p(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,o.prototype),t}function o(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(r)}return f(r,t,e)}o.poolSize=8192;function f(r,t,e){if(typeof r=="string")return E(r,t);if(ArrayBuffer.isView(r))return y(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(q(r,ArrayBuffer)||r&&q(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(r,SharedArrayBuffer)||r&&q(r.buffer,SharedArrayBuffer)))return m(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return o.from(i,t,e);let a=B(r);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return o.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}o.from=function(r,t,e){return f(r,t,e)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function I(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function A(r,t,e){return I(r),r<=0?p(r):t!==void 0?typeof e=="string"?p(r).fill(t,e):p(r).fill(t):p(r)}o.alloc=function(r,t,e){return A(r,t,e)};function g(r){return I(r),p(r<0?0:S(r)|0)}o.allocUnsafe=function(r){return g(r)},o.allocUnsafeSlow=function(r){return g(r)};function E(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=C(r,t)|0,i=p(e),a=i.write(r,t);return a!==e&&(i=i.slice(0,a)),i}function U(r){let t=r.length<0?0:S(r.length)|0,e=p(t);for(let i=0;i<t;i+=1)e[i]=r[i]&255;return e}function y(r){if(q(r,Uint8Array)){let t=new Uint8Array(r);return m(t.buffer,t.byteOffset,t.byteLength)}return U(r)}function m(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let i;return t===void 0&&e===void 0?i=new Uint8Array(r):e===void 0?i=new Uint8Array(r,t):i=new Uint8Array(r,t,e),Object.setPrototypeOf(i,o.prototype),i}function B(r){if(o.isBuffer(r)){let t=S(r.length)|0,e=p(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||Nt(r.length)?p(0):U(r);if(r.type==="Buffer"&&Array.isArray(r.data))return U(r.data)}function S(r){if(r>=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return r|0}function T(r){return+r!=r&&(r=0),o.alloc(+r)}o.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==o.prototype},o.compare=function(t,e){if(q(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),q(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let i=t.length,a=e.length;for(let l=0,h=Math.min(i,a);l<h;++l)if(t[l]!==e[l]){i=t[l],a=e[l];break}return i<a?-1:a<i?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return o.alloc(0);let i;if(e===void 0)for(e=0,i=0;i<t.length;++i)e+=t[i].length;let a=o.allocUnsafe(e),l=0;for(i=0;i<t.length;++i){let h=t[i];if(q(h,Uint8Array))l+h.length>a.length?(o.isBuffer(h)||(h=o.from(h)),h.copy(a,l)):Uint8Array.prototype.set.call(a,h,l);else if(o.isBuffer(h))h.copy(a,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=h.length}return a};function C(r,t){if(o.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||q(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&e===0)return 0;let a=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return Kt(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return oe(r).length;default:if(a)return i?-1:Kt(r).length;t=(""+t).toLowerCase(),a=!0}}o.byteLength=C;function P(r,t,e){let i=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ze(this,t,e);case"utf8":case"utf-8":return Ht(this,t,e);case"ascii":return He(this,t,e);case"latin1":case"binary":return Je(this,t,e);case"base64":return qe(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qe(this,t,e);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}o.prototype._isBuffer=!0;function K(r,t,e){let i=r[t];r[t]=r[e],r[e]=i}o.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)K(this,e,e+1);return this},o.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)K(this,e,e+3),K(this,e+1,e+2);return this},o.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)K(this,e,e+7),K(this,e+1,e+6),K(this,e+2,e+5),K(this,e+3,e+4);return this},o.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Ht(this,0,t):P.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:o.compare(this,t)===0},o.prototype.inspect=function(){let t="",e=et.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(t,e,i,a,l){if(q(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),i===void 0&&(i=t?t.length:0),a===void 0&&(a=0),l===void 0&&(l=this.length),e<0||i>t.length||a<0||l>this.length)throw new RangeError("out of range index");if(a>=l&&e>=i)return 0;if(a>=l)return-1;if(e>=i)return 1;if(e>>>=0,i>>>=0,a>>>=0,l>>>=0,this===t)return 0;let h=l-a,_=i-e,O=Math.min(h,_),R=this.slice(a,l),M=t.slice(e,i);for(let k=0;k<O;++k)if(R[k]!==M[k]){h=R[k],_=M[k];break}return h<_?-1:_<h?1:0};function N(r,t,e,i,a){if(r.length===0)return-1;if(typeof e=="string"?(i=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Nt(e)&&(e=a?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(a)return-1;e=r.length-1}else if(e<0)if(a)e=0;else return-1;if(typeof t=="string"&&(t=o.from(t,i)),o.isBuffer(t))return t.length===0?-1:j(r,t,e,i,a);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):j(r,[t],e,i,a);throw new TypeError("val must be string, number or Buffer")}function j(r,t,e,i,a){let l=1,h=r.length,_=t.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||t.length<2)return-1;l=2,h/=2,_/=2,e/=2}function O(M,k){return l===1?M[k]:M.readUInt16BE(k*l)}let R;if(a){let M=-1;for(R=e;R<h;R++)if(O(r,R)===O(t,M===-1?0:R-M)){if(M===-1&&(M=R),R-M+1===_)return M*l}else M!==-1&&(R-=R-M),M=-1}else for(e+_>h&&(e=h-_),R=e;R>=0;R--){let M=!0;for(let k=0;k<_;k++)if(O(r,R+k)!==O(t,k)){M=!1;break}if(M)return R}return-1}o.prototype.includes=function(t,e,i){return this.indexOf(t,e,i)!==-1},o.prototype.indexOf=function(t,e,i){return N(this,t,e,i,!0)},o.prototype.lastIndexOf=function(t,e,i){return N(this,t,e,i,!1)};function G(r,t,e,i){e=Number(e)||0;let a=r.length-e;i?(i=Number(i),i>a&&(i=a)):i=a;let l=t.length;i>l/2&&(i=l/2);let h;for(h=0;h<i;++h){let _=parseInt(t.substr(h*2,2),16);if(Nt(_))return h;r[e+h]=_}return h}function st(r,t,e,i){return At(Kt(t,r.length-e),r,e,i)}function ze(r,t,e,i){return At(nr(t),r,e,i)}function Ye(r,t,e,i){return At(oe(t),r,e,i)}function Ge(r,t,e,i){return At(ir(t,r.length-e),r,e,i)}o.prototype.write=function(t,e,i,a){if(e===void 0)a="utf8",i=this.length,e=0;else if(i===void 0&&typeof e=="string")a=e,i=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(i)?(i=i>>>0,a===void 0&&(a="utf8")):(a=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let l=this.length-e;if((i===void 0||i>l)&&(i=l),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");let h=!1;for(;;)switch(a){case"hex":return G(this,t,e,i);case"utf8":case"utf-8":return st(this,t,e,i);case"ascii":case"latin1":case"binary":return ze(this,t,e,i);case"base64":return Ye(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge(this,t,e,i);default:if(h)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),h=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function qe(r,t,e){return t===0&&e===r.length?c.fromByteArray(r):c.fromByteArray(r.slice(t,e))}function Ht(r,t,e){e=Math.min(r.length,e);let i=[],a=t;for(;a<e;){let l=r[a],h=null,_=l>239?4:l>223?3:l>191?2:1;if(a+_<=e){let O,R,M,k;switch(_){case 1:l<128&&(h=l);break;case 2:O=r[a+1],(O&192)===128&&(k=(l&31)<<6|O&63,k>127&&(h=k));break;case 3:O=r[a+1],R=r[a+2],(O&192)===128&&(R&192)===128&&(k=(l&15)<<12|(O&63)<<6|R&63,k>2047&&(k<55296||k>57343)&&(h=k));break;case 4:O=r[a+1],R=r[a+2],M=r[a+3],(O&192)===128&&(R&192)===128&&(M&192)===128&&(k=(l&15)<<18|(O&63)<<12|(R&63)<<6|M&63,k>65535&&k<1114112&&(h=k))}}h===null?(h=65533,_=1):h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|h&1023),i.push(h),a+=_}return Xe(i)}let Jt=4096;function Xe(r){let t=r.length;if(t<=Jt)return String.fromCharCode.apply(String,r);let e="",i=0;for(;i<t;)e+=String.fromCharCode.apply(String,r.slice(i,i+=Jt));return e}function He(r,t,e){let i="";e=Math.min(r.length,e);for(let a=t;a<e;++a)i+=String.fromCharCode(r[a]&127);return i}function Je(r,t,e){let i="";e=Math.min(r.length,e);for(let a=t;a<e;++a)i+=String.fromCharCode(r[a]);return i}function Ze(r,t,e){let i=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>i)&&(e=i);let a="";for(let l=t;l<e;++l)a+=or[r[l]];return a}function Qe(r,t,e){let i=r.slice(t,e),a="";for(let l=0;l<i.length-1;l+=2)a+=String.fromCharCode(i[l]+i[l+1]*256);return a}o.prototype.slice=function(t,e){let i=this.length;t=~~t,e=e===void 0?i:~~e,t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),e<t&&(e=t);let a=this.subarray(t,e);return Object.setPrototypeOf(a,o.prototype),a};function F(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=this[t],l=1,h=0;for(;++h<e&&(l*=256);)a+=this[t+h]*l;return a},o.prototype.readUintBE=o.prototype.readUIntBE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=this[t+--e],l=1;for(;e>0&&(l*=256);)a+=this[t+--e]*l;return a},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||F(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,l=this[++t]+this[++t]*2**8+this[++t]*2**16+i*2**24;return BigInt(a)+(BigInt(l)<<BigInt(32))}),o.prototype.readBigUInt64BE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],l=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+i;return(BigInt(a)<<BigInt(32))+BigInt(l)}),o.prototype.readIntLE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=this[t],l=1,h=0;for(;++h<e&&(l*=256);)a+=this[t+h]*l;return l*=128,a>=l&&(a-=Math.pow(2,8*e)),a},o.prototype.readIntBE=function(t,e,i){t=t>>>0,e=e>>>0,i||F(t,e,this.length);let a=e,l=1,h=this[t+--a];for(;a>0&&(l*=256);)h+=this[t+--a]*l;return l*=128,h>=l&&(h-=Math.pow(2,8*e)),h},o.prototype.readInt8=function(t,e){return t=t>>>0,e||F(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){t=t>>>0,e||F(t,2,this.length);let i=this[t]|this[t+1]<<8;return i&32768?i|4294901760:i},o.prototype.readInt16BE=function(t,e){t=t>>>0,e||F(t,2,this.length);let i=this[t+1]|this[t]<<8;return i&32768?i|4294901760:i},o.prototype.readInt32LE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t=t>>>0,e||F(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(i<<24);return(BigInt(a)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),o.prototype.readBigInt64BE=Z(function(t){t=t>>>0,ct(t,"offset");let e=this[t],i=this[t+7];(e===void 0||i===void 0)&&pt(t,this.length-8);let a=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(a)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+i)}),o.prototype.readFloatLE=function(t,e){return t=t>>>0,e||F(t,4,this.length),n.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t=t>>>0,e||F(t,4,this.length),n.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||F(t,8,this.length),n.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||F(t,8,this.length),n.read(this,t,!1,52,8)};function Y(r,t,e,i,a,l){if(!o.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<l)throw new RangeError('"value" argument is out of bounds');if(e+i>r.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,i,a){if(t=+t,e=e>>>0,i=i>>>0,!a){let _=Math.pow(2,8*i)-1;Y(this,t,e,i,_,0)}let l=1,h=0;for(this[e]=t&255;++h<i&&(l*=256);)this[e+h]=t/l&255;return e+i},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(t,e,i,a){if(t=+t,e=e>>>0,i=i>>>0,!a){let _=Math.pow(2,8*i)-1;Y(this,t,e,i,_,0)}let l=i-1,h=1;for(this[e+l]=t&255;--l>=0&&(h*=256);)this[e+l]=t/h&255;return e+i},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,1,255,0),this[e]=t&255,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Zt(r,t,e,i,a){ie(t,i,a,r,e,7);let l=Number(t&BigInt(4294967295));r[e++]=l,l=l>>8,r[e++]=l,l=l>>8,r[e++]=l,l=l>>8,r[e++]=l;let h=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=h,h=h>>8,r[e++]=h,h=h>>8,r[e++]=h,h=h>>8,r[e++]=h,e}function Qt(r,t,e,i,a){ie(t,i,a,r,e,7);let l=Number(t&BigInt(4294967295));r[e+7]=l,l=l>>8,r[e+6]=l,l=l>>8,r[e+5]=l,l=l>>8,r[e+4]=l;let h=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=h,h=h>>8,r[e+2]=h,h=h>>8,r[e+1]=h,h=h>>8,r[e]=h,e+8}o.prototype.writeBigUInt64LE=Z(function(t,e=0){return Zt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Z(function(t,e=0){return Qt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(t,e,i,a){if(t=+t,e=e>>>0,!a){let O=Math.pow(2,8*i-1);Y(this,t,e,i,O-1,-O)}let l=0,h=1,_=0;for(this[e]=t&255;++l<i&&(h*=256);)t<0&&_===0&&this[e+l-1]!==0&&(_=1),this[e+l]=(t/h>>0)-_&255;return e+i},o.prototype.writeIntBE=function(t,e,i,a){if(t=+t,e=e>>>0,!a){let O=Math.pow(2,8*i-1);Y(this,t,e,i,O-1,-O)}let l=i-1,h=1,_=0;for(this[e+l]=t&255;--l>=0&&(h*=256);)t<0&&_===0&&this[e+l+1]!==0&&(_=1),this[e+l]=(t/h>>0)-_&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},o.prototype.writeInt16LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},o.prototype.writeInt32LE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,i){return t=+t,e=e>>>0,i||Y(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},o.prototype.writeBigInt64LE=Z(function(t,e=0){return Zt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Z(function(t,e=0){return Qt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function te(r,t,e,i,a,l){if(e+i>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function ee(r,t,e,i,a){return t=+t,e=e>>>0,a||te(r,t,e,4),n.write(r,t,e,i,23,4),e+4}o.prototype.writeFloatLE=function(t,e,i){return ee(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return ee(this,t,e,!1,i)};function re(r,t,e,i,a){return t=+t,e=e>>>0,a||te(r,t,e,8),n.write(r,t,e,i,52,8),e+8}o.prototype.writeDoubleLE=function(t,e,i){return re(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return re(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,a){if(!o.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),!a&&a!==0&&(a=this.length),e>=t.length&&(e=t.length),e||(e=0),a>0&&a<i&&(a=i),a===i||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),t.length-e<a-i&&(a=t.length-e+i);let l=a-i;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,i,a):Uint8Array.prototype.set.call(t,this.subarray(i,a),e),l},o.prototype.fill=function(t,e,i,a){if(typeof t=="string"){if(typeof e=="string"?(a=e,e=0,i=this.length):typeof i=="string"&&(a=i,i=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!o.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(t.length===1){let h=t.charCodeAt(0);(a==="utf8"&&h<128||a==="latin1")&&(t=h)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<i)throw new RangeError("Out of range index");if(i<=e)return this;e=e>>>0,i=i===void 0?this.length:i>>>0,t||(t=0);let l;if(typeof t=="number")for(l=e;l<i;++l)this[l]=t;else{let h=o.isBuffer(t)?t:o.from(t,a),_=h.length;if(_===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(l=0;l<i-e;++l)this[l+e]=h[l%_]}return this};let at={};function kt(r,t,e){at[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(a){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:a,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}kt("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),kt("ERR_INVALID_ARG_TYPE",function(r,t){return`The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError),kt("ERR_OUT_OF_RANGE",function(r,t,e){let i=`The value of "${r}" is out of range.`,a=e;return Number.isInteger(e)&&Math.abs(e)>2**32?a=ne(String(e)):typeof e=="bigint"&&(a=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(a=ne(a)),a+="n"),i+=` It must be ${t}. Received ${a}`,i},RangeError);function ne(r){let t="",e=r.length,i=r[0]==="-"?1:0;for(;e>=i+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function tr(r,t,e){ct(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&pt(t,r.length-(e+1))}function ie(r,t,e,i,a,l){if(r>e||r<t){let h=typeof t=="bigint"?"n":"",_;throw l>3?t===0||t===BigInt(0)?_=`>= 0${h} and < 2${h} ** ${(l+1)*8}${h}`:_=`>= -(2${h} ** ${(l+1)*8-1}${h}) and < 2 ** ${(l+1)*8-1}${h}`:_=`>= ${t}${h} and <= ${e}${h}`,new at.ERR_OUT_OF_RANGE("value",_,r)}tr(i,a,l)}function ct(r,t){if(typeof r!="number")throw new at.ERR_INVALID_ARG_TYPE(t,"number",r)}function pt(r,t,e){throw Math.floor(r)!==r?(ct(r,e),new at.ERR_OUT_OF_RANGE(e||"offset","an integer",r)):t<0?new at.ERR_BUFFER_OUT_OF_BOUNDS:new at.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,r)}let er=/[^+/0-9A-Za-z-_]/g;function rr(r){if(r=r.split("=")[0],r=r.trim().replace(er,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Kt(r,t){t=t||1/0;let e,i=r.length,a=null,l=[];for(let h=0;h<i;++h){if(e=r.charCodeAt(h),e>55295&&e<57344){if(!a){if(e>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(h+1===i){(t-=3)>-1&&l.push(239,191,189);continue}a=e;continue}if(e<56320){(t-=3)>-1&&l.push(239,191,189),a=e;continue}e=(a-55296<<10|e-56320)+65536}else a&&(t-=3)>-1&&l.push(239,191,189);if(a=null,e<128){if((t-=1)<0)break;l.push(e)}else if(e<2048){if((t-=2)<0)break;l.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;l.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;l.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return l}function nr(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function ir(r,t){let e,i,a,l=[];for(let h=0;h<r.length&&!((t-=2)<0);++h)e=r.charCodeAt(h),i=e>>8,a=e%256,l.push(a),l.push(i);return l}function oe(r){return c.toByteArray(rr(r))}function At(r,t,e,i){let a;for(a=0;a<i&&!(a+e>=t.length||a>=r.length);++a)t[a+e]=r[a];return a}function q(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function Nt(r){return r!==r}let or=function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let i=e*16;for(let a=0;a<16;++a)t[i+a]=r[e]+r[a]}return t}();function Z(r){return typeof BigInt>"u"?sr:r}function sr(){throw new Error("BigInt not supported")}return et}var ft,le,bt,de,et,he,rt,D,Lr,Fr,Dt=yt(()=>{"use strict";b();x();v();ft={},le=!1;bt={},de=!1;et={},he=!1;rt=mr();rt.Buffer;rt.SlowBuffer;rt.INSPECT_MAX_BYTES;rt.kMaxLength;D=rt.Buffer,Lr=rt.INSPECT_MAX_BYTES,Fr=rt.kMaxLength});var x=yt(()=>{"use strict";Dt()});var ye=se((Gr,pe)=>{"use strict";b();x();v();function wr(c){if(c.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),s=0;s<n.length;s++)n[s]=255;for(var u=0;u<c.length;u++){var d=c.charAt(u),p=d.charCodeAt(0);if(n[p]!==255)throw new TypeError(d+" is ambiguous");n[p]=u}var o=c.length,f=c.charAt(0),I=Math.log(o)/Math.log(256),A=Math.log(256)/Math.log(o);function g(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var m=0,B=0,S=0,T=y.length;S!==T&&y[S]===0;)S++,m++;for(var C=(T-S)*A+1>>>0,P=new Uint8Array(C);S!==T;){for(var K=y[S],N=0,j=C-1;(K!==0||N<B)&&j!==-1;j--,N++)K+=256*P[j]>>>0,P[j]=K%o>>>0,K=K/o>>>0;if(K!==0)throw new Error("Non-zero carry");B=N,S++}for(var G=C-B;G!==C&&P[G]===0;)G++;for(var st=f.repeat(m);G<C;++G)st+=c.charAt(P[G]);return st}function E(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var m=0,B=0,S=0;y[m]===f;)B++,m++;for(var T=(y.length-m)*I+1>>>0,C=new Uint8Array(T);y[m];){var P=n[y.charCodeAt(m)];if(P===255)return;for(var K=0,N=T-1;(P!==0||K<S)&&N!==-1;N--,K++)P+=o*C[N]>>>0,C[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");S=K,m++}for(var j=T-S;j!==T&&C[j]===0;)j++;for(var G=new Uint8Array(B+(T-j)),st=B;j!==T;)G[st++]=C[j++];return G}function U(y){var m=E(y);if(m)return m;throw new Error("Non-base"+o+" character")}return{encode:g,decodeUnsafe:E,decode:U}}pe.exports=wr});var ge=se((Jr,fe)=>{"use strict";b();x();v();var Ir=ye(),Er="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";fe.exports=Ir(Er)});var Tr={};hr(Tr,{Account:()=>Et,BaseConfigStore:()=>Gt,BaseContractManager:()=>Ut,BaseKeyStore:()=>wt,BaseOrderlyKeyPair:()=>H,BaseSigner:()=>J,EtherAdapter:()=>Tt,EventEmitter:()=>We.default,LocalStorageStore:()=>dt,MemoryConfigStore:()=>It,MockKeyStore:()=>ht,SimpleDI:()=>Ve,getDefaultSigner:()=>Fe,getMockSigner:()=>Le});module.exports=pr(Tr);b();x();v();b();x();v();b();x();v();var mt=Rt(ge());b();x();v();var V=2n**255n-19n,ut=2n**252n+27742317777372353535851937790883648493n,Lt=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Ft=0x6666666666666666666666666666666666666666666666666666666666666658n,vt={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:V,n:ut,h:8,Gx:Lt,Gy:Ft},z=(c="")=>{throw new Error(c)},Ae=c=>typeof c=="string",_t=(c,n)=>!(c instanceof Uint8Array)||typeof n=="number"&&n>0&&c.length!==n?z("Uint8Array expected"):c,lt=c=>new Uint8Array(c),Ct=(c,n)=>_t(Ae(c)?jt(c):lt(c),n),w=(c,n=V)=>{let s=c%n;return s>=0n?s:n+s},me=c=>c instanceof Q?c:z("Point expected"),we,Q=class c{constructor(n,s,u,d){this.ex=n,this.ey=s,this.ez=u,this.et=d}static fromAffine(n){return new c(n.x,n.y,1n,w(n.x*n.y))}static fromHex(n,s=!0){let{d:u}=vt;n=Ct(n,32);let d=n.slice();d[31]=n[31]&-129;let p=ve(d);p===0n||(s&&!(0n<p&&p<V)&&z("bad y coord 1"),!s&&!(0n<p&&p<2n**256n)&&z("bad y coord 2"));let o=w(p*p),f=w(o-1n),I=w(u*o+1n),{isValid:A,value:g}=Br(f,I);A||z("bad y coordinate 3");let E=(g&1n)===1n;return(n[31]&128)!==0!==E&&(g=w(-g)),new c(g,p,1n,w(g*p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(n){let{ex:s,ey:u,ez:d}=this,{ex:p,ey:o,ez:f}=me(n),I=w(s*f),A=w(p*d),g=w(u*f),E=w(o*d);return I===A&&g===E}is0(){return this.equals(xt)}negate(){return new c(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){let{ex:n,ey:s,ez:u}=this,{a:d}=vt,p=w(n*n),o=w(s*s),f=w(2n*w(u*u)),I=w(d*p),A=n+s,g=w(w(A*A)-p-o),E=I+o,U=E-f,y=I-o,m=w(g*U),B=w(E*y),S=w(g*y),T=w(U*E);return new c(m,B,T,S)}add(n){let{ex:s,ey:u,ez:d,et:p}=this,{ex:o,ey:f,ez:I,et:A}=me(n),{a:g,d:E}=vt,U=w(s*o),y=w(u*f),m=w(p*E*A),B=w(d*I),S=w((s+u)*(o+f)-U-y),T=w(B-m),C=w(B+m),P=w(y-g*U),K=w(S*T),N=w(C*P),j=w(S*P),G=w(T*C);return new c(K,N,G,j)}mul(n,s=!0){if(n===0n)return s===!0?z("cannot multiply by 0"):xt;if(typeof n=="bigint"&&0n<n&&n<ut||z("invalid scalar, must be < L"),!s&&this.is0()||n===1n)return this;if(this.equals(it))return _r(n).p;let u=xt,d=it;for(let p=this;n>0n;p=p.double(),n>>=1n)n&1n?u=u.add(p):s&&(d=d.add(p));return u}multiply(n){return this.mul(n)}clearCofactor(){return this.mul(BigInt(vt.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let n=this.mul(ut/2n,!1).double();return ut%2n&&(n=n.add(this)),n.is0()}toAffine(){let{ex:n,ey:s,ez:u}=this;if(this.is0())return{x:0n,y:0n};let d=xe(u);return w(u*d)!==1n&&z("invalid inverse"),{x:w(n*d),y:w(s*d)}}toRawBytes(){let{x:n,y:s}=this.toAffine(),u=be(s);return u[31]|=n&1n?128:0,u}toHex(){return Vt(this.toRawBytes())}};Q.BASE=new Q(Lt,Ft,1n,w(Lt*Ft));Q.ZERO=new Q(0n,1n,1n,0n);var{BASE:it,ZERO:xt}=Q,Be=(c,n)=>c.toString(16).padStart(n,"0"),Vt=c=>Array.from(c).map(n=>Be(n,2)).join(""),jt=c=>{let n=c.length;(!Ae(c)||n%2)&&z("hex invalid 1");let s=lt(n/2);for(let u=0;u<s.length;u++){let d=u*2,p=c.slice(d,d+2),o=Number.parseInt(p,16);(Number.isNaN(o)||o<0)&&z("hex invalid 2"),s[u]=o}return s},be=c=>jt(Be(c,32*2)).reverse(),ve=c=>BigInt("0x"+Vt(lt(_t(c)).reverse())),St=(...c)=>{let n=lt(c.reduce((u,d)=>u+_t(d).length,0)),s=0;return c.forEach(u=>{n.set(u,s),s+=u.length}),n},xe=(c,n=V)=>{(c===0n||n<=0n)&&z("no inverse n="+c+" mod="+n);let s=w(c,n),u=n,d=0n,p=1n,o=1n,f=0n;for(;s!==0n;){let I=u/s,A=u%s,g=d-o*I,E=p-f*I;u=s,s=A,d=o,p=f,o=g,f=E}return u===1n?w(d,n):z("no inverse")},X=(c,n)=>{let s=c;for(;n-- >0n;)s*=s,s%=V;return s},Ar=c=>{let s=c*c%V*c%V,u=X(s,2n)*s%V,d=X(u,1n)*c%V,p=X(d,5n)*d%V,o=X(p,10n)*p%V,f=X(o,20n)*o%V,I=X(f,40n)*f%V,A=X(I,80n)*I%V,g=X(A,80n)*I%V,E=X(g,10n)*p%V;return{pow_p_5_8:X(E,2n)*c%V,b2:s}},Ie=19681161376707505956807079304988542015446066515923890162744021073123829784752n,Br=(c,n)=>{let s=w(n*n*n),u=w(s*s*n),d=Ar(c*u).pow_p_5_8,p=w(c*s*d),o=w(n*p*p),f=p,I=w(p*Ie),A=o===c,g=o===w(-c),E=o===w(-c*Ie);return A&&(p=f),(g||E)&&(p=I),(w(p)&1n)===1n&&(p=w(-p)),{isValid:A||g,value:p}},$t=c=>w(ve(c),ut),gt,Wt=(...c)=>Yt.sha512Async(...c),Se=(...c)=>typeof gt=="function"?gt(...c):z("etc.sha512Sync not set"),_e=c=>{let n=c.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let s=c.slice(32,64),u=$t(n),d=it.mul(u),p=d.toRawBytes();return{head:n,prefix:s,scalar:u,point:d,pointBytes:p}},zt=c=>Wt(Ct(c,32)).then(_e),br=c=>_e(Se(Ct(c,32))),Ce=c=>zt(c).then(n=>n.pointBytes);function vr(c,n){return c?Wt(n.hashable).then(n.finish):n.finish(Se(n.hashable))}var xr=(c,n,s)=>{let{pointBytes:u,scalar:d}=c,p=$t(n),o=it.mul(p).toRawBytes();return{hashable:St(o,u,s),finish:A=>{let g=w(p+$t(A)*d,ut);return _t(St(o,be(g)),64)}}},Ue=async(c,n)=>{let s=Ct(c),u=await zt(n),d=await Wt(u.prefix,s);return vr(!0,xr(u,d,s))};var Ee=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Yt={bytesToHex:Vt,hexToBytes:jt,concatBytes:St,mod:w,invert:xe,randomBytes:c=>{let n=Ee();return n||z("crypto.getRandomValues must be defined"),n.getRandomValues(lt(c))},sha512Async:async(...c)=>{let n=Ee();n||z("crypto.subtle or etc.sha512Async must be defined");let s=St(...c);return lt(await n.subtle.digest("SHA-512",s.buffer))},sha512Sync:void 0};Object.defineProperties(Yt,{sha512Sync:{configurable:!1,get(){return gt},set(c){gt||(gt=c)}}});var Te={getExtendedPublicKeyAsync:zt,getExtendedPublicKey:br,randomPrivateKey:()=>Yt.randomBytes(32),precompute(c=8,n=it){return n.multiply(3n),n}},nt=8,Sr=()=>{let c=[],n=256/nt+1,s=it,u=s;for(let d=0;d<n;d++){u=s,c.push(u);for(let p=1;p<2**(nt-1);p++)u=u.add(s),c.push(u);s=u.double()}return c},_r=c=>{let n=we||(we=Sr()),s=(g,E)=>{let U=E.negate();return g?U:E},u=xt,d=it,p=1+256/nt,o=2**(nt-1),f=BigInt(2**nt-1),I=2**nt,A=BigInt(nt);for(let g=0;g<p;g++){let E=g*o,U=Number(c&f);c>>=A,U>o&&(U-=I,c+=1n);let y=E,m=E+Math.abs(U)-1,B=g%2!==0,S=U<0;U===0?d=d.add(s(B,n[y])):u=u.add(s(S,n[m]))}return{p:u,f:d}};var H=class c{static generateKey(){let n,s;do n=Te.randomPrivateKey(),s=(0,mt.encode)(n);while(s.length!==44);return new c(s)}constructor(n){this.secretKey=n;let s=(0,mt.decode)(n);this.privateKey=D.from(s).toString("hex")}async sign(n){return await Ue(n,this.privateKey)}async getPublicKey(){let n=await Ce(this.privateKey);return`ed25519:${(0,mt.encode)(n)}`}toString(){return this.privateKey}};var wt=class{constructor(n="testnet"){this.networkId=n}get keyPrefix(){return`orderly_${this.networkId}_`}},dt=class extends wt{getOrderlyKey(n){let s;if(n)s=this.getItem(n,"orderlyKey");else{let u=this.getAddress();if(!u)return null;s=this.getItem(u,"orderlyKey")}return s?new H(s):null}getAccountId(n){return this.getItem(n,"accountId")}setAccountId(n,s){this.setItem(n,{accountId:s})}getAddress(){return localStorage.getItem(`${this.keyPrefix}address`)}setAddress(n){localStorage.setItem(`${this.keyPrefix}address`,n)}generateKey(){return H.generateKey()}setKey(n,s){this.setItem(n,{orderlyKey:s.secretKey})}cleanAllKey(n){localStorage.removeItem(`${this.keyPrefix}${n}`),localStorage.removeItem(`${this.keyPrefix}address`)}cleanKey(n,s){let u=this.getItem(n);delete u[s],localStorage.setItem(`${this.keyPrefix}${n}`,JSON.stringify(u))}setItem(n,s){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);d?d=JSON.parse(d):d={},localStorage.setItem(u,JSON.stringify({...d,...s}))}getItem(n,s){let u=`${this.keyPrefix}${n}`,d=localStorage.getItem(u);return d?d=JSON.parse(d):d={},typeof s>"u"?d:d[s]}},ht=class{constructor(n){this.secretKey=n}generateKey(){return new H(this.secretKey)}getOrderlyKey(){return new H(this.secretKey)}getAccountId(){return""}setAccountId(n){}getAddress(){return""}setAddress(n){}setKey(n,s){}cleanAllKey(){}cleanKey(n){}};b();x();v();b();x();v();b();x();v();var ot={EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Registration:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"timestamp",type:"uint64"},{name:"registrationNonce",type:"uint256"}],Withdraw:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"receiver",type:"address"},{name:"token",type:"string"},{name:"amount",type:"uint256"},{name:"withdrawNonce",type:"uint64"},{name:"timestamp",type:"uint64"}],AddOrderlyKey:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"orderlyKey",type:"string"},{name:"scope",type:"string"},{name:"timestamp",type:"uint64"},{name:"expiration",type:"uint64"}],SettlePnl:[{name:"brokerId",type:"string"},{name:"chainId",type:"uint256"},{name:"settleNonce",type:"uint64"},{name:"timestamp",type:"uint64"}]},Pe="0x004d88aa993fd2100d6c8beb6cdb6bc04f565b44",ke="0x0C554dDb6a9010Ed1FD7e50d92559A06655dA482",Ke="0x8794E7260517B1766fc7b55cAfcd56e6bf08600e";var Ne=function(c){return c.replace(/\+/g,"-").replace(/\//g,"_")};function Ur(){return"0x8794E7260517B1766fc7b55cAfcd56e6bf08600e"}function Re(c,n){return{name:"Orderly",version:"1",chainId:c,verifyingContract:n?Ur():"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}function Oe(c){let{chainId:n,registrationNonce:s,brokerId:u}=c,d=Date.now(),p="Registration",o={brokerId:u,chainId:n,timestamp:d,registrationNonce:s},f={EIP712Domain:ot.EIP712Domain,[p]:ot[p]};return[o,{domain:Re(n),message:o,primaryType:p,types:f}]}function Me(c){let{publicKey:n,chainId:s,primaryType:u,brokerId:d,expiration:p=365}=c,o=Date.now(),f={brokerId:d,orderlyKey:n,scope:"read,trading",chainId:s,timestamp:o,expiration:o+1e3*60*60*24*p},I={EIP712Domain:ot.EIP712Domain,[u]:ot[u]},A={domain:Re(s),message:f,primaryType:u,types:I};return[f,A]}function De(c){let{chainId:n,settlePnlNonce:s,domain:u,brokerId:d}=c,p="SettlePnl",o=new Date().getTime(),f={EIP712Domain:ot.EIP712Domain,[p]:ot[p]},I={brokerId:d,chainId:n,timestamp:o,settleNonce:s};return[I,{domain:u,message:I,primaryType:p,types:f}]}Dt();var J=class{constructor(n){this.keyStore=n}async sign(n){let s=Date.now().toString(),u=[s,n.method.toUpperCase(),n.url].join("");n.data&&Object.keys(n.data).length&&(u+=JSON.stringify(n.data));let{signature:d,publicKey:p}=await this.signText(u);return{"orderly-key":p,"orderly-timestamp":s,"orderly-signature":d}}async signText(n){let s=this.keyStore.getOrderlyKey();if(!s)throw new Error("orderlyKeyPair is not defined");let u=D.from(n),d=await s.sign(u),p=D.from(d).toString("base64");return{signature:Ne(p),publicKey:await s.getPublicKey()}}};var We=Rt(require("eventemitter3"));b();x();v();b();x();v();var It=class{constructor(){this._restore()}_restore(){this.map=new Map([["apiBaseUrl","https://testnet-api-evm.orderly.org"],["klineDataUrl","https://testnet-api-evm.orderly.org"],["publicWsUrl","wss://testnet-ws-evm.orderly.org"],["publicWebsocketKey","OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY"],["privateWsUrl","wss://testnet-ws-private-evm.orderly.org"],["brokerId","woofi_dex"],["env","dev-evm"]])}get(n){return this.map.get(n)}set(n,s){this.map.set(n,s)}clear(){}},Gt=class extends It{constructor(s){super();this.configMap=s}_restore(){let s=Object.entries(this.configMap);this.map=new Map(s)}};var Le=c=>{let n=new ht(c||"AFmQSju4FhDwG93cMdKogcnKx7SWmViDtDv5PVzfvRDF");return new J(n)},Fe=()=>{if(typeof window>"u")throw new Error("the default signer only supports browsers.");let c=new dt("");return new J(c)};b();x();v();var Ut=class{constructor(n){this.configStore=n}getContractInfoByEnv(){return{usdcAddress:Pe,vaultAddress:ke,verifyContractAddress:Ke}}};b();x();v();b();x();v();var qt=class{constructor(n=[],s={}){this.providers=n;this.services=s;this.injectProperties={}}register(...n){this.providers.push(...n),n.forEach(s=>{let u=s;u instanceof Function&&(u=new s),this.add(u)})}registerByName(n,s){let u=s;u instanceof Function&&(u=new s),this.addByName(n,u)}get(n){return this.services[n]}getAll(){return Object.assign({},this.services)}add(n){return this.addByName(n.constructor.name,n)}addByName(n,s){return this.services[n]=s,this.services[n.toLowerCase()]=s,this.injectIntoProperties(s,n),this.get(n)}inject(n,s,u){n&&u&&(n[s]=u)}injectIntoProperties(n,s=n.constructor.name){this.getInjectProperty(s.toLowerCase()).forEach(u=>{this.inject(u.target,u.propertyKey,n)})}getInjectProperty(n){return this.injectProperties[n]||(this.injectProperties[n]=[]),this.injectProperties[n]}},$e=qt;var Xt=class c{static getContainer(){return c.container||(c.container=new $e),c.container}static register(...n){this.getContainer().register(...n)}static registerByName(n,s){this.getContainer().registerByName(n,s)}static get(n){return this.getContainer().get(n)}static getAll(){return this.getContainer().getAll()}constructor(){}},Ve=Xt;b();x();v();var W=require("@orderly.network/types");var je=Rt(require("eventemitter3")),Et=class{constructor(n,s,u,d){this.configStore=n;this.keyStore=s;this.contractManger=u;this.getWalletAdapter=d;this._ee=new je.default;this._state={status:W.AccountStatusEnum.NotConnected,balance:"",checking:!1,leverage:Number.NaN};this._bindEvents()}login(n){if(!n)throw new Error("address is required")}logout(){}async setAddress(n,s){if(!n)throw new Error("address is required");this.keyStore.setAddress(n);let u={...this.stateValue,status:W.AccountStatusEnum.Connected,address:n,connectWallet:s?.wallet};return this._ee.emit("change:status",u),s&&(this.walletClient=this.getWalletAdapter({...s,address:n})),await this._checkAccount(n)}get stateValue(){return this._state}get accountId(){return this.stateValue.accountId}get address(){return this.stateValue.address}get chainId(){return this.walletClient?.chainId}set position(n){let s={...this.stateValue,positon:n};this._ee.emit("change:status",s)}set orders(n){let s={...this.stateValue,orders:n};this._ee.emit("change:status",s)}_bindEvents(){this._ee.addListener("change:status",n=>{console.log("change:status",n),this._state=n})}async _checkAccount(n){console.log("check account is esist",n);let s;try{let u=await this._checkAccountExist(n);if(console.log("accountInfo:",u),u&&u.account_id)console.log("account is exist"),this.keyStore.setAccountId(n,u.account_id),s={...this.stateValue,status:W.AccountStatusEnum.SignedIn,accountId:u.account_id,userId:u.user_id},this._ee.emit("change:status",s);else return s={...this.stateValue,status:W.AccountStatusEnum.NotSignedIn},this._ee.emit("change:status",s),W.AccountStatusEnum.NotSignedIn;let d=this.keyStore.getOrderlyKey();if(console.log("orderlyKey:::::::",d),s={...this.stateValue,status:W.AccountStatusEnum.DisabledTrading},!d)return console.log("orderlyKey is null"),this._ee.emit("change:status",s),W.AccountStatusEnum.DisabledTrading;let p=await d.getPublicKey(),o=await this._checkOrderlyKeyState(u.account_id,p);if(console.log("orderlyKeyStatus:",o),o&&o.orderly_key&&o.key_status==="ACTIVE"){let f=Date.now(),I=o.expiration;if(f>I)return this.keyStore.cleanKey(n,"orderlyKey"),W.AccountStatusEnum.DisabledTrading;let A={...this.stateValue,status:W.AccountStatusEnum.EnableTrading};return this._ee.emit("change:status",A),W.AccountStatusEnum.EnableTrading}return this.keyStore.cleanKey(n,"orderlyKey"),W.AccountStatusEnum.NotConnected}catch(u){console.log("\u68C0\u67E5\u8D26\u6237\u72B6\u6001\u9519\u8BEF:",u)}return W.AccountStatusEnum.NotSignedIn}async _checkAccountExist(n){let s=await this._simpleFetch(`/v1/get_account?address=${n}&broker_id=woofi_dex`);return s.success?s.data:null}async createAccount(){let n=await this._getRegisterationNonce(),s=this.stateValue.address;if(!s)throw new Error("address is undefined");let[u,d]=Oe({registrationNonce:n,chainId:this.walletClient.chainId,brokerId:this.configStore.get("brokerId")}),p=await this.walletClient.signTypedData(s,JSON.stringify(d)),o=await this._simpleFetch("/v1/register_account",{method:"POST",body:JSON.stringify({signature:p,message:u,userAddress:s}),headers:{"Content-Type":"application/json"}});if(o.success){this.keyStore.setAccountId(s,o.data.account_id);let f={...this.stateValue,status:W.AccountStatusEnum.DisabledTrading,accountId:o.data.account_id,userId:o.data.user_id};return this._ee.emit("change:status",f),o}}async createOrderlyKey(n){if(this.stateValue.accountId===void 0)throw new Error("account id is undefined");if(this.walletClient===void 0)throw new Error("walletClient is undefined");let s="AddOrderlyKey",u=this.keyStore.generateKey(),d=await u.getPublicKey(),[p,o]=Me({publicKey:d,chainId:this.walletClient.chainId,primaryType:s,expiration:n,brokerId:this.configStore.get("brokerId")}),f=this.stateValue.address;if(!f)throw new Error("address is undefined");let I=await this.walletClient.signTypedData(f,JSON.stringify(o)),A=await this._simpleFetch("/v1/orderly_key",{method:"POST",body:JSON.stringify({signature:I,message:p,userAddress:f}),headers:{"X-Account-Id":this.stateValue.accountId,"Content-Type":"application/json"}});if(A.success){this.keyStore.setKey(f,u);let g={...this.stateValue,status:W.AccountStatusEnum.EnableTrading};return this._ee.emit("change:status",g),A}else throw new Error(A.message)}async settlement(){let n=await this._getSettleNonce(),s=this.stateValue.address,u=this.getDomain(!0),d="/v1/settle_pnl",[p,o]=De({settlePnlNonce:n,chainId:this.walletClient.chainId,brokerId:this.configStore.get("brokerId"),domain:u}),I={signature:await this.walletClient.signTypedData(s,JSON.stringify(o)),message:p,userAddress:s,verifyingContract:u.verifyingContract},A={method:"POST",url:d,data:I},g=await this.signer.sign(A),E=await this._simpleFetch(d,{method:"POST",body:JSON.stringify(I),headers:{"Content-Type":"application/json","orderly-account-id":this.stateValue.accountId,...g}});if(E.success)return E;throw new Error(E.message)}async disconnect(){let n={...this.stateValue,status:W.AccountStatusEnum.NotConnected,accountId:void 0,userId:void 0,address:void 0};this._ee.emit("change:status",n)}async _checkOrderlyKeyState(n,s){let u=await this._simpleFetch(`/v1/get_orderly_key?account_id=${n}&orderly_key=${s}`);if(u.success)return u.data;throw new Error(u.message)}get signer(){return this._singer||(this._singer=new J(this.keyStore)),this._singer}get wallet(){return this.walletClient}async _getRegisterationNonce(){let n=await this._simpleFetch("/v1/registration_nonce",{headers:{"orderly-account-id":this.stateValue.accountId}});if(console.log("getRegisterationNonce:",n),n.success)return n.data?.registration_nonce;throw new Error(n.message)}async _getSettleNonce(){let n=Date.now().toString(),u=[n,"GET","/v1/settle_nonce"].join(""),d=this.signer,{publicKey:p,signature:o}=await d.signText(u),f=await this._simpleFetch("/v1/settle_nonce",{headers:{"orderly-account-id":this.stateValue.accountId,"orderly-key":p,"orderly-timestamp":n,"orderly-signature":o}});if(f.success)return f.data?.settle_nonce;throw new Error(f.message)}async _simpleFetch(n,s={}){let u=`${this.configStore.get("apiBaseUrl")}${n}`;return fetch(u,s).then(d=>d.json())}getDomain(n){return{name:"Orderly",version:"1",chainId:this.walletClient.chainId,verifyingContract:n?this.contractManger.getContractInfoByEnv().verifyContractAddress:"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"}}get on(){return this._ee.on.bind(this._ee)}get once(){return this._ee.once.bind(this._ee)}get off(){return this._ee.off.bind(this._ee)}};Et.instanceName="account";b();x();v();b();x();v();var Pt=require("ethers"),Tt=class{constructor(n){console.log("EtherAdapter constructor",n),this._chainId=parseInt(n.chain.id,16),this.provider=new Pt.BrowserProvider(n.provider,"any"),this._address=n.address}getBalance(n){throw new Error("Method not implemented.")}deposit(n,s,u){throw new Error("Method not implemented.")}get chainId(){return this._chainId}get addresses(){return this._address}async send(n,s){return await this.provider?.send(n,s)}async signTypedData(n,s){return await this.provider?.send("eth_signTypedData_v4",[n,s])}async verify(n,s){let{domain:u,types:d,message:p}=n,o=Pt.ethers.verifyTypedData(u,d,p,s);console.log("recovered",o)}};0&&(module.exports={Account,BaseConfigStore,BaseContractManager,BaseKeyStore,BaseOrderlyKeyPair,BaseSigner,EtherAdapter,EventEmitter,LocalStorageStore,MemoryConfigStore,MockKeyStore,SimpleDI,getDefaultSigner,getMockSigner});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@jspm/core/nodelibs/browser/buffer.js:
|