diff --git a/src/chains/Parmigiana.sol b/src/chains/Parmigiana.sol new file mode 100644 index 0000000..bbcfde1 --- /dev/null +++ b/src/chains/Parmigiana.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {RollupOrders} from "zenith/src/orders/RollupOrders.sol"; +import {RollupPassage} from "zenith/src/passage/RollupPassage.sol"; +import {HostOrders} from "zenith/src/orders/HostOrders.sol"; +import {Passage} from "zenith/src/passage/Passage.sol"; +import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; + +/// @title ParmigianaConstants +/// @author init4 +/// @notice Constants for the Parmigiana testnet. +/// @dev These constants are used to configure the SignetStd contract in its +/// constructor, if the chain ID matches the Parmigiana testnet chain ID. +library ParmigianaConstants { + /// @notice The Parmigiana host chain ID. + uint32 constant HOST_CHAIN_ID = 3151908; + /// @notice The Parmigiana Rollup chain ID. + uint32 constant ROLLUP_CHAIN_ID = 88888; + + /// @notice The Passage contract for the Parmigiana testnet host chain. + Passage constant HOST_PASSAGE = Passage(payable(0x28524D2a753925Ef000C3f0F811cDf452C6256aF)); + + /// @notice The HostOrders contract for the Parmigiana testnet host chain. + HostOrders constant HOST_ORDERS = HostOrders(0x96f44ddc3Bc8892371305531F1a6d8ca2331fE6C); + + /// @notice The Rollup Passage contract for the Parmigiana testnet. + RollupPassage constant ROLLUP_PASSAGE = RollupPassage(payable(0x0000000000007369676E65742D70617373616765)); + + /// @notice The Rollup Orders contract for the Parmigiana testnet. + RollupOrders constant ROLLUP_ORDERS = RollupOrders(0x000000000000007369676E65742D6f7264657273); + + /// USDC token for the Parmigiana testnet host chain. + address constant HOST_USDC = 0x65Fb255585458De1F9A246b476aa8d5C5516F6fd; + /// USDT token for the Parmigiana testnet host chain. + address constant HOST_USDT = 0xb9Df1b911B6cf6935b2a918Ba03dF2372E94e267; + /// WBTC token for the Parmigiana testnet host chain. + address constant HOST_WBTC = 0xfb29F7d7a4CE607D6038d44150315e5F69BEa08A; + /// WETH token for the Parmigiana testnet host chain. + address constant HOST_WETH = 0xD1278f17e86071f1E658B656084c65b7FD3c90eF; + + /// @notice WETH token address for the Parmigiana testnet. + IERC20 constant WETH = IERC20(0x0000000000000000007369676e65742d77657468); + /// @notice WBTC token address for the Parmigiana testnet. + IERC20 constant WBTC = IERC20(0x0000000000000000007369676e65742D77627463); + /// @notice WUSD token address for the Parmigiana testnet. + IERC20 constant WUSD = IERC20(0x0000000000000000007369676e65742D77757364); +} diff --git a/src/chains/Pecorino.sol b/src/chains/Pecorino.sol deleted file mode 100644 index 146f3b5..0000000 --- a/src/chains/Pecorino.sol +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {RollupOrders} from "zenith/src/orders/RollupOrders.sol"; -import {RollupPassage} from "zenith/src/passage/RollupPassage.sol"; -import {HostOrders} from "zenith/src/orders/HostOrders.sol"; -import {Passage} from "zenith/src/passage/Passage.sol"; -import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; - -/// @title PecorinoConstants -/// @author init4 -/// @notice Constants for the Pecorino testnet. -/// @dev These constants are used to configure the SignetStd contract in its -/// constructor, if the chain ID matches the Pecorino testnet chain ID. -library PecorinoConstants { - /// @notice The Pecorino host chain ID. - uint32 constant HOST_CHAIN_ID = 3151908; - /// @notice The Pecorino Rollup chain ID. - uint32 constant ROLLUP_CHAIN_ID = 14174; - - /// @notice The Passage contract for the Pecorino testnet host chain. - Passage constant HOST_PASSAGE = Passage(payable(0x12585352AA1057443D6163B539EfD4487f023182)); - - /// @notice The HostOrders contract for the Pecorino testnet host chain. - HostOrders constant HOST_ORDERS = HostOrders(0x0A4f505364De0Aa46c66b15aBae44eBa12ab0380); - - /// @notice The Rollup Passage contract for the Pecorino testnet. - RollupPassage constant ROLLUP_PASSAGE = RollupPassage(payable(0x0000000000007369676E65742D70617373616765)); - - /// @notice The Rollup Orders contract for the Pecorino testnet. - RollupOrders constant ROLLUP_ORDERS = RollupOrders(0x000000000000007369676E65742D6f7264657273); - - /// USDC token for the Pecorino testnet host chain. - address constant HOST_USDC = 0x65Fb255585458De1F9A246b476aa8d5C5516F6fd; - /// USDT token for the Pecorino testnet host chain. - address constant HOST_USDT = 0xb9Df1b911B6cf6935b2a918Ba03dF2372E94e267; - /// WBTC token for the Pecorino testnet host chain. - address constant HOST_WBTC = 0xfb29F7d7a4CE607D6038d44150315e5F69BEa08A; - /// WETH token for the Pecorino testnet host chain. - address constant HOST_WETH = 0xd03d085B78067A18155d3B29D64914df3D19A53C; - - /// @notice WETH token address for the Pecorino testnet. - IERC20 constant WETH = IERC20(0x0000000000000000007369676e65742d77657468); - /// @notice WBTC token address for the Pecorino testnet. - IERC20 constant WBTC = IERC20(0x0000000000000000007369676e65742D77627463); - /// @notice WUSD token address for the Pecorino testnet. - IERC20 constant WUSD = IERC20(0x0000000000000000007369676e65742D77757364); -} diff --git a/src/l1/Signet.sol b/src/l1/Signet.sol index 5377d5e..1a31862 100644 --- a/src/l1/Signet.sol +++ b/src/l1/Signet.sol @@ -7,8 +7,8 @@ import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {IWETH} from "../interfaces/IWETH.sol"; +import {ParmigianaConstants} from "../chains/Parmigiana.sol"; import {AddressAliasHelper} from "../vendor/AddressAliasHelper.sol"; -import {PecorinoConstants} from "../chains/Pecorino.sol"; abstract contract SignetL1 { using SafeERC20 for IERC20; @@ -16,6 +16,9 @@ abstract contract SignetL1 { /// @notice Sentinel value for the native asset in order inputs/outputs address constant NATIVE_ASSET = address(0); + /// @notice The chain ID of the host network. + uint256 immutable HOST_CHAIN_ID; + /// @notice The Passage address Passage internal immutable PASSAGE; /// @notice The Host Orders address @@ -41,18 +44,21 @@ abstract contract SignetL1 { error UnsupportedChain(uint256); constructor() { - if (block.chainid == PecorinoConstants.HOST_CHAIN_ID) { - PASSAGE = PecorinoConstants.HOST_PASSAGE; - ORDERS = PecorinoConstants.HOST_ORDERS; - - WETH = IWETH(PecorinoConstants.HOST_WETH); - WBTC = IERC20(PecorinoConstants.HOST_WBTC); - USDC = IERC20(PecorinoConstants.HOST_USDC); - USDT = IERC20(PecorinoConstants.HOST_USDT); - - RU_WUSD = address(PecorinoConstants.WUSD); - RU_WBTC = address(PecorinoConstants.WBTC); - RU_WETH = address(PecorinoConstants.WETH); + uint256 chainId = block.chainid; + if (chainId == ParmigianaConstants.HOST_CHAIN_ID) { + HOST_CHAIN_ID = ParmigianaConstants.HOST_CHAIN_ID; + + PASSAGE = ParmigianaConstants.HOST_PASSAGE; + ORDERS = ParmigianaConstants.HOST_ORDERS; + + WETH = IWETH(ParmigianaConstants.HOST_WETH); + WBTC = IERC20(ParmigianaConstants.HOST_WBTC); + USDC = IERC20(ParmigianaConstants.HOST_USDC); + USDT = IERC20(ParmigianaConstants.HOST_USDT); + + RU_WUSD = address(ParmigianaConstants.WUSD); + RU_WBTC = address(ParmigianaConstants.WBTC); + RU_WETH = address(ParmigianaConstants.WETH); } else { revert UnsupportedChain(block.chainid); } @@ -82,13 +88,14 @@ abstract contract SignetL1 { /// @notice Helper to create an output struct. function makeOutput(address token, uint256 amount, address recipient) internal - pure + view returns (HostOrders.Output memory output) { output.token = token; output.amount = amount; output.recipient = recipient; - output.chainId = PecorinoConstants.HOST_CHAIN_ID; + // forge-lint: disable-next-line(unsafe-typecast) + output.chainId = uint32(HOST_CHAIN_ID); } /// @notice Helper to create an Output struct for usdc. @@ -112,7 +119,7 @@ abstract contract SignetL1 { } /// @notice Helper to create an Output struct for eth. - function ethOutput(uint256 amount, address recipient) internal pure returns (HostOrders.Output memory output) { + function ethOutput(uint256 amount, address recipient) internal view returns (HostOrders.Output memory output) { return makeOutput(NATIVE_ASSET, amount, recipient); } diff --git a/src/l2/Signet.sol b/src/l2/Signet.sol index 4912c82..edafa2f 100644 --- a/src/l2/Signet.sol +++ b/src/l2/Signet.sol @@ -5,7 +5,7 @@ import {RollupOrders} from "zenith/src/orders/RollupOrders.sol"; import {RollupPassage} from "zenith/src/passage/RollupPassage.sol"; import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; -import {PecorinoConstants} from "../chains/Pecorino.sol"; +import {ParmigianaConstants} from "../chains/Parmigiana.sol"; import {AddressAliasHelper} from "../vendor/AddressAliasHelper.sol"; contract SignetL2 { @@ -47,22 +47,22 @@ contract SignetL2 { constructor() { // Auto-configure based on the chain ID. - if (block.chainid == PecorinoConstants.ROLLUP_CHAIN_ID) { - HOST_CHAIN_ID = PecorinoConstants.HOST_CHAIN_ID; + if (block.chainid == ParmigianaConstants.ROLLUP_CHAIN_ID) { + HOST_CHAIN_ID = ParmigianaConstants.HOST_CHAIN_ID; - HOST_PASSAGE = address(PecorinoConstants.HOST_PASSAGE); + HOST_PASSAGE = address(ParmigianaConstants.HOST_PASSAGE); - PASSAGE = PecorinoConstants.ROLLUP_PASSAGE; - ORDERS = PecorinoConstants.ROLLUP_ORDERS; + PASSAGE = ParmigianaConstants.ROLLUP_PASSAGE; + ORDERS = ParmigianaConstants.ROLLUP_ORDERS; - WETH = PecorinoConstants.WETH; - WBTC = PecorinoConstants.WBTC; - WUSD = PecorinoConstants.WUSD; + WETH = ParmigianaConstants.WETH; + WBTC = ParmigianaConstants.WBTC; + WUSD = ParmigianaConstants.WUSD; - HOST_USDC = PecorinoConstants.HOST_USDC; - HOST_USDT = PecorinoConstants.HOST_USDT; - HOST_WBTC = PecorinoConstants.HOST_WBTC; - HOST_WETH = PecorinoConstants.HOST_WETH; + HOST_USDC = ParmigianaConstants.HOST_USDC; + HOST_USDT = ParmigianaConstants.HOST_USDT; + HOST_WBTC = ParmigianaConstants.HOST_WBTC; + HOST_WETH = ParmigianaConstants.HOST_WETH; } else { revert UnsupportedChain(block.chainid); } diff --git a/test/Base.sol b/test/Base.sol index a99f53d..a0a3cdb 100644 --- a/test/Base.sol +++ b/test/Base.sol @@ -3,11 +3,11 @@ pragma solidity ^0.8.13; import {Test} from "forge-std/Test.sol"; -import {PecorinoConstants} from "../src/chains/Pecorino.sol"; +import {ParmigianaConstants} from "../src/chains/Parmigiana.sol"; -contract PecorinoTest is Test { +contract ParmigianaTest is Test { constructor() { - vm.chainId(PecorinoConstants.ROLLUP_CHAIN_ID); + vm.chainId(ParmigianaConstants.ROLLUP_CHAIN_ID); } } diff --git a/test/SelfOwned.sol b/test/SelfOwned.sol index 36fe046..03f5dbd 100644 --- a/test/SelfOwned.sol +++ b/test/SelfOwned.sol @@ -3,8 +3,7 @@ pragma solidity ^0.8.13; import {SimpleERC20} from "simple-erc20/SimpleERC20.sol"; -import {PecorinoTest} from "./Base.sol"; - +import {ParmigianaTest} from "./Base.sol"; import {SignetL2} from "../src/l2/Signet.sol"; import {SelfOwned} from "../src/l2/SelfOwned.sol"; import {AddressAliasHelper} from "../src/vendor/AddressAliasHelper.sol"; @@ -19,7 +18,7 @@ contract SelfOwnedToken is SignetL2, SimpleERC20 { } } -contract TestSelfOwned is PecorinoTest { +contract TestSelfOwned is ParmigianaTest { SelfOwnedToken token; SelfOwnedNothing nothing;