Skip to content

Commit

Permalink
sdk - retrieve_account_as_scenario_set_state refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Oct 3, 2024
1 parent cf8b83d commit 3e29d77
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions framework/snippets/src/account_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ use multiversx_sc_scenario::{
imports::Bech32Address,
scenario_model::{Account, BytesKey, BytesValue, Scenario, SetStateStep, Step},
};
use multiversx_sdk::gateway::{
GetAccountEsdtRolesRequest, GetAccountEsdtTokensRequest, GetAccountRequest,
GetAccountStorageRequest,
};
use multiversx_sdk_http::GatewayHttpProxy;
use std::collections::{BTreeMap, HashMap};

Expand Down Expand Up @@ -39,25 +43,28 @@ pub async fn retrieve_account_as_scenario_set_state(
address: &Bech32Address,
) -> SetStateStep {
let sdk_address = SdkAddress::from_bech32_string(address.to_bech32_str()).unwrap();
let sdk_account = api.get_account(&sdk_address).await.unwrap();
let sdk_account = api
.http_request(GetAccountRequest::new(&sdk_address))
.await
.unwrap();

let (account_esdt, account_esdt_roles, account_storage) = if use_chain_simulator {
(HashMap::new(), HashMap::new(), HashMap::new())
} else {
let account_esdt = api
.get_account_esdt_tokens(&sdk_address)
.http_request(GetAccountEsdtTokensRequest::new(&sdk_address))
.await
.unwrap_or_else(|err| {
panic!("failed to retrieve ESDT tokens for address {address}: {err}")
});
let account_esdt_roles = api
.get_account_esdt_roles(&sdk_address)
.http_request(GetAccountEsdtRolesRequest::new(&sdk_address))
.await
.unwrap_or_else(|err| {
panic!("failed to retrieve ESDT roles for address {address}: {err}")
});
let account_storage = api
.get_account_storage_keys(&sdk_address)
.http_request(GetAccountStorageRequest::new(&sdk_address))
.await
.unwrap_or_else(|err| {
panic!("failed to retrieve storage for address {address}: {err}")
Expand Down

0 comments on commit 3e29d77

Please sign in to comment.