From 25e7206048b8717d84d6b3fe8771d3af70c5df7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Tue, 9 Apr 2024 19:55:34 +0800 Subject: [PATCH] add sepolia deploy scripts --- script/DeployCanvasContracts.sol | 82 ++++++++++++++++++++ script/DeployCanvasTestBadgeContracts.sol | 92 +++++++++++++++++++++++ script/DeployTestContracts.sol | 5 +- 3 files changed, 176 insertions(+), 3 deletions(-) create mode 100644 script/DeployCanvasContracts.sol create mode 100644 script/DeployCanvasTestBadgeContracts.sol diff --git a/script/DeployCanvasContracts.sol b/script/DeployCanvasContracts.sol new file mode 100644 index 0000000..731a1dc --- /dev/null +++ b/script/DeployCanvasContracts.sol @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.19; + +import {Script} from "forge-std/Script.sol"; +import {console} from "forge-std/console.sol"; + +import {EAS} from "@eas/contracts/EAS.sol"; + +import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; + +import { + ITransparentUpgradeableProxy, + TransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; + +import {EmptyContract} from "../src/misc/EmptyContract.sol"; +import {Profile} from "../src/profile/Profile.sol"; +import {ProfileRegistry} from "../src/profile/ProfileRegistry.sol"; +import {ScrollBadgeResolver} from "../src/resolver/ScrollBadgeResolver.sol"; + +contract DeployTestContracts is Script { + uint256 DEPLOYER_PRIVATE_KEY = vm.envUint("DEPLOYER_PRIVATE_KEY"); + + address SIGNER_ADDRESS = vm.envAddress("SIGNER_ADDRESS"); + address TREASURY_ADDRESS = vm.envAddress("TREASURY_ADDRESS"); + + address EAS_ADDRESS = vm.envAddress("EAS_ADDRESS"); + + function run() external { + vm.startBroadcast(DEPLOYER_PRIVATE_KEY); + + // deploy proxy admin + ProxyAdmin proxyAdmin = new ProxyAdmin(); + + // deploy profile registry placeholder + address placeholder = address(new EmptyContract()); + address profileRegistryProxy = address(new TransparentUpgradeableProxy(placeholder, address(proxyAdmin), "")); + + // deploy Scroll badge resolver + address resolverImpl = address(new ScrollBadgeResolver(EAS_ADDRESS, profileRegistryProxy)); + address resolverProxy = address(new TransparentUpgradeableProxy(resolverImpl, address(proxyAdmin), "")); + ScrollBadgeResolver resolver = ScrollBadgeResolver(payable(resolverProxy)); + resolver.initialize(); + + bytes32 schema = resolver.schema(); + + // deploy profile implementation and upgrade registry + Profile profileImpl = new Profile(address(resolver)); + ProfileRegistry profileRegistryImpl = new ProfileRegistry(); + proxyAdmin.upgrade(ITransparentUpgradeableProxy(profileRegistryProxy), address(profileRegistryImpl)); + ProfileRegistry(profileRegistryProxy).initialize(TREASURY_ADDRESS, SIGNER_ADDRESS, address(profileImpl)); + + // misc + bytes32[] memory blacklist = new bytes32[](1); + blacklist[0] = keccak256(bytes("vpn")); + ProfileRegistry(profileRegistryProxy).blacklistUsername(blacklist); + + ProfileRegistry(profileRegistryProxy).updateSigner(0x70997970C51812dc3A010C7d01b50e0d17dc79C8); + + // log addresses + logAddress("DEPLOYER_ADDRESS", vm.addr(DEPLOYER_PRIVATE_KEY)); + logAddress("SIGNER_ADDRESS", SIGNER_ADDRESS); + logAddress("TREASURY_ADDRESS", TREASURY_ADDRESS); + logAddress("EAS_ADDRESS", EAS_ADDRESS); + logAddress("SCROLL_PROFILE_REGISTRY_PROXY_ADMIN_ADDRESS", address(proxyAdmin)); + logAddress("SCROLL_PROFILE_REGISTRY_PROXY_CONTRACT_ADDRESS", address(profileRegistryProxy)); + logAddress("SCROLL_BADGE_RESOLVER_CONTRACT_ADDRESS", address(resolver)); + logBytes32("SCROLL_BADGE_SCHEMA_UID", schema); + logAddress("SCROLL_PROFILE_IMPLEMENTATION_CONTRACT_ADDRESS", address(profileImpl)); + logAddress("SCROLL_PROFILE_REGISTRY_IMPLEMENTATION_CONTRACT_ADDRESS", address(profileRegistryImpl)); + + vm.stopBroadcast(); + } + + function logAddress(string memory name, address addr) internal view { + console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr))))); + } + + function logBytes32(string memory name, bytes32 data) internal view { + console.log(string(abi.encodePacked(name, "=", vm.toString(data)))); + } +} diff --git a/script/DeployCanvasTestBadgeContracts.sol b/script/DeployCanvasTestBadgeContracts.sol new file mode 100644 index 0000000..a9961ba --- /dev/null +++ b/script/DeployCanvasTestBadgeContracts.sol @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.19; + +import {Script} from "forge-std/Script.sol"; +import {console} from "forge-std/console.sol"; + +import {Attestation} from "@eas/contracts/IEAS.sol"; + +import {ScrollBadge} from "../src/badge/ScrollBadge.sol"; +import {ScrollBadgeTokenOwner} from "../src/badge/examples/ScrollBadgeTokenOwner.sol"; +import {ScrollBadgeSelfAttest} from "../src/badge/extensions/ScrollBadgeSelfAttest.sol"; +import {ScrollBadgeSingleton} from "../src/badge/extensions/ScrollBadgeSingleton.sol"; +import {ScrollBadgeResolver} from "../src/resolver/ScrollBadgeResolver.sol"; + +contract CanvasTestBadge is ScrollBadgeSelfAttest, ScrollBadgeSingleton { + string public sharedTokenURI; + + constructor(address resolver_, string memory tokenUri_) ScrollBadge(resolver_) { + sharedTokenURI = tokenUri_; + } + + function onIssueBadge(Attestation calldata attestation) + internal + virtual + override (ScrollBadgeSelfAttest, ScrollBadgeSingleton) + returns (bool) + { + return super.onIssueBadge(attestation); + } + + function onRevokeBadge(Attestation calldata attestation) + internal + virtual + override (ScrollBadgeSelfAttest, ScrollBadgeSingleton) + returns (bool) + { + return super.onRevokeBadge(attestation); + } + + function badgeTokenURI(bytes32 /*uid*/ ) public view override returns (string memory) { + return sharedTokenURI; + } +} + +contract DeployTestContracts is Script { + uint256 DEPLOYER_PRIVATE_KEY = vm.envUint("DEPLOYER_PRIVATE_KEY"); + + address RESOLVER_ADDRESS = vm.envAddress("SCROLL_BADGE_RESOLVER_CONTRACT_ADDRESS"); + + function run() external { + vm.startBroadcast(DEPLOYER_PRIVATE_KEY); + + ScrollBadgeResolver resolver = ScrollBadgeResolver(payable(RESOLVER_ADDRESS)); + + // deploy test badges + CanvasTestBadge badge1 = new CanvasTestBadge( + address(resolver), "ipfs://bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/1" + ); + + CanvasTestBadge badge2 = new CanvasTestBadge( + address(resolver), "ipfs://bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/2" + ); + + CanvasTestBadge badge3 = new CanvasTestBadge( + address(resolver), "ipfs://bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/3" + ); + + address[] memory tokens = new address[](1); + tokens[0] = 0xDd7d857F570B0C211abfe05cd914A85BefEC2464; + + ScrollBadgeTokenOwner badge4 = new ScrollBadgeTokenOwner(address(resolver), tokens); + + // set permissions + resolver.toggleBadge(address(badge1), true); + resolver.toggleBadge(address(badge2), true); + resolver.toggleBadge(address(badge3), true); + resolver.toggleBadge(address(badge4), true); + + // log addresses + logAddress("DEPLOYER_ADDRESS", vm.addr(DEPLOYER_PRIVATE_KEY)); + logAddress("SIMPLE_BADGE_A_CONTRACT_ADDRESS", address(badge1)); + logAddress("SIMPLE_BADGE_B_CONTRACT_ADDRESS", address(badge2)); + logAddress("SIMPLE_BADGE_C_CONTRACT_ADDRESS", address(badge3)); + logAddress("ORIGINS_BADGE_ADDRESS", address(badge4)); + + vm.stopBroadcast(); + } + + function logAddress(string memory name, address addr) internal view { + console.log(string(abi.encodePacked(name, "=", vm.toString(address(addr))))); + } +} diff --git a/script/DeployTestContracts.sol b/script/DeployTestContracts.sol index 66eb7b5..a70fc6a 100644 --- a/script/DeployTestContracts.sol +++ b/script/DeployTestContracts.sol @@ -38,9 +38,8 @@ contract DeployTestContracts is Script { ProxyAdmin proxyAdmin = new ProxyAdmin(); // deploy profile registry placeholder - EmptyContract placeholder = new EmptyContract(); - address profileRegistryProxy = - address(new TransparentUpgradeableProxy(address(placeholder), address(proxyAdmin), "")); + address placeholder = address(new EmptyContract()); + address profileRegistryProxy = address(new TransparentUpgradeableProxy(placeholder, address(proxyAdmin), "")); // deploy Scroll badge resolver address resolverImpl = address(new ScrollBadgeResolver(address(eas), profileRegistryProxy));