Skip to content

Commit

Permalink
Feat/add linea (#51)
Browse files Browse the repository at this point in the history
* feat: add linea network

* feat: add linea to deploy scripts
  • Loading branch information
sendra authored Dec 6, 2024
1 parent 469f1c3 commit 6f72233
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/contracts/utils/ChainHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ library ChainIds {
uint256 internal constant HARMONY = 1666600000;
uint256 internal constant CELO = 42220;
uint256 internal constant POLYGON_ZK_EVM = 1101;
uint256 internal constant LINEA = 59144;
}

library TestNetChainIds {
Expand All @@ -38,6 +39,7 @@ library TestNetChainIds {
uint256 internal constant OPTIMISM_SEPOLIA = 11155420;
uint256 internal constant ARBITRUM_SEPOLIA = 421614;
uint256 internal constant ZKSYNC_SEPOLIA = 300;
uint256 internal constant LINEA_SEPOLIA = 59141;
}

library ChainHelpers {
Expand Down Expand Up @@ -79,6 +81,8 @@ library ChainHelpers {
newFork = vm.createSelectFork(vm.rpcUrl('harmony'));
} else if (chainId == ChainIds.ZKSYNC) {
newFork = vm.createSelectFork(vm.rpcUrl('zksync'));
} else if (chainId == ChainIds.LINEA) {
newFork = vm.createSelectFork(vm.rpcUrl('linea'));
} else {
revert UnknownChainId();
}
Expand Down Expand Up @@ -113,6 +117,8 @@ library ChainHelpers {
networkName = 'celo';
} else if (chainId == ChainIds.ZKSYNC) {
networkName = 'zksync';
} else if (chainId == ChainIds.LINEA) {
networkName = 'linea';
}
// testnets
else if (chainId == TestNetChainIds.ETHEREUM_SEPOLIA) {
Expand All @@ -139,6 +145,8 @@ library ChainHelpers {
networkName = 'celo_alfajores';
} else if (chainId == TestNetChainIds.ZKSYNC_SEPOLIA) {
networkName = 'zksync_sepolia';
} else if (chainId == TestNetChainIds.LINEA_SEPOLIA) {
networkName = 'linea_sepolia';
} else {
revert('chain id is not supported');
}
Expand Down
22 changes: 12 additions & 10 deletions src/contracts/utils/ScriptUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ abstract contract ZkSyncScript is WithChainIdValidation {
constructor() WithChainIdValidation(ChainIds.ZKSYNC) {}
}

abstract contract LineaScript is WithChainIdValidation {
constructor() WithChainIdValidation(ChainIds.LINEA) {}
}

abstract contract SepoliaScript is WithChainIdValidation {
constructor() WithChainIdValidation(ChainIds.SEPOLIA) {}
}
Expand Down Expand Up @@ -127,22 +131,20 @@ library Create2Utils {
return (_addr.code.length > 0);
}

function computeCreate2Address(bytes32 salt, bytes32 initcodeHash)
internal
pure
returns (address)
{
function computeCreate2Address(
bytes32 salt,
bytes32 initcodeHash
) internal pure returns (address) {
return
addressFromLast20Bytes(
keccak256(abi.encodePacked(bytes1(0xff), CREATE2_FACTORY, salt, initcodeHash))
);
}

function computeCreate2Address(bytes32 salt, bytes memory bytecode)
internal
pure
returns (address)
{
function computeCreate2Address(
bytes32 salt,
bytes memory bytecode
) internal pure returns (address) {
return computeCreate2Address(salt, keccak256(abi.encodePacked(bytecode)));
}

Expand Down

0 comments on commit 6f72233

Please sign in to comment.