0

This is the TrustedForwarder.sol, which acts as the forwarder contract for meta transactions.

// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/metatx/ERC2771ForwarderUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; contract TrustedForwarder is Initializable, ERC2771ForwarderUpgradeable, OwnableUpgradeable { mapping(address => bool) private _whitelistedAddresses; event AddressWhitelisted(address indexed account); event AddressRemovedFromWhitelist(address indexed account); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( string memory name ) public virtual override initializer { __ERC2771Forwarder_init(name); __Ownable_init(msg.sender); } modifier onlyWhitelisted() { require( _whitelistedAddresses[_msgSender()], "TrustedForwarder: caller is not whitelisted" ); _; } function whitelistAddress(address account) external onlyOwner { _whitelistedAddresses[account] = true; emit AddressWhitelisted(account); } function removeWhitelistedAddress(address account) external onlyOwner { _whitelistedAddresses[account] = false; emit AddressRemovedFromWhitelist(account); } function isWhitelisted(address account) external view returns (bool) { return _whitelistedAddresses[account]; } function execute( ForwardRequestData calldata request ) public payable virtual override onlyWhitelisted { if (msg.value != request.value) { revert ERC2771ForwarderMismatchedValue(request.value, msg.value); } if (!_execute(request, true)) { revert Errors.FailedCall(); } } } 

I am using @openzeppelin/[email protected] and @openzeppelin/[email protected]

Deployement script:

 const Forwarder = await ethers.getContractFactory("TrustedForwarder"); const forwarder = await upgrades.deployProxy( Forwarder, ["TrustedForwarder"], { initializer: "initialize", } ); 

When I try to deploy the proxy, I get the following error:

Error: Contract `contracts/MetaTransaction/TrustedForwarder.sol:TrustedForwarder` is not upgrade safe @openzeppelin/contracts-upgradeable/metatx/ERC2771ForwarderUpgradeable.sol:109: Missing initializer calls for one or more parent contracts: `EIP712Upgradeable` Call the parent initializers in your initializer function https://zpl.in/upgrades/error-001 

It seems ERC2771ForwarderUpgradeable inherits from EIP712Upgradeable, and I may need to call its initializer explicitly. But I assumed __ERC2771Forwarder_init(name) would handle that.

But, even when I try to explicitly call __EIP712_init(name), I get a duplicate calls error.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.