Skip to content

Commit

Permalink
fix: forge fmt error
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas committed Oct 18, 2023
1 parent 41bb8bd commit 163a6b0
Show file tree
Hide file tree
Showing 26 changed files with 1,081 additions and 397 deletions.
7 changes: 7 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read-write", path = "./"}]

[fmt]
line_length = 100
tab_width = 4
func_attrs_with_params_multiline = true
ignore = ["lib/**"]


# See more config options https://github.com/foundry-rs/foundry/tree/master/config
7 changes: 5 additions & 2 deletions contracts/script/deploy/FunctionGateway.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";

contract DeployFunctionGateway is BaseScript {
function run() external broadcaster {
console.log("Deploying FunctionGateway contract on chain %s", Strings.toString(block.chainid));
console.log(
"Deploying FunctionGateway contract on chain %s", Strings.toString(block.chainid)
);

// Check inputs
uint256 SCALAR = envUint256("SCALAR");
Expand All @@ -23,7 +25,8 @@ contract DeployFunctionGateway is BaseScript {
FunctionGateway gatewayImpl = new FunctionGateway{salt: CREATE2_SALT}();
FunctionGateway gateway;
if (!UPGRADE) {
gateway = FunctionGateway(address(new Proxy{salt: CREATE2_SALT}(address(gatewayImpl), "")));
gateway =
FunctionGateway(address(new Proxy{salt: CREATE2_SALT}(address(gatewayImpl), "")));
gateway.initialize(SCALAR, SUCCINCT_FEE_VAULT, TIMELOCK, GUARDIAN);
} else {
gateway = FunctionGateway(envAddress("FUNCTION_GATEWAY", block.chainid));
Expand Down
12 changes: 10 additions & 2 deletions contracts/script/deploy/Guardian.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
// "Guardian" refers to a Gnosis Safe proxy.
contract DeployGuardian is BaseScript {
function run() external broadcaster {
console.log("Deploying Guardian (Safe) contract on chain %s", Strings.toString(block.chainid));
console.log(
"Deploying Guardian (Safe) contract on chain %s", Strings.toString(block.chainid)
);

// Check inputs

Expand Down Expand Up @@ -48,6 +50,12 @@ contract DeployGuardian is BaseScript {
address(0)
);

return Safe(payable(_safeFactory.createProxyWithNonce(address(_safeSingleton), initializer, uint256(_salt))));
return Safe(
payable(
_safeFactory.createProxyWithNonce(
address(_safeSingleton), initializer, uint256(_salt)
)
)
);
}
}
3 changes: 2 additions & 1 deletion contracts/script/deploy/StorageOracle.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ contract DeployStorageOracle is BaseScript {
StorageOracle gatewayImpl = new StorageOracle{salt: CREATE2_SALT}();
StorageOracle gateway;
if (!UPGRADE) {
gateway = StorageOracle(address(new Proxy{salt: CREATE2_SALT}(address(gatewayImpl), "")));
gateway =
StorageOracle(address(new Proxy{salt: CREATE2_SALT}(address(gatewayImpl), "")));
gateway.initialize(FUNCTION_GATEWAY, FUNCTION_ID, TIMELOCK, GUARDIAN);
} else {
gateway = StorageOracle(envAddress("STORAGE_ORACLE", block.chainid));
Expand Down
7 changes: 5 additions & 2 deletions contracts/script/deploy/StorageVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import {IFunctionRegistry} from "src/interfaces/IFunctionRegistry.sol";

contract DeployStorageVerifier is BaseScript {
function run() external broadcaster {
console.log("Deploying StorageVerifier contract on chain %s", Strings.toString(block.chainid));
console.log(
"Deploying StorageVerifier contract on chain %s", Strings.toString(block.chainid)
);

// Check inputs
address FUNCTION_GATEWAY = envAddress("FUNCTION_GATEWAY", block.chainid);
bytes32 CREATE2_SALT = envBytes32("CREATE2_SALT");

// Deploy contract
StorageVerifier verifier = new StorageVerifier{salt: CREATE2_SALT}();
bytes32 functionId = IFunctionRegistry(FUNCTION_GATEWAY).registerFunction(address(verifier), "storage");
bytes32 functionId =
IFunctionRegistry(FUNCTION_GATEWAY).registerFunction(address(verifier), "storage");
console.log("FunctionId:");
console.logBytes32(functionId);

Expand Down
4 changes: 3 additions & 1 deletion contracts/script/deploy/SuccinctFeeVault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";

contract DeploySuccinctFeeVault is BaseScript {
function run() external broadcaster {
console.log("Deploying SuccinctFeeVault contract on chain %s", Strings.toString(block.chainid));
console.log(
"Deploying SuccinctFeeVault contract on chain %s", Strings.toString(block.chainid)
);

// Check inputs
bytes32 CREATE2_SALT = envBytes32("CREATE2_SALT");
Expand Down
20 changes: 15 additions & 5 deletions contracts/script/misc/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ abstract contract BaseScript is Script {
return value;
}

function envUint32s(string memory name, string memory delimiter) internal returns (uint32[] memory) {
function envUint32s(string memory name, string memory delimiter)
internal
returns (uint32[] memory)
{
uint256[] memory values = new uint256[](0);
values = vm.envOr(name, delimiter, values);
if (values.length == 0) {
Expand Down Expand Up @@ -167,9 +170,12 @@ abstract contract BaseScript is Script {
console.log(string.concat(string.concat(addrVar, "="), Strings.toHexString(value)));
}

function writeEnvAddresses(string memory file, string memory name, address[] memory values, string memory delimiter)
internal
{
function writeEnvAddresses(
string memory file,
string memory name,
address[] memory values,
string memory delimiter
) internal {
string memory addrVar = string.concat(name, "_", Strings.toString(block.chainid));
string memory line = string.concat(addrVar, "=");
string memory addrs;
Expand Down Expand Up @@ -243,7 +249,11 @@ abstract contract BaseScript is Script {
return _b;
}

function buildSignaturesFromArray(bytes[] memory _signatures) internal pure returns (bytes memory) {
function buildSignaturesFromArray(bytes[] memory _signatures)
internal
pure
returns (bytes memory)
{
bytes memory signatures;
for (uint256 i = 0; i < _signatures.length; i++) {
signatures = bytes.concat(signatures, bytes(_signatures[i]));
Expand Down
83 changes: 62 additions & 21 deletions contracts/script/misc/Upgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
// );
//
contract UpgradeSignSchedule is BaseScript {
function run(address PROXY, address IMPL) external returns (address signer, bytes memory signature) {
function run(address PROXY, address IMPL)
external
returns (address signer, bytes memory signature)
{
// Check inputs
address TIMELOCK = envAddress("TIMELOCK", block.chainid);
address GUARDIAN = envAddress("GUARDIAN", block.chainid);
Expand All @@ -36,9 +39,12 @@ contract UpgradeSignSchedule is BaseScript {
bytes[] memory payloads = new bytes[](1);
payloads[0] = abi.encodeWithSelector(IProxy.upgradeTo.selector, IMPL);

bytes32 id = ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
bytes32 id =
ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
if (ITimelock(TIMELOCK).isOperation(id)) {
revert("operation already exists in Timelock, change CREATE2_SALT to schedule a new one");
revert(
"operation already exists in Timelock, change CREATE2_SALT to schedule a new one"
);
}

scheduleBatchData = abi.encodeWithSelector(
Expand Down Expand Up @@ -82,7 +88,11 @@ contract UpgradeSignSchedule is BaseScript {
// After enough signatures have been collected, a call to Safe.execTransaction(..., signatures) is
// made which schedules the call on the Timelock.
contract UpgradeSendSchedule is BaseScript {
function run(address PROXY, address IMPL, bytes memory _signatures) external broadcaster returns (bool success) {
function run(address PROXY, address IMPL, bytes memory _signatures)
external
broadcaster
returns (bool success)
{
// Check inputs
address TIMELOCK = envAddress("TIMELOCK", block.chainid);
address GUARDIAN = envAddress("GUARDIAN", block.chainid);
Expand All @@ -103,9 +113,12 @@ contract UpgradeSendSchedule is BaseScript {
bytes[] memory payloads = new bytes[](1);
payloads[0] = abi.encodeWithSelector(IProxy.upgradeTo.selector, IMPL);

bytes32 id = ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
bytes32 id =
ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
if (ITimelock(TIMELOCK).isOperation(id)) {
revert("operation already exists in Timelock, change CREATE2_SALT to schedule a new one");
revert(
"operation already exists in Timelock, change CREATE2_SALT to schedule a new one"
);
}

scheduleBatchData = abi.encodeWithSelector(
Expand All @@ -122,7 +135,9 @@ contract UpgradeSendSchedule is BaseScript {
{
if (ISafe(GUARDIAN).getThreshold() * 65 > _signatures.length) {
console.log(
"not enough signatures, need %d have %d", ISafe(GUARDIAN).getThreshold(), _signatures.length / 65
"not enough signatures, need %d have %d",
ISafe(GUARDIAN).getThreshold(),
_signatures.length / 65
);
return false;
}
Expand All @@ -147,7 +162,10 @@ contract UpgradeSendSchedule is BaseScript {

// After MINIMUM_DELAY has passed, the call to Timelock.execute() can be made.
contract UpgradeSignExecute is BaseScript {
function run(address PROXY, address IMPL) external returns (address signer, bytes memory signature) {
function run(address PROXY, address IMPL)
external
returns (address signer, bytes memory signature)
{
// Check inputs
address TIMELOCK = envAddress("TIMELOCK", block.chainid);
address GUARDIAN = envAddress("GUARDIAN", block.chainid);
Expand All @@ -168,7 +186,8 @@ contract UpgradeSignExecute is BaseScript {
bytes[] memory payloads = new bytes[](1);
payloads[0] = abi.encodeWithSelector(IProxy.upgradeTo.selector, IMPL);

bytes32 id = ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
bytes32 id =
ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
if (ITimelock(TIMELOCK).isOperationDone(id)) {
console.log("operation already executed in Timelock");
return (address(0), "");
Expand Down Expand Up @@ -212,7 +231,11 @@ contract UpgradeSignExecute is BaseScript {
}

contract UpgradeSendExecute is BaseScript {
function run(address PROXY, address IMPL, bytes memory _signatures) external broadcaster returns (bool success) {
function run(address PROXY, address IMPL, bytes memory _signatures)
external
broadcaster
returns (bool success)
{
// Check inputs
address TIMELOCK = envAddress("TIMELOCK", block.chainid);
address GUARDIAN = envAddress("GUARDIAN", block.chainid);
Expand All @@ -233,7 +256,8 @@ contract UpgradeSendExecute is BaseScript {
bytes[] memory payloads = new bytes[](1);
payloads[0] = abi.encodeWithSelector(IProxy.upgradeTo.selector, IMPL);

bytes32 id = ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
bytes32 id =
ITimelock(TIMELOCK).hashOperationBatch(targets, values, payloads, 0, CREATE2_SALT);
if (ITimelock(TIMELOCK).isOperationDone(id)) {
console.log("operation already executed in Timelock");
return true;
Expand All @@ -253,7 +277,9 @@ contract UpgradeSendExecute is BaseScript {
{
if (ISafe(GUARDIAN).getThreshold() * 65 > _signatures.length) {
console.log(
"not enough signatures, need %d have %d", ISafe(GUARDIAN).getThreshold(), _signatures.length / 65
"not enough signatures, need %d have %d",
ISafe(GUARDIAN).getThreshold(),
_signatures.length / 65
);
return false;
}
Expand Down Expand Up @@ -338,7 +364,11 @@ interface ISafe {
event RemovedOwner(address owner);
event SafeReceived(address indexed sender, uint256 value);
event SafeSetup(
address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler
address indexed initiator,
address[] owners,
uint256 threshold,
address initializer,
address fallbackHandler
);
event SignMsg(bytes32 indexed msgHash);

Expand All @@ -347,10 +377,15 @@ interface ISafe {
function approveHash(bytes32 hashToApprove) external;
function approvedHashes(address, bytes32) external view returns (uint256);
function changeThreshold(uint256 _threshold) external;
function checkNSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, uint256 requiredSignatures)
function checkNSignatures(
bytes32 dataHash,
bytes memory data,
bytes memory signatures,
uint256 requiredSignatures
) external view;
function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures)
external
view;
function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures) external view;
function disableModule(address prevModule, address module) external;
function domainSeparator() external view returns (bytes32);
function enableModule(address module) external;
Expand Down Expand Up @@ -378,12 +413,18 @@ interface ISafe {
address refundReceiver,
bytes memory signatures
) external payable returns (bool success);
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success);
function execTransactionFromModuleReturnData(address to, uint256 value, bytes memory data, Enum.Operation operation)
external
returns (bool success, bytes memory returnData);
function execTransactionFromModule(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) external returns (bool success);
function execTransactionFromModuleReturnData(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) external returns (bool success, bytes memory returnData);
function getChainId() external view returns (uint256);
function getModulesPaginated(address start, uint256 pageSize)
external
Expand Down
44 changes: 30 additions & 14 deletions contracts/src/FunctionGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ contract FunctionGateway is IFunctionGateway, FunctionRegistry, TimelockedUpgrad
__TimelockedUpgradeable_init(_timelock, _guardian);
}

function request(bytes32 _functionId, bytes memory _input, bytes4 _callbackSelector, bytes memory _context)
external
payable
returns (bytes32)
{
return request(_functionId, _input, _callbackSelector, _context, DEFAULT_GAS_LIMIT, tx.origin);
function request(
bytes32 _functionId,
bytes memory _input,
bytes4 _callbackSelector,
bytes memory _context
) external payable returns (bytes32) {
return
request(_functionId, _input, _callbackSelector, _context, DEFAULT_GAS_LIMIT, tx.origin);
}

/// @dev Requests for a proof to be generated by the marketplace.
Expand Down Expand Up @@ -158,12 +160,23 @@ contract FunctionGateway is IFunctionGateway, FunctionRegistry, TimelockedUpgrad

// Verify the aggregate proof.
address aggregationVerifier = verifiers[AGGREGATION_FUNCTION_ID];
if (!IFunctionVerifier(aggregationVerifier).verify(_inputsRoot, _outputsRoot, _aggregateProof)) {
revert InvalidProof(address(aggregationVerifier), _inputsRoot, _outputsRoot, _aggregateProof);
if (
!IFunctionVerifier(aggregationVerifier).verify(
_inputsRoot, _outputsRoot, _aggregateProof
)
) {
revert InvalidProof(
address(aggregationVerifier), _inputsRoot, _outputsRoot, _aggregateProof
);
}

emit ProofBatchFulfilled(
_requestIds, _aggregateProof, _inputsRoot, _outputHashes, _outputsRoot, _verificationKeyRoot
_requestIds,
_aggregateProof,
_inputsRoot,
_outputHashes,
_outputsRoot,
_verificationKeyRoot
);
}

Expand All @@ -190,7 +203,8 @@ contract FunctionGateway is IFunctionGateway, FunctionRegistry, TimelockedUpgrad
r.callbackFulfilled = true;

// Call the callback.
(bool status,) = r.callbackAddress.call(abi.encodeWithSelector(r.callbackSelector, _output, _context));
(bool status,) =
r.callbackAddress.call(abi.encodeWithSelector(r.callbackSelector, _output, _context));
if (!status) {
revert CallbackFailed(r.callbackAddress, r.callbackSelector);
}
Expand Down Expand Up @@ -221,10 +235,12 @@ contract FunctionGateway is IFunctionGateway, FunctionRegistry, TimelockedUpgrad

/// @dev Calculates the feeAmount for the request, sends the feeAmount to the FeeVault, and
/// sends the excess amount as a refund to the refundAccount.
function _handlePayment(uint256 _gasLimit, address _refundAccount, address _senderAccount, uint256 _value)
private
returns (uint256 feeAmount)
{
function _handlePayment(
uint256 _gasLimit,
address _refundAccount,
address _senderAccount,
uint256 _value
) private returns (uint256 feeAmount) {
feeAmount = calculateFeeAmount(_gasLimit);
if (_value < feeAmount) {
revert InsufficientFeeAmount(feeAmount, _value);
Expand Down
Loading

0 comments on commit 163a6b0

Please sign in to comment.