Skip to content

Commit

Permalink
Feature: added maxSupportedTransactionVersion field to getBlock opts
Browse files Browse the repository at this point in the history
  • Loading branch information
yakud committed May 18, 2022
1 parent 7886c8c commit 6ead48a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
17 changes: 10 additions & 7 deletions rpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,15 @@ func TestClient_GetBlockWithOpts(t *testing.T) {

block := 33
rewards := true
maxSupportedTransactionVersion := uint64(0)
_, err := client.GetBlockWithOpts(
context.Background(),
uint64(block),
&GetBlockOpts{
TransactionDetails: TransactionDetailsSignatures,
Rewards: &rewards,
Commitment: CommitmentMax,
TransactionDetails: TransactionDetailsSignatures,
Rewards: &rewards,
Commitment: CommitmentMax,
MaxSupportedTransactionVersion: &maxSupportedTransactionVersion,
},
)
require.NoError(t, err)
Expand All @@ -508,10 +510,11 @@ func TestClient_GetBlockWithOpts(t *testing.T) {
"params": []interface{}{
float64(block),
map[string]interface{}{
"encoding": string(solana.EncodingBase64),
"transactionDetails": string(TransactionDetailsSignatures),
"rewards": rewards,
"commitment": string(CommitmentMax),
"encoding": string(solana.EncodingBase64),
"transactionDetails": string(TransactionDetailsSignatures),
"rewards": rewards,
"commitment": string(CommitmentMax),
"maxSupportedTransactionVersion": float64(maxSupportedTransactionVersion),
},
},
},
Expand Down
7 changes: 7 additions & 0 deletions rpc/getBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type GetBlockOpts struct {
//
// This parameter is optional.
Commitment CommitmentType

// Max transaction version to return in responses.
// If the requested block contains a transaction with a higher version, an error will be returned.
MaxSupportedTransactionVersion *uint64
}

// GetBlock returns identity and transaction information about a confirmed block in the ledger.
Expand Down Expand Up @@ -109,6 +113,9 @@ func (cl *Client) GetBlockWithOpts(
}
obj["encoding"] = opts.Encoding
}
if opts.MaxSupportedTransactionVersion != nil {
obj["maxSupportedTransactionVersion"] = *opts.MaxSupportedTransactionVersion
}
}

params := []interface{}{slot, obj}
Expand Down

0 comments on commit 6ead48a

Please sign in to comment.