dash-platform-sdk 1.4.0-dev.8 → 1.4.0-dev.9

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/bundle.min.js CHANGED
@@ -18,4 +18,4 @@ const By=(t,e)=>(t+(t>=0?e:-e)/Sy)/e;function Ey(t,e,n){const[[r,i],[o,s]]=e,a=B
18
18
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Dy={Qe:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),kv:BigInt(1),a:BigInt(0),b:BigInt(7),sk:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),ak:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Wy={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),rk:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_y=BigInt(0),Hy=BigInt(2);const jy=oy(Dy.Qe,{sqrt:function(t){const e=Dy.Qe,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,h=qp(u,n,e)*u%e,f=qp(h,n,e)*u%e,d=qp(f,Hy,e)*l%e,w=qp(d,i,e)*d%e,p=qp(w,o,e)*w%e,y=qp(p,a,e)*p%e,g=qp(y,c,e)*y%e,b=qp(g,a,e)*p%e,m=qp(b,n,e)*u%e,v=qp(m,s,e)*w%e,I=qp(v,r,e)*l%e,k=qp(I,Hy,e);if(!jy.Lv(jy.Zv(k),t))throw new Error("Cannot find square root");return k}}),My=Vy(Dy,{yI:jy,nk:Wy}),Ly=Fy(My,Ip),Zy={};function qy(t,...e){let n=Zy[t];if(void 0===n){const e=Ip((r=t,Uint8Array.from(r,(t,e)=>{const n=t.charCodeAt(0);if(1!==t.length||n>127)throw new Error(`string contains non-ASCII character "${r[e]}" with code ${n} at position ${e}`);return n})));n=lp(e,e),Zy[t]=n}var r;return Ip(lp(n,...e))}const Yy=t=>t.wI(!0).slice(1),zy=t=>t%Hy===_y;function Xy(t){const{xI:e,RI:n}=My,r=e.hh(t),i=n.multiply(r);return{zt:zy(i.y)?r:e.zv(r),bytes:Yy(i)}}function Jy(t){const e=jy;if(!e.cI(t))throw new Error("invalid x: Fail if x ≥ p");const n=e.create(t*t),r=e.create(n*t+BigInt(7));let i=e.sqrt(r);zy(i)||(i=e.zv(i));const o=My.bI({x:t,y:i});return o.uk(),o}const Qy=Pp;function tg(...t){return My.xI.create(Qy(qy("BIP0340/challenge",...t)))}function eg(t){return Xy(t).bytes}function ng(t,e,n=hp(32)){const{xI:r}=My,i=Mw(t,void 0,"message"),{bytes:o,zt:s}=Xy(e),a=Mw(n,32,"auxRand"),c=r.wI(s^Qy(qy("BIP0340/aux",a))),l=qy("BIP0340/nonce",c,o,i),{bytes:u,zt:h}=Xy(l),f=tg(u,o,i),d=new Uint8Array(64);if(d.set(u,0),d.set(r.wI(r.create(h+f*s)),32),!rg(d,i,o))throw new Error("sign: Invalid signature produced");return d}function rg(t,e,n){const{yI:r,xI:i,RI:o}=My,s=Mw(t,64,"signature"),a=Mw(e,void 0,"message"),c=Mw(n,32,"publicKey");try{const t=Jy(Qy(c)),e=Qy(s.subarray(0,32));if(!r.cI(e))return!1;const n=Qy(s.subarray(32,64));if(!i.cI(n))return!1;const l=tg(i.wI(e),Yy(t),a),u=o.wk(n).add(t.wk(i.zv(l))),{x:h,y:f}=u.mI();return!(u.Yv()||!zy(f)||h!==e)}catch(t){return!1}}const ig=(()=>{const t=(t=hp(48))=>cy(t,Dy.n);return{Tk:ky(t,eg),getPublicKey:eg,sign:ng,verify:rg,Ak:My,Bk:{Ik:t,bT:qy,mT:Jy,vT:Yy},Ek:{yk:32,publicKey:32,gk:!1,signature:64,seed:48}}})(),og=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),sg=(()=>Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)))(),ag=(()=>sg.map(t=>(9*t+5)%16))(),cg=(()=>{const t=[[sg],[ag]];for(let e=0;e<4;e++)for(let n of t)n.push(n[e].map(t=>og[t]));return t})(),lg=(()=>cg[0])(),ug=(()=>cg[1])(),hg=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),fg=lg.map((t,e)=>t.map(t=>hg[e][t])),dg=ug.map((t,e)=>t.map(t=>hg[e][t])),wg=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),pg=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function yg(t,e,n,r){return 0===t?e^n^r:1===t?e&n|~e&r:2===t?(e|~n)^r:3===t?e&r|n&~r:e^(n|~r)}const gg=new Uint32Array(16);class bg extends pp{Ok=1732584193;Fk=-271733879;Dk=-1732584194;Wk=271733878;_k=-1009589776;constructor(){super(64,20,8,!0)}get(){const{Ok:t,Fk:e,Dk:n,Wk:r,_k:i}=this;return[t,e,n,r,i]}set(t,e,n,r,i){this.Ok=0|t,this.Fk=0|e,this.Dk=0|n,this.Wk=0|r,this._k=0|i}process(t,e){for(let n=0;n<16;n++,e+=4)gg[n]=t.getUint32(e,!0);let n=0|this.Ok,r=n,i=0|this.Fk,o=i,s=0|this.Dk,a=s,c=0|this.Wk,l=c,u=0|this._k,h=u;for(let t=0;t<5;t++){const e=4-t,f=wg[t],d=pg[t],w=lg[t],p=ug[t],y=fg[t],g=dg[t];for(let e=0;e<16;e++){const r=Xw(n+yg(t,i,s,c)+gg[w[e]]+f,y[e])+u|0;n=u,u=c,c=0|Xw(s,10),s=i,i=r}for(let t=0;t<16;t++){const n=Xw(r+yg(e,o,a,l)+gg[p[t]]+d,g[t])+h|0;r=h,h=l,l=0|Xw(a,10),a=o,o=n}}this.set(this.Fk+s+l|0,this.Dk+c+h|0,this.Wk+u+r|0,this._k+n+o|0,this.Ok+i+a|0)}mv(){qw(gg)}destroy(){this.pv=!0,qw(this.buffer),this.set(0,0,0,0,0)}}const mg=up(()=>new bg);
19
19
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function vg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Ig(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function kg(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function Tg(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Ag(t){if(!Array.isArray(t))throw new Error("array expected")}function Bg(t,e){if(!Ig(!0,e))throw new Error(`${t}: array of strings expected`)}const Eg=(t,e)=>0===e?t:Eg(e,t%e),Rg=(t,e)=>t+(e-Eg(t,e)),Pg=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function xg(t,e,n,r){if(Ag(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Rg(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Rg(e,n)}`);let i=0,o=0;const s=Pg[e],a=Pg[n]-1,c=[];for(const r of t){if(Tg(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(i=i<<e|r,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)c.push((i>>o-n&a)>>>0);const t=Pg[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<n-o&a,!r&&o>=e)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&c.push(i>>>0),c}const Ng=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()?{encode:t=>(function(t){if(!vg(t))throw new Error("Uint8Array expected")}(t),t.toHex()),decode:t=>(kg("hex",t),Uint8Array.fromHex(t))}:function(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}(function(t,e=!1){if(Tg(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Rg(8,t)>32||Rg(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!vg(n))throw new Error("radix2.encode input should be Uint8Array");return xg(Array.from(n),8,t,!e)},decode:n=>(function(t,e){if(!Ig(!1,e))throw new Error(`${t}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(xg(n,t,8,e)))}}(4),function(t){const e="string"==typeof t?t.split(""):t,n=e.length;Bg("alphabet",e);const r=new Map(e.map((t,e)=>[t,e]));return{encode:r=>(Ag(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${t}`);return e[r]})),decode:e=>(Ag(e),e.map(e=>{kg("alphabet.decode",e);const n=r.get(e);if(void 0===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}("0123456789abcdef"),function(t=""){return kg("join",t),{encode:e=>(Bg("join.decode",e),e.join(t)),decode:e=>(kg("join.decode",e),e.split(t))}}(""),(function(t){if("function"!=typeof t)throw new Error("function expected")}($g=t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}),{encode:t=>t,decode:t=>$g(t)}));var $g;function Ug(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function Sg(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}const Cg=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Gg(t){return"[object Object]"===Object.prototype.toString.call(t)}function Vg(t){return Number.isSafeInteger(t)}const Kg=Sg,Og=function(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];if(!Sg(r))throw new Error("Uint8Array expected");e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n},Fg=t=>{if(null!==t&&"string"!=typeof t&&!Yg(t)&&!Sg(t)&&!Vg(t))throw new Error(`lengthCoder: expected null | number | Uint8Array | CoderType, got ${t} (${typeof t})`);return{IT(e,n){if(null===t)return;if(Yg(t))return t.IT(e,n);let r;if("number"==typeof t?r=t:"string"==typeof t&&(r=Wg.resolve(e.stack,t)),"bigint"==typeof r&&(r=Number(r)),void 0===r||r!==n)throw e.Fe(`Wrong length: ${r} len=${t} exp=${n} (${typeof n})`)},kT(e){let n;if(Yg(t)?n=Number(t.kT(e)):"number"==typeof t?n=t:"string"==typeof t&&(n=Wg.resolve(e.stack,t)),"bigint"==typeof n&&(n=Number(n)),"number"!=typeof n)throw e.Fe(`Wrong length: ${n}`);return n}}},Dg={Qv:32,TT:-1>>>0,j:t=>Math.ceil(t/32),create:t=>new Uint32Array(Dg.j(t)),AT:t=>t.fill(0),debug:t=>Array.from(t).map(t=>(t>>>0).toString(2).padStart(32,"0")),BT:(t,e)=>{if(Dg.j(e)!==t.length)throw new Error(`wrong length=${t.length}. Expected: ${Dg.j(e)}`)},ET:(t,e,n)=>{if(e<0)throw new Error(`wrong pos=${e}`);if(e+n>t)throw new Error(`wrong range=${e}/${n} of ${t}`)},set:(t,e,n,r=!0)=>!(!r&&0!==(t[e]&n))&&(t[e]|=n,!0),o:(t,e)=>({RT:Math.floor((t+e)/32),mask:1<<32-(t+e)%32-1}),indices:(t,e,n=!1)=>{Dg.BT(t,e);const{TT:r,Qv:i}=Dg,o=i-e%i,s=o?r>>>o<<o:r,a=[];for(let e=0;e<t.length;e++){let r=t[e];if(n&&(r=~r),e===t.length-1&&(r&=s),0!==r)for(let t=0;t<i;t++){r&1<<i-t-1&&a.push(e*i+t)}}return a},range:t=>{const e=[];let n;for(const r of t)void 0===n||r!==n.o+n.length?e.push(n={o:r,length:1}):n.length+=1;return e},PT:(t,e,n=!1)=>`[${Dg.range(Dg.indices(t,e,n)).map(t=>`(${t.o}/${t.length})`).join(", ")}]`,xT:(t,e,n,r,i=!0)=>{Dg.ET(e,n,r);const{TT:o,Qv:s}=Dg,a=n%s?Math.floor(n/s):void 0,c=n+r,l=c%s?Math.floor(c/s):void 0;if(void 0!==a&&a===l)return Dg.set(t,a,o>>>s-r<<s-r-n,i);if(void 0!==a&&!Dg.set(t,a,o>>>n%s,i))return!1;const u=void 0!==l?l:c/s;for(let e=void 0!==a?a+1:n/s;e<u;e++)if(!Dg.set(t,e,o,i))return!1;return!(void 0!==l&&a!==l&&!Dg.set(t,l,o<<s-c%s,i))}},Wg={NT:(t,e,n)=>{const r={$T:e};t.push(r),n((t,e)=>{r.Lt=t,e(),r.Lt=void 0}),t.pop()},path:t=>{const e=[];for(const n of t)void 0!==n.Lt&&e.push(n.Lt);return e.join("/")},Fe:(t,e,n)=>{const r=new Error(`${t}(${Wg.path(e)}): ${"string"==typeof n?n:n.message}`);return n instanceof Error&&n.stack&&(r.stack=n.stack),r},resolve:(t,e)=>{const n=e.split("/"),r=t.map(t=>t.$T);let i=0;for(;i<n.length&&".."===n[i];i++)r.pop();let o=r.pop();for(;i<n.length;i++){if(!o||void 0===o[n[i]])return;o=o[n[i]]}return o}};class _g{o=0;data;UT;stack;parent;ST;CT=0;GT=0;VT;view;constructor(t,e={},n=[],r=void 0,i=0){this.data=t,this.UT=e,this.stack=n,this.parent=r,this.ST=i,this.view=Cg(t)}KT(){if(this.parent)return this.parent.KT();this.VT||(this.VT=Dg.create(this.data.length),Dg.xT(this.VT,this.data.length,0,this.o,this.UT.OT))}FT(t,e){return this.parent?this.parent.FT(this.ST+t,e):!e||(!this.VT||Dg.xT(this.VT,this.data.length,t,e,!1))}DT(t){const e=this.o;this.o+=t;const n=this.FT(e,t);if(!this.UT.OT&&!n)throw this.Fe(`multiple read pos=${this.o} len=${t}`);return n}NT(t,e){return Wg.NT(this.stack,t,e)}WT(t,e){if(!Number.isFinite(t))throw this.Fe(`readView: wrong length=${t}`);if(this.o+t>this.data.length)throw this.Fe("readView: Unexpected end of buffer");const n=e(this.view,this.o);return this.DT(t),n}_T(t){if(t>this.data.length)throw new Error("Unexpected end of buffer");return this.data.subarray(t)}finish(){if(!this.UT.HT){if(this.GT)throw this.Fe(`${this.GT} bits left after unpack: ${Ng.encode(this.data.slice(this.o))}`);if(this.VT&&!this.parent){const t=Dg.indices(this.VT,this.data.length,!0);if(t.length){const e=Dg.range(t).map(({o:t,length:e})=>`(${t}/${e})[${Ng.encode(this.data.subarray(t,t+e))}]`).join(", ");throw this.Fe(`unread byte ranges: ${e} (total=${this.data.length})`)}return}if(!this.jT())throw this.Fe(`${this.MT} bytes ${this.GT} bits left after unpack: ${Ng.encode(this.data.slice(this.o))}`)}}Fe(t){return Wg.Fe("Reader",this.stack,t)}LT(t){if(t>this.data.length)throw this.Fe("offsetReader: Unexpected end of buffer");return new _g(this._T(t),this.UT,this.stack,this,t)}bytes(t,e=!1){if(this.GT)throw this.Fe("readBytes: bitPos not empty");if(!Number.isFinite(t))throw this.Fe(`readBytes: wrong length=${t}`);if(this.o+t>this.data.length)throw this.Fe("readBytes: Unexpected end of buffer");const n=this.data.subarray(this.o,this.o+t);return e||this.DT(t),n}ZT(t=!1){if(this.GT)throw this.Fe("readByte: bitPos not empty");if(this.o+1>this.data.length)throw this.Fe("readBytes: Unexpected end of buffer");const e=this.data[this.o];return t||this.DT(1),e}get MT(){return this.data.length-this.o}get qT(){return this.data.length}jT(){return this.o>=this.data.length&&!this.GT}NI(t){if(t>32)throw this.Fe("BitReader: cannot read more than 32 bits in single call");let e=0;for(;t;){this.GT||(this.CT=this.ZT(),this.GT=8);const n=Math.min(t,this.GT);this.GT-=n,e=e<<n|this.CT>>this.GT&2**n-1,this.CT&=2**this.GT-1,t-=n}return e>>>0}find(t,e=this.o){if(!Sg(t))throw this.Fe(`find: needle is not bytes! ${t}`);if(this.GT)throw this.Fe("findByte: bitPos not empty");if(!t.length)throw this.Fe("find: needle is empty");for(let n=e;-1!==(n=this.data.indexOf(t[0],n));n++){if(-1===n)return;if(this.data.length-n<t.length)return;if(Ug(t,this.data.subarray(n,n+t.length)))return n}}}class Hg{o=0;stack;buffers=[];YT=[];CT=0;GT=0;zT=new Uint8Array(8);view;finished=!1;constructor(t=[]){this.stack=t,this.view=Cg(this.zT)}NT(t,e){return Wg.NT(this.stack,t,e)}XT(t,e){if(this.finished)throw this.Fe("buffer: finished");if(!Vg(t)||t>8)throw new Error(`wrong writeView length=${t}`);e(this.view),this.bytes(this.zT.slice(0,t)),this.zT.fill(0)}Fe(t){if(this.finished)throw this.Fe("buffer: finished");return Wg.Fe("Reader",this.stack,t)}bytes(t){if(this.finished)throw this.Fe("buffer: finished");if(this.GT)throw this.Fe("writeBytes: ends with non-empty bit buffer");this.buffers.push(t),this.o+=t.length}ZT(t){if(this.finished)throw this.Fe("buffer: finished");if(this.GT)throw this.Fe("writeByte: ends with non-empty bit buffer");this.buffers.push(new Uint8Array([t])),this.o++}finish(t=!0){if(this.finished)throw this.Fe("buffer: finished");if(this.GT)throw this.Fe("buffer: ends with non-empty bit buffer");const e=this.buffers.concat(this.YT.map(t=>t.buffer)),n=e.map(t=>t.length).reduce((t,e)=>t+e,0),r=new Uint8Array(n);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}for(let t=this.o,e=0;e<this.YT.length;e++){const n=this.YT[e];r.set(n.JT.encode(t),n.o),t+=n.buffer.length}if(t){this.buffers=[];for(const t of this.YT)t.buffer.fill(0);this.YT=[],this.finished=!0,this.CT=0}return r}NI(t,e){if(e>32)throw this.Fe("writeBits: cannot write more than 32 bits in single call");if(t>=2**e)throw this.Fe(`writeBits: value (${t}) >= 2**bits (${e})`);for(;e;){const n=Math.min(e,8-this.GT);this.CT=this.CT<<n|t>>e-n,this.GT+=n,t&=2**(e-=n)-1,8===this.GT&&(this.GT=0,this.buffers.push(new Uint8Array([this.CT])),this.o++)}}}const jg=t=>Uint8Array.from(t).reverse();function Mg(t){return{IT:t.IT,kT:t.kT,size:t.size,encode:e=>{const n=new Hg;return t.IT(n,e),n.finish()},decode:(e,n={})=>{const r=new _g(e,n),i=t.kT(r);return r.finish(),i}}}function Lg(t,e){if(!Yg(t))throw new Error(`validate: invalid inner value ${t}`);if("function"!=typeof e)throw new Error("validate: fn should be function");return Mg({size:t.size,IT:(n,r)=>{let i;try{i=e(r)}catch(t){throw n.Fe(t)}t.IT(n,i)},kT:n=>{const r=t.kT(n);try{return e(r)}catch(t){throw n.Fe(t)}}})}const Zg=t=>{const e=Mg(t);return t.validate?Lg(e,t.validate):e},qg=t=>Gg(t)&&"function"==typeof t.decode&&"function"==typeof t.encode;function Yg(t){return Gg(t)&&qg(t)&&"function"==typeof t.IT&&"function"==typeof t.kT&&(void 0===t.size||Vg(t.size))}const zg={QT:function(){return{encode:t=>{if(!Array.isArray(t))throw new Error("array expected");const e={};for(const n of t){if(!Array.isArray(n)||2!==n.length)throw new Error("array of two elements expected");const t=n[0],r=n[1];if(void 0!==e[t])throw new Error(`key(${t}) appears twice in struct`);e[t]=r}return e},decode:t=>{if(!Gg(t))throw new Error(`expected plain object, got ${t}`);return Object.entries(t)}}},tA:{encode:t=>{if("bigint"!=typeof t)throw new Error("expected bigint, got "+typeof t);if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error(`element bigger than MAX_SAFE_INTEGER=${t}`);return Number(t)},decode:t=>{if(!Vg(t))throw new Error("element is not a safe integer");return BigInt(t)}},eA:function(t){if(!Gg(t))throw new Error("plain object expected");return{encode:e=>{if(!Vg(e)||!(e in t))throw new Error(`wrong value ${e}`);return t[e]},decode:e=>{if("string"!=typeof e)throw new Error("wrong value "+typeof e);return t[e]}}},nA:function(t,e=!1){if(!Vg(t))throw new Error(`decimal/precision: wrong value ${t}`);if("boolean"!=typeof e)throw new Error("decimal/round: expected boolean, got "+typeof e);const n=10n**BigInt(t);return{encode:e=>{if("bigint"!=typeof e)throw new Error("expected bigint, got "+typeof e);let n=(e<0n?-e:e).toString(10),r=n.length-t;r<0&&(n=n.padStart(n.length-r,"0"),r=0);let i=n.length-1;for(;i>=r&&"0"===n[i];i--);let o=n.slice(0,r),s=n.slice(r,i+1);return o||(o="0"),e<0n&&(o="-"+o),s?`${o}.${s}`:o},decode:r=>{if("string"!=typeof r)throw new Error("expected string, got "+typeof r);if("-0"===r)throw new Error("negative zero is not allowed");let i=!1;if(r.startsWith("-")&&(i=!0,r=r.slice(1)),!/^(0|[1-9]\d*)(\.\d+)?$/.test(r))throw new Error(`wrong string value=${r}`);let o=r.indexOf(".");o=-1===o?r.length:o;const s=r.slice(0,o),a=r.slice(o+1).replace(/0+$/,""),c=BigInt(s)*n;if(!e&&a.length>t)throw new Error(`fractional part cannot be represented with this precision (num=${r}, prec=${t})`);const l=Math.min(a.length,t),u=c+BigInt(a.slice(0,l))*10n**BigInt(t-l);return i?-u:u}}},match:function(t){if(!Array.isArray(t))throw new Error("expected array, got "+typeof t);for(const e of t)if(!qg(e))throw new Error(`wrong base coder ${e}`);return{encode:e=>{for(const n of t){const t=n.encode(e);if(void 0!==t)return t}throw new Error(`match/encode: cannot find match in ${e}`)},decode:e=>{for(const n of t){const t=n.decode(e);if(void 0!==t)return t}throw new Error(`match/decode: cannot find match in ${e}`)}}},reverse:t=>{if(!qg(t))throw new Error("BaseCoder expected");return{encode:t.decode,decode:t.encode}}},Xg=((t,e=!1,n=!1,r=!0)=>{if(!Vg(t))throw new Error(`bigint/size: wrong value ${t}`);if("boolean"!=typeof e)throw new Error("bigint/le: expected boolean, got "+typeof e);if("boolean"!=typeof n)throw new Error("bigint/signed: expected boolean, got "+typeof n);if("boolean"!=typeof r)throw new Error("bigint/sized: expected boolean, got "+typeof r);const i=BigInt(t),o=2n**(8n*i-1n);return Zg({size:r?t:void 0,IT:(i,s)=>{n&&s<0&&(s|=o);const a=[];for(let e=0;e<t;e++)a.push(Number(255n&s)),s>>=8n;let c=new Uint8Array(a).reverse();if(!r){let t=0;for(t=0;t<c.length&&0===c[t];t++);c=c.subarray(t)}i.bytes(e?c.reverse():c)},kT:i=>{const s=i.bytes(r?t:Math.min(t,i.MT)),a=e?s:jg(s);let c=0n;for(let t=0;t<a.length;t++)c|=BigInt(a[t])<<8n*BigInt(t);return n&&c&o&&(c=(c^o)-o),c},validate:t=>{if("bigint"!=typeof t)throw new Error(`bigint: invalid value: ${t}`);return function(t,e,n){if(n){const n=2n**(e-1n);if(t<-n||t>=n)throw new Error(`value out of signed bounds. Expected ${-n} <= ${t} < ${n}`)}else if(0n>t||t>=2n**e)throw new Error(`value out of unsigned bounds. Expected 0 <= ${t} < ${2n**e}`)}(t,8n*i,!!n),t}})})(8,!0),Jg=(t,e,n)=>{const r=8*t,i=2**(r-1),o=2**r;return((t,e)=>Zg({size:t,IT:(n,r)=>n.XT(t,t=>e.write(t,r)),kT:n=>n.WT(t,e.read),validate:t=>{if("number"!=typeof t)throw new Error("viewCoder: expected number, got "+typeof t);return e.validate&&e.validate(t),t}}))(t,{write:n.write,read:n.read,validate:e?t=>{if(!Vg(t))throw new Error(`sintView: value is not safe integer: ${t}`);if(t<-i||t>=i)throw new Error(`sintView: value out of bounds. Expected ${-i} <= ${t} < ${i}`)}:t=>{if(!Vg(t))throw new Error(`uintView: value is not safe integer: ${t}`);if(0>t||t>=o)throw new Error(`uintView: value out of bounds. Expected 0 <= ${t} < ${o}`)}})},Qg=Jg(4,!1,{read:(t,e)=>t.getUint32(e,!0),write:(t,e)=>t.setUint32(0,e,!0)}),tb=Jg(4,!0,{read:(t,e)=>t.getInt32(e,!0),write:(t,e)=>t.setInt32(0,e,!0)}),eb=Jg(2,!1,{read:(t,e)=>t.getUint16(e,!0),write:(t,e)=>t.setUint16(0,e,!0)}),nb=Jg(1,!1,{read:(t,e)=>t.getUint8(e),write:(t,e)=>t.setUint8(0,e)}),rb=(t,e=!1)=>{if("boolean"!=typeof e)throw new Error("bytes/le: expected boolean, got "+typeof e);const n=Fg(t),r=Sg(t);return Zg({size:"number"==typeof t?t:void 0,IT:(i,o)=>{r||n.IT(i,o.length),i.bytes(e?jg(o):o),r&&i.bytes(t)},kT:i=>{let o;if(r){const e=i.find(t);if(!e)throw i.Fe("bytes: cannot find terminator");o=i.bytes(e-i.o),i.bytes(t.length)}else o=i.bytes(null===t?i.MT:n.kT(i));return e?jg(o):o},validate:t=>{if(!Sg(t))throw new Error(`bytes: invalid value ${t}`);return t}})};function ib(t,e){if(!Yg(t))throw new Error(`apply: invalid inner value ${t}`);if(!qg(e))throw new Error(`apply: invalid base value ${t}`);return Zg({size:t.size,IT:(n,r)=>{let i;try{i=e.decode(r)}catch(t){throw n.Fe(""+t)}return t.IT(n,i)},kT:n=>{const r=t.kT(n);try{return e.encode(r)}catch(t){throw n.Fe(""+t)}}})}function ob(t){let e=0;for(const n of t){if(void 0===n.size)return;if(!Vg(n.size))throw new Error(`sizeof: wrong element size=${e}`);e+=n.size}return e}function sb(t){if(!Gg(t))throw new Error(`struct: expected plain object, got ${t}`);for(const e in t)if(!Yg(t[e]))throw new Error(`struct: field ${e} is not CoderType`);return Zg({size:ob(Object.values(t)),IT:(e,n)=>{e.NT(n,r=>{for(const i in t)r(i,()=>t[i].IT(e,n[i]))})},kT:e=>{const n={};return e.NT(n,r=>{for(const i in t)r(i,()=>n[i]=t[i].kT(e))}),n},validate:t=>{if("object"!=typeof t||null===t)throw new Error(`struct: invalid value ${t}`);return t}})}function ab(t,e){if(!Yg(e))throw new Error(`array: invalid inner value ${e}`);const n=Fg("string"==typeof t?`../${t}`:t);return Zg({size:"number"==typeof t&&e.size?t*e.size:void 0,IT:(r,i)=>{const o=r;o.NT(i,s=>{Sg(t)||n.IT(r,i.length);for(let n=0;n<i.length;n++)s(`${n}`,()=>{const s=i[n],a=r.o;if(e.IT(r,s),Sg(t)){if(t.length>o.o-a)return;const e=o.finish(!1).subarray(a,o.o);if(Ug(e.subarray(0,t.length),t))throw o.Fe(`array: inner element encoding same as separator. elm=${s} data=${e}`)}})}),Sg(t)&&r.bytes(t)},kT:r=>{const i=[];return r.NT(i,o=>{if(null===t)for(let t=0;!r.jT()&&(o(`${t}`,()=>i.push(e.kT(r))),!(e.size&&r.MT<e.size));t++);else if(Sg(t))for(let n=0;;n++){if(Ug(r.bytes(t.length,!0),t)){r.bytes(t.length);break}o(`${n}`,()=>i.push(e.kT(r)))}else{let t;o("arrayLen",()=>t=n.kT(r));for(let n=0;n<t;n++)o(`${n}`,()=>i.push(e.kT(r)))}}),i},validate:t=>{if(!Array.isArray(t))throw new Error(`array: invalid value ${t}`);return t}})}const cb=Ly.Ak;cb.xI,cb.xI.qv;const lb=Kg,ub=Og;Ly.getPublicKey;const hb=0,fb=1;Ip(cb.RI.wI(!1));const db={rA:"bc",Zk:0,iA:5,oA:128};
20
20
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
21
- function wb(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function pb(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function yb(t){if("function"!=typeof t)throw new Error("function expected");return!0}function gb(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function bb(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function mb(t){if(!Array.isArray(t))throw new Error("array expected")}function vb(t,e){if(!pb(!0,e))throw new Error(`${t}: array of strings expected`)}function Ib(t,e){if(!pb(!1,e))throw new Error(`${t}: array of numbers expected`)}function kb(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}function Tb(t){const e="string"==typeof t?t.split(""):t,n=e.length;vb("alphabet",e);const r=new Map(e.map((t,e)=>[t,e]));return{encode:r=>(mb(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${t}`);return e[r]})),decode:e=>(mb(e),e.map(e=>{gb("alphabet.decode",e);const n=r.get(e);if(void 0===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}function Ab(t=""){return gb("join",t),{encode:e=>(vb("join.decode",e),e.join(t)),decode:e=>(gb("join.decode",e),e.split(t))}}function Bb(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(mb(t),!t.length)return[];let r=0;const i=[],o=Array.from(t,t=>{if(bb(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),s=o.length;for(;;){let t=0,a=!0;for(let i=r;i<s;i++){const s=o[i],c=e*t,l=c+s;if(!Number.isSafeInteger(l)||c/e!==t||l-s!==c)throw new Error("convertRadix: carry overflow");const u=l/n;t=l%n;const h=Math.floor(u);if(o[i]=h,!Number.isSafeInteger(h)||h*n+t!==l)throw new Error("convertRadix: carry overflow");a&&(h?a=!1:r=i)}if(i.push(t),a)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const Eb=(t,e)=>0===e?t:Eb(e,t%e),Rb=(t,e)=>t+(e-Eb(t,e)),Pb=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function xb(t,e,n,r){if(mb(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Rb(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Rb(e,n)}`);let i=0,o=0;const s=Pb[e],a=Pb[n]-1,c=[];for(const r of t){if(bb(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(i=i<<e|r,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)c.push((i>>o-n&a)>>>0);const t=Pb[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<n-o&a,!r&&o>=e)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&c.push(i>>>0),c}function Nb(t,e=!1){if(bb(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Rb(8,t)>32||Rb(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!wb(n))throw new Error("radix2.encode input should be Uint8Array");return xb(Array.from(n),8,t,!e)},decode:n=>(Ib("radix2.decode",n),Uint8Array.from(xb(n,t,8,e)))}}function $b(t){return yb(t),function(...e){try{return t.apply(null,e)}catch(t){}}}const Ub=(t=>kb(function(t){return bb(t),{encode:e=>{if(!wb(e))throw new Error("radix.encode input should be Uint8Array");return Bb(Array.from(e),256,t)},decode:e=>(Ib("radix.decode",e),Uint8Array.from(Bb(e,t,256)))}}(58),Tb(t),Ab("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Sb=kb(Tb("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ab("")),Cb=[996825010,642813549,513874426,1027748829,705979059];function Gb(t){const e=t>>25;let n=(33554431&t)<<5;for(let t=0;t<Cb.length;t++)1==(e>>t&1)&&(n^=Cb[t]);return n}function Vb(t,e,n=1){const r=t.length;let i=1;for(let e=0;e<r;e++){const n=t.charCodeAt(e);if(n<33||n>126)throw new Error(`Invalid prefix (${t})`);i=Gb(i)^n>>5}i=Gb(i);for(let e=0;e<r;e++)i=Gb(i)^31&t.charCodeAt(e);for(let t of e)i=Gb(i)^t;for(let t=0;t<6;t++)i=Gb(i);return i^=n,Sb.encode(xb([i%Pb[30]],30,5,!1))}function Kb(t){const e="bech32"===t?1:734539939,n=Nb(5),r=n.decode,i=n.encode,o=$b(r);function s(t,n,r=90){gb("bech32.encode prefix",t),wb(n)&&(n=Array.from(n)),Ib("bech32.encode",n);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);const s=t.toLowerCase(),a=Vb(s,n,e);return`${s}1${Sb.encode(n)}${a}`}function a(t,n=90){gb("bech32.decode input",t);const r=t.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${t}). Expected (8..${n})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=i.slice(0,o),a=i.slice(o+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const c=Sb.decode(a).slice(0,-6),l=Vb(s,c,e);if(!a.endsWith(l))throw new Error(`Invalid checksum in ${t}: expected "${l}"`);return{prefix:s,gT:c}}return{encode:s,decode:a,sA:function(t,e){return s(t,i(e))},aA:function(t){const{prefix:e,gT:n}=a(t,!1);return{prefix:e,gT:n,bytes:r(n)}},cA:$b(a),lA:r,uA:o,hA:i}}const Ob=Kb("bech32"),Fb=Kb("bech32m"),Db=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()?{encode:t=>(function(t){if(!wb(t))throw new Error("Uint8Array expected")}(t),t.toHex()),decode:t=>(gb("hex",t),Uint8Array.fromHex(t))}:kb(Nb(4),Tb("0123456789abcdef"),Ab(""),function(t){return yb(t),{encode:t=>t,decode:e=>t(e)}}(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),Wb={fA:0,dA:76,wA:77,pA:78,yA:79,gA:80,bA:81,mA:82,vA:83,IA:84,kA:85,TA:86,AA:87,BA:88,EA:89,RA:90,PA:91,xA:92,NA:93,$A:94,UA:95,SA:96,CA:97,GA:98,VA:99,KA:100,OA:101,FA:102,DA:103,WA:104,_A:105,HA:106,jA:107,MA:108,LA:109,ZA:110,qA:111,YA:112,zA:113,XA:114,JA:115,DEPTH:116,QA:117,tB:118,eB:119,nB:120,rB:121,iB:122,oB:123,sB:124,aB:125,cB:126,lB:127,uB:128,hB:129,fB:130,INVERT:131,dB:132,wB:133,pB:134,EQUAL:135,yB:136,gB:137,bB:138,mB:139,vB:140,IB:141,kB:142,TB:143,AB:144,BB:145,EB:146,RB:147,PB:148,xB:149,NB:150,$B:151,UB:152,SB:153,CB:154,GB:155,VB:156,KB:157,OB:158,FB:159,DB:160,WB:161,_B:162,MIN:163,MAX:164,HB:165,jB:166,MB:167,LB:168,ZB:169,qB:170,YB:171,zB:172,XB:173,JB:174,QB:175,tE:176,eE:177,nE:178,rE:179,iE:180,oE:181,sE:182,aE:183,cE:184,lE:185,uE:186,hE:255},_b=function(t){const e={};for(const n in t){if(void 0!==e[t[n]])throw new Error("duplicate key");e[t[n]]=n}return e}(Wb);function Hb(t=6,e=!1){return Zg({IT:(t,e)=>{if(0n===e)return;const n=e<0,r=BigInt(e),i=[];for(let t=n?-r:r;t;t>>=8n)i.push(Number(0xffn&t));i[i.length-1]>=128?i.push(n?128:0):n&&(i[i.length-1]|=128),t.bytes(new Uint8Array(i))},kT:n=>{const r=n.MT;if(r>t)throw new Error(`ScriptNum: number (${r}) bigger than limit=${t}`);if(0===r)return 0n;if(e){const t=n.bytes(r,!0);if(!(127&t[t.length-1]||!(r<=1)&&128&t[t.length-2]))throw new Error("Non-minimally encoded ScriptNum")}let i=0,o=0n;for(let t=0;t<r;++t)i=n.ZT(),o|=BigInt(i)<<8n*BigInt(t);return i>=128&&(o&=2n**BigInt(8*r)-1n>>1n,o=-o),o}})}const jb=Zg({IT:(t,e)=>{for(let n of e){if("string"==typeof n){if(void 0===Wb[n])throw new Error(`Unknown opcode=${n}`);t.ZT(Wb[n]);continue}if("number"==typeof n){if(0===n){t.ZT(0);continue}if(1<=n&&n<=16){t.ZT(Wb.bA-1+n);continue}}if("number"==typeof n&&(n=Hb().encode(BigInt(n))),!lb(n))throw new Error(`Wrong Script OP=${n} (${typeof n})`);const e=n.length;e<Wb.dA?t.ZT(e):e<=255?(t.ZT(Wb.dA),t.ZT(e)):e<=65535?(t.ZT(Wb.wA),t.bytes(eb.encode(e))):(t.ZT(Wb.pA),t.bytes(Qg.encode(e))),t.bytes(n)}},kT:t=>{const e=[];for(;!t.jT();){const n=t.ZT();if(Wb.fA<n&&n<=Wb.pA){let r;if(n<Wb.dA)r=n;else if(n===Wb.dA)r=nb.kT(t);else if(n===Wb.wA)r=eb.kT(t);else{if(n!==Wb.pA)throw new Error("Should be not possible");r=Qg.kT(t)}e.push(t.bytes(r))}else if(0===n)e.push(0);else if(Wb.bA<=n&&n<=Wb.SA)e.push(n-(Wb.bA-1));else{const t=_b[n];if(void 0===t)throw new Error(`Unknown opcode=${n.toString(16)}`);e.push(t)}}return e}}),Mb={253:[253,2,253n,65535n],254:[254,4,65536n,4294967295n],255:[255,8,4294967296n,18446744073709551615n]},Lb=Zg({IT:(t,e)=>{if("number"==typeof e&&(e=BigInt(e)),0n<=e&&e<=252n)return t.ZT(Number(e));for(const[n,r,i,o]of Object.values(Mb))if(!(i>e||e>o)){t.ZT(n);for(let n=0;n<r;n++)t.ZT(Number(e>>8n*BigInt(n)&0xffn));return}throw t.Fe(`VarInt too big: ${e}`)},kT:t=>{const e=t.ZT();if(e<=252)return BigInt(e);const[n,r,i]=Mb[e];let o=0n;for(let e=0;e<r;e++)o|=BigInt(t.ZT())<<8n*BigInt(e);if(o<i)throw t.Fe(`Wrong CompactSize(${8*r})`);return o}}),Zb=ib(Lb,zg.tA),qb=rb(Lb),Yb=ab(Zb,qb),zb=t=>ab(Lb,t),Xb=sb({dh:rb(32,!0),index:Qg,fE:qb,dE:Qg}),Jb=sb({Pd:Xg,wE:qb});Lg(sb({version:tb,pE:((t,e=!1)=>{if(!Sg(t))throw new Error("flag/flagValue: expected Uint8Array, got "+typeof t);if("boolean"!=typeof e)throw new Error("flag/xor: expected boolean, got "+typeof e);return Zg({size:t.length,IT:(n,r)=>{!!r!==e&&n.bytes(t)},kT:n=>{let r=n.MT>=t.length;return r&&(r=Ug(n.bytes(t.length,!0),t),r&&n.bytes(t.length)),r!==e},validate:t=>{if(void 0!==t&&"boolean"!=typeof t)throw new Error("flag: expected boolean value or undefined, got "+typeof t);return t}})})(new Uint8Array([0,1])),inputs:zb(Xb),outputs:zb(Jb),yE:function(t,e){if(!Yg(e))throw new Error(`flagged: invalid inner value ${e}`);return Zg({IT:(n,r)=>{Wg.resolve(n.stack,t)&&e.IT(n,r)},kT:n=>{let r=!1;if(r=!!Wg.resolve(n.stack,t),r)return e.kT(n)}})}("segwitFlag",ab("inputs/length",Yb)),gE:Qg}),function(t){if(t.pE&&t.yE&&!t.yE.length)throw new Error("Segwit flag with empty witnesses array");return t}),sb({version:tb,inputs:zb(Xb),outputs:zb(Jb),gE:Qg});function Qb(t,e){try{return function(t,e){const n=t.length;if(e===hb){if(32===n)throw new Error("Expected non-Schnorr key");return cb.hh(t),t}if(e===fb){if(32!==n)throw new Error("Expected 32-byte Schnorr key");return ig.Bk.mT(Pp(t)),t}throw new Error("Unknown key type")}(t,e),!0}catch(t){return!1}}const tm=[{encode(t){if(2===t.length&&1===t[0]&&lb(t[1])&&"4e73"===Db.encode(t[1]))return{type:"p2a",wE:jb.encode(t)}},decode:t=>{if("p2a"===t.type)return[1,Db.decode("4e73")]}},{encode(t){if(2===t.length&&lb(t[0])&&Qb(t[0],hb)&&"CHECKSIG"===t[1])return{type:"pk",bE:t[0]}},decode:t=>"pk"===t.type?[t.bE,"CHECKSIG"]:void 0},{encode(t){if(5===t.length&&"DUP"===t[0]&&"HASH160"===t[1]&&lb(t[2])&&"EQUALVERIFY"===t[3]&&"CHECKSIG"===t[4])return{type:"pkh",hash:t[2]}},decode:t=>"pkh"===t.type?["DUP","HASH160",t.hash,"EQUALVERIFY","CHECKSIG"]:void 0},{encode(t){if(3===t.length&&"HASH160"===t[0]&&lb(t[1])&&"EQUAL"===t[2])return{type:"sh",hash:t[1]}},decode:t=>"sh"===t.type?["HASH160",t.hash,"EQUAL"]:void 0},{encode(t){if(2===t.length&&0===t[0]&&lb(t[1])&&32===t[1].length)return{type:"wsh",hash:t[1]}},decode:t=>"wsh"===t.type?[0,t.hash]:void 0},{encode(t){if(2===t.length&&0===t[0]&&lb(t[1])&&20===t[1].length)return{type:"wpkh",hash:t[1]}},decode:t=>"wpkh"===t.type?[0,t.hash]:void 0},{encode(t){const e=t.length-1;if("CHECKMULTISIG"!==t[e])return;const n=t[0],r=t[e-1];if("number"!=typeof n||"number"!=typeof r)return;const i=t.slice(1,-2);if(r===i.length){for(const t of i)if(!lb(t))return;return{type:"ms",mE:n,vE:i}}},decode:t=>"ms"===t.type?[t.mE,...t.vE,t.vE.length,"CHECKMULTISIG"]:void 0},{encode(t){if(2===t.length&&1===t[0]&&lb(t[1]))return{type:"tr",bE:t[1]}},decode:t=>"tr"===t.type?[1,t.bE]:void 0},{encode(t){const e=t.length-1;if("CHECKSIG"!==t[e])return;const n=[];for(let r=0;r<e;r++){const i=t[r];if(1&r){if("CHECKSIGVERIFY"!==i||r===e-1)return}else{if(!lb(i))return;n.push(i)}}return{type:"tr_ns",vE:n}},decode:t=>{if("tr_ns"!==t.type)return;const e=[];for(let n=0;n<t.vE.length-1;n++)e.push(t.vE[n],"CHECKSIGVERIFY");return e.push(t.vE[t.vE.length-1],"CHECKSIG"),e}},{encode(t){const e=t.length-1;if("NUMEQUAL"!==t[e]||"CHECKSIG"!==t[1])return;const n=[],r=function(t,e=4,n=!0){if("number"==typeof t)return t;if(lb(t))try{const r=Hb(e,n).decode(t);if(r>Number.MAX_SAFE_INTEGER)return;return Number(r)}catch(t){return}}(t[e-1]);if("number"==typeof r){for(let r=0;r<e-1;r++){const e=t[r];if(1&r){if(e!==(1===r?"CHECKSIG":"CHECKSIGADD"))throw new Error("OutScript.encode/tr_ms: wrong element")}else{if(!lb(e))throw new Error("OutScript.encode/tr_ms: wrong key element");n.push(e)}}return{type:"tr_ms",vE:n,mE:r}}},decode:t=>{if("tr_ms"!==t.type)return;const e=[t.vE[0],"CHECKSIG"];for(let n=1;n<t.vE.length;n++)e.push(t.vE[n],"CHECKSIGADD");return e.push(t.mE,"NUMEQUAL"),e}},{encode:t=>({type:"unknown",wE:jb.encode(t)}),decode:t=>"unknown"===t.type?jb.decode(t.wE):void 0}],em=Lg(ib(jb,zg.match(tm)),t=>{if("pk"===t.type&&!Qb(t.bE,hb))throw new Error("OutScript/pk: wrong key");if(!("pkh"!==t.type&&"sh"!==t.type&&"wpkh"!==t.type||lb(t.hash)&&20===t.hash.length))throw new Error(`OutScript/${t.type}: wrong hash`);if("wsh"===t.type&&(!lb(t.hash)||32!==t.hash.length))throw new Error("OutScript/wsh: wrong hash");if(!("tr"!==t.type||lb(t.bE)&&Qb(t.bE,fb)))throw new Error("OutScript/tr: wrong taproot public key");if(("ms"===t.type||"tr_ns"===t.type||"tr_ms"===t.type)&&!Array.isArray(t.vE))throw new Error("OutScript/multisig: wrong pubkeys array");if("ms"===t.type){const e=t.vE.length;for(const e of t.vE)if(!Qb(e,hb))throw new Error("OutScript/multisig: wrong pubkey");if(t.mE<=0||e>16||t.mE>e)throw new Error("OutScript/multisig: invalid params")}if("tr_ns"===t.type||"tr_ms"===t.type)for(const e of t.vE)if(!Qb(e,fb))throw new Error(`OutScript/${t.type}: wrong pubkey`);if("tr_ms"===t.type){const e=t.vE.length;if(t.mE<=0||e>999||t.mE>e)throw new Error("OutScript/tr_ms: invalid params")}return t}),nm=(t,e=db)=>{if(!Qb(t,hb))throw new Error("P2PKH: invalid publicKey");const n=mg(Ip(t));return{type:"pkh",wE:em.encode({type:"pkh",hash:n}),address:am(e).encode({type:"pkh",hash:n}),hash:n}},rm=(t=>kb(function(t,e){return bb(t),yb(e),{encode(n){if(!wb(n))throw new Error("checksum.encode: input should be Uint8Array");const r=e(n).slice(0,t),i=new Uint8Array(n.length+t);return i.set(n),i.set(r,n.length),i},decode(n){if(!wb(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-t),i=n.slice(-t),o=e(r).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return r}}}(4,e=>t(t(e))),Ub))(Ip);function im(t,e){if(e.length<2||e.length>40)throw new Error("Witness: invalid length");if(t>16)throw new Error("Witness: invalid version");if(0===t&&20!==e.length&&32!==e.length)throw new Error("Witness: invalid length for version")}function om(t,e,n=db){im(t,e);const r=0===t?Ob:Fb;return r.encode(n.rA,[t].concat(r.hA(e)))}function sm(t,e){return rm.encode(ub(Uint8Array.from(e),t))}function am(t=db){return{encode(e){const{type:n}=e;if("wpkh"===n)return om(0,e.hash,t);if("wsh"===n)return om(0,e.hash,t);if("tr"===n)return om(1,e.bE,t);if("pkh"===n)return sm(e.hash,[t.Zk]);if("sh"===n)return sm(e.hash,[t.iA]);throw new Error(`Unknown address type=${n}`)},decode(e){if(e.length<14||e.length>74)throw new Error("Invalid address length");if(t.rA&&e.toLowerCase().startsWith(`${t.rA}1`)){let n;try{if(n=Ob.decode(e),0!==n.gT[0])throw new Error(`bech32: wrong version=${n.gT[0]}`)}catch(t){if(n=Fb.decode(e),0===n.gT[0])throw new Error(`bech32m: wrong version=${n.gT[0]}`)}if(n.prefix!==t.rA)throw new Error(`wrong bech32 prefix=${n.prefix}`);const[r,...i]=n.gT,o=Ob.lA(i);if(im(r,o),0===r&&32===o.length)return{type:"wsh",hash:o};if(0===r&&20===o.length)return{type:"wpkh",hash:o};if(1===r&&32===o.length)return{type:"tr",bE:o};throw new Error("Unknown witness program")}const n=rm.decode(e);if(21!==n.length)throw new Error("Invalid base58 address");if(n[0]===t.Zk)return{type:"pkh",hash:n.slice(1)};if(n[0]===t.iA)return{type:"sh",hash:n.slice(1)};throw new Error(`Invalid address prefix=${n[0]}`)}}}const cm={ws:{Zk:76,iA:16,rA:"dc",oA:204,Hk:76066276,jk:76067358},ds:{Zk:140,iA:19,rA:"dc",oA:239,Hk:70615956,jk:70617039}};class lm{IE(t,e){return function(t,e){return Ww(t,e)}(t,e)}kE(t,e="mainnet"){return Kw.tT(t,cm[e])}async cT(t,e){return function(t,e){return t.cT(e)}(t,e)}async TE(t,e){return _w(t,e)}AE(t,e,n,r){return _w(t,`m/9'/${"mainnet"===r?5:1}'${`/5'/0'/0'/${e}'/${n}'`}`)}BE(t,e){return nm(t,cm[e]).address}}async function um(t,e,n,r){const i=Ze.create({version:{Tt:"v0",wr:{Qr:null!=r?Rt.create({value:r}):void 0,count:e,Jr:n,pr:!0}}}),{response:o}=await t.Ts().Xo(i),{version:s}=o;if("v0"!==s.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:a}=s;if("proof"!==a.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:c},metadata:l}=a;if(null==l)throw new Error("Metadata not found");const{hb:u,EE:h}=function(t,e,n,r,i,o){const s=Qs.ru.Zs(t,e,n,r,i??!1,Ta(o));return{hb:s.hb,EE:s.EE.map(t=>({index:t.index,RE:BigInt(t.RE),ni:BigInt(t.ni),ri:t.ri,PE:BigInt(t.PE),ur:t.ur}))}}(c.nr,l.cr,r,e,n,pl),f=await Hc(t.Ui,c.sr,jc(c.rr));if(!await dl(c,l,u,f))throw new Error("Failed to verify query");return h.map(t=>({number:t.index,ni:t.ni,ri:t.ri,startTime:t.RE,ii:t.PE,ur:t.ur}))}async function hm(t){const e=wn.create({version:{Tt:"v0",wr:{pr:!0}}}),{response:n}=await t.Ts().ts(e),{version:r}=n;if("v0"!==r.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:i}=r;if("proof"!==i.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:o},metadata:s}=i;if(null==s)throw new Error("Metadata not found");const a="testnet"===t.Ui?1066900:2128896,{hb:c,xE:l}=function(t,e,n,r,i){const o=Qs.ru.ca(t,e,n,r,Ta(i));return{hb:o.hb,xE:BigInt(o.xE)}}(o.nr,210240,a,Number(s.height),pl),u=await Hc(t.Ui,o.sr,jc(o.rr));if(!await dl(o,s,c,u))throw new Error("Failed to verify query");return l}class fm{kb;constructor(t){this.kb=t}async status(){return await async function(t){const e=bn.create({version:{Tt:"v0",wr:{}}}),{response:n}=await t.Ts().es(e),{version:r}=n;if("v0"!==r.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:i}=r;return{node:null!=i.node?{id:jc(i.node.id),ji:null!=i.node.ji?jc(i.node.ji):void 0}:void 0,chain:null!=i.chain?{Mi:i.chain.Mi,qi:i.chain.qi,Xi:i.chain.Xi,Ji:i.chain.Ji,ar:i.chain.ar,Li:null!=i.chain?.Li?jc(i.chain?.Li):"",Zi:null!=i.chain?.Zi?jc(i.chain?.Zi):"",Yi:null!=i.chain?.Yi?jc(i.chain?.Yi):"",zi:null!=i.chain?.zi?jc(i.chain?.zi):""}:void 0,version:i.version,Ui:i.Ui,Si:i.Si,time:i.time}}(this.kb)}async xE(){return await hm(this.kb)}async Xo(t,e,n){return await um(this.kb,t,e,n)}}function dm(t){return/^[a-zA-Z01-]{3,19}$/.test(t)}async function wm(t,e,n,r){const[i]=n.Rf().filter(t=>t.rf()===r.rf());if(null==i)throw new Error("Private key does not match the identity");if("HIGH"!==i.wf&&"AUTHENTICATION"!==i.Or)throw new Error("Wrong private key, must be from AUTHENTICATION HIGH identity public key");const[o,s]=e.split("."),a=function(t){const e=Uint8Array.from({length:t});return crypto.getRandomValues(e)}(32),c=Ph(s),l=Ph(o),u=`${l}.${c}`,h=await Mc(await Mc(new Uint8Array([...a,...(new TextEncoder).encode(u)])));let f,d;const w={NE:Array.from(h)},p=await gl(t,n.id,wl);f=zl(wl,"preorder",w,n.id.gh()),d=Jl(f,"create",{vr:p+BigInt(1)}),await d.sign(r,i),await ql(t,d),await Ll(t,d);const y={label:o,$E:l,UE:s,SE:c,CE:Array.from(a),GE:{identity:Array.from(n.id.bytes())},VE:{KE:!1}};f=zl(wl,"domain",y,n.id.gh()),d=Jl(f,"create",{vr:p+BigInt(2),bg:dm(l)?new gc("parentNameAndLabel",BigInt(2e10)):void 0}),await d.sign(r,i),await ql(t,d)}function pm(t){const e=t.split(".");if(2!==e.length)return"Name to search should be a full domain name (ex. pshenmic.dash)";const[n,r]=e;return"dash"!==r?"Root domain must be .dash":/^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$/.test(n)?null:"Unacceptable label name"}class ym{kb;constructor(t){this.kb=t}async OE(t){const e=pm(t);if(null!=e)throw new Error(e);return await async function(t,e){const[n,r]=e.split("."),i=[["normalizedParentDomainName","==",Ph(r)],["normalizedLabel","startsWith",Ph(n)]];return await Eh(t,"GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec","domain",i,[["normalizedLabel","asc"]])}(this.kb,t)}FE(t){const e=pm(t);if(null!=e)throw new Error(e);const[n]=t.split(".");return dm(Ph(n))}async DE(t){return await async function(t,e){return await Eh(t,"GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec","domain",[["records.identity","=",e.gh()]],[["records.identity","asc"]])}(this.kb,new ga(t))}async WE(t,e,n){const r=pm(t);if(null!=r)throw new Error(r);const i=await Tl(this.kb,e);await wm(this.kb,t,i,n)}_E(t){return Ph(t)}HE(t){return pm(t)}}var gm;!function(t){t[t.cu=0]="Create",t[t.jE=1]="Update"}(gm||(gm={}));const bm={create:fc,update:dc};class mm{kb;constructor(t){this.kb=t}create(t,e,n,r,i,o,s){return function(t,e,n,r,i,o,s){const a=new ga(t),c=new hc(a,e,n,void 0,r,o??!0,s??pl);return null!=i&&c.ky(i,s),c}(t,e,n,i,o,r,s)}async ME(t){return await Ml(this.kb,t)}Bb(t,e,n){return function(t,e,n){const r=bm[e];if(null==r)throw new Error(`Unknown DataContract transition type: ${e}. Should be 'create' or 'update'.`);return new r(t,n).pd()}(t,e,n)}}async function vm(t,e,n,r,i,o,s,a,c){null!=a&&(a={yi:new ga(a.yi).bytes(),gi:a.gi});const l=sn.create({version:{Tt:"v0",wr:{gr:e.id.bytes(),Vr:n,oi:r,di:i,resultType:o,wi:s,pi:a,count:c,pr:!0}}}),{response:u}=await t.Ts().Qo(l),{version:h}=u;if("v0"!==h.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:f}=h;if("proof"!==f.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:d},metadata:w}=f;if(null==w)throw new Error("Metadata not found");const{hb:p,result:y}=function(t,e,n,r,i,o,s,a,c,l){const u=Qs.ru.la(t,e.wy,n,r,i,Ta(o),s??!1,a,Ta(c),Ta(l)),h=Aa(u.result.LE),f=h?.ZE,d=null!=h?{type:h.type,yr:h.yr,ZE:{height:BigInt(f.height),xb:f.xb,lr:BigInt(f.lr),cr:null!=f.cr?f?.cr:void 0}}:void 0;return{hb:u.hb,result:{qE:u.result.qE??void 0,Ei:u.result.Ei.map(t=>({yr:ga.rh(t.yr),YE:t.YE??void 0,zE:t.zE??void 0})),XE:u.result.XE??void 0,LE:d,skipped:u.result.skipped}}}(d.nr,e,n,r,i,o,s,c,a,pl),g=await Hc(t.Ui,d.sr,jc(d.rr));if(!await dl(d,w,p,g))throw new Error("Failed to verify query");const{Ei:b}=y??{Ei:[]},{LE:m}=y??{LE:void 0};if(0===b.length)throw new Error("Vote state not found");return{Ei:b.map(t=>({identifier:t.yr,document:null!=t.YE?wc.hh(t.YE,e,n,pl):void 0,zE:t.zE})),Ri:y?.XE??0,Pi:y?.qE??0,skipped:1===y?.skipped,xi:null!=m?{type:m.type,Bi:"yr"in m?new ga(m.yr):void 0,Ii:m.ZE.height,ki:m.ZE.xb,Ti:m.ZE.lr,Ai:m.ZE.cr}:void 0}}class Im{kb;constructor(t){this.kb=t}async Qo(t,e,n,r,i,o,s,a){return await vm(this.kb,t,e,n,r,i,o,s,a)}}async function km(t,e,n){const r=e.map(t=>new ga(t)),i=new ga(n),o=On.create({version:{Tt:"v0",wr:{fo:i.bytes(),do:r.map(t=>t.bytes()),pr:!0}}}),{response:s}=await t.Ts().rs(o),{version:a}=s;if("v0"!==a.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:c}=a;if("proof"!==c.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:l},metadata:u}=c;if(null==u)throw new Error("Metadata not found");const{hb:h,JE:f}=function(t,e,n,r,i){const o=Qs.ru.ra(t,Ba(e),n,r.map(Ba),Ta(i));return{hb:o.hb,JE:o.JE.map(t=>({balance:null!=t.balance?BigInt(t.balance):void 0,id:ga.rh(t.id)}))}}(l.nr,i,!0,r,pl),d=await Hc(t.Ui,l.sr,jc(l.rr));if(!await dl(l,u,h,d))throw new Error("Failed to verify query");return f.map(({id:t,balance:e})=>({yr:new ga(t),balance:e}))}async function Tm(t,e,n){const r=new ga(e),i=n.map(t=>new ga(t)),o=Un.create({version:{Tt:"v0",wr:{uo:i.map(t=>t.bytes()),yr:r.bytes(),pr:!0}}}),{response:s}=await t.Ts().ns(o),{version:a}=s;if("v0"!==a.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:c}=a;if("proof"!==c.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:l},metadata:u}=c;if(null==u)throw new Error("Metadata not found");const{hb:h,JE:f}=function(t,e,n,r,i){const o=Qs.ru.sa(t,e.map(Ba),Ba(n),r,Ta(i));return{hb:o.hb,JE:o.JE.map(t=>({balance:null!=t.balance?BigInt(t.balance):void 0,id:ga.rh(t.id)}))}}(l.nr,i,r,!0,pl),d=await Hc(t.Ui,l.sr,jc(l.rr));if(!await dl(l,u,h,d))throw new Error("Failed to verify query");return f.map(({id:t,balance:e})=>({fo:new ga(t),balance:e}))}async function Am(t,e){const n=new ga(e),r=jn.create({version:{Tt:"v0",wr:{fo:n.bytes(),pr:!0}}}),{response:i}=await t.Ts().ss(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,QE:u}=function(t,e,n,r){const i=Qs.ru.ia(t,Ba(e),n,Ta(r));return{hb:i.hb,QE:null!=i.QE?{gr:ga.rh(i.QE.gr),po:i.QE.po}:void 0}}(a.nr,n,!0,pl);if(null==u)throw new Error("ContractInfo not found");const h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return{_r:u.gr,po:u.po}}async function Bm(t,e){const n=new ga(e),r=rr.create({version:{Tt:"v0",wr:{fo:n.bytes(),pr:!0}}}),{response:i}=await t.Ts().ls(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,tR:u}=function(t,e,n,r){const i=Qs.ru.aa(t,Ba(e),n,Ta(r));return{hb:i.hb,tR:{eR:BigInt(i.tR.eR),nR:BigInt(i.tR.nR)}}}(a.nr,n,!0,pl),h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return{fo:n,Eo:u.eR,Bo:u.nR}}const Em={rR:{wb:Nc,arguments:["amount","publicNote"],pb:["publicNote"]},iR:{wb:Gc,arguments:["identityId","amount","publicNote"],pb:["publicNote"]},transfer:{wb:Vc,arguments:["identityId","amount","publicNote","sharedEncryptedNote","privateEncryptedNote"],pb:["publicNote","sharedEncryptedNote","privateEncryptedNote"]},freeze:{wb:Cc,arguments:["identityId","publicNote"],pb:["publicNote"]},oR:{wb:Kc,arguments:["identityId","publicNote"],pb:["publicNote"]},sR:{wb:Uc,arguments:["identityId","publicNote"],pb:["publicNote"]},Ug:{wb:Sc,arguments:["emergencyAction","publicNote"],pb:["publicNote"]},aR:{wb:Pc,arguments:["amount","totalAgreedPrice"],pb:[]},cR:{wb:xc,arguments:["price","publicNote"],pb:["publicNote"]}};async function Rm(t,e){const n=e.map(t=>new ga(t).bytes()),r=Yn.create({version:{Tt:"v0",wr:{uo:n,pr:!0}}}),{response:i}=await t.Ts().cs(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,lR:u}=function(t,e,n,r){const i=Qs.ru.oa(t,e.map(Ba),n,Ta(r));return{hb:i.hb,lR:i.lR.map(t=>({fo:ga.rh(t.id),Xg:null!=t.Xg?Bc.rh(t.Xg):void 0}))}}(a.nr,n,!0,pl);if(null==u)throw new Error("Prices not found");const h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return u}class Pm{kb;constructor(t){this.kb=t}async rs(t,e){return await km(this.kb,t,e)}async uR(t,e){return await Tm(this.kb,t,e)}async ss(t){return await Am(this.kb,t)}async ls(t){return await Bm(this.kb,t)}async hR(t){return await Rm(this.kb,t)}async fR(t,e){const{_r:n,po:r}=await Am(this.kb,t),i=await gl(this.kb,e,n);return new Ec(i+BigInt(1),r,n,t,void 0)}Bb(t,e,n,r){const i=new ga(e);return null!=r.yr&&(r.yr=new ga(r.yr)),null!=r.mo&&"bigint"==typeof r.mo&&(r.mo=Bc.Ig(r.mo)),function(t,e,n,r){const{wb:i,arguments:o,pb:s}=Em[n];if(null==i)throw new Error(`Unimplemented transition type: ${n}`);const[a]=o.filter(t=>null==r[t]&&!s.includes(t));if(null!=a)throw new Error(`Token transition param "${a}" is missing`);const c=new i(t,...o.map(t=>r[t])),l=new Oc(c),u=new Fc(l);return Dc.jg([u],e,1).pd()}(t,i,n,r)}}class xm{async dR(t,e){return await xh(t,e)}wR(t,e,n,r,i){let o;return o="lock"===i?ja.Lock():"abstain"===i?ja.Vd():ja.Gd(new ga(i)),function(t,e,n,r,i){const o=new Ma(t,e,n,r);return new La(o,i)}(new ga(t),e,n,r,o)}Bb(t,e,n,r){return new Za(ga.fromHex(e),new ga(n),t,r).pd()}}async function Nm(t,e){const n=new ka(e),r=wr.create({version:{Tt:"v0",wr:{address:n.bytes(),pr:!0}}}),{response:i}=await t.Ts().hs(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,address:u,nonce:h,balance:f}=function(t,e,n,r){const i=Qs.ru.js(t,Ea(e),n,Ta(r));return{hb:i.hb,address:null!=i.address?ka.rh(i.address):void 0,balance:null!=i.balance?BigInt(i.balance):void 0,nonce:i.nonce}}(a.nr,n,!0,pl);if(null==u||null==h||null==f)throw new Error(`Failed to fetch info for address ${n.Wh(t.Ui)}`);const d=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,d))throw new Error("Failed to verify query");return{address:u,nonce:h,balance:f}}async function $m(t,e){const n=e.map(t=>new ka(t)),r=vr.create({version:{Tt:"v0",wr:{So:n.map(t=>t.bytes()),pr:!0}}}),{response:i}=await t.Ts().fs(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,tb:u}=function(t,e,n,r){const i=Qs.ru.Hs(t,e.map(Ea),n,Ta(r));return{hb:i.hb,tb:i.tb.map(({nonce:t,$i:e,address:n})=>({nonce:t,balance:null!=e?BigInt(e):void 0,address:ka.rh(n)}))}}(a.nr,n,!0,pl),h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return u.map(t=>({address:t.address,nonce:t.nonce??0,balance:BigInt(t.balance??0)}))}class Um{kb;constructor(t){this.kb=t}async hs(t){return await Nm(this.kb,t)}async fs(t){return await $m(this.kb,t)}}t.t=class{Ui;kb;options;pR;yR;gR;bR;mR;qr;vR;IR;by;Bk;names;node;constructor(t){if(null!=t&&(null==t.Ui||!["testnet","mainnet"].includes(t.Ui)))throw new Error("If options is passed, network must be set (either mainnet or testnet)");this.Ui=t?.Ui??"mainnet",this.options=t,this.Bk=new Nh,null!=t?.bs&&null==t?.kR&&(this.options.kR={bs:t.bs}),this.kb=new xr(this.Ui,this.options?.kR),this.gs(this.kb)}gs(t){this.kb=t,this.pR=new Im(t),this.yR=new Um(t),this.gR=new Yl(t),this.bR=new mm(t),this.mR=new jl(t),this.qr=new Rh(t),this.IR=new xm,this.node=new fm(t),this.by=new Pm(t),this.names=new ym(t),this.vR=new lm}af(){return this.Ui}TR(t){if("testnet"!==t&&"mainnet"!==t)throw new Error("Unknown network, should be mainnet or testnet");this.Ui=t;const e=new xr(this.Ui,this.options?.kR);this.gs(e)}}});
21
+ function wb(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function pb(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function yb(t){if("function"!=typeof t)throw new Error("function expected");return!0}function gb(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function bb(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function mb(t){if(!Array.isArray(t))throw new Error("array expected")}function vb(t,e){if(!pb(!0,e))throw new Error(`${t}: array of strings expected`)}function Ib(t,e){if(!pb(!1,e))throw new Error(`${t}: array of numbers expected`)}function kb(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}function Tb(t){const e="string"==typeof t?t.split(""):t,n=e.length;vb("alphabet",e);const r=new Map(e.map((t,e)=>[t,e]));return{encode:r=>(mb(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${t}`);return e[r]})),decode:e=>(mb(e),e.map(e=>{gb("alphabet.decode",e);const n=r.get(e);if(void 0===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}function Ab(t=""){return gb("join",t),{encode:e=>(vb("join.decode",e),e.join(t)),decode:e=>(gb("join.decode",e),e.split(t))}}function Bb(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(mb(t),!t.length)return[];let r=0;const i=[],o=Array.from(t,t=>{if(bb(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),s=o.length;for(;;){let t=0,a=!0;for(let i=r;i<s;i++){const s=o[i],c=e*t,l=c+s;if(!Number.isSafeInteger(l)||c/e!==t||l-s!==c)throw new Error("convertRadix: carry overflow");const u=l/n;t=l%n;const h=Math.floor(u);if(o[i]=h,!Number.isSafeInteger(h)||h*n+t!==l)throw new Error("convertRadix: carry overflow");a&&(h?a=!1:r=i)}if(i.push(t),a)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const Eb=(t,e)=>0===e?t:Eb(e,t%e),Rb=(t,e)=>t+(e-Eb(t,e)),Pb=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function xb(t,e,n,r){if(mb(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Rb(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Rb(e,n)}`);let i=0,o=0;const s=Pb[e],a=Pb[n]-1,c=[];for(const r of t){if(bb(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(i=i<<e|r,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)c.push((i>>o-n&a)>>>0);const t=Pb[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<n-o&a,!r&&o>=e)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&c.push(i>>>0),c}function Nb(t,e=!1){if(bb(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Rb(8,t)>32||Rb(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!wb(n))throw new Error("radix2.encode input should be Uint8Array");return xb(Array.from(n),8,t,!e)},decode:n=>(Ib("radix2.decode",n),Uint8Array.from(xb(n,t,8,e)))}}function $b(t){return yb(t),function(...e){try{return t.apply(null,e)}catch(t){}}}const Ub=(t=>kb(function(t){return bb(t),{encode:e=>{if(!wb(e))throw new Error("radix.encode input should be Uint8Array");return Bb(Array.from(e),256,t)},decode:e=>(Ib("radix.decode",e),Uint8Array.from(Bb(e,t,256)))}}(58),Tb(t),Ab("")))("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Sb=kb(Tb("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ab("")),Cb=[996825010,642813549,513874426,1027748829,705979059];function Gb(t){const e=t>>25;let n=(33554431&t)<<5;for(let t=0;t<Cb.length;t++)1==(e>>t&1)&&(n^=Cb[t]);return n}function Vb(t,e,n=1){const r=t.length;let i=1;for(let e=0;e<r;e++){const n=t.charCodeAt(e);if(n<33||n>126)throw new Error(`Invalid prefix (${t})`);i=Gb(i)^n>>5}i=Gb(i);for(let e=0;e<r;e++)i=Gb(i)^31&t.charCodeAt(e);for(let t of e)i=Gb(i)^t;for(let t=0;t<6;t++)i=Gb(i);return i^=n,Sb.encode(xb([i%Pb[30]],30,5,!1))}function Kb(t){const e="bech32"===t?1:734539939,n=Nb(5),r=n.decode,i=n.encode,o=$b(r);function s(t,n,r=90){gb("bech32.encode prefix",t),wb(n)&&(n=Array.from(n)),Ib("bech32.encode",n);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);const s=t.toLowerCase(),a=Vb(s,n,e);return`${s}1${Sb.encode(n)}${a}`}function a(t,n=90){gb("bech32.decode input",t);const r=t.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${t}). Expected (8..${n})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=i.slice(0,o),a=i.slice(o+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const c=Sb.decode(a).slice(0,-6),l=Vb(s,c,e);if(!a.endsWith(l))throw new Error(`Invalid checksum in ${t}: expected "${l}"`);return{prefix:s,gT:c}}return{encode:s,decode:a,sA:function(t,e){return s(t,i(e))},aA:function(t){const{prefix:e,gT:n}=a(t,!1);return{prefix:e,gT:n,bytes:r(n)}},cA:$b(a),lA:r,uA:o,hA:i}}const Ob=Kb("bech32"),Fb=Kb("bech32m"),Db=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()?{encode:t=>(function(t){if(!wb(t))throw new Error("Uint8Array expected")}(t),t.toHex()),decode:t=>(gb("hex",t),Uint8Array.fromHex(t))}:kb(Nb(4),Tb("0123456789abcdef"),Ab(""),function(t){return yb(t),{encode:t=>t,decode:e=>t(e)}}(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),Wb={fA:0,dA:76,wA:77,pA:78,yA:79,gA:80,bA:81,mA:82,vA:83,IA:84,kA:85,TA:86,AA:87,BA:88,EA:89,RA:90,PA:91,xA:92,NA:93,$A:94,UA:95,SA:96,CA:97,GA:98,VA:99,KA:100,OA:101,FA:102,DA:103,WA:104,_A:105,HA:106,jA:107,MA:108,LA:109,ZA:110,qA:111,YA:112,zA:113,XA:114,JA:115,DEPTH:116,QA:117,tB:118,eB:119,nB:120,rB:121,iB:122,oB:123,sB:124,aB:125,cB:126,lB:127,uB:128,hB:129,fB:130,INVERT:131,dB:132,wB:133,pB:134,EQUAL:135,yB:136,gB:137,bB:138,mB:139,vB:140,IB:141,kB:142,TB:143,AB:144,BB:145,EB:146,RB:147,PB:148,xB:149,NB:150,$B:151,UB:152,SB:153,CB:154,GB:155,VB:156,KB:157,OB:158,FB:159,DB:160,WB:161,_B:162,MIN:163,MAX:164,HB:165,jB:166,MB:167,LB:168,ZB:169,qB:170,YB:171,zB:172,XB:173,JB:174,QB:175,tE:176,eE:177,nE:178,rE:179,iE:180,oE:181,sE:182,aE:183,cE:184,lE:185,uE:186,hE:255},_b=function(t){const e={};for(const n in t){if(void 0!==e[t[n]])throw new Error("duplicate key");e[t[n]]=n}return e}(Wb);function Hb(t=6,e=!1){return Zg({IT:(t,e)=>{if(0n===e)return;const n=e<0,r=BigInt(e),i=[];for(let t=n?-r:r;t;t>>=8n)i.push(Number(0xffn&t));i[i.length-1]>=128?i.push(n?128:0):n&&(i[i.length-1]|=128),t.bytes(new Uint8Array(i))},kT:n=>{const r=n.MT;if(r>t)throw new Error(`ScriptNum: number (${r}) bigger than limit=${t}`);if(0===r)return 0n;if(e){const t=n.bytes(r,!0);if(!(127&t[t.length-1]||!(r<=1)&&128&t[t.length-2]))throw new Error("Non-minimally encoded ScriptNum")}let i=0,o=0n;for(let t=0;t<r;++t)i=n.ZT(),o|=BigInt(i)<<8n*BigInt(t);return i>=128&&(o&=2n**BigInt(8*r)-1n>>1n,o=-o),o}})}const jb=Zg({IT:(t,e)=>{for(let n of e){if("string"==typeof n){if(void 0===Wb[n])throw new Error(`Unknown opcode=${n}`);t.ZT(Wb[n]);continue}if("number"==typeof n){if(0===n){t.ZT(0);continue}if(1<=n&&n<=16){t.ZT(Wb.bA-1+n);continue}}if("number"==typeof n&&(n=Hb().encode(BigInt(n))),!lb(n))throw new Error(`Wrong Script OP=${n} (${typeof n})`);const e=n.length;e<Wb.dA?t.ZT(e):e<=255?(t.ZT(Wb.dA),t.ZT(e)):e<=65535?(t.ZT(Wb.wA),t.bytes(eb.encode(e))):(t.ZT(Wb.pA),t.bytes(Qg.encode(e))),t.bytes(n)}},kT:t=>{const e=[];for(;!t.jT();){const n=t.ZT();if(Wb.fA<n&&n<=Wb.pA){let r;if(n<Wb.dA)r=n;else if(n===Wb.dA)r=nb.kT(t);else if(n===Wb.wA)r=eb.kT(t);else{if(n!==Wb.pA)throw new Error("Should be not possible");r=Qg.kT(t)}e.push(t.bytes(r))}else if(0===n)e.push(0);else if(Wb.bA<=n&&n<=Wb.SA)e.push(n-(Wb.bA-1));else{const t=_b[n];if(void 0===t)throw new Error(`Unknown opcode=${n.toString(16)}`);e.push(t)}}return e}}),Mb={253:[253,2,253n,65535n],254:[254,4,65536n,4294967295n],255:[255,8,4294967296n,18446744073709551615n]},Lb=Zg({IT:(t,e)=>{if("number"==typeof e&&(e=BigInt(e)),0n<=e&&e<=252n)return t.ZT(Number(e));for(const[n,r,i,o]of Object.values(Mb))if(!(i>e||e>o)){t.ZT(n);for(let n=0;n<r;n++)t.ZT(Number(e>>8n*BigInt(n)&0xffn));return}throw t.Fe(`VarInt too big: ${e}`)},kT:t=>{const e=t.ZT();if(e<=252)return BigInt(e);const[n,r,i]=Mb[e];let o=0n;for(let e=0;e<r;e++)o|=BigInt(t.ZT())<<8n*BigInt(e);if(o<i)throw t.Fe(`Wrong CompactSize(${8*r})`);return o}}),Zb=ib(Lb,zg.tA),qb=rb(Lb),Yb=ab(Zb,qb),zb=t=>ab(Lb,t),Xb=sb({dh:rb(32,!0),index:Qg,fE:qb,dE:Qg}),Jb=sb({Pd:Xg,wE:qb});Lg(sb({version:tb,pE:((t,e=!1)=>{if(!Sg(t))throw new Error("flag/flagValue: expected Uint8Array, got "+typeof t);if("boolean"!=typeof e)throw new Error("flag/xor: expected boolean, got "+typeof e);return Zg({size:t.length,IT:(n,r)=>{!!r!==e&&n.bytes(t)},kT:n=>{let r=n.MT>=t.length;return r&&(r=Ug(n.bytes(t.length,!0),t),r&&n.bytes(t.length)),r!==e},validate:t=>{if(void 0!==t&&"boolean"!=typeof t)throw new Error("flag: expected boolean value or undefined, got "+typeof t);return t}})})(new Uint8Array([0,1])),inputs:zb(Xb),outputs:zb(Jb),yE:function(t,e){if(!Yg(e))throw new Error(`flagged: invalid inner value ${e}`);return Zg({IT:(n,r)=>{Wg.resolve(n.stack,t)&&e.IT(n,r)},kT:n=>{let r=!1;if(r=!!Wg.resolve(n.stack,t),r)return e.kT(n)}})}("segwitFlag",ab("inputs/length",Yb)),gE:Qg}),function(t){if(t.pE&&t.yE&&!t.yE.length)throw new Error("Segwit flag with empty witnesses array");return t}),sb({version:tb,inputs:zb(Xb),outputs:zb(Jb),gE:Qg});function Qb(t,e){try{return function(t,e){const n=t.length;if(e===hb){if(32===n)throw new Error("Expected non-Schnorr key");return cb.hh(t),t}if(e===fb){if(32!==n)throw new Error("Expected 32-byte Schnorr key");return ig.Bk.mT(Pp(t)),t}throw new Error("Unknown key type")}(t,e),!0}catch(t){return!1}}const tm=[{encode(t){if(2===t.length&&1===t[0]&&lb(t[1])&&"4e73"===Db.encode(t[1]))return{type:"p2a",wE:jb.encode(t)}},decode:t=>{if("p2a"===t.type)return[1,Db.decode("4e73")]}},{encode(t){if(2===t.length&&lb(t[0])&&Qb(t[0],hb)&&"CHECKSIG"===t[1])return{type:"pk",bE:t[0]}},decode:t=>"pk"===t.type?[t.bE,"CHECKSIG"]:void 0},{encode(t){if(5===t.length&&"DUP"===t[0]&&"HASH160"===t[1]&&lb(t[2])&&"EQUALVERIFY"===t[3]&&"CHECKSIG"===t[4])return{type:"pkh",hash:t[2]}},decode:t=>"pkh"===t.type?["DUP","HASH160",t.hash,"EQUALVERIFY","CHECKSIG"]:void 0},{encode(t){if(3===t.length&&"HASH160"===t[0]&&lb(t[1])&&"EQUAL"===t[2])return{type:"sh",hash:t[1]}},decode:t=>"sh"===t.type?["HASH160",t.hash,"EQUAL"]:void 0},{encode(t){if(2===t.length&&0===t[0]&&lb(t[1])&&32===t[1].length)return{type:"wsh",hash:t[1]}},decode:t=>"wsh"===t.type?[0,t.hash]:void 0},{encode(t){if(2===t.length&&0===t[0]&&lb(t[1])&&20===t[1].length)return{type:"wpkh",hash:t[1]}},decode:t=>"wpkh"===t.type?[0,t.hash]:void 0},{encode(t){const e=t.length-1;if("CHECKMULTISIG"!==t[e])return;const n=t[0],r=t[e-1];if("number"!=typeof n||"number"!=typeof r)return;const i=t.slice(1,-2);if(r===i.length){for(const t of i)if(!lb(t))return;return{type:"ms",mE:n,vE:i}}},decode:t=>"ms"===t.type?[t.mE,...t.vE,t.vE.length,"CHECKMULTISIG"]:void 0},{encode(t){if(2===t.length&&1===t[0]&&lb(t[1]))return{type:"tr",bE:t[1]}},decode:t=>"tr"===t.type?[1,t.bE]:void 0},{encode(t){const e=t.length-1;if("CHECKSIG"!==t[e])return;const n=[];for(let r=0;r<e;r++){const i=t[r];if(1&r){if("CHECKSIGVERIFY"!==i||r===e-1)return}else{if(!lb(i))return;n.push(i)}}return{type:"tr_ns",vE:n}},decode:t=>{if("tr_ns"!==t.type)return;const e=[];for(let n=0;n<t.vE.length-1;n++)e.push(t.vE[n],"CHECKSIGVERIFY");return e.push(t.vE[t.vE.length-1],"CHECKSIG"),e}},{encode(t){const e=t.length-1;if("NUMEQUAL"!==t[e]||"CHECKSIG"!==t[1])return;const n=[],r=function(t,e=4,n=!0){if("number"==typeof t)return t;if(lb(t))try{const r=Hb(e,n).decode(t);if(r>Number.MAX_SAFE_INTEGER)return;return Number(r)}catch(t){return}}(t[e-1]);if("number"==typeof r){for(let r=0;r<e-1;r++){const e=t[r];if(1&r){if(e!==(1===r?"CHECKSIG":"CHECKSIGADD"))throw new Error("OutScript.encode/tr_ms: wrong element")}else{if(!lb(e))throw new Error("OutScript.encode/tr_ms: wrong key element");n.push(e)}}return{type:"tr_ms",vE:n,mE:r}}},decode:t=>{if("tr_ms"!==t.type)return;const e=[t.vE[0],"CHECKSIG"];for(let n=1;n<t.vE.length;n++)e.push(t.vE[n],"CHECKSIGADD");return e.push(t.mE,"NUMEQUAL"),e}},{encode:t=>({type:"unknown",wE:jb.encode(t)}),decode:t=>"unknown"===t.type?jb.decode(t.wE):void 0}],em=Lg(ib(jb,zg.match(tm)),t=>{if("pk"===t.type&&!Qb(t.bE,hb))throw new Error("OutScript/pk: wrong key");if(!("pkh"!==t.type&&"sh"!==t.type&&"wpkh"!==t.type||lb(t.hash)&&20===t.hash.length))throw new Error(`OutScript/${t.type}: wrong hash`);if("wsh"===t.type&&(!lb(t.hash)||32!==t.hash.length))throw new Error("OutScript/wsh: wrong hash");if(!("tr"!==t.type||lb(t.bE)&&Qb(t.bE,fb)))throw new Error("OutScript/tr: wrong taproot public key");if(("ms"===t.type||"tr_ns"===t.type||"tr_ms"===t.type)&&!Array.isArray(t.vE))throw new Error("OutScript/multisig: wrong pubkeys array");if("ms"===t.type){const e=t.vE.length;for(const e of t.vE)if(!Qb(e,hb))throw new Error("OutScript/multisig: wrong pubkey");if(t.mE<=0||e>16||t.mE>e)throw new Error("OutScript/multisig: invalid params")}if("tr_ns"===t.type||"tr_ms"===t.type)for(const e of t.vE)if(!Qb(e,fb))throw new Error(`OutScript/${t.type}: wrong pubkey`);if("tr_ms"===t.type){const e=t.vE.length;if(t.mE<=0||e>999||t.mE>e)throw new Error("OutScript/tr_ms: invalid params")}return t}),nm=(t,e=db)=>{if(!Qb(t,hb))throw new Error("P2PKH: invalid publicKey");const n=mg(Ip(t));return{type:"pkh",wE:em.encode({type:"pkh",hash:n}),address:am(e).encode({type:"pkh",hash:n}),hash:n}},rm=(t=>kb(function(t,e){return bb(t),yb(e),{encode(n){if(!wb(n))throw new Error("checksum.encode: input should be Uint8Array");const r=e(n).slice(0,t),i=new Uint8Array(n.length+t);return i.set(n),i.set(r,n.length),i},decode(n){if(!wb(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-t),i=n.slice(-t),o=e(r).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return r}}}(4,e=>t(t(e))),Ub))(Ip);function im(t,e){if(e.length<2||e.length>40)throw new Error("Witness: invalid length");if(t>16)throw new Error("Witness: invalid version");if(0===t&&20!==e.length&&32!==e.length)throw new Error("Witness: invalid length for version")}function om(t,e,n=db){im(t,e);const r=0===t?Ob:Fb;return r.encode(n.rA,[t].concat(r.hA(e)))}function sm(t,e){return rm.encode(ub(Uint8Array.from(e),t))}function am(t=db){return{encode(e){const{type:n}=e;if("wpkh"===n)return om(0,e.hash,t);if("wsh"===n)return om(0,e.hash,t);if("tr"===n)return om(1,e.bE,t);if("pkh"===n)return sm(e.hash,[t.Zk]);if("sh"===n)return sm(e.hash,[t.iA]);throw new Error(`Unknown address type=${n}`)},decode(e){if(e.length<14||e.length>74)throw new Error("Invalid address length");if(t.rA&&e.toLowerCase().startsWith(`${t.rA}1`)){let n;try{if(n=Ob.decode(e),0!==n.gT[0])throw new Error(`bech32: wrong version=${n.gT[0]}`)}catch(t){if(n=Fb.decode(e),0===n.gT[0])throw new Error(`bech32m: wrong version=${n.gT[0]}`)}if(n.prefix!==t.rA)throw new Error(`wrong bech32 prefix=${n.prefix}`);const[r,...i]=n.gT,o=Ob.lA(i);if(im(r,o),0===r&&32===o.length)return{type:"wsh",hash:o};if(0===r&&20===o.length)return{type:"wpkh",hash:o};if(1===r&&32===o.length)return{type:"tr",bE:o};throw new Error("Unknown witness program")}const n=rm.decode(e);if(21!==n.length)throw new Error("Invalid base58 address");if(n[0]===t.Zk)return{type:"pkh",hash:n.slice(1)};if(n[0]===t.iA)return{type:"sh",hash:n.slice(1)};throw new Error(`Invalid address prefix=${n[0]}`)}}}const cm={ws:{Zk:76,iA:16,rA:"dc",oA:204,Hk:76066276,jk:76067358},ds:{Zk:140,iA:19,rA:"dc",oA:239,Hk:70615956,jk:70617039}};class lm{IE(t,e){return function(t,e){return Ww(t,e)}(t,e)}kE(t,e="mainnet"){return Kw.tT(t,cm[e])}async cT(t,e){return function(t,e){return t.cT(e)}(t,e)}async TE(t,e){return _w(t,e)}AE(t,e,n,r){return _w(t,`m/9'/${"mainnet"===r?5:1}'${`/5'/0'/0'/${e}'/${n}'`}`)}BE(t,e){return nm(t,cm[e]).address}}async function um(t,e,n,r){const i=Ze.create({version:{Tt:"v0",wr:{Qr:null!=r?Rt.create({value:r}):void 0,count:e,Jr:n,pr:!0}}}),{response:o}=await t.Ts().Xo(i),{version:s}=o;if("v0"!==s.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:a}=s;if("proof"!==a.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:c},metadata:l}=a;if(null==l)throw new Error("Metadata not found");const{hb:u,EE:h}=function(t,e,n,r,i,o){const s=Qs.ru.Zs(t,e,n,r,i??!1,Ta(o));return{hb:s.hb,EE:s.EE.map(t=>({index:t.index,RE:BigInt(t.RE),ni:BigInt(t.ni),ri:t.ri,PE:BigInt(t.PE),ur:t.ur}))}}(c.nr,l.cr,r,e,n,pl),f=await Hc(t.Ui,c.sr,jc(c.rr));if(!await dl(c,l,u,f))throw new Error("Failed to verify query");return h.map(t=>({number:t.index,ni:t.ni,ri:t.ri,startTime:t.RE,ii:t.PE,ur:t.ur}))}async function hm(t){const e=wn.create({version:{Tt:"v0",wr:{pr:!0}}}),{response:n}=await t.Ts().ts(e),{version:r}=n;if("v0"!==r.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:i}=r;if("proof"!==i.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:o},metadata:s}=i;if(null==s)throw new Error("Metadata not found");const a="testnet"===t.Ui?1066900:2128896,{hb:c,xE:l}=function(t,e,n,r,i){const o=Qs.ru.ca(t,e,n,r,Ta(i));return{hb:o.hb,xE:BigInt(o.xE)}}(o.nr,210240,a,Number(s.height),pl),u=await Hc(t.Ui,o.sr,jc(o.rr));if(!await dl(o,s,c,u))throw new Error("Failed to verify query");return l}class fm{kb;constructor(t){this.kb=t}async status(){return await async function(t){const e=bn.create({version:{Tt:"v0",wr:{}}}),{response:n}=await t.Ts().es(e),{version:r}=n;if("v0"!==r.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:i}=r;return{node:null!=i.node?{id:jc(i.node.id),ji:null!=i.node.ji?jc(i.node.ji):void 0}:void 0,chain:null!=i.chain?{Mi:i.chain.Mi,qi:i.chain.qi,Xi:i.chain.Xi,Ji:i.chain.Ji,ar:i.chain.ar,Li:null!=i.chain?.Li?jc(i.chain?.Li):"",Zi:null!=i.chain?.Zi?jc(i.chain?.Zi):"",Yi:null!=i.chain?.Yi?jc(i.chain?.Yi):"",zi:null!=i.chain?.zi?jc(i.chain?.zi):""}:void 0,version:i.version,Ui:i.Ui,Si:i.Si,time:i.time}}(this.kb)}async xE(){return await hm(this.kb)}async Xo(t,e,n){return await um(this.kb,t,e,n)}}function dm(t){return/^[a-zA-Z01-]{3,19}$/.test(t)}async function wm(t,e,n,r){const[i]=n.Rf().filter(t=>t.rf()===r.rf());if(null==i)throw new Error("Private key does not match the identity");if("HIGH"!==i.wf&&"AUTHENTICATION"!==i.Or)throw new Error("Wrong private key, must be from AUTHENTICATION HIGH identity public key");const[o,s]=e.split("."),a=function(t){const e=Uint8Array.from({length:t});return crypto.getRandomValues(e)}(32),c=Ph(s),l=Ph(o),u=`${l}.${c}`,h=await Mc(await Mc(new Uint8Array([...a,...(new TextEncoder).encode(u)])));let f,d;const w={NE:Array.from(h)},p=await gl(t,n.id,wl);f=zl(wl,"preorder",w,n.id.gh()),d=Jl(f,"create",{vr:p+BigInt(1)}),await d.sign(r,i),await ql(t,d),await Ll(t,d);const y={label:o,$E:l,UE:s,SE:c,CE:Array.from(a),GE:{identity:Array.from(n.id.bytes())},VE:{KE:!1}};f=zl(wl,"domain",y,n.id.gh()),d=Jl(f,"create",{vr:p+BigInt(2),bg:dm(l)?new gc("parentNameAndLabel",BigInt(2e10)):void 0}),await d.sign(r,i),await ql(t,d)}function pm(t){const e=t.split(".");if(2!==e.length)return"Name to search should be a full domain name (ex. pshenmic.dash)";const[n,r]=e;return"dash"!==r?"Root domain must be .dash":/^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$/.test(n)?null:"Unacceptable label name"}class ym{kb;constructor(t){this.kb=t}async OE(t){const e=pm(t);if(null!=e)throw new Error(e);return await async function(t,e){const[n,r]=e.split("."),i=[["normalizedParentDomainName","==",Ph(r)],["normalizedLabel","startsWith",Ph(n)]];return await Eh(t,"GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec","domain",i,[["normalizedLabel","asc"]])}(this.kb,t)}FE(t){const e=pm(t);if(null!=e)throw new Error(e);const[n]=t.split(".");return dm(Ph(n))}async DE(t){return await async function(t,e){return await Eh(t,"GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec","domain",[["records.identity","=",e.gh()]],[["records.identity","asc"]])}(this.kb,new ga(t))}async WE(t,e,n){const r=pm(t);if(null!=r)throw new Error(r);const i=await Tl(this.kb,e);await wm(this.kb,t,i,n)}_E(t){return Ph(t)}HE(t){return pm(t)}}var gm;!function(t){t[t.cu=0]="Create",t[t.jE=1]="Update"}(gm||(gm={}));const bm={create:fc,update:dc};class mm{kb;constructor(t){this.kb=t}create(t,e,n,r,i,o,s){return function(t,e,n,r,i,o,s){const a=new ga(t),c=new hc(a,e,n,void 0,r,o??!0,s??pl);return null!=i&&c.ky(i,s),c}(t,e,n,i,o,r,s)}async ME(t){return await Ml(this.kb,t)}Bb(t,e,n){return function(t,e,n){const r=bm[e];if(null==r)throw new Error(`Unknown DataContract transition type: ${e}. Should be 'create' or 'update'.`);return new r(t,n).pd()}(t,e,n)}}async function vm(t,e,n,r,i,o,s,a,c){null!=a&&(a={yi:new ga(a.yi).bytes(),gi:a.gi});const l=sn.create({version:{Tt:"v0",wr:{gr:e.id.bytes(),Vr:n,oi:r,di:i,resultType:o,wi:s,pi:a,count:c,pr:!0}}}),{response:u}=await t.Ts().Qo(l),{version:h}=u;if("v0"!==h.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:f}=h;if("proof"!==f.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:d},metadata:w}=f;if(null==w)throw new Error("Metadata not found");const{hb:p,result:y}=function(t,e,n,r,i,o,s,a,c,l){const u=Qs.ru.la(t,e.wy,n,r,i,Ta(o),s??!1,a,Ta(c),Ta(l)),h=Aa(u.result.LE),f=h?.ZE,d=null!=h?{type:h.type,yr:h.yr,ZE:{height:BigInt(f.height),xb:f.xb,lr:BigInt(f.lr),cr:null!=f.cr?f?.cr:void 0}}:void 0;return{hb:u.hb,result:{qE:u.result.qE??void 0,Ei:u.result.Ei.map(t=>({yr:ga.rh(t.yr),YE:t.YE??void 0,zE:t.zE??void 0})),XE:u.result.XE??void 0,LE:d,skipped:u.result.skipped}}}(d.nr,e,n,r,i,o,s,c,a,pl),g=await Hc(t.Ui,d.sr,jc(d.rr));if(!await dl(d,w,p,g))throw new Error("Failed to verify query");const{Ei:b}=y??{Ei:[]},{LE:m}=y??{LE:void 0};if(0===b.length)throw new Error("Vote state not found");return{Ei:b.map(t=>({identifier:t.yr,document:null!=t.YE?wc.hh(t.YE,e,n,pl):void 0,zE:t.zE})),Ri:y?.XE??0,Pi:y?.qE??0,skipped:1===y?.skipped,xi:null!=m?{type:m.type,Bi:"yr"in m&&null!=m.yr?new ga(m.yr):void 0,Ii:m.ZE.height,ki:m.ZE.xb,Ti:m.ZE.lr,Ai:m.ZE.cr}:void 0}}class Im{kb;constructor(t){this.kb=t}async Qo(t,e,n,r,i,o,s,a){return await vm(this.kb,t,e,n,r,i,o,s,a)}}async function km(t,e,n){const r=e.map(t=>new ga(t)),i=new ga(n),o=On.create({version:{Tt:"v0",wr:{fo:i.bytes(),do:r.map(t=>t.bytes()),pr:!0}}}),{response:s}=await t.Ts().rs(o),{version:a}=s;if("v0"!==a.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:c}=a;if("proof"!==c.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:l},metadata:u}=c;if(null==u)throw new Error("Metadata not found");const{hb:h,JE:f}=function(t,e,n,r,i){const o=Qs.ru.ra(t,Ba(e),n,r.map(Ba),Ta(i));return{hb:o.hb,JE:o.JE.map(t=>({balance:null!=t.balance?BigInt(t.balance):void 0,id:ga.rh(t.id)}))}}(l.nr,i,!0,r,pl),d=await Hc(t.Ui,l.sr,jc(l.rr));if(!await dl(l,u,h,d))throw new Error("Failed to verify query");return f.map(({id:t,balance:e})=>({yr:new ga(t),balance:e}))}async function Tm(t,e,n){const r=new ga(e),i=n.map(t=>new ga(t)),o=Un.create({version:{Tt:"v0",wr:{uo:i.map(t=>t.bytes()),yr:r.bytes(),pr:!0}}}),{response:s}=await t.Ts().ns(o),{version:a}=s;if("v0"!==a.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:c}=a;if("proof"!==c.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:l},metadata:u}=c;if(null==u)throw new Error("Metadata not found");const{hb:h,JE:f}=function(t,e,n,r,i){const o=Qs.ru.sa(t,e.map(Ba),Ba(n),r,Ta(i));return{hb:o.hb,JE:o.JE.map(t=>({balance:null!=t.balance?BigInt(t.balance):void 0,id:ga.rh(t.id)}))}}(l.nr,i,r,!0,pl),d=await Hc(t.Ui,l.sr,jc(l.rr));if(!await dl(l,u,h,d))throw new Error("Failed to verify query");return f.map(({id:t,balance:e})=>({fo:new ga(t),balance:e}))}async function Am(t,e){const n=new ga(e),r=jn.create({version:{Tt:"v0",wr:{fo:n.bytes(),pr:!0}}}),{response:i}=await t.Ts().ss(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,QE:u}=function(t,e,n,r){const i=Qs.ru.ia(t,Ba(e),n,Ta(r));return{hb:i.hb,QE:null!=i.QE?{gr:ga.rh(i.QE.gr),po:i.QE.po}:void 0}}(a.nr,n,!0,pl);if(null==u)throw new Error("ContractInfo not found");const h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return{_r:u.gr,po:u.po}}async function Bm(t,e){const n=new ga(e),r=rr.create({version:{Tt:"v0",wr:{fo:n.bytes(),pr:!0}}}),{response:i}=await t.Ts().ls(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,tR:u}=function(t,e,n,r){const i=Qs.ru.aa(t,Ba(e),n,Ta(r));return{hb:i.hb,tR:{eR:BigInt(i.tR.eR),nR:BigInt(i.tR.nR)}}}(a.nr,n,!0,pl),h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return{fo:n,Eo:u.eR,Bo:u.nR}}const Em={rR:{wb:Nc,arguments:["amount","publicNote"],pb:["publicNote"]},iR:{wb:Gc,arguments:["identityId","amount","publicNote"],pb:["publicNote"]},transfer:{wb:Vc,arguments:["identityId","amount","publicNote","sharedEncryptedNote","privateEncryptedNote"],pb:["publicNote","sharedEncryptedNote","privateEncryptedNote"]},freeze:{wb:Cc,arguments:["identityId","publicNote"],pb:["publicNote"]},oR:{wb:Kc,arguments:["identityId","publicNote"],pb:["publicNote"]},sR:{wb:Uc,arguments:["identityId","publicNote"],pb:["publicNote"]},Ug:{wb:Sc,arguments:["emergencyAction","publicNote"],pb:["publicNote"]},aR:{wb:Pc,arguments:["amount","totalAgreedPrice"],pb:[]},cR:{wb:xc,arguments:["price","publicNote"],pb:["publicNote"]}};async function Rm(t,e){const n=e.map(t=>new ga(t).bytes()),r=Yn.create({version:{Tt:"v0",wr:{uo:n,pr:!0}}}),{response:i}=await t.Ts().cs(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,lR:u}=function(t,e,n,r){const i=Qs.ru.oa(t,e.map(Ba),n,Ta(r));return{hb:i.hb,lR:i.lR.map(t=>({fo:ga.rh(t.id),Xg:null!=t.Xg?Bc.rh(t.Xg):void 0}))}}(a.nr,n,!0,pl);if(null==u)throw new Error("Prices not found");const h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return u}class Pm{kb;constructor(t){this.kb=t}async rs(t,e){return await km(this.kb,t,e)}async uR(t,e){return await Tm(this.kb,t,e)}async ss(t){return await Am(this.kb,t)}async ls(t){return await Bm(this.kb,t)}async hR(t){return await Rm(this.kb,t)}async fR(t,e){const{_r:n,po:r}=await Am(this.kb,t),i=await gl(this.kb,e,n);return new Ec(i+BigInt(1),r,n,t,void 0)}Bb(t,e,n,r){const i=new ga(e);return null!=r.yr&&(r.yr=new ga(r.yr)),null!=r.mo&&"bigint"==typeof r.mo&&(r.mo=Bc.Ig(r.mo)),function(t,e,n,r){const{wb:i,arguments:o,pb:s}=Em[n];if(null==i)throw new Error(`Unimplemented transition type: ${n}`);const[a]=o.filter(t=>null==r[t]&&!s.includes(t));if(null!=a)throw new Error(`Token transition param "${a}" is missing`);const c=new i(t,...o.map(t=>r[t])),l=new Oc(c),u=new Fc(l);return Dc.jg([u],e,1).pd()}(t,i,n,r)}}class xm{async dR(t,e){return await xh(t,e)}wR(t,e,n,r,i){let o;return o="lock"===i?ja.Lock():"abstain"===i?ja.Vd():ja.Gd(new ga(i)),function(t,e,n,r,i){const o=new Ma(t,e,n,r);return new La(o,i)}(new ga(t),e,n,r,o)}Bb(t,e,n,r){return new Za(ga.fromHex(e),new ga(n),t,r).pd()}}async function Nm(t,e){const n=new ka(e),r=wr.create({version:{Tt:"v0",wr:{address:n.bytes(),pr:!0}}}),{response:i}=await t.Ts().hs(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,address:u,nonce:h,balance:f}=function(t,e,n,r){const i=Qs.ru.js(t,Ea(e),n,Ta(r));return{hb:i.hb,address:null!=i.address?ka.rh(i.address):void 0,balance:null!=i.balance?BigInt(i.balance):void 0,nonce:i.nonce}}(a.nr,n,!0,pl);if(null==u||null==h||null==f)throw new Error(`Failed to fetch info for address ${n.Wh(t.Ui)}`);const d=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,d))throw new Error("Failed to verify query");return{address:u,nonce:h,balance:f}}async function $m(t,e){const n=e.map(t=>new ka(t)),r=vr.create({version:{Tt:"v0",wr:{So:n.map(t=>t.bytes()),pr:!0}}}),{response:i}=await t.Ts().fs(r),{version:o}=i;if("v0"!==o.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be v0)");const{wr:s}=o;if("proof"!==s.result.Tt)throw new Error("Unexpected oneOf type returned from DAPI (must be proof)");const{result:{br:a},metadata:c}=s;if(null==c)throw new Error("Metadata not found");const{hb:l,tb:u}=function(t,e,n,r){const i=Qs.ru.Hs(t,e.map(Ea),n,Ta(r));return{hb:i.hb,tb:i.tb.map(({nonce:t,$i:e,address:n})=>({nonce:t,balance:null!=e?BigInt(e):void 0,address:ka.rh(n)}))}}(a.nr,n,!0,pl),h=await Hc(t.Ui,a.sr,jc(a.rr));if(!await dl(a,c,l,h))throw new Error("Failed to verify query");return u.map(t=>({address:t.address,nonce:t.nonce??0,balance:BigInt(t.balance??0)}))}class Um{kb;constructor(t){this.kb=t}async hs(t){return await Nm(this.kb,t)}async fs(t){return await $m(this.kb,t)}}t.t=class{Ui;kb;options;pR;yR;gR;bR;mR;qr;vR;IR;by;Bk;names;node;constructor(t){if(null!=t&&(null==t.Ui||!["testnet","mainnet"].includes(t.Ui)))throw new Error("If options is passed, network must be set (either mainnet or testnet)");this.Ui=t?.Ui??"mainnet",this.options=t,this.Bk=new Nh,null!=t?.bs&&null==t?.kR&&(this.options.kR={bs:t.bs}),this.kb=new xr(this.Ui,this.options?.kR),this.gs(this.kb)}gs(t){this.kb=t,this.pR=new Im(t),this.yR=new Um(t),this.gR=new Yl(t),this.bR=new mm(t),this.mR=new jl(t),this.qr=new Rh(t),this.IR=new xm,this.node=new fm(t),this.by=new Pm(t),this.names=new ym(t),this.vR=new lm}af(){return this.Ui}TR(t){if("testnet"!==t&&"mainnet"!==t)throw new Error("Unknown network, should be mainnet or testnet");this.Ui=t;const e=new xr(this.Ui,this.options?.kR);this.gs(e)}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-platform-sdk",
3
- "version": "1.4.0-dev.8",
3
+ "version": "1.4.0-dev.9",
4
4
  "main": "index.js",
5
5
  "description": "Lightweight SDK for accessing Dash Platform blockchain",
6
6
  "ts-standard": {
@@ -66,7 +66,7 @@ export default async function getContestedResourceVoteState(grpcPool, contract,
66
66
  finishedVoteInfo: (winner != null)
67
67
  ? {
68
68
  type: winner.type,
69
- wonByIdentityId: 'identityId' in winner ? new IdentifierWASM(winner.identityId) : undefined,
69
+ wonByIdentityId: 'identityId' in winner && winner.identityId != null ? new IdentifierWASM(winner.identityId) : undefined,
70
70
  finishedAtBlockHeight: winner.blockInfo.height,
71
71
  finishedAtCoreBlockHeight: winner.blockInfo.coreHeight,
72
72
  finishedAtBlockTimeMs: winner.blockInfo.timeMs,