Skip to content

Commit

Permalink
fix(portal-contract): wrong 'from' when depositing from the contract …
Browse files Browse the repository at this point in the history
…through Portal.onApprove function
  • Loading branch information
0x6e616d committed Oct 17, 2024
1 parent 11a09ba commit fa3208c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion op-bindings/bindingspreview/optimismportal2.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindingspreview/optimismportal2_more.go

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions packages/tokamak/contracts-bedrock/src/L1/OptimismPortal2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, OnApprove, ISemver
{
(address to, uint256 value, uint32 gasLimit, bytes calldata message) = unpackOnApproveData(_data);
if (msg.sender == _nativeToken()) {
_depositTransaction(_owner, to, _amount, value, gasLimit, to == address(0), message, true);
_depositTransaction(_owner, to, _amount, value, gasLimit, to == address(0), message);
return true;
} else {
return false;
Expand Down Expand Up @@ -495,7 +495,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, OnApprove, ISemver
)
external
{
_depositTransaction(msg.sender, _to, _mint, _value, _gasLimit, _isCreation, _data, false);
_depositTransaction(msg.sender, _to, _mint, _value, _gasLimit, _isCreation, _data);
}

/// @notice Accepts deposits of L2's native token and data, and emits a TransactionDeposited event for
Expand All @@ -509,16 +509,14 @@ contract OptimismPortal2 is Initializable, ResourceMetering, OnApprove, ISemver
/// @param _gasLimit Amount of L2 gas to purchase by burning gas on L1.
/// @param _isCreation Whether or not the transaction is a contract creation.
/// @param _data Data to trigger the recipient with.
/// @param _isOnApproveTrigger Whether or not the transaction is trigger from approveAndCall.
function _depositTransaction(
address _sender,
address _to,
uint256 _mint,
uint256 _value,
uint64 _gasLimit,
bool _isCreation,
bytes calldata _data,
bool _isOnApproveTrigger
bytes calldata _data
)
internal
metered(_gasLimit)
Expand Down Expand Up @@ -546,7 +544,7 @@ contract OptimismPortal2 is Initializable, ResourceMetering, OnApprove, ISemver

// Transform the from-address to its alias if the caller is a contract.
address from =
((_sender != tx.origin) && !_isOnApproveTrigger) ? AddressAliasHelper.applyL1ToL2Alias(_sender) : _sender;
((_sender != tx.origin)) ? AddressAliasHelper.applyL1ToL2Alias(_sender) : _sender;

// Compute the opaque data that will be emitted as part of the TransactionDeposited event.
// We use opaque data so that we can update the TransactionDeposited event in the future
Expand Down

0 comments on commit fa3208c

Please sign in to comment.