-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.ts
47 lines (38 loc) · 1.43 KB
/
template.ts
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
import {ethereum } from "@graphprotocol/graph-ts"
import {
CallData,
} from "../generated/schema"
import {
<CALL_OBJECTS>
} from "../generated/<ABI>/<ABI>"
<HANDLERS>
function paramHandler(call: ethereum.Call, name: string): void {
let cd = new CallData(call.block.number.toString())
let params: string[] = []
for (var i = 0; i < call.inputValues.length; i++ ){
switch(call.inputValues[i].value.kind){
case ethereum.ValueKind.ADDRESS:
params.push(call.inputValues[i].value.toAddress().toHexString())
break
case ethereum.ValueKind.INT:
case ethereum.ValueKind.UINT:
params.push(call.inputValues[i].value.toBigInt().toString())
break
case ethereum.ValueKind.BOOL:
params.push(call.inputValues[i].value.toBoolean().toString())
break
case ethereum.ValueKind.STRING:
params.push(call.inputValues[i].value.toString())
break
case ethereum.ValueKind.ARRAY:
params.push(call.inputValues[i].value.toArray().toString()) // does it work??
break
case ethereum.ValueKind.BYTES:
params.push(call.inputValues[i].value.toBytes().toHex()) // does it work??
break
}
}
cd.functionName = name
cd.params = params
cd.save()
}