Skip to content

Commit a2c6746

Browse files
uniform all the hh helper functions to use bind
1 parent 6432544 commit a2c6746

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

v-next/hardhat-ethers/src/internal/initialization.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ export async function initializeEthers(
3232

3333
provider,
3434

35-
getSigner: (address: string) => hardhatHelpers.getSigner(address),
36-
getSigners: () => hardhatHelpers.getSigners(),
37-
getImpersonatedSigner: (address: string) =>
38-
hardhatHelpers.getImpersonatedSigner(address),
35+
// The bind is necessary because otherwise in the function the "this" that refers to the HardhatHelpers class will be overwritten
36+
getSigner: hardhatHelpers.getSigner.bind(hardhatHelpers),
37+
getSigners: hardhatHelpers.getSigners.bind(hardhatHelpers),
38+
getImpersonatedSigner:
39+
hardhatHelpers.getImpersonatedSigner.bind(hardhatHelpers),
3940
getContractFactory: hardhatHelpers.getContractFactory.bind(hardhatHelpers),
40-
getContractFactoryFromArtifact: (...args) =>
41-
hardhatHelpers.getContractFactoryFromArtifact(...args),
42-
getContractAt: (...args) => hardhatHelpers.getContractAt(...args),
43-
getContractAtFromArtifact: (...args) =>
44-
hardhatHelpers.getContractAtFromArtifact(...args),
41+
getContractFactoryFromArtifact:
42+
hardhatHelpers.getContractFactoryFromArtifact.bind(hardhatHelpers),
43+
getContractAt: hardhatHelpers.getContractAt.bind(hardhatHelpers),
44+
getContractAtFromArtifact:
45+
hardhatHelpers.getContractAtFromArtifact.bind(hardhatHelpers),
4546
deployContract: hardhatHelpers.deployContract.bind(hardhatHelpers),
4647
};
4748
}

0 commit comments

Comments
 (0)