Skip to content
Snippets Groups Projects
Commit 124bd9c2 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

Resolve "fix outdated transaction" (clients/rust/gcli-v2s!23)

* review poka

+fmt

* use custom nonce
parent 4166a7b4
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,6 @@ pub mod collective; ...@@ -6,7 +6,6 @@ pub mod collective;
pub mod distance; pub mod distance;
pub mod expire; pub mod expire;
pub mod identity; pub mod identity;
pub mod vault;
pub mod net_test; pub mod net_test;
pub mod oneshot; pub mod oneshot;
pub mod publish; pub mod publish;
...@@ -16,3 +15,4 @@ pub mod smith; ...@@ -16,3 +15,4 @@ pub mod smith;
pub mod sudo; pub mod sudo;
pub mod transfer; pub mod transfer;
pub mod ud; pub mod ud;
pub mod vault;
...@@ -48,29 +48,33 @@ pub async fn submit_call<Payload: TxPayload>( ...@@ -48,29 +48,33 @@ pub async fn submit_call<Payload: TxPayload>(
data: &Data, data: &Data,
payload: &Payload, payload: &Payload,
) -> Result<TxProgress, subxt::Error> { ) -> Result<TxProgress, subxt::Error> {
// get account nonce manually to be based on last block and not last finalized
let nonce = data
.legacy_rpc_methods() // see issue #32
.await
.system_account_next_index(&data.address())
.await?;
// sign and submit
match data.keypair() { match data.keypair() {
// sr25519 key pair // sr25519 key pair
KeyPair::Sr25519(keypair) => { KeyPair::Sr25519(keypair) => data.client().tx().create_signed_with_nonce(
data.client()
.tx()
.sign_and_submit_then_watch_default(
payload, payload,
&PairSigner::<Runtime, sp_core::sr25519::Pair>::new(keypair), &PairSigner::<Runtime, sp_core::sr25519::Pair>::new(keypair),
) nonce,
.await Default::default(),
} ),
// nacl key pair // nacl key pair
KeyPair::Nacl(keypair) => { KeyPair::Nacl(keypair) => data.client().tx().create_signed_with_nonce(
data.client()
.tx()
.sign_and_submit_then_watch_default(
payload, payload,
&commands::cesium::CesiumSigner::new(keypair), &commands::cesium::CesiumSigner::new(keypair),
) nonce,
Default::default(),
),
}?
.submit_and_watch()
.await .await
} }
}
}
/// look event /// look event
pub fn look_event<E: std::fmt::Debug + StaticEvent + DisplayEvent>( pub fn look_event<E: std::fmt::Debug + StaticEvent + DisplayEvent>(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment