Skip to content

Commit

Permalink
[types] diem_account -> aptos_account
Browse files Browse the repository at this point in the history
  • Loading branch information
davidiw committed Apr 25, 2022
1 parent ae0a4ed commit 72e5018
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 58 deletions.
8 changes: 4 additions & 4 deletions aptos-move/aptos-vm/src/read_write_set_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ pub fn add_on_functions_list() -> Vec<(ModuleId, Identifier)> {
vec![
(BLOCK_MODULE.clone(), BLOCK_PROLOGUE.to_owned()),
(
account_config::constants::DIEM_ACCOUNT_MODULE.clone(),
account_config::constants::APTOS_ACCOUNT_MODULE.clone(),
SCRIPT_PROLOGUE_NAME.to_owned(),
),
(
account_config::constants::DIEM_ACCOUNT_MODULE.clone(),
account_config::constants::APTOS_ACCOUNT_MODULE.clone(),
USER_EPILOGUE_NAME.to_owned(),
),
]
Expand Down Expand Up @@ -215,7 +215,7 @@ impl<'a, R: MoveResolver> ReadWriteSetAnalysis<'a, R> {
account_config::from_currency_code_string(tx.gas_currency_code())?,
);
let prologue_accesses = self.get_partially_concretized_summary(
&account_config::constants::DIEM_ACCOUNT_MODULE,
&account_config::constants::APTOS_ACCOUNT_MODULE,
SCRIPT_PROLOGUE_NAME,
&signers,
&serialize_values(&vec![
Expand All @@ -232,7 +232,7 @@ impl<'a, R: MoveResolver> ReadWriteSetAnalysis<'a, R> {
)?;

let epilogue_accesses = self.get_partially_concretized_summary(
&account_config::constants::DIEM_ACCOUNT_MODULE,
&account_config::constants::APTOS_ACCOUNT_MODULE,
USER_EPILOGUE_NAME,
&signers,
&serialize_values(&vec![
Expand Down
10 changes: 5 additions & 5 deletions aptos-move/e2e-tests-replay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use aptos_types::{
account_address::AccountAddress,
account_config::{
from_currency_code_string, reserved_vm_address, type_tag_for_currency_code,
DIEM_ACCOUNT_MODULE,
APTOS_ACCOUNT_MODULE,
},
block_metadata::BlockMetadata,
on_chain_config::Version,
Expand Down Expand Up @@ -768,7 +768,7 @@ fn execute_txn_user_script_prologue(
let rets = execute_function_via_session_and_xrunner(
session,
xrunner,
&*DIEM_ACCOUNT_MODULE,
&*APTOS_ACCOUNT_MODULE,
&*SCRIPT_PROLOGUE_NAME,
vec![gas_currency_ty.clone()],
args,
Expand Down Expand Up @@ -806,7 +806,7 @@ fn execute_txn_user_script_epilogue(
let rets = execute_function_via_session_and_xrunner(
session,
xrunner,
&*DIEM_ACCOUNT_MODULE,
&*APTOS_ACCOUNT_MODULE,
&*USER_EPILOGUE_NAME,
vec![gas_currency_ty.clone()],
args,
Expand Down Expand Up @@ -842,7 +842,7 @@ fn execute_txn_admin_script_prologue(
let rets = execute_function_via_session_and_xrunner(
session,
xrunner,
&*DIEM_ACCOUNT_MODULE,
&*APTOS_ACCOUNT_MODULE,
&*WRITESET_PROLOGUE_NAME,
vec![],
args,
Expand Down Expand Up @@ -873,7 +873,7 @@ fn execute_txn_admin_script_epilogue(
let rets = execute_function_via_session_and_xrunner(
session,
xrunner,
&*DIEM_ACCOUNT_MODULE,
&*APTOS_ACCOUNT_MODULE,
&*WRITESET_EPILOGUE_NAME,
vec![],
args,
Expand Down
5 changes: 3 additions & 2 deletions types/src/account_config/constants/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

pub use move_core_types::vm_status::known_locations::{
CORE_ACCOUNT_MODULE, CORE_ACCOUNT_MODULE_IDENTIFIER, DIEM_ACCOUNT_MODULE,
DIEM_ACCOUNT_MODULE_IDENTIFIER,
CORE_ACCOUNT_MODULE, CORE_ACCOUNT_MODULE_IDENTIFIER,
DIEM_ACCOUNT_MODULE as APTOS_ACCOUNT_MODULE,
DIEM_ACCOUNT_MODULE_IDENTIFIER as APTOS_ACCOUNT_MODULE_IDENTIFIER,
};
4 changes: 2 additions & 2 deletions types/src/account_config/events/admin_transaction.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

use crate::account_config::DIEM_ACCOUNT_MODULE_IDENTIFIER;
use crate::account_config::APTOS_ACCOUNT_MODULE_IDENTIFIER;
use anyhow::Result;
use move_core_types::{ident_str, identifier::IdentStr, move_resource::MoveStructType};
use serde::{Deserialize, Serialize};
Expand All @@ -24,6 +24,6 @@ impl AdminTransactionEvent {
}

impl MoveStructType for AdminTransactionEvent {
const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER;
const MODULE_NAME: &'static IdentStr = APTOS_ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = ident_str!("AdminTransactionEvent");
}
4 changes: 2 additions & 2 deletions types/src/account_config/events/create_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{
account_address::AccountAddress, account_config,
account_config::DIEM_ACCOUNT_MODULE_IDENTIFIER, event::EventKey,
account_config::APTOS_ACCOUNT_MODULE_IDENTIFIER, event::EventKey,
};
use anyhow::Result;
use move_core_types::{ident_str, identifier::IdentStr, move_resource::MoveStructType};
Expand Down Expand Up @@ -34,6 +34,6 @@ impl CreateAccountEvent {
}

impl MoveStructType for CreateAccountEvent {
const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER;
const MODULE_NAME: &'static IdentStr = APTOS_ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = ident_str!("CreateAccountEvent");
}
16 changes: 8 additions & 8 deletions types/src/account_config/resources/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{
account_config::{
constants::DIEM_ACCOUNT_MODULE_IDENTIFIER, KeyRotationCapabilityResource,
constants::APTOS_ACCOUNT_MODULE_IDENTIFIER, KeyRotationCapabilityResource,
WithdrawCapabilityResource,
},
event::EventHandle,
Expand All @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
/// This is not how the Account is represented in the VM but it's a convenient representation.
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "fuzzing"), derive(Arbitrary))]
pub struct DiemAccountResource {
pub struct AptosAccountResource {
authentication_key: Vec<u8>,
withdrawal_capability: Option<WithdrawCapabilityResource>,
key_rotation_capability: Option<KeyRotationCapabilityResource>,
Expand All @@ -30,7 +30,7 @@ pub struct DiemAccountResource {
sequence_number: u64,
}

impl DiemAccountResource {
impl AptosAccountResource {
/// Constructs an Account resource.
pub fn new(
sequence_number: u64,
Expand All @@ -40,7 +40,7 @@ impl DiemAccountResource {
sent_events: EventHandle,
received_events: EventHandle,
) -> Self {
DiemAccountResource {
AptosAccountResource {
authentication_key,
withdrawal_capability,
key_rotation_capability,
Expand Down Expand Up @@ -85,9 +85,9 @@ impl DiemAccountResource {
}
}

impl MoveStructType for DiemAccountResource {
const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER;
impl MoveStructType for AptosAccountResource {
const MODULE_NAME: &'static IdentStr = APTOS_ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = APTOS_ACCOUNT_MODULE_IDENTIFIER;
}

impl MoveResource for DiemAccountResource {}
impl MoveResource for AptosAccountResource {}
4 changes: 2 additions & 2 deletions types/src/account_config/resources/chain_account_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::account_config::constants::{
CORE_ACCOUNT_MODULE_IDENTIFIER, CORE_CODE_ADDRESS, DIEM_ACCOUNT_MODULE_IDENTIFIER,
APTOS_ACCOUNT_MODULE_IDENTIFIER, CORE_ACCOUNT_MODULE_IDENTIFIER, CORE_CODE_ADDRESS,
};
use move_core_types::{
account_address::AccountAddress,
Expand All @@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
pub static DPN_CHAIN_INFO: Lazy<ChainSpecificAccountInfo> =
Lazy::new(|| ChainSpecificAccountInfo {
module_addr: CORE_CODE_ADDRESS,
module_name: DIEM_ACCOUNT_MODULE_IDENTIFIER.to_owned(),
module_name: APTOS_ACCOUNT_MODULE_IDENTIFIER.to_owned(),
script_prologue_name: Identifier::new("script_prologue").unwrap(),
module_prologue_name: Identifier::new("module_prologue").unwrap(),
writeset_prologue_name: Identifier::new("writeset_prologue").unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions types/src/account_config/resources/key_rotation_capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
account_address::AccountAddress, account_config::constants::DIEM_ACCOUNT_MODULE_IDENTIFIER,
account_address::AccountAddress, account_config::constants::APTOS_ACCOUNT_MODULE_IDENTIFIER,
};
use move_core_types::{
ident_str,
Expand All @@ -20,7 +20,7 @@ pub struct KeyRotationCapabilityResource {
}

impl MoveStructType for KeyRotationCapabilityResource {
const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER;
const MODULE_NAME: &'static IdentStr = APTOS_ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = ident_str!("KeyRotationCapability");
}

Expand Down
4 changes: 2 additions & 2 deletions types/src/account_config/resources/withdraw_capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
account_address::AccountAddress, account_config::constants::DIEM_ACCOUNT_MODULE_IDENTIFIER,
account_address::AccountAddress, account_config::constants::APTOS_ACCOUNT_MODULE_IDENTIFIER,
};
use move_core_types::{
ident_str,
Expand All @@ -20,7 +20,7 @@ pub struct WithdrawCapabilityResource {
}

impl MoveStructType for WithdrawCapabilityResource {
const MODULE_NAME: &'static IdentStr = DIEM_ACCOUNT_MODULE_IDENTIFIER;
const MODULE_NAME: &'static IdentStr = APTOS_ACCOUNT_MODULE_IDENTIFIER;
const STRUCT_NAME: &'static IdentStr = ident_str!("WithdrawCapability");
}

Expand Down
22 changes: 9 additions & 13 deletions types/src/account_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ use crate::{
access_path::Path,
account_address::AccountAddress,
account_config::{
AccountResource, BalanceResource, CRSNResource,
ChainIdResource,
DiemAccountResource,
AccountResource, AptosAccountResource, BalanceResource, CRSNResource, ChainIdResource,
},
account_state_blob::AccountStateBlob,
block_metadata::BlockResource,
Expand All @@ -20,9 +18,7 @@ use crate::{
validator_config::{ValidatorConfig, ValidatorOperatorConfigResource},
};
use anyhow::{format_err, Error, Result};
use move_core_types::{
language_storage::StructTag, move_resource::MoveResource,
};
use move_core_types::{language_storage::StructTag, move_resource::MoveResource};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{collections::btree_map::BTreeMap, convert::TryFrom, fmt};

Expand All @@ -36,17 +32,17 @@ impl AccountState {
.map(|opt_ar| opt_ar.map(|ar| ar.address()))
}

pub fn get_diem_account_resource(&self) -> Result<Option<DiemAccountResource>> {
self.get_resource::<DiemAccountResource>()
pub fn get_diem_account_resource(&self) -> Result<Option<AptosAccountResource>> {
self.get_resource::<AptosAccountResource>()
}

// Return the `AccountResource` for this blob. If the blob doesn't have an `AccountResource`
// then it must have a `DiemAccountResource` in which case we convert that to an
// then it must have a `AptosAccountResource` in which case we convert that to an
// `AccountResource`.
pub fn get_account_resource(&self) -> Result<Option<AccountResource>> {
match self.get_resource::<AccountResource>()? {
x @ Some(_) => Ok(x),
None => match self.get_resource::<DiemAccountResource>()? {
None => match self.get_resource::<AptosAccountResource>()? {
Some(diem_ar) => Ok(Some(AccountResource::new(
diem_ar.sequence_number(),
diem_ar.authentication_key().to_vec(),
Expand Down Expand Up @@ -263,13 +259,13 @@ impl TryFrom<&Vec<u8>> for AccountState {
}
}

impl TryFrom<(&AccountResource, &DiemAccountResource, &BalanceResource)> for AccountState {
impl TryFrom<(&AccountResource, &AptosAccountResource, &BalanceResource)> for AccountState {
type Error = Error;

fn try_from(
(account_resource, diem_account_resource, balance_resource): (
&AccountResource,
&DiemAccountResource,
&AptosAccountResource,
&BalanceResource,
),
) -> Result<Self> {
Expand All @@ -279,7 +275,7 @@ impl TryFrom<(&AccountResource, &DiemAccountResource, &BalanceResource)> for Acc
bcs::to_bytes(account_resource)?,
);
btree_map.insert(
DiemAccountResource::resource_path(),
AptosAccountResource::resource_path(),
bcs::to_bytes(diem_account_resource)?,
);
btree_map.insert(
Expand Down
12 changes: 6 additions & 6 deletions types/src/account_state_blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
account_config::{AccountResource, BalanceResource, DiemAccountResource},
account_config::{AccountResource, AptosAccountResource, BalanceResource},
account_state::AccountState,
state_store::state_value::StateValue,
};
Expand Down Expand Up @@ -110,13 +110,13 @@ impl TryFrom<StateValue> for AccountStateBlob {
}
}

impl TryFrom<(&AccountResource, &DiemAccountResource, &BalanceResource)> for AccountStateBlob {
impl TryFrom<(&AccountResource, &AptosAccountResource, &BalanceResource)> for AccountStateBlob {
type Error = Error;

fn try_from(
(account_resource, diem_account_resource, balance_resource): (
&AccountResource,
&DiemAccountResource,
&AptosAccountResource,
&BalanceResource,
),
) -> Result<Self> {
Expand All @@ -128,13 +128,13 @@ impl TryFrom<(&AccountResource, &DiemAccountResource, &BalanceResource)> for Acc
}
}

impl TryFrom<&AccountStateBlob> for DiemAccountResource {
impl TryFrom<&AccountStateBlob> for AptosAccountResource {
type Error = Error;

fn try_from(account_state_blob: &AccountStateBlob) -> Result<Self> {
AccountState::try_from(account_state_blob)?
.get_diem_account_resource()?
.ok_or_else(|| anyhow!("DiemAccountResource not found."))
.ok_or_else(|| anyhow!("AptosAccountResource not found."))
}
}

Expand All @@ -158,7 +158,7 @@ impl CryptoHash for AccountStateBlob {

#[cfg(any(test, feature = "fuzzing"))]
prop_compose! {
fn account_state_blob_strategy()(account_resource in any::<AccountResource>(), diem_account_resource in any::<DiemAccountResource>(), balance_resource in any::<BalanceResource>()) -> AccountStateBlob {
fn account_state_blob_strategy()(account_resource in any::<AccountResource>(), diem_account_resource in any::<AptosAccountResource>(), balance_resource in any::<BalanceResource>()) -> AccountStateBlob {
AccountStateBlob::try_from((&account_resource, &diem_account_resource, &balance_resource)).unwrap()
}
}
Expand Down
Loading

0 comments on commit 72e5018

Please sign in to comment.