@@ -55,7 +55,8 @@ export const protocolSetHandler = async (event: SubstrateEvent): Promise<void> =
55
55
record . currentConsent = currentConsent
56
56
record . endBlock = endBlock
57
57
record . threshold = threshold
58
- record . isActive = protocol === ProtocolAction . OnConsent || protocol === ProtocolAction . OnConsentAtBlock ? false : true
58
+ record . isActive = true
59
+ record . isThresholdReached = false
59
60
record . cancellation = cancellation === TransmissionCancellationAction . None ? null : cancellation
60
61
record . cancellationBlock = cancellationBlock
61
62
record . createdAt = commonEventData . timestamp
@@ -71,7 +72,7 @@ export const protocolSetHandler = async (event: SubstrateEvent): Promise<void> =
71
72
const nftRecord = await NftEntity . get ( nftId . toString ( ) )
72
73
if ( nftRecord === undefined )
73
74
throw new Error ( "NFT record not found in db for when setting a new transmission protocol" )
74
- nftRecord . isTransmission = true
75
+ nftRecord . isTransmission = record . isActive
75
76
nftRecord . transmissionRecipient = record . to
76
77
nftRecord . transmissionProtocolId = transmissionId
77
78
nftRecord . updatedAt = commonEventData . timestamp
@@ -81,6 +82,7 @@ export const protocolSetHandler = async (event: SubstrateEvent): Promise<void> =
81
82
await nftOperationEntityHandler ( nftRecord , record . from , commonEventData , NFTOperation . TransmissionProtocolSet , [
82
83
record . protocol ,
83
84
record . endBlock ,
85
+ record . to ,
84
86
] )
85
87
}
86
88
@@ -100,7 +102,7 @@ export const protocolRemovedHandler = async (event: SubstrateEvent): Promise<voi
100
102
// Side Effects on NftEntity
101
103
const nftRecord = await NftEntity . get ( nftId . toString ( ) )
102
104
if ( nftRecord === undefined ) throw new Error ( "NFT record not found in db for when removing transmission protocol" )
103
- nftRecord . isTransmission = false
105
+ nftRecord . isTransmission = record . isActive
104
106
nftRecord . transmissionRecipient = null
105
107
nftRecord . transmissionProtocolId = null
106
108
nftRecord . updatedAt = commonEventData . timestamp
@@ -128,6 +130,7 @@ export const timerResetHandler = async (event: SubstrateEvent): Promise<void> =>
128
130
await nftOperationEntityHandler ( nftRecord , record . from , commonEventData , NFTOperation . TransmissionTimerReset , [
129
131
record . protocol ,
130
132
record . endBlock ,
133
+ record . to ,
131
134
] )
132
135
}
133
136
@@ -151,6 +154,7 @@ export const consentAddedHandler = async (event: SubstrateEvent): Promise<void>
151
154
await nftOperationEntityHandler ( nftRecord , consentFrom , commonEventData , NFTOperation . TransmissionConsentAdded , [
152
155
record . protocol ,
153
156
record . endBlock ,
157
+ record . to ,
154
158
] )
155
159
}
156
160
@@ -161,19 +165,19 @@ export const thresholdReachedHandler = async (event: SubstrateEvent): Promise<vo
161
165
const [ nftId ] = event . event . data
162
166
const record = await getLastTransmission ( nftId . toString ( ) )
163
167
if ( record === undefined ) throw new Error ( "Transmission not found in db" )
164
- record . isActive = true
168
+ record . isThresholdReached = true
165
169
record . updatedAt = commonEventData . timestamp
166
170
record . timestampUpdated = commonEventData . timestamp
171
+ await record . save ( )
167
172
168
173
const nftRecord = await NftEntity . get ( nftId . toString ( ) )
169
174
170
175
// Side Effects on NftOperationEntity
171
176
await nftOperationEntityHandler ( nftRecord , null , commonEventData , NFTOperation . TransmissionThresholdReached , [
172
177
record . protocol ,
173
178
record . endBlock ,
179
+ record . to ,
174
180
] )
175
-
176
- await record . save ( )
177
181
}
178
182
179
183
export const capsuleTransmittedHandler = async ( event : SubstrateEvent ) : Promise < void > => {
@@ -192,7 +196,7 @@ export const capsuleTransmittedHandler = async (event: SubstrateEvent): Promise<
192
196
// Side Effects on NftEntity
193
197
const nftRecord = await NftEntity . get ( nftId . toString ( ) )
194
198
if ( nftRecord === undefined ) throw new Error ( "NFT record not found in db for when transmitting a capsule" )
195
- nftRecord . isTransmission = false
199
+ nftRecord . isTransmission = record . isActive
196
200
nftRecord . transmissionRecipient = null
197
201
nftRecord . transmissionProtocolId = null
198
202
nftRecord . owner = record . to
0 commit comments