diff --git a/docs/modules/ROOT/pages/api/introspection.adoc b/docs/modules/ROOT/pages/api/introspection.adoc index 91def5579..e8dba8149 100644 --- a/docs/modules/ROOT/pages/api/introspection.adoc +++ b/docs/modules/ROOT/pages/api/introspection.adoc @@ -66,6 +66,7 @@ SRC5 component extending xref:ISRC5[`ISRC5`]. .InternalImpl * xref:#SRC5Component-register_interface[`++register_interface(self, interface_id)++`] +* xref:#SRC5Component-register_interfaces[`++register_interfaces(self, interface_ids)++`] * xref:#SRC5Component-deregister_interface[`++deregister_interface(self, interface_id)++`] -- @@ -87,6 +88,12 @@ See xref:ISRC5-supports_interface[`ISRC5::supports_interface`]. Registers support for the given `interface_id`. +[.contract-item] +[[SRC5Component-register_interfaces]] +==== `[.contract-item-name]#++register_interfaces++#++(ref self: ComponentState, interface_ids: Span)++` [.item-kind]#internal# + +Registers support for the given `interface_ids`. + [.contract-item] [[SRC5Component-deregister_interface]] ==== `[.contract-item-name]#++deregister_interface++#++(ref self: ComponentState, interface_id: felt252)++` [.item-kind]#internal# diff --git a/docs/modules/ROOT/pages/guides/src5-migration.adoc b/docs/modules/ROOT/pages/guides/src5-migration.adoc index 71f436189..71781763a 100644 --- a/docs/modules/ROOT/pages/guides/src5-migration.adoc +++ b/docs/modules/ROOT/pages/guides/src5-migration.adoc @@ -71,7 +71,7 @@ mod MigratingContract { } ---- -The contract will also need to register the interface ID values in order to continue declaring support for those interfaces. +The contract will also need to register the new SRC5 interface IDs in order to continue declaring support for those interfaces. We can create a migration initializer to handle this which needs to be called after the contract upgrade. TIP: OpenZeppelin's Contracts for Cairo already provides the interface IDs of common interfaces in the API section (like {isrc6}). @@ -85,30 +85,13 @@ mod MigratingContract { (...) #[external(v0)] - fn initialize_src5_migration(ref self: ContractState, interface_ids: Span) { + fn migration_initializer(ref self: ContractState, interface_ids: Span) { // Add permissions mechanism - self.register_interfaces(interface_ids); - } - - #[generate_trait] - impl InternalImpl of InternalTrait { - fn register_interfaces(ref self: ContractState, mut interface_ids: Span) { - loop { - if interface_ids.len() == 0 { - break; - } - - let id = *interface_ids.pop_front().unwrap(); - self.src5.register_interface(id); - } - } + self.src5.register_interfaces(interface_ids); } } ---- -Note that SRC5 interface IDs are calculated differently than those in ERC165. -Because of this, contracts that leverage introspection (like ERC721) will also need to be upgraded in order to query the correct interface IDs. - -Deployed contracts with upgradeability should also be carefully tested before migrating. +Note that deployed contracts with upgradeability should also be carefully tested before migrating. Upgradeable contracts will likely include some form of a permissions mechanism for upgrading contracts. Take extreme care with ensuring admins are not inadvertantly stripped of their permissions.