-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
3,380 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cmd | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/web/presenters" | ||
) | ||
|
||
// TronChainPresenter implements TableRenderer for a TronChainResource | ||
type TronChainPresenter struct { | ||
presenters.TronChainResource | ||
} | ||
|
||
// ToRow presents the TronChainResource as a slice of strings. | ||
func (p *TronChainPresenter) ToRow() []string { | ||
return []string{p.GetID(), strconv.FormatBool(p.Enabled), p.Config} | ||
} | ||
|
||
// RenderTable implements TableRenderer | ||
// Just renders a single row | ||
func (p TronChainPresenter) RenderTable(rt RendererTable) error { | ||
rows := [][]string{} | ||
rows = append(rows, p.ToRow()) | ||
|
||
renderList(chainHeaders, rows, rt.Writer) | ||
|
||
return nil | ||
} | ||
|
||
// TronChainPresenters implements TableRenderer for a slice of TronChainPresenters. | ||
type TronChainPresenters []TronChainPresenter | ||
|
||
// RenderTable implements TableRenderer | ||
func (ps TronChainPresenters) RenderTable(rt RendererTable) error { | ||
rows := [][]string{} | ||
|
||
for _, p := range ps { | ||
rows = append(rows, p.ToRow()) | ||
} | ||
|
||
renderList(chainHeaders, rows, rt.Writer) | ||
|
||
return nil | ||
} | ||
|
||
func TronChainClient(s *Shell) ChainClient { | ||
return newChainClient[TronChainPresenters](s, "tron") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/smartcontractkit/chainlink-common/pkg/utils" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/tronkey" | ||
"github.com/smartcontractkit/chainlink/v2/core/web/presenters" | ||
) | ||
|
||
type TronKeyPresenter struct { | ||
JAID | ||
presenters.TronKeyResource | ||
} | ||
|
||
// RenderTable implements TableRenderer | ||
func (p TronKeyPresenter) RenderTable(rt RendererTable) error { | ||
headers := []string{"ID", "Public key"} | ||
rows := [][]string{p.ToRow()} | ||
|
||
if _, err := rt.Write([]byte("🔑 Tron Keys\n")); err != nil { | ||
return err | ||
} | ||
renderList(headers, rows, rt.Writer) | ||
|
||
return utils.JustError(rt.Write([]byte("\n"))) | ||
} | ||
|
||
func (p *TronKeyPresenter) ToRow() []string { | ||
row := []string{ | ||
p.ID, | ||
p.PubKey, | ||
} | ||
|
||
return row | ||
} | ||
|
||
type TronKeyPresenters []TronKeyPresenter | ||
|
||
// RenderTable implements TableRenderer | ||
func (ps TronKeyPresenters) 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("🔑 Tron Keys\n")); err != nil { | ||
return err | ||
} | ||
renderList(headers, rows, rt.Writer) | ||
|
||
return utils.JustError(rt.Write([]byte("\n"))) | ||
} | ||
|
||
func NewTronKeysClient(s *Shell) KeysClient { | ||
return newKeysClient[tronkey.Key, TronKeyPresenter, TronKeyPresenters]("Tron", s) | ||
} |
Oops, something went wrong.