@ethereansos/interfaces-core 0.4.106 → 0.4.109

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
@@ -48767,6 +48767,51 @@ var useEthosContext = function useEthosContext() {
48767
48767
  var Web3Context = /*#__PURE__*/React.createContext('web3');
48768
48768
  var DEFAULT_BLOCK_INTERVAL = 15;
48769
48769
  var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
48770
+
48771
+ var chains = require('use-wallet').chains;
48772
+ /**
48773
+ * WRAP CHAINS START
48774
+ **/
48775
+
48776
+
48777
+ var ETH = chains.getChainInformation(1).nativeCurrency;
48778
+ var WRAPPED_CHAINS = {
48779
+ 10: {
48780
+ id: 10,
48781
+ nativeCurrency: ETH,
48782
+ type: 'main',
48783
+ fullName: 'Optimism Mainnet',
48784
+ shortName: 'Optimism',
48785
+ explorerUrl: 'https://optimistic.etherscan.io',
48786
+ testnet: false
48787
+ }
48788
+ };
48789
+
48790
+ function wrap(methodName, funct, force) {
48791
+ var oldFunction = chains[methodName];
48792
+
48793
+ chains[methodName] = function (chainId) {
48794
+ var args = [].concat(Array.prototype.slice.call(arguments), [oldFunction]);
48795
+ return (WRAPPED_CHAINS[parseInt(chainId)] || force ? funct : oldFunction).apply(chains, args);
48796
+ };
48797
+ }
48798
+
48799
+ wrap('isKnownChain', function () {
48800
+ return true;
48801
+ });
48802
+ wrap('getChainInformation', function (chainId) {
48803
+ return WRAPPED_CHAINS[parseInt(chainId)];
48804
+ });
48805
+ wrap('getKnownChainsIds', function (oldFunction) {
48806
+ return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.keys(WRAPPED_CHAINS)));
48807
+ });
48808
+ wrap('getKnownChainInformation', function (oldFunction) {
48809
+ return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.values(WRAPPED_CHAINS)));
48810
+ });
48811
+ /**
48812
+ * WRAP CHAINS END
48813
+ **/
48814
+
48770
48815
  var web3States = {
48771
48816
  NOT_CONNECTED: NOT_CONNECTED,
48772
48817
  CONNECTED: CONNECTED,
@@ -50099,7 +50144,21 @@ function toDecimals(number, decimals) {
50099
50144
  var symbol = toEthereumSymbol(decimals);
50100
50145
 
50101
50146
  if (symbol) {
50102
- return web3Utils.toWei(numberToString(number), symbol);
50147
+ number = numberToString(number);
50148
+
50149
+ while (true) {
50150
+ try {
50151
+ return web3Utils.toWei(number, symbol);
50152
+ } catch (e) {
50153
+ var message = (e.message || e).toLowerCase();
50154
+
50155
+ if (message.indexOf('too many') !== -1) {
50156
+ number = number.substring(0, number.length - 1);
50157
+ } else {
50158
+ throw e;
50159
+ }
50160
+ }
50161
+ }
50103
50162
  }
50104
50163
 
50105
50164
  return numberToString(number * (decimals < 2 ? 1 : Math.pow(10, decimals)));