UNPKG

tronweb

Version:

JavaScript SDK that encapsulates the TRON HTTP API

1 lines 152 kB
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.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/typeof")},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("ethers")},function(e,t){e.exports=require("bignumber.js")},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/getPrototypeOf")},function(e,t){e.exports=require("@babel/runtime/helpers/inherits")},function(e,t){e.exports=require("@babel/runtime/helpers/possibleConstructorReturn")},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":"3.2.6"}')},function(e,t){e.exports=require("querystring")},function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return Pt}));var n={};r.r(n),r.d(n,"byte2hexStr",(function(){return O})),r.d(n,"bytesToString",(function(){return C})),r.d(n,"hextoString",(function(){return B})),r.d(n,"byteArray2hexStr",(function(){return E})),r.d(n,"base64DecodeFromString",(function(){return q})),r.d(n,"base64EncodeToString",(function(){return D}));var i={};r.r(i),r.d(i,"bin2String",(function(){return V})),r.d(i,"arrayEquals",(function(){return L})),r.d(i,"stringToBytes",(function(){return U})),r.d(i,"byte2hexStr",(function(){return O})),r.d(i,"bytesToString",(function(){return C})),r.d(i,"hextoString",(function(){return B})),r.d(i,"byteArray2hexStr",(function(){return E})),r.d(i,"base64DecodeFromString",(function(){return q})),r.d(i,"base64EncodeToString",(function(){return D})),r.d(i,"hexChar2byte",(function(){return z})),r.d(i,"isHexChar",(function(){return M})),r.d(i,"hexStr2byteArray",(function(){return G})),r.d(i,"strToDate",(function(){return J})),r.d(i,"isNumber",(function(){return Y})),r.d(i,"getStringType",(function(){return X}));var s={};r.r(s),r.d(s,"encode58",(function(){return ee})),r.d(s,"decode58",(function(){return te}));var a={};r.r(a),r.d(a,"keccak256",(function(){return ie})),r.d(a,"sha256",(function(){return se})),r.d(a,"toUtf8Bytes",(function(){return ae})),r.d(a,"toUtf8String",(function(){return oe})),r.d(a,"recoverAddress",(function(){return ue})),r.d(a,"SigningKey",(function(){return ce})),r.d(a,"AbiCoder",(function(){return de}));var o={};r.r(o),r.d(o,"getBase58CheckAddress",(function(){return le})),r.d(o,"decodeBase58Address",(function(){return he})),r.d(o,"signTransaction",(function(){return fe})),r.d(o,"arrayToBase64String",(function(){return ve})),r.d(o,"signBytes",(function(){return pe})),r.d(o,"getRowBytesFromTransactionBase64",(function(){return ge})),r.d(o,"genPriKey",(function(){return be})),r.d(o,"computeAddress",(function(){return me})),r.d(o,"getAddressFromPriKey",(function(){return ye})),r.d(o,"decode58Check",(function(){return ke})),r.d(o,"isAddressValid",(function(){return xe})),r.d(o,"getBase58CheckAddressFromPriKeyBase64String",(function(){return we})),r.d(o,"getHexStrAddressFromPriKeyBase64String",(function(){return Ie})),r.d(o,"getAddressFromPriKeyBase64String",(function(){return Ae})),r.d(o,"getPubKeyFromPriKey",(function(){return Pe})),r.d(o,"ECKeySign",(function(){return We})),r.d(o,"SHA256",(function(){return _e})),r.d(o,"passwordToAddress",(function(){return Se})),r.d(o,"pkToAddress",(function(){return Ne}));var u={};r.r(u),r.d(u,"generateAccount",(function(){return Te}));var c={};r.r(c),r.d(c,"decodeParams",(function(){return Fe})),r.d(c,"encodeParams",(function(){return Oe}));var d=r(0),l=r.n(d),h=r(1),f=r.n(h),v=r(6),p=r.n(v),g=r(2),b=r.n(g),m=r(3),y=r.n(m),k=r(11),x=r.n(k),w=r(15),I=r.n(w),A=r(16),P=r.n(A),W=r(14),_=r.n(W),S=r(4),N=r.n(S),T=r(17),j=r.n(T);function F(){var e=this;this._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",this.encode=function(t){for(var r,n,i,s,a,o,u,c="",d=0;d<t.length;)s=(r=t.charCodeAt(d++))>>2,a=(3&r)<<4|(n=t.charCodeAt(d++))>>4,o=(15&n)<<2|(i=t.charCodeAt(d++))>>6,u=63&i,isNaN(n)?o=u=64:isNaN(i)&&(u=64),c=c+e._keyStr.charAt(s)+e._keyStr.charAt(a)+e._keyStr.charAt(o)+e._keyStr.charAt(u);return c},this.encodeIgnoreUtf8=function(t){for(var r,n,i,s,a,o,u,c="",d=0;d<t.length;)s=(r=t[d++])>>2,a=(3&r)<<4|(n=t[d++])>>4,o=(15&n)<<2|(i=t[d++])>>6,u=63&i,isNaN(n)?o=u=64:isNaN(i)&&(u=64),c=c+e._keyStr.charAt(s)+e._keyStr.charAt(a)+e._keyStr.charAt(o)+e._keyStr.charAt(u);return c},this.decode=function(t){var r,n,i,s,a,o,u="",c=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<t.length;)r=e._keyStr.indexOf(t.charAt(c++))<<2|(s=e._keyStr.indexOf(t.charAt(c++)))>>4,n=(15&s)<<4|(a=e._keyStr.indexOf(t.charAt(c++)))>>2,i=(3&a)<<6|(o=e._keyStr.indexOf(t.charAt(c++))),u+=String.fromCharCode(r),64!=a&&(u+=String.fromCharCode(n)),64!=o&&(u+=String.fromCharCode(i));return e._utf8_decode(u)},this.decodeToByteArray=function(t){var r,n,i,s,a,o,u="",c=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<t.length;)r=e._keyStr.indexOf(t.charAt(c++))<<2|(s=e._keyStr.indexOf(t.charAt(c++)))>>4,n=(15&s)<<4|(a=e._keyStr.indexOf(t.charAt(c++)))>>2,i=(3&a)<<6|(o=e._keyStr.indexOf(t.charAt(c++))),u+=String.fromCharCode(r),64!=a&&(u+=String.fromCharCode(n)),64!=o&&(u+=String.fromCharCode(i));return e._out2ByteArray(u)},this._out2ByteArray=function(e){for(var t=new Array(e.length),r=0,n=0;r<e.length;)n=e.charCodeAt(r),t[r]=n,r++;return t},this._utf8_encode=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",r=0;r<e.length;r++){var n=e.charCodeAt(r);n<128?t+=String.fromCharCode(n):n>127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t},this._utf8_decode=function(e){for(var t="",r=0,n=0,i=0,s=0;r<e.length;)(n=e.charCodeAt(r))<128?(t+=String.fromCharCode(n),r++):n>191&&n<224?(i=e.charCodeAt(r+1),t+=String.fromCharCode((31&n)<<6|63&i),r+=2):(i=e.charCodeAt(r+1),s=e.charCodeAt(r+2),t+=String.fromCharCode((15&n)<<12|(63&i)<<6|63&s),r+=3);return t}}function O(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="",r=0;r<e.length;r++){var n=e[r].toString(2),i=n.match(/^1+?(?=0)/);if(i&&8===n.length){for(var s=i[0].length,a=e[r].toString(2).slice(7-s),o=1;o<s;o++)a+=e[o+r].toString(2).slice(2);t+=String.fromCharCode(parseInt(a,2)),r+=s-1}else t+=String.fromCharCode(e[r])}return t}function B(e){for(var t=e.replace(/^0x/,"").split(""),r="",n=0;n<t.length/2;n++){var i="0x".concat(t[2*n]).concat(t[2*n+1]);r+=String.fromCharCode(i)}return r}function E(e){for(var t="",r=0;r<e.length;r++)t+=O(e[r]);return t}function q(e){return(new F).decodeToByteArray(e)}function D(e){return(new F).encodeIgnoreUtf8(e)}var K=r(7),R=r.n(K),H=/^(41)/;function V(e){return C(e)}function L(e,t,r){if(e.length!=t.length)return!1;var n;for(n=0;n<e.length;n++)if(r){if(e[n]!=t[n])return!1}else if(JSON.stringify(e[n])!=JSON.stringify(t[n]))return!1;return!0}function U(e){if("string"!=typeof e)throw new Error("The passed string is not a string");var t,r,n=new Array;t=e.length;for(var i=0;i<t;i++)(r=e.charCodeAt(i))>=65536&&r<=1114111?(n.push(r>>18&7|240),n.push(r>>12&63|128),n.push(r>>6&63|128),n.push(63&r|128)):r>=2048&&r<=65535?(n.push(r>>12&15|224),n.push(r>>6&63|128),n.push(63&r|128)):r>=128&&r<=2047?(n.push(r>>6&31|192),n.push(63&r|128)):n.push(255&r);return n}function z(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 M(e){return e>="A"&&e<="F"||e>="a"&&e<="f"||e>="0"&&e<="9"?1:0}function G(e){if("string"!=typeof e)throw new Error("The passed string is not a string");for(var t=Array(),r=0,n=0,i=0,s=0;s<e.length;s++){var a=e.charAt(s);if(!M(a))throw new Error("The passed hex char is not a valid hex string");r<<=4,r+=z(a),0==++n%2&&(t[i++]=r,r=0)}return t}function J(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(" "),r=t[0].split("-"),n=parseInt(r[0],10),i=parseInt(r[1],10)-1,s=parseInt(r[2],10);if(t.length>1){var a=t[1].split("-"),o=parseInt(a[0],10),u=parseInt(a[1],10),c=parseInt(a[2],10);return new Date(n,i,s,o,u,c)}return new Date(n,i,s)}function Y(e){return e>="0"&&e<="9"?1:0}function X(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(!M(e.charAt(t)))break}if(40==t)return 1;for(t=0;t<e.length;t++){if(!Y(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 $="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Z={},Q=0;Q<$.length;Q++)Z[$.charAt(Q)]=Q;function ee(e){if(0===e.length)return"";var t,r,n=[0];for(t=0;t<e.length;t++){for(r=0;r<n.length;r++)n[r]<<=8;n[0]+=e[t];var i=0;for(r=0;r<n.length;++r)n[r]+=i,i=n[r]/58|0,n[r]%=58;for(;i;)n.push(i%58),i=i/58|0}for(t=0;0===e[t]&&t<e.length-1;t++)n.push(0);return n.reverse().map((function(e){return $[e]})).join("")}function te(e){if(0===e.length)return[];var t,r,n=[0];for(t=0;t<e.length;t++){var i=e[t];if(!(i in Z))throw new Error("Non-base58 character");for(r=0;r<n.length;r++)n[r]*=58;n[0]+=Z[i];var s=0;for(r=0;r<n.length;++r)n[r]+=s,s=n[r]>>8,n[r]&=255;for(;s;)n.push(255&s),s>>=8}for(t=0;"1"===e[t]&&t<e.length-1;t++)n.push(0);return n.reverse()}var re=r(13),ne=r(9),ie=ne.utils.keccak256,se=ne.utils.sha256,ae=ne.utils.toUtf8Bytes,oe=ne.utils.toUtf8String,ue=ne.utils.recoverAddress,ce=ne.utils.SigningKey,de=ne.utils.AbiCoder;function le(e){var t=_e(e),r=_e(t).slice(0,4);return ee(r=e.concat(r))}function he(e){if("string"!=typeof e)return!1;if(e.length<=4)return!1;var t=te(e);if(e.length<=4)return!1;var r=t.length-4,n=t.slice(r),i=_e(t=t.slice(0,r)),s=_e(i).slice(0,4);if(n[0]==s[0]&&n[1]==s[1]&&n[2]==s[2]&&n[3]==s[3])return t;throw new Error("Invalid address provided")}function fe(e,t){"string"==typeof e&&(e=G(e));var r=We(G(t.txID),e);return Array.isArray(t.signature)?t.signature.includes(r)||t.signature.push(r):t.signature=[r],t}function ve(e){return btoa(String.fromCharCode.apply(String,R()(e)))}function pe(e,t){return"string"==typeof e&&(e=G(e)),We(_e(t),e)}function ge(e){var t=q(e);return proto.protocol.Transaction.deserializeBinary(t).getRawData().serializeBinary()}function be(){for(var e=new re.ec("secp256k1").genKeyPair().getPrivate().toString("hex");e.length<64;)e="0".concat(e);return G(e)}function me(e){return 65===e.length&&(e=e.slice(1)),G("41"+ie(e).toString().substring(2).substring(24))}function ye(e){return me(Pe(e))}function ke(e){var t=te(e);if(t.length<=4)return!1;var r=t.slice(0,t.length-4),n=_e(r),i=_e(n);return i[0]===t[r.length]&&i[1]===t[r.length+1]&&i[2]===t[r.length+2]&&i[3]===t[r.length+3]&&r}function xe(e){if("string"!=typeof e)return!1;if(34!==e.length)return!1;var t=te(e);if(25!==t.length)return!1;if(65!==t[0])return!1;var r=t.slice(21),n=_e(t=t.slice(0,21)),i=_e(n).slice(0,4);return r[0]==i[0]&&r[1]==i[1]&&r[2]==i[2]&&r[3]==i[3]}function we(e){return le(me(Pe(q(e))))}function Ie(e){return E(me(Pe(q(e))))}function Ae(e){return D(me(Pe(q(e))))}function Pe(e){for(var t=new re.ec("secp256k1").keyFromPrivate(e,"bytes").getPublic(),r=t.x,n=t.y,i=r.toString("hex");i.length<64;)i="0".concat(i);for(var s=n.toString("hex");s.length<64;)s="0".concat(s);return G("04".concat(i).concat(s))}function We(e,t){for(var r=new re.ec("secp256k1").keyFromPrivate(t,"bytes").sign(e),n=r.r,i=r.s,s=r.recoveryParam,a=n.toString("hex");a.length<64;)a="0".concat(a);for(var o=i.toString("hex");o.length<64;)o="0".concat(o);return a+o+O(s)}function _e(e){var t=E(e);return G(se("0x"+t).replace(/^0x/,""))}function Se(e){return le(ye(q(e)))}function Ne(e){return le(ye(G(e)))}function Te(){var e=be(),t=Pe(e),r=ye(e);return{privateKey:E(e),publicKey:E(t),address:{base58:le(r),hex:E(r)}}}var je=new de;function Fe(e,t,r,n){if(r&&"boolean"!=typeof r||(n=r,r=t,t=e,e=[]),n&&r.replace(/^0x/,"").length%64==8&&(r="0x"+r.replace(/^0x/,"").substring(8)),r.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})),je.decode(t,r).reduce((function(r,n,i){return"address"==t[i]&&(n="41"+n.substr(2).toLowerCase()),e.length?r[e[i]]=n:r.push(n),r}),e.length?{}:[])}function Oe(e,t){for(var r=0;r<e.length;r++)"address"===e[r]&&(t[r]=Pt.address.toHex(t[r]).replace(H,"0x"));return je.encode(e,t)}var Ce=r(18),Be=r.n(Ce),Ee=r(10),qe=r.n(Ee);function De(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ke(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?De(Object(r),!0).forEach((function(t){N()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):De(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Re=Ke(Ke({},{isValidURL:function(e){return"string"==typeof e&&Be.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 qe.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,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return n.length&&!n.map((function(r){return t.hasProperty(e,r)})).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 r=t.inputs;if(!e.result)return e;if(this.isObject(e.result))for(var n=0;n<r.length;n++){var i=r[n];"address"==i.type&&i.name in e.result&&(e.result[i.name]="41"+e.result[i.name].substr(2).toLowerCase())}else this.isArray(e.result)&&(e.result=e.result.reduce((function(e,t,n){var i=r[n],s=i.name;return"address"==i.type&&(t="41"+t.substr(2).toLowerCase()),e[s]=t,e}),{}));return e},padLeft:function(e,t,r){for(var n=e.toString();n.length<r;)n=t+n;return n},isNotNullOrUndefined:function(e){return null!=e},sleep:function(){var e=arguments;return f()(l.a.mark((function t(){var r;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.length>0&&void 0!==e[0]?e[0]:1e3,t.abrupt("return",new Promise((function(e){return setTimeout(e,r)})));case 2:case"end":return t.stop()}}),t)})))()}}),{},{code:i,accounts:u,base58:s,bytes:n,crypto:o,abi:c,ethersUtils:a}),He={HttpProvider:function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e4,n=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]:{},a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"/";if(b()(this,e),!Re.isValidURL(t))throw new Error("Invalid URL provided to HttpProvider");if(isNaN(r)||r<0)throw new Error("Invalid timeout duration provided");if(!Re.isObject(s))throw new Error("Invalid headers object provided");t=t.replace(/\/+$/,""),this.host=t,this.timeout=r,this.user=n,this.password=i,this.headers=s,this.statusPage=a,this.instance=j.a.create({baseURL:t,timeout:r,headers:s,auth:n&&{user:n,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,r=arguments;return l.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:this.statusPage,e.abrupt("return",this.request(t).then((function(e){return Re.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]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"get";return r=r.toLowerCase(),this.instance.request({data:"post"==r&&Object.keys(t).length?t:null,params:"get"==r&&t,url:e,method:r}).then((function(e){return e.data}))}}]),e}()},Ve=r(19),Le=r.n(Ve),Ue=r(20),ze=r(12),Me=r.n(ze),Ge=r(5),Je=r.n(Ge),Ye=r(8),Xe=r.n(Ye);function $e(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Ze(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ze(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}function Ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Qe,et=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b()(this,e),!t||!t instanceof Pt)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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Function,n={},i=!1,s=$e(t);try{for(s.s();!(e=s.n()).done;){var a=e.value,o=a.name,u=a.names,c=a.value,d=a.type,l=a.gt,h=a.lt,f=a.gte,v=a.lte,p=(a.se,a.optional);if(!p||Re.isNotNullOrUndefined(c)&&("boolean"===d||!1!==c)){switch(n[a.name]=a.value,d){case"address":this.tronWeb.isAddress(c)?n[o]=this.tronWeb.address.toHex(c):i=!0;break;case"integer":(!Re.isInteger(c)||"number"==typeof l&&c<=a.gt||"number"==typeof h&&c>=a.lt||"number"==typeof f&&c<a.gte||"number"==typeof v&&c>a.lte)&&(i=!0);break;case"positive-integer":if(!Re.isInteger(c)||c<=0)return void r(this.notPositive(a));break;case"tokenId":Re.isString(c)&&c.length||(i=!0);break;case"notEmptyObject":Re.isObject(c)&&Object.keys(c).length||(i=!0);break;case"notEqual":if(n[u[0]]===n[u[1]])return r(this.notEqual(a)),!0;break;case"resource":["BANDWIDTH","ENERGY"].includes(c)||(i=!0);break;case"url":Re.isValidURL(c)||(i=!0);break;case"hex":Re.isHex(c)||(i=!0);break;case"array":Array.isArray(c)||(i=!0);break;case"not-empty-string":Re.isString(c)&&c.length||(i=!0);break;case"boolean":Re.isBoolean(c)||(i=!0);break;case"string":(!Re.isString(c)||"number"==typeof l&&c.length<=a.gt||"number"==typeof h&&c.length>=a.lt||"number"==typeof f&&c.length<a.gte||"number"==typeof v&&c.length>a.lte)&&(i=!0)}if(i)return r(this.invalid(a)),!0}}}catch(e){s.e(e)}finally{s.f()}return!1}}]),e}();function tt(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return rt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return rt(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}function rt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function nt(e){return Pt.address.toHex(e)}function it(e){return Qe.tronWeb.fromUtf8(e)}function st(e,t){return e.Error?t(e.Error):e.result&&e.result.message?t(Qe.tronWeb.toUtf8(e.result.message)):t(null,e)}var at=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(b()(this,e),!t||!t instanceof Pt)throw new Error("Expected instance of TronWeb");Qe=this,this.tronWeb=t,this.injectPromise=Je()(this),this.validator=new et(t)}var t,r,n,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,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.tronWeb.defaultAddress.hex,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Re.isFunction(n)&&(i=n,n={}),Re.isFunction(r)?(i=r,r=this.tronWeb.defaultAddress.hex):Re.isObject(r)&&(n=r,r=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.sendTrx,e,t,r,n);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 TRX to the same account"},{name:"amount",type:"integer",gt:0,value:t}],i)){var s={to_address:nt(e),owner_address:nt(r),amount:t};n&&n.permissionId&&(s.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/createtransaction",s,"post").then((function(e){return st(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,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=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(Re.isFunction(i)&&(s=i,i={}),Re.isFunction(n)?(s=n,n=this.tronWeb.defaultAddress.hex):Re.isObject(n)&&(i=n,n=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.sendToken,e,t,r,n,i);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 tokens to the same account"},{name:"amount",type:"integer",gt:0,value:t},{name:"token ID",type:"tokenId",value:r}],s)){var a={to_address:nt(e),owner_address:nt(n),asset_name:it(r),amount:parseInt(t)};i&&i.permissionId&&(a.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/transferasset",a,"post").then((function(e){return st(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],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=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(Re.isFunction(i)&&(s=i,i={}),Re.isFunction(n)?(s=n,n=this.tronWeb.defaultAddress.hex):Re.isObject(n)&&(i=n,n=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.purchaseToken,e,t,r,n,i);if(!this.validator.notValid([{name:"buyer",type:"address",value:n},{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:r},{name:"token ID",type:"tokenId",value:t}],s)){var a={to_address:nt(e),owner_address:nt(n),asset_name:it(t),amount:parseInt(r)};i&&i.permissionId&&(a.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/participateassetissue",a,"post").then((function(e){return st(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,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"BANDWIDTH",n=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,a=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(Re.isFunction(s)&&(a=s,s={}),Re.isFunction(i)?(a=i,i=void 0):Re.isObject(i)&&(s=i,i=void 0),Re.isFunction(n)?(a=n,n=this.tronWeb.defaultAddress.hex):Re.isObject(n)&&(s=n,n=this.tronWeb.defaultAddress.hex),Re.isFunction(t)&&(a=t,t=3),Re.isFunction(r)&&(a=r,r="BANDWIDTH"),!a)return this.injectPromise(this.freezeBalance,e,t,r,n,i,s);if(!this.validator.notValid([{name:"origin",type:"address",value:n},{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:r,msg:'Invalid resource provided: Expected "BANDWIDTH" or "ENERGY'}],a)){var o={owner_address:nt(n),frozen_balance:parseInt(e),frozen_duration:parseInt(t),resource:r};Re.isNotNullOrUndefined(i)&&nt(i)!==nt(n)&&(o.receiver_address=nt(i)),s&&s.permissionId&&(o.Permission_id=s.permissionId),this.tronWeb.fullNode.request("wallet/freezebalance",o,"post").then((function(e){return st(e,a)})).catch((function(e){return a(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,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Re.isFunction(n)&&(i=n,n={}),Re.isFunction(r)?(i=r,r=void 0):Re.isObject(r)&&(n=r,r=void 0),Re.isFunction(t)?(i=t,t=this.tronWeb.defaultAddress.hex):Re.isObject(t)&&(n=t,t=this.tronWeb.defaultAddress.hex),Re.isFunction(e)&&(i=e,e="BANDWIDTH"),!i)return this.injectPromise(this.unfreezeBalance,e,t,r,n);if(!this.validator.notValid([{name:"origin",type:"address",value:t},{name:"receiver",type:"address",value:r,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};Re.isNotNullOrUndefined(r)&&nt(r)!==nt(t)&&(s.receiver_address=nt(r)),n&&n.permissionId&&(s.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/unfreezebalance",s,"post").then((function(e){return st(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,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Re.isFunction(t)&&(r=t,t={}),Re.isFunction(e)?(r=e,e=this.tronWeb.defaultAddress.hex):Re.isObject(e)&&(t=e,e=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.withdrawBlockRewards,e,t);if(!this.validator.notValid([{name:"origin",type:"address",value:e}],r)){var n={owner_address:nt(e)};t&&t.permissionId&&(n.Permission_id=t.permissionId),this.tronWeb.fullNode.request("wallet/withdrawbalance",n,"post").then((function(e){return st(e,r)})).catch((function(e){return r(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],r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Re.isFunction(r)&&(n=r,r={}),Re.isObject(t)&&Re.isValidURL(e)&&(r=t,t=e,e=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.applyForSR,e,t,r);if(!this.validator.notValid([{name:"origin",type:"address",value:e},{name:"url",type:"url",value:t,msg:"Invalid url provided"}],n)){var i={owner_address:nt(e),url:it(t)};r&&r.permissionId&&(i.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/createwitness",i,"post").then((function(e){return st(e,n)})).catch((function(e){return n(e)}))}}},{key:"vote",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Re.isFunction(n)&&(i=n,n={}),Re.isFunction(r)?(i=r,r=this.tronWeb.defaultAddress.hex):Re.isObject(r)&&(n=r,r=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.vote,t,r,n);if(!this.validator.notValid([{name:"voter",type:"address",value:r},{name:"votes",type:"notEmptyObject",value:t}],i)){var s=!1;if(t=Object.entries(t).map((function(t){var r=Xe()(t,2),n=r[0],i=r[1];if(!s)return e.validator.notValid([{name:"SR",type:"address",value:n},{name:"vote count",type:"integer",gt:0,value:i,msg:"Invalid vote count provided for SR: "+n}])?s=!0:{vote_address:nt(n),vote_count:parseInt(i)}})),!s){var a={owner_address:nt(r),votes:t};n&&n.permissionId&&(a.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/votewitnessaccount",a,"post").then((function(e){return st(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,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Re.isFunction(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.createSmartContract,e,t);var n=e.feeLimit||this.tronWeb.feeLimit,i=e.userFeePercentage;"number"==typeof i||i||(i=100);var s=e.originEnergyLimit||1e7,a=e.callValue||0,o=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&&Re.isString(d))try{d=JSON.parse(d)}catch(e){return r("Invalid options.abi provided")}if(d.entrys&&(d=d.entrys),!Re.isArray(d))return r("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:n,gt:0,lte:5e9},{name:"callValue",type:"integer",value:a,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:o,gte:0,optional:!0},{name:"tokenId",type:"integer",value:u,gte:0,optional:!0}],r)){if(b&&0==a&&0==o)return r("When contract is payable, options.callValue or options.tokenValue must be a positive integer");if(!b&&(a>0||o>0))return r("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 de,k=[],x=[];if(m=m.inputs,v.length!=m.length)return r("constructor needs ".concat(m.length," but ").concat(v.length," provided"));for(var w=0;w<v.length;w++){var I=m[w].type,A=v[w];if(!I||!Re.isString(I)||!I.length)return r("Invalid parameter type provided: "+I);"address"==I?A=nt(A).replace(H,"0x"):"address[]"==I&&(A=A.map((function(e){return nt(e).replace(H,"0x")}))),k.push(I),x.push(A)}try{v=y.encode(k,x).replace(/^(0x)/,"")}catch(e){return r(e)}}else v="";var P={owner_address:nt(t),fee_limit:parseInt(n),call_value:parseInt(a),consume_user_resource_percent:i,origin_energy_limit:s,abi:JSON.stringify(d),bytecode:h,parameter:v,name:g};Re.isNotNullOrUndefined(o)&&(P.call_token_value=parseInt(o)),Re.isNotNullOrUndefined(u)&&(P.token_id=parseInt(u)),e&&e.permissionId&&(P.Permission_id=e.permissionId),this.tronWeb.fullNode.request("wallet/deploycontract",P,"post").then((function(e){return st(e,r)})).catch((function(e){return r(e)}))}}},{key:"triggerSmartContract",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];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),r=0;r<e;r++)t[r]=arguments[r];return t[2]._isConstant=!0,this.triggerSmartContract.apply(this,t)}},{key:"triggerConfirmedConstantContract",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[2]._isConstant=!0,t[2].confirmed=!0,this.triggerSmartContract.apply(this,t)}},{key:"_triggerSmartContract",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=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(Re.isFunction(i)&&(s=i,i=this.tronWeb.defaultAddress.hex),Re.isFunction(n)&&(s=n,n=[]),!s)return this.injectPromise(this._triggerSmartContract,e,t,r,n,i);var a=Object.assign({callValue:0,feeLimit:this.tronWeb.feeLimit},r),o=a.tokenValue,u=a.tokenId,c=a.callValue,d=a.feeLimit;if(!this.validator.notValid([{name:"feeLimit",type:"integer",value:d,gt:0,lte:5e9},{name:"callValue",type:"integer",value:c,gte:0},{name:"parameters",type:"array",value:n},{name:"contract",type:"address",value:e},{name:"issuer",type:"address",value:i,optional:!0},{name:"tokenValue",type:"integer",value:o,gte:0,optional:!0},{name:"tokenId",type:"integer",value:u,gte:0,optional:!0}],s)){var l={contract_address:nt(e),owner_address:nt(i)};if(t&&Re.isString(t)){if(t=t.replace("/s*/g",""),n.length){for(var h=new de,f=[],v=[],p=0;p<n.length;p++){var g=n[p],b=g.type,m=g.value;if(!b||!Re.isString(b)||!b.length)return s("Invalid parameter type provided: "+b);"address"==b?m=nt(m).replace(H,"0x"):"address[]"==b&&(m=m.map((function(e){return nt(e).replace(H,"0x")}))),f.push(b),v.push(m)}try{f=f.map((function(e){return/trcToken/.test(e)&&(e=e.replace(/trcToken/,"uint256")),e})),n=h.encode(f,v).replace(/^(0x)/,"")}catch(e){return s(e)}}else n="";r.shieldedParameter&&(n=r.shieldedParameter.replace(/^(0x)/,"")),l.function_selector=t,l.parameter=n}r._isConstant||(l.call_value=parseInt(c),l.fee_limit=parseInt(d),Re.isNotNullOrUndefined(o)&&(l.call_token_value=parseInt(o)),Re.isNotNullOrUndefined(u)&&(l.token_id=parseInt(u))),r.permissionId&&(l.Permission_id=r.permissionId),this.tronWeb[r.confirmed?"solidityNode":"fullNode"].request("wallet".concat(r.confirmed?"solidity":"","/trigger").concat(r._isConstant?"constant":"smart","contract"),l,"post").then((function(e){return st(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,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!r)return this.injectPromise(this.clearABI,e,t);if(!this.tronWeb.isAddress(e))return r("Invalid contract address provided");if(!this.tronWeb.isAddress(t))return r("Invalid owner address provided");var n={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",n,"post").then((function(e){return st(e,r)})).catch((function(e){return r(e)}))}},{key:"updateBrokerage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!r)return this.injectPromise(this.updateBrokerage,e,t);if(!Re.isNotNullOrUndefined(e))return r("Invalid brokerage provided");if(!Re.isInteger(e)||e<0||e>100)return r("Brokerage must be an integer between 0 and 100");if(!this.tronWeb.isAddress(t))return r("Invalid owner address provided");var n={brokerage:parseInt(e),owner_address:nt(t)};this.tronWeb.fullNode.request("wallet/updateBrokerage",n,"post").then((function(e){return st(e,r)})).catch((function(e){return r(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,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Re.isFunction(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.createToken,e,t);var n=e.name,i=void 0!==n&&n,s=e.abbreviation,a=void 0!==s&&s,o=e.description,u=void 0!==o&&o,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,A=void 0===I?0:I,P=e.frozenAmount,W=void 0===P?0:P,_=e.frozenDuration,S=void 0===_?0:_,N=e.voteScore,T=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:a},{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:A,gte:0},{name:"Frozen supply",type:"integer",value:W,gte:0},{name:"Frozen duration",type:"integer",value:S,gte:0}],r)){if(Re.isNotNullOrUndefined(N)&&(!Re.isInteger(N)||N<=0))return r("voteScore must be a positive integer greater than 0");if(Re.isNotNullOrUndefined(T)&&(!Re.isInteger(T)||T<0||T>6))return r("precision must be a positive integer >= 0 and <= 6");var j={owner_address:nt(t),name:it(i),abbr:it(a),description:it(u),url:it(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(A),frozen_supply:{frozen_amount:parseInt(W),frozen_days:parseInt(S)}};!this.tronWeb.fullnodeSatisfies(">=3.5.0")||parseInt(W)>0||delete j.frozen_supply,T&&!isNaN(parseInt(T))&&(j.precision=parseInt(T)),N&&!isNaN(parseInt(N))&&(j.vote_score=parseInt(N)),e&&e.permissionId&&(j.Permission_id=e.permissionId),this.tronWeb.fullNode.request("wallet/createassetissue",j,"post").then((function(e){return st(e,r)})).catch((function(e){return r(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,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Re.isFunction(r)&&(n=r,r={}),Re.isFunction(t)?(n=t,t=this.tronWeb.defaultAddress.hex):Re.isObject(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.updateAccount,e,t,r);if(!this.validator.notValid([{name:"Name",type:"not-empty-string",value:e},{name:"origin",type:"address",value:t}],n)){var i={account_name:it(e),owner_address:nt(t)};r&&r.permissionId&&(i.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/updateaccount",i,"post").then((function(e){return st(e,n)})).catch((function(e){return n(e)}))}}},{key:"setAccountId",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.tronWeb.defaultAddress.hex,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Re.isFunction(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.setAccountId,e,t);e&&Re.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}],r)||this.tronWeb.fullNode.request("wallet/setaccountid",{account_id:e,owner_address:nt(t)},"post").then((function(e){return st(e,r)})).catch((function(e){return r(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,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Re.isFunction(t)?(r=t,t=this.tronWeb.defaultAddress.hex):Re.isObject(t)&&(e=t,t=this.tronWeb.defaultAddress.hex),!r)return this.injectPromise(this.updateToken,e,t);var n=e,i=n.description,s=void 0!==i&&i,a=n.url,o=void 0!==a&&a,u=n.freeBandwidth,c=void 0===u?0:u,d=n.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:o},{name:"issuer",type:"address",value:t},{name:"Free bandwidth amount",type:"positive-integer",value:c},{name:"Free bandwidth limit",type:"positive-integer",value:l}],r)){var h={owner_address:nt(t),description:it(s),url:it(o),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 st(e,r)})).catch((function(e){return r(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,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Re.isFunction(r)&&(n=r,r={}),Re.isFunction(t)?(n=t,t=this.tronWeb.defaultAddress.hex):Re.isObject(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.createProposal,e,t,r);if(!this.validator.notValid([{name:"issuer",type:"address",value:t}],n)){var i="Invalid proposal parameters provided";if(!e)return n(i);Re.isArray(e)||(e=[e]);var s,a=tt(e);try{for(a.s();!(s=a.n()).done;){var o=s.value;if(!Re.isObject(o))return n(i)}}catch(e){a.e(e)}finally{a.f()}var u={owner_address:nt(t),parameters:e};r&&r.permissionId&&(u.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/proposalcreate",u,"post").then((function(e){return st(e,n)})).catch((function(e){return n(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,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(Re.isFunction(r)&&(n=r,r={}),Re.isFunction(t)?(n=t,t=this.tronWeb.defaultAddress.hex):Re.isObject(t)&&(r=t,t=this.tronWeb.defaultAddress.hex),!n)return this.injectPromise(this.deleteProposal,e,t,r);if(!this.validator.notValid([{name:"issuer",type:"address",value:t},{name:"proposalID",type:"integer",value:e,gte:0}],n)){var i={owner_address:nt(t),proposal_id:parseInt(e)};r&&r.permissionId&&(i.Permission_id=r.permissionId),this.tronWeb.fullNode.request("wallet/proposaldelete",i,"post").then((function(e){return st(e,n)})).catch((function(e){return n(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],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.tronWeb.defaultAddress.hex,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(Re.isFunction(n)&&(i=n,n={}),Re.isFunction(r)?(i=r,r=this.tronWeb.defaultAddress.hex):Re.isObject(r)&&(n=r,r=this.tronWeb.defaultAddress.hex),!i)return this.injectPromise(this.voteProposal,e,t,r,n);if(!this.validator.notValid([{name:"voter",type:"address",value:r},{name:"proposalID",type:"integer",value:e,gte:0},{name:"has approval",type:"boolean",value:t}],i)){var s={owner_address:nt(r),proposal_id:parseInt(e),is_add_approval:t};n&&n.permissionId&&(s.Permission_id=n.permissionId),this.tronWeb.fullNode.request("wallet/proposalapprove",s,"post").then((function(e){return st(e,i)})).catch((function(e){return i(e)}))}}},{key:"createTRXExchange",value:function(e,t,r){var n=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(Re.isFunction(i)&&(s=i,i={}),Re.isFunction(n)?(s=n,n=this.tronWeb.defaultAddress.hex):Re.isObject(n)&&(i=n,n=this.tronWeb.defaultAddress.hex),!s)return this.injectPromise(this.createTRXExchange,e,t,r,n,i);if(!this.validator.notValid([{name:"owner",type:"address",value:n},{name:"token name",type:"not-empty-string",value:e},{name:"token balance",type:"positive-integer",value:t},{name:"trx balance",type:"positive-integer",value:r}],s)){var a={owner_address:nt(n),first_token_id:it(e),first_token_balance:t,second_token_id:"5f",second_token_balance:r};i&&i.permissionId&&(a.Permission_id=i.permissionId),this.tronWeb.fullNode.request("wallet/exchangecreate",a,"post").then((function(e){s(null,e)})).catch((function(e){return s(e)}))}}},{key:"createTokenExchange",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.tronWeb.defaultAddress.hex,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6&&void 0!==arguments[6]&&arguments[6];if(Re.isFunction(s)&&(a=s,s={}),Re.isFunction(i)?(a=i,i=this.tronWeb.defaultAddress.hex):Re.isObject(i)&&(s=i,i=this.tronWeb.defaultAddress.hex),!a)return this.injectPromise(this.createTokenExchange,e,t,r,n,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:r},{name:"first token balance",type:"positive-integer",value:t},{name:"second token balance",type:"positive-integer",value:n}],a)){var o={owner_address:nt(i),first_token_id:it(e),first_token_balance:t,second_token_id:it(r),second_token_balance:n};s&&s.permissionId&&(o.Permission_id=s.permissionId),this.tronWeb.fullNode.request("wallet/exchangecreate",o,"post").then((function(e){a(null,e)})).catch((function(e){return a(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],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=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(Re.isFunction(i)&&(s=i,i={}),Re.isFunction(n)?(s=n,n=this.tronWeb.defaultAddress.hex):Re.isObject(