@ethereansos/interfaces-core 0.4.93 → 0.4.96

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
@@ -33482,41 +33482,87 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
33482
33482
  }
33483
33483
 
33484
33484
  function _tryUpdateBlock() {
33485
- _tryUpdateBlock = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(force) {
33485
+ _tryUpdateBlock = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(force) {
33486
33486
  var currentBlock, currentBlockNumber;
33487
- return regeneratorRuntime.wrap(function _callee$(_context) {
33487
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
33488
33488
  while (1) {
33489
- switch (_context.prev = _context.next) {
33489
+ switch (_context2.prev = _context2.next) {
33490
33490
  case 0:
33491
- _context.prev = 0;
33492
- _context.next = 3;
33491
+ _context2.prev = 0;
33492
+ _context2.next = 3;
33493
33493
  return sendAsync(wallet.ethereum, 'eth_getBlockByNumber', 'latest', true);
33494
33494
 
33495
33495
  case 3:
33496
- currentBlock = _context.sent;
33496
+ currentBlock = _context2.sent;
33497
33497
  currentBlockNumber = parseInt(currentBlock.number);
33498
33498
 
33499
33499
  if (force === true || currentBlockNumber - block >= realBlockInterval) {
33500
33500
  setBlock(currentBlockNumber);
33501
33501
  }
33502
33502
 
33503
- _context.next = 10;
33503
+ _context2.next = 10;
33504
33504
  break;
33505
33505
 
33506
33506
  case 8:
33507
- _context.prev = 8;
33508
- _context.t0 = _context["catch"](0);
33507
+ _context2.prev = 8;
33508
+ _context2.t0 = _context2["catch"](0);
33509
33509
 
33510
33510
  case 10:
33511
33511
  case "end":
33512
- return _context.stop();
33512
+ return _context2.stop();
33513
33513
  }
33514
33514
  }
33515
- }, _callee, null, [[0, 8]]);
33515
+ }, _callee2, null, [[0, 8]]);
33516
33516
  }));
33517
33517
  return _tryUpdateBlock.apply(this, arguments);
33518
33518
  }
33519
33519
 
33520
+ window.updateAccount = window.updateAccount || /*#__PURE__*/function () {
33521
+ var _updateAccount = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(acc) {
33522
+ return regeneratorRuntime.wrap(function _callee$(_context) {
33523
+ while (1) {
33524
+ switch (_context.prev = _context.next) {
33525
+ case 0:
33526
+ delete window.account;
33527
+ acc && (window.account = acc);
33528
+ _context.prev = 2;
33529
+ _context.t0 = acc && window.ganache;
33530
+
33531
+ if (!_context.t0) {
33532
+ _context.next = 7;
33533
+ break;
33534
+ }
33535
+
33536
+ _context.next = 7;
33537
+ return sendAsync(window.ganache, 'evm_addAccount', acc, 0);
33538
+
33539
+ case 7:
33540
+ _context.next = 11;
33541
+ break;
33542
+
33543
+ case 9:
33544
+ _context.prev = 9;
33545
+ _context.t1 = _context["catch"](2);
33546
+
33547
+ case 11:
33548
+ setBlock(new Date().getTime());
33549
+ setTimeout(resetBlockInterval);
33550
+
33551
+ case 13:
33552
+ case "end":
33553
+ return _context.stop();
33554
+ }
33555
+ }
33556
+ }, _callee, null, [[2, 9]]);
33557
+ }));
33558
+
33559
+ function updateAccount(_x2) {
33560
+ return _updateAccount.apply(this, arguments);
33561
+ }
33562
+
33563
+ return updateAccount;
33564
+ }();
33565
+
33520
33566
  function resetBlockInterval() {
33521
33567
  intervalId && clearInterval(intervalId);
33522
33568
  wallet && wallet.ethereum && tryUpdateBlock(true);
@@ -33599,7 +33645,7 @@ var Web3ContextInitializer = function Web3ContextInitializer(_ref) {
33599
33645
  }),
33600
33646
  ipfsHttpClient: ipfsHttpClient
33601
33647
  }, wallet && connectionStatus === CONNECTED && {
33602
- account: wallet.account,
33648
+ account: window.account || wallet.account,
33603
33649
  chainId: chainId,
33604
33650
  chainName: wallet.networkName,
33605
33651
  web3: web3Instance,
@@ -34925,10 +34971,10 @@ function formatMoney(value, decPlaces, thouSeparator, decSeparator) {
34925
34971
  function fromDecimals(number, decimals, skipFormat) {
34926
34972
  var _number, _decimals;
34927
34973
 
34928
- number = Number(!isNaN((_number = number) === null || _number === void 0 ? void 0 : _number.value) ? number.value : number);
34974
+ number = !isNaN((_number = number) === null || _number === void 0 ? void 0 : _number.value) ? number.value : number;
34929
34975
  decimals = Number(!isNaN((_decimals = decimals) === null || _decimals === void 0 ? void 0 : _decimals.value) ? decimals.value : decimals);
34930
34976
 
34931
- if (!number) {
34977
+ if (!number || number === '0') {
34932
34978
  number = '0';
34933
34979
  }
34934
34980
 
@@ -34936,7 +34982,7 @@ function fromDecimals(number, decimals, skipFormat) {
34936
34982
  return number;
34937
34983
  }
34938
34984
 
34939
- if (!number || !decimals) {
34985
+ if (!number || number === '0' || !decimals) {
34940
34986
  return '0';
34941
34987
  }
34942
34988