-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed_ontology_builtins.js
70 lines (59 loc) · 1.73 KB
/
seed_ontology_builtins.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
const Web3 = require("web3");
const rlay = require("./web3-rlay.js");
const address = "0xc02345a911471fd46c47c4d3c2e5c85f5ae93d13";
const web3 = new Web3("http://localhost:8546");
rlay.extendWeb3WithRlay(web3);
web3.eth.defaultAccount = address;
async function storeEntity(entity) {
return await rlay.store(web3, entity, { gas: 1000000 });
}
async function seed() {
const rawLabelAnnotation = await storeEntity({
type: "Annotation",
value: rlay.encodeValue("label")
});
const rawLabelAnnotationProperty = await storeEntity({
type: "AnnotationProperty",
annotations: [rawLabelAnnotation]
});
const labelAnnotation = await storeEntity({
type: "Annotation",
property: rawLabelAnnotationProperty,
value: rlay.encodeValue("label")
});
const labelAnnotationProperty = await storeEntity({
type: "AnnotationProperty",
annotations: [labelAnnotation]
});
const seeAlsoLabelAnnotation = await storeEntity({
type: "Annotation",
property: labelAnnotationProperty,
value: rlay.encodeValue("seeAlso")
});
const seeAlsoAnnotationProperty = await storeEntity({
type: "AnnotationProperty",
annotations: [seeAlsoLabelAnnotation]
});
const commentLabelAnnotation = await storeEntity({
type: "Annotation",
property: labelAnnotationProperty,
value: rlay.encodeValue("comment")
});
const commentAnnotationProperty = await storeEntity({
type: "AnnotationProperty",
annotations: [commentLabelAnnotation]
});
return {
labelAnnotation,
seeAlsoLabelAnnotation,
commentLabelAnnotation,
labelAnnotationProperty,
seeAlsoAnnotationProperty,
commentAnnotationProperty
};
}
async function main() {
let cids = await seed();
console.log(cids);
}
main();