diff --git a/rpc/deprecated.go b/rpc/deprecated.go index be888c30..f3ab1dc3 100644 --- a/rpc/deprecated.go +++ b/rpc/deprecated.go @@ -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 +}