-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
solana_keys_commands.go
57 lines (44 loc) · 1.31 KB
/
solana_keys_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
49
50
51
52
53
54
55
56
57
package cmd
import (
"github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/solkey"
"github.com/smartcontractkit/chainlink/v2/core/web/presenters"
)
type SolanaKeyPresenter struct {
JAID
presenters.SolanaKeyResource
}
// RenderTable implements TableRenderer
func (p SolanaKeyPresenter) RenderTable(rt RendererTable) error {
headers := []string{"ID", "Public key"}
rows := [][]string{p.ToRow()}
if _, err := rt.Write([]byte("🔑 Solana Keys\n")); err != nil {
return err
}
renderList(headers, rows, rt.Writer)
return utils.JustError(rt.Write([]byte("\n")))
}
func (p *SolanaKeyPresenter) ToRow() []string {
row := []string{
p.ID,
p.PubKey,
}
return row
}
type SolanaKeyPresenters []SolanaKeyPresenter
// RenderTable implements TableRenderer
func (ps SolanaKeyPresenters) RenderTable(rt RendererTable) error {
headers := []string{"ID", "Public key"}
rows := [][]string{}
for _, p := range ps {
rows = append(rows, p.ToRow())
}
if _, err := rt.Write([]byte("🔑 Solana Keys\n")); err != nil {
return err
}
renderList(headers, rows, rt.Writer)
return utils.JustError(rt.Write([]byte("\n")))
}
func NewSolanaKeysClient(s *Shell) KeysClient {
return newKeysClient[solkey.Key, SolanaKeyPresenter, SolanaKeyPresenters]("Solana", s)
}