@ethereansos/interfaces-core 0.4.144 → 0.4.147

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 CHANGED
@@ -64049,54 +64049,262 @@ const gBase64 = {
64049
64049
  extendBuiltins: extendBuiltins,
64050
64050
  };
64051
64051
 
64052
+ (typeof window === "undefined" ? "undefined" : _typeof(window)).toLowerCase() === 'undefined' && (global.window = global);
64053
+ var dbEngine = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
64054
+ window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction || {
64055
+ READ_WRITE: 'readwrite'
64056
+ };
64057
+ window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
64058
+ var dbName = 'ethereansos';
64059
+ var dbTable = 'ethereansos';
64060
+ var dbVersion = 1;
64061
+ var internalDB;
64062
+
64063
+ function openDB(name, version) {
64064
+ return new Promise(function (ok, ko) {
64065
+ if (internalDB) {
64066
+ return ok(internalDB);
64067
+ }
64068
+
64069
+ var request = dbEngine.open(name, version);
64070
+
64071
+ request.onerror = function (event) {
64072
+ return ko(event.target.errorCode);
64073
+ };
64074
+
64075
+ request.onsuccess = function (event) {
64076
+ return ok(internalDB = event.target.result);
64077
+ };
64078
+
64079
+ request.onupgradeneeded = function (event) {
64080
+ var store = event.target.result.createObjectStore(dbTable, {
64081
+ autoIncrement: true
64082
+ });
64083
+ store.createIndex('key', 'key', {
64084
+ unique: true
64085
+ });
64086
+ };
64087
+ });
64088
+ }
64089
+
64090
+ function setItem(key, value) {
64091
+ return new Promise( /*#__PURE__*/function () {
64092
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(ok, ko) {
64093
+ var db, txn, store, query;
64094
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
64095
+ while (1) {
64096
+ switch (_context2.prev = _context2.next) {
64097
+ case 0:
64098
+ _context2.next = 2;
64099
+ return openDB(dbName, dbVersion);
64100
+
64101
+ case 2:
64102
+ db = _context2.sent;
64103
+ txn = db.transaction(dbTable, 'readwrite');
64104
+ store = txn.objectStore(dbTable);
64105
+ query = store.put({
64106
+ key: key,
64107
+ value: value && _typeof(value).toLowerCase() === 'string' ? value : JSON.stringify(value || null)
64108
+ });
64109
+
64110
+ query.onsuccess = function (event) {
64111
+ return ok(event.target.result);
64112
+ };
64113
+
64114
+ query.onerror = function (event) {
64115
+ return ko(event.target.errorCode);
64116
+ };
64117
+
64118
+ txn.oncomplete = /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
64119
+ return regeneratorRuntime.wrap(function _callee$(_context) {
64120
+ while (1) {
64121
+ switch (_context.prev = _context.next) {
64122
+ case 0:
64123
+ case "end":
64124
+ return _context.stop();
64125
+ }
64126
+ }
64127
+ }, _callee);
64128
+ }));
64129
+
64130
+ case 9:
64131
+ case "end":
64132
+ return _context2.stop();
64133
+ }
64134
+ }
64135
+ }, _callee2);
64136
+ }));
64137
+
64138
+ return function (_x, _x2) {
64139
+ return _ref.apply(this, arguments);
64140
+ };
64141
+ }());
64142
+ }
64143
+
64144
+ function getItem(key) {
64145
+ return new Promise( /*#__PURE__*/function () {
64146
+ var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(ok, ko) {
64147
+ var db, txn, store, index, query;
64148
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
64149
+ while (1) {
64150
+ switch (_context4.prev = _context4.next) {
64151
+ case 0:
64152
+ _context4.next = 2;
64153
+ return openDB(dbName, dbVersion);
64154
+
64155
+ case 2:
64156
+ db = _context4.sent;
64157
+ txn = db.transaction(dbTable, 'readonly');
64158
+ store = txn.objectStore(dbTable);
64159
+ index = store.index('key');
64160
+ query = index.get(key);
64161
+
64162
+ query.onsuccess = function (event) {
64163
+ var _event$target, _event$target$result;
64164
+
64165
+ return ok(((_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$result = _event$target.result) === null || _event$target$result === void 0 ? void 0 : _event$target$result.value) || 'null');
64166
+ };
64167
+
64168
+ query.onerror = function (event) {
64169
+ return ko(event.target.errorCode);
64170
+ };
64171
+
64172
+ txn.oncomplete = /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
64173
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
64174
+ while (1) {
64175
+ switch (_context3.prev = _context3.next) {
64176
+ case 0:
64177
+ case "end":
64178
+ return _context3.stop();
64179
+ }
64180
+ }
64181
+ }, _callee3);
64182
+ }));
64183
+
64184
+ case 10:
64185
+ case "end":
64186
+ return _context4.stop();
64187
+ }
64188
+ }
64189
+ }, _callee4);
64190
+ }));
64191
+
64192
+ return function (_x3, _x4) {
64193
+ return _ref3.apply(this, arguments);
64194
+ };
64195
+ }());
64196
+ }
64197
+
64198
+ function clear(_x5) {
64199
+ return _clear.apply(this, arguments);
64200
+ }
64201
+
64202
+ function _clear() {
64203
+ _clear = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(key) {
64204
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
64205
+ while (1) {
64206
+ switch (_context5.prev = _context5.next) {
64207
+ case 0:
64208
+ case "end":
64209
+ return _context5.stop();
64210
+ }
64211
+ }
64212
+ }, _callee5);
64213
+ }));
64214
+ return _clear.apply(this, arguments);
64215
+ }
64216
+
64217
+ var cache = window.ethereansOSCache = {
64218
+ getItem: getItem,
64219
+ setItem: setItem,
64220
+ clear: clear
64221
+ };
64222
+
64052
64223
  function memoryFetch(_x, _x2) {
64053
64224
  return _memoryFetch.apply(this, arguments);
64054
64225
  }
64055
64226
 
64056
64227
  function _memoryFetch() {
64057
64228
  _memoryFetch = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, type) {
64058
- var key, element;
64229
+ var element, key;
64059
64230
  return regeneratorRuntime.wrap(function _callee$(_context) {
64060
64231
  while (1) {
64061
64232
  switch (_context.prev = _context.next) {
64062
64233
  case 0:
64234
+ if (!(url.indexOf('data') === 0)) {
64235
+ _context.next = 8;
64236
+ break;
64237
+ }
64238
+
64239
+ _context.next = 3;
64240
+ return fetch(url);
64241
+
64242
+ case 3:
64243
+ element = _context.sent;
64244
+ _context.next = 6;
64245
+ return element[type || 'json']();
64246
+
64247
+ case 6:
64248
+ element = _context.sent;
64249
+ return _context.abrupt("return", element);
64250
+
64251
+ case 8:
64063
64252
  key = web3Utils__default["default"].sha3(url);
64253
+ _context.prev = 9;
64254
+ _context.t0 = JSON;
64255
+ _context.next = 13;
64256
+ return cache.getItem(key);
64064
64257
 
64065
- try {
64066
- element = JSON.parse(window.localStorage.getItem(key));
64067
- } catch (e) {}
64258
+ case 13:
64259
+ _context.t1 = _context.sent;
64260
+ element = _context.t0.parse.call(_context.t0, _context.t1);
64261
+ _context.next = 19;
64262
+ break;
64263
+
64264
+ case 17:
64265
+ _context.prev = 17;
64266
+ _context.t2 = _context["catch"](9);
64068
64267
 
64268
+ case 19:
64069
64269
  if (!element) {
64070
- _context.next = 4;
64270
+ _context.next = 21;
64071
64271
  break;
64072
64272
  }
64073
64273
 
64074
64274
  return _context.abrupt("return", element);
64075
64275
 
64076
- case 4:
64077
- _context.next = 6;
64276
+ case 21:
64277
+ _context.next = 23;
64078
64278
  return fetch(url);
64079
64279
 
64080
- case 6:
64280
+ case 23:
64081
64281
  element = _context.sent;
64082
- _context.next = 9;
64282
+ _context.next = 26;
64083
64283
  return element[type || 'json']();
64084
64284
 
64085
- case 9:
64285
+ case 26:
64086
64286
  element = _context.sent;
64287
+ _context.prev = 27;
64288
+ _context.next = 30;
64289
+ return cache.setItem(key, JSON.stringify(element));
64087
64290
 
64088
- try {
64089
- window.localStorage.setItem(key, JSON.stringify(element));
64090
- } catch (e) {}
64291
+ case 30:
64292
+ _context.next = 34;
64293
+ break;
64294
+
64295
+ case 32:
64296
+ _context.prev = 32;
64297
+ _context.t3 = _context["catch"](27);
64091
64298
 
64299
+ case 34:
64092
64300
  return _context.abrupt("return", element);
64093
64301
 
64094
- case 12:
64302
+ case 35:
64095
64303
  case "end":
64096
64304
  return _context.stop();
64097
64305
  }
64098
64306
  }
64099
- }, _callee);
64307
+ }, _callee, null, [[9, 17], [27, 32]]);
64100
64308
  }));
64101
64309
  return _memoryFetch.apply(this, arguments);
64102
64310
  }
@@ -65416,6 +65624,7 @@ exports.Wordlist = Wordlist;
65416
65624
  exports.abi = abi;
65417
65625
  exports.add = add;
65418
65626
  exports.blockchainCall = blockchainCall;
65627
+ exports.cache = cache;
65419
65628
  exports.checkCoverSize = checkCoverSize;
65420
65629
  exports.computePoolAddress = computePoolAddress;
65421
65630
  exports.computePriceImpact = computePriceImpact;