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

fix(Delegation): remove value from Call struct #28

Merged
merged 1 commit into from
Mar 11, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions abis/Delegation.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
Expand Down
18 changes: 8 additions & 10 deletions contracts/Delegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ pragma solidity 0.8.6;
* @dev This contract will hold tickets that will be delegated to a chosen delegatee.
*/
contract Delegation {
/// @notice A structure to define arbitrary contract calls.
/**
* @notice A structure to define arbitrary contract calls.
* @param to The address to call
* @param data The call data
*/
struct Call {
address to;
uint256 value;
bytes data;
}

Expand Down Expand Up @@ -44,7 +47,7 @@ contract Delegation {

for (uint256 i; i < _callsLength; i++) {
call = calls[i];
response[i] = _executeCall(call.to, call.value, call.data);
response[i] = _executeCall(call.to, call.data);
}

return response;
Expand All @@ -61,16 +64,11 @@ contract Delegation {
/**
* @notice Executes a call to another contract.
* @param to The address to call
* @param value The Ether to pass along with the call
* @param data The call data
* @return The return data from the call
*/
function _executeCall(
address to,
uint256 value,
bytes memory data
) internal returns (bytes memory) {
(bool succeeded, bytes memory returnValue) = to.call{ value: value }(data);
function _executeCall(address to, bytes memory data) internal returns (bytes memory) {
(bool succeeded, bytes memory returnValue) = to.call{ value: 0 }(data);
require(succeeded, string(returnValue));
return returnValue;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/TWABDelegator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ contract TWABDelegator is ERC20, LowLevelDelegator, PermitAndMulticall {
returns (bytes[] memory)
{
Delegation.Call[] memory _calls = new Delegation.Call[](1);
_calls[0] = Delegation.Call({ to: address(ticket), value: 0, data: _data });
_calls[0] = Delegation.Call({ to: address(ticket), data: _data });

return _delegation.executeCalls(_calls);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/TWABDelegatorHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract TWABDelegatorHarness is TWABDelegator {
returns (bytes[] memory)
{
Delegation.Call[] memory _calls = new Delegation.Call[](1);
_calls[0] = Delegation.Call({ to: address(ticket), value: 0, data: _data });
_calls[0] = Delegation.Call({ to: address(ticket), data: _data });

return _delegation.executeCalls(_calls);
}
Expand Down
6 changes: 3 additions & 3 deletions test/TWABDelegator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,9 @@ describe('Test Set Name', () => {
});

it('should fail to transfer tickets from a delegation if recipient is the contract address', async () => {
await expect(twabDelegator.transferDelegationTo(0, amount, twabDelegator.address)).to.be.revertedWith(
'TWABDelegator/to-not-this-addr',
);
await expect(
twabDelegator.transferDelegationTo(0, amount, twabDelegator.address),
).to.be.revertedWith('TWABDelegator/to-not-this-addr');
});

it('should fail to transfer tickets from an inexistent delegation', async () => {
Expand Down