diff --git a/docs/contracts/_interface_ids_table.mdx b/docs/contracts/_interface_ids_table.mdx index dce5ae1a44..674870dac8 100644 --- a/docs/contracts/_interface_ids_table.mdx +++ b/docs/contracts/_interface_ids_table.mdx @@ -6,7 +6,7 @@ | **ERC725Y** | `0x629aa694` | General Data key-value store. | | **LSP0ERC725Account** | `0x24871b3d` | Interface of the [LSP-0-ERC725Account] standard, an account based smart contract that represents an identity on-chain. | | **LSP1UniversalReceiver** | `0x6bb56a14` | Interface of the LSP1 - Universal Receiver standard, an entry function for a contract to receive arbitrary information. | -| **LSP6KeyManager** | `0x66918867` | Interface of the LSP6 - Key Manager standard, a contract acting as a controller of an ERC725 Account using predfined permissions. | +| **LSP6KeyManager** | `0xe7424397` | Interface of the LSP6 - Key Manager standard, a contract acting as a controller of an ERC725 Account using predfined permissions. | | **LSP7DigitalAsset** | `0x05519512` | Interface of the LSP7 - Digital Asset standard, a fungible digital asset. | | **LSP8IdentifiableDigitalAsset** | `0x1ae9ba1f` | 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. | @@ -15,5 +15,5 @@ | **LSP17Extendable** | `0xa918fa6b` | Module to add more functionalities to a contract using extensions. | | **LSP17Extension** | `0xcee78b40` | Module to create a contract that can act as an extension. | | **LSP20CallVerification** | `0x1a0eb6a5` | Implementation of a contract calling the verification functions according to LSP20 - Call Verification standard. | -| **LSP20CallVerifier** | `0x480c0ec2` | Interface for the LSP20 Call Verification standard, a set of functions intended to perform verifications on behalf of another contract. | +| **LSP20CallVerifier** | `0xc9dfc532` | Interface for the LSP20 Call Verification standard, a set of functions intended to perform verifications on behalf of another contract. | | **LSP25ExecuteRelayCall** | `0x5ac79908` | | diff --git a/docs/contracts/contracts/LSP0ERC725Account/LSP0ERC725Account.md b/docs/contracts/contracts/LSP0ERC725Account/LSP0ERC725Account.md index 22e6c566f7..e2f1825bb4 100644 --- a/docs/contracts/contracts/LSP0ERC725Account/LSP0ERC725Account.md +++ b/docs/contracts/contracts/LSP0ERC725Account/LSP0ERC725Account.md @@ -216,7 +216,7 @@ _`msg.sender` is accepting ownership of contract: `address(this)`._ Transfer ownership of the contract from the current [`owner()`](#owner) to the [`pendingOwner()`](#pendingowner). Once this function is called: -- The current [`owner()`](#owner) will loose access to the functions restricted to the [`owner()`](#owner) only. +- The current [`owner()`](#owner) will lose access to the functions restricted to the [`owner()`](#owner) only. - The [`pendingOwner()`](#pendingowner) will gain access to the functions restricted to the [`owner()`](#owner) only. @@ -350,6 +350,12 @@ Generic executor function to: ::: +:::caution Warning + +- The `msg.value` should not be trusted for any method called within the batch with `operationType`: `DELEGATECALL` (4). + +::: + ```solidity function executeBatch( uint256[] operationsType, @@ -588,7 +594,7 @@ The address that ownership of the contract is transferred to. This address may u :::danger -Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable. +Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner or an address allowed by the owner will be permanently inaccessible, making these functions not callable anymore and unusable. ::: @@ -1149,6 +1155,19 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::tip Hint + +This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`. +If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow: + +```solidity +(bool success, bytes memory result) = extension.call{value: msg.value}( + abi.encodePacked(callData, msg.sender, msg.value) +); +``` + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1156,9 +1175,11 @@ function _fallbackLSP17Extendable( ``` Forwards the call to an extension mapped to a function selector. -Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned. -Reverts if there is no extension for the function being called, except for the bytes4(0) function selector, which passes even if there is no extension for it. -If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value` +Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being +called on the account. If there is no extension, the `address(0)` will be returned. +Reverts if there is no extension for the function being called, except for the `bytes4(0)` function selector, which passes even if there is no extension for it. +If there is an extension for the function selector being called, it calls the extension with the +`CALL` opcode, passing the `msg.data` appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the `msg.value`.
@@ -1665,6 +1686,25 @@ Reverts when the `operationTypeProvided` is none of the default operation types
+### ERC725Y_DataKeysValuesEmptyArray + +:::note References + +- Specification details: [**LSP-0-ERC725Account**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-0-ERC725Account.md#erc725y_datakeysvaluesemptyarray) +- Solidity implementation: [`LSP0ERC725Account.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP0ERC725Account/LSP0ERC725Account.sol) +- Error signature: `ERC725Y_DataKeysValuesEmptyArray()` +- Error hash: `0x97da5f95` + +::: + +```solidity +error ERC725Y_DataKeysValuesEmptyArray(); +``` + +Reverts when one of the array parameter provided to [`setDataBatch`](#setdatabatch) function is an empty array. + +
+ ### ERC725Y_DataKeysValuesLengthMismatch :::note References @@ -1730,6 +1770,31 @@ reverts when the call to the owner fail with no revert reason
+### LSP20EOACannotVerifyCall + +:::note References + +- Specification details: [**LSP-0-ERC725Account**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-0-ERC725Account.md#lsp20eoacannotverifycall) +- Solidity implementation: [`LSP0ERC725Account.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP0ERC725Account/LSP0ERC725Account.sol) +- Error signature: `LSP20EOACannotVerifyCall(address)` +- Error hash: `0x0c392301` + +::: + +```solidity +error LSP20EOACannotVerifyCall(address logicVerifier); +``` + +Reverts when the logic verifier is an Externally Owned Account (EOA) that cannot return the LSP20 magic value. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | --------------------------------- | +| `logicVerifier` | `address` | The address of the logic verifier | + +
+ ### LSP20InvalidMagicValue :::note References diff --git a/docs/contracts/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md b/docs/contracts/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md index 8b9de0ceef..89e2ed2d23 100644 --- a/docs/contracts/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md +++ b/docs/contracts/contracts/LSP14Ownable2Step/LSP14Ownable2Step.md @@ -98,7 +98,7 @@ _`msg.sender` is accepting ownership of contract: `address(this)`._ Transfer ownership of the contract from the current [`owner()`](#owner) to the [`pendingOwner()`](#pendingowner). Once this function is called: -- The current [`owner()`](#owner) will loose access to the functions restricted to the [`owner()`](#owner) only. +- The current [`owner()`](#owner) will lose access to the functions restricted to the [`owner()`](#owner) only. - The [`pendingOwner()`](#pendingowner) will gain access to the functions restricted to the [`owner()`](#owner) only. diff --git a/docs/contracts/contracts/LSP16UniversalFactory/LSP16UniversalFactory.md b/docs/contracts/contracts/LSP16UniversalFactory/LSP16UniversalFactory.md index 8365acf9ca..6d5e6a0024 100644 --- a/docs/contracts/contracts/LSP16UniversalFactory/LSP16UniversalFactory.md +++ b/docs/contracts/contracts/LSP16UniversalFactory/LSP16UniversalFactory.md @@ -129,6 +129,8 @@ function deployCreate2( ) external payable returns (address); ``` +_Contract deployed. Salt, `providedSalt`, used._ + Deploys a contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the [`computeAddress`](#computeaddress) function. This function deploys contracts without initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(false, providedSalt))`. See [`generateSalt`](#generatesalt) function for more details. Using the same `byteCode` and `providedSalt` multiple times will revert, as the contract cannot be deployed twice at the same address. If the constructor of the contract to deploy is payable, value can be sent to this function to fund the created contract. However, sending value to this function while the constructor is not payable will result in a revert. #### Parameters @@ -167,6 +169,8 @@ function deployCreate2AndInitialize( ) external payable returns (address); ``` +_Contract deployed. Salt, `providedSalt`, used._ + Deploys a contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the [`computeAddress`](#computeaddress) function. This function deploys contracts with initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(true, initializeCalldata, providedSalt))`. See [`generateSalt`](#generatesalt) function for more details. Using the same `byteCode`, `providedSalt` and `initializeCalldata` multiple times will revert, as the contract cannot be deployed twice at the same address. If the constructor or the initialize function of the contract to deploy is payable, value can be sent along with the deployment/initialization to fund the created contract. However, sending value to this function while the constructor/initialize function is not payable will result in a revert. Will revert if the `msg.value` sent to the function is not equal to the sum of `constructorMsgValue` and `initializeCalldataMsgValue`. #### Parameters @@ -205,6 +209,8 @@ function deployERC1167Proxy( ) external nonpayable returns (address); ``` +_Proxy deployed. Salt, `providedSalt`, used._ + Deploys an ERC1167 minimal proxy contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the [`computeERC1167Address`](#computeerc1167address) function. This function deploys contracts without initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(false, providedSalt))`. See [`generateSalt`](#generatesalt) function for more details. See [`generateSalt`](#generatesalt) function for more details. Using the same `implementationContract` and `providedSalt` multiple times will revert, as the contract cannot be deployed twice at the same address. Sending value to the contract created is not possible since the constructor of the ERC1167 minimal proxy is not payable. #### Parameters @@ -241,6 +247,8 @@ function deployERC1167ProxyAndInitialize( ) external payable returns (address); ``` +_Proxy deployed & initialized. Salt, `providedSalt`, used._ + Deploys an ERC1167 minimal proxy contract using the CREATE2 opcode. The address where the contract will be deployed can be known in advance via the [`computeERC1167Address`](#computeerc1167address) function. This function deploys contracts with initialization (external call after deployment). The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is hashed with keccak256: `keccak256(abi.encodePacked(true, initializeCalldata, providedSalt))`. See [`generateSalt`](#generatesalt) function for more details. Using the same `implementationContract`, `providedSalt` and `initializeCalldata` multiple times will revert, as the contract cannot be deployed twice at the same address. If the initialize function of the contract to deploy is payable, value can be sent along to fund the created contract while initializing. However, sending value to this function while the initialize function is not payable will result in a revert. #### Parameters @@ -280,17 +288,37 @@ function generateSalt( Generates the salt used to deploy the contract by hashing the following parameters (concatenated together) with keccak256: -- the `providedSalt` +1. the `providedSalt` -- the `initializable` boolean +2. the `initializable` boolean -- the `initializeCalldata`, only if the contract is initializable (the `initializable` boolean is set to `true`) The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is used along with these parameters: +3. the `initializeCalldata`, only if the contract is initializable (the `initializable` boolean is set to `true`) -- `initializable` boolean +- The `providedSalt` parameter is not used directly as the salt by the CREATE2 opcode. Instead, it is used along with these parameters: + +1. `initializable` boolean + +2. `initializeCalldata` (when the contract is initializable and `initializable` is set to `true`). + +- This approach ensures that in order to reproduce an initializable contract at the same address on another chain, not only the `providedSalt` is required to be the same, but also the initialize parameters within the `initializeCalldata` must also be the same. This maintains consistent deployment behaviour. Users are required to initialize contracts with the same parameters across different chains to ensure contracts are deployed at the same address across different chains. + +1. Example (for initializable contracts) -- `initializeCalldata` (when the contract is initializable and `initializable` is set to `true`). These three parameters are concatenated together and hashed to generate the final salt for CREATE2. This approach ensures that in order to reproduce an initializable contract at the same address on another chain, not only the `providedSalt` is required to be the same, but also the initialize parameters within the `initializeCalldata` must also be the same. This maintains consistent deployment behaviour. Users are required to initialize contracts with the same parameters across different chains to ensure contracts are deployed at the same address across different chains. ----------- Example (for initializable contracts) For an existing contract A on chain 1 owned by X, to replicate the same contract at the same address with the same owner X on chain 2, the salt used to generate the address should include the initializeCalldata that assigns X as the owner of contract A. For instance, if another user, Y, tries to deploy the contract at the same address on chain 2 using the same providedSalt, but with a different initializeCalldata to make Y the owner instead of X, the generated address would be different, preventing Y from deploying the contract with different ownership at the same address. ----------- However, for non-initializable contracts, if the constructor has arguments that specify the deployment behavior, they will be included in the bytecode. Any change in the constructor arguments will lead to a different contract's bytecode which will result in a different address on other chains. ----------- Example (for non-initializable contracts) If a contract is deployed with specific constructor arguments on chain 1, these arguments are embedded within the bytecode. For instance, if contract B is deployed with a specific `tokenName` and `tokenSymbol` on chain 1, and a user wants to deploy the same contract with the same `tokenName` and `tokenSymbol` on chain 2, they must use the same constructor arguments to produce the same bytecode. This ensures that the same deployment behaviour is maintained across different chains, as long as the same bytecode is used. If another user Z, tries to deploy the same contract B at the same address on chain 2 using the same `providedSalt` but different constructor arguments (a different `tokenName` and/or `tokenSymbol`), the generated address will be different. This prevents user Z from deploying the contract with different constructor arguments at the same address on chain +- For an existing contract A on chain 1 owned by X, to replicate the same contract at the same address with the same owner X on chain 2, the salt used to generate the address should include the initializeCalldata that assigns X as the owner of contract A. -2. ----------- The providedSalt was hashed to produce the salt used by CREATE2 opcode to prevent users from deploying initializable contracts using non-initializable functions such as [`deployCreate2`](#deploycreate2) without having the initialization call. In other words, if the providedSalt was not hashed and was used as it is as the salt by the CREATE2 opcode, malicious users can check the generated salt used for the already deployed initializable contract on chain 1, and deploy the contract from [`deployCreate2`](#deploycreate2) function on chain 2, with passing the generated salt of the deployed contract as providedSalt that will produce the same address but without the initialization, where the malicious user can initialize after. +- For instance, if another user, Y, tries to deploy the contract at the same address on chain 2 using the same providedSalt, but with a different initializeCalldata to make Y the owner instead of X, the generated address would be different, preventing Y from deploying the contract with different ownership at the same address. + +- However, for non-initializable contracts, if the constructor has arguments that specify the deployment behavior, they will be included in the bytecode. Any change in the constructor arguments will lead to a different contract's bytecode which will result in a different address on other chains. + +2. Example (for non-initializable contracts) + +- If a contract is deployed with specific constructor arguments on chain 1, these arguments are embedded within the bytecode. For instance, if contract B is deployed with a specific `tokenName` and `tokenSymbol` on chain 1, and a user wants to deploy the same contract with the same `tokenName` and `tokenSymbol` on chain 2, they must use the same constructor arguments to produce the same bytecode. This ensures that the same deployment behaviour is maintained across different chains, as long as the same bytecode is used. + +- If another user Z, tries to deploy the same contract B at the same address on chain 2 using the same `providedSalt` but different constructor arguments (a different `tokenName` and/or `tokenSymbol`), the generated address will be different. This prevents user Z from deploying the contract with different constructor arguments at the same address on chain 2. + +- The providedSalt was hashed to produce the salt used by CREATE2 opcode to prevent users from deploying initializable contracts using non-initializable functions such as [`deployCreate2`](#deploycreate2) without having the initialization call. + +- In other words, if the providedSalt was not hashed and was used as it is as the salt by the CREATE2 opcode, malicious users can check the generated salt used for the already deployed initializable contract on chain 1, and deploy the contract from [`deployCreate2`](#deploycreate2) function on chain 2, with passing the generated salt of the deployed contract as providedSalt that will produce the same address but without the initialization, where the malicious user can initialize after. #### Parameters @@ -339,20 +367,22 @@ Bubble the revert reason if present, revert with `ContractInitializationFailed` ::: ```solidity -event ContractCreated(address indexed contractCreated, bytes32 indexed providedSalt, bytes32 generatedSalt, bool indexed initialized, bytes initializeCalldata); +event ContractCreated(address indexed createdContract, bytes32 indexed providedSalt, bytes32 generatedSalt, bool indexed initialized, bytes initializeCalldata); ``` -Emitted whenever a contract is created +_Contract created. Contract address: `createdContract`._ + +Emitted whenever a contract is created. #### Parameters -| Name | Type | Description | -| ------------------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| `contractCreated` **`indexed`** | `address` | The address of the contract created | -| `providedSalt` **`indexed`** | `bytes32` | The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment | -| `generatedSalt` | `bytes32` | The salt used by the `CREATE2` opcode for contract deployment | -| `initialized` **`indexed`** | `bool` | The Boolean that specifies if the contract must be initialized or not | -| `initializeCalldata` | `bytes` | The bytes provided as initializeCalldata (Empty string when `initialized` is set to false) | +| Name | Type | Description | +| ------------------------------- | :-------: | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| `createdContract` **`indexed`** | `address` | The address of the contract created. | +| `providedSalt` **`indexed`** | `bytes32` | The salt provided by the deployer, which will be used to generate the final salt that will be used by the `CREATE2` opcode for contract deployment. | +| `generatedSalt` | `bytes32` | The salt used by the `CREATE2` opcode for contract deployment. | +| `initialized` **`indexed`** | `bool` | The Boolean that specifies if the contract must be initialized or not. | +| `initializeCalldata` | `bytes` | The bytes provided as initializeCalldata (Empty string when `initialized` is set to false). |
@@ -373,7 +403,9 @@ Emitted whenever a contract is created error ContractInitializationFailed(); ``` -Reverts when there is no revert reason bubbled up by the contract created when initializing +_Couldn't initialize the contract._ + +Reverts when there is no revert reason bubbled up by the created contract when initializing
@@ -392,7 +424,7 @@ Reverts when there is no revert reason bubbled up by the contract created when i error InvalidValueSum(); ``` -Reverts when msg.value sent to [`deployCreate2AndInitialize`](#deploycreate2andinitialize) function is not equal to the sum of the `initializeCalldataMsgValue` and `constructorMsgValue` +Reverts when `msg.value` sent to [`deployCreate2AndInitialize(..)`](#deploycreate2andinitialize) function is not equal to the sum of the `initializeCalldataMsgValue` and `constructorMsgValue`
diff --git a/docs/contracts/contracts/LSP17ContractExtension/LSP17Extendable.md b/docs/contracts/contracts/LSP17ContractExtension/LSP17Extendable.md index 8a8305a80a..bcda48c318 100644 --- a/docs/contracts/contracts/LSP17ContractExtension/LSP17Extendable.md +++ b/docs/contracts/contracts/LSP17ContractExtension/LSP17Extendable.md @@ -93,6 +93,19 @@ Up to the implementor contract to return an extension based on a function select ### \_fallbackLSP17Extendable +:::tip Hint + +This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`. +If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow: + +```solidity +(bool success, bytes memory result) = extension.call{value: msg.value}( + abi.encodePacked(callData, msg.sender, msg.value) +); +``` + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -101,14 +114,10 @@ function _fallbackLSP17Extendable( Forwards the call to an extension mapped to a function selector. Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being -called on the account. If there is no extension, the address(0) will be returned. +called on the account. If there is no extension, the `address(0)` will be returned. Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the -CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and -32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached. +`CALL` opcode, passing the `msg.data` appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the `msg.value`.
diff --git a/docs/contracts/contracts/LSP17ContractExtension/LSP17Extension.md b/docs/contracts/contracts/LSP17ContractExtension/LSP17Extension.md index 2d2d273b56..b211e73729 100644 --- a/docs/contracts/contracts/LSP17ContractExtension/LSP17Extension.md +++ b/docs/contracts/contracts/LSP17ContractExtension/LSP17Extension.md @@ -66,8 +66,8 @@ Internal functions cannot be called externally, whether from other smart contrac function _extendableMsgData() internal view returns (bytes); ``` -Returns the original msg.data passed to the extendable contract -without the appended msg.sender and msg.value +Returns the original `msg.data` passed to the extendable contract +without the appended `msg.sender` and `msg.value`.
@@ -77,7 +77,7 @@ without the appended msg.sender and msg.value function _extendableMsgSender() internal view returns (address); ``` -Returns the original msg.sender calling the extendable contract +Returns the original `msg.sender` calling the extendable contract.
@@ -87,7 +87,7 @@ Returns the original msg.sender calling the extendable contract function _extendableMsgValue() internal view returns (uint256); ``` -Returns the original msg.value sent to the extendable contract +Returns the original `msg.value` sent to the extendable contract.
diff --git a/docs/contracts/contracts/LSP6KeyManager/LSP6KeyManager.md b/docs/contracts/contracts/LSP6KeyManager/LSP6KeyManager.md index 407f6b5477..5da0503d9f 100644 --- a/docs/contracts/contracts/LSP6KeyManager/LSP6KeyManager.md +++ b/docs/contracts/contracts/LSP6KeyManager/LSP6KeyManager.md @@ -332,13 +332,23 @@ Checks if a signature was signed by a controller that has the permission `SIGN`. - Specification details: [**LSP-6-KeyManager**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-6-KeyManager.md#lsp20verifycall) - Solidity implementation: [`LSP6KeyManager.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP6KeyManager/LSP6KeyManager.sol) -- Function signature: `lsp20VerifyCall(address,uint256,bytes)` -- Function selector: `0x9bf04b11` +- Function signature: `lsp20VerifyCall(address,address,uint256,bytes)` +- Function selector: `0x1a2380e1` + +::: + +:::tip Hint + +This function can call by any other address than the {`target`}. This allows to verify permissions in a _"read-only"_ manner. Anyone can call this function to verify if the `caller` has the right permissions to perform the abi-encoded function call `data` on the {`target`} contract (while sending `msgValue` alongside the call). If the permissions have been verified successfully and `caller` is authorized, one of the following two LSP20 magic value will be returned: + +- `0x1a238000`: LSP20 magic value **without** post verification (last byte is `0x00`). +- `0x1a238001`: LSP20 magic value **with** post-verification (last byte is `0x01`). ::: ```solidity function lsp20VerifyCall( + address targetContract, address caller, uint256 msgValue, bytes data @@ -347,11 +357,12 @@ function lsp20VerifyCall( #### Parameters -| Name | Type | Description | -| ---------- | :-------: | ----------------------------------------------------- | -| `caller` | `address` | The address who called the function on the msg.sender | -| `msgValue` | `uint256` | - | -| `data` | `bytes` | - | +| Name | Type | Description | +| ---------------- | :-------: | ----------------------------------------------------- | +| `targetContract` | `address` | - | +| `caller` | `address` | The address who called the function on the msg.sender | +| `msgValue` | `uint256` | - | +| `data` | `bytes` | - | #### Returns @@ -932,6 +943,17 @@ function _isAllowedCallType(
+### \_verifyExecuteRelayCallPermission + +```solidity +function _verifyExecuteRelayCallPermission( + address controllerAddress, + bytes32 controllerPermissions +) internal pure; +``` + +
+ ### \_verifyOwnershipPermissions ```solidity @@ -1115,6 +1137,7 @@ and conform to the signature format according to the LSP25 standard. ```solidity function _executePayload( + address targetContract, uint256 msgValue, bytes payload ) internal nonpayable returns (bytes); @@ -1124,10 +1147,11 @@ _Execute the `payload` passed to `execute(...)` or `executeRelayCall(...)`_ #### Parameters -| Name | Type | Description | -| ---------- | :-------: | ------------------------------------------------------------------ | -| `msgValue` | `uint256` | - | -| `payload` | `bytes` | The abi-encoded function call to execute on the {target} contract. | +| Name | Type | Description | +| ---------------- | :-------: | ------------------------------------------------------------------ | +| `targetContract` | `address` | - | +| `msgValue` | `uint256` | - | +| `payload` | `bytes` | The abi-encoded function call to execute on the {target} contract. | #### Returns @@ -1141,8 +1165,10 @@ _Execute the `payload` passed to `execute(...)` or `executeRelayCall(...)`_ ```solidity function _verifyPermissions( + address targetContract, address from, uint256 msgValue, + bool isRelayedCall, bytes payload ) internal view; ``` @@ -1151,21 +1177,13 @@ Verify if the `from` address is allowed to execute the `payload` on the [`target #### Parameters -| Name | Type | Description | -| ---------- | :-------: | ------------------------------------------------------------------- | -| `from` | `address` | Either the caller of {execute} or the signer of {executeRelayCall}. | -| `msgValue` | `uint256` | - | -| `payload` | `bytes` | The abi-encoded function call to execute on the {target} contract. | - -
- -### \_setupLSP6ReentrancyGuard - -```solidity -function _setupLSP6ReentrancyGuard() internal nonpayable; -``` - -Initialise \_reentrancyStatus to \_NOT_ENTERED. +| Name | Type | Description | +| ---------------- | :-------: | ------------------------------------------------------------------- | +| `targetContract` | `address` | - | +| `from` | `address` | Either the caller of {execute} or the signer of {executeRelayCall}. | +| `msgValue` | `uint256` | - | +| `isRelayedCall` | `bool` | - | +| `payload` | `bytes` | The abi-encoded function call to execute on the {target} contract. |
@@ -1173,9 +1191,10 @@ Initialise \_reentrancyStatus to \_NOT_ENTERED. ```solidity function _nonReentrantBefore( + address targetContract, bool isSetData, address from -) internal nonpayable returns (bool isReentrantCall); +) internal nonpayable returns (bool reentrancyStatus); ``` Update the status from `_NON_ENTERED` to `_ENTERED` and checks if @@ -1187,10 +1206,10 @@ Used in the beginning of the `nonReentrant` modifier, before the method executio ### \_nonReentrantAfter ```solidity -function _nonReentrantAfter() internal nonpayable; +function _nonReentrantAfter(address targetContract) internal nonpayable; ``` -Resets the status to `_NOT_ENTERED` +Resets the status to `false` Used in the end of the `nonReentrant` modifier after the method execution is terminated
diff --git a/docs/contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md b/docs/contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md index 30843c4a66..062a1511e9 100644 --- a/docs/contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md +++ b/docs/contracts/contracts/LSP7DigitalAsset/LSP7DigitalAsset.md @@ -58,6 +58,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#receive) +- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP7 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP7 contract. + +
+ ### authorizeOperator :::note References @@ -206,12 +225,12 @@ This is a non-standard function, not part of the LSP7 standard interface. It has ```solidity function decreaseAllowance( address operator, - uint256 substractedAmount, + uint256 subtractedAmount, bytes operatorNotificationData ) external nonpayable; ``` -_Decrease the allowance of `operator` by -`substractedAmount`_ +_Decrease the allowance of `operator` by -`subtractedAmount`_ Atomically decreases the allowance granted to `operator` by the caller. This is an alternative approach to [`authorizeOperator`](#authorizeoperator) that can be used as a mitigation for the double spending allowance problem. @@ -220,7 +239,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Requirements:** - `operator` cannot be the zero address. -- `operator` must have allowance for the caller of at least `substractedAmount`. +- `operator` must have allowance for the caller of at least `subtractedAmount`. @@ -229,7 +248,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Emitted events:** - [`AuthorizedOperator`](#authorizedoperator) event indicating the updated allowance after decreasing it. -- [`RevokeOperator`](#revokeoperator) event if `substractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. +- [`RevokeOperator`](#revokeoperator) event if `subtractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. @@ -237,8 +256,8 @@ 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` | -| `substractedAmount` | `uint256` | the amount to decrease by in the operator's allowance. | +| `operator` | `address` | The operator to decrease allowance for `msg.sender` | +| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. | | `operatorNotificationData` | `bytes` | - |
@@ -392,8 +411,8 @@ Atomically increases the allowance granted to `operator` by the caller. This is | Name | Type | Description | | -------------------------- | :-------: | ----------------------------------------------------------------------- | -| `operator` | `address` | the operator to increase the allowance for `msg.sender` | -| `addedAmount` | `uint256` | the additional amount to add on top of the current operator's allowance | +| `operator` | `address` | The operator to increase the allowance for `msg.sender` | +| `addedAmount` | `uint256` | The additional amount to add on top of the current operator's allowance | | `operatorNotificationData` | `bytes` | - |
@@ -643,7 +662,7 @@ function transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -652,13 +671,13 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | The recipient address. | -| `amount` | `uint256` | The amount of tokens to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | The recipient address. | +| `amount` | `uint256` | The amount of tokens to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -678,7 +697,7 @@ function transferBatch( address[] from, address[] to, uint256[] amount, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -687,13 +706,13 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of receiving addresses. | -| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | -| `allowNonLSP1Recipient` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of receiving addresses. | +| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | +| `force` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -792,7 +811,7 @@ Save gas by emitting the [`DataChanged`](#datachanged) event with only the first function _updateOperator( address tokenOwner, address operator, - uint256 amount, + uint256 allowance, bytes operatorNotificationData ) internal nonpayable; ``` @@ -801,6 +820,15 @@ Changes token `amount` the `operator` has access to from `tokenOwner` tokens. If the amount is zero the operator is removed from the list of operators, otherwise he is added to the list of operators. If the amount is zero then the operator is being revoked, otherwise the operator amount is being modified. +#### Parameters + +| Name | Type | Description | +| -------------------------- | :-------: | -------------------------------------------------------------------------------------- | +| `tokenOwner` | `address` | The address that will give `operator` an allowance for on its balance. | +| `operator` | `address` | The address to grant an allowance to spend. | +| `allowance` | `uint256` | The maximum amount of token that `operator` can spend from the `tokenOwner`'s balance. | +| `operatorNotificationData` | `bytes` | - | +
### \_mint @@ -809,7 +837,7 @@ If the amount is zero then the operator is being revoked, otherwise the operator function _mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -826,12 +854,12 @@ Mints `amount` of tokens and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | the address to mint tokens for. | -| `amount` | `uint256` | the amount of tokens to mint. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted {Transfer} event, and sent in the LSP1 hook to the `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to mint tokens for. | +| `amount` | `uint256` | The amount of tokens to mint. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted {Transfer} event, and sent in the LSP1 hook to the `to` address. |
@@ -865,12 +893,34 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r | Name | Type | Description | | -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to burn tokens from its balance. | -| `amount` | `uint256` | the amount of tokens to burn. | +| `from` | `address` | The address to burn tokens from its balance. | +| `amount` | `uint256` | The amount of tokens to burn. | | `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
+### \_spendAllowance + +```solidity +function _spendAllowance( + address operator, + address tokenOwner, + uint256 amountToSpend +) internal nonpayable; +``` + +Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------- | +| `operator` | `address` | The address of the operator to decrease the allowance of. | +| `tokenOwner` | `address` | The address that granted an allowance on its balance to `operator`. | +| `amountToSpend` | `uint256` | The amount of tokens to substract in allowance of `operator`. | + +
+ ### \_transfer ```solidity @@ -878,7 +928,7 @@ function _transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -900,13 +950,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to decrease the balance. | -| `to` | `address` | the address to increase the balance. | -| `amount` | `uint256` | the amount of tokens to transfer from `from` to `to`. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address to decrease the balance. | +| `to` | `address` | The address to increase the balance. | +| `amount` | `uint256` | The amount of tokens to transfer from `from` to `to`. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
@@ -979,26 +1029,26 @@ If `from` is an EOA or a contract that does not support the LSP1 interface, noth ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` Attempt to notify the token receiver `to` about the `amount` tokens being received. This is done by calling its [`universalReceiver`](#universalreceiver) function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface. -If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `allowNonLSP1Recipient` boolean flag. +If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag. -- if `allowNonLSP1Recipient` is set to `true`, nothing will happen and no notification will be sent. +- if `force` is set to `true`, nothing will happen and no notification will be sent. -- if `allowNonLSP1Recipient` is set to `false, the transaction will revert. +- if `force` is set to `false, the transaction will revert. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | --------------------------------------------------------------------------------------------------- | -| `to` | `address` | The address to call the {universalReceiver} function on. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `lsp1Data` | `bytes` | the data to be sent to the `to` address in the `universalReceiver(...)` call. | +| Name | Type | Description | +| ---------- | :-------: | --------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to call the {universalReceiver} function on. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `lsp1Data` | `bytes` | The data to be sent to the `to` address in the `universalReceiver(...)` call. |
@@ -1034,6 +1084,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1047,9 +1104,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1174,7 +1228,7 @@ Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its [` ::: ```solidity -event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool allowNonLSP1Recipient, bytes data); +event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data); ``` Emitted when the `from` transferred successfully `amount` of tokens to `to`. @@ -1187,7 +1241,7 @@ Emitted when the `from` transferred successfully `amount` of tokens to `to`. | `from` **`indexed`** | `address` | The address which tokens were sent from (balance decreased by `-amount`). | | `to` **`indexed`** | `address` | The address that received the tokens (balance increased by `+amount`). | | `amount` | `uint256` | The amount of tokens transferred. | -| `allowNonLSP1Recipient` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses. |
@@ -1521,7 +1575,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1546,7 +1600,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1556,6 +1610,27 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit
+### LSP7TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7tokencontractcannotholdvalue) +- Solidity implementation: [`LSP7DigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol) +- Error signature: `LSP7TokenContractCannotHoldValue()` +- Error hash: `0x388f5adc` + +::: + +```solidity +error LSP7TokenContractCannotHoldValue(); +``` + +_LSP7 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP7 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP7TokenOwnerCannotBeOperator :::note References diff --git a/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md b/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md index cbd5d9599f..2a26527317 100644 --- a/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md +++ b/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#receive) +- Solidity implementation: [`LSP7Burnable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP7 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP7 contract. + +
+ ### authorizeOperator :::note References @@ -231,12 +250,12 @@ This is a non-standard function, not part of the LSP7 standard interface. It has ```solidity function decreaseAllowance( address operator, - uint256 substractedAmount, + uint256 subtractedAmount, bytes operatorNotificationData ) external nonpayable; ``` -_Decrease the allowance of `operator` by -`substractedAmount`_ +_Decrease the allowance of `operator` by -`subtractedAmount`_ Atomically decreases the allowance granted to `operator` by the caller. This is an alternative approach to [`authorizeOperator`](#authorizeoperator) that can be used as a mitigation for the double spending allowance problem. @@ -245,7 +264,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Requirements:** - `operator` cannot be the zero address. -- `operator` must have allowance for the caller of at least `substractedAmount`. +- `operator` must have allowance for the caller of at least `subtractedAmount`. @@ -254,7 +273,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Emitted events:** - [`AuthorizedOperator`](#authorizedoperator) event indicating the updated allowance after decreasing it. -- [`RevokeOperator`](#revokeoperator) event if `substractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. +- [`RevokeOperator`](#revokeoperator) event if `subtractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. @@ -262,8 +281,8 @@ 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` | -| `substractedAmount` | `uint256` | the amount to decrease by in the operator's allowance. | +| `operator` | `address` | The operator to decrease allowance for `msg.sender` | +| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. | | `operatorNotificationData` | `bytes` | - |
@@ -417,8 +436,8 @@ Atomically increases the allowance granted to `operator` by the caller. This is | Name | Type | Description | | -------------------------- | :-------: | ----------------------------------------------------------------------- | -| `operator` | `address` | the operator to increase the allowance for `msg.sender` | -| `addedAmount` | `uint256` | the additional amount to add on top of the current operator's allowance | +| `operator` | `address` | The operator to increase the allowance for `msg.sender` | +| `addedAmount` | `uint256` | The additional amount to add on top of the current operator's allowance | | `operatorNotificationData` | `bytes` | - |
@@ -668,7 +687,7 @@ function transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -677,13 +696,13 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | The recipient address. | -| `amount` | `uint256` | The amount of tokens to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | The recipient address. | +| `amount` | `uint256` | The amount of tokens to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -703,7 +722,7 @@ function transferBatch( address[] from, address[] to, uint256[] amount, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -712,13 +731,13 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of receiving addresses. | -| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | -| `allowNonLSP1Recipient` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of receiving addresses. | +| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | +| `force` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -817,7 +836,7 @@ Save gas by emitting the [`DataChanged`](#datachanged) event with only the first function _updateOperator( address tokenOwner, address operator, - uint256 amount, + uint256 allowance, bytes operatorNotificationData ) internal nonpayable; ``` @@ -826,6 +845,15 @@ Changes token `amount` the `operator` has access to from `tokenOwner` tokens. If the amount is zero the operator is removed from the list of operators, otherwise he is added to the list of operators. If the amount is zero then the operator is being revoked, otherwise the operator amount is being modified. +#### Parameters + +| Name | Type | Description | +| -------------------------- | :-------: | -------------------------------------------------------------------------------------- | +| `tokenOwner` | `address` | The address that will give `operator` an allowance for on its balance. | +| `operator` | `address` | The address to grant an allowance to spend. | +| `allowance` | `uint256` | The maximum amount of token that `operator` can spend from the `tokenOwner`'s balance. | +| `operatorNotificationData` | `bytes` | - | +
### \_mint @@ -834,7 +862,7 @@ If the amount is zero then the operator is being revoked, otherwise the operator function _mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -851,12 +879,12 @@ Mints `amount` of tokens and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | the address to mint tokens for. | -| `amount` | `uint256` | the amount of tokens to mint. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted {Transfer} event, and sent in the LSP1 hook to the `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to mint tokens for. | +| `amount` | `uint256` | The amount of tokens to mint. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted {Transfer} event, and sent in the LSP1 hook to the `to` address. |
@@ -890,12 +918,34 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r | Name | Type | Description | | -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to burn tokens from its balance. | -| `amount` | `uint256` | the amount of tokens to burn. | +| `from` | `address` | The address to burn tokens from its balance. | +| `amount` | `uint256` | The amount of tokens to burn. | | `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
+### \_spendAllowance + +```solidity +function _spendAllowance( + address operator, + address tokenOwner, + uint256 amountToSpend +) internal nonpayable; +``` + +Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------- | +| `operator` | `address` | The address of the operator to decrease the allowance of. | +| `tokenOwner` | `address` | The address that granted an allowance on its balance to `operator`. | +| `amountToSpend` | `uint256` | The amount of tokens to substract in allowance of `operator`. | + +
+ ### \_transfer ```solidity @@ -903,7 +953,7 @@ function _transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -925,13 +975,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to decrease the balance. | -| `to` | `address` | the address to increase the balance. | -| `amount` | `uint256` | the amount of tokens to transfer from `from` to `to`. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address to decrease the balance. | +| `to` | `address` | The address to increase the balance. | +| `amount` | `uint256` | The amount of tokens to transfer from `from` to `to`. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
@@ -1004,26 +1054,26 @@ If `from` is an EOA or a contract that does not support the LSP1 interface, noth ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` Attempt to notify the token receiver `to` about the `amount` tokens being received. This is done by calling its [`universalReceiver`](#universalreceiver) function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface. -If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `allowNonLSP1Recipient` boolean flag. +If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag. -- if `allowNonLSP1Recipient` is set to `true`, nothing will happen and no notification will be sent. +- if `force` is set to `true`, nothing will happen and no notification will be sent. -- if `allowNonLSP1Recipient` is set to `false, the transaction will revert. +- if `force` is set to `false, the transaction will revert. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | --------------------------------------------------------------------------------------------------- | -| `to` | `address` | The address to call the {universalReceiver} function on. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `lsp1Data` | `bytes` | the data to be sent to the `to` address in the `universalReceiver(...)` call. | +| Name | Type | Description | +| ---------- | :-------: | --------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to call the {universalReceiver} function on. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `lsp1Data` | `bytes` | The data to be sent to the `to` address in the `universalReceiver(...)` call. |
@@ -1059,6 +1109,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1072,9 +1129,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1199,7 +1253,7 @@ Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its [` ::: ```solidity -event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool allowNonLSP1Recipient, bytes data); +event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data); ``` Emitted when the `from` transferred successfully `amount` of tokens to `to`. @@ -1212,7 +1266,7 @@ Emitted when the `from` transferred successfully `amount` of tokens to `to`. | `from` **`indexed`** | `address` | The address which tokens were sent from (balance decreased by `-amount`). | | `to` **`indexed`** | `address` | The address that received the tokens (balance increased by `+amount`). | | `amount` | `uint256` | The amount of tokens transferred. | -| `allowNonLSP1Recipient` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses. |
@@ -1546,7 +1600,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1571,7 +1625,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1581,6 +1635,27 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit
+### LSP7TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7tokencontractcannotholdvalue) +- Solidity implementation: [`LSP7Burnable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol) +- Error signature: `LSP7TokenContractCannotHoldValue()` +- Error hash: `0x388f5adc` + +::: + +```solidity +error LSP7TokenContractCannotHoldValue(); +``` + +_LSP7 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP7 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP7TokenOwnerCannotBeOperator :::note References diff --git a/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md b/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md index 503d783e2d..cc2501eae4 100644 --- a/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md +++ b/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#receive) +- Solidity implementation: [`LSP7CappedSupply.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP7 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP7 contract. + +
+ ### authorizeOperator :::note References @@ -204,12 +223,12 @@ This is a non-standard function, not part of the LSP7 standard interface. It has ```solidity function decreaseAllowance( address operator, - uint256 substractedAmount, + uint256 subtractedAmount, bytes operatorNotificationData ) external nonpayable; ``` -_Decrease the allowance of `operator` by -`substractedAmount`_ +_Decrease the allowance of `operator` by -`subtractedAmount`_ Atomically decreases the allowance granted to `operator` by the caller. This is an alternative approach to [`authorizeOperator`](#authorizeoperator) that can be used as a mitigation for the double spending allowance problem. @@ -218,7 +237,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Requirements:** - `operator` cannot be the zero address. -- `operator` must have allowance for the caller of at least `substractedAmount`. +- `operator` must have allowance for the caller of at least `subtractedAmount`. @@ -227,7 +246,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Emitted events:** - [`AuthorizedOperator`](#authorizedoperator) event indicating the updated allowance after decreasing it. -- [`RevokeOperator`](#revokeoperator) event if `substractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. +- [`RevokeOperator`](#revokeoperator) event if `subtractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. @@ -235,8 +254,8 @@ 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` | -| `substractedAmount` | `uint256` | the amount to decrease by in the operator's allowance. | +| `operator` | `address` | The operator to decrease allowance for `msg.sender` | +| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. | | `operatorNotificationData` | `bytes` | - |
@@ -390,8 +409,8 @@ Atomically increases the allowance granted to `operator` by the caller. This is | Name | Type | Description | | -------------------------- | :-------: | ----------------------------------------------------------------------- | -| `operator` | `address` | the operator to increase the allowance for `msg.sender` | -| `addedAmount` | `uint256` | the additional amount to add on top of the current operator's allowance | +| `operator` | `address` | The operator to increase the allowance for `msg.sender` | +| `addedAmount` | `uint256` | The additional amount to add on top of the current operator's allowance | | `operatorNotificationData` | `bytes` | - |
@@ -615,7 +634,7 @@ Returns true if this contract implements the interface defined by `interfaceId`. function tokenSupplyCap() external view returns (uint256); ``` -_The maximum supply amount of tokens allowed to exist is `_tokenSupplyCap`._ +_The maximum supply amount of tokens allowed to exist is `_TOKEN_SUPPLY_CAP`._ Get the maximum number of tokens that can exist to circulate. Once [`totalSupply`](#totalsupply) reaches reaches [`totalSuuplyCap`](#totalsuuplycap), it is not possible to mint more tokens. @@ -668,7 +687,7 @@ function transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -677,13 +696,13 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | The recipient address. | -| `amount` | `uint256` | The amount of tokens to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | The recipient address. | +| `amount` | `uint256` | The amount of tokens to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -703,7 +722,7 @@ function transferBatch( address[] from, address[] to, uint256[] amount, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -712,13 +731,13 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of receiving addresses. | -| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | -| `allowNonLSP1Recipient` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of receiving addresses. | +| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | +| `force` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -817,7 +836,7 @@ Save gas by emitting the [`DataChanged`](#datachanged) event with only the first function _updateOperator( address tokenOwner, address operator, - uint256 amount, + uint256 allowance, bytes operatorNotificationData ) internal nonpayable; ``` @@ -826,6 +845,15 @@ Changes token `amount` the `operator` has access to from `tokenOwner` tokens. If the amount is zero the operator is removed from the list of operators, otherwise he is added to the list of operators. If the amount is zero then the operator is being revoked, otherwise the operator amount is being modified. +#### Parameters + +| Name | Type | Description | +| -------------------------- | :-------: | -------------------------------------------------------------------------------------- | +| `tokenOwner` | `address` | The address that will give `operator` an allowance for on its balance. | +| `operator` | `address` | The address to grant an allowance to spend. | +| `allowance` | `uint256` | The maximum amount of token that `operator` can spend from the `tokenOwner`'s balance. | +| `operatorNotificationData` | `bytes` | - | +
### \_mint @@ -834,7 +862,7 @@ If the amount is zero then the operator is being revoked, otherwise the operator function _mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -874,12 +902,34 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r | Name | Type | Description | | -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to burn tokens from its balance. | -| `amount` | `uint256` | the amount of tokens to burn. | +| `from` | `address` | The address to burn tokens from its balance. | +| `amount` | `uint256` | The amount of tokens to burn. | | `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
+### \_spendAllowance + +```solidity +function _spendAllowance( + address operator, + address tokenOwner, + uint256 amountToSpend +) internal nonpayable; +``` + +Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------- | +| `operator` | `address` | The address of the operator to decrease the allowance of. | +| `tokenOwner` | `address` | The address that granted an allowance on its balance to `operator`. | +| `amountToSpend` | `uint256` | The amount of tokens to substract in allowance of `operator`. | + +
+ ### \_transfer ```solidity @@ -887,7 +937,7 @@ function _transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -909,13 +959,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to decrease the balance. | -| `to` | `address` | the address to increase the balance. | -| `amount` | `uint256` | the amount of tokens to transfer from `from` to `to`. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address to decrease the balance. | +| `to` | `address` | The address to increase the balance. | +| `amount` | `uint256` | The amount of tokens to transfer from `from` to `to`. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
@@ -988,26 +1038,26 @@ If `from` is an EOA or a contract that does not support the LSP1 interface, noth ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` Attempt to notify the token receiver `to` about the `amount` tokens being received. This is done by calling its [`universalReceiver`](#universalreceiver) function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface. -If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `allowNonLSP1Recipient` boolean flag. +If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag. -- if `allowNonLSP1Recipient` is set to `true`, nothing will happen and no notification will be sent. +- if `force` is set to `true`, nothing will happen and no notification will be sent. -- if `allowNonLSP1Recipient` is set to `false, the transaction will revert. +- if `force` is set to `false, the transaction will revert. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | --------------------------------------------------------------------------------------------------- | -| `to` | `address` | The address to call the {universalReceiver} function on. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `lsp1Data` | `bytes` | the data to be sent to the `to` address in the `universalReceiver(...)` call. | +| Name | Type | Description | +| ---------- | :-------: | --------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to call the {universalReceiver} function on. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `lsp1Data` | `bytes` | The data to be sent to the `to` address in the `universalReceiver(...)` call. |
@@ -1043,6 +1093,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1056,9 +1113,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1183,7 +1237,7 @@ Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its [` ::: ```solidity -event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool allowNonLSP1Recipient, bytes data); +event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data); ``` Emitted when the `from` transferred successfully `amount` of tokens to `to`. @@ -1196,7 +1250,7 @@ Emitted when the `from` transferred successfully `amount` of tokens to `to`. | `from` **`indexed`** | `address` | The address which tokens were sent from (balance decreased by `-amount`). | | `to` **`indexed`** | `address` | The address that received the tokens (balance increased by `+amount`). | | `amount` | `uint256` | The amount of tokens transferred. | -| `allowNonLSP1Recipient` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses. |
@@ -1572,7 +1626,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1597,7 +1651,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1607,6 +1661,27 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit
+### LSP7TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7tokencontractcannotholdvalue) +- Solidity implementation: [`LSP7CappedSupply.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol) +- Error signature: `LSP7TokenContractCannotHoldValue()` +- Error hash: `0x388f5adc` + +::: + +```solidity +error LSP7TokenContractCannotHoldValue(); +``` + +_LSP7 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP7 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP7TokenOwnerCannotBeOperator :::note References diff --git a/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md b/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md index bff5340d0b..b5892952b0 100644 --- a/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md +++ b/docs/contracts/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#receive) +- Solidity implementation: [`LSP7CompatibleERC20.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP7 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP7 contract. + +
+ ### allowance :::note References @@ -270,12 +289,12 @@ This is a non-standard function, not part of the LSP7 standard interface. It has ```solidity function decreaseAllowance( address operator, - uint256 substractedAmount, + uint256 subtractedAmount, bytes operatorNotificationData ) external nonpayable; ``` -_Decrease the allowance of `operator` by -`substractedAmount`_ +_Decrease the allowance of `operator` by -`subtractedAmount`_ Atomically decreases the allowance granted to `operator` by the caller. This is an alternative approach to [`authorizeOperator`](#authorizeoperator) that can be used as a mitigation for the double spending allowance problem. @@ -284,7 +303,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Requirements:** - `operator` cannot be the zero address. -- `operator` must have allowance for the caller of at least `substractedAmount`. +- `operator` must have allowance for the caller of at least `subtractedAmount`. @@ -293,7 +312,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Emitted events:** - [`AuthorizedOperator`](#authorizedoperator) event indicating the updated allowance after decreasing it. -- [`RevokeOperator`](#revokeoperator) event if `substractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. +- [`RevokeOperator`](#revokeoperator) event if `subtractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. @@ -301,8 +320,8 @@ 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` | -| `substractedAmount` | `uint256` | the amount to decrease by in the operator's allowance. | +| `operator` | `address` | The operator to decrease allowance for `msg.sender` | +| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. | | `operatorNotificationData` | `bytes` | - |
@@ -456,8 +475,8 @@ Atomically increases the allowance granted to `operator` by the caller. This is | Name | Type | Description | | -------------------------- | :-------: | ----------------------------------------------------------------------- | -| `operator` | `address` | the operator to increase the allowance for `msg.sender` | -| `addedAmount` | `uint256` | the additional amount to add on top of the current operator's allowance | +| `operator` | `address` | The operator to increase the allowance for `msg.sender` | +| `addedAmount` | `uint256` | The additional amount to add on top of the current operator's allowance | | `operatorNotificationData` | `bytes` | - |
@@ -757,7 +776,7 @@ function transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -766,13 +785,13 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | The recipient address. | -| `amount` | `uint256` | The amount of tokens to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | The recipient address. | +| `amount` | `uint256` | The amount of tokens to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -789,7 +808,7 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and :::info -This function uses the `allowNonLSP1Recipient` parameter as `true` so that EOA and any contract can receive tokens. +This function uses the `force` parameter as `true` so that EOA and any contract can receive tokens. ::: @@ -831,7 +850,7 @@ function transferBatch( address[] from, address[] to, uint256[] amount, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -840,13 +859,13 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of receiving addresses. | -| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | -| `allowNonLSP1Recipient` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of receiving addresses. | +| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | +| `force` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -863,7 +882,7 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the :::info -This function uses the `allowNonLSP1Recipient` parameter as `true` so that EOA and any contract can receive tokens. +This function uses the `force` parameter as `true` so that EOA and any contract can receive tokens. ::: @@ -997,7 +1016,7 @@ function _updateOperator( function _mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1012,6 +1031,28 @@ function _burn(address from, uint256 amount, bytes data) internal nonpayable;
+### \_spendAllowance + +```solidity +function _spendAllowance( + address operator, + address tokenOwner, + uint256 amountToSpend +) internal nonpayable; +``` + +Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------- | +| `operator` | `address` | The address of the operator to decrease the allowance of. | +| `tokenOwner` | `address` | The address that granted an allowance on its balance to `operator`. | +| `amountToSpend` | `uint256` | The amount of tokens to substract in allowance of `operator`. | + +
+ ### \_transfer ```solidity @@ -1019,7 +1060,7 @@ function _transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1095,26 +1136,26 @@ If `from` is an EOA or a contract that does not support the LSP1 interface, noth ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` Attempt to notify the token receiver `to` about the `amount` tokens being received. This is done by calling its [`universalReceiver`](#universalreceiver) function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface. -If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `allowNonLSP1Recipient` boolean flag. +If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag. -- if `allowNonLSP1Recipient` is set to `true`, nothing will happen and no notification will be sent. +- if `force` is set to `true`, nothing will happen and no notification will be sent. -- if `allowNonLSP1Recipient` is set to `false, the transaction will revert. +- if `force` is set to `false, the transaction will revert. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | --------------------------------------------------------------------------------------------------- | -| `to` | `address` | The address to call the {universalReceiver} function on. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `lsp1Data` | `bytes` | the data to be sent to the `to` address in the `universalReceiver(...)` call. | +| Name | Type | Description | +| ---------- | :-------: | --------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to call the {universalReceiver} function on. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `lsp1Data` | `bytes` | The data to be sent to the `to` address in the `universalReceiver(...)` call. |
@@ -1150,6 +1191,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1163,9 +1211,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1344,7 +1389,7 @@ Emitted when `value` tokens are moved from one account (`from`) to another (`to` ::: ```solidity -event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool allowNonLSP1Recipient, bytes data); +event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data); ``` Emitted when the `from` transferred successfully `amount` of tokens to `to`. @@ -1357,7 +1402,7 @@ Emitted when the `from` transferred successfully `amount` of tokens to `to`. | `from` **`indexed`** | `address` | The address which tokens were sent from (balance decreased by `-amount`). | | `to` **`indexed`** | `address` | The address that received the tokens (balance increased by `+amount`). | | `amount` | `uint256` | The amount of tokens transferred. | -| `allowNonLSP1Recipient` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses. |
@@ -1691,7 +1736,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1716,7 +1761,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1726,6 +1771,27 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit
+### LSP7TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7tokencontractcannotholdvalue) +- Solidity implementation: [`LSP7CompatibleERC20.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol) +- Error signature: `LSP7TokenContractCannotHoldValue()` +- Error hash: `0x388f5adc` + +::: + +```solidity +error LSP7TokenContractCannotHoldValue(); +``` + +_LSP7 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP7 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP7TokenOwnerCannotBeOperator :::note References diff --git a/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md b/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md index b854b5904d..8a5d97d562 100644 --- a/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md +++ b/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.md @@ -61,6 +61,21 @@ fallback() external payable;
+### receive + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#receive) +- Solidity implementation: [`LSP7CompatibleERC20Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol) + +::: + +```solidity +receive() external payable; +``` + +
+ ### allowance :::note References @@ -275,12 +290,12 @@ This is a non-standard function, not part of the LSP7 standard interface. It has ```solidity function decreaseAllowance( address operator, - uint256 substractedAmount, + uint256 subtractedAmount, bytes operatorNotificationData ) external nonpayable; ``` -_Decrease the allowance of `operator` by -`substractedAmount`_ +_Decrease the allowance of `operator` by -`subtractedAmount`_ Atomically decreases the allowance granted to `operator` by the caller. This is an alternative approach to [`authorizeOperator`](#authorizeoperator) that can be used as a mitigation for the double spending allowance problem. @@ -289,7 +304,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Requirements:** - `operator` cannot be the zero address. -- `operator` must have allowance for the caller of at least `substractedAmount`. +- `operator` must have allowance for the caller of at least `subtractedAmount`. @@ -298,7 +313,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Emitted events:** - [`AuthorizedOperator`](#authorizedoperator) event indicating the updated allowance after decreasing it. -- [`RevokeOperator`](#revokeoperator) event if `substractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. +- [`RevokeOperator`](#revokeoperator) event if `subtractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. @@ -306,8 +321,8 @@ 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` | -| `substractedAmount` | `uint256` | the amount to decrease by in the operator's allowance. | +| `operator` | `address` | The operator to decrease allowance for `msg.sender` | +| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. | | `operatorNotificationData` | `bytes` | - |
@@ -461,8 +476,8 @@ Atomically increases the allowance granted to `operator` by the caller. This is | Name | Type | Description | | -------------------------- | :-------: | ----------------------------------------------------------------------- | -| `operator` | `address` | the operator to increase the allowance for `msg.sender` | -| `addedAmount` | `uint256` | the additional amount to add on top of the current operator's allowance | +| `operator` | `address` | The operator to increase the allowance for `msg.sender` | +| `addedAmount` | `uint256` | The additional amount to add on top of the current operator's allowance | | `operatorNotificationData` | `bytes` | - |
@@ -482,7 +497,7 @@ Atomically increases the allowance granted to `operator` by the caller. This is function mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -491,12 +506,12 @@ Public [`_mint`](#_mint) function only callable by the [`owner`](#owner). #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ----------- | -| `to` | `address` | - | -| `amount` | `uint256` | - | -| `allowNonLSP1Recipient` | `bool` | - | -| `data` | `bytes` | - | +| Name | Type | Description | +| -------- | :-------: | ----------- | +| `to` | `address` | - | +| `amount` | `uint256` | - | +| `force` | `bool` | - | +| `data` | `bytes` | - |
@@ -795,7 +810,7 @@ function transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -804,13 +819,13 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | The recipient address. | -| `amount` | `uint256` | The amount of tokens to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | The recipient address. | +| `amount` | `uint256` | The amount of tokens to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -827,7 +842,7 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and :::info -This function uses the `allowNonLSP1Recipient` parameter as `true` so that EOA and any contract can receive tokens. +This function uses the `force` parameter as `true` so that EOA and any contract can receive tokens. ::: @@ -869,7 +884,7 @@ function transferBatch( address[] from, address[] to, uint256[] amount, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -878,13 +893,13 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of receiving addresses. | -| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | -| `allowNonLSP1Recipient` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of receiving addresses. | +| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | +| `force` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -901,7 +916,7 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the :::info -This function uses the `allowNonLSP1Recipient` parameter as `true` so that EOA and any contract can receive tokens. +This function uses the `force` parameter as `true` so that EOA and any contract can receive tokens. ::: @@ -1035,7 +1050,7 @@ function _updateOperator( function _mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1050,6 +1065,28 @@ function _burn(address from, uint256 amount, bytes data) internal nonpayable;
+### \_spendAllowance + +```solidity +function _spendAllowance( + address operator, + address tokenOwner, + uint256 amountToSpend +) internal nonpayable; +``` + +Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------- | +| `operator` | `address` | The address of the operator to decrease the allowance of. | +| `tokenOwner` | `address` | The address that granted an allowance on its balance to `operator`. | +| `amountToSpend` | `uint256` | The amount of tokens to substract in allowance of `operator`. | + +
+ ### \_transfer ```solidity @@ -1057,7 +1094,7 @@ function _transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1133,26 +1170,26 @@ If `from` is an EOA or a contract that does not support the LSP1 interface, noth ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` Attempt to notify the token receiver `to` about the `amount` tokens being received. This is done by calling its [`universalReceiver`](#universalreceiver) function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface. -If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `allowNonLSP1Recipient` boolean flag. +If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag. -- if `allowNonLSP1Recipient` is set to `true`, nothing will happen and no notification will be sent. +- if `force` is set to `true`, nothing will happen and no notification will be sent. -- if `allowNonLSP1Recipient` is set to `false, the transaction will revert. +- if `force` is set to `false, the transaction will revert. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | --------------------------------------------------------------------------------------------------- | -| `to` | `address` | The address to call the {universalReceiver} function on. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `lsp1Data` | `bytes` | the data to be sent to the `to` address in the `universalReceiver(...)` call. | +| Name | Type | Description | +| ---------- | :-------: | --------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to call the {universalReceiver} function on. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `lsp1Data` | `bytes` | The data to be sent to the `to` address in the `universalReceiver(...)` call. |
@@ -1188,6 +1225,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1201,9 +1245,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1382,7 +1423,7 @@ Emitted when `value` tokens are moved from one account (`from`) to another (`to` ::: ```solidity -event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool allowNonLSP1Recipient, bytes data); +event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data); ``` Emitted when the `from` transferred successfully `amount` of tokens to `to`. @@ -1395,7 +1436,7 @@ Emitted when the `from` transferred successfully `amount` of tokens to `to`. | `from` **`indexed`** | `address` | The address which tokens were sent from (balance decreased by `-amount`). | | `to` **`indexed`** | `address` | The address that received the tokens (balance increased by `+amount`). | | `amount` | `uint256` | The amount of tokens transferred. | -| `allowNonLSP1Recipient` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses. |
@@ -1729,7 +1770,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1754,7 +1795,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1764,6 +1805,27 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit
+### LSP7TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7tokencontractcannotholdvalue) +- Solidity implementation: [`LSP7CompatibleERC20Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol) +- Error signature: `LSP7TokenContractCannotHoldValue()` +- Error hash: `0x388f5adc` + +::: + +```solidity +error LSP7TokenContractCannotHoldValue(); +``` + +_LSP7 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP7 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP7TokenOwnerCannotBeOperator :::note References diff --git a/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md b/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md index e3ee21c6a7..b9de110e43 100644 --- a/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md +++ b/docs/contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.md @@ -87,6 +87,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#receive) +- Solidity implementation: [`LSP7Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP7 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP7 contract. + +
+ ### authorizeOperator :::note References @@ -235,12 +254,12 @@ This is a non-standard function, not part of the LSP7 standard interface. It has ```solidity function decreaseAllowance( address operator, - uint256 substractedAmount, + uint256 subtractedAmount, bytes operatorNotificationData ) external nonpayable; ``` -_Decrease the allowance of `operator` by -`substractedAmount`_ +_Decrease the allowance of `operator` by -`subtractedAmount`_ Atomically decreases the allowance granted to `operator` by the caller. This is an alternative approach to [`authorizeOperator`](#authorizeoperator) that can be used as a mitigation for the double spending allowance problem. @@ -249,7 +268,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Requirements:** - `operator` cannot be the zero address. -- `operator` must have allowance for the caller of at least `substractedAmount`. +- `operator` must have allowance for the caller of at least `subtractedAmount`. @@ -258,7 +277,7 @@ Atomically decreases the allowance granted to `operator` by the caller. This is **Emitted events:** - [`AuthorizedOperator`](#authorizedoperator) event indicating the updated allowance after decreasing it. -- [`RevokeOperator`](#revokeoperator) event if `substractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. +- [`RevokeOperator`](#revokeoperator) event if `subtractedAmount` is the full allowance, indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`. @@ -266,8 +285,8 @@ 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` | -| `substractedAmount` | `uint256` | the amount to decrease by in the operator's allowance. | +| `operator` | `address` | The operator to decrease allowance for `msg.sender` | +| `subtractedAmount` | `uint256` | The amount to decrease by in the operator's allowance. | | `operatorNotificationData` | `bytes` | - |
@@ -421,8 +440,8 @@ Atomically increases the allowance granted to `operator` by the caller. This is | Name | Type | Description | | -------------------------- | :-------: | ----------------------------------------------------------------------- | -| `operator` | `address` | the operator to increase the allowance for `msg.sender` | -| `addedAmount` | `uint256` | the additional amount to add on top of the current operator's allowance | +| `operator` | `address` | The operator to increase the allowance for `msg.sender` | +| `addedAmount` | `uint256` | The additional amount to add on top of the current operator's allowance | | `operatorNotificationData` | `bytes` | - |
@@ -442,7 +461,7 @@ Atomically increases the allowance granted to `operator` by the caller. This is function mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -451,12 +470,12 @@ Public [`_mint`](#_mint) function only callable by the [`owner`](#owner). #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ----------- | -| `to` | `address` | - | -| `amount` | `uint256` | - | -| `allowNonLSP1Recipient` | `bool` | - | -| `data` | `bytes` | - | +| Name | Type | Description | +| -------- | :-------: | ----------- | +| `to` | `address` | - | +| `amount` | `uint256` | - | +| `force` | `bool` | - | +| `data` | `bytes` | - |
@@ -705,7 +724,7 @@ function transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` @@ -714,13 +733,13 @@ Transfers an `amount` of tokens from the `from` address to the `to` address and #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | The recipient address. | -| `amount` | `uint256` | The amount of tokens to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | The recipient address. | +| `amount` | `uint256` | The amount of tokens to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -740,7 +759,7 @@ function transferBatch( address[] from, address[] to, uint256[] amount, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -749,13 +768,13 @@ Same as [`transfer(...)`](#`transfer) but transfer multiple tokens based on the #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of receiving addresses. | -| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | -| `allowNonLSP1Recipient` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of receiving addresses. | +| `amount` | `uint256[]` | An array of amount of tokens to transfer for each `from -> to` transfer. | +| `force` | `bool[]` | For each transfer, when set to `true`, the `to` address CAN be any address. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes[]` | An array of additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -854,7 +873,7 @@ Save gas by emitting the [`DataChanged`](#datachanged) event with only the first function _updateOperator( address tokenOwner, address operator, - uint256 amount, + uint256 allowance, bytes operatorNotificationData ) internal nonpayable; ``` @@ -863,6 +882,15 @@ Changes token `amount` the `operator` has access to from `tokenOwner` tokens. If the amount is zero the operator is removed from the list of operators, otherwise he is added to the list of operators. If the amount is zero then the operator is being revoked, otherwise the operator amount is being modified. +#### Parameters + +| Name | Type | Description | +| -------------------------- | :-------: | -------------------------------------------------------------------------------------- | +| `tokenOwner` | `address` | The address that will give `operator` an allowance for on its balance. | +| `operator` | `address` | The address to grant an allowance to spend. | +| `allowance` | `uint256` | The maximum amount of token that `operator` can spend from the `tokenOwner`'s balance. | +| `operatorNotificationData` | `bytes` | - | +
### \_mint @@ -871,7 +899,7 @@ If the amount is zero then the operator is being revoked, otherwise the operator function _mint( address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -888,12 +916,12 @@ Mints `amount` of tokens and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | the address to mint tokens for. | -| `amount` | `uint256` | the amount of tokens to mint. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted {Transfer} event, and sent in the LSP1 hook to the `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to mint tokens for. | +| `amount` | `uint256` | The amount of tokens to mint. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted {Transfer} event, and sent in the LSP1 hook to the `to` address. |
@@ -927,12 +955,34 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r | Name | Type | Description | | -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to burn tokens from its balance. | -| `amount` | `uint256` | the amount of tokens to burn. | +| `from` | `address` | The address to burn tokens from its balance. | +| `amount` | `uint256` | The amount of tokens to burn. | | `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
+### \_spendAllowance + +```solidity +function _spendAllowance( + address operator, + address tokenOwner, + uint256 amountToSpend +) internal nonpayable; +``` + +Spend `amountToSpend` from the `operator`'s authorized on behalf of the `tokenOwner`. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | ------------------------------------------------------------------- | +| `operator` | `address` | The address of the operator to decrease the allowance of. | +| `tokenOwner` | `address` | The address that granted an allowance on its balance to `operator`. | +| `amountToSpend` | `uint256` | The amount of tokens to substract in allowance of `operator`. | + +
+ ### \_transfer ```solidity @@ -940,7 +990,7 @@ function _transfer( address from, address to, uint256 amount, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -962,13 +1012,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | the address to decrease the balance. | -| `to` | `address` | the address to increase the balance. | -| `amount` | `uint256` | the amount of tokens to transfer from `from` to `to`. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. | +| Name | Type | Description | +| -------- | :-------: | ------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address to decrease the balance. | +| `to` | `address` | The address to increase the balance. | +| `amount` | `uint256` | The amount of tokens to transfer from `from` to `to`. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the LSP1 hook to the `from` and `to` address. |
@@ -1041,26 +1091,26 @@ If `from` is an EOA or a contract that does not support the LSP1 interface, noth ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` Attempt to notify the token receiver `to` about the `amount` tokens being received. This is done by calling its [`universalReceiver`](#universalreceiver) function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface. -If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `allowNonLSP1Recipient` boolean flag. +If `to` is is an EOA or a contract that does not support the LSP1 interface, the behaviour will depend on the `force` boolean flag. -- if `allowNonLSP1Recipient` is set to `true`, nothing will happen and no notification will be sent. +- if `force` is set to `true`, nothing will happen and no notification will be sent. -- if `allowNonLSP1Recipient` is set to `false, the transaction will revert. +- if `force` is set to `false, the transaction will revert. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | --------------------------------------------------------------------------------------------------- | -| `to` | `address` | The address to call the {universalReceiver} function on. | -| `allowNonLSP1Recipient` | `bool` | a boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | -| `lsp1Data` | `bytes` | the data to be sent to the `to` address in the `universalReceiver(...)` call. | +| Name | Type | Description | +| ---------- | :-------: | --------------------------------------------------------------------------------------------------- | +| `to` | `address` | The address to call the {universalReceiver} function on. | +| `force` | `bool` | A boolean that describe if transfer to a `to` address that does not support LSP1 is allowed or not. | +| `lsp1Data` | `bytes` | The data to be sent to the `to` address in the `universalReceiver(...)` call. |
@@ -1096,6 +1146,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1109,9 +1166,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1236,7 +1290,7 @@ Emitted when `tokenOwner` disables `operator` for `amount` tokens and set its [` ::: ```solidity -event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool allowNonLSP1Recipient, bytes data); +event Transfer(address indexed operator, address indexed from, address indexed to, uint256 amount, bool force, bytes data); ``` Emitted when the `from` transferred successfully `amount` of tokens to `to`. @@ -1249,7 +1303,7 @@ Emitted when the `from` transferred successfully `amount` of tokens to `to`. | `from` **`indexed`** | `address` | The address which tokens were sent from (balance decreased by `-amount`). | | `to` **`indexed`** | `address` | The address that received the tokens (balance increased by `+amount`). | | `amount` | `uint256` | The amount of tokens transferred. | -| `allowNonLSP1Recipient` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | if the transferred enforced the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data included by the caller during the transfer, and sent in the LSP1 hooks to the `from` and `to` addresses. |
@@ -1583,7 +1637,7 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1608,7 +1662,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1618,6 +1672,27 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit
+### LSP7TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-7-DigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-7-DigitalAsset.md#lsp7tokencontractcannotholdvalue) +- Solidity implementation: [`LSP7Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol) +- Error signature: `LSP7TokenContractCannotHoldValue()` +- Error hash: `0x388f5adc` + +::: + +```solidity +error LSP7TokenContractCannotHoldValue(); +``` + +_LSP7 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP7 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP7TokenOwnerCannotBeOperator :::note References diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md index af61aefbf0..df5fc75593 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md @@ -58,6 +58,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP8 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP8 contract. + +
+ ### authorizeOperator :::note References @@ -563,22 +582,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -598,7 +617,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -607,13 +626,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -702,7 +721,8 @@ mapping(bytes32 => bytes) _store function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; ``` -Save gas by emitting the [`DataChanged`](#datachanged) event with only the first 256 bytes of dataValue +The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed +once the identifiable digital asset contract has been deployed.
@@ -787,7 +807,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -804,12 +824,12 @@ Create `tokenId` by minting it and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | @param tokenId The token ID to create (= mint). | -| `tokenId` | `bytes32` | The token ID to create (= mint). | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | @param tokenId The token ID to create (= mint). | +| `tokenId` | `bytes32` | The token ID to create (= mint). | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. |
@@ -862,7 +882,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -883,13 +903,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | @param tokenId The token to transfer. | -| `tokenId` | `bytes32` | The token to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | @param tokenId The token to transfer. | +| `tokenId` | `bytes32` | The token to transfer. | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -955,13 +975,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -998,6 +1018,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1011,9 +1038,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1139,7 +1163,7 @@ Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on i ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1152,7 +1176,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1319,7 +1343,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1338,7 +1362,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1357,7 +1381,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1376,7 +1400,7 @@ reverts when trying to set the zero address as an operator. error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1395,7 +1419,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1420,7 +1444,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1446,7 +1470,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1472,7 +1496,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1501,7 +1525,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1526,7 +1550,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1551,7 +1575,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -1562,6 +1586,46 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ +### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8IdentifiableDigitalAsset.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -1577,7 +1641,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md index 3b57aa3699..acfdb68cd9 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8Burnable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP8 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP8 contract. + +
+ ### authorizeOperator :::note References @@ -589,22 +608,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -624,7 +643,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -633,13 +652,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -728,7 +747,8 @@ mapping(bytes32 => bytes) _store function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; ``` -Save gas by emitting the [`DataChanged`](#datachanged) event with only the first 256 bytes of dataValue +The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed +once the identifiable digital asset contract has been deployed.
@@ -813,7 +833,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -830,12 +850,12 @@ Create `tokenId` by minting it and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | @param tokenId The token ID to create (= mint). | -| `tokenId` | `bytes32` | The token ID to create (= mint). | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | @param tokenId The token ID to create (= mint). | +| `tokenId` | `bytes32` | The token ID to create (= mint). | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. |
@@ -888,7 +908,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -909,13 +929,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | @param tokenId The token to transfer. | -| `tokenId` | `bytes32` | The token to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | @param tokenId The token to transfer. | +| `tokenId` | `bytes32` | The token to transfer. | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -981,13 +1001,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -1024,6 +1044,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1037,9 +1064,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1165,7 +1189,7 @@ Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on i ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1178,7 +1202,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1345,7 +1369,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1364,7 +1388,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1383,7 +1407,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1402,7 +1426,7 @@ reverts when trying to set the zero address as an operator. error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1421,7 +1445,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1446,7 +1470,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1472,7 +1496,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1498,7 +1522,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1527,7 +1551,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1552,7 +1576,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1577,7 +1601,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -1588,6 +1612,46 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8Burnable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ +### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8Burnable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -1603,7 +1667,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md index a693708886..5946dd474a 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8CappedSupply.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP8 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP8 contract. + +
+ ### authorizeOperator :::note References @@ -535,7 +554,7 @@ Returns the list of `tokenIds` for the `tokenOwner` address. function tokenSupplyCap() external view returns (uint256); ``` -_The maximum supply amount of tokens allowed to exist is `_tokenSupplyCap`._ +_The maximum supply amount of tokens allowed to exist is `_TOKEN_SUPPLY_CAP`._ Get the maximum number of tokens that can exist to circulate. Once [`totalSupply`](#totalsupply) reaches reaches [`totalSuuplyCap`](#totalsuuplycap), it is not possible to mint more tokens. @@ -588,22 +607,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -623,7 +642,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -632,13 +651,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -727,7 +746,8 @@ mapping(bytes32 => bytes) _store function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; ``` -Save gas by emitting the [`DataChanged`](#datachanged) event with only the first 256 bytes of dataValue +The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed +once the identifiable digital asset contract has been deployed.
@@ -812,7 +832,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -872,7 +892,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -893,13 +913,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | @param tokenId The token to transfer. | -| `tokenId` | `bytes32` | The token to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | @param tokenId The token to transfer. | +| `tokenId` | `bytes32` | The token to transfer. | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -965,13 +985,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -1008,6 +1028,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1021,9 +1048,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1149,7 +1173,7 @@ Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on i ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1162,7 +1186,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1329,7 +1353,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1348,7 +1372,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1367,7 +1391,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1428,7 +1452,7 @@ Reverts when setting `0` for the [`tokenSupplyCap`](#tokensupplycap). The max to error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1447,7 +1471,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1472,7 +1496,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1498,7 +1522,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1524,7 +1548,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1553,7 +1577,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1578,7 +1602,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1603,7 +1627,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -1614,6 +1638,46 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8CappedSupply.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ +### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8CappedSupply.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -1629,7 +1693,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md index 85efdae389..d1693dda6e 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8CompatibleERC721.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP8 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP8 contract. + +
+ ### approve :::note References @@ -501,7 +520,7 @@ Remove access of `operator` for a given `tokenId`, disallowing it to transfer `t :::info -This function sets the `allowNonLSP1Recipient` parameter to `true` so that EOAs and any contract can receive the `tokenId`. +This function sets the `force` parameter to `true` so that EOAs and any contract can receive the `tokenId`. ::: @@ -540,7 +559,7 @@ Safe Transfer function without optional data from the ERC721 standard interface. :::info -This function sets the `allowNonLSP1Recipient` parameter to `true` so that EOAs and any contract can receive the `tokenId`. +This function sets the `force` parameter to `true` so that EOAs and any contract can receive the `tokenId`. ::: @@ -882,22 +901,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -917,7 +936,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -926,13 +945,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -949,7 +968,7 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token :::info -This function sets the `allowNonLSP1Recipient` parameter to `true` so that EOAs and any contract can receive the `tokenId`. +This function sets the `force` parameter to `true` so that EOAs and any contract can receive the `tokenId`. ::: @@ -1143,7 +1162,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1165,7 +1184,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1234,13 +1253,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -1277,6 +1296,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1290,9 +1316,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1544,7 +1567,7 @@ Emitted when `value` tokens are moved from one account (`from`) to another (`to` ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1557,7 +1580,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1724,7 +1747,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1743,7 +1766,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1762,7 +1785,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1781,7 +1804,7 @@ reverts when trying to set the zero address as an operator. error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1800,7 +1823,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1825,7 +1848,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1851,7 +1874,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1877,7 +1900,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1906,7 +1929,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1931,7 +1954,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1956,7 +1979,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -1967,6 +1990,46 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8CompatibleERC721.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ +### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8CompatibleERC721.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -1982,7 +2045,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md index 46edaa81d5..36bc2804e1 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md @@ -56,6 +56,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8Enumerable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP8 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP8 contract. + +
+ ### authorizeOperator :::note References @@ -594,22 +613,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -629,7 +648,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -638,13 +657,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -733,7 +752,8 @@ mapping(bytes32 => bytes) _store function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; ``` -Save gas by emitting the [`DataChanged`](#datachanged) event with only the first 256 bytes of dataValue +The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed +once the identifiable digital asset contract has been deployed.
@@ -818,7 +838,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -835,12 +855,12 @@ Create `tokenId` by minting it and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | @param tokenId The token ID to create (= mint). | -| `tokenId` | `bytes32` | The token ID to create (= mint). | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | @param tokenId The token ID to create (= mint). | +| `tokenId` | `bytes32` | The token ID to create (= mint). | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. |
@@ -893,7 +913,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -914,13 +934,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | @param tokenId The token to transfer. | -| `tokenId` | `bytes32` | The token to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | @param tokenId The token to transfer. | +| `tokenId` | `bytes32` | The token to transfer. | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -982,13 +1002,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -1025,6 +1045,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1038,9 +1065,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1166,7 +1190,7 @@ Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on i ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1179,7 +1203,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1346,7 +1370,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1365,7 +1389,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1384,7 +1408,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1403,7 +1427,7 @@ reverts when trying to set the zero address as an operator. error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1422,7 +1446,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1447,7 +1471,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1473,7 +1497,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1499,7 +1523,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1528,7 +1552,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1553,7 +1577,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1578,7 +1602,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -1589,6 +1613,46 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8Enumerable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ +### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8Enumerable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -1604,7 +1668,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md index b495bd998a..33d19c009a 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md @@ -31,18 +31,24 @@ When marked as 'public', a method can be called both externally and internally, ::: ```solidity -constructor(string name_, string symbol_, address newOwner_); +constructor( + string name_, + string symbol_, + address newOwner_, + uint256 tokenIdType_ +); ``` _Deploying a `LSP8CompatibleERC721Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ #### Parameters -| Name | Type | Description | -| ----------- | :-------: | -------------------------------- | -| `name_` | `string` | The name of the token. | -| `symbol_` | `string` | The symbol of the token. | -| `newOwner_` | `address` | The owner of the token contract. | +| Name | Type | Description | +| -------------- | :-------: | -------------------------------- | +| `name_` | `string` | The name of the token. | +| `symbol_` | `string` | The symbol of the token. | +| `newOwner_` | `address` | The owner of the token contract. | +| `tokenIdType_` | `uint256` | - |
@@ -61,6 +67,21 @@ fallback() external payable;
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8CompatibleERC721Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol) + +::: + +```solidity +receive() external payable; +``` + +
+ ### approve :::note References @@ -375,23 +396,23 @@ Returns whether `operator` address is an operator for a given `tokenId`. function mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -_Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `allowNonLSP1Recipient`)._ +_Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`)._ Public [`_mint`](#_mint) function only callable by the [`owner`](#owner). #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------ | -| `to` | `address` | The address that will receive the minted `tokenId`. | -| `tokenId` | `bytes32` | The tokenId to mint. | -| `allowNonLSP1Recipient` | `bool` | Set to `false` to ensure that you are minting for a recipient that implements LSP1, `false` otherwise for forcing the minting. | -| `data` | `bytes` | Any addition data to be sent alongside the minting. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------ | +| `to` | `address` | The address that will receive the minted `tokenId`. | +| `tokenId` | `bytes32` | The tokenId to mint. | +| `force` | `bool` | Set to `false` to ensure that you are minting for a recipient that implements LSP1, `false` otherwise for forcing the minting. | +| `data` | `bytes` | Any addition data to be sent alongside the minting. |
@@ -541,7 +562,7 @@ Remove access of `operator` for a given `tokenId`, disallowing it to transfer `t :::info -This function sets the `allowNonLSP1Recipient` parameter to `true` so that EOAs and any contract can receive the `tokenId`. +This function sets the `force` parameter to `true` so that EOAs and any contract can receive the `tokenId`. ::: @@ -580,7 +601,7 @@ Safe Transfer function without optional data from the ERC721 standard interface. :::info -This function sets the `allowNonLSP1Recipient` parameter to `true` so that EOAs and any contract can receive the `tokenId`. +This function sets the `force` parameter to `true` so that EOAs and any contract can receive the `tokenId`. ::: @@ -922,22 +943,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -957,7 +978,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -966,13 +987,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -989,7 +1010,7 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token :::info -This function sets the `allowNonLSP1Recipient` parameter to `true` so that EOAs and any contract can receive the `tokenId`. +This function sets the `force` parameter to `true` so that EOAs and any contract can receive the `tokenId`. ::: @@ -1183,7 +1204,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1205,7 +1226,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -1274,13 +1295,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -1317,6 +1338,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1330,9 +1358,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1584,7 +1609,7 @@ Emitted when `value` tokens are moved from one account (`from`) to another (`to` ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1597,7 +1622,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1764,7 +1789,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1783,7 +1808,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1802,7 +1827,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1821,7 +1846,7 @@ reverts when trying to set the zero address as an operator. error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1840,7 +1865,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1865,7 +1890,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1891,7 +1916,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1917,7 +1942,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1946,7 +1971,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1971,7 +1996,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1996,7 +2021,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -2007,6 +2032,27 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8CompatibleERC721Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP8TokenIdAlreadyMinted :::note References @@ -2022,7 +2068,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenIdAlreadyMinted(bytes32 tokenId); ``` -reverts when `tokenId` has already been minted. +Reverts when `tokenId` has already been minted. #### Parameters @@ -2032,6 +2078,25 @@ reverts when `tokenId` has already been minted.
+### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8CompatibleERC721Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -2047,7 +2112,7 @@ reverts when `tokenId` has already been minted. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md index 1e54c36b0f..e71fb2a68c 100644 --- a/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md +++ b/docs/contracts/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md @@ -31,18 +31,24 @@ When marked as 'public', a method can be called both externally and internally, ::: ```solidity -constructor(string name_, string symbol_, address newOwner_); +constructor( + string name_, + string symbol_, + address newOwner_, + uint256 tokenIdType_ +); ``` _Deploying a `LSP8Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and address `newOwner_` as the token contract owner._ #### Parameters -| Name | Type | Description | -| ----------- | :-------: | -------------------------------- | -| `name_` | `string` | The name of the token. | -| `symbol_` | `string` | The symbol of the token. | -| `newOwner_` | `address` | The owner of the token contract. | +| Name | Type | Description | +| -------------- | :-------: | -------------------------------- | +| `name_` | `string` | The name of the token. | +| `symbol_` | `string` | The symbol of the token. | +| `newOwner_` | `address` | The owner of the token contract. | +| `tokenIdType_` | `uint256` | - |
@@ -81,6 +87,25 @@ This function is executed when:
+### receive + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#receive) +- Solidity implementation: [`LSP8Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol) + +::: + +```solidity +receive() external payable; +``` + +_LSP8 contract cannot receive native tokens._ + +Reverts whenever someone tries to send native tokens to a LSP8 contract. + +
+ ### authorizeOperator :::note References @@ -292,23 +317,23 @@ Returns whether `operator` address is an operator for a given `tokenId`. function mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -_Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `allowNonLSP1Recipient`)._ +_Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`)._ Public [`_mint`](#_mint) function only callable by the [`owner`](#owner). #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------ | -| `to` | `address` | The address that will receive the minted `tokenId`. | -| `tokenId` | `bytes32` | The tokenId to mint. | -| `allowNonLSP1Recipient` | `bool` | Set to `false` to ensure that you are minting for a recipient that implements LSP1, `false` otherwise for forcing the minting. | -| `data` | `bytes` | Any addition data to be sent alongside the minting. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------ | +| `to` | `address` | The address that will receive the minted `tokenId`. | +| `tokenId` | `bytes32` | The tokenId to mint. | +| `force` | `bool` | Set to `false` to ensure that you are minting for a recipient that implements LSP1, `false` otherwise for forcing the minting. | +| `data` | `bytes` | Any addition data to be sent alongside the minting. |
@@ -621,22 +646,22 @@ function transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) external nonpayable; ``` -Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `allowNonLSP1Recipient` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. +Transfer a given `tokenId` token from the `from` address to the `to` address. If operators are set for a specific `tokenId`, all the operators are revoked after the tokenId have been transferred. The `force` parameter MUST be set to `true` when transferring tokens to Externally Owned Accounts (EOAs) or contracts that do not implement the LSP1 standard. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The address that owns the given `tokenId`. | -| `to` | `address` | The address that will receive the `tokenId`. | -| `tokenId` | `bytes32` | The token ID to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The address that owns the given `tokenId`. | +| `to` | `address` | The address that will receive the `tokenId`. | +| `tokenId` | `bytes32` | The token ID to transfer. | +| `force` | `bool` | When set to `true`, the `to` address CAN be any addres. When set to `false`, the `to` address MUST be a contract that supports the LSP1 UniversalReceiver standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hooks of the `from` and `to` addresses. |
@@ -656,7 +681,7 @@ function transferBatch( address[] from, address[] to, bytes32[] tokenId, - bool[] allowNonLSP1Recipient, + bool[] force, bytes[] data ) external nonpayable; ``` @@ -665,13 +690,13 @@ Transfers multiple tokens at once based on the arrays of `from`, `to` and `token #### Parameters -| Name | Type | Description | -| ----------------------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address[]` | An array of sending addresses. | -| `to` | `address[]` | An array of recipient addresses. | -| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | -| `allowNonLSP1Recipient` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | -| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :---------: | ----------------------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address[]` | An array of sending addresses. | +| `to` | `address[]` | An array of recipient addresses. | +| `tokenId` | `bytes32[]` | An array of token IDs to transfer. | +| `force` | `bool[]` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard and not revert. | +| `data` | `bytes[]` | Any additional data the caller wants included in the emitted event, and sent in the hooks to the `from` and `to` addresses. |
@@ -760,7 +785,8 @@ mapping(bytes32 => bytes) _store function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable; ``` -Save gas by emitting the [`DataChanged`](#datachanged) event with only the first 256 bytes of dataValue +The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed +once the identifiable digital asset contract has been deployed.
@@ -845,7 +871,7 @@ When `tokenId` does not exist then revert with an error. function _mint( address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -862,12 +888,12 @@ Create `tokenId` by minting it and transfers it to `to`. #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `to` | `address` | @param tokenId The token ID to create (= mint). | -| `tokenId` | `bytes32` | The token ID to create (= mint). | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `to` | `address` | @param tokenId The token ID to create (= mint). | +| `tokenId` | `bytes32` | The token ID to create (= mint). | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address. |
@@ -920,7 +946,7 @@ function _transfer( address from, address to, bytes32 tokenId, - bool allowNonLSP1Recipient, + bool force, bytes data ) internal nonpayable; ``` @@ -941,13 +967,13 @@ Any logic in the [`_beforeTokenTransfer`](#_beforetokentransfer) function will r #### Parameters -| Name | Type | Description | -| ----------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | -| `from` | `address` | The sender address. | -| `to` | `address` | @param tokenId The token to transfer. | -| `tokenId` | `bytes32` | The token to transfer. | -| `allowNonLSP1Recipient` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | -| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. | +| Name | Type | Description | +| --------- | :-------: | -------------------------------------------------------------------------------------------------------------------------- | +| `from` | `address` | The sender address. | +| `to` | `address` | @param tokenId The token to transfer. | +| `tokenId` | `bytes32` | The token to transfer. | +| `force` | `bool` | When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard. | +| `data` | `bytes` | Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses. |
@@ -1013,13 +1039,13 @@ LSP1 interface. ```solidity function _notifyTokenReceiver( address to, - bool allowNonLSP1Recipient, + bool force, bytes lsp1Data ) internal nonpayable; ``` An attempt is made to notify the token receiver about the `tokenId` changing owners -using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1. +using LSP1 interface. When force is FALSE the token receiver MUST support LSP1. The receiver may revert when the token being sent is not wanted.
@@ -1056,6 +1082,13 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::info + +The LSP8 Token contract should not hold any native tokens. Any native tokens received by the contract +will be forwarded to the extension address mapped to the selector from `msg.sig`. + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1069,9 +1102,6 @@ Reverts if there is no extension for the function being called. If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the [`msg.data`](#msg.data) appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the [`msg.value`](#msg.value) -Because the function uses assembly [`return()/revert()`](#return) to terminate the call, it cannot be -called before other codes in fallback(). -Otherwise, the codes after \_fallbackLSP17Extendable() may never be reached.
@@ -1197,7 +1227,7 @@ Emitted when `tokenOwner` disables `operator` to transfer or burn `tokenId` on i ::: ```solidity -event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool allowNonLSP1Recipient, bytes data); +event Transfer(address operator, address indexed from, address indexed to, bytes32 indexed tokenId, bool force, bytes data); ``` Emitted when `tokenId` token is transferred from the `from` to the `to` address. @@ -1210,7 +1240,7 @@ Emitted when `tokenId` token is transferred from the `from` to the `to` address. | `from` **`indexed`** | `address` | The previous owner of the `tokenId` | | `to` **`indexed`** | `address` | The new owner of `tokenId` | | `tokenId` **`indexed`** | `bytes32` | The tokenId that was transferred | -| `allowNonLSP1Recipient` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | +| `force` | `bool` | If the token transfer enforces the `to` recipient address to be a contract that implements the LSP1 standard or not. | | `data` | `bytes` | Any additional data the caller included by the caller during the transfer, and sent in the hooks to the `from` and `to` addresses. |
@@ -1377,7 +1407,7 @@ Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital ass error LSP8CannotSendToAddressZero(); ``` -reverts when trying to send token to the zero address. +Reverts when trying to send token to the zero address.
@@ -1396,7 +1426,7 @@ reverts when trying to send token to the zero address. error LSP8CannotSendToSelf(); ``` -reverts when specifying the same address for `from` and `to` in a token transfer. +Reverts when specifying the same address for `from` and `to` in a token transfer.
@@ -1415,7 +1445,7 @@ reverts when specifying the same address for `from` and `to` in a token transfer error LSP8CannotUseAddressZeroAsOperator(); ``` -reverts when trying to set the zero address as an operator. +Reverts when trying to set the zero address as an operator.
@@ -1434,7 +1464,7 @@ reverts when trying to set the zero address as an operator. error LSP8InvalidTransferBatch(); ``` -reverts when the parameters used for `transferBatch` have different lengths. +Reverts when the parameters used for `transferBatch` have different lengths.
@@ -1453,7 +1483,7 @@ reverts when the parameters used for `transferBatch` have different lengths. error LSP8NonExistentTokenId(bytes32 tokenId); ``` -reverts when `tokenId` has not been minted. +Reverts when `tokenId` has not been minted. #### Parameters @@ -1478,7 +1508,7 @@ reverts when `tokenId` has not been minted. error LSP8NonExistingOperator(address operator, bytes32 tokenId); ``` -reverts when `operator` is not an operator for the `tokenId`. +Reverts when `operator` is not an operator for the `tokenId`. #### Parameters @@ -1504,7 +1534,7 @@ reverts when `operator` is not an operator for the `tokenId`. error LSP8NotTokenOperator(bytes32 tokenId, address caller); ``` -reverts when `caller` is not an allowed operator for `tokenId`. +Reverts when `caller` is not an allowed operator for `tokenId`. #### Parameters @@ -1530,7 +1560,7 @@ reverts when `caller` is not an allowed operator for `tokenId`. error LSP8NotTokenOwner(address tokenOwner, bytes32 tokenId, address caller); ``` -reverts when `caller` is not the `tokenOwner` of the `tokenId`. +Reverts when `caller` is not the `tokenOwner` of the `tokenId`. #### Parameters @@ -1559,7 +1589,7 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface( ); ``` -reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` does not implement LSP1 when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1584,7 +1614,7 @@ reverts if the `tokenReceiver` does not implement LSP1 when minting or transferr error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver); ``` -reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`. +Reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`. #### Parameters @@ -1609,7 +1639,7 @@ reverts if the `tokenReceiver` is an EOA when minting or transferring tokens wit error LSP8OperatorAlreadyAuthorized(address operator, bytes32 tokenId); ``` -reverts when `operator` is already authorized for the `tokenId`. +Reverts when `operator` is already authorized for the `tokenId`. #### Parameters @@ -1620,6 +1650,27 @@ reverts when `operator` is already authorized for the `tokenId`.
+### LSP8TokenContractCannotHoldValue + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokencontractcannotholdvalue) +- Solidity implementation: [`LSP8Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol) +- Error signature: `LSP8TokenContractCannotHoldValue()` +- Error hash: `0x61f49442` + +::: + +```solidity +error LSP8TokenContractCannotHoldValue(); +``` + +_LSP8 contract cannot receive native tokens._ + +Error occurs when sending native tokens to the LSP8 contract without sending any data. E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension. + +
+ ### LSP8TokenIdAlreadyMinted :::note References @@ -1635,7 +1686,7 @@ reverts when `operator` is already authorized for the `tokenId`. error LSP8TokenIdAlreadyMinted(bytes32 tokenId); ``` -reverts when `tokenId` has already been minted. +Reverts when `tokenId` has already been minted. #### Parameters @@ -1645,6 +1696,25 @@ reverts when `tokenId` has already been minted.
+### LSP8TokenIdTypeNotEditable + +:::note References + +- Specification details: [**LSP-8-IdentifiableDigitalAsset**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtypenoteditable) +- Solidity implementation: [`LSP8Mintable.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol) +- Error signature: `LSP8TokenIdTypeNotEditable()` +- Error hash: `0x53bc1122` + +::: + +```solidity +error LSP8TokenIdTypeNotEditable(); +``` + +Reverts when trying to edit the data key `LSP8TokenIdType` after the identifiable digital asset contract has been deployed. The `LSP8TokenIdType` data key is located inside the ERC725Y Data key-value store of the identifiable digital asset contract. It can be set only once inside the constructor/initializer when the identifiable digital asset contract is being deployed. + +
+ ### LSP8TokenOwnerCannotBeOperator :::note References @@ -1660,7 +1730,7 @@ reverts when `tokenId` has already been minted. error LSP8TokenOwnerCannotBeOperator(); ``` -reverts when trying to authorize or revoke the token's owner as an operator. +Reverts when trying to authorize or revoke the token's owner as an operator.
diff --git a/docs/contracts/contracts/LSP9Vault/LSP9Vault.md b/docs/contracts/contracts/LSP9Vault/LSP9Vault.md index a57c9a9bd7..bb898ed226 100644 --- a/docs/contracts/contracts/LSP9Vault/LSP9Vault.md +++ b/docs/contracts/contracts/LSP9Vault/LSP9Vault.md @@ -202,7 +202,7 @@ _`msg.sender` is accepting ownership of contract: `address(this)`._ Transfer ownership of the contract from the current [`owner()`](#owner) to the [`pendingOwner()`](#pendingowner). Once this function is called: -- The current [`owner()`](#owner) will loose access to the functions restricted to the [`owner()`](#owner) only. +- The current [`owner()`](#owner) will lose access to the functions restricted to the [`owner()`](#owner) only. - The [`pendingOwner()`](#pendingowner) will gain access to the functions restricted to the [`owner()`](#owner) only. @@ -1113,6 +1113,19 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::tip Hint + +This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`. +If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow: + +```solidity +(bool success, bytes memory result) = extension.call{value: msg.value}( + abi.encodePacked(callData, msg.sender, msg.value) +); +``` + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1120,9 +1133,11 @@ function _fallbackLSP17Extendable( ``` Forwards the call to an extension mapped to a function selector. -Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned. -Reverts if there is no extension for the function being called, except for the bytes4(0) function selector, which passes even if there is no extension for it. -If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value` +Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being +called on the account. If there is no extension, the `address(0)` will be returned. +Reverts if there is no extension for the function being called, except for the `bytes4(0)` function selector, which passes even if there is no extension for it. +If there is an extension for the function selector being called, it calls the extension with the +`CALL` opcode, passing the `msg.data` appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the `msg.value`.
diff --git a/docs/contracts/contracts/UniversalProfile.md b/docs/contracts/contracts/UniversalProfile.md index ed5fcdbe8b..1516eb39e0 100644 --- a/docs/contracts/contracts/UniversalProfile.md +++ b/docs/contracts/contracts/UniversalProfile.md @@ -159,7 +159,7 @@ _`msg.sender` is accepting ownership of contract: `address(this)`._ Transfer ownership of the contract from the current [`owner()`](#owner) to the [`pendingOwner()`](#pendingowner). Once this function is called: -- The current [`owner()`](#owner) will loose access to the functions restricted to the [`owner()`](#owner) only. +- The current [`owner()`](#owner) will lose access to the functions restricted to the [`owner()`](#owner) only. - The [`pendingOwner()`](#pendingowner) will gain access to the functions restricted to the [`owner()`](#owner) only. @@ -293,6 +293,12 @@ Generic executor function to: ::: +:::caution Warning + +- The `msg.value` should not be trusted for any method called within the batch with `operationType`: `DELEGATECALL` (4). + +::: + ```solidity function executeBatch( uint256[] operationsType, @@ -531,7 +537,7 @@ The address that ownership of the contract is transferred to. This address may u :::danger -Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable. +Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner or an address allowed by the owner will be permanently inaccessible, making these functions not callable anymore and unusable. ::: @@ -1092,6 +1098,19 @@ Returns the extension address stored under the following data key: ### \_fallbackLSP17Extendable +:::tip Hint + +This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`. +If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow: + +```solidity +(bool success, bytes memory result) = extension.call{value: msg.value}( + abi.encodePacked(callData, msg.sender, msg.value) +); +``` + +::: + ```solidity function _fallbackLSP17Extendable( bytes callData @@ -1099,9 +1118,11 @@ function _fallbackLSP17Extendable( ``` Forwards the call to an extension mapped to a function selector. -Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned. -Reverts if there is no extension for the function being called, except for the bytes4(0) function selector, which passes even if there is no extension for it. -If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value` +Calls [`_getExtension`](#_getextension) to get the address of the extension mapped to the function selector being +called on the account. If there is no extension, the `address(0)` will be returned. +Reverts if there is no extension for the function being called, except for the `bytes4(0)` function selector, which passes even if there is no extension for it. +If there is an extension for the function selector being called, it calls the extension with the +`CALL` opcode, passing the `msg.data` appended with the 20 bytes of the [`msg.sender`](#msg.sender) and 32 bytes of the `msg.value`.
@@ -1608,6 +1629,25 @@ Reverts when the `operationTypeProvided` is none of the default operation types
+### ERC725Y_DataKeysValuesEmptyArray + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#erc725y_datakeysvaluesemptyarray) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `ERC725Y_DataKeysValuesEmptyArray()` +- Error hash: `0x97da5f95` + +::: + +```solidity +error ERC725Y_DataKeysValuesEmptyArray(); +``` + +Reverts when one of the array parameter provided to [`setDataBatch`](#setdatabatch) function is an empty array. + +
+ ### ERC725Y_DataKeysValuesLengthMismatch :::note References @@ -1673,6 +1713,31 @@ reverts when the call to the owner fail with no revert reason
+### LSP20EOACannotVerifyCall + +:::note References + +- Specification details: [**UniversalProfile**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-3-UniversalProfile-Metadata.md#lsp20eoacannotverifycall) +- Solidity implementation: [`UniversalProfile.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/UniversalProfile.sol) +- Error signature: `LSP20EOACannotVerifyCall(address)` +- Error hash: `0x0c392301` + +::: + +```solidity +error LSP20EOACannotVerifyCall(address logicVerifier); +``` + +Reverts when the logic verifier is an Externally Owned Account (EOA) that cannot return the LSP20 magic value. + +#### Parameters + +| Name | Type | Description | +| --------------- | :-------: | --------------------------------- | +| `logicVerifier` | `address` | The address of the logic verifier | + +
+ ### LSP20InvalidMagicValue :::note References diff --git a/docs/contracts/libraries/LSP2Utils.md b/docs/contracts/libraries/LSP2Utils.md index 5163772281..34debe8732 100644 --- a/docs/contracts/libraries/LSP2Utils.md +++ b/docs/contracts/libraries/LSP2Utils.md @@ -361,50 +361,6 @@ Verify if `data` is an abi-encoded array.
-### isEncodedArrayOfAddresses - -```solidity -function isEncodedArrayOfAddresses(bytes data) internal pure returns (bool); -``` - -Verify if `data` is an abi-encoded array of addresses (`address[]`) encoded according to the ABI specs. - -#### Parameters - -| Name | Type | Description | -| ------ | :-----: | -------------------------- | -| `data` | `bytes` | The bytes value to verify. | - -#### Returns - -| Name | Type | Description | -| ---- | :----: | ------------------------------------------------------------------------------------- | -| `0` | `bool` | `true` if the `data` represents an abi-encoded array of addresses, `false` otherwise. | - -
- -### isBytes4EncodedArray - -```solidity -function isBytes4EncodedArray(bytes data) internal pure returns (bool); -``` - -Verify if `data` is an abi-array of `bytes4` values (`bytes4[]`) encoded according to the ABI specs. - -#### Parameters - -| Name | Type | Description | -| ------ | :-----: | -------------------------- | -| `data` | `bytes` | The bytes value to verify. | - -#### Returns - -| Name | Type | Description | -| ---- | :----: | ------------------------------------------------------------------------------------ | -| `0` | `bool` | `true` if the `data` represents an abi-encoded array of `bytes4`, `false` otherwise. | - -
- ### isCompactBytesArray ```solidity diff --git a/docs/contracts/libraries/LSP6Utils.md b/docs/contracts/libraries/LSP6Utils.md index 5789174b78..5da90cae49 100644 --- a/docs/contracts/libraries/LSP6Utils.md +++ b/docs/contracts/libraries/LSP6Utils.md @@ -26,6 +26,13 @@ Internal functions cannot be called externally, whether from other smart contrac ### getPermissionsFor +:::info + +If the raw value fetched from the ERC725Y storage of `target` is not 32 bytes long, this is considered +like _"no permissions are set"_ and will return 32 x `0x00` bytes as `bytes32(0)`. + +::: + ```solidity function getPermissionsFor(contract IERC725Y target, address caller) internal view returns (bytes32); ``` diff --git a/docs/standards/universal-profile/lsp6-key-manager.md b/docs/standards/universal-profile/lsp6-key-manager.md index 0205b6c075..84aeba8f1e 100644 --- a/docs/standards/universal-profile/lsp6-key-manager.md +++ b/docs/standards/universal-profile/lsp6-key-manager.md @@ -59,7 +59,7 @@ While the Key Manager allows for a very fine-grained control over the Universal ::: -![LSP6 permissions](/img/standards/lsp6/lsp6-permissions.jpeg) +![LSP6 permissions](/img/standards/lsp6/lsp6-permissions.jpg) Click on the toggles below to **learn more about the features enabled by each permission**. @@ -328,6 +328,16 @@ The permission `SIGN` enables a controller to authenticate on behalf of the UP. +
+ EXECUTE_RELAY_CALL: Enables a controller's signed relay calls to be executable +

+ value = 0x0000000000000000000000000000000000000000000000000000000000400000 +

+ +The permission `EXECUTE_RELAY_CALL` enables a controller's signed relay calls to be executable. This permission will be checked against the controller that signed the relay call. + +
+ :::note When deployed with our [**lsp-factory.js** tool](https://docs.lukso.tech/tools/lsp-factoryjs/getting-started), the Universal Profile owner will have all the permissions above set by default. @@ -517,7 +527,7 @@ To grant permission(s) to a controller, set the following data key-value pair in } ``` -![Address Permissions range](/img/standards/lsp6/lsp6-address-permissions.jpeg) +![Address Permissions range](/img/standards/lsp6/lsp6-address-permissions.jpg) :::danger diff --git a/static/img/standards/lsp6/lsp6-address-permissions.jpeg b/static/img/standards/lsp6/lsp6-address-permissions.jpeg deleted file mode 100644 index ef3070518b..0000000000 Binary files a/static/img/standards/lsp6/lsp6-address-permissions.jpeg and /dev/null differ diff --git a/static/img/standards/lsp6/lsp6-address-permissions.jpg b/static/img/standards/lsp6/lsp6-address-permissions.jpg new file mode 100644 index 0000000000..688211577f Binary files /dev/null and b/static/img/standards/lsp6/lsp6-address-permissions.jpg differ diff --git a/static/img/standards/lsp6/lsp6-permissions.jpeg b/static/img/standards/lsp6/lsp6-permissions.jpeg deleted file mode 100644 index 86a0f87a71..0000000000 Binary files a/static/img/standards/lsp6/lsp6-permissions.jpeg and /dev/null differ diff --git a/static/img/standards/lsp6/lsp6-permissions.jpg b/static/img/standards/lsp6/lsp6-permissions.jpg new file mode 100644 index 0000000000..10c1343dbd Binary files /dev/null and b/static/img/standards/lsp6/lsp6-permissions.jpg differ