Skip to content

Commit

Permalink
contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Gajesh2007 committed May 13, 2024
1 parent 99cda61 commit 29ddf94
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ optimizer_runs = 200
# Whether or not to use the Yul intermediate representation compilation pipeline
via_ir = false
# Override the Solidity version (this overrides `auto_detect_solc`)
solc_version = '0.8.12'
auto_detect_solc = true

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
6 changes: 3 additions & 3 deletions contracts/src/HelloWorldServiceManager.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "../lib//contracts/libraries/BytesLib.sol";
import "@eigenlayer/contracts/libraries/BytesLib.sol";
import "./IHelloWorldTaskManager.sol";
import "@eigenlayer-middleware/src/ServiceManagerBase.sol";

Expand Down Expand Up @@ -37,7 +37,7 @@ contract HelloWorldServiceManager is ServiceManagerBase {
_stakeRegistry
)
{
HelloWorldTaskManager = _helloWorldTaskManager;
helloWorldTaskManager = _helloWorldTaskManager;
}

/// @notice Called in the event of challenge resolution, in order to forward a call to the Slasher, which 'freezes' the `operator`.
Expand All @@ -46,6 +46,6 @@ contract HelloWorldServiceManager is ServiceManagerBase {
function freezeOperator(
address operatorAddr
) external onlyHelloWorldTaskManager {

}
}
16 changes: 7 additions & 9 deletions contracts/src/HelloWorldTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.9;

import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin-upgrades/contracts/utils/cryptography/ECDSAUpgradeable.sol";
import "@eigenlayer/contracts/permissions/Pausable.sol";
import "@eigenlayer-middleware/src/interfaces/IServiceManager.sol";
import {IRegistryCoordinator} from "@eigenlayer-middleware/src/interfaces/IRegistryCoordinator.sol";
Expand All @@ -17,7 +17,7 @@ contract HelloWorldTaskManager is
OperatorStateRetriever,
IHelloWorldTaskManager
{
using ECDSA for bytes32;
using ECDSAUpgradeable for bytes32;

/* STORAGE */
// The latest task index
Expand All @@ -30,16 +30,16 @@ contract HelloWorldTaskManager is
mapping(uint32 => bytes32) public allTaskHashes;

// mapping of task indices to hash of abi.encode(taskResponse, taskResponseMetadata)
mapping(address => mapping(uint32 => bytes32)) public allTaskResponses;
mapping(address => mapping(uint32 => bytes)) public allTaskResponses;

IRegistryCoordinator public registryCoordinator;

/* MODIFIERS */
modifier onlyOperator() {
require(
registryCoordinator.getOperator(msg.sender).status
registryCoordinator.getOperatorStatus(msg.sender)
==
registryCoordinator.OperatorStatus.REGISTERED,
IRegistryCoordinator.OperatorStatus.REGISTERED,
"Operator must be the caller"
);
_;
Expand Down Expand Up @@ -81,8 +81,6 @@ contract HelloWorldTaskManager is
uint32 referenceTaskIndex,
bytes calldata signature
) external onlyOperator {
uint32 taskCreatedBlock = task.taskCreatedBlock;

// check that the task is valid, hasn't been responsed yet, and is being responsed in time
require(
keccak256(abi.encode(task)) ==
Expand All @@ -91,12 +89,12 @@ contract HelloWorldTaskManager is
);
// some logical checks
require(
allTaskResponses[msg.sender][referenceTaskIndex] == bytes32(0),
allTaskResponses[msg.sender][referenceTaskIndex].length == 0,
"Operator has already responded to the task"
);

// The message that was signed
bytes32 messageHash = keccak256(abi.encodePacked("Hello, "+name));
bytes32 messageHash = keccak256(abi.encodePacked("Hello, ", task.name));
bytes32 ethSignedMessageHash = messageHash.toEthSignedMessageHash();

// Recover the signer address from the signature
Expand Down

0 comments on commit 29ddf94

Please sign in to comment.