Skip to content

Commit f544ef1

Browse files
nkrishangKrishang Nadgauda
and
Krishang Nadgauda
authored
Data: get no. of pre-built contract deploys for a chain. (#174)
* script to get pre-built deploys in a date range, for a chain * revert hardhat config change * update data scripts Co-authored-by: Krishang Nadgauda <nkrishang@Krishangs-MBP.lan>
1 parent 1d4651b commit f544ef1

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

scripts/data/preBuiltDeploys.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import hre, { ethers } from "hardhat";
2+
import { TWRegistry } from "typechain";
3+
import { AddedEvent } from "typechain/contracts/TWRegistry";
4+
5+
// ====================================
6+
7+
// REPLACE according to desired date range.
8+
const startBlock: number = 0;
9+
const endBlock: number = 0;
10+
11+
async function main() {
12+
13+
const chainId: number = hre.network.config.chainId as number;
14+
console.log(`\nGetting the number of pre-built contracts deployed:\nChain: ${chainId}\nStart block: ${startBlock} End block: ${endBlock}`)
15+
16+
const twRegistry: TWRegistry = await ethers.getContractAt("TWRegistry", "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd");
17+
18+
const filter = twRegistry.filters.Added();
19+
let events: AddedEvent[];
20+
21+
if(!startBlock && !endBlock) {
22+
events = await twRegistry.queryFilter(filter);
23+
} else if (!endBlock) {
24+
events = await twRegistry.queryFilter(filter, startBlock);
25+
} else {
26+
events = await twRegistry.queryFilter(filter, startBlock, endBlock);
27+
}
28+
29+
console.log("Total number of pre-built contracts deployed: ", events.length);
30+
}
31+
32+
main()
33+
.then(() => process.exit(0))
34+
.catch(e => {
35+
console.error(e);
36+
process.exit(1);
37+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import hre, { ethers } from "hardhat";
2+
import { TWRegistry } from "typechain";
3+
import { AddedEvent } from "typechain/contracts/TWRegistry";
4+
5+
// ====================================
6+
7+
// REPLACE according to desired date range.
8+
const startBlock: number = 0;
9+
const endBlock: number = 0;
10+
11+
// REPLACE
12+
const deployer: string = "0x38abaC1B42ebC9429CB3c9E242dee5eA1104be5d";
13+
14+
async function main() {
15+
16+
const chainId: number = hre.network.config.chainId as number;
17+
console.log(`\nGetting the number of pre-built contracts deployed:\nChain: ${chainId}\nStart block: ${startBlock} End block: ${endBlock}\nDeployer: ${deployer}`)
18+
19+
const twRegistry: TWRegistry = await ethers.getContractAt("TWRegistry", "0x7c487845f98938Bb955B1D5AD069d9a30e4131fd");
20+
21+
const filter = twRegistry.filters.Added(deployer);
22+
let events: AddedEvent[];
23+
24+
if(!startBlock && !endBlock) {
25+
events = await twRegistry.queryFilter(filter);
26+
} else if (!endBlock) {
27+
events = await twRegistry.queryFilter(filter, startBlock);
28+
} else {
29+
events = await twRegistry.queryFilter(filter, startBlock, endBlock);
30+
}
31+
32+
console.log("Total deploys by deployer: ", events.length);
33+
console.log("Deployment addresses: ", events.map(x => x.args.deployment));
34+
}
35+
36+
main()
37+
.then(() => process.exit(0))
38+
.catch(e => {
39+
console.error(e);
40+
process.exit(1);
41+
});

0 commit comments

Comments
 (0)