-
Notifications
You must be signed in to change notification settings - Fork 0
Adds hardhat-deploy scripts for proxy contracts #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
acenolaza
wants to merge
1
commit into
morpho-market
Choose a base branch
from
proxy-deploy-scripts
base: morpho-market
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getUnnamedAccounts } = hre; | ||
const { deploy, log } = deployments; | ||
|
||
const [deployerAddress] = await getUnnamedAccounts(); | ||
if (!deployerAddress) { | ||
throw new Error("No deployer address found."); | ||
} | ||
log(`Deployer address: ${deployerAddress}`); | ||
|
||
const proxyAddress = process.env.PROXY; | ||
if (!proxyAddress) { | ||
throw new Error("PROXY environment variable not set. Please provide the address of the proxy contract."); | ||
} | ||
if (!hre.ethers.isAddress(proxyAddress)) { | ||
throw new Error(`Invalid address provided for PROXY: ${proxyAddress}`); | ||
} | ||
log(`Proxy address: ${proxyAddress}`); | ||
|
||
await deployments | ||
.get("InverseApi3ReaderProxyV1") | ||
.catch(async () => { | ||
return deploy("InverseApi3ReaderProxyV1", { | ||
from: deployerAddress, | ||
args: [proxyAddress], | ||
log: true, | ||
}); | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['InverseApi3ReaderProxyV1']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { DeployFunction, DeploymentsExtension } from 'hardhat-deploy/types'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
const deployTestFeed = async (deployments: DeploymentsExtension, deployerAddress: string) => { | ||
const { address: scaledApi3FeedProxyV1Address } = await deployments | ||
.get("ScaledApi3FeedProxyV1") | ||
.catch(async () => { | ||
return deployments.deploy("ScaledApi3FeedProxyV1", { | ||
from: deployerAddress, | ||
args: ["0x5b0cf2b36a65a6BB085D501B971e4c102B9Cd473", 8], | ||
log: true, | ||
}); | ||
}); | ||
return scaledApi3FeedProxyV1Address; | ||
} | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getUnnamedAccounts, network } = hre; | ||
const { deploy, log } = deployments; | ||
|
||
const [deployerAddress] = await getUnnamedAccounts(); | ||
if (!deployerAddress) { | ||
throw new Error("No deployer address found."); | ||
} | ||
log(`Deployer address: ${deployerAddress}`); | ||
|
||
const feedAddress = network.name !== "hardhat" ? process.env.FEED : await deployTestFeed(deployments, deployerAddress); | ||
if (!feedAddress) { | ||
throw new Error("FEED environment variable not set. Please provide the address of the AggregatorV2V3Interface contract."); | ||
} | ||
if (!hre.ethers.isAddress(feedAddress)) { | ||
throw new Error(`Invalid address provided for FEED: ${feedAddress}`); | ||
} | ||
log(`Feed address: ${feedAddress}`); | ||
|
||
await deployments | ||
.get("NormalizedApi3ReaderProxyV1") | ||
.catch(async () => { | ||
return deploy("NormalizedApi3ReaderProxyV1", { | ||
from: deployerAddress, | ||
args: [feedAddress], | ||
log: true, | ||
}); | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['NormalizedApi3ReaderProxyV1']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getUnnamedAccounts } = hre; | ||
const { deploy, log } = deployments; | ||
|
||
const [deployerAddress] = await getUnnamedAccounts(); | ||
if (!deployerAddress) { | ||
throw new Error("No deployer address found."); | ||
} | ||
log(`Deployer address: ${deployerAddress}`); | ||
|
||
const proxy1Address = process.env.PROXY1; | ||
if (!proxy1Address) { | ||
throw new Error("PROXY1 environment variable not set. Please provide the address of the first proxy contract."); | ||
} | ||
if (!hre.ethers.isAddress(proxy1Address)) { | ||
throw new Error(`Invalid address provided for PROXY1: ${proxy1Address}`); | ||
} | ||
log(`Proxy 1 address: ${proxy1Address}`); | ||
|
||
const proxy2Address = process.env.PROXY2; | ||
if (!proxy2Address) { | ||
throw new Error("PROXY2 environment variable not set. Please provide the address of the second proxy contract."); | ||
} | ||
if (!hre.ethers.isAddress(proxy2Address)) { | ||
throw new Error(`Invalid address provided for PROXY2: ${proxy2Address}`); | ||
} | ||
log(`Proxy 2 address: ${proxy2Address}`); | ||
|
||
await deployments | ||
.get("ProductApi3ReaderProxyV1") | ||
.catch(async () => { | ||
return deploy("ProductApi3ReaderProxyV1", { | ||
from: deployerAddress, | ||
args: [proxy1Address, proxy2Address], | ||
log: true, | ||
}); | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['ProductApi3ReaderProxyV1']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { DeployFunction, DeploymentsExtension } from 'hardhat-deploy/types'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
const deployTestProxy = async (deployments: DeploymentsExtension, deployerAddress: string) => { | ||
const { address: inverseApi3ReaderProxyV1Address } = await deployments | ||
.get("InverseApi3ReaderProxyV1") | ||
.catch(async () => { | ||
return deployments.deploy("InverseApi3ReaderProxyV1", { | ||
from: deployerAddress, | ||
args: ["0x5b0cf2b36a65a6BB085D501B971e4c102B9Cd473"], | ||
log: true, | ||
}); | ||
}); | ||
return inverseApi3ReaderProxyV1Address; | ||
} | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getUnnamedAccounts, network } = hre; | ||
const { deploy, log } = deployments; | ||
|
||
const [deployerAddress] = await getUnnamedAccounts(); | ||
if (!deployerAddress) { | ||
throw new Error("No deployer address found."); | ||
} | ||
log(`Deployer address: ${deployerAddress}`); | ||
|
||
const proxyAddress = network.name !== "hardhat" ? process.env.PROXY : await deployTestProxy(deployments, deployerAddress); | ||
if (!proxyAddress) { | ||
throw new Error("PROXY environment variable not set. Please provide the address of the Api3ReaderProxy contract."); | ||
} | ||
if (!hre.ethers.isAddress(proxyAddress)) { | ||
throw new Error(`Invalid address provided for PROXY: ${proxyAddress}`); | ||
} | ||
log(`Proxy address: ${proxyAddress}`); | ||
|
||
const decimals = process.env.DECIMALS ? parseInt(process.env.DECIMALS) : 18; | ||
log(`Decimals: ${decimals}`); | ||
|
||
await deployments | ||
.get("ScaledApi3FeedProxyV1") | ||
.catch(async () => { | ||
return deploy("ScaledApi3FeedProxyV1", { | ||
from: deployerAddress, | ||
args: [proxyAddress, decimals], | ||
log: true, | ||
}); | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ['ScaledApi3FeedProxyV1']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files are somehow excluded from linter (or not linted).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so 🤔