-
Notifications
You must be signed in to change notification settings - Fork 31
/
2_deploy_contracts.js
86 lines (68 loc) · 3.86 KB
/
2_deploy_contracts.js
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
78
79
80
81
82
83
84
85
86
const AvastarTeleporter = artifacts.require("./AvastarTeleporter.sol");
const AvastarMetadata = artifacts.require("./AvastarMetadata.sol");
const AvastarPrimeMinter = artifacts.require("./AvastarPrimeMinter.sol");
const constants = require("../util/Constants");
const AccountManager = require("../util/AccountManager");
const BN = require('bn.js');
module.exports = (deployer, network, liveAccounts) => {
deployer.then(async () => {
const generation = new BN(constants.GENERATION.ONE, 10);
const environment = AccountManager.getEnvByNetwork(network);
const currentAdmin = liveAccounts[0];
const accounts = AccountManager.getAccounts(environment);
const {owners, minters} = accounts;
const admins = accounts.admins.filter(acct => acct !== currentAdmin);
let promises;
// Deploy the Avastar Teleporter, Prime Minter, and Metadata contracts
console.log("Deploying contracts...");
const avastarTeleporter = await deployer.deploy(AvastarTeleporter);
const avastarPrimeMinter = await deployer.deploy(AvastarPrimeMinter);
const avastarMetadata = await deployer.deploy(AvastarMetadata);
// Prepare the Avastar Metadata contract for use
console.log("----------------------------------");
console.log("Preparing AvastarMetadata contract");
console.log("----------------------------------");
console.log("Set teleporter contract address");
await avastarMetadata.setTeleporterContract(avastarTeleporter.address);
console.log("Set Token URI Base");
await avastarMetadata.setTokenUriBase(constants.TOKEN_URI_BASE[environment]);
console.log("Set View URI Base");
await avastarMetadata.setViewUriBase(constants.VIEW_URI_BASE[environment]);
console.log("Set Media URI Base");
await avastarMetadata.setMediaUriBase(constants.MEDIA_URI_BASE[environment]);
console.log("Add admins");
promises = admins.map( admin => avastarMetadata.addSysAdmin(admin));
await Promise.all(promises);
console.log("Unpause\n");
await avastarMetadata.unpause();
// Prepare the Avastar Teleporter contract for use
console.log("------------------------------------");
console.log("Preparing AvastarTeleporter contract");
console.log("------------------------------------");
console.log("Add admins, owners");
promises = admins.map(admin => avastarTeleporter.addSysAdmin(admin));
promises.concat(owners.map(owner => avastarTeleporter.addOwner(owner)));
await Promise.all(promises);
console.log("Add minters");
await avastarTeleporter.addMinter(minters[0]);
await avastarTeleporter.addMinter(avastarPrimeMinter.address);
console.log("Set metadata contract address");
await avastarTeleporter.setMetadataContractAddress(avastarMetadata.address);
console.log("Unpause\n");
await avastarTeleporter.unpause();
// Prepare the Avastar Prime Minter contract for use
console.log("-------------------------------------");
console.log("Preparing AvastarPrimeMinter contract");
console.log("-------------------------------------");
console.log("Set teleporter contract address");
await avastarPrimeMinter.setTeleporterContract(avastarTeleporter.address);
console.log("Add admins, owners, minters");
promises = admins.map(admin => avastarPrimeMinter.addSysAdmin(admin));
promises.concat(owners.map(owner => avastarPrimeMinter.addOwner(owner)));
promises.concat(minters.map(minter => avastarPrimeMinter.addMinter(minter)));
console.log("Set current generation");
await avastarPrimeMinter.setCurrentGeneration(generation); // auto resets sets series
console.log("Unpause\n");
await avastarPrimeMinter.unpause();
});
};