multiversx_sc_scenario/scenario/model/account_data/
accounts_check.rs1use std::collections::BTreeMap;
2
3use crate::scenario_format::{
4 interpret_trait::{InterpretableFrom, InterpreterContext, IntoRaw},
5 serde_raw::CheckAccountsRaw,
6};
7
8use crate::scenario::model::AddressKey;
9
10use super::CheckAccount;
11
12#[derive(Debug, Default, Clone)]
13pub struct CheckAccounts {
14 pub other_accounts_allowed: bool,
15 pub accounts: BTreeMap<AddressKey, CheckAccount>,
16}
17
18impl InterpretableFrom<CheckAccountsRaw> for CheckAccounts {
19 fn interpret_from(from: CheckAccountsRaw, context: &InterpreterContext) -> Self {
20 CheckAccounts {
21 other_accounts_allowed: from.other_accounts_allowed,
22 accounts: from
23 .accounts
24 .into_iter()
25 .map(|(k, v)| {
26 (
27 AddressKey::interpret_from(k, context),
28 CheckAccount::interpret_from(v, context),
29 )
30 })
31 .collect(),
32 }
33 }
34}
35
36impl IntoRaw<CheckAccountsRaw> for CheckAccounts {
37 fn into_raw(self) -> CheckAccountsRaw {
38 CheckAccountsRaw {
39 other_accounts_allowed: self.other_accounts_allowed,
40 accounts: self
41 .accounts
42 .into_iter()
43 .map(|(k, v)| (k.into_raw(), Box::new(v.into_raw())))
44 .collect(),
45 }
46 }
47}