Skip to content
Merged
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
2 changes: 1 addition & 1 deletion FunctionSignatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
| `requestOwnershipHandover` | `0x25692962` |
| `sbType` | `0x745de344` |
| `transferOwnership` | `0xf2fde38b` |
| `transmitterFees` | `0xefb4cdea` |
| `transmitterCredits` | `0xefb4cdea` |
| `unblockAndAssignFees` | `0x3c5366a2` |
| `unblockFees` | `0xc1867a4b` |
| `watcherPrecompileConfig` | `0x8618a912` |
Expand Down
34 changes: 17 additions & 17 deletions contracts/base/AppGatewayBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import "../interfaces/IForwarder.sol";
import "../interfaces/IMiddleware.sol";
import "../interfaces/IPromise.sol";

import {FeesPlugin} from "../protocol/utils/FeesPlugin.sol";
import {InvalidPromise, FeesNotSet, AsyncModifierNotUsed} from "../protocol/utils/common/Errors.sol";
import {FAST} from "../protocol/utils/common/Constants.sol";

/// @title AppGatewayBase
/// @notice Abstract contract for the app gateway
/// @dev This contract contains helpers for contract deployment, overrides, hooks and request processing
abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin {
abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway {
OverrideParams public overrideParams;
bool public isAsyncModifierSet;
address public auctionManager;
bytes32 public sbType;
bytes public onCompleteData;
uint256 public maxFees;

mapping(address => bool) public isValidPromise;
mapping(bytes32 => mapping(uint32 => address)) public override forwarderAddresses;
Expand All @@ -29,20 +29,19 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin
modifier async(bytes memory feesApprovalData_) {
_preAsync();
_;
_postAsync();
_postAsync(feesApprovalData_);
}

function _postAsync() internal {
function _postAsync(bytes memory feesApprovalData_) internal {
isAsyncModifierSet = false;

// todo: cache the feesApprovalData for next async in same request
deliveryHelper__().batch(fees, auctionManager, feesApprovalData_, onCompleteData);
deliveryHelper__().batch(maxFees, auctionManager, feesApprovalData_, onCompleteData);
_markValidPromises();
onCompleteData = bytes("");
}

function _preAsync() internal {
if (fees.feePoolChain == 0) revert FeesNotSet();
isAsyncModifierSet = true;
_clearOverrides();
deliveryHelper__().clearQueue();
Expand Down Expand Up @@ -188,7 +187,8 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin
return address(0);
}

onChainAddress = IForwarder(forwarderAddresses[contractId_][chainSlug_]).getOnChainAddress();
onChainAddress = IForwarder(forwarderAddresses[contractId_][chainSlug_])
.getOnChainAddress();
}

////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -197,19 +197,19 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin

/// @notice Sets multiple overrides in one call
/// @param isReadCall_ The read call flag
/// @param fees_ The fees configuration
/// @param fees_ The maxFees configuration
/// @param gasLimit_ The gas limit
/// @param isParallelCall_ The sequential call flag
function _setOverrides(
Read isReadCall_,
Parallel isParallelCall_,
uint256 gasLimit_,
Fees memory fees_
uint256 fees_
) internal {
overrideParams.isReadCall = isReadCall_;
overrideParams.isParallelCall = isParallelCall_;
overrideParams.gasLimit = gasLimit_;
fees = fees_;
maxFees = fees_;
}

function _clearOverrides() internal {
Expand All @@ -221,7 +221,7 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin
overrideParams.writeFinality = WriteFinality.LOW;
}

/// @notice Sets isReadCall, fees and gasLimit overrides
/// @notice Sets isReadCall, maxFees and gasLimit overrides
/// @param isReadCall_ The read call flag
/// @param isParallelCall_ The sequential call flag
/// @param gasLimit_ The gas limit
Expand Down Expand Up @@ -283,10 +283,10 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin
overrideParams.value = value_;
}

/// @notice Sets fees overrides
/// @param fees_ The fees configuration
function _setOverrides(Fees memory fees_) internal {
fees = fees_;
/// @notice Sets maxFees overrides
/// @param fees_ The maxFees configuration
function _setMaxFees(uint256 fees_) internal {
maxFees = fees_;
}

function getOverrideParams()
Expand Down Expand Up @@ -315,7 +315,7 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin
deliveryHelper__().cancelRequest(requestCount_);
}

/// @notice increases the transaction fees
/// @notice increases the transaction maxFees
/// @param requestCount_ The async ID
function _increaseFees(uint40 requestCount_, uint256 newMaxFees_) internal {
deliveryHelper__().increaseFees(requestCount_, newMaxFees_);
Expand All @@ -339,7 +339,7 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin
amount_,
receiver_,
auctionManager,
fees
maxFees
);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IAppGateway.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import {Fees, Read, Parallel, QueuePayloadParams, OverrideParams, CallType, WriteFinality, PayloadParams} from "../protocol/utils/common/Structs.sol";
import {Read, Parallel, QueuePayloadParams, OverrideParams, CallType, WriteFinality, PayloadParams} from "../protocol/utils/common/Structs.sol";

/// @title IAppGateway
/// @notice Interface for the app gateway
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IAuctionManager.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import {Bid, Fees, RequestMetadata, RequestParams} from "../protocol/utils/common/Structs.sol";
import {Bid, RequestMetadata, RequestParams} from "../protocol/utils/common/Structs.sol";

interface IAuctionManager {
/// @notice Bids for an auction
Expand Down
31 changes: 15 additions & 16 deletions contracts/interfaces/IFeesManager.sol
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import {Fees, Bid, QueuePayloadParams} from "../protocol/utils/common/Structs.sol";
import {Bid, QueuePayloadParams} from "../protocol/utils/common/Structs.sol";

interface IFeesManager {
function blockFees(
address appGateway_,
Fees memory fees_,
Bid memory winningBid_,
address consumeFrom_,
uint256 transmitterCredits_,
uint40 requestCount_
) external;

function unblockFees(uint40 requestCount_) external;

function isFeesEnough(
address appGateway_,
address consumeFrom_,
Fees memory fees_
address appGateway_,
uint256 amount_
) external view returns (bool);

function unblockAndAssignFees(
uint40 requestCount_,
address transmitter_,
address appGateway_
) external;
function unblockAndAssignFees(uint40 requestCount_, address transmitter_) external;

function withdrawFees(
address appGateway_,
Expand All @@ -33,10 +28,14 @@ interface IFeesManager {
address receiver_
) external;

function assignWatcherPrecompileFees(
uint32 chainSlug_,
address token_,
uint256 amount_,
address consumeFrom_
function assignWatcherPrecompileFeesFromRequestCount(
uint256 fees_,
uint40 requestCount_
) external;

function assignWatcherPrecompileFeesFromAddress(uint256 fees_, address consumeFrom_) external;

function setAppGatewayWhitelist(
bytes memory feeApprovalData_
) external returns (address consumeFrom, address appGateway, bool isApproved);
}
6 changes: 5 additions & 1 deletion contracts/interfaces/IFeesPlug.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ interface IFeesPlug {

function feesRedeemed(bytes32 feesId_) external view returns (bool);

function deposit(address token_, address appGateway_, uint256 amount_) external payable;
function depositToFee(address token_, uint256 amount_, address receiver_) external;

function depositToFeeAndNative(address token_, uint256 amount_, address receiver_) external;

function depositToNative(address token_, uint256 amount_, address receiver_) external;

function distributeFee(
address feeToken_,
Expand Down
8 changes: 4 additions & 4 deletions contracts/interfaces/IMiddleware.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
import {PayloadSubmitParams, QueuePayloadParams, Bid, Fees, WriteFinality, CallType, Parallel, IsPlug, RequestMetadata, } from "../protocol/utils/common/Structs.sol";
import {PayloadSubmitParams, QueuePayloadParams, Bid, WriteFinality, CallType, Parallel, IsPlug, RequestMetadata} from "../protocol/utils/common/Structs.sol";

/// @title IMiddleware
/// @notice Interface for the Middleware contract
Expand Down Expand Up @@ -29,7 +29,7 @@ interface IMiddleware {
/// @param onCompleteData_ The data to be passed to the onComplete callback
/// @return requestCount The request id
function batch(
Fees memory fees_,
uint256 fees_,
address auctionManager_,
bytes memory feesApprovalData_,
bytes memory onCompleteData_
Expand All @@ -48,7 +48,7 @@ interface IMiddleware {
uint256 amount_,
address receiver_,
address auctionManager_,
Fees memory fees_
uint256 fees_
) external returns (uint40);

/// @notice Cancels a request
Expand All @@ -66,7 +66,7 @@ interface IMiddleware {
function startRequestProcessing(uint40 requestCount_, Bid memory winningBid_) external;

/// @notice Returns the fees for a request
function getFees(uint40 requestCount_) external view returns (Fees memory);
function getFees(uint40 requestCount_) external view returns (uint256);

/// @notice Finishes a request by assigning fees and calling the onComplete callback
/// @param requestCount_ The request id
Expand Down
5 changes: 3 additions & 2 deletions contracts/interfaces/IWatcherPrecompile.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import {DigestParams, ResolvedPromises, PayloadParams, TriggerParams, PayloadSubmitParams, RequestParams} from "../protocol/utils/common/Structs.sol";
import {DigestParams, ResolvedPromises, PayloadParams, TriggerParams, PayloadSubmitParams, Bid, RequestParams, RequestMetadata} from "../protocol/utils/common/Structs.sol";
import {IWatcherPrecompileLimits} from "./IWatcherPrecompileLimits.sol";
import {IWatcherPrecompileConfig} from "./IWatcherPrecompileConfig.sol";

Expand Down Expand Up @@ -174,7 +174,8 @@ interface IWatcherPrecompile {
function setExpiryTime(uint256 expiryTime_) external;

function submitRequest(
PayloadSubmitParams[] calldata payloadSubmitParams
PayloadSubmitParams[] calldata payloadSubmitParams,
RequestMetadata memory requestMetadata
) external returns (uint40 requestCount);

function startProcessingRequest(uint40 requestCount, address transmitter) external;
Expand Down
19 changes: 12 additions & 7 deletions contracts/interfaces/IWatcherPrecompileLimits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ interface IWatcherPrecompileLimits {
/// @param appGateway_ The app gateway address
/// @param limitType_ The type of limit to consume
/// @param consumeLimit_ The amount of limit to consume
function consumeLimit(address appGateway_, bytes32 limitType_, uint256 consumeLimit_) external;
function consumeLimit(
address appGateway_,
bytes32 limitType_,
uint256 consumeLimit_
) external;

function getTotalFeesRequired(uint40 requestCount_) external view returns (uint256);

function queryFees() external view returns (uint256);
function finalizeFees() external view returns (uint256);
function scheduleFees() external view returns (uint256);
function callBackFees() external view returns (uint256);

function getTotalFeesRequired(
address token_,
uint queryCount,
uint finalizeCount,
uint scheduleCount
) external view returns (uint256);
/// @notice Emitted when limit parameters are updated
event LimitParamsUpdated(UpdateLimitParams[] updates);

Expand Down
Loading