Skip to content

Commit

Permalink
Rename Functions Client i_router to i_functionsRouter (#11450)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkaseman authored Dec 1, 2023
1 parent a2a97cc commit 0e301e8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions contracts/src/v0.8/functions/dev/v1_X/FunctionsClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {FunctionsRequest} from "./libraries/FunctionsRequest.sol";
abstract contract FunctionsClient is IFunctionsClient {
using FunctionsRequest for FunctionsRequest.Request;

IFunctionsRouter internal immutable i_router;
IFunctionsRouter internal immutable i_functionsRouter;

event RequestSent(bytes32 indexed id);
event RequestFulfilled(bytes32 indexed id);

error OnlyRouterCanFulfill();

constructor(address router) {
i_router = IFunctionsRouter(router);
i_functionsRouter = IFunctionsRouter(router);
}

/// @notice Sends a Chainlink Functions request
Expand All @@ -33,7 +33,7 @@ abstract contract FunctionsClient is IFunctionsClient {
uint32 callbackGasLimit,
bytes32 donId
) internal returns (bytes32) {
bytes32 requestId = i_router.sendRequest(
bytes32 requestId = i_functionsRouter.sendRequest(
subscriptionId,
data,
FunctionsRequest.REQUEST_DATA_VERSION,
Expand All @@ -53,7 +53,7 @@ abstract contract FunctionsClient is IFunctionsClient {

/// @inheritdoc IFunctionsClient
function handleOracleFulfillment(bytes32 requestId, bytes memory response, bytes memory err) external override {
if (msg.sender != address(i_router)) {
if (msg.sender != address(i_functionsRouter)) {
revert OnlyRouterCanFulfill();
}
_fulfillRequest(requestId, response, err);
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/functions/dev/v1_X/Routable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IOwnableFunctionsRouter} from "./interfaces/IOwnableFunctionsRouter.sol"
/// 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;
IOwnableFunctionsRouter private immutable i_functionsRouter;

error RouterMustBeSet();
error OnlyCallableByRouter();
Expand All @@ -19,25 +19,25 @@ abstract contract Routable is ITypeAndVersion {
if (router == address(0)) {
revert RouterMustBeSet();
}
i_router = IOwnableFunctionsRouter(router);
i_functionsRouter = IOwnableFunctionsRouter(router);
}

/// @notice Return the Router
function _getRouter() internal view returns (IOwnableFunctionsRouter router) {
return i_router;
return i_functionsRouter;
}

/// @notice Reverts if called by anyone other than the router.
modifier onlyRouter() {
if (msg.sender != address(i_router)) {
if (msg.sender != address(i_functionsRouter)) {
revert OnlyCallableByRouter();
}
_;
}

/// @notice Reverts if called by anyone other than the router owner.
modifier onlyRouterOwner() {
if (msg.sender != i_router.owner()) {
if (msg.sender != i_functionsRouter.owner()) {
revert OnlyCallableByRouterOwner();
}
_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract FunctionsClientHarness is FunctionsClientUpgradeHelper {
constructor(address router) FunctionsClientUpgradeHelper(router) {}

function getRouter_HARNESS() external view returns (address) {
return address(i_router);
return address(i_functionsRouter);
}

function sendRequest_HARNESS(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ contract FunctionsClientTestHelper is FunctionsClient {
uint32 callbackGasLimit = 20_000;
request._initializeRequestForInlineJavaScript(sourceCode);
bytes memory requestData = FunctionsRequest._encodeCBOR(request);
requestId = i_router.sendRequestToProposed(
requestId = i_functionsRouter.sendRequestToProposed(
subscriptionId,
requestData,
FunctionsRequest.REQUEST_DATA_VERSION,
Expand All @@ -76,13 +76,13 @@ contract FunctionsClientTestHelper is FunctionsClient {
}

function acceptTermsOfService(address acceptor, address recipient, bytes32 r, bytes32 s, uint8 v) external {
bytes32 allowListId = i_router.getAllowListId();
ITermsOfServiceAllowList allowList = ITermsOfServiceAllowList(i_router.getContractById(allowListId));
bytes32 allowListId = i_functionsRouter.getAllowListId();
ITermsOfServiceAllowList allowList = ITermsOfServiceAllowList(i_functionsRouter.getContractById(allowListId));
allowList.acceptTermsOfService(acceptor, recipient, r, s, v);
}

function acceptSubscriptionOwnerTransfer(uint64 subscriptionId) external {
IFunctionsSubscriptions(address(i_router)).acceptSubscriptionOwnerTransfer(subscriptionId);
IFunctionsSubscriptions(address(i_functionsRouter)).acceptSubscriptionOwnerTransfer(subscriptionId);
}

function _fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override {
Expand All @@ -98,7 +98,7 @@ contract FunctionsClientTestHelper is FunctionsClient {
sendSimpleRequestWithJavaScript("somedata", s_subscriptionId, s_donId, 20_000);
}
if (s_doInvalidReentrantOperation) {
IFunctionsSubscriptions(address(i_router)).cancelSubscription(s_subscriptionId, msg.sender);
IFunctionsSubscriptions(address(i_functionsRouter)).cancelSubscription(s_subscriptionId, msg.sender);
}
emit FulfillRequestInvoked(requestId, response, err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ contract FunctionsClientUpgradeHelper is FunctionsClient, ConfirmedOwner {
uint32 callbackGasLimit,
bytes32 donId
) internal returns (bytes32) {
bytes32 requestId = i_router.sendRequestToProposed(
bytes32 requestId = i_functionsRouter.sendRequestToProposed(
subscriptionId,
data,
FunctionsRequest.REQUEST_DATA_VERSION,
Expand Down

0 comments on commit 0e301e8

Please sign in to comment.