File tree Expand file tree Collapse file tree
packages/world-modules/src/modules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,3 +33,23 @@ function registerERC20(
3333 // Return the newly created ERC20 token
3434 token = IERC20Mintable (ERC20Registry .get (ERC20_REGISTRY_TABLE_ID , WorldResourceIdLib.encodeNamespace (namespace)));
3535}
36+
37+ /**
38+ * @notice Register a new ERC20 token with the given metadata in a given namespace
39+ * @dev This function must be called within a Store context (i.e. using StoreSwitch.setStoreAddress())
40+ */
41+ function registerERC20Strict (
42+ IBaseWorld world ,
43+ bytes14 namespace ,
44+ ERC20MetadataData memory metadata
45+ ) returns (IERC20Mintable token ) {
46+ // Get the ERC20 module
47+ ERC20Module erc20Module = ERC20Module (NamespaceOwner.get (MODULE_NAMESPACE_ID));
48+ require (address (erc20Module) != address (0 ), "ERC20Module not installed " );
49+
50+ // Install the ERC20 module with the provided args
51+ world.installModule (erc20Module, abi.encode (namespace, metadata));
52+
53+ // Return the newly created ERC20 token
54+ token = IERC20Mintable (ERC20Registry .get (ERC20_REGISTRY_TABLE_ID , WorldResourceIdLib.encodeNamespace (namespace)));
55+ }
Original file line number Diff line number Diff line change @@ -35,3 +35,23 @@ function registerERC721(
3535 // Return the newly created ERC721 token
3636 token = IERC721Mintable (ERC721Registry .get (ERC721_REGISTRY_TABLE_ID , WorldResourceIdLib.encodeNamespace (namespace)));
3737}
38+
39+ /**
40+ * @notice Register a new ERC721 token with the given metadata in a given namespace
41+ * @dev This function must be called within a Store context (i.e. using StoreSwitch.setStoreAddress())
42+ */
43+ function registerERC721Strict (
44+ IBaseWorld world ,
45+ bytes14 namespace ,
46+ ERC721MetadataData memory metadata
47+ ) returns (IERC721Mintable token ) {
48+ // Get the ERC721 module
49+ ERC721Module erc721Module = ERC721Module (NamespaceOwner.get (MODULE_NAMESPACE_ID));
50+ require (address (erc721Module) != address (0 ), "ERC721Module not installed " );
51+
52+ // Install the ERC721 module with the provided args
53+ world.installModule (erc721Module, abi.encode (namespace, metadata));
54+
55+ // Return the newly created ERC721 token
56+ token = IERC721Mintable (ERC721Registry .get (ERC721_REGISTRY_TABLE_ID , WorldResourceIdLib.encodeNamespace (namespace)));
57+ }
You can’t perform that action at this time.
0 commit comments