Retry sign&broadcast on sequence errors

This commit is contained in:
Bogdan-Ștefan Neacşu
2025-08-21 17:54:34 +03:00
committed by Andrej Mihajlov
parent 7677c02494
commit 120220517d
@@ -665,8 +665,7 @@ where
CosmWasmClient::broadcast_tx_commit(self, tx_bytes).await
}
/// Broadcast a transaction to the network and monitors its inclusion in a block.
async fn sign_and_broadcast(
async fn sign_and_broadcast_inner(
&self,
signer_address: &AccountId,
messages: Vec<Any>,
@@ -686,6 +685,35 @@ where
self.broadcast_tx(tx_bytes, None, None).await
}
/// Broadcast a transaction to the network and monitors its inclusion in a block.
async fn sign_and_broadcast(
&self,
signer_address: &AccountId,
messages: Vec<Any>,
fee: Fee,
memo: impl Into<String> + Send + 'static,
) -> Result<TxResponse, NyxdError> {
let memo = memo.into();
loop {
match self
.sign_and_broadcast_inner(
signer_address,
messages.clone(),
fee.clone(),
memo.clone(),
)
.await
{
Ok(res) => return Ok(res),
Err(err) => {
if !err.to_string().contains("sequence") {
return Err(err);
}
}
}
}
}
async fn sign(
&self,
signer_address: &AccountId,