-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhelpers.ts
63 lines (53 loc) · 1.56 KB
/
helpers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { HardhatRuntimeEnvironment } from "hardhat/types";
const {
LedgerSigner,
} = require("../aavegotchi-contracts/node_modules/@ethersproject/hardware-wallets");
//Raffle contract
export const maticRafflesAddress = "0x6c723cac1E35FE29a175b287AE242d424c52c1CE";
export const maticTicketAddress = "0xA02d547512Bb90002807499F05495Fe9C4C3943f";
export const gasPrice = 275000000000;
export async function getLedgerSigner(
hre: HardhatRuntimeEnvironment,
deployer: string
) {
let testing = ["hardhat", "localhost"].includes(hre.network.name);
if (testing) {
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [deployer],
});
return await hre.ethers.getSigner(deployer);
} else {
return new LedgerSigner(hre.ethers.provider, "hid", "m/44'/60'/2'/0/0");
}
}
export async function getSigner(
hre: HardhatRuntimeEnvironment,
deployer: string
) {
let testing = ["hardhat", "localhost"].includes(hre.network.name);
if (testing) {
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [deployer],
});
return await hre.ethers.getSigner(deployer);
} else {
const accounts = await hre.ethers.getSigners();
return accounts[0];
}
}
export async function impersonate(
address: string,
contract: any,
ethers: any,
network: any
) {
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [address],
});
let signer = await ethers.getSigner(address);
contract = contract.connect(signer);
return contract;
}