Skip to content

Commit

Permalink
Combine setLink and setLinkNativeFeed into a single function (#12368)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyikjiun committed Mar 12, 2024
1 parent 15103b8 commit f9b9d33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 35 deletions.
11 changes: 3 additions & 8 deletions contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,17 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
}

/**
* @notice set the link token to be used by this wrapper
* @notice set the link token and link native feed to be used by this wrapper
* @param link address of the link token
* @param linkNativeFeed address of the link native feed
*/
function setLINK(address link) external onlyOwner {
function setLinkAndLinkNativeFeed(address link, address linkNativeFeed) external onlyOwner {
// Disallow re-setting link token because the logic wouldn't really make sense
if (address(s_link) != address(0)) {
revert LinkAlreadySet();
}
s_link = LinkTokenInterface(link);
}

/**
* @notice set the link native feed to be used by this wrapper
* @param linkNativeFeed address of the link native feed
*/
function setLinkNativeFeed(address linkNativeFeed) external onlyOwner {
s_linkNativeFeed = AggregatorV3Interface(linkNativeFeed);
}

Expand Down
5 changes: 2 additions & 3 deletions contracts/test/v0.8/foundry/vrf/VRFV2Wrapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,13 @@ contract VRFV2PlusWrapperTest is BaseTest {
VRFV2PlusWrapper wrapper = new VRFV2PlusWrapper(address(0), address(0), address(s_testCoordinator));

// Set LINK and LINK/Native feed on wrapper.
wrapper.setLINK(address(s_linkToken));
wrapper.setLinkNativeFeed(address(s_linkNativeFeed));
wrapper.setLinkAndLinkNativeFeed(address(s_linkToken), address(s_linkNativeFeed));
assertEq(address(wrapper.s_link()), address(s_linkToken));
assertEq(address(wrapper.s_linkNativeFeed()), address(s_linkNativeFeed));

// Revert for subsequent assignment.
vm.expectRevert(VRFV2PlusWrapper.LinkAlreadySet.selector);
wrapper.setLINK(address(s_linkToken));
wrapper.setLinkAndLinkNativeFeed(address(s_linkToken), address(s_linkNativeFeed));

// Consumer can set LINK token.
VRFV2PlusWrapperConsumerExample consumer = new VRFV2PlusWrapperConsumerExample(address(0), address(wrapper));
Expand Down
32 changes: 9 additions & 23 deletions core/gethwrappers/generated/vrfv2plus_wrapper/vrfv2plus_wrapper.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ vrfv2plus_client: ../../contracts/solc/v0.8.6/VRFV2PlusClient/VRFV2PlusClient.ab
vrfv2plus_consumer_example: ../../contracts/solc/v0.8.6/VRFV2PlusConsumerExample/VRFV2PlusConsumerExample.abi ../../contracts/solc/v0.8.6/VRFV2PlusConsumerExample/VRFV2PlusConsumerExample.bin 2c480a6d7955d33a00690fdd943486d95802e48a03f3cc243df314448e4ddb2c
vrfv2plus_malicious_migrator: ../../contracts/solc/v0.8.6/VRFV2PlusMaliciousMigrator/VRFV2PlusMaliciousMigrator.abi ../../contracts/solc/v0.8.6/VRFV2PlusMaliciousMigrator/VRFV2PlusMaliciousMigrator.bin 80dbc98be5e42246960c889d29488f978d3db0127e95e9b295352c481d8c9b07
vrfv2plus_reverting_example: ../../contracts/solc/v0.8.6/VRFV2PlusRevertingExample/VRFV2PlusRevertingExample.abi ../../contracts/solc/v0.8.6/VRFV2PlusRevertingExample/VRFV2PlusRevertingExample.bin 6c9053a94f90b8151964d3311310478b57744fbbd153e8ee742ed570e1e49798
vrfv2plus_wrapper: ../../contracts/solc/v0.8.6/VRFV2PlusWrapper/VRFV2PlusWrapper.abi ../../contracts/solc/v0.8.6/VRFV2PlusWrapper/VRFV2PlusWrapper.bin 934bafba386b934f491827e535306726069f4cafef9125079ea88abf0d808877
vrfv2plus_wrapper: ../../contracts/solc/v0.8.6/VRFV2PlusWrapper/VRFV2PlusWrapper.abi ../../contracts/solc/v0.8.6/VRFV2PlusWrapper/VRFV2PlusWrapper.bin 86f352f70da2a52bf0081ec3780a363fb8f5873217f81b4e4a8b68a59dff3575
vrfv2plus_wrapper_consumer_example: ../../contracts/solc/v0.8.6/VRFV2PlusWrapperConsumerExample/VRFV2PlusWrapperConsumerExample.abi ../../contracts/solc/v0.8.6/VRFV2PlusWrapperConsumerExample/VRFV2PlusWrapperConsumerExample.bin a14c4c6e2299cd963a8f0ed069e61dd135af5aad4c13a94f6ea7e086eced7191
vrfv2plus_wrapper_load_test_consumer: ../../contracts/solc/v0.8.6/VRFV2PlusWrapperLoadTestConsumer/VRFV2PlusWrapperLoadTestConsumer.abi ../../contracts/solc/v0.8.6/VRFV2PlusWrapperLoadTestConsumer/VRFV2PlusWrapperLoadTestConsumer.bin 55e3bd534045125fb6579a201ab766185e9b0fac5737b4f37897bb69c9f599fa

0 comments on commit f9b9d33

Please sign in to comment.