Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VRF-923-VRF-V2-Plus-Wrapper-Remove-amount-from-withdraw-and-withdrawNative #12369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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

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 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
Loading