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(portal-contract): wrong 'from' when depositing from the contract through Portal.onApprove function #275

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading