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

Feat/add linea #51

Merged
merged 2 commits into from
Dec 6, 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
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
Loading