-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.txt
86 lines (63 loc) · 3.06 KB
/
hello.txt
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Address, BigInt } from "@graphprotocol/graph-ts"
import {
accessLevel as accessLevelEvent,
fileAdded as fileAddedEvent,
fileDeleted as fileDeletedEvent
} from "../generated/Web3Drive/Web3Drive"
import { accessLevel, fileAdded, fileDeleted, activeFile } from "../generated/schema"
export function handleaccessLevel(event: accessLevelEvent): void {
let accessLevelObject = accessLevel.load(getIdFromEventParams(event.params.token,event.params.gotAccess));
let activeFileObject = activeFile.load(getIdFromEventParams(event.params.token,event.params.gotAccess));
if(!accessLevelObject){
accessLevelObject = new accessLevel(getIdFromEventParams(event.params.token,event.params.gotAccess));
}
if(!activeFileObject){
activeFileObject = new activeFile(getIdFromEventParams(event.params.token,event.params.gotAccess));
}
accessLevelObject.gotAccess = event.params.gotAccess;
accessLevelObject.token = event.params.token;
accessLevelObject.AdminPrivilege = event.params.AdminPrivilege;
activeFileObject.Account = event.params.gotAccess;
activeFileObject.tokenId = event.params.token;
activeFileObject.Privilege = event.params.AdminPrivilege;
accessLevelObject.save();
activeFileObject.save();
}
export function handlefileAdded(event: fileAddedEvent): void {
let fileAddedObject = fileAdded.load(getIdFromEventParams(event.params.tokenId,event.params.Owner));
let activeFileObject = activeFile.load(getIdFromEventParams(event.params.tokenId,event.params.Owner));
if(!fileAddedObject){
fileAddedObject = new fileAdded(getIdFromEventParams(event.params.tokenId,event.params.Owner));
}
if(!activeFileObject){
activeFileObject = new activeFile(getIdFromEventParams(event.params.tokenId,event.params.Owner));
}
fileAddedObject.Owner = event.params.Owner;
fileAddedObject.tokenId = event.params.tokenId;
fileAddedObject.ipfsHash = event.params.ipfsHash;
activeFileObject.Account = event.params.Owner;
activeFileObject.tokenId = event.params.tokenId;
activeFileObject.ipfsHash = event.params.ipfsHash;
activeFileObject.Privilege = 3
fileAddedObject.save()
activeFileObject.save()
}
export function handlefileDeleted(event: fileDeletedEvent): void {
let fileDeletedObject = fileDeleted.load(getIdFromEventParams(event.params.token,event.params.whoDeleted));
let activeFileObject = activeFile.load(getIdFromEventParams(event.params.token,event.params.whoDeleted));
if(!activeFileObject){
activeFileObject = new activeFile(getIdFromEventParams(event.params.token,event.params.whoDeleted));
}
if(!fileDeletedObject){
fileDeletedObject = new fileDeleted(getIdFromEventParams(event.params.token,event.params.whoDeleted));
}
fileDeletedObject.token = event.params.token;
fileDeletedObject.whoDeleted = event.params.whoDeleted;
activeFileObject.Account = event.params.whoDeleted;
activeFileObject.tokenId = event.params.token;
fileDeletedObject.save();
activeFileObject.save();
}
function getIdFromEventParams(tokenId: BigInt, address: Address) : string {
return tokenId.toHexString() + address.toHexString();
}