From d3dfc5c9d5a64fd1df86bf68f452baf06c66ef06 Mon Sep 17 00:00:00 2001 From: Justin Kaseman Date: Fri, 8 Sep 2023 19:10:44 -0400 Subject: [PATCH] (chore): Update Functions v1 single line comments to nat spec (#10567) --- .../functions/dev/1_0_0/FunctionsBilling.sol | 68 ++++---- .../functions/dev/1_0_0/FunctionsClient.sol | 26 +-- .../dev/1_0_0/FunctionsCoordinator.sol | 28 ++-- .../functions/dev/1_0_0/FunctionsRouter.sol | 42 ++--- .../dev/1_0_0/FunctionsSubscriptions.sol | 80 +++++----- .../src/v0.8/functions/dev/1_0_0/Routable.sol | 14 +- .../accessControl/TermsOfServiceAllowList.sol | 26 +-- .../interfaces/ITermsOfServiceAllowList.sol | 48 +++--- .../1_0_0/example/FunctionsClientExample.sol | 28 ++-- .../1_0_0/interfaces/IFunctionsBilling.sol | 42 ++--- .../dev/1_0_0/interfaces/IFunctionsClient.sol | 14 +- .../interfaces/IFunctionsCoordinator.sol | 38 ++--- .../dev/1_0_0/interfaces/IFunctionsRouter.sol | 112 ++++++------- .../interfaces/IFunctionsSubscriptions.sol | 150 +++++++++--------- .../interfaces/IOwnableFunctionsRouter.sol | 2 +- .../dev/1_0_0/libraries/FunctionsRequest.sol | 54 +++---- .../dev/1_0_0/libraries/FunctionsResponse.sol | 2 +- 17 files changed, 381 insertions(+), 393 deletions(-) diff --git a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsBilling.sol b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsBilling.sol index 5518bad1513..c616f7355d2 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsBilling.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsBilling.sol @@ -10,11 +10,9 @@ import {FunctionsResponse} from "./libraries/FunctionsResponse.sol"; import {SafeCast} from "../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/math/SafeCast.sol"; -/** - * @title Functions Billing contract - * @notice Contract that calculates payment from users to the nodes of the Decentralized Oracle Network (DON). - * @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. - */ +/// @title Functions Billing contract +/// @notice Contract that calculates payment from users to the nodes of the Decentralized Oracle Network (DON). +/// @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. abstract contract FunctionsBilling is Routable, IFunctionsBilling { using FunctionsResponse for FunctionsResponse.RequestMeta; using FunctionsResponse for FunctionsResponse.Commitment; @@ -82,14 +80,14 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { // | Configuration | // ================================================================ - // @notice Gets the Chainlink Coordinator's billing configuration - // @return config + /// @notice Gets the Chainlink Coordinator's billing configuration + /// @return config function getConfig() external view returns (Config memory) { return s_config; } - // @notice Sets the Chainlink Coordinator's billing configuration - // @param config - See the contents of the Config struct in IFunctionsBilling.Config for more information + /// @notice Sets the Chainlink Coordinator's billing configuration + /// @param config - See the contents of the Config struct in IFunctionsBilling.Config for more information function updateConfig(Config memory config) public { _onlyOwner(); @@ -101,17 +99,17 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { // | Fee Calculation | // ================================================================ - // @inheritdoc IFunctionsBilling + /// @inheritdoc IFunctionsBilling function getDONFee(bytes memory /* requestData */) public view override returns (uint72) { return s_config.donFee; } - // @inheritdoc IFunctionsBilling + /// @inheritdoc IFunctionsBilling function getAdminFee() public view override returns (uint72) { return _getRouter().getAdminFee(); } - // @inheritdoc IFunctionsBilling + /// @inheritdoc IFunctionsBilling function getWeiPerUnitLink() public view returns (uint256) { Config memory config = s_config; (, int256 weiPerUnitLink, , uint256 timestamp, ) = s_linkToNativeFeed.latestRoundData(); @@ -135,7 +133,7 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { // | Cost Estimation | // ================================================================ - // @inheritdoc IFunctionsBilling + /// @inheritdoc IFunctionsBilling function estimateCost( uint64 subscriptionId, bytes calldata data, @@ -152,7 +150,7 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { return _calculateCostEstimate(callbackGasLimit, gasPriceWei, donFee, adminFee); } - // @notice Estimate the cost in Juels of LINK + /// @notice Estimate the cost in Juels of LINK // that will be charged to a subscription to fulfill a Functions request // Gas Price can be overestimated to account for flucuations between request and response time function _calculateCostEstimate( @@ -165,7 +163,7 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { uint256 gasPriceWithOverestimation = gasPriceWei + ((gasPriceWei * s_config.fulfillmentGasPriceOverEstimationBP) / 10_000); - // @NOTE: Basis Points are 1/100th of 1%, divide by 10_000 to bring back to original units + /// @NOTE: Basis Points are 1/100th of 1%, divide by 10_000 to bring back to original units uint96 juelsPerGas = _getJuelsPerGas(gasPriceWithOverestimation); uint256 estimatedGasReimbursement = juelsPerGas * executionGas; @@ -178,12 +176,10 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { // | Billing | // ================================================================ - // @notice Initiate the billing process for an Functions request - // @dev Only callable by the Functions Router - // @param data - Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - // @param requestDataVersion - Version number of the structure of the request data - // @param billing - Billing configuration for the request - // @return commitment - The parameters of the request that must be held consistent at response time + /// @notice Initiate the billing process for an Functions request + /// @dev Only callable by the Functions Router + /// @param request - Chainlink Functions request data, see FunctionsResponse.RequestMeta for the structure + /// @return commitment - The parameters of the request that must be held consistent at response time function _startBilling( FunctionsResponse.RequestMeta memory request ) internal returns (FunctionsResponse.Commitment memory commitment) { @@ -233,8 +229,8 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { return commitment; } - // @notice Generate a keccak hash request ID - // @dev uses the number of requests that the consumer of a subscription has sent as a nonce + /// @notice Generate a keccak hash request ID + /// @dev uses the number of requests that the consumer of a subscription has sent as a nonce function _computeRequestId( address don, address client, @@ -244,13 +240,13 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { return keccak256(abi.encode(don, client, subscriptionId, nonce)); } - // @notice Finalize billing process for an Functions request by sending a callback to the Client contract and then charging the subscription - // @param requestId identifier for the request that was generated by the Registry in the beginBilling commitment - // @param response response data from DON consensus - // @param err error from DON consensus - // @return result fulfillment result - // @dev Only callable by a node that has been approved on the Coordinator - // @dev simulated offchain to determine if sufficient balance is present to fulfill the request + /// @notice Finalize billing process for an Functions request by sending a callback to the Client contract and then charging the subscription + /// @param requestId identifier for the request that was generated by the Registry in the beginBilling commitment + /// @param response response data from DON consensus + /// @param err error from DON consensus + /// @return result fulfillment result + /// @dev Only callable by a node that has been approved on the Coordinator + /// @dev simulated offchain to determine if sufficient balance is present to fulfill the request function _fulfillAndBill( bytes32 requestId, bytes memory response, @@ -305,9 +301,9 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { // | Request Timeout | // ================================================================ - // @inheritdoc IFunctionsBilling - // @dev Only callable by the Router - // @dev Used by FunctionsRouter.sol during timeout of a request + /// @inheritdoc IFunctionsBilling + /// @dev Only callable by the Router + /// @dev Used by FunctionsRouter.sol during timeout of a request function deleteCommitment(bytes32 requestId) external override onlyRouter { // Delete commitment delete s_requestCommitments[requestId]; @@ -318,7 +314,7 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { // | Fund withdrawal | // ================================================================ - // @inheritdoc IFunctionsBilling + /// @inheritdoc IFunctionsBilling function oracleWithdraw(address recipient, uint96 amount) external { _disperseFeePool(); @@ -331,8 +327,8 @@ abstract contract FunctionsBilling is Routable, IFunctionsBilling { IFunctionsSubscriptions(address(_getRouter())).oracleWithdraw(recipient, amount); } - // @inheritdoc IFunctionsBilling - // @dev Only callable by the Coordinator owner + /// @inheritdoc IFunctionsBilling + /// @dev Only callable by the Coordinator owner function oracleWithdrawAll() external { _onlyOwner(); _disperseFeePool(); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsClient.sol b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsClient.sol index 41db3e98b29..ecbbbd928fe 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsClient.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsClient.sol @@ -6,8 +6,8 @@ import {IFunctionsClient} from "./interfaces/IFunctionsClient.sol"; import {FunctionsRequest} from "./libraries/FunctionsRequest.sol"; -// @title The Chainlink Functions client contract -// @notice Contract developers can inherit this contract in order to make Chainlink Functions requests +/// @title The Chainlink Functions client contract +/// @notice Contract developers can inherit this contract in order to make Chainlink Functions requests abstract contract FunctionsClient is IFunctionsClient { using FunctionsRequest for FunctionsRequest.Request; @@ -22,11 +22,11 @@ abstract contract FunctionsClient is IFunctionsClient { i_router = IFunctionsRouter(router); } - // @notice Sends a Chainlink Functions request - // @param data The CBOR encoded bytes data for a Functions request - // @param subscriptionId The subscription ID that will be charged to service the request - // @param callbackGasLimit the amount of gas that will be available for the fulfillment callback - // @return requestId The generated request ID for this request + /// @notice Sends a Chainlink Functions request + /// @param data The CBOR encoded bytes data for a Functions request + /// @param subscriptionId The subscription ID that will be charged to service the request + /// @param callbackGasLimit the amount of gas that will be available for the fulfillment callback + /// @return requestId The generated request ID for this request function _sendRequest( bytes memory data, uint64 subscriptionId, @@ -44,14 +44,14 @@ abstract contract FunctionsClient is IFunctionsClient { return requestId; } - // @notice User defined function to handle a response from the DON - // @param requestId The request ID, returned by sendRequest() - // @param response Aggregated response from the execution of the user's source code - // @param err Aggregated error from the execution of the user code or from the execution pipeline - // @dev Either response or error parameter will be set, but never both + /// @notice User defined function to handle a response from the DON + /// @param requestId The request ID, returned by sendRequest() + /// @param response Aggregated response from the execution of the user's source code + /// @param err Aggregated error from the execution of the user code or from the execution pipeline + /// @dev Either response or error parameter will be set, but never both function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal virtual; - // @inheritdoc IFunctionsClient + /// @inheritdoc IFunctionsClient function handleOracleFulfillment(bytes32 requestId, bytes memory response, bytes memory err) external override { if (msg.sender != address(i_router)) { revert OnlyRouterCanFulfill(); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsCoordinator.sol b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsCoordinator.sol index aa7b1d5c7e1..540b382d652 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsCoordinator.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsCoordinator.sol @@ -9,15 +9,15 @@ import {FunctionsBilling} from "./FunctionsBilling.sol"; import {OCR2Base} from "./ocr/OCR2Base.sol"; import {FunctionsResponse} from "./libraries/FunctionsResponse.sol"; -// @title Functions Coordinator contract -// @notice Contract that nodes of a Decentralized Oracle Network (DON) interact with -// @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. +/// @title Functions Coordinator contract +/// @notice Contract that nodes of a Decentralized Oracle Network (DON) interact with +/// @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilling { using FunctionsResponse for FunctionsResponse.RequestMeta; using FunctionsResponse for FunctionsResponse.Commitment; using FunctionsResponse for FunctionsResponse.FulfillResult; - // @inheritdoc ITypeAndVersion + /// @inheritdoc ITypeAndVersion string public constant override typeAndVersion = "Functions Coordinator v1.0.0"; event OracleRequest( @@ -47,7 +47,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli address linkToNativeFeed ) OCR2Base(true) FunctionsBilling(router, config, linkToNativeFeed) {} - // @inheritdoc IFunctionsCoordinator + /// @inheritdoc IFunctionsCoordinator function getThresholdPublicKey() external view override returns (bytes memory) { if (s_thresholdPublicKey.length == 0) { revert EmptyPublicKey(); @@ -55,7 +55,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli return s_thresholdPublicKey; } - // @inheritdoc IFunctionsCoordinator + /// @inheritdoc IFunctionsCoordinator function setThresholdPublicKey(bytes calldata thresholdPublicKey) external override onlyOwner { if (thresholdPublicKey.length == 0) { revert EmptyPublicKey(); @@ -63,7 +63,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli s_thresholdPublicKey = thresholdPublicKey; } - // @inheritdoc IFunctionsCoordinator + /// @inheritdoc IFunctionsCoordinator function getDONPublicKey() external view override returns (bytes memory) { if (s_donPublicKey.length == 0) { revert EmptyPublicKey(); @@ -71,7 +71,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli return s_donPublicKey; } - // @inheritdoc IFunctionsCoordinator + /// @inheritdoc IFunctionsCoordinator function setDONPublicKey(bytes calldata donPublicKey) external override onlyOwner { if (donPublicKey.length == 0) { revert EmptyPublicKey(); @@ -79,7 +79,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli s_donPublicKey = donPublicKey; } - // @dev check if node is in current transmitter list + /// @dev check if node is in current transmitter list function _isTransmitter(address node) internal view returns (bool) { address[] memory nodes = s_transmitters; // Bounded by "maxNumOracles" on OCR2Abstract.sol @@ -91,7 +91,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli return false; } - // @inheritdoc IFunctionsCoordinator + /// @inheritdoc IFunctionsCoordinator function startRequest( FunctionsResponse.RequestMeta calldata request ) external override onlyRouter returns (FunctionsResponse.Commitment memory commitment) { @@ -113,19 +113,19 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli return commitment; } - // DON fees are pooled together. If the OCR configuration is going to change, these need to be distributed. + /// @dev DON fees are pooled together. If the OCR configuration is going to change, these need to be distributed. function _beforeSetConfig(uint8 /* _f */, bytes memory /* _onchainConfig */) internal override { if (_getTransmitters().length > 0) { _disperseFeePool(); } } - // Used by FunctionsBilling.sol + /// @dev Used by FunctionsBilling.sol function _getTransmitters() internal view override returns (address[] memory) { return s_transmitters; } - // Report hook called within OCR2Base.sol + /// @dev Report hook called within OCR2Base.sol function _report( uint256 /*initialGas*/, address /*transmitter*/, @@ -171,7 +171,7 @@ contract FunctionsCoordinator is OCR2Base, IFunctionsCoordinator, FunctionsBilli } } - // Used in FunctionsBilling.sol + /// @dev Used in FunctionsBilling.sol function _onlyOwner() internal view override { _validateOwnership(); } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsRouter.sol b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsRouter.sol index 1d09b1e6739..41cd90341f3 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsRouter.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsRouter.sol @@ -137,20 +137,20 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, // | Configuration | // ================================================================ - // @notice The identifier of the route to retrieve the address of the access control contract + /// @notice The identifier of the route to retrieve the address of the access control contract // The access control contract controls which accounts can manage subscriptions - // @return id - bytes32 id that can be passed to the "getContractById" of the Router + /// @return id - bytes32 id that can be passed to the "getContractById" of the Router function getConfig() external view returns (Config memory) { return s_config; } - // @notice The router configuration + /// @notice The router configuration function updateConfig(Config memory config) public onlyOwner { s_config = config; emit ConfigUpdated(config); } - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function isValidCallbackGasLimit(uint64 subscriptionId, uint32 callbackGasLimit) public view { uint8 callbackGasLimitsIndexSelector = uint8(getFlags(subscriptionId)[MAX_CALLBACK_GAS_LIMIT_FLAGS_INDEX]); if (callbackGasLimitsIndexSelector >= s_config.maxCallbackGasLimits.length) { @@ -162,22 +162,22 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, } } - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function getAdminFee() external view override returns (uint72) { return s_config.adminFee; } - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function getAllowListId() external view override returns (bytes32) { return s_allowListId; } - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function setAllowListId(bytes32 allowListId) external override onlyOwner { s_allowListId = allowListId; } - // Used within FunctionsSubscriptions.sol + /// @dev Used within FunctionsSubscriptions.sol function _getMaxConsumers() internal view override returns (uint16) { return s_config.maxConsumersPerSubscription; } @@ -191,7 +191,7 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, // | Requests | // ================================================================ - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function sendRequest( uint64 subscriptionId, bytes calldata data, @@ -203,7 +203,7 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, return _sendRequest(donId, coordinator, subscriptionId, data, dataVersion, callbackGasLimit); } - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function sendRequestToProposed( uint64 subscriptionId, bytes calldata data, @@ -299,7 +299,7 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, // | Responses | // ================================================================ - // @inheritdoc IFunctionsRouter + /// @inheritdoc IFunctionsRouter function fulfill( bytes memory response, bytes memory err, @@ -474,7 +474,7 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, // | Route methods | // ================================================================ - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function getContractById(bytes32 id) public view override returns (address) { address currentImplementation = s_route[id]; if (currentImplementation == address(0)) { @@ -483,7 +483,7 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, return currentImplementation; } - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function getProposedContractById(bytes32 id) public view override returns (address) { // Iterations will not exceed MAX_PROPOSAL_SET_LENGTH for (uint8 i = 0; i < s_proposedContractSet.ids.length; ++i) { @@ -498,12 +498,12 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, // | Contract Proposal methods | // ================================================================ - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function getProposedContractSet() external view override returns (bytes32[] memory, address[] memory) { return (s_proposedContractSet.ids, s_proposedContractSet.to); } - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function proposeContractsUpdate( bytes32[] memory proposedContractSetIds, address[] memory proposedContractSetAddresses @@ -535,7 +535,7 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, s_proposedContractSet = ContractProposalSet({ids: proposedContractSetIds, to: proposedContractSetAddresses}); } - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function updateContracts() external override onlyOwner { // Iterations will not exceed MAX_PROPOSAL_SET_LENGTH for (uint256 i = 0; i < s_proposedContractSet.ids.length; ++i) { @@ -553,17 +553,17 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, // ================================================================ // Favoring internal functions over actual modifiers to reduce contract size - // Used within FunctionsSubscriptions.sol + /// @dev Used within FunctionsSubscriptions.sol function _whenNotPaused() internal view override { _requireNotPaused(); } - // Used within FunctionsSubscriptions.sol + /// @dev Used within FunctionsSubscriptions.sol function _onlyRouterOwner() internal view override { _validateOwnership(); } - // Used within FunctionsSubscriptions.sol + /// @dev Used within FunctionsSubscriptions.sol function _onlySenderThatAcceptedToS() internal view override { address currentImplementation = s_route[s_allowListId]; if (currentImplementation == address(0)) { @@ -575,12 +575,12 @@ contract FunctionsRouter is IFunctionsRouter, FunctionsSubscriptions, Pausable, } } - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function pause() external override onlyOwner { _pause(); } - // @inheritdoc IRouterBase + /// @inheritdoc IFunctionsRouter function unpause() external override onlyOwner { _unpause(); } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsSubscriptions.sol b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsSubscriptions.sol index cab8e2b0803..864225fd38c 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/FunctionsSubscriptions.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/FunctionsSubscriptions.sol @@ -13,9 +13,9 @@ import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.0/contracts/tok import {SafeERC20} from "../../../vendor/openzeppelin-solidity/v4.8.0/contracts/token/ERC20/utils/SafeERC20.sol"; import {SafeCast} from "../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/math/SafeCast.sol"; -// @title Functions Subscriptions contract -// @notice Contract that coordinates payment from users to the nodes of the Decentralized Oracle Network (DON). -// @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. +/// @title Functions Subscriptions contract +/// @notice Contract that coordinates payment from users to the nodes of the Decentralized Oracle Network (DON). +/// @dev THIS CONTRACT HAS NOT GONE THROUGH ANY SECURITY REVIEW. DO NOT USE IN PROD. abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Receiver { using SafeERC20 for IERC20; using FunctionsResponse for FunctionsResponse.Commitment; @@ -32,7 +32,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // sent tokens using transfer and so we may need to use recoverFunds. uint96 private s_totalLinkBalance; - // @dev NOP balances are held as a single amount. The breakdown is held by the Coordinator. + /// @dev NOP balances are held as a single amount. The breakdown is held by the Coordinator. mapping(address coordinator => uint96 balanceJuelsLink) private s_withdrawableTokens; // ================================================================ @@ -96,8 +96,8 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // | Request/Response | // ================================================================ - // @notice Sets a request as in-flight - // @dev Only callable within the Router + /// @notice Sets a request as in-flight + /// @dev Only callable within the Router function _markRequestInFlight(address client, uint64 subscriptionId, uint96 estimatedTotalCostJuels) internal { // Earmark subscription funds s_subscriptions[subscriptionId].blockedBalance += estimatedTotalCostJuels; @@ -106,8 +106,8 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece s_consumers[client][subscriptionId].initiatedRequests += 1; } - // @notice Moves funds from one subscription account to another. - // @dev Only callable by the Coordinator contract that is saved in the request commitment + /// @notice Moves funds from one subscription account to another. + /// @dev Only callable by the Coordinator contract that is saved in the request commitment function _pay( uint64 subscriptionId, uint96 estimatedTotalCostJuels, @@ -149,14 +149,14 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // | Owner methods | // ================================================================ - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function ownerCancelSubscription(uint64 subscriptionId) external override { _onlyRouterOwner(); _isExistingSubscription(subscriptionId); _cancelSubscriptionHelper(subscriptionId, s_subscriptions[subscriptionId].owner, false); } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function recoverFunds(address to) external override { _onlyRouterOwner(); uint256 externalBalance = i_linkToken.balanceOf(address(this)); @@ -173,7 +173,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // | Fund withdrawal | // ================================================================ - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function oracleWithdraw(address recipient, uint96 amount) external override { _whenNotPaused(); @@ -189,10 +189,10 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece i_linkToken.safeTransfer(recipient, amount); } - // @notice Owner withdraw LINK earned through admin fees - // @notice If amount is 0 the full balance will be withdrawn - // @param recipient where to send the funds - // @param amount amount to withdraw + /// @notice Owner withdraw LINK earned through admin fees + /// @notice If amount is 0 the full balance will be withdrawn + /// @param recipient where to send the funds + /// @param amount amount to withdraw function ownerWithdraw(address recipient, uint96 amount) external { _onlyRouterOwner(); if (amount == 0) { @@ -213,11 +213,11 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // ================================================================ // This function is to be invoked when using LINK.transferAndCall - // @dev Note to fund the subscription, use transferAndCall. For example - // @dev LINKTOKEN.transferAndCall( - // @dev address(ROUTER), - // @dev amount, - // @dev abi.encode(subscriptionId)); + /// @dev Note to fund the subscription, use transferAndCall. For example + /// @dev LINKTOKEN.transferAndCall( + /// @dev address(ROUTER), + /// @dev amount, + /// @dev abi.encode(subscriptionId)); function onTokenTransfer(address /* sender */, uint256 amount, bytes calldata data) external override { _whenNotPaused(); if (msg.sender != address(i_linkToken)) { @@ -242,17 +242,17 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // | Subscription management | // ================================================================ - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function getTotalBalance() external view override returns (uint96) { return s_totalLinkBalance; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function getSubscriptionCount() external view override returns (uint64) { return s_currentSubscriptionId; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function getSubscription(uint64 subscriptionId) public view override returns (Subscription memory) { _isExistingSubscription(subscriptionId); return s_subscriptions[subscriptionId]; @@ -279,26 +279,26 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece return subscriptions; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function getConsumer(address client, uint64 subscriptionId) public view override returns (Consumer memory) { return s_consumers[client][subscriptionId]; } - // Used within this file & FunctionsRouter.sol + /// @dev Used within this file & FunctionsRouter.sol function _isExistingSubscription(uint64 subscriptionId) internal view { if (s_subscriptions[subscriptionId].owner == address(0)) { revert InvalidSubscription(); } } - // Used within FunctionsRouter.sol + /// @dev Used within FunctionsRouter.sol function _isAllowedConsumer(address client, uint64 subscriptionId) internal view { if (!s_consumers[client][subscriptionId].allowed) { revert InvalidConsumer(); } } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function createSubscription() external override returns (uint64 subscriptionId) { _whenNotPaused(); _onlySenderThatAcceptedToS(); @@ -318,7 +318,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece return subscriptionId; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function createSubscriptionWithConsumer(address consumer) external override returns (uint64 subscriptionId) { _whenNotPaused(); _onlySenderThatAcceptedToS(); @@ -342,7 +342,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece return subscriptionId; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function proposeSubscriptionOwnerTransfer(uint64 subscriptionId, address newOwner) external override { _whenNotPaused(); _onlySubscriptionOwner(subscriptionId); @@ -356,7 +356,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece emit SubscriptionOwnerTransferRequested(subscriptionId, msg.sender, newOwner); } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function acceptSubscriptionOwnerTransfer(uint64 subscriptionId) external override { _whenNotPaused(); _onlySenderThatAcceptedToS(); @@ -371,7 +371,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece emit SubscriptionOwnerTransferred(subscriptionId, previousOwner, msg.sender); } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function removeConsumer(uint64 subscriptionId, address consumer) external override { _whenNotPaused(); _onlySubscriptionOwner(subscriptionId); @@ -397,10 +397,10 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece emit SubscriptionConsumerRemoved(subscriptionId, consumer); } - // overriden in FunctionsRouter.sol + /// @dev Overriden in FunctionsRouter.sol function _getMaxConsumers() internal view virtual returns (uint16); - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function addConsumer(uint64 subscriptionId, address consumer) external override { _whenNotPaused(); _onlySubscriptionOwner(subscriptionId); @@ -471,7 +471,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece _cancelSubscriptionHelper(subscriptionId, to, true); } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function pendingRequestExists(uint64 subscriptionId) public view override returns (bool) { address[] memory consumers = s_subscriptions[subscriptionId].consumers; // NOTE: loop iterations are bounded by config.maxConsumers @@ -484,14 +484,14 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece return false; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function setFlags(uint64 subscriptionId, bytes32 flags) external override { _onlyRouterOwner(); _isExistingSubscription(subscriptionId); s_subscriptions[subscriptionId].flags = flags; } - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function getFlags(uint64 subscriptionId) public view returns (bytes32) { return s_subscriptions[subscriptionId].flags; } @@ -500,7 +500,7 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece // | Request Timeout | // ================================================================ - // @inheritdoc IFunctionsSubscriptions + /// @inheritdoc IFunctionsSubscriptions function timeoutRequests(FunctionsResponse.Commitment[] calldata requestsToTimeoutByCommitment) external override { _whenNotPaused(); @@ -545,12 +545,12 @@ abstract contract FunctionsSubscriptions is IFunctionsSubscriptions, IERC677Rece } } - // Overriden in FunctionsRouter.sol + /// @dev Overriden in FunctionsRouter.sol function _onlySenderThatAcceptedToS() internal virtual; - // Overriden in FunctionsRouter.sol + /// @dev Overriden in FunctionsRouter.sol function _onlyRouterOwner() internal virtual; - // Overriden in FunctionsRouter.sol + /// @dev Overriden in FunctionsRouter.sol function _whenNotPaused() internal virtual; } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/Routable.sol b/contracts/src/v0.8/functions/dev/1_0_0/Routable.sol index 8c09eba5d79..b50b1e603f9 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/Routable.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/Routable.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.19; import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol"; import {IOwnableFunctionsRouter} from "./interfaces/IOwnableFunctionsRouter.sol"; -// @title This abstract should be inherited by contracts that will be used -// as the destinations to a route (id=>contract) on the Router. -// It provides a Router getter and modifiers +/// @title This abstract should be inherited by contracts that will be used +/// as the destinations to a route (id=>contract) on the Router. +/// It provides a Router getter and modifiers. abstract contract Routable is ITypeAndVersion { IOwnableFunctionsRouter private immutable i_router; @@ -14,7 +14,7 @@ abstract contract Routable is ITypeAndVersion { error OnlyCallableByRouter(); error OnlyCallableByRouterOwner(); - // @dev Initializes the contract. + /// @dev Initializes the contract. constructor(address router) { if (router == address(0)) { revert RouterMustBeSet(); @@ -22,12 +22,12 @@ abstract contract Routable is ITypeAndVersion { i_router = IOwnableFunctionsRouter(router); } - // @notice Return the Router + /// @notice Return the Router function _getRouter() internal view returns (IOwnableFunctionsRouter router) { return i_router; } - // @notice Reverts if called by anyone other than the router. + /// @notice Reverts if called by anyone other than the router. modifier onlyRouter() { if (msg.sender != address(i_router)) { revert OnlyCallableByRouter(); @@ -35,7 +35,7 @@ abstract contract Routable is ITypeAndVersion { _; } - // @notice Reverts if called by anyone other than the router owner. + /// @notice Reverts if called by anyone other than the router owner. modifier onlyRouterOwner() { if (msg.sender != i_router.owner()) { revert OnlyCallableByRouterOwner(); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/accessControl/TermsOfServiceAllowList.sol b/contracts/src/v0.8/functions/dev/1_0_0/accessControl/TermsOfServiceAllowList.sol index 2ce107c9861..c4bd524b522 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/accessControl/TermsOfServiceAllowList.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/accessControl/TermsOfServiceAllowList.sol @@ -10,12 +10,12 @@ import {ConfirmedOwner} from "../../../../shared/access/ConfirmedOwner.sol"; import {Address} from "../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/Address.sol"; import {EnumerableSet} from "../../../../vendor/openzeppelin-solidity/v4.8.0/contracts/utils/structs/EnumerableSet.sol"; -// @notice A contract to handle access control of subscription management dependent on signing a Terms of Service +/// @notice A contract to handle access control of subscription management dependent on signing a Terms of Service contract TermsOfServiceAllowList is ITermsOfServiceAllowList, IAccessController, ITypeAndVersion, ConfirmedOwner { using Address for address; using EnumerableSet for EnumerableSet.AddressSet; - // @inheritdoc ITypeAndVersion + /// @inheritdoc ITypeAndVersion string public constant override typeAndVersion = "Functions Terms of Service Allow List v1.0.0"; EnumerableSet.AddressSet private s_allowedSenders; @@ -53,14 +53,14 @@ contract TermsOfServiceAllowList is ITermsOfServiceAllowList, IAccessController, // | Configuration | // ================================================================ - // @notice Gets the contracts's configuration - // @return config + /// @notice Gets the contracts's configuration + /// @return config function getConfig() external view returns (Config memory) { return s_config; } - // @notice Sets the contracts's configuration - // @param config - See the contents of the TermsOfServiceAllowList.Config struct for more information + /// @notice Sets the contracts's configuration + /// @param config - See the contents of the TermsOfServiceAllowList.Config struct for more information function updateConfig(Config memory config) public onlyOwner { s_config = config; emit ConfigUpdated(config); @@ -70,12 +70,12 @@ contract TermsOfServiceAllowList is ITermsOfServiceAllowList, IAccessController, // | Allow methods | // ================================================================ - // @inheritdoc ITermsOfServiceAllowList + /// @inheritdoc ITermsOfServiceAllowList function getMessage(address acceptor, address recipient) public pure override returns (bytes32) { return keccak256(abi.encodePacked(acceptor, recipient)); } - // @inheritdoc ITermsOfServiceAllowList + /// @inheritdoc ITermsOfServiceAllowList function acceptTermsOfService(address acceptor, address recipient, bytes32 r, bytes32 s, uint8 v) external override { if (s_blockedSenders[recipient]) { revert RecipientIsBlocked(); @@ -102,12 +102,12 @@ contract TermsOfServiceAllowList is ITermsOfServiceAllowList, IAccessController, emit AddedAccess(recipient); } - // @inheritdoc ITermsOfServiceAllowList + /// @inheritdoc ITermsOfServiceAllowList function getAllAllowedSenders() external view override returns (address[] memory) { return s_allowedSenders.values(); } - // @inheritdoc IAccessController + /// @inheritdoc IAccessController function hasAccess(address user, bytes calldata /* data */) external view override returns (bool) { if (!s_config.enabled) { return true; @@ -119,7 +119,7 @@ contract TermsOfServiceAllowList is ITermsOfServiceAllowList, IAccessController, // | Block methods | // ================================================================ - // @inheritdoc ITermsOfServiceAllowList + /// @inheritdoc ITermsOfServiceAllowList function isBlockedSender(address sender) external view override returns (bool) { if (!s_config.enabled) { return false; @@ -127,14 +127,14 @@ contract TermsOfServiceAllowList is ITermsOfServiceAllowList, IAccessController, return s_blockedSenders[sender]; } - // @inheritdoc ITermsOfServiceAllowList + /// @inheritdoc ITermsOfServiceAllowList function blockSender(address sender) external override onlyOwner { s_allowedSenders.remove(sender); s_blockedSenders[sender] = true; emit BlockedAccess(sender); } - // @inheritdoc ITermsOfServiceAllowList + /// @inheritdoc ITermsOfServiceAllowList function unblockSender(address sender) external override onlyOwner { s_blockedSenders[sender] = false; emit UnblockedAccess(sender); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/accessControl/interfaces/ITermsOfServiceAllowList.sol b/contracts/src/v0.8/functions/dev/1_0_0/accessControl/interfaces/ITermsOfServiceAllowList.sol index b83375ee01f..af4daa18bc3 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/accessControl/interfaces/ITermsOfServiceAllowList.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/accessControl/interfaces/ITermsOfServiceAllowList.sol @@ -1,40 +1,40 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -// @notice A contract to handle access control of subscription management dependent on signing a Terms of Service +/// @notice A contract to handle access control of subscription management dependent on signing a Terms of Service interface ITermsOfServiceAllowList { - // @notice Return the message data for the proof given to accept the Terms of Service - // @param acceptor - The wallet address that has accepted the Terms of Service on the UI - // @param recipient - The recipient address that the acceptor is taking responsibility for - // @return Hash of the message data + /// @notice Return the message data for the proof given to accept the Terms of Service + /// @param acceptor - The wallet address that has accepted the Terms of Service on the UI + /// @param recipient - The recipient address that the acceptor is taking responsibility for + /// @return Hash of the message data function getMessage(address acceptor, address recipient) external pure returns (bytes32); - // @notice Check if the address is blocked for usage - // @param sender The transaction sender's address - // @return True or false + /// @notice Check if the address is blocked for usage + /// @param sender The transaction sender's address + /// @return True or false function isBlockedSender(address sender) external returns (bool); - // @notice Get a list of all allowed senders - // @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed - // to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that - // this function has an unbounded cost, and using it as part of a state-changing function may render the function - // uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. - // @return addresses - all allowed addresses + /// @notice Get a list of all allowed senders + /// @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed + /// to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that + /// this function has an unbounded cost, and using it as part of a state-changing function may render the function + /// uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. + /// @return addresses - all allowed addresses function getAllAllowedSenders() external view returns (address[] memory); - // @notice Allows access to the sender based on acceptance of the Terms of Service - // @param acceptor - The wallet address that has accepted the Terms of Service on the UI - // @param recipient - The recipient address that the acceptor is taking responsibility for - // @param r - ECDSA signature r data produced by the Chainlink Functions Subscription UI - // @param s - ECDSA signature s produced by the Chainlink Functions Subscription UI - // @param v - ECDSA signature v produced by the Chainlink Functions Subscription UI + /// @notice Allows access to the sender based on acceptance of the Terms of Service + /// @param acceptor - The wallet address that has accepted the Terms of Service on the UI + /// @param recipient - The recipient address that the acceptor is taking responsibility for + /// @param r - ECDSA signature r data produced by the Chainlink Functions Subscription UI + /// @param s - ECDSA signature s produced by the Chainlink Functions Subscription UI + /// @param v - ECDSA signature v produced by the Chainlink Functions Subscription UI function acceptTermsOfService(address acceptor, address recipient, bytes32 r, bytes32 s, uint8 v) external; - // @notice Removes a sender's access if already authorized, and disallows re-accepting the Terms of Service - // @param sender - Address of the sender to block + /// @notice Removes a sender's access if already authorized, and disallows re-accepting the Terms of Service + /// @param sender - Address of the sender to block function blockSender(address sender) external; - // @notice Re-allows a previously blocked sender to accept the Terms of Service - // @param sender - Address of the sender to unblock + /// @notice Re-allows a previously blocked sender to accept the Terms of Service + /// @param sender - Address of the sender to unblock function unblockSender(address sender) external; } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/example/FunctionsClientExample.sol b/contracts/src/v0.8/functions/dev/1_0_0/example/FunctionsClientExample.sol index 5feee704ef5..f0f154c07b2 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/example/FunctionsClientExample.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/example/FunctionsClientExample.sol @@ -5,9 +5,7 @@ import {FunctionsClient} from "../FunctionsClient.sol"; import {ConfirmedOwner} from "../../../../shared/access/ConfirmedOwner.sol"; import {FunctionsRequest} from "../libraries/FunctionsRequest.sol"; -/** - * @title Chainlink Functions example Client contract implementation - */ +/// @title Chainlink Functions example Client contract implementation contract FunctionsClientExample is FunctionsClient, ConfirmedOwner { using FunctionsRequest for FunctionsRequest.Request; @@ -23,13 +21,11 @@ contract FunctionsClientExample is FunctionsClient, ConfirmedOwner { constructor(address router) FunctionsClient(router) ConfirmedOwner(msg.sender) {} - /** - * @notice Send a simple request - * @param source JavaScript source code - * @param encryptedSecretsReferences Encrypted secrets payload - * @param args List of arguments accessible from within the source code - * @param subscriptionId Billing ID - */ + /// @notice Send a simple request + /// @param source JavaScript source code + /// @param encryptedSecretsReferences Encrypted secrets payload + /// @param args List of arguments accessible from within the source code + /// @param subscriptionId Billing ID function sendRequest( string calldata source, bytes calldata encryptedSecretsReferences, @@ -44,13 +40,11 @@ contract FunctionsClientExample is FunctionsClient, ConfirmedOwner { s_lastRequestId = _sendRequest(req.encodeCBOR(), subscriptionId, MAX_CALLBACK_GAS, jobId); } - /** - * @notice Store latest result/error - * @param requestId The request ID, returned by sendRequest() - * @param response Aggregated response from the user code - * @param err Aggregated error from the user code or from the execution pipeline - * Either response or error parameter will be set, but never both - */ + /// @notice Store latest result/error + /// @param requestId The request ID, returned by sendRequest() + /// @param response Aggregated response from the user code + /// @param err Aggregated error from the user code or from the execution pipeline + /// @dev Either response or error parameter will be set, but never both function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override { if (s_lastRequestId != requestId) { revert UnexpectedRequestID(requestId); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsBilling.sol b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsBilling.sol index c9730da899b..6291d05e57c 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsBilling.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsBilling.sol @@ -1,27 +1,27 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -// @title Chainlink Functions DON billing interface. +/// @title Chainlink Functions DON billing interface. interface IFunctionsBilling { - // @notice Return the current conversion from WEI of ETH to LINK from the configured Chainlink data feed - // @return weiPerUnitLink - The amount of WEI in one LINK + /// @notice Return the current conversion from WEI of ETH to LINK from the configured Chainlink data feed + /// @return weiPerUnitLink - The amount of WEI in one LINK function getWeiPerUnitLink() external view returns (uint256); - // @notice Determine the fee that will be split between Node Operators for servicing a request - // @param requestCBOR - CBOR encoded Chainlink Functions request data, use FunctionsRequest library to encode a request - // @return fee - Cost in Juels (1e18) of LINK + /// @notice Determine the fee that will be split between Node Operators for servicing a request + /// @param requestCBOR - CBOR encoded Chainlink Functions request data, use FunctionsRequest library to encode a request + /// @return fee - Cost in Juels (1e18) of LINK function getDONFee(bytes memory requestCBOR) external view returns (uint72); - // @notice Determine the fee that will be paid to the Router owner for operating the network - // @return fee - Cost in Juels (1e18) of LINK + /// @notice Determine the fee that will be paid to the Router owner for operating the network + /// @return fee - Cost in Juels (1e18) of LINK function getAdminFee() external view returns (uint72); - // @notice Estimate the total cost that will be charged to a subscription to make a request: transmitter gas re-reimbursement, plus DON fee, plus Registry fee - // @param - subscriptionId An identifier of the billing account - // @param - data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request - // @param - callbackGasLimit Gas limit for the fulfillment callback - // @param - gasPriceWei The blockchain's gas price to estimate with - // @return - billedCost Cost in Juels (1e18) of LINK + /// @notice Estimate the total cost that will be charged to a subscription to make a request: transmitter gas re-reimbursement, plus DON fee, plus Registry fee + /// @param - subscriptionId An identifier of the billing account + /// @param - data Encoded Chainlink Functions request data, use FunctionsClient API to encode a request + /// @param - callbackGasLimit Gas limit for the fulfillment callback + /// @param - gasPriceWei The blockchain's gas price to estimate with + /// @return - billedCost Cost in Juels (1e18) of LINK function estimateCost( uint64 subscriptionId, bytes calldata data, @@ -29,16 +29,16 @@ interface IFunctionsBilling { uint256 gasPriceWei ) external view returns (uint96); - // @notice Remove a request commitment that the Router has determined to be stale - // @param requestId - The request ID to remove + /// @notice Remove a request commitment that the Router has determined to be stale + /// @param requestId - The request ID to remove function deleteCommitment(bytes32 requestId) external; - // @notice Oracle withdraw LINK earned through fulfilling requests - // @notice If amount is 0 the full balance will be withdrawn - // @param recipient where to send the funds - // @param amount amount to withdraw + /// @notice Oracle withdraw LINK earned through fulfilling requests + /// @notice If amount is 0 the full balance will be withdrawn + /// @param recipient where to send the funds + /// @param amount amount to withdraw function oracleWithdraw(address recipient, uint96 amount) external; - // @notice Withdraw all LINK earned by Oracles through fulfilling requests + /// @notice Withdraw all LINK earned by Oracles through fulfilling requests function oracleWithdrawAll() external; } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsClient.sol b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsClient.sol index 5fbee58274e..f28a41666b5 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsClient.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsClient.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -// @title Chainlink Functions client interface. +/// @title Chainlink Functions client interface. interface IFunctionsClient { - // @notice Chainlink Functions response handler called by the Functions Router - // during fullilment from the designated transmitter node in an OCR round. - // @param requestId The requestId returned by FunctionsClient.sendRequest(). - // @param response Aggregated response from the request's source code. - // @param err Aggregated error either from the request's source code or from the execution pipeline. - // @dev Either response or error parameter will be set, but never both. + /// @notice Chainlink Functions response handler called by the Functions Router + /// during fullilment from the designated transmitter node in an OCR round. + /// @param requestId The requestId returned by FunctionsClient.sendRequest(). + /// @param response Aggregated response from the request's source code. + /// @param err Aggregated error either from the request's source code or from the execution pipeline. + /// @dev Either response or error parameter will be set, but never both. function handleOracleFulfillment(bytes32 requestId, bytes memory response, bytes memory err) external; } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsCoordinator.sol b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsCoordinator.sol index 5a0d07415bd..4e2bd703dc4 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsCoordinator.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsCoordinator.sol @@ -3,34 +3,34 @@ pragma solidity ^0.8.19; import {FunctionsResponse} from "../libraries/FunctionsResponse.sol"; -// @title Chainlink Functions DON Coordinator interface. +/// @title Chainlink Functions DON Coordinator interface. interface IFunctionsCoordinator { - // @notice Returns the DON's threshold encryption public key used to encrypt secrets - // @dev All nodes on the DON have separate key shares of the threshold decryption key - // and nodes must participate in a threshold decryption OCR round to decrypt secrets - // @return thresholdPublicKey the DON's threshold encryption public key + /// @notice Returns the DON's threshold encryption public key used to encrypt secrets + /// @dev All nodes on the DON have separate key shares of the threshold decryption key + /// and nodes must participate in a threshold decryption OCR round to decrypt secrets + /// @return thresholdPublicKey the DON's threshold encryption public key function getThresholdPublicKey() external view returns (bytes memory); - // @notice Sets the DON's threshold encryption public key used to encrypt secrets - // @dev Used to rotate the key - // @param thresholdPublicKey The new public key + /// @notice Sets the DON's threshold encryption public key used to encrypt secrets + /// @dev Used to rotate the key + /// @param thresholdPublicKey The new public key function setThresholdPublicKey(bytes calldata thresholdPublicKey) external; - // @notice Returns the DON's secp256k1 public key that is used to encrypt secrets - // @dev All nodes on the DON have the corresponding private key - // needed to decrypt the secrets encrypted with the public key - // @return publicKey the DON's public key + /// @notice Returns the DON's secp256k1 public key that is used to encrypt secrets + /// @dev All nodes on the DON have the corresponding private key + /// needed to decrypt the secrets encrypted with the public key + /// @return publicKey the DON's public key function getDONPublicKey() external view returns (bytes memory); - // @notice Sets DON's secp256k1 public key used to encrypt secrets - // @dev Used to rotate the key - // @param donPublicKey The new public key + /// @notice Sets DON's secp256k1 public key used to encrypt secrets + /// @dev Used to rotate the key + /// @param donPublicKey The new public key function setDONPublicKey(bytes calldata donPublicKey) external; - // @notice Receives a request to be emitted to the DON for processing - // @param request The request metadata - // @dev see the struct for field descriptions - // @return commitment - The parameters of the request that must be held consistent at response time + /// @notice Receives a request to be emitted to the DON for processing + /// @param request The request metadata + /// @dev see the struct for field descriptions + /// @return commitment - The parameters of the request that must be held consistent at response time function startRequest( FunctionsResponse.RequestMeta calldata request ) external returns (FunctionsResponse.Commitment memory commitment); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsRouter.sol b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsRouter.sol index ebc1dbd4538..5f93aac873e 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsRouter.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsRouter.sol @@ -3,29 +3,29 @@ pragma solidity ^0.8.19; import {FunctionsResponse} from "../libraries/FunctionsResponse.sol"; -// @title Chainlink Functions Router interface. +/// @title Chainlink Functions Router interface. interface IFunctionsRouter { - // @notice The identifier of the route to retrieve the address of the access control contract - // The access control contract controls which accounts can manage subscriptions - // @return id - bytes32 id that can be passed to the "getContractById" of the Router + /// @notice The identifier of the route to retrieve the address of the access control contract + /// The access control contract controls which accounts can manage subscriptions + /// @return id - bytes32 id that can be passed to the "getContractById" of the Router function getAllowListId() external view returns (bytes32); - // @notice Set the identifier of the route to retrieve the address of the access control contract - // The access control contract controls which accounts can manage subscriptions + /// @notice Set the identifier of the route to retrieve the address of the access control contract + /// The access control contract controls which accounts can manage subscriptions function setAllowListId(bytes32 allowListId) external; - // @notice Get the flat fee (in Juels of LINK) that will be paid to the Router owner for operation of the network - // @return adminFee + /// @notice Get the flat fee (in Juels of LINK) that will be paid to the Router owner for operation of the network + /// @return adminFee function getAdminFee() external view returns (uint72 adminFee); - // @notice Sends a request using the provided subscriptionId - // @param subscriptionId - A unique subscription ID allocated by billing system, - // a client can make requests from different contracts referencing the same subscription - // @param data - CBOR encoded Chainlink Functions request data, use FunctionsClient API to encode a request - // @param dataVersion - Gas limit for the fulfillment callback - // @param callbackGasLimit - Gas limit for the fulfillment callback - // @param donId - An identifier used to determine which route to send the request along - // @return requestId - A unique request identifier + /// @notice Sends a request using the provided subscriptionId + /// @param subscriptionId - A unique subscription ID allocated by billing system, + /// a client can make requests from different contracts referencing the same subscription + /// @param data - CBOR encoded Chainlink Functions request data, use FunctionsClient API to encode a request + /// @param dataVersion - Gas limit for the fulfillment callback + /// @param callbackGasLimit - Gas limit for the fulfillment callback + /// @param donId - An identifier used to determine which route to send the request along + /// @return requestId - A unique request identifier function sendRequest( uint64 subscriptionId, bytes calldata data, @@ -34,14 +34,14 @@ interface IFunctionsRouter { bytes32 donId ) external returns (bytes32); - // @notice Sends a request to the proposed contracts - // @param subscriptionId - A unique subscription ID allocated by billing system, - // a client can make requests from different contracts referencing the same subscription - // @param data - CBOR encoded Chainlink Functions request data, use FunctionsClient API to encode a request - // @param dataVersion - Gas limit for the fulfillment callback - // @param callbackGasLimit - Gas limit for the fulfillment callback - // @param donId - An identifier used to determine which route to send the request along - // @return requestId - A unique request identifier + /// @notice Sends a request to the proposed contracts + /// @param subscriptionId - A unique subscription ID allocated by billing system, + /// a client can make requests from different contracts referencing the same subscription + /// @param data - CBOR encoded Chainlink Functions request data, use FunctionsClient API to encode a request + /// @param dataVersion - Gas limit for the fulfillment callback + /// @param callbackGasLimit - Gas limit for the fulfillment callback + /// @param donId - An identifier used to determine which route to send the request along + /// @return requestId - A unique request identifier function sendRequestToProposed( uint64 subscriptionId, bytes calldata data, @@ -50,18 +50,18 @@ interface IFunctionsRouter { bytes32 donId ) external returns (bytes32); - // @notice Fulfill the request by: - // - calling back the data that the Oracle returned to the client contract - // - pay the DON for processing the request - // @dev Only callable by the Coordinator contract that is saved in the commitment - // @param response response data from DON consensus - // @param err error from DON consensus - // @param juelsPerGas - current rate of juels/gas - // @param costWithoutFulfillment - The cost of processing the request (in Juels of LINK ), without fulfillment - // @param transmitter - The Node that transmitted the OCR report - // @param commitment - The parameters of the request that must be held consistent between request and response time - // @return fulfillResult - - // @return callbackGasCostJuels - + /// @notice Fulfill the request by: + /// - calling back the data that the Oracle returned to the client contract + /// - pay the DON for processing the request + /// @dev Only callable by the Coordinator contract that is saved in the commitment + /// @param response response data from DON consensus + /// @param err error from DON consensus + /// @param juelsPerGas - current rate of juels/gas + /// @param costWithoutFulfillment - The cost of processing the request (in Juels of LINK ), without fulfillment + /// @param transmitter - The Node that transmitted the OCR report + /// @param commitment - The parameters of the request that must be held consistent between request and response time + /// @return fulfillResult - + /// @return callbackGasCostJuels - function fulfill( bytes memory response, bytes memory err, @@ -71,39 +71,39 @@ interface IFunctionsRouter { FunctionsResponse.Commitment memory commitment ) external returns (FunctionsResponse.FulfillResult, uint96); - // @notice Validate requested gas limit is below the subscription max. - // @param subscriptionId subscription ID - // @param callbackGasLimit desired callback gas limit + /// @notice Validate requested gas limit is below the subscription max. + /// @param subscriptionId subscription ID + /// @param callbackGasLimit desired callback gas limit function isValidCallbackGasLimit(uint64 subscriptionId, uint32 callbackGasLimit) external view; - // @notice Get the current contract given an ID - // @param id A bytes32 identifier for the route - // @return contract The current contract address + /// @notice Get the current contract given an ID + /// @param id A bytes32 identifier for the route + /// @return contract The current contract address function getContractById(bytes32 id) external view returns (address); - // @notice Get the proposed next contract given an ID - // @param id A bytes32 identifier for the route - // @return contract The current or proposed contract address + /// @notice Get the proposed next contract given an ID + /// @param id A bytes32 identifier for the route + /// @return contract The current or proposed contract address function getProposedContractById(bytes32 id) external view returns (address); - // @notice Return the latest proprosal set - // @return ids The identifiers of the contracts to update - // @return to The addresses of the contracts that will be updated to + /// @notice Return the latest proprosal set + /// @return ids The identifiers of the contracts to update + /// @return to The addresses of the contracts that will be updated to function getProposedContractSet() external view returns (bytes32[] memory, address[] memory); - // @notice Proposes one or more updates to the contract routes - // @dev Only callable by owner + /// @notice Proposes one or more updates to the contract routes + /// @dev Only callable by owner function proposeContractsUpdate(bytes32[] memory proposalSetIds, address[] memory proposalSetAddresses) external; - // @notice Updates the current contract routes to the proposed contracts - // @dev Only callable by owner + /// @notice Updates the current contract routes to the proposed contracts + /// @dev Only callable by owner function updateContracts() external; - // @dev Puts the system into an emergency stopped state. - // @dev Only callable by owner + /// @dev Puts the system into an emergency stopped state. + /// @dev Only callable by owner function pause() external; - // @dev Takes the system out of an emergency stopped state. - // @dev Only callable by owner + /// @dev Takes the system out of an emergency stopped state. + /// @dev Only callable by owner function unpause() external; } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsSubscriptions.sol b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsSubscriptions.sol index dacd0f13e62..eafd6f4fe99 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsSubscriptions.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IFunctionsSubscriptions.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.19; import {FunctionsResponse} from "../libraries/FunctionsResponse.sol"; -// @title Chainlink Functions Subscription interface. +/// @title Chainlink Functions Subscription interface. interface IFunctionsSubscriptions { struct Subscription { uint96 balance; // ═════════╗ Common LINK balance that is controlled by the Router to be used for all consumer requests. @@ -20,9 +20,9 @@ interface IFunctionsSubscriptions { uint64 completedRequests; // ══╝ The number of requests that have successfully completed or timed out } - // @notice Get details about a subscription. - // @param subscriptionId - the ID of the subscription - // @return subscription - see IFunctionsSubscriptions.Subscription for more information on the structure + /// @notice Get details about a subscription. + /// @param subscriptionId - the ID of the subscription + /// @return subscription - see IFunctionsSubscriptions.Subscription for more information on the structure function getSubscription(uint64 subscriptionId) external view returns (Subscription memory); /// @notice Retrieve details about multiple subscriptions using an inclusive range @@ -34,109 +34,107 @@ interface IFunctionsSubscriptions { uint64 subscriptionIdEnd ) external view returns (Subscription[] memory); - // @notice Get details about a consumer of a subscription. - // @param client - the consumer contract address - // @param subscriptionId - the ID of the subscription - // @return consumer - see IFunctionsSubscriptions.Consumer for more information on the structure + /// @notice Get details about a consumer of a subscription. + /// @param client - the consumer contract address + /// @param subscriptionId - the ID of the subscription + /// @return consumer - see IFunctionsSubscriptions.Consumer for more information on the structure function getConsumer(address client, uint64 subscriptionId) external view returns (Consumer memory); - // @notice Get details about the total amount of LINK within the system - // @return totalBalance - total Juels of LINK held by the contract + /// @notice Get details about the total amount of LINK within the system + /// @return totalBalance - total Juels of LINK held by the contract function getTotalBalance() external view returns (uint96); - // @notice Get details about the total number of subscription accounts - // @return count - total number of subscriptions in the system + /// @notice Get details about the total number of subscription accounts + /// @return count - total number of subscriptions in the system function getSubscriptionCount() external view returns (uint64); - // @notice Time out all expired requests: unlocks funds and removes the ability for the request to be fulfilled - // @param requestsToTimeoutByCommitment - A list of request commitments to time out - // @dev The commitment can be found on the "OracleRequest" event created when sending the request. + /// @notice Time out all expired requests: unlocks funds and removes the ability for the request to be fulfilled + /// @param requestsToTimeoutByCommitment - A list of request commitments to time out + /// @dev The commitment can be found on the "OracleRequest" event created when sending the request. function timeoutRequests(FunctionsResponse.Commitment[] calldata requestsToTimeoutByCommitment) external; - // @notice Oracle withdraw LINK earned through fulfilling requests - // @notice If amount is 0 the full balance will be withdrawn - // @notice Both signing and transmitting wallets will have a balance to withdraw - // @param recipient where to send the funds - // @param amount amount to withdraw + /// @notice Oracle withdraw LINK earned through fulfilling requests + /// @notice If amount is 0 the full balance will be withdrawn + /// @notice Both signing and transmitting wallets will have a balance to withdraw + /// @param recipient where to send the funds + /// @param amount amount to withdraw function oracleWithdraw(address recipient, uint96 amount) external; - // @notice Owner cancel subscription, sends remaining link directly to the subscription owner. - // @dev Only callable by the Router Owner - // @param subscriptionId subscription id - // @dev notably can be called even if there are pending requests, outstanding ones may fail onchain + /// @notice Owner cancel subscription, sends remaining link directly to the subscription owner. + /// @dev Only callable by the Router Owner + /// @param subscriptionId subscription id + /// @dev notably can be called even if there are pending requests, outstanding ones may fail onchain function ownerCancelSubscription(uint64 subscriptionId) external; - // @notice Recover link sent with transfer instead of transferAndCall. - // @dev Only callable by the Router Owner - // @param to address to send link to + /// @notice Recover link sent with transfer instead of transferAndCall. + /// @dev Only callable by the Router Owner + /// @param to address to send link to function recoverFunds(address to) external; - // @notice Create a new subscription. - // @return subscriptionId - A unique subscription id. - // @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. - // @dev Note to fund the subscription, use transferAndCall. For example - // @dev LINKTOKEN.transferAndCall( - // @dev address(ROUTER), - // @dev amount, - // @dev abi.encode(subscriptionId)); + /// @notice Create a new subscription. + /// @return subscriptionId - A unique subscription id. + /// @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. + /// @dev Note to fund the subscription, use transferAndCall. For example + /// @dev LINKTOKEN.transferAndCall( + /// @dev address(ROUTER), + /// @dev amount, + /// @dev abi.encode(subscriptionId)); function createSubscription() external returns (uint64); - // @notice Create a new subscription and add a consumer. - // @return subscriptionId - A unique subscription id. - // @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. - // @dev Note to fund the subscription, use transferAndCall. For example - // @dev LINKTOKEN.transferAndCall( - // @dev address(ROUTER), - // @dev amount, - // @dev abi.encode(subscriptionId)); + /// @notice Create a new subscription and add a consumer. + /// @return subscriptionId - A unique subscription id. + /// @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. + /// @dev Note to fund the subscription, use transferAndCall. For example + /// @dev LINKTOKEN.transferAndCall( + /// @dev address(ROUTER), + /// @dev amount, + /// @dev abi.encode(subscriptionId)); function createSubscriptionWithConsumer(address consumer) external returns (uint64 subscriptionId); - // @notice Propose a new owner for a subscription. - // @dev Only callable by the Subscription's owner - // @param subscriptionId - ID of the subscription - // @param newOwner - proposed new owner of the subscription + /// @notice Propose a new owner for a subscription. + /// @dev Only callable by the Subscription's owner + /// @param subscriptionId - ID of the subscription + /// @param newOwner - proposed new owner of the subscription function proposeSubscriptionOwnerTransfer(uint64 subscriptionId, address newOwner) external; - // @notice Accept an ownership transfer. - // @param subscriptionId - ID of the subscription - // @dev will revert if original owner of subscriptionId has - // not requested that msg.sender become the new owner. + /// @notice Accept an ownership transfer. + /// @param subscriptionId - ID of the subscription + /// @dev will revert if original owner of subscriptionId has not requested that msg.sender become the new owner. function acceptSubscriptionOwnerTransfer(uint64 subscriptionId) external; - // @notice Remove a consumer from a Chainlink Functions subscription. - // @dev Only callable by the Subscription's owner - // @param subscriptionId - ID of the subscription - // @param consumer - Consumer to remove from the subscription + /// @notice Remove a consumer from a Chainlink Functions subscription. + /// @dev Only callable by the Subscription's owner + /// @param subscriptionId - ID of the subscription + /// @param consumer - Consumer to remove from the subscription function removeConsumer(uint64 subscriptionId, address consumer) external; - // @notice Add a consumer to a Chainlink Functions subscription. - // @dev Only callable by the Subscription's owner - // @param subscriptionId - ID of the subscription - // @param consumer - New consumer which can use the subscription + /// @notice Add a consumer to a Chainlink Functions subscription. + /// @dev Only callable by the Subscription's owner + /// @param subscriptionId - ID of the subscription + /// @param consumer - New consumer which can use the subscription function addConsumer(uint64 subscriptionId, address consumer) external; - // @notice Cancel a subscription - // @dev Only callable by the Subscription's owner - // @param subscriptionId - ID of the subscription - // @param to - Where to send the remaining LINK to + /// @notice Cancel a subscription + /// @dev Only callable by the Subscription's owner + /// @param subscriptionId - ID of the subscription + /// @param to - Where to send the remaining LINK to function cancelSubscription(uint64 subscriptionId, address to) external; - // @notice Check to see if there exists a request commitment for all consumers for a given sub. - // @param subscriptionId - ID of the subscription - // @return true if there exists at least one unfulfilled request for the subscription, false - // otherwise. - // @dev Looping is bounded to MAX_CONSUMERS*(number of DONs). - // @dev Used to disable subscription canceling while outstanding request are present. + /// @notice Check to see if there exists a request commitment for all consumers for a given sub. + /// @param subscriptionId - ID of the subscription + /// @return true if there exists at least one unfulfilled request for the subscription, false otherwise. + /// @dev Looping is bounded to MAX_CONSUMERS*(number of DONs). + /// @dev Used to disable subscription canceling while outstanding request are present. function pendingRequestExists(uint64 subscriptionId) external view returns (bool); - // @notice Set subscription specific flags for a subscription. - // Each byte of the flag is used to represent a resource tier that the subscription can utilize. - // @param subscriptionId - ID of the subscription - // @param flags - desired flag values + /// @notice Set subscription specific flags for a subscription. + /// Each byte of the flag is used to represent a resource tier that the subscription can utilize. + /// @param subscriptionId - ID of the subscription + /// @param flags - desired flag values function setFlags(uint64 subscriptionId, bytes32 flags) external; - // @notice Get flags for a given subscription. - // @param subscriptionId - ID of the subscription - // @return flags - current flag values + /// @notice Get flags for a given subscription. + /// @param subscriptionId - ID of the subscription + /// @return flags - current flag values function getFlags(uint64 subscriptionId) external view returns (bytes32); } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IOwnableFunctionsRouter.sol b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IOwnableFunctionsRouter.sol index 5a2f85fd32e..39b84a930aa 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IOwnableFunctionsRouter.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/interfaces/IOwnableFunctionsRouter.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.19; import {IFunctionsRouter} from "./IFunctionsRouter.sol"; import {IOwnable} from "../../../../shared/interfaces/IOwnable.sol"; -// @title Chainlink Functions Router interface with Ownability. +/// @title Chainlink Functions Router interface with Ownability. interface IOwnableFunctionsRouter is IOwnable, IFunctionsRouter { } diff --git a/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsRequest.sol b/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsRequest.sol index 76b83a998bd..efc3a811e6a 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsRequest.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsRequest.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.19; import {CBOR} from "../../../../vendor/solidity-cborutils/v2.0.0/CBOR.sol"; -// @title Library for encoding the input data of a Functions request into CBOR +/// @title Library for encoding the input data of a Functions request into CBOR library FunctionsRequest { using CBOR for CBOR.CBORBuffer; @@ -36,9 +36,9 @@ library FunctionsRequest { error EmptyArgs(); error NoInlineSecrets(); - // @notice Encodes a Request to CBOR encoded bytes - // @param self The request to encode - // @return CBOR encoded bytes + /// @notice Encodes a Request to CBOR encoded bytes + /// @param self The request to encode + /// @return CBOR encoded bytes function encodeCBOR(Request memory self) internal pure returns (bytes memory) { CBOR.CBORBuffer memory buffer = CBOR.create(DEFAULT_BUFFER_SIZE); @@ -82,12 +82,12 @@ library FunctionsRequest { return buffer.buf.buf; } - // @notice Initializes a Chainlink Functions Request - // @dev Sets the codeLocation and code on the request - // @param self The uninitialized request - // @param codeLocation The user provided source code location - // @param language The programming language of the user code - // @param source The user provided source code or a url + /// @notice Initializes a Chainlink Functions Request + /// @dev Sets the codeLocation and code on the request + /// @param self The uninitialized request + /// @param codeLocation The user provided source code location + /// @param language The programming language of the user code + /// @param source The user provided source code or a url function initializeRequest( Request memory self, Location codeLocation, @@ -101,17 +101,17 @@ library FunctionsRequest { self.source = source; } - // @notice Initializes a Chainlink Functions Request - // @dev Simplified version of initializeRequest for PoC - // @param self The uninitialized request - // @param javaScriptSource The user provided JS code (must not be empty) + /// @notice Initializes a Chainlink Functions Request + /// @dev Simplified version of initializeRequest for PoC + /// @param self The uninitialized request + /// @param javaScriptSource The user provided JS code (must not be empty) function initializeRequestForInlineJavaScript(Request memory self, string memory javaScriptSource) internal pure { initializeRequest(self, Location.Inline, CodeLanguage.JavaScript, javaScriptSource); } - // @notice Adds Remote user encrypted secrets to a Request - // @param self The initialized request - // @param encryptedSecretsReference Encrypted comma-separated string of URLs pointing to off-chain secrets + /// @notice Adds Remote user encrypted secrets to a Request + /// @param self The initialized request + /// @param encryptedSecretsReference Encrypted comma-separated string of URLs pointing to off-chain secrets function addSecretsReference(Request memory self, bytes memory encryptedSecretsReference) internal pure { if (encryptedSecretsReference.length == 0) revert EmptySecrets(); @@ -119,10 +119,10 @@ library FunctionsRequest { self.encryptedSecretsReference = encryptedSecretsReference; } - // @notice Adds DON-hosted secrets reference to a Request - // @param self The initialized request - // @param slotID Slot ID of the user's secrets hosted on DON - // @param version User data version (for the slotID) + /// @notice Adds DON-hosted secrets reference to a Request + /// @param self The initialized request + /// @param slotID Slot ID of the user's secrets hosted on DON + /// @param version User data version (for the slotID) function addDONHostedSecrets(Request memory self, uint8 slotID, uint64 version) internal pure { CBOR.CBORBuffer memory buffer = CBOR.create(DEFAULT_BUFFER_SIZE); @@ -135,18 +135,18 @@ library FunctionsRequest { self.encryptedSecretsReference = buffer.buf.buf; } - // @notice Sets args for the user run function - // @param self The initialized request - // @param args The array of string args (must not be empty) + /// @notice Sets args for the user run function + /// @param self The initialized request + /// @param args The array of string args (must not be empty) function setArgs(Request memory self, string[] memory args) internal pure { if (args.length == 0) revert EmptyArgs(); self.args = args; } - // @notice Sets bytes args for the user run function - // @param self The initialized request - // @param args The array of bytes args (must not be empty) + /// @notice Sets bytes args for the user run function + /// @param self The initialized request + /// @param args The array of bytes args (must not be empty) function setBytesArgs(Request memory self, bytes[] memory args) internal pure { if (args.length == 0) revert EmptyArgs(); diff --git a/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsResponse.sol b/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsResponse.sol index 71e731b2e33..31a33169226 100644 --- a/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsResponse.sol +++ b/contracts/src/v0.8/functions/dev/1_0_0/libraries/FunctionsResponse.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.19; import {IFunctionsSubscriptions} from "../interfaces/IFunctionsSubscriptions.sol"; -// @title Library of types that are used for fulfillment of a Functions request +/// @title Library of types that are used for fulfillment of a Functions request library FunctionsResponse { // Used to send request information from the Router to the Coordinator struct RequestMeta {