move-language / move

Apache License 2.0
2.24k stars 677 forks source link

[Bug] Unable to generate ABI when feature address20 or feature address32 is enabled. #1033

Open jewelzms opened 1 year ago

jewelzms commented 1 year ago

🐛 Bug

To reproduce

Install move-cli Unable to generate ABI when feature address20 or feature address32 is enabled.

# cargo install --features address20 --path language/tools/move-cli

build move contract No ABI is generated when building, nor are there any error messages.

# move build --abi

Reason

Module type judgment logic error.

Error code segment

// language/move-model/src/ast.rs
pub fn is_script(&self) -> bool {
    static MAX_ADDR: Lazy<BigUint> = Lazy::new(|| {
        BigUint::from_str_radix("ffffffffffffffffffffffffffffffff", 16).expect("valid hex")
    });
    self.0 == *MAX_ADDR
}

Fix suggestion

// language/move-model/src/ast.rs
pub fn is_script(&self) -> bool {
    static MAX_ADDR: Lazy<BigUint> = Lazy::new(|| {
        use move_core_types::account_address::AccountAddress;
        BigUint::from_bytes_be(&[0xff; AccountAddress::LENGTH].to_vec())
    });
    self.0 == *MAX_ADDR
}