@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.esm.js CHANGED
@@ -4,7 +4,7 @@ import web3Utils, { toChecksumAddress } from 'web3-utils';
4
4
  export { default as web3Utils } from 'web3-utils';
5
5
  import Web3 from 'web3';
6
6
  import { create } from 'ipfs-http-client';
7
- import { UseWalletProvider, useWallet } from 'use-wallet';
7
+ import { chains, UseWalletProvider, useWallet } from 'use-wallet';
8
8
  import require$$0 from 'buffer';
9
9
  import require$$0$1 from 'util';
10
10
 
@@ -48767,6 +48767,48 @@ 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
+ * WRAP CHAINS START
48772
+ **/
48773
+
48774
+ var ETH = chains.getChainInformation(1).nativeCurrency;
48775
+ var WRAPPED_CHAINS = {
48776
+ 10: {
48777
+ id: 10,
48778
+ nativeCurrency: ETH,
48779
+ type: 'main',
48780
+ fullName: 'Optimism Mainnet',
48781
+ shortName: 'Optimism',
48782
+ explorerUrl: 'https://optimistic.etherscan.io',
48783
+ testnet: false
48784
+ }
48785
+ };
48786
+
48787
+ function wrap(methodName, funct, force) {
48788
+ var oldFunction = chains[methodName];
48789
+
48790
+ chains[methodName] = function (chainId) {
48791
+ var args = [].concat(Array.prototype.slice.call(arguments), [oldFunction]);
48792
+ return (WRAPPED_CHAINS[parseInt(chainId)] || force ? funct : oldFunction).apply(chains, args);
48793
+ };
48794
+ }
48795
+
48796
+ wrap('isKnownChain', function () {
48797
+ return true;
48798
+ });
48799
+ wrap('getChainInformation', function (chainId) {
48800
+ return WRAPPED_CHAINS[parseInt(chainId)];
48801
+ });
48802
+ wrap('getKnownChainsIds', function (oldFunction) {
48803
+ return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.keys(WRAPPED_CHAINS)));
48804
+ });
48805
+ wrap('getKnownChainInformation', function (oldFunction) {
48806
+ return [].concat(_toConsumableArray(oldFunction()), _toConsumableArray(Object.values(WRAPPED_CHAINS)));
48807
+ });
48808
+ /**
48809
+ * WRAP CHAINS END
48810
+ **/
48811
+
48770
48812
  var web3States = {
48771
48813
  NOT_CONNECTED: NOT_CONNECTED,
48772
48814
  CONNECTED: CONNECTED,
@@ -50099,7 +50141,21 @@ function toDecimals(number, decimals) {
50099
50141
  var symbol = toEthereumSymbol(decimals);
50100
50142
 
50101
50143
  if (symbol) {
50102
- return web3Utils.toWei(numberToString(number), symbol);
50144
+ number = numberToString(number);
50145
+
50146
+ while (true) {
50147
+ try {
50148
+ return web3Utils.toWei(number, symbol);
50149
+ } catch (e) {
50150
+ var message = (e.message || e).toLowerCase();
50151
+
50152
+ if (message.indexOf('too many') !== -1) {
50153
+ number = number.substring(0, number.length - 1);
50154
+ } else {
50155
+ throw e;
50156
+ }
50157
+ }
50158
+ }
50103
50159
  }
50104
50160
 
50105
50161
  return numberToString(number * (decimals < 2 ? 1 : Math.pow(10, decimals)));