carbon-js-sdk 0.11.23 → 0.11.24

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.
@@ -102,6 +102,9 @@ declare class CarbonSDK {
102
102
  bsc: ETHClient;
103
103
  arbitrum: ETHClient;
104
104
  polygon: ETHClient;
105
+ mantle: ETHClient;
106
+ op: ETHClient;
107
+ base: ETHClient;
105
108
  okc: ETHClient;
106
109
  axelarBridgeClient: AxelarBridgeClient;
107
110
  zil: ZILClient;
package/lib/CarbonSDK.js CHANGED
@@ -158,6 +158,21 @@ class CarbonSDK {
158
158
  this.axelarBridgeClient = clients_1.AxelarBridgeClient.instance({
159
159
  configProvider: this,
160
160
  });
161
+ this.mantle = clients_1.ETHClient.instance({
162
+ configProvider: this,
163
+ blockchain: blockchain_1.Blockchain.Mantle,
164
+ tokenClient: this.token,
165
+ });
166
+ this.op = clients_1.ETHClient.instance({
167
+ configProvider: this,
168
+ blockchain: blockchain_1.Blockchain.OP,
169
+ tokenClient: this.token,
170
+ });
171
+ this.base = clients_1.ETHClient.instance({
172
+ configProvider: this,
173
+ blockchain: blockchain_1.Blockchain.Base,
174
+ tokenClient: this.token,
175
+ });
161
176
  }
162
177
  static instance(opts = DEFAULT_SDK_INIT_OPTS) {
163
178
  var _a, _b, _c, _d;
@@ -52,13 +52,16 @@ export declare class ETHClient {
52
52
  readonly configProvider: NetworkConfigProvider;
53
53
  readonly blockchain: typeof ETHClient.SUPPORTED_BLOCKCHAINS[number];
54
54
  readonly tokenClient: TokenClient;
55
- static SUPPORTED_BLOCKCHAINS: readonly [Blockchain.BinanceSmartChain, Blockchain.Ethereum, Blockchain.Arbitrum, Blockchain.Polygon, Blockchain.Okc];
55
+ static SUPPORTED_BLOCKCHAINS: readonly [Blockchain.BinanceSmartChain, Blockchain.Ethereum, Blockchain.Arbitrum, Blockchain.Polygon, Blockchain.Okc, Blockchain.Mantle, Blockchain.OP, Blockchain.Base];
56
56
  static BLOCKCHAIN_KEY: {
57
57
  bsc: string;
58
58
  eth: string;
59
59
  arbitrum: string;
60
60
  polygon: string;
61
61
  okc: string;
62
+ mantle: string;
63
+ op: string;
64
+ base: string;
62
65
  };
63
66
  static BLOCKCHAINV2_MAPPING: {
64
67
  bsc: string;
@@ -66,6 +69,9 @@ export declare class ETHClient {
66
69
  arbitrum: string;
67
70
  polygon: string;
68
71
  okc: string;
72
+ mantle: string;
73
+ op: string;
74
+ base: string;
69
75
  };
70
76
  private constructor();
71
77
  static instance(opts: ETHClientOpts): CarbonSDK.ETHClient;
@@ -359,13 +359,16 @@ class ETHClient {
359
359
  }
360
360
  }
361
361
  exports.ETHClient = ETHClient;
362
- ETHClient.SUPPORTED_BLOCKCHAINS = [blockchain_1.Blockchain.BinanceSmartChain, blockchain_1.Blockchain.Ethereum, blockchain_1.Blockchain.Arbitrum, blockchain_1.Blockchain.Polygon, blockchain_1.Blockchain.Okc];
362
+ ETHClient.SUPPORTED_BLOCKCHAINS = [blockchain_1.Blockchain.BinanceSmartChain, blockchain_1.Blockchain.Ethereum, blockchain_1.Blockchain.Arbitrum, blockchain_1.Blockchain.Polygon, blockchain_1.Blockchain.Okc, blockchain_1.Blockchain.Mantle, blockchain_1.Blockchain.OP, blockchain_1.Blockchain.Base];
363
363
  ETHClient.BLOCKCHAIN_KEY = {
364
364
  [blockchain_1.Blockchain.BinanceSmartChain]: "bsc",
365
365
  [blockchain_1.Blockchain.Ethereum]: "eth",
366
366
  [blockchain_1.Blockchain.Arbitrum]: "arbitrum",
367
367
  [blockchain_1.Blockchain.Polygon]: "polygon",
368
368
  [blockchain_1.Blockchain.Okc]: "okc",
369
+ [blockchain_1.Blockchain.Mantle]: 'mantle',
370
+ [blockchain_1.Blockchain.OP]: 'op',
371
+ [blockchain_1.Blockchain.Base]: 'base',
369
372
  };
370
373
  ETHClient.BLOCKCHAINV2_MAPPING = {
371
374
  [blockchain_1.Blockchain.BinanceSmartChain]: "Binance Smart Chain",
@@ -373,5 +376,8 @@ ETHClient.BLOCKCHAINV2_MAPPING = {
373
376
  [blockchain_1.Blockchain.Arbitrum]: "Arbitrum",
374
377
  [blockchain_1.Blockchain.Polygon]: "Polygon",
375
378
  [blockchain_1.Blockchain.Okc]: "OKC",
379
+ [blockchain_1.Blockchain.Mantle]: 'Mantle',
380
+ [blockchain_1.Blockchain.OP]: 'OP',
381
+ [blockchain_1.Blockchain.Base]: 'Base',
376
382
  };
377
383
  exports.default = ETHClient;
@@ -17,8 +17,10 @@ export declare const CarbonEvmChainIDs: {
17
17
  readonly localhost: "carbon_9999-1";
18
18
  };
19
19
  export declare const DEFAULT_NETWORK = Network.MainNet;
20
- export interface EthNetworkConfig {
20
+ export interface BasicNetworkConfig {
21
21
  rpcURL: string;
22
+ }
23
+ export interface EthNetworkConfig extends BasicNetworkConfig {
22
24
  wsURL: string;
23
25
  payerURL: string;
24
26
  lockProxyAddr: string;
@@ -26,23 +28,17 @@ export interface EthNetworkConfig {
26
28
  balanceReader: string;
27
29
  byteCodeHash: string;
28
30
  }
29
- export interface NeoNetworkConfig {
30
- rpcURL: string;
31
+ export interface NeoNetworkConfig extends BasicNetworkConfig {
31
32
  wrapperScriptHash: string;
32
33
  }
33
- export interface N3NetworkConfig {
34
- rpcURL: string;
34
+ export interface N3NetworkConfig extends BasicNetworkConfig {
35
35
  networkMagic: number;
36
36
  }
37
- export interface ZilNetworkConfig {
38
- rpcURL: string;
37
+ export interface ZilNetworkConfig extends BasicNetworkConfig {
39
38
  chainId: number;
40
39
  lockProxyAddr: string;
41
40
  bridgeEntranceAddr: string;
42
41
  }
43
- export interface MantleNetworkConfig {
44
- rpcURL: string;
45
- }
46
42
  export interface NetworkConfig {
47
43
  tmRpcUrl: string;
48
44
  tmWsUrl: string;
@@ -66,7 +62,9 @@ export interface NetworkConfig {
66
62
  neo: NeoNetworkConfig;
67
63
  n3: N3NetworkConfig;
68
64
  zil: ZilNetworkConfig;
69
- mantle: MantleNetworkConfig;
65
+ mantle: EthNetworkConfig;
66
+ op: EthNetworkConfig;
67
+ base: EthNetworkConfig;
70
68
  }
71
69
  export interface NetworkConfigProvider {
72
70
  getConfig(): NetworkConfig;
@@ -22,6 +22,15 @@ exports.CarbonEvmChainIDs = {
22
22
  [Network.LocalHost]: "carbon_9999-1",
23
23
  };
24
24
  exports.DEFAULT_NETWORK = Network.MainNet;
25
+ const EthNetworkConfigFallback = {
26
+ rpcURL: "",
27
+ wsURL: "",
28
+ payerURL: "",
29
+ bridgeEntranceAddr: "",
30
+ lockProxyAddr: "",
31
+ balanceReader: "",
32
+ byteCodeHash: "",
33
+ };
25
34
  exports.NetworkConfigs = {
26
35
  [Network.MainNet]: {
27
36
  network: Network.MainNet,
@@ -97,9 +106,9 @@ exports.NetworkConfigs = {
97
106
  bridgeEntranceAddr: "0x5d78b51a1ceae202a793f4e87478253f41a22956",
98
107
  chainId: 1,
99
108
  },
100
- mantle: {
101
- rpcURL: 'https://rpc.mantle.xyz',
102
- },
109
+ mantle: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://rpc.mantle.xyz" }),
110
+ op: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://mainnet.optimism.io" }),
111
+ base: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://base-rpc.publicnode.com" }),
103
112
  },
104
113
  [Network.TestNet]: {
105
114
  network: Network.TestNet,
@@ -175,9 +184,9 @@ exports.NetworkConfigs = {
175
184
  bridgeEntranceAddr: "0xccf798e633d6fb6505b494fc010903f9be3bc99b",
176
185
  chainId: 111,
177
186
  },
178
- mantle: {
179
- rpcURL: "https://rpc.sepolia.mantle.xyz",
180
- },
187
+ mantle: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://rpc.sepolia.mantle.xyz" }),
188
+ op: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://sepolia.optimism.io" }),
189
+ base: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://base-sepolia-rpc.publicnode.com" }),
181
190
  },
182
191
  [Network.DevNet]: {
183
192
  network: Network.DevNet,
@@ -264,9 +273,9 @@ exports.NetworkConfigs = {
264
273
  bridgeEntranceAddr: "0xbbe98D54689c96D0278a1222594533e8C5fa551e",
265
274
  chainId: 333,
266
275
  },
267
- mantle: {
268
- rpcURL: "https://rpc.sepolia.mantle.xyz",
269
- },
276
+ mantle: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://rpc.sepolia.mantle.xyz" }),
277
+ op: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://sepolia.optimism.io" }),
278
+ base: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://base-sepolia-rpc.publicnode.com" }),
270
279
  },
271
280
  [Network.LocalHost]: {
272
281
  network: Network.LocalHost,
@@ -342,8 +351,8 @@ exports.NetworkConfigs = {
342
351
  bridgeEntranceAddr: "",
343
352
  chainId: 1,
344
353
  },
345
- mantle: {
346
- rpcURL: "https://rpc.sepolia.mantle.xyz",
347
- },
354
+ mantle: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://rpc.sepolia.mantle.xyz" }),
355
+ op: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://sepolia.optimism.io" }),
356
+ base: Object.assign(Object.assign({}, EthNetworkConfigFallback), { rpcURL: "https://base-sepolia-rpc.publicnode.com" }),
348
357
  },
349
358
  };
@@ -31,3 +31,7 @@ export declare const OKC_MAINNET: ChangeNetworkParam;
31
31
  export declare const OKC_TESTNET: ChangeNetworkParam;
32
32
  export declare const MANTLE_MAINNET: ChangeNetworkParam;
33
33
  export declare const MANTLE_TESTNET: ChangeNetworkParam;
34
+ export declare const OP_MAINNET: ChangeNetworkParam;
35
+ export declare const OP_TESTNET: ChangeNetworkParam;
36
+ export declare const BASE_MAINNET: ChangeNetworkParam;
37
+ export declare const BASE_TESTNET: ChangeNetworkParam;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MANTLE_TESTNET = exports.MANTLE_MAINNET = exports.OKC_TESTNET = exports.OKC_MAINNET = exports.POLYGON_TESTNET = exports.POLYGON_MAINNET = exports.ARBITRUM_TESTNET = exports.ARBITRUM_MAINNET = exports.ETH_TESTNET = exports.ETH_MAINNET = exports.BSC_TESTNET = exports.BSC_MAINNET = exports.CARBON_EVM_MAINNET = exports.CARBON_EVM_TESTNET = exports.CARBON_EVM_DEVNET = exports.CARBON_EVM_LOCALHOST = exports.CarbonEvmNativeCurrency = void 0;
3
+ exports.BASE_TESTNET = exports.BASE_MAINNET = exports.OP_TESTNET = exports.OP_MAINNET = exports.MANTLE_TESTNET = exports.MANTLE_MAINNET = exports.OKC_TESTNET = exports.OKC_MAINNET = exports.POLYGON_TESTNET = exports.POLYGON_MAINNET = exports.ARBITRUM_TESTNET = exports.ARBITRUM_MAINNET = exports.ETH_TESTNET = exports.ETH_MAINNET = exports.BSC_TESTNET = exports.BSC_MAINNET = exports.CARBON_EVM_MAINNET = exports.CARBON_EVM_TESTNET = exports.CARBON_EVM_DEVNET = exports.CARBON_EVM_LOCALHOST = exports.CarbonEvmNativeCurrency = void 0;
4
4
  const constant_1 = require("../constant");
5
5
  const ethermint_1 = require("../util/ethermint");
6
6
  exports.CarbonEvmNativeCurrency = {
@@ -173,3 +173,55 @@ exports.MANTLE_TESTNET = {
173
173
  symbol: "MNT",
174
174
  },
175
175
  };
176
+ exports.OP_MAINNET = {
177
+ chainId: "0xA",
178
+ blockExplorerUrls: ["https://optimistic.etherscan.io"],
179
+ chainName: "OP Mainnet",
180
+ rpcUrls: [
181
+ "https://mainnet.optimism.io",
182
+ ],
183
+ nativeCurrency: {
184
+ decimals: 18,
185
+ name: "Ethereum",
186
+ symbol: "ETH",
187
+ },
188
+ };
189
+ exports.OP_TESTNET = {
190
+ chainId: "0xaa36a7",
191
+ blockExplorerUrls: ["https://sepolia-optimism.etherscan.io"],
192
+ chainName: "OP Sepolia Testnet",
193
+ rpcUrls: [
194
+ "https://sepolia.optimism.io",
195
+ ],
196
+ nativeCurrency: {
197
+ decimals: 18,
198
+ name: "Ethereum",
199
+ symbol: "ETH",
200
+ },
201
+ };
202
+ exports.BASE_MAINNET = {
203
+ chainId: "0x2105",
204
+ blockExplorerUrls: ["https://basescan.org"],
205
+ chainName: "Base Mainnet",
206
+ rpcUrls: [
207
+ "https://base-rpc.publicnode.com",
208
+ ],
209
+ nativeCurrency: {
210
+ decimals: 18,
211
+ name: "Ethereum",
212
+ symbol: "ETH",
213
+ },
214
+ };
215
+ exports.BASE_TESTNET = {
216
+ chainId: "0x14a34",
217
+ blockExplorerUrls: ["https://sepolia.basescan.org"],
218
+ chainName: "Base Sepolia Testnet",
219
+ rpcUrls: [
220
+ "https://base-sepolia-rpc.publicnode.com",
221
+ ],
222
+ nativeCurrency: {
223
+ decimals: 18,
224
+ name: "Ethereum",
225
+ symbol: "ETH",
226
+ },
227
+ };
@@ -101,6 +101,20 @@ const CONTRACT_HASH = {
101
101
  [constant_1.Network.LocalHost]: "",
102
102
  [constant_1.Network.MainNet]: "",
103
103
  },
104
+ OP: {
105
+ // use same testnet contract for all non-mainnet uses
106
+ [constant_1.Network.TestNet]: "",
107
+ [constant_1.Network.DevNet]: "",
108
+ [constant_1.Network.LocalHost]: "",
109
+ [constant_1.Network.MainNet]: "",
110
+ },
111
+ Base: {
112
+ // use same testnet contract for all non-mainnet uses
113
+ [constant_1.Network.TestNet]: "",
114
+ [constant_1.Network.DevNet]: "",
115
+ [constant_1.Network.LocalHost]: "",
116
+ [constant_1.Network.MainNet]: "",
117
+ },
104
118
  Carbon: {
105
119
  //Carbon does not support Metamask legacy mnemonic sign in
106
120
  [constant_1.Network.TestNet]: "",
@@ -251,37 +265,25 @@ class MetaMask extends eip6963Provider_1.Eip6963Provider {
251
265
  if (blockchain === 'Carbon') {
252
266
  return MetaMask.getCarbonEvmNetworkParams(network);
253
267
  }
254
- if (network === constant_1.Network.MainNet) {
255
- switch (blockchain) {
256
- case 'Binance Smart Chain':
257
- return constant_2.BSC_MAINNET;
258
- case 'Arbitrum':
259
- return constant_2.ARBITRUM_MAINNET;
260
- case 'Polygon':
261
- return constant_2.POLYGON_MAINNET;
262
- case 'OKC':
263
- return constant_2.OKC_MAINNET;
264
- case 'Mantle':
265
- return constant_1.MANTLE_MAINNET;
266
- default:
267
- // metamask should come with Ethereum configs
268
- return constant_2.ETH_MAINNET;
269
- }
270
- }
268
+ const isMainnet = network === constant_1.Network.MainNet;
271
269
  switch (blockchain) {
272
270
  case 'Binance Smart Chain':
273
- return constant_2.BSC_TESTNET;
271
+ return isMainnet ? constant_2.BSC_MAINNET : constant_2.BSC_TESTNET;
274
272
  case 'Arbitrum':
275
- return constant_2.ARBITRUM_TESTNET;
273
+ return isMainnet ? constant_2.ARBITRUM_MAINNET : constant_2.ARBITRUM_TESTNET;
276
274
  case 'Polygon':
277
- return constant_2.POLYGON_TESTNET;
275
+ return isMainnet ? constant_2.POLYGON_MAINNET : constant_2.POLYGON_TESTNET;
278
276
  case 'OKC':
279
- return constant_2.OKC_TESTNET;
277
+ return isMainnet ? constant_2.OKC_MAINNET : constant_2.OKC_TESTNET;
280
278
  case 'Mantle':
281
- return constant_1.MANTLE_TESTNET;
279
+ return isMainnet ? constant_1.MANTLE_MAINNET : constant_1.MANTLE_TESTNET;
280
+ case 'OP':
281
+ return isMainnet ? constant_1.OP_MAINNET : constant_1.OP_TESTNET;
282
+ case 'Base':
283
+ return isMainnet ? constant_1.BASE_MAINNET : constant_1.BASE_TESTNET;
282
284
  default:
283
285
  // metamask should come with Ethereum configs
284
- return constant_2.ETH_TESTNET;
286
+ return isMainnet ? constant_2.ETH_MAINNET : constant_2.ETH_TESTNET;
285
287
  }
286
288
  }
287
289
  static getCarbonEvmNetworkParams(network) {
@@ -300,35 +302,25 @@ class MetaMask extends eip6963Provider_1.Eip6963Provider {
300
302
  if (blockchain === "Carbon") {
301
303
  return Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[network]));
302
304
  }
303
- if (network === constant_1.Network.MainNet) {
304
- switch (blockchain) {
305
- case 'Binance Smart Chain':
306
- return 56;
307
- case 'Mantle':
308
- return 5000;
309
- case 'Arbitrum':
310
- return 42161;
311
- case 'Polygon':
312
- return 137;
313
- case 'OKC':
314
- return 66;
315
- default:
316
- return 1;
317
- }
318
- }
305
+ const isMainnet = network === constant_1.Network.MainNet;
319
306
  switch (blockchain) {
320
307
  case 'Binance Smart Chain':
321
- return 97;
308
+ return isMainnet ? 56 : 97;
322
309
  case 'Mantle':
323
- return 5003;
310
+ return isMainnet ? 5000 : 5003;
324
311
  case 'Arbitrum':
325
- return 421611;
312
+ return isMainnet ? 42161 : 421611;
326
313
  case 'Polygon':
327
- return 80001;
314
+ return isMainnet ? 137 : 80001;
328
315
  case 'OKC':
329
- return 65;
316
+ return isMainnet ? 66 : 65;
317
+ case 'OP':
318
+ return isMainnet ? 10 : 11155420;
319
+ case 'Base':
320
+ return isMainnet ? 8453 : 84532;
330
321
  default:
331
- return 5;
322
+ // Fallback to Ethereum chain ID
323
+ return isMainnet ? 1 : 5;
332
324
  }
333
325
  }
334
326
  checkProvider(blockchain = this.blockchain) {
@@ -631,6 +623,7 @@ class MetaMask extends eip6963Provider_1.Eip6963Provider {
631
623
  });
632
624
  }
633
625
  login(blockchain) {
626
+ var _a;
634
627
  return __awaiter(this, void 0, void 0, function* () {
635
628
  if (blockchain === 'Carbon') {
636
629
  throw new Error('Carbon EVM does not support Metamask Legacy');
@@ -642,7 +635,7 @@ class MetaMask extends eip6963Provider_1.Eip6963Provider {
642
635
  const chainId = parseInt(chainIdHex, 16);
643
636
  const requiredChainId = this.getRequiredChain(this.network, chainId);
644
637
  if (chainId !== requiredChainId) {
645
- const requiredNetworkName = blockchain_1.ChainNames[requiredChainId] || blockchain_1.ChainNames[3];
638
+ const requiredNetworkName = (_a = blockchain_1.ChainNames[requiredChainId]) !== null && _a !== void 0 ? _a : blockchain_1.ChainNames[3];
646
639
  throw new Error(`MetaMask not connected to correct network, please use ${requiredNetworkName} (Chain ID: ${requiredChainId})`);
647
640
  }
648
641
  const mnemonic = this.decryptCipher(cipherTextHex);
@@ -685,55 +678,44 @@ class MetaMask extends eip6963Provider_1.Eip6963Provider {
685
678
  });
686
679
  }
687
680
  getRequiredChain(network, currentChainId) {
688
- // set correct blockchain given the chain ID
689
- if (network === constant_1.Network.MainNet) {
690
- if (currentChainId === 1) {
681
+ const isMainnet = network === constant_1.Network.MainNet;
682
+ switch (currentChainId) {
683
+ case 1: // Ethereum Mainnet
684
+ case 5: // Ethereum Goerli Testnet
691
685
  this.blockchain = 'Ethereum';
692
- return currentChainId;
693
- }
694
- if (currentChainId === 56) {
686
+ return isMainnet ? 1 : 5;
687
+ case 56: // Binance Smart Chain Mainnet
688
+ case 97: // Binance Smart Chain Testnet
695
689
  this.blockchain = 'Binance Smart Chain';
696
- return currentChainId;
697
- }
698
- if (currentChainId === 42161) {
690
+ return isMainnet ? 56 : 97;
691
+ case 42161: // Arbitrum Mainnet
692
+ case 421611: // Arbitrum Testnet
699
693
  this.blockchain = 'Arbitrum';
700
- return currentChainId;
701
- }
702
- if (currentChainId === 137) {
694
+ return isMainnet ? 42161 : 421611;
695
+ case 137: // Polygon Mainnet
696
+ case 80001: // Polygon Testnet
703
697
  this.blockchain = 'Polygon';
704
- return currentChainId;
705
- }
706
- if (currentChainId === 66) {
698
+ return isMainnet ? 137 : 80001;
699
+ case 66: // OKC Mainnet
700
+ case 65: // OKC Testnet
707
701
  this.blockchain = 'OKC';
708
- return currentChainId;
709
- }
710
- return 1;
711
- }
712
- if (currentChainId === 5) {
713
- this.blockchain = 'Ethereum';
714
- return currentChainId;
715
- }
716
- if (currentChainId === 97) {
717
- this.blockchain = 'Binance Smart Chain';
718
- return currentChainId;
719
- }
720
- if (currentChainId === 421611) {
721
- this.blockchain = 'Arbitrum';
722
- return currentChainId;
723
- }
724
- if (currentChainId === 80001) {
725
- this.blockchain = 'Polygon';
726
- return currentChainId;
727
- }
728
- if (currentChainId === 65) {
729
- this.blockchain = 'OKC';
730
- return currentChainId;
731
- }
732
- // Deal with cases where users are logging in to devnet using mainnet chains
733
- if (currentChainId === 56) {
734
- return 97;
702
+ return isMainnet ? 66 : 65;
703
+ case 5000: // Mantle Mainnet
704
+ case 5003: // Mantle Testnet
705
+ this.blockchain = 'Mantle';
706
+ return isMainnet ? 5000 : 5003;
707
+ case 10: // OP Mainnet
708
+ case 11155420: // OP Sepolia Testnet
709
+ this.blockchain = 'OP';
710
+ return isMainnet ? 10 : 11155420;
711
+ case 8453:
712
+ case 84532:
713
+ this.blockchain = 'Base';
714
+ return isMainnet ? 8453 : 84532;
715
+ default:
716
+ // Default fallback for Ethereum if no specific match found
717
+ return isMainnet ? 1 : 5;
735
718
  }
736
- return 5;
737
719
  }
738
720
  getContractHash(blockchain = this.blockchain) {
739
721
  const contractHash = CONTRACT_HASH[blockchain][this.network];
@@ -174,31 +174,25 @@ class RainbowKitAccount extends eip6963Provider_1.Eip6963Provider {
174
174
  if (blockchain === "Carbon") {
175
175
  return Number(ethermint_1.parseChainId(constant_1.CarbonEvmChainIDs[network]));
176
176
  }
177
- if (network === constant_1.Network.MainNet) {
178
- switch (blockchain) {
179
- case 'Binance Smart Chain':
180
- return 56;
181
- case 'Arbitrum':
182
- return 42161;
183
- case 'Polygon':
184
- return 137;
185
- case 'OKC':
186
- return 66;
187
- default:
188
- return 1;
189
- }
190
- }
177
+ const isMainnet = network === constant_1.Network.MainNet;
191
178
  switch (blockchain) {
192
179
  case 'Binance Smart Chain':
193
- return 97;
180
+ return isMainnet ? 56 : 97;
181
+ case 'Mantle':
182
+ return isMainnet ? 5000 : 5003;
194
183
  case 'Arbitrum':
195
- return 421611;
184
+ return isMainnet ? 42161 : 421611;
196
185
  case 'Polygon':
197
- return 80001;
186
+ return isMainnet ? 137 : 80001;
198
187
  case 'OKC':
199
- return 65;
188
+ return isMainnet ? 66 : 65;
189
+ case 'OP':
190
+ return isMainnet ? 10 : 11155420;
191
+ case 'Base':
192
+ return isMainnet ? 8453 : 84532;
200
193
  default:
201
- return 5;
194
+ // Fallback to Ethereum chain ID
195
+ return isMainnet ? 1 : 5;
202
196
  }
203
197
  }
204
198
  static getCarbonEvmNetworkParams(network) {
@@ -217,33 +211,25 @@ class RainbowKitAccount extends eip6963Provider_1.Eip6963Provider {
217
211
  if (blockchain === 'Carbon') {
218
212
  return RainbowKitAccount.getCarbonEvmNetworkParams(network);
219
213
  }
220
- if (network === constant_1.Network.MainNet) {
221
- switch (blockchain) {
222
- case 'Binance Smart Chain':
223
- return constant_2.BSC_MAINNET;
224
- case 'Arbitrum':
225
- return constant_2.ARBITRUM_MAINNET;
226
- case 'Polygon':
227
- return constant_2.POLYGON_MAINNET;
228
- case 'OKC':
229
- return constant_2.OKC_MAINNET;
230
- default:
231
- // should come with Ethereum configs
232
- return constant_2.ETH_MAINNET;
233
- }
234
- }
214
+ const isMainnet = network === constant_1.Network.MainNet;
235
215
  switch (blockchain) {
236
216
  case 'Binance Smart Chain':
237
- return constant_2.BSC_TESTNET;
217
+ return isMainnet ? constant_2.BSC_MAINNET : constant_2.BSC_TESTNET;
238
218
  case 'Arbitrum':
239
- return constant_2.ARBITRUM_TESTNET;
219
+ return isMainnet ? constant_2.ARBITRUM_MAINNET : constant_2.ARBITRUM_TESTNET;
240
220
  case 'Polygon':
241
- return constant_2.POLYGON_TESTNET;
221
+ return isMainnet ? constant_2.POLYGON_MAINNET : constant_2.POLYGON_TESTNET;
242
222
  case 'OKC':
243
- return constant_2.OKC_TESTNET;
223
+ return isMainnet ? constant_2.OKC_MAINNET : constant_2.OKC_TESTNET;
224
+ case 'Mantle':
225
+ return isMainnet ? constant_1.MANTLE_MAINNET : constant_1.MANTLE_TESTNET;
226
+ case 'OP':
227
+ return isMainnet ? constant_1.OP_MAINNET : constant_1.OP_TESTNET;
228
+ case 'Base':
229
+ return isMainnet ? constant_1.BASE_MAINNET : constant_1.BASE_TESTNET;
244
230
  default:
245
- // should come with Ethereum configs
246
- return constant_2.ETH_TESTNET;
231
+ // metamask should come with Ethereum configs
232
+ return isMainnet ? constant_2.ETH_MAINNET : constant_2.ETH_TESTNET;
247
233
  }
248
234
  }
249
235
  isChangeNetworkRequired(blockchain, network) {
@@ -41,7 +41,9 @@ export declare enum Blockchain {
41
41
  OmniFlixHub = "omniflixhub",
42
42
  Agoric = "agoric",
43
43
  Sommelier = "sommelier",
44
- Mantle = "mantle"
44
+ Mantle = "mantle",
45
+ OP = "op",
46
+ Base = "base"
45
47
  }
46
48
  export declare type BlockchainV2 = ReturnType<TokenClient['getAllBlockchainNames']>[number] | "Native" | "Carbon" | "Tradehub" | "Ibc" | "Polynetwork";
47
49
  export declare const BLOCKCHAIN_V2_TO_V1_MAPPING: SimpleMap<Blockchain>;
@@ -72,22 +74,7 @@ export interface BridgeMap {
72
74
  axelar: AxelarBridge[];
73
75
  }
74
76
  export declare type ChainIds = SimpleMap<number>;
75
- export declare const ChainNames: {
76
- readonly 1: "MainNet";
77
- readonly 3: "Ropsten";
78
- readonly 4: "Rinkeby";
79
- readonly 5: "Goerli";
80
- readonly 56: "BSC MainNet";
81
- readonly 97: "BSC TestNet";
82
- readonly 110: "ZIL DevNet";
83
- readonly 111: "ZIL TestNet";
84
- readonly 65: "Okc TestNet";
85
- readonly 66: "Okc MainNet";
86
- readonly 137: "Polygon MainNet";
87
- readonly 80001: "Polygon Mumbai";
88
- readonly 42161: "Arbitrum MainNet";
89
- readonly 421611: "Arbitrum TestNet";
90
- };
77
+ export declare const ChainNames: SimpleMap<string>;
91
78
  export declare const CHAIN_IDS: ChainIds;
92
79
  export declare const CHAIN_IDS_DEV: ChainIds;
93
80
  export declare const CHAIN_IDS_TEST: ChainIds;
@@ -96,12 +83,12 @@ export declare function parseBlockchain(value: string | null): Blockchain | null
96
83
  export declare function getChainFromID(id: number): string | undefined;
97
84
  export declare const getBlockchainFromChain: (chainId?: number | undefined) => Blockchain.Ethereum | Blockchain.BinanceSmartChain | Blockchain.Zilliqa | Blockchain.Arbitrum | Blockchain.Polygon | Blockchain.Okc | undefined;
98
85
  export declare const blockchainForChainId: (chainId?: number | undefined, network?: Network) => Blockchain | undefined;
99
- export declare const getBlockchainFromChainV2: (chainId?: number | undefined) => "Carbon" | "Ethereum" | "Binance Smart Chain" | "Arbitrum" | "Polygon" | "Okc" | "Zilliqa" | undefined;
86
+ export declare const getBlockchainFromChainV2: (chainId?: number | undefined) => "Carbon" | "Ethereum" | "Binance Smart Chain" | "Arbitrum" | "Polygon" | "Mantle" | "Base" | "Okc" | "Zilliqa" | "Optimism" | undefined;
100
87
  export declare const blockchainForChainIdV2: (chainId?: number | undefined, network?: Network) => Blockchain | BlockchainV2 | undefined;
101
88
  export declare const blockchainForChainName: {
102
89
  [key: string]: string;
103
90
  };
104
91
  export declare const getFormattedBlockchainName: (chain: string) => BlockchainV2 | undefined;
105
- export declare const EvmChains: readonly ["Ethereum", "Binance Smart Chain", "Arbitrum", "Polygon", "OKC", "Carbon", "Mantle"];
92
+ export declare const EvmChains: readonly ["Ethereum", "Binance Smart Chain", "Arbitrum", "Polygon", "OKC", "Carbon", "Mantle", "OP", "Base"];
106
93
  export declare type EVMChain = (typeof EvmChains)[number];
107
- export declare const isEvmChain: (chain: string) => chain is "Carbon" | "Ethereum" | "Binance Smart Chain" | "Arbitrum" | "Polygon" | "OKC" | "Mantle";
94
+ export declare const isEvmChain: (chain: string) => chain is "Carbon" | "Ethereum" | "Binance Smart Chain" | "Arbitrum" | "Polygon" | "OKC" | "Mantle" | "OP" | "Base";
@@ -45,6 +45,8 @@ var Blockchain;
45
45
  Blockchain["Agoric"] = "agoric";
46
46
  Blockchain["Sommelier"] = "sommelier";
47
47
  Blockchain["Mantle"] = "mantle";
48
+ Blockchain["OP"] = "op";
49
+ Blockchain["Base"] = "base";
48
50
  })(Blockchain = exports.Blockchain || (exports.Blockchain = {}));
49
51
  exports.BLOCKCHAIN_V2_TO_V1_MAPPING = {
50
52
  "Binance Smart Chain": Blockchain.BinanceSmartChain,
@@ -56,6 +58,9 @@ exports.BLOCKCHAIN_V2_TO_V1_MAPPING = {
56
58
  "Zilliqa": Blockchain.Zilliqa,
57
59
  "Neo": Blockchain.Neo,
58
60
  "Neo3": Blockchain.Neo3,
61
+ "Mantle": Blockchain.Mantle,
62
+ "OP": Blockchain.OP,
63
+ "Base": Blockchain.Base,
59
64
  };
60
65
  exports.BRIDGE_IDS = {
61
66
  polynetwork: 1,
@@ -81,6 +86,12 @@ exports.ChainNames = {
81
86
  80001: "Polygon Mumbai",
82
87
  42161: "Arbitrum MainNet",
83
88
  421611: "Arbitrum TestNet",
89
+ 5000: "Mantle MainNet",
90
+ 5003: "Mantle Sepolia TestNet",
91
+ 10: "OP MainNet",
92
+ 11155420: "OP Sepolia TestNet",
93
+ 8453: "Base",
94
+ 84532: "Base Sepolia TestNet",
84
95
  };
85
96
  exports.CHAIN_IDS = {
86
97
  native: 0,
@@ -238,6 +249,12 @@ const blockchainForChainId = (chainId, network = network_1.Network.MainNet) => {
238
249
  case 19: /* FALLTHROUGH */
239
250
  case 42161:
240
251
  return Blockchain.Arbitrum;
252
+ case 5000:
253
+ return Blockchain.Mantle;
254
+ case 10:
255
+ return Blockchain.OP;
256
+ case 8453:
257
+ return Blockchain.Base;
241
258
  default:
242
259
  return undefined;
243
260
  }
@@ -257,6 +274,12 @@ const blockchainForChainId = (chainId, network = network_1.Network.MainNet) => {
257
274
  case 2: /* FALLTHROUGH */
258
275
  case 502:
259
276
  return Blockchain.Ethereum;
277
+ case 5003:
278
+ return Blockchain.Mantle;
279
+ case 11155420:
280
+ return Blockchain.OP;
281
+ case 84532:
282
+ return Blockchain.Base;
260
283
  default:
261
284
  return undefined;
262
285
  }
@@ -275,6 +298,12 @@ const blockchainForChainId = (chainId, network = network_1.Network.MainNet) => {
275
298
  return Blockchain.BinanceSmartChain;
276
299
  case 111:
277
300
  return Blockchain.Zilliqa;
301
+ case 5003:
302
+ return Blockchain.Mantle;
303
+ case 11155420:
304
+ return Blockchain.OP;
305
+ case 84532:
306
+ return Blockchain.Base;
278
307
  default:
279
308
  return undefined;
280
309
  }
@@ -307,6 +336,15 @@ const getBlockchainFromChainV2 = (chainId) => {
307
336
  case 42161:
308
337
  case 421611:
309
338
  return 'Arbitrum';
339
+ case 5000:
340
+ case 5003:
341
+ return 'Mantle';
342
+ case 10:
343
+ case 11155420:
344
+ return 'Optimism';
345
+ case 8453:
346
+ case 84532:
347
+ return 'Base';
310
348
  case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.LocalHost]))):
311
349
  case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.DevNet]))):
312
350
  case Number(ethermint_1.parseChainId((network_1.CarbonEvmChainIDs[network_1.Network.TestNet]))):
@@ -386,6 +424,12 @@ const blockchainForChainIdV2 = (chainId, network = network_1.Network.MainNet) =>
386
424
  case 19: /* FALLTHROUGH */
387
425
  case 42161:
388
426
  return "Arbitrum";
427
+ case 5000:
428
+ return "Mantle";
429
+ case 10:
430
+ return "OP";
431
+ case 8453:
432
+ return "Base";
389
433
  default:
390
434
  return undefined;
391
435
  }
@@ -405,6 +449,12 @@ const blockchainForChainIdV2 = (chainId, network = network_1.Network.MainNet) =>
405
449
  case 2: /* FALLTHROUGH */
406
450
  case 502:
407
451
  return "Ethereum";
452
+ case 5003:
453
+ return "Mantle";
454
+ case 11155420:
455
+ return "OP";
456
+ case 84532:
457
+ return "Base";
408
458
  default:
409
459
  return undefined;
410
460
  }
@@ -423,6 +473,12 @@ const blockchainForChainIdV2 = (chainId, network = network_1.Network.MainNet) =>
423
473
  return "Binance Smart Chain";
424
474
  case 111:
425
475
  return 'Zilliqa';
476
+ case 5003:
477
+ return "Mantle";
478
+ case 11155420:
479
+ return "OP";
480
+ case 84532:
481
+ return "Base";
426
482
  default:
427
483
  return undefined;
428
484
  }
@@ -469,11 +525,13 @@ exports.blockchainForChainName = {
469
525
  [Blockchain.Agoric]: "Agoric",
470
526
  [Blockchain.Sommelier]: "Sommelier",
471
527
  [Blockchain.Mantle]: "Mantle",
528
+ [Blockchain.OP]: "OP",
529
+ [Blockchain.Base]: "Base",
472
530
  };
473
531
  const getFormattedBlockchainName = (chain) => {
474
532
  return exports.blockchainForChainName[chain];
475
533
  };
476
534
  exports.getFormattedBlockchainName = getFormattedBlockchainName;
477
- exports.EvmChains = ['Ethereum', 'Binance Smart Chain', 'Arbitrum', 'Polygon', 'OKC', 'Carbon', 'Mantle'];
535
+ exports.EvmChains = ['Ethereum', 'Binance Smart Chain', 'Arbitrum', 'Polygon', 'OKC', 'Carbon', 'Mantle', 'OP', 'Base'];
478
536
  const isEvmChain = (chain) => exports.EvmChains.includes(chain);
479
537
  exports.isEvmChain = isEvmChain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.11.23",
3
+ "version": "0.11.24",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",