@ethereansos/interfaces-core 0.4.105 → 0.4.108

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
@@ -48779,6 +48779,48 @@ var useEthosContext = function useEthosContext() {
48779
48779
  var Web3Context = /*#__PURE__*/React__default["default"].createContext('web3');
48780
48780
  var DEFAULT_BLOCK_INTERVAL = 15;
48781
48781
  var DEFAULT_BLOCK_INTERVAL_TIMEOUT = 40000;
48782
+ /**
48783
+ * WRAP CHAINS START
48784
+ **/
48785
+
48786
+ var ETH = useWallet.chains.getChainInformation(1).nativeCurrency;
48787
+ var WRAPPED_CHAINS = {
48788
+ 10: {
48789
+ id: 10,
48790
+ nativeCurrency: ETH,
48791
+ type: 'main',
48792
+ fullName: 'Optimism Mainnet',
48793
+ shortName: 'Optimism',
48794
+ explorerUrl: 'https://optimistic.etherscan.io',
48795
+ testnet: false
48796
+ }
48797
+ };
48798
+
48799
+ function wrap(methodName, funct, force) {
48800
+ var oldFunction = useWallet.chains[methodName];
48801
+
48802
+ useWallet.chains[methodName] = function (chainId) {
48803
+ var args = [].concat(Array.prototype.slice.call(arguments), [oldFunction]);
48804
+ return (WRAPPED_CHAINS[parseInt(chainId)] || force ? funct : oldFunction).apply(useWallet.chains, args);
48805
+ };
48806
+ }
48807
+
48808
+ wrap('isKnownChain', function () {
48809
+ return true;
48810
+ });
48811
+ wrap('getChainInformation', function (chainId) {
48812
+ return WRAPPED_CHAINS[parseInt(chainId)];
48813
+ });
48814
+ wrap('getKnownChainsIds', function (oldFunction) {
48815
+ return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.keys(WRAPPED_CHAINS)));
48816
+ });
48817
+ wrap('getKnownChainInformation', function (oldFunction) {
48818
+ return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.values(WRAPPED_CHAINS)));
48819
+ });
48820
+ /**
48821
+ * WRAP CHAINS END
48822
+ **/
48823
+
48782
48824
  var web3States = {
48783
48825
  NOT_CONNECTED: NOT_CONNECTED,
48784
48826
  CONNECTED: CONNECTED,
@@ -50111,7 +50153,21 @@ function toDecimals(number, decimals) {
50111
50153
  var symbol = toEthereumSymbol(decimals);
50112
50154
 
50113
50155
  if (symbol) {
50114
- return web3Utils__default["default"].toWei(numberToString(number), symbol);
50156
+ number = numberToString(number);
50157
+
50158
+ while (true) {
50159
+ try {
50160
+ return web3Utils__default["default"].toWei(number, symbol);
50161
+ } catch (e) {
50162
+ var message = (e.message || e).toLowerCase();
50163
+
50164
+ if (message.indexOf('too many') !== -1) {
50165
+ number = number.substring(0, number.length - 1);
50166
+ } else {
50167
+ throw e;
50168
+ }
50169
+ }
50170
+ }
50115
50171
  }
50116
50172
 
50117
50173
  return numberToString(number * (decimals < 2 ? 1 : Math.pow(10, decimals)));