Skip to content

Commit 7b5bcfd

Browse files
committed
Adds check-deployment-addresses.ts script
1 parent c59f5dd commit 7b5bcfd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"scripts": {
2424
"build": "pnpm build:hardhat && tsc -p tsconfig.build.json",
2525
"build:hardhat": "hardhat --config hardhat.build.config.ts compile",
26+
"check:deployment-addresses": "ts-node scripts/check-deployment-addresses.ts",
2627
"deploy:InverseApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags InverseApi3ReaderProxyV1",
2728
"deploy:NormalizedApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags NormalizedApi3ReaderProxyV1",
2829
"deploy:ProductApi3ReaderProxyV1": "hardhat deploy --network $NETWORK --tags ProductApi3ReaderProxyV1",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as fs from 'node:fs';
2+
import { join } from 'node:path';
3+
4+
import { getDeploymentAddresses } from './src/deployment-addresses';
5+
6+
async function main(): Promise<void> {
7+
const addressesJsonPath = join('deployments', 'addresses.json');
8+
const existingAddressesJsonString = fs.existsSync(addressesJsonPath)
9+
? fs.readFileSync(addressesJsonPath, 'utf8')
10+
: '{}';
11+
12+
const generatedAddressesJsonString = getDeploymentAddresses();
13+
14+
// Normalize by parsing and re-stringifying to ensure consistent formatting for comparison
15+
const normalizedExisting = `${JSON.stringify(JSON.parse(existingAddressesJsonString), null, 2)}\n`;
16+
const normalizedGenerated = `${JSON.stringify(JSON.parse(generatedAddressesJsonString), null, 2)}\n`;
17+
18+
if (normalizedExisting !== normalizedGenerated) {
19+
throw new Error(`${addressesJsonPath} is outdated. Please run "pnpm generate:deployment-addresses".`);
20+
}
21+
}
22+
23+
main()
24+
.then(() => process.exit(0))
25+
.catch((error) => {
26+
// eslint-disable-next-line no-console
27+
console.error(error);
28+
process.exit(1);
29+
});

0 commit comments

Comments
 (0)