ontology-ts-sdk
Version:
Comprehensive TypeScript library for the Ontology blockchain.
1 lines • 1.84 MB
JavaScript
var Ont=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=440)}([function(t,e,r){"use strict";r.r(e),function(t){r.d(e,"hexstring2ab",(function(){return M})),r.d(e,"ab2hexstring",(function(){return _})),r.d(e,"ab2str",(function(){return S})),r.d(e,"str2ab",(function(){return E})),r.d(e,"str2hexstr",(function(){return x})),r.d(e,"hexstr2str",(function(){return A})),r.d(e,"hex2VarBytes",(function(){return k})),r.d(e,"str2VarBytes",(function(){return R})),r.d(e,"bool2VarByte",(function(){return I})),r.d(e,"hexXor",(function(){return B})),r.d(e,"num2hexstring",(function(){return O})),r.d(e,"num2VarInt",(function(){return T})),r.d(e,"reverseHex",(function(){return P})),r.d(e,"bigIntFromBytes",(function(){return C})),r.d(e,"bigIntToBytes",(function(){return N})),r.d(e,"StringReader",(function(){return j})),r.d(e,"EventEmitter",(function(){return U})),r.d(e,"sendBackResult2Native",(function(){return D})),r.d(e,"axiosPost",(function(){return L})),r.d(e,"now",(function(){return F})),r.d(e,"sha256",(function(){return z})),r.d(e,"ripemd160",(function(){return G})),r.d(e,"hash160",(function(){return V})),r.d(e,"generateRandomArray",(function(){return q})),r.d(e,"randomBytes",(function(){return H})),r.d(e,"generateMnemonic",(function(){return K})),r.d(e,"parseMnemonic",(function(){return W})),r.d(e,"varifyPositiveInt",(function(){return Y})),r.d(e,"isBase64",(function(){return Z})),r.d(e,"isHexString",(function(){return X})),r.d(e,"unboundDeadline",(function(){return J})),r.d(e,"calcUnboundOng",(function(){return $})),r.d(e,"needUseFetch",(function(){return Q}));var n=r(5),i=r.n(n),o=r(3),a=r.n(o),s=r(4),u=r.n(s),h=r(433),c=r.n(h),f=r(17),l=r.n(f),d=r(22),p=r(82),m=r(199),v=r(19),g=r(287),y=r(207),b=r(16),w=r(7);function M(t){for(var e=[];t.length>=2;)e.push(parseInt(t.substring(0,2),16)),t=t.substring(2,t.length);return e}function _(t){for(var e="",r=new Uint8Array(t),n=0;n<r.byteLength;n++){var i=r[n].toString(16);e+=i=0===i.length?"00":1===i.length?"0"+i:i}return e}function S(t){var e,r=void 0,n=void 0,i=void 0,o=void 0,a=void 0;r="";var s=new Uint8Array(t);for(e=s.length,n=0;n<e;)switch((i=s[n++])>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r+=String.fromCharCode(i);break;case 12:case 13:o=s[n++],r+=String.fromCharCode((31&i)<<6|63&o);break;case 14:o=s[n++],a=s[n++],r+=String.fromCharCode((15&i)<<12|(63&o)<<6|(63&a)<<0)}return r}function E(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|63&n):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&t.charCodeAt(r)),e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return Uint8Array.from(e)}function x(t){return _(E(t))}function A(t){return S(M(t))}function k(t){var e="";return e+=T(t.length/2),e+=t}function R(t){var e="",r=x(t);return e+=T(r.length/2),e+=r}function I(t){return t?"01":"00"}function B(t,e){if(t.length!==e.length)throw new Error("strings are disparate lengths");if(t.length%2!=0)throw new Error("strings must be hex");for(var r=new ArrayBuffer(t.length/2),n=new Uint8Array(r),i=0;i<t.length;i+=2)n[i/2]=parseInt(t.substr(i,2),16)^parseInt(e.substr(i,2),16);return _(r)}var O=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t<0)throw new RangeError("num must be >=0");if(e%1!=0)throw new Error("size must be a whole integer");if(!c()(t))throw new RangeError("num ("+t+") must be a safe integer");e*=2;var n=t.toString(16);return n=n.length%e==0?n:("0".repeat(e)+n).substring(n.length),r&&(n=P(n)),n},T=function(t){return t<253?O(t):t<=65535?"fd"+O(t,2,!0):t<=4294967295?"fe"+O(t,4,!0):"ff"+O(t,8,!0)},P=function(t){if(t.length%2!=0)throw new Error("Incorrect Length: "+t);for(var e="",r=t.length-2;r>=0;r-=2)e+=t.substr(r,2);return e};function C(e){var r=t.from(e,"hex").reverse();return 0===r.length?"0":new m(r).fromTwos(8*r.length).toString()}function N(e){var r=e instanceof d.BigNumber?g(e):g(new d.BigNumber(e));if(r.isZero())return"";var n=r.toTwos(8*r.byteLength()).toArray();return r.isNeg()?n[0]<128&&n.unshift(255):n[0]>=128&&n.unshift(0),t.from(n.reverse()).toString("hex")}var j=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(a()(this,t),e.length%2!=0)throw new Error("Param's length is not even.");this.str=e,this.pos=0,this.size=this.str.length/2}return u()(t,[{key:"isEmpty",value:function(){return this.pos>=this.str.length}},{key:"read",value:function(t){if(this.isEmpty())throw new Error("StringReader reached the end.");var e=this.str.substr(this.pos,2*t);return this.pos+=2*t,e}},{key:"unreadBytes",value:function(t){if(this.pos-2*t<0)throw new Error("Can not unread too many bytes.");this.pos-=2*t}},{key:"readNullTerminated",value:function(){var t=this.str.indexOf("00",this.pos);if(-1===t)throw new Error("No ending NULL found");var e=this.str.substring(this.pos,t);return this.pos=t+2,e}},{key:"readNextByte",value:function(){return this.read(1)}},{key:"readNextBytes",value:function(){var t=this.readNextLen();return 0===t?"":this.read(t)}},{key:"readNextLen",value:function(){var t=parseInt(this.read(1),16);return 253===t?t=parseInt(P(this.read(2)),16):254===t?t=parseInt(P(this.read(4)),16):255===t&&(t=parseInt(P(this.read(8)),16)),t}},{key:"readVarUint",value:function(){return this.readNextLen()}},{key:"readUint8",value:function(){return parseInt(P(this.read(1)),16)}},{key:"readUint16",value:function(){return parseInt(P(this.read(2)),16)}},{key:"readUint32",value:function(){return parseInt(P(this.read(4)),16)}},{key:"readUint64",value:function(){return parseInt(P(this.read(8)),16)}},{key:"readUint128",value:function(){return parseInt(P(this.read(16)),16)}},{key:"readInt",value:function(){return parseInt(P(this.read(4)),16)}},{key:"readLong",value:function(){return parseInt(P(this.read(8)),16)}},{key:"readBoolean",value:function(){return 0!==parseInt(this.read(1),16)}},{key:"readH256",value:function(){return this.read(32)}}]),t}(),U=function(){function t(){a()(this,t),this.handlers={}}return u()(t,[{key:"on",value:function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e)}},{key:"trigger",value:function(t,e){if(this.handlers[t]instanceof Array)for(var r=this.handlers[t],n=0,i=r.length;n<i;n++)r[n](e)}},{key:"off",value:function(t){delete this.handlers[t]}}]),t}(),D=function(t,e){window&&window.prompt&&window.prompt(b.WEBVIEW_SCHEME+"://"+e+"?params="+t)},L=function(t,e){return l.a.post(t,e).then((function(t){return console.log("axios res:"+t),t})).catch((function(t){return console.log("axios res:"+i()(t)),t}))};function F(){return Math.floor(Date.now()/1e3)}function z(t){var e=v.enc.Hex.parse(t);return v.SHA256(e).toString()}function G(t){var e=v.enc.Hex.parse(t);return v.RIPEMD160(e).toString()}function V(t){return G(z(t))}function q(t){try{return y(t)}catch(r){var e=new Uint8Array(t);return crypto.getRandomValues(e),[].slice.call(e)}}function H(t){return _(q(t))}function K(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,e=_(q(t));return p.entropyToMnemonic(e)}function W(t){return p.mnemonicToEntropy(t)}function Y(t){if(!/^[1-9]\d*$/.test(t.toString()))throw w.a.INVALID_PARAMS}function Z(e){return t.from(e,"base64").toString("base64")===e}function X(t){return/^[0-9a-fA-F]+$/.test(t)&&t.length%2==0}function J(){var t=Math.floor(Date.UTC(2018,5,30,0,0,0)/1e3);return Math.floor(Date.UTC(2020,6,7,0,0,0)/1e3)-t}function $(t,e,r){var n=0;if(e>=r)return 0;var i=J();if(e<i){var o=Math.floor(e/b.UNBOUND_TIME_INTERVAL),a=e%b.UNBOUND_TIME_INTERVAL;r>=i&&(r=i);for(var s=Math.floor(r/b.UNBOUND_TIME_INTERVAL),u=r%b.UNBOUND_TIME_INTERVAL;o<s;)n+=(b.UNBOUND_TIME_INTERVAL-a)*b.UNBOUND_GENERATION_AMOUNT[o],o++,a=0;n+=(u-a)*b.UNBOUND_GENERATION_AMOUNT[o]}return n*t}function Q(){var t=!1;try{new XMLHttpRequest}catch(e){try{fetch;t=!0}catch(t){}}return t}}.call(this,r(29).Buffer)},function(t,e,r){"use strict";r.r(e),r.d(e,"Address",(function(){return n.a})),r.d(e,"KeyType",(function(){return i.a})),r.d(e,"CurveLabel",(function(){return o.a})),r.d(e,"SignatureScheme",(function(){return a.a})),r.d(e,"KeyParameters",(function(){return s.b})),r.d(e,"PrivateKey",(function(){return u.a})),r.d(e,"registerKeyDeserializer",(function(){return h.b})),r.d(e,"PublicKey",(function(){return c.a})),r.d(e,"PublicKeyStatus",(function(){return c.b})),r.d(e,"Signature",(function(){return f.a})),r.d(e,"Issuer",(function(){return E})),r.d(e,"User",(function(){return x})),r.d(e,"Ecies",(function(){return O.a}));var n=r(33),i=r(41),o=r(127),a=r(18),s=r(81),u=r(201),h=r(142),c=r(50),f=r(202),l=r(31),d=r.n(l),p=r(38),m=r.n(p),v=r(39),g=r.n(v),y=r(3),b=r.n(y),w=r(4),M=r.n(w),_=r(435),S=r(0),E=function(){function t(e){b()(this,t),this.param=new A(e),this.sk=new R(this.param)}return M()(t,[{key:"GenerateSk",value:function(){return this.sk.Rand(),this.sk}},{key:"GenerateKeyPair",value:function(){this.sk=R.GenerateSk(this.param),this.pk=this.sk.GenerateIssuerPublicKey()}},{key:"SetAttributeSet",value:function(t){this.AttributeName=t,this.pk.GenerateAttr(t)}},{key:"Sign",value:function(t,e){var r=this.param.getRandBN(),n=this.param.getRandBN(),i=new this.param.ECP;i.copy(this.param.g1),i.add(this.param.PAIR.G1mul(this.pk.h0,n)),i.add(t);for(var o=0;o<this.pk.attr.length;o++)i.add(this.param.PAIR.G1mul(this.pk.h[o],e[o]));var a=new this.param.ECP,s=new this.param.BIG;s.copy(r),s.add(this.sk.value),s.invmodp(this.param.order),a=this.param.PAIR.G1mul(i,s);var u=new B(this.param);return u.Set(a,i,r,n,e),u}},{key:"GetPk",value:function(){return I.COPY(this.pk)}},{key:"GenerateNonce",value:function(){return this.param.getRandBN()}},{key:"VerifyCredentialRequest",value:function(t){return this.pk.VerifyCredentialRequest(t)}}]),t}(),x=function(){function t(e){b()(this,t),this.param=new A(e)}return M()(t,[{key:"GenerateSk",value:function(){return this.sk=R.GenerateSk(this.param),this.sk}},{key:"SetIpk",value:function(t){this.ipk=I.COPY(t)}},{key:"GenerateCrendentialRequest",value:function(t){if(void 0!==this.ipk){var e=this.ipk,r=this.param.PAIR.G1mul(e.h_sk,this.sk.value),n=this.param.getRandBN(),i=this.param.PAIR.G1mul(e.h_sk,n),o=this.param.hashToBN(i,e.h_sk,r,t),a=this.param.BIG.modmul(o,this.sk.value,this.param.order);a.add(n),a.mod(this.param.order);var s={C:o,S:a},u=this.param.genAttrBN(e.attr);return this.Nym=r,this.attrs=u,{Nym:r,pi:s,nonce:t,attrs:u}}console.log("Please set ipk first.")}},{key:"VerifyBBSplus",value:function(t){var e=new this.param.ECP2;e.copy(this.ipk.w),e.add(this.param.PAIR.G2mul(this.param.g2,t.sig.e)),e.affine();var r=new this.param.ECP;r.copy(t.sig.A),r.affine();var n=this.param.PAIR.ate(e,r);n=this.param.PAIR.fexp(n);var i=new this.param.ECP;i.copy(this.param.g1),i.add(this.param.PAIR.G1mul(this.ipk.h0,t.sig.s)),i.add(this.Nym);for(var o=0;o<t.attrs.length;o++)i.add(this.param.PAIR.G1mul(this.ipk.h[o],t.attrs[o]));i.affine();var a=this.param.PAIR.ate(this.param.g2,i);return a=this.param.PAIR.fexp(a),n.equals(a)}},{key:"SetCredential",value:function(t){return this.Cred=new B(this.param),this.Cred.Copy(t),!0}},{key:"Prove",value:function(t){var e=this.ipk,r=this.Cred,n=this.param.getRandBN(),i=this.param.PAIR.G1mul(r.sig.A,n),o=new this.param.BIG(0);o.copy(n),o.invmodp(this.param.order);var a=new this.param.BIG(0);a.copy(r.sig.e),a=this.param.BIG.modneg(a,this.param.order);var s=this.param.PAIR.G1mul(i,a);s.add(this.param.PAIR.G1mul(r.sig.B,n));var u=this.param.getRandBN(),h=new this.param.BIG(0);h.copy(u),h=this.param.BIG.modneg(h,this.param.order);var c=this.param.PAIR.G1mul(r.sig.B,n);c.add(this.param.PAIR.G1mul(e.h0,h));var f=this.param.BIG.modmul(u,o,this.param.order);(f=this.param.BIG.modneg(f,this.param.order)).add(r.sig.s),f.mod(this.param.order);for(var l=[],d=0;d<t.length;d++)0===t[d]?l[d]=this.param.getRandBN():l[d]=!1;var p=this.param.getRandBN(),m=this.param.getRandBN(),v=this.param.getRandBN(),g=this.param.getRandBN(),y=this.param.getRandBN(),b=this.param.PAIR.G1mul(e.h_sk,y),w=this.param.PAIR.G1mul(i,p);w.add(this.param.PAIR.G1mul(e.h0,m));var M=this.param.PAIR.G1mul(c,v);M.add(this.param.PAIR.G1mul(e.h0,g)),M.add(this.param.PAIR.G1mul(b,new this.param.BIG(-1)));for(var _=0;_<l.length;_++)!1!==l[_]&&M.add(this.param.PAIR.G1mul(e.h[_],l[_]));var S=this.param.hashToBN(i,s,c,this.Nym,w,M,this.param.g1,e.h0,e.h,e.w),E=this.param.getRandBN(),x=this.param.hashToBN(E,S,t,this.attrs),A=new this.param.BIG(0);A.copy(y),A.add(this.param.BIG.modmul(x,this.sk.value,this.param.order)),A.mod(this.param.order);for(var k=[],R=0;R<t.length;R++)0===t[R]?(k[R]=new this.param.BIG(0),k[R].copy(l[R]),k[R].sub(this.param.BIG.modmul(x,this.attrs[R],this.param.order)),k[R].mod(this.param.order)):k[R]=!1;var I=new this.param.BIG(0);I.copy(p),I.sub(this.param.BIG.modmul(x,r.sig.e,this.param.order)),I.mod(this.param.order);var B=new this.param.BIG(0);B.copy(m),B.add(this.param.BIG.modmul(x,u,this.param.order)),B.mod(this.param.order);var O=new this.param.BIG(0);O.copy(v),O.add(this.param.BIG.modmul(x,o,this.param.order)),O.mod(this.param.order);var T=new this.param.BIG(0);T.copy(g),T.sub(this.param.BIG.modmul(x,f,this.param.order)),T.mod(this.param.order);var P={c:x,s_sk:A,s_a:k,s_e:I,s_r2:B,s_r3:O,s_s_:T,nonce:E};return{A_:i,_A:s,B_:c,Nym:this.Nym,pi:P}}},{key:"Verify",value:function(t,e,r){var n=this.ipk,i=new this.param.ECP(0);if(t.A_.equals(i))return console.log("A' == O return true, verify failed."),!1;var o=new this.param.ECP;o.copy(t.A_);var a=new this.param.ECP2;a.copy(n.w);var s=new this.param.ECP;s.copy(t._A);var u=new this.param.ECP2;u.copy(this.param.g2),o.affine(),a.affine(),s.affine(),u.affine();var h=this.param.PAIR.ate(a,o),c=this.param.PAIR.ate(u,s);if(h=this.param.PAIR.fexp(h),c=this.param.PAIR.fexp(c),!h.equals(c))return console.log("e(A', w) == e(_A, g2) return false, verify failed."),!1;s.copy(t._A);var f=this.param.PAIR.G1mul(o,t.pi.s_e);f.add(this.param.PAIR.G1mul(n.h0,t.pi.s_r2)),s.sub(t.B_),f.add(this.param.PAIR.G1mul(s,this.param.BIG.modneg(t.pi.c,this.param.order)));var l=this.param.PAIR.G1mul(t.B_,t.pi.s_r3);l.add(this.param.PAIR.G1mul(n.h0,t.pi.s_s_)),l.add(this.param.PAIR.G1mul(n.h_sk,this.param.BIG.modneg(t.pi.s_sk,this.param.order)));var d=new this.param.ECP;d.copy(this.param.g1);for(var p=0;p<e.length;p++)0===e[p]?l.add(this.param.PAIR.G1mul(n.h[p],t.pi.s_a[p])):d.add(this.param.PAIR.G1mul(n.h[p],r[p]));l.add(this.param.PAIR.G1mul(d,this.param.BIG.modneg(t.pi.c,this.param.order)));var m=this.param.hashToBN(t.A_,t._A,t.B_,t.Nym,f,l,this.param.g1,n.h0,n.h,n.w),v=this.param.hashToBN(t.pi.nonce,m,e,r);return 0===this.param.BIG.comp(v,t.pi.c)||(console.log("c == H(nonce, H(A', _A, B', Nym, ~t1, ~t2, g1, HRand, h1, ... , hL, w), (D, I)) return false, verify failed."),!1)}}]),t}(),A=function(){function t(e){b()(this,t),this.curve=e,this.ctx=new _(e),this.PAIR=this.ctx.PAIR,this.ECP=this.ctx.ECP,this.ECP2=this.ctx.ECP2,this.BIG=this.ctx.BIG,this.rng=new this.ctx.RAND,this.g1=this.getG1Generator(),this.g2=this.getG2Generator(),this.order=this.getOrder()}return M()(t,[{key:"getG1Generator",value:function(){var t=new this.ctx.ECP(0),e=new this.ctx.BIG(0),r=new this.ctx.BIG(0);return e.rcopy(this.ctx.ROM_CURVE.CURVE_Gx),r.rcopy(this.ctx.ROM_CURVE.CURVE_Gy),t.setxy(e,r),t}},{key:"getG2Generator",value:function(){var t=new this.ctx.ECP2(0),e=new this.ctx.BIG(0),r=new this.ctx.BIG(0),n=new this.ctx.FP2(0),i=new this.ctx.FP2(0);return e.rcopy(this.ctx.ROM_CURVE.CURVE_Pxa),r.rcopy(this.ctx.ROM_CURVE.CURVE_Pxb),n.bset(e,r),e.rcopy(this.ctx.ROM_CURVE.CURVE_Pya),r.rcopy(this.ctx.ROM_CURVE.CURVE_Pyb),i.bset(e,r),t.setxy(n,i),t}},{key:"getOrder",value:function(){var t=new this.ctx.BIG(0);return t.rcopy(this.ctx.ROM_CURVE.CURVE_Order),t}},{key:"getRandBN",value:function(){var t=S.generateRandomArray(256);return this.rng.clean(),this.rng.seed(256,t),this.BIG.randomnum(this.order,this.rng)}},{key:"getRandG1",value:function(){var t=this.getRandBN();return this.PAIR.G1mul(this.g1,t)}},{key:"getRandG2",value:function(){var t=this.getRandBN();return this.PAIR.G2mul(this.g2,t)}},{key:"hashToBN",value:function(){for(var t=[],e=[],r=arguments.length,n=Array(r),i=0;i<r;i++)n[i]=arguments[i];n.forEach((function(r){Array.isArray(r)?"number"==typeof r[0]?(t=t.concat(r),e=[]):r.forEach((function(r){r.toBytes(e),t=t.concat(e),e=[]})):(r.toBytes(e),t=t.concat(e),e=[])}));var o=new this.ctx.HASH256;o.process_array(t);var a=o.hash(),s=this.BIG.fromBytes(a);return s.mod(this.order),s}},{key:"genAttrBN",value:function(t){for(var e=[],r=0;r<t.length;r++){var n=this.getRandBN();e[r]=n}return e}},{key:"genAttrElement",value:function(t){for(var e=[],r=0;r<t.length;r++){var n=this.getRandG1();e[r]=n}return e}}]),t}(),k=function t(e){b()(this,t),this.param=e},R=function(t){function e(t){b()(this,e);var r=m()(this,(e.__proto__||d()(e)).call(this,t));return r.value=new r.param.BIG(0),r}return g()(e,t),M()(e,[{key:"setValue",value:function(t){this.value.copy(t)}},{key:"GenerateIssuerPublicKey",value:function(){var t=this.value,e=this.param.PAIR.G2mul(this.param.g2,t),r=this.param.getRandBN(),n=this.param.PAIR.G1mul(this.param.g1,r),i=this.param.PAIR.G1mul(n,t);r=this.param.getRandBN();var o=this.param.PAIR.G2mul(this.param.g2,r),a=this.param.PAIR.G1mul(n,r),s=this.param.hashToBN(o,a,this.param.g2,n,e,i),u=this.param.BIG.modmul(s,t,this.param.order);u.add(r),u.mod(this.param.order);var h={C:s,S:u},c=new I(this.param);return c.SetBasicValue(e,n,i,h),c}},{key:"ToBytes",value:function(){return void 0===this.value?"":this.value.toBytes()}},{key:"FromBytes",value:function(t){return this.value=this.param.BIG.fromBytes(t),this.value.toString()}},{key:"Rand",value:function(){var t=this.param.getRandBN();this.setValue(t)}}],[{key:"GenerateSk",value:function(t){var r=t.getRandBN(),n=new e(t);return n.setValue(r),n}}]),e}(k),I=function(t){function e(t){b()(this,e);var r=m()(this,(e.__proto__||d()(e)).call(this,t));r.w=new r.param.ECP2,r._g1=new r.param.ECP,r._g2=new r.param.ECP;var n=new r.param.BIG,i=new r.param.BIG;return r.pi={C:n,S:i},r.h0=new r.param.ECP,r.h_sk=new r.param.ECP,r.attr=[],r}return g()(e,t),M()(e,[{key:"SetBasicValue",value:function(t,e,r,n){this.w.copy(t),this._g1.copy(e),this._g2.copy(r),this.pi.C.copy(n.C),this.pi.S.copy(n.S)}},{key:"SetAttrValue",value:function(t,e,r,n){this.h0.copy(t),this.h_sk.copy(e),this.h=[],this.attr=[];for(var i=0;i<r.length;i++)this.h[i]=new this.param.ECP,this.h[i].copy(r[i]);for(var o=0;o<n.length;o++)this.attr[o]=n[o]}},{key:"GenerateAttr",value:function(t){var e=this.param.genAttrElement(t),r=this.param.getRandG1(),n=this.param.getRandG1(),i=[];e.forEach((function(t){i.push(t)})),this.h0=r,this.h_sk=n,this.h=i,this.attr=t}},{key:"VerifyCredentialRequest",value:function(t){var e=new this.param.BIG(0);e.copy(t.pi.C);var r=this.param.PAIR.G1mul(this.h_sk,t.pi.S);r.add(this.param.PAIR.G1mul(t.Nym,this.param.BIG.modneg(e,this.param.order)));var n=this.param.hashToBN(r,this.h_sk,t.Nym,t.nonce);return 0===this.param.BIG.comp(t.pi.C,n)}}],[{key:"COPY",value:function(t){var r=new e(t.param);return r.SetBasicValue(t.w,t._g1,t._g2,t.pi),r.SetAttrValue(t.h0,t.h_sk,t.h,t.attr),r}}]),e}(k),B=function(t){function e(t){b()(this,e);var r=m()(this,(e.__proto__||d()(e)).call(this,t)),n=new r.param.ECP,i=new r.param.ECP,o=new r.param.BIG,a=new r.param.BIG;return r.sig={A:n,B:i,e:o,s:a},r.attrs=[],r}return g()(e,t),M()(e,[{key:"Set",value:function(t,e,r,n,i){this.sig.A.copy(t),this.sig.B.copy(e),this.sig.e.copy(r),this.sig.s.copy(n);for(var o=0;o<i.length;o++)this.attrs[o]=new this.param.BIG,this.attrs[o].copy(i[o])}},{key:"Copy",value:function(t){this.Set(t.sig.A,t.sig.B,t.sig.e,t.sig.s,t.attrs)}}]),e}(k),O=r(203)},function(t,e,r){"use strict";r.d(e,"b",(function(){return n})),r.d(e,"c",(function(){return i})),r.d(e,"a",(function(){return h}));var n,i,o=r(3),a=r.n(o),s=r(4),u=r.n(s);!function(t){t.Boolean="Boolean",t.Integer="Integer",t.ByteArray="ByteArray",t.Interface="Interface",t.Array="Array",t.Struct="Struct",t.Map="Map",t.String="String",t.Int="Integer",t.Long="Long",t.IntArray="IntArray",t.LongArray="LongArray",t.Address="Address",t.H256="H256"}(n||(n={})),function(t){t[t.ByteArray=0]="ByteArray",t[t.Boolean=1]="Boolean",t[t.Integer=2]="Integer",t[t.Interface=64]="Interface",t[t.Array=128]="Array",t[t.Struct=129]="Struct",t[t.Map=130]="Map"}(i||(i={}));var h=function(){function t(e,r,n){a()(this,t),this.name=e,this.type=r,this.value=n}return u()(t,[{key:"getName",value:function(){return this.name}},{key:"getType",value:function(){return this.type}},{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(t){return t.type===this.type&&t.name===this.name&&null!=t.value&&(this.value=t.value,!0)}}]),t}()},function(t,e,r){"use strict";e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,r){"use strict";e.__esModule=!0;var n,i=r(326),o=(n=i)&&n.__esModule?n:{default:n};e.default=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),(0,o.default)(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}()},function(t,e,r){t.exports={default:r(652),__esModule:!0}},function(t,e,r){var n=r(26),i=r(73),o=r(62),a=r(63),s=r(74),u=function(t,e,r){var h,c,f,l,d=t&u.F,p=t&u.G,m=t&u.S,v=t&u.P,g=t&u.B,y=p?n:m?n[e]||(n[e]={}):(n[e]||{}).prototype,b=p?i:i[e]||(i[e]={}),w=b.prototype||(b.prototype={});for(h in p&&(r=e),r)f=((c=!d&&y&&void 0!==y[h])?y:r)[h],l=g&&c?s(f,n):v&&"function"==typeof f?s(Function.call,f):f,y&&a(y,h,f,t&u.U),b[h]!=f&&o(b,h,l),v&&w[h]!=f&&(w[h]=f)};n.core=i,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,e,r){"use strict";var n;r.d(e,"a",(function(){return n})),function(t){t[t.SUCCESS=0]="SUCCESS",t[t.SESSION_EXPIRED=41001]="SESSION_EXPIRED",t[t.SERVICE_CEILING=41002]="SERVICE_CEILING",t[t.ILLEGAL_DATAFORMAT=41003]="ILLEGAL_DATAFORMAT",t[t.INVALID_VERSION=41004]="INVALID_VERSION",t[t.INVALID_METHOD=42001]="INVALID_METHOD",t[t.INVALID_PARAMS=42002]="INVALID_PARAMS",t[t.INVALID_TRANSACTION=43001]="INVALID_TRANSACTION",t[t.INVALID_ASSET=43002]="INVALID_ASSET",t[t.INVALID_BLOCK=43003]="INVALID_BLOCK",t[t.UNKNOWN_TRANSACTION=44001]="UNKNOWN_TRANSACTION",t[t.UNKNOWN_ASSET=44002]="UNKNOWN_ASSET",t[t.UNKNOWN_BLOCK=44003]="UNKNOWN_BLOCK",t[t.UNKNWN_CONTRACT=44004]="UNKNWN_CONTRACT",t[t.INTERNAL_ERROR=45001]="INTERNAL_ERROR",t[t.SMARTCODE_ERROR=47001]="SMARTCODE_ERROR",t[t.UNKNOWN_ONTID=51e3]="UNKNOWN_ONTID",t[t.NETWORK_ERROR=52e3]="NETWORK_ERROR",t[t.Decrypto_ERROR=53e3]="Decrypto_ERROR",t[t.INVALID_ADDR=53001]="INVALID_ADDR",t[t.PreExec_ERROR=54e3]="PreExec_ERROR"}(n||(n={}))},function(t,e,r){t.exports=r(825)},function(t,e,r){"use strict";var n=r(10),i=r.n(n),o=r(3),a=r.n(o),s=r(4),u=r.n(s),h=function(){function t(){a()(this,t),this.list=[]}return u()(t,[{key:"add",value:function(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=!0,o=!1,a=void 0;try{for(var s,u=i()(e);!(n=(s=u.next()).done);n=!0){var h=s.value;this.list.push(h)}}catch(t){o=!0,a=t}finally{try{!n&&u.return&&u.return()}finally{if(o)throw a}}}}]),t}();e.a=h},function(t,e,r){t.exports={default:r(686),__esModule:!0}},function(t,e,r){"use strict";r.d(e,"a",(function(){return l}));var n=r(55),i=r(16),o=r(0),a=r(14),s=r(106),u=r(20),h=r(27),c=r(40),f=r(170);function l(t,e,r,l,d,p){var m="";m+=e,m+=Object(u.h)(Object(o.str2hexstr)(t)),m+=Object(u.h)(r.serialize()),m+=Object(h.pushInt)(0),m+=Object(o.num2hexstring)(a.a.SYSCALL),m+=Object(u.h)(Object(o.str2hexstr)(i.NATIVE_INVOKE_NAME));var v=new s.a;v.code=m;var g=void 0;return(g=["transfer","transferV2","transferFrom","transferFromV2"].includes(t)?new f.a:new c.a).type=c.b.Invoke,g.payload=v,d&&(g.gasLimit=new n.a(d)),l&&(g.gasPrice=new n.a(l)),p&&(g.payer=p),g}},function(t,e,r){"use strict";r.d(e,"a",(function(){return d}));var n=r(10),i=r.n(n),o=r(22),a=r(33),s=r(14),u=r(0),h=r(20),c=r(27),f=(r(2),r(9));function l(t){var e="";if("string"==typeof t)e+=Object(h.h)(t);else if("boolean"==typeof t)e+=Object(c.pushBool)(t);else if("number"==typeof t)e+=Object(c.pushInt)(t);else if(t instanceof o.BigNumber)e+=Object(c.pushBigNum)(t);else if(t instanceof a.a)e+=Object(h.h)(t.serialize());else if(t instanceof f.a){e+=Object(c.pushInt)(0),e+=Object(u.num2hexstring)(s.a.NEWSTRUCT),e+=Object(u.num2hexstring)(s.a.TOALTSTACK);var r=!0,n=!1,d=void 0;try{for(var p,m=i()(t.list);!(r=(p=m.next()).done);r=!0){e+=l(p.value),e+=Object(u.num2hexstring)(s.a.DUPFROMALTSTACK),e+=Object(u.num2hexstring)(s.a.SWAP),e+=Object(u.num2hexstring)(s.a.APPEND)}}catch(t){n=!0,d=t}finally{try{!r&&m.return&&m.return()}finally{if(n)throw d}}e+=Object(u.num2hexstring)(s.a.FROMALTSTACK)}return e}function d(t){for(var e="",r=t.length-1;r>=0;r--){var n=t[r];if("string"==typeof n)e+=Object(h.h)(n);else if("boolean"==typeof n)e+=Object(c.pushBool)(n);else if("number"==typeof n)e+=Object(c.pushInt)(n);else if(n instanceof o.BigNumber)e+=Object(c.pushBigNum)(n);else if(n instanceof a.a)e+=Object(h.h)(n.serialize());else if(n instanceof f.a){e+=Object(c.pushInt)(0),e+=Object(u.num2hexstring)(s.a.NEWSTRUCT),e+=Object(u.num2hexstring)(s.a.TOALTSTACK);var p=!0,m=!1,v=void 0;try{for(var g,y=i()(n.list);!(p=(g=y.next()).done);p=!0){e+=l(g.value),e+=Object(u.num2hexstring)(s.a.DUPFROMALTSTACK),e+=Object(u.num2hexstring)(s.a.SWAP),e+=Object(u.num2hexstring)(s.a.APPEND)}}catch(t){m=!0,v=t}finally{try{!p&&y.return&&y.return()}finally{if(m)throw v}}e+=Object(u.num2hexstring)(s.a.FROMALTSTACK)}else Array.isArray(n)&&(e+=d(n),e+=Object(c.pushInt)(n.length),e+=Object(u.num2hexstring)(s.a.PACK))}return e}},function(t,e,r){"use strict";r.r(e),r.d(e,"Default_params",(function(){return U})),r.d(e,"signTransaction",(function(){return D})),r.d(e,"signTransactionAsync",(function(){return L})),r.d(e,"addSign",(function(){return F})),r.d(e,"signTx",(function(){return G})),r.d(e,"makeInvokeTransaction",(function(){return V})),r.d(e,"buildWasmVmInvokeCode",(function(){return q})),r.d(e,"makeWasmVmInvokeTransaction",(function(){return H})),r.d(e,"makeDeployCodeTransaction",(function(){return K})),r.d(e,"buildTxParam",(function(){return W})),r.d(e,"buildRpcParam",(function(){return Y})),r.d(e,"buildRestfulParam",(function(){return Z})),r.d(e,"sendRawTxRestfulUrl",(function(){return X})),r.d(e,"transferStringParameter",(function(){return J})),r.d(e,"transformMapParameter",(function(){return $})),r.d(e,"transformArrayParameter",(function(){return Q})),r.d(e,"transformParameter",(function(){return tt})),r.d(e,"buildParamsByJson",(function(){return et})),r.d(e,"makeTransactionsByJson",(function(){return rt})),r.d(e,"makeTransactionsByJsonV2",(function(){return nt})),r.d(e,"buildNativeTxFromJson",(function(){return it})),r.d(e,"buildNativeTxFromJsonV2",(function(){return ot}));var n,i=r(143),o=r.n(i),a=r(208),s=r.n(a),u=r(10),h=r.n(u),c=r(169),f=r.n(c),l=r(5),d=r.n(l),p=r(209),m=r.n(p),v=r(8),g=r.n(v),y=r(15),b=r.n(y),w=r(55),M=r(16),_=r(1),S=r(50),E=r(7),x=r(128),A=r(2),k=r(0),R=r(14),I=r(144),B=r(106),O=r(20),T=r(27),P=r(40),C=r(59),N=r(36),j=r(91),U={Action:"sendrawtransaction",Version:"1.0.0",Type:"",Op:"test"},D=function(t,e,r){var n=j.a.create(t,e,r);t.sigs=[n]},L=(n=b()(g.a.mark((function t(e,r,n){var i;return g.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,j.a.createAsync(e,r,n);case 2:i=t.sent,e.sigs=[i];case 4:case"end":return t.stop()}}),t,void 0)}))),function(t,e,r){return n.apply(this,arguments)}),F=function(t,e,r){var n=j.a.create(t,e,r);t.sigs.push(n)},z=function(t,e){if(t===e)return!0;if(t.sort(O.a),e.sort(O.a),t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(t[r].key!==e[r].key)return!1;return!0},G=function(t,e,r,n,i){if(0===t.sigs.length)t.sigs=[];else{if(t.sigs.length>M.TX_MAX_SIG_SIZE||e>r.length||e<=0||0===r.length)throw E.a.INVALID_PARAMS;for(var o=0;o<t.sigs.length;o++)if(z(t.sigs[o].pubKeys,r)){if(t.sigs[o].sigData.length+1>r.length)throw new Error("Too many sigData");var a=n.sign(t,i).serializeHex();return void t.sigs[o].sigData.push(a)}}var s=new j.a;s.M=e,s.pubKeys=r,s.sigData=[n.sign(t,i).serializeHex()],t.sigs.push(s)},V=function(t,e,r,n,i,o){var a=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],s=new P.a;s.type=P.b.Invoke;var u="";if("string"==typeof e)u=e;else{var h=new x.a(t,"",e);u=Object(T.serializeAbiFunction)(h,a)}var c=u+Object(k.num2hexstring)(R.a.APPCALL);c+=r.serialize();var f=new B.a;return f.code=c,s.payload=f,i&&(s.gasLimit=new w.a(i)),n&&(s.gasPrice=new w.a(n)),o&&(s.payer=o),s};function q(t,e){var r="";r+=t.serialize();var n=Object(T.buildWasmContractParam)(e);return r+=Object(T.writeVarBytes)(n)}function H(t,e,r,n,i,o){var a=new P.a;a.type=P.b.InvokeWasm;var s=q(r,[new A.a("method",A.b.String,t)].concat(m()(e))),u=new B.a;return u.code=s,a.payload=u,i&&(a.gasLimit=new w.a(i)),n&&(a.gasPrice=new w.a(n)),o&&(a.payer=o),a}function K(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"1.0",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",a=arguments[6],s=arguments[7],u=arguments[8],h=arguments[9],c=new I.b;c.author=n,c.code=t,c.version=r,c.description=o,c.email=i,c.name=e,c.vmType="boolean"==typeof a?I.a.NEOVM_TYPE:a;var f=new P.a;return f.version=0,f.payload=c,f.type=P.b.Deploy,f.gasLimit=new w.a(u),f.gasPrice=new w.a(s),h&&(f.payer=h),f}function W(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e?{PreExec:"1"}:{},n=t.serialize();return d()(f()({},U,{Data:n},r))}function Y(t,e){return{jsonrpc:"2.0",method:e||"sendrawtransaction",params:[t.serialize()],id:10}}function Z(t){return{Action:"sendrawtransaction",Version:"1.0.0",Data:t.serialize()}}function X(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"/"===t.charAt(t.length-1)&&(t=t.substring(0,t.length-1));var r=t+M.REST_API.sendRawTx;return e&&(r+="?preExec=1"),r}function J(t){if(t.split(":").length<2)throw new Error("Invalid parameter. "+t);var e=t.substring(0,t.indexOf(":")),r=t.substring(t.indexOf(":")+1),n=new A.a("",e,r);return n.type===A.b.Address&&(n.type=A.b.ByteArray,n.value=new _.Address(n.value).serialize()),n}function $(t){var e={},r=!0,n=!1,i=void 0;try{for(var a,u=h()(s()(t));!(r=(a=u.next()).done);r=!0){var c=a.value,f=t[c];"number"==typeof f?e[c]=new A.a("",A.b.Integer,f):"boolean"==typeof f?e[c]=new A.a("",A.b.Boolean,f):Array.isArray(f)?e[c]=new A.a("",A.b.Array,Q(f)):"object"===(void 0===f?"undefined":o()(f))?e[c]=new A.a("",A.b.Map,$(f)):"string"==typeof f&&(e[c]=J(f))}}catch(t){n=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(n)throw i}}return e}function Q(t){var e=[],r=!0,n=!1,i=void 0;try{for(var a,s=h()(t);!(r=(a=s.next()).done);r=!0){var u=a.value,c=new A.a("",A.b.ByteArray,u);"number"==typeof u?c.type=A.b.Integer:"boolean"==typeof u?c.type=A.b.Boolean:Array.isArray(u)?(c.type=A.b.Array,c.value=Q(u)):"object"===(void 0===u?"undefined":o()(u))?(c.type=A.b.Map,c.value=$(u)):"string"==typeof u&&(c=J(u)),e.push(c)}}catch(t){n=!0,i=t}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}return e}function tt(t){var e=t.name,r=t.value,n=new A.a(e,A.b.ByteArray,r);return"number"==typeof r?(n.type=A.b.Integer,n.value=Number(r)):"boolean"==typeof r?(n.type=A.b.Boolean,n.value=Boolean(r)):Array.isArray(r)?(n.type=A.b.Array,n.value=Q(r)):"object"===(void 0===r?"undefined":o()(r))?(n.type=A.b.Map,n.value=$(r)):"string"==typeof r&&(n=J(r)),n}function et(t){var e=[],r=t.functions,n=!0,i=!1,o=void 0;try{for(var a,s=h()(r);!(n=(a=s.next()).done);n=!0){var u=a.value,c=u.operation,f=u.args,l=[];l.push(Object(k.str2hexstr)(c));var d=[],p=!0,m=!1,v=void 0;try{for(var g,y=h()(f);!(p=(g=y.next()).done);p=!0){var b=g.value;d.push(tt(b))}}catch(t){m=!0,v=t}finally{try{!p&&y.return&&y.return()}finally{if(m)throw v}}l.push(d),e.push(l)}}catch(t){i=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return e}function rt(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t)throw new Error("Invalid parameter. Expect JSON object");if(!t.action||"invoke"!==t.action&&"invokeRead"!==t.action&&"invokePasswordFree"!==t.action)throw new Error('Invalid parameter. The action type must be "invoke or invokeRead"');if(!t.params||!t.params.invokeConfig)throw new Error("Invalid parameter. The params can not be empty.");var r=t.params.invokeConfig,n=r.payer,i=r.gasPrice,o=r.gasLimit,a=r.contractHash;if(!a)throw new Error("Invalid parameter. The contractHash can not be empty.");var s=new _.Address(Object(k.reverseHex)(a));n=n?new _.Address(n):null,i=i+""||"500",o=o+""||"200000";var u=[];if(a.indexOf("00000000000000000000000000000000000000")>-1){var c=it(r);u.push(c)}else{var f=et(r),l=!0,d=!1,p=void 0;try{for(var m,v=h()(f);!(l=(m=v.next()).done);l=!0){var g=m.value,y=Object(T.createCodeParamsScript)(g,e),b=V("",y,s,i,o,n,e);u.push(b)}}catch(t){d=!0,p=t}finally{try{!l&&v.return&&v.return()}finally{if(d)throw p}}}return u}function nt(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t)throw new Error("Invalid parameter. Expect JSON object");if(!t.action||"invoke"!==t.action&&"invokeRead"!==t.action&&"invokePasswordFree"!==t.action)throw new Error('Invalid parameter. The action type must be "invoke or invokeRead"');if(!t.params||!t.params.invokeConfig)throw new Error("Invalid parameter. The params can not be empty.");var r=t.params.invokeConfig,n=r.payer,i=r.gasPrice,o=r.gasLimit,a=r.contractHash;if(!a)throw new Error("Invalid parameter. The contractHash can not be empty.");var s=new _.Address(Object(k.reverseHex)(a));n=n?new _.Address(n):null,i=i+""||"500",o=o+""||"200000";var u=[];if(a.indexOf("00000000000000000000000000000000000000")>-1){var c=ot(r);u.push(c)}else{var f=et(r),l=!0,d=!1,p=void 0;try{for(var m,v=h()(f);!(l=(m=v.next()).done);l=!0){var g=m.value,y=Object(T.createCodeParamsScript)(g,e),b=V("",y,s,i,o,n,e);u.push(b)}}catch(t){d=!0,p=t}finally{try{!l&&v.return&&v.return()}finally{if(d)throw p}}}return u}function it(t){var e=t.functions[0],r=e.args;if(t.contractHash.indexOf("02")>-1||t.contractHash.indexOf("01")>-1){var n=t.contractHash.indexOf("02")>-1?"ONG":"ONT";if("transfer"===e.operation){var i=new _.Address(r[0].value.split(":")[1]),o=new _.Address(r[1].value.split(":")[1]),a=r[2].value.split(":")[1]+"",s=new _.Address(t.payer);return Object(C.makeTransferTx)(n,i,o,a,t.gasPrice,t.gasLimit,s)}}else if(t.contractHash.indexOf("03")>-1){if("regIDWithPublicKey"===e.operation){var u=r[0].value.substr(r[0].value.indexOf(":")+1),h=new S.a(r[1].value.split(":")[1]),c=new _.Address(t.payer);return Object(N.buildRegisterOntidTx)(u,h,t.gasPrice,t.gasLimit,c)}if("getDDO"===e.operation){var f=r[0].value.substr(r[0].value.indexOf(":")+1);return Object(N.buildGetDDOTx)(f)}}}function ot(t){var e=t.functions[0],r=e.args;if(t.contractHash.indexOf("02")>-1||t.contractHash.indexOf("01")>-1){var n=t.contractHash.indexOf("02")>-1?"ONG":"ONT";if("transfer"===e.operation){var i=new _.Address(r[0].value.split(":")[1]),o=new _.Address(r[1].value.split(":")[1]),a=r[2].value.split(":")[1]+"",s=new _.Address(t.payer);return Object(C.makeTransferTxV2)(n,i,o,a,t.gasPrice,t.gasLimit,s)}}else if(t.contractHash.indexOf("03")>-1){if("regIDWithPublicKey"===e.operation){var u=r[0].value.substr(r[0].value.indexOf(":")+1),h=new S.a(r[1].value.split(":")[1]),c=new _.Address(t.payer);return Object(N.buildRegisterOntidTx)(u,h,t.gasPrice,t.gasLimit,c)}if("getDDO"===e.operation){var f=r[0].value.substr(r[0].value.indexOf(":")+1);return Object(N.buildGetDDOTx)(f)}}}},function(t,e,r){"use strict";var n;!function(t){t[t.PUSH0=0]="PUSH0",t[t.PUSHF=0]="PUSHF",t[t.PUSHBYTES1=1]="PUSHBYTES1",t[t.PUSHBYTES75=75]="PUSHBYTES75",t[t.PUSHDATA1=76]="PUSHDATA1",t[t.PUSHDATA2=77]="PUSHDATA2",t[t.PUSHDATA4=78]="PUSHDATA4",t[t.PUSHM1=79]="PUSHM1",t[t.PUSH1=81]="PUSH1",t[t.PUSHT=81]="PUSHT",t[t.PUSH2=82]="PUSH2",t[t.PUSH3=83]="PUSH3",t[t.PUSH4=84]="PUSH4",t[t.PUSH5=85]="PUSH5",t[t.PUSH6=86]="PUSH6",t[t.PUSH7=87]="PUSH7",t[t.PUSH8=88]="PUSH8",t[t.PUSH9=89]="PUSH9",t[t.PUSH10=90]="PUSH10",t[t.PUSH11=91]="PUSH11",t[t.PUSH12=92]="PUSH12",t[t.PUSH13=93]="PUSH13",t[t.PUSH14=94]="PUSH14",t[t.PUSH15=95]="PUSH15",t[t.PUSH16=96]="PUSH16",t[t.NOP=97]="NOP",t[t.JMP=98]="JMP",t[t.JMPIF=99]="JMPIF",t[t.JMPIFNOT=100]="JMPIFNOT",t[t.CALL=101]="CALL",t[t.RET=102]="RET",t[t.APPCALL=103]="APPCALL",t[t.SYSCALL=104]="SYSCALL",t[t.TAILCALL=105]="TAILCALL",t[t.DUPFROMALTSTACK=106]="DUPFROMALTSTACK",t[t.TOALTSTACK=107]="TOALTSTACK",t[t.FROMALTSTACK=108]="FROMALTSTACK",t[t.XDROP=109]="XDROP",t[t.XSWAP=114]="XSWAP",t[t.XTUCK=115]="XTUCK",t[t.DEPTH=116]="DEPTH",t[t.DROP=117]="DROP",t[t.DUP=118]="DUP",t[t.NIP=119]="NIP",t[t.OVER=120]="OVER",t[t.PICK=121]="PICK",t[t.ROLL=122]="ROLL",t[t.ROT=123]="ROT",t[t.SWAP=124]="SWAP",t[t.TUCK=125]="TUCK",t[t.CAT=126]="CAT",t[t.SUBSTR=127]="SUBSTR",t[t.LEFT=128]="LEFT",t[t.RIGHT=129]="RIGHT",t[t.SIZE=130]="SIZE",t[t.INVERT=131]="INVERT",t[t.AND=132]="AND",t[t.OR=133]="OR",t[t.XOR=134]="XOR",t[t.EQUAL=135]="EQUAL",t[t.INC=139]="INC",t[t.DEC=140]="DEC",t[t.NEGATE=143]="NEGATE",t[t.ABS=144]="ABS",t[t.NOT=145]="NOT",t[t.NZ=146]="NZ",t[t.ADD=147]="ADD",t[t.SUB=148]="SUB",t[t.MUL=149]="MUL",t[t.DIV=150]="DIV",t[t.MOD=151]="MOD",t[t.SHL=152]="SHL",t[t.SHR=153]="SHR",t[t.BOOLAND=154]="BOOLAND",t[t.BOOLOR=155]="BOOLOR",t[t.NUMEQUAL=156]="NUMEQUAL",t[t.NUMNOTEQUAL=158]="NUMNOTEQUAL",t[t.LT=159]="LT",t[t.GT=160]="GT",t[t.LTE=161]="LTE",t[t.GTE=162]="GTE",t[t.MIN=163]="MIN",t[t.MAX=164]="MAX",t[t.WITHIN=165]="WITHIN",t[t.SHA1=167]="SHA1",t[t.SHA256=168]="SHA256",t[t.HASH160=169]="HASH160",t[t.HASH256=170]="HASH256",t[t.CHECKSIG=172]="CHECKSIG",t[t.CHECKMULTISIG=174]="CHECKMULTISIG",t[t.ARRAYSIZE=192]="ARRAYSIZE",t[t.PACK=193]="PACK",t[t.UNPACK=194]="UNPACK",t[t.PICKITEM=195]="PICKITEM",t[t.SETITEM=196]="SETITEM",t[t.NEWARRAY=197]="NEWARRAY",t[t.NEWSTRUCT=198]="NEWSTRUCT",t[t.NEWMAP=199]="NEWMAP",t[t.APPEND=200]="APPEND",t[t.REVERSE=201]="REVERSE",t[t.REMOVE=202]="REMOVE",t[t.HASKEY=203]="HASKEY",t[t.KEYS=204]="KEYS",t[t.VALUES=205]="VALUES",t[t.THROW=240]="THROW",t[t.THROWIFNOT=241]="THROWIFNOT"}(n||(n={})),e.a=n},function(t,e,r){"use strict";e.__esModule=!0;var n,i=r(130),o=(n=i)&&n.__esModule?n:{default:n};e.default=function(t){return function(){var e=t.apply(this,arguments);return new o.default((function(t,r){return function n(i,a){try{var s=e[i](a),u=s.value}catch(t){return void r(t)}if(!s.done)return o.default.resolve(u).then((function(t){n("next",t)}),(function(t){n("throw",t)}));t(u)}("next")}))}}},function(t,e,r){"use strict";r.r(e),r.d(e,"ADDR_VERSION",(function(){return n})),r.d(e,"DEFAULT_SCRYPT",(function(){return i})),r.d(e,"OEP_HEADER",(function(){return o})),r.d(e,"OEP_FLAG",(function(){return a})),r.d(e,"WEBVIEW_SCHEME",(function(){return s})),r.d(e,"DEFAULT_ALGORITHM",(function(){return u})),r.d(e,"DEFAULT_SM2_ID",(function(){return h})),r.d(e,"TEST_NODE",(function(){return c})),r.d(e,"TEST_NODE_1",(function(){return f})),r.d(e,"TEST_NODE_2",(function(){return l})),r.d(e,"MAIN_NODE",(function(){return d})),r.d(e,"HTTPS_REST_PORT",(function(){return p})),r.d(e,"HTTPS_WS_PORT",(function(){return m})),r.d(e,"HTTPS_JSON_PORT",(function(){return v})),r.d(e,"REST_API",(function(){return g})),r.d(e,"ONT_NETWORK",(function(){return y})),r.d(e,"TEST_ONT_URL_1",(function(){return b})),r.d(e,"TEST_ONT_URL_2",(function(){return w})),r.d(e,"TEST_ONT_URL",(function(){return M})),r.d(e,"MAIN_ONT_URL",(function(){return _})),r.d(e,"TOKEN_TYPE",(function(){return S})),r.d(e,"DEFAULT_GAS_LIMIT",(function(){return E})),r.d(e,"NATIVE_INVOKE_NAME",(function(){return x})),r.d(e,"TX_MAX_SIG_SIZE",(function(){return A})),r.d(e,"ONT_BIP44_PATH",(function(){return k})),r.d(e,"UNBOUND_GENERATION_AMOUNT",(function(){return R})),r.d(e,"UNBOUND_TIME_INTERVAL",(function(){return I})),r.d(e,"ONT_TOTAL_SUPPLY",(function(){return B})),r.d(e,"GENESIS_BLOCK_TIMESTAMP",(function(){return O}));var n="17",i={cost:4096,blockSize:8,parallel:8,size:64},o="0142",a="e0",s="Ont",u={algorithm:"ECDSA",parameters:{curve:"P-256"}},h="1234567812345678",c="polaris1.ont.io",f="polaris1.ont.io",l="polaris2.ont.io",d="dappnode1.ont.io",p="10334",m="10335",v="10336",g={getBalance:"/api/v1/balance",getBalanceV2:"/api/v1/balancev2",sendRawTx:"/api/v1/transaction",getMerkleProof:"/api/v1/merkleproof"},y={MAIN:"MainNet",TEST:"TestNet"},b={SOCKET_URL:"wss://"+f+":"+m,RPC_URL:"https://"+f+":"+v,REST_URL:"https://"+f+":"+p,sendRawTxByRestful:"https://"+f+":"+p+g.sendRawTx},w={SOCKET_URL:"wss://"+l+":"+m,RPC_URL:"https://"+l+":"+v,REST_URL:"https://"+l+":"+p,sendRawTxByRestful:"https://"+l+":"+p+g.sendRawTx},M={SOCKET_URL:"wss://"+c+":"+m,RPC_URL:"https://"+c+":"+v,REST_URL:"https://"+c+":"+p,sendRawTxByRestful:"https://"+c+":"+p+g.sendRawTx},_={SOCKET_URL:"wss://"+d+":"+m,RPC_URL:"https://"+d+":"+v+"/",REST_URL:"https://"+d+":"+p+"/",sendRawTxByRestful:"https://"+c+":"+p+g.sendRawTx},S={ONT:"ONT",ONG:"ONG"},E=3e4,x="Ontology.Native.Invoke",A=16,k="m/44'/1024'/0'/0/0",R=[5,4,3,3,2,2,2,1,1,1,1,1,1,1,1,1,1,1],I=31536e3,B=1e9,O=1530316800},function(t,e,r){t.exports=r(788)},function(t,e,r){"use strict";r.d(e,"a",(function(){return s}));var n=r(3),i=r.n(n),o=r(4),a=r.n(o),s=function(){function t(e,r,n){i()(this,t),this.label=e,this.hex=r,this.labelJWS=n,t.values.push(this)}return a()(t,null,[{key:"fromHex",value:function(e){var r=t.values.find((function(t){return t.hex===e}));if(void 0===r)throw new Error("Enum value not found");return r}},{key:"fromLabel",value:function(e){var r=t.values.find((function(t){return t.label===e}));if(void 0===r)throw new Error("Enum value not found");return r}},{key:"fromLabelJWS",value:function(e){var r=t.values.find((function(t){return t.labelJWS===e||e.indexOf(t.labelJWS)>-1}));if(void 0===r)throw new Error("Enum value not found");return r}}]),t}();s.values=[],s.ECDSAwithSHA224=new s("SHA224withECDSA",0,"ES224"),s.ECDSAwithSHA256=new s("SHA256withECDSA",1,"ES256"),s.ECDSAwithSHA384=new s("SHA384withECDSA",2,"ES384"),s.ECDSAwithSHA512=new s("SHA512withECDSA",3,"ES512"),s.ECDSAwithSHA3_224=new s("SHA3-224withECDSA",4,"ES3-224"),s.ECDSAwithSHA3_256=new s("SHA3-256withECDSA",5,"ES3-256"),s.ECDSAwithSHA3_384=new s("SHA3-384withECDSA",6,"ES3-384"),s.ECDSAwithSHA3_512=new s("SHA3-512withECDSA",7,"ES3-512"),s.ECDSAwithRIPEMD160=new s("RIPEMD160withECDSA",8,"ER160"),s.SM2withSM3=new s("SM3withSM2",9,"SM"),s.EDDSAwithSHA512=new s("SHA512withEdDSA",10,"EDS512")},function(t,e,r){var n;t.exports=(n=r(28),r(193),r(693),r(694),r(140),r(141),r(259),r(355),r(695),r(356),r(696),r(697),r(698),r(260),r(699),r(126),r(47),r(700),r(701),r(702),r(703),r(704),r(705),r(706),r(707),r(708),r(709),r(710),r(711),r(712),r(713),r(714),r(715),n)},function(t,e,r){"use strict";r.d(e,"a",(function(){return m})),r.d(e,"g",(function(){return g})),r.d(e,"f",(function(){return w})),r.d(e,"d",(function(){return M})),r.d(e,"e",(function(){return _})),r.d(e,"b",(function(){return A})),r.d(e,"c",(function(){return R})),r.d(e,"h",(function(){return I}));var n=r(3),i=r.n(n),o=r(10),a=r.n(o),s=r(90),u=r(49),h=r(34),c=r(41),f=r(50),l=r(7),d=r(0),p=r(14);function m(t,e){if(t.algorithm!==e.algorithm)return t.algorithm.hex-e.algorithm.hex;switch(t.algorithm){case c.a.ECDSA:var r=new u.ec(t.parameters.curve.preset),n=r.keyFromPublic(t.key,"hex",!0),i=r.keyFromPublic(e.key,"hex",!0),o=n.getPublic(),a=i.getPublic();return o.getX()!==a.getX()?o.getX()-a.getX():o.getY()-a.getY();case c.a.SM2:var h=new s.sm2.SM2KeyPair,f=new s.sm2.SM2KeyPair;return h._pubFromString(t.key),f._pubFromString(e.key),h.getX().toString()!==f.getX().toString()?Number(h.getX().toString())-Number(f.getX().toString()):Number(h.getY().toString())-Number(f.getY().toString());case c.a.EDDSA:return Number(t.key)-Number(e.key);default:return 0}}function v(t){return Object(d.num2hexstring)(t)}function g(t){return-1===t?Object(d.num2hexstring)(p.a.PUSHM1):0===t?Object(d.num2hexstring)(p.a.PUSH0):t>0&&t<=16?Object(d.num2hexstring)(p.a.PUSH1-1+t):Object(d.num2hexstring)(t,8,!0)}function y(t){return 0===t?v(p.a.PUSH0):t<=16?Object(d.num2hexstring)(t-1+p.a.PUSH1):b(new h.a(t.toString()).toHexstr())}function b(t){var e="";if(0===t.length)throw new Error("pushBytes error, hexstr is empty.");var r=t.length/2;if(r<=p.a.PUSHBYTES75+1-p.a.PUSHBYTES1)e+=Object(d.num2hexstring)(r+p.a.PUSHBYTES1-1);else if(r<256)e+=Object(d.num2hexstring)(p.a.PUSHDATA1),e+=Object(d.num2hexstring)(r);else if(r<65536)e+=Object(d.num2hexstring)(p.a.PUSHDATA2),e+=Object(d.num2hexstring)(r,2,!0);else{if(!(r<4294967296))throw l.a.INVALID_PARAMS;e+=Object(d.num2hexstring)(p.a.PUSHDATA4),e+=Object(d.num2hexstring)(r,4,!0)}return e+=t}function w(t){var e="";return e+=function(t){return b(t.serializeHex())}(t),e+=v(p.a.CHECKSIG)}function M(t,e){var r=t.length;if(!(1<=e&&e<=r&&r<=1024))throw new Error("Wrong multi-sig param");t.sort(m);var n="";n+=y(e);var i=!0,o=!1,s=void 0;try{for(var u,h=a()(t);!(i=(u=h.next()).done);i=!0){n+=b(u.value.serializeHex())}}catch(t){o=!0,s=t}finally{try{!i&&h.return&&h.return()}finally{if(o)throw s}}return n+=y(r),n+=v(p.a.CHECKMULTISIG)}function _(t){var e="";t.sort();var r=!0,n=!1,i=void 0;try{for(var o,s=a()(t);!(r=(o=s.next()).done);r=!0){e+=b(o.value)}}catch(t){n=!0,i=t}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}return e}function S(t){return parseInt(t.read(1),16)}function E(t){var e=S(t),r=void 0;if(e===p.a.PUSHDATA4)r=t.readUint32();else if(e===p.a.PUSHDATA2)r=t.readUint16();else if(e===p.a.PUSHDATA1)r=t.readUint8();else{if(!(e<=p.a.PUSHBYTES75&&e>=p.a.PUSHBYTES1))throw new Error("unexpected opcode: "+e);r=e-p.a.PUSHBYTES1+1}return t.read(r)}function x(t){var e=t.readNextBytes();return f.a.deserializeHex(new d.StringReader(e))}function A(t){for(var e=[],r=new d.StringReader(t);!r.isEmpty();)e.push(E(r));return e}var k=function t(){i()(this,t)};function R(t){var e=new k,r=parseInt(t.substr(-2,2),16);if(r===p.a.CHECKSIG){var n=x(new d.StringReader(t));return e.M=1,e.pubKeys=[n],e}if(r===p.a.CHECKMULTISIG){var i=new d.StringReader(t),o=parseInt(i.read(1),16)-p.a.PUSH1+1,a=parseInt(t.substr(-4,2),16)-p.a.PUSH1+1;e.M=o,e.pubKeys=[];for(var s=0;s<a;s++){var u=x(i);e.pubKeys.push(u)}return e}throw new Error("Unsupported program.")}var I=function(t){var e="",r=t.length/2;return r<=p.a.PUSHBYTES75?e+=Object(d.num2hexstring)(r):r<256?(e+=Object(d.num2hexstring)(p.a.PUSHDATA1),e+=Object(d.num2hexstring)(r)):r<65536?(e+=Object(d.num2hexstring)(p.a.PUSHDATA2),e+=Object(d.num2hexstring)(r,2,!0)):(e+=Object(d.num2hexstring)(p.a.PUSHDATA4),e+=Object(d.num2hexstring)(r,4,!0)),e+=t}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){var n;!function(i){"use strict";var o,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,u=Math.floor,h="[BigNumber Error] ",c=h+"Number primitive has more than 15 significant digits: ",f=1e14,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e9;function p(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,i=t.length,o=t[0]+"";n<i;){for(r=14-(e=t[n++]+"").length;r--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function v(t,e){var r,n,i=t.c,o=e.c,a=t.s,s=e.s,u=t.e,h=e.e;if(!a||!s)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=u==h,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>h^r?1:-1;for(s=(u=i.length)<(h=o.length)?u:h,a=0;a<s;a++)if(i[a]!=o[a])return i[a]>o[a]^r?1:-1;return u==h?0:u>h^r?1:-1}function g(t,e,r,n){if(t<e||t>r||t!==(t<0?s(t):u(t)))throw Error(h+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+t)}function y(t){return"[object Array]"==Object.prototype.toString.call(t)}function b(t){var e=t.c.length-1;return p(t.e/14)==e&&t.c[e]%2!=0}function w(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function M(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}(o=function t(e){var r,n,i,o,_,S,E,x,A,k=F.prototype={constructor:F,toString:null,valueOf:null},R=new F(1),I=20,B=4,O=-7,T=21,P=-1e7,C=1e7,N=!1,j=1,U=0,D={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0},L="0123456789abcdefghijklmnopqrstuvwxyz";function F(t,e){var r,o,s,h,f,l,d,p,m=this;if(!(m instanceof F))return new F(t,e);if(null==e){if(t instanceof F)return m.s=t.s,m.e=t.e,void(m.c=(t=t.c)?t.slice():t);if((l="number"==typeof t)&&0*t==0){if(m.s=1/t<0?(t=-t,-1):1,t===~~t){for(h=0,f=t;f>=10;f/=10,h++);return m.e=h,void(m.c=[t])}p=t+""}else{if(!a.test(p=t+""))return i(m,p,l);m.s=45==p.charCodeAt(0)?(p=p.sli