-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_all_validators.go
57 lines (49 loc) · 1.19 KB
/
get_all_validators.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
package main
import (
"fmt"
"main/base"
"main/node_manager"
"strings"
)
type GetAllValidatorsParser struct {
rawAction *RawAction
}
func (g *GetAllValidatorsParser) ParseInput(input string) error {
g.rawAction.Input = &node_manager.GetAllValidatorsParam{}
return nil
}
func (g *GetAllValidatorsParser) ParseAssertion(input string) error {
if input == "nil" {
return nil
}
parts := strings.Split(input, ";")
field := parts[1]
assertType, err := formatAssertType(parts[0])
if err != nil {
return err
}
values := parts[2:]
switch field {
case "AllValidators":
assertion := Assertion{}
assertion.AssertType = assertType
assertion.MethodName = base.MethodGetAllValidators
fieldValues := make([]FieldValue, 0)
for _, value := range values {
fieldValue := FieldValue{}
fieldValue.Field = field
hdAddress, e := parseAddress(value)
if e != nil {
return e
}
address := hdAddress.ToAddress()
fieldValue.Value = address
fieldValues = append(fieldValues, fieldValue)
}
assertion.FieldValues = fieldValues
g.rawAction.Assertions = append(g.rawAction.Assertions, assertion)
default:
return fmt.Errorf("undefined assertion field: %s", field)
}
return nil
}