-
Notifications
You must be signed in to change notification settings - Fork 504
/
params.go
45 lines (35 loc) · 1.09 KB
/
params.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
package registration
import (
"bytes"
"fmt"
"github.com/0xPolygon/polygon-edge/command/helper"
sidechainHelper "github.com/0xPolygon/polygon-edge/command/sidechain"
)
type registerParams struct {
accountDir string
accountConfig string
supernetManagerAddress string
jsonRPC string
}
func (rp *registerParams) validateFlags() error {
// validate jsonrpc address
_, err := helper.ParseJSONRPCAddress(rp.jsonRPC)
if err != nil {
return fmt.Errorf("failed to parse json rpc address. Error: %w", err)
}
return sidechainHelper.ValidateSecretFlags(rp.accountDir, rp.accountConfig)
}
type registerResult struct {
validatorAddress string
koskSignature string
}
func (rr registerResult) GetOutput() string {
var buffer bytes.Buffer
buffer.WriteString("\n[VALIDATOR REGISTRATION]\n")
vals := make([]string, 0, 2)
vals = append(vals, fmt.Sprintf("Validator Address|%s", rr.validatorAddress))
vals = append(vals, fmt.Sprintf("KOSK Signature|%s", rr.koskSignature))
buffer.WriteString(helper.FormatKV(vals))
buffer.WriteString("\n")
return buffer.String()
}