Skip to content

Commit 9895c7c

Browse files
committed
refactor: using the template syntax for hardhat-deploy-ethers getContract()
1 parent 413a85a commit 9895c7c

14 files changed

+54
-55
lines changed

contracts/deploy/00-home-chain-arbitration-neo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8585
}); // nonce+2 (implementation), nonce+3 (proxy)
8686

8787
// disputeKit.changeCore() only if necessary
88-
const disputeKitContract = (await hre.ethers.getContract("DisputeKitClassicNeo")) as DisputeKitClassic;
88+
const disputeKitContract = await hre.ethers.getContract<DisputeKitClassic>("DisputeKitClassicNeo");
8989
const currentCore = await disputeKitContract.core();
9090
if (currentCore !== klerosCore.address) {
9191
console.log(`disputeKit.changeCore(${klerosCore.address})`);
@@ -99,7 +99,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
9999
await rngWithFallback.changeConsumer(sortitionModule.address);
100100
}
101101

102-
const core = (await hre.ethers.getContract("KlerosCoreNeo")) as KlerosCoreNeo;
102+
const core = await hre.ethers.getContract<KlerosCoreNeo>("KlerosCoreNeo");
103103
try {
104104
await changeCurrencyRate(core, await weth.getAddress(), true, 1, 1);
105105
} catch (e) {

contracts/deploy/00-home-chain-arbitration-ruler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3535
],
3636
log: true,
3737
});
38-
const core = (await hre.ethers.getContract("KlerosCoreRuler")) as KlerosCoreRuler;
38+
const core = await hre.ethers.getContract<KlerosCoreRuler>("KlerosCoreRuler");
3939

4040
try {
4141
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);

contracts/deploy/00-home-chain-arbitration-university.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6464
}); // nonce+2 (implementation), nonce+3 (proxy)
6565

6666
// disputeKit.changeCore() only if necessary
67-
const disputeKitContract = (await ethers.getContract("DisputeKitClassicUniversity")) as DisputeKitClassic;
67+
const disputeKitContract = await ethers.getContract<DisputeKitClassic>("DisputeKitClassicUniversity");
6868
const currentCore = await disputeKitContract.core();
6969
if (currentCore !== klerosCore.address) {
7070
console.log(`disputeKit.changeCore(${klerosCore.address})`);
7171
await disputeKitContract.changeCore(klerosCore.address);
7272
}
7373

74-
const core = (await hre.ethers.getContract("KlerosCoreUniversity")) as KlerosCoreUniversity;
74+
const core = await hre.ethers.getContract<KlerosCoreUniversity>("KlerosCoreUniversity");
7575
try {
7676
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
7777
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);

contracts/deploy/00-home-chain-arbitration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
9393
await rngWithFallback.changeConsumer(sortitionModule.address);
9494
}
9595

96-
const core = (await hre.ethers.getContract("KlerosCore")) as KlerosCore;
96+
const core = await hre.ethers.getContract<KlerosCore>("KlerosCore");
9797
try {
9898
await changeCurrencyRate(core, await pnk.getAddress(), true, 12225583, 12);
9999
await changeCurrencyRate(core, await dai.getAddress(), true, 60327783, 11);

contracts/deploy/change-arbitrable-dispute-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const deployResolver: DeployFunction = async (hre: HardhatRuntimeEnvironment) =>
3131
"specification": "KIP88"
3232
}`;
3333

34-
const arbitrable = (await ethers.getContract("ArbitrableExample")) as ArbitrableExample;
34+
const arbitrable = await ethers.getContract<ArbitrableExample>("ArbitrableExample");
3535
let tx = await (await arbitrable.changeDisputeTemplate(template, "disputeTemplateMapping: TODO")).wait();
3636
tx?.logs?.forEach((event) => {
3737
if (event instanceof EventLog) console.log("event: %O", event.args);

contracts/scripts/disputeRelayerBot.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export default async function main(
3333
homeGatewayArtifact: string,
3434
feeTokenArtifact?: string
3535
) {
36-
const core = (await ethers.getContract("KlerosCore")) as KlerosCore;
37-
const homeGateway = (await ethers.getContract(homeGatewayArtifact)) as HomeGateway;
38-
const feeToken = feeTokenArtifact ? ((await ethers.getContract(feeTokenArtifact)) as TestERC20) : undefined;
36+
const core = await ethers.getContract<KlerosCore>("KlerosCore");
37+
const homeGateway = await ethers.getContract<HomeGateway>(homeGatewayArtifact);
38+
const feeToken = feeTokenArtifact ? await ethers.getContract<TestERC20>(feeTokenArtifact) : undefined;
3939

4040
const foreignChainProvider = new ethers.providers.JsonRpcProvider(foreignNetwork.url);
4141
const foreignGatewayDeployment = await foreignDeployments.get(foreignGatewayArtifact);

contracts/test/arbitration/dispute-kit-gated.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,28 @@ describe("DisputeKitGated", async () => {
4747
fallbackToGlobal: true,
4848
keepExistingDeployments: false,
4949
});
50-
disputeKitGated = (await ethers.getContract("DisputeKitGated")) as DisputeKitGated;
51-
pnk = (await ethers.getContract("PNK")) as PNK;
52-
dai = (await ethers.getContract("DAI")) as TestERC20;
53-
core = (await ethers.getContract("KlerosCore")) as KlerosCore;
54-
sortitionModule = (await ethers.getContract("SortitionModule")) as SortitionModule;
50+
disputeKitGated = await ethers.getContract<DisputeKitGated>("DisputeKitGated");
51+
pnk = await ethers.getContract<PNK>("PNK");
52+
dai = await ethers.getContract<TestERC20>("DAI");
53+
core = await ethers.getContract<KlerosCore>("KlerosCore");
54+
sortitionModule = await ethers.getContract<SortitionModule>("SortitionModule");
5555

5656
// Make the tests more deterministic with this dummy RNG
5757
await deployments.deploy("IncrementalNG", {
5858
from: deployer,
5959
args: [RANDOM],
6060
log: true,
6161
});
62-
rng = (await ethers.getContract("IncrementalNG")) as IncrementalNG;
62+
rng = await ethers.getContract<IncrementalNG>("IncrementalNG");
6363

6464
await sortitionModule.changeRandomNumberGenerator(rng.target).then((tx) => tx.wait());
6565

6666
const hre = require("hardhat");
6767
await deployERC721(hre, deployer, "TestERC721", "Nft721");
68-
nft721 = (await ethers.getContract("Nft721")) as TestERC721;
68+
nft721 = await ethers.getContract<TestERC721>("Nft721");
6969

7070
await deployERC1155(hre, deployer, "TestERC1155", "Nft1155");
71-
nft1155 = (await ethers.getContract("Nft1155")) as TestERC1155;
71+
nft1155 = await ethers.getContract<TestERC1155>("Nft1155");
7272
await nft1155.mint(deployer, TOKEN_ID, 1, "0x00");
7373
});
7474

contracts/test/arbitration/draw.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ describe("Draw Benchmark", async () => {
6262
fallbackToGlobal: true,
6363
keepExistingDeployments: false,
6464
});
65-
disputeKit = (await ethers.getContract("DisputeKitClassic")) as DisputeKitClassic;
66-
pnk = (await ethers.getContract("PNK")) as PNK;
67-
core = (await ethers.getContract("KlerosCore")) as KlerosCore;
68-
homeGateway = (await ethers.getContract("HomeGatewayToEthereum")) as HomeGateway;
69-
arbitrable = (await ethers.getContract("ArbitrableExample")) as ArbitrableExample;
70-
sortitionModule = (await ethers.getContract("SortitionModule")) as SortitionModule;
65+
disputeKit = await ethers.getContract<DisputeKitClassic>("DisputeKitClassic");
66+
pnk = await ethers.getContract<PNK>("PNK");
67+
core = await ethers.getContract<KlerosCore>("KlerosCore");
68+
homeGateway = await ethers.getContract<HomeGateway>("HomeGatewayToEthereum");
69+
arbitrable = await ethers.getContract<ArbitrableExample>("ArbitrableExample");
70+
sortitionModule = await ethers.getContract<SortitionModule>("SortitionModule");
7171

7272
parentCourtMinStake = await core.courts(Courts.GENERAL).then((court) => court.minStake);
7373

@@ -79,7 +79,7 @@ describe("Draw Benchmark", async () => {
7979
args: [RANDOM],
8080
log: true,
8181
});
82-
rng = (await ethers.getContract("IncrementalNG")) as IncrementalNG;
82+
rng = await ethers.getContract<IncrementalNG>("IncrementalNG");
8383

8484
await sortitionModule.changeRandomNumberGenerator(rng.target).then((tx) => tx.wait());
8585

contracts/test/arbitration/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ async function deployContracts(): Promise<
100100
fallbackToGlobal: true,
101101
keepExistingDeployments: false,
102102
});
103-
const disputeKit = (await ethers.getContract("DisputeKitClassic")) as DisputeKitClassic;
104-
const disputeKitShutter = (await ethers.getContract("DisputeKitShutter")) as DisputeKitShutter;
105-
const disputeKitGated = (await ethers.getContract("DisputeKitGated")) as DisputeKitGated;
106-
const disputeKitGatedShutter = (await ethers.getContract("DisputeKitGatedShutter")) as DisputeKitGatedShutter;
107-
const core = (await ethers.getContract("KlerosCore")) as KlerosCore;
103+
const disputeKit = await ethers.getContract<DisputeKitClassic>("DisputeKitClassic");
104+
const disputeKitShutter = await ethers.getContract<DisputeKitShutter>("DisputeKitShutter");
105+
const disputeKitGated = await ethers.getContract<DisputeKitGated>("DisputeKitGated");
106+
const disputeKitGatedShutter = await ethers.getContract<DisputeKitGatedShutter>("DisputeKitGatedShutter");
107+
const core = await ethers.getContract<KlerosCore>("KlerosCore");
108108
return [core, disputeKit, disputeKitShutter, disputeKitGated, disputeKitGatedShutter];
109109
}

contracts/test/arbitration/ruler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function deployContracts(): Promise<[KlerosCoreRuler, DisputeResolver]> {
163163
fallbackToGlobal: true,
164164
keepExistingDeployments: false,
165165
});
166-
const resolver = (await ethers.getContract("DisputeResolverRuler")) as DisputeResolver;
167-
const core = (await ethers.getContract("KlerosCoreRuler")) as KlerosCoreRuler;
166+
const resolver = await ethers.getContract<DisputeResolver>("DisputeResolverRuler");
167+
const core = await ethers.getContract<KlerosCoreRuler>("KlerosCoreRuler");
168168
return [core, resolver];
169169
}

0 commit comments

Comments
 (0)