-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdeploy_cloneable.ts
62 lines (51 loc) · 1.91 KB
/
deploy_cloneable.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
import { ethers, ignition } from "hardhat";
import erc20Module from "../ignition/modules/erc20";
import { getLinkedContractFactory, deploy } from "./lib/common";
export async function deployFungible(tokenName: string) {
const { erc20 } = await ignition.deploy(erc20Module);
const verifiersDeployer = require(`./tokens/${tokenName}`);
const { deployer, args, libraries } =
await verifiersDeployer.deployDependencies();
let zetoFactory;
if (libraries) {
zetoFactory = await getLinkedContractFactory(tokenName, libraries);
} else {
zetoFactory = await ethers.getContractFactory(tokenName);
}
const zetoImpl: any = await zetoFactory.deploy();
await zetoImpl.waitForDeployment();
// console.log(args);
await zetoImpl.connect(deployer).initialize(...args);
const tx3 = await zetoImpl.connect(deployer).setERC20(erc20.target);
await tx3.wait();
console.log(`ERC20 deployed: ${erc20.target}`);
console.log(`ZetoToken deployed: ${zetoImpl.target}`);
return { deployer, zetoImpl, erc20, args };
}
export async function deployNonFungible(tokenName: string) {
const [deployer] = await ethers.getSigners();
const verifiersDeployer = require(`./tokens/${tokenName}`);
const { args, libraries } = await verifiersDeployer.deployDependencies();
let zetoFactory;
if (libraries) {
zetoFactory = await getLinkedContractFactory(tokenName, libraries);
} else {
zetoFactory = await ethers.getContractFactory(tokenName);
}
const zetoImpl: any = await zetoFactory.deploy();
await zetoImpl.waitForDeployment();
await zetoImpl.connect(deployer).initialize(...args);
console.log(`ZetoToken deployed: ${zetoImpl.target}`);
return { deployer, zetoImpl, args };
}
deploy(deployFungible, deployNonFungible)
.then(() => {
if (process.env.TEST_DEPLOY_SCRIPTS == "true") {
return;
}
process.exit(0);
})
.catch((error) => {
console.error(error);
process.exit(1);
});