Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token-client: Make confirmation of ProgramRpcClientSendTransaction optional #7596

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

acheroncrypto
Copy link
Contributor

Problem

SendTransactionRpc implementation of ProgramRpcClientSendTransaction both sends and confirms the transaction:

impl SendTransactionRpc for ProgramRpcClientSendTransaction {
fn send<'a>(
&self,
client: &'a RpcClient,
transaction: &'a Transaction,
) -> BoxFuture<'a, ProgramClientResult<Self::Output>> {
Box::pin(async move {
if !transaction.is_signed() {
return Err("Cannot send transaction: not fully signed".into());
}
client
.send_and_confirm_transaction(transaction)
.await
.map(RpcClientResponse::Signature)
.map_err(Into::into)
})
}
}

The behavior is misleading, especially considering its naming, and it's also the root cause of the problem mentioned in #7595.

Summary of changes

  • Convert ProgramRpcClientSendTransaction to a named struct and add confirm field
  • Use the confirm field to decide whether to confirm the sent transaction
  • Add new and new_with_confirmation methods to the ProgramRpcClientSendTransaction struct
  • Use ProgramRpcClientSendTransaction::new during token-cli's Config creation
  • Use ProgramRpcClientSendTransaction::new_with_confirmation everywhere else in the repository to keep the changes minimal and behavior the same

Note: 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

@mergify mergify bot added the community Community contribution label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

spl-token transfer --no-wait still waits for transaction to confirm
1 participant