bloc-web3-utils
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -890,3 +890,3 @@ 'use strict'; | ||
_getBalanceOf = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tokens, addresses, noChunkItems) { | ||
var resultIndex, tasks, _iterator, _step, token, formatValue, _iterator3, _step3, address, output, _iterator2, _step2, chunkTasks, calls, results, i, task, value; | ||
var tasks, _iterator, _step, token, formatValue, _iterator3, _step3, address, output, _iterator2, _step2, chunkTasks, calls, results, i, task, value; | ||
@@ -902,9 +902,8 @@ return runtime_1.wrap(function _callee2$(_context2) { | ||
_context2.prev = 1; | ||
resultIndex = []; | ||
tasks = []; | ||
_iterator = _createForOfIteratorHelperLoose(tokens); | ||
case 5: | ||
case 4: | ||
if ((_step = _iterator()).done) { | ||
_context2.next = 16; | ||
_context2.next = 15; | ||
break; | ||
@@ -917,3 +916,3 @@ } | ||
if (!(upperCase(token) === 'BNB')) { | ||
_context2.next = 13; | ||
_context2.next = 12; | ||
break; | ||
@@ -931,15 +930,10 @@ } | ||
}); | ||
resultIndex[tasks.length - 1] = { | ||
path: address + "." + token, | ||
token: token, | ||
formatValue: formatValue | ||
}; | ||
} | ||
_context2.next = 14; | ||
_context2.next = 13; | ||
break; | ||
case 13: | ||
case 12: | ||
return _context2.delegateYield( /*#__PURE__*/runtime_1.mark(function _callee() { | ||
var contract, decimals, _iterator4, _step4, _address; | ||
var contract, _yield$ethcallProvide, decimals, _iterator4, _step4, _address; | ||
@@ -952,6 +946,7 @@ return runtime_1.wrap(function _callee$(_context) { | ||
_context.next = 3; | ||
return contract.decimals(); | ||
return ethcallProvider.all([contract.decimals()]); | ||
case 3: | ||
decimals = _context.sent; | ||
_yield$ethcallProvide = _context.sent; | ||
decimals = _yield$ethcallProvide[0]; | ||
@@ -969,10 +964,5 @@ formatValue = function formatValue(value) { | ||
}); | ||
resultIndex[tasks.length - 1] = { | ||
path: _address + "." + token, | ||
token: token, | ||
formatValue: formatValue | ||
}; | ||
} | ||
case 6: | ||
case 7: | ||
case "end": | ||
@@ -983,15 +973,15 @@ return _context.stop(); | ||
}, _callee); | ||
})(), "t0", 14); | ||
})(), "t0", 13); | ||
case 14: | ||
_context2.next = 5; | ||
case 13: | ||
_context2.next = 4; | ||
break; | ||
case 16: | ||
case 15: | ||
output = {}; | ||
_iterator2 = _createForOfIteratorHelperLoose(chunk(tasks, noChunkItems)); | ||
case 18: | ||
case 17: | ||
if ((_step2 = _iterator2()).done) { | ||
_context2.next = 27; | ||
_context2.next = 26; | ||
break; | ||
@@ -1004,6 +994,6 @@ } | ||
}); | ||
_context2.next = 23; | ||
_context2.next = 22; | ||
return ethcallProvider.all(calls); | ||
case 23: | ||
case 22: | ||
results = _context2.sent; | ||
@@ -1017,15 +1007,15 @@ | ||
case 25: | ||
_context2.next = 18; | ||
case 24: | ||
_context2.next = 17; | ||
break; | ||
case 27: | ||
case 26: | ||
return _context2.abrupt("return", output); | ||
case 30: | ||
_context2.prev = 30; | ||
case 29: | ||
_context2.prev = 29; | ||
_context2.t1 = _context2["catch"](1); | ||
throw _context2.t1; | ||
case 33: | ||
case 32: | ||
case "end": | ||
@@ -1035,3 +1025,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, null, [[1, 30]]); | ||
}, _callee2, null, [[1, 29]]); | ||
})); | ||
@@ -1038,0 +1028,0 @@ return _getBalanceOf.apply(this, arguments); |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("lodash/setWith")),r=t(require("lodash/upperCase")),n=t(require("lodash/chunk")),o=require("ethers/lib/utils"),a=require("ethers-multicall"),i=require("ethers");function u(t,e,r,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){u(a,n,o,i,c,"next",t)}function c(t){u(a,n,o,i,c,"throw",t)}i(void 0)}))}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return l(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,h=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),a=new E(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=b(i,r);if(u){if(u===s)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===s)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function f(){}function h(){}function p(){}var d={};u(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var m=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,a){function i(){return new e((function(n,i){!function n(o,a,i,u){var c=l(t[o],t,a);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,u(m,"constructor",p),u(p,"constructor",h),h.displayName=u(p,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,i,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new w(c(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(m),u(m,i,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,s):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),s},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(f={exports:{}}),f.exports),p=new a.Provider(new i.ethers.providers.JsonRpcProvider("https://bsc-dataseed.binance.org"),56);function d(t){return new a.Contract(t,[{constant:!0,inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}])}function v(){return(v=c(h.mark((function t(a,i,u){var c,l,f,v,y,m,g,w,b,x,L,E,k,O,j,_,S;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:void 0===u&&(u=500),t.prev=1,c=[],l=[],f=s(a);case 5:if((v=f()).done){t.next=16;break}if(m=void 0,"BNB"!==r(y=v.value)){t.next=13;break}for(m=o.formatEther,g=s(i);!(w=g()).done;)l.push({call:p.getEthBalance(b=w.value),path:b+"."+y,formatValue:m}),c[l.length-1]={path:b+"."+y,token:y,formatValue:m};t.next=14;break;case 13:return t.delegateYield(h.mark((function t(){var e,r,n,a,u;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=d(y),t.next=3,e.decimals();case 3:for(r=t.sent,m=function(t){return o.formatUnits(t,r)},n=s(i);!(a=n()).done;)l.push({call:e.balanceOf(u=a.value),path:u+"."+y,formatValue:m}),c[l.length-1]={path:u+"."+y,token:y,formatValue:m};case 6:case"end":return t.stop()}}),t)}))(),"t0",14);case 14:t.next=5;break;case 16:x={},L=s(n(l,u));case 18:if((E=L()).done){t.next=27;break}return O=(k=E.value).map((function(t){return t.call})),t.next=23,p.all(O);case 23:for(_ in j=t.sent)x=e(x,(S=k[_]).path,S.formatValue(j[_]));case 25:t.next=18;break;case 27:return t.abrupt("return",x);case 30:throw t.prev=30,t.t1=t.catch(1),t.t1;case 33:case"end":return t.stop()}}),t,null,[[1,30]])})))).apply(this,arguments)}exports.getBalanceOf=function(t,e,r){return v.apply(this,arguments)}; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("lodash/setWith")),r=t(require("lodash/upperCase")),n=t(require("lodash/chunk")),o=require("ethers/lib/utils"),i=require("ethers-multicall"),a=require("ethers");function u(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){u(i,n,o,a,c,"next",t)}function c(t){u(i,n,o,a,c,"throw",t)}a(void 0)}))}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return s(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,h=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new E(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=b(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function f(){}function h(){}function p(){}var d={};u(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(O([])));y&&y!==e&&r.call(y,o)&&(d=y);var m=p.prototype=f.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=p,u(m,"constructor",p),u(p,"constructor",h),h.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,a,"Generator"),u(m,o,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(f={exports:{}}),f.exports),p=new i.Provider(new a.ethers.providers.JsonRpcProvider("https://bsc-dataseed.binance.org"),56);function d(t){return new i.Contract(t,[{constant:!0,inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}])}function v(){return(v=c(h.mark((function t(i,a,u){var c,s,f,v,y,m,g,w,b,x,L,E,O,j,k,_;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:void 0===u&&(u=500),t.prev=1,c=[],s=l(i);case 4:if((f=s()).done){t.next=15;break}if(y=void 0,"BNB"!==r(v=f.value)){t.next=12;break}for(y=o.formatEther,m=l(a);!(g=m()).done;)c.push({call:p.getEthBalance(w=g.value),path:w+"."+v,formatValue:y});t.next=13;break;case 12:return t.delegateYield(h.mark((function t(){var e,r,n,i,u;return h.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=d(v),t.next=3,p.all([e.decimals()]);case 3:for(r=t.sent[0],y=function(t){return o.formatUnits(t,r)},n=l(a);!(i=n()).done;)c.push({call:e.balanceOf(u=i.value),path:u+"."+v,formatValue:y});case 7:case"end":return t.stop()}}),t)}))(),"t0",13);case 13:t.next=4;break;case 15:b={},x=l(n(c,u));case 17:if((L=x()).done){t.next=26;break}return O=(E=L.value).map((function(t){return t.call})),t.next=22,p.all(O);case 22:for(k in j=t.sent)b=e(b,(_=E[k]).path,_.formatValue(j[k]));case 24:t.next=17;break;case 26:return t.abrupt("return",b);case 29:throw t.prev=29,t.t1=t.catch(1),t.t1;case 32:case"end":return t.stop()}}),t,null,[[1,29]])})))).apply(this,arguments)}exports.getBalanceOf=function(t,e,r){return v.apply(this,arguments)}; | ||
//# sourceMappingURL=bloc-web3-utils.cjs.production.min.js.map |
@@ -884,3 +884,3 @@ import setWith from 'lodash-es/setWith'; | ||
_getBalanceOf = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tokens, addresses, noChunkItems) { | ||
var resultIndex, tasks, _iterator, _step, token, formatValue, _iterator3, _step3, address, output, _iterator2, _step2, chunkTasks, calls, results, i, task, value; | ||
var tasks, _iterator, _step, token, formatValue, _iterator3, _step3, address, output, _iterator2, _step2, chunkTasks, calls, results, i, task, value; | ||
@@ -896,9 +896,8 @@ return runtime_1.wrap(function _callee2$(_context2) { | ||
_context2.prev = 1; | ||
resultIndex = []; | ||
tasks = []; | ||
_iterator = _createForOfIteratorHelperLoose(tokens); | ||
case 5: | ||
case 4: | ||
if ((_step = _iterator()).done) { | ||
_context2.next = 16; | ||
_context2.next = 15; | ||
break; | ||
@@ -911,3 +910,3 @@ } | ||
if (!(upperCase(token) === 'BNB')) { | ||
_context2.next = 13; | ||
_context2.next = 12; | ||
break; | ||
@@ -925,15 +924,10 @@ } | ||
}); | ||
resultIndex[tasks.length - 1] = { | ||
path: address + "." + token, | ||
token: token, | ||
formatValue: formatValue | ||
}; | ||
} | ||
_context2.next = 14; | ||
_context2.next = 13; | ||
break; | ||
case 13: | ||
case 12: | ||
return _context2.delegateYield( /*#__PURE__*/runtime_1.mark(function _callee() { | ||
var contract, decimals, _iterator4, _step4, _address; | ||
var contract, _yield$ethcallProvide, decimals, _iterator4, _step4, _address; | ||
@@ -946,6 +940,7 @@ return runtime_1.wrap(function _callee$(_context) { | ||
_context.next = 3; | ||
return contract.decimals(); | ||
return ethcallProvider.all([contract.decimals()]); | ||
case 3: | ||
decimals = _context.sent; | ||
_yield$ethcallProvide = _context.sent; | ||
decimals = _yield$ethcallProvide[0]; | ||
@@ -963,10 +958,5 @@ formatValue = function formatValue(value) { | ||
}); | ||
resultIndex[tasks.length - 1] = { | ||
path: _address + "." + token, | ||
token: token, | ||
formatValue: formatValue | ||
}; | ||
} | ||
case 6: | ||
case 7: | ||
case "end": | ||
@@ -977,15 +967,15 @@ return _context.stop(); | ||
}, _callee); | ||
})(), "t0", 14); | ||
})(), "t0", 13); | ||
case 14: | ||
_context2.next = 5; | ||
case 13: | ||
_context2.next = 4; | ||
break; | ||
case 16: | ||
case 15: | ||
output = {}; | ||
_iterator2 = _createForOfIteratorHelperLoose(chunk(tasks, noChunkItems)); | ||
case 18: | ||
case 17: | ||
if ((_step2 = _iterator2()).done) { | ||
_context2.next = 27; | ||
_context2.next = 26; | ||
break; | ||
@@ -998,6 +988,6 @@ } | ||
}); | ||
_context2.next = 23; | ||
_context2.next = 22; | ||
return ethcallProvider.all(calls); | ||
case 23: | ||
case 22: | ||
results = _context2.sent; | ||
@@ -1011,15 +1001,15 @@ | ||
case 25: | ||
_context2.next = 18; | ||
case 24: | ||
_context2.next = 17; | ||
break; | ||
case 27: | ||
case 26: | ||
return _context2.abrupt("return", output); | ||
case 30: | ||
_context2.prev = 30; | ||
case 29: | ||
_context2.prev = 29; | ||
_context2.t1 = _context2["catch"](1); | ||
throw _context2.t1; | ||
case 33: | ||
case 32: | ||
case "end": | ||
@@ -1029,3 +1019,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, null, [[1, 30]]); | ||
}, _callee2, null, [[1, 29]]); | ||
})); | ||
@@ -1032,0 +1022,0 @@ return _getBalanceOf.apply(this, arguments); |
{ | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
@@ -38,3 +38,2 @@ import setWith from 'lodash/setWith'; | ||
try { | ||
let resultIndex = []; | ||
let tasks = []; | ||
@@ -52,11 +51,6 @@ for (let token of tokens) { | ||
}); | ||
resultIndex[tasks.length - 1] = { | ||
path: `${address}.${token}`, | ||
token, | ||
formatValue, | ||
}; | ||
} | ||
} else { | ||
const contract = getContract(token); | ||
const decimals = await contract.decimals(); | ||
const [decimals] = await ethcallProvider.all([contract.decimals()]); | ||
formatValue = (value: BigNumberish) => formatUnits(value, decimals); | ||
@@ -69,7 +63,2 @@ for (let address of addresses) { | ||
}); | ||
resultIndex[tasks.length - 1] = { | ||
path: `${address}.${token}`, | ||
token, | ||
formatValue, | ||
}; | ||
} | ||
@@ -76,0 +65,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223424
1853