-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds several utilities to catalog and catalog factory.
- Loading branch information
1 parent
1717da0
commit 9b215cc
Showing
9 changed files
with
682 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.8.21; | ||
|
||
import {RMRKCatalogImpl} from "./RMRKCatalogImpl.sol"; | ||
|
||
/** | ||
* @title RMRKCatalogFactory | ||
* @author RMRK team | ||
* @notice Smart contract to deploy catalog implementations and keep track of deployers. | ||
*/ | ||
contract RMRKCatalogFactory { | ||
mapping(address deployer => address[] catalogs) private _deployerCatalogs; | ||
|
||
event CatalogDeployed(address indexed deployer, address indexed catalog); | ||
|
||
/** | ||
* @notice Used to deploy a new RMRKCatalog implementation. | ||
* @param metadataURI Base metadata URI of the catalog | ||
* @param type_ The type of the catalog | ||
* @return The address of the deployed catalog | ||
*/ | ||
function deployCatalog( | ||
string memory metadataURI, | ||
string memory type_ | ||
) public returns (address) { | ||
RMRKCatalogImpl catalog = new RMRKCatalogImpl(metadataURI, type_); | ||
_deployerCatalogs[msg.sender].push(address(catalog)); | ||
emit CatalogDeployed(msg.sender, address(catalog)); | ||
return address(catalog); | ||
} | ||
|
||
/** | ||
* @notice Used to get all catalogs deployed by a given deployer. | ||
* @param deployer The address of the deployer | ||
* @return An array of addresses of the catalogs deployed by the deployer | ||
*/ | ||
function getDeployerCatalogs( | ||
address deployer | ||
) public view returns (address[] memory) { | ||
return _deployerCatalogs[deployer]; | ||
} | ||
|
||
/** | ||
* @notice Used to get the total number of catalogs deployed by a given deployer. | ||
* @param deployer The address of the deployer | ||
* @return total The total number of catalogs deployed by the deployer | ||
*/ | ||
function getTotalDeployerCatalogs( | ||
address deployer | ||
) public view returns (uint256 total) { | ||
total = _deployerCatalogs[deployer].length; | ||
} | ||
|
||
/** | ||
* @notice Used to get a catalog deployed by a given deployer at a given index. | ||
* @param deployer The address of the deployer | ||
* @param index The index of the catalog | ||
* @return catalogAddress The address of the catalog | ||
*/ | ||
function getDeployerCatalogAtIndex( | ||
address deployer, | ||
uint256 index | ||
) public view returns (address catalogAddress) { | ||
catalogAddress = _deployerCatalogs[deployer][index]; | ||
} | ||
|
||
/** | ||
* @notice Used to get the last catalog deployed by a given deployer. | ||
* @param deployer The address of the deployer | ||
* @return catalogAddress The address of the last catalog deployed by the deployer | ||
*/ | ||
function getLastDeployerCatalog( | ||
address deployer | ||
) public view returns (address catalogAddress) { | ||
catalogAddress = _deployerCatalogs[deployer][ | ||
_deployerCatalogs[deployer].length - 1 | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# console | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# RMRKCatalogFactory | ||
|
||
*RMRK team* | ||
|
||
> RMRKCatalogFactory | ||
Smart contract to deploy catalog implementations and keep track of deployers. | ||
|
||
|
||
|
||
## Methods | ||
|
||
### deployCatalog | ||
|
||
```solidity | ||
function deployCatalog(string metadataURI, string type_) external nonpayable returns (address) | ||
``` | ||
|
||
Used to deploy a new RMRKCatalog implementation. | ||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| metadataURI | string | Base metadata URI of the catalog | | ||
| type_ | string | The type of the catalog | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | address | The address of the deployed catalog | | ||
|
||
### getDeployerCatalogAtIndex | ||
|
||
```solidity | ||
function getDeployerCatalogAtIndex(address deployer, uint256 index) external view returns (address catalogAddress) | ||
``` | ||
|
||
Used to get a catalog deployed by a given deployer at a given index. | ||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| deployer | address | The address of the deployer | | ||
| index | uint256 | The index of the catalog | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| catalogAddress | address | The address of the catalog | | ||
|
||
### getDeployerCatalogs | ||
|
||
```solidity | ||
function getDeployerCatalogs(address deployer) external view returns (address[]) | ||
``` | ||
|
||
Used to get all catalogs deployed by a given deployer. | ||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| deployer | address | The address of the deployer | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | address[] | An array of addresses of the catalogs deployed by the deployer | | ||
|
||
### getLastDeployerCatalog | ||
|
||
```solidity | ||
function getLastDeployerCatalog(address deployer) external view returns (address catalogAddress) | ||
``` | ||
|
||
Used to get the last catalog deployed by a given deployer. | ||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| deployer | address | The address of the deployer | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| catalogAddress | address | The address of the last catalog deployed by the deployer | | ||
|
||
### getTotalDeployerCatalogs | ||
|
||
```solidity | ||
function getTotalDeployerCatalogs(address deployer) external view returns (uint256 total) | ||
``` | ||
|
||
Used to get the total number of catalogs deployed by a given deployer. | ||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| deployer | address | The address of the deployer | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| total | uint256 | The total number of catalogs deployed by the deployer | | ||
|
||
|
||
|
||
## Events | ||
|
||
### CatalogDeployed | ||
|
||
```solidity | ||
event CatalogDeployed(address indexed deployer, address indexed catalog) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| deployer `indexed` | address | undefined | | ||
| catalog `indexed` | address | undefined | | ||
|
||
|
||
|
Oops, something went wrong.