Skip to content

Commit

Permalink
Update interface to single quote payload
Browse files Browse the repository at this point in the history
  • Loading branch information
austinborn committed Sep 13, 2023
1 parent f6548d9 commit e2df7e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
8 changes: 4 additions & 4 deletions contracts/src/v0.8/llo-feeds/VerifierProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,24 @@ contract VerifierProxy is IVerifierProxy, ConfirmedOwner, TypeAndVersionInterfac
}

/// @inheritdoc IVerifierProxy
function verify(bytes calldata payload, bytes calldata quotePayload) external payable checkAccess returns (bytes memory) {
function verify(bytes calldata payload, bytes calldata feePayload) external payable checkAccess returns (bytes memory) {
IVerifierFeeManager feeManager = s_feeManager;

// Bill the verifier
if (address(feeManager) != address(0)) {
feeManager.processFee{value: msg.value}(payload, quotePayload, msg.sender);
feeManager.processFee{value: msg.value}(payload, feePayload, msg.sender);
}

return _verify(payload);
}

/// @inheritdoc IVerifierProxy
function verifyBulk(bytes[] calldata payloads, bytes[] calldata quotePayloads) external payable checkAccess returns (bytes[] memory verifiedReports) {
function verifyBulk(bytes[] calldata payloads, bytes calldata feePayload) external payable checkAccess returns (bytes[] memory verifiedReports) {
IVerifierFeeManager feeManager = s_feeManager;

// Bill the verifier
if (address(feeManager) != address(0)) {
feeManager.processFeeBulk{value: msg.value}(payloads, quotePayloads, msg.sender);
feeManager.processFeeBulk{value: msg.value}(payloads, feePayload, msg.sender);
}

//verify the reports
Expand Down
12 changes: 4 additions & 8 deletions contracts/src/v0.8/llo-feeds/dev/FeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ contract FeeManager is IFeeManager, ConfirmedOwner, TypeAndVersionInterface {
}

/// @inheritdoc IVerifierFeeManager
function processFee(bytes calldata payload, bytes calldata quotePayload, address subscriber) external payable override onlyProxy {
(Common.Asset memory fee, Common.Asset memory reward, uint256 appliedDiscount) = _processFee(payload, quotePayload, subscriber);
function processFee(bytes calldata payload, bytes calldata feePayload, address subscriber) external payable override onlyProxy {
(Common.Asset memory fee, Common.Asset memory reward, uint256 appliedDiscount) = _processFee(payload, feePayload, subscriber);

if (fee.amount == 0) {
_tryReturnChange(subscriber, msg.value);
Expand All @@ -188,22 +188,18 @@ contract FeeManager is IFeeManager, ConfirmedOwner, TypeAndVersionInterface {
}

/// @inheritdoc IVerifierFeeManager
function processFeeBulk(bytes[] calldata payloads, bytes[] calldata quotePayloads, address subscriber) external payable override onlyProxy {
function processFeeBulk(bytes[] calldata payloads, bytes calldata feePayload, address subscriber) external payable override onlyProxy {
FeeAndReward[] memory feesAndRewards = new IFeeManager.FeeAndReward[](payloads.length);

//keep track of the number of fees to prevent over initialising the FeePayment array within _convertToLinkAndNativeFees
uint256 numberOfLinkFees;
uint256 numberOfNativeFees;

bool separateQuotePayloads = quotePayloads.length > 1;

uint256 feesAndRewardsIndex;
for (uint256 i; i < payloads.length; ++i) {
bytes calldata quotePayload = separateQuotePayloads ? quotePayloads[i] : quotePayloads[0];

(Common.Asset memory fee, Common.Asset memory reward, uint256 appliedDiscount) = _processFee(
payloads[i],
quotePayload,
feePayload,
subscriber
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ interface IVerifierFeeManager is IERC165 {
/**
* @notice Handles fees for a report from the subscriber and manages rewards
* @param payload report to process the fee for
* @param quotePayload quote payload
* @param feePayload fee payload
* @param subscriber address of the fee will be applied
*/
function processFee(bytes calldata payload, bytes calldata quotePayload, address subscriber) external payable;
function processFee(bytes calldata payload, bytes calldata feePayload, address subscriber) external payable;

/**
* @notice Processes the fees for each report in the payload, billing the subscriber and paying the reward manager
* @param payloads reports to process
* @param quotePayloads quote payloads for each payload or 1 for all
* @param feePayload fee payload
* @param subscriber address of the user to process fee for
*/
function processFeeBulk(bytes[] calldata payloads, bytes[] calldata quotePayloads, address subscriber) external payable;
function processFeeBulk(bytes[] calldata payloads, bytes calldata feePayload, address subscriber) external payable;

/**
* @notice Sets the fee recipients according to the fee manager
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/v0.8/llo-feeds/interfaces/IVerifierProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ interface IVerifierProxy {
* correctly by routing to the correct verifier, and bills the user if applicable.
* @param payload The encoded data to be verified, including the signed
* report.
* @param quotePayload quote metadata for billing
* @param feePayload fee metadata for billing
* @return verifierResponse The encoded report from the verifier.
*/
function verify(bytes calldata payload, bytes calldata quotePayload) external payable returns (bytes memory verifierResponse);
function verify(bytes calldata payload, bytes calldata feePayload) external payable returns (bytes memory verifierResponse);

/**
* @notice Bulk verifies that the data encoded has been signed
* correctly by routing to the correct verifier, and bills the user if applicable.
* @param payloads The encoded payloads to be verified, including the signed
* report.
* @param quotePayloads quote metadata for billing
* @param feePayload fee metadata for billing
* @return verifiedReports The encoded reports from the verifier.
*/
function verifyBulk(bytes[] calldata payloads, bytes[] calldata quotePayloads) external payable returns (bytes[] memory verifiedReports);
function verifyBulk(bytes[] calldata payloads, bytes calldata feePayload) external payable returns (bytes[] memory verifiedReports);

/**
* @notice Sets the verifier address initially, allowing `setVerifier` to be set by this Verifier in the future
Expand Down

0 comments on commit e2df7e1

Please sign in to comment.