/
SoulName.ts
77 lines (67 loc) · 2.04 KB
/
SoulName.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import hre from "hardhat";
import { getEnvParams, getPrivateKey } from "../src/utils/EnvParams";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { DeployFunction } from "hardhat-deploy/dist/types";
let owner: SignerWithAddress;
const func: DeployFunction = async ({
// @ts-ignore
getNamedAccounts,
// @ts-ignore
deployments,
// @ts-ignore
ethers,
network
}) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
[, owner] = await ethers.getSigners();
const env = getEnvParams(network.name);
const soulboundIdentityDeployed = await deployments.get("SoulboundIdentity");
const soulNameDeploymentResult = await deploy("SoulName", {
from: deployer,
args: [
env.OWNER || owner.address,
soulboundIdentityDeployed.address,
".soul",
""
],
log: true
});
// verify contract with etherscan, if its not a local network
if (network.name == "mainnet" || network.name == "goerli") {
await hre.run("verify:verify", {
address: soulNameDeploymentResult.address,
constructorArguments: [
env.OWNER || owner.address,
soulboundIdentityDeployed.address,
".soul",
""
]
});
}
const soulboundIdentity = await ethers.getContractAt(
"SoulboundIdentity",
soulboundIdentityDeployed.address
);
const soulName = await ethers.getContractAt(
"SoulName",
soulNameDeploymentResult.address
);
// we set the soulName contract in soulboundIdentity and we add soulboundIdentity as soulName minter
const signer = env.OWNER
? new ethers.Wallet(
getPrivateKey(network.name),
ethers.getDefaultProvider(network.name)
)
: owner;
const MINTER_ROLE = await soulName.MINTER_ROLE();
await soulboundIdentity
.connect(signer)
.setSoulName(soulNameDeploymentResult.address);
await soulName
.connect(signer)
.grantRole(MINTER_ROLE, soulboundIdentityDeployed.address);
};
func.tags = ["SoulName"];
func.dependencies = ["SoulboundIdentity"];
export default func;