-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtransaction.go
More file actions
477 lines (420 loc) · 17.3 KB
/
Copy pathtransaction.go
File metadata and controls
477 lines (420 loc) · 17.3 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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
package data
import (
"time"
"github.com/klever-io/klever-go/data/transaction"
)
// Transaction is a structure containing all the fields that need
//
// to be saved for a transaction. It has all the default fields
// plus some extra information for ease of search and filter
type Transaction struct {
Hash string `json:"hash"`
BlockNum uint64 `json:"blockNum,omitempty"`
Sender string `json:"sender"`
Nonce uint64 `json:"nonce"`
PermissionID int32 `json:"permissionID,omitempty"`
Data []string `json:"data,omitempty"`
Timestamp time.Duration `json:"timestamp,omitempty"`
KAppFee int64 `json:"kAppFee"`
KDAFee *KDAFee `json:"kdaFee,omitempty"`
BandwidthFee int64 `json:"bandwidthFee"`
Status string `json:"status"`
ResultCode string `json:"resultCode,omitempty"`
Version uint32 `json:"version,omitempty"`
ChainID string `json:"chainID,omitempty"`
Signature []string `json:"signature,omitempty"`
SearchOrder uint32 `json:"searchOrder"`
Receipts []map[string]interface{} `json:"receipts"`
Contracts []*TXContract `json:"contract"`
Logs *Logs `json:"logs,omitempty"`
HasLogs bool `json:"hasLogs,omitempty"`
HasOperations bool `json:"hasOperations,omitempty"`
}
// Logs represents logs with changed fields
type Logs struct {
ID string `json:"-"`
Address string `json:"address"`
Caller string `json:"caller,omitempty"`
ContractID int32 `json:"contractId"`
Timestamp time.Duration `json:"timestamp"`
// Status/ResultCode mirror the producing transaction's own fields, so a reverted/failed
// transaction's logs are distinguishable from a committed one's.
Status string `json:"status,omitempty"`
ResultCode string `json:"resultCode,omitempty"`
Events []*Event `json:"events"`
}
// Events represents the events generated by a transaction with changed fields
type Event struct {
Address string `json:"address"`
Identifier string `json:"identifier"`
Topics []string `json:"topics"`
Data []string `json:"data"`
Order int `json:"order"`
// IsSystemLog marks an event generated by the node itself (e.g. an internal VM
// error) rather than by contract code, so consumers of a live/public feed can filter
// out node-internal noise instead of it being indistinguishable from a real
// contract-emitted event.
IsSystemLog bool `json:"isSystemLog,omitempty"`
}
type KDAFee struct {
KDA string `json:"kda"`
Amount int64 `json:"amount"`
}
type TXContract struct {
Type transaction.TXContract_ContractType `json:"type"`
TypeString string `json:"typeString"`
Parameter interface{} `json:"parameter,omitempty"`
}
// -- TransferContract
type TransferContract struct {
AssetID string `json:"assetId,omitempty"`
ToAddress string `json:"toAddress,omitempty"`
Amount int64 `json:"amount,omitempty"`
KDARoyalties int64 `json:"kdaRoyalties,omitempty"`
KLVRoyalties int64 `json:"klvRoyalties,omitempty"`
}
// -- CreateAssetContract
type CreateAssetContract struct {
Type string `json:"type"`
Name string `json:"name"`
Ticker string `json:"ticker"`
Logo string `json:"logo"`
OwnerAddress string `json:"ownerAddress"`
AdminAddress string `json:"adminAddress"`
URIs []*URI `json:"uris"`
Precision uint32 `json:"precision"`
InitialSupply int64 `json:"initialSupply"`
CirculatingSupply int64 `json:"circulatingSupply"`
MaxSupply int64 `json:"maxSupply"`
MintedValue int64 `json:"mintedValue"`
BurnedValue int64 `json:"burnedValue"`
IssueDate int64 `json:"issueDate"`
Royalties *RoyaltiesInfo `json:"royalties"`
Properties *PropertiesInfo `json:"properties"`
Attributes *AttributesInfo `json:"attributes"`
Staking *Staking `json:"staking"`
Roles []*RolesInfo `json:"roles"`
Metadata *Meta `json:"meta,omitempty"`
}
type RolesInfo struct {
Address string `json:"address"`
HasRoleMint bool `json:"hasRoleMint"`
HasRoleSetITOPrices bool `json:"hasRoleSetITOPrices"`
HasRoleDeposit bool `json:"hasRoleDeposit"`
HasRoleTransfer bool `json:"hasRoleTransfer"`
}
type RoyaltiesInfo struct {
Address string `json:"address,omitempty"`
TransferPercentage []*RoyaltyDataInfo `json:"transferPercentage"`
TransferFixed int64 `json:"transferFixed"`
MarketPercentage uint32 `json:"marketPercentage"`
MarketFixed int64 `json:"marketFixed"`
ITOPercentage uint32 `json:"itoPercentage"`
ITOFixed int64 `json:"itoFixed"`
SplitRoyalties []*RoyaltySplitInfo `json:"splitRoyalties"`
}
type RoyaltyDataInfo struct {
Amount int64 `json:"amount,omitempty"`
Percentage uint32 `json:"percentage,omitempty"`
}
type RoyaltySplitInfo struct {
Address string `json:"address,omitempty"`
PercentTransferPercentage uint32 `json:"percentTransferPercentage,omitempty"`
PercentTransferFixed uint32 `json:"percentTransferFixed,omitempty"`
PercentMarketPercentage uint32 `json:"percentMarketPercentage,omitempty"`
PercentMarketFixed uint32 `json:"percentMarketFixed,omitempty"`
PercentITOPercentage uint32 `json:"percentITOPercentage,omitempty"`
PercentITOFixed uint32 `json:"percentITOFixed,omitempty"`
}
type PropertiesInfo struct {
CanFreeze bool `json:"canFreeze"`
CanWipe bool `json:"canWipe"`
CanPause bool `json:"canPause"`
CanMint bool `json:"canMint"`
CanBurn bool `json:"canBurn"`
CanChangeOwner bool `json:"canChangeOwner"`
CanAddRoles bool `json:"canAddRoles"`
LimitTransfer bool `json:"limitTransfer"`
}
type AttributesInfo struct {
IsPaused bool `json:"isPaused"`
IsNFTMintStopped bool `json:"isNFTMintStopped"`
IsRoyaltiesChangeStopped bool `json:"isRoyaltiesChangeStopped"`
}
type Staking struct {
Type string `json:"type,omitempty"`
APR uint32 `json:"apr,omitempty"`
MinEpochsToClaim uint32 `json:"minEpochsToClaim,omitempty"`
MinEpochsToUnstake uint32 `json:"minEpochsToUnstake,omitempty"`
MinEpochsToWithdraw uint32 `json:"minEpochsToWithdraw,omitempty"`
}
type StakingData struct {
InterestType string `json:"interestType"`
APR []*APRData `json:"apr"`
FPR []*FPRData `json:"fpr"`
TotalStaked int64 `json:"totalStaked"`
CurrentFPRAmount int64 `json:"currentFPRAmount"`
MinEpochsToClaim uint32 `json:"minEpochsToClaim"`
MinEpochsToUnstake uint32 `json:"minEpochsToUnstake"`
MinEpochsToWithdraw uint32 `json:"minEpochsToWithdraw"`
}
type KDAPool struct {
KDA string `json:"kda"`
Active bool `json:"active"`
AdminAddress string `json:"adminAddress"`
FRatioKLV int64 `json:"fRatioKLV"`
FRatioKDA int64 `json:"fRatioKDA"`
}
type Meta struct {
MaxSupply int64 `json:"maxSupply"`
Circulation int64 `json:"circulationSupply"`
Metadata Metadata `json:"metadata"`
}
type Metadata struct {
Name string `json:"name"`
Hash string `json:"hash"`
ContentType string `json:"contentType"`
Attributes string `json:"attributes"`
}
type KDAPoolData struct {
OwnerAddress string `json:"ownerAddress"`
KDA string `json:"kda"`
Active bool `json:"active"`
KLVBalance int64 `json:"klvBalance"`
KDABalance int64 `json:"kdaBalance"`
ConvertedFees int64 `json:"convertedFees"`
AdminAddress string `json:"adminAddress"`
FRatioKLV int64 `json:"fRatioKLV"`
FRatioKDA int64 `json:"fRatioKDA"`
Hidden *bool `json:"hidden,omitempty"`
Verified *bool `json:"verified,omitempty"`
}
type APRData struct {
Timestamp int64 `json:"timestamp"`
Epoch uint32 `json:"epoch"`
Value uint32 `json:"value"`
}
type FPRData struct {
TotalAmount int64 `json:"totalAmount"`
TotalStaked int64 `json:"totalStaked"`
Epoch uint32 `json:"epoch"`
TotalClaimed int64 `json:"TotalClaimed"`
KDA []*KDAFPRData `json:"kda"`
}
type KDAFPRData struct {
KDA string `json:"kda"`
TotalAmount int64 `json:"totalAmount"`
TotalClaimed int64 `json:"totalClaimed"`
}
// -- CreateValidatorContract
type CreateValidatorContract struct {
OwnerAddress string `json:"ownerAddress"`
Config ValidatorConfig `json:"config"`
}
// -- ValidatorConfigContract
type ValidatorConfigContract struct {
Config ValidatorConfig `json:"config,omitempty"`
}
// -- ValidatorConfig
type ValidatorConfig struct {
BLSPublicKey string `json:"blsPublicKey,omitempty"`
RewardAddress string `json:"rewardAddress,omitempty"`
CanDelegate bool `json:"canDelegate"`
Commission uint32 `json:"commission"`
MaxDelegationAmount int64 `json:"maxDelegationAmount"`
Logo string `json:"logo"`
URIs []*URI `json:"uris"`
Name string `json:"name"`
}
// -- FreezeContract
type FreezeContract struct {
Amount int64 `json:"amount,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// -- UnfreezeContract
type UnfreezeContract struct {
BucketID string `json:"bucketID,omitempty"`
AssetID string `json:"assetId,omitempty"`
}
// -- DelegateContract
type DelegateContract struct {
ToAddress string `json:"toAddress,omitempty"`
BucketID string `json:"bucketID,omitempty"`
}
// -- UndelegateContract
type UndelegateContract struct {
BucketID string `json:"bucketID,omitempty"`
}
// -- WithdrawContract
type WithdrawContract struct {
AssetID string `json:"assetId,omitempty"`
WithdrawTypeString string `json:"withdrawTypeString,omitempty"`
WithdrawType transaction.WithdrawContract_EnumWithdrawType `json:"withdrawType,omitempty"`
Amount int64 `json:"amount,omitempty"`
CurrencyID string `json:"currencyID,omitempty"`
}
// -- DepositContract
type DepositContract struct {
DepositTypeString string `json:"depositTypeString,omitempty"`
DepositType transaction.DepositContract_EnumDepositType `json:"depositType,omitempty"`
ID string `json:"id,omitempty"`
Amount int64 `json:"amount,omitempty"`
CurrencyID string `json:"currencyID,omitempty"`
}
// -- UnjailContract
type UnjailContract struct {
}
// -- RedeemContract
type RedeemContract struct {
}
// -- ClaimContract
type ClaimContract struct {
ClaimType string `json:"claimType,omitempty"`
ID string `json:"id,omitempty"`
}
// -- SetAccountNameContract
type SetAccountNameContract struct {
Name string `json:"name"`
}
// -- AssetTriggerContract
type AssetTriggerContract struct {
TriggerType string `json:"triggerType"`
AssetID string `json:"assetId"`
ToAddress string `json:"toAddress,omitempty"`
Amount int64 `json:"amount,omitempty"`
MIME string `json:"mime,omitempty"`
Logo string `json:"logo,omitempty"`
URIs []*URI `json:"uris,omitempty"`
Role *RolesInfo `json:"role,omitempty"`
Royalties *RoyaltiesInfo `json:"royalties,omitempty"`
Staking *Staking `json:"staking,omitempty"`
KDAPool *KDAPool `json:"kdaPool,omitempty"`
}
// -- ProposalContract
type ProposalContract struct {
Parameters map[int32]string `json:"parameters"`
Description string `json:"description"`
EpochsDuration uint32 `json:"epochsDuration"`
}
// -- VoteContract
type VoteContract struct {
Type string `json:"type"`
ProposalID uint64 `json:"proposalId"`
Amount int64 `json:"amount"`
}
// -- ConfigITOContract
type ConfigITOContract struct {
AssetID string `json:"assetId,omitempty"`
ReceiverAddress string `json:"receiverAddress,omitempty"`
Status string `json:"status,omitempty"`
MaxAmount int64 `json:"maxAmount,omitempty"`
PackInfo []*PackInfo `json:"packInfo,omitempty"`
DefaultLimitPerAddress int64 `json:"defaultLimitPerAddress,omitempty"`
WhitelistStatus string `json:"whitelistStatus,omitempty"`
WhitelistInfo []*WhitelistInfo `json:"whitelistInfo,omitempty"`
WhitelistStartTime int64 `json:"whitelistStartTime,omitempty"`
WhitelistEndTime int64 `json:"whitelistEndTime,omitempty"`
StartTime int64 `json:"startTime,omitempty"`
EndTime int64 `json:"endTime,omitempty"`
}
// -- WhitelistInfo
type WhitelistInfo struct {
Address string `json:"address"`
Limit int64 `json:"limit,omitempty"`
}
// -- ITOTriggerContract
type ITOTriggerContract struct {
TriggerType string `json:"triggerType,omitempty"`
AssetID string `json:"assetId,omitempty"`
ReceiverAddress string `json:"receiverAddress,omitempty"`
Status string `json:"status,omitempty"`
MaxAmount int64 `json:"maxAmount,omitempty"`
PackInfo []*PackInfo `json:"packInfo,omitempty"`
DefaultLimitPerAddress int64 `json:"defaultLimitPerAddress,omitempty"`
WhitelistStatus string `json:"whitelistStatus,omitempty"`
WhitelistInfo []*WhitelistInfo `json:"whitelistInfo,omitempty"`
WhitelistStartTime int64 `json:"whitelistStartTime,omitempty"`
WhitelistEndTime int64 `json:"whitelistEndTime,omitempty"`
StartTime int64 `json:"startTime,omitempty"`
EndTime int64 `json:"endTime,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
}
// -- SetITOPricesContract
type SetITOPricesContract struct {
AssetID string `json:"assetId,omitempty"`
PackInfo []*PackInfo `json:"packInfo,omitempty"`
}
// PackInfo holds the pack list structure for the ITO contract
type PackInfo struct {
Key string `json:"key,omitempty"`
Packs []*PackItem `json:"packs,omitempty"`
}
// PackItem hold the pack structure for the ITO contract
type PackItem struct {
Amount int64 `json:"amount,omitempty"`
Price int64 `json:"price,omitempty"`
}
// -- BuyContract
type BuyContract struct {
BuyType string `json:"buyType,omitempty"`
ID string `json:"id,omitempty"`
CurrencyID string `json:"currencyID,omitempty"`
Amount int64 `json:"amount,omitempty"`
CurrencyAmount int64 `json:"currencyAmount,omitempty"`
}
// -- SellContract
type SellContract struct {
MarketType string `json:"marketType,omitempty"`
MarketplaceID string `json:"marketplaceID,omitempty"`
AssetID string `json:"assetId,omitempty"`
CurrencyID string `json:"currencyID,omitempty"`
Price int64 `json:"price,omitempty"`
ReservePrice int64 `json:"reservePrice,omitempty"`
EndTime int64 `json:"endTime,omitempty"`
}
// -- CancelMarketOrderContract
type CancelMarketOrderContract struct {
OrderID string `json:"orderID,omitempty"`
}
// -- CreateMarketplaceContract
type CreateMarketplaceContract struct {
Name string `json:"name,omitempty"`
ReferralAddress string `json:"referralAddress,omitempty"`
ReferralPercentage uint32 `json:"referralPercentage,omitempty"`
}
// -- ConfigMarketplaceContract
type ConfigMarketplaceContract struct {
MarketplaceID string `json:"marketplaceID,omitempty"`
Name string `json:"name,omitempty"`
ReferralAddress string `json:"referralAddress,omitempty"`
ReferralPercentage uint32 `json:"referralPercentage,omitempty"`
}
type AccKey struct {
Address string `json:"address"`
Weight int64 `json:"weight"`
}
type AccPermission struct {
Type int32 `json:"type"`
PermissionName string `json:"permissionName"`
Threshold int64 `json:"threshold"`
Operations string `json:"operations"`
Signers []AccKey `json:"signers"`
}
// -- UpdateAccountPermissionContract
type UpdateAccountPermissionContract struct {
Permissions []AccPermission `json:"permissions"`
}
// SmartContract is a structure containing all the fields that need
type SmartContract struct {
Type string `json:"type"`
TypeValue int32 `json:"typeValue"`
Address string `json:"address"`
CallValue []SCCallValue `json:"callValue"`
}
// SCCallValue
type SCCallValue struct {
Asset string `json:"asset"`
Value int64 `json:"value"`
KDARoyalties int64 `json:"kdaRoyalties"`
KLVRoyalties int64 `json:"klvRoyalties"`
}