@reality.eth/graph 0.4.23 → 0.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +38 -22
- package/schema.graphql +0 -16
- package/src/mapping.ts +103 -113
- package/src/mapping_factory.ts +28 -0
- package/subgraph.datasource.template.yaml +1 -1
- package/subgraph.factory.template.yaml +2 -2
- package/subgraph.template.template.yaml +1 -1
package/README.md
CHANGED
|
@@ -3,3 +3,9 @@
|
|
|
3
3
|
This is the subgraph for reality.eth.
|
|
4
4
|
|
|
5
5
|
It should be able to parse most templates correctly, but as we do not yet have a complete port of the sprintf-js library used by the dapp, we cannot guarantee the exact same handling of edge cases. We recommend that anywhere important, such as a page where you allow people to submit bonds, you do the template handling and formatting in JavaScript.
|
|
6
|
+
|
|
7
|
+
You may need to pass the GRAPH_AUTH environmental variable with the param
|
|
8
|
+
--access-token <YOUR KEY>
|
|
9
|
+
We suggest keeping this in a file, eg
|
|
10
|
+
GRAPH_AUTH="--access-token `cat ~/secrets/graph_auth`" yarn deploy:zksync-goerli
|
|
11
|
+
|
package/package.json
CHANGED
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reality.eth/graph",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.25",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"create-local": "graph create realityeth/realityeth --node http://127.0.0.1:8020",
|
|
6
6
|
"remove-local": "graph remove realityeth/realityeth --node http://127.0.0.1:8020",
|
|
7
7
|
"codegen": "graph codegen",
|
|
8
8
|
"build": "graph build",
|
|
9
|
+
"oink": "echo $GRAPH_AUTH",
|
|
9
10
|
"deploy-local": "yarn deploy-local:rinkeby",
|
|
10
|
-
"deploy-local:rinkeby": "yarn prepare:rinkeby && graph deploy
|
|
11
|
-
"deploy:arbitrum": "yarn prepare:arbitrum && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-arbitrum",
|
|
12
|
-
"deploy:ava": "yarn prepare:ava && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-ava",
|
|
13
|
-
"deploy:bsc": "yarn prepare:bsc && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-bsc",
|
|
14
|
-
"deploy:chapel": "yarn prepare:chapel && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-chapel",
|
|
15
|
-
"deploy:kovan": "yarn prepare:kovan && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-kovan",
|
|
16
|
-
"deploy:goerli": "yarn prepare:goerli && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-goerli",
|
|
17
|
-
"deploy:mainnet": "yarn prepare:mainnet && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth",
|
|
18
|
-
"deploy:optimism": "yarn prepare:optimism && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-optimism",
|
|
19
|
-
"deploy:polygon": "yarn prepare:polygon && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-polygon",
|
|
20
|
-
"deploy:mumbai": "yarn prepare:mumbai && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-mumbai",
|
|
21
|
-
"deploy:rinkeby": "yarn prepare:rinkeby && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-rinkeby",
|
|
22
|
-
"deploy:sokol": "yarn prepare:sokol && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-sokol",
|
|
23
|
-
"deploy:xdai": "yarn prepare:xdai && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-xdai",
|
|
24
|
-
"deploy:zksync-goerli": "yarn prepare:zksync-goerli && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-zksync-goerli",
|
|
11
|
+
"deploy-local:rinkeby": "yarn prepare:rinkeby && graph deploy $GRAPH_AUTHrealityeth/realityeth --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
|
|
12
|
+
"deploy:arbitrum": "yarn prepare:arbitrum && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-arbitrum",
|
|
13
|
+
"deploy:ava": "yarn prepare:ava && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-ava",
|
|
14
|
+
"deploy:bsc": "yarn prepare:bsc && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-bsc",
|
|
15
|
+
"deploy:chapel": "yarn prepare:chapel && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-chapel",
|
|
16
|
+
"deploy:kovan": "yarn prepare:kovan && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-kovan",
|
|
17
|
+
"deploy:goerli": "yarn prepare:goerli && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-goerli",
|
|
18
|
+
"deploy:mainnet": "yarn prepare:mainnet && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth",
|
|
19
|
+
"deploy:optimism": "yarn prepare:optimism && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-optimism",
|
|
20
|
+
"deploy:polygon": "yarn prepare:polygon && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-polygon",
|
|
21
|
+
"deploy:mumbai": "yarn prepare:mumbai && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-mumbai",
|
|
22
|
+
"deploy:rinkeby": "yarn prepare:rinkeby && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-rinkeby",
|
|
23
|
+
"deploy:sokol": "yarn prepare:sokol && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-sokol",
|
|
24
|
+
"deploy:xdai": "yarn prepare:xdai && graph deploy $GRAPH_AUTH--ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-xdai",
|
|
25
|
+
"deploy:zksync-goerli": "yarn prepare:zksync-goerli && graph deploy $GRAPH_AUTH --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-zksync-goerli-2",
|
|
25
26
|
"deploy:all": "yarn deploy:arbitrum && yarn deploy:ava && yarn deploy:bsc && yarn deploy:kovan && yarn deploy:mainnet && yarn deploy:mainnet && yarn deploy:optimism && yarn deploy:polygon && yarn deploy:rinkeby && yarn deploy:sokol && yarn deploy:xdai",
|
|
27
|
+
"deploy-studio:arbitrum": "yarn prepare:arbitrum && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-arbitrum",
|
|
28
|
+
"deploy-studio:ava": "yarn prepare:ava && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-ava",
|
|
29
|
+
"deploy-studio:bsc": "yarn prepare:bsc && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-bsc",
|
|
30
|
+
"deploy-studio:chapel": "yarn prepare:chapel && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-chapel",
|
|
31
|
+
"deploy-studio:kovan": "yarn prepare:kovan && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-kovan",
|
|
32
|
+
"deploy-studio:goerli": "yarn prepare:goerli && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-goerli",
|
|
33
|
+
"deploy-studio:mainnet": "yarn prepare:mainnet && graph deploy $GRAPH_AUTH --studio realityeth/realityeth",
|
|
34
|
+
"deploy-studio:optimism": "yarn prepare:optimism && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-optimism",
|
|
35
|
+
"deploy-studio:polygon": "yarn prepare:polygon && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-polygon",
|
|
36
|
+
"deploy-studio:mumbai": "yarn prepare:mumbai && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-mumbai",
|
|
37
|
+
"deploy-studio:rinkeby": "yarn prepare:rinkeby && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-rinkeby",
|
|
38
|
+
"deploy-studio:sokol": "yarn prepare:sokol && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-sokol",
|
|
39
|
+
"deploy-studio:xdai": "yarn prepare:xdai && graph deploy $GRAPH_AUTH --studio realityeth/realityeth-xdai",
|
|
40
|
+
"deploy-studio:zksync-goerli": "yarn prepare:zksync-goerli && graph deploy $GRAPH_AUTH realityeth/realityeth-zksync-goerli-2",
|
|
41
|
+
"deploy-studio:all": "yarn deploy-studio:arbitrum && yarn deploy-studio:ava && yarn deploy-studio:bsc && yarn deploy-studio:kovan && yarn deploy-studio:mainnet && yarn deploy-studio:mainnet && yarn deploy-studio:optimism && yarn deploy-studio:polygon && yarn deploy-studio:rinkeby && yarn deploy-studio:sokol && yarn deploy-studio:xdai",
|
|
26
42
|
"prepare:arbitrum": "yarn clean && node render-templates.js 42161 && graph codegen",
|
|
27
43
|
"prepare:ava": "yarn clean && node render-templates.js 43114 && graph codegen",
|
|
28
44
|
"prepare:bsc": "yarn clean && node render-templates.js 56 && graph codegen",
|
|
@@ -43,16 +59,16 @@
|
|
|
43
59
|
"prettier": "prettier '**/*.ts'",
|
|
44
60
|
"prettier-write": "prettier --write '**/*.ts'"
|
|
45
61
|
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@graphprotocol/graph-cli": "^0.20.0",
|
|
48
|
-
"@graphprotocol/graph-ts": "^0.20.0"
|
|
49
|
-
},
|
|
50
62
|
"dependencies": {
|
|
51
|
-
"@reality.eth/contracts": "^3.0.
|
|
63
|
+
"@reality.eth/contracts": "^3.0.23",
|
|
52
64
|
"babel-polyfill": "^6.26.0",
|
|
53
65
|
"babel-register": "^6.26.0",
|
|
54
66
|
"mustache": "^4.2.0",
|
|
55
67
|
"truffle-hdwallet-provider": "^1.0.4"
|
|
56
68
|
},
|
|
57
|
-
"
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@graphprotocol/graph-cli": "^0.30.2",
|
|
71
|
+
"@graphprotocol/graph-ts": "^0.27.0"
|
|
72
|
+
},
|
|
73
|
+
"gitHead": "d115d0f9e969993975ef156c559d6f247c783b81"
|
|
58
74
|
}
|
package/schema.graphql
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
type _Schema_
|
|
2
|
-
@fulltext(
|
|
3
|
-
name: "questionSearch",
|
|
4
|
-
language: en
|
|
5
|
-
algorithm: rank,
|
|
6
|
-
include: [
|
|
7
|
-
{
|
|
8
|
-
entity: "Question",
|
|
9
|
-
fields: [
|
|
10
|
-
{ name: "qTitle" },
|
|
11
|
-
{ name: "qCategory" }
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
)
|
|
16
|
-
|
|
17
1
|
type Question @entity {
|
|
18
2
|
id: ID!
|
|
19
3
|
questionId: Bytes!
|
package/src/mapping.ts
CHANGED
|
@@ -31,15 +31,7 @@ import {
|
|
|
31
31
|
LogWithdraw,
|
|
32
32
|
LogMinimumBond,
|
|
33
33
|
LogReopenQuestion
|
|
34
|
-
} from '../generated/RealityETH/RealityETH'
|
|
35
|
-
|
|
36
|
-
import {
|
|
37
|
-
RealityETH_ERC20_deployed
|
|
38
|
-
} from '../generated/RealityETH_ERC20_Factory/RealityETH_ERC20_Factory'
|
|
39
|
-
|
|
40
|
-
import {
|
|
41
|
-
FactoryCreatedRealityETH,
|
|
42
|
-
} from '../generated/templates'
|
|
34
|
+
} from '../generated/RealityETH-3.0-ETH/RealityETH'
|
|
43
35
|
|
|
44
36
|
export function handleNewTemplate(event: LogNewTemplate): void {
|
|
45
37
|
let contractTemplateId = event.address.toHexString() + '-' + event.params.template_id.toHexString();
|
|
@@ -47,7 +39,9 @@ export function handleNewTemplate(event: LogNewTemplate): void {
|
|
|
47
39
|
tmpl.templateId = event.params.template_id;
|
|
48
40
|
tmpl.contract = event.address;
|
|
49
41
|
tmpl.user = event.params.user;
|
|
50
|
-
|
|
42
|
+
if (event.params.question_text) {
|
|
43
|
+
tmpl.questionText = event.params.question_text;
|
|
44
|
+
}
|
|
51
45
|
tmpl.createdBlock = event.block.number;
|
|
52
46
|
tmpl.save()
|
|
53
47
|
|
|
@@ -70,100 +64,103 @@ export function handleNewQuestion(event: LogNewQuestion): void {
|
|
|
70
64
|
let tmpl = Template.load(contractTemplateId);
|
|
71
65
|
question.template = contractTemplateId;
|
|
72
66
|
|
|
73
|
-
|
|
67
|
+
if (tmpl) {
|
|
68
|
+
let questionText = tmpl.questionText;
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
let data = event.params.question;
|
|
71
|
+
let fields = data.split('\u241f');
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
if (questionText) {
|
|
74
|
+
let qJsonStr = sprintf(questionText, fields)
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
let tryData = json.try_fromString(qJsonStr)
|
|
77
|
+
if (tryData.isOk) {
|
|
78
|
+
let json_dict = tryData.value.toObject()
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
let qTitle = json_dict.get('title')
|
|
81
|
+
if (qTitle != null && qTitle.kind === JSONValueKind.STRING) {
|
|
82
|
+
question.qTitle = qTitle.toString()
|
|
83
|
+
}
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
let qCategory = json_dict.get('category')
|
|
86
|
+
if (qCategory != null && qCategory.kind == JSONValueKind.STRING) {
|
|
87
|
+
question.qCategory = qCategory.toString();
|
|
88
|
+
}
|
|
93
89
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
let qLang = json_dict.get('lang')
|
|
91
|
+
if (qLang != null && qLang.kind == JSONValueKind.STRING) {
|
|
92
|
+
question.qLang = qLang.toString();
|
|
93
|
+
}
|
|
98
94
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
let qType = json_dict.get('type')
|
|
96
|
+
if (qType != null && qType.kind == JSONValueKind.STRING) {
|
|
97
|
+
question.qType = qType.toString();
|
|
98
|
+
}
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
let q_outcomes_val = json_dict.get('outcomes')
|
|
101
|
+
if (q_outcomes_val != null && q_outcomes_val.kind === JSONValueKind.ARRAY) {
|
|
102
|
+
let q_outcomes = q_outcomes_val.toArray()
|
|
103
|
+
for(let i = 0; i < q_outcomes.length; i++) {
|
|
104
|
+
let outcomeID = contractQuestionId + '-' + i.toString();
|
|
105
|
+
let outcome = new Outcome(outcomeID);
|
|
106
|
+
if (q_outcomes[i].kind === JSONValueKind.STRING) {
|
|
107
|
+
outcome.answer = q_outcomes[i].toString()
|
|
108
|
+
} else {
|
|
109
|
+
outcome.answer = "[FORMATTING ERROR]";
|
|
110
|
+
}
|
|
111
|
+
outcome.question = contractQuestionId;
|
|
112
|
+
outcome.save()
|
|
113
|
+
}
|
|
117
114
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
} else {
|
|
116
|
+
log.info('Could not parse json for question {}', [contractQuestionId]);
|
|
117
|
+
}
|
|
118
|
+
question.contract = contract;
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
question.data = data
|
|
121
|
+
question.contentHash = event.params.content_hash;
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
question.contentHash = event.params.content_hash;
|
|
123
|
+
question.qJsonStr = qJsonStr
|
|
127
124
|
|
|
128
|
-
|
|
125
|
+
question.createdBlock = event.block.number;
|
|
126
|
+
question.createdTimestamp = event.params.created;
|
|
127
|
+
question.updatedBlock = event.block.number;
|
|
128
|
+
question.updatedTimestamp = event.block.timestamp;
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
question.user = event.params.user;
|
|
131
|
+
question.arbitrator = event.params.arbitrator;
|
|
132
|
+
question.openingTimestamp = event.params.opening_ts;
|
|
133
|
+
question.timeout = event.params.timeout;
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
question.openingTimestamp = event.params.opening_ts;
|
|
138
|
-
question.timeout = event.params.timeout;
|
|
135
|
+
question.isPendingArbitration = false;
|
|
136
|
+
question.arbitrationOccurred = false;
|
|
139
137
|
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
question.currentAnswerBond = new BigInt(0);
|
|
139
|
+
question.lastBond = new BigInt(0);
|
|
140
|
+
question.cumulativeBonds = new BigInt(0);
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
question.lastBond = new BigInt(0);
|
|
145
|
-
question.cumulativeBonds = new BigInt(0);
|
|
142
|
+
question.minBond = new BigInt(0);
|
|
146
143
|
|
|
147
|
-
|
|
144
|
+
question.currentScheduledFinalizationTimestamp = BigInt.fromI32(I32.MAX_VALUE);
|
|
148
145
|
|
|
149
|
-
|
|
146
|
+
// In version 3 and above the bounty should be picked up by the LogFundAnswerBounty event.
|
|
147
|
+
// In version 2 this isn't fired on question create.
|
|
148
|
+
// We could handle this with a call but this would mean we'd need an archive node to index.
|
|
149
|
+
// Instead, make sure we do a call in the UI for the current bounty when using the v2 contract.
|
|
150
|
+
// This shouldn't matter much as neither v2 nor the bounty feature is used much.
|
|
151
|
+
question.bounty = new BigInt(0);
|
|
150
152
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// We could handle this with a call but this would mean we'd need an archive node to index.
|
|
154
|
-
// Instead, make sure we do a call in the UI for the current bounty when using the v2 contract.
|
|
155
|
-
// This shouldn't matter much as neither v2 nor the bounty feature is used much.
|
|
156
|
-
question.bounty = new BigInt(0);
|
|
157
|
-
|
|
158
|
-
question.save();
|
|
153
|
+
question.save();
|
|
154
|
+
}
|
|
159
155
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
156
|
+
let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
|
|
157
|
+
ua.actionType = 'AskQuestion';
|
|
158
|
+
ua.user = event.params.user;
|
|
159
|
+
ua.question = contractQuestionId;
|
|
160
|
+
ua.createdBlock = event.block.number;
|
|
161
|
+
ua.createdTimestamp = event.block.timestamp;
|
|
162
|
+
ua.save();
|
|
163
|
+
}
|
|
167
164
|
|
|
168
165
|
}
|
|
169
166
|
|
|
@@ -368,11 +365,13 @@ export function handleLogClaim(event: LogClaim): void {
|
|
|
368
365
|
|
|
369
366
|
let question = Question.load(contractQuestionId);
|
|
370
367
|
let contract = RealityETH.bind(event.address)
|
|
371
|
-
|
|
368
|
+
if (question) {
|
|
369
|
+
question.historyHash = contract.getHistoryHash(event.params.question_id);
|
|
372
370
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
371
|
+
question.updatedBlock = event.block.number;
|
|
372
|
+
question.updatedTimestamp = event.block.timestamp;
|
|
373
|
+
question.save();
|
|
374
|
+
}
|
|
376
375
|
}
|
|
377
376
|
|
|
378
377
|
export function handleLogWithdraw(event: LogWithdraw): void {
|
|
@@ -389,8 +388,10 @@ export function handleLogWithdraw(event: LogWithdraw): void {
|
|
|
389
388
|
export function handleLogMinimumBond(event: LogMinimumBond): void {
|
|
390
389
|
let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
|
|
391
390
|
let question = Question.load(contractQuestionId);
|
|
392
|
-
question
|
|
393
|
-
|
|
391
|
+
if (question) {
|
|
392
|
+
question.minBond = event.params.min_bond;
|
|
393
|
+
question.save();
|
|
394
|
+
}
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
export function handleLogReopenQuestion(event: LogReopenQuestion): void {
|
|
@@ -399,14 +400,18 @@ export function handleLogReopenQuestion(event: LogReopenQuestion): void {
|
|
|
399
400
|
let reopenedContractQuestionId = event.address.toHexString() + '-' + event.params.reopened_question_id.toHexString();
|
|
400
401
|
let question = Question.load(contractQuestionId);
|
|
401
402
|
let reopenedQuestion = Question.load(reopenedContractQuestionId);
|
|
402
|
-
question
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
reopenedQuestion
|
|
409
|
-
|
|
403
|
+
if (question) {
|
|
404
|
+
question.reopens = reopenedContractQuestionId;
|
|
405
|
+
question.updatedBlock = event.block.number;
|
|
406
|
+
question.updatedTimestamp = event.block.timestamp;
|
|
407
|
+
question.save();
|
|
408
|
+
}
|
|
409
|
+
if (reopenedQuestion) {
|
|
410
|
+
reopenedQuestion.reopenedBy = contractQuestionId;
|
|
411
|
+
reopenedQuestion.updatedBlock = event.block.number;
|
|
412
|
+
reopenedQuestion.updatedTimestamp = event.block.timestamp;
|
|
413
|
+
reopenedQuestion.save();
|
|
414
|
+
}
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts: BigInt, createdBlock: BigInt): void {
|
|
@@ -432,18 +437,3 @@ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts:
|
|
|
432
437
|
answerEntity.save();
|
|
433
438
|
}
|
|
434
439
|
}
|
|
435
|
-
|
|
436
|
-
export function handleFactoryRealityETHDeploy(event: RealityETH_ERC20_deployed): void {
|
|
437
|
-
FactoryCreatedRealityETH.create(event.params.reality_eth)
|
|
438
|
-
|
|
439
|
-
let deploymentId = event.address.toHexString() + event.params.token.toHexString();
|
|
440
|
-
let facdep = new FactoryDeployment(deploymentId)
|
|
441
|
-
facdep.token_address = event.params.token;
|
|
442
|
-
facdep.token_symbol = event.params.token_ticker;
|
|
443
|
-
facdep.token_decimals = BigInt.fromI32(event.params.decimals);
|
|
444
|
-
facdep.realityETH = event.params.reality_eth;
|
|
445
|
-
facdep.factory = event.address;
|
|
446
|
-
facdep.createdBlock = event.block.number;
|
|
447
|
-
facdep.createdTimestamp = event.block.timestamp;
|
|
448
|
-
facdep.save();
|
|
449
|
-
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { crypto, log, BigInt, Bytes, ByteArray } from '@graphprotocol/graph-ts'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
FactoryDeployment,
|
|
5
|
+
} from '../generated/schema'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
RealityETH_ERC20_deployed
|
|
9
|
+
} from '../generated/RealityETH_ERC20_Factory/RealityETH_ERC20_Factory'
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
FactoryCreatedRealityETH,
|
|
13
|
+
} from '../generated/templates'
|
|
14
|
+
|
|
15
|
+
export function handleFactoryRealityETHDeploy(event: RealityETH_ERC20_deployed): void {
|
|
16
|
+
FactoryCreatedRealityETH.create(event.params.reality_eth)
|
|
17
|
+
|
|
18
|
+
let deploymentId = event.address.toHexString() + event.params.token.toHexString();
|
|
19
|
+
let facdep = new FactoryDeployment(deploymentId)
|
|
20
|
+
facdep.token_address = event.params.token;
|
|
21
|
+
facdep.token_symbol = event.params.token_ticker;
|
|
22
|
+
facdep.token_decimals = BigInt.fromI32(event.params.decimals);
|
|
23
|
+
facdep.realityETH = event.params.reality_eth;
|
|
24
|
+
facdep.factory = event.address;
|
|
25
|
+
facdep.createdBlock = event.block.number;
|
|
26
|
+
facdep.createdTimestamp = event.block.timestamp;
|
|
27
|
+
facdep.save();
|
|
28
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
abi: RealityETH_ERC20_Factory
|
|
8
8
|
mapping:
|
|
9
9
|
kind: ethereum/events
|
|
10
|
-
apiVersion: 0.0.
|
|
10
|
+
apiVersion: 0.0.6
|
|
11
11
|
language: wasm/assemblyscript
|
|
12
12
|
entities:
|
|
13
13
|
- Directory
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
eventHandlers:
|
|
18
18
|
- event: RealityETH_ERC20_deployed(address,address,uint8,string)
|
|
19
19
|
handler: handleFactoryRealityETHDeploy
|
|
20
|
-
file: ./src/
|
|
20
|
+
file: ./src/mapping_factory.ts
|