-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.go
97 lines (83 loc) · 3.14 KB
/
schema.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
package tron
import "github.com/fbsobreira/gotron-sdk/pkg/proto/core"
type Resource string
const (
Resource_Bandwidth Resource = "bandwidth"
Resource_Energy = "energy"
Resource_TronPower = "tron_power"
)
func (inst Resource) ToResourceCode() core.ResourceCode {
switch inst {
case "bandwidth":
return core.ResourceCode_BANDWIDTH
case "energy":
return core.ResourceCode_ENERGY
case "tron_power":
return core.ResourceCode_TRON_POWER
}
return -1
}
type DelegateResourceParams struct {
Owner Address `json:"owner"`
Receiver Address `json:"receiver"`
Resource Resource `json:"resource"`
Balance int64 `json:"balance"`
Lock bool `json:"lock"`
LockPeriod int64 `json:"lock_period"`
PermissionId int32 `json:"permission_id"`
}
type UnDelegateResourceParams struct {
Owner Address `json:"owner"`
Receiver Address `json:"receiver"`
Resource Resource `json:"resource"`
Balance int64 `json:"balance"`
PermissionId int32 `json:"permission_id"`
}
type AccountResource struct {
FreeNetLimit int64 `json:"freeNetLimit"` // Total free bandwidth
NetUsed int64 `json:"netUsed"` // Used amount of bandwidth obtained by staking
NetLimit int64 `json:"netLimit"` // Total bandwidth obtained by staking
EnergyLimit int64 `json:"energyLimit"` // Total energy obtained by staking
EnergyUsed int64 `json:"energyUsed"` // Energy used
TotalNetWeight int64 `json:"totalNetWeight"` // Total TRX staked for bandwidth by the whole network
TotalNetLimit int64 `json:"totalNetLimit"` // Total bandwidth can be obtained by staking by the whole network
TotalEnergyLimit int64 `json:"totalEnergyLimit"` // Total energy can be obtained by staking by the whole network
TotalEnergyWeight int64 `json:"totalEnergyWeight"` // Total TRX staked for energy by the whole network
TronPowerUsed int64 `json:"tronPowerUsed"` // TRON Power(vote) used
TronPowerLimit int64 `json:"tronPowerLimit"` // TRON Power(vote)
}
type Balance struct {
Energy *ResourceBalance `json:"energy"`
Bandwidth *ResourceBalance `json:"bandwidth"`
TRX int64 `json:"trx"` // current usable trx
TRXTotal int64 `json:"trx_total"` // total trx (usable+frozen+unfrozen trx)
TRXFrozenV1 int64 `json:"trx_frozen_v1"`
TRXFrozenV2 *TRXFrozenV2 `json:"trx_frozen_v2"`
UnfrozenV2 *UnfrozenV2 `json:"unfrozen_v2"`
}
type ResourceBalance struct {
Current int64 `json:"current"`
Limit int64 `json:"limit"`
}
type TRXFrozenV2 struct {
Total int64 `json:"total"`
Energy *ResourceFrozenV2 `json:"energy"`
Bandwidth *ResourceFrozenV2 `json:"bandwidth"`
}
type ResourceFrozenV2 struct {
Total int64 `json:"total"`
Self int64 `json:"self"`
Delegate int64 `json:"delegate"`
}
type UnfrozenV2 struct {
Total int64 `json:"total"`
Unstacking int64 `json:"unstacking"`
ToBeWithdrawn int64 `json:"to_be_withdrawn"`
}
type SmartContractEvent struct {
Contract Address
Owner Address
To Address
Amount SUN
Method ContractMethod
}