Skip to content

Commit 824551e

Browse files
majectyjoojis
authored andcommitted
Remove all "master" from CodeChain
We use "owner" instead of "master"
1 parent 9d66dbd commit 824551e

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

state/src/impls/top_level.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ impl TopLevelState {
355355
fee_payer: &Address,
356356
fee_payer_public: &Public,
357357
) -> StateResult<ParcelInvoice> {
358-
// Change the address to a master address if it is a regular key.
358+
// Change the address to an owner address if it is a regular key.
359359
let fee_payer = if self.regular_account_exists_and_not_null(fee_payer)? {
360360
let regular_account = self.require_regular_account_from_address(fee_payer)?;
361361
public_to_address(&regular_account.owner_public())
@@ -764,16 +764,16 @@ impl TopState<StateDB> for TopLevelState {
764764
Ok(())
765765
}
766766

767-
fn set_regular_key(&mut self, master_public: &Public, regular_key: &Public) -> StateResult<()> {
768-
let master_address = public_to_address(master_public);
767+
fn set_regular_key(&mut self, owner_public: &Public, regular_key: &Public) -> StateResult<()> {
768+
let owner_address = public_to_address(owner_public);
769769

770-
let (master_public, master_address) = if self.regular_account_exists_and_not_null(&master_address)? {
771-
let regular_account = self.require_regular_account_from_address(&master_address)?;
772-
let master_public = regular_account.owner_public().clone();
773-
let master_address = public_to_address(&master_public);
774-
(master_public, master_address)
770+
let (owner_public, owner_address) = if self.regular_account_exists_and_not_null(&owner_address)? {
771+
let regular_account = self.require_regular_account_from_address(&owner_address)?;
772+
let owner_public = regular_account.owner_public().clone();
773+
let owner_address = public_to_address(&owner_public);
774+
(owner_public, owner_address)
775775
} else {
776-
(*master_public, public_to_address(&master_public))
776+
(*owner_public, public_to_address(&owner_public))
777777
};
778778

779779
let regular_address = public_to_address(regular_key);
@@ -782,18 +782,18 @@ impl TopState<StateDB> for TopLevelState {
782782
}
783783

784784
if self.account_exists_and_not_null(&regular_address)? {
785-
return Err(ParcelError::RegularKeyAlreadyInUseAsMaster.into())
785+
return Err(ParcelError::RegularKeyAlreadyInUseAsPlatformAccount.into())
786786
}
787787

788-
let prev_regular_key = self.require_account(&master_address)?.regular_key();
788+
let prev_regular_key = self.require_account(&owner_address)?.regular_key();
789789

790790
if let Some(prev_regular_key) = prev_regular_key {
791791
self.kill_regular_account(&prev_regular_key);
792792
}
793793

794-
let mut master_account = self.require_account(&master_address)?;
795-
master_account.set_regular_key(regular_key);
796-
self.require_regular_account(&regular_key)?.set_owner_public(&master_public);
794+
let mut owner_account = self.require_account(&owner_address)?;
795+
owner_account.set_regular_key(regular_key);
796+
self.require_regular_account(&regular_key)?.set_owner_public(&owner_public);
797797
Ok(())
798798
}
799799

@@ -1346,7 +1346,7 @@ mod tests_parcel {
13461346
}
13471347

13481348
#[test]
1349-
fn use_master_balance_when_signed_with_regular_key() {
1349+
fn use_owner_balance_when_signed_with_regular_key() {
13501350
let mut state = get_temp_state();
13511351
let regular_keypair = Random.generate().unwrap();
13521352
let key = regular_keypair.public();
@@ -1419,7 +1419,7 @@ mod tests_parcel {
14191419
}
14201420

14211421
#[test]
1422-
fn fail_when_regular_key_is_already_registered_as_master_key() {
1422+
fn fail_when_regular_key_is_already_registered_as_owner_key() {
14231423
let (sender, sender_public) = address();
14241424
let (sender2, sender_public2) = address();
14251425

@@ -1438,7 +1438,7 @@ mod tests_parcel {
14381438
};
14391439

14401440
let result = state.apply(&parcel, &sender, &sender_public);
1441-
assert_eq!(Err(StateError::Parcel(ParcelError::RegularKeyAlreadyInUseAsMaster)), result);
1441+
assert_eq!(Err(StateError::Parcel(ParcelError::RegularKeyAlreadyInUseAsPlatformAccount)), result);
14421442
}
14431443

14441444
#[test]
@@ -1558,7 +1558,7 @@ mod tests_parcel {
15581558
}
15591559

15601560
#[test]
1561-
fn use_deleted_regular_key_as_master_key() {
1561+
fn use_deleted_regular_key_as_owner_key() {
15621562
let (sender, sender_public) = address();
15631563
let (regular_address, regular_public) = address();
15641564
let (_, regular_public2) = address();

state/src/item/regular_account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ impl RegularAccount {
3636
&self.owner_public
3737
}
3838

39-
pub fn set_owner_public(&mut self, master_public: &Public) {
40-
self.owner_public = *master_public;
39+
pub fn set_owner_public(&mut self, owner_public: &Public) {
40+
self.owner_public = *owner_public;
4141
}
4242
}
4343

state/src/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ where
102102
/// Increment the nonce of account `a` by 1.
103103
fn inc_nonce(&mut self, a: &Address) -> TrieResult<()>;
104104

105-
/// Set the regular key of account `master_public`
106-
fn set_regular_key(&mut self, master_public: &Public, key: &Public) -> StateResult<()>;
105+
/// Set the regular key of account `owner_public`
106+
fn set_regular_key(&mut self, owner_public: &Public, key: &Public) -> StateResult<()>;
107107

108108
fn create_shard(&mut self, shard_creation_cost: &U256, fee_payer: &Address) -> StateResult<()>;
109109
fn change_shard_owners(&mut self, shard_id: ShardId, owners: &[Address], sender: &Address) -> StateResult<()>;

types/src/parcel/error.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub enum Error {
7272
InconsistentShardOutcomes,
7373
ParcelsTooBig,
7474
RegularKeyAlreadyInUse,
75-
RegularKeyAlreadyInUseAsMaster,
75+
RegularKeyAlreadyInUseAsPlatformAccount,
7676
InvalidTransferDestination,
7777
/// Transaction error
7878
InvalidTransaction(TransactionError),
@@ -96,7 +96,7 @@ const ERROR_ID_INVALID_SIGNATURE: u8 = 14u8;
9696
const ERROR_ID_INCONSISTENT_SHARD_OUTCOMES: u8 = 15u8;
9797
const ERROR_ID_PARCELS_TOO_BIG: u8 = 16u8;
9898
const ERROR_ID_REGULAR_KEY_ALREADY_IN_USE: u8 = 17u8;
99-
const ERROR_ID_REGULAR_KEY_ALREADY_IN_USE_AS_MASTER: u8 = 18u8;
99+
const ERROR_ID_REGULAR_KEY_ALREADY_IN_USE_AS_PLATFORM: u8 = 18u8;
100100
const ERROR_ID_INVALID_TRANSFER_DESTINATION: u8 = 19u8;
101101
const ERROR_ID_INVALID_TRANSACTION: u8 = 20u8;
102102
const ERROR_ID_INSUFFICIENT_PERMISSION: u8 = 21u8;
@@ -133,8 +133,8 @@ impl Encodable for Error {
133133
Error::InconsistentShardOutcomes => s.begin_list(1).append(&ERROR_ID_INCONSISTENT_SHARD_OUTCOMES),
134134
Error::ParcelsTooBig => s.begin_list(1).append(&ERROR_ID_PARCELS_TOO_BIG),
135135
Error::RegularKeyAlreadyInUse => s.begin_list(1).append(&ERROR_ID_REGULAR_KEY_ALREADY_IN_USE),
136-
Error::RegularKeyAlreadyInUseAsMaster => {
137-
s.begin_list(1).append(&ERROR_ID_REGULAR_KEY_ALREADY_IN_USE_AS_MASTER)
136+
Error::RegularKeyAlreadyInUseAsPlatformAccount => {
137+
s.begin_list(1).append(&ERROR_ID_REGULAR_KEY_ALREADY_IN_USE_AS_PLATFORM)
138138
}
139139
Error::InvalidTransferDestination => s.begin_list(1).append(&ERROR_ID_INVALID_TRANSFER_DESTINATION),
140140
Error::InvalidTransaction(err) => s.begin_list(2).append(&ERROR_ID_INVALID_TRANSACTION).append(err),
@@ -174,7 +174,7 @@ impl Decodable for Error {
174174
ERROR_ID_INCONSISTENT_SHARD_OUTCOMES => Error::InconsistentShardOutcomes,
175175
ERROR_ID_PARCELS_TOO_BIG => Error::ParcelsTooBig,
176176
ERROR_ID_REGULAR_KEY_ALREADY_IN_USE => Error::RegularKeyAlreadyInUse,
177-
ERROR_ID_REGULAR_KEY_ALREADY_IN_USE_AS_MASTER => Error::RegularKeyAlreadyInUseAsMaster,
177+
ERROR_ID_REGULAR_KEY_ALREADY_IN_USE_AS_PLATFORM => Error::RegularKeyAlreadyInUseAsPlatformAccount,
178178
ERROR_ID_INVALID_TRANSFER_DESTINATION => Error::InvalidTransferDestination,
179179
ERROR_ID_INVALID_TRANSACTION => Error::InvalidTransaction(rlp.val_at(1)?),
180180
ERROR_ID_INSUFFICIENT_PERMISSION => Error::InsufficientPermission,
@@ -213,7 +213,9 @@ impl Display for Error {
213213
Error::InconsistentShardOutcomes => "Shard outcomes are inconsistent".to_string(),
214214
Error::ParcelsTooBig => "Parcel size exceeded the body size limit".to_string(),
215215
Error::RegularKeyAlreadyInUse => "The regular key is already registered to another account".to_string(),
216-
Error::RegularKeyAlreadyInUseAsMaster => "The regular key is already used as a master account".to_string(),
216+
Error::RegularKeyAlreadyInUseAsPlatformAccount => {
217+
"The regular key is already used as a platform account".to_string()
218+
}
217219
Error::InvalidTransferDestination => "Transfer receiver is not valid account".to_string(),
218220
Error::InvalidTransaction(err) => format!("Parcel has an invalid transaction: {}", err).to_string(),
219221
Error::InsufficientPermission => "Sender doesn't have a permission".to_string(),

0 commit comments

Comments
 (0)