Repository navigation
Expand file tree
/
Copy pathtalent-layer-platform-id.ts
More file actions
149 lines (123 loc) · 4.97 KB
/
Copy pathtalent-layer-platform-id.ts
File metadata and controls
149 lines (123 loc) · 4.97 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { BigInt, DataSourceContext, store } from '@graphprotocol/graph-ts'
import { PlatformData } from '../../generated/templates'
import { MintFeeUpdated } from '../../generated/TalentLayerID/TalentLayerID'
import {
Approval,
ApprovalForAll,
ArbitrationFeeTimeoutUpdated,
ArbitratorAdded,
ArbitratorRemoved,
ArbitratorUpdated,
CidUpdated,
MinArbitrationFeeTimeoutUpdated,
Mint,
OriginServiceFeeRateUpdated,
OriginValidatedProposalFeeRateUpdated,
ProposalPostingFeeUpdated,
ServicePostingFeeUpdated,
SignerUpdated,
Transfer,
} from '../../generated/TalentLayerPlatformID/TalentLayerPlatformID'
import { getOrCreateArbitrator, getOrCreatePlatform, getOrCreateProtocol } from '../getters'
export function handleApproval(event: Approval): void {}
export function handleApprovalForAll(event: ApprovalForAll): void {}
export function handleCidUpdated(event: CidUpdated): void {
const platformId = event.params.platformId
const platform = getOrCreatePlatform(platformId)
const oldCid = platform.cid
const newCid = event.params.newCid
const dataId = newCid + '-' + event.block.timestamp.toString()
platform.updatedAt = event.block.timestamp
if (!oldCid) {
platform.createdAt = event.block.timestamp
}
platform.cid = newCid
const context = new DataSourceContext()
context.setBigInt('platformId', platformId)
context.setString('id', dataId)
if (oldCid) {
store.remove('PlatformDescription', oldCid)
}
PlatformData.createWithContext(newCid, context)
platform.description = dataId
platform.save()
}
export function handleMint(event: Mint): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.address = event.params.platformOwnerAddress
platform.name = event.params.platformName
platform.createdAt = event.block.timestamp
platform.updatedAt = event.block.timestamp
platform.arbitrationFeeTimeout = event.params.arbitrationFeeTimeout
platform.signer = event.params.platformOwnerAddress
platform.save()
const protocol = getOrCreateProtocol()
const currentTotalMintFees = protocol.totalMintFees || new BigInt(0)
protocol.totalMintFees = currentTotalMintFees.plus(event.params.fee)
protocol.save()
}
export function handleTransfer(event: Transfer): void {
const platform = getOrCreatePlatform(event.params.tokenId);
platform.address = event.params.to;
platform.save();
}
export function handleMintFeeUpdated(event: MintFeeUpdated): void {
const protocol = getOrCreateProtocol()
protocol.platformMintFee = event.params.mintFee
protocol.save()
}
export function handleOriginServiceFeeRateUpdated(event: OriginServiceFeeRateUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.originServiceFeeRate = event.params.originServiceFeeRate
platform.save()
}
export function handleOriginValidatedProposalFeeRateUpdated(event: OriginValidatedProposalFeeRateUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.originValidatedProposalFeeRate = event.params.originValidatedProposalFeeRate
platform.save()
}
export function handleArbitratorAdded(event: ArbitratorAdded): void {
const arbitrator = getOrCreateArbitrator(event.params.arbitrator)
arbitrator.address = event.params.arbitrator
arbitrator.isValid = true
arbitrator.isInternal = event.params.isInternal
arbitrator.save()
}
export function handleArbitratorRemoved(event: ArbitratorRemoved): void {
const arbitrator = getOrCreateArbitrator(event.params.arbitrator)
arbitrator.address = event.params.arbitrator
arbitrator.isValid = false
arbitrator.isInternal = false
arbitrator.save()
}
export function handleArbitratorUpdated(event: ArbitratorUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.arbitrator = event.params.arbitrator
platform.arbitratorExtraData = event.params.extraData
platform.save()
}
export function handleArbitrationFeeTimeoutUpdated(event: ArbitrationFeeTimeoutUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.arbitrationFeeTimeout = event.params.arbitrationFeeTimeout
platform.save()
}
export function handleMinArbitrationFeeTimeoutUpdated(event: MinArbitrationFeeTimeoutUpdated): void {
const protocol = getOrCreateProtocol()
protocol.minArbitrationFeeTimeout = event.params.minArbitrationFeeTimeout
protocol.save()
}
export function handleServicePostingFeeUpdated(event: ServicePostingFeeUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.servicePostingFee = event.params.servicePostingFee
platform.save()
}
export function handleProposalPostingFeeUpdated(event: ProposalPostingFeeUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.proposalPostingFee = event.params.proposalPostingFee
platform.save()
}
export function handleSignerUpdated(event: SignerUpdated): void {
const platform = getOrCreatePlatform(event.params.platformId)
platform.signer = event.params.signer
platform.save()
}