Skip to content

Commit

Permalink
Merge 2ebe0bf into 4d2163e
Browse files Browse the repository at this point in the history
  • Loading branch information
PierrickGT committed Mar 2, 2022
2 parents 4d2163e + 2ebe0bf commit 089c1d2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
5 changes: 0 additions & 5 deletions abis/Delegation.json
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
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
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
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
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

0 comments on commit 089c1d2

Please sign in to comment.