Skip to content

Commit

Permalink
feat!: remove success from ERC-20 deposit input
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Nov 21, 2023
1 parent 00a5b14 commit d063478
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
7 changes: 7 additions & 0 deletions onchain/rollups/.changeset/plenty-feet-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cartesi/rollups": major
---

Removed the boolean `success` flag from ERC-20 deposit inputs.
This change was made because this flag would always be `true`, giving no extra information to the DApp back-end.
Consumers of this input should be aware of the new encoding.
3 changes: 0 additions & 3 deletions onchain/rollups/contracts/common/InputEncoding.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,19 @@ library InputEncoding {
}

/// @notice Encode an ERC-20 token deposit.
/// @param ret The return value of `transferFrom`
/// @param token The token contract
/// @param sender The token sender
/// @param amount The amount of tokens being sent
/// @param execLayerData Additional data to be interpreted by the execution layer
/// @return The encoded input
function encodeERC20Deposit(
bool ret,
IERC20 token,
address sender,
uint256 amount,
bytes calldata execLayerData
) internal pure returns (bytes memory) {
return
abi.encodePacked(
ret, // 1B
token, // 20B
sender, // 20B
amount, // 32B
Expand Down
1 change: 0 additions & 1 deletion onchain/rollups/contracts/portals/ERC20Portal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ contract ERC20Portal is InputRelay, IERC20Portal {
_token.safeTransferFrom(msg.sender, _dapp, _amount);

bytes memory input = InputEncoding.encodeERC20Deposit(
true,
_token,
msg.sender,
_amount,
Expand Down
8 changes: 1 addition & 7 deletions onchain/rollups/test/foundry/portals/ERC20Portal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,7 @@ contract ERC20PortalTest is Test {
token = new NormalToken(alice, _amount);

// Construct the ERC-20 deposit input
bytes memory input = abi.encodePacked(
true,
token,
alice,
_amount,
_data
);
bytes memory input = abi.encodePacked(token, alice, _amount, _data);

vm.startPrank(alice);

Expand Down

0 comments on commit d063478

Please sign in to comment.