-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcontract_events.go
274 lines (237 loc) · 6.68 KB
/
contract_events.go
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
package substrate
import (
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/scale"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
)
// ContractBill structure
type ContractBill struct {
ContractID types.U64 `json:"contract_id"`
Timestamp types.U64 `json:"timestamp"`
DiscountLevel DiscountLevel `json:"discount_level"`
AmountBilled types.U128 `json:"amount_billed"`
}
// DiscountLevel enum
type DiscountLevel struct {
IsNone bool `json:"is_none"`
IsDefault bool `json:"is_default"`
IsBronze bool `json:"is_bronze"`
IsSilver bool `json:"is_silver"`
IsGold bool `json:"is_gold"`
}
// Decode implementation for the enum type
func (r *DiscountLevel) Decode(decoder scale.Decoder) error {
b, err := decoder.ReadOneByte()
if err != nil {
return err
}
switch b {
case 0:
r.IsNone = true
case 1:
r.IsDefault = true
case 2:
r.IsBronze = true
case 3:
r.IsSilver = true
case 4:
r.IsGold = true
default:
return fmt.Errorf("unknown Contract Discount Level value")
}
return nil
}
// Encode implementation
func (r DiscountLevel) Encode(encoder scale.Encoder) (err error) {
if r.IsNone {
err = encoder.PushByte(0)
} else if r.IsDefault {
err = encoder.PushByte(1)
} else if r.IsBronze {
err = encoder.PushByte(2)
} else if r.IsSilver {
err = encoder.PushByte(3)
} else if r.IsGold {
err = encoder.PushByte(4)
}
return
}
// ContractCreated is the contract created event
type ContractCreated struct {
Phase types.Phase
Contract Contract `json:"contract"`
Topics []types.Hash
}
// ContractUpdated is the contract updated event
type ContractUpdated struct {
Phase types.Phase
Contract Contract `json:"contract"`
Topics []types.Hash
}
// NodeContractCanceled
type NodeContractCanceled struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Node types.U32 `json:"node_id"`
Twin types.U32 `json:"twin_id"`
Topics []types.Hash
}
// NameContractCanceled
type NameContractCanceled struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Topics []types.Hash
}
// ServiceContractCreated
type ServiceContractCreated struct {
Phase types.Phase
ServiceContract ServiceContract `json:"service_contract"`
Topics []types.Hash
}
// ServiceContractCanceled
type ServiceContractCanceled struct {
Phase types.Phase
ServiceContractID types.U64 `json:"service_contract_id"`
Cause DeletedState `json:"cause"`
Topics []types.Hash
}
// ServiceContractBilled
type ServiceContractBilled struct {
Phase types.Phase
ServiceContract ServiceContract `json:"service_contract"`
ServiceContractBill ServiceContractBill `json:"service_contract_bill"`
Amount types.U128 `json:"amount"`
Topics []types.Hash
}
// ContractDeployed
type ContractDeployed struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
AccountID AccountID `json:"account_id"`
Topics []types.Hash
}
// DEPRECATED
// ConsumptionReportReceived
type ConsumptionReportReceived struct {
Phase types.Phase
Consumption Consumption `json:"consumption"`
Topics []types.Hash
}
// ConsumptionReportReceived
type NruConsumptionReportReceived struct {
Phase types.Phase
Consumption NruConsumption `json:"consumption"`
Topics []types.Hash
}
// ContractBilled
type ContractBilled struct {
Phase types.Phase
ContractBill ContractBill `json:"contract_bill"`
Topics []types.Hash
}
// IPsReserved
type IPsReserved struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
IPs []PublicIP `json:"ips"`
Topics []types.Hash
}
// IPsFreed
type IPsFreed struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
IPs []PublicIP `json:"ips"`
Topics []types.Hash
}
// TokensBurned
type TokensBurned struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Amount types.U128 `json:"amount"`
Topics []types.Hash
}
type UpdatedUsedResources struct {
Phase types.Phase
ContractResources ContractResources `json:"contract_resources"`
Topics []types.Hash
}
// RentContractCanceled
type RentContractCanceled struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Topics []types.Hash
}
type ContractGracePeriodStarted struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
NodeID types.U32 `json:"node_id"`
TwinID types.U32 `json:"twin_id"`
StartBlock types.U64 `json:"start_block"`
Topics []types.Hash
}
type ContractGracePeriodEnded struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
NodeID types.U32 `json:"node_id"`
TwinID types.U32 `json:"twin_id"`
Topics []types.Hash
}
type SolutionProvider struct {
SolutionProviderID types.U64 `json:"solution_provider_id"`
Providers []Provider `json:"providers"`
Description string `json:"description"`
Link string `json:"link"`
Approved bool `json:"approved"`
}
type Provider struct {
Who types.AccountID `json:"who"`
Take types.U8 `json:"take"`
}
type SolutionProviderCreated struct {
Phase types.Phase
SolutionProvider SolutionProvider `json:"solution_provider"`
Topics []types.Hash
}
type SolutionProviderApproved struct {
Phase types.Phase
SolutionProviderID types.U64 `json:"solution_provider_id"`
Approved bool `json:"approved"`
Topics []types.Hash
}
type BillingFrequencyChanged struct {
Phase types.Phase
Frequency types.U64 `json:"frequency"`
Topics []types.Hash
}
type NodeExtraFeeSet struct {
Phase types.Phase
NodeID types.U32 `json:"node_id"`
ExtraFee types.U64 `json:"extra_fee"`
Topics []types.Hash
}
type RentWaived struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Topics []types.Hash
}
type ContractGracePeriodElapsed struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
GracePeriod types.U64 `json:"grace_period"`
Topics []types.Hash
}
type ContractPaymentOverdrawn struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Timestamp types.U64 `json:"timestamp"`
PartiallyBilledAmount types.U128 `json:"partially_billed_amount"`
Overdraft types.U128 `json:"overdraft"`
Topics []types.Hash
}
type RewardDistributed struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
StandardRewards types.U128 `json:"standard_rewards"`
AdditionalRewards types.U128 `json:"additional_rewards"`
Topics []types.Hash
}