-
Notifications
You must be signed in to change notification settings - Fork 0
/
accountwhitelistoperation.go
65 lines (52 loc) · 1.67 KB
/
accountwhitelistoperation.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
package operations
//go:generate ffjson $GOFILE
import (
"github.com/CybexDex/cybex-go/types"
"github.com/CybexDex/cybex-go/util"
"github.com/juju/errors"
)
func init() {
types.OperationMap[types.OperationTypeAccountWhitelist] = func() types.Operation {
op := &AccountWhitelistOperation{}
return op
}
}
type AccountWhitelistOperation struct {
types.OperationFee
AccountToList types.GrapheneID `json:"account_to_list"`
AuthorizingAccount types.GrapheneID `json:"authorizing_account"`
Extensions types.Extensions `json:"extensions"`
NewListing types.UInt8 `json:"new_listing"`
}
func (p AccountWhitelistOperation) Type() types.OperationType {
return types.OperationTypeAccountWhitelist
}
//TODO: validate order
func (p AccountWhitelistOperation) Marshal(enc *util.TypeEncoder) error {
if err := enc.Encode(int8(p.Type())); err != nil {
return errors.Annotate(err, "encode OperationType")
}
if err := enc.Encode(p.Fee); err != nil {
return errors.Annotate(err, "encode Fee")
}
if err := enc.Encode(p.AuthorizingAccount); err != nil {
return errors.Annotate(err, "encode AuthorizingAccount")
}
if err := enc.Encode(p.AccountToList); err != nil {
return errors.Annotate(err, "encode AccountToList")
}
if err := enc.Encode(p.NewListing); err != nil {
return errors.Annotate(err, "encode NewListing")
}
if err := enc.Encode(p.Extensions); err != nil {
return errors.Annotate(err, "encode extensions")
}
return nil
}
//NewAccountWhitelistOperation creates a new AccountWhitelistOperation
func NewAccountWhitelistOperation() *AccountWhitelistOperation {
tx := AccountWhitelistOperation{
Extensions: types.Extensions{},
}
return &tx
}