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-0.14.0; fix parachain block import #1452

Merged
merged 28 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1aacacf
[itc-parentchain] test replace the wsrpc-client with the tungstenite …
clangenb Sep 13, 2023
4619fc3
fix api-client feature flags in cli and service
clangenb Sep 13, 2023
16466f2
bump api-client to polkadot-v0.9.42-tag-v0.14.0; dependency resolutio…
clangenb Sep 14, 2023
a7e48b9
bump api client to fix some trait bound errors
clangenb Sep 14, 2023
404269e
[api-client-types] fix import paths
clangenb Sep 14, 2023
ac3251e
[node-metadata] fix deprecated methods
clangenb Sep 14, 2023
79c164c
fixes to make the service compile
clangenb Sep 14, 2023
e716ef9
update api client to fix client-keystore compilation
clangenb Sep 14, 2023
dd97e29
fix client build
clangenb Sep 14, 2023
ce0200e
fix service build
clangenb Sep 14, 2023
c15b9b7
upgrade api-client to fix no-std compilation issue
clangenb Sep 15, 2023
84d1bac
cargo lock
clangenb Sep 15, 2023
a2cd3f4
add code annotations for api-client type update
clangenb Sep 15, 2023
85bb079
[cli] fix `register_tcb_info` after rebase on master
clangenb Sep 15, 2023
22aeb4f
[cli] minor code optimizations
clangenb Sep 15, 2023
26b1ddd
[ipt-api-client-extensions] optimize toml
clangenb Sep 15, 2023
78859f0
[api-client-extensions] remove unnecessary trait bounds
clangenb Sep 15, 2023
fdf4e2e
[service] add more comments for clean up of the api-client types
clangenb Sep 15, 2023
6511392
[service/account_funding] restore previous behaviour of waiting until…
clangenb Sep 15, 2023
8ee308f
[local-setup] fix node-log for `tmux_logger.sh`
clangenb Sep 15, 2023
80283c8
[service/parentchain_handler] fix clippy
clangenb Sep 15, 2023
38fbca0
taplo fmt
clangenb Sep 15, 2023
bb214d5
fix cargo test
clangenb Sep 15, 2023
bf8a68c
Fix: Don't panic if the extrinsic was not found while registering.
clangenb Sep 15, 2023
1cf1be9
fix teeracle mode compilation
clangenb Sep 15, 2023
e3f77cf
fix teeracle build
clangenb Sep 15, 2023
f1b02a5
fix warnings when not compiling with teeracle flag
clangenb Sep 15, 2023
f331ae4
fix clippy again
clangenb Sep 15, 2023
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
806 changes: 390 additions & 416 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ pallet-evm = { optional = true, git = "https://github.com/integritee-network/fro
pallet-teerex = { git = "https://github.com/integritee-network/pallets.git", branch = "sdk-v0.12.0-polkadot-v0.9.42" }
# `default-features = false` to remove the jsonrpsee dependency.
enclave-bridge-primitives = { git = "https://github.com/integritee-network/pallets.git", branch = "sdk-v0.12.0-polkadot-v0.9.42" }
substrate-api-client = { default-features = false, features = ["std", "ws-client"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.10.0" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.10.0" }
# disable unsupported jsonrpcsee
substrate-api-client = { default-features = false, features = ["std", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" }
substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" }

# substrate dependencies
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
Expand Down
5 changes: 2 additions & 3 deletions cli/src/base_cli/commands/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use crate::{
command_utils::{get_accountid_from_str, get_chain_api},
Cli, CliResult, CliResultOk,
};
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};
use substrate_api_client::{ac_compose_macros::compose_extrinsic_offline, SubmitExtrinsic};

const PREFUNDING_AMOUNT: u128 = 1_000_000_000;

Expand All @@ -38,7 +37,7 @@ pub struct FaucetCommand {
impl FaucetCommand {
pub(crate) fn run(&self, cli: &Cli) -> CliResult {
let mut api = get_chain_api(cli);
api.set_signer(ParentchainExtrinsicSigner::new(AccountKeyring::Alice.pair()));
api.set_signer(AccountKeyring::Alice.pair().into());
let mut nonce = api.get_nonce().unwrap();
for account in &self.accounts {
let to = get_accountid_from_str(account);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/base_cli/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl ListenCommand {
}
};

let event_results = subscription.next_event::<RuntimeEvent, Hash>().unwrap();
let event_results = subscription.next_events::<RuntimeEvent, Hash>().unwrap();
blocks += 1;
match event_results {
Ok(evts) =>
Expand Down
12 changes: 7 additions & 5 deletions cli/src/base_cli/commands/register_tcb_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ use crate::{
command_utils::{get_chain_api, *},
Cli, CliResult, CliResultOk,
};
use itp_node_api::api_client::{ParentchainExtrinsicSigner, TEEREX};
use itp_node_api::api_client::TEEREX;
use itp_types::{parentchain::Hash, OpaqueCall};
use itp_utils::ToHexPrefixed;
use log::*;
use regex::Regex;
use serde::Deserialize;
use sp_core::sr25519 as sr25519_core;
use substrate_api_client::{compose_call, compose_extrinsic_offline, SubmitAndWatchUntilSuccess};
use substrate_api_client::{
ac_compose_macros::{compose_call, compose_extrinsic_offline},
SubmitAndWatch, XtStatus,
};
use urlencoding;

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -54,7 +56,7 @@ impl RegisterTcbInfoCommand {

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

let fmspcs = if self.all {
trace!("fetching all fmspc's from api.trustedservices.intel.com");
Expand Down Expand Up @@ -123,7 +125,7 @@ impl RegisterTcbInfoCommand {
chain_api.extrinsic_params(nonce)
);
nonce += 1;
match chain_api.submit_and_watch_extrinsic_until_success(xt, false) {
match chain_api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock) {
brenzi marked this conversation as resolved.
Show resolved Hide resolved
Ok(xt_report) => {
println!(
"[+] register_tcb_info. extrinsic hash: {:?} / status: {:?}",
Expand Down
8 changes: 4 additions & 4 deletions cli/src/base_cli/commands/shield_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ use crate::{
};
use base58::FromBase58;
use codec::{Decode, Encode};
use itp_node_api::api_client::{ParentchainExtrinsicSigner, ENCLAVE_BRIDGE};
use itp_node_api::api_client::ENCLAVE_BRIDGE;
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, SubmitAndWatchUntilSuccess};
use substrate_api_client::{ac_compose_macros::compose_extrinsic, SubmitAndWatch, XtStatus};

#[derive(Parser)]
pub struct ShieldFundsCommand {
Expand Down Expand Up @@ -57,7 +57,7 @@ impl ShieldFundsCommand {

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

// Get the recipient.
let to = get_accountid_from_str(&self.to);
Expand All @@ -75,7 +75,7 @@ impl ShieldFundsCommand {
self.amount
);

match chain_api.submit_and_watch_extrinsic_until_success(xt, true) {
match chain_api.submit_and_watch_extrinsic_until(xt, XtStatus::Finalized) {
Ok(xt_report) => {
println!(
"[+] shield funds success. extrinsic hash: {:?} / status: {:?} / block hash: {:?}",
Expand Down
11 changes: 5 additions & 6 deletions cli/src/base_cli/commands/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use crate::{
command_utils::{get_accountid_from_str, get_chain_api, *},
Cli, CliResult, CliResultOk,
};
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 sp_core::{crypto::Ss58Codec, Pair};
use substrate_api_client::{
extrinsic::BalancesExtrinsics, GetAccountInformation, SubmitAndWatchUntilSuccess,
extrinsic::BalancesExtrinsics, GetAccountInformation, SubmitAndWatch, XtStatus,
};

#[derive(Parser)]
Expand All @@ -46,9 +45,9 @@ 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(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from(from_account)));
let xt = api.balance_transfer_allow_death(Address::Id(to_account.clone()), self.amount);
let tx_report = api.submit_and_watch_extrinsic_until_success(xt, false).unwrap();
api.set_signer(from_account.into());
let xt = api.balance_transfer_allow_death(to_account.clone().into(), self.amount);
let tx_report = api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock).unwrap();
println!(
"[+] L1 extrinsic success. extrinsic hash: {:?} / status: {:?}",
tx_report.extrinsic_hash, tx_report.status
Expand Down
6 changes: 2 additions & 4 deletions cli/src/base_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use itp_node_api::api_client::PalletTeerexApi;
use sp_core::crypto::Ss58Codec;
use sp_keystore::Keystore;
use std::path::PathBuf;
use substrate_api_client::Metadata;
use substrate_client_keystore::LocalKeystore;

mod commands;
Expand Down Expand Up @@ -130,14 +129,13 @@ fn list_accounts() -> CliResult {
fn print_metadata(cli: &Cli) -> CliResult {
let api = get_chain_api(cli);
let meta = api.metadata();
println!("Metadata:\n {}", Metadata::pretty_format(&meta.runtime_metadata()).unwrap());
println!("Metadata:\n {}", &meta.pretty_format().unwrap());
Ok(CliResultOk::Metadata { metadata: meta.clone() })
}

fn print_sgx_metadata(cli: &Cli) -> CliResult {
let worker_api_direct = get_worker_api_direct(cli);
let metadata = worker_api_direct.get_state_metadata().unwrap();
println!("Metadata:\n {}", Metadata::pretty_format(metadata.runtime_metadata()).unwrap());
println!("Metadata:\n {}", metadata.pretty_format().unwrap());
Ok(CliResultOk::Metadata { metadata })
}

Expand Down
4 changes: 2 additions & 2 deletions cli/src/command_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::Cli;
use base58::FromBase58;
use itc_rpc_client::direct_client::{DirectApi, DirectClient as DirectWorkerApi};
use itp_node_api::api_client::{ParentchainApi, WsRpcClient};
use itp_node_api::api_client::{ParentchainApi, TungsteniteRpcClient};
brenzi marked this conversation as resolved.
Show resolved Hide resolved
use log::*;
use my_node_runtime::{AccountId, Signature};
use sgx_crypto_helper::rsa3072::Rsa3072PubKey;
Expand All @@ -40,7 +40,7 @@ pub(crate) fn get_shielding_key(cli: &Cli) -> Result<Rsa3072PubKey, String> {
pub(crate) fn get_chain_api(cli: &Cli) -> ParentchainApi {
let url = format!("{}:{}", cli.node_url, cli.node_port);
info!("connecting to {}", url);
ParentchainApi::new(WsRpcClient::new(&url).unwrap()).unwrap()
ParentchainApi::new(TungsteniteRpcClient::new(&url, 5).unwrap()).unwrap()
}

pub(crate) fn get_accountid_from_str(account: &str) -> AccountId {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ pub mod commands;

use crate::commands::Commands;
use clap::Parser;
use itp_node_api::api_client::Metadata;
use sp_application_crypto::KeyTypeId;
use sp_core::{H160, H256};
use substrate_api_client::Metadata;
use thiserror::Error;

const VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down
4 changes: 2 additions & 2 deletions cli/src/oracle/commands/add_to_whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
command_utils::{get_chain_api, get_pair_from_str, mrenclave_from_base58},
Cli,
};
use itp_node_api::api_client::{ParentchainExtrinsicSigner, ADD_TO_WHITELIST, TEERACLE};
use itp_node_api::api_client::{ADD_TO_WHITELIST, TEERACLE};
use substrate_api_client::{compose_call, compose_extrinsic, SubmitAndWatch, XtStatus};

/// Add a trusted market data source to the on-chain whitelist.
Expand All @@ -45,7 +45,7 @@ impl AddToWhitelistCmd {

let market_data_source = self.source.clone();

api.set_signer(ParentchainExtrinsicSigner::new(from.into()));
api.set_signer(from.into());

let call = compose_call!(
api.metadata(),
Expand Down
12 changes: 6 additions & 6 deletions cli/src/trusted_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use codec::{Decode, Encode};
use enclave_bridge_primitives::Request;
use ita_stf::{Getter, TrustedOperation};
use itc_rpc_client::direct_client::{DirectApi, DirectClient};
use itp_node_api::api_client::{ParentchainApi, ParentchainExtrinsicSigner, ENCLAVE_BRIDGE};
use itp_node_api::api_client::{ParentchainApi, ENCLAVE_BRIDGE};
use itp_rpc::{RpcRequest, RpcResponse, RpcReturnValue};
use itp_sgx_crypto::ShieldingCryptoEncrypt;
use itp_stf_primitives::types::ShardIdentifier;
Expand All @@ -35,14 +35,14 @@ use itp_utils::{FromHexPrefixed, ToHexPrefixed};
use log::*;
use my_node_runtime::{Hash, RuntimeEvent};
use pallet_enclave_bridge::Event as EnclaveBridgeEvent;
use sp_core::{sr25519 as sr25519_core, H256};
use sp_core::H256;
use std::{
result::Result as StdResult,
sync::mpsc::{channel, Receiver},
time::Instant,
};
use substrate_api_client::{
compose_extrinsic, GetHeader, SubmitAndWatchUntilSuccess, SubscribeEvents,
ac_compose_macros::compose_extrinsic, GetChainInfo, SubmitAndWatch, SubscribeEvents, XtStatus,
};
use thiserror::Error;

Expand Down Expand Up @@ -135,12 +135,12 @@ fn send_indirect_request(
);
let arg_signer = &trusted_args.xt_signer;
let signer = get_pair_from_str(arg_signer);
chain_api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from(signer)));
chain_api.set_signer(signer.into());

let request = Request { shard, cyphertext: call_encrypted };
let xt = compose_extrinsic!(&chain_api, ENCLAVE_BRIDGE, "invoke", request);

let block_hash = match chain_api.submit_and_watch_extrinsic_until_success(xt, false) {
let block_hash = match chain_api.submit_and_watch_extrinsic_until(xt, XtStatus::InBlock) {
Ok(xt_report) => {
println!(
"[+] invoke TrustedOperation extrinsic success. extrinsic hash: {:?} / status: {:?} / block hash: {:?}",
Expand All @@ -161,7 +161,7 @@ fn send_indirect_request(
info!("Waiting for execution confirmation from enclave...");
let mut subscription = chain_api.subscribe_events().unwrap();
loop {
let event_records = subscription.next_event::<RuntimeEvent, Hash>().unwrap().unwrap();
let event_records = subscription.next_events::<RuntimeEvent, Hash>().unwrap().unwrap();
for event_record in event_records {
if let RuntimeEvent::EnclaveBridge(EnclaveBridgeEvent::ProcessedParentchainBlock {
shard,
Expand Down
6 changes: 3 additions & 3 deletions core-primitives/enclave-api/src/sidechain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ use itp_enclave_api_ffi as ffi;
use itp_storage::StorageProof;
use itp_types::parentchain::ParentchainId;
use sgx_types::sgx_status_t;
use sp_runtime::{generic::SignedBlock, traits::Block as ParentchainBlockTrait};
use sp_runtime::generic::SignedBlock;

/// trait for handling blocks on the side chain
pub trait Sidechain: Send + Sync + 'static {
/// Sync parentchain blocks and events. Execute pending tops
/// and events proof in the enclave.
fn sync_parentchain<ParentchainBlock: ParentchainBlockTrait>(
fn sync_parentchain<ParentchainBlock: Encode>(
brenzi marked this conversation as resolved.
Show resolved Hide resolved
&self,
blocks: &[SignedBlock<ParentchainBlock>],
events: &[Vec<u8>],
Expand All @@ -41,7 +41,7 @@ pub trait Sidechain: Send + Sync + 'static {
}

impl Sidechain for Enclave {
fn sync_parentchain<ParentchainBlock: ParentchainBlockTrait>(
fn sync_parentchain<ParentchainBlock: Encode>(
&self,
blocks: &[SignedBlock<ParentchainBlock>],
events: &[Vec<u8>],
Expand Down
2 changes: 1 addition & 1 deletion core-primitives/extrinsics-factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
# sgx dependencies
sgx_tstd = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git", optional = true }
sgx_types = { branch = "master", git = "https://github.com/apache/teaclave-sgx-sdk.git" }
substrate-api-client = { default-features = false, git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.10.0" }
substrate-api-client = { default-features = false, features = ["sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" }

# local dependencies
itp-node-api = { path = "../node-api", default-features = false }
Expand Down
6 changes: 4 additions & 2 deletions core-primitives/extrinsics-factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ pub mod sgx_reexport_prelude {
use codec::Encode;
use error::Result;
use itp_node_api::{
api_client::{ParentchainAdditionalParams, ParentchainExtrinsicParams},
api_client::{
ExtrinsicParams, ParentchainAdditionalParams, ParentchainExtrinsicParams, SignExtrinsic,
},
metadata::{provider::AccessNodeMetadata, NodeMetadata},
};
use itp_nonce_cache::{MutateNonce, Nonce};
use itp_types::{parentchain::AccountId, OpaqueCall};
use sp_core::H256;
use sp_runtime::{generic::Era, OpaqueExtrinsic};
use std::{sync::Arc, vec::Vec};
use substrate_api_client::{compose_extrinsic_offline, ExtrinsicParams, SignExtrinsic};
use substrate_api_client::ac_compose_macros::compose_extrinsic_offline;

pub mod error;

Expand Down
3 changes: 2 additions & 1 deletion core-primitives/node-api/api-client-extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
# crates.io
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
log = { version = "0.4", default-features = false }
thiserror = { version = "1.0" }

# substrate
Expand All @@ -16,7 +17,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "po

# scs
# `default-features = false` to remove the jsonrpsee dependency.
substrate-api-client = { default-features = false, features = ["std"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.10.0" }
substrate-api-client = { default-features = false, features = ["std", "tungstenite-client", "sync-api"], git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" }

# local deps
itp-api-client-types = { path = "../api-client-types" }
Expand Down
31 changes: 18 additions & 13 deletions core-primitives/node-api/api-client-extensions/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,34 @@
*/

use crate::ApiResult;
use itp_types::parentchain::{AccountData, AccountId, Balance, Index};
use substrate_api_client::{
rpc::Request, Api, ExtrinsicParams, FrameSystemConfig, GetAccountInformation, SignExtrinsic,
use itp_api_client_types::{
traits::GetAccountInformation, Api, Config, ParentchainRuntimeConfig, Request,
};

/// ApiClient extension that contains some convenience methods around accounts.
// Todo: make generic over `Config` type instead?
pub trait AccountApi {
fn get_nonce_of(&self, who: &AccountId) -> ApiResult<Index>;
fn get_free_balance(&self, who: &AccountId) -> ApiResult<Balance>;
type AccountId;
type Index;
type Balance;

fn get_nonce_of(&self, who: &Self::AccountId) -> ApiResult<Self::Index>;
fn get_free_balance(&self, who: &Self::AccountId) -> ApiResult<Self::Balance>;
}

impl<Signer, Client, Params, Runtime> AccountApi for Api<Signer, Client, Params, Runtime>
impl<Client> AccountApi for Api<ParentchainRuntimeConfig, Client>
where
Signer: SignExtrinsic<Runtime::AccountId>,
Client: Request,
Runtime: FrameSystemConfig<AccountId = AccountId, AccountData = AccountData, Index = Index>,
Params: ExtrinsicParams<Runtime::Index, Runtime::Hash>,
{
fn get_nonce_of(&self, who: &AccountId) -> ApiResult<Index> {
Ok(self.get_account_info(who)?.map_or_else(|| 0, |info| info.nonce))
type AccountId = <ParentchainRuntimeConfig as Config>::AccountId;
type Index = <ParentchainRuntimeConfig as Config>::Index;
type Balance = <ParentchainRuntimeConfig as Config>::Balance;

fn get_nonce_of(&self, who: &Self::AccountId) -> ApiResult<Self::Index> {
Ok(self.get_account_info(who)?.map(|info| info.nonce).unwrap_or_default())
}

fn get_free_balance(&self, who: &AccountId) -> ApiResult<Balance> {
Ok(self.get_account_data(who)?.map_or_else(|| 0, |data| data.free))
fn get_free_balance(&self, who: &Self::AccountId) -> ApiResult<Self::Balance> {
Ok(self.get_account_data(who)?.map(|data| data.free).unwrap_or_default())
}
}
Loading
Loading