OpenZeppelin / OpenZeppelin/openzeppelin-upgrades
Retrieve ProxyDeployment by ContractName
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 658
- Forks
- 286
- PR merge metrics
- No merged PRs in 30d
Description
Hi there, coming from using the hardhat-deploy-ethers plugin to retrieve a contract by its name, I found a deployed proxy through hardhat upgrades plugin cannot be retrieved the same way. See this link for how getContract<T>(contractName) works under the hood.
Wondering if proxy deployment could be retreived by contract name in the same way. If this is already possible, how is it achieved? Thanks.
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import { ethers, upgrades } from "hardhat";
import { Manifest } from '@openzeppelin/upgrades-core';
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployProxy } = upgrades;
const { deployer } = await getNamedAccounts();
const { provider } = hre.network;
const manifest = await Manifest.forNetwork(provider);
const get = deployments.getOrNull;
const Box = await ethers.getContractFactory("Box");
const box = await deployProxy(Box, [], { kind: "uups" });
await box.connect(deployer).deployed();
console.log(await get("Box"));
const proxies = (await manifest.read()).proxies;
console.log(proxies);
console.log(await manifest.getProxyFromAddress(proxies[0].address));
};
export default func;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked hardhat-deploy-ethers helper at src/internal/helpers.ts#L460 and the deployProxy, deployments.getOrNull, and Manifest calls shown in the issue. Trace how proxy addresses are recorded and resolved, then verify that retrieval by contract name is supported or specify the missing behavior and its tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100