Skip to content

Commit 8940812

Browse files
committed
chore: getDisputeTemplate task
1 parent 35bb1b1 commit 8940812

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

contracts/hardhat.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require("./scripts/simulations/tasks");
1717
require("./scripts/populatePolicyRegistry");
1818
require("./scripts/populateCourts");
1919
require("./scripts/changeGovernor");
20+
require("./scripts/getDisputeTemplate");
2021

2122
dotenv.config();
2223

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { task } from "hardhat/config";
2+
import { HardhatRuntimeEnvironment } from "hardhat/types";
3+
import { IDisputeTemplateRegistry } from "../typechain-types";
4+
5+
task("get-dispute-template", "Gets a dispute template by ID")
6+
.addPositionalParam("templateId", "The ID of the template to query")
7+
.setAction(async function ({ templateId }: { templateId: string }, hre: HardhatRuntimeEnvironment) {
8+
const { ethers } = hre;
9+
10+
// Get the contract instance
11+
const disputeTemplateRegistry = await ethers.getContract<IDisputeTemplateRegistry>("DisputeTemplateRegistry");
12+
13+
// Query the events
14+
const filter = disputeTemplateRegistry.filters.DisputeTemplate(BigInt(templateId));
15+
const events = await disputeTemplateRegistry.queryFilter(filter);
16+
17+
if (events.length === 0) {
18+
console.log(`No template found with ID ${templateId}`);
19+
return;
20+
}
21+
22+
// Get the most recent event
23+
const event = events[events.length - 1];
24+
25+
console.log("Template Details:");
26+
console.log("----------------");
27+
console.log(`Template ID: ${event.args._templateId}`);
28+
console.log(`Template Tag: ${event.args._templateTag}`);
29+
console.log(`Template Data: ${event.args._templateData}`);
30+
console.log(`Template Data Mappings: ${event.args._templateDataMappings}`);
31+
});

0 commit comments

Comments
 (0)