Skip to content
Closed
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
24 changes: 24 additions & 0 deletions contracts/Orchestrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import "./_external/Ownable.sol";

import "./UFragmentsPolicy.sol";

import "openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/**
* @title Orchestrator
* @notice The orchestrator is the main entry point for rebase operations. It coordinates the policy
* actions with external consumers.
*/
contract Orchestrator is Ownable {
using ECDSA for address;

struct Transaction {
bool enabled;
address destination;
Expand Down Expand Up @@ -53,6 +57,26 @@ contract Orchestrator is Ownable {
}
}

/**
* @notice Based on the hashed message and the signature (which is composed of v, r, s),
* erecover can return the address of the signer and since only EOAs can create valid
* signatures, this guarantees that the beneficiary address is not a contract but an EOA
* @param hash hashed message
* @param v {27 or 28}
* @param r 32 bytes of the first half of signature
* @param s 32 bytes of the second half of the signature
*/
function verifyAddressOfSignature(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal returns (bool) {
bytes32 prefixedHash = ECDSA.toEthSignedMessageHash(hash);

return ECDSA.recover(prefixedHash, v, r, s) == msg.sender;
}

/**
* @notice Adds a transaction that gets called for a downstream receiver of rebases
* @param destination Address of contract destination
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"typescript": "^4.0.2"
},
"dependencies": {
"@openzeppelin/contracts": "^3.4.0",
"hardhat-gas-reporter": "^1.0.4"
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,11 @@
"@types/sinon-chai" "^3.2.3"
"@types/web3" "1.0.19"

"@openzeppelin/contracts@^3.4.0":
version "3.4.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.0.tgz#9a1669ad5f9fdfb6e273bb5a4fed10cb4cc35eb0"
integrity sha512-qh+EiHWzfY/9CORr+eRUkeEUP1WiFUcq3974bLHwyYzLBUtK6HPaMkIUHi74S1rDTZ0sNz42DwPc5A4IJvN3rg==

"@openzeppelin/hardhat-upgrades@^1.4.3":
version "1.4.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-1.4.3.tgz#dfd0f7668cbc343455c2a6b2d3ba4d68034e5dc2"
Expand Down