|
| 1 | +import { LiquidInfrastructureERC20 } from "../typechain-types"; |
| 2 | +import { exit } from "process"; |
| 3 | + |
| 4 | +// const WxDAI_address = "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"; |
| 5 | +// const LiquidNFTExpectedAddress = "0x59ae6Db6e90488D645Cf0796a79C3A47b6B56ef5"; |
| 6 | +// const LiquidERC20ExpectedAddress = "0x8c4460023f9a1c7f97c2bB96b4143a37af5EDA0f"; |
| 7 | + |
| 8 | +export async function whitelistHolder( |
| 9 | + hre: any, |
| 10 | + contract: string, |
| 11 | + toApprove: string |
| 12 | +) { |
| 13 | + const ethers = hre.ethers; |
| 14 | + var startTime = new Date(); |
| 15 | + const signers = await ethers.getSigners(); |
| 16 | + let wallet = signers[0]; |
| 17 | + console.log("Owner Wallet address: ", wallet.address); |
| 18 | + |
| 19 | + var success = false; |
| 20 | + while (!success) { |
| 21 | + console.log("Looping until connection to network is made"); |
| 22 | + var present = new Date(); |
| 23 | + var timeDiff: number = present.getTime() - startTime.getTime(); |
| 24 | + timeDiff = timeDiff / 1000; |
| 25 | + try { |
| 26 | + const number = await ethers.provider.getBlockNumber(); |
| 27 | + success = true; |
| 28 | + } catch (e) { |
| 29 | + console.log("Ethereum RPC error, trying again"); |
| 30 | + } |
| 31 | + |
| 32 | + if (timeDiff > 600) { |
| 33 | + console.log( |
| 34 | + "Could not contact Ethereum RPC after 10 minutes, check the URL!" |
| 35 | + ); |
| 36 | + exit(1); |
| 37 | + } |
| 38 | + await sleep(1000); |
| 39 | + } |
| 40 | + console.log("Connected to network"); |
| 41 | + |
| 42 | + let liquidERC20: LiquidInfrastructureERC20; |
| 43 | + |
| 44 | + let liquidERC20Address; |
| 45 | + let lerc20Factory = await ethers.getContractFactory( |
| 46 | + "LiquidInfrastructureERC20" |
| 47 | + ); |
| 48 | + |
| 49 | + let lerc20 = lerc20Factory.attach( |
| 50 | + contract |
| 51 | + ) as unknown as LiquidInfrastructureERC20; |
| 52 | + |
| 53 | + liquidERC20 = lerc20; |
| 54 | + liquidERC20Address = await liquidERC20.getAddress(); |
| 55 | + console.log( |
| 56 | + "LiquidInfrastructureERC20 found at Address - ", |
| 57 | + liquidERC20Address |
| 58 | + ); |
| 59 | + |
| 60 | + if (!(await liquidERC20.isApprovedHolder(toApprove))) { |
| 61 | + console.log("Approving holder %s", toApprove); |
| 62 | + let receipt = await (await liquidERC20.approveHolder(toApprove)).wait(); |
| 63 | + console.assert(receipt?.blockNumber != null); |
| 64 | + } |
| 65 | + let totalSupply = await liquidERC20.totalSupply(); |
| 66 | + console.log("Total Supply: ", totalSupply.toString()); |
| 67 | + |
| 68 | + exit(0); |
| 69 | +} |
| 70 | +function sleep(ms: number) { |
| 71 | + return new Promise((resolve) => setTimeout(resolve, ms)); |
| 72 | +} |
0 commit comments