OpenZeppelin / openzeppelin-foundry-upgrades

Foundry library for deploying and managing upgradeable contracts
MIT License
177 stars 23 forks source link

FAIL. Reason: setup failed: Multiple matching artifacts found #58

Closed vinaykharayat closed 2 months ago

vinaykharayat commented 3 months ago

I am getting this error

This is my setUp()

function setUp() public {
        vm.startPrank(vm.addr(1));
        token = new MyToken(vm.addr(1));
        address proxy = Upgrades.deployUUPSProxy(
            "Upshort.sol",
            abi.encodeCall(Upshort.initialize, (vm.addr(1), address(token)))
        );
        console2.logAddress(proxy);
    }

This is my initialize

function initialize(
        address _initialOwner,
        address _tokenAddress
    ) public initializer {
        __Pausable_init();
        __Ownable_init(_initialOwner);
        __UUPSUpgradeable_init();
        tokenAddress = _tokenAddress;
    }

It is failing at deployUUPSProxy. I already tried forge clean, forge test --force

Output of forge test -vvvvv

    │   └─ ← [Return] "0x70689fd73a04ed40e31ed23c11e721b8377eeadae8e50c1e4a52c050fea96a0c"
    ├─ [0] VM::envOr("OPENZEPPELIN_BASH_PATH", "bash") [staticcall]
    │   └─ ← [Return] <env var value>
    ├─ [0] VM::tryFfi(["bash", "-c", "npx @openzeppelin/upgrades-core@^1.32.3 validate out/build-info --contract src/Upshort.sol:Upshort"])
    │   └─ ← [Return] (0, 0xe29c9420207372632f557073686f72742e736f6c3a557073686f72740a0a53554343455353, 0x)
    ├─ [0] VM::getCode("Upshort.sol") [staticcall]
    │   └─ ← [Revert] Multiple matching artifacts found
    └─ ← [Revert] Multiple matching artifacts found

Directory structure

.
├── cache
│   └── solidity-files-cache.json
├── foundry.toml
├── lib
│   ├── forge-std
│   ├── openzeppelin-contracts
│   ├── openzeppelin-contracts-upgradeable
│   └── openzeppelin-foundry-upgrades
├── out
│   ├── Address.sol
│   ├── Base.sol
│   ├── BeaconProxy.sol
│   ├── Context.sol
│   ├── ContextUpgradeable.sol
│   ├── Core.sol
│   ├── Defender.sol
│   ├── DefenderDeploy.sol
│   ├── ERC1967Proxy.sol
│   ├── ERC1967Utils.sol
│   ├── ERC20
│   ├── ERC20.sol
│   ├── IBeacon.sol
│   ├── IERC165.sol
│   ├── IERC1967.sol
│   ├── IERC20.sol
│   ├── IERC20Metadata.sol
│   ├── IERC721.sol
│   ├── IMulticall3.sol
│   ├── IProxyAdmin.sol
│   ├── IUpgradeableBeacon.sol
│   ├── IUpgradeableProxy.sol
│   ├── Initializable.sol
│   ├── Math.sol
│   ├── MockERC20.sol
│   ├── MockERC721.sol
│   ├── MyToken.sol
│   ├── Options.sol
│   ├── Ownable.sol
│   ├── OwnableUpgradeable.sol
│   ├── PausableUpgradeable.sol
│   ├── Proxy.sol
│   ├── ProxyAdmin.sol
│   ├── SignedMath.sol
│   ├── StdAssertions.sol
│   ├── StdChains.sol
│   ├── StdCheats.sol
│   ├── StdError.sol
│   ├── StdInvariant.sol
│   ├── StdJson.sol
│   ├── StdMath.sol
│   ├── StdStorage.sol
│   ├── StdStyle.sol
│   ├── StdToml.sol
│   ├── StdUtils.sol
│   ├── StorageSlot.sol
│   ├── Strings.sol
│   ├── Test.sol
│   ├── TransparentUpgradeableProxy.sol
│   ├── UUPSUpgradeable.sol
│   ├── UpgradeableBeacon.sol
│   ├── Upgrades.sol
│   ├── Upshort.sol
│   ├── Upshort.t.sol
│   ├── Utils.sol
│   ├── Versions.sol
│   ├── Vm.sol
│   ├── build-info
│   ├── console.sol
│   ├── console2.sol
│   ├── draft-IERC1822.sol
│   ├── draft-IERC6093.sol
│   ├── safeconsole.sol
│   └── src
├── src
│   ├── MyToken.sol
│   └── Upshort.sol
└── test
    └── Upshort.t.sol
ericglau commented 3 months ago

It looks like you may have multiple contracts with the same name (perhaps the test script name?)

You could disambiguate it by using the fully qualified contract name when calling deployUUPSProxy, for example:

address proxy = Upgrades.deployUUPSProxy(
            "src/Upshort.sol:Upshort",
            abi.encodeCall(Upshort.initialize, (vm.addr(1), address(token)))
        );
ericglau commented 2 months ago

Closing since this should be solvable as per the comment above. Feel free to reopen if you are still encountering the problem.