Skip to content
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

feat: update the deploy script #56

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add forking logic
clauBv23 committed Jan 28, 2025
commit 174f8b00bbd5018d32dd40f699a937a318794f4c
20 changes: 9 additions & 11 deletions packages/contracts/deploy/00_info/01_info.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import {
getProductionNetworkName,
isLocal,
} from '../../utils/helpers';
import {forkNetwork} from '../helpers';
import {getNetworkByNameOrAlias} from '@aragon/osx-commons-configs';
import {UnsupportedNetworkError} from '@aragon/osx-commons-sdk';
import {DeployFunction} from 'hardhat-deploy/types';
@@ -20,7 +21,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(`\n✨ ${path.basename(__filename)}:`);

const [deployer] = await hre.ethers.getSigners();
if (isLocal(hre)) {
if (process.env.FORKING_RPC_URL) {
await forkNetwork(hre, process.env.FORKING_RPC_URL);
} else if (isLocal(hre)) {
const productionNetworkName: string = getProductionNetworkName(hre);

console.log(
@@ -32,16 +35,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
if (networkConfig === null) {
throw new UnsupportedNetworkError(productionNetworkName);
}
await hre.network.provider.request({
method: 'hardhat_reset',
params: [
{
forking: {
jsonRpcUrl: networkConfig.url,
},
},
],
});
if (!networkConfig.url) {
throw new Error('RPC Url on network not defined');
}

await forkNetwork(hre, networkConfig.url);
} else {
console.log(`Production deployment on network '${hre.network.name}'.`);
}
16 changes: 16 additions & 0 deletions packages/contracts/deploy/helpers.ts
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@
contractName: string,
hre: HardhatRuntimeEnvironment
): string {
let networkName = hre.network.name;

Check failure on line 111 in packages/contracts/deploy/helpers.ts

GitHub Actions / checks

'networkName' is never reassigned. Use 'const' instead

Check failure on line 111 in packages/contracts/deploy/helpers.ts

GitHub Actions / formatting-linting / checks

'networkName' is never reassigned. Use 'const' instead

Check failure on line 111 in packages/contracts/deploy/helpers.ts

GitHub Actions / formatting-linting / checks

'networkName' is never reassigned. Use 'const' instead

const osxNetworkName = getNetworkNameByAlias(networkName);
if (!osxNetworkName) {
@@ -127,6 +127,22 @@
return '';
}

export async function forkNetwork(
hre: HardhatRuntimeEnvironment,
fork_url: string
) {
await hre.network.provider.request({
method: 'hardhat_reset',
params: [
{
forking: {
jsonRpcUrl: fork_url,
},
},
],
});
}

export async function detemineDeployerNextAddress(
index: number,
deployer: SignerWithAddress