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

Sube Examples: Multiple Queries At once for multiple Chains/Parachains #28

Open
S0c5 opened this issue Apr 4, 2023 · 1 comment
Open
Assignees
Labels

Comments

@S0c5
Copy link
Member

S0c5 commented Apr 4, 2023

As a developer in the Dotsama ecosystem, usually i have to interact with multiple parachains (including the Kusama relychain) at once, the main idea with this example is to show how to interact or make multiple queries at once.

let [account1, account2] = sube_multi!([
"http://kusama.node/balances/account/0x123123123",
"http://statemine.node/balances/account/0x123123123",
])
[
 sube!(""),
 sube!("")
]
@S0c5 S0c5 added the examples label Apr 4, 2023
@S0c5 S0c5 self-assigned this Apr 4, 2023
@olanod
Copy link
Member

olanod commented Apr 4, 2023

I think we can adapt the sube! macro to change based on different combinations of parameters to fit the simple and more complex cases.

I think something along this lines should be possible

// simple usage for storage queries, under the hood uses the builder to create a type that
// implements `IntoFuture` that can be awaited(returns a scales::Value ?).
let account = sube!("balances/account/0x1234").await?;
// multi query
let (balanceKSM, balanceUSDT) = sube!(
    "balances/account/0x1234", 
    "statemine://assets/account/1984/0x1234",
).await?;
// subscribe to updates, the type returned by the builder has a method(e.g. `next`) to get updates
// when async itereators are supported there is a some form of for-await it will be even more convenient to use 
while let Some(n) = sube!("system/number").next().await {
    // handle update
}
// Single extrinsic
sube!("balances/transfer" => { dest: "0x1234", value: 100_000  }).await?;
// Multi extrinsic
sube!{
    "balances/transfer" => { dest: "0x1234", value: 100_000  },
    "statemine://assets/transfer" => { id: 1984, target: "0x1234", amount: 100_000  },
}.await?;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants