This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (48 loc) · 1.63 KB
/
index.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
const contract = require("truffle-contract");
const AETH = require("./build/contracts/AETH.json");
const Comments = require("./build/contracts/Comments.json");
const Entries = require("./build/contracts/Entries.json");
const Essence = require("./build/contracts/Essence.json");
const Feed = require("./build/contracts/Feed.json");
const ProfileRegistrar = require("./build/contracts/ProfileRegistrar.json");
const ProfileResolver = require("./build/contracts/ProfileResolver.json");
const Tags = require("./build/contracts/Tags.json");
const Votes = require("./build/contracts/Votes.json");
module.exports = async function init(web3Provider) {
const contracts = {
AETH: AETH,
Comments: Comments,
Entries: Entries,
Essence: Essence,
Feed: Feed,
ProfileRegistrar: ProfileRegistrar,
ProfileResolver: ProfileResolver,
Tags: Tags,
Votes: Votes
};
const exported = {};
const exportValue = function (val) {
return {
enumerable: true,
configurable: false,
writable: false,
value: val
}
};
const binds = Object.keys(contracts).map(
function (contractName) {
const instance = contract(contracts[contractName]);
instance.setProvider(web3Provider);
if(contractName === 'AETH'){
return instance.at('0x398a7a69f3c59181a1ffe34bed11dcb5df863a8a').then(function (data) {
Object.defineProperty(exported, contractName, exportValue(data));
});
}
return instance.deployed().then(function (data) {
Object.defineProperty(exported, contractName, exportValue(data));
});
}
);
await Promise.all(binds);
return exported;
};