Skip to content

Commit

Permalink
VRF-923-VRF-V2-Plus-Wrapper-Remove-amount-from-withdraw-and-withdrawN…
Browse files Browse the repository at this point in the history
…ative (#12369)

* Remove amount from withdraw and withdraw native

* Fix Go script
  • Loading branch information
leeyikjiun authored and kidambisrinivas committed Mar 18, 2024
1 parent 1177538 commit aa29635
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
12 changes: 4 additions & 8 deletions contracts/src/v0.8/vrf/dev/VRFV2PlusWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,9 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
* @notice withdraw is used by the VRFV2Wrapper's owner to withdraw LINK revenue.
*
* @param _recipient is the address that should receive the LINK funds.
*
* @param _amount is the amount of LINK in Juels that should be withdrawn.
*/
function withdraw(address _recipient, uint256 _amount) external onlyOwner {
if (!s_link.transfer(_recipient, _amount)) {
function withdraw(address _recipient) external onlyOwner {
if (!s_link.transfer(_recipient, s_link.balanceOf(address(this)))) {
revert FailedToTransferLink();
}
}
Expand All @@ -481,11 +479,9 @@ contract VRFV2PlusWrapper is ConfirmedOwner, TypeAndVersionInterface, VRFConsume
* @notice withdraw is used by the VRFV2Wrapper's owner to withdraw native revenue.
*
* @param _recipient is the address that should receive the native funds.
*
* @param _amount is the amount of native in Wei that should be withdrawn.
*/
function withdrawNative(address _recipient, uint256 _amount) external onlyOwner {
(bool success, ) = payable(_recipient).call{value: _amount}("");
function withdrawNative(address _recipient) external onlyOwner {
(bool success, ) = payable(_recipient).call{value: address(this).balance}("");
// solhint-disable-next-line custom-errors
require(success, "failed to withdraw native");
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/v0.8/foundry/vrf/VRFV2Wrapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ contract VRFV2PlusWrapperTest is BaseTest {
// Withdraw funds from wrapper.
changePrank(LINK_WHALE);
uint256 priorWhaleBalance = LINK_WHALE.balance;
s_wrapper.withdrawNative(LINK_WHALE, paid);
s_wrapper.withdrawNative(LINK_WHALE);
assertEq(LINK_WHALE.balance, priorWhaleBalance + paid);
assertEq(address(s_wrapper).balance, 0);
}
Expand Down Expand Up @@ -247,7 +247,7 @@ contract VRFV2PlusWrapperTest is BaseTest {
// Withdraw funds from wrapper.
changePrank(LINK_WHALE);
uint256 priorWhaleBalance = s_linkToken.balanceOf(LINK_WHALE);
s_wrapper.withdraw(LINK_WHALE, paid);
s_wrapper.withdraw(LINK_WHALE);
assertEq(s_linkToken.balanceOf(LINK_WHALE), priorWhaleBalance + paid);
assertEq(s_linkToken.balanceOf(address(s_wrapper)), 0);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/v0.8/foundry/vrf/VRFV2Wrapper_Migration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ contract VRFV2PlusWrapperTest is BaseTest {
/// Withdraw funds from wrapper.
vm.startPrank(LINK_WHALE);
uint256 priorWhaleBalance = s_linkToken.balanceOf(LINK_WHALE);
s_wrapper.withdraw(LINK_WHALE, paid);
s_wrapper.withdraw(LINK_WHALE);
assertEq(s_linkToken.balanceOf(LINK_WHALE), priorWhaleBalance + paid);
assertEq(s_linkToken.balanceOf(address(s_wrapper)), 0);

Expand Down Expand Up @@ -349,7 +349,7 @@ contract VRFV2PlusWrapperTest is BaseTest {
// Withdraw funds from wrapper.
vm.startPrank(LINK_WHALE);
uint256 priorWhaleBalance = LINK_WHALE.balance;
s_wrapper.withdrawNative(LINK_WHALE, paid);
s_wrapper.withdrawNative(LINK_WHALE);
assertEq(LINK_WHALE.balance, priorWhaleBalance + paid);
assertEq(address(s_wrapper).balance, 0);

Expand Down
32 changes: 16 additions & 16 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 @@ -114,6 +114,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 86f352f70da2a52bf0081ec3780a363fb8f5873217f81b4e4a8b68a59dff3575
vrfv2plus_wrapper: ../../contracts/solc/v0.8.6/VRFV2PlusWrapper/VRFV2PlusWrapper.abi ../../contracts/solc/v0.8.6/VRFV2PlusWrapper/VRFV2PlusWrapper.bin a8f1d74722fa01a9e6de74bfd898b41b22bbc0acc4a943a977cc871d73e4c33e
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
2 changes: 1 addition & 1 deletion core/scripts/vrfv2plus/testnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ func main() {
helpers.PanicErr(err)
balance, err := link.BalanceOf(nil, common.HexToAddress(*wrapperAddress))
helpers.PanicErr(err)
tx, err := wrapper.Withdraw(e.Owner, common.HexToAddress(*recipientAddress), balance)
tx, err := wrapper.Withdraw(e.Owner, common.HexToAddress(*recipientAddress))
helpers.PanicErr(err)
helpers.ConfirmTXMined(context.Background(), e.Ec, tx, e.ChainID, "withdrawing", balance.String(), "Juels from", *wrapperAddress, "to", *recipientAddress)
case "wrapper-get-subscription-id":
Expand Down

0 comments on commit aa29635

Please sign in to comment.