Skip to content

Commit

Permalink
Add GetConfirmedTransactionWithOpts
Browse files Browse the repository at this point in the history
  • Loading branch information
leoluk committed Jul 29, 2021
1 parent 9c9f6d1 commit 67b495e
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 67b495e

Please sign in to comment.