FuelLabs / sway-libs

Miscellaneous Sway libraries.
https://docs.fuel.network/docs/sway-libs/
Apache License 2.0
146 stars 61 forks source link

Release v0.24.0 #292

Closed bitzoic closed 2 months ago

bitzoic commented 2 months ago

Type of change

[Version 0.24.0]

Added v0.24.0

Changed v0.24.0

Breaking v0.24.0

The following demonstrates the breaking change.

Before:

// Compute bytecode root
let root_no_configurables: BytecodeRoot = compute_bytecode_root(my_bytecode);
let root_with_configurables: BytecodeRoot = compute_bytecode_root_with_configurables(my_bytecode, my_configurables);

// Compute predicate address
let address_no_configurables: Address = compute_predicate_address(my_bytecode);
let address_with_configurables: Address = compute_predicate_address_with_configurables(my_bytecode, my_configurables);

// Verify contract bytecode
verify_contract_bytecode(my_contract_id, my_bytecode); // No configurables
verify_contract_bytecode_with_configurables(my_contract_id, my_bytecode, my_configurables); // With configurables

// Verify predicate address
verify_predicate_address(my_predicate_address, my_bytecode); // No configurables
verify_predicate_address_with_configurables(my_predicate_address, my_bytecode, my_configurables); // With configurables

After:

// Compute bytecode root
let root_no_configurables: BytecodeRoot = compute_bytecode_root(my_bytecode, None);
let root_with_configurables: BytecodeRoot = compute_bytecode_root(my_bytecode, Some(my_configurables));

// Compute predicate address
let address_no_configurables: Address = compute_predicate_address(my_bytecode, None);
let address_with_configurables: Address = compute_predicate_address(my_bytecode, Some(my_configurables));

// Verify contract bytecode
verify_contract_bytecode(my_contract_id, my_bytecode, None); // No configurables
verify_contract_bytecode(my_contract_id, my_bytecode, Some(my_configurables)); // With configurables

// Verify predicate address
verify_predicate_address(my_predicate_address, my_bytecode, None); // No configurables
verify_predicate_address(my_predicate_address, my_bytecode, Some(my_configurables)); // With configurables

Before:

use sway_libs::asset::metadata::*;

fn foo(my_metadata: Metadata) {
     let res: bool = my_metadata.is_b256(); 
     let res: bool = my_metadata.is_string(); 
     let res: bool = my_metadata.is_bytes(); 
     let res: bool = my_metadata.is_uint();
}

After:

use standards::src7::*;

fn foo(my_metadata: Metadata) {
     let res: bool = my_metadata.is_b256(); 
     let res: bool = my_metadata.is_string(); 
     let res: bool = my_metadata.is_bytes(); 
     let res: bool = my_metadata.is_uint();
}

Before:

abi SetAssetMetadata {
    #[storage(read, write)]
    fn set_metadata(asset: AssetId, key: String, metadata: Metadata);
}

After:

abi SetAssetMetadata {
    #[storage(read, write)]
    fn set_metadata(asset: AssetId, metadata: Option<Metadata>, key: String);
}

Before:

fn foo(asset: AssetId, recipient: Identity, amount: u64, key: String, metadata: Metadata) {
    _set_name(storage.name, asset, String::from_ascii_str("Ether"));
    _set_symbol(storage.symbol, asset, String::from_ascii_str("ETH"));
    _mint(storage.total_assets, storage.total_supply, recipient, SubId::zero(), amount);
    _set_metadata(storage.metadata, asset, key, metadata);
}

After:

fn foo(asset: AssetId, recipient: Identity, amount: u64, metadata: Metadata, key: String) {
    _set_name(storage.name, asset, Some(String::from_ascii_str("Ether")));
    _set_symbol(storage.symbol, asset, Some(String::from_ascii_str("ETH")));
    _mint(storage.total_assets, storage.total_supply, recipient, Some(SubId::zero()), amount);
    // Note: Ordering of arguments has changed for `_set_metadata()`
    _set_metadata(storage.metadata, asset, Some(metadata), key);
}

Before:

fn foo() {
    let stored_proxy_owner = _proxy_owner(storage.proxy_owner);
    only_proxy_owner(storage.proxy_owner);
    _set_proxy_owner(new_proxy_owner, storage.proxy_owner);
}

After:

fn foo() {
    let stored_proxy_owner = _proxy_owner();
    only_proxy_owner();
    _set_proxy_owner(new_proxy_owner);
}
bitzoic commented 2 months ago

Closing for now and will reopen