Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #158 from api3dao/deploy-and-verify-proxies
Browse files Browse the repository at this point in the history
Deploy and verify proxies
  • Loading branch information
bbenligiray authored Sep 13, 2023
2 parents 6b95de4 + 3e56b70 commit a02b1eb
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
37 changes: 35 additions & 2 deletions deploy/1_deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,46 @@ module.exports = async ({ getUnnamedAccounts, deployments }) => {
});
log(`Deployed Api3ServerV1 at ${api3ServerV1.address}`);

const proxyFactory = await deploy('ProxyFactory', {
const { address: proxyFactoryAddress, abi: proxyFactoryAbi } = await deploy('ProxyFactory', {
from: accounts[0],
args: [api3ServerV1.address],
log: true,
deterministicDeployment: process.env.DETERMINISTIC ? ethers.constants.HashZero : undefined,
});
log(`Deployed ProxyFactory at ${proxyFactory.address}`);
log(`Deployed ProxyFactory at ${proxyFactoryAddress}`);

const proxyFactory = new ethers.Contract(proxyFactoryAddress, proxyFactoryAbi, (await ethers.getSigners())[0]);
const nodaryEthUsdDataFeedId = '0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d';
const expectedDataFeedProxyAddress = await proxyFactory.computeDataFeedProxyAddress(nodaryEthUsdDataFeedId, '0x');
if ((await ethers.provider.getCode(expectedDataFeedProxyAddress)) === '0x') {
await proxyFactory.deployDataFeedProxy(nodaryEthUsdDataFeedId, '0x');
log(`Deployed example DataFeedProxy at ${expectedDataFeedProxyAddress}`);
}
const ethUsdDapiName = ethers.utils.formatBytes32String('ETH/USD');
const expectedDapiProxyAddress = await proxyFactory.computeDapiProxyAddress(ethUsdDapiName, '0x');
if ((await ethers.provider.getCode(expectedDapiProxyAddress)) === '0x') {
await proxyFactory.deployDapiProxy(ethUsdDapiName, '0x');
log(`Deployed example DapiProxy at ${expectedDapiProxyAddress}`);
}
const exampleOevBeneficiaryAddress = (await ethers.getSigners())[0].address;
const expectedDataFeedProxyWithOevAddress = await proxyFactory.computeDataFeedProxyWithOevAddress(
nodaryEthUsdDataFeedId,
exampleOevBeneficiaryAddress,
'0x'
);
if ((await ethers.provider.getCode(expectedDataFeedProxyWithOevAddress)) === '0x') {
await proxyFactory.deployDataFeedProxyWithOev(nodaryEthUsdDataFeedId, exampleOevBeneficiaryAddress, '0x');
log(`Deployed example DataFeedProxyWithOev at ${expectedDataFeedProxyWithOevAddress}`);
}
const expectedDapiProxyWithOevAddress = await proxyFactory.computeDapiProxyWithOevAddress(
ethUsdDapiName,
exampleOevBeneficiaryAddress,
'0x'
);
if ((await ethers.provider.getCode(expectedDapiProxyWithOevAddress)) === '0x') {
await proxyFactory.deployDapiProxyWithOev(ethUsdDapiName, exampleOevBeneficiaryAddress, '0x');
log(`Deployed example DapiProxyWithOev at ${expectedDapiProxyWithOevAddress}`);
}

if ([...chainsSupportedByOevRelay].includes(network.name)) {
let tokenAddress = tokenAddresses.usdc[network.name];
Expand Down
41 changes: 41 additions & 0 deletions deploy/3_verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,47 @@ module.exports = async ({ getUnnamedAccounts, deployments }) => {
constructorArguments: [Api3ServerV1.address],
});

const proxyFactory = new hre.ethers.Contract(
ProxyFactory.address,
ProxyFactory.abi,
(await hre.ethers.getSigners())[0]
);
const nodaryEthUsdDataFeedId = '0x4385954e058fbe6b6a744f32a4f89d67aad099f8fb8b23e7ea8dd366ae88151d';
const expectedDataFeedProxyAddress = await proxyFactory.computeDataFeedProxyAddress(nodaryEthUsdDataFeedId, '0x');
await hre.run('verify:verify', {
address: expectedDataFeedProxyAddress,
constructorArguments: [Api3ServerV1.address, nodaryEthUsdDataFeedId],
});
const ethUsdDapiName = hre.ethers.utils.formatBytes32String('ETH/USD');
const expectedDapiProxyAddress = await proxyFactory.computeDapiProxyAddress(ethUsdDapiName, '0x');
await hre.run('verify:verify', {
address: expectedDapiProxyAddress,
constructorArguments: [Api3ServerV1.address, hre.ethers.utils.keccak256(ethUsdDapiName)],
});
const testOevBeneficiaryAddress = (await hre.ethers.getSigners())[0].address;
const expectedDataFeedProxyWithOevAddress = await proxyFactory.computeDataFeedProxyWithOevAddress(
nodaryEthUsdDataFeedId,
testOevBeneficiaryAddress,
'0x'
);
await hre.run('verify:verify', {
address: expectedDataFeedProxyWithOevAddress,
constructorArguments: [Api3ServerV1.address, nodaryEthUsdDataFeedId, testOevBeneficiaryAddress],
});
const expectedDapiProxyWithOevAddress = await proxyFactory.computeDapiProxyWithOevAddress(
ethUsdDapiName,
testOevBeneficiaryAddress,
'0x'
);
await hre.run('verify:verify', {
address: expectedDapiProxyWithOevAddress,
constructorArguments: [
Api3ServerV1.address,
hre.ethers.utils.keccak256(ethUsdDapiName),
testOevBeneficiaryAddress,
],
});

if ([...chainsSupportedByOevRelay].includes(network.name)) {
let tokenAddress = tokenAddresses.usdc[network.name];
if (!tokenAddress) {
Expand Down

0 comments on commit a02b1eb

Please sign in to comment.