@ethereansos/interfaces-core 0.4.116 → 0.4.119
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.js +146 -70
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +146 -70
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -48764,6 +48764,7 @@ var useEthosContext = function useEthosContext() {
|
|
48764
48764
|
return context;
|
48765
48765
|
};
|
48766
48766
|
|
48767
|
+
var abi$8 = new AbiCoder();
|
48767
48768
|
var Web3Context = /*#__PURE__*/React.createContext('web3');
|
48768
48769
|
var DEFAULT_BLOCK_INTERVAL = 15;
|
48769
48770
|
var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
|
@@ -48907,15 +48908,65 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48907
48908
|
return _ref2.apply(this, arguments);
|
48908
48909
|
};
|
48909
48910
|
}(), [realBlockInterval]);
|
48911
|
+
var tryUpdateBlockDual = useCallback( /*#__PURE__*/function () {
|
48912
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(provider, oldValue, setter, force) {
|
48913
|
+
var currentBlockNumber;
|
48914
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
48915
|
+
while (1) {
|
48916
|
+
switch (_context2.prev = _context2.next) {
|
48917
|
+
case 0:
|
48918
|
+
if (provider) {
|
48919
|
+
_context2.next = 2;
|
48920
|
+
break;
|
48921
|
+
}
|
48922
|
+
|
48923
|
+
return _context2.abrupt("return", setter(0));
|
48924
|
+
|
48925
|
+
case 2:
|
48926
|
+
_context2.prev = 2;
|
48927
|
+
_context2.next = 5;
|
48928
|
+
return sendAsync(provider, 'eth_call', {
|
48929
|
+
to: '0x4200000000000000000000000000000000000013',
|
48930
|
+
data: web3Utils.sha3('getL1BlockNumber()').substring(0, 10)
|
48931
|
+
});
|
48932
|
+
|
48933
|
+
case 5:
|
48934
|
+
currentBlockNumber = _context2.sent;
|
48935
|
+
currentBlockNumber = abi$8.decode(['uint256'], currentBlockNumber)[0].toString();
|
48936
|
+
currentBlockNumber = parseInt(currentBlockNumber);
|
48937
|
+
|
48938
|
+
if (force === true || currentBlockNumber - oldValue >= realBlockInterval) {
|
48939
|
+
setter(currentBlockNumber);
|
48940
|
+
}
|
48941
|
+
|
48942
|
+
_context2.next = 13;
|
48943
|
+
break;
|
48944
|
+
|
48945
|
+
case 11:
|
48946
|
+
_context2.prev = 11;
|
48947
|
+
_context2.t0 = _context2["catch"](2);
|
48948
|
+
|
48949
|
+
case 13:
|
48950
|
+
case "end":
|
48951
|
+
return _context2.stop();
|
48952
|
+
}
|
48953
|
+
}
|
48954
|
+
}, _callee2, null, [[2, 11]]);
|
48955
|
+
}));
|
48956
|
+
|
48957
|
+
return function (_x5, _x6, _x7, _x8) {
|
48958
|
+
return _ref3.apply(this, arguments);
|
48959
|
+
};
|
48960
|
+
}(), [realBlockInterval]);
|
48910
48961
|
var resetBlockInterval = useCallback(function () {
|
48911
48962
|
intervalId && clearInterval(intervalId);
|
48912
48963
|
tryUpdateBlock(wallet === null || wallet === void 0 ? void 0 : wallet.ethereum, block, setBlock, true);
|
48913
|
-
|
48964
|
+
tryUpdateBlockDual(dualProvider && (wallet === null || wallet === void 0 ? void 0 : wallet.ethereum), dualBlock, setDualBlock, true);
|
48914
48965
|
|
48915
48966
|
if (wallet && wallet.ethereum || dualProvider) {
|
48916
48967
|
setIntervalId(setInterval(function () {
|
48917
48968
|
wallet && wallet.ethereum && tryUpdateBlock(wallet.ethereum, block, setBlock);
|
48918
|
-
dualProvider &&
|
48969
|
+
dualProvider && wallet && wallet.ethereum && tryUpdateBlockDual(wallet.ethereum, dualBlock, setDualBlock);
|
48919
48970
|
}, realBlockIntervalTimeout));
|
48920
48971
|
}
|
48921
48972
|
}, [wallet, dualProvider, realBlockIntervalTimeout, intervalId]);
|
@@ -48988,31 +49039,31 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
48988
49039
|
};
|
48989
49040
|
|
48990
49041
|
window.setAccount = /*#__PURE__*/function () {
|
48991
|
-
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
48992
|
-
return regeneratorRuntime.wrap(function
|
49042
|
+
var _setAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(acc) {
|
49043
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
48993
49044
|
while (1) {
|
48994
|
-
switch (
|
49045
|
+
switch (_context3.prev = _context3.next) {
|
48995
49046
|
case 0:
|
48996
49047
|
delete window.account;
|
48997
49048
|
acc && (window.account = acc);
|
48998
|
-
|
48999
|
-
|
49049
|
+
_context3.prev = 2;
|
49050
|
+
_context3.t0 = acc && window.ganache;
|
49000
49051
|
|
49001
|
-
if (!
|
49002
|
-
|
49052
|
+
if (!_context3.t0) {
|
49053
|
+
_context3.next = 7;
|
49003
49054
|
break;
|
49004
49055
|
}
|
49005
49056
|
|
49006
|
-
|
49057
|
+
_context3.next = 7;
|
49007
49058
|
return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
|
49008
49059
|
|
49009
49060
|
case 7:
|
49010
|
-
|
49061
|
+
_context3.next = 11;
|
49011
49062
|
break;
|
49012
49063
|
|
49013
49064
|
case 9:
|
49014
|
-
|
49015
|
-
|
49065
|
+
_context3.prev = 9;
|
49066
|
+
_context3.t1 = _context3["catch"](2);
|
49016
49067
|
|
49017
49068
|
case 11:
|
49018
49069
|
setBlock(new Date().getTime());
|
@@ -49021,13 +49072,13 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
|
|
49021
49072
|
|
49022
49073
|
case 14:
|
49023
49074
|
case "end":
|
49024
|
-
return
|
49075
|
+
return _context3.stop();
|
49025
49076
|
}
|
49026
49077
|
}
|
49027
|
-
},
|
49078
|
+
}, _callee3, null, [[2, 9]]);
|
49028
49079
|
}));
|
49029
49080
|
|
49030
|
-
function setAccount(
|
49081
|
+
function setAccount(_x9) {
|
49031
49082
|
return _setAccount.apply(this, arguments);
|
49032
49083
|
}
|
49033
49084
|
|
@@ -64416,12 +64467,12 @@ function getTokenPricesInDollarsOnCoingecko(_x4, _x5) {
|
|
64416
64467
|
}
|
64417
64468
|
|
64418
64469
|
function _getTokenPricesInDollarsOnCoingecko() {
|
64419
|
-
_getTokenPricesInDollarsOnCoingecko = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
64470
|
+
_getTokenPricesInDollarsOnCoingecko = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref2, t) {
|
64420
64471
|
var context, web3Data, tokens, response, tkns, _iterator2, _step2, token, prom, _i, _tkns, _i2, _tkns2, _iterator3, _step3;
|
64421
64472
|
|
64422
|
-
return regeneratorRuntime.wrap(function
|
64473
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
64423
64474
|
while (1) {
|
64424
|
-
switch (
|
64475
|
+
switch (_context4.prev = _context4.next) {
|
64425
64476
|
case 0:
|
64426
64477
|
context = _ref2.context, web3Data = _ref2.web3Data;
|
64427
64478
|
tokens = (!(t instanceof Array) ? t = t.split(',') : t).map(function (it) {
|
@@ -64432,139 +64483,164 @@ function _getTokenPricesInDollarsOnCoingecko() {
|
|
64432
64483
|
};
|
64433
64484
|
tkns = [];
|
64434
64485
|
_iterator2 = _createForOfIteratorHelper(tokens);
|
64435
|
-
|
64486
|
+
_context4.prev = 5;
|
64436
64487
|
|
64437
64488
|
_iterator2.s();
|
64438
64489
|
|
64439
64490
|
case 7:
|
64440
64491
|
if ((_step2 = _iterator2.n()).done) {
|
64441
|
-
|
64492
|
+
_context4.next = 29;
|
64442
64493
|
break;
|
64443
64494
|
}
|
64444
64495
|
|
64445
64496
|
token = _step2.value;
|
64446
64497
|
|
64447
64498
|
if (!(!token || token === VOID_ETHEREUM_ADDRESS)) {
|
64448
|
-
|
64499
|
+
_context4.next = 14;
|
64449
64500
|
break;
|
64450
64501
|
}
|
64451
64502
|
|
64452
|
-
|
64503
|
+
_context4.next = 12;
|
64453
64504
|
return getEthereumPrice({
|
64454
64505
|
context: context
|
64455
64506
|
});
|
64456
64507
|
|
64457
64508
|
case 12:
|
64458
|
-
response.data[token] =
|
64459
|
-
return
|
64509
|
+
response.data[token] = _context4.sent;
|
64510
|
+
return _context4.abrupt("continue", 27);
|
64460
64511
|
|
64461
64512
|
case 14:
|
64462
64513
|
if (!(tokenPrices[token] && tokenPrices[token].requestExpires > new Date().getTime() && tokenPrices[token].price !== 0)) {
|
64463
|
-
|
64514
|
+
_context4.next = 18;
|
64464
64515
|
break;
|
64465
64516
|
}
|
64466
64517
|
|
64467
64518
|
response.data[token] = {
|
64468
64519
|
usd: tokenPrices[token].price
|
64469
64520
|
};
|
64470
|
-
|
64521
|
+
_context4.next = 27;
|
64471
64522
|
break;
|
64472
64523
|
|
64473
64524
|
case 18:
|
64474
64525
|
if (!tokenPricesPromises[token]) {
|
64475
|
-
|
64526
|
+
_context4.next = 26;
|
64476
64527
|
break;
|
64477
64528
|
}
|
64478
64529
|
|
64479
|
-
|
64530
|
+
_context4.next = 21;
|
64480
64531
|
return tokenPricesPromises[token];
|
64481
64532
|
|
64482
64533
|
case 21:
|
64483
|
-
|
64484
|
-
|
64534
|
+
_context4.t0 = token;
|
64535
|
+
_context4.t1 = _context4.sent.data[_context4.t0].usd;
|
64485
64536
|
response.data[token] = {
|
64486
|
-
usd:
|
64537
|
+
usd: _context4.t1
|
64487
64538
|
};
|
64488
|
-
|
64539
|
+
_context4.next = 27;
|
64489
64540
|
break;
|
64490
64541
|
|
64491
64542
|
case 26:
|
64492
64543
|
tkns.push(token);
|
64493
64544
|
|
64494
64545
|
case 27:
|
64495
|
-
|
64546
|
+
_context4.next = 7;
|
64496
64547
|
break;
|
64497
64548
|
|
64498
64549
|
case 29:
|
64499
|
-
|
64550
|
+
_context4.next = 34;
|
64500
64551
|
break;
|
64501
64552
|
|
64502
64553
|
case 31:
|
64503
|
-
|
64504
|
-
|
64554
|
+
_context4.prev = 31;
|
64555
|
+
_context4.t2 = _context4["catch"](5);
|
64505
64556
|
|
64506
|
-
_iterator2.e(
|
64557
|
+
_iterator2.e(_context4.t2);
|
64507
64558
|
|
64508
64559
|
case 34:
|
64509
|
-
|
64560
|
+
_context4.prev = 34;
|
64510
64561
|
|
64511
64562
|
_iterator2.f();
|
64512
64563
|
|
64513
|
-
return
|
64564
|
+
return _context4.finish(34);
|
64514
64565
|
|
64515
64566
|
case 37:
|
64516
64567
|
prom = /*#__PURE__*/function () {
|
64517
|
-
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
64568
|
+
var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(t1, t2) {
|
64518
64569
|
var res;
|
64519
|
-
return regeneratorRuntime.wrap(function
|
64570
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
64520
64571
|
while (1) {
|
64521
|
-
switch (
|
64572
|
+
switch (_context3.prev = _context3.next) {
|
64522
64573
|
case 0:
|
64523
64574
|
res = {
|
64524
64575
|
data: {}
|
64525
64576
|
};
|
64526
|
-
|
64527
|
-
|
64577
|
+
_context3.prev = 1;
|
64578
|
+
_context3.t0 = t1.length > 0;
|
64528
64579
|
|
64529
|
-
if (!
|
64530
|
-
|
64580
|
+
if (!_context3.t0) {
|
64581
|
+
_context3.next = 7;
|
64531
64582
|
break;
|
64532
64583
|
}
|
64533
64584
|
|
64534
|
-
|
64535
|
-
return
|
64585
|
+
_context3.next = 6;
|
64586
|
+
return Promise.all(context.coingeckoCoinPriceURLTemplates.map( /*#__PURE__*/function () {
|
64587
|
+
var _ref4 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(it) {
|
64588
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
64589
|
+
while (1) {
|
64590
|
+
switch (_context2.prev = _context2.next) {
|
64591
|
+
case 0:
|
64592
|
+
_context2.next = 2;
|
64593
|
+
return fetch(it + t1.join(','));
|
64594
|
+
|
64595
|
+
case 2:
|
64596
|
+
_context2.next = 4;
|
64597
|
+
return _context2.sent.json();
|
64598
|
+
|
64599
|
+
case 4:
|
64600
|
+
return _context2.abrupt("return", _context2.sent);
|
64601
|
+
|
64602
|
+
case 5:
|
64603
|
+
case "end":
|
64604
|
+
return _context2.stop();
|
64605
|
+
}
|
64606
|
+
}
|
64607
|
+
}, _callee2);
|
64608
|
+
}));
|
64609
|
+
|
64610
|
+
return function (_x8) {
|
64611
|
+
return _ref4.apply(this, arguments);
|
64612
|
+
};
|
64613
|
+
}()));
|
64536
64614
|
|
64537
64615
|
case 6:
|
64538
|
-
|
64539
|
-
|
64616
|
+
res.data = _context3.sent.reduce(function (acc, it) {
|
64617
|
+
return _objectSpread2(_objectSpread2({}, acc), it);
|
64618
|
+
}, {});
|
64540
64619
|
|
64541
|
-
case
|
64542
|
-
|
64620
|
+
case 7:
|
64621
|
+
_context3.next = 11;
|
64622
|
+
break;
|
64543
64623
|
|
64544
64624
|
case 9:
|
64545
|
-
|
64546
|
-
|
64625
|
+
_context3.prev = 9;
|
64626
|
+
_context3.t1 = _context3["catch"](1);
|
64547
64627
|
|
64548
64628
|
case 11:
|
64549
|
-
|
64550
|
-
_context2.t1 = _context2["catch"](1);
|
64551
|
-
|
64552
|
-
case 13:
|
64553
|
-
_context2.next = 15;
|
64629
|
+
_context3.next = 13;
|
64554
64630
|
return elaboratePrices({
|
64555
64631
|
context: context,
|
64556
64632
|
web3Data: web3Data
|
64557
64633
|
}, res, t2);
|
64558
64634
|
|
64559
|
-
case
|
64560
|
-
return
|
64635
|
+
case 13:
|
64636
|
+
return _context3.abrupt("return", _context3.sent);
|
64561
64637
|
|
64562
|
-
case
|
64638
|
+
case 14:
|
64563
64639
|
case "end":
|
64564
|
-
return
|
64640
|
+
return _context3.stop();
|
64565
64641
|
}
|
64566
64642
|
}
|
64567
|
-
},
|
64643
|
+
}, _callee3, null, [[1, 9]]);
|
64568
64644
|
}));
|
64569
64645
|
|
64570
64646
|
return function prom(_x6, _x7) {
|
@@ -64579,11 +64655,11 @@ function _getTokenPricesInDollarsOnCoingecko() {
|
|
64579
64655
|
tokenPricesPromises[token] = prom;
|
64580
64656
|
}
|
64581
64657
|
|
64582
|
-
|
64658
|
+
_context4.next = 42;
|
64583
64659
|
return prom;
|
64584
64660
|
|
64585
64661
|
case 42:
|
64586
|
-
prom =
|
64662
|
+
prom = _context4.sent;
|
64587
64663
|
Object.entries(prom.data).forEach(function (it) {
|
64588
64664
|
return response.data[it[0]] = it[1];
|
64589
64665
|
});
|
@@ -64609,14 +64685,14 @@ function _getTokenPricesInDollarsOnCoingecko() {
|
|
64609
64685
|
_iterator3.f();
|
64610
64686
|
}
|
64611
64687
|
|
64612
|
-
return
|
64688
|
+
return _context4.abrupt("return", response);
|
64613
64689
|
|
64614
64690
|
case 48:
|
64615
64691
|
case "end":
|
64616
|
-
return
|
64692
|
+
return _context4.stop();
|
64617
64693
|
}
|
64618
64694
|
}
|
64619
|
-
},
|
64695
|
+
}, _callee4, null, [[5, 31, 34, 37]]);
|
64620
64696
|
}));
|
64621
64697
|
return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
|
64622
64698
|
}
|