-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(rpc): add Accounts config support to SimulateTransaction * feat(rpc): add new rpc getSignaturesForAddress * feat(rpc): add new rpc getBlocksWithLimit * feat(rpc): add new rpc getTransaction * feat(rpc): add new rpc getBlocks * feat(rpc): add new rpc getBlock * feat(rpc): update get epoch info response type * feat(rpc): add new rpc getBlockHeight * feat(rpc): add new rpc getFirstAvailableBlock * feat(rpc): add new rpc getGenesisHash * feat(rpc): add new rpc get identity * feat(rpc): add brief desc to rpc functions
- Loading branch information
Showing
28 changed files
with
298 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package client | ||
|
||
import "context" | ||
|
||
type GetBlockConfig struct { | ||
// TODO custom | ||
// Encoding string `json:"encoding"` // default: "json", either "json", "jsonParsed", "base58" (slow), "base64" | ||
// TransactionDetails string `json:"transactionDetails"` // default: "full", either "full", "signatures", "none" | ||
Commitment Commitment `json:"commitment,omitempty"` // "processed" is not supported. If parameter not provided, the default is "finalized". | ||
} | ||
|
||
type GetBlockResponse struct { | ||
Blockhash string `json:"blockhash"` | ||
PreviousBlockhash string `json:"previousBlockhash"` | ||
ParentSLot uint64 `json:"parentSlot"` | ||
BlockTime int64 `json:"blockTime"` | ||
Transactions []struct { | ||
Meta TransactionMeta `json:"meta"` | ||
Transaction Transaction `json:"transaction"` | ||
} `json:"transactions"` | ||
Rewards []struct { | ||
Pubkey string `json:"pubkey"` | ||
Lamports int64 `json:"lamports"` | ||
PostBalance uint64 `json:"postBalance"` | ||
RewardType string `json:"rewardType"` // type of reward: "fee", "rent", "voting", "staking" | ||
} `json:"rewards"` | ||
} | ||
|
||
// NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlock for solana-core v1.6 | ||
// GetBlock returns identity and transaction information about a confirmed block in the ledger | ||
func (s *Client) GetBlock(ctx context.Context, slot uint64, cfg GetBlockConfig) (GetBlockResponse, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result GetBlockResponse `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getBlock", []interface{}{slot, cfg}, &res) | ||
if err != nil { | ||
return GetBlockResponse{}, err | ||
} | ||
return res.Result, nil | ||
} |
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,26 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
type GetBlockHeightConfig struct { | ||
Commitment Commitment `json:"commitment,omitempty"` | ||
} | ||
|
||
// GetBlockHeight returns the current block height of the node | ||
func (s *Client) GetBlockHeight(ctx context.Context, cfg GetBlockHeightConfig) (uint64, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result uint64 `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getBlockHeight", []interface{}{cfg}, &res) | ||
if err != nil { | ||
return 0, err | ||
} | ||
if res.Error != (ErrorResponse{}) { | ||
return 0, errors.New(res.Error.Message) | ||
} | ||
return res.Result, nil | ||
} |
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,22 @@ | ||
package client | ||
|
||
import "context" | ||
|
||
type GetBlocksConfig struct { | ||
Commitment Commitment `json:"commitment,omitempty"` | ||
} | ||
|
||
// NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlocks for solana-core v1.6 | ||
// GetBlocks returns a list of confirmed blocks between two slots | ||
// Max range allowed is 500,000 slots | ||
func (s *Client) GetBlocks(ctx context.Context, startSlot uint64, endSlot uint64, cfg GetBlocksConfig) ([]uint64, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result []uint64 `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getBlocks", []interface{}{startSlot, endSlot, cfg}, &res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return res.Result, nil | ||
} |
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,21 @@ | ||
package client | ||
|
||
import "context" | ||
|
||
type GetBlocksWithLimitConfig struct { | ||
Commitment Commitment `json:"commitment,omitempty"` | ||
} | ||
|
||
// NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlocksWithLimit for solana-core v1.6 | ||
// GetBlocksWithLimit returns a list of confirmed blocks starting at the given slot | ||
func (s *Client) GetBlocksWithLimit(ctx context.Context, startSlot uint64, limit uint64, cfg GetBlocksWithLimitConfig) ([]uint64, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result []uint64 `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getBlocksWithLimit", []interface{}{startSlot, limit, cfg}, &res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return res.Result, nil | ||
} |
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
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,22 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
// GetFirstAvailableBlock returns the slot of the lowest confirmed block that has not been purged from the ledger | ||
func (s *Client) GetFirstAvailableBlock(ctx context.Context) (uint64, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result uint64 `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getFirstAvailableBlock", []interface{}{}, &res) | ||
if err != nil { | ||
return 0, err | ||
} | ||
if res.Error != (ErrorResponse{}) { | ||
return 0, errors.New(res.Error.Message) | ||
} | ||
return res.Result, nil | ||
} |
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,22 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
// GetGenesisHash returns the genesis hash | ||
func (s *Client) GetGenesisHash(ctx context.Context) (string, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result string `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getGenesisHash", []interface{}{}, &res) | ||
if err != nil { | ||
return "", err | ||
} | ||
if res.Error != (ErrorResponse{}) { | ||
return "", errors.New(res.Error.Message) | ||
} | ||
return res.Result, nil | ||
} |
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,24 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
// GetIdentity returns the identity pubkey for the current node | ||
func (s *Client) GetIdentity(ctx context.Context) (string, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result struct { | ||
Identity string `json:"identity"` | ||
} `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getIdentity", []interface{}{}, &res) | ||
if err != nil { | ||
return "", err | ||
} | ||
if res.Error != (ErrorResponse{}) { | ||
return "", errors.New(res.Error.Message) | ||
} | ||
return res.Result.Identity, nil | ||
} |
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,39 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
type GetSignaturesForAddress struct { | ||
Signature string `json:"signature"` | ||
Slot uint64 `json:"slot"` | ||
BlockTime *int64 `json:"blockTime"` | ||
Err interface{} `json:"err"` | ||
Memo *string `json:"memo"` | ||
} | ||
|
||
type GetSignaturesForAddressConfig struct { | ||
Limit int `json:"limit,omitempty"` // between 1 and 1000, default: 1000 | ||
Before string `json:"before,omitempty"` | ||
Until string `json:"until,omitempty"` | ||
Commitment Commitment `json:"commitment,omitempty"` // "processed" is not supported, default is "finalized" | ||
} | ||
|
||
// NEW: This method is only available in solana-core v1.7 or newer. Please use "getConfirmedSignaturesForAddress2" for solana-core v1.6 | ||
// GetSignaturesForAddress Returns confirmed signatures for transactions involving an address backwards | ||
// in time from the provided signature or most recent confirmed block | ||
func (s *Client) GetSignaturesForAddress(ctx context.Context, base58Addr string, config GetConfirmedSignaturesForAddressConfig) ([]GetConfirmedSignaturesForAddress, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result []GetConfirmedSignaturesForAddress `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getSignaturesForAddress", []interface{}{base58Addr, config}, &res) | ||
if err != nil { | ||
return []GetConfirmedSignaturesForAddress{}, err | ||
} | ||
if res.Error != (ErrorResponse{}) { | ||
return []GetConfirmedSignaturesForAddress{}, errors.New(res.Error.Message) | ||
} | ||
return res.Result, nil | ||
} |
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,29 @@ | ||
package client | ||
|
||
import "context" | ||
|
||
type GetTransactionWithLimitConfig struct { | ||
// TODO custom encoding | ||
// Encoding string `json:"encoding"` // either "json", "jsonParsed", "base58" (slow), "base64", default: json | ||
Commitment Commitment `json:"commitment,omitempty"` // "processed" is not supported. If parameter not provided, the default is "finalized". | ||
} | ||
|
||
type GetTransaction struct { | ||
Slot uint64 `json:"slot"` | ||
Meta TransactionMeta `json:"meta"` | ||
Transaction Transaction `json:"transaction"` | ||
} | ||
|
||
// NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedTransaction for solana-core v1.6 | ||
// GetConfirmedTransaction returns transaction details for a confirmed transaction | ||
func (s *Client) GetTransaction(ctx context.Context, txhash string, cfg GetTransactionWithLimitConfig) (GetConfirmedTransactionResponse, error) { | ||
res := struct { | ||
GeneralResponse | ||
Result GetConfirmedTransactionResponse `json:"result"` | ||
}{} | ||
err := s.request(ctx, "getTransaction", []interface{}{txhash, cfg}, &res) | ||
if err != nil { | ||
return GetConfirmedTransactionResponse{}, err | ||
} | ||
return res.Result, nil | ||
} |
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
Oops, something went wrong.