-
Notifications
You must be signed in to change notification settings - Fork 254
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
Add multisig static example #713
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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,66 @@ | ||
// Copyright 2019-2022 Parity Technologies (UK) Ltd. | ||
// This file is dual-licensed as Apache-2.0 or GPL-3.0. | ||
// see LICENSE for license details. | ||
|
||
//! To run this example, a local polkadot node should be running. Example verified against substrate latest-38a955ba4a0. | ||
//! | ||
//! E.g. | ||
//! ```bash | ||
//! curl "https://releases.parity.io/substrate/x86_64-debian:stretch/latest/substrate/substrate" --output /usr/local/bin/substrate --location | ||
//! substrate --dev --tmp | ||
//! ``` | ||
|
||
use sp_keyring::AccountKeyring; | ||
use subxt::{ | ||
tx::PairSigner, | ||
OnlineClient, | ||
SubstrateConfig, | ||
}; | ||
|
||
#[subxt::subxt(runtime_metadata_path = "../artifacts/substrate_metadata.scale")] | ||
pub mod substrate {} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
tracing_subscriber::fmt::init(); | ||
|
||
let signer = PairSigner::new(AccountKeyring::Alice.pair()); | ||
|
||
// Create a client to use: | ||
let api = OnlineClient::<SubstrateConfig>::new().await?; | ||
|
||
// The call data of for the `Multisig::as_multi`. | ||
// This must be of type `RuntimeCall` and represents the `Assets::freeze_asset` method. | ||
// Otherwise, could have been obtained using | ||
// `substrate::tx().assets().freeze_asset(100)` | ||
let call = substrate::runtime_types::kitchensink_runtime::RuntimeCall::Assets( | ||
substrate::runtime_types::pallet_assets::pallet::Call::freeze_asset { id: 100 }, | ||
); | ||
Comment on lines
+35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about: substrate::tx().assets().freeze_asset(100).call_data().clone() does that work instead? And if so, perhaps we could add an It'd be awesome if we can add that and make embedding calls like this way smoother! |
||
|
||
// The maximum weight (gas) for this extrinsic. | ||
let max_weight = substrate::runtime_types::sp_weights::weight_v2::Weight { | ||
ref_time: 10000000000, | ||
proof_size: u64::MAX / 2, | ||
}; | ||
|
||
// Construct the multisig extrinsic. | ||
let tx = substrate::tx().multisig().as_multi( | ||
// threashold | ||
1, | ||
// other signatories | ||
vec![AccountKeyring::Alice.to_account_id()], | ||
// maybe timepoint | ||
None, | ||
// call | ||
call, | ||
// max weight | ||
max_weight, | ||
); | ||
|
||
// Submit the transaction with default params: | ||
let hash = api.tx().sign_and_submit_default(&tx, &signer).await?; | ||
|
||
println!("Multisig extrinsic submitted: {:?}", hash); | ||
|
||
Ok(()) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only example using Substrate? I think just for consistency with other examples maybe it's best to stick to Polkadot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Polkadot node does not contain the
Assets
pallet, at least I didn't see it in the metadata ofwss://rpc.polkadot.io:443
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's ok; we don't need to specifically use this Assets call as the example; in https://github.com/paritytech/subxt/pull/714/files I used a balance transfer so perhaps we could standardise and both just do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think I'll rename my example to
dynamic_multisig.rs
to align with yours :)