Skip to content

Commit

Permalink
feat: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jtguibas committed Oct 11, 2023
1 parent 850a2d9 commit 7e2ab7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
33 changes: 8 additions & 25 deletions contracts/src/FunctionGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {IFunctionGateway} from "./interfaces/IFunctionGateway.sol";
import {IFunctionVerifier} from "./interfaces/IFunctionVerifier.sol";
import {FunctionRegistry} from "./FunctionRegistry.sol";
import {TimelockedUpgradeable} from "./upgrades/TimelockedUpgradeable.sol";
import {IFeeVault} from "./payments/interfaces/IFeeVault.sol";

contract FunctionGateway is
IFunctionGateway,
FunctionRegistry,
TimelockedUpgradeable
{
/// @dev The default gas limit for requests.
uint32 public constant DEFAULT_GAS_LIMIT = 1000000;
/// @dev The address of the fee vault.
address public feeVault;

/// @dev A nonce for keeping track of requests.
uint32 public nonce;
Expand All @@ -40,28 +41,6 @@ contract FunctionGateway is
__TimelockedUpgradeable_init(_timelock, _guardian);
}

/// @dev Creates a onchain request for a proof. The output and proof is fulfilled asynchronously
/// by the provided callback.
/// @param _functionId The function identifier.
/// @param _input The function input.
/// @param _context The function context.
/// @param _callbackSelector The selector of the callback function.
function zkRequest(
bytes32 _functionId,
bytes memory _input,
bytes memory _context,
bytes4 _callbackSelector
) external returns (bytes32) {
return
zkRequest(
_functionId,
_input,
_context,
_callbackSelector,
DEFAULT_GAS_LIMIT
);
}

/// @dev Creates a onchain request for a proof. The output and proof is fulfilled asynchronously
/// by the provided callback.
/// @param _functionId The function identifier.
Expand All @@ -75,7 +54,7 @@ contract FunctionGateway is
bytes memory _context,
bytes4 _callbackSelector,
uint32 _callbackGasLimit
) public returns (bytes32) {
) external payable returns (bytes32) {
// Compute the callback hash uniquely associated with this request.
bytes32 inputHash = sha256(_input);
bytes32 contextHash = sha256(_context);
Expand Down Expand Up @@ -103,6 +82,10 @@ contract FunctionGateway is

// Increment the nonce.
nonce++;

// Send the fee to the vault.
IFeeVault(feeVault).depositNative{value: msg.value}(callbackAddress);

return requestHash;
}

Expand Down
9 changes: 1 addition & 8 deletions contracts/src/interfaces/IFunctionGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,13 @@ interface IFunctionGatewayErrors {
}

interface IFunctionGateway is IFunctionGatewayEvents, IFunctionGatewayErrors {
function zkRequest(
bytes32 _functionId,
bytes memory _input,
bytes memory _context,
bytes4 _callbackSelector
) external returns (bytes32);

function zkRequest(
bytes32 _functionId,
bytes memory _input,
bytes memory _context,
bytes4 _callbackSelector,
uint32 _callbackGasLimit
) external returns (bytes32);
) external payable returns (bytes32);

function zkCall(
bytes32 _functionId,
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/libraries/OutputReader.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "forge-std/Vm.sol";
import "forge-std/console.sol";
import "forge-std/Test.sol";

import {OutputReader} from "src/libraries/OutputReader.sol";
import {OutputReader} from "../../src/libraries/OutputReader.sol";

contract OutputReaderTest is Test {
function setUp() public {}
Expand Down

0 comments on commit 7e2ab7f

Please sign in to comment.