token-client: Make confirmation of ProgramRpcClientSendTransaction
optional
#7596
+60
−31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
SendTransactionRpc
implementation ofProgramRpcClientSendTransaction
both sends and confirms the transaction:solana-program-library/token/client/src/client.rs
Lines 136 to 154 in 7e6c031
The behavior is misleading, especially considering its naming, and it's also the root cause of the problem mentioned in #7595.
Summary of changes
ProgramRpcClientSendTransaction
to a named struct and addconfirm
fieldconfirm
field to decide whether to confirm the sent transactionnew
andnew_with_confirmation
methods to theProgramRpcClientSendTransaction
structProgramRpcClientSendTransaction::new
during token-cli'sConfig
creationProgramRpcClientSendTransaction::new_with_confirmation
everywhere else in the repository to keep the changes minimal and behavior the sameNote: I found this solution to be simpler than adding a new type (like mentioned in #3139 (review)), but I'd be down to implement it that way too if that's what you prefer.
Fixes #7595