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

Implement new API for sign_and_submit_then_watch #354

Merged
merged 33 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
388a335
WIP Implementing new event subscription API
jsdw Dec 3, 2021
aa27ce4
back to lifetimes, fix example
jsdw Dec 3, 2021
fe40bab
no more need for accept_weak_inclusion
jsdw Dec 3, 2021
c802499
thread lifetime through to prevent 'temporary dropped' issue
jsdw Dec 6, 2021
4187e65
make working with events a little nicer
jsdw Dec 6, 2021
50f45b1
Get tests compiling
jsdw Dec 6, 2021
4255c3f
fmt and clippy
jsdw Dec 6, 2021
66420fe
_name back to name
jsdw Dec 6, 2021
7913613
dont take ownership, just have stronger note
jsdw Dec 6, 2021
a52b296
Attempt to fix test
jsdw Dec 6, 2021
970d7ed
remove commented-out code
jsdw Dec 6, 2021
36ad6a2
Add a couple more helper methods and a test
jsdw Dec 6, 2021
c44cc60
Remove custom ExtrinsicFailed handling; treat them like other events
jsdw Dec 7, 2021
b51e43a
Handle runtime errors in TransactionProgress related bits
jsdw Dec 7, 2021
3102267
cargo fmt + clippy
jsdw Dec 7, 2021
0176d07
Fix some of the failing tests
jsdw Dec 7, 2021
1032e93
remove unused import
jsdw Dec 7, 2021
a42dfc3
fix transfer_error test
jsdw Dec 7, 2021
50a309a
Fix compile errors against new substrate latest
jsdw Dec 7, 2021
9407ef9
Comment tweaks, and force test-runtime rebuild
jsdw Dec 7, 2021
ec3050c
Drop the TransactionProgress subscription when we hit 'end' statuses
jsdw Dec 7, 2021
b2e61d2
cargo fmt
jsdw Dec 7, 2021
4c66bab
find_event to find_first_event and helper to return all matching events
jsdw Dec 8, 2021
7f92f46
TransactionProgressStatus to TransactionStatus
jsdw Dec 8, 2021
5f9ce69
Copy and improve docs on TransactionStatus from substrate
jsdw Dec 8, 2021
f05e68a
debug impl for Client to avoid manual debug impls elsewhere
jsdw Dec 8, 2021
8ba531a
Add and tweak comments, specifically a note about block inclusion on …
jsdw Dec 8, 2021
c161d87
clippy + fmt
jsdw Dec 8, 2021
19a2116
Fix docs
jsdw Dec 8, 2021
2afd9ac
Ignore 'error' statuses and adhere to the substrate docs
jsdw Dec 8, 2021
41ef757
tweak and improve some comments per @dvdplm's suggestions
jsdw Dec 8, 2021
2a4c4b4
Break transaction* structs into separate file
jsdw Dec 9, 2021
f4f113e
fmt and fix doc link
jsdw Dec 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/src/api/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn generate_calls(
pub fn #fn_name(
&self,
#( #call_fn_args, )*
) -> ::subxt::SubmittableExtrinsic<T, #call_struct_name> {
) -> ::subxt::SubmittableExtrinsic<'a, T, #call_struct_name> {
let call = #call_struct_name { #( #call_args, )* };
::subxt::SubmittableExtrinsic::new(self.client, call)
}
Expand Down
1 change: 1 addition & 0 deletions codegen/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl ItemMod {
}
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, PartialEq, Eq)]
pub enum Item {
Rust(syn::Item),
Expand Down
10 changes: 8 additions & 2 deletions examples/submit_and_watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.build()
.await?
.to_runtime_api::<polkadot::RuntimeApi<polkadot::DefaultConfig>>();
let result = api

let balance_transfer = api
.tx()
.balances()
.transfer(dest, 10_000)
.sign_and_submit_then_watch(&signer)
.await?
.wait_for_finalized_success()
.await?;

if let Some(event) = result.find_event::<polkadot::balances::events::Transfer>()? {
let transfer_event =
balance_transfer.find_first_event::<polkadot::balances::events::Transfer>()?;

if let Some(event) = transfer_event {
println!("Balance transfer success: value: {:?}", event.2);
} else {
println!("Failed to find Balances::Transfer Event");
Expand Down
Loading