From 89d9255bee110ee49aea7e9a4cd5902c34f8011f Mon Sep 17 00:00:00 2001 From: Luphia Chang Date: Fri, 24 Dec 2021 19:47:51 +0800 Subject: [PATCH] Fix Bignumber accurancy issue --- build/lunar.js | 2 +- package.json | 2 +- src/connectors/imtoken.js | 18 ++++++++++++++++++ src/connectors/metamask.js | 3 +-- src/libs/smartcontract.js | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build/lunar.js b/build/lunar.js index 3aff8a6..7b8175b 100644 --- a/build/lunar.js +++ b/build/lunar.js @@ -1,2 +1,2 @@ /*! For license information please see lunar.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Lunar=t():e.Lunar=t()}(this,(function(){return(()=>{var e={92:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}d(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&d(e,"error",t,{once:!0})}(e,o)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function s(e,t,r,n){var o,i,a,s;if(c(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),a=i[t]),void 0===a)a=i[t]=r,++e._eventsCount;else if("function"==typeof a?a=i[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(o=u(e))>0&&a.length>o&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=a.length,s=f,console&&console.warn&&console.warn(s)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=f.bind(n);return o.listener=r,n.wrapFn=o,o}function h(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(a=t[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)n(u,this,t);else{var s=u.length,f=y(u,s);for(r=0;r=0;i--)if(r[i]===t||r[i].listener===t){a=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},751:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof v?t:v,i=Object.create(o.prototype),a=new T(n||[]);return i._invoke=function(e,t,r){var n=l;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw i;return C()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?y:h,u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=y,r.method="throw",r.arg=u.arg)}}}(e,r,a),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",h="suspendedYield",p="executing",y="completed",d={};function v(){}function m(){}function g(){}var b={};u(b,i,(function(){return this}));var w=Object.getPrototypeOf,k=w&&w(w(R([])));k&&k!==r&&n.call(k,i)&&(b=k);var x=g.prototype=v.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(o,i,a,c){var u=f(e[o],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function E(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=f(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function R(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}},375:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}r.d(t,{Z:()=>B}),e=r.hmd(e);var o="input is invalid type",i="object"===("undefined"==typeof window?"undefined":n(window)),a=i?window:{};a.JS_SHA3_NO_WINDOW&&(i=!1);var c=!i&&"object"===("undefined"==typeof self?"undefined":n(self));!a.JS_SHA3_NO_NODE_JS&&"object"===("undefined"==typeof process?"undefined":n(process))&&process.versions&&process.versions.node?a=r.g:c&&(a=self),!a.JS_SHA3_NO_COMMON_JS&&"object"===n(e)&&e.exports,"function"==typeof define&&r.amdO;var u=!a.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,s="0123456789abcdef".split(""),f=[4,1024,262144,67108864],l=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],p=[224,256,384,512],y=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};!a.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===n(e)&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var m=function(e,t,r){return function(n){return new N(e,t,e).update(n)[r]()}},g=function(e,t,r){return function(n,o){return new N(e,t,o).update(n)[r]()}},b=function(e,t,r){return function(t,n,o,i){return O["cshake"+e].update(t,n,o,i)[r]()}},w=function(e,t,r){return function(t,n,o,i){return O["kmac"+e].update(t,n,o,i)[r]()}},k=function(e,t,r,n){for(var o=0;o>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function j(e,t,r){N.call(this,e,t,r)}N.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=n(e);if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(o);t=!0}for(var i,a,c=this.blocks,s=this.byteCount,f=e.length,h=this.blockCount,p=0,y=this.s;p>2]|=e[p]<>2]|=a<>2]|=(192|a>>6)<>2]|=(128|63&a)<=57344?(c[i>>2]|=(224|a>>12)<>2]|=(128|a>>6&63)<>2]|=(128|63&a)<>2]|=(240|a>>18)<>2]|=(128|a>>12&63)<>2]|=(128|a>>6&63)<>2]|=(128|63&a)<=s){for(this.start=i-s,this.block=c[h],i=0;i>=8);r>0;)o.unshift(r),r=255&(e>>=8),++n;return t?o.push(n):o.unshift(n),this.update(o),o.length},N.prototype.encodeString=function(e){var t,r=n(e);if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(o);t=!0}var i=0,a=e.length;if(t)i=a;else for(var c=0;c=57344?i+=3:(s=65536+((1023&s)<<10|1023&e.charCodeAt(++c)),i+=4)}return i+=this.encode(8*i),this.update(e),i},N.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+s[15&e]+s[e>>12&15]+s[e>>8&15]+s[e>>20&15]+s[e>>16&15]+s[e>>28&15]+s[e>>24&15];a%t==0&&(L(r),i=0)}return o&&(e=r[i],c+=s[e>>4&15]+s[15&e],o>1&&(c+=s[e>>12&15]+s[e>>8&15]),o>2&&(c+=s[e>>20&15]+s[e>>16&15])),c},N.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,o=this.extraBytes,i=0,a=0,c=this.outputBits>>3;e=o?new ArrayBuffer(n+1<<2):new ArrayBuffer(c);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;c%r==0&&L(n)}return i&&(e=c<<2,t=n[a],u[e]=255&t,i>1&&(u[e+1]=t>>8&255),i>2&&(u[e+2]=t>>16&255)),u},j.prototype=new N,j.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var L=function(e){var t,r,n,o,i,a,c,u,s,f,l,p,y,d,v,m,g,b,w,k,x,_,O,E,S,A,T,R,C,P,N,j,L,B,I,U,D,M,H,F,G,W,z,q,V,$,J,Y,X,K,Z,Q,ee,te,re,ne,oe,ie,ae,ce,ue,se,fe;for(n=0;n<48;n+=2)o=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],c=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],s=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(p=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|c>>>31),r=(y=e[9]^e[19]^e[29]^e[39]^e[49])^(c<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=o^(u<<1|s>>>31),r=i^(s<<1|u>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(f<<1|l>>>31),r=c^(l<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=u^(p<<1|y>>>31),r=s^(y<<1|p>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(o<<1|i>>>31),r=l^(i<<1|o>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,d=e[0],v=e[1],$=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,R=e[20]<<3|e[21]>>>29,C=e[21]<<3|e[20]>>>29,ce=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,W=e[40]<<18|e[41]>>>14,z=e[41]<<18|e[40]>>>14,B=e[2]<<1|e[3]>>>31,I=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,g=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,N=e[32]<<13|e[33]>>>19,se=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,U=e[14]<<6|e[15]>>>26,D=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,K=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,j=e[45]<<29|e[44]>>>3,L=e[44]<<29|e[45]>>>3,E=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,oe=e[16]<<23|e[17]>>>9,M=e[26]<<25|e[27]>>>7,H=e[27]<<25|e[26]>>>7,k=e[36]<<21|e[37]>>>11,x=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,q=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,A=e[18]<<20|e[19]>>>12,T=e[19]<<20|e[18]>>>12,ie=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,F=e[38]<<8|e[39]>>>24,G=e[39]<<8|e[38]>>>24,_=e[48]<<14|e[49]>>>18,O=e[49]<<14|e[48]>>>18,e[0]=d^~m&b,e[1]=v^~g&w,e[10]=E^~A&R,e[11]=S^~T&C,e[20]=B^~U&M,e[21]=I^~D&H,e[30]=q^~$&Y,e[31]=V^~J&X,e[40]=te^~ne&ie,e[41]=re^~oe&ae,e[2]=m^~b&k,e[3]=g^~w&x,e[12]=A^~R&P,e[13]=T^~C&N,e[22]=U^~M&F,e[23]=D^~H&G,e[32]=$^~Y&K,e[33]=J^~X&Z,e[42]=ne^~ie&ce,e[43]=oe^~ae&ue,e[4]=b^~k&_,e[5]=w^~x&O,e[14]=R^~P&j,e[15]=C^~N&L,e[24]=M^~F&W,e[25]=H^~G&z,e[34]=Y^~K&Q,e[35]=X^~Z&ee,e[44]=ie^~ce&se,e[45]=ae^~ue&fe,e[6]=k^~_&d,e[7]=x^~O&v,e[16]=P^~j&E,e[17]=N^~L&S,e[26]=F^~W&B,e[27]=G^~z&I,e[36]=K^~Q&q,e[37]=Z^~ee&V,e[46]=ce^~se&te,e[47]=ue^~fe&re,e[8]=_^~d&m,e[9]=O^~v&g,e[18]=j^~E&A,e[19]=L^~S&T,e[28]=W^~B&U,e[29]=z^~I&D,e[38]=Q^~q&$,e[39]=ee^~V&J,e[48]=se^~te&ne,e[49]=fe^~re&oe,e[0]^=h[n],e[1]^=h[n+1]};const B=O},896:(e,t,r)=>{"use strict";r.d(t,{default:()=>Te});var n=r(92);function o(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=t.toString(16);return 0!=r.indexOf("0x")&&(r="0x".concat(r)),this.keys.map((function(t){return e[t]})).find((function(e){return parseInt(e.chainId)==parseInt(r)}))}}],null&&o(t.prototype,null),r&&o(t,r),e}();i(a,"Avax",{chainId:"0xa86a",key:"Avax",chainName:"Avalanche Network",nativeCurrency:{symbol:"AVAX",decimals:18},rpcUrls:["https://api.avax.network/ext/bc/C/rpc"],blockExplorerUrls:["https://cchain.explorer.avax.network/"],isTestnet:!1}),i(a,"BSC",{chainId:"0x38",key:"BSC",chainName:"Binance Smart Chain Mainnet",nativeCurrency:{symbol:"BNB",decimals:18},rpcUrls:["https://bsc-dataseed.binance.org/"],blockExplorerUrls:["https://bscscan.com/"],isTestnet:!1}),i(a,"BSCTestnet",{chainId:"0x61",key:"BSCTestnet",chainName:"Binance Smart Chain Testnet",nativeCurrency:{symbol:"BNB",decimals:18},rpcUrls:["https://data-seed-prebsc-1-s1.binance.org:8545/"],blockExplorerUrls:["https://testnet.bscscan.com"],isTestnet:!0}),i(a,"Ethereum",{chainId:"0x1",key:"Ethereum",chainName:"Ethereum",nativeCurrency:{symbol:"ETH",decimals:18},isTestnet:!1}),i(a,"AvaxTestnet",{chainId:"0xa869",key:"AvaxTestnet",chainName:"Avalanche Testnet FUJI",nativeCurrency:{symbol:"AVAX",decimals:18},rpcUrls:["https://api.avax-test.network/ext/bc/C/rpc"],blockExplorerUrls:["https://cchain.explorer.avax-test.network"],isTestnet:!0}),i(a,"Huobi",{chainId:"0x80",key:"Huobi",chainName:"HuobiChain",nativeCurrency:{symbol:"HT",decimals:18},rpcUrls:["https://http-mainnet-node.huobichain.com/"],blockExplorerUrls:["https://hecoinfo.com/"],isTestnet:!1}),i(a,"HuobiTestnet",{chainId:"0x100",key:"HuobiTestnet",chainName:"HuobiChain Testnet",nativeCurrency:{symbol:"HT",decimals:18},rpcUrls:["https://http-testnet.hecochain.com/"],blockExplorerUrls:["https://scan-testnet.hecochain.com"],isTestnet:!0}),i(a,"Polygon",{chainId:"0x89",key:"Polygon",chainName:"Polygon",nativeCurrency:{symbol:"MATIC",decimals:18},rpcUrls:["https://rpc-mainnet.maticvigil.com/"],blockExplorerUrls:["https://explorer.matic.network/"],isTestnet:!1}),i(a,"PolygonTestnet",{chainId:"0x13881",key:"PolygonTestnet",chainName:"Polygon Testnet Mumbai",nativeCurrency:{symbol:"MATIC",decimals:18},rpcUrls:["https://rpc-mumbai.maticvigil.com/"],blockExplorerUrls:["https://mumbai-explorer.matic.today/"],isTestnet:!0}),i(a,"EthereumTestnet",{chainId:"0x3",key:"EthereumTestnet",chainName:"ETH testnet Ropsten",nativeCurrency:{symbol:"ETH",decimals:18},isTestnet:!0}),i(a,"Tidetime",{chainId:"0x1f51",key:"Tidetime",chainName:"Tidetime",nativeCurrency:{name:"Tidetime Token",symbol:"TTT",decimals:18},rpcUrls:["https://rpc.tidebit.network"],blockExplorerUrls:["https://explorer.tidebit.network"],iconUrls:["https://iconape.com/wp-content/png_logo_vector/tidebit.png"],isTestnet:!1}),i(a,"xDAI",{chainId:"0x64",key:"xDAI",chainName:"xDai",nativeCurrency:{symbol:"xDAI",decimals:18},rpcUrls:["https://rpc.xdaichain.com/"],blockExplorerUrls:["https://blockscout.com/xdai/mainnet"],isTestnet:!1});const c=a;function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};u(s,"Metamask","Metamask"),u(s,"imToken","imToken"),u(s,"TideWallet","TideWallet"),u(s,"Trust","Trust");const f=s;function l(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function h(e,t){for(var r=0;ro?c:o,n[i]=t.charCodeAt(i).toString(16).padStart(2*c,"0")}r=(n=n.map((function(e){return e.padStart(2*o,"0")}))).join("")}else try{r=e.toString(16)}catch(e){r=""}return r}},{key:"isHex",value:function(e){return/^0x[a-fA-F0-9]*$/.test(e)}},{key:"toHex",value:function(e){var t;if(null==e)t="";else if(this.isHex(e))t=e.substr(2);else if(Number.isInteger(e))t=e.toString(16);else if("string"==typeof e)t=this.stringToHex(e);else try{t=e.toString(16)}catch(e){t=""}return t}}],null&&E(t.prototype,null),r&&E(t,r),e}();var A=r(375);function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}var R,C=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,P=Math.ceil,N=Math.floor,j="[BigNumber Error] ",L=j+"Number primitive has more than 15 significant digits: ",B=1e14,I=14,U=9007199254740991,D=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],M=1e7,H=1e9;function F(e){var t=0|e;return e>0||e===t?t:t-1}function G(e){for(var t,r,n=1,o=e.length,i=e[0]+"";ns^r?1:-1;for(c=(u=o.length)<(s=i.length)?u:s,a=0;ai[a]^r?1:-1;return u==s?0:u>s^r?1:-1}function z(e,t,r,n){if(er||e!==N(e))throw Error(j+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function q(e){var t=e.c.length-1;return F(e.e/I)==t&&e.c[t]%2!=0}function V(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function $(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else tb?h.c=h.e=null:e.e=10;u/=10,c++);return void(c>b?h.c=h.e=null:(h.e=c,h.c=[e]))}l=String(e)}else{if(!C.test(l=String(e)))return o(h,l,s);h.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}(c=l.indexOf("."))>-1&&(l=l.replace(".","")),(u=l.search(/e/i))>0?(c<0&&(c=u),c+=+l.slice(u+1),l=l.substring(0,u)):c<0&&(c=l.length)}else{if(z(t,2,O.length,"Base"),10==t)return J(h=new E(e),y+h.e+1,d);if(l=String(e),s="number"==typeof e){if(0*e!=0)return o(h,l,s,t);if(h.s=1/e<0?(l=l.slice(1),-1):1,E.DEBUG&&l.replace(/^0\.0*|\./,"").length>15)throw Error(L+e)}else h.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(r=O.slice(0,t),c=u=0,f=l.length;uc){c=f;continue}}else if(!a&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){a=!0,u=-1,c=0;continue}return o(h,String(e),s,t)}s=!1,(c=(l=n(l,t,10,h.s)).indexOf("."))>-1?l=l.replace(".",""):c=l.length}for(u=0;48===l.charCodeAt(u);u++);for(f=l.length;48===l.charCodeAt(--f););if(l=l.slice(u,++f)){if(f-=u,s&&E.DEBUG&&f>15&&(e>U||e!==N(e)))throw Error(L+h.s*e);if((c=c-u-1)>b)h.c=h.e=null;else if(c=m)?V(u,a):$(u,a,"0");else if(i=(e=J(new E(e),t,r)).e,c=(u=G(e.c)).length,1==n||2==n&&(t<=i||i<=v)){for(;cc){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=i-c)>0)for(i+1==c&&(u+=".");t--;u+="0");return e.s<0&&o?"-"+u:u}function A(e,t){for(var r,n=1,o=new E(e[0]);n=10;o/=10,n++);return(r=n+r*I-1)>b?e.c=e.e=null:r=10;c/=10,o++);if((i=t-o)<0)i+=I,a=t,f=(u=l[s=0])/h[o-a-1]%10|0;else if((s=P((i+1)/I))>=l.length){if(!n)break e;for(;l.length<=s;l.push(0));u=f=0,o=1,a=(i%=I)-I+1}else{for(u=c=l[s],o=1;c>=10;c/=10,o++);f=(a=(i%=I)-I+o)<0?0:u/h[o-a-1]%10|0}if(n=n||t<0||null!=l[s+1]||(a<0?u:u%h[o-a-1]),n=r<4?(f||n)&&(0==r||r==(e.s<0?3:2)):f>5||5==f&&(4==r||n||6==r&&(i>0?a>0?u/h[o-a]:0:l[s-1])%10&1||r==(e.s<0?8:7)),t<1||!l[0])return l.length=0,n?(t-=e.e+1,l[0]=h[(I-t%I)%I],e.e=-t||0):l[0]=e.e=0,e;if(0==i?(l.length=s,c=1,s--):(l.length=s+1,c=h[I-i],l[s]=a>0?N(u/h[o-a]%h[a])*c:0),n)for(;;){if(0==s){for(i=1,a=l[0];a>=10;a/=10,i++);for(a=l[0]+=c,c=1;a>=10;a/=10,c++);i!=c&&(e.e++,l[0]==B&&(l[0]=1));break}if(l[s]+=c,l[s]!=B)break;l[s--]=0,c=1}for(i=l.length;0===l[--i];l.pop());}e.e>b?e.c=e.e=null:e.e=m?V(t,r):$(t,r,"0"),e.s<0?"-"+t:t)}return E.clone=e,E.ROUND_UP=0,E.ROUND_DOWN=1,E.ROUND_CEIL=2,E.ROUND_FLOOR=3,E.ROUND_HALF_UP=4,E.ROUND_HALF_DOWN=5,E.ROUND_HALF_EVEN=6,E.ROUND_HALF_CEIL=7,E.ROUND_HALF_FLOOR=8,E.EUCLID=9,E.config=E.set=function(e){var t,r;if(null!=e){if("object"!=T(e))throw Error(j+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(z(r=e[t],0,H,t),y=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(z(r=e[t],0,8,t),d=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(z(r[0],-H,0,t),z(r[1],0,H,t),v=r[0],m=r[1]):(z(r,-H,H,t),v=-(m=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)z(r[0],-H,-1,t),z(r[1],1,H,t),g=r[0],b=r[1];else{if(z(r,-H,H,t),!r)throw Error(j+t+" cannot be zero: "+r);g=-(b=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(j+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw w=!r,Error(j+"crypto unavailable");w=r}else w=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(z(r=e[t],0,9,t),k=r),e.hasOwnProperty(t="POW_PRECISION")&&(z(r=e[t],0,H,t),x=r),e.hasOwnProperty(t="FORMAT")){if("object"!=T(r=e[t]))throw Error(j+t+" not an object: "+r);_=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(j+t+" invalid: "+r);O=r}}return{DECIMAL_PLACES:y,ROUNDING_MODE:d,EXPONENTIAL_AT:[v,m],RANGE:[g,b],CRYPTO:w,MODULO_MODE:k,POW_PRECISION:x,FORMAT:_,ALPHABET:O}},E.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!E.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&o>=-H&&o<=H&&o===N(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((t=(o+1)%I)<1&&(t+=I),String(n[0]).length==t){for(t=0;t=B||r!==N(r))break e;if(0!==r)return!0}}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(j+"Invalid BigNumber: "+e)},E.maximum=E.max=function(){return A(arguments,h.lt)},E.minimum=E.min=function(){return A(arguments,h.gt)},E.random=(i=9007199254740992,a=Math.random()*i&2097151?function(){return N(Math.random()*i)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,c=0,u=[],s=new E(p);if(null==e?e=y:z(e,0,H),o=P(e/I),w)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));c>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[c]=r[0],t[c+1]=r[1]):(u.push(i%1e14),c+=2);c=o/2}else{if(!crypto.randomBytes)throw w=!1,Error(j+"crypto unavailable");for(t=crypto.randomBytes(o*=7);c=9e15?crypto.randomBytes(7).copy(t,c):(u.push(i%1e14),c+=7);c=o/7}if(!w)for(;c=10;i/=10,c++);cr-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/r|0,a[o]%=r)}return a.reverse()}return function(n,o,i,a,c){var u,s,f,l,h,p,v,m,g=n.indexOf("."),b=y,w=d;for(g>=0&&(l=x,x=0,n=n.replace(".",""),p=(m=new E(o)).pow(n.length-g),x=l,m.c=t($(G(p.c),p.e,"0"),10,i,e),m.e=m.c.length),f=l=(v=t(n,o,i,c?(u=O,e):(u=e,O))).length;0==v[--l];v.pop());if(!v[0])return u.charAt(0);if(g<0?--f:(p.c=v,p.e=f,p.s=a,v=(p=r(p,m,b,w,i)).c,h=p.r,f=p.e),g=v[s=f+b+1],l=i/2,h=h||s<0||null!=v[s+1],h=w<4?(null!=g||h)&&(0==w||w==(p.s<0?3:2)):g>l||g==l&&(4==w||h||6==w&&1&v[s-1]||w==(p.s<0?8:7)),s<1||!v[0])n=h?$(u.charAt(1),-b,u.charAt(0)):u.charAt(0);else{if(v.length=s,h)for(--i;++v[--s]>i;)v[s]=0,s||(++f,v=[1].concat(v));for(l=v.length;!v[--l];);for(g=0,n="";g<=l;n+=u.charAt(v[g++]));n=$(n,f,u.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,o,i,a,c=0,u=e.length,s=t%M,f=t/M|0;for(e=e.slice();u--;)c=((o=s*(i=e[u]%M)+(n=f*i+(a=e[u]/M|0)*s)%M*M+c)/r|0)+(n/M|0)+f*a,e[u]=o%r;return c&&(e=[c].concat(e)),e}function t(e,t,r,n){var o,i;if(r!=n)i=r>n?1:-1;else for(o=i=0;ot[o]?1:-1;break}return i}function r(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]1;e.splice(0,1));}return function(n,o,i,a,c){var u,s,f,l,h,p,y,d,v,m,g,b,w,k,x,_,O,S=n.s==o.s?1:-1,A=n.c,T=o.c;if(!(A&&A[0]&&T&&T[0]))return new E(n.s&&o.s&&(A?!T||A[0]!=T[0]:T)?A&&0==A[0]||!T?0*S:S/0:NaN);for(v=(d=new E(S)).c=[],S=i+(s=n.e-o.e)+1,c||(c=B,s=F(n.e/I)-F(o.e/I),S=S/I|0),f=0;T[f]==(A[f]||0);f++);if(T[f]>(A[f]||0)&&s--,S<0)v.push(1),l=!0;else{for(k=A.length,_=T.length,f=0,S+=2,(h=N(c/(T[0]+1)))>1&&(T=e(T,h,c),A=e(A,h,c),_=T.length,k=A.length),w=_,g=(m=A.slice(0,_)).length;g<_;m[g++]=0);O=T.slice(),O=[0].concat(O),x=T[0],T[1]>=c/2&&x++;do{if(h=0,(u=t(T,m,_,g))<0){if(b=m[0],_!=g&&(b=b*c+(m[1]||0)),(h=N(b/x))>1)for(h>=c&&(h=c-1),y=(p=e(T,h,c)).length,g=m.length;1==t(p,m,y,g);)h--,r(p,_=10;S/=10,f++);J(d,i+(d.e=f+s*I-1)+1,a,l)}else d.e=s,d.r=+l;return d}}(),c=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,s=/^\.([^.]+)$/,f=/^-?(Infinity|NaN)$/,l=/^\s*\+(?=[\w.])|^\s+|\s+$/g,o=function(e,t,r,n){var o,i=r?t:t.replace(l,"");if(f.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(c,(function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t})),n&&(o=n,i=i.replace(u,"$1").replace(s,"0.$1")),t!=i))return new E(i,o);if(E.DEBUG)throw Error(j+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},h.absoluteValue=h.abs=function(){var e=new E(this);return e.s<0&&(e.s=1),e},h.comparedTo=function(e,t){return W(this,new E(e,t))},h.decimalPlaces=h.dp=function(e,t){var r,n,o,i=this;if(null!=e)return z(e,0,H),null==t?t=d:z(t,0,8),J(new E(i),e+i.e+1,t);if(!(r=i.c))return null;if(n=((o=r.length-1)-F(this.e/I))*I,o=r[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},h.dividedBy=h.div=function(e,t){return r(this,new E(e,t),y,d)},h.dividedToIntegerBy=h.idiv=function(e,t){return r(this,new E(e,t),0,1)},h.exponentiatedBy=h.pow=function(e,t){var r,n,o,i,a,c,u,s,f=this;if((e=new E(e)).c&&!e.isInteger())throw Error(j+"Exponent not an integer: "+Y(e));if(null!=t&&(t=new E(t)),a=e.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!e.c||!e.c[0])return s=new E(Math.pow(+Y(f),a?2-q(e):+Y(e))),t?s.mod(t):s;if(c=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new E(NaN);(n=!c&&f.isInteger()&&t.isInteger())&&(f=f.mod(t))}else{if(e.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||a&&f.c[1]>=24e7:f.c[0]<8e13||a&&f.c[0]<=9999975e7)))return i=f.s<0&&q(e)?-0:0,f.e>-1&&(i=1/i),new E(c?1/i:i);x&&(i=P(x/I+2))}for(a?(r=new E(.5),c&&(e.s=1),u=q(e)):u=(o=Math.abs(+Y(e)))%2,s=new E(p);;){if(u){if(!(s=s.times(f)).c)break;i?s.c.length>i&&(s.c.length=i):n&&(s=s.mod(t))}if(o){if(0===(o=N(o/2)))break;u=o%2}else if(J(e=e.times(r),e.e+1,1),e.e>14)u=q(e);else{if(0==(o=+Y(e)))break;u=o%2}f=f.times(f),i?f.c&&f.c.length>i&&(f.c.length=i):n&&(f=f.mod(t))}return n?s:(c&&(s=p.div(s)),t?s.mod(t):i?J(s,x,d,void 0):s)},h.integerValue=function(e){var t=new E(this);return null==e?e=d:z(e,0,8),J(t,t.e+1,e)},h.isEqualTo=h.eq=function(e,t){return 0===W(this,new E(e,t))},h.isFinite=function(){return!!this.c},h.isGreaterThan=h.gt=function(e,t){return W(this,new E(e,t))>0},h.isGreaterThanOrEqualTo=h.gte=function(e,t){return 1===(t=W(this,new E(e,t)))||0===t},h.isInteger=function(){return!!this.c&&F(this.e/I)>this.c.length-2},h.isLessThan=h.lt=function(e,t){return W(this,new E(e,t))<0},h.isLessThanOrEqualTo=h.lte=function(e,t){return-1===(t=W(this,new E(e,t)))||0===t},h.isNaN=function(){return!this.s},h.isNegative=function(){return this.s<0},h.isPositive=function(){return this.s>0},h.isZero=function(){return!!this.c&&0==this.c[0]},h.minus=function(e,t){var r,n,o,i,a=this,c=a.s;if(t=(e=new E(e,t)).s,!c||!t)return new E(NaN);if(c!=t)return e.s=-t,a.plus(e);var u=a.e/I,s=e.e/I,f=a.c,l=e.c;if(!u||!s){if(!f||!l)return f?(e.s=-t,e):new E(l?a:NaN);if(!f[0]||!l[0])return l[0]?(e.s=-t,e):new E(f[0]?a:3==d?-0:0)}if(u=F(u),s=F(s),f=f.slice(),c=u-s){for((i=c<0)?(c=-c,o=f):(s=u,o=l),o.reverse(),t=c;t--;o.push(0));o.reverse()}else for(n=(i=(c=f.length)<(t=l.length))?c:t,c=t=0;t0)for(;t--;f[r++]=0);for(t=B-1;n>c;){if(f[--n]=0;){for(r=0,h=b[o]%v,p=b[o]/v|0,i=o+(a=u);i>o;)r=((s=h*(s=g[--a]%v)+(c=p*s+(f=g[a]/v|0)*h)%v*v+y[i]+r)/d|0)+(c/v|0)+p*f,y[i--]=s%d;y[i]=r}return r?++n:y.splice(0,1),R(e,y,n)},h.negated=function(){var e=new E(this);return e.s=-e.s||null,e},h.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new E(e,t)).s,!o||!t)return new E(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/I,a=e.e/I,c=n.c,u=e.c;if(!i||!a){if(!c||!u)return new E(o/0);if(!c[0]||!u[0])return u[0]?e:new E(c[0]?n:0*o)}if(i=F(i),a=F(a),c=c.slice(),o=i-a){for(o>0?(a=i,r=u):(o=-o,r=c),r.reverse();o--;r.push(0));r.reverse()}for((o=c.length)-(t=u.length)<0&&(r=u,u=c,c=r,t=o),o=0;t;)o=(c[--t]=c[t]+u[t]+o)/B|0,c[t]=B===c[t]?0:c[t]%B;return o&&(c=[o].concat(c),++a),R(e,c,a)},h.precision=h.sd=function(e,t){var r,n,o,i=this;if(null!=e&&e!==!!e)return z(e,1,H),null==t?t=d:z(t,0,8),J(new E(i),e,t);if(!(r=i.c))return null;if(n=(o=r.length-1)*I+1,o=r[o]){for(;o%10==0;o/=10,n--);for(o=r[0];o>=10;o/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},h.shiftedBy=function(e){return z(e,-9007199254740991,U),this.times("1e"+e)},h.squareRoot=h.sqrt=function(){var e,t,n,o,i,a=this,c=a.c,u=a.s,s=a.e,f=y+4,l=new E("0.5");if(1!==u||!c||!c[0])return new E(!u||u<0&&(!c||c[0])?NaN:c?a:1/0);if(0==(u=Math.sqrt(+Y(a)))||u==1/0?(((t=G(c)).length+s)%2==0&&(t+="0"),u=Math.sqrt(+t),s=F((s+1)/2)-(s<0||s%2),n=new E(t=u==1/0?"5e"+s:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+s)):n=new E(u+""),n.c[0])for((u=(s=n.e)+f)<3&&(u=0);;)if(i=n,n=l.times(i.plus(r(a,i,f,1))),G(i.c).slice(0,u)===(t=G(n.c)).slice(0,u)){if(n.e0&&y>0){for(i=y%c||c,f=p.substr(0,i);i0&&(f+=s+p.slice(i)),h&&(f="-"+f)}n=l?f+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?l.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):l):f}return(r.prefix||"")+n+(r.suffix||"")},h.toFraction=function(e){var t,n,o,i,a,c,u,s,f,l,h,y,v=this,m=v.c;if(null!=e&&(!(u=new E(e)).isInteger()&&(u.c||1!==u.s)||u.lt(p)))throw Error(j+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+Y(u));if(!m)return new E(v);for(t=new E(p),f=n=new E(p),o=s=new E(p),y=G(m),a=t.e=y.length-v.e-1,t.c[0]=D[(c=a%I)<0?I+c:c],e=!e||u.comparedTo(t)>0?a>0?t:f:u,c=b,b=1/0,u=new E(y),s.c[0]=0;l=r(u,t,0,1),1!=(i=n.plus(l.times(o))).comparedTo(e);)n=o,o=i,f=s.plus(l.times(i=f)),s=i,t=u.minus(l.times(i=t)),u=i;return i=r(e.minus(n),o,0,1),s=s.plus(i.times(f)),n=n.plus(i.times(o)),s.s=f.s=v.s,h=r(f,o,a*=2,d).minus(v).abs().comparedTo(r(s,n,a,d).minus(v).abs())<1?[f,o]:[s,n],b=c,h},h.toNumber=function(){return+Y(this)},h.toPrecision=function(e,t){return null!=e&&z(e,1,H),S(this,e,t,2)},h.toString=function(e){var t,r=this,o=r.s,i=r.e;return null===i?o?(t="Infinity",o<0&&(t="-"+t)):t="NaN":(null==e?t=i<=v||i>=m?V(G(r.c),i):$(G(r.c),i,"0"):10===e?t=$(G((r=J(new E(r),y+i+1,d)).c),r.e,"0"):(z(e,2,O.length,"Base"),t=n($(G(r.c),i,"0"),10,e,o,!0)),o<0&&r.c[0]&&(t="-"+t)),t},h.valueOf=h.toJSON=function(){return Y(this)},h._isBigNumber=!0,null!=t&&E.set(t),E}();const J=R;function Y(e,t){for(var r=0;r64)return S.chunkSubstr(r,64).slice(2).map((function(e){return t.parseString(e)})).join("");var n="";try{n=decodeURIComponent("%"+r.match(/.{1,2}/g).filter((function(e){return"00"!=e})).join("%"))}catch(e){}return n}},{key:"parseHexRLP",value:function(e){var t=e;return"0"==t.indexOf("0x")&&(t=t.substr(2)),t.length>64?S.chunkSubstr(t,64):[t]}},{key:"toSmallestUnitHex",value:function(e){var t=e.amount,r=e.decimals;return new J(t).multipliedBy(new J(10).pow(r)).toString(16)}},{key:"toSmallestUnit",value:function(e){var t=e.amount,r=e.decimals;return new J(t).multipliedBy(new J(10).pow(r)).toString()}},{key:"toContractData",value:function(e){var t=this,r=e.func,n=e.params;if(!r)return"0x";var o="string"==typeof r?r:r.toString(),i=Array.isArray(n)?n.map((function(e){return t.leftPad32(S.toHex(e))})):[this.leftPad32(S.toHex(n))];return"0x".concat(A.Z.keccak256(o).substr(0,8)).concat(i.join(""))}},{key:"isEthereumAddress",value:function(e){return/^0x[a-fA-F0-9]{40}$/.test(e)}}],null&&Y(t.prototype,null),r&&Y(t,r),e}();function K(e){return K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},K(e)}function Z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==u[0]?u[0]:{},r=t.contract,n=t.address,o=t.state,i=void 0===o?"latest":o,a=n,X.isEthereumAddress(n)||(a=this.address),"string"!=typeof r){e.next=5;break}return e.abrupt("return",this.getContractBalance({contract:r,address:n}));case 5:return c={method:"eth_getBalance",params:[a,i]},e.abrupt("return",ethereum.request(c).then((function(e){return new J(e).dividedBy(new J(10).pow(18)).toString()})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getContractBalance",value:(y=te(regeneratorRuntime.mark((function e(){var t,r,n,o,i,a,c=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.contract,n=t.address,o=t.state,i=void 0===o?"latest":o,a=n,X.isEthereumAddress(n)||(a=this.address),e.abrupt("return",Promise.all([this.getData({contract:r,func:"balanceOf(address)",params:[a],state:i}),this.getDecimals({contract:r})]).then((function(e){var t=Z(e,2),r=t[0],n=t[1],o=new J(r).dividedBy(new J(10).pow(n)).toString();return Promise.resolve(o)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"getDecimals",value:(p=te(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract){e.next=4;break}try{n=this.blockchain.nativeCurrency.decimals}catch(e){n=18}return e.abrupt("return",Promise.resolve(n));case 4:return e.abrupt("return",this.getData({contract:r,func:"decimals()"}).then((function(e){var t=parseInt(e);return Promise.resolve(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"getName",value:(h=te(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract){e.next=4;break}try{n=this.blockchain.nativeCurrency.symbol}catch(e){n="ETH"}return e.abrupt("return",Promise.resolve(n));case 4:return e.abrupt("return",this.getData({contract:r,func:"name()"}).then((function(e){var t=X.parseString(e);return Promise.resolve(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"getSymbol",value:(l=te(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract){e.next=4;break}try{n=this.blockchain.nativeCurrency.symbol}catch(e){n="ETH"}return e.abrupt("return",Promise.resolve(n));case 4:return e.abrupt("return",this.getData({contract:r,func:"symbol()"}).then((function(e){var t=X.parseString(e);return Promise.resolve(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getTotalSupply",value:(s=te(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},r=t.contract){e.next=3;break}return e.abrupt("return",Promise.resolve("0"));case 3:return e.abrupt("return",Promise.all([this.getData({contract:r,func:"totalSupply()"}),this.getDecimals({contract:r})]).then((function(e){var t=Z(e,2),r=t[0],n=t[1],o=new J(r).dividedBy(new J(10).pow(n)).toString();return Promise.resolve(o)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getAsset",value:(u=te(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=t.contract,t.decimals,e.abrupt("return",Promise.all([this.getName({contract:r}),this.getSymbol({contract:r}),this.getDecimals({contract:r}),this.getTotalSupply({contract:r})]).then((function(e){var t=Z(e,4),r=t[0],n=t[1],o=t[2],i=t[3];return Promise.resolve({name:r,symbol:n,decimals:o,totalSupply:i})})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getAllowance",value:(a=te(regeneratorRuntime.mark((function e(){var t,r,n,o,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},r=t.contract,n=t.owner,o=t.spender,r){e.next=3;break}return e.abrupt("return",Promise.resolve("0"));case 3:return e.abrupt("return",Promise.all([this.getData({contract:r,func:"allowance(address,address)",params:[n,o]}),this.getDecimals({contract:r})]).then((function(e){var t=Z(e,2),r=t[0],n=t[1],o=new J(r).dividedBy(new J(10).pow(n)).toString();return Promise.resolve(o)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_connect",value:(i=te(regeneratorRuntime.mark((function e(t){var r,n,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blockchain,n={method:"eth_requestAccounts"},e.abrupt("return",ethereum.request(n).then((function(e){return o._blockchain=r,o._address=e[0],o._isConnected=!0,o.switchBlockchain({blockchain:r})})));case 3:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"switchBlockchain",value:(o=te(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blockchain,e.abrupt("return",this._addBlockchain({blockchain:r}).then((function(){var e={method:"wallet_switchEthereumChain",params:[{chainId:r.chainId}]};return ethereum.request(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_addBlockchain",value:(n=te(regeneratorRuntime.mark((function e(t){var r,n,o,i,a,c,u,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.blockchain,n=r.chainId,o=r.chainName,i=r.nativeCurrency,a=r.rpcUrls,c=r.blockExplorerUrls,u=parseInt(n),!([1,3,4,5,42].indexOf(u)>-1)){e.next=6;break}return e.abrupt("return",!0);case 6:return s={method:"wallet_addEthereumChain",params:[{chainId:n,chainName:o,nativeCurrency:i,rpcUrls:a,blockExplorerUrls:c}]},e.abrupt("return",ethereum.request(s));case 8:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],r&&re(t.prototype,r),_}(d);const ue=ce;function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function fe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function le(e,t){return le=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},le(e,t)}function he(e,t){if(t&&("object"===se(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return pe(e)}function pe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ye(e){return ye=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ye(e)}function de(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ve=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&le(e,t)}(o,e);var t,r,n=(t=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=ye(t);if(r){var o=ye(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return he(this,e)});function o(){var e;fe(this,o);for(var t=arguments.length,r=new Array(t),i=0;i0&&void 0!==arguments[0]?arguments[0]:"";switch(t){case f.TideWallet:e=new O;break;case f.imToken:e=new me;break;default:e=new ue}return e}}],null&&ge(t.prototype,null),r&&ge(t,r),e}();const we=be;function ke(e,t){for(var r=0;r0&&void 0!==c[0]?c[0]:{},r=t.wallet,n=t.blockchain,!this.isConnected){e.next=3;break}return e.abrupt("return",!0);case 3:if(o=this.env.wallets[0],i=r||o,this._connector=this.findConnector({walletType:i}),this._connector){e.next=12;break}return a=we.create(i),this._connectors.push(a),this._connector=a,e.next=12,this._connector.connect({blockchain:n});case 12:return e.abrupt("return",this.address);case 13:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"switchBlockchain",value:(p=Oe(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blockchain,e.next=3,this._connector.switchBlockchain({blockchain:r});case 3:return e.abrupt("return",this.address);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"disconnect",value:(h=Oe(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._connector.disconnect());case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"getAsset",value:(l=Oe(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=t.contract,e.abrupt("return",this._connector.getAsset({contract:r}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getBalance",value:(f=Oe(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract,n=t.address,e.abrupt("return",this._connector.getBalance({contract:r,address:n}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getAllowance",value:(s=Oe(regeneratorRuntime.mark((function e(t){var r,n,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.contract,n=t.owner,o=t.spender,e.abrupt("return",this._connector.getAllowance({contract:r,owner:n,spender:o}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getData",value:(u=Oe(regeneratorRuntime.mark((function e(t){var r,n,o,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.contract,n=t.func,o=t.params,i=t.data,e.abrupt("return",this._connector.getData({contract:r,func:n,params:o,data:i}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"send",value:(a=Oe(regeneratorRuntime.mark((function e(t){var r,n,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.to,n=t.amount,o=t.data,e.abrupt("return",this._connector.send({to:r,amount:n,data:o}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"interfaceOf",value:(i=Oe(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.contract,n=t.abi,e.abrupt("return",this._connector.interfaceOf({contract:r,abi:n}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}],o=[{key:"listBlockchain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.testnet;return c.list({testnet:t})}},{key:"findBlockchain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.chainId;return c.findByChainId(t)}}],r&&Ee(t.prototype,r),o&&Ee(t,o),e}();Se(Ae,"Blockchains",c),Se(Ae,"Wallets",f),Se(Ae,"version","v".concat("0.3.5")),window&&(window.Lunar=Ae);const Te=Ae}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n](i,i.exports,r),i.loaded=!0,i.exports}r.amdO={},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(751);var n=r(896);return n.default})()})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Lunar=t():e.Lunar=t()}(this,(function(){return(()=>{var e={92:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}d(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&d(e,"error",t,{once:!0})}(e,o)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function s(e,t,r,n){var o,i,a,s;if(c(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),a=i[t]),void 0===a)a=i[t]=r,++e._eventsCount;else if("function"==typeof a?a=i[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(o=u(e))>0&&a.length>o&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=a.length,s=f,console&&console.warn&&console.warn(s)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=f.bind(n);return o.listener=r,n.wrapFn=o,o}function h(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(a=t[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)n(u,this,t);else{var s=u.length,f=y(u,s);for(r=0;r=0;i--)if(r[i]===t||r[i].listener===t){a=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},751:e=>{var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof v?t:v,i=Object.create(o.prototype),a=new T(n||[]);return i._invoke=function(e,t,r){var n=l;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw i;return C()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=f(e,t,r);if("normal"===u.type){if(n=r.done?y:h,u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=y,r.method="throw",r.arg=u.arg)}}}(e,r,a),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",h="suspendedYield",p="executing",y="completed",d={};function v(){}function m(){}function g(){}var b={};u(b,i,(function(){return this}));var w=Object.getPrototypeOf,k=w&&w(w(R([])));k&&k!==r&&n.call(k,i)&&(b=k);var x=g.prototype=v.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(o,i,a,c){var u=f(e[o],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,c)}))}c(u.arg)}var o;this._invoke=function(e,n){function i(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(i,i):i()}}function E(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=f(n,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function R(e){if(e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}},375:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}r.d(t,{Z:()=>B}),e=r.hmd(e);var o="input is invalid type",i="object"===("undefined"==typeof window?"undefined":n(window)),a=i?window:{};a.JS_SHA3_NO_WINDOW&&(i=!1);var c=!i&&"object"===("undefined"==typeof self?"undefined":n(self));!a.JS_SHA3_NO_NODE_JS&&"object"===("undefined"==typeof process?"undefined":n(process))&&process.versions&&process.versions.node?a=r.g:c&&(a=self),!a.JS_SHA3_NO_COMMON_JS&&"object"===n(e)&&e.exports,"function"==typeof define&&r.amdO;var u=!a.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,s="0123456789abcdef".split(""),f=[4,1024,262144,67108864],l=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],p=[224,256,384,512],y=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};!a.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===n(e)&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var m=function(e,t,r){return function(n){return new N(e,t,e).update(n)[r]()}},g=function(e,t,r){return function(n,o){return new N(e,t,o).update(n)[r]()}},b=function(e,t,r){return function(t,n,o,i){return O["cshake"+e].update(t,n,o,i)[r]()}},w=function(e,t,r){return function(t,n,o,i){return O["kmac"+e].update(t,n,o,i)[r]()}},k=function(e,t,r,n){for(var o=0;o>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function j(e,t,r){N.call(this,e,t,r)}N.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=n(e);if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(o);t=!0}for(var i,a,c=this.blocks,s=this.byteCount,f=e.length,h=this.blockCount,p=0,y=this.s;p>2]|=e[p]<>2]|=a<>2]|=(192|a>>6)<>2]|=(128|63&a)<=57344?(c[i>>2]|=(224|a>>12)<>2]|=(128|a>>6&63)<>2]|=(128|63&a)<>2]|=(240|a>>18)<>2]|=(128|a>>12&63)<>2]|=(128|a>>6&63)<>2]|=(128|63&a)<=s){for(this.start=i-s,this.block=c[h],i=0;i>=8);r>0;)o.unshift(r),r=255&(e>>=8),++n;return t?o.push(n):o.unshift(n),this.update(o),o.length},N.prototype.encodeString=function(e){var t,r=n(e);if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(o);t=!0}var i=0,a=e.length;if(t)i=a;else for(var c=0;c=57344?i+=3:(s=65536+((1023&s)<<10|1023&e.charCodeAt(++c)),i+=4)}return i+=this.encode(8*i),this.update(e),i},N.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+s[15&e]+s[e>>12&15]+s[e>>8&15]+s[e>>20&15]+s[e>>16&15]+s[e>>28&15]+s[e>>24&15];a%t==0&&(L(r),i=0)}return o&&(e=r[i],c+=s[e>>4&15]+s[15&e],o>1&&(c+=s[e>>12&15]+s[e>>8&15]),o>2&&(c+=s[e>>20&15]+s[e>>16&15])),c},N.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,o=this.extraBytes,i=0,a=0,c=this.outputBits>>3;e=o?new ArrayBuffer(n+1<<2):new ArrayBuffer(c);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;c%r==0&&L(n)}return i&&(e=c<<2,t=n[a],u[e]=255&t,i>1&&(u[e+1]=t>>8&255),i>2&&(u[e+2]=t>>16&255)),u},j.prototype=new N,j.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var L=function(e){var t,r,n,o,i,a,c,u,s,f,l,p,y,d,v,m,g,b,w,k,x,_,O,E,S,A,T,R,C,P,N,j,L,B,I,U,D,M,H,F,G,W,q,z,V,$,J,Y,X,K,Z,Q,ee,te,re,ne,oe,ie,ae,ce,ue,se,fe;for(n=0;n<48;n+=2)o=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],c=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],s=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(p=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|c>>>31),r=(y=e[9]^e[19]^e[29]^e[39]^e[49])^(c<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=o^(u<<1|s>>>31),r=i^(s<<1|u>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(f<<1|l>>>31),r=c^(l<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=u^(p<<1|y>>>31),r=s^(y<<1|p>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(o<<1|i>>>31),r=l^(i<<1|o>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,d=e[0],v=e[1],$=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,R=e[20]<<3|e[21]>>>29,C=e[21]<<3|e[20]>>>29,ce=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,W=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,B=e[2]<<1|e[3]>>>31,I=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,g=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,N=e[32]<<13|e[33]>>>19,se=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,U=e[14]<<6|e[15]>>>26,D=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,K=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,j=e[45]<<29|e[44]>>>3,L=e[44]<<29|e[45]>>>3,E=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,oe=e[16]<<23|e[17]>>>9,M=e[26]<<25|e[27]>>>7,H=e[27]<<25|e[26]>>>7,k=e[36]<<21|e[37]>>>11,x=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,z=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,A=e[18]<<20|e[19]>>>12,T=e[19]<<20|e[18]>>>12,ie=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,F=e[38]<<8|e[39]>>>24,G=e[39]<<8|e[38]>>>24,_=e[48]<<14|e[49]>>>18,O=e[49]<<14|e[48]>>>18,e[0]=d^~m&b,e[1]=v^~g&w,e[10]=E^~A&R,e[11]=S^~T&C,e[20]=B^~U&M,e[21]=I^~D&H,e[30]=z^~$&Y,e[31]=V^~J&X,e[40]=te^~ne&ie,e[41]=re^~oe&ae,e[2]=m^~b&k,e[3]=g^~w&x,e[12]=A^~R&P,e[13]=T^~C&N,e[22]=U^~M&F,e[23]=D^~H&G,e[32]=$^~Y&K,e[33]=J^~X&Z,e[42]=ne^~ie&ce,e[43]=oe^~ae&ue,e[4]=b^~k&_,e[5]=w^~x&O,e[14]=R^~P&j,e[15]=C^~N&L,e[24]=M^~F&W,e[25]=H^~G&q,e[34]=Y^~K&Q,e[35]=X^~Z&ee,e[44]=ie^~ce&se,e[45]=ae^~ue&fe,e[6]=k^~_&d,e[7]=x^~O&v,e[16]=P^~j&E,e[17]=N^~L&S,e[26]=F^~W&B,e[27]=G^~q&I,e[36]=K^~Q&z,e[37]=Z^~ee&V,e[46]=ce^~se&te,e[47]=ue^~fe&re,e[8]=_^~d&m,e[9]=O^~v&g,e[18]=j^~E&A,e[19]=L^~S&T,e[28]=W^~B&U,e[29]=q^~I&D,e[38]=Q^~z&$,e[39]=ee^~V&J,e[48]=se^~te&ne,e[49]=fe^~re&oe,e[0]^=h[n],e[1]^=h[n+1]};const B=O},896:(e,t,r)=>{"use strict";r.d(t,{default:()=>Ce});var n=r(92);function o(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"",r=t.toString(16);return 0!=r.indexOf("0x")&&(r="0x".concat(r)),this.keys.map((function(t){return e[t]})).find((function(e){return parseInt(e.chainId)==parseInt(r)}))}}],null&&o(t.prototype,null),r&&o(t,r),e}();i(a,"Avax",{chainId:"0xa86a",key:"Avax",chainName:"Avalanche Network",nativeCurrency:{symbol:"AVAX",decimals:18},rpcUrls:["https://api.avax.network/ext/bc/C/rpc"],blockExplorerUrls:["https://cchain.explorer.avax.network/"],isTestnet:!1}),i(a,"BSC",{chainId:"0x38",key:"BSC",chainName:"Binance Smart Chain Mainnet",nativeCurrency:{symbol:"BNB",decimals:18},rpcUrls:["https://bsc-dataseed.binance.org/"],blockExplorerUrls:["https://bscscan.com/"],isTestnet:!1}),i(a,"BSCTestnet",{chainId:"0x61",key:"BSCTestnet",chainName:"Binance Smart Chain Testnet",nativeCurrency:{symbol:"BNB",decimals:18},rpcUrls:["https://data-seed-prebsc-1-s1.binance.org:8545/"],blockExplorerUrls:["https://testnet.bscscan.com"],isTestnet:!0}),i(a,"Ethereum",{chainId:"0x1",key:"Ethereum",chainName:"Ethereum",nativeCurrency:{symbol:"ETH",decimals:18},isTestnet:!1}),i(a,"AvaxTestnet",{chainId:"0xa869",key:"AvaxTestnet",chainName:"Avalanche Testnet FUJI",nativeCurrency:{symbol:"AVAX",decimals:18},rpcUrls:["https://api.avax-test.network/ext/bc/C/rpc"],blockExplorerUrls:["https://cchain.explorer.avax-test.network"],isTestnet:!0}),i(a,"Huobi",{chainId:"0x80",key:"Huobi",chainName:"HuobiChain",nativeCurrency:{symbol:"HT",decimals:18},rpcUrls:["https://http-mainnet-node.huobichain.com/"],blockExplorerUrls:["https://hecoinfo.com/"],isTestnet:!1}),i(a,"HuobiTestnet",{chainId:"0x100",key:"HuobiTestnet",chainName:"HuobiChain Testnet",nativeCurrency:{symbol:"HT",decimals:18},rpcUrls:["https://http-testnet.hecochain.com/"],blockExplorerUrls:["https://scan-testnet.hecochain.com"],isTestnet:!0}),i(a,"Polygon",{chainId:"0x89",key:"Polygon",chainName:"Polygon",nativeCurrency:{symbol:"MATIC",decimals:18},rpcUrls:["https://rpc-mainnet.maticvigil.com/"],blockExplorerUrls:["https://explorer.matic.network/"],isTestnet:!1}),i(a,"PolygonTestnet",{chainId:"0x13881",key:"PolygonTestnet",chainName:"Polygon Testnet Mumbai",nativeCurrency:{symbol:"MATIC",decimals:18},rpcUrls:["https://rpc-mumbai.maticvigil.com/"],blockExplorerUrls:["https://mumbai-explorer.matic.today/"],isTestnet:!0}),i(a,"EthereumTestnet",{chainId:"0x3",key:"EthereumTestnet",chainName:"ETH testnet Ropsten",nativeCurrency:{symbol:"ETH",decimals:18},isTestnet:!0}),i(a,"Tidetime",{chainId:"0x1f51",key:"Tidetime",chainName:"Tidetime",nativeCurrency:{name:"Tidetime Token",symbol:"TTT",decimals:18},rpcUrls:["https://rpc.tidebit.network"],blockExplorerUrls:["https://explorer.tidebit.network"],iconUrls:["https://iconape.com/wp-content/png_logo_vector/tidebit.png"],isTestnet:!1}),i(a,"xDAI",{chainId:"0x64",key:"xDAI",chainName:"xDai",nativeCurrency:{symbol:"xDAI",decimals:18},rpcUrls:["https://rpc.xdaichain.com/"],blockExplorerUrls:["https://blockscout.com/xdai/mainnet"],isTestnet:!1});const c=a;function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var s=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)};u(s,"Metamask","Metamask"),u(s,"imToken","imToken"),u(s,"TideWallet","TideWallet"),u(s,"Trust","Trust");const f=s;function l(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function h(e,t){for(var r=0;ro?c:o,n[i]=t.charCodeAt(i).toString(16).padStart(2*c,"0")}r=(n=n.map((function(e){return e.padStart(2*o,"0")}))).join("")}else try{r=e.toString(16)}catch(e){r=""}return r}},{key:"isHex",value:function(e){return/^0x[a-fA-F0-9]*$/.test(e)}},{key:"toHex",value:function(e){var t;if(null==e)t="";else if(this.isHex(e))t=e.substr(2);else if(Number.isInteger(e))t=e.toString(16);else if("string"==typeof e)t=this.stringToHex(e);else try{t=e.toString(16)}catch(e){t=""}return t}}],null&&E(t.prototype,null),r&&E(t,r),e}();var A=r(375);function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}var R,C=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,P=Math.ceil,N=Math.floor,j="[BigNumber Error] ",L=j+"Number primitive has more than 15 significant digits: ",B=1e14,I=14,U=9007199254740991,D=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],M=1e7,H=1e9;function F(e){var t=0|e;return e>0||e===t?t:t-1}function G(e){for(var t,r,n=1,o=e.length,i=e[0]+"";ns^r?1:-1;for(c=(u=o.length)<(s=i.length)?u:s,a=0;ai[a]^r?1:-1;return u==s?0:u>s^r?1:-1}function q(e,t,r,n){if(er||e!==N(e))throw Error(j+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function z(e){var t=e.c.length-1;return F(e.e/I)==t&&e.c[t]%2!=0}function V(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function $(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else tb?h.c=h.e=null:e.e=10;u/=10,c++);return void(c>b?h.c=h.e=null:(h.e=c,h.c=[e]))}l=String(e)}else{if(!C.test(l=String(e)))return o(h,l,s);h.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}(c=l.indexOf("."))>-1&&(l=l.replace(".","")),(u=l.search(/e/i))>0?(c<0&&(c=u),c+=+l.slice(u+1),l=l.substring(0,u)):c<0&&(c=l.length)}else{if(q(t,2,O.length,"Base"),10==t)return J(h=new E(e),y+h.e+1,d);if(l=String(e),s="number"==typeof e){if(0*e!=0)return o(h,l,s,t);if(h.s=1/e<0?(l=l.slice(1),-1):1,E.DEBUG&&l.replace(/^0\.0*|\./,"").length>15)throw Error(L+e)}else h.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(r=O.slice(0,t),c=u=0,f=l.length;uc){c=f;continue}}else if(!a&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){a=!0,u=-1,c=0;continue}return o(h,String(e),s,t)}s=!1,(c=(l=n(l,t,10,h.s)).indexOf("."))>-1?l=l.replace(".",""):c=l.length}for(u=0;48===l.charCodeAt(u);u++);for(f=l.length;48===l.charCodeAt(--f););if(l=l.slice(u,++f)){if(f-=u,s&&E.DEBUG&&f>15&&(e>U||e!==N(e)))throw Error(L+h.s*e);if((c=c-u-1)>b)h.c=h.e=null;else if(c=m)?V(u,a):$(u,a,"0");else if(i=(e=J(new E(e),t,r)).e,c=(u=G(e.c)).length,1==n||2==n&&(t<=i||i<=v)){for(;cc){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=i-c)>0)for(i+1==c&&(u+=".");t--;u+="0");return e.s<0&&o?"-"+u:u}function A(e,t){for(var r,n=1,o=new E(e[0]);n=10;o/=10,n++);return(r=n+r*I-1)>b?e.c=e.e=null:r=10;c/=10,o++);if((i=t-o)<0)i+=I,a=t,f=(u=l[s=0])/h[o-a-1]%10|0;else if((s=P((i+1)/I))>=l.length){if(!n)break e;for(;l.length<=s;l.push(0));u=f=0,o=1,a=(i%=I)-I+1}else{for(u=c=l[s],o=1;c>=10;c/=10,o++);f=(a=(i%=I)-I+o)<0?0:u/h[o-a-1]%10|0}if(n=n||t<0||null!=l[s+1]||(a<0?u:u%h[o-a-1]),n=r<4?(f||n)&&(0==r||r==(e.s<0?3:2)):f>5||5==f&&(4==r||n||6==r&&(i>0?a>0?u/h[o-a]:0:l[s-1])%10&1||r==(e.s<0?8:7)),t<1||!l[0])return l.length=0,n?(t-=e.e+1,l[0]=h[(I-t%I)%I],e.e=-t||0):l[0]=e.e=0,e;if(0==i?(l.length=s,c=1,s--):(l.length=s+1,c=h[I-i],l[s]=a>0?N(u/h[o-a]%h[a])*c:0),n)for(;;){if(0==s){for(i=1,a=l[0];a>=10;a/=10,i++);for(a=l[0]+=c,c=1;a>=10;a/=10,c++);i!=c&&(e.e++,l[0]==B&&(l[0]=1));break}if(l[s]+=c,l[s]!=B)break;l[s--]=0,c=1}for(i=l.length;0===l[--i];l.pop());}e.e>b?e.c=e.e=null:e.e=m?V(t,r):$(t,r,"0"),e.s<0?"-"+t:t)}return E.clone=e,E.ROUND_UP=0,E.ROUND_DOWN=1,E.ROUND_CEIL=2,E.ROUND_FLOOR=3,E.ROUND_HALF_UP=4,E.ROUND_HALF_DOWN=5,E.ROUND_HALF_EVEN=6,E.ROUND_HALF_CEIL=7,E.ROUND_HALF_FLOOR=8,E.EUCLID=9,E.config=E.set=function(e){var t,r;if(null!=e){if("object"!=T(e))throw Error(j+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(q(r=e[t],0,H,t),y=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(q(r=e[t],0,8,t),d=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(q(r[0],-H,0,t),q(r[1],0,H,t),v=r[0],m=r[1]):(q(r,-H,H,t),v=-(m=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)q(r[0],-H,-1,t),q(r[1],1,H,t),g=r[0],b=r[1];else{if(q(r,-H,H,t),!r)throw Error(j+t+" cannot be zero: "+r);g=-(b=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(j+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw w=!r,Error(j+"crypto unavailable");w=r}else w=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(q(r=e[t],0,9,t),k=r),e.hasOwnProperty(t="POW_PRECISION")&&(q(r=e[t],0,H,t),x=r),e.hasOwnProperty(t="FORMAT")){if("object"!=T(r=e[t]))throw Error(j+t+" not an object: "+r);_=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(j+t+" invalid: "+r);O=r}}return{DECIMAL_PLACES:y,ROUNDING_MODE:d,EXPONENTIAL_AT:[v,m],RANGE:[g,b],CRYPTO:w,MODULO_MODE:k,POW_PRECISION:x,FORMAT:_,ALPHABET:O}},E.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!E.DEBUG)return!0;var t,r,n=e.c,o=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&o>=-H&&o<=H&&o===N(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((t=(o+1)%I)<1&&(t+=I),String(n[0]).length==t){for(t=0;t=B||r!==N(r))break e;if(0!==r)return!0}}}else if(null===n&&null===o&&(null===i||1===i||-1===i))return!0;throw Error(j+"Invalid BigNumber: "+e)},E.maximum=E.max=function(){return A(arguments,h.lt)},E.minimum=E.min=function(){return A(arguments,h.gt)},E.random=(i=9007199254740992,a=Math.random()*i&2097151?function(){return N(Math.random()*i)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,i,c=0,u=[],s=new E(p);if(null==e?e=y:q(e,0,H),o=P(e/I),w)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));c>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[c]=r[0],t[c+1]=r[1]):(u.push(i%1e14),c+=2);c=o/2}else{if(!crypto.randomBytes)throw w=!1,Error(j+"crypto unavailable");for(t=crypto.randomBytes(o*=7);c=9e15?crypto.randomBytes(7).copy(t,c):(u.push(i%1e14),c+=7);c=o/7}if(!w)for(;c=10;i/=10,c++);cr-1&&(null==a[o+1]&&(a[o+1]=0),a[o+1]+=a[o]/r|0,a[o]%=r)}return a.reverse()}return function(n,o,i,a,c){var u,s,f,l,h,p,v,m,g=n.indexOf("."),b=y,w=d;for(g>=0&&(l=x,x=0,n=n.replace(".",""),p=(m=new E(o)).pow(n.length-g),x=l,m.c=t($(G(p.c),p.e,"0"),10,i,e),m.e=m.c.length),f=l=(v=t(n,o,i,c?(u=O,e):(u=e,O))).length;0==v[--l];v.pop());if(!v[0])return u.charAt(0);if(g<0?--f:(p.c=v,p.e=f,p.s=a,v=(p=r(p,m,b,w,i)).c,h=p.r,f=p.e),g=v[s=f+b+1],l=i/2,h=h||s<0||null!=v[s+1],h=w<4?(null!=g||h)&&(0==w||w==(p.s<0?3:2)):g>l||g==l&&(4==w||h||6==w&&1&v[s-1]||w==(p.s<0?8:7)),s<1||!v[0])n=h?$(u.charAt(1),-b,u.charAt(0)):u.charAt(0);else{if(v.length=s,h)for(--i;++v[--s]>i;)v[s]=0,s||(++f,v=[1].concat(v));for(l=v.length;!v[--l];);for(g=0,n="";g<=l;n+=u.charAt(v[g++]));n=$(n,f,u.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,o,i,a,c=0,u=e.length,s=t%M,f=t/M|0;for(e=e.slice();u--;)c=((o=s*(i=e[u]%M)+(n=f*i+(a=e[u]/M|0)*s)%M*M+c)/r|0)+(n/M|0)+f*a,e[u]=o%r;return c&&(e=[c].concat(e)),e}function t(e,t,r,n){var o,i;if(r!=n)i=r>n?1:-1;else for(o=i=0;ot[o]?1:-1;break}return i}function r(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]1;e.splice(0,1));}return function(n,o,i,a,c){var u,s,f,l,h,p,y,d,v,m,g,b,w,k,x,_,O,S=n.s==o.s?1:-1,A=n.c,T=o.c;if(!(A&&A[0]&&T&&T[0]))return new E(n.s&&o.s&&(A?!T||A[0]!=T[0]:T)?A&&0==A[0]||!T?0*S:S/0:NaN);for(v=(d=new E(S)).c=[],S=i+(s=n.e-o.e)+1,c||(c=B,s=F(n.e/I)-F(o.e/I),S=S/I|0),f=0;T[f]==(A[f]||0);f++);if(T[f]>(A[f]||0)&&s--,S<0)v.push(1),l=!0;else{for(k=A.length,_=T.length,f=0,S+=2,(h=N(c/(T[0]+1)))>1&&(T=e(T,h,c),A=e(A,h,c),_=T.length,k=A.length),w=_,g=(m=A.slice(0,_)).length;g<_;m[g++]=0);O=T.slice(),O=[0].concat(O),x=T[0],T[1]>=c/2&&x++;do{if(h=0,(u=t(T,m,_,g))<0){if(b=m[0],_!=g&&(b=b*c+(m[1]||0)),(h=N(b/x))>1)for(h>=c&&(h=c-1),y=(p=e(T,h,c)).length,g=m.length;1==t(p,m,y,g);)h--,r(p,_=10;S/=10,f++);J(d,i+(d.e=f+s*I-1)+1,a,l)}else d.e=s,d.r=+l;return d}}(),c=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,s=/^\.([^.]+)$/,f=/^-?(Infinity|NaN)$/,l=/^\s*\+(?=[\w.])|^\s+|\s+$/g,o=function(e,t,r,n){var o,i=r?t:t.replace(l,"");if(f.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(c,(function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t})),n&&(o=n,i=i.replace(u,"$1").replace(s,"0.$1")),t!=i))return new E(i,o);if(E.DEBUG)throw Error(j+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},h.absoluteValue=h.abs=function(){var e=new E(this);return e.s<0&&(e.s=1),e},h.comparedTo=function(e,t){return W(this,new E(e,t))},h.decimalPlaces=h.dp=function(e,t){var r,n,o,i=this;if(null!=e)return q(e,0,H),null==t?t=d:q(t,0,8),J(new E(i),e+i.e+1,t);if(!(r=i.c))return null;if(n=((o=r.length-1)-F(this.e/I))*I,o=r[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},h.dividedBy=h.div=function(e,t){return r(this,new E(e,t),y,d)},h.dividedToIntegerBy=h.idiv=function(e,t){return r(this,new E(e,t),0,1)},h.exponentiatedBy=h.pow=function(e,t){var r,n,o,i,a,c,u,s,f=this;if((e=new E(e)).c&&!e.isInteger())throw Error(j+"Exponent not an integer: "+Y(e));if(null!=t&&(t=new E(t)),a=e.e>14,!f.c||!f.c[0]||1==f.c[0]&&!f.e&&1==f.c.length||!e.c||!e.c[0])return s=new E(Math.pow(+Y(f),a?2-z(e):+Y(e))),t?s.mod(t):s;if(c=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new E(NaN);(n=!c&&f.isInteger()&&t.isInteger())&&(f=f.mod(t))}else{if(e.e>9&&(f.e>0||f.e<-1||(0==f.e?f.c[0]>1||a&&f.c[1]>=24e7:f.c[0]<8e13||a&&f.c[0]<=9999975e7)))return i=f.s<0&&z(e)?-0:0,f.e>-1&&(i=1/i),new E(c?1/i:i);x&&(i=P(x/I+2))}for(a?(r=new E(.5),c&&(e.s=1),u=z(e)):u=(o=Math.abs(+Y(e)))%2,s=new E(p);;){if(u){if(!(s=s.times(f)).c)break;i?s.c.length>i&&(s.c.length=i):n&&(s=s.mod(t))}if(o){if(0===(o=N(o/2)))break;u=o%2}else if(J(e=e.times(r),e.e+1,1),e.e>14)u=z(e);else{if(0==(o=+Y(e)))break;u=o%2}f=f.times(f),i?f.c&&f.c.length>i&&(f.c.length=i):n&&(f=f.mod(t))}return n?s:(c&&(s=p.div(s)),t?s.mod(t):i?J(s,x,d,void 0):s)},h.integerValue=function(e){var t=new E(this);return null==e?e=d:q(e,0,8),J(t,t.e+1,e)},h.isEqualTo=h.eq=function(e,t){return 0===W(this,new E(e,t))},h.isFinite=function(){return!!this.c},h.isGreaterThan=h.gt=function(e,t){return W(this,new E(e,t))>0},h.isGreaterThanOrEqualTo=h.gte=function(e,t){return 1===(t=W(this,new E(e,t)))||0===t},h.isInteger=function(){return!!this.c&&F(this.e/I)>this.c.length-2},h.isLessThan=h.lt=function(e,t){return W(this,new E(e,t))<0},h.isLessThanOrEqualTo=h.lte=function(e,t){return-1===(t=W(this,new E(e,t)))||0===t},h.isNaN=function(){return!this.s},h.isNegative=function(){return this.s<0},h.isPositive=function(){return this.s>0},h.isZero=function(){return!!this.c&&0==this.c[0]},h.minus=function(e,t){var r,n,o,i,a=this,c=a.s;if(t=(e=new E(e,t)).s,!c||!t)return new E(NaN);if(c!=t)return e.s=-t,a.plus(e);var u=a.e/I,s=e.e/I,f=a.c,l=e.c;if(!u||!s){if(!f||!l)return f?(e.s=-t,e):new E(l?a:NaN);if(!f[0]||!l[0])return l[0]?(e.s=-t,e):new E(f[0]?a:3==d?-0:0)}if(u=F(u),s=F(s),f=f.slice(),c=u-s){for((i=c<0)?(c=-c,o=f):(s=u,o=l),o.reverse(),t=c;t--;o.push(0));o.reverse()}else for(n=(i=(c=f.length)<(t=l.length))?c:t,c=t=0;t0)for(;t--;f[r++]=0);for(t=B-1;n>c;){if(f[--n]=0;){for(r=0,h=b[o]%v,p=b[o]/v|0,i=o+(a=u);i>o;)r=((s=h*(s=g[--a]%v)+(c=p*s+(f=g[a]/v|0)*h)%v*v+y[i]+r)/d|0)+(c/v|0)+p*f,y[i--]=s%d;y[i]=r}return r?++n:y.splice(0,1),R(e,y,n)},h.negated=function(){var e=new E(this);return e.s=-e.s||null,e},h.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new E(e,t)).s,!o||!t)return new E(NaN);if(o!=t)return e.s=-t,n.minus(e);var i=n.e/I,a=e.e/I,c=n.c,u=e.c;if(!i||!a){if(!c||!u)return new E(o/0);if(!c[0]||!u[0])return u[0]?e:new E(c[0]?n:0*o)}if(i=F(i),a=F(a),c=c.slice(),o=i-a){for(o>0?(a=i,r=u):(o=-o,r=c),r.reverse();o--;r.push(0));r.reverse()}for((o=c.length)-(t=u.length)<0&&(r=u,u=c,c=r,t=o),o=0;t;)o=(c[--t]=c[t]+u[t]+o)/B|0,c[t]=B===c[t]?0:c[t]%B;return o&&(c=[o].concat(c),++a),R(e,c,a)},h.precision=h.sd=function(e,t){var r,n,o,i=this;if(null!=e&&e!==!!e)return q(e,1,H),null==t?t=d:q(t,0,8),J(new E(i),e,t);if(!(r=i.c))return null;if(n=(o=r.length-1)*I+1,o=r[o]){for(;o%10==0;o/=10,n--);for(o=r[0];o>=10;o/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},h.shiftedBy=function(e){return q(e,-9007199254740991,U),this.times("1e"+e)},h.squareRoot=h.sqrt=function(){var e,t,n,o,i,a=this,c=a.c,u=a.s,s=a.e,f=y+4,l=new E("0.5");if(1!==u||!c||!c[0])return new E(!u||u<0&&(!c||c[0])?NaN:c?a:1/0);if(0==(u=Math.sqrt(+Y(a)))||u==1/0?(((t=G(c)).length+s)%2==0&&(t+="0"),u=Math.sqrt(+t),s=F((s+1)/2)-(s<0||s%2),n=new E(t=u==1/0?"5e"+s:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+s)):n=new E(u+""),n.c[0])for((u=(s=n.e)+f)<3&&(u=0);;)if(i=n,n=l.times(i.plus(r(a,i,f,1))),G(i.c).slice(0,u)===(t=G(n.c)).slice(0,u)){if(n.e0&&y>0){for(i=y%c||c,f=p.substr(0,i);i0&&(f+=s+p.slice(i)),h&&(f="-"+f)}n=l?f+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?l.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):l):f}return(r.prefix||"")+n+(r.suffix||"")},h.toFraction=function(e){var t,n,o,i,a,c,u,s,f,l,h,y,v=this,m=v.c;if(null!=e&&(!(u=new E(e)).isInteger()&&(u.c||1!==u.s)||u.lt(p)))throw Error(j+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+Y(u));if(!m)return new E(v);for(t=new E(p),f=n=new E(p),o=s=new E(p),y=G(m),a=t.e=y.length-v.e-1,t.c[0]=D[(c=a%I)<0?I+c:c],e=!e||u.comparedTo(t)>0?a>0?t:f:u,c=b,b=1/0,u=new E(y),s.c[0]=0;l=r(u,t,0,1),1!=(i=n.plus(l.times(o))).comparedTo(e);)n=o,o=i,f=s.plus(l.times(i=f)),s=i,t=u.minus(l.times(i=t)),u=i;return i=r(e.minus(n),o,0,1),s=s.plus(i.times(f)),n=n.plus(i.times(o)),s.s=f.s=v.s,h=r(f,o,a*=2,d).minus(v).abs().comparedTo(r(s,n,a,d).minus(v).abs())<1?[f,o]:[s,n],b=c,h},h.toNumber=function(){return+Y(this)},h.toPrecision=function(e,t){return null!=e&&q(e,1,H),S(this,e,t,2)},h.toString=function(e){var t,r=this,o=r.s,i=r.e;return null===i?o?(t="Infinity",o<0&&(t="-"+t)):t="NaN":(null==e?t=i<=v||i>=m?V(G(r.c),i):$(G(r.c),i,"0"):10===e?t=$(G((r=J(new E(r),y+i+1,d)).c),r.e,"0"):(q(e,2,O.length,"Base"),t=n($(G(r.c),i,"0"),10,e,o,!0)),o<0&&r.c[0]&&(t="-"+t)),t},h.valueOf=h.toJSON=function(){return Y(this)},h._isBigNumber=!0,null!=t&&E.set(t),E}();const J=R;function Y(e,t){for(var r=0;r64)return S.chunkSubstr(r,64).slice(2).map((function(e){return t.parseString(e)})).join("");var n="";try{n=decodeURIComponent("%"+r.match(/.{1,2}/g).filter((function(e){return"00"!=e})).join("%"))}catch(e){}return n}},{key:"parseHexRLP",value:function(e){var t=e;return"0"==t.indexOf("0x")&&(t=t.substr(2)),t.length>64?S.chunkSubstr(t,64):[t]}},{key:"toSmallestUnitHex",value:function(e){var t=e.amount,r=e.decimals;return new J(t).multipliedBy(new J(10).pow(r)).toString(16)}},{key:"toSmallestUnit",value:function(e){var t=e.amount,r=e.decimals;return new J(t).multipliedBy(new J(10).pow(r)).toFixed()}},{key:"toContractData",value:function(e){var t=this,r=e.func,n=e.params;if(!r)return"0x";var o="string"==typeof r?r:r.toString(),i=Array.isArray(n)?n.map((function(e){return t.leftPad32(S.toHex(e))})):[this.leftPad32(S.toHex(n))];return"0x".concat(A.Z.keccak256(o).substr(0,8)).concat(i.join(""))}},{key:"isEthereumAddress",value:function(e){return/^0x[a-fA-F0-9]{40}$/.test(e)}}],null&&Y(t.prototype,null),r&&Y(t,r),e}();function K(e){return K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},K(e)}function Z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==u[0]?u[0]:{},r=t.contract,n=t.address,o=t.state,i=void 0===o?"latest":o,a=n,X.isEthereumAddress(n)||(a=this.address),"string"!=typeof r){e.next=5;break}return e.abrupt("return",this.getContractBalance({contract:r,address:n}));case 5:return c={method:"eth_getBalance",params:[a,i]},e.abrupt("return",ethereum.request(c).then((function(e){return new J(e).dividedBy(new J(10).pow(18)).toString()})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"getContractBalance",value:(y=te(regeneratorRuntime.mark((function e(){var t,r,n,o,i,a,c=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.contract,n=t.address,o=t.state,i=void 0===o?"latest":o,a=n,X.isEthereumAddress(n)||(a=this.address),e.abrupt("return",Promise.all([this.getData({contract:r,func:"balanceOf(address)",params:[a],state:i}),this.getDecimals({contract:r})]).then((function(e){var t=Z(e,2),r=t[0],n=t[1],o=new J(r).dividedBy(new J(10).pow(n)).toString();return Promise.resolve(o)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"getDecimals",value:(p=te(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract){e.next=4;break}try{n=this.blockchain.nativeCurrency.decimals}catch(e){n=18}return e.abrupt("return",Promise.resolve(n));case 4:return e.abrupt("return",this.getData({contract:r,func:"decimals()"}).then((function(e){var t=parseInt(e);return Promise.resolve(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"getName",value:(h=te(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract){e.next=4;break}try{n=this.blockchain.nativeCurrency.symbol}catch(e){n="ETH"}return e.abrupt("return",Promise.resolve(n));case 4:return e.abrupt("return",this.getData({contract:r,func:"name()"}).then((function(e){var t=X.parseString(e);return Promise.resolve(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"getSymbol",value:(l=te(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract){e.next=4;break}try{n=this.blockchain.nativeCurrency.symbol}catch(e){n="ETH"}return e.abrupt("return",Promise.resolve(n));case 4:return e.abrupt("return",this.getData({contract:r,func:"symbol()"}).then((function(e){var t=X.parseString(e);return Promise.resolve(t)})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getTotalSupply",value:(s=te(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.length>0&&void 0!==n[0]?n[0]:{},r=t.contract){e.next=3;break}return e.abrupt("return",Promise.resolve("0"));case 3:return e.abrupt("return",Promise.all([this.getData({contract:r,func:"totalSupply()"}),this.getDecimals({contract:r})]).then((function(e){var t=Z(e,2),r=t[0],n=t[1],o=new J(r).dividedBy(new J(10).pow(n)).toString();return Promise.resolve(o)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getAsset",value:(u=te(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=t.contract,t.decimals,e.abrupt("return",Promise.all([this.getName({contract:r}),this.getSymbol({contract:r}),this.getDecimals({contract:r}),this.getTotalSupply({contract:r})]).then((function(e){var t=Z(e,4),r=t[0],n=t[1],o=t[2],i=t[3];return Promise.resolve({name:r,symbol:n,decimals:o,totalSupply:i})})));case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getAllowance",value:(a=te(regeneratorRuntime.mark((function e(){var t,r,n,o,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},r=t.contract,n=t.owner,o=t.spender,r){e.next=3;break}return e.abrupt("return",Promise.resolve("0"));case 3:return e.abrupt("return",Promise.all([this.getData({contract:r,func:"allowance(address,address)",params:[n,o]}),this.getDecimals({contract:r})]).then((function(e){var t=Z(e,2),r=t[0],n=t[1],o=new J(r).dividedBy(new J(10).pow(n)).toString();return Promise.resolve(o)})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_connect",value:(i=te(regeneratorRuntime.mark((function e(t){var r,n,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blockchain,n={method:"eth_requestAccounts"},e.abrupt("return",ethereum.request(n).then((function(e){return o._blockchain=r,o._address=e[0],o._isConnected=!0,o.switchBlockchain({blockchain:r})})));case 3:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"switchBlockchain",value:(o=te(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blockchain,e.abrupt("return",this._addBlockchain({blockchain:r}).then((function(){var e={method:"wallet_switchEthereumChain",params:[{chainId:r.chainId}]};return ethereum.request(e)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_addBlockchain",value:(n=te(regeneratorRuntime.mark((function e(t){var r,n,o,i,a,c,u,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.blockchain,n=r.chainId,o=r.chainName,i=r.nativeCurrency,a=r.rpcUrls,c=r.blockExplorerUrls,u=parseInt(n),!([1,3,4,5,42].indexOf(u)>-1)){e.next=6;break}return e.abrupt("return",!0);case 6:return s={method:"wallet_addEthereumChain",params:[{chainId:n,chainName:o,nativeCurrency:i,rpcUrls:a,blockExplorerUrls:c}]},e.abrupt("return",ethereum.request(s));case 8:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],r&&re(t.prototype,r),_}(d);const ue=ce;function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function fe(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";switch(t){case f.TideWallet:e=new O;break;case f.imToken:e=new be;break;default:e=new ue}return e}}],null&&we(t.prototype,null),r&&we(t,r),e}();const xe=ke;function _e(e,t){for(var r=0;r0&&void 0!==c[0]?c[0]:{},r=t.wallet,n=t.blockchain,!this.isConnected){e.next=3;break}return e.abrupt("return",!0);case 3:if(o=this.env.wallets[0],i=r||o,this._connector=this.findConnector({walletType:i}),this._connector){e.next=12;break}return a=xe.create(i),this._connectors.push(a),this._connector=a,e.next=12,this._connector.connect({blockchain:n});case 12:return e.abrupt("return",this.address);case 13:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"switchBlockchain",value:(p=Se(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.blockchain,e.next=3,this._connector.switchBlockchain({blockchain:r});case 3:return e.abrupt("return",this.address);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"disconnect",value:(h=Se(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._connector.disconnect());case 1:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"getAsset",value:(l=Se(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:{},r=t.contract,e.abrupt("return",this._connector.getAsset({contract:r}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"getBalance",value:(f=Se(regeneratorRuntime.mark((function e(){var t,r,n,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:{},r=t.contract,n=t.address,e.abrupt("return",this._connector.getBalance({contract:r,address:n}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getAllowance",value:(s=Se(regeneratorRuntime.mark((function e(t){var r,n,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.contract,n=t.owner,o=t.spender,e.abrupt("return",this._connector.getAllowance({contract:r,owner:n,spender:o}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getData",value:(u=Se(regeneratorRuntime.mark((function e(t){var r,n,o,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.contract,n=t.func,o=t.params,i=t.data,e.abrupt("return",this._connector.getData({contract:r,func:n,params:o,data:i}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"send",value:(a=Se(regeneratorRuntime.mark((function e(t){var r,n,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.to,n=t.amount,o=t.data,e.abrupt("return",this._connector.send({to:r,amount:n,data:o}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"interfaceOf",value:(i=Se(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.contract,n=t.abi,e.abrupt("return",this._connector.interfaceOf({contract:r,abi:n}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})}],o=[{key:"listBlockchain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.testnet;return c.list({testnet:t})}},{key:"findBlockchain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.chainId;return c.findByChainId(t)}}],r&&Ae(t.prototype,r),o&&Ae(t,o),e}();Te(Re,"Blockchains",c),Te(Re,"Wallets",f),Te(Re,"version","v".concat("0.3.5")),window&&(window.Lunar=Re);const Ce=Re}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n](i,i.exports,r),i.loaded=!0,i.exports}r.amdO={},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(751);var n=r(896);return n.default})()})); \ No newline at end of file diff --git a/package.json b/package.json index 575dd28..f86a922 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cafeca/lunar", - "version": "0.3.5", + "version": "0.3.6", "description": "Blockchain Connect Module", "main": "./build/lunar.js", "scripts": { diff --git a/src/connectors/imtoken.js b/src/connectors/imtoken.js index 520569d..f57ff53 100644 --- a/src/connectors/imtoken.js +++ b/src/connectors/imtoken.js @@ -3,6 +3,24 @@ import Metamask from './metamask.js' class ImToken extends Metamask { _type = Wallets.imToken; + + async send({ from = this.address, to, amount, data }) { + const decimals = await this.getDecimals(); + const value = SmartContract.toSmallestUnit({ amount, decimals }); + const transactionParameters = { + from, + to, + value, + data, + chainId: this.chainId + } + const requestData = { + method: 'eth_sendTransaction', + params: [ transactionParameters ], + }; + const txHash = await ethereum.request(requestData); + return txHash; + } } export default ImToken; \ No newline at end of file diff --git a/src/connectors/metamask.js b/src/connectors/metamask.js index 46c2989..cedb134 100644 --- a/src/connectors/metamask.js +++ b/src/connectors/metamask.js @@ -28,7 +28,7 @@ class Metamask extends Connector { async send({ from = this.address, to, amount, data }) { const decimals = await this.getDecimals(); - const value = SmartContract.toSmallestUnit({ amount, decimals }); + const value = SmartContract.toSmallestUnitHex({ amount, decimals }); const transactionParameters = { from, to, @@ -40,7 +40,6 @@ class Metamask extends Connector { method: 'eth_sendTransaction', params: [ transactionParameters ], }; - console.log(requestData) const txHash = await ethereum.request(requestData); return txHash; } diff --git a/src/libs/smartcontract.js b/src/libs/smartcontract.js index 42730cd..9a0b5cf 100644 --- a/src/libs/smartcontract.js +++ b/src/libs/smartcontract.js @@ -67,7 +67,7 @@ class SmartContract { static toSmallestUnit({ amount, decimals }) { const result = new BigNumber(amount) .multipliedBy(new BigNumber(10).pow(decimals)) - .toString(); + .toFixed(); return result; }