Skip to content

Commit

Permalink
feat!: execute delegatecall vouchers
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Apr 9, 2024
1 parent 54347db commit 8e958f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-crews-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": minor
---

Supported the execution of `DELEGATECALL` vouchers
23 changes: 23 additions & 0 deletions contracts/dapp/Application.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ contract Application is
revert OutputNotReexecutable(output);
}
_executeVoucher(arguments);
} else if (selector == Outputs.DelegateCallVoucher.selector) {
if (bitmap.get(inputIndex)) {
revert OutputNotReexecutable(output);
}
_executeDelegateCallVoucher(arguments);
} else {
revert OutputNotExecutable(output);
}
Expand Down Expand Up @@ -205,4 +210,22 @@ contract Application is
returndata.raise();
}
}

/// @notice Executes a delegatecall voucher
/// @param arguments ABI-encoded arguments
function _executeDelegateCallVoucher(bytes calldata arguments) internal {
address destination;
bytes memory payload;

(destination, payload) = abi.decode(arguments, (address, bytes));

bool success;
bytes memory returndata;

(success, returndata) = destination.delegatecall(payload);

if (!success) {
returndata.raise();
}
}
}

0 comments on commit 8e958f2

Please sign in to comment.