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

fix: Added support for viewing account summary on networks without NEAR Social contract #302

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Changes from all 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
51 changes: 28 additions & 23 deletions src/commands/account/view_account_summary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,33 @@ impl ViewAccountSummaryContext {
.try_collect(),
)?;

let contract_account_id = network_config.get_near_social_account_id_from_network()?;

let social_db = network_config
.json_rpc_client()
.blocking_call_view_function(
&contract_account_id,
"get",
serde_json::to_vec(&serde_json::json!({
"keys": vec![format!("{account_id}/profile/**")],
}))?,
block_reference.clone(),
)
.wrap_err_with(|| {
format!("Failed to fetch query for view method: 'get {account_id}/profile/**' (contract <{}> on network <{}>)",
contract_account_id,
network_config.network_name
)
})?
.parse_result_from_json::<near_socialdb_client::types::socialdb_types::SocialDb>()
.wrap_err_with(|| {
format!("Failed to parse view function call return value for {account_id}/profile.")
})?;
let optional_account_profile =
if let Ok(contract_account_id) = network_config.get_near_social_account_id_from_network() {
let mut social_db = network_config
.json_rpc_client()
.blocking_call_view_function(
&contract_account_id,
"get",
serde_json::to_vec(&serde_json::json!({
"keys": vec![format!("{account_id}/profile/**")],
}))?,
block_reference.clone(),
)
.wrap_err_with(|| {
format!("Failed to fetch query for view method: 'get {account_id}/profile/**' (contract <{}> on network <{}>)",
contract_account_id,
network_config.network_name
)
})?
.parse_result_from_json::<near_socialdb_client::types::socialdb_types::SocialDb>()
.wrap_err_with(|| {
format!("Failed to parse view function call return value for {account_id}/profile.")
})?;

social_db.accounts.remove(&account_id)
} else {
None
};

crate::common::display_account_info(
&rpc_query_response.block_hash,
Expand All @@ -111,7 +116,7 @@ impl ViewAccountSummaryContext {
&delegated_stake,
&account_view,
&access_key_list.keys,
social_db.accounts.get(&account_id)
optional_account_profile.as_ref()
);

Ok(())
Expand Down
Loading