/
signWhitelist.ts
29 lines (25 loc) · 920 Bytes
/
signWhitelist.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
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
export default async function signWhitelist(
chainId: number,
contractAddress: string,
whitelistKey: SignerWithAddress,
mintingAddress: string
) {
// Domain data should match whats specified in the DOMAIN_SEPARATOR constructed in the contract
// https://github.com/msfeldstein/EIP712-whitelisting/blob/main/contracts/EIP712Whitelisting.sol#L33-L43
const domain = {
name: "WhitelistToken",
version: "1",
chainId,
verifyingContract: contractAddress,
};
// The types should match the TYPEHASH specified in the contract
// https://github.com/msfeldstein/EIP712-whitelisting/blob/main/contracts/EIP712Whitelisting.sol#L27-L28
const types = {
Minter: [{ name: "wallet", type: "address" }],
};
const sig = await whitelistKey._signTypedData(domain, types, {
wallet: mintingAddress,
});
return sig
}