Skip to content

Commit

Permalink
Unified contributor management
Browse files Browse the repository at this point in the history
Two methods to manage the contributor role have been merged into a
single one. The change was propagated to relevant tests.

(cherry picked from commit 8633a0c)
  • Loading branch information
ThunderDeliverer committed Jan 17, 2023
1 parent d56ebe0 commit 6aef40d
Show file tree
Hide file tree
Showing 29 changed files with 431 additions and 794 deletions.
25 changes: 11 additions & 14 deletions contracts/RMRK/access/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,21 @@ contract Ownable is Context {
}

/**
* @notice Adds a contributor to the smart contract.
* @notice Adds or removes a contributor to the smart contract.
* @dev Can only be called by the owner.
* @param contributor Address of the contributor's account
* @param grantRole A boolean value signifying whether the contributor role is being granted (`true`) or revoked
* (`false`)
*/
function addContributor(address contributor) external onlyOwner {
function manageContributor(
address contributor,
bool grantRole
) external onlyOwner {
if (contributor == address(0)) revert RMRKNewContributorIsZeroAddress();
_contributors[contributor] = 1;
emit ContributorUpdate(contributor, true);
}

/**
* @notice Removes a contributor from the smart contract.
* @dev Can only be called by the owner.
* @param contributor Address of the contributor's account
*/
function revokeContributor(address contributor) external onlyOwner {
delete _contributors[contributor];
emit ContributorUpdate(contributor, false);
grantRole
? _contributors[contributor] = 1
: _contributors[contributor] = 0;
emit ContributorUpdate(contributor, grantRole);
}

/**
Expand Down
49 changes: 17 additions & 32 deletions docs/RMRK/access/Ownable.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ A minimal ownable smart contractf or owner and contributors.

## Methods

### addContributor

```solidity
function addContributor(address contributor) external nonpayable
```

Adds a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### isContributor

```solidity
Expand All @@ -48,6 +32,23 @@ Used to check if the address is one of the contributors.
|---|---|---|
| _0 | bool | Boolean value indicating whether the address is a contributor or not |

### manageContributor

```solidity
function manageContributor(address contributor, bool grantRole) external nonpayable
```

Adds or removes a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |
| grantRole | bool | A boolean value signifying whether the contributor role is being granted (`true`) or revoked (`false`) |

### owner

```solidity
Expand Down Expand Up @@ -76,22 +77,6 @@ Leaves the contract without owner. Functions using the `onlyOwner` modifier will
*Can only be called by the current owner.Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*


### revokeContributor

```solidity
function revokeContributor(address contributor) external nonpayable
```

Removes a contributor from the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### transferOwnership

```solidity
Expand Down
49 changes: 17 additions & 32 deletions docs/RMRK/access/OwnableLock.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ A minimal ownable lock smart contract.

## Methods

### addContributor

```solidity
function addContributor(address contributor) external nonpayable
```

Adds a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### getLock

```solidity
Expand Down Expand Up @@ -65,6 +49,23 @@ Used to check if the address is one of the contributors.
|---|---|---|
| _0 | bool | Boolean value indicating whether the address is a contributor or not |

### manageContributor

```solidity
function manageContributor(address contributor, bool grantRole) external nonpayable
```

Adds or removes a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |
| grantRole | bool | A boolean value signifying whether the contributor role is being granted (`true`) or revoked (`false`) |

### owner

```solidity
Expand Down Expand Up @@ -93,22 +94,6 @@ Leaves the contract without owner. Functions using the `onlyOwner` modifier will
*Can only be called by the current owner.Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*


### revokeContributor

```solidity
function revokeContributor(address contributor) external nonpayable
```

Removes a contributor from the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### setLock

```solidity
Expand Down
49 changes: 17 additions & 32 deletions docs/RMRK/utils/RMRKMintingUtils.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ Smart contract of the RMRK minting utils module.

## Methods

### addContributor

```solidity
function addContributor(address contributor) external nonpayable
```

Adds a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### getLock

```solidity
Expand Down Expand Up @@ -65,6 +49,23 @@ Used to check if the address is one of the contributors.
|---|---|---|
| _0 | bool | Boolean value indicating whether the address is a contributor or not |

### manageContributor

```solidity
function manageContributor(address contributor, bool grantRole) external nonpayable
```

Adds or removes a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |
| grantRole | bool | A boolean value signifying whether the contributor role is being granted (`true`) or revoked (`false`) |

### maxSupply

```solidity
Expand Down Expand Up @@ -127,22 +128,6 @@ Leaves the contract without owner. Functions using the `onlyOwner` modifier will
*Can only be called by the current owner.Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*


### revokeContributor

```solidity
function revokeContributor(address contributor) external nonpayable
```

Removes a contributor from the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### setLock

```solidity
Expand Down
49 changes: 17 additions & 32 deletions docs/implementations/RMRKCatalogImpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@ Implementation of RMRK catalog.

## Methods

### addContributor

```solidity
function addContributor(address contributor) external nonpayable
```

Adds a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### addEquippableAddresses

```solidity
Expand Down Expand Up @@ -237,6 +221,23 @@ Used to check if the address is one of the contributors.
|---|---|---|
| _0 | bool | Boolean value indicating whether the address is a contributor or not |

### manageContributor

```solidity
function manageContributor(address contributor, bool grantRole) external nonpayable
```

Adds or removes a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |
| grantRole | bool | A boolean value signifying whether the contributor role is being granted (`true`) or revoked (`false`) |

### owner

```solidity
Expand Down Expand Up @@ -281,22 +282,6 @@ Used to remove all of the `equippableAddresses` for a `Part` associated with the
|---|---|---|
| partId | uint64 | ID of the part that we are clearing the `equippableAddresses` from |

### revokeContributor

```solidity
function revokeContributor(address contributor) external nonpayable
```

Removes a contributor from the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### setEquippableAddresses

```solidity
Expand Down
49 changes: 17 additions & 32 deletions docs/implementations/abstracts/RMRKAbstractEquippableImpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,6 @@ Used to add a child token to a given parent token.
| childId | uint256 | ID of the new proposed child token |
| data | bytes | Additional data with no specified format |

### addContributor

```solidity
function addContributor(address contributor) external nonpayable
```

Adds a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### addEquippableAssetEntry

```solidity
Expand Down Expand Up @@ -757,6 +741,23 @@ Used to check if the address is one of the contributors.
|---|---|---|
| _0 | bool | Boolean value indicating whether the address is a contributor or not |

### manageContributor

```solidity
function manageContributor(address contributor, bool grantRole) external nonpayable
```

Adds or removes a contributor to the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |
| grantRole | bool | A boolean value signifying whether the contributor role is being granted (`true`) or revoked (`false`) |

### maxSupply

```solidity
Expand Down Expand Up @@ -975,22 +976,6 @@ Leaves the contract without owner. Functions using the `onlyOwner` modifier will
*Can only be called by the current owner.Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.*


### revokeContributor

```solidity
function revokeContributor(address contributor) external nonpayable
```

Removes a contributor from the smart contract.

*Can only be called by the owner.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| contributor | address | Address of the contributor's account |

### royaltyInfo

```solidity
Expand Down
Loading

0 comments on commit 6aef40d

Please sign in to comment.