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(evm): contract verification including proxies #3392

Merged
merged 1 commit into from
Dec 19, 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
6 changes: 3 additions & 3 deletions evm/evm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ _: {
cp --no-preserve=mode -r ${self'.packages.evm-contracts}/* .
cp --no-preserve=mode -r ${evmSources}/* .

jq -r 'to_entries | map([.key, .value]) | .[] | @tsv' "$PROJECT_ROOT"/contracts.json | \
while IFS=$'\t' read -r contract address; do
jq -r 'to_entries | map([.key, .value.args, .value.contract]) | .[] | @tsv' "$PROJECT_ROOT"/contracts.json | \
while IFS=$'\t' read -r address args contract; do
PRIVATE_KEY=${private-key} \
FOUNDRY_PROFILE="script" \
forge verify-contract --force --watch "$address" "$contract" --api-key "$3" \
forge verify-contract --force --watch "$address" "$contract" --constructor-args "$args" --api-key "$3" \
--rpc-url ${rpc-url}
done

Expand Down
151 changes: 135 additions & 16 deletions evm/scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ abstract contract UnionScript is UnionBase {
Protocols.make(Protocols.UCS02),
abi.encode(
address(new UCS02NFT()),
abi.encodeCall(UCS01Relay.initialize, (handler, owner))
abi.encodeCall(UCS02NFT.initialize, (handler, owner))
)
)
);
Expand Down Expand Up @@ -328,13 +328,17 @@ contract GetDeployed is Script {
}

function run() public {
address multicall = getDeployed(LIB.make(LIB.MULTICALL));
address handler = getDeployed(IBC.BASED);
address cometblsClient =
getDeployed(LightClients.make(LightClients.COMETBLS));
address ucs00 = getDeployed(Protocols.make(Protocols.UCS00));
address ucs01 = getDeployed(Protocols.make(Protocols.UCS01));
address ucs02 = getDeployed(Protocols.make(Protocols.UCS02));

console.log(
string(abi.encodePacked("Multicall: ", multicall.toHexString()))
);
console.log(
string(abi.encodePacked("IBCHandler: ", handler.toHexString()))
);
Expand All @@ -349,26 +353,141 @@ contract GetDeployed is Script {
console.log(string(abi.encodePacked("UCS01: ", ucs01.toHexString())));
console.log(string(abi.encodePacked("UCS02: ", ucs02.toHexString())));

string memory json = "";
json.serialize(
"contracts/core/OwnableIBCHandler.sol:OwnableIBCHandler",
implOf(handler)
string memory impls = "base";

string memory proxyHandler = "proxyHandler";
proxyHandler.serialize(
"contract",
string(
"libs/@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
)
);
proxyHandler = proxyHandler.serialize(
"args",
abi.encode(
implOf(handler), abi.encodeCall(IBCHandler.initialize, sender)
)
);
impls.serialize(handler.toHexString(), proxyHandler);

string memory proxyComet = "proxyComet";
proxyComet.serialize(
"contract",
string(
"libs/@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
)
);
proxyComet = proxyComet.serialize(
"args",
abi.encode(
implOf(cometblsClient),
abi.encodeCall(CometblsClient.initialize, (handler, sender))
)
);
impls.serialize(cometblsClient.toHexString(), proxyComet);

string memory proxyUCS00 = "proxyUCS00";
proxyUCS00.serialize(
"contract",
string(
"libs/@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
)
);
proxyUCS00 = proxyUCS00.serialize(
"args",
abi.encode(
implOf(ucs00),
abi.encodeCall(
PingPong.initialize,
(IIBCPacket(handler), sender, 100000000000000)
)
)
);
impls.serialize(ucs00.toHexString(), proxyUCS00);

string memory proxyUCS01 = "proxyUCS01";
proxyUCS01.serialize(
"contract",
string(
"libs/@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
)
);
proxyUCS01 = proxyUCS01.serialize(
"args",
abi.encode(
implOf(ucs01),
abi.encodeCall(
UCS01Relay.initialize, (IIBCPacket(handler), sender)
)
)
);
impls.serialize(ucs01.toHexString(), proxyUCS01);

string memory proxyUCS02 = "proxyUCS02";
proxyUCS02.serialize(
"contract",
string(
"libs/@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy"
)
);
proxyUCS02 = proxyUCS02.serialize(
"args",
abi.encode(
implOf(ucs02),
abi.encodeCall(
UCS02NFT.initialize, (IIBCPacket(handler), sender)
)
)
);
impls.serialize(ucs02.toHexString(), proxyUCS02);

string memory implMulticall = "implMulticall";
implMulticall.serialize(
"contract", string("contracts/Multicall.sol:Multicall")
);
json.serialize(
"contracts/clients/CometblsClient.sol:CometblsClient",
implOf(cometblsClient)
implMulticall = implMulticall.serialize("args", bytes(hex""));
impls.serialize(multicall.toHexString(), implMulticall);

string memory implHandler = "implHandler";
implHandler.serialize(
"contract",
string("contracts/core/OwnableIBCHandler.sol:OwnableIBCHandler")
);
json.serialize(
"contracts/apps/ucs/00-pingpong/PingPong.sol:PingPong",
implOf(ucs00)
implHandler = implHandler.serialize("args", bytes(hex""));
impls.serialize(implOf(handler).toHexString(), implHandler);

string memory implComet = "implComet";
implComet.serialize(
"contract",
string("contracts/clients/CometblsClient.sol:CometblsClient")
);
json.serialize(
"contracts/apps/ucs/01-relay/Relay.sol:UCS01Relay", implOf(ucs01)
implComet = implComet.serialize("args", bytes(hex""));
impls.serialize(implOf(cometblsClient).toHexString(), implComet);

string memory implUCS00 = "implUCS00";
implUCS00.serialize(
"contract",
string("contracts/apps/ucs/00-pingpong/PingPong.sol:PingPong")
);
json = json.serialize(
"contracts/apps/ucs/02-nft/NFT.sol:UCS02NFT", implOf(ucs02)
implUCS00 = implUCS00.serialize("args", bytes(hex""));
impls.serialize(implOf(ucs00).toHexString(), implUCS00);

string memory implUCS01 = "implUCS01";
implUCS01.serialize(
"contract",
string("contracts/apps/ucs/01-relay/Relay.sol:UCS01Relay")
);
json.write(vm.envString("OUTPUT"));
implUCS01 = implUCS01.serialize("args", bytes(hex""));
impls.serialize(implOf(ucs01).toHexString(), implUCS01);

string memory implUCS02 = "implUCS02";
implUCS02.serialize(
"contract", string("contracts/apps/ucs/02-nft/NFT.sol:UCS02NFT")
);
implUCS02 = implUCS02.serialize("args", bytes(hex""));
impls = impls.serialize(implOf(ucs01).toHexString(), implUCS02);

impls.write(vm.envString("OUTPUT"));
}
}

Expand Down
Loading