-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
evm_chains_commands.go
48 lines (35 loc) · 1.11 KB
/
evm_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"
)
// EVMChainPresenter implements TableRenderer for an EVMChainResource.
type EVMChainPresenter struct {
presenters.EVMChainResource
}
// ToRow presents the EVMChainResource as a slice of strings.
func (p *EVMChainPresenter) ToRow() []string {
return []string{p.GetID(), strconv.FormatBool(p.Enabled), p.Config}
}
// RenderTable implements TableRenderer
// Just renders a single row
func (p EVMChainPresenter) RenderTable(rt RendererTable) error {
rows := [][]string{}
rows = append(rows, p.ToRow())
renderList(chainHeaders, rows, rt.Writer)
return nil
}
// EVMChainPresenters implements TableRenderer for a slice of EVMChainPresenters.
type EVMChainPresenters []EVMChainPresenter
// RenderTable implements TableRenderer
func (ps EVMChainPresenters) RenderTable(rt RendererTable) error {
rows := [][]string{}
for _, p := range ps {
rows = append(rows, p.ToRow())
}
renderList(chainHeaders, rows, rt.Writer)
return nil
}
func EVMChainClient(s *Shell) ChainClient {
return newChainClient[EVMChainPresenters](s, "evm")
}