@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.esm.js CHANGED
@@ -23074,6 +23074,10 @@ function _createSuper(Derived) {
23074
23074
  };
23075
23075
  }
23076
23076
 
23077
+ function _readOnlyError(name) {
23078
+ throw new TypeError("\"" + name + "\" is read-only");
23079
+ }
23080
+
23077
23081
  function _slicedToArray(arr, i) {
23078
23082
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
23079
23083
  }
@@ -64098,6 +64102,335 @@ function _getTokenPriceInDollarsOnUniswapV() {
64098
64102
  return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
64099
64103
  }
64100
64104
 
64105
+ var tokenPrices = {};
64106
+ var tokenPricesPromises = {};
64107
+
64108
+ function elaboratePrices(_x, _x2, _x3) {
64109
+ return _elaboratePrices.apply(this, arguments);
64110
+ }
64111
+
64112
+ function _elaboratePrices() {
64113
+ _elaboratePrices = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref, res, tokens) {
64114
+ var context, web3Data, response, _iterator, _step, token;
64115
+
64116
+ return regeneratorRuntime.wrap(function _callee$(_context) {
64117
+ while (1) {
64118
+ switch (_context.prev = _context.next) {
64119
+ case 0:
64120
+ context = _ref.context, web3Data = _ref.web3Data;
64121
+ response = {
64122
+ data: {}
64123
+ };
64124
+ Object.entries(res.data).forEach(function (entry) {
64125
+ return response.data[entry[0]] = entry[1];
64126
+ });
64127
+ tokens = (!(tokens instanceof Array) ? tokens = tokens.split(',') : tokens).map(function (it) {
64128
+ return it.toLowerCase();
64129
+ }).filter(function (it) {
64130
+ return it && it !== VOID_ETHEREUM_ADDRESS && !response.data[it];
64131
+ });
64132
+ _iterator = _createForOfIteratorHelper(tokens);
64133
+ _context.prev = 5;
64134
+
64135
+ _iterator.s();
64136
+
64137
+ case 7:
64138
+ if ((_step = _iterator.n()).done) {
64139
+ _context.next = 36;
64140
+ break;
64141
+ }
64142
+
64143
+ token = _step.value;
64144
+ _context.prev = 9;
64145
+ _context.t0 = getTokenPriceInDollarsOnUniswapV3;
64146
+ _context.t1 = _objectSpread2({
64147
+ context: context
64148
+ }, web3Data);
64149
+ _context.t2 = token;
64150
+ _context.next = 15;
64151
+ return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64152
+
64153
+ case 15:
64154
+ _context.t3 = _context.sent;
64155
+ _context.next = 18;
64156
+ return (0, _context.t0)(_context.t1, _context.t2, _context.t3);
64157
+
64158
+ case 18:
64159
+ _context.t4 = _context.sent;
64160
+ response.data[token] = {
64161
+ usd: _context.t4
64162
+ };
64163
+ _context.next = 34;
64164
+ break;
64165
+
64166
+ case 22:
64167
+ _context.prev = 22;
64168
+ _context.t5 = _context["catch"](9);
64169
+ _context.t6 = getTokenPriceInDollarsOnUniswap;
64170
+ _context.t7 = _objectSpread2({
64171
+ context: context
64172
+ }, web3Data);
64173
+ _context.t8 = token;
64174
+ _context.next = 29;
64175
+ return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64176
+
64177
+ case 29:
64178
+ _context.t9 = _context.sent;
64179
+ _context.next = 32;
64180
+ return (0, _context.t6)(_context.t7, _context.t8, _context.t9);
64181
+
64182
+ case 32:
64183
+ _context.t10 = _context.sent;
64184
+ response.data[token] = {
64185
+ usd: _context.t10
64186
+ };
64187
+
64188
+ case 34:
64189
+ _context.next = 7;
64190
+ break;
64191
+
64192
+ case 36:
64193
+ _context.next = 41;
64194
+ break;
64195
+
64196
+ case 38:
64197
+ _context.prev = 38;
64198
+ _context.t11 = _context["catch"](5);
64199
+
64200
+ _iterator.e(_context.t11);
64201
+
64202
+ case 41:
64203
+ _context.prev = 41;
64204
+
64205
+ _iterator.f();
64206
+
64207
+ return _context.finish(41);
64208
+
64209
+ case 44:
64210
+ return _context.abrupt("return", response);
64211
+
64212
+ case 45:
64213
+ case "end":
64214
+ return _context.stop();
64215
+ }
64216
+ }
64217
+ }, _callee, null, [[5, 38, 41, 44], [9, 22]]);
64218
+ }));
64219
+ return _elaboratePrices.apply(this, arguments);
64220
+ }
64221
+
64222
+ function getTokenPricesInDollarsOnCoingecko(_x4, _x5) {
64223
+ return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
64224
+ }
64225
+
64226
+ function _getTokenPricesInDollarsOnCoingecko() {
64227
+ _getTokenPricesInDollarsOnCoingecko = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2, t) {
64228
+ var context, web3Data, tokens, response, tkns, _iterator2, _step2, token, prom, _i, _tkns, _i2, _tkns2, _iterator3, _step3;
64229
+
64230
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
64231
+ while (1) {
64232
+ switch (_context3.prev = _context3.next) {
64233
+ case 0:
64234
+ context = _ref2.context, web3Data = _ref2.web3Data;
64235
+ tokens = (!(t instanceof Array) ? t = t.split(',') : t).map(function (it) {
64236
+ return it.toLowerCase();
64237
+ });
64238
+ response = {
64239
+ data: {}
64240
+ };
64241
+ _readOnlyError("tokenPrices");
64242
+ _readOnlyError("tokenPricesPromises");
64243
+ tkns = [];
64244
+ _iterator2 = _createForOfIteratorHelper(tokens);
64245
+ _context3.prev = 7;
64246
+
64247
+ _iterator2.s();
64248
+
64249
+ case 9:
64250
+ if ((_step2 = _iterator2.n()).done) {
64251
+ _context3.next = 31;
64252
+ break;
64253
+ }
64254
+
64255
+ token = _step2.value;
64256
+
64257
+ if (!(!token || token === VOID_ETHEREUM_ADDRESS)) {
64258
+ _context3.next = 16;
64259
+ break;
64260
+ }
64261
+
64262
+ _context3.next = 14;
64263
+ return getEthereumPrice({
64264
+ context: context
64265
+ });
64266
+
64267
+ case 14:
64268
+ response.data[token] = _context3.sent;
64269
+ return _context3.abrupt("continue", 29);
64270
+
64271
+ case 16:
64272
+ if (!(tokenPrices[token] && tokenPrices[token].requestExpires > new Date().getTime() && tokenPrices[token].price !== 0)) {
64273
+ _context3.next = 20;
64274
+ break;
64275
+ }
64276
+
64277
+ response.data[token] = {
64278
+ usd: tokenPrices[token].price
64279
+ };
64280
+ _context3.next = 29;
64281
+ break;
64282
+
64283
+ case 20:
64284
+ if (!tokenPricesPromises[token]) {
64285
+ _context3.next = 28;
64286
+ break;
64287
+ }
64288
+
64289
+ _context3.next = 23;
64290
+ return tokenPricesPromises[token];
64291
+
64292
+ case 23:
64293
+ _context3.t0 = token;
64294
+ _context3.t1 = _context3.sent.data[_context3.t0].usd;
64295
+ response.data[token] = {
64296
+ usd: _context3.t1
64297
+ };
64298
+ _context3.next = 29;
64299
+ break;
64300
+
64301
+ case 28:
64302
+ tkns.push(token);
64303
+
64304
+ case 29:
64305
+ _context3.next = 9;
64306
+ break;
64307
+
64308
+ case 31:
64309
+ _context3.next = 36;
64310
+ break;
64311
+
64312
+ case 33:
64313
+ _context3.prev = 33;
64314
+ _context3.t2 = _context3["catch"](7);
64315
+
64316
+ _iterator2.e(_context3.t2);
64317
+
64318
+ case 36:
64319
+ _context3.prev = 36;
64320
+
64321
+ _iterator2.f();
64322
+
64323
+ return _context3.finish(36);
64324
+
64325
+ case 39:
64326
+ prom = /*#__PURE__*/function () {
64327
+ var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(t1, t2) {
64328
+ var res;
64329
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
64330
+ while (1) {
64331
+ switch (_context2.prev = _context2.next) {
64332
+ case 0:
64333
+ res = {
64334
+ data: {}
64335
+ };
64336
+ _context2.prev = 1;
64337
+ _context2.t0 = t1.length > 0;
64338
+
64339
+ if (!_context2.t0) {
64340
+ _context2.next = 9;
64341
+ break;
64342
+ }
64343
+
64344
+ _context2.next = 6;
64345
+ return fetch(context.coingeckoCoinPriceURL + t1.join(','));
64346
+
64347
+ case 6:
64348
+ _context2.next = 8;
64349
+ return _context2.sent.json();
64350
+
64351
+ case 8:
64352
+ res.data = _context2.sent;
64353
+
64354
+ case 9:
64355
+ _context2.next = 13;
64356
+ break;
64357
+
64358
+ case 11:
64359
+ _context2.prev = 11;
64360
+ _context2.t1 = _context2["catch"](1);
64361
+
64362
+ case 13:
64363
+ _context2.next = 15;
64364
+ return elaboratePrices({
64365
+ context: context,
64366
+ web3Data: web3Data
64367
+ }, res, t2);
64368
+
64369
+ case 15:
64370
+ return _context2.abrupt("return", _context2.sent);
64371
+
64372
+ case 16:
64373
+ case "end":
64374
+ return _context2.stop();
64375
+ }
64376
+ }
64377
+ }, _callee2, null, [[1, 11]]);
64378
+ }));
64379
+
64380
+ return function prom(_x6, _x7) {
64381
+ return _ref3.apply(this, arguments);
64382
+ };
64383
+ }();
64384
+
64385
+ prom = prom(tkns, t);
64386
+
64387
+ for (_i = 0, _tkns = tkns; _i < _tkns.length; _i++) {
64388
+ token = _tkns[_i];
64389
+ tokenPricesPromises[token] = prom;
64390
+ }
64391
+
64392
+ _context3.next = 44;
64393
+ return prom;
64394
+
64395
+ case 44:
64396
+ prom = _context3.sent;
64397
+ Object.entries(prom.data).forEach(function (it) {
64398
+ return response.data[it[0]] = it[1];
64399
+ });
64400
+
64401
+ for (_i2 = 0, _tkns2 = tkns; _i2 < _tkns2.length; _i2++) {
64402
+ token = _tkns2[_i2];
64403
+ tokenPrices[token] = {
64404
+ requestExpires: new Date().getTime() + context.coingeckoEthereumPriceRequestInterval,
64405
+ price: response.data[token].usd
64406
+ };
64407
+ }
64408
+
64409
+ _iterator3 = _createForOfIteratorHelper(tokens);
64410
+
64411
+ try {
64412
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
64413
+ token = _step3.value;
64414
+ delete tokenPricesPromises[token];
64415
+ }
64416
+ } catch (err) {
64417
+ _iterator3.e(err);
64418
+ } finally {
64419
+ _iterator3.f();
64420
+ }
64421
+
64422
+ return _context3.abrupt("return", response);
64423
+
64424
+ case 50:
64425
+ case "end":
64426
+ return _context3.stop();
64427
+ }
64428
+ }
64429
+ }, _callee3, null, [[7, 33, 36, 39]]);
64430
+ }));
64431
+ return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
64432
+ }
64433
+
64101
64434
  function op(a, operator, b) {
64102
64435
  var operations = {
64103
64436
  '+': 'add',
@@ -64548,5 +64881,5 @@ var tokenPercentage = function tokenPercentage(amount, totalSupply) {
64548
64881
 
64549
64882
  var abi = new AbiCoder();
64550
64883
 
64551
- export { ADDRESS_ZERO, BASE64_REGEXP, BLOCK_SEARCH_SIZE, gBase64 as Base64, BaseContract, BigNumber, Contract, ContractFactory, CurrencyAmount, DFO_DEPLOYED_EVENT, Ether, FACTORY_ADDRESS, FeeAmount, FixedNumber, Fraction, FullMath, GlobalContextsProvider, InitContextProvider, LiquidityMath, MaxUint256, Multicall, NEW_DFO_DEPLOYED_EVENT, NativeCurrency, NoTickDataProvider, NonfungiblePositionManager, POOL_INIT_CODE_HASH, Payments, Percent, PluginsContextProvider, Pool, Position, PositionLibrary, Price, Rounding, Route, SelfPermit, Signer, SqrtPriceMath, Staker, SwapMath, SwapQuoter, SwapRouter, TICK_SPACINGS, Tick, TickLibrary, TickList, TickListDataProvider, TickMath, Token, Trade, TradeType, URL_REGEXP, VOID_BYTES32, VOID_ETHEREUM_ADDRESS, VoidSigner, WETH9, Wallet, Web3ContextProvider, Wordlist, abi, add, blockchainCall, checkCoverSize, computePoolAddress, computePriceImpact, index$2 as constants, createContract, deployMetadataLink, div, eliminateFloatingFinalZeroes, encodeRouteToPath, encodeSqrtRatioX96, ErrorCode as errors, ethers, PubSub as ethosEvents, extractComment, extractHTMLDescription, formatLink, formatMoney, formatMoneyUniV3, formatNumber, formatString, fromDecimals, generateAndCompileContract, generateFunctionalityMetadataLink, getAllContracts, getDefaultProvider, getEthereumPrice, getLogs, getNetworkElement, getRandomArrayElement, getRandomArrayIndex, SolidityUtilities as getSolidityUtilities, getSupportedSolidityVersion, getTokenPriceInDollarsOnUniswap, getTokenPriceInDollarsOnUniswapV3, hasEthereumAddress, isEthereumAddress, isSorted, loadBlockSearchTranches, loadContent, loadFunctionality, loadFunctionalityNames, loadMetadatas, loadOffChainWallets as loadOffchainWallets, logger, maxLiquidityForAmounts, methodSignatureMatch, mint, mostSignificantBit, mul, nearestUsableTick, newContract, normalizeValue, numberToString, packCollection, pragmaSolidityRule, priceToClosestTick, index as providers, refreshBalances, resetContracts, searchForCodeErrors, sendAsync, sendGeneratedProposal, shortenWord, sleep, solidityImportRule, sortedInsert, split, sqrt, toLines as stringToLines, sub, subIn256, swap, tickToPrice, toDecimals, toEthereumSymbol, toHex, toSubArrays, tokenPercentage, tradeComparator, transfer, truncatedWord, tryRetrieveMetadata, uploadMetadata, uploadToIPFS, useEthosContext, useInit, useIsUnmounted, useLoadUniswapPairs, useLocalStorage, usePlaceholder, usePlugins, usePrevious, useSinglePlaceholder, useWeb3, utils, validateAndParseAddress, validateDFOMetadata, version$1 as version, web3States, wordlists };
64884
+ export { ADDRESS_ZERO, BASE64_REGEXP, BLOCK_SEARCH_SIZE, gBase64 as Base64, BaseContract, BigNumber, Contract, ContractFactory, CurrencyAmount, DFO_DEPLOYED_EVENT, Ether, FACTORY_ADDRESS, FeeAmount, FixedNumber, Fraction, FullMath, GlobalContextsProvider, InitContextProvider, LiquidityMath, MaxUint256, Multicall, NEW_DFO_DEPLOYED_EVENT, NativeCurrency, NoTickDataProvider, NonfungiblePositionManager, POOL_INIT_CODE_HASH, Payments, Percent, PluginsContextProvider, Pool, Position, PositionLibrary, Price, Rounding, Route, SelfPermit, Signer, SqrtPriceMath, Staker, SwapMath, SwapQuoter, SwapRouter, TICK_SPACINGS, Tick, TickLibrary, TickList, TickListDataProvider, TickMath, Token, Trade, TradeType, URL_REGEXP, VOID_BYTES32, VOID_ETHEREUM_ADDRESS, VoidSigner, WETH9, Wallet, Web3ContextProvider, Wordlist, abi, add, blockchainCall, checkCoverSize, computePoolAddress, computePriceImpact, index$2 as constants, createContract, deployMetadataLink, div, eliminateFloatingFinalZeroes, encodeRouteToPath, encodeSqrtRatioX96, ErrorCode as errors, ethers, PubSub as ethosEvents, extractComment, extractHTMLDescription, formatLink, formatMoney, formatMoneyUniV3, formatNumber, formatString, fromDecimals, generateAndCompileContract, generateFunctionalityMetadataLink, getAllContracts, getDefaultProvider, getEthereumPrice, getLogs, getNetworkElement, getRandomArrayElement, getRandomArrayIndex, SolidityUtilities as getSolidityUtilities, getSupportedSolidityVersion, getTokenPriceInDollarsOnUniswap, getTokenPriceInDollarsOnUniswapV3, getTokenPricesInDollarsOnCoingecko, hasEthereumAddress, isEthereumAddress, isSorted, loadBlockSearchTranches, loadContent, loadFunctionality, loadFunctionalityNames, loadMetadatas, loadOffChainWallets as loadOffchainWallets, logger, maxLiquidityForAmounts, methodSignatureMatch, mint, mostSignificantBit, mul, nearestUsableTick, newContract, normalizeValue, numberToString, packCollection, pragmaSolidityRule, priceToClosestTick, index as providers, refreshBalances, resetContracts, searchForCodeErrors, sendAsync, sendGeneratedProposal, shortenWord, sleep, solidityImportRule, sortedInsert, split, sqrt, toLines as stringToLines, sub, subIn256, swap, tickToPrice, toDecimals, toEthereumSymbol, toHex, toSubArrays, tokenPercentage, tradeComparator, transfer, truncatedWord, tryRetrieveMetadata, uploadMetadata, uploadToIPFS, useEthosContext, useInit, useIsUnmounted, useLoadUniswapPairs, useLocalStorage, usePlaceholder, usePlugins, usePrevious, useSinglePlaceholder, useWeb3, utils, validateAndParseAddress, validateDFOMetadata, version$1 as version, web3States, wordlists };
64552
64885
  //# sourceMappingURL=index.esm.js.map