UNPKG

125 kBJavaScriptView Raw
1module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=22)}([function(e,t){e.exports=require("@babel/runtime/regenerator")},function(e,t){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},function(e,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t){e.exports=require("injectpromise")},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,t){e.exports=require("@babel/runtime/helpers/typeof")},function(e,t){e.exports=require("bignumber.js")},function(e,t){e.exports=require("ethers")},function(e,t){e.exports=require("@babel/runtime/helpers/assertThisInitialized")},function(e,t){e.exports=require("semver")},function(e,t){e.exports=require("elliptic")},function(e,t){e.exports=require("@babel/runtime/helpers/possibleConstructorReturn")},function(e,t){e.exports=require("@babel/runtime/helpers/getPrototypeOf")},function(e,t){e.exports=require("@babel/runtime/helpers/inherits")},function(e,t){e.exports=require("axios")},function(e,t){e.exports=require("validator")},function(e,t){e.exports=require("eventemitter3")},function(e){e.exports=JSON.parse('{"a":"2.10.0"}')},function(e,t){e.exports=require("querystring")},function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"byte2hexStr",(function(){return F})),n.d(r,"bytesToString",(function(){return C})),n.d(r,"hextoString",(function(){return O})),n.d(r,"byteArray2hexStr",(function(){return E})),n.d(r,"base64DecodeFromString",(function(){return q})),n.d(r,"base64EncodeToString",(function(){return D}));var i={};n.r(i),n.d(i,"bin2String",(function(){return z})),n.d(i,"arrayEquals",(function(){return M})),n.d(i,"stringToBytes",(function(){return J})),n.d(i,"byte2hexStr",(function(){return F})),n.d(i,"bytesToString",(function(){return C})),n.d(i,"hextoString",(function(){return O})),n.d(i,"byteArray2hexStr",(function(){return E})),n.d(i,"base64DecodeFromString",(function(){return q})),n.d(i,"base64EncodeToString",(function(){return D})),n.d(i,"hexChar2byte",(function(){return G})),n.d(i,"isHexChar",(function(){return Y})),n.d(i,"hexStr2byteArray",(function(){return X})),n.d(i,"strToDate",(function(){return Z})),n.d(i,"isNumber",(function(){return $})),n.d(i,"getStringType",(function(){return Q}));var s={};n.r(s),n.d(s,"encode58",(function(){return ie})),n.d(s,"decode58",(function(){return se}));var o={};n.r(o),n.d(o,"keccak256",(function(){return ue})),n.d(o,"sha256",(function(){return ce})),n.d(o,"toUtf8Bytes",(function(){return de})),n.d(o,"recoverAddress",(function(){return le})),n.d(o,"SigningKey",(function(){return he})),n.d(o,"AbiCoder",(function(){return fe}));var a={};n.r(a),n.d(a,"getBase58CheckAddress",(function(){return ve})),n.d(a,"decodeBase58Address",(function(){return pe})),n.d(a,"signTransaction",(function(){return ge})),n.d(a,"arrayToBase64String",(function(){return be})),n.d(a,"signBytes",(function(){return me})),n.d(a,"getRowBytesFromTransactionBase64",(function(){return ye})),n.d(a,"genPriKey",(function(){return ke})),n.d(a,"computeAddress",(function(){return xe})),n.d(a,"getAddressFromPriKey",(function(){return we})),n.d(a,"decode58Check",(function(){return Ie})),n.d(a,"isAddressValid",(function(){return We})),n.d(a,"getBase58CheckAddressFromPriKeyBase64String",(function(){return Ae})),n.d(a,"getHexStrAddressFromPriKeyBase64String",(function(){return Pe})),n.d(a,"getAddressFromPriKeyBase64String",(function(){return _e})),n.d(a,"getPubKeyFromPriKey",(function(){return Ne})),n.d(a,"ECKeySign",(function(){return Se})),n.d(a,"SHA256",(function(){return je})),n.d(a,"passwordToAddress",(function(){return Te})),n.d(a,"pkToAddress",(function(){return Be}));var u={};n.r(u),n.d(u,"generateAccount",(function(){return Fe}));var c={};n.r(c),n.d(c,"decodeParams",(function(){return Oe})),n.d(c,"encodeParams",(function(){return Ee}));var d=n(0),l=n.n(d),h=n(1),f=n.n(h),v=n(8),p=n.n(v),g=n(2),b=n.n(g),m=n(3),y=n.n(m),k=n(14),x=n.n(k),w=n(15),I=n.n(w),W=n(11),A=n.n(W),P=n(16),_=n.n(P),N=n(4),S=n.n(N),j=n(17),T=n.n(j);function B(){var e=this;this._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",this.encode=function(t){for(var n,r,i,s,o,a,u,c="",d=0;d<t.length;)s=(n=t.charCodeAt(d++))>>2,o=(3&n)<<4|(r=t.charCodeAt(d++))>>4,a=(15&r)<<2|(i=t.charCodeAt(d++))>>6,u=63&i,isNaN(r)?a=u=64:isNaN(i)&&(u=64),c=c+e._keyStr.charAt(s)+e._keyStr.charAt(o)+e._keyStr.charAt(a)+e._keyStr.charAt(u);return c},this.encodeIgnoreUtf8=function(t){for(var n,r,i,s,o,a,u,c="",d=0;d<t.length;)s=(n=t[d++])>>2,o=(3&n)<<4|(r=t[d++])>>4,a=(15&r)<<2|(i=t[d++])>>6,u=63&i,isNaN(r)?a=u=64:isNaN(i)&&(u=64),c=c+e._keyStr.charAt(s)+e._keyStr.charAt(o)+e._keyStr.charAt(a)+e._keyStr.charAt(u);return c},this.decode=function(t){var n,r,i,s,o,a,u="",c=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<t.length;)n=e._keyStr.indexOf(t.charAt(c++))<<2|(s=e._keyStr.indexOf(t.charAt(c++)))>>4,r=(15&s)<<4|(o=e._keyStr.indexOf(t.charAt(c++)))>>2,i=(3&o)<<6|(a=e._keyStr.indexOf(t.charAt(c++))),u+=String.fromCharCode(n),64!=o&&(u+=String.fromCharCode(r)),64!=a&&(u+=String.fromCharCode(i));return e._utf8_decode(u)},this.decodeToByteArray=function(t){var n,r,i,s,o,a,u="",c=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<t.length;)n=e._keyStr.indexOf(t.charAt(c++))<<2|(s=e._keyStr.indexOf(t.charAt(c++)))>>4,r=(15&s)<<4|(o=e._keyStr.indexOf(t.charAt(c++)))>>2,i=(3&o)<<6|(a=e._keyStr.indexOf(t.charAt(c++))),u+=String.fromCharCode(n),64!=o&&(u+=String.fromCharCode(r)),64!=a&&(u+=String.fromCharCode(i));return e._out2ByteArray(u)},this._out2ByteArray=function(e){for(var t=new Array(e.length),n=0,r=0;n<e.length;)r=e.charCodeAt(n),t[n]=r,n++;return t},this._utf8_encode=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},this._utf8_decode=function(e){for(var t="",n=0,r=0,i=0,s=0;n<e.length;)(r=e.charCodeAt(n))<128?(t+=String.fromCharCode(r),n++):r>191&&r<224?(i=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&i),n+=2):(i=e.charCodeAt(n+1),s=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&i)<<6|63&s),n+=3);return t}}function F(e){if("number"!=typeof e)throw new Error("Input must be a number");if(e<0||e>255)throw new Error("Input must be a byte");var t="";return t+="0123456789ABCDEF".charAt(e>>4),t+="0123456789ABCDEF".charAt(15&e)}function C(e){if("string"==typeof e)return e;for(var t="",n=0;n<e.length;n++){var r=e[n].toString(2),i=r.match(/^1+?(?=0)/);if(i&&8===r.length){for(var s=i[0].length,o=e[n].toString(2).slice(7-s),a=1;a<s;a++)o+=e[a+n].toString(2).slice(2);t+=String.fromCharCode(parseInt(o,2)),n+=s-1}else t+=String.fromCharCode(e[n])}return t}function O(e){for(var t=e.replace(/^0x/,"").split(""),n="",r=0;r<t.length/2;r++){var i="0x".concat(t[2*r]).concat(t[2*r+1]);n+=String.fromCharCode(i)}return n}function E(e){for(var t="",n=0;n<e.length;n++)t+=F(e[n]);return t}function q(e){return(new B).decodeToByteArray(e)}function D(e){return(new B).encodeIgnoreUtf8(e)}var K=n(6),R=n.n(K),H=34,U="41",V=65,L=/^(41)/;function z(e){return C(e)}function M(e,t,n){if(e.length!=t.length)return!1;var r;for(r=0;r<e.length;r++)if(n){if(e[r]!=t[r])return!1}else if(JSON.stringify(e[r])!=JSON.stringify(t[r]))return!1;return!0}function J(e){if("string"!=typeof e)throw new Error("The passed string is not a string");var t,n,r=new Array;t=e.length;for(var i=0;i<t;i++)(n=e.charCodeAt(i))>=65536&&n<=1114111?(r.push(n>>18&7|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)):n>=2048&&n<=65535?(r.push(n>>12&15|224),r.push(n>>6&63|128),r.push(63&n|128)):n>=128&&n<=2047?(r.push(n>>6&31|192),r.push(63&n|128)):r.push(255&n);return r}function G(e){var t;if(e>="A"&&e<="F"?t=e.charCodeAt(0)-"A".charCodeAt(0)+10:e>="a"&&e<="f"?t=e.charCodeAt(0)-"a".charCodeAt(0)+10:e>="0"&&e<="9"&&(t=e.charCodeAt(0)-"0".charCodeAt(0)),"number"==typeof t)return t;throw new Error("The passed hex char is not a valid hex char")}function Y(e){return e>="A"&&e<="F"||e>="a"&&e<="f"||e>="0"&&e<="9"?1:0}function X(e){if("string"!=typeof e)throw new Error("The passed string is not a string");for(var t=Array(),n=0,r=0,i=0,s=0;s<e.length;s++){var o=e.charAt(s);if(!Y(o))throw new Error("The passed hex char is not a valid hex string");n<<=4,n+=G(o),0==++r%2&&(t[i++]=n,n=0)}return t}function Z(e){if(!/^\d{4}-\d{2}-\d{2}( \d{2}-\d{2}-\d{2}|)/.test(e))throw new Error("The passed date string is not valid");var t=e.split(" "),n=t[0].split("-"),r=parseInt(n[0],10),i=parseInt(n[1],10)-1,s=parseInt(n[2],10);if(t.length>1){var o=t[1].split("-"),a=parseInt(o[0],10),u=parseInt(o[1],10),c=parseInt(o[2],10);return new Date(r,i,s,a,u,c)}return new Date(r,i,s)}function $(e){return e>="0"&&e<="9"?1:0}function Q(e){if(null==e)return-1;if("string"!=typeof e)return-1;if(0==e.length||""==e)return-1;var t=0;if(40==e.length)for(;t<40;t++){if(!Y(e.charAt(t)))break}if(40==t)return 1;for(t=0;t<e.length;t++){if(!$(e.charAt(t)))break}if(t==e.length)return 2;for(t=0;t<e.length;t++){if(e.charAt(t)>" ")return 3}return-1}for(var ee="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",te={},ne=0;ne<ee.length;ne++)te[ee.charAt(ne)]=ne;var re=58;function ie(e){if(0===e.length)return"";var t,n,r=[0];for(t=0;t<e.length;t++){for(n=0;n<r.length;n++)r[n]<<=8;r[0]+=e[t];var i=0;for(n=0;n<r.length;++n)r[n]+=i,i=r[n]/re|0,r[n]%=re;for(;i;)r.push(i%re),i=i/re|0}for(t=0;0===e[t]&&t<e.length-1;t++)r.push(0);return r.reverse().map((function(e){return ee[e]})).join("")}function se(e){if(0===e.length)return[];var t,n,r=[0];for(t=0;t<e.length;t++){var i=e[t];if(!(i in te))throw new Error("Non-base58 character");for(n=0;n<r.length;n++)r[n]*=re;r[0]+=te[i];var s=0;for(n=0;n<r.length;++n)r[n]+=s,s=r[n]>>8,r[n]&=255;for(;s;)r.push(255&s),s>>=8}for(t=0;"1"===e[t]&&t<e.length-1;t++)r.push(0);return r.reverse()}var oe=n(13),ae=n(10),ue=ae.utils.keccak256,ce=ae.utils.sha256,de=ae.utils.toUtf8Bytes,le=ae.utils.recoverAddress,he=ae.utils.SigningKey,fe=ae.utils.AbiCoder;function ve(e){var t=je(e),n=je(t).slice(0,4);return ie(n=e.concat(n))}function pe(e){if("string"!=typeof e)return!1;if(e.length<=4)return!1;var t=se(e);if(e.length<=4)return!1;var n=t.length-4,r=t.slice(n),i=je(t=t.slice(0,n)),s=je(i).slice(0,4);if(r[0]==s[0]&&r[1]==s[1]&&r[2]==s[2]&&r[3]==s[3])return t;throw new Error("Invalid address provided")}function ge(e,t){"string"==typeof e&&(e=X(e));var n=Se(X(t.txID),e);return Array.isArray(t.signature)?t.signature.includes(n)||t.signature.push(n):t.signature=[n],t}function be(e){return btoa(String.fromCharCode.apply(String,R()(e)))}function me(e,t){return"string"==typeof e&&(e=X(e)),Se(je(t),e)}function ye(e){var t=q(e);return proto.protocol.Transaction.deserializeBinary(t).getRawData().serializeBinary()}function ke(){for(var e=new oe.ec("secp256k1").genKeyPair().getPrivate().toString("hex");e.length<64;)e="0".concat(e);return X(e)}function xe(e){65===e.length&&(e=e.slice(1));var t=ue(e).toString().substring(2);return X(U+t.substring(24))}function we(e){return xe(Ne(e))}function Ie(e){var t=se(e);if(t.length<=4)return!1;var n=t.slice(0,t.length-4),r=je(n),i=je(r);return i[0]===t[n.length]&&i[1]===t[n.length+1]&&i[2]===t[n.length+2]&&i[3]===t[n.length+3]&&n}function We(e){if("string"!=typeof e)return!1;if(e.length!==H)return!1;var t=se(e);if(25!==t.length)return!1;if(t[0]!==V)return!1;var n=t.slice(21),r=je(t=t.slice(0,21)),i=je(r).slice(0,4);return n[0]==i[0]&&n[1]==i[1]&&n[2]==i[2]&&n[3]==i[3]}function Ae(e){return ve(xe(Ne(q(e))))}function Pe(e){return E(xe(Ne(q(e))))}function _e(e){return D(xe(Ne(q(e))))}function Ne(e){for(var t=new oe.ec("secp256k1").keyFromPrivate(e,"bytes").getPublic(),n=t.x,r=t.y,i=n.toString("hex");i.length<64;)i="0".concat(i);for(var s=r.toString("hex");s.length<64;)s="0".concat(s);return X("04".concat(i).concat(s))}function Se(e,t){for(var n=new oe.ec("secp256k1").keyFromPrivate(t,"bytes").sign(e),r=n.r,i=n.s,s=n.recoveryParam,o=r.toString("hex");o.length<64;)o="0".concat(o);for(var a=i.toString("hex");a.length<64;)a="0".concat(a);return o+a+F(s)}function je(e){var t=E(e);return X(ce("0x"+t).replace(/^0x/,""))}function Te(e){return ve(we(q(e)))}function Be(e){return ve(we(X(e)))}function Fe(){var e=ke(),t=Ne(e),n=we(e);return{privateKey:E(e),publicKey:E(t),address:{base58:ve(n),hex:E(n)}}}var Ce=new fe;function Oe(e,t,n,r){if(n&&"boolean"!=typeof n||(r=n,n=t,t=e,e=[]),r&&n.replace(/^0x/,"").length%64==8&&(n="0x"+n.replace(/^0x/,"").substring(8)),n.replace(/^0x/,"").length%64)throw new Error("The encoded string is not valid. Its length must be a multiple of 64.");return t=t.map((function(e){return/trcToken/.test(e)&&(e=e.replace(/trcToken/,"uint256")),e})),Ce.decode(t,n).reduce((function(n,r,i){return"address"==t[i]&&(r=U+r.substr(2).toLowerCase()),e.length?n[e[i]]=r:n.push(r),n}),e.length?{}:[])}function Ee(e,t){for(var n=0;n<e.length;n++)"address"===e[n]&&(t[n]=It.address.toHex(t[n]).replace(L,"0x"));return Ce.encode(e,t)}var qe=n(18),De=n.n(qe),Ke=n(9),Re=n.n(Ke);function He(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Ue,Ve,Le=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?He(Object(n),!0).forEach((function(t){S()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):He(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},{isValidURL:function(e){return"string"==typeof e&&De.a.isURL(e.toString(),{protocols:["http","https"],require_tld:!1})},isObject:function(e){return e===Object(e)&&"[object Array]"!==Object.prototype.toString.call(e)},isArray:function(e){return Array.isArray(e)},isJson:function(e){try{return!!JSON.parse(e)}catch(e){return!1}},isBoolean:function(e){return"boolean"==typeof e},isBigNumber:function(e){return e&&(e instanceof Re.a||e.constructor&&"BigNumber"===e.constructor.name)},isString:function(e){return"string"==typeof e||e&&e.constructor&&"String"===e.constructor.name},isFunction:function(e){return"function"==typeof e},isHex:function(e){return"string"==typeof e&&!isNaN(parseInt(e,16))&&/^(0x|)[a-fA-F0-9]+$/.test(e)},isInteger:function(e){return null!==e&&Number.isInteger(Number(e))},hasProperty:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},hasProperties:function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.length&&!r.map((function(n){return t.hasProperty(e,n)})).includes(!1)},mapEvent:function(e){var t={block:e.block_number,timestamp:e.block_timestamp,contract:e.contract_address,name:e.event_name,transaction:e.transaction_id,result:e.result,resourceNode:e.resource_Node||(e._unconfirmed?"fullNode":"solidityNode")};return e._unconfirmed&&(t.unconfirmed=e._unconfirmed),e._fingerprint&&(t.fingerprint=e._fingerprint),t},parseEvent:function(e,t){var n=t.inputs;if(!e.result)return e;if(this.isObject(e.result))for(var r=0;r<n.length;r++){var i=n[r];"address"==i.type&&i.name in e.result&&(e.result[i.name]=U+e.result[i.name].substr(2).toLowerCase())}else this.isArray(e.result)&&(e.result=e.result.reduce((function(e,t,r){var i=n[r],s=i.name;return"address"==i.type&&(t=U+t.substr(2).toLowerCase()),e[s]=t,e}),{}));return e},padLeft:function(e,t,n){for(var r=e.toString();r.length<n;)r=t+r;return r},isNotNullOrUndefined:function(e){return null!=e},sleep:(Ue=f()(l.a.mark((function e(){var t,n=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:1e3,e.abrupt("return",new Promise((function(e){return setTimeout(e,t)})));case 2:case"end":return e.stop()}}),e)}))),function(){return Ue.apply(this,arguments)})},{code:i,accounts:u,base58:s,bytes:r,crypto:a,abi:c,ethersUtils:o}),ze={HttpProvider:function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e4,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"/";if(b()(this,e),!Le.isValidURL(t))throw new Error("Invalid URL provided to HttpProvider");if(isNaN(n)||n<0)throw new Error("Invalid timeout duration provided");if(!Le.isObject(s))throw new Error("Invalid headers object provided");t=t.replace(/\/+$/,""),this.host=t,this.timeout=n,this.user=r,this.password=i,this.headers=s,this.statusPage=o,this.instance=T.a.create({baseURL:t,timeout:n,headers:s,auth:r&&{user:r,password:i}})}var t;return y()(e,[{key:"setStatusPage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/";this.statusPage=e}},{key:"isConnected",value:(t=f()(l.a.mark((function e(){var t,n=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:this.statusPage,e.abrupt("return",this.request(t).then((function(e){return Le.hasProperties(e,"blockID","block_header")})).catch((function(){return!1})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"request",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"get";return n=n.toLowerCase(),this.instance.request({data:"post"==n&&Object.keys(t).length?t:null,params:"get"==n&&t,url:e,method:n}).then((function(e){return e.data}))}}]),e}()},Me=n(19),Je=n.n(Me),Ge=n(20),Ye=n(12),Xe=n.n(Ye),Ze=n(5),$e=n.n(Ze),Qe=n(7),et=n.n(Qe),tt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b()(this,e),!t||!t instanceof It)throw new Error("Expected instance of TronWeb");this.tronWeb=t}return y()(e,[{key:"invalid",value:function(e){return e.msg||"Invalid ".concat(e.name).concat("address"===e.type?" address":""," provided")}},{key:"notPositive",value:function(e){return"".concat(e.name," must be a positive integer")}},{key:"notEqual",value:function(e){return e.msg||"".concat(e.names[0]," can not be equal to ").concat(e.names[1])}},{key:"notValid",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Function,n={},r=!1,i=!0,s=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(i=(a=u.next()).done);i=!0){var c=a.value,d=c.name,l=c.names,h=c.value,f=c.type,v=c.gt,p=c.lt,g=c.gte,b=c.lte,m=(c.se,c.optional);if(!m||Le.isNotNullOrUndefined(h)&&("boolean"===f||!1!==h)){switch(n[c.name]=c.value,f){case"address":this.tronWeb.isAddress(h)?n[d]=this.tronWeb.address.toHex(h):r=!0;break;case"integer":(!Le.isInteger(h)||"number"==typeof v&&h<=c.gt||"number"==typeof p&&h>=c.lt||"number"==typeof g&&h<c.gte||"number"==typeof b&&h>c.lte)&&(r=!0);break;case"positive-integer":if(!Le.isInteger(h)||h<=0)return void t(this.notPositive(c));break;case"tokenId":Le.isString(h)&&h.length||(r=!0);break;case"notEmptyObject":Le.isObject(h)&&Object.keys(h).length||(r=!0);break;case"notEqual":if(n[l[0]]===n[l[1]])return t(this.notEqual(c)),!0;break;case"resource":["BANDWIDTH","ENERGY"].includes(h)||(r=!0);break;case"url":Le.isValidURL(h)||(r=!0);break;case"hex":Le.isHex(h)||(r=!0);break;case"array":Array.isArray(h)||(r=!0);break;case"not-empty-string":Le.isString(h)&&h.length||(r=!0);break;case"boolean":Le.isBoolean(h)||(r=!0);break;case"string":(!Le.isString(h)||"number"==typeof v&&h.length<=c.gt||"number"==typeof p&&h.length>=c.lt||"number"==typeof g&&h.length<c.gte||"number"==typeof b&&h.length>c.lte)&&(r=!0)}if(r)return t(this.invalid(c)),!0}}}catch(e){s=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(s)throw o}}return!1}}]),e}();function nt(e){return It.address.toHex(e)}function rt(e){return Ve.tronWeb.fromUtf8(e)}function it(e,t){return e.Error?t(e.Error):e.result&&e.result.message?t(Ve.tronWeb.toUtf8(e.result.message)):t(null,e)}var st=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b()(this,e),!t||!t instanceof It)throw new Error("Expected instance of TronWeb");Ve=this,this.tronWeb=t,this.injectPromise=$e()(this),this.validator=new tt(t)}var t,n,r,i;return y()(e,[{key:"sendTrx",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.tronWeb.defaultAddress.hex,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Le.isFunction(r)&&(i=r,r={}),Le.isFunction(n)?(i=n,n=this.tronWeb.defaultAddress.hex):Le.isObject(n)&&(r=n,n=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.sendTrx,e,t,n,r);if(t=parseInt(t),!this.validator.notValid([{name:"recipient",type:"address",value:e},{name:"origin",type:"address",value:n},{names:["recipient","origin"],type:"notEqual",msg:"Cannot transfer TRX to the same account"},{name:"amount",type:"integer",gt:0,value:t}],i)){var s={to_address:nt(e),owner_address:nt(n),amount:t};r&&r.permissionId&&(s.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/createtransaction",s,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}}},{key:"sendToken",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.tronWeb.defaultAddress.hex,i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(Le.isFunction(i)&&(s=i,i={}),Le.isFunction(r)?(s=r,r=this.tronWeb.defaultAddress.hex):Le.isObject(r)&&(i=r,r=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.sendToken,e,t,n,r,i);if(t=parseInt(t),!this.validator.notValid([{name:"recipient",type:"address",value:e},{name:"origin",type:"address",value:r},{names:["recipient","origin"],type:"notEqual",msg:"Cannot transfer tokens to the same account"},{name:"amount",type:"integer",gt:0,value:t},{name:"token ID",type:"tokenId",value:n}],s)){var o={to_address:nt(e),owner_address:nt(r),asset_name:rt(n),amount:parseInt(t)};i&&i.permissionId&&(o.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/transferasset",o,"post").then((function(e){return it(e,s)})).catch((function(e){return s(e)}))}}},{key:"purchaseToken",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.tronWeb.defaultAddress.hex,i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(Le.isFunction(i)&&(s=i,i={}),Le.isFunction(r)?(s=r,r=this.tronWeb.defaultAddress.hex):Le.isObject(r)&&(i=r,r=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.purchaseToken,e,t,n,r,i);if(!this.validator.notValid([{name:"buyer",type:"address",value:r},{name:"issuer",type:"address",value:e},{names:["buyer","issuer"],type:"notEqual",msg:"Cannot purchase tokens from same account"},{name:"amount",type:"integer",gt:0,value:n},{name:"token ID",type:"tokenId",value:t}],s)){var o={to_address:nt(e),owner_address:nt(r),asset_name:rt(t),amount:parseInt(n)};i&&i.permissionId&&(o.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/participateassetissue",o,"post").then((function(e){return it(e,s)})).catch((function(e){return s(e)}))}}},{key:"freezeBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"BANDWIDTH",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.tronWeb.defaultAddress.hex,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(Le.isFunction(s)&&(o=s,s={}),Le.isFunction(i)?(o=i,i=void 0):Le.isObject(i)&&(s=i,i=void 0),Le.isFunction(r)?(o=r,r=this.tronWeb.defaultAddress.hex):Le.isObject(r)&&(s=r,r=this.tronWeb.defaultAddress.hex),Le.isFunction(t)&&(o=t,t=3),Le.isFunction(n)&&(o=n,n="BANDWIDTH"),!o)return this.injectPromise(this.freezeBalance,e,t,n,r,i,s);if(!this.validator.notValid([{name:"origin",type:"address",value:r},{name:"receiver",type:"address",value:i,optional:!0},{name:"amount",type:"integer",gt:0,value:e},{name:"duration",type:"integer",gte:3,value:t},{name:"resource",type:"resource",value:n,msg:'Invalid resource provided: Expected "BANDWIDTH" or "ENERGY'}],o)){var a={owner_address:nt(r),frozen_balance:parseInt(e),frozen_duration:parseInt(t),resource:n};Le.isNotNullOrUndefined(i)&&nt(i)!==nt(r)&&(a.receiver_address=nt(i)),s&&s.permissionId&&(a.Permission_id=s.permissionId),this.tronWeb.fullNode.request("wallet/freezebalance",a,"post").then((function(e){return it(e,o)})).catch((function(e){return o(e)}))}}},{key:"unfreezeBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"BANDWIDTH",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Le.isFunction(r)&&(i=r,r={}),Le.isFunction(n)?(i=n,n=void 0):Le.isObject(n)&&(r=n,n=void 0),Le.isFunction(t)?(i=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),Le.isFunction(e)&&(i=e,e="BANDWIDTH"),!i)return this.injectPromise(this.unfreezeBalance,e,t,n,r);if(!this.validator.notValid([{name:"origin",type:"address",value:t},{name:"receiver",type:"address",value:n,optional:!0},{name:"resource",type:"resource",value:e,msg:'Invalid resource provided: Expected "BANDWIDTH" or "ENERGY'}],i)){var s={owner_address:nt(t),resource:e};Le.isNotNullOrUndefined(n)&&nt(n)!==nt(t)&&(s.receiver_address=nt(n)),r&&r.permissionId&&(s.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/unfreezebalance",s,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}}},{key:"withdrawBlockRewards",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)&&(n=t,t={}),Le.isFunction(e)?(n=e,e=this.tronWeb.defaultAddress.hex):Le.isObject(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.withdrawBlockRewards,e,t);if(!this.validator.notValid([{name:"origin",type:"address",value:e}],n)){var r={owner_address:nt(e)};t&&t.permissionId&&(r.Permission_id=t.permissionId),this.tronWeb.fullNode.request("wallet/withdrawbalance",r,"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}}},{key:"applyForSR",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(console.log(nt(e),Le.isObject(t)),Le.isFunction(n)&&(r=n,n={}),Le.isObject(t)&&Le.isValidURL(e)&&(n=t,t=e,e=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.applyForSR,e,t,n);if(!this.validator.notValid([{name:"origin",type:"address",value:e},{name:"url",type:"url",value:t,msg:"Invalid url provided"}],r)){console.log(nt(e));var i={owner_address:nt(e),url:rt(t)};n&&n.permissionId&&(i.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/createwitness",i,"post").then((function(e){return it(e,r)})).catch((function(e){return r(e)}))}}},{key:"vote",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Le.isFunction(r)&&(i=r,r={}),Le.isFunction(n)?(i=n,n=this.tronWeb.defaultAddress.hex):Le.isObject(n)&&(r=n,n=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.vote,t,n,r);if(!this.validator.notValid([{name:"voter",type:"address",value:n},{name:"votes",type:"notEmptyObject",value:t}],i)){var s=!1;if(t=Object.entries(t).map((function(t){var n=et()(t,2),r=n[0],i=n[1];if(!s)return e.validator.notValid([{name:"SR",type:"address",value:r},{name:"vote count",type:"integer",gt:0,value:i,msg:"Invalid vote count provided for SR: "+r}])?s=!0:{vote_address:nt(r),vote_count:parseInt(i)}})),!s){var o={owner_address:nt(n),votes:t};r&&r.permissionId&&(o.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/votewitnessaccount",o,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}}}},{key:"createSmartContract",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.createSmartContract,e,t);var r=e.feeLimit||1e9,i=e.userFeePercentage;"number"==typeof i||i||(i=100);var s=e.originEnergyLimit||1e7,o=e.callValue||0,a=e.tokenValue,u=e.tokenId||e.token_id,c=e.abi,d=void 0!==c&&c,l=e.bytecode,h=void 0!==l&&l,f=e.parameters,v=void 0===f?[]:f,p=e.name,g=void 0===p?"":p;if(d&&Le.isString(d))try{d=JSON.parse(d)}catch(e){return n("Invalid options.abi provided")}if(d.entrys&&(d=d.entrys),!Le.isArray(d))return n("Invalid options.abi provided");var b=d.some((function(e){return"constructor"==e.type&&e.payable}));if(!this.validator.notValid([{name:"bytecode",type:"hex",value:h},{name:"feeLimit",type:"integer",value:r,gt:0,lte:1e9},{name:"callValue",type:"integer",value:o,gte:0},{name:"userFeePercentage",type:"integer",value:i,gte:0,lte:100},{name:"originEnergyLimit",type:"integer",value:s,gte:0,lte:1e7},{name:"parameters",type:"array",value:v},{name:"issuer",type:"address",value:t},{name:"tokenValue",type:"integer",value:a,gte:0,optional:!0},{name:"tokenId",type:"integer",value:u,gte:0,optional:!0}],n)){if(b&&0==o&&0==a)return n("When contract is payable, options.callValue or options.tokenValue must be a positive integer");if(!b&&(o>0||a>0))return n("When contract is not payable, options.callValue and options.tokenValue must be 0");var m=d.find((function(e){return"constructor"===e.type}));if(void 0!==m&&m){var y=new fe,k=[],x=[];if(m=m.inputs,v.length!=m.length)return n("constructor needs ".concat(m.length," but ").concat(v.length," provided"));for(var w=0;w<v.length;w++){var I=m[w].type,W=v[w];if(!I||!Le.isString(I)||!I.length)return n("Invalid parameter type provided: "+I);"address"==I?W=nt(W).replace(L,"0x"):"address[]"==I&&(W=W.map((function(e){return nt(e).replace(L,"0x")}))),k.push(I),x.push(W)}try{v=y.encode(k,x).replace(/^(0x)/,"")}catch(e){return n(e)}}else v="";var A={owner_address:nt(t),fee_limit:parseInt(r),call_value:parseInt(o),consume_user_resource_percent:i,origin_energy_limit:s,abi:JSON.stringify(d),bytecode:h,parameter:v,name:g};Le.isNotNullOrUndefined(a)&&(A.call_token_value=parseInt(a)),Le.isNotNullOrUndefined(u)&&(A.token_id=parseInt(u)),e&&e.permissionId&&(A.Permission_id=e.permissionId),this.tronWeb.fullNode.request("wallet/deploycontract",A,"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}}},{key:"triggerSmartContract",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return"object"!==p()(t[2])&&(t[2]={feeLimit:t[2],callValue:t[3]},t.splice(3,1)),this._triggerSmartContract.apply(this,t)}},{key:"triggerConstantContract",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[2]._isConstant=!0,this.triggerSmartContract.apply(this,t)}},{key:"triggerConfirmedConstantContract",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[2]._isConstant=!0,t[2].confirmed=!0,this.triggerSmartContract.apply(this,t)}},{key:"_triggerSmartContract",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.tronWeb.defaultAddress.hex,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(Le.isFunction(i)&&(s=i,i=this.tronWeb.defaultAddress.hex),Le.isFunction(r)&&(s=r,r=[]),!s)return this.injectPromise(this._triggerSmartContract,e,t,n,r,i);var o=Object.assign({callValue:0,feeLimit:1e9},n),a=o.tokenValue,u=o.tokenId,c=o.callValue,d=o.feeLimit;if(!this.validator.notValid([{name:"feeLimit",type:"integer",value:d,gt:0,lte:1e9},{name:"callValue",type:"integer",value:c,gte:0},{name:"parameters",type:"array",value:r},{name:"contract",type:"address",value:e},{name:"issuer",type:"address",value:i,optional:!0},{name:"tokenValue",type:"integer",value:a,gte:0,optional:!0},{name:"tokenId",type:"integer",value:u,gte:0,optional:!0},{name:"function selector",type:"not-empty-string",value:t}],s)){if(t=t.replace("/s*/g",""),r.length){for(var l=new fe,h=[],f=[],v=0;v<r.length;v++){var p=r[v],g=p.type,b=p.value;if(!g||!Le.isString(g)||!g.length)return s("Invalid parameter type provided: "+g);"address"==g?b=nt(b).replace(L,"0x"):"address[]"==g&&(b=b.map((function(e){return nt(e).replace(L,"0x")}))),h.push(g),f.push(b)}try{h=h.map((function(e){return/trcToken/.test(e)&&(e=e.replace(/trcToken/,"uint256")),e})),r=l.encode(h,f).replace(/^(0x)/,"")}catch(e){return s(e)}}else r="";var m={contract_address:nt(e),owner_address:nt(i),function_selector:t,parameter:r};n._isConstant||(m.call_value=parseInt(c),m.fee_limit=parseInt(d),Le.isNotNullOrUndefined(a)&&(m.call_token_value=parseInt(a)),Le.isNotNullOrUndefined(u)&&(m.token_id=parseInt(u))),n.permissionId&&(m.Permission_id=n.permissionId),this.tronWeb[n.confirmed?"solidityNode":"fullNode"].request("wallet".concat(n.confirmed?"solidity":"","/trigger").concat(n._isConstant?"constant":"smart","contract"),m,"post").then((function(e){return it(e,s)})).catch((function(e){return s(e)}))}}},{key:"clearABI",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!n)return this.injectPromise(this.clearABI,e,t);if(!this.tronWeb.isAddress(e))return n("Invalid contract address provided");if(!this.tronWeb.isAddress(t))return n("Invalid owner address provided");var r={contract_address:nt(e),owner_address:nt(t)};this.tronWeb.trx.cache.contracts[e]&&delete this.tronWeb.trx.cache.contracts[e],this.tronWeb.fullNode.request("wallet/clearabi",r,"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}},{key:"updateBrokerage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!n)return this.injectPromise(this.updateBrokerage,e,t);if(!Le.isNotNullOrUndefined(e))return n("Invalid brokerage provided");if(!Le.isInteger(e)||e<0||e>100)return n("Brokerage must be an integer between 0 and 100");if(!this.tronWeb.isAddress(t))return n("Invalid owner address provided");var r={brokerage:parseInt(e),owner_address:nt(t)};this.tronWeb.fullNode.request("wallet/updateBrokerage",r,"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}},{key:"createToken",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.createToken,e,t);var r=e.name,i=void 0!==r&&r,s=e.abbreviation,o=void 0!==s&&s,a=e.description,u=void 0!==a&&a,c=e.url,d=void 0!==c&&c,l=e.totalSupply,h=void 0===l?0:l,f=e.trxRatio,v=void 0===f?1:f,p=e.tokenRatio,g=void 0===p?1:p,b=e.saleStart,m=void 0===b?Date.now():b,y=e.saleEnd,k=void 0!==y&&y,x=e.freeBandwidth,w=void 0===x?0:x,I=e.freeBandwidthLimit,W=void 0===I?0:I,A=e.frozenAmount,P=void 0===A?0:A,_=e.frozenDuration,N=void 0===_?0:_,S=e.voteScore,j=e.precision;if(!this.validator.notValid([{name:"Supply amount",type:"positive-integer",value:h},{name:"TRX ratio",type:"positive-integer",value:v},{name:"Token ratio",type:"positive-integer",value:g},{name:"token abbreviation",type:"not-empty-string",value:o},{name:"token name",type:"not-empty-string",value:i},{name:"token description",type:"not-empty-string",value:u},{name:"token url",type:"url",value:d},{name:"issuer",type:"address",value:t},{name:"sale start timestamp",type:"integer",value:m,gte:Date.now()},{name:"sale end timestamp",type:"integer",value:k,gt:m},{name:"Free bandwidth amount",type:"integer",value:w,gte:0},{name:"Free bandwidth limit",type:"integer",value:W,gte:0},{name:"Frozen supply",type:"integer",value:P,gte:0},{name:"Frozen duration",type:"integer",value:N,gte:0}],n)){if(Le.isNotNullOrUndefined(S)&&(!Le.isInteger(S)||S<=0))return n("voteScore must be a positive integer greater than 0");if(Le.isNotNullOrUndefined(j)&&(!Le.isInteger(j)||j<=0||j>6))return n("precision must be a positive integer > 0 and <= 6");var T={owner_address:nt(t),name:rt(i),abbr:rt(o),description:rt(u),url:rt(d),total_supply:parseInt(h),trx_num:parseInt(v),num:parseInt(g),start_time:parseInt(m),end_time:parseInt(k),free_asset_net_limit:parseInt(w),public_free_asset_net_limit:parseInt(W),frozen_supply:{frozen_amount:parseInt(P),frozen_days:parseInt(N)}};!this.tronWeb.fullnodeSatisfies(">=3.5.0")||parseInt(P)>0||delete T.frozen_supply,j&&!isNaN(parseInt(j))&&(T.precision=parseInt(j)),S&&!isNaN(parseInt(S))&&(T.vote_score=parseInt(S)),e&&e.permissionId&&(T.Permission_id=e.permissionId),this.tronWeb.fullNode.request("wallet/createassetissue",T,"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}}},{key:"updateAccount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Le.isFunction(n)&&(r=n,n={}),Le.isFunction(t)?(r=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.updateAccount,e,t,n);if(!this.validator.notValid([{name:"Name",type:"not-empty-string",value:e},{name:"origin",type:"address",value:t}],r)){var i={account_name:rt(e),owner_address:nt(t)};n&&n.permissionId&&(i.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/updateaccount",i,"post").then((function(e){return it(e,r)})).catch((function(e){return r(e)}))}}},{key:"setAccountId",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.setAccountId,e,t);e&&Le.isString(e)&&e.startsWith("0x")&&(e=e.slice(2)),this.validator.notValid([{name:"accountId",type:"hex",value:e},{name:"accountId",type:"string",lte:32,gte:8,value:e},{name:"origin",type:"address",value:t}],n)||this.tronWeb.fullNode.request("wallet/setaccountid",{account_id:e,owner_address:nt(t)},"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}},{key:"updateToken",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)?(n=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(e=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.updateToken,e,t);var r=e,i=r.description,s=void 0!==i&&i,o=r.url,a=void 0!==o&&o,u=r.freeBandwidth,c=void 0===u?0:u,d=r.freeBandwidthLimit,l=void 0===d?0:d;if(!this.validator.notValid([{name:"token description",type:"not-empty-string",value:s},{name:"token url",type:"url",value:a},{name:"issuer",type:"address",value:t},{name:"Free bandwidth amount",type:"positive-integer",value:c},{name:"Free bandwidth limit",type:"positive-integer",value:l}],n)){var h={owner_address:nt(t),description:rt(s),url:rt(a),new_limit:parseInt(c),new_public_limit:parseInt(l)};e&&e.permissionId&&(h.Permission_id=e.permissionId),this.tronWeb.fullNode.request("wallet/updateasset",h,"post").then((function(e){return it(e,n)})).catch((function(e){return n(e)}))}}},{key:"sendAsset",value:function(){return this.sendToken.apply(this,arguments)}},{key:"purchaseAsset",value:function(){return this.purchaseToken.apply(this,arguments)}},{key:"createAsset",value:function(){return this.createToken.apply(this,arguments)}},{key:"updateAsset",value:function(){return this.updateToken.apply(this,arguments)}},{key:"createProposal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Le.isFunction(n)&&(r=n,n={}),Le.isFunction(t)?(r=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.createProposal,e,t,n);if(!this.validator.notValid([{name:"issuer",type:"address",value:t}],r)){var i="Invalid proposal parameters provided";if(!e)return r(i);Le.isArray(e)||(e=[e]);var s=!0,o=!1,a=void 0;try{for(var u,c=e[Symbol.iterator]();!(s=(u=c.next()).done);s=!0){var d=u.value;if(!Le.isObject(d))return r(i)}}catch(e){o=!0,a=e}finally{try{s||null==c.return||c.return()}finally{if(o)throw a}}var l={owner_address:nt(t),parameters:e};n&&n.permissionId&&(l.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/proposalcreate",l,"post").then((function(e){return it(e,r)})).catch((function(e){return r(e)}))}}},{key:"deleteProposal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Le.isFunction(n)&&(r=n,n={}),Le.isFunction(t)?(r=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.deleteProposal,e,t,n);if(!this.validator.notValid([{name:"issuer",type:"address",value:t},{name:"proposalID",type:"integer",value:e,gte:0}],r)){var i={owner_address:nt(t),proposal_id:parseInt(e)};n&&n.permissionId&&(i.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/proposaldelete",i,"post").then((function(e){return it(e,r)})).catch((function(e){return r(e)}))}}},{key:"voteProposal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.tronWeb.defaultAddress.hex,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Le.isFunction(r)&&(i=r,r={}),Le.isFunction(n)?(i=n,n=this.tronWeb.defaultAddress.hex):Le.isObject(n)&&(r=n,n=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.voteProposal,e,t,n,r);if(!this.validator.notValid([{name:"voter",type:"address",value:n},{name:"proposalID",type:"integer",value:e,gte:0},{name:"has approval",type:"boolean",value:t}],i)){var s={owner_address:nt(n),proposal_id:parseInt(e),is_add_approval:t};r&&r.permissionId&&(s.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/proposalapprove",s,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}}},{key:"createTRXExchange",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.tronWeb.defaultAddress.hex,i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(Le.isFunction(i)&&(s=i,i={}),Le.isFunction(r)?(s=r,r=this.tronWeb.defaultAddress.hex):Le.isObject(r)&&(i=r,r=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.createTRXExchange,e,t,n,r,i);if(!this.validator.notValid([{name:"owner",type:"address",value:r},{name:"token name",type:"not-empty-string",value:e},{name:"token balance",type:"positive-integer",value:t},{name:"trx balance",type:"positive-integer",value:n}],s)){var o={owner_address:nt(r),first_token_id:rt(e),first_token_balance:t,second_token_id:"5f",second_token_balance:n};i&&i.permissionId&&(o.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/exchangecreate",o,"post").then((function(e){s(null,e)})).catch((function(e){return s(e)}))}}},{key:"createTokenExchange",value:function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.tronWeb.defaultAddress.hex,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(Le.isFunction(s)&&(o=s,s={}),Le.isFunction(i)?(o=i,i=this.tronWeb.defaultAddress.hex):Le.isObject(i)&&(s=i,i=this.tronWeb.defaultAddress.hex),!o)return this.injectPromise(this.createTokenExchange,e,t,n,r,i,s);if(!this.validator.notValid([{name:"owner",type:"address",value:i},{name:"first token name",type:"not-empty-string",value:e},{name:"second token name",type:"not-empty-string",value:n},{name:"first token balance",type:"positive-integer",value:t},{name:"second token balance",type:"positive-integer",value:r}],o)){var a={owner_address:nt(i),first_token_id:rt(e),first_token_balance:t,second_token_id:rt(n),second_token_balance:r};s&&s.permissionId&&(a.Permission_id=s.permissionId),this.tronWeb.fullNode.request("wallet/exchangecreate",a,"post").then((function(e){o(null,e)})).catch((function(e){return o(e)}))}}},{key:"injectExchangeTokens",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.tronWeb.defaultAddress.hex,i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(Le.isFunction(i)&&(s=i,i={}),Le.isFunction(r)?(s=r,r=this.tronWeb.defaultAddress.hex):Le.isObject(r)&&(i=r,r=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.injectExchangeTokens,e,t,n,r,i);if(!this.validator.notValid([{name:"owner",type:"address",value:r},{name:"token name",type:"not-empty-string",value:t},{name:"token amount",type:"integer",value:n,gte:1},{name:"exchangeID",type:"integer",value:e,gte:0}],s)){var o={owner_address:nt(r),exchange_id:parseInt(e),token_id:rt(t),quant:parseInt(n)};i&&i.permissionId&&(o.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/exchangeinject",o,"post").then((function(e){return it(e,s)})).catch((function(e){return s(e)}))}}},{key:"withdrawExchangeTokens",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.tronWeb.defaultAddress.hex,i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(Le.isFunction(i)&&(s=i,i={}),Le.isFunction(r)?(s=r,r=this.tronWeb.defaultAddress.hex):Le.isObject(r)&&(i=r,r=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.withdrawExchangeTokens,e,t,n,r,i);if(!this.validator.notValid([{name:"owner",type:"address",value:r},{name:"token name",type:"not-empty-string",value:t},{name:"token amount",type:"integer",value:n,gte:1},{name:"exchangeID",type:"integer",value:e,gte:0}],s)){var o={owner_address:nt(r),exchange_id:parseInt(e),token_id:rt(t),quant:parseInt(n)};i&&i.permissionId&&(o.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/exchangewithdraw",o,"post").then((function(e){return it(e,s)})).catch((function(e){return s(e)}))}}},{key:"tradeExchangeTokens",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.tronWeb.defaultAddress.hex,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(Le.isFunction(s)&&(o=s,s={}),Le.isFunction(i)?(o=i,i=this.tronWeb.defaultAddress.hex):Le.isObject(i)&&(s=i,i=this.tronWeb.defaultAddress.hex),!o)return this.injectPromise(this.tradeExchangeTokens,e,t,n,r,i,s);if(!this.validator.notValid([{name:"owner",type:"address",value:i},{name:"token name",type:"not-empty-string",value:t},{name:"tokenAmountSold",type:"integer",value:n,gte:1},{name:"tokenAmountExpected",type:"integer",value:r,gte:1},{name:"exchangeID",type:"integer",value:e,gte:0}],o)){var a={owner_address:nt(i),exchange_id:parseInt(e),token_id:this.tronWeb.fromAscii(t),quant:parseInt(n),expected:parseInt(r)};s&&s.permissionId&&(a.Permission_id=s.permissionId),this.tronWeb.fullNode.request("wallet/exchangetransaction",a,"post").then((function(e){return it(e,o)})).catch((function(e){return o(e)}))}}},{key:"updateSetting",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.tronWeb.defaultAddress.hex,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Le.isFunction(r)&&(i=r,r={}),Le.isFunction(n)?(i=n,n=this.tronWeb.defaultAddress.hex):Le.isObject(n)&&(r=n,n=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.updateSetting,e,t,n,r);if(!this.validator.notValid([{name:"owner",type:"address",value:n},{name:"contract",type:"address",value:e},{name:"userFeePercentage",type:"integer",value:t,gte:0,lte:100}],i)){var s={owner_address:nt(n),contract_address:nt(e),consume_user_resource_percent:t};r&&r.permissionId&&(s.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/updatesetting",s,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}}},{key:"updateEnergyLimit",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.tronWeb.defaultAddress.hex,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Le.isFunction(r)&&(i=r,r={}),Le.isFunction(n)?(i=n,n=this.tronWeb.defaultAddress.hex):Le.isObject(n)&&(r=n,n=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.updateEnergyLimit,e,t,n,r);if(!this.validator.notValid([{name:"owner",type:"address",value:n},{name:"contract",type:"address",value:e},{name:"originEnergyLimit",type:"integer",value:t,gte:0,lte:1e7}],i)){var s={owner_address:nt(n),contract_address:nt(e),origin_energy_limit:t};r&&r.permissionId&&(s.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/updateenergylimit",s,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}}},{key:"checkPermissions",value:function(e,t){if(e){if(e.type!==t||!e.permission_name||!Le.isString(e.permission_name)||!Le.isInteger(e.threshold)||e.threshold<1||!e.keys)return!1;var n=!0,r=!1,i=void 0;try{for(var s,o=e.keys[Symbol.iterator]();!(n=(s=o.next()).done);n=!0){var a=s.value;if(!this.tronWeb.isAddress(a.address)||!Le.isInteger(a.weight)||a.weight>e.threshold||a.weight<1||2===t&&!e.operations)return!1}}catch(e){r=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw i}}}return!0}},{key:"updateAccountPermissions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Le.isFunction(r)&&(i=r,r=!1),Le.isFunction(n)&&(i=n,n=r=!1),Le.isFunction(t)&&(i=t,t=n=r=!1),!i)return this.injectPromise(this.updateAccountPermissions,e,t,n,r);if(!this.tronWeb.isAddress(e))return i("Invalid ownerAddress provided");if(!this.checkPermissions(t,0))return i("Invalid ownerPermissions provided");if(!this.checkPermissions(n,1))return i("Invalid witnessPermissions provided");Array.isArray(r)||(r=[r]);var s=!0,o=!1,a=void 0;try{for(var u,c=r[Symbol.iterator]();!(s=(u=c.next()).done);s=!0){var d=u.value;if(!this.checkPermissions(d,2))return i("Invalid activesPermissions provided")}}catch(e){o=!0,a=e}finally{try{s||null==c.return||c.return()}finally{if(o)throw a}}var l={owner_address:e};t&&(l.owner=t),n&&(l.witness=n),r&&(l.actives=1===r.length?r[0]:r),this.tronWeb.fullNode.request("wallet/accountpermissionupdate",l,"post").then((function(e){return it(e,i)})).catch((function(e){return i(e)}))}},{key:"newTxID",value:(i=f()(l.a.mark((function e(t,n){return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return",this.injectPromise(this.newTxID,t));case 2:this.tronWeb.fullNode.request("wallet/getsignweight",t,"post").then((function(e){e=e.transaction.transaction,"boolean"==typeof t.visible&&(e.visible=t.visible),n(null,e)})).catch((function(e){return n("Error generating a new transaction id.")}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"alterTransaction",value:(r=f()(l.a.mark((function e(t){var n,r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2&&void 0!==i[2]&&i[2]){e.next=4;break}return e.abrupt("return",this.injectPromise(this.alterTransaction,t,n));case 4:if(!t.signature){e.next=6;break}return e.abrupt("return",r("You can not extend the expiration of a signed transaction."));case 6:if(!n.data){e.next=12;break}if("hex"!==n.dataFormat&&(n.data=this.tronWeb.toHex(n.data)),n.data=n.data.replace(/^0x/,""),0!==n.data.length){e.next=11;break}return e.abrupt("return",r("Invalid data provided"));case 11:t.raw_data.data=n.data;case 12:if(!n.extension){e.next=17;break}if(n.extension=parseInt(1e3*n.extension),!(isNaN(n.extension)||t.raw_data.expiration+n.extension<=Date.now()+3e3)){e.next=16;break}return e.abrupt("return",r("Invalid extension provided"));case 16:t.raw_data.expiration+=n.extension;case 17:this.newTxID(t,r);case 18:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"extendExpiration",value:(n=f()(l.a.mark((function e(t,n){var r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>2&&void 0!==i[2]&&i[2]){e.next=3;break}return e.abrupt("return",this.injectPromise(this.extendExpiration,t,n));case 3:this.alterTransaction(t,{extension:n},r);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"addUpdateData",value:(t=f()(l.a.mark((function e(t,n){var r,i,s=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]?s[2]:"utf8",i=s.length>3&&void 0!==s[3]&&s[3],Le.isFunction(r)&&(i=r,r="utf8"),i){e.next=5;break}return e.abrupt("return",this.injectPromise(this.addUpdateData,t,n,r));case 5:this.alterTransaction(t,{data:n,dataFormat:r},i);case 6:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}();function ot(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(n),!0).forEach((function(t){S()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ot(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ut="Ethereum Signed Message:\n32";function ct(e){return It.address.toHex(e)}var dt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b()(this,e),!t||!t instanceof It)throw new Error("Expected instance of TronWeb");this.tronWeb=t,this.injectPromise=$e()(this),this.cache={contracts:{}},this.validator=new tt(t)}var t,n,r,i,s,o,a,u,c,d,h,v,p,g,m,k,x;return y()(e,[{key:"_parseToken",value:function(e){return at({},e,{name:this.tronWeb.toUtf8(e.name),abbr:e.abbr&&this.tronWeb.toUtf8(e.abbr),description:e.description&&this.tronWeb.toUtf8(e.description),url:e.url&&this.tronWeb.toUtf8(e.url)})}},{key:"getCurrentBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.getCurrentBlock);this.tronWeb.fullNode.request("wallet/getnowblock").then((function(t){e(null,t)})).catch((function(t){return e(t)}))}},{key:"getConfirmedCurrentBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.getConfirmedCurrentBlock);this.tronWeb.solidityNode.request("walletsolidity/getnowblock").then((function(t){e(null,t)})).catch((function(t){return e(t)}))}},{key:"getBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultBlock,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultBlock),t?!1===e?t("No block identifier provided"):("earliest"==e&&(e=0),"latest"==e?this.getCurrentBlock(t):isNaN(e)&&Le.isHex(e)?this.getBlockByHash(e,t):void this.getBlockByNumber(e,t)):this.injectPromise(this.getBlock,e)}},{key:"getBlockByHash",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)return this.injectPromise(this.getBlockByHash,e);this.tronWeb.fullNode.request("wallet/getblockbyid",{value:e},"post").then((function(e){if(!Object.keys(e).length)return t("Block not found");t(null,e)})).catch((function(e){return t(e)}))}},{key:"getBlockByNumber",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?!Le.isInteger(e)||e<0?t("Invalid block number provided"):void this.tronWeb.fullNode.request("wallet/getblockbynum",{num:parseInt(e)},"post").then((function(e){if(!Object.keys(e).length)return t("Block not found");t(null,e)})).catch((function(e){return t(e)})):this.injectPromise(this.getBlockByNumber,e)}},{key:"getBlockTransactionCount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultBlock,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultBlock),!t)return this.injectPromise(this.getBlockTransactionCount,e);this.getBlock(e).then((function(e){var n=e.transactions;t(null,(void 0===n?[]:n).length)})).catch((function(e){return t(e)}))}},{key:"getTransactionFromBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultBlock,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)&&(n=t,t=0),Le.isFunction(e)&&(n=e,e=this.tronWeb.defaultBlock),!n)return this.injectPromise(this.getTransactionFromBlock,e,t);this.getBlock(e).then((function(e){var r=e.transactions,i=void 0!==r&&r;i?"number"==typeof t?t>=0&&t<i.length?n(null,i[t]):n("Invalid transaction index provided"):n(null,i):n("Transaction not found in block")})).catch((function(e){return n(e)}))}},{key:"getTransaction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)return this.injectPromise(this.getTransaction,e);this.tronWeb.fullNode.request("wallet/gettransactionbyid",{value:e},"post").then((function(e){if(!Object.keys(e).length)return t("Transaction not found");t(null,e)})).catch((function(e){return t(e)}))}},{key:"getConfirmedTransaction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)return this.injectPromise(this.getConfirmedTransaction,e);this.tronWeb.solidityNode.request("walletsolidity/gettransactionbyid",{value:e},"post").then((function(e){if(!Object.keys(e).length)return t("Transaction not found");t(null,e)})).catch((function(e){return t(e)}))}},{key:"getUnconfirmedTransactionInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this._getTransactionInfoById(e,{confirmed:!1},t)}},{key:"getTransactionInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this._getTransactionInfoById(e,{confirmed:!0},t)}},{key:"_getTransactionInfoById",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!n)return this.injectPromise(this._getTransactionInfoById,e,t);this.tronWeb[t.confirmed?"solidityNode":"fullNode"].request("wallet".concat(t.confirmed?"solidity":"","/gettransactioninfobyid"),{value:e},"post").then((function(e){n(null,e)})).catch((function(e){return n(e)}))}},{key:"getTransactionsToAddress",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Le.isFunction(n)&&(r=n,n=0),Le.isFunction(t)&&(r=t,t=30),r?(e=this.tronWeb.address.toHex(e),this.getTransactionsRelated(e,"to",t,n,r)):this.injectPromise(this.getTransactionsToAddress,e,t,n)}},{key:"getTransactionsFromAddress",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Le.isFunction(n)&&(r=n,n=0),Le.isFunction(t)&&(r=t,t=30),r?(e=this.tronWeb.address.toHex(e),this.getTransactionsRelated(e,"from",t,n,r)):this.injectPromise(this.getTransactionsFromAddress,e,t,n)}},{key:"getTransactionsRelated",value:(x=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u,c,d=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=d.length>0&&void 0!==d[0]?d[0]:this.tronWeb.defaultAddress.hex,n=d.length>1&&void 0!==d[1]?d[1]:"all",r=d.length>2&&void 0!==d[2]?d[2]:30,i=d.length>3&&void 0!==d[3]?d[3]:0,s=d.length>4&&void 0!==d[4]&&d[4],Le.isFunction(i)&&(s=i,i=0),Le.isFunction(r)&&(s=r,r=30),Le.isFunction(n)&&(s=n,n="all"),Le.isFunction(t)&&(s=t,t=this.tronWeb.defaultAddress.hex),s){e.next=11;break}return e.abrupt("return",this.injectPromise(this.getTransactionsRelated,t,n,r,i));case 11:if(["to","from","all"].includes(n)){e.next=13;break}return e.abrupt("return",s('Invalid direction provided: Expected "to", "from" or "all"'));case 13:if("all"!=n){e.next=27;break}return e.prev=14,e.next=17,Promise.all([this.getTransactionsRelated(t,"from",r,i),this.getTransactionsRelated(t,"to",r,i)]);case 17:return o=e.sent,a=et()(o,2),u=a[0],c=a[1],e.abrupt("return",s(null,[].concat(R()(u.map((function(e){return e.direction="from",e}))),R()(c.map((function(e){return e.direction="to",e})))).sort((function(e,t){return t.raw_data.timestamp-e.raw_data.timestamp}))));case 24:return e.prev=24,e.t0=e.catch(14),e.abrupt("return",s(e.t0));case 27:if(this.tronWeb.isAddress(t)){e.next=29;break}return e.abrupt("return",s("Invalid address provided"));case 29:if(!(!Le.isInteger(r)||r<0||i&&r<1)){e.next=31;break}return e.abrupt("return",s("Invalid limit provided"));case 31:if(Le.isInteger(i)&&!(i<0)){e.next=33;break}return e.abrupt("return",s("Invalid offset provided"));case 33:t=this.tronWeb.address.toHex(t),this.tronWeb.solidityNode.request("walletextension/gettransactions".concat(n,"this"),{account:{address:t},offset:i,limit:r},"post").then((function(e){var t=e.transaction;s(null,t)})).catch((function(e){return s(e)}));case 35:case"end":return e.stop()}}),e,this,[[14,24]])}))),function(){return x.apply(this,arguments)})},{key:"getAccount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),t?this.tronWeb.isAddress(e)?(e=this.tronWeb.address.toHex(e),void this.tronWeb.solidityNode.request("walletsolidity/getaccount",{address:e},"post").then((function(e){t(null,e)})).catch((function(e){return t(e)}))):t("Invalid address provided"):this.injectPromise(this.getAccount,e)}},{key:"getAccountById",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)return this.injectPromise(this.getAccountById,e);this.getAccountInfoById(e,{confirmed:!0},t)}},{key:"getAccountInfoById",value:function(e,t,n){this.validator.notValid([{name:"accountId",type:"hex",value:e},{name:"accountId",type:"string",lte:32,gte:8,value:e}],n)||(e.startsWith("0x")&&(e=e.slice(2)),this.tronWeb[t.confirmed?"solidityNode":"fullNode"].request("wallet".concat(t.confirmed?"solidity":"","/getaccountbyid"),{account_id:e},"post").then((function(e){n(null,e)})).catch((function(e){return n(e)})))}},{key:"getBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),!t)return this.injectPromise(this.getBalance,e);this.getAccount(e).then((function(e){var n=e.balance;t(null,void 0===n?0:n)})).catch((function(e){return t(e)}))}},{key:"getUnconfirmedAccount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),t?this.tronWeb.isAddress(e)?(e=this.tronWeb.address.toHex(e),void this.tronWeb.fullNode.request("wallet/getaccount",{address:e},"post").then((function(e){t(null,e)})).catch((function(e){return t(e)}))):t("Invalid address provided"):this.injectPromise(this.getUnconfirmedAccount,e)}},{key:"getUnconfirmedAccountById",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)return this.injectPromise(this.getUnconfirmedAccountById,e);this.getAccountInfoById(e,{confirmed:!1},t)}},{key:"getUnconfirmedBalance",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),!t)return this.injectPromise(this.getUnconfirmedBalance,e);this.getUnconfirmedAccount(e).then((function(e){var n=e.balance;t(null,void 0===n?0:n)})).catch((function(e){return t(e)}))}},{key:"getBandwidth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Le.isFunction(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),t?this.tronWeb.isAddress(e)?(e=this.tronWeb.address.toHex(e),void this.tronWeb.fullNode.request("wallet/getaccountnet",{address:e},"post").then((function(e){var n=e.freeNetUsed,r=void 0===n?0:n,i=e.freeNetLimit,s=void 0===i?0:i,o=e.NetUsed,a=void 0===o?0:o,u=e.NetLimit;t(null,s-r+((void 0===u?0:u)-a))})).catch((function(e){return t(e)}))):t("Invalid address provided"):this.injectPromise(this.getBandwidth,e)}},{key:"getTokensIssuedByAddress",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Le.isFunction(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),n?this.tronWeb.isAddress(t)?(t=this.tronWeb.address.toHex(t),void this.tronWeb.fullNode.request("wallet/getassetissuebyaccount",{address:t},"post").then((function(t){var r=t.assetIssue,i=void 0!==r&&r;if(!i)return n(null,{});var s=i.map((function(t){return e._parseToken(t)})).reduce((function(e,t){return e[t.name]=t,e}),{});n(null,s)})).catch((function(e){return n(e)}))):n("Invalid address provided"):this.injectPromise(this.getTokensIssuedByAddress,t)}},{key:"getTokenFromID",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n?(Le.isInteger(t)&&(t=t.toString()),Le.isString(t)&&t.length?void this.tronWeb.fullNode.request("wallet/getassetissuebyname",{value:this.tronWeb.fromUtf8(t)},"post").then((function(t){if(!t.name)return n("Token does not exist");n(null,e._parseToken(t))})).catch((function(e){return n(e)})):n("Invalid token ID provided")):this.injectPromise(this.getTokenFromID,t)}},{key:"listNodes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!t)return this.injectPromise(this.listNodes);this.tronWeb.fullNode.request("wallet/listnodes").then((function(n){var r=n.nodes;t(null,(void 0===r?[]:r).map((function(t){var n=t.address,r=n.host,i=n.port;return"".concat(e.tronWeb.toUtf8(r),":").concat(i)})))})).catch((function(e){return t(e)}))}},{key:"getBlockRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Le.isFunction(t)&&(n=t,t=30),Le.isFunction(e)&&(n=e,e=0),n?!Le.isInteger(e)||e<0?n("Invalid start of range provided"):!Le.isInteger(t)||t<=e?n("Invalid end of range provided"):void this.tronWeb.fullNode.request("wallet/getblockbylimitnext",{startNum:parseInt(e),endNum:parseInt(t)+1},"post").then((function(e){var t=e.block;n(null,void 0===t?[]:t)})).catch((function(e){return n(e)})):this.injectPromise(this.getBlockRange,e,t)}},{key:"listSuperRepresentatives",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.listSuperRepresentatives);this.tronWeb.fullNode.request("wallet/listwitnesses").then((function(t){var n=t.witnesses;e(null,void 0===n?[]:n)})).catch((function(t){return e(t)}))}},{key:"listTokens",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Le.isFunction(n)&&(r=n,n=0),Le.isFunction(t)&&(r=t,t=0),r?!Le.isInteger(t)||t<0||n&&t<1?r("Invalid limit provided"):!Le.isInteger(n)||n<0?r("Invalid offset provided"):t?void this.tronWeb.fullNode.request("wallet/getpaginatedassetissuelist",{offset:parseInt(n),limit:parseInt(t)},"post").then((function(t){var n=t.assetIssue;r(null,(void 0===n?[]:n).map((function(t){return e._parseToken(t)})))})).catch((function(e){return r(e)})):this.tronWeb.fullNode.request("wallet/getassetissuelist").then((function(t){var n=t.assetIssue;r(null,(void 0===n?[]:n).map((function(t){return e._parseToken(t)})))})).catch((function(e){return r(e)})):this.injectPromise(this.listTokens,t,n)}},{key:"timeUntilNextVoteCycle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.timeUntilNextVoteCycle);this.tronWeb.fullNode.request("wallet/getnextmaintenancetime").then((function(t){var n=t.num,r=void 0===n?-1:n;if(-1==r)return e("Failed to get time until next vote cycle");e(null,Math.floor(r/1e3))})).catch((function(t){return e(t)}))}},{key:"getContract",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n?this.tronWeb.isAddress(e)?void(this.cache.contracts[e]?n(null,this.cache.contracts[e]):(e=this.tronWeb.address.toHex(e),this.tronWeb.fullNode.request("wallet/getcontract",{value:e}).then((function(r){if(r.Error)return n("Contract does not exist");t.cache.contracts[e]=r,n(null,r)})).catch((function(e){return n(e)})))):n("Invalid contract address provided"):this.injectPromise(this.getContract,e)}},{key:"verifyMessage",value:(k=f()(l.a.mark((function t(){var n,r,i,s,o,a=arguments;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]&&a[1],i=a.length>2&&void 0!==a[2]?a[2]:this.tronWeb.defaultAddress.base58,s=!(a.length>3&&void 0!==a[3])||a[3],o=a.length>4&&void 0!==a[4]&&a[4],Le.isFunction(i)&&(o=i,i=this.tronWeb.defaultAddress.base58,s=!0),Le.isFunction(s)&&(o=s,s=!0),o){t.next=9;break}return t.abrupt("return",this.injectPromise(this.verifyMessage,n,r,i,s));case 9:if(Le.isHex(n)){t.next=11;break}return t.abrupt("return",o("Expected hex message input"));case 11:if(!e.verifySignature(n,i,r,s)){t.next=13;break}return t.abrupt("return",o(null,!0));case 13:o("Signature does not match");case 14:case"end":return t.stop()}}),t,this)}))),function(){return k.apply(this,arguments)})},{key:"sign",value:(m=f()(l.a.mark((function t(){var n,r,i,s,o,a,u=arguments;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>0&&void 0!==u[0]&&u[0],r=u.length>1&&void 0!==u[1]?u[1]:this.tronWeb.defaultPrivateKey,i=!(u.length>2&&void 0!==u[2])||u[2],s=u.length>3&&void 0!==u[3]&&u[3],o=u.length>4&&void 0!==u[4]&&u[4],Le.isFunction(s)&&(o=s,s=!1),Le.isFunction(i)&&(o=i,i=!0,s=!1),Le.isFunction(r)&&(o=r,r=this.tronWeb.defaultPrivateKey,i=!0,s=!1),o){t.next=10;break}return t.abrupt("return",this.injectPromise(this.sign,n,r,i,s));case 10:if(!Le.isString(n)){t.next=21;break}if(Le.isHex(n)){t.next=13;break}return t.abrupt("return",o("Expected hex message input"));case 13:return t.prev=13,a=e.signString(n,r,i),t.abrupt("return",o(null,a));case 18:t.prev=18,t.t0=t.catch(13),o(t.t0);case 21:if(Le.isObject(n)){t.next=23;break}return t.abrupt("return",o("Invalid transaction provided"));case 23:if(s||!n.signature){t.next=25;break}return t.abrupt("return",o("Transaction is already signed"));case 25:if(t.prev=25,s){t.next=30;break}if(this.tronWeb.address.toHex(this.tronWeb.address.fromPrivateKey(r)).toLowerCase()===n.raw_data.contract[0].parameter.value.owner_address.toLowerCase()){t.next=30;break}return t.abrupt("return",o("Private key does not match address in transaction"));case 30:return t.abrupt("return",o(null,Le.crypto.signTransaction(r,n)));case 33:t.prev=33,t.t1=t.catch(25),o(t.t1);case 36:case"end":return t.stop()}}),t,this,[[13,18],[25,33]])}))),function(){return m.apply(this,arguments)})},{key:"multiSign",value:(g=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=u.length>0&&void 0!==u[0]&&u[0],n=u.length>1&&void 0!==u[1]?u[1]:this.tronWeb.defaultPrivateKey,r=u.length>2&&void 0!==u[2]&&u[2],i=u.length>3&&void 0!==u[3]&&u[3],Le.isFunction(r)&&(i=r,r=0),Le.isFunction(n)&&(i=n,n=this.tronWeb.defaultPrivateKey,r=0),i){e.next=8;break}return e.abrupt("return",this.injectPromise(this.multiSign,t,n,r));case 8:if(Le.isObject(t)&&t.raw_data&&t.raw_data.contract){e.next=10;break}return e.abrupt("return",i("Invalid transaction provided"));case 10:if(t.raw_data.contract[0].Permission_id||!(r>0)){e.next=30;break}return t.raw_data.contract[0].Permission_id=r,s=this.tronWeb.address.toHex(this.tronWeb.address.fromPrivateKey(n)).toLowerCase(),e.next=15,this.getSignWeight(t,r);case 15:if("PERMISSION_ERROR"!==(o=e.sent).result.code){e.next=18;break}return e.abrupt("return",i(o.result.message));case 18:if(a=!1,o.permission.keys.map((function(e){e.address===s&&(a=!0)})),a){e.next=22;break}return e.abrupt("return",i(n+" has no permission to sign"));case 22:if(!o.approved_list||-1==o.approved_list.indexOf(s)){e.next=24;break}return e.abrupt("return",i(n+" already sign transaction"));case 24:if(!o.transaction||!o.transaction.transaction){e.next=29;break}t=o.transaction.transaction,r>0&&(t.raw_data.contract[0].Permission_id=r),e.next=30;break;case 29:return e.abrupt("return",i("Invalid transaction provided"));case 30:return e.prev=30,e.abrupt("return",i(null,Le.crypto.signTransaction(n,t)));case 34:e.prev=34,e.t0=e.catch(30),i(e.t0);case 37:case"end":return e.stop()}}),e,this,[[30,34]])}))),function(){return g.apply(this,arguments)})},{key:"getApprovedList",value:(p=f()(l.a.mark((function e(t){var n,r=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=r.length>1&&void 0!==r[1]&&r[1]){e.next=3;break}return e.abrupt("return",this.injectPromise(this.getApprovedList,t));case 3:if(Le.isObject(t)){e.next=5;break}return e.abrupt("return",n("Invalid transaction provided"));case 5:this.tronWeb.fullNode.request("wallet/getapprovedlist",t,"post").then((function(e){n(null,e)})).catch((function(e){return n(e)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getSignWeight",value:(v=f()(l.a.mark((function e(t,n){var r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>2&&void 0!==i[2]&&i[2],Le.isFunction(n)&&(r=n,n=void 0),r){e.next=4;break}return e.abrupt("return",this.injectPromise(this.getSignWeight,t,n));case 4:if(Le.isObject(t)&&t.raw_data&&t.raw_data.contract){e.next=6;break}return e.abrupt("return",r("Invalid transaction provided"));case 6:if(Le.isInteger(n)?t.raw_data.contract[0].Permission_id=parseInt(n):"number"!=typeof t.raw_data.contract[0].Permission_id&&(t.raw_data.contract[0].Permission_id=0),Le.isObject(t)){e.next=9;break}return e.abrupt("return",r("Invalid transaction provided"));case 9:this.tronWeb.fullNode.request("wallet/getsignweight",t,"post").then((function(e){r(null,e)})).catch((function(e){return r(e)}));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"sendRawTransaction",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Le.isFunction(t)&&(n=t,t={}),n?Le.isObject(e)?Le.isObject(t)?e.signature&&Le.isArray(e.signature)?void this.tronWeb.fullNode.request("wallet/broadcasttransaction",e,"post").then((function(t){t.result&&(t.transaction=e),n(null,t)})).catch((function(e){return n(e)})):n("Transaction is not signed"):n("Invalid options provided"):n("Invalid transaction provided"):this.injectPromise(this.sendRawTransaction,e,t)}},{key:"sendTransaction",value:(h=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u,c=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]&&c[0],n=c.length>1&&void 0!==c[1]&&c[1],r=c.length>2&&void 0!==c[2]?c[2]:{},i=c.length>3&&void 0!==c[3]&&c[3],Le.isFunction(r)&&(i=r,r={}),"string"==typeof r&&(r={privateKey:r}),i){e.next=8;break}return e.abrupt("return",this.injectPromise(this.sendTransaction,t,n,r));case 8:if(this.tronWeb.isAddress(t)){e.next=10;break}return e.abrupt("return",i("Invalid recipient provided"));case 10:if(Le.isInteger(n)&&!(n<=0)){e.next=12;break}return e.abrupt("return",i("Invalid amount provided"));case 12:if((r=at({privateKey:this.tronWeb.defaultPrivateKey,address:this.tronWeb.defaultAddress.hex},r)).privateKey||r.address){e.next=15;break}return e.abrupt("return",i("Function requires either a private key or address to be set"));case 15:return e.prev=15,s=r.privateKey?this.tronWeb.address.fromPrivateKey(r.privateKey):r.address,e.next=19,this.tronWeb.transactionBuilder.sendTrx(t,n,s);case 19:return o=e.sent,e.next=22,this.sign(o,r.privateKey||void 0);case 22:return a=e.sent,e.next=25,this.sendRawTransaction(a);case 25:return u=e.sent,e.abrupt("return",i(null,u));case 29:return e.prev=29,e.t0=e.catch(15),e.abrupt("return",i(e.t0));case 32:case"end":return e.stop()}}),e,this,[[15,29]])}))),function(){return h.apply(this,arguments)})},{key:"sendToken",value:(d=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u,c,d=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=d.length>0&&void 0!==d[0]&&d[0],n=d.length>1&&void 0!==d[1]&&d[1],r=d.length>2&&void 0!==d[2]&&d[2],i=d.length>3&&void 0!==d[3]?d[3]:{},s=d.length>4&&void 0!==d[4]&&d[4],Le.isFunction(i)&&(s=i,i={}),"string"==typeof i&&(i={privateKey:i}),s){e.next=9;break}return e.abrupt("return",this.injectPromise(this.sendToken,t,n,r,i));case 9:if(this.tronWeb.isAddress(t)){e.next=11;break}return e.abrupt("return",s("Invalid recipient provided"));case 11:if(Le.isInteger(n)&&!(n<=0)){e.next=13;break}return e.abrupt("return",s("Invalid amount provided"));case 13:if(Le.isInteger(r)&&(r=r.toString()),Le.isString(r)){e.next=16;break}return e.abrupt("return",s("Invalid token ID provided"));case 16:if((i=at({privateKey:this.tronWeb.defaultPrivateKey,address:this.tronWeb.defaultAddress.hex},i)).privateKey||i.address){e.next=19;break}return e.abrupt("return",s("Function requires either a private key or address to be set"));case 19:return e.prev=19,o=i.privateKey?this.tronWeb.address.fromPrivateKey(i.privateKey):i.address,e.next=23,this.tronWeb.transactionBuilder.sendToken(t,n,r,o);case 23:return a=e.sent,e.next=26,this.sign(a,i.privateKey||void 0);case 26:return u=e.sent,e.next=29,this.sendRawTransaction(u);case 29:return c=e.sent,e.abrupt("return",s(null,c));case 33:return e.prev=33,e.t0=e.catch(19),e.abrupt("return",s(e.t0));case 36:case"end":return e.stop()}}),e,this,[[19,33]])}))),function(){return d.apply(this,arguments)})},{key:"freezeBalance",value:(c=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u,c,d,h=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=h.length>0&&void 0!==h[0]?h[0]:0,n=h.length>1&&void 0!==h[1]?h[1]:3,r=h.length>2&&void 0!==h[2]?h[2]:"BANDWIDTH",i=h.length>3&&void 0!==h[3]?h[3]:{},s=h.length>4&&void 0!==h[4]?h[4]:void 0,o=h.length>5&&void 0!==h[5]&&h[5],Le.isFunction(s)&&(o=s,s=void 0),Le.isFunction(n)&&(o=n,n=3),Le.isFunction(r)&&(o=r,r="BANDWIDTH"),Le.isFunction(i)&&(o=i,i={}),"string"==typeof i&&(i={privateKey:i}),o){e.next=13;break}return e.abrupt("return",this.injectPromise(this.freezeBalance,t,n,r,i,s));case 13:if(["BANDWIDTH","ENERGY"].includes(r)){e.next=15;break}return e.abrupt("return",o('Invalid resource provided: Expected "BANDWIDTH" or "ENERGY"'));case 15:if(Le.isInteger(t)&&!(t<=0)){e.next=17;break}return e.abrupt("return",o("Invalid amount provided"));case 17:if(Le.isInteger(n)&&!(n<3)){e.next=19;break}return e.abrupt("return",o("Invalid duration provided, minimum of 3 days"));case 19:if((i=at({privateKey:this.tronWeb.defaultPrivateKey,address:this.tronWeb.defaultAddress.hex},i)).privateKey||i.address){e.next=22;break}return e.abrupt("return",o("Function requires either a private key or address to be set"));case 22:return e.prev=22,a=i.privateKey?this.tronWeb.address.fromPrivateKey(i.privateKey):i.address,e.next=26,this.tronWeb.transactionBuilder.freezeBalance(t,n,r,a,s);case 26:return u=e.sent,e.next=29,this.sign(u,i.privateKey||void 0);case 29:return c=e.sent,e.next=32,this.sendRawTransaction(c);case 32:return d=e.sent,e.abrupt("return",o(null,d));case 36:return e.prev=36,e.t0=e.catch(22),e.abrupt("return",o(e.t0));case 39:case"end":return e.stop()}}),e,this,[[22,36]])}))),function(){return c.apply(this,arguments)})},{key:"unfreezeBalance",value:(u=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u,c=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:"BANDWIDTH",n=c.length>1&&void 0!==c[1]?c[1]:{},r=c.length>2&&void 0!==c[2]?c[2]:void 0,i=c.length>3&&void 0!==c[3]&&c[3],Le.isFunction(r)&&(i=r,r=void 0),Le.isFunction(t)&&(i=t,t="BANDWIDTH"),Le.isFunction(n)&&(i=n,n={}),"string"==typeof n&&(n={privateKey:n}),i){e.next=10;break}return e.abrupt("return",this.injectPromise(this.unfreezeBalance,t,n,r));case 10:if(["BANDWIDTH","ENERGY"].includes(t)){e.next=12;break}return e.abrupt("return",i('Invalid resource provided: Expected "BANDWIDTH" or "ENERGY"'));case 12:if((n=at({privateKey:this.tronWeb.defaultPrivateKey,address:this.tronWeb.defaultAddress.hex},n)).privateKey||n.address){e.next=15;break}return e.abrupt("return",i("Function requires either a private key or address to be set"));case 15:return e.prev=15,s=n.privateKey?this.tronWeb.address.fromPrivateKey(n.privateKey):n.address,e.next=19,this.tronWeb.transactionBuilder.unfreezeBalance(t,s,r);case 19:return o=e.sent,e.next=22,this.sign(o,n.privateKey||void 0);case 22:return a=e.sent,e.next=25,this.sendRawTransaction(a);case 25:return u=e.sent,e.abrupt("return",i(null,u));case 29:return e.prev=29,e.t0=e.catch(15),e.abrupt("return",i(e.t0));case 32:case"end":return e.stop()}}),e,this,[[15,29]])}))),function(){return u.apply(this,arguments)})},{key:"updateAccount",value:(a=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=u.length>0&&void 0!==u[0]&&u[0],n=u.length>1&&void 0!==u[1]?u[1]:{},r=u.length>2&&void 0!==u[2]&&u[2],Le.isFunction(n)&&(r=n,n={}),"string"==typeof n&&(n={privateKey:n}),r){e.next=7;break}return e.abrupt("return",this.injectPromise(this.updateAccount,t,n));case 7:if(Le.isString(t)&&t.length){e.next=9;break}return e.abrupt("return",r("Name must be a string"));case 9:if((n=at({privateKey:this.tronWeb.defaultPrivateKey,address:this.tronWeb.defaultAddress.hex},n)).privateKey||n.address){e.next=12;break}return e.abrupt("return",r("Function requires either a private key or address to be set"));case 12:return e.prev=12,i=n.privateKey?this.tronWeb.address.fromPrivateKey(n.privateKey):n.address,e.next=16,this.tronWeb.transactionBuilder.updateAccount(t,i);case 16:return s=e.sent,e.next=19,this.sign(s,n.privateKey||void 0);case 19:return o=e.sent,e.next=22,this.sendRawTransaction(o);case 22:return a=e.sent,e.abrupt("return",r(null,a));case 26:return e.prev=26,e.t0=e.catch(12),e.abrupt("return",r(e.t0));case 29:case"end":return e.stop()}}),e,this,[[12,26]])}))),function(){return a.apply(this,arguments)})},{key:"signMessage",value:function(){return this.sign.apply(this,arguments)}},{key:"sendAsset",value:function(){return this.sendToken.apply(this,arguments)}},{key:"send",value:function(){return this.sendTransaction.apply(this,arguments)}},{key:"sendTrx",value:function(){return this.sendTransaction.apply(this,arguments)}},{key:"broadcast",value:function(){return this.sendRawTransaction.apply(this,arguments)}},{key:"signTransaction",value:function(){return this.sign.apply(this,arguments)}},{key:"getProposal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?!Le.isInteger(e)||e<0?t("Invalid proposalID provided"):void this.tronWeb.fullNode.request("wallet/getproposalbyid",{id:parseInt(e)},"post").then((function(e){t(null,e)})).catch((function(e){return t(e)})):this.injectPromise(this.getProposal,e)}},{key:"listProposals",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.listProposals);this.tronWeb.fullNode.request("wallet/listproposals",{},"post").then((function(t){var n=t.proposals;e(null,void 0===n?[]:n)})).catch((function(t){return e(t)}))}},{key:"getChainParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.getChainParameters);this.tronWeb.fullNode.request("wallet/getchainparameters",{},"post").then((function(t){var n=t.chainParameter;e(null,void 0===n?[]:n)})).catch((function(t){return e(t)}))}},{key:"getAccountResources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.tronWeb.defaultAddress.hex,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?this.tronWeb.isAddress(e)?void this.tronWeb.fullNode.request("wallet/getaccountresource",{address:this.tronWeb.address.toHex(e)},"post").then((function(e){t(null,e)})).catch((function(e){return t(e)})):t("Invalid address provided"):this.injectPromise(this.getAccountResources,e)}},{key:"getExchangeByID",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t?!Le.isInteger(e)||e<0?t("Invalid exchangeID provided"):void this.tronWeb.fullNode.request("wallet/getexchangebyid",{id:e},"post").then((function(e){t(null,e)})).catch((function(e){return t(e)})):this.injectPromise(this.getExchangeByID,e)}},{key:"listExchanges",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.listExchanges);this.tronWeb.fullNode.request("wallet/listexchanges",{},"post").then((function(t){var n=t.exchanges;e(null,void 0===n?[]:n)}),"post").catch((function(t){return e(t)}))}},{key:"listExchangesPaginated",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Le.isFunction(t)&&(n=t,t=0),Le.isFunction(e)&&(n=e,e=30),!n)return this.injectPromise(this.listExchanges);this.tronWeb.fullNode.request("wallet/listexchangespaginated",{limit:e,offset:t},"post").then((function(e){var t=e.exchanges;n(null,void 0===t?[]:t)})).catch((function(e){return n(e)}))}},{key:"getNodeInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e)return this.injectPromise(this.getNodeInfo);this.tronWeb.fullNode.request("wallet/getnodeinfo",{},"post").then((function(t){e(null,t)}),"post").catch((function(t){return e(t)}))}},{key:"getTokenListByName",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n?(Le.isInteger(t)&&(t=t.toString()),Le.isString(t)&&t.length?void this.tronWeb.fullNode.request("wallet/getassetissuelistbyname",{value:this.tronWeb.fromUtf8(t)},"post").then((function(t){if(Array.isArray(t.assetIssue))n(null,t.assetIssue.map((function(t){return e._parseToken(t)})));else if(!t.name)return n("Token does not exist");n(null,e._parseToken(t))})).catch((function(e){return n(e)})):n("Invalid token ID provided")):this.injectPromise(this.getTokenListByName,t)}},{key:"getTokenByID",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n?(Le.isInteger(t)&&(t=t.toString()),Le.isString(t)&&t.length?void this.tronWeb.fullNode.request("wallet/getassetissuebyid",{value:t},"post").then((function(t){if(!t.name)return n("Token does not exist");n(null,e._parseToken(t))})).catch((function(e){return n(e)})):n("Invalid token ID provided")):this.injectPromise(this.getTokenByID,t)}},{key:"getReward",value:(o=f()(l.a.mark((function e(t){var n,r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2&&void 0!==i[2]&&i[2],n.confirmed=!0,e.abrupt("return",this._getReward(t,n,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getUnconfirmedReward",value:(s=f()(l.a.mark((function e(t){var n,r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2&&void 0!==i[2]&&i[2],n.confirmed=!1,e.abrupt("return",this._getReward(t,n,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getBrokerage",value:(i=f()(l.a.mark((function e(t){var n,r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2&&void 0!==i[2]&&i[2],n.confirmed=!0,e.abrupt("return",this._getBrokerage(t,n,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getUnconfirmedBrokerage",value:(r=f()(l.a.mark((function e(t){var n,r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2&&void 0!==i[2]&&i[2],n.confirmed=!1,e.abrupt("return",this._getBrokerage(t,n,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getReward",value:(n=f()(l.a.mark((function e(){var t,n,r,i,s=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:this.tronWeb.defaultAddress.hex,n=s.length>1?s[1]:void 0,r=s.length>2&&void 0!==s[2]&&s[2],Le.isFunction(n)&&(r=n,n={}),Le.isFunction(t)?(r=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),r){e.next=7;break}return e.abrupt("return",this.injectPromise(this._getReward,t,n));case 7:if(!this.validator.notValid([{name:"origin",type:"address",value:t}],r)){e.next=9;break}return e.abrupt("return");case 9:i={address:ct(t)},this.tronWeb[n.confirmed?"solidityNode":"fullNode"].request("wallet".concat(n.confirmed?"solidity":"","/getReward"),i,"post").then((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(void 0===e.reward)return r("Not found.");r(null,e.reward)})).catch((function(e){return r(e)}));case 11:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_getBrokerage",value:(t=f()(l.a.mark((function e(){var t,n,r,i,s=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:this.tronWeb.defaultAddress.hex,n=s.length>1?s[1]:void 0,r=s.length>2&&void 0!==s[2]&&s[2],Le.isFunction(n)&&(r=n,n={}),Le.isFunction(t)?(r=t,t=this.tronWeb.defaultAddress.hex):Le.isObject(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),r){e.next=7;break}return e.abrupt("return",this.injectPromise(this._getBrokerage,t,n));case 7:if(!this.validator.notValid([{name:"origin",type:"address",value:t}],r)){e.next=9;break}return e.abrupt("return");case 9:i={address:ct(t)},this.tronWeb[n.confirmed?"solidityNode":"fullNode"].request("wallet".concat(n.confirmed?"solidity":"","/getBrokerage"),i,"post").then((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(void 0===e.brokerage)return r("Not found.");r(null,e.brokerage)})).catch((function(e){return r(e)}));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"verifySignature",value:function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];e=e.replace(/^0x/,""),n=n.replace(/^0x/,"");var i=[].concat(R()(de(r?"TRON Signed Message:\n32":ut)),R()(Le.code.hexStr2byteArray(e))),s=ue(i),o=le(s,{recoveryParam:"1c"==n.substring(128,130)?1:0,r:"0x"+n.substring(0,64),s:"0x"+n.substring(64,128)}),a=U+o.substr(2),u=It.address.fromHex(a);return u==It.address.fromHex(t)}},{key:"signString",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e=e.replace(/^0x/,"");var r=new he(t),i=[].concat(R()(de(n?"TRON Signed Message:\n32":ut)),R()(Le.code.hexStr2byteArray(e))),s=ue(i),o=r.signDigest(s),a=["0x",o.r.substring(2),o.s.substring(2),Number(o.v).toString(16)].join("");return a}}]),e}();function lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ht(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(n),!0).forEach((function(t){S()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ft=function(e){return e.name+"("+vt(e.inputs||[]).join(",")+")"},vt=function(e){return e.map((function(e){return e.type}))},pt=function(e,t){var n=e.map((function(e){return e.name})).filter((function(e){return!!e})),r=e.map((function(e){return e.type}));return Le.abi.decodeParams(n,r,t)},gt=function(){function e(t,n){b()(this,e),this.tronWeb=t.tronWeb,this.contract=t,this.abi=n,this.name=n.name||(n.name=n.type),this.inputs=n.inputs||[],this.outputs=n.outputs||[],this.functionSelector=ft(n),this.signature=this.tronWeb.sha3(this.functionSelector,!1).slice(0,8),this.injectPromise=$e()(this),this.defaultOptions={feeLimit:1e9,callValue:0,userFeePercentage:100,shouldPollResponse:!1}}var t,n,r;return y()(e,[{key:"decodeInput",value:function(e){return pt(this.inputs,"0x"+e)}},{key:"onMethod",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=vt(this.inputs);return n.forEach((function(t,r){"address"==i[r]&&(n[r]=e.tronWeb.address.toHex(t).replace(L,"0x")),"address[]"==i[r]&&(n[r]=n[r].map((function(t){return e.tronWeb.address.toHex(t).replace(L,"0x")})))})),{call:function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return e._call.apply(e,[i,n].concat(r))},send:function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return e._send.apply(e,[i,n].concat(r))},watch:function(){return e._watch.apply(e,arguments)}}}},{key:"_call",value:(r=f()(l.a.mark((function e(t,n){var r,i,s,o,a=this,u=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>2&&void 0!==u[2]?u[2]:{},i=u.length>3&&void 0!==u[3]&&u[3],Le.isFunction(r)&&(i=r,r={}),i){e.next=5;break}return e.abrupt("return",this.injectPromise(this._call,t,n,r));case 5:if(t.length===n.length){e.next=7;break}return e.abrupt("return",i("Invalid argument count provided"));case 7:if(this.contract.address){e.next=9;break}return e.abrupt("return",i("Smart contract is missing address"));case 9:if(this.contract.deployed){e.next=11;break}return e.abrupt("return",i("Calling smart contracts requires you to load the contract first"));case 11:if(s=this.abi.stateMutability,["pure","view"].includes(s.toLowerCase())){e.next=14;break}return e.abrupt("return",i('Methods with state mutability "'.concat(s,'" must use send()')));case 14:r=ht({},this.defaultOptions,{from:this.tronWeb.defaultAddress.hex},r),o=n.map((function(e,n){return{type:t[n],value:e}})),this.tronWeb.transactionBuilder.triggerSmartContract(this.contract.address,this.functionSelector,r,o,!!r.from&&this.tronWeb.address.toHex(r.from),(function(e,t){if(e)return i(e);if(!Le.hasProperty(t,"constant_result"))return i("Failed to execute");try{var n=t.constant_result[0].length;if(0===n||n%64==8){var r="The call has been reverted or has thrown an error.";if(0!==n){r+=" Error message: ";for(var s="",o=t.constant_result[0].substring(8),u=0;u<n-8;u+=64)s+=a.tronWeb.toUtf8(o.substring(u,u+64));r+=s.replace(/(\u0000|\u000b|\f)+/g," ").replace(/ +/g," ").replace(/\s+$/g,"")}return i(r)}var c=pt(a.outputs,"0x"+t.constant_result[0]);return 1===c.length&&(c=c[0]),i(null,c)}catch(e){return i(e)}}));case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_send",value:(n=f()(l.a.mark((function e(t,n){var r,i,s,o,a,u,c,d,h,v,p,g=this,b=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=b.length>2&&void 0!==b[2]?b[2]:{},i=b.length>3&&void 0!==b[3]?b[3]:this.tronWeb.defaultPrivateKey,s=b.length>4&&void 0!==b[4]&&b[4],Le.isFunction(i)&&(s=i,i=this.tronWeb.defaultPrivateKey),Le.isFunction(r)&&(s=r,r={}),s){e.next=7;break}return e.abrupt("return",this.injectPromise(this._send,t,n,r,i));case 7:if(t.length===n.length){e.next=9;break}throw new Error("Invalid argument count provided");case 9:if(this.contract.address){e.next=11;break}return e.abrupt("return",s("Smart contract is missing address"));case 11:if(this.contract.deployed){e.next=13;break}return e.abrupt("return",s("Calling smart contracts requires you to load the contract first"));case 13:if(o=this.abi.stateMutability,!["pure","view"].includes(o.toLowerCase())){e.next=16;break}return e.abrupt("return",s('Methods with state mutability "'.concat(o,'" must use call()')));case 16:return["payable"].includes(o.toLowerCase())||(r.callValue=0),r=ht({},this.defaultOptions,{from:this.tronWeb.defaultAddress.hex},r),a=n.map((function(e,n){return{type:t[n],value:e}})),e.prev=19,u=i?this.tronWeb.address.fromPrivateKey(i):this.tronWeb.defaultAddress.base58,e.next=23,this.tronWeb.transactionBuilder.triggerSmartContract(this.contract.address,this.functionSelector,r,a,this.tronWeb.address.toHex(u));case 23:if((c=e.sent).result&&c.result.result){e.next=26;break}return e.abrupt("return",s("Unknown error: "+JSON.stringify(c,null,2)));case 26:return e.next=28,this.tronWeb.trx.sign(c.transaction,i);case 28:if((d=e.sent).signature){e.next=33;break}if(i){e.next=32;break}return e.abrupt("return",s("Transaction was not signed properly"));case 32:return e.abrupt("return",s("Invalid private key provided"));case 33:return e.next=35,this.tronWeb.trx.sendRawTransaction(d);case 35:if(!(h=e.sent).code){e.next=40;break}return v={error:h.code,message:h.code},h.message&&(v.message=this.tronWeb.toUtf8(h.message)),e.abrupt("return",s(v));case 40:if(r.shouldPollResponse){e.next=42;break}return e.abrupt("return",s(null,d.txID));case 42:(p=function(){var e=f()(l.a.mark((function e(){var t,n,i,o=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(20!==(t=o.length>0&&void 0!==o[0]?o[0]:0)){e.next=3;break}return e.abrupt("return",s({error:"Cannot find result in solidity node",transaction:d}));case 3:return e.next=5,g.tronWeb.trx.getTransactionInfo(d.txID);case 5:if(n=e.sent,Object.keys(n).length){e.next=8;break}return e.abrupt("return",setTimeout((function(){p(t+1)}),3e3));case 8:if(!n.result||"FAILED"!==n.result){e.next=10;break}return e.abrupt("return",s({error:g.tronWeb.toUtf8(n.resMessage),transaction:d,output:n}));case 10:if(Le.hasProperty(n,"contractResult")){e.next=12;break}return e.abrupt("return",s({error:"Failed to execute: "+JSON.stringify(n,null,2),transaction:d,output:n}));case 12:if(!r.rawResponse){e.next=14;break}return e.abrupt("return",s(null,n));case 14:if(1===(i=pt(g.outputs,"0x"+n.contractResult[0])).length&&(i=i[0]),!r.keepTxID){e.next=18;break}return e.abrupt("return",s(null,[d.txID,i]));case 18:return e.abrupt("return",s(null,i));case 19:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}())(),e.next=49;break;case 46:return e.prev=46,e.t0=e.catch(19),e.abrupt("return",s(e.t0));case 49:case"end":return e.stop()}}),e,this,[[19,46]])}))),function(e,t){return n.apply(this,arguments)})},{key:"_watch",value:(t=f()(l.a.mark((function e(){var t,n,r,i,s,o,a,u=this,c=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:{},n=c.length>1&&void 0!==c[1]&&c[1],Le.isFunction(t)&&(n=t,t={}),Le.isFunction(n)){e.next=5;break}throw new Error("Expected callback to be provided");case 5:if(this.contract.address){e.next=7;break}return e.abrupt("return",n("Smart contract is missing address"));case 7:if(this.abi.type&&/event/i.test(this.abi.type)){e.next=9;break}return e.abrupt("return",n("Invalid method type for event watching"));case 9:if(this.tronWeb.eventServer){e.next=11;break}return e.abrupt("return",n("No event server configured"));case 11:return r=!1,i=!1,s=Date.now()-1e3,o=function(){var e=f()(l.a.mark((function e(){var n,r,o,a,c,d;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={since:s,eventName:u.name,sort:"block_timestamp",blockNumber:"latest",filters:t.filters},t.resourceNode&&(/full/i.test(t.resourceNode)?n.onlyUnconfirmed=!0:n.onlyConfirmed=!0),e.next=5,u.tronWeb.event.getEventsByContractAddress(u.contract.address,n);case 5:return r=e.sent,o=r.sort((function(e,t){return t.block-e.block})),a=et()(o,1),c=a[0],d=r.filter((function(e,n){return!(t.resourceNode&&e.resourceNode&&t.resourceNode.toLowerCase()!==e.resourceNode.toLowerCase()||r.slice(0,n).some((function(t){return JSON.stringify(t)==JSON.stringify(e)}))||i&&!(e.block>i))})),c&&(i=c.block),e.abrupt("return",d);case 12:return e.prev=12,e.t0=e.catch(0),e.abrupt("return",Promise.reject(e.t0));case 15:case"end":return e.stop()}}),e,null,[[0,12]])})));return function(){return e.apply(this,arguments)}}(),a=function(){r&&clearInterval(r),r=setInterval((function(){o().then((function(e){return e.forEach((function(e){n(null,Le.parseEvent(e,u.abi))}))})).catch((function(e){return n(e)}))}),3e3)},e.next=18,o();case 18:return a(),e.abrupt("return",{start:a(),stop:function(){r&&(clearInterval(r),r=!1)}});case 20:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),bt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(b()(this,e),!t||!t instanceof It)throw new Error("Expected instance of TronWeb");this.tronWeb=t,this.injectPromise=$e()(this),this.address=r,this.abi=n,this.eventListener=!1,this.bytecode=!1,this.deployed=!1,this.lastBlock=!1,this.methods={},this.methodInstances={},this.props=[],this.tronWeb.isAddress(r)?this.deployed=!0:this.address=!1,this.loadAbi(n)}var t,n,r,i;return y()(e,[{key:"_getEvents",value:(i=f()(l.a.mark((function e(){var t,n,r,i,s,o,a=this,u=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:{},e.next=3,this.tronWeb.event.getEventsByContractAddress(this.address,t);case 3:return n=e.sent,r=n.sort((function(e,t){return t.block-e.block})),i=et()(r,1),s=i[0],o=n.filter((function(e,r){return!(t.resourceNode&&e.resourceNode&&t.resourceNode.toLowerCase()!==e.resourceNode.toLowerCase()||n.slice(0,r).some((function(t){return JSON.stringify(t)==JSON.stringify(e)}))||a.lastBlock&&!(e.block>a.lastBlock))})),s&&(this.lastBlock=s.block),e.abrupt("return",o);case 8:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_startEventListener",value:(r=f()(l.a.mark((function e(){var t,n,r=this,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},n=i.length>1?i[1]:void 0,Le.isFunction(t)&&(n=t,t={}),this.eventListener&&clearInterval(this.eventListener),this.tronWeb.eventServer){e.next=6;break}throw new Error("Event server is not configured");case 6:if(this.address){e.next=8;break}throw new Error("Contract is not configured with an address");case 8:return this.eventCallback=n,e.next=11,this._getEvents(t);case 11:this.eventListener=setInterval((function(){r._getEvents(t).then((function(e){return e.forEach((function(e){r.eventCallback&&r.eventCallback(e)}))})).catch((function(e){console.error("Failed to get event list",e)}))}),3e3);case 12:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_stopEventListener",value:function(){this.eventListener&&(clearInterval(this.eventListener),this.eventListener=!1,this.eventCallback=!1)}},{key:"hasProperty",value:function(e){return this.hasOwnProperty(e)||this.__proto__.hasOwnProperty(e)}},{key:"loadAbi",value:function(e){var t=this;this.abi=e,this.methods={},this.props.forEach((function(e){return delete t[e]})),e.forEach((function(e){if(e.type&&!/constructor/i.test(e.type)){var n=new gt(t,e),r=n.onMethod.bind(n),i=n.name,s=n.functionSelector,o=n.signature;t.methods[i]=r,t.methods[s]=r,t.methods[o]=r,t.methodInstances[i]=n,t.methodInstances[s]=n,t.methodInstances[o]=n,t.hasProperty(i)||(t[i]=r,t.props.push(i)),t.hasProperty(s)||(t[s]=r,t.props.push(s)),t.hasProperty(o)||(t[o]=r,t.props.push(o))}}))}},{key:"decodeInput",value:function(e){var t=e.substring(0,8),n=e.substring(8);if(!this.methodInstances[t])throw new Error("Contract method "+t+" not found");return{name:this.methodInstances[t].name,params:this.methodInstances[t].decodeInput(n)}}},{key:"new",value:(n=f()(l.a.mark((function e(t){var n,r,i,s,o,a,u=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.length>1&&void 0!==u[1]?u[1]:this.tronWeb.defaultPrivateKey,r=u.length>2&&void 0!==u[2]&&u[2],Le.isFunction(n)&&(r=n,n=this.tronWeb.defaultPrivateKey),r){e.next=5;break}return e.abrupt("return",this.injectPromise(this.new,t,n));case 5:return e.prev=5,i=this.tronWeb.address.fromPrivateKey(n),e.next=9,this.tronWeb.transactionBuilder.createSmartContract(t,i);case 9:return s=e.sent,e.next=12,this.tronWeb.trx.sign(s,n);case 12:return o=e.sent,e.next=15,this.tronWeb.trx.sendRawTransaction(o);case 15:if(!(a=e.sent).code){e.next=18;break}return e.abrupt("return",r({error:a.code,message:this.tronWeb.toUtf8(a.message)}));case 18:return e.next=20,Le.sleep(3e3);case 20:return e.abrupt("return",this.at(o.contract_address,r));case 23:return e.prev=23,e.t0=e.catch(5),e.abrupt("return",r(e.t0));case 26:case"end":return e.stop()}}),e,this,[[5,23]])}))),function(e){return n.apply(this,arguments)})},{key:"at",value:(t=f()(l.a.mark((function e(t){var n,r,i=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=i.length>1&&void 0!==i[1]&&i[1]){e.next=3;break}return e.abrupt("return",this.injectPromise(this.at,t));case 3:return e.prev=3,e.next=6,this.tronWeb.trx.getContract(t);case 6:if((r=e.sent).contract_address){e.next=9;break}return e.abrupt("return",n("Unknown error: "+JSON.stringify(r,null,2)));case 9:return this.address=r.contract_address,this.bytecode=r.bytecode,this.deployed=!0,this.loadAbi(r.abi?r.abi.entrys:[]),e.abrupt("return",n(null,this));case 16:if(e.prev=16,e.t0=e.catch(3),!e.t0.toString().includes("does not exist")){e.next=20;break}return e.abrupt("return",n("Contract has not been deployed on the network"));case 20:return e.abrupt("return",n(e.t0));case 21:case"end":return e.stop()}}),e,this,[[3,16]])}))),function(e){return t.apply(this,arguments)})},{key:"events",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Le.isFunction(e)&&(t=e,e={}),!Le.isFunction(t))throw new Error("Callback function expected");var n=this;return{start:function(){var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return r?(n._startEventListener(e,t).then((function(){r()})).catch((function(e){r(e)})),this):(n._startEventListener(e,t),this)},stop:function(){n._stopEventListener()}}}}]),e}(),mt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(b()(this,e),!t||!t instanceof It)throw new Error("Expected instance of TronWeb");this.tronWeb=t,this.pluginNoOverride=["register"],this.disablePlugins=n.disablePlugins}return y()(e,[{key:"register",value:function(e,t){var n={requires:"0.0.0",components:{}},r={libs:[],plugged:[],skipped:[]};if(this.disablePlugins)return r.error="This instance of TronWeb has plugins disabled.",r;var i=new e(this.tronWeb);if(Le.isFunction(i.pluginInterface)&&(n=i.pluginInterface(t)),!Xe.a.satisfies(It.version,n.requires))throw new Error("The plugin is not compatible with this version of TronWeb");if(n.fullClass){var s=i.constructor.name,o=s.substring(0,1).toLowerCase()+s.substring(1);s!==o&&(It[s]=e,this.tronWeb[o]=i,r.libs.push(s))}else for(var a in n.components)if(this.tronWeb.hasOwnProperty(a)){var u=n.components[a],c=this.tronWeb[a].pluginNoOverride||[];for(var d in u)"constructor"===d||this.tronWeb[a][d]&&(c.includes(d)||/^_/.test(d))?r.skipped.push(d):(this.tronWeb[a][d]=u[d].bind(this.tronWeb[a]),r.plugged.push(d))}return r}}]),e}(),yt=n(21),kt=n.n(yt),xt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b()(this,e),!(t&&t instanceof It))throw new Error("Expected instance of TronWeb");this.tronWeb=t,this.injectPromise=$e()(this)}return y()(e,[{key:"setServer",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"healthcheck";if(!t)return this.tronWeb.eventServer=!1;if(Le.isString(t)&&(t=new ze.HttpProvider(t)),!this.tronWeb.isValidProvider(t))throw new Error("Invalid event server provided");this.tronWeb.eventServer=t,this.tronWeb.eventServer.isConnected=function(){return e.tronWeb.eventServer.request(n).then((function(){return!0})).catch((function(){return!1}))}}},{key:"getEventsByContractAddress",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=Object.assign({sinceTimestamp:0,eventName:!1,blockNumber:!1,size:20,page:1},t),i=r.sinceTimestamp,s=r.since,o=r.fromTimestamp,a=r.eventName,u=r.blockNumber,c=r.size,d=r.page,l=r.onlyConfirmed,h=r.onlyUnconfirmed,f=r.previousLastEventFingerprint,v=r.previousFingerprint,g=r.fingerprint,b=r.rawResponse,m=r.sort,y=r.filters;if(!n)return this.injectPromise(this.getEventsByContractAddress,e,t);if(o=o||i||s,!this.tronWeb.eventServer)return n("No event server configured");var k=[];if(!this.tronWeb.isAddress(e))return n("Invalid contract address provided");if(a&&!e)return n("Usage of event name filtering requires a contract address");if(void 0!==o&&!Le.isInteger(o))return n("Invalid fromTimestamp provided");if(!Le.isInteger(c))return n("Invalid size provided");if(c>200&&(console.warn("Defaulting to maximum accepted size: 200"),c=200),!Le.isInteger(d))return n("Invalid page provided");if(u&&!a)return n("Usage of block number filtering requires an event name");e&&k.push(this.tronWeb.address.fromHex(e)),a&&k.push(a),u&&k.push(u);var x={size:c,page:d};return"object"===p()(y)&&Object.keys(y).length>0&&(x.filters=JSON.stringify(y)),o&&(x.fromTimestamp=x.since=o),l&&(x.onlyConfirmed=l),h&&!l&&(x.onlyUnconfirmed=h),m&&(x.sort=m),(g=g||v||f)&&(x.fingerprint=g),this.tronWeb.eventServer.request("event/contract/".concat(k.join("/"),"?").concat(kt.a.stringify(x))).then((function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e?Le.isArray(e)?n(null,!0===b?e:e.map((function(e){return Le.mapEvent(e)}))):n(e):n("Unknown error occurred")})).catch((function(e){return n(e.response&&e.response.data||e)}))}},{key:"getEventsByTransactionID",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return Le.isFunction(t)&&(n=t,t={}),n?this.tronWeb.eventServer?this.tronWeb.eventServer.request("event/transaction/".concat(e)).then((function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e?Le.isArray(e)?n(null,!0===t.rawResponse?e:e.map((function(e){return Le.mapEvent(e)}))):n(e):n("Unknown error occurred")})).catch((function(e){return n(e.response&&e.response.data||e)})):n("No event server configured"):this.injectPromise(this.getEventsByTransactionID,e,t)}}]),e}();n.d(t,"default",(function(){return It}));var wt="3.5.0",It=function(e){function t(){var e,n,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return b()(this,t),e=x()(this,I()(t).call(this)),"object"===p()(r)&&(r.fullNode||r.fullHost)?(n=r.fullNode||r.fullHost,i=r.solidityNode||r.fullHost,s=r.eventServer||r.fullHost,o=r.privateKey):n=r,Le.isString(n)&&(n=new ze.HttpProvider(n)),Le.isString(i)&&(i=new ze.HttpProvider(i)),Le.isString(s)&&(s=new ze.HttpProvider(s)),e.event=new xt(A()(e)),e.transactionBuilder=new st(A()(e)),e.trx=new dt(A()(e)),e.plugin=new mt(A()(e),r),e.utils=Le,e.setFullNode(n),e.setSolidityNode(i),e.setEventServer(s),e.providers=ze,e.BigNumber=Re.a,e.defaultBlock=!1,e.defaultPrivateKey=!1,e.defaultAddress={hex:!1,base58:!1},["sha3","toHex","toUtf8","fromUtf8","toAscii","fromAscii","toDecimal","fromDecimal","toSun","fromSun","toBigNumber","isAddress","createAccount","address","version"].forEach((function(n){e[n]=t[n]})),o&&e.setPrivateKey(o),e.fullnodeVersion=wt,e.injectPromise=$e()(A()(e)),e}var n,r,i;return _()(t,e),y()(t,[{key:"getFullnodeVersion",value:(i=f()(l.a.mark((function e(){var t;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.trx.getNodeInfo();case 3:t=e.sent,this.fullnodeVersion=t.configNodeInfo.codeVersion,2===this.fullnodeVersion.split(".").length&&(this.fullnodeVersion+=".0"),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this.fullnodeVersion=wt;case 11:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return i.apply(this,arguments)})},{key:"setDefaultBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if([!1,"latest","earliest",0].includes(e))return this.defaultBlock=e;if(!Le.isInteger(e)||!e)throw new Error("Invalid block ID provided");this.defaultBlock=Math.abs(e)}},{key:"setPrivateKey",value:function(e){try{this.setAddress(this.address.fromPrivateKey(e))}catch(e){throw new Error("Invalid private key provided")}this.defaultPrivateKey=e,this.emit("privateKeyChanged",e)}},{key:"setAddress",value:function(e){if(!this.isAddress(e))throw new Error("Invalid address provided");var t=this.address.toHex(e),n=this.address.fromHex(e);this.defaultPrivateKey&&this.address.fromPrivateKey(this.defaultPrivateKey)!==n&&(this.defaultPrivateKey=!1),this.defaultAddress={hex:t,base58:n},this.emit("addressChanged",{hex:t,base58:n})}},{key:"fullnodeSatisfies",value:function(e){return Xe.a.satisfies(this.fullnodeVersion,e)}},{key:"isValidProvider",value:function(e){return Object.values(ze).some((function(t){return e instanceof t}))}},{key:"setFullNode",value:function(e){if(Le.isString(e)&&(e=new ze.HttpProvider(e)),!this.isValidProvider(e))throw new Error("Invalid full node provided");this.fullNode=e,this.fullNode.setStatusPage("wallet/getnowblock"),this.getFullnodeVersion()}},{key:"setSolidityNode",value:function(e){if(Le.isString(e)&&(e=new ze.HttpProvider(e)),!this.isValidProvider(e))throw new Error("Invalid solidity node provided");this.solidityNode=e,this.solidityNode.setStatusPage("walletsolidity/getnowblock")}},{key:"setEventServer",value:function(){var e;(e=this.event).setServer.apply(e,arguments)}},{key:"currentProviders",value:function(){return{fullNode:this.fullNode,solidityNode:this.solidityNode,eventServer:this.eventServer}}},{key:"currentProvider",value:function(){return this.currentProviders()}},{key:"getEventResult",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return"object"!==p()(n[1])&&(n[1]={sinceTimestamp:n[1]||0,eventName:n[2]||!1,blockNumber:n[3]||!1,size:n[4]||20,page:n[5]||1},n.splice(2,4),Le.isFunction(n[2])||(Le.isFunction(n[1].page)?(n[2]=n[1].page,n[1].page=1):Le.isFunction(n[1].size)&&(n[2]=n[1].size,n[1].size=20,n[1].page=1))),(e=this.event).getEventsByContractAddress.apply(e,n)}},{key:"getEventByTransactionID",value:function(){var e;return(e=this.event).getEventsByTransactionID.apply(e,arguments)}},{key:"contract",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new bt(this,e,t)}},{key:"isConnected",value:(r=f()(l.a.mark((function e(){var t,n=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]&&n[0]){e.next=3;break}return e.abrupt("return",this.injectPromise(this.isConnected));case 3:return e.t0=t,e.next=6,this.fullNode.isConnected();case 6:return e.t1=e.sent,e.next=9,this.solidityNode.isConnected();case 9:if(e.t2=e.sent,e.t3=this.eventServer,!e.t3){e.next=15;break}return e.next=14,this.eventServer.isConnected();case 14:e.t3=e.sent;case 15:return e.t4=e.t3,e.t5={fullNode:e.t1,solidityNode:e.t2,eventServer:e.t4},e.abrupt("return",(0,e.t0)(null,e.t5));case 18:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})}],[{key:"sha3",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(t?"0x":"")+ue(Buffer.from(e,"utf-8")).toString().substring(2)}},{key:"toHex",value:function(e){if(Le.isBoolean(e))return t.fromDecimal(+e);if(Le.isBigNumber(e))return t.fromDecimal(e);if("object"===p()(e))return t.fromUtf8(JSON.stringify(e));if(Le.isString(e)){if(/^(-|)0x/.test(e))return e;if(!isFinite(e))return t.fromUtf8(e)}var n=t.fromDecimal(e);if("0xNaN"===n)throw new Error("The passed value is not convertible to a hex string");return n}},{key:"toUtf8",value:function(e){if(Le.isHex(e))return e=e.replace(/^0x/,""),Buffer.from(e,"hex").toString("utf8");throw new Error("The passed value is not a valid hex string")}},{key:"fromUtf8",value:function(e){if(!Le.isString(e))throw new Error("The passed value is not a valid utf-8 string");return"0x"+Buffer.from(e,"utf8").toString("hex")}},{key:"toAscii",value:function(e){if(Le.isHex(e)){var t="",n=0,r=e.length;for("0x"===e.substring(0,2)&&(n=2);n<r;n+=2){var i=parseInt(e.substr(n,2),16);t+=String.fromCharCode(i)}return t}throw new Error("The passed value is not a valid hex string")}},{key:"fromAscii",value:function(e,t){if(!Le.isString(e))throw new Error("The passed value is not a valid utf-8 string");return"0x"+Buffer.from(e,"ascii").toString("hex").padEnd(t,"0")}},{key:"toDecimal",value:function(e){return t.toBigNumber(e).toNumber()}},{key:"fromDecimal",value:function(e){var n=t.toBigNumber(e),r=n.toString(16);return n.isLessThan(0)?"-0x"+r.substr(1):"0x"+r}},{key:"fromSun",value:function(e){var n=t.toBigNumber(e).div(1e6);return Le.isBigNumber(e)?n:n.toString(10)}},{key:"toSun",value:function(e){var n=t.toBigNumber(e).times(1e6);return Le.isBigNumber(e)?n:n.toString(10)}},{key:"toBigNumber",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Le.isBigNumber(e)?e:Le.isString(e)&&/^(-|)0x/.test(e)?new Re.a(e.replace("0x",""),16):new Re.a(e.toString(10),10)}},{key:"isAddress",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!Le.isString(e))return!1;if(42===e.length)try{return t.isAddress(Le.crypto.getBase58CheckAddress(Le.code.hexStr2byteArray(e)))}catch(e){return!1}try{return Le.crypto.isAddressValid(e)}catch(e){return!1}}},{key:"createAccount",value:(n=f()(l.a.mark((function e(){var t;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Le.accounts.generateAccount(),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"address",get:function(){return{fromHex:function(e){return Le.isHex(e)?Le.crypto.getBase58CheckAddress(Le.code.hexStr2byteArray(e.replace(/^0x/,U))):e},toHex:function(e){return Le.isHex(e)?e.toLowerCase().replace(/^0x/,U):Le.code.byteArray2hexStr(Le.crypto.decodeBase58Address(e)).toLowerCase()},fromPrivateKey:function(e){try{return Le.crypto.pkToAddress(e)}catch(e){return!1}}}}}]),t}(Je.a);S()(It,"providers",ze),S()(It,"BigNumber",Re.a),S()(It,"TransactionBuilder",st),S()(It,"Trx",dt),S()(It,"Contract",bt),S()(It,"Plugin",mt),S()(It,"Event",xt),S()(It,"version",Ge.a),S()(It,"utils",Le)}]).default;
2//# sourceMappingURL=TronWeb.node.js.map
\No newline at end of file