Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Support for Linea ENS #2094

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Features

* bump snapshot version to 4.12.2 [#2093](https://github.com/hyperledger/web3j/pull/2093)
* Adds Support for Linea ENS [#2094](https://github.com/hyperledger/web3j/pull/2094)

### BREAKING CHANGES

Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/org/web3j/ens/Contracts.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Contracts {
public static final String RINKEBY = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
public static final String GOERLI = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
public static final String SEPOLIA = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
public static final String LINEA = "0x50130b669B28C339991d8676FA73CF122a121267";
public static final String LINEA_SEPOLIA = "0x5B2636F0f2137B4aE722C01dd5122D7d3e9541f7";

public static String resolveRegistryContract(String chainId) {
final Long chainIdLong = Long.parseLong(chainId);
Expand All @@ -35,6 +37,10 @@ public static String resolveRegistryContract(String chainId) {
return GOERLI;
} else if (chainIdLong.equals(ChainIdLong.SEPOLIA)) {
return SEPOLIA;
} else if (chainIdLong.equals(ChainIdLong.LINEA)) {
return LINEA;
} else if (chainIdLong.equals(ChainIdLong.LINEA_SEPOLIA)) {
return LINEA_SEPOLIA;
} else {
throw new EnsResolutionException(
"Unable to resolve ENS registry contract for network id: " + chainId);
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/web3j/tx/ChainIdLong.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ public class ChainIdLong {
public static final long KOVAN = 42;
public static final long ETHEREUM_CLASSIC_MAINNET = 61;
public static final long ETHEREUM_CLASSIC_TESTNET = 62;
public static final long LINEA = 59144;
public static final long LINEA_SEPOLIA = 59141;
}
4 changes: 4 additions & 0 deletions core/src/test/java/org/web3j/ens/ContractsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.web3j.ens.Contracts.LINEA;
import static org.web3j.ens.Contracts.LINEA_SEPOLIA;
import static org.web3j.ens.Contracts.MAINNET;
import static org.web3j.ens.Contracts.RINKEBY;
import static org.web3j.ens.Contracts.ROPSTEN;
Expand All @@ -33,6 +35,8 @@ public void testResolveRegistryContract() {
assertEquals(resolveRegistryContract(ChainIdLong.ROPSTEN + ""), (ROPSTEN));
assertEquals(resolveRegistryContract(ChainIdLong.RINKEBY + ""), (RINKEBY));
assertEquals(resolveRegistryContract(ChainIdLong.SEPOLIA + ""), (SEPOLIA));
assertEquals(resolveRegistryContract(ChainIdLong.LINEA + ""), (LINEA));
assertEquals(resolveRegistryContract(ChainIdLong.LINEA_SEPOLIA + ""), (LINEA_SEPOLIA));
}

@Test
Expand Down
Loading