Skip to content

Commit

Permalink
chore: fix parameter and generate natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
YamenMerhi committed Feb 27, 2024
1 parent bf23626 commit abf0691
Show file tree
Hide file tree
Showing 15 changed files with 476 additions and 205 deletions.
8 changes: 4 additions & 4 deletions contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
* @dev Removes the `operator` address as an operator of callers tokens, disallowing it to send any amount of tokens
* on behalf of the token owner (the caller of the function `msg.sender`). See also {authorizedAmountFor}.
*
* @param operator The address of the token owner.
* @param operator The address to revoke as an operator.
* @param tokenOwner The address of the token owner.
* @param notify Boolean indicating whether to notify the operator or not.
* @param operatorNotificationData The data to notify the operator about via LSP1.
*
Expand All @@ -137,8 +137,8 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
* @custom:events {OperatorRevoked} event with address of the operator being revoked for the caller (token holder).
*/
function revokeOperator(
address tokenOwner,
address operator,
address tokenOwner,
bool notify,
bytes memory operatorNotificationData
) external;
Expand Down Expand Up @@ -185,17 +185,17 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
* - {OperatorRevoked} event if `subtractedAmount` is the full allowance,
* indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`.
*
* @param operator The address of the token owner.
* @param operator The operator to decrease allowance for `msg.sender`
* @param tokenOwner The address of the token owner.
* @param subtractedAmount The amount to decrease by in the operator's allowance.
*
* @custom:requirements
* - `operator` cannot be the zero address.
* - `operator` must have allowance for the caller of at least `subtractedAmount`.
*/
function decreaseAllowance(
address tokenOwner,
address operator,
address tokenOwner,
uint256 subtractedAmount,
bytes memory operatorNotificationData
) external;
Expand Down
16 changes: 11 additions & 5 deletions contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
bool notify,
bytes memory operatorNotificationData
) public virtual override {

if (msg.sender != tokenOwner && msg.sender != operator) {
revert LSP7RevokeOperatorNotAuthorized(msg.sender, tokenOwner, operator);
revert LSP7RevokeOperatorNotAuthorized(
msg.sender,
tokenOwner,
operator
);
}

_updateOperator(
tokenOwner,
operator,
Expand Down Expand Up @@ -265,9 +268,12 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
uint256 subtractedAmount,
bytes memory operatorNotificationData
) public virtual override {

if (msg.sender != tokenOwner && msg.sender != operator) {
revert LSP7DecreaseAllowanceNotAuthorized(msg.sender, tokenOwner, operator);
revert LSP7DecreaseAllowanceNotAuthorized(
msg.sender,
tokenOwner,
operator
);
}

uint256 currentAllowance = authorizedAmountFor(operator, tokenOwner);
Expand Down
13 changes: 10 additions & 3 deletions contracts/LSP7DigitalAsset/LSP7Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ error LSP7BatchCallFailed(uint256 callIndex);
/**
* @dev Reverts when the call to revoke operator is not authorized.
*/
error LSP7RevokeOperatorNotAuthorized(address caller, address tokenOwner, address operator);

error LSP7RevokeOperatorNotAuthorized(
address caller,
address tokenOwner,
address operator
);

/**
* @dev Reverts when the call to decrease allowance is not authorized.
*/
error LSP7DecreaseAllowanceNotAuthorized(address caller, address tokenOwner, address operator);
error LSP7DecreaseAllowanceNotAuthorized(
address caller,
address tokenOwner,
address operator
);
7 changes: 5 additions & 2 deletions contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ error LSP8TokenOwnerChanged(
address newOwner
);


/**
* @dev Reverts when the call to revoke operator is not authorized.
*/
error LSP8RevokeOperatorNotAuthorized(address caller, address tokenOwner, bytes32 tokenId);
error LSP8RevokeOperatorNotAuthorized(
address caller,
address tokenOwner,
bytes32 tokenId
);
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,16 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
) public virtual override {
address tokenOwner = tokenOwnerOf(tokenId);

if (msg.sender != tokenOwner){
if (!_operators[tokenId].contains(msg.sender) || operator != msg.sender) {
revert LSP8RevokeOperatorNotAuthorized(msg.sender, tokenOwner, tokenId);
if (msg.sender != tokenOwner) {
if (
!_operators[tokenId].contains(msg.sender) ||
operator != msg.sender
) {
revert LSP8RevokeOperatorNotAuthorized(
msg.sender,
tokenOwner,
tokenId
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/_interface_ids_table.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| **LSP1UniversalReceiver** | `0x6bb56a14` | Interface of the LSP1 - Universal Receiver standard, an entry function for a contract to receive arbitrary information. |
| **LSP1UniversalReceiverDelegate** | `0xa245bbda` | Interface of the LSP1 - Universal Receiver Delegate standard. |
| **LSP6KeyManager** | `0x23f34c62` | Interface of the LSP6 - Key Manager standard, a contract acting as a controller of an ERC725 Account using predfined permissions. |
| **LSP7DigitalAsset** | `0xb3c4928f` | Interface of the LSP7 - Digital Asset standard, a fungible digital asset. |
| **LSP7DigitalAsset** | `0xc52d6008` | Interface of the LSP7 - Digital Asset standard, a fungible digital asset. |
| **LSP8IdentifiableDigitalAsset** | `0x3a271706` | Interface of the LSP8 - Identifiable Digital Asset standard, a non-fungible digital asset. |
| **LSP9Vault** | `0x28af17e6` | Interface of LSP9 - Vault standard, a blockchain vault that can hold assets and interact with other smart contracts. |
| **LSP11BasicSocialRecovery** | `0x049a28f1` | Interface of the LSP11 - Basic Social Recovery standard, a contract to recover access control into an account. |
Expand Down
93 changes: 70 additions & 23 deletions docs/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,15 @@ Returns the number of decimals used to get its user representation. If the asset

- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#decreaseallowance)
- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol)
- Function signature: `decreaseAllowance(address,uint256,bytes)`
- Function selector: `0x7b204c4e`
- Function signature: `decreaseAllowance(address,address,uint256,bytes)`
- Function selector: `0x78381670`

:::

```solidity
function decreaseAllowance(
address operator,
address tokenOwner,
uint256 subtractedAmount,
bytes operatorNotificationData
) external nonpayable;
Expand All @@ -272,6 +273,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is
| Name | Type | Description |
| -------------------------- | :-------: | ------------------------------------------------------ |
| `operator` | `address` | The operator to decrease allowance for `msg.sender` |
| `tokenOwner` | `address` | The address of the token owner. |
| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. |
| `operatorNotificationData` | `bytes` | - |

Expand Down Expand Up @@ -459,14 +461,15 @@ Leaves the contract without owner. It will not be possible to call `onlyOwner` f

- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#revokeoperator)
- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol)
- Function signature: `revokeOperator(address,bool,bytes)`
- Function selector: `0x4521748e`
- Function signature: `revokeOperator(address,address,bool,bytes)`
- Function selector: `0x30d0dc37`

:::

```solidity
function revokeOperator(
address operator,
address tokenOwner,
bool notify,
bytes operatorNotificationData
) external nonpayable;
Expand All @@ -479,6 +482,7 @@ Removes the `operator` address as an operator of callers tokens, disallowing it
| Name | Type | Description |
| -------------------------- | :-------: | --------------------------------------------------------- |
| `operator` | `address` | The address to revoke as an operator. |
| `tokenOwner` | `address` | The address of the token owner. |
| `notify` | `bool` | Boolean indicating whether to notify the operator or not. |
| `operatorNotificationData` | `bytes` | The data to notify the operator about via LSP1. |

Expand Down Expand Up @@ -1561,25 +1565,6 @@ Reverts when a batch call failed.

<br/>

### LSP7CannotSendToSelf

:::note References

- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7cannotsendtoself)
- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol)
- Error signature: `LSP7CannotSendToSelf()`
- Error hash: `0xb9afb000`

:::

```solidity
error LSP7CannotSendToSelf();
```

reverts when specifying the same address for `from` or `to` in a token transfer.

<br/>

### LSP7CannotSendWithAddressZero

:::note References
Expand Down Expand Up @@ -1624,6 +1609,37 @@ reverts when trying to set the zero address as an operator.

<br/>

### LSP7DecreaseAllowanceNotAuthorized

:::note References

- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7decreaseallowancenotauthorized)
- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol)
- Error signature: `LSP7DecreaseAllowanceNotAuthorized(address,address,address)`
- Error hash: `0x98ce2945`

:::

```solidity
error LSP7DecreaseAllowanceNotAuthorized(
address caller,
address tokenOwner,
address operator
);
```

Reverts when the call to decrease allowance is not authorized.

#### Parameters

| Name | Type | Description |
| ------------ | :-------: | ----------- |
| `caller` | `address` | - |
| `tokenOwner` | `address` | - |
| `operator` | `address` | - |

<br/>

### LSP7DecreasedAllowanceBelowZero

:::note References
Expand Down Expand Up @@ -1714,6 +1730,37 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit

<br/>

### LSP7RevokeOperatorNotAuthorized

:::note References

- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7revokeoperatornotauthorized)
- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol)
- Error signature: `LSP7RevokeOperatorNotAuthorized(address,address,address)`
- Error hash: `0x1a525b32`

:::

```solidity
error LSP7RevokeOperatorNotAuthorized(
address caller,
address tokenOwner,
address operator
);
```

Reverts when the call to revoke operator is not authorized.

#### Parameters

| Name | Type | Description |
| ------------ | :-------: | ----------- |
| `caller` | `address` | - |
| `tokenOwner` | `address` | - |
| `operator` | `address` | - |

<br/>

### LSP7TokenContractCannotHoldValue

:::note References
Expand Down
Loading

0 comments on commit abf0691

Please sign in to comment.