-
Notifications
You must be signed in to change notification settings - Fork 3
/
createCommon.js
61 lines (53 loc) · 2.33 KB
/
createCommon.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
const { getArc, ADDRESS_1, PRIVATE_KEY_1, ARC_VERSION, OVERRIDES } = require('./settings')
const { getForgeOrgData, getSetSchemesData } = require('@daostack/common-factory')
async function createCommon() {
const DAONAME = `Test DAO ${Math.floor(Math.random() * 100000)}`
let tx;
let receipt
const arc = await getArc();
console.log(`fetching contractinfo from graphql...`)
const contractInfo = arc.getContractInfoByName(`DAOFactoryInstance`, ARC_VERSION)
const contractABI = arc.getABI( undefined, 'DAOFactory', ARC_VERSION)
const daoFactoryContract = await arc.getContract(contractInfo.address, contractABI)
const votingMachineInfo = arc.getContractInfoByName(`GenesisProtocol`, ARC_VERSION)
console.log(`Calling DAOFactory.forgeOrg(...)`)
const forgeOrgData =
getForgeOrgData({
DAOFactoryInstance: contractInfo.address,
orgName: DAONAME,
founderAddresses: [ADDRESS_1],
repDist: [100]
})
tx = await daoFactoryContract.forgeOrg(...forgeOrgData, OVERRIDES)
console.log(`waiting for tx to be mined`)
console.log(`https://rinkeby.etherscan.io/tx/${tx.hash}`)
receipt = await tx.wait()
console.log(`done!`)
// get the new avatar address of the thing that was just created..
const newOrgEvent = receipt.events.filter((e) => e.event === 'NewOrg')[0]
const newOrgAddress = newOrgEvent.args['_avatar']
console.log(`Calling DAOFactory.setSchemes(...)`)
// TODO: Use proper IPFS hash
let ipfsHash = 'metaData'
// deadline in Ethereum time, where 1 unit = 1 second (I think)
const deadline = (await arc.web3.getBlock('latest')).timestamp + 3000
// console.log(deadline)
const schemeData = getSetSchemesData({
DAOFactoryInstance: contractInfo.address,
avatar: newOrgAddress,
votingMachine: votingMachineInfo.address,
fundingToken: '0x0000000000000000000000000000000000000000',
minFeeToJoin: 100,
memberReputation: 100,
goal: 1000,
deadline,
metaData: ipfsHash,
})
tx = await daoFactoryContract.setSchemes(...schemeData, OVERRIDES)
console.log(`waiting for tx to be mined`)
console.log(`https://rinkeby.etherscan.io/tx/${tx.hash}`)
receipt = await tx.wait()
console.log(`Created a DAO at ${newOrgAddress} with name "${DAONAME}"`)
process.exit(0)
};
createCommon().catch((err) => {console.log(err); process.exit(0)})