@ethereansos/interfaces-core 0.4.99 → 0.4.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +334 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +334 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -23086,6 +23086,10 @@ function _createSuper(Derived) {
|
|
23086
23086
|
};
|
23087
23087
|
}
|
23088
23088
|
|
23089
|
+
function _readOnlyError(name) {
|
23090
|
+
throw new TypeError("\"" + name + "\" is read-only");
|
23091
|
+
}
|
23092
|
+
|
23089
23093
|
function _slicedToArray(arr, i) {
|
23090
23094
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
|
23091
23095
|
}
|
@@ -64110,6 +64114,335 @@ function _getTokenPriceInDollarsOnUniswapV() {
|
|
64110
64114
|
return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
|
64111
64115
|
}
|
64112
64116
|
|
64117
|
+
var tokenPrices = {};
|
64118
|
+
var tokenPricesPromises = {};
|
64119
|
+
|
64120
|
+
function elaboratePrices(_x, _x2, _x3) {
|
64121
|
+
return _elaboratePrices.apply(this, arguments);
|
64122
|
+
}
|
64123
|
+
|
64124
|
+
function _elaboratePrices() {
|
64125
|
+
_elaboratePrices = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref, res, tokens) {
|
64126
|
+
var context, web3Data, response, _iterator, _step, token;
|
64127
|
+
|
64128
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
64129
|
+
while (1) {
|
64130
|
+
switch (_context.prev = _context.next) {
|
64131
|
+
case 0:
|
64132
|
+
context = _ref.context, web3Data = _ref.web3Data;
|
64133
|
+
response = {
|
64134
|
+
data: {}
|
64135
|
+
};
|
64136
|
+
Object.entries(res.data).forEach(function (entry) {
|
64137
|
+
return response.data[entry[0]] = entry[1];
|
64138
|
+
});
|
64139
|
+
tokens = (!(tokens instanceof Array) ? tokens = tokens.split(',') : tokens).map(function (it) {
|
64140
|
+
return it.toLowerCase();
|
64141
|
+
}).filter(function (it) {
|
64142
|
+
return it && it !== VOID_ETHEREUM_ADDRESS && !response.data[it];
|
64143
|
+
});
|
64144
|
+
_iterator = _createForOfIteratorHelper(tokens);
|
64145
|
+
_context.prev = 5;
|
64146
|
+
|
64147
|
+
_iterator.s();
|
64148
|
+
|
64149
|
+
case 7:
|
64150
|
+
if ((_step = _iterator.n()).done) {
|
64151
|
+
_context.next = 36;
|
64152
|
+
break;
|
64153
|
+
}
|
64154
|
+
|
64155
|
+
token = _step.value;
|
64156
|
+
_context.prev = 9;
|
64157
|
+
_context.t0 = getTokenPriceInDollarsOnUniswapV3;
|
64158
|
+
_context.t1 = _objectSpread2({
|
64159
|
+
context: context
|
64160
|
+
}, web3Data);
|
64161
|
+
_context.t2 = token;
|
64162
|
+
_context.next = 15;
|
64163
|
+
return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
|
64164
|
+
|
64165
|
+
case 15:
|
64166
|
+
_context.t3 = _context.sent;
|
64167
|
+
_context.next = 18;
|
64168
|
+
return (0, _context.t0)(_context.t1, _context.t2, _context.t3);
|
64169
|
+
|
64170
|
+
case 18:
|
64171
|
+
_context.t4 = _context.sent;
|
64172
|
+
response.data[token] = {
|
64173
|
+
usd: _context.t4
|
64174
|
+
};
|
64175
|
+
_context.next = 34;
|
64176
|
+
break;
|
64177
|
+
|
64178
|
+
case 22:
|
64179
|
+
_context.prev = 22;
|
64180
|
+
_context.t5 = _context["catch"](9);
|
64181
|
+
_context.t6 = getTokenPriceInDollarsOnUniswap;
|
64182
|
+
_context.t7 = _objectSpread2({
|
64183
|
+
context: context
|
64184
|
+
}, web3Data);
|
64185
|
+
_context.t8 = token;
|
64186
|
+
_context.next = 29;
|
64187
|
+
return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
|
64188
|
+
|
64189
|
+
case 29:
|
64190
|
+
_context.t9 = _context.sent;
|
64191
|
+
_context.next = 32;
|
64192
|
+
return (0, _context.t6)(_context.t7, _context.t8, _context.t9);
|
64193
|
+
|
64194
|
+
case 32:
|
64195
|
+
_context.t10 = _context.sent;
|
64196
|
+
response.data[token] = {
|
64197
|
+
usd: _context.t10
|
64198
|
+
};
|
64199
|
+
|
64200
|
+
case 34:
|
64201
|
+
_context.next = 7;
|
64202
|
+
break;
|
64203
|
+
|
64204
|
+
case 36:
|
64205
|
+
_context.next = 41;
|
64206
|
+
break;
|
64207
|
+
|
64208
|
+
case 38:
|
64209
|
+
_context.prev = 38;
|
64210
|
+
_context.t11 = _context["catch"](5);
|
64211
|
+
|
64212
|
+
_iterator.e(_context.t11);
|
64213
|
+
|
64214
|
+
case 41:
|
64215
|
+
_context.prev = 41;
|
64216
|
+
|
64217
|
+
_iterator.f();
|
64218
|
+
|
64219
|
+
return _context.finish(41);
|
64220
|
+
|
64221
|
+
case 44:
|
64222
|
+
return _context.abrupt("return", response);
|
64223
|
+
|
64224
|
+
case 45:
|
64225
|
+
case "end":
|
64226
|
+
return _context.stop();
|
64227
|
+
}
|
64228
|
+
}
|
64229
|
+
}, _callee, null, [[5, 38, 41, 44], [9, 22]]);
|
64230
|
+
}));
|
64231
|
+
return _elaboratePrices.apply(this, arguments);
|
64232
|
+
}
|
64233
|
+
|
64234
|
+
function getTokenPricesInDollarsOnCoingecko(_x4, _x5) {
|
64235
|
+
return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
|
64236
|
+
}
|
64237
|
+
|
64238
|
+
function _getTokenPricesInDollarsOnCoingecko() {
|
64239
|
+
_getTokenPricesInDollarsOnCoingecko = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2, t) {
|
64240
|
+
var context, web3Data, tokens, response, tkns, _iterator2, _step2, token, prom, _i, _tkns, _i2, _tkns2, _iterator3, _step3;
|
64241
|
+
|
64242
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
64243
|
+
while (1) {
|
64244
|
+
switch (_context3.prev = _context3.next) {
|
64245
|
+
case 0:
|
64246
|
+
context = _ref2.context, web3Data = _ref2.web3Data;
|
64247
|
+
tokens = (!(t instanceof Array) ? t = t.split(',') : t).map(function (it) {
|
64248
|
+
return it.toLowerCase();
|
64249
|
+
});
|
64250
|
+
response = {
|
64251
|
+
data: {}
|
64252
|
+
};
|
64253
|
+
_readOnlyError("tokenPrices");
|
64254
|
+
_readOnlyError("tokenPricesPromises");
|
64255
|
+
tkns = [];
|
64256
|
+
_iterator2 = _createForOfIteratorHelper(tokens);
|
64257
|
+
_context3.prev = 7;
|
64258
|
+
|
64259
|
+
_iterator2.s();
|
64260
|
+
|
64261
|
+
case 9:
|
64262
|
+
if ((_step2 = _iterator2.n()).done) {
|
64263
|
+
_context3.next = 31;
|
64264
|
+
break;
|
64265
|
+
}
|
64266
|
+
|
64267
|
+
token = _step2.value;
|
64268
|
+
|
64269
|
+
if (!(!token || token === VOID_ETHEREUM_ADDRESS)) {
|
64270
|
+
_context3.next = 16;
|
64271
|
+
break;
|
64272
|
+
}
|
64273
|
+
|
64274
|
+
_context3.next = 14;
|
64275
|
+
return getEthereumPrice({
|
64276
|
+
context: context
|
64277
|
+
});
|
64278
|
+
|
64279
|
+
case 14:
|
64280
|
+
response.data[token] = _context3.sent;
|
64281
|
+
return _context3.abrupt("continue", 29);
|
64282
|
+
|
64283
|
+
case 16:
|
64284
|
+
if (!(tokenPrices[token] && tokenPrices[token].requestExpires > new Date().getTime() && tokenPrices[token].price !== 0)) {
|
64285
|
+
_context3.next = 20;
|
64286
|
+
break;
|
64287
|
+
}
|
64288
|
+
|
64289
|
+
response.data[token] = {
|
64290
|
+
usd: tokenPrices[token].price
|
64291
|
+
};
|
64292
|
+
_context3.next = 29;
|
64293
|
+
break;
|
64294
|
+
|
64295
|
+
case 20:
|
64296
|
+
if (!tokenPricesPromises[token]) {
|
64297
|
+
_context3.next = 28;
|
64298
|
+
break;
|
64299
|
+
}
|
64300
|
+
|
64301
|
+
_context3.next = 23;
|
64302
|
+
return tokenPricesPromises[token];
|
64303
|
+
|
64304
|
+
case 23:
|
64305
|
+
_context3.t0 = token;
|
64306
|
+
_context3.t1 = _context3.sent.data[_context3.t0].usd;
|
64307
|
+
response.data[token] = {
|
64308
|
+
usd: _context3.t1
|
64309
|
+
};
|
64310
|
+
_context3.next = 29;
|
64311
|
+
break;
|
64312
|
+
|
64313
|
+
case 28:
|
64314
|
+
tkns.push(token);
|
64315
|
+
|
64316
|
+
case 29:
|
64317
|
+
_context3.next = 9;
|
64318
|
+
break;
|
64319
|
+
|
64320
|
+
case 31:
|
64321
|
+
_context3.next = 36;
|
64322
|
+
break;
|
64323
|
+
|
64324
|
+
case 33:
|
64325
|
+
_context3.prev = 33;
|
64326
|
+
_context3.t2 = _context3["catch"](7);
|
64327
|
+
|
64328
|
+
_iterator2.e(_context3.t2);
|
64329
|
+
|
64330
|
+
case 36:
|
64331
|
+
_context3.prev = 36;
|
64332
|
+
|
64333
|
+
_iterator2.f();
|
64334
|
+
|
64335
|
+
return _context3.finish(36);
|
64336
|
+
|
64337
|
+
case 39:
|
64338
|
+
prom = /*#__PURE__*/function () {
|
64339
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(t1, t2) {
|
64340
|
+
var res;
|
64341
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
64342
|
+
while (1) {
|
64343
|
+
switch (_context2.prev = _context2.next) {
|
64344
|
+
case 0:
|
64345
|
+
res = {
|
64346
|
+
data: {}
|
64347
|
+
};
|
64348
|
+
_context2.prev = 1;
|
64349
|
+
_context2.t0 = t1.length > 0;
|
64350
|
+
|
64351
|
+
if (!_context2.t0) {
|
64352
|
+
_context2.next = 9;
|
64353
|
+
break;
|
64354
|
+
}
|
64355
|
+
|
64356
|
+
_context2.next = 6;
|
64357
|
+
return fetch(context.coingeckoCoinPriceURL + t1.join(','));
|
64358
|
+
|
64359
|
+
case 6:
|
64360
|
+
_context2.next = 8;
|
64361
|
+
return _context2.sent.json();
|
64362
|
+
|
64363
|
+
case 8:
|
64364
|
+
res.data = _context2.sent;
|
64365
|
+
|
64366
|
+
case 9:
|
64367
|
+
_context2.next = 13;
|
64368
|
+
break;
|
64369
|
+
|
64370
|
+
case 11:
|
64371
|
+
_context2.prev = 11;
|
64372
|
+
_context2.t1 = _context2["catch"](1);
|
64373
|
+
|
64374
|
+
case 13:
|
64375
|
+
_context2.next = 15;
|
64376
|
+
return elaboratePrices({
|
64377
|
+
context: context,
|
64378
|
+
web3Data: web3Data
|
64379
|
+
}, res, t2);
|
64380
|
+
|
64381
|
+
case 15:
|
64382
|
+
return _context2.abrupt("return", _context2.sent);
|
64383
|
+
|
64384
|
+
case 16:
|
64385
|
+
case "end":
|
64386
|
+
return _context2.stop();
|
64387
|
+
}
|
64388
|
+
}
|
64389
|
+
}, _callee2, null, [[1, 11]]);
|
64390
|
+
}));
|
64391
|
+
|
64392
|
+
return function prom(_x6, _x7) {
|
64393
|
+
return _ref3.apply(this, arguments);
|
64394
|
+
};
|
64395
|
+
}();
|
64396
|
+
|
64397
|
+
prom = prom(tkns, t);
|
64398
|
+
|
64399
|
+
for (_i = 0, _tkns = tkns; _i < _tkns.length; _i++) {
|
64400
|
+
token = _tkns[_i];
|
64401
|
+
tokenPricesPromises[token] = prom;
|
64402
|
+
}
|
64403
|
+
|
64404
|
+
_context3.next = 44;
|
64405
|
+
return prom;
|
64406
|
+
|
64407
|
+
case 44:
|
64408
|
+
prom = _context3.sent;
|
64409
|
+
Object.entries(prom.data).forEach(function (it) {
|
64410
|
+
return response.data[it[0]] = it[1];
|
64411
|
+
});
|
64412
|
+
|
64413
|
+
for (_i2 = 0, _tkns2 = tkns; _i2 < _tkns2.length; _i2++) {
|
64414
|
+
token = _tkns2[_i2];
|
64415
|
+
tokenPrices[token] = {
|
64416
|
+
requestExpires: new Date().getTime() + context.coingeckoEthereumPriceRequestInterval,
|
64417
|
+
price: response.data[token].usd
|
64418
|
+
};
|
64419
|
+
}
|
64420
|
+
|
64421
|
+
_iterator3 = _createForOfIteratorHelper(tokens);
|
64422
|
+
|
64423
|
+
try {
|
64424
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
64425
|
+
token = _step3.value;
|
64426
|
+
delete tokenPricesPromises[token];
|
64427
|
+
}
|
64428
|
+
} catch (err) {
|
64429
|
+
_iterator3.e(err);
|
64430
|
+
} finally {
|
64431
|
+
_iterator3.f();
|
64432
|
+
}
|
64433
|
+
|
64434
|
+
return _context3.abrupt("return", response);
|
64435
|
+
|
64436
|
+
case 50:
|
64437
|
+
case "end":
|
64438
|
+
return _context3.stop();
|
64439
|
+
}
|
64440
|
+
}
|
64441
|
+
}, _callee3, null, [[7, 33, 36, 39]]);
|
64442
|
+
}));
|
64443
|
+
return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
|
64444
|
+
}
|
64445
|
+
|
64113
64446
|
function op(a, operator, b) {
|
64114
64447
|
var operations = {
|
64115
64448
|
'+': 'add',
|
@@ -64656,6 +64989,7 @@ exports.getSolidityUtilities = SolidityUtilities;
|
|
64656
64989
|
exports.getSupportedSolidityVersion = getSupportedSolidityVersion;
|
64657
64990
|
exports.getTokenPriceInDollarsOnUniswap = getTokenPriceInDollarsOnUniswap;
|
64658
64991
|
exports.getTokenPriceInDollarsOnUniswapV3 = getTokenPriceInDollarsOnUniswapV3;
|
64992
|
+
exports.getTokenPricesInDollarsOnCoingecko = getTokenPricesInDollarsOnCoingecko;
|
64659
64993
|
exports.hasEthereumAddress = hasEthereumAddress;
|
64660
64994
|
exports.isEthereumAddress = isEthereumAddress;
|
64661
64995
|
exports.isSorted = isSorted;
|