mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 12:37:57 +00:00
43809ee592
* implement partial key iters * format * make tests compile * fix docs and try example * codegen: Fetch and decode metadata version then fallback (#1092) * codegen: Fetch and decode metadata version then fallback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add `unstable-metadata` attribute to the subxt macro Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * docs: Add missing comma Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Add `GenerateRuntimeApi` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update subxt/src/lib.rs Co-authored-by: James Wilson <james@jsdw.me> * Update macro/src/lib.rs Co-authored-by: James Wilson <james@jsdw.me> * subxt: Adjust docs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Import `GenerateRuntimeApi` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> * Bump darling from 0.20.1 to 0.20.3 (#1085) Bumps [darling](https://github.com/TedDriggs/darling) from 0.20.1 to 0.20.3. - [Release notes](https://github.com/TedDriggs/darling/releases) - [Changelog](https://github.com/TedDriggs/darling/blob/master/CHANGELOG.md) - [Commits](https://github.com/TedDriggs/darling/compare/v0.20.1...v0.20.3) --- updated-dependencies: - dependency-name: darling dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> * Bump either from 1.8.1 to 1.9.0 (#1084) Bumps [either](https://github.com/bluss/either) from 1.8.1 to 1.9.0. - [Commits](https://github.com/bluss/either/compare/1.8.1...1.9.0) --- updated-dependencies: - dependency-name: either dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> * Bump clap from 4.3.11 to 4.3.19 (#1083) Bumps [clap](https://github.com/clap-rs/clap) from 4.3.11 to 4.3.19. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.3.11...v4.3.19) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: Tadeo Hepperle <62739623+tadeohepperle@users.noreply.github.com> * Bump trybuild from 1.0.81 to 1.0.82 (#1082) Bumps [trybuild](https://github.com/dtolnay/trybuild) from 1.0.81 to 1.0.82. - [Release notes](https://github.com/dtolnay/trybuild/releases) - [Commits](https://github.com/dtolnay/trybuild/compare/1.0.81...1.0.82) --- updated-dependencies: - dependency-name: trybuild dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> * Prep for 0.30.1 release (#1094) * Set minimum supported `rust-version` to `1.70` (#1097) * Bump serde_json from 1.0.103 to 1.0.104 (#1100) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.103 to 1.0.104. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.103...v1.0.104) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump serde from 1.0.175 to 1.0.179 (#1101) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.175 to 1.0.179. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.175...v1.0.179) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Tests: support 'substrate-node' too and allow multiple binary paths (#1102) * Support 'substrate-node' too and allow multiple binary paths * fmt * clippy * fix path * adjust book * remove the partial iteration example. there was nothing good to show * revert spaces in changelog * Support more types in Storage entry constructors (#1105) * implement test for type alias being used * Bump serde from 1.0.179 to 1.0.183 (#1112) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.179 to 1.0.183. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.179...v1.0.183) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump regex from 1.9.1 to 1.9.3 (#1110) Bumps [regex](https://github.com/rust-lang/regex) from 1.9.1 to 1.9.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.9.1...1.9.3) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * revert yaml changes --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update subxt/src/book/usage/storage.rs Co-authored-by: James Wilson <james@jsdw.me> * remove dynamic_iter * fix example * format * add example, adjust book * Update subxt/src/book/usage/storage.rs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Jones <ascjones@gmail.com>
84 lines
2.9 KiB
Rust
84 lines
2.9 KiB
Rust
use subxt::{OnlineClient, PolkadotConfig};
|
|
|
|
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
|
|
pub mod polkadot {}
|
|
|
|
use subxt::utils::AccountId32;
|
|
use subxt_signer::sr25519::{dev, Keypair};
|
|
|
|
use polkadot::multisig::events::NewMultisig;
|
|
use polkadot::runtime_types::{
|
|
frame_system::pallet::Call, polkadot_runtime::RuntimeCall, sp_weights::weight_v2::Weight,
|
|
};
|
|
|
|
#[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?;
|
|
|
|
// Prepare the chain to have 3 open multisig requests (2 of them are alice + bob):
|
|
let alice_signer = dev::alice();
|
|
let bob = AccountId32(dev::bob().public_key().0);
|
|
let charlie = AccountId32(dev::charlie().public_key().0);
|
|
|
|
let new_multisig_1 = submit_remark_as_multi(&alice_signer, &bob, b"Hello", &api).await?;
|
|
let new_multisig_2 = submit_remark_as_multi(&alice_signer, &bob, b"Hi", &api).await?;
|
|
let new_multisig_3 = submit_remark_as_multi(&alice_signer, &charlie, b"Hello", &api).await?;
|
|
// Note: the NewMultisig event contains the multisig address we need to use for the storage queries:
|
|
assert_eq!(new_multisig_1.multisig, new_multisig_2.multisig);
|
|
assert_ne!(new_multisig_1.multisig, new_multisig_3.multisig);
|
|
|
|
// Build a storage query to iterate over open multisig extrinsics from
|
|
// new_multisig_1.multisig which is the AccountId of the alice + bob multisig account
|
|
let alice_bob_account_id = &new_multisig_1.multisig;
|
|
let storage_query = polkadot::storage()
|
|
.multisig()
|
|
.multisigs_iter1(alice_bob_account_id);
|
|
|
|
// Get back an iterator of results (here, we are fetching 10 items at
|
|
// a time from the node, but we always iterate over one at a time).
|
|
let mut results = api
|
|
.storage()
|
|
.at_latest()
|
|
.await?
|
|
.iter(storage_query, 10)
|
|
.await?;
|
|
|
|
while let Some((key, value)) = results.next().await? {
|
|
println!("Key: 0x{}", hex::encode(&key));
|
|
println!("Value: {:?}", value);
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn submit_remark_as_multi(
|
|
signer: &Keypair,
|
|
other: &AccountId32,
|
|
remark: &[u8],
|
|
api: &OnlineClient<PolkadotConfig>,
|
|
) -> Result<NewMultisig, Box<dyn std::error::Error>> {
|
|
let multisig_remark_tx = polkadot::tx().multisig().as_multi(
|
|
2,
|
|
vec![other.clone()],
|
|
None,
|
|
RuntimeCall::System(Call::remark {
|
|
remark: remark.to_vec(),
|
|
}),
|
|
Weight {
|
|
ref_time: 0,
|
|
proof_size: 0,
|
|
},
|
|
);
|
|
let events = api
|
|
.tx()
|
|
.sign_and_submit_then_watch_default(&multisig_remark_tx, signer)
|
|
.await?
|
|
.wait_for_finalized_success()
|
|
.await?;
|
|
let new_multisig = events
|
|
.find_first::<polkadot::multisig::events::NewMultisig>()?
|
|
.expect("should contain event");
|
|
Ok(new_multisig)
|
|
}
|