Skip to content

Commit 53c2c64

Browse files
Amxxernestognw
andauthored
Use Context._msgSender in BridgeERC20Core and ERC20Crosschain (#6189)
Co-authored-by: ernestognw <ernestognw@gmail.com>
1 parent ea89d42 commit 53c2c64

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

contracts/crosschain/bridges/BridgeERC20Core.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
pragma solidity ^0.8.26;
44

55
import {InteroperableAddress} from "../../utils/draft-InteroperableAddress.sol";
6+
import {Context} from "../../utils/Context.sol";
67
import {ERC7786Recipient} from "../ERC7786Recipient.sol";
78
import {CrosschainLinked} from "../CrosschainLinked.sol";
89

@@ -17,7 +18,7 @@ import {CrosschainLinked} from "../CrosschainLinked.sol";
1718
* which interface with ERC-7802 to provide an approve-free user experience. It is also used by the {ERC20Crosschain}
1819
* extension, which embeds the bridge logic directly in the token contract.
1920
*/
20-
abstract contract BridgeERC20Core is CrosschainLinked {
21+
abstract contract BridgeERC20Core is Context, CrosschainLinked {
2122
using InteroperableAddress for bytes;
2223

2324
event CrosschainERC20TransferSent(bytes32 indexed sendId, address indexed from, bytes to, uint256 amount);
@@ -29,7 +30,7 @@ abstract contract BridgeERC20Core is CrosschainLinked {
2930
* Note: The `to` parameter is the full InteroperableAddress (chain ref + address).
3031
*/
3132
function crosschainTransfer(bytes memory to, uint256 amount) public virtual returns (bytes32) {
32-
return _crosschainTransfer(msg.sender, to, amount);
33+
return _crosschainTransfer(_msgSender(), to, amount);
3334
}
3435

3536
/**

contracts/token/ERC20/extensions/ERC20Crosschain.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {BridgeERC20Core} from "../../../crosschain/bridges/BridgeERC20Core.sol";
2222
abstract contract ERC20Crosschain is ERC20, BridgeERC20Core {
2323
/// @dev Variant of {crosschainTransfer} that allows an authorized account (using ERC20 allowance) to operate on `from`'s assets.
2424
function crosschainTransferFrom(address from, bytes memory to, uint256 amount) public virtual returns (bytes32) {
25-
_spendAllowance(from, msg.sender, amount);
25+
_spendAllowance(from, _msgSender(), amount);
2626
return _crosschainTransfer(from, to, amount);
2727
}
2828

0 commit comments

Comments
 (0)