From 67cb3333256e31a0c432a9bcd62f08e83e969222 Mon Sep 17 00:00:00 2001 From: Jean Cvllr <31145285+CJ42@users.noreply.github.com> Date: Wed, 27 Sep 2023 13:06:55 +0100 Subject: [PATCH] refactor!: set LSP8 TokenId Type on deployment / initialization (#712) * feat!: add tokenidType setting in `constructor` + prevent updating it via `_setData` * build: add constants for different types of LSP8 tokenIds * refactor: remove error check to allow setting additional future types of tokenIds * docs: auto-generate new docs for LSP8 * test: fix failing tests for Foundry and LSP1 * chore: fix linter errors and re-generate docs * docs: add leading `_` to param name + add Natspec --- README.md | 1 + constants.ts | 18 +++++++ .../LSP4DigitalAssetMetadata.sol | 2 +- .../LSP4DigitalAssetMetadataInitAbstract.sol | 2 +- .../LSP8Constants.sol | 11 +++++ .../LSP8Errors.sol | 7 +++ .../LSP8IdentifiableDigitalAsset.sol | 46 ++++++++++++++++-- ...P8IdentifiableDigitalAssetInitAbstract.sol | 47 +++++++++++++++++-- .../extensions/LSP8CompatibleERC721.sol | 10 ++-- .../LSP8CompatibleERC721InitAbstract.sol | 11 +++-- .../presets/LSP8CompatibleERC721Mintable.sol | 5 +- .../LSP8CompatibleERC721MintableInit.sol | 6 ++- ...P8CompatibleERC721MintableInitAbstract.sol | 10 +++- .../presets/LSP8Mintable.sol | 5 +- .../presets/LSP8MintableInit.sol | 10 +++- .../presets/LSP8MintableInitAbstract.sol | 6 ++- .../Mocks/Tokens/LSP8BurnableInitTester.sol | 6 ++- contracts/Mocks/Tokens/LSP8BurnableTester.sol | 5 +- .../Tokens/LSP8CappedSupplyInitTester.sol | 4 +- .../Mocks/Tokens/LSP8CappedSupplyTester.sol | 3 +- .../Tokens/LSP8CompatibleERC721Tester.sol | 3 +- .../Tokens/LSP8CompatibleERC721TesterInit.sol | 8 +++- .../Mocks/Tokens/LSP8EnumerableInitTester.sol | 6 ++- .../Mocks/Tokens/LSP8EnumerableTester.sol | 5 +- contracts/Mocks/Tokens/LSP8InitTester.sol | 6 ++- contracts/Mocks/Tokens/LSP8Tester.sol | 5 +- .../LSP8IdentifiableDigitalAsset.md | 22 ++++++++- .../extensions/LSP8Burnable.md | 22 ++++++++- .../extensions/LSP8CappedSupply.md | 22 ++++++++- .../extensions/LSP8CompatibleERC721.md | 19 ++++++++ .../extensions/LSP8Enumerable.md | 22 ++++++++- .../presets/LSP8CompatibleERC721Mintable.md | 37 ++++++++++++--- .../presets/LSP8Mintable.md | 40 +++++++++++++--- ...P1UniversalReceiverDelegateUP.behaviour.ts | 12 ++++- ...niversalReceiverDelegateVault.behaviour.ts | 12 ++++- .../Interactions/AllowedFunctions.test.ts | 2 + .../Interactions/AllowedFunctions.test.ts | 2 + .../LSP8CappedSupply.behaviour.ts | 1 + .../LSP8CompatibleERC721.behaviour.ts | 16 +++++++ .../LSP8Enumerable.behaviour.ts | 1 + .../LSP8IdentifiableDigitalAsset.behaviour.ts | 43 ++++++++++++++--- .../LSP8Mintable.behaviour.ts | 1 + .../proxy/LSP8BurnableInit.test.ts | 4 ++ .../proxy/LSP8CappedSupplyInit.test.ts | 5 +- .../proxy/LSP8CompatibleERC721Init.test.ts | 14 +++--- .../proxy/LSP8EnumerableInit.test.ts | 5 +- .../LSP8IdentifiableDigitalAssetInit.test.ts | 18 ++++--- .../proxy/LSP8MintableInit.test.ts | 8 +++- .../standard/LSP8Burnable.test.ts | 4 ++ .../standard/LSP8CappedSupply.test.ts | 3 ++ .../standard/LSP8CompatibleERC721.test.ts | 3 ++ .../standard/LSP8Enumerable.test.ts | 9 +++- .../LSP8IdentifiableDigitalAsset.test.ts | 12 +++-- .../standard/LSP8Mintable.test.ts | 3 ++ .../GasTests/execute/RestrictedController.sol | 6 ++- .../execute/UnrestrictedController.sol | 6 ++- 56 files changed, 523 insertions(+), 99 deletions(-) diff --git a/README.md b/README.md index a5fff68d1..42c6fd102 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ import { ERC725YDataKeys, PERMISSIONS, ALL_PERMISSIONS, + LSP8_TOKEN_ID_TYPES, LSP25_VERSION, ErrorSelectors, EventSigHashes, diff --git a/constants.ts b/constants.ts index 884c1a54b..2b7ff0a76 100644 --- a/constants.ts +++ b/constants.ts @@ -226,6 +226,9 @@ export const ERC725YDataKeys = { // AddressPermissions:AllowedCalls:
+ bytes2(0) 'AddressPermissions:AllowedCalls': '0x4b80742de2bf393a64c70000', }, + LSP8: { + LSP8TokenIdType: '0x715f248956de7ce65e94d9d836bfead479f7e70d69b718d47bfe7b00e05b4fe4', + }, LSP9: { SupportedStandards_LSP9: SupportedStandards.LSP9Vault.key, }, @@ -371,6 +374,21 @@ export const LSP1_TYPE_IDS = { '0xe32c7debcb817925ba4883fdbfc52797187f28f73f860641dab1a68d9b32902c', }; +// LSP8 +// ---------- + +/** + * @dev list of LSP8 Token ID types that can be used to create different types of NFTs. + * @see for details see: https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtype + */ +export const LSP8_TOKEN_ID_TYPES = { + NUMBER: 0, + STRING: 1, + UNIQUE_ID: 2, + HASH: 3, + ADDRESS: 4, +}; + // LSP25 // ---------- diff --git a/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol b/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol index e9e562d47..a57731572 100644 --- a/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +++ b/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol @@ -51,7 +51,7 @@ abstract contract LSP4DigitalAssetMetadata is ERC725Y { /** * @dev The ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed - * via this function once the digital asset contract has been deployed. + * via this function once the digital asset contract has been deployed. * * @dev Save gas by emitting the {DataChanged} event with only the first 256 bytes of dataValue */ diff --git a/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol b/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol index b64e6c1b0..56603d4ff 100644 --- a/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +++ b/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol @@ -55,7 +55,7 @@ abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract { /** * @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed - * via this function once the digital asset contract has been deployed. + * via this function once the digital asset contract has been deployed. * * @dev Save gas by emitting the {DataChanged} event with only the first 256 bytes of dataValue */ diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol index eea9db83a..a117eeaf1 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol @@ -6,6 +6,9 @@ bytes4 constant _INTERFACEID_LSP8 = 0x1ae9ba1f; // --- ERC725Y Data Keys +// keccak256('LSP8TokenIdType') +bytes32 constant _LSP8_TOKENID_TYPE_KEY = 0x715f248956de7ce65e94d9d836bfead479f7e70d69b718d47bfe7b00e05b4fe4; + // bytes10(keccak256('LSP8MetadataAddress')) + bytes2(0) bytes12 constant _LSP8_METADATA_ADDRESS_KEY_PREFIX = 0x73dcc7c3c4096cdc7f8a0000; @@ -22,3 +25,11 @@ bytes32 constant _TYPEID_LSP8_TOKENSRECIPIENT = 0x0b084a55ebf70fd3c06fd755269dac // keccak256('LSP8Tokens_OperatorNotification') bytes32 constant _TYPEID_LSP8_TOKENOPERATOR = 0x8a1c15a8799f71b547e08e2bcb2e85257e81b0a07eee2ce6712549eef1f00970; + +// --- Types of token IDs + +uint256 constant _LSP8_TOKENID_TYPE_NUMBER = 0; +uint256 constant _LSP8_TOKENID_TYPE_STRING = 1; +uint256 constant _LSP8_TOKENID_TYPE_UNIQUE_ID = 2; +uint256 constant _LSP8_TOKENID_TYPE_HASH = 3; +uint256 constant _LSP8_TOKENID_TYPE_ADDRESS = 4; diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol index 24bbe571c..3a37b8ca3 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol @@ -80,3 +80,10 @@ error LSP8TokenOwnerCannotBeOperator(); * @notice LSP8 contract cannot receive native tokens. */ error LSP8TokenContractCannotHoldValue(); + +/** + * @dev 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. + */ +error LSP8TokenIdTypeNotEditable(); diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol index 9a3193796..0143d4ae0 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol @@ -19,8 +19,13 @@ import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol"; import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol"; // constants -import {_INTERFACEID_LSP8} from "./LSP8Constants.sol"; -import {LSP8TokenContractCannotHoldValue} from "./LSP8Errors.sol"; +import {_INTERFACEID_LSP8, _LSP8_TOKENID_TYPE_KEY} from "./LSP8Constants.sol"; + +// errors +import { + LSP8TokenContractCannotHoldValue, + LSP8TokenIdTypeNotEditable +} from "./LSP8Errors.sol"; import { _LSP17_EXTENSION_PREFIX @@ -51,16 +56,32 @@ abstract contract LSP8IdentifiableDigitalAsset is LSP17Extendable { /** - * @notice Sets the token-Metadata + * @notice Deploying a LSP8IdentifiableDigitalAsset with name `name_`, symbol `symbol_`, owned by address `newOwner_` + * with tokenId type `tokenIdType_`. + * + * @dev Deploy a `LSP8IdentifiableDigitalAsset` contract and set the tokenId type inside the ERC725Y storage of the contract. + * This will also set the token `name_` and `symbol_` under the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol`. + * * @param name_ The name of the token * @param symbol_ The symbol of the token * @param newOwner_ The owner of the the token-Metadata + * @param tokenIdType_ The type of tokenIds (= NFTs) that this contract will create. + * Available options are: NUMBER = `0`; STRING = `1`; UNIQUE_ID = `2`; HASH = `3`; ADDRESS = `4`. + * + * @custom:warning Make sure the tokenId type provided on deployment is correct, as it can only be set once + * and cannot be changed in the ERC725Y storage after the contract has been deployed. */ constructor( string memory name_, string memory symbol_, - address newOwner_ - ) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) {} + address newOwner_, + uint256 tokenIdType_ + ) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) { + LSP4DigitalAssetMetadata._setData( + _LSP8_TOKENID_TYPE_KEY, + abi.encode(tokenIdType_) + ); + } // fallback function @@ -190,4 +211,19 @@ abstract contract LSP8IdentifiableDigitalAsset is super.supportsInterface(interfaceId) || LSP17Extendable._supportsInterfaceInERC165Extension(interfaceId); } + + /** + * @inheritdoc LSP4DigitalAssetMetadata + * @dev The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed + * once the identifiable digital asset contract has been deployed. + */ + function _setData( + bytes32 dataKey, + bytes memory dataValue + ) internal virtual override { + if (dataKey == _LSP8_TOKENID_TYPE_KEY) { + revert LSP8TokenIdTypeNotEditable(); + } + LSP4DigitalAssetMetadata._setData(dataKey, dataValue); + } } diff --git a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol index f6041d856..bfcbffa8b 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol @@ -19,8 +19,13 @@ import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol"; import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol"; // constants -import {_INTERFACEID_LSP8} from "./LSP8Constants.sol"; -import {LSP8TokenContractCannotHoldValue} from "./LSP8Errors.sol"; +import {_INTERFACEID_LSP8, _LSP8_TOKENID_TYPE_KEY} from "./LSP8Constants.sol"; + +// errors +import { + LSP8TokenContractCannotHoldValue, + LSP8TokenIdTypeNotEditable +} from "./LSP8Errors.sol"; import { _LSP17_EXTENSION_PREFIX @@ -50,16 +55,35 @@ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is LSP8IdentifiableDigitalAssetCore, LSP17Extendable { + /** + * @dev Initialize a `LSP8IdentifiableDigitalAsset` contract and set the tokenId type inside the ERC725Y storage of the contract. + * This will also set the token `name_` and `symbol_` under the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol`. + * + * @param name_ The name of the token + * @param symbol_ The symbol of the token + * @param newOwner_ The owner of the the token-Metadata + * @param tokenIdType_ The type of tokenIds (= NFTs) that this contract will create. + * Available options are: NUMBER = `0`; STRING = `1`; UNIQUE_ID = `2`; HASH = `3`; ADDRESS = `4`. + * + * @custom:warning Make sure the tokenId type provided on deployment is correct, as it can only be set once + * and cannot be changed in the ERC725Y storage after the contract has been initialized. + */ function _initialize( string memory name_, string memory symbol_, - address newOwner_ - ) internal virtual override onlyInitializing { + address newOwner_, + uint256 tokenIdType_ + ) internal virtual onlyInitializing { LSP4DigitalAssetMetadataInitAbstract._initialize( name_, symbol_, newOwner_ ); + + LSP4DigitalAssetMetadataInitAbstract._setData( + _LSP8_TOKENID_TYPE_KEY, + abi.encode(tokenIdType_) + ); } // fallback function @@ -190,4 +214,19 @@ abstract contract LSP8IdentifiableDigitalAssetInitAbstract is super.supportsInterface(interfaceId) || LSP17Extendable._supportsInterfaceInERC165Extension(interfaceId); } + + /** + * @inheritdoc LSP4DigitalAssetMetadataInitAbstract + * @dev The ERC725Y data key `_LSP8_TOKENID_TYPE_KEY` cannot be changed + * once the identifiable digital asset contract has been deployed. + */ + function _setData( + bytes32 dataKey, + bytes memory dataValue + ) internal virtual override { + if (dataKey == _LSP8_TOKENID_TYPE_KEY) { + revert LSP8TokenIdTypeNotEditable(); + } + LSP4DigitalAssetMetadataInitAbstract._setData(dataKey, dataValue); + } } diff --git a/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol b/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol index 07738be5e..6136f4cf1 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol @@ -23,7 +23,6 @@ import { } from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol"; import { LSP8IdentifiableDigitalAsset, - LSP4DigitalAssetMetadata, ERC725YCore } from "../LSP8IdentifiableDigitalAsset.sol"; import { @@ -74,8 +73,9 @@ abstract contract LSP8CompatibleERC721 is constructor( string memory name_, string memory symbol_, - address newOwner_ - ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {} + address newOwner_, + uint256 tokenIdType_ + ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_, tokenIdType_) {} /** * @inheritdoc LSP8IdentifiableDigitalAsset @@ -407,12 +407,12 @@ abstract contract LSP8CompatibleERC721 is } /** - * @inheritdoc LSP4DigitalAssetMetadata + * @inheritdoc LSP8IdentifiableDigitalAsset */ function _setData( bytes32 key, bytes memory value - ) internal virtual override(LSP4DigitalAssetMetadata, ERC725YCore) { + ) internal virtual override(LSP8IdentifiableDigitalAsset, ERC725YCore) { super._setData(key, value); } } diff --git a/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol b/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol index 42cd8f02e..851a0e361 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol @@ -23,7 +23,6 @@ import { } from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol"; import { LSP8IdentifiableDigitalAssetInitAbstract, - LSP4DigitalAssetMetadataInitAbstract, ERC725YCore } from "../LSP8IdentifiableDigitalAssetInitAbstract.sol"; import { @@ -75,12 +74,14 @@ abstract contract LSP8CompatibleERC721InitAbstract is function _initialize( string memory name_, string memory symbol_, - address newOwner_ + address newOwner_, + uint256 tokenIdType_ ) internal virtual override onlyInitializing { LSP8IdentifiableDigitalAssetInitAbstract._initialize( name_, symbol_, - newOwner_ + newOwner_, + tokenIdType_ ); } @@ -415,7 +416,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is } /** - * @inheritdoc LSP4DigitalAssetMetadataInitAbstract + * @inheritdoc LSP8IdentifiableDigitalAssetInitAbstract */ function _setData( bytes32 key, @@ -423,7 +424,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is ) internal virtual - override(LSP4DigitalAssetMetadataInitAbstract, ERC725YCore) + override(LSP8IdentifiableDigitalAssetInitAbstract, ERC725YCore) { super._setData(key, value); } diff --git a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol index 482394e5b..cec967433 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol @@ -18,8 +18,9 @@ contract LSP8CompatibleERC721Mintable is LSP8CompatibleERC721 { constructor( string memory name_, string memory symbol_, - address newOwner_ - ) LSP8CompatibleERC721(name_, symbol_, newOwner_) {} + address newOwner_, + uint256 tokenIdType_ + ) LSP8CompatibleERC721(name_, symbol_, newOwner_, tokenIdType_) {} /** * @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`). diff --git a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol index 2472662c6..7558bc368 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol @@ -30,12 +30,14 @@ contract LSP8CompatibleERC721MintableInit is function initialize( string memory name_, string memory symbol_, - address newOwner_ + address newOwner_, + uint256 tokenIdType_ ) external virtual initializer { LSP8CompatibleERC721MintableInitAbstract._initialize( name_, symbol_, - newOwner_ + newOwner_, + tokenIdType_ ); } } diff --git a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol index e36d1d2af..58e7d31aa 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol @@ -18,9 +18,15 @@ contract LSP8CompatibleERC721MintableInitAbstract is function _initialize( string memory name_, string memory symbol_, - address newOwner_ + address newOwner_, + uint256 tokenIdType_ ) internal virtual override onlyInitializing { - LSP8CompatibleERC721InitAbstract._initialize(name_, symbol_, newOwner_); + LSP8CompatibleERC721InitAbstract._initialize( + name_, + symbol_, + newOwner_, + tokenIdType_ + ); } /** diff --git a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol index 2b9e389fb..4a113bb47 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol @@ -25,8 +25,9 @@ contract LSP8Mintable is LSP8IdentifiableDigitalAsset, ILSP8Mintable { constructor( string memory name_, string memory symbol_, - address newOwner_ - ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {} + address newOwner_, + uint256 tokenIdType_ + ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_, tokenIdType_) {} /** * @notice Minting tokenId `tokenId` for address `to` with the additional data `data` (Note: allow non-LSP1 recipient is set to `force`). diff --git a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol index 58a43eb0f..72532187e 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol @@ -27,8 +27,14 @@ contract LSP8MintableInit is LSP8MintableInitAbstract { function initialize( string memory name_, string memory symbol_, - address newOwner_ + address newOwner_, + uint256 tokenIdType_ ) external virtual initializer { - LSP8MintableInitAbstract._initialize(name_, symbol_, newOwner_); + LSP8MintableInitAbstract._initialize( + name_, + symbol_, + newOwner_, + tokenIdType_ + ); } } diff --git a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol index 004a0f5af..a7acd984b 100644 --- a/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +++ b/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol @@ -27,12 +27,14 @@ abstract contract LSP8MintableInitAbstract is function _initialize( string memory name_, string memory symbol_, - address newOwner_ + address newOwner_, + uint256 tokenIdType_ ) internal virtual override onlyInitializing { LSP8IdentifiableDigitalAssetInitAbstract._initialize( name_, symbol_, - newOwner_ + newOwner_, + tokenIdType_ ); } diff --git a/contracts/Mocks/Tokens/LSP8BurnableInitTester.sol b/contracts/Mocks/Tokens/LSP8BurnableInitTester.sol index 1d0d0109d..0b63ce67b 100644 --- a/contracts/Mocks/Tokens/LSP8BurnableInitTester.sol +++ b/contracts/Mocks/Tokens/LSP8BurnableInitTester.sol @@ -14,12 +14,14 @@ contract LSP8BurnableInitTester is LSP8BurnableInitAbstract { function initialize( string memory name_, string memory symbol_, - address newOwner_ + address newOwner_, + uint256 tokenIdType_ ) public virtual initializer { LSP8IdentifiableDigitalAssetInitAbstract._initialize( name_, symbol_, - newOwner_ + newOwner_, + tokenIdType_ ); } } diff --git a/contracts/Mocks/Tokens/LSP8BurnableTester.sol b/contracts/Mocks/Tokens/LSP8BurnableTester.sol index ae492c50d..02c38dbb4 100644 --- a/contracts/Mocks/Tokens/LSP8BurnableTester.sol +++ b/contracts/Mocks/Tokens/LSP8BurnableTester.sol @@ -14,6 +14,7 @@ contract LSP8BurnableTester is LSP8Burnable { constructor( string memory name_, string memory symbol_, - address newOwner_ - ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {} + address newOwner_, + uint256 tokenIdType_ + ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_, tokenIdType_) {} } diff --git a/contracts/Mocks/Tokens/LSP8CappedSupplyInitTester.sol b/contracts/Mocks/Tokens/LSP8CappedSupplyInitTester.sol index 93571c7b4..ece6a3b52 100644 --- a/contracts/Mocks/Tokens/LSP8CappedSupplyInitTester.sol +++ b/contracts/Mocks/Tokens/LSP8CappedSupplyInitTester.sol @@ -15,12 +15,14 @@ contract LSP8CappedSupplyInitTester is LSP8CappedSupplyInitAbstract { string memory name_, string memory symbol_, address newOwner_, + uint256 tokenIdType_, uint256 tokenSupplyCap_ ) public virtual initializer { LSP8IdentifiableDigitalAssetInitAbstract._initialize( name_, symbol_, - newOwner_ + newOwner_, + tokenIdType_ ); LSP8CappedSupplyInitAbstract._initialize(tokenSupplyCap_); } diff --git a/contracts/Mocks/Tokens/LSP8CappedSupplyTester.sol b/contracts/Mocks/Tokens/LSP8CappedSupplyTester.sol index a05d2f09f..5ee6bea0c 100644 --- a/contracts/Mocks/Tokens/LSP8CappedSupplyTester.sol +++ b/contracts/Mocks/Tokens/LSP8CappedSupplyTester.sol @@ -15,9 +15,10 @@ contract LSP8CappedSupplyTester is LSP8CappedSupply { string memory name_, string memory symbol_, address newOwner_, + uint256 tokenIdType_, uint256 tokenSupplyCap_ ) - LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) + LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_, tokenIdType_) LSP8CappedSupply(tokenSupplyCap_) {} diff --git a/contracts/Mocks/Tokens/LSP8CompatibleERC721Tester.sol b/contracts/Mocks/Tokens/LSP8CompatibleERC721Tester.sol index 705a13515..e713ebe63 100644 --- a/contracts/Mocks/Tokens/LSP8CompatibleERC721Tester.sol +++ b/contracts/Mocks/Tokens/LSP8CompatibleERC721Tester.sol @@ -17,8 +17,9 @@ contract LSP8CompatibleERC721Tester is LSP8CompatibleERC721 { string memory name_, string memory symbol_, address newOwner_, + uint256 tokenIdType_, bytes memory tokenURIValue_ - ) LSP8CompatibleERC721(name_, symbol_, newOwner_) { + ) LSP8CompatibleERC721(name_, symbol_, newOwner_, tokenIdType_) { _setData(_LSP4_METADATA_KEY, tokenURIValue_); } diff --git a/contracts/Mocks/Tokens/LSP8CompatibleERC721TesterInit.sol b/contracts/Mocks/Tokens/LSP8CompatibleERC721TesterInit.sol index 7cb92bf08..51689eb2e 100644 --- a/contracts/Mocks/Tokens/LSP8CompatibleERC721TesterInit.sol +++ b/contracts/Mocks/Tokens/LSP8CompatibleERC721TesterInit.sol @@ -24,9 +24,15 @@ contract LSP8CompatibleERC721InitTester is LSP8CompatibleERC721InitAbstract { string memory name_, string memory symbol_, address newOwner_, + uint256 tokenIdType_, bytes memory tokenURIValue_ ) public virtual initializer { - LSP8CompatibleERC721InitAbstract._initialize(name_, symbol_, newOwner_); + LSP8CompatibleERC721InitAbstract._initialize( + name_, + symbol_, + newOwner_, + tokenIdType_ + ); _setData(_LSP4_METADATA_KEY, tokenURIValue_); } diff --git a/contracts/Mocks/Tokens/LSP8EnumerableInitTester.sol b/contracts/Mocks/Tokens/LSP8EnumerableInitTester.sol index f809100ca..50aa38f66 100644 --- a/contracts/Mocks/Tokens/LSP8EnumerableInitTester.sol +++ b/contracts/Mocks/Tokens/LSP8EnumerableInitTester.sol @@ -14,12 +14,14 @@ contract LSP8EnumerableInitTester is LSP8EnumerableInitAbstract { function initialize( string memory name, string memory symbol, - address newOwner + address newOwner, + uint256 tokenIdType ) public virtual initializer { LSP8IdentifiableDigitalAssetInitAbstract._initialize( name, symbol, - newOwner + newOwner, + tokenIdType ); } diff --git a/contracts/Mocks/Tokens/LSP8EnumerableTester.sol b/contracts/Mocks/Tokens/LSP8EnumerableTester.sol index f2bde7f42..ef7d25858 100644 --- a/contracts/Mocks/Tokens/LSP8EnumerableTester.sol +++ b/contracts/Mocks/Tokens/LSP8EnumerableTester.sol @@ -14,8 +14,9 @@ contract LSP8EnumerableTester is LSP8Enumerable { constructor( string memory name, string memory symbol, - address newOwner - ) LSP8IdentifiableDigitalAsset(name, symbol, newOwner) {} + address newOwner, + uint256 tokenIdType + ) LSP8IdentifiableDigitalAsset(name, symbol, newOwner, tokenIdType) {} function mint(address to, bytes32 tokenId) public { _mint(to, tokenId, true, "token printer go brrr"); diff --git a/contracts/Mocks/Tokens/LSP8InitTester.sol b/contracts/Mocks/Tokens/LSP8InitTester.sol index 9efdabfc2..9f8e3245d 100644 --- a/contracts/Mocks/Tokens/LSP8InitTester.sol +++ b/contracts/Mocks/Tokens/LSP8InitTester.sol @@ -17,12 +17,14 @@ contract LSP8InitTester is function initialize( string memory name, string memory symbol, - address newOwner + address newOwner, + uint256 tokenIdType ) public initializer { LSP8IdentifiableDigitalAssetInitAbstract._initialize( name, symbol, - newOwner + newOwner, + tokenIdType ); } diff --git a/contracts/Mocks/Tokens/LSP8Tester.sol b/contracts/Mocks/Tokens/LSP8Tester.sol index d6af853dc..337cdc2b9 100644 --- a/contracts/Mocks/Tokens/LSP8Tester.sol +++ b/contracts/Mocks/Tokens/LSP8Tester.sol @@ -14,8 +14,9 @@ contract LSP8Tester is LSP8IdentifiableDigitalAsset, LSP8Burnable { constructor( string memory name, string memory symbol, - address newOwner - ) LSP8IdentifiableDigitalAsset(name, symbol, newOwner) {} + address newOwner, + uint256 tokenIdType + ) LSP8IdentifiableDigitalAsset(name, symbol, newOwner, tokenIdType) {} function mint( address to, diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md b/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md index 47bb4a37c..64eb7b0b8 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.md @@ -721,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.
@@ -1606,6 +1607,25 @@ Error occurs when sending native tokens to the LSP8 contract without sending any
+### 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 diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md index 6864202c2..acfdb68cd 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.md @@ -747,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.
@@ -1632,6 +1633,25 @@ Error occurs when sending native tokens to the LSP8 contract without sending any
+### 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 diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md index e659b3842..5946dd474 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.md @@ -746,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.
@@ -1658,6 +1659,25 @@ Error occurs when sending native tokens to the LSP8 contract without sending any
+### 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 diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md index beb1a520d..d1693dda6 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.md @@ -2011,6 +2011,25 @@ Error occurs when sending native tokens to the LSP8 contract without sending any
+### 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 diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md index 5b4667384..36bc2804e 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md +++ b/docs/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.md @@ -752,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.
@@ -1633,6 +1634,25 @@ Error occurs when sending native tokens to the LSP8 contract without sending any
+### 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 diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md index 687547fe6..33d19c009 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.md +++ b/docs/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` | - |
@@ -2072,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 diff --git a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md b/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md index 569610357..e71fb2a68 100644 --- a/docs/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.md +++ b/docs/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` | - |
@@ -779,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.
@@ -1689,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 diff --git a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts index adf8bc19c..e38f35450 100644 --- a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts +++ b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP.behaviour.ts @@ -30,7 +30,13 @@ import { import { ARRAY_LENGTH, LSP1_HOOK_PLACEHOLDER, abiCoder } from '../utils/helpers'; // constants -import { ERC725YDataKeys, INTERFACE_IDS, OPERATION_TYPES, LSP1_TYPE_IDS } from '../../constants'; +import { + ERC725YDataKeys, + INTERFACE_IDS, + OPERATION_TYPES, + LSP1_TYPE_IDS, + LSP8_TOKEN_ID_TYPES, +} from '../../constants'; // fixtures import { callPayload, getLSP5MapAndArrayKeysValue, setupKeyManager } from '../utils/fixtures'; @@ -1743,18 +1749,21 @@ export const shouldBehaveLikeLSP1Delegate = ( 'TokenAlpha', 'TA', context.accounts.random.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); lsp8TokenB = await new LSP8Tester__factory(context.accounts.random).deploy( 'TokenBeta', 'TB', context.accounts.random.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); lsp8TokenC = await new LSP8Tester__factory(context.accounts.random).deploy( 'TokenGamma', 'TA', context.accounts.random.address, + LSP8_TOKEN_ID_TYPES.UNIQUE_ID, ); }); @@ -3069,6 +3078,7 @@ export const shouldBehaveLikeLSP1Delegate = ( 'MyToken', 'MTK', context.universalProfile1.address, + LSP8_TOKEN_ID_TYPES.NUMBER, ); // Mint token for UP1 await LSP8.mint(context.universalProfile1.address, '0x' + '0'.repeat(64), true, '0x'); diff --git a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault.behaviour.ts b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault.behaviour.ts index 866dab1d6..c773e1e03 100644 --- a/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault.behaviour.ts +++ b/tests/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault.behaviour.ts @@ -19,7 +19,13 @@ import { import { ARRAY_LENGTH, LSP1_HOOK_PLACEHOLDER, abiCoder } from '../utils/helpers'; // constants -import { ERC725YDataKeys, INTERFACE_IDS, OPERATION_TYPES, LSP1_TYPE_IDS } from '../../constants'; +import { + ERC725YDataKeys, + INTERFACE_IDS, + OPERATION_TYPES, + LSP1_TYPE_IDS, + LSP8_TOKEN_ID_TYPES, +} from '../../constants'; import { callPayload, getLSP5MapAndArrayKeysValue } from '../utils/fixtures'; import { BigNumber, BytesLike, Transaction } from 'ethers'; @@ -1151,18 +1157,21 @@ export const shouldBehaveLikeLSP1Delegate = (buildContext: () => Promise Promise Promise Promise { + it('should not allow to update the `LSP8TokenIdType` after deployment', async () => { + await expect( + context.lsp8CompatibleERC721.setData(ERC725YDataKeys.LSP8.LSP8TokenIdType, '0xdeadbeef'), + ).to.be.revertedWithCustomError(context.lsp8CompatibleERC721, 'LSP8TokenIdTypeNotEditable'); + }); + }); + + describe('when setting data', () => { + it('should not allow to update the `LSP8TokenIdType` after deployment', async () => { + await expect( + context.lsp8CompatibleERC721.setData(ERC725YDataKeys.LSP8.LSP8TokenIdType, '0xdeadbeef'), + ).to.be.revertedWithCustomError(context.lsp8CompatibleERC721, 'LSP8TokenIdTypeNotEditable'); + }); + }); + describe('when checking supported ERC165 interfaces', () => { it('should support ERC721', async () => { expect(await context.lsp8CompatibleERC721.supportsInterface(INTERFACE_IDS.ERC721)).to.equal( diff --git a/tests/LSP8IdentifiableDigitalAsset/LSP8Enumerable.behaviour.ts b/tests/LSP8IdentifiableDigitalAsset/LSP8Enumerable.behaviour.ts index 5c567be7f..0be64bb05 100644 --- a/tests/LSP8IdentifiableDigitalAsset/LSP8Enumerable.behaviour.ts +++ b/tests/LSP8IdentifiableDigitalAsset/LSP8Enumerable.behaviour.ts @@ -18,6 +18,7 @@ export type LSP8EnumerableDeployParams = { name: string; symbol: string; newOwner: string; + tokenIdType: number; }; export type LSP8EnumerableTestContext = { diff --git a/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts b/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts index df1c4a9af..7c726b6c5 100644 --- a/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts +++ b/tests/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.behaviour.ts @@ -42,6 +42,7 @@ export type LSP8DeployParams = { name: string; symbol: string; newOwner: string; + tokenIdType: number; }; export type LSP8TestContext = { @@ -58,12 +59,30 @@ export type ExpectedError = { const mintedTokenId = tokenIdAsBytes32(10); const neverMintedTokenId = tokenIdAsBytes32(1010110); -export const shouldBehaveLikeLSP8 = (buildContext: () => Promise) => { +export const shouldBehaveLikeLSP8 = ( + buildContext: (nftType: number) => Promise, +) => { let context: LSP8TestContext; let expectedTotalSupply = 0; before(async () => { - context = await buildContext(); + context = await buildContext(0); + }); + + describe('when setting data', () => { + it('should not allow to update the `LSP8TokenIdType` after deployment', async () => { + await expect( + context.lsp8.setData(ERC725YDataKeys.LSP8.LSP8TokenIdType, '0xdeadbeef'), + ).to.be.revertedWithCustomError(context.lsp8, 'LSP8TokenIdTypeNotEditable'); + }); + }); + + describe('when setting data', () => { + it('should not allow to update the `LSP8TokenIdType` after deployment', async () => { + await expect( + context.lsp8.setData(ERC725YDataKeys.LSP8.LSP8TokenIdType, '0xdeadbeef'), + ).to.be.revertedWithCustomError(context.lsp8, 'LSP8TokenIdTypeNotEditable'); + }); }); describe('when minting tokens', () => { @@ -625,7 +644,7 @@ export const shouldBehaveLikeLSP8 = (buildContext: () => Promise { - context = await buildContext(); + context = await buildContext(0); // mint a tokenId await context.lsp8.mint( @@ -1495,7 +1514,7 @@ export const shouldBehaveLikeLSP8 = (buildContext: () => Promise { beforeEach(async () => { - context = await buildContext(); + context = await buildContext(0); await context.lsp8.mint( context.accounts.owner.address, @@ -1697,7 +1716,7 @@ export const shouldBehaveLikeLSP8 = (buildContext: () => Promise { - context = await buildContext(); + context = await buildContext(0); oldOwner = context.accounts.owner; newOwner = context.accounts.anyone; }); @@ -1716,7 +1735,7 @@ export const shouldBehaveLikeLSP8 = (buildContext: () => Promise { beforeEach(async () => { - context = await buildContext(); + context = await buildContext(0); await context.lsp8.connect(oldOwner).transferOwnership(newOwner.address); }); @@ -1805,7 +1824,7 @@ export const shouldInitializeLikeLSP8 = ( let context: LSP8InitializeTestContext; before(async () => { - context = await buildContext(); + context = await buildContext(0); }); describe('when the contract was initialized', () => { @@ -1853,6 +1872,16 @@ export const shouldInitializeLikeLSP8 = ( .to.emit(context.lsp8, 'DataChanged') .withArgs(symbolKey, expectedSymbolValue); expect(await context.lsp8.getData(symbolKey)).to.equal(expectedSymbolValue); + + const lsp8TokenIdTypeDataKey = ERC725YDataKeys.LSP8['LSP8TokenIdType']; + const expectedTokenIdDataValue = abiCoder.encode( + ['uint256'], + [context.deployParams.tokenIdType], + ); + await expect(context.initializeTransaction) + .to.emit(context.lsp8, 'DataChanged') + .withArgs(lsp8TokenIdTypeDataKey, expectedTokenIdDataValue); + expect(await context.lsp8.getData(lsp8TokenIdTypeDataKey)).to.equal(expectedTokenIdDataValue); }); }); }; diff --git a/tests/LSP8IdentifiableDigitalAsset/LSP8Mintable.behaviour.ts b/tests/LSP8IdentifiableDigitalAsset/LSP8Mintable.behaviour.ts index 8afb19708..0c4d54e6a 100644 --- a/tests/LSP8IdentifiableDigitalAsset/LSP8Mintable.behaviour.ts +++ b/tests/LSP8IdentifiableDigitalAsset/LSP8Mintable.behaviour.ts @@ -28,6 +28,7 @@ export type LSP8MintableDeployParams = { name: string; symbol: string; newOwner: string; + tokenIdType: number; }; export type LSP8MintableTestContext = { diff --git a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8BurnableInit.test.ts b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8BurnableInit.test.ts index 208769948..f6d1cf7db 100644 --- a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8BurnableInit.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8BurnableInit.test.ts @@ -7,6 +7,7 @@ import { LSP8BurnableInitTester, LSP8BurnableInitTester__factory } from '../../. import { shouldInitializeLikeLSP8 } from '../LSP8IdentifiableDigitalAsset.behaviour'; import { deployProxy } from '../../utils/fixtures'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; type LSP8BurnableInitTestContext = { accounts: SignerWithAddress[]; @@ -15,6 +16,7 @@ type LSP8BurnableInitTestContext = { name: string; symbol: string; newOwner: string; + tokenIdType: number; }; }; @@ -25,6 +27,7 @@ describe('LSP8BurnableInit with proxy', () => { name: 'LSP8 Burnable - deployed with constructor', symbol: 'BRN', newOwner: accounts[0].address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const lsp8BurnableImplementation = await new LSP8BurnableInitTester__factory( @@ -41,6 +44,7 @@ describe('LSP8BurnableInit with proxy', () => { context.deployParams.name, context.deployParams.symbol, context.deployParams.newOwner, + context.deployParams.tokenIdType, ); }; diff --git a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CappedSupplyInit.test.ts b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CappedSupplyInit.test.ts index 18dfb8c16..b1091b1b4 100644 --- a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CappedSupplyInit.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CappedSupplyInit.test.ts @@ -10,6 +10,7 @@ import { } from '../LSP8CappedSupply.behaviour'; import { deployProxy } from '../../utils/fixtures'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8CappedSupplyInit with proxy', () => { const buildTestContext = async () => { @@ -18,6 +19,7 @@ describe('LSP8CappedSupplyInit with proxy', () => { name: 'LSP8 capped supply - deployed with proxy', symbol: 'CAP', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, tokenSupplyCap: ethers.BigNumber.from('2'), }; const lsp8CappedSupplyInit = await new LSP8CappedSupplyInitTester__factory( @@ -30,10 +32,11 @@ describe('LSP8CappedSupplyInit with proxy', () => { }; const initializeProxy = async (context: LSP8CappedSupplyTestContext) => { - return context.lsp8CappedSupply['initialize(string,string,address,uint256)']( + return context.lsp8CappedSupply['initialize(string,string,address,uint256,uint256)']( context.deployParams.name, context.deployParams.symbol, context.deployParams.newOwner, + context.deployParams.tokenIdType, context.deployParams.tokenSupplyCap, ); }; diff --git a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CompatibleERC721Init.test.ts b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CompatibleERC721Init.test.ts index fc0229f59..cf444cca8 100644 --- a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CompatibleERC721Init.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8CompatibleERC721Init.test.ts @@ -14,6 +14,7 @@ import { } from '../LSP8CompatibleERC721.behaviour'; import { deployProxy } from '../../utils/fixtures'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8CompatibleERC721Init with proxy', () => { const buildTestContext = async (): Promise => { @@ -31,6 +32,7 @@ describe('LSP8CompatibleERC721Init with proxy', () => { name: 'LSP8 - deployed with constructor', symbol: 'NFT', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, lsp4MetadataValue, }; @@ -47,10 +49,11 @@ describe('LSP8CompatibleERC721Init with proxy', () => { }; const initializeProxy = async (context: LSP8CompatibleERC721TestContext) => { - return context.lsp8CompatibleERC721['initialize(string,string,address,bytes)']( + return context.lsp8CompatibleERC721['initialize(string,string,address,uint256,bytes)']( context.deployParams.name, context.deployParams.symbol, context.deployParams.newOwner, + context.deployParams.tokenIdType, context.deployParams.lsp4MetadataValue, ); }; @@ -65,10 +68,11 @@ describe('LSP8CompatibleERC721Init with proxy', () => { const randomCaller = accounts[1]; await expect( - lsp8CompatibilityForERC721TesterInit['initialize(string,string,address,bytes)']( + lsp8CompatibilityForERC721TesterInit['initialize(string,string,address,uint256,bytes)']( 'XXXXXXXXXXX', 'XXX', randomCaller.address, + 0, '0x', ), ).to.be.revertedWith('Initializable: contract is already initialized'); @@ -84,11 +88,7 @@ describe('LSP8CompatibleERC721Init with proxy', () => { const randomCaller = accounts[1]; await expect( - lsp8CompatibleERC721MintableInit['initialize(string,string,address)']( - 'XXXXXXXXXXX', - 'XXX', - randomCaller.address, - ), + lsp8CompatibleERC721MintableInit.initialize('XXXXXXXXXXX', 'XXX', randomCaller.address, 0), ).to.be.revertedWith('Initializable: contract is already initialized'); }); }); diff --git a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8EnumerableInit.test.ts b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8EnumerableInit.test.ts index ba3ed1bc8..7aae65422 100644 --- a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8EnumerableInit.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8EnumerableInit.test.ts @@ -9,6 +9,7 @@ import { } from '../LSP8Enumerable.behaviour'; import { deployProxy } from '../../utils/fixtures'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8EnumerableInit with proxy', () => { const buildTestContext = async () => { @@ -17,6 +18,7 @@ describe('LSP8EnumerableInit with proxy', () => { name: 'LSP8 Enumerable - deployed with proxy', symbol: 'LSP8 NMRBL', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const LSP8EnumerableInit: LSP8EnumerableInitTester = @@ -29,10 +31,11 @@ describe('LSP8EnumerableInit with proxy', () => { }; const initializeProxy = async (context: LSP8EnumerableTestContext) => { - return context.lsp8Enumerable['initialize(string,string,address)']( + return context.lsp8Enumerable['initialize(string,string,address,uint256)']( context.deployParams.name, context.deployParams.symbol, context.deployParams.newOwner, + context.deployParams.tokenIdType, ); }; diff --git a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8IdentifiableDigitalAssetInit.test.ts b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8IdentifiableDigitalAssetInit.test.ts index faaceab15..cc58c704e 100644 --- a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8IdentifiableDigitalAssetInit.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8IdentifiableDigitalAssetInit.test.ts @@ -18,12 +18,13 @@ import { import { deployProxy } from '../../utils/fixtures'; describe('LSP8IdentifiableDigitalAssetInit with proxy', () => { - const buildTestContext = async (): Promise => { + const buildTestContext = async (nftType: number): Promise => { const accounts = await getNamedAccounts(); const deployParams = { name: 'LSP8 - deployed with constructor', symbol: 'NFT', newOwner: accounts.owner.address, + tokenIdType: nftType, }; const lsp8TesterInit = await new LSP8InitTester__factory(accounts.owner).deploy(); @@ -35,7 +36,7 @@ describe('LSP8IdentifiableDigitalAssetInit with proxy', () => { const buildLSP4DigitalAssetMetadataTestContext = async (): Promise => { - const { lsp8 } = await buildTestContext(); + const { lsp8 } = await buildTestContext(0); const accounts = await ethers.getSigners(); const deployParams = { @@ -50,10 +51,11 @@ describe('LSP8IdentifiableDigitalAssetInit with proxy', () => { }; const initializeProxy = async (context: LSP8TestContext) => { - return context.lsp8['initialize(string,string,address)']( + return context.lsp8['initialize(string,string,address,uint256)']( context.deployParams.name, context.deployParams.symbol, context.deployParams.newOwner, + context.deployParams.tokenIdType, ); }; @@ -61,15 +63,16 @@ describe('LSP8IdentifiableDigitalAssetInit with proxy', () => { let context: LSP8TestContext; before(async () => { - context = await buildTestContext(); + context = await buildTestContext(0); }); it('should revert when initializing with address(0) as owner', async () => { await expect( - context.lsp8['initialize(string,string,address)']( + context.lsp8['initialize(string,string,address,uint256)']( context.deployParams.name, context.deployParams.symbol, ethers.constants.AddressZero, + 0, ), ).to.be.revertedWith('Ownable: new owner is the zero address'); }); @@ -100,17 +103,18 @@ describe('LSP8IdentifiableDigitalAssetInit with proxy', () => { shouldBehaveLikeLSP4DigitalAssetMetadata(async () => { const lsp4Context = await buildLSP4DigitalAssetMetadataTestContext(); - await lsp4Context.contract['initialize(string,string,address)']( + await lsp4Context.contract['initialize(string,string,address,uint256)']( 'LSP8 - deployed with proxy', 'NFT', lsp4Context.deployParams.owner.address, + 0, ); return lsp4Context; }); shouldBehaveLikeLSP8(() => - buildTestContext().then(async (context) => { + buildTestContext(0).then(async (context) => { await initializeProxy(context); return context; diff --git a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8MintableInit.test.ts b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8MintableInit.test.ts index 96cd82060..aa8062b55 100644 --- a/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8MintableInit.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/proxy/LSP8MintableInit.test.ts @@ -10,6 +10,7 @@ import { } from '../LSP8Mintable.behaviour'; import { deployProxy } from '../../utils/fixtures'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8MintableInit with proxy', () => { const buildTestContext = async () => { @@ -18,6 +19,7 @@ describe('LSP8MintableInit with proxy', () => { name: 'LSP8 Mintable - deployed with proxy', symbol: 'MNTBL', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const LSP8MintableInit: LSP8MintableInit = await new LSP8MintableInit__factory( @@ -31,10 +33,11 @@ describe('LSP8MintableInit with proxy', () => { }; const initializeProxy = async (context: LSP8MintableTestContext) => { - return context.lsp8Mintable['initialize(string,string,address)']( + return context.lsp8Mintable['initialize(string,string,address,uint256)']( context.deployParams.name, context.deployParams.symbol, context.deployParams.newOwner, + context.deployParams.tokenIdType, ); }; @@ -47,10 +50,11 @@ describe('LSP8MintableInit with proxy', () => { const randomCaller = accounts[1]; await expect( - lsp8Mintable['initialize(string,string,address)']( + lsp8Mintable['initialize(string,string,address,uint256)']( 'XXXXXXXXXXX', 'XXX', randomCaller.address, + 0, ), ).to.be.revertedWith('Initializable: contract is already initialized'); }); diff --git a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Burnable.test.ts b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Burnable.test.ts index e15e676f8..4170d7959 100644 --- a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Burnable.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Burnable.test.ts @@ -4,6 +4,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { LSP8BurnableTester, LSP8BurnableTester__factory } from '../../../types'; import { shouldInitializeLikeLSP8 } from '../LSP8IdentifiableDigitalAsset.behaviour'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; type LSP8BurnableTestContext = { accounts: SignerWithAddress[]; @@ -12,6 +13,7 @@ type LSP8BurnableTestContext = { name: string; symbol: string; newOwner: string; + tokenIdType: number; }; }; @@ -22,12 +24,14 @@ describe('LSP8Burnable with constructor', () => { name: 'LSP8 Burnable - deployed with constructor', symbol: 'BRN', newOwner: accounts[0].address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const lsp8Burnable = await new LSP8BurnableTester__factory(accounts[0]).deploy( deployParams.name, deployParams.symbol, deployParams.newOwner, + deployParams.tokenIdType, ); return { accounts, lsp8Burnable, deployParams }; diff --git a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CappedSupply.test.ts b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CappedSupply.test.ts index c92f74a7d..9d3c85e41 100644 --- a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CappedSupply.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CappedSupply.test.ts @@ -8,6 +8,7 @@ import { LSP8CappedSupplyTestContext, getNamedAccounts, } from '../LSP8CappedSupply.behaviour'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8CappedSupply with constructor', () => { const buildTestContext = async () => { @@ -16,12 +17,14 @@ describe('LSP8CappedSupply with constructor', () => { name: 'LSP8 capped supply - deployed with constructor', symbol: 'CAP', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, tokenSupplyCap: ethers.BigNumber.from('2'), }; const lsp8CappedSupply = await new LSP8CappedSupplyTester__factory(accounts.owner).deploy( deployParams.name, deployParams.symbol, deployParams.newOwner, + deployParams.tokenIdType, deployParams.tokenSupplyCap, ); diff --git a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CompatibleERC721.test.ts b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CompatibleERC721.test.ts index f24298b47..e55499f8f 100644 --- a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CompatibleERC721.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8CompatibleERC721.test.ts @@ -8,6 +8,7 @@ import { shouldInitializeLikeLSP8CompatibleERC721, LSP8CompatibleERC721TestContext, } from '../LSP8CompatibleERC721.behaviour'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8CompatibleERC721 with constructor', () => { const buildTestContext = async (): Promise => { @@ -25,6 +26,7 @@ describe('LSP8CompatibleERC721 with constructor', () => { name: 'Compat for ERC721', symbol: 'NFT', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, lsp4MetadataValue, }; @@ -34,6 +36,7 @@ describe('LSP8CompatibleERC721 with constructor', () => { deployParams.name, deployParams.symbol, deployParams.newOwner, + deployParams.tokenIdType, deployParams.lsp4MetadataValue, ); diff --git a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Enumerable.test.ts b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Enumerable.test.ts index ff35676d4..e78b97336 100644 --- a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Enumerable.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Enumerable.test.ts @@ -6,6 +6,7 @@ import { LSP8EnumerableTestContext, getNamedAccounts, } from '../LSP8Enumerable.behaviour'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8Enumerable with constructor', () => { const buildTestContext = async () => { @@ -15,11 +16,17 @@ describe('LSP8Enumerable with constructor', () => { name: 'LSP8 Enumerable - deployed with constructor', symbol: 'LSP8 NMRBL', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const lsp8Enumerable: LSP8EnumerableTester = await new LSP8EnumerableTester__factory( accounts.owner, - ).deploy(deployParams.name, deployParams.symbol, deployParams.newOwner); + ).deploy( + deployParams.name, + deployParams.symbol, + deployParams.newOwner, + deployParams.tokenIdType, + ); return { accounts, lsp8Enumerable, deployParams }; }; diff --git a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8IdentifiableDigitalAsset.test.ts b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8IdentifiableDigitalAsset.test.ts index e1263a0e2..b1faa703c 100644 --- a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8IdentifiableDigitalAsset.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8IdentifiableDigitalAsset.test.ts @@ -19,19 +19,22 @@ import { LS4DigitalAssetMetadataTestContext, shouldBehaveLikeLSP4DigitalAssetMetadata, } from '../../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.behaviour'; +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; describe('LSP8IdentifiableDigitalAsset with constructor', () => { - const buildTestContext = async (): Promise => { + const buildTestContext = async (nftType: number): Promise => { const accounts = await getNamedAccounts(); const deployParams = { name: 'LSP8 - deployed with constructor', symbol: 'NFT', newOwner: accounts.owner.address, + tokenIdType: nftType, }; const lsp8 = await new LSP8Tester__factory(accounts.owner).deploy( deployParams.name, deployParams.symbol, deployParams.newOwner, + deployParams.tokenIdType, ); return { accounts, lsp8, deployParams }; @@ -39,7 +42,7 @@ describe('LSP8IdentifiableDigitalAsset with constructor', () => { const buildLSP4DigitalAssetMetadataTestContext = async (): Promise => { - const { lsp8 } = await buildTestContext(); + const { lsp8 } = await buildTestContext(LSP8_TOKEN_ID_TYPES.NUMBER); const accounts = await ethers.getSigners(); const deployParams = { @@ -60,11 +63,13 @@ describe('LSP8IdentifiableDigitalAsset with constructor', () => { name: 'LSP8 - deployed with constructor', symbol: 'NFT', owner: accounts[0], + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const contract = await new LSP8Tester__factory(accounts[0]).deploy( deployParams.name, deployParams.symbol, deployParams.owner.address, + deployParams.tokenIdType, ); return { accounts, contract, deployParams }; @@ -85,6 +90,7 @@ describe('LSP8IdentifiableDigitalAsset with constructor', () => { deployParams.name, deployParams.symbol, ethers.constants.AddressZero, + LSP8_TOKEN_ID_TYPES.NUMBER, ), ).to.be.revertedWith('Ownable: new owner is the zero address'); }); @@ -93,7 +99,7 @@ describe('LSP8IdentifiableDigitalAsset with constructor', () => { let context: LSP8TestContext; before(async () => { - context = await buildTestContext(); + context = await buildTestContext(0); }); shouldInitializeLikeLSP8(async () => { diff --git a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Mintable.test.ts b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Mintable.test.ts index 81409c007..79b77d849 100644 --- a/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Mintable.test.ts +++ b/tests/LSP8IdentifiableDigitalAsset/standard/LSP8Mintable.test.ts @@ -1,3 +1,4 @@ +import { LSP8_TOKEN_ID_TYPES } from '../../../constants'; import { LSP8Mintable, LSP8Mintable__factory } from '../../../types'; import { shouldInitializeLikeLSP8 } from '../LSP8IdentifiableDigitalAsset.behaviour'; @@ -15,12 +16,14 @@ describe('LSP8Mintable with constructor', () => { name: 'LSP8 Mintable - deployed with constructor', symbol: 'LSP8 MNTBL', newOwner: accounts.owner.address, + tokenIdType: LSP8_TOKEN_ID_TYPES.NUMBER, }; const lsp8Mintable: LSP8Mintable = await new LSP8Mintable__factory(accounts.owner).deploy( deployParams.name, deployParams.symbol, deployParams.newOwner, + deployParams.tokenIdType, ); return { accounts, lsp8Mintable, deployParams }; diff --git a/tests/foundry/GasTests/execute/RestrictedController.sol b/tests/foundry/GasTests/execute/RestrictedController.sol index 34fb01a92..a7bf58cf0 100644 --- a/tests/foundry/GasTests/execute/RestrictedController.sol +++ b/tests/foundry/GasTests/execute/RestrictedController.sol @@ -19,6 +19,9 @@ import { _PERMISSION_CALL, _PERMISSION_TRANSFERVALUE } from "../../../../contracts/LSP6KeyManager/LSP6Constants.sol"; +import { + _LSP8_TOKENID_TYPE_NUMBER +} from "../../../../contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol"; import "../UniversalProfileTestsHelper.sol"; contract ExecuteRestrictedController is UniversalProfileTestsHelper { @@ -438,7 +441,8 @@ contract ExecuteRestrictedController is UniversalProfileTestsHelper { indentifiableDigitalAsset = new LSP8Tester( "TestLSP8", "TSTLSP8", - digitalAssetsOwner + digitalAssetsOwner, + _LSP8_TOKENID_TYPE_NUMBER ); bytes32 tokenID = bytes32(uint256(1)); diff --git a/tests/foundry/GasTests/execute/UnrestrictedController.sol b/tests/foundry/GasTests/execute/UnrestrictedController.sol index 1f4bab4c1..49ca3b07a 100644 --- a/tests/foundry/GasTests/execute/UnrestrictedController.sol +++ b/tests/foundry/GasTests/execute/UnrestrictedController.sol @@ -17,6 +17,9 @@ import { _PERMISSION_REENTRANCY, _PERMISSION_SUPER_TRANSFERVALUE } from "../../../../contracts/LSP6KeyManager/LSP6Constants.sol"; +import { + _LSP8_TOKENID_TYPE_NUMBER +} from "../../../../contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol"; import "../UniversalProfileTestsHelper.sol"; contract ExecuteUnrestrictedController is UniversalProfileTestsHelper { @@ -260,7 +263,8 @@ contract ExecuteUnrestrictedController is UniversalProfileTestsHelper { indentifiableDigitalAsset = new LSP8Tester( "TestLSP8", "TSTLSP8", - digitalAssetsOwner + digitalAssetsOwner, + _LSP8_TOKENID_TYPE_NUMBER ); bytes32 tokenID = bytes32(uint256(1));