Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/.changeset/v0.16.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add a method to read Solana keys to `clclient`
40 changes: 40 additions & 0 deletions framework/clclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,46 @@ func (c *ChainlinkClient) MustReadAptosAccounts() ([]string, error) {
return accounts, nil
}

// ReadSolanaKeys reads all Solana keys from the Chainlink node
func (c *ChainlinkClient) ReadSolanaKeys() (*SolanaKeys, *resty.Response, error) {
solanaKeys := &SolanaKeys{}
framework.L.Info().Str(NodeURL, c.Config.URL).Msg("Reading Solana Keys")
resp, err := c.APIClient.R().
SetResult(solanaKeys).
Get("/v2/keys/solana")
if err != nil {
return nil, nil, err
}
if len(solanaKeys.Data) == 0 {
framework.L.Warn().Str(NodeURL, c.Config.URL).Msg("Found no Solana Keys on the node")
}
return solanaKeys, resp, nil
}

// MustReadSolanaKeys reads all Solana keys from the Chainlink node and returns an error if the request is unsuccessful.
func (c *ChainlinkClient) MustReadSolanaKeys() (*SolanaKeys, *resty.Response, error) {
solanaKeys, res, err := c.ReadSolanaKeys()
if err != nil {
return nil, res, err
}
return solanaKeys, res, VerifyStatusCodeWithResponse(res, http.StatusOK)
}

// MustReadSolanaAccounts reads all Solana public keys (used as account addresses) from the Chainlink node.
func (c *ChainlinkClient) MustReadSolanaAccounts() ([]string, error) {
solanaKeys, _, err := c.MustReadSolanaKeys()
if err != nil {
return nil, err
}

accounts := make([]string, 0, len(solanaKeys.Data))
for _, key := range solanaKeys.Data {
accounts = append(accounts, key.Attributes.PublicKey)
}

return accounts, nil
}

// DeleteTxKey deletes an tx key based on the provided ID
func (c *ChainlinkClient) DeleteTxKey(chain string, id string) (*http.Response, error) {
framework.L.Info().Str(NodeURL, c.Config.URL).Str("ID", id).Msg("Deleting Tx Key")
Expand Down
21 changes: 21 additions & 0 deletions framework/clclient/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@ type AptosKeys struct {
Data []AptosKeyData `json:"data"`
}

// SolanaKeyAttributes is the model that represents the created Solana key attributes when read
type SolanaKeyAttributes struct {
PublicKey string `json:"publicKey"`
}

// SolanaKeyData is the model that represents the created Solana keys when read
type SolanaKeyData struct {
ID string `json:"id"`
Attributes SolanaKeyAttributes `json:"attributes"`
}

// SolanaKey is the model that represents the created Solana key when read
type SolanaKey struct {
Data SolanaKeyData `json:"data"`
}

// SolanaKeys is the model that represents the created Solana keys when read
type SolanaKeys struct {
Data []SolanaKeyData `json:"data"`
}

// OCRKeys is the model that represents the created OCR keys when read
type OCRKeys struct {
Data []OCRKeyData `json:"data"`
Expand Down
Loading