-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
cosmos_chains_commands.go
48 lines (35 loc) · 1.16 KB
/
cosmos_chains_commands.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
package cmd
import (
"strconv"
"github.com/smartcontractkit/chainlink/v2/core/web/presenters"
)
// CosmosChainPresenter implements TableRenderer for a CosmosChainResource
type CosmosChainPresenter struct {
presenters.CosmosChainResource
}
// ToRow presents the CosmosChainResource as a slice of strings.
func (p *CosmosChainPresenter) ToRow() []string {
return []string{p.GetID(), strconv.FormatBool(p.Enabled), p.Config}
}
// RenderTable implements TableRenderer
// Just renders a single row
func (p CosmosChainPresenter) RenderTable(rt RendererTable) error {
rows := [][]string{}
rows = append(rows, p.ToRow())
renderList(chainHeaders, rows, rt.Writer)
return nil
}
// CosmosChainPresenters implements TableRenderer for a slice of CosmosChainPresenters.
type CosmosChainPresenters []CosmosChainPresenter
// RenderTable implements TableRenderer
func (ps CosmosChainPresenters) RenderTable(rt RendererTable) error {
rows := [][]string{}
for _, p := range ps {
rows = append(rows, p.ToRow())
}
renderList(chainHeaders, rows, rt.Writer)
return nil
}
func CosmosChainClient(s *Shell) ChainClient {
return newChainClient[CosmosChainPresenters](s, "cosmos")
}