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

Update api-client to tag v0.10.0 #1265

Merged
merged 5 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 28 additions & 39 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ dependencies = [

[[package]]
name = "ac-compose-macros"
version = "0.2.2"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39-tag-v0.9.0#c4d3f110b94e25d5ce52d5bb64d0c778c4c7f2da"
version = "0.2.3"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39#417c301cce7e23f765891cd56ca48878390c5cf9"
dependencies = [
"ac-primitives",
"log 0.4.17",
Expand All @@ -27,14 +27,14 @@ dependencies = [

[[package]]
name = "ac-node-api"
version = "0.2.2"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39-tag-v0.9.0#c4d3f110b94e25d5ce52d5bb64d0c778c4c7f2da"
version = "0.2.3"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39#417c301cce7e23f765891cd56ca48878390c5cf9"
dependencies = [
"ac-primitives",
"bitvec",
"derive_more",
"either",
"frame-metadata 15.0.0 (git+https://github.com/paritytech/frame-metadata)",
"frame-metadata 15.1.0",
"hex",
"log 0.4.17",
"parity-scale-codec",
Expand All @@ -49,8 +49,8 @@ dependencies = [

[[package]]
name = "ac-primitives"
version = "0.4.0"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39-tag-v0.9.0#c4d3f110b94e25d5ce52d5bb64d0c778c4c7f2da"
version = "0.5.0"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39#417c301cce7e23f765891cd56ca48878390c5cf9"
dependencies = [
"frame-system",
"hex",
Expand Down Expand Up @@ -196,6 +196,12 @@ version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6"

[[package]]
name = "array-bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22f72e9d6fac4bc80778ea470b20197b88d28c292bb7d60c3fb099280003cd19"

[[package]]
name = "arrayref"
version = "0.3.7"
Expand Down Expand Up @@ -1749,8 +1755,8 @@ dependencies = [

[[package]]
name = "frame-metadata"
version = "15.0.0"
source = "git+https://github.com/paritytech/frame-metadata#040a53c63af277e280282028b73b992eac9c35a2"
version = "15.1.0"
source = "git+https://github.com/paritytech/frame-metadata#438a5b098bb9d5b5a09bdc5b68275b2c5e63a010"
dependencies = [
"cfg-if 1.0.0",
"parity-scale-codec",
Expand All @@ -1764,7 +1770,7 @@ version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375"
dependencies = [
"bitflags",
"frame-metadata 15.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"frame-metadata 15.0.0",
"frame-support-procedural",
"impl-trait-for-tuples",
"k256",
Expand Down Expand Up @@ -2664,6 +2670,7 @@ dependencies = [
name = "integritee-cli"
version = "0.9.0"
dependencies = [
"array-bytes 6.0.0",
"base58",
"blake2-rfc",
"chrono 0.4.24",
Expand All @@ -2685,6 +2692,7 @@ dependencies = [
"log 0.4.17",
"pallet-balances",
"pallet-evm",
"pallet-teerex",
"parity-scale-codec",
"primitive-types",
"rand 0.8.5",
Expand All @@ -2700,6 +2708,7 @@ dependencies = [
"substrate-api-client",
"substrate-client-keystore",
"teerex-primitives",
"thiserror 1.0.40",
"ws",
]

Expand Down Expand Up @@ -3164,7 +3173,7 @@ name = "itc-rpc-client"
version = "0.9.0"
dependencies = [
"env_logger 0.9.3",
"frame-metadata 15.0.0 (git+https://github.com/paritytech/frame-metadata)",
"frame-metadata 15.1.0",
"itc-tls-websocket-server",
"itp-networking-utils",
"itp-rpc",
Expand Down Expand Up @@ -3648,7 +3657,7 @@ name = "itp-storage"
version = "0.9.0"
dependencies = [
"derive_more",
"frame-metadata 15.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"frame-metadata 15.0.0",
"frame-support",
"hash-db",
"itp-types",
Expand Down Expand Up @@ -6777,7 +6786,7 @@ name = "sc-keystore"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375"
dependencies = [
"array-bytes",
"array-bytes 4.2.0",
"async-trait",
"parking_lot 0.12.1",
"serde_json 1.0.94",
Expand Down Expand Up @@ -7644,7 +7653,7 @@ name = "sp-core"
version = "7.0.0"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375"
dependencies = [
"array-bytes",
"array-bytes 4.2.0",
"base58",
"bitflags",
"blake2",
Expand Down Expand Up @@ -8197,13 +8206,14 @@ dependencies = [

[[package]]
name = "substrate-api-client"
version = "0.9.0"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39-tag-v0.9.0#c4d3f110b94e25d5ce52d5bb64d0c778c4c7f2da"
version = "0.10.0"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39#417c301cce7e23f765891cd56ca48878390c5cf9"
dependencies = [
"ac-compose-macros",
"ac-node-api",
"ac-primitives",
"frame-metadata 15.0.0 (git+https://github.com/paritytech/frame-metadata)",
"derive_more",
"frame-metadata 15.1.0",
"frame-support",
"futures 0.3.27",
"hex",
Expand All @@ -8215,7 +8225,6 @@ dependencies = [
"sp-core",
"sp-runtime",
"sp-runtime-interface",
"thiserror-core",
"url 2.3.1",
"ws",
]
Expand All @@ -8236,7 +8245,7 @@ dependencies = [
[[package]]
name = "substrate-client-keystore"
version = "0.7.0"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39-tag-v0.9.0#c4d3f110b94e25d5ce52d5bb64d0c778c4c7f2da"
source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.39#417c301cce7e23f765891cd56ca48878390c5cf9"
dependencies = [
"async-trait",
"hex",
Expand Down Expand Up @@ -8420,26 +8429,6 @@ dependencies = [
"thiserror-impl 1.0.40",
]

[[package]]
name = "thiserror-core"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497"
dependencies = [
"thiserror-core-impl",
]

[[package]]
name = "thiserror-core-impl"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]

[[package]]
name = "thiserror-impl"
version = "1.0.9"
Expand Down
7 changes: 5 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Integritee AG <[email protected]>"]
edition = "2021"

[dependencies]
array-bytes = { version = "6.0.0" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure if I want to have this crate just for the array_bytes::hex2bytes function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. But instead of removing it, one could also consider using it for all hex conversions. I've seen other hex functions that are defined within the worker.

Copy link
Contributor Author

@haerdib haerdib Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth an issue to unify the hex conversion to some place.

base58 = "0.2"
blake2-rfc = { version = "0.2.18" }
chrono = "*"
Expand All @@ -20,13 +21,15 @@ rayon = "1.5.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sgx_crypto_helper = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
thiserror = "1.0"
ws = { version = "0.9.1", features = ["ssl"] }

# scs / integritee
my-node-runtime = { package = "integritee-node-runtime", git = "https://github.com/integritee-network/integritee-node.git", branch = "polkadot-v0.9.39" }
pallet-evm = { optional = true, git = "https://github.com/integritee-network/frontier.git", branch = "polkadot-v0.9.39" }
substrate-api-client = { features = ["ws-client"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.39-tag-v0.9.0" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.39-tag-v0.9.0" }
pallet-teerex = { git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v0.9.39" }
substrate-api-client = { features = ["ws-client"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.39" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.39" }
teerex-primitives = { git = "https://github.com/integritee-network/pallets.git", branch = "polkadot-v0.9.39" }

# substrate dependencies
Expand Down
10 changes: 5 additions & 5 deletions cli/src/base_cli/commands/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use crate::{
command_utils::{get_accountid_from_str, get_chain_api},
Cli,
};
use codec::Encode;
use itp_node_api::api_client::ParentchainExtrinsicSigner;
use my_node_runtime::{BalancesCall, RuntimeCall};
use sp_keyring::AccountKeyring;
use sp_runtime::MultiAddress;
use std::vec::Vec;
use substrate_api_client::{compose_extrinsic_offline, SubmitExtrinsic, UncheckedExtrinsicV4};
use substrate_api_client::{compose_extrinsic_offline, SubmitExtrinsic};

const PREFUNDING_AMOUNT: u128 = 1_000_000_000;

Expand All @@ -38,12 +38,12 @@ pub struct FaucetCommand {
impl FaucetCommand {
pub(crate) fn run(&self, cli: &Cli) {
let mut api = get_chain_api(cli);
api.set_signer(AccountKeyring::Alice.pair());
api.set_signer(ParentchainExtrinsicSigner::new(AccountKeyring::Alice.pair()));
let mut nonce = api.get_nonce().unwrap();
for account in &self.accounts {
let to = get_accountid_from_str(account);
#[allow(clippy::redundant_clone)]
let xt: UncheckedExtrinsicV4<_, _> = compose_extrinsic_offline!(
let xt = compose_extrinsic_offline!(
api.signer().unwrap(),
RuntimeCall::Balances(BalancesCall::transfer {
dest: MultiAddress::Id(to.clone()),
Expand All @@ -53,7 +53,7 @@ impl FaucetCommand {
);
// send and watch extrinsic until finalized
println!("Faucet drips to {} (Alice's nonce={})", to, nonce);
let _blockh = api.submit_extrinsic(xt.encode()).unwrap();
let _blockh = api.submit_extrinsic(xt).unwrap();
nonce += 1;
}
}
Expand Down
14 changes: 5 additions & 9 deletions cli/src/base_cli/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

use crate::{command_utils::get_chain_api, Cli};
use base58::ToBase58;
use codec::{Decode, Encode};
use codec::Encode;
use log::*;
use my_node_runtime::{Hash, RuntimeEvent};
use std::vec::Vec;
use substrate_api_client::{rpc::HandleSubscription, SubscribeFrameSystem};
use substrate_api_client::SubscribeEvents;

#[derive(Parser)]
pub struct ListenCommand {
Expand All @@ -41,7 +40,7 @@ impl ListenCommand {
info!("Subscribing to events");
let mut count = 0u32;
let mut blocks = 0u32;
let mut subscription = api.subscribe_system_events().unwrap();
let mut subscription = api.subscribe_events().unwrap();
loop {
if let Some(e) = self.events {
if count >= e {
Expand All @@ -54,12 +53,9 @@ impl ListenCommand {
}
};

let event_bytes = subscription.next().unwrap().unwrap().changes[0].1.clone().unwrap().0;
let events_result = Vec::<frame_system::EventRecord<RuntimeEvent, Hash>>::decode(
&mut event_bytes.as_slice(),
);
let event_results = subscription.next_event::<RuntimeEvent, Hash>().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful

blocks += 1;
match events_result {
match event_results {
Ok(evts) =>
for evr in &evts {
println!("decoded: phase {:?} event {:?}", evr.phase, evr.event);
Expand Down
29 changes: 12 additions & 17 deletions cli/src/base_cli/commands/shield_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,23 @@ use crate::{
};
use base58::FromBase58;
use codec::{Decode, Encode};
use itp_node_api::api_client::TEEREX;
use itp_node_api::api_client::{ParentchainExtrinsicSigner, TEEREX};
use itp_sgx_crypto::ShieldingCryptoEncrypt;
use itp_stf_primitives::types::ShardIdentifier;
use log::*;
use my_node_runtime::Balance;
use sp_core::sr25519 as sr25519_core;
use substrate_api_client::{compose_extrinsic, SubmitAndWatch, UncheckedExtrinsicV4, XtStatus};
use substrate_api_client::{compose_extrinsic, SubmitAndWatch, XtStatus};

#[derive(Parser)]
pub struct ShieldFundsCommand {
/// Sender's parentchain AccountId in ss58check format
/// Sender's parentchain AccountId in ss58check format.
from: String,

/// Recipient's incognito AccountId in ss58check format
/// Recipient's incognito AccountId in ss58check format.
to: String,

/// Amount to be transferred
/// Amount to be transferred.
amount: Balance,

/// Shard identifier
/// Shard identifier.
shard: String,
}

Expand All @@ -58,18 +55,18 @@ impl ShieldFundsCommand {
Err(e) => panic!("{}", e),
};

// get the sender
// Get the sender.
let from = get_pair_from_str(&self.from);
chain_api.set_signer(sr25519_core::Pair::from(from));
chain_api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from(from)));

// get the recipient
// Get the recipient.
let to = get_accountid_from_str(&self.to);

let encryption_key = get_shielding_key(cli).unwrap();
let encrypted_recevier = encryption_key.encrypt(&to.encode()).unwrap();

// compose the extrinsic
let xt: UncheckedExtrinsicV4<_, _> = compose_extrinsic!(
// Compose the extrinsic.
let xt = compose_extrinsic!(
chain_api,
TEEREX,
"shield_funds",
Expand All @@ -78,9 +75,7 @@ impl ShieldFundsCommand {
shard
);

let tx_hash = chain_api
.submit_and_watch_extrinsic_until(xt.encode(), XtStatus::Finalized)
.unwrap();
let tx_hash = chain_api.submit_and_watch_extrinsic_until(xt, XtStatus::Finalized).unwrap();
println!("[+] TrustedOperation got finalized. Hash: {:?}\n", tx_hash);
}
}
15 changes: 10 additions & 5 deletions cli/src/base_cli/commands/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ use crate::{
command_utils::{get_accountid_from_str, get_chain_api, *},
Cli,
};
use codec::Encode;
use itp_node_api::api_client::{Address, ParentchainExtrinsicSigner};
use log::*;
use my_node_runtime::Balance;
use sp_core::{crypto::Ss58Codec, sr25519 as sr25519_core, Pair};
use substrate_api_client::{GenericAddress, GetAccountInformation, SubmitAndWatch, XtStatus};
use substrate_api_client::{
extrinsic::BalancesExtrinsics, GetAccountInformation, SubmitAndWatch, XtStatus,
};

#[derive(Parser)]
pub struct TransferCommand {
Expand All @@ -44,9 +46,12 @@ impl TransferCommand {
info!("from ss58 is {}", from_account.public().to_ss58check());
info!("to ss58 is {}", to_account.to_ss58check());
let mut api = get_chain_api(cli);
api.set_signer(sr25519_core::Pair::from(from_account));
let xt = api.balance_transfer(GenericAddress::Id(to_account.clone()), self.amount);
let tx_hash = api.submit_and_watch_extrinsic_until(xt.encode(), XtStatus::InBlock).unwrap();
api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from(from_account)));
let xt = api.balance_transfer(Address::Id(to_account.clone()), self.amount);
let tx_hash = api
.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock)
.unwrap()
.extrinsic_hash;
println!("[+] TrustedOperation got finalized. Hash: {:?}\n", tx_hash);
let result = api.get_account_data(&to_account).unwrap().unwrap();
println!("balance for {} is now {}", to_account, result.free);
Expand Down
Loading