Skip to content

Commit faaf6e1

Browse files
committed
chore(solana/base): re-integrate Solana and Base bridge
1 parent 92bcb09 commit faaf6e1

File tree

26 files changed

+1161
-1021
lines changed

26 files changed

+1161
-1021
lines changed

base/script/Deploy.s.sol

Lines changed: 109 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,109 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.28;
3-
4-
import {Script} from "forge-std/Script.sol";
5-
import {console} from "forge-std/console.sol";
6-
7-
import {ERC1967Factory} from "solady/utils/ERC1967Factory.sol";
8-
import {ERC1967FactoryConstants} from "solady/utils/ERC1967FactoryConstants.sol";
9-
10-
import {CrossChainERC20Factory} from "../src/CrossChainERC20Factory.sol";
11-
import {CrossChainMessenger} from "../src/CrossChainMessenger.sol";
12-
import {MessagePasser} from "../src/MessagePasser.sol";
13-
import {TokenBridge} from "../src/TokenBridge.sol";
14-
15-
contract DeployScript is Script {
16-
address public constant PROXY_ADMIN = 0x0fe884546476dDd290eC46318785046ef68a0BA9;
17-
18-
bytes32 public constant ORACLE = 0x0000000000000000000000000e9a877906EBc3b7098DA2404412BF0Ed1A5EFb4;
19-
bytes32 public constant REMOTE_MESSENGER = 0x7e273983f136714ba93a740a050279b541d6f25ebc6bbc6fc67616d0d5529cea;
20-
bytes32 public constant OTHER_BRIDGE = 0x7a25452c36304317d6fe970091c383b0d45e9b0b06485d2561156f025c6936af;
21-
22-
function setUp() public {
23-
vm.label(PROXY_ADMIN, "PROXY_ADMIN");
24-
vm.label(ERC1967FactoryConstants.ADDRESS, "ERC1967_FACTORY");
25-
}
26-
27-
function run() public {
28-
Chain memory chain = getChain(block.chainid);
29-
console.log("Deploying on chain: %s", chain.name);
30-
31-
vm.startBroadcast();
32-
address messagePasser = _deployMessagePasser();
33-
address messenger = _deployMessenger(messagePasser);
34-
address bridge = _deployBridge(messenger);
35-
address factory = _deployFactory(bridge);
36-
vm.stopBroadcast();
37-
38-
console.log("Deployed MessagePasser at: %s", messagePasser);
39-
console.log("Deployed CrossChainMessenger at: %s", messenger);
40-
console.log("Deployed TokenBridge at: %s", bridge);
41-
console.log("Deployed CrossChainERC20Factory at: %s", factory);
42-
43-
string memory out = "{";
44-
out = _record(out, "MessagePasser", messagePasser, false);
45-
out = _record(out, "CrossChainMessenger", messenger, false);
46-
out = _record(out, "TokenBridge", bridge, false);
47-
out = _record(out, "CrossChainERC20Factory", factory, true);
48-
out = string.concat(out, "}");
49-
50-
vm.createDir("deployments", true);
51-
vm.writeFile(string.concat("deployments/", chain.chainAlias, ".json"), out);
52-
}
53-
54-
function _deployMessagePasser() private returns (address) {
55-
MessagePasser messagePasser = new MessagePasser();
56-
return address(messagePasser);
57-
}
58-
59-
function _deployMessenger(address messagePasser) private returns (address) {
60-
CrossChainMessenger messengerImpl = new CrossChainMessenger(messagePasser, REMOTE_MESSENGER);
61-
CrossChainMessenger messengerProxy = CrossChainMessenger(
62-
ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({
63-
implementation: address(messengerImpl),
64-
admin: PROXY_ADMIN,
65-
data: abi.encodeCall(CrossChainMessenger.initialize, (ORACLE))
66-
})
67-
);
68-
69-
return address(messengerProxy);
70-
}
71-
72-
function _deployBridge(address messenger) private returns (address) {
73-
TokenBridge bridgeImpl = new TokenBridge();
74-
TokenBridge bridgeProxy = TokenBridge(
75-
ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({
76-
implementation: address(bridgeImpl),
77-
admin: PROXY_ADMIN,
78-
data: abi.encodeCall(TokenBridge.initialize, (messenger, OTHER_BRIDGE))
79-
})
80-
);
81-
82-
return address(bridgeProxy);
83-
}
84-
85-
function _deployFactory(address bridge) private returns (address) {
86-
CrossChainERC20Factory xChainERC20FactoryImpl = new CrossChainERC20Factory();
87-
CrossChainERC20Factory xChainERC20Factory = CrossChainERC20Factory(
88-
ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({
89-
implementation: address(xChainERC20FactoryImpl),
90-
admin: PROXY_ADMIN,
91-
data: abi.encodeCall(CrossChainERC20Factory.initialize, (bridge))
92-
})
93-
);
94-
95-
return address(xChainERC20Factory);
96-
}
97-
98-
function _record(string memory out, string memory key, address addr, bool isLast)
99-
private
100-
pure
101-
returns (string memory)
102-
{
103-
return string.concat(out, "\"", key, "\": \"", vm.toString(addr), isLast ? "\"" : "\",");
104-
}
105-
106-
function _addressToBytes32(address value) private pure returns (bytes32) {
107-
return bytes32(uint256(uint160(value)));
108-
}
109-
}
1+
// // SPDX-License-Identifier: MIT
2+
// pragma solidity 0.8.28;
3+
4+
// import {Script} from "forge-std/Script.sol";
5+
// import {console} from "forge-std/console.sol";
6+
7+
// import {ERC1967Factory} from "solady/utils/ERC1967Factory.sol";
8+
// import {ERC1967FactoryConstants} from "solady/utils/ERC1967FactoryConstants.sol";
9+
10+
// import {CrossChainERC20Factory} from "../src/CrossChainERC20Factory.sol";
11+
// import {CrossChainMessenger} from "../src/CrossChainMessenger.sol";
12+
// import {MessagePasser} from "../src/MessagePasser.sol";
13+
// import {TokenBridge} from "../src/TokenBridge.sol";
14+
15+
// contract DeployScript is Script {
16+
// address public constant PROXY_ADMIN = 0x0fe884546476dDd290eC46318785046ef68a0BA9;
17+
18+
// bytes32 public constant ORACLE = 0x0000000000000000000000000e9a877906EBc3b7098DA2404412BF0Ed1A5EFb4;
19+
// bytes32 public constant REMOTE_MESSENGER = 0x7e273983f136714ba93a740a050279b541d6f25ebc6bbc6fc67616d0d5529cea;
20+
// bytes32 public constant OTHER_BRIDGE = 0x7a25452c36304317d6fe970091c383b0d45e9b0b06485d2561156f025c6936af;
21+
22+
// function setUp() public {
23+
// vm.label(PROXY_ADMIN, "PROXY_ADMIN");
24+
// vm.label(ERC1967FactoryConstants.ADDRESS, "ERC1967_FACTORY");
25+
// }
26+
27+
// function run() public {
28+
// Chain memory chain = getChain(block.chainid);
29+
// console.log("Deploying on chain: %s", chain.name);
30+
31+
// vm.startBroadcast();
32+
// address messagePasser = _deployMessagePasser();
33+
// address messenger = _deployMessenger(messagePasser);
34+
// address bridge = _deployBridge(messenger);
35+
// address factory = _deployFactory(bridge);
36+
// vm.stopBroadcast();
37+
38+
// console.log("Deployed MessagePasser at: %s", messagePasser);
39+
// console.log("Deployed CrossChainMessenger at: %s", messenger);
40+
// console.log("Deployed TokenBridge at: %s", bridge);
41+
// console.log("Deployed CrossChainERC20Factory at: %s", factory);
42+
43+
// string memory out = "{";
44+
// out = _record(out, "MessagePasser", messagePasser, false);
45+
// out = _record(out, "CrossChainMessenger", messenger, false);
46+
// out = _record(out, "TokenBridge", bridge, false);
47+
// out = _record(out, "CrossChainERC20Factory", factory, true);
48+
// out = string.concat(out, "}");
49+
50+
// vm.createDir("deployments", true);
51+
// vm.writeFile(string.concat("deployments/", chain.chainAlias, ".json"), out);
52+
// }
53+
54+
// function _deployMessagePasser() private returns (address) {
55+
// MessagePasser messagePasser = new MessagePasser();
56+
// return address(messagePasser);
57+
// }
58+
59+
// function _deployMessenger(address messagePasser) private returns (address) {
60+
// CrossChainMessenger messengerImpl = new CrossChainMessenger(messagePasser, REMOTE_MESSENGER);
61+
// CrossChainMessenger messengerProxy = CrossChainMessenger(
62+
// ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({
63+
// implementation: address(messengerImpl),
64+
// admin: PROXY_ADMIN,
65+
// data: abi.encodeCall(CrossChainMessenger.initialize, (ORACLE))
66+
// })
67+
// );
68+
69+
// return address(messengerProxy);
70+
// }
71+
72+
// function _deployBridge(address messenger) private returns (address) {
73+
// TokenBridge bridgeImpl = new TokenBridge();
74+
// TokenBridge bridgeProxy = TokenBridge(
75+
// ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({
76+
// implementation: address(bridgeImpl),
77+
// admin: PROXY_ADMIN,
78+
// data: abi.encodeCall(TokenBridge.initialize, (messenger, OTHER_BRIDGE))
79+
// })
80+
// );
81+
82+
// return address(bridgeProxy);
83+
// }
84+
85+
// function _deployFactory(address bridge) private returns (address) {
86+
// CrossChainERC20Factory xChainERC20FactoryImpl = new CrossChainERC20Factory();
87+
// CrossChainERC20Factory xChainERC20Factory = CrossChainERC20Factory(
88+
// ERC1967Factory(ERC1967FactoryConstants.ADDRESS).deployAndCall({
89+
// implementation: address(xChainERC20FactoryImpl),
90+
// admin: PROXY_ADMIN,
91+
// data: abi.encodeCall(CrossChainERC20Factory.initialize, (bridge))
92+
// })
93+
// );
94+
95+
// return address(xChainERC20Factory);
96+
// }
97+
98+
// function _record(string memory out, string memory key, address addr, bool isLast)
99+
// private
100+
// pure
101+
// returns (string memory)
102+
// {
103+
// return string.concat(out, "\"", key, "\": \"", vm.toString(addr), isLast ? "\"" : "\",");
104+
// }
105+
106+
// function _addressToBytes32(address value) private pure returns (bytes32) {
107+
// return bytes32(uint256(uint160(value)));
108+
// }
109+
// }
Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.28;
3-
4-
import {Script} from "forge-std/Script.sol";
5-
import {stdJson} from "forge-std/StdJson.sol";
6-
import {console} from "forge-std/console.sol";
7-
import {ERC20} from "solady/tokens/ERC20.sol";
8-
9-
import {TokenBridge} from "../../src/TokenBridge.sol";
10-
11-
contract BridgeTokensToSolanaScript is Script {
12-
using stdJson for string;
13-
14-
address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
15-
16-
address public immutable LOCAL_TOKEN = vm.envAddress("LOCAL_TOKEN");
17-
bytes32 public immutable REMOTE_TOKEN = vm.envBytes32("REMOTE_TOKEN");
18-
bytes32 public immutable TO = vm.envBytes32("TO");
19-
uint64 public immutable AMOUNT = uint64(vm.envUint("AMOUNT"));
20-
bytes public extraData = bytes("Dummy extra data");
21-
22-
TokenBridge public bridge;
23-
24-
function setUp() public {
25-
Chain memory chain = getChain(block.chainid);
26-
console.log("Creating token on chain: %s", chain.name);
27-
28-
string memory rootPath = vm.projectRoot();
29-
string memory path = string.concat(rootPath, "/deployments/", chain.chainAlias, ".json");
30-
address bridgeAddress = vm.readFile(path).readAddress(".TokenBridge");
31-
bridge = TokenBridge(bridgeAddress);
32-
}
33-
34-
function run() public payable {
35-
vm.startBroadcast();
36-
if (vm.envOr("NEEDS_APPROVAL", false)) {
37-
ERC20(LOCAL_TOKEN).approve(address(bridge), AMOUNT);
38-
}
39-
uint256 value = LOCAL_TOKEN == ETH_ADDRESS ? AMOUNT : 0;
40-
bridge.bridgeToken{value: value}(LOCAL_TOKEN, REMOTE_TOKEN, TO, AMOUNT, extraData);
41-
vm.stopBroadcast();
42-
}
43-
}
1+
// // SPDX-License-Identifier: MIT
2+
// pragma solidity 0.8.28;
3+
4+
// import {Script} from "forge-std/Script.sol";
5+
// import {stdJson} from "forge-std/StdJson.sol";
6+
// import {console} from "forge-std/console.sol";
7+
// import {ERC20} from "solady/tokens/ERC20.sol";
8+
9+
// import {TokenBridge} from "../../src/TokenBridge.sol";
10+
11+
// contract BridgeTokensToSolanaScript is Script {
12+
// using stdJson for string;
13+
14+
// address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
15+
16+
// address public immutable LOCAL_TOKEN = vm.envAddress("LOCAL_TOKEN");
17+
// bytes32 public immutable REMOTE_TOKEN = vm.envBytes32("REMOTE_TOKEN");
18+
// bytes32 public immutable TO = vm.envBytes32("TO");
19+
// uint64 public immutable AMOUNT = uint64(vm.envUint("AMOUNT"));
20+
// bytes public extraData = bytes("Dummy extra data");
21+
22+
// TokenBridge public bridge;
23+
24+
// function setUp() public {
25+
// Chain memory chain = getChain(block.chainid);
26+
// console.log("Creating token on chain: %s", chain.name);
27+
28+
// string memory rootPath = vm.projectRoot();
29+
// string memory path = string.concat(rootPath, "/deployments/", chain.chainAlias, ".json");
30+
// address bridgeAddress = vm.readFile(path).readAddress(".TokenBridge");
31+
// bridge = TokenBridge(bridgeAddress);
32+
// }
33+
34+
// function run() public payable {
35+
// vm.startBroadcast();
36+
// if (vm.envOr("NEEDS_APPROVAL", false)) {
37+
// ERC20(LOCAL_TOKEN).approve(address(bridge), AMOUNT);
38+
// }
39+
// uint256 value = LOCAL_TOKEN == ETH_ADDRESS ? AMOUNT : 0;
40+
// bridge.bridgeToken{value: value}(LOCAL_TOKEN, REMOTE_TOKEN, TO, AMOUNT, extraData);
41+
// vm.stopBroadcast();
42+
// }
43+
// }

base/src/CrossChainERC20Factory.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ contract CrossChainERC20Factory is Initializable {
7575
/// Emits CrossChainERC20Created event upon successful deployment.
7676
///
7777
/// @param remoteToken The 32-byte identifier of the corresponding token on the remote chain
78-
/// @param name The human-readable name of the token (e.g., "My Token")
79-
/// @param symbol The symbol of the token (e.g., "MTK")
80-
/// @param decimals The number of decimal places the token uses
78+
/// @param name The human-readable name of the token (e.g., "My Token")
79+
/// @param symbol The symbol of the token (e.g., "MTK")
80+
/// @param decimals The number of decimal places the token uses
8181
///
8282
/// @return crossChainERC20 The address of the newly deployed CrossChainERC20 contract
8383
function deploy(bytes32 remoteToken, string memory name, string memory symbol, uint8 decimals)

0 commit comments

Comments
 (0)