Migrating from Scrypto v0.8.0 to v0.9.0

Scrypto Changes

Refactored the traits you have to implement on custom struct

Deriving ScryptoEncode, ScryptoDecode, ScryptoDescribe, and ScryptoCategorize can now be replaced with deriving ScryptoSbor.

Similarly, Encode, Decode, Categorize, and Describe can be replaced with deriving Sbor.

LegacyDescribe has now been removed.

Renamed Account Component methods

v0.8

v0.9

withdraw_by_amount

withdraw

withdraw_by_ids

withdraw_non_fungibles

lock_fee_and_withdraw_by_amount

lock_fee_and_withdraw

lock_fee_and_withdraw_by_ids

lock_fee_and_withdraw_non_fungibles

withdraw method has been removed.

Changed syntax for creating NonFungible resource

Creating a non-fungible resource now require specifying the NonFungibleData struct:

#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
    pub name: String,
    #[mutable]
    pub flag: bool,
}

{
    ResourceBuilder::new_uuid_non_fungible::<NFData>()
    ...
}

Changed argument parameters for updating NonFungibleData

Updating NonFungibleData using .update_non_fungible_data with the ResourceManager now updates one field at a time.

#[derive(ScryptoSbor, NonFungibleData)]
pub struct Sandwich {
    pub name: String,
    #[mutable]
    pub available: bool,
}

borrow_resource_manager!(resource_address).update_non_fungible_data(
     non_fungible_local_id,
     "available",
     true,
);

Updated AccessRules

The syntax for creating AccessRules is now changed to AccessRulesConfig.

The component no longer has to be mutable to implement AccessRulesConfig.

AccessRules now represents the access rules module under a global component and AccessRulesConfig represents the actual access configuration (rules). Developers can use .access_rules() on a global component to get a reference to the AccessRules module and the call .set_method_auth() / .lock_method_auth()

Removed support for import! macro

Instead of import! you can use external_component!/external_blueprint!

Added support for application events in Scrypto

You can now register and emit events directly from Scrypto.

use scrypto::prelude::*;

#[derive(ScryptoSbor, ScryptoEvent)]
struct RegisteredEvent {
    number: u64,
}

#[blueprint]
#[events(RegisteredEvent)]
mod scrypto_events {
    struct ScryptoEvents;

    impl ScryptoEvents {
        pub fn emit_registered_event(number: u64) {
            Runtime::emit_event(RegisteredEvent { number });
        }
    }
}

Blueprint macro now expects an optional #[events(…​)] attribute for the event registration. Multiple attributes could be provided to add more events. I.e:

#[blueprint]
#[event(NewUserEvent, UserIsNoMoreEvent, UserIsUserEvent)]
mod blueprint {
	struct Club {}
	impl Club {}
}

Added drop_empty method to buckets

You can now use .drop_empty() on buckets.

Transaction Manifest

Replaced types for addresses

Dropped support for PackageAddress, ComponentAddress, and ResourceAddress. Instead for address types, you can now use Address for all three. I.e what used to be ComponentAddress("component_address") is now just Address("component_address"). Likewise for the other address types.

Added new instructions

  • CLEAR_SIGNATURE_PROOFS removes all signature proofs in the auth zone.

  • CLEAR_AUTH_ZONE removes all signature proofs and regular proofs in the auth zone;

  • DROP_ALL_PROOFS removes all named proofs in the call frame, and then calls CLEAR_AUTH_ZONE.

The syntax for these instructions are detailed in the Transaction Manifest Specification.

Changed instruction for creation of Account, Identity, Validator, and Package

The syntax for these instructions are detailed in the Transaction Manifest Specification.

Changed the order of the argument parameters for Account Component methods

As a result of changes in the Account Component methods dropped support for PackageAddress, ComponentAddress, and ResourceAddress` in the manifest, the order of the argument parameters have changed.

I.e what used to be:

CALL_METHOD
  ComponentAddress("[your_account_address]")
  "withdraw_by_amount"
  Decimal("10")
  ResourceAddress("[xrd_address]");

is now:

CALL_METHOD
  Address("[your_account_address]")
  "withdraw"
  Address("[xrd_address]")
  Decimal("10");