Skip to content
Snippets Groups Projects
Commit 6f36165f authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

update to runtime 800

parent a39465e6
No related branches found
No related tags found
No related merge requests found
Showing
with 4631 additions and 4910 deletions
This diff is collapsed.
[package]
authors = ["librelois <c@elo.tf>", "tuxmain <tuxmain@zettascript.org>"]
authors = ["librelois <c@elo.tf>", "tuxmain <tuxmain@zettascript.org>", "h30x <hugo@trentesaux.fr>"]
edition = "2021"
license = "AGPL-3.0"
name = "gcli"
......@@ -7,28 +7,29 @@ repository = "https://git.duniter.org/clients/rust/gcli-v2s"
version = "0.1.0"
[dependencies]
anyhow = "1.0"
clap = { version = "4.1.9", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.4.0" }
env_logger = "0.10"
futures = "0.3.27"
graphql_client = { version = "0.12.0", features = ["reqwest"] }
hex = "0.4.3"
log = "0.4.17"
reqwest = "0.11.14"
rpassword = "7.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "^1.0.107"
sp-core = { git = "https://github.com/duniter/substrate.git", branch = "duniter-substrate-v0.9.42" }
sp-runtime = { git = "https://github.com/duniter/substrate", branch = "duniter-substrate-v0.9.42" }
subxt = { git = "https://github.com/duniter/subxt.git", branch = "subxt-v0.32.1-duniter-substrate-v0.9.42", features = ["substrate-compat"] }
# subxt-signer = { git = "https://github.com/duniter/subxt.git", branch = "subxt-v0.32.1-duniter-substrate-v0.9.42", features = ["subxt"] }
# sp-api = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42'}
tokio = { version = "1.26.0", features = ["macros"] }
confy = "0.5.1"
scrypt = { version = "0.11", default-features = false } # for old-style key generation
nacl = { version = "0.5.3" } # for old-style key generation
bs58 = "0.5.0"
# subxt is main dependency
subxt = { git = 'https://github.com/duniter/subxt', branch = 'subxt-v0.34.0-duniter-substrate-v1.6.0', default-features = false, features = ["substrate-compat", "native", "jsonrpsee"] }
# substrate primitives dependencies
sp-core = { git = "https://github.com/duniter/duniter-polkadot-sdk.git", branch = "duniter-substrate-v1.6.0" }
sp-runtime = { git = "https://github.com/duniter/duniter-polkadot-sdk.git", branch = "duniter-substrate-v1.6.0" }
# crates.io dependencies
anyhow = "^1.0"
clap = { version = "^4.4.18", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "^3.6.9" }
env_logger = "^0.10"
futures = "^0.3.30"
graphql_client = { version = "^0.12.0", features = ["reqwest"] }
hex = "^0.4.3"
log = "^0.4.20"
reqwest = "^0.11.23"
rpassword = "^7.3.1"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0.113"
tokio = { version = "^1.35.1", features = ["macros"] }
confy = "^0.5.1"
scrypt = { version = "^0.11", default-features = false } # for old-style key generation
nacl = { version = "^0.5.3" } # for old-style key generation
bs58 = "^0.5.0"
# allows to build gcli for different runtimes and with different predefined networks
[features]
......@@ -36,3 +37,5 @@ default = ["gdev"] # default runtime is "gdev", gdev network is available
gdev = []
gtest = []
g1 = []
......@@ -71,6 +71,19 @@ Secret key format can be changed using `--secret-format` with the following valu
- [x] implement config formatter
- [x] add link/unlink account commands
- [ ] migrate all xt to submit_call_and_look_event
- [ ] add transfer with unit (ĞD, UD...)
- [x] migrate all xt to submit_call_and_look_event
- [x] add transfer with unit (ĞD, UD...)
- [x] add more runtime-info like cert count, wot and smith params...
- [ ] add more info like sudo key, block interval
- [ ] better format runtime info block number (duration in days...) and perbill (%)
- [ ] add proper tabulation for runtime info
- [ ] add clap complete for autocompletion
- [ ] allow to listen to multiple events (like CertAdded and CertRenewed)
- [ ] add more info on identity view like status, number certs emitted, received
- [ ] implement squid indexer to get cert list + tx history...
- [ ]
- [ ]
- [ ]
- [ ]
- [ ]
- [ ]
\ No newline at end of file
......@@ -12,7 +12,7 @@ cargo run -- config show
# [stdout]
# Ğcli config
# duniter endpoint ws://localhost:9944
# indexer endpoint http://localhost:8080/v1/graphql
# indexer endpoint http://localhost:4350/graphql
# address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY (secret defined)
# use different address in command line
......@@ -20,7 +20,7 @@ cargo run -- --address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n config s
# [stdout]
# Ğcli config
# duniter endpoint ws://localhost:9944
# indexer endpoint http://localhost:8080/v1/graphql
# indexer endpoint http://localhost:4350/graphql
# address 5Fxune7f71ZbpP2FoY3mhYcmM596Erhv1gRue4nsPwkxMR4n (no secret)
```
......
query IdentityByIndex($index: Int!) {
identity_by_pk(index: $index) {
identities(where: {index_eq: $index}) {
index
name
pubkey
account {
id
}
}
}
query IdentityByName($name: String!) {
identity(where: { name: { _eq: $name } }) {
identities(where: {name_eq: $name}) {
index
name
pubkey
account {
id
}
}
}
query IdentityByPubkey($pubkey: String!) {
identity(where: { pubkey: { _eq: $pubkey } }) {
identities(where: {account: {id_eq: $pubkey}}) {
index
name
pubkey
account {
id
}
}
}
query LatestBlock {
parameters(where: { key: { _eq: "last_indexed_block_number" } }) {
value
blocks(limit: 1, orderBy: height_DESC) {
height
}
}
query GenesisHash {
block(where: {number: {_eq: 0}}) {
blocks(where: {height_eq: 0}) {
hash
}
}
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
No preview for this file type
......@@ -2,17 +2,13 @@ use crate::*;
/// submit a certification and track progress
pub async fn certify(data: &Data, receiver: IdtyId) -> Result<(), anyhow::Error> {
let progress = submit_call(
data,
&runtime::tx().cert().add_cert(data.idty_index(), receiver),
)
.await?;
let progress = submit_call(data, &runtime::tx().certification().add_cert(receiver)).await?;
if data.args.no_wait {
return Ok(());
}
let events = track_progress(progress).await?;
// look for the expected event
look_event::<runtime::cert::events::NewCert>(data, &events)?;
look_event::<runtime::cert::events::RenewedCert>(data, &events)?;
look_event::<runtime::certification::events::CertAdded>(data, &events)?;
look_event::<runtime::certification::events::CertRenewed>(data, &events)?;
Ok(())
}
......@@ -8,9 +8,9 @@ pub enum Subcommand {
#[default]
#[clap(hide = true)]
Nothing,
/// Generate key pair with old style unsafe scrypt
Pubkey { id: String, pass: String },
/// Prompt
/// Analyse a base58 pubkey and gives it in all its form
Pubkey { pubkey: String },
/// Prompt for cesium input
Prompt,
}
......@@ -18,17 +18,25 @@ pub enum Subcommand {
pub async fn handle_command(_data: Data, command: Subcommand) -> Result<(), GcliError> {
match command {
Subcommand::Nothing => {}
Subcommand::Pubkey { id, pass } => {
let keypair = pair_from_cesium(id, pass);
println!("Pubkey: {}", bs58::encode(keypair.pkey).into_string());
let address: AccountId = keypair.pkey.into();
println!("Address: {}", address.to_string());
Subcommand::Pubkey { pubkey } => {
let raw_pubkey = bs58::decode(pubkey).into_vec().unwrap();
let raw_pubkey: [u8; 32] = if raw_pubkey.len() > 32 {
return Err(GcliError::Input("invalid pubkey size".to_string()));
} else {
[vec![0; 32 - raw_pubkey.len()], raw_pubkey]
.concat()
.try_into()
.unwrap()
};
println!("Pubkey (hex): 0x{}", hex::encode(raw_pubkey));
let address: AccountId = sp_core::ed25519::Public(raw_pubkey).into();
println!("Address (SS58): {}", address);
}
Subcommand::Prompt => {
let keypair = prompt_secret_cesium();
println!("Pubkey: {}", bs58::encode(keypair.pkey).into_string());
let address: AccountId = keypair.pkey.into();
println!("Address: {}", address.to_string());
println!("Address: {}", address);
}
}
Ok(())
......
......@@ -8,6 +8,8 @@ pub enum Subcommand {
#[default]
/// List members of the technical committee
Members,
/// Propose a hex encoded call
Propose { hex: String },
/// List proposals to the technical committee
Proposals,
/// Vote a proposal to the technical committee
......@@ -23,24 +25,18 @@ pub enum Subcommand {
/// handle technical committee commands
pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> {
let mut data = data.build_client().await?.build_indexer().await?;
let data = data.build_client().await?;
match command {
Subcommand::Members => {
data = data.build_client().await?;
commands::collective::technical_committee_members(&data).await?
}
Subcommand::Proposals => {
data = data.build_client().await?;
commands::collective::technical_committee_proposals(data.client()).await?
}
Subcommand::Members => technical_committee_members(&data).await?,
Subcommand::Propose { hex } => technical_committee_propose(&data, &hex).await?,
Subcommand::Proposals => technical_committee_proposals(data.client()).await?,
Subcommand::Vote { hash, index, vote } => {
data = data.build_client().await?;
let vote = match vote {
0 => false,
1 => true,
_ => panic!("Vote must be written 0 if you disagree, or 1 if you agree."),
};
commands::collective::technical_committee_vote(
technical_committee_vote(
&data, hash, //Hash::from_str(&hash).expect("Invalid hash formatting"),
index, vote,
)
......@@ -141,3 +137,17 @@ pub async fn technical_committee_vote(
)
.await
}
/// propose call given as hexadecimal
/// can be generated with `subxt explore` for example
pub async fn technical_committee_propose(data: &Data, proposal: &str) -> Result<(), subxt::Error> {
let raw_call = hex::decode(proposal).expect("invalid hex");
let call = codec::decode_from_bytes(raw_call.into()).expect("invalid call");
let payload = runtime::tx().technical_committee().propose(5, call, 100);
submit_call_and_look_event::<
runtime::technical_committee::events::Proposed,
Payload<runtime::technical_committee::calls::types::Propose>,
>(data, &payload)
.await
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -28,10 +28,12 @@ pub async fn transfer(
(false, false) => {
submit_call_and_look_event::<
runtime::balances::events::Transfer,
Payload<runtime::balances::calls::types::Transfer>,
Payload<runtime::balances::calls::types::TransferAllowDeath>,
>(
data,
&runtime::tx().balances().transfer(dest.into(), balance),
&runtime::tx()
.balances()
.transfer_allow_death(dest.into(), balance),
)
.await
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment