Skip to content

Commit

Permalink
feat: update dep
Browse files Browse the repository at this point in the history
  • Loading branch information
Atlasoin committed Dec 30, 2024
1 parent 9898839 commit 11acec5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/forge-std
12 changes: 10 additions & 2 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down
29 changes: 22 additions & 7 deletions src/Pi.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion test/Pi.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions verify.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 11acec5

Please sign in to comment.