-
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.
- Loading branch information
1 parent
20cffd5
commit ddf6113
Showing
6 changed files
with
598 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//SPDX-License-Identifier: Apache 2.0 | ||
|
||
pragma solidity ^0.8.18; | ||
|
||
interface IRMRKCollectionData { | ||
function totalSupply() external view returns (uint256); | ||
|
||
function maxSupply() external view returns (uint256); | ||
|
||
function getRoyaltyPercentage() external view returns (uint256); | ||
|
||
function getRoyaltyRecipient() external view returns (address); | ||
|
||
function owner() external view returns (address); | ||
|
||
function name() external view returns (string memory); | ||
|
||
function symbol() external view returns (string memory); | ||
|
||
function collectionMetadata() external view returns (string memory); | ||
} |
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,131 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.8.18; | ||
|
||
import "@openzeppelin/contracts/interfaces/IERC2981.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; | ||
import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; | ||
import "../equippable/IERC6220.sol"; | ||
import "../nestable/IERC6059.sol"; | ||
import "../extension/soulbound/IERC6454.sol"; | ||
import "./IRMRKCollectionData.sol"; | ||
|
||
/** | ||
* @title RMRKCollectionUtils | ||
* @author RMRK team | ||
* @notice Smart contract of the RMRK Collection utils module. | ||
* @dev Extra utility functions for RMRK contracts. | ||
*/ | ||
contract RMRKCollectionUtils { | ||
/** | ||
* notice Structure used to represent the collection data. | ||
* @return totalSupply The total supply of the collection | ||
* @return maxSupply The maximum supply of the collection | ||
* @return royaltyPercentage The royalty percentage of the collection | ||
* @return royaltyRecipient The address of the royalty recipient | ||
* @return owner The address of the owner of the collection | ||
* @return name The name of the collection | ||
* @return symbol The symbol of the collection | ||
* @return collectionMetadata The metadata of the collection | ||
*/ | ||
struct CollectionData { | ||
uint256 totalSupply; | ||
uint256 maxSupply; | ||
uint256 royaltyPercentage; | ||
address royaltyRecipient; | ||
address owner; | ||
string name; | ||
string symbol; | ||
string collectionMetadata; | ||
} | ||
|
||
/** | ||
* @notice Used to get the collection data of a specified collection. | ||
* @dev The full `CollectionData` struct looks like this: | ||
* [ | ||
* totalSupply, | ||
* maxSupply, | ||
* royaltyPercentage, | ||
* royaltyRecipient, | ||
* owner, | ||
* symbol, | ||
* name, | ||
* collectionMetadata | ||
* ] | ||
* @param collection Address of the collection to get the data from | ||
* @return data Collection data struct containing the collection data | ||
*/ | ||
function getCollectionData( | ||
address collection | ||
) public view returns (CollectionData memory data) { | ||
IRMRKCollectionData target = IRMRKCollectionData(collection); | ||
|
||
try target.totalSupply() returns (uint256 totalSupply) { | ||
data.totalSupply = totalSupply; | ||
} catch {} | ||
try target.maxSupply() returns (uint256 maxSupply) { | ||
data.maxSupply = maxSupply; | ||
} catch {} | ||
try target.getRoyaltyPercentage() returns (uint256 royaltyPercentage) { | ||
data.royaltyPercentage = royaltyPercentage; | ||
} catch {} | ||
try target.getRoyaltyRecipient() returns (address royaltyRecipient) { | ||
data.royaltyRecipient = royaltyRecipient; | ||
} catch {} | ||
try target.owner() returns (address owner) { | ||
data.owner = owner; | ||
} catch {} | ||
try target.name() returns (string memory name) { | ||
data.name = name; | ||
} catch {} | ||
try target.symbol() returns (string memory symbol) { | ||
data.symbol = symbol; | ||
} catch {} | ||
try target.collectionMetadata() returns ( | ||
string memory collectionMetadata | ||
) { | ||
data.collectionMetadata = collectionMetadata; | ||
} catch {} | ||
} | ||
|
||
/** | ||
* @notice Used to get the interface support of a specified collection. | ||
* @param collection Address of the collection to get the interface support from | ||
* @return supports721 Boolean value signifying whether the collection supports ERC721 interface | ||
* @return supportsMultiAsset Boolean value signifying whether the collection supports MultiAsset interface (ERC5773) | ||
* @return supportsNesting Boolean value signifying whether the collection supports Nestable interface (ERC6059) | ||
* @return supportsEquippable Boolean value signifying whether the collection supports Equippable interface (ERC6220) | ||
* @return supportsSoulbound Boolean value signifying whether the collection supports Soulbound interface (ERC6454) | ||
* @return supportsRoyalties Boolean value signifying whether the collection supports Royaltiesy interface (ERC2981) | ||
*/ | ||
function getInterfaceSupport( | ||
address collection | ||
) | ||
public | ||
view | ||
returns ( | ||
bool supports721, | ||
bool supportsMultiAsset, | ||
bool supportsNesting, | ||
bool supportsEquippable, | ||
bool supportsSoulbound, | ||
bool supportsRoyalties | ||
) | ||
{ | ||
IERC165 target = IERC165(collection); | ||
supports721 = target.supportsInterface(type(IERC721).interfaceId); | ||
supportsMultiAsset = target.supportsInterface( | ||
type(IERC5773).interfaceId | ||
); | ||
supportsNesting = target.supportsInterface(type(IERC6059).interfaceId); | ||
supportsEquippable = target.supportsInterface( | ||
type(IERC6220).interfaceId | ||
); | ||
supportsSoulbound = target.supportsInterface( | ||
type(IERC6454).interfaceId | ||
); | ||
supportsRoyalties = target.supportsInterface( | ||
type(IERC2981).interfaceId | ||
); | ||
} | ||
} |
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,151 @@ | ||
# IRMRKCollectionData | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Methods | ||
|
||
### collectionMetadata | ||
|
||
```solidity | ||
function collectionMetadata() external view returns (string) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | string | undefined | | ||
|
||
### getRoyaltyPercentage | ||
|
||
```solidity | ||
function getRoyaltyPercentage() external view returns (uint256) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | uint256 | undefined | | ||
|
||
### getRoyaltyRecipient | ||
|
||
```solidity | ||
function getRoyaltyRecipient() external view returns (address) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | address | undefined | | ||
|
||
### maxSupply | ||
|
||
```solidity | ||
function maxSupply() external view returns (uint256) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | uint256 | undefined | | ||
|
||
### name | ||
|
||
```solidity | ||
function name() external view returns (string) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | string | undefined | | ||
|
||
### owner | ||
|
||
```solidity | ||
function owner() external view returns (address) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | address | undefined | | ||
|
||
### symbol | ||
|
||
```solidity | ||
function symbol() external view returns (string) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | string | undefined | | ||
|
||
### totalSupply | ||
|
||
```solidity | ||
function totalSupply() external view returns (uint256) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| _0 | uint256 | undefined | | ||
|
||
|
||
|
||
|
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,64 @@ | ||
# RMRKCollectionUtils | ||
|
||
*RMRK team* | ||
|
||
> RMRKCollectionUtils | ||
Smart contract of the RMRK Collection utils module. | ||
|
||
*Extra utility functions for RMRK contracts.* | ||
|
||
## Methods | ||
|
||
### getCollectionData | ||
|
||
```solidity | ||
function getCollectionData(address collection) external view returns (struct RMRKCollectionUtils.CollectionData data) | ||
``` | ||
|
||
Used to get the collection data of a specified collection. | ||
|
||
*The full `CollectionData` struct looks like this: [ totalSupply, maxSupply, royaltyPercentage, royaltyRecipient, owner, symbol, name, collectionMetadata ]* | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| collection | address | Address of the collection to get the data from | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| data | RMRKCollectionUtils.CollectionData | Collection data struct containing the collection data | | ||
|
||
### getInterfaceSupport | ||
|
||
```solidity | ||
function getInterfaceSupport(address collection) external view returns (bool supports721, bool supportsMultiAsset, bool supportsNesting, bool supportsEquippable, bool supportsSoulbound, bool supportsRoyalties) | ||
``` | ||
|
||
Used to get the interface support of a specified collection. | ||
|
||
|
||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| collection | address | Address of the collection to get the interface support from | | ||
|
||
#### Returns | ||
|
||
| Name | Type | Description | | ||
|---|---|---| | ||
| supports721 | bool | Boolean value signifying whether the collection supports ERC721 interface | | ||
| supportsMultiAsset | bool | Boolean value signifying whether the collection supports MultiAsset interface (ERC5773) | | ||
| supportsNesting | bool | Boolean value signifying whether the collection supports Nestable interface (ERC6059) | | ||
| supportsEquippable | bool | Boolean value signifying whether the collection supports Equippable interface (ERC6220) | | ||
| supportsSoulbound | bool | Boolean value signifying whether the collection supports Soulbound interface (ERC6454) | | ||
| supportsRoyalties | bool | Boolean value signifying whether the collection supports Royaltiesy interface (ERC2981) | | ||
|
||
|
||
|
||
|
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,28 @@ | ||
import { ethers, run } from 'hardhat'; | ||
|
||
export const sleep = (ms: number): Promise<void> => { | ||
return new Promise((resolve) => { | ||
setTimeout(() => resolve(), ms); | ||
}); | ||
}; | ||
|
||
async function main() { | ||
// We get the contract to deploy | ||
const collectionUtilsFactory = await ethers.getContractFactory('RMRKCollectionUtils'); | ||
const collectionUtils = await collectionUtilsFactory.deploy(); | ||
await collectionUtils.deployed(); | ||
console.log('RMRK Collection Utils deployed to:', collectionUtils.address); | ||
await sleep(1000); | ||
|
||
await run('verify:verify', { | ||
address: collectionUtils.address, | ||
constructorArguments: [], | ||
}); | ||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
Oops, something went wrong.