Hello I'm trying to test the ERC1967Proxy to delegate calls to a implementation.
However I don't understand why I cannot use it.
Here my proxy code:
// SPDX-License-Identifier: AGPL-3
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
contract AProxy is ERC1967Proxy {
constructor(address _impl) ERC1967Proxy(_impl, "") {}
}
Here the code of the implementation:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract DummyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("DummyToken", "DTK") {
_mint(msg.sender, initialSupply);
}
}
Here the code of the test
const AProxy = artifacts.require("AProxy")
const DummyToken = artifacts.require("DummyToken")
contract("Proxy", (accounts) => {
it("delegate call", async () => {
const DummyTokenInstance = await DummyToken.new(web3.utils.toWei('1000'))
const ProxyInstance = await AProxy.new(DummyTokenInstance.address)
assert.equal(web3.utils.toWei('1000'), await DummyTokenInstance.totalSupply())
const methodCall = DummyTokenInstance.contract.methods.totalSupply().encodeABI()
const response = await web3.eth.call({ to: ProxyInstance.address, data: methodCall, from: accounts[2] })
console.log(web3.utils.fromWei(response))
// Returns 0x0000000000000000000000000000000000000000000000000000000000000000
// Expect 1000 tokens
})
})
I'm sure you can help to resolve my issue, please let me know ^^