From 11acec513cd1f81f526f3988de20a97ba8beeea8 Mon Sep 17 00:00:00 2001 From: Atlas Date: Mon, 30 Dec 2024 16:43:05 +0100 Subject: [PATCH] feat: update dep --- lib/forge-std | 2 +- lib/ovm-contracts | 2 +- script/Deploy.s.sol | 12 ++++++++++-- src/Pi.sol | 29 ++++++++++++++++++++++------- test/Pi.t.sol | 7 ++++++- verify.sh | 8 ++++++++ 6 files changed, 48 insertions(+), 12 deletions(-) create mode 100755 verify.sh diff --git a/lib/forge-std b/lib/forge-std index 8f24d6b..b5a8691 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 8f24d6b04c92975e0795b5868aa0d783251cdeaa +Subproject commit b5a86914561f38735ef1fc357685de3e7c92dc48 diff --git a/lib/ovm-contracts b/lib/ovm-contracts index cd57e9f..639550b 160000 --- a/lib/ovm-contracts +++ b/lib/ovm-contracts @@ -1 +1 @@ -Subproject commit cd57e9fe61b421932c9d3ab59fae60a8063492a6 +Subproject commit 639550b6df0e86c9033a74864f4bdaadab08b76c diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index bdcd70c..7c19a17 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -38,8 +38,15 @@ contract Deploy is Deployer { /* solhint-disable comprehensive-interface */ function run() external { deployImplementations(); - deployProxies(); + initializePi(); + } + + function initializePi() public { + Pi pi = Pi(mustGetAddress("PiProxy")); + + console.log("Initializing Pi at %s", address(pi)); + pi.initialize(_cfg.templateAdmin()); } /// @notice Deploy all of the proxies @@ -69,7 +76,8 @@ contract Deploy is Deployer { function deployPi() public returns (address addr) { console.log("Deploying Pi.sol"); - Pi pi = new Pi(_cfg.ovmTaskAddress(), _cfg.templateAdmin()); + Pi pi = new Pi(); + pi.initialize(_cfg.templateAdmin()); save("Pi", address(pi)); console.log("Pi deployed at %s", address(pi)); diff --git a/src/Pi.sol b/src/Pi.sol index 2685f1b..e00bfc5 100644 --- a/src/Pi.sol +++ b/src/Pi.sol @@ -10,19 +10,18 @@ import { Specification } from "@webisopen/ovm-contracts/src/libraries/DataTypes.sol"; +import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; + event ResponseParsed(bytes32 requestId, bool success, string strPI); -contract Pi is OVMClient { +contract Pi is OVMClient, OwnableUpgradeable { bool public constant REQ_DETERMINISTIC = true; mapping(bytes32 requestId => string _strPI) internal _responseData; - /** - * @dev Constructor function for the PI contract. - * @param OVMGatewayAddress The address of the OVMGateway contract. - * @param admin The address of the admin. - */ - constructor(address OVMGatewayAddress, address admin) OVMClient(OVMGatewayAddress, admin) { + function initialize(address admin) external initializer { + __Ownable_init(admin); + // set specification Specification memory spec; spec.name = "ovm-cal-pi"; @@ -89,6 +88,22 @@ contract Pi is OVMClient { return _responseData[requestId]; } + /** + * @dev Updates the specification of the OVM task. + * @param spec The new specification to be set. + */ + function updateSpecification(Specification memory spec) external onlyOwner { + _updateSpecification(spec); + } + + /** + * @dev Updates the address of the OVMGateway contract. + * @param OVMGatewayAddress The new address of the OVMGateway contract. + */ + function updateOVMGateway(address OVMGatewayAddress) external onlyOwner { + _updateOVMGatewayAddress(OVMGatewayAddress); + } + /** * @dev Parses the given data and returns a boolean value and a string. * @param data The input data to be parsed. diff --git a/test/Pi.t.sol b/test/Pi.t.sol index 8c81edf..ef3e8f2 100644 --- a/test/Pi.t.sol +++ b/test/Pi.t.sol @@ -9,7 +9,12 @@ contract PiTest is Test { Pi public pi; function setUp() public { - pi = new Pi(mockTask, alice); + pi = new Pi(); + + pi.initialize(alice); + + vm.prank(alice); + pi.updateOVMGateway(address(mockTask)); } function testSetResponse() public { diff --git a/verify.sh b/verify.sh new file mode 100755 index 0000000..4067de8 --- /dev/null +++ b/verify.sh @@ -0,0 +1,8 @@ +export VERIFIER=blockscout +export VERIFIER_URL='https://scan.testnet.open.network/api' + +forge verify-contract \ +--verifier-url $VERIFIER_URL \ +--verifier $VERIFIER \ +0xTODO \ +src/Pi.sol:Pi