Skip to content

Commit 3a4cc1e

Browse files
committed
feat: update deployment scripts to return proxy addresses and add mint function in RLCOFT
1 parent 707da40 commit 3a4cc1e

File tree

6 files changed

+159
-6
lines changed

6 files changed

+159
-6
lines changed

lib/createx

Submodule createx added at cbac803

script/RLCAdapter.s.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {EnvUtils} from "./UpdateEnvUtils.sol";
1010
import {ICreateX} from "@createx/contracts/ICreateX.sol";
1111

1212
contract Deploy is Script {
13-
function run() external {
13+
function run() external returns (address) {
1414
vm.startBroadcast();
1515

1616
address rlcToken = vm.envAddress("RLC_SEPOLIA_ADDRESS"); // RLC token address on sepolia testnet
@@ -29,11 +29,12 @@ contract Deploy is Script {
2929
abi.encodeWithSelector(rlcAdapterImplementation.initialize.selector, ownerAddress), // data for initialize
3030
ICreateX.Values({constructorAmount: 0, initCallAmount: 0}) // values for CreateX
3131
);
32-
console.log("RLCAdapter proxy deployed at:", address(rlcAdapterProxy));
32+
console.log("RLCAdapter proxy deployed at:", rlcAdapterProxy);
3333

3434
vm.stopBroadcast();
3535

36-
EnvUtils.updateEnvVariable("RLC_SEPOLIA_ADAPTER_ADDRESS", address(rlcAdapterProxy));
36+
EnvUtils.updateEnvVariable("RLC_SEPOLIA_ADAPTER_ADDRESS", rlcAdapterProxy);
37+
return rlcAdapterProxy;
3738
}
3839
}
3940

script/RLCOFT.s.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.s
1010
import {ICreateX} from "@createx/contracts/ICreateX.sol";
1111

1212
contract Deploy is Script {
13-
function run() external {
13+
function run() external returns (address) {
1414
vm.startBroadcast();
1515

1616
string memory name = vm.envString("RLC_OFT_TOKEN_NAME");
@@ -34,6 +34,7 @@ contract Deploy is Script {
3434
vm.stopBroadcast();
3535

3636
EnvUtils.updateEnvVariable("RLC_ARBITRUM_SEPOLIA_OFT_ADDRESS", rlcOFTProxy);
37+
return rlcOFTProxy;
3738
}
3839
}
3940

src/RLCOFT.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ contract RLCOFT is OFTUpgradeable, UUPSUpgradeable, AccessControlDefaultAdminRul
4646
return 9;
4747
}
4848

49-
function burn(uint256 _value) external returns (bool) {
49+
function mint(address to, uint256 amount) external onlyRole(BRIDGE_ROLE) {
50+
_mint(to, amount);
51+
}
52+
53+
function burn(uint256 _value) external onlyRole(BRIDGE_ROLE) {
5054
_burn(msg.sender, _value);
51-
return true;
5255
}
5356

5457
function owner()

test/invariant/RLCAdapter.t.sol

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.22;
3+
4+
import {Test, console} from "forge-std/Test.sol";
5+
import {Deploy as RLCOFTDeploy} from "../../script/RLCOFT.s.sol";
6+
import {RLCOFT} from "../../src/RLCOFT.sol";
7+
import {ITokenSpender} from "../../src/ITokenSpender.sol";
8+
9+
contract RLCOFTTest is Test {
10+
RLCOFT public rlcOft;
11+
12+
address public owner;
13+
address public bridge;
14+
address public pauser;
15+
address public user1;
16+
address public user2;
17+
18+
// Events to test
19+
event Paused(address account);
20+
event Unpaused(address account);
21+
event Transfer(address indexed from, address indexed to, uint256 value);
22+
23+
// Custom errors from OpenZeppelin
24+
error EnforcedPause();
25+
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
26+
27+
function setUp() public {
28+
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC_URL"));
29+
30+
// Create addresses using makeAddr
31+
owner = makeAddr("owner");
32+
bridge = makeAddr("bridge");
33+
pauser = makeAddr("pauser");
34+
user1 = makeAddr("user1");
35+
user2 = makeAddr("user2");
36+
37+
// Set up environment variables for the deployment
38+
vm.setEnv("RLC_OFT_TOKEN_NAME", "RLC OFT Test");
39+
vm.setEnv("RLC_TOKEN_SYMBOL", "RLCT");
40+
vm.setEnv("LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS", "0x6EDCE65403992e310A62460808c4b910D972f10f");
41+
vm.setEnv("OWNER_ADDRESS", vm.toString(owner));
42+
vm.setEnv("PAUSER_ADDRESS", vm.toString(pauser));
43+
44+
// Deploy the contract using the deployment script
45+
rlcOft = RLCOFT(new RLCOFTDeploy().run());
46+
47+
vm.startPrank(owner); // We can't use vm.prank here as the first call will be rlcOft.BRIDGE_ROLE() before doing the grantRole
48+
rlcOft.grantRole(rlcOft.BRIDGE_ROLE(), bridge);
49+
vm.stopPrank();
50+
51+
vm.startPrank(bridge);
52+
rlcOft.mint(user1, 1000 * 10 ** 9);
53+
rlcOft.mint(user2, 500 * 10 ** 9);
54+
vm.stopPrank();
55+
}
56+
57+
// ============ Deployment Tests ============
58+
function testDeployment() public {
59+
60+
}
61+
62+
}

test/invariant/RLCOFT.t.sol

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.22;
3+
4+
import {Test, console} from "forge-std/Test.sol";
5+
import {Deploy as RLCOFTDeploy} from "../../script/RLCOFT.s.sol";
6+
import {RLCOFT} from "../../src/RLCOFT.sol";
7+
import {ITokenSpender} from "../../src/ITokenSpender.sol";
8+
import {ICreateX} from "@createx/contracts/ICreateX.sol";
9+
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
10+
11+
contract RLCOFTTest is Test {
12+
RLCOFT public rlcOft;
13+
14+
address public owner;
15+
address public bridge;
16+
address public pauser;
17+
address public user1;
18+
address public user2;
19+
20+
// CreateX factory address (should be the same across networks)
21+
address constant CREATEX_FACTORY = 0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed;
22+
23+
// Events to test
24+
event Paused(address account);
25+
event Unpaused(address account);
26+
event Transfer(address indexed from, address indexed to, uint256 value);
27+
28+
// Custom errors from OpenZeppelin
29+
error EnforcedPause();
30+
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
31+
32+
function setUp() public {
33+
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC_URL"));
34+
35+
// Create addresses using makeAddr
36+
owner = makeAddr("owner");
37+
bridge = makeAddr("bridge");
38+
pauser = makeAddr("pauser");
39+
user1 = makeAddr("user1");
40+
user2 = makeAddr("user2");
41+
42+
// Set up environment variables for the deployment
43+
vm.setEnv("RLC_OFT_TOKEN_NAME", "RLC OFT Test");
44+
vm.setEnv("RLC_TOKEN_SYMBOL", "RLCT");
45+
vm.setEnv("LAYER_ZERO_ARBITRUM_SEPOLIA_ENDPOINT_ADDRESS", "0x6EDCE65403992e310A62460808c4b910D972f10f");
46+
vm.setEnv("OWNER_ADDRESS", vm.toString(owner));
47+
vm.setEnv("PAUSER_ADDRESS", vm.toString(pauser));
48+
vm.setEnv("CREATE_X_FACTORY_ADDRESS", vm.toString(CREATEX_FACTORY));
49+
vm.setEnv("SALT", vm.toString(bytes32("test_salt_123")));
50+
}
51+
52+
// ============ Deployment Tests ============
53+
function testDeployment() public {
54+
// Basic deployment verification
55+
assertEq(rlcOft.name(), "RLC OFT Test");
56+
assertEq(rlcOft.symbol(), "RLCT");
57+
assertEq(rlcOft.decimals(), 9);
58+
59+
assertTrue(rlcOft.hasRole(rlcOft.DEFAULT_ADMIN_ROLE(), owner));
60+
}
61+
62+
function testMultipleDeterministicDeployments() public {
63+
// Test that different salts produce different addresses
64+
bytes32 salt1 = bytes32("salt_1");
65+
bytes32 salt2 = bytes32("salt_2");
66+
67+
address address1 = new RLCOFTDeploy().run();
68+
address address2 = new RLCOFTDeploy().run();
69+
70+
assertTrue(address1 != address2, "Different salts should produce different addresses");
71+
console.log("Address with salt1:", address1);
72+
console.log("Address with salt2:", address2);
73+
}
74+
75+
function testRedeploymentWithSameSalt() public {
76+
// Deploy implementation
77+
address deployedAddress = new RLCOFTDeploy().run();
78+
79+
assertTrue(deployedAddress != address(0), "First deployment should succeed");
80+
81+
// Second deployment with same salt should fail
82+
vm.expectRevert();
83+
new RLCOFTDeploy().run();
84+
}
85+
}

0 commit comments

Comments
 (0)