Skip to content

Commit

Permalink
Change deployment to typescrpit file
Browse files Browse the repository at this point in the history
  • Loading branch information
alavarello committed Dec 26, 2024
1 parent 899f2a8 commit 33bc55f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ and add a new script in the package.json

You can deploy specific modules using hardhat ignition

After running the deployment, make sure to add the addresses to the deployment.json file
After running the deployment, make sure to add the addresses to the deployments.ts file

```shell
pnpm save:deployments
Expand Down
4 changes: 2 additions & 2 deletions deployments.json → deployments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
export const deployments = {
"11155111": {
"SciRegistry#SciRegistry": "0xaDD75Aecd98f0ADAD899729c88BfED4f8951c02A",
"PublicListVerifier#PublicListVerifier": "0xd58d48185146343720df2C26FcD8D3C3734e22cf",
Expand All @@ -8,4 +8,4 @@
"ProxyModule#ProxyAdmin": "0x9007eD4FFa791BB63662D6E894A97e163e4C2A23",
"SciModule#SCI": "0x1694F779f28E3B3ff409d62c9d9d7042Ff406aEC"
}
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"./contracts/**/*.sol",
"./artifacts/**/*.json",
"./dist/types/**",
"deployments.json",
"deployments.ts",
"README.md",
"LICENSE.txt"
],
Expand Down
14 changes: 9 additions & 5 deletions scripts/build-deployment-address.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readJson, writeJson, readdir } from 'fs-extra';
import { readJson, writeFile, readdir } from 'fs-extra';
import path from 'path';

const EXCLUDE_CHAINS = ['31337'];
Expand All @@ -14,7 +14,7 @@ async function main() {
.map((file) => file.split('-')[1]) // Extract the chain number
.filter((chain) => !EXCLUDE_CHAINS.includes(chain)); // Exclude chains

const outputJson: { [key: string]: Object } = {};
const outputData: { [key: string]: Object } = {};

for (const chain of validChains) {
const deployedAddressesPath = path.join(
Expand All @@ -24,14 +24,18 @@ async function main() {
);

try {
outputJson[chain] = await readJson(deployedAddressesPath);
outputData[chain] = await readJson(deployedAddressesPath);
} catch (error) {
console.warn(`Skipping chain-${chain}: Failed to read deployed_addresses.json.`);
}
}

await writeJson('deployments.json', outputJson, { spaces: 2 });
console.log(`Created`);
// Convert the output data into a TypeScript file
const tsContent = `export const deployments = ${JSON.stringify(outputData, null, 2)};`;

// Write the TypeScript file
await writeFile('deployments.ts', tsContent);
console.log('Created deployments.ts');
} catch (error) {
console.error('An error occurred:', error);
}
Expand Down

0 comments on commit 33bc55f

Please sign in to comment.