Skip to content

Commit

Permalink
merge name and address checking to id check
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjennings-mysten committed Jan 8, 2025
1 parent 0910ada commit 2cc791e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,14 @@ impl InclusionCheck {
) -> Result<(), M::Error> {
let mut context = M::default();

// Module checks
if old_module.name != new_module.name {
context.module_name_mismatch(&old_module.name, &new_module.name);
}

if old_module.address != new_module.address {
context.module_address_mismatch(&old_module.address, &new_module.address);
// module's name and address are unchanged
if old_module.address != new_module.address || old_module.name != new_module.name {
context.module_id_mismatch(
&old_module.address,
&old_module.name,
&new_module.address,
&new_module.name,
);
}

if old_module.file_format_version > new_module.file_format_version {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use crate::compatibility::InclusionCheck;
use crate::normalized::{Enum, Function, Struct};
use move_core_types::account_address::AccountAddress;
use move_core_types::identifier::Identifier;
use move_core_types::identifier::{IdentStr, Identifier};

pub trait InclusionCheckMode: Default {
type Error;
fn module_name_mismatch(&mut self, old_address: &Identifier, new_address: &Identifier);
fn module_id_mismatch(
&mut self,
old_address: &AccountAddress,
old_name: &IdentStr,
new_address: &AccountAddress,
new_name: &IdentStr,
);
fn module_address_mismatch(
&mut self,
old_address: &AccountAddress,
Expand Down Expand Up @@ -45,7 +51,13 @@ impl Default for InclusionCheckExecutionMode {
impl InclusionCheckMode for InclusionCheckExecutionMode {
type Error = ();

fn module_name_mismatch(&mut self, _old_address: &Identifier, _new_address: &Identifier) {
fn module_id_mismatch(
&mut self,
_old_address: &AccountAddress,
_old_name: &IdentStr,
_new_address: &AccountAddress,
_new_name: &IdentStr,
) {
self.is_subset = false;
self.is_equal = false;
}
Expand Down

0 comments on commit 2cc791e

Please sign in to comment.