Skip to content

Commit

Permalink
Merge pull request #1 from certusone/main
Browse files Browse the repository at this point in the history
Add GetConfirmedTransactionWithOpts
  • Loading branch information
gagliardetto authored Aug 28, 2021
2 parents fd90cb9 + 67b495e commit 7e0eaa6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions rpc/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package rpc

import (
"context"
"fmt"

"github.com/gagliardetto/solana-go"
)
Expand Down Expand Up @@ -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
}

0 comments on commit 7e0eaa6

Please sign in to comment.