-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP Starting to write book; extrinsics first pass done * cargo fmt * Ongoing work; events, constants, wip blocks * at_latest() and wip blocks * remove need to import parity-scale-codec crate with Subxt for macro to work * More docs; expanding on setup guide and finish pass of main sections * Tidy and remove example section for now * format book lines to 100chars * Fix example code * cargo fmt * cargo fmt * fix example * Fix typos * fix broken doc links, pub mods * Update Subxt macro docs * can't link to Subxt here * move macro docs to Subxt to make linking better and fix example code * note on macro about docs * cargo fmt * document the no_default_derives macro feature * Address feedback and remove redundant text * address review comments; minor tweaks * WIP add Runtime calls to book * Improve Runtime API docs * expose thing we forgot to expose and doc link fixes
- Loading branch information
Showing
58 changed files
with
1,474 additions
and
1,508 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Subxt Examples | ||
|
||
Take a look in the [examples](./examples) subfolder for various `subxt` usage examples. | ||
Take a look in the [examples](./examples) subfolder for various `subxt` usage examples. | ||
|
||
All examples form part of the `subxt` documentation; there should be no examples without corresponding links from the docs. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use sp_keyring::AccountKeyring; | ||
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig}; | ||
|
||
// Generate an interface that we can use from the node's metadata. | ||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")] | ||
pub mod polkadot {} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Create a new API client, configured to talk to Polkadot nodes. | ||
let api = OnlineClient::<PolkadotConfig>::new().await?; | ||
|
||
// Build a balance transfer extrinsic. | ||
let dest = AccountKeyring::Bob.to_account_id().into(); | ||
let balance_transfer_tx = polkadot::tx().balances().transfer(dest, 10_000); | ||
|
||
// Submit the balance transfer extrinsic from Alice, and wait for it to be successful | ||
// and in a finalized block. We get back the extrinsic events if all is well. | ||
let from = PairSigner::new(AccountKeyring::Alice.pair()); | ||
let events = api | ||
.tx() | ||
.sign_and_submit_then_watch_default(&balance_transfer_tx, &from) | ||
.await? | ||
.wait_for_finalized_success() | ||
.await?; | ||
|
||
// Find a Transfer event and print it. | ||
let transfer_event = events.find_first::<polkadot::balances::events::Transfer>()?; | ||
if let Some(event) = transfer_event { | ||
println!("Balance transfer success: {event:?}"); | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.