Skip to content

Commit ccdd167

Browse files
committed
chore: update hardocded devnet and mainnet evm ids
1 parent 5022bb7 commit ccdd167

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

packages/ts-types/src/enums.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export enum EthereumChainId {
88
Sepolia = 11155111,
99
Ganache = 1337,
1010
HardHat = 31337,
11-
DevnetEvm = 1778,
11+
MainnetEvm = 1776,
12+
DevnetEvm = 1337,
1213
TestnetEvm = 1439,
1314
}
1415

packages/wallets/wallet-core/src/broadcaster/MsgBroadcaster.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,30 @@ export class MsgBroadcaster {
153153
options.txTimeoutOnFeeDelegation || this.txTimeoutOnFeeDelegation
154154
}
155155

156-
async verifyEvmChainId() {
156+
async getEvmChainId(): Promise<EthereumChainId | undefined> {
157157
const { walletStrategy } = this
158+
158159
if (!isEvmBrowserWallet(walletStrategy.wallet)) {
159-
return
160+
return this.ethereumChainId
160161
}
161162

162-
const mainnetEvmIds = [EthereumChainId.Mainnet]
163+
const mainnetEvmIds = [EthereumChainId.Mainnet, EthereumChainId.MainnetEvm]
163164
const testnetEvmIds = [EthereumChainId.Sepolia, EthereumChainId.TestnetEvm]
164165
const devnetEvmIds = [EthereumChainId.Sepolia, EthereumChainId.DevnetEvm]
165166

166167
try {
167168
const chainId = await walletStrategy.getEthereumChainId()
169+
170+
if (!chainId) {
171+
return this.ethereumChainId
172+
}
173+
168174
const evmChainId = parseInt(chainId, 16) as EthereumChainId
169175

176+
if (isNaN(evmChainId)) {
177+
return this.ethereumChainId
178+
}
179+
170180
if (
171181
(isMainnet(this.options.network) &&
172182
!mainnetEvmIds.includes(evmChainId)) ||
@@ -181,10 +191,10 @@ export class MsgBroadcaster {
181191
)
182192
}
183193

184-
if (this.ethereumChainId !== evmChainId) {
185-
this.ethereumChainId = evmChainId
186-
}
187-
} catch {}
194+
return evmChainId
195+
} catch (e: any) {
196+
throw new WalletException(e)
197+
}
188198
}
189199

190200
/**
@@ -317,16 +327,15 @@ export class MsgBroadcaster {
317327
* @returns transaction hash
318328
*/
319329
private async broadcastEip712(tx: MsgBroadcasterTxOptionsWithAddresses) {
320-
const { chainId, txTimeout, endpoints, ethereumChainId, walletStrategy } =
321-
this
330+
const { chainId, txTimeout, endpoints, walletStrategy } = this
322331
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs]
323332

333+
const ethereumChainId = await this.getEvmChainId()
334+
324335
if (!ethereumChainId) {
325336
throw new GeneralException(new Error('Please provide ethereumChainId'))
326337
}
327338

328-
await this.verifyEvmChainId()
329-
330339
/** Account Details * */
331340
const { baseAccount, latestHeight } =
332341
await this.fetchAccountAndBlockDetails(tx.injectiveAddress)
@@ -431,16 +440,15 @@ export class MsgBroadcaster {
431440
private async broadcastEip712V2(
432441
tx: MsgBroadcasterTxOptionsWithAddresses,
433442
): Promise<TxResponse> {
434-
const { chainId, endpoints, txTimeout, walletStrategy, ethereumChainId } =
435-
this
443+
const { chainId, endpoints, txTimeout, walletStrategy } = this
436444
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs]
437445

446+
const ethereumChainId = await this.getEvmChainId()
447+
438448
if (!ethereumChainId) {
439449
throw new GeneralException(new Error('Please provide ethereumChainId'))
440450
}
441451

442-
await this.verifyEvmChainId()
443-
444452
/** Account Details * */
445453
const { baseAccount, latestHeight } =
446454
await this.fetchAccountAndBlockDetails(tx.injectiveAddress)
@@ -560,18 +568,17 @@ export class MsgBroadcaster {
560568
simulateTx,
561569
httpHeaders,
562570
walletStrategy,
563-
ethereumChainId,
564571
txTimeoutOnFeeDelegation,
565572
} = this
566573
const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs]
567574
const web3Msgs = msgs.map((msg) => msg.toWeb3())
568575

576+
const ethereumChainId = await this.getEvmChainId()
577+
569578
if (!ethereumChainId) {
570579
throw new GeneralException(new Error('Please provide ethereumChainId'))
571580
}
572581

573-
await this.verifyEvmChainId()
574-
575582
const transactionApi = new IndexerGrpcWeb3GwApi(
576583
endpoints.web3gw || endpoints.indexer,
577584
)

0 commit comments

Comments
 (0)