Merge pull request #1 from certusone/main
Add GetConfirmedTransactionWithOpts
This commit is contained in:
commit
7e0eaa6ef1
|
@ -16,6 +16,7 @@ package rpc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/gagliardetto/solana-go"
|
||||
)
|
||||
|
@ -182,3 +183,42 @@ func (cl *Client) GetConfirmedTransaction(
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetConfirmedTransactionWithOpts returns transaction details for a confirmed transaction.
|
||||
func (cl *Client) GetConfirmedTransactionWithOpts(
|
||||
ctx context.Context,
|
||||
signature solana.Signature,
|
||||
opts *GetTransactionOpts,
|
||||
) (out *TransactionWithMeta, err error) {
|
||||
params := []interface{}{signature}
|
||||
if opts != nil {
|
||||
obj := M{}
|
||||
if opts.Encoding != "" {
|
||||
if !solana.IsAnyOfEncodingType(
|
||||
opts.Encoding,
|
||||
// Valid encodings:
|
||||
solana.EncodingJSON,
|
||||
// solana.EncodingJSONParsed, // TODO
|
||||
solana.EncodingBase58,
|
||||
solana.EncodingBase64,
|
||||
) {
|
||||
return nil, fmt.Errorf("provided encoding is not supported: %s", opts.Encoding)
|
||||
}
|
||||
obj["encoding"] = opts.Encoding
|
||||
}
|
||||
if opts.Commitment != "" {
|
||||
obj["commitment"] = opts.Commitment
|
||||
}
|
||||
if len(obj) > 0 {
|
||||
params = append(params, obj)
|
||||
}
|
||||
}
|
||||
err = cl.rpcClient.CallForInto(ctx, &out, "getConfirmedTransaction", params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out == nil {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue