Skip to content

Commit

Permalink
feat: rename LSP8CompatibilityForERC721 to LSP8CompatibleERC721 + add…
Browse files Browse the repository at this point in the history
… mintable preset contracts (#218)

* chore: change references in Hardhat config file

* chore: change references in Mythx file

* test: change contract names to CompatibleERC721

* feat: add LSP8CompatibleERC721 Mintable contracts

* chore: change name of compatible contracts to CompatibleERC721

* Update contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol

Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>

* chore: add LSP8CompatibleERC721Mintable contracts to hardhat congfig

* chore: fix typos in contract name

Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>
  • Loading branch information
YamenMerhi and CJ42 authored Jun 30, 2022
1 parent fc7b0df commit 53e33cc
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .mythx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ analyze:
- contracts/LSP7DigitalAsset/extensions/LSP7MintableInit.sol
- contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol
- contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol
- contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol
- contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Init.sol
- contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInit.sol
- contracts/LSP9Vault/LSP9VaultInit.sol
# Legacy L14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ pragma solidity ^0.8.0;

// modules
import {LSP8IdentifiableDigitalAsset} from "../../LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol";
import {LSP8CompatibilityForERC721} from "../../LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol";
import {LSP8CompatibleERC721} from "../../LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol";

// constants
import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";

contract LSP8CompatibilityForERC721Tester is LSP8CompatibilityForERC721 {
contract LSP8CompatibleERC721Tester is LSP8CompatibleERC721 {
constructor(
string memory name,
string memory symbol,
address newOwner,
bytes memory tokenURIValue
) LSP8CompatibilityForERC721(name, symbol, newOwner) {
) LSP8CompatibleERC721(name, symbol, newOwner) {
_setData(_LSP4_METADATA_KEY, tokenURIValue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ pragma solidity ^0.8.0;

// modules
import {LSP8IdentifiableDigitalAsset} from "../../LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol";
import {LSP8CompatibilityForERC721InitAbstract} from "../../LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol";
import {LSP8CompatibleERC721InitAbstract} from "../../LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol";

// constants
import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";

contract LSP8CompatibilityForERC721InitTester is LSP8CompatibilityForERC721InitAbstract {
contract LSP8CompatibleERC721InitTester is LSP8CompatibleERC721InitAbstract {
function initialize(
string memory name,
string memory symbol,
address newOwner,
bytes memory tokenURIValue
) public virtual initializer {
LSP8CompatibilityForERC721InitAbstract._initialize(name, symbol, newOwner);
LSP8CompatibleERC721InitAbstract._initialize(name, symbol, newOwner);

_setData(_LSP4_METADATA_KEY, tokenURIValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.so
/**
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
*/
interface ILSP8CompatibilityForERC721 is ILSP8IdentifiableDigitalAsset {
interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
/**
* @notice To provide compatibility with indexing ERC721 events.
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet
// modules
import {LSP8IdentifiableDigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP8IdentifiableDigitalAsset.sol";
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
import {LSP8CompatibilityForERC721Core} from "./LSP8CompatibilityForERC721Core.sol";
import {LSP8CompatibleERC721Core} from "./LSP8CompatibleERC721Core.sol";

// constants
import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibilityConstants.sol";
import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibleConstants.sol";

/**
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
*/
contract LSP8CompatibilityForERC721 is
LSP8IdentifiableDigitalAsset,
LSP8CompatibilityForERC721Core
{
contract LSP8CompatibleERC721 is LSP8IdentifiableDigitalAsset, LSP8CompatibleERC721Core {
using EnumerableSet for EnumerableSet.AddressSet;

/**
Expand All @@ -42,7 +39,7 @@ contract LSP8CompatibilityForERC721 is
function authorizeOperator(address operator, bytes32 tokenId)
public
virtual
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
{
super.authorizeOperator(operator, tokenId);
}
Expand All @@ -53,7 +50,7 @@ contract LSP8CompatibilityForERC721 is
bytes32 tokenId,
bool force,
bytes memory data
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
super._transfer(from, to, tokenId, force, data);
}

Expand All @@ -62,14 +59,14 @@ contract LSP8CompatibilityForERC721 is
bytes32 tokenId,
bool force,
bytes memory data
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
super._mint(to, tokenId, force, data);
}

function _burn(bytes32 tokenId, bytes memory data)
internal
virtual
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
{
super._burn(tokenId, data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;

// interfaces
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
import {ILSP8CompatibilityForERC721} from "./ILSP8CompatibilityForERC721.sol";
import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";

// libraries
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
Expand All @@ -20,15 +20,15 @@ import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.s
/**
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
*/
abstract contract LSP8CompatibilityForERC721Core is
abstract contract LSP8CompatibleERC721Core is
LSP4Compatibility,
LSP8IdentifiableDigitalAssetCore,
ILSP8CompatibilityForERC721
ILSP8CompatibleERC721
{
using EnumerableSet for EnumerableSet.AddressSet;

/*
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
// silence compiler warning about unused variable
Expand All @@ -44,14 +44,14 @@ abstract contract LSP8CompatibilityForERC721Core is
}

/**
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return tokenOwnerOf(bytes32(tokenId));
}

/**
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
*/
function approve(address operator, uint256 tokenId) public virtual override {
authorizeOperator(operator, bytes32(tokenId));
Expand All @@ -60,7 +60,7 @@ abstract contract LSP8CompatibilityForERC721Core is
}

/**
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
bytes32 tokenIdAsBytes32 = bytes32(tokenId);
Expand All @@ -83,7 +83,7 @@ abstract contract LSP8CompatibilityForERC721Core is
}

/*
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
*/
function isApprovedForAll(address tokenOwner, address operator)
public
Expand All @@ -100,7 +100,7 @@ abstract contract LSP8CompatibilityForERC721Core is
}

/**
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
* @dev Compatible with ERC721 transferFrom.
* Using force=true so that EOA and any contract may receive the tokenId.
*/
Expand All @@ -113,7 +113,7 @@ abstract contract LSP8CompatibilityForERC721Core is
}

/**
* @inheritdoc ILSP8CompatibilityForERC721
* @inheritdoc ILSP8CompatibleERC721
* @dev Compatible with ERC721 safeTransferFrom.
* Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
pragma solidity ^0.8.0;

// modules
import {LSP8CompatibilityForERC721InitAbstract} from "./LSP8CompatibilityForERC721InitAbstract.sol";
import {LSP8CompatibleERC721InitAbstract} from "./LSP8CompatibleERC721InitAbstract.sol";

/**
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
*/
contract LSP8CompatibilityForERC721Init is LSP8CompatibilityForERC721InitAbstract {
contract LSP8CompatibleERC721Init is LSP8CompatibleERC721InitAbstract {
/**
* @notice Sets the name, the symbol and the owner of the token
* @param name_ The name of the token
Expand All @@ -20,6 +20,6 @@ contract LSP8CompatibilityForERC721Init is LSP8CompatibilityForERC721InitAbstrac
string memory symbol_,
address newOwner_
) public virtual initializer {
LSP8CompatibilityForERC721InitAbstract._initialize(name_, symbol_, newOwner_);
LSP8CompatibleERC721InitAbstract._initialize(name_, symbol_, newOwner_);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
// modules
import {LSP8IdentifiableDigitalAssetInitAbstract, LSP4DigitalAssetMetadataInitAbstract, ERC725YCore} from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
import {LSP8CompatibilityForERC721Core} from "./LSP8CompatibilityForERC721Core.sol";
import {LSP8CompatibleERC721Core} from "./LSP8CompatibleERC721Core.sol";

// constants
import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibilityConstants.sol";
import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./LSP8CompatibleConstants.sol";

/**
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
*/
contract LSP8CompatibilityForERC721InitAbstract is
contract LSP8CompatibleERC721InitAbstract is
LSP8IdentifiableDigitalAssetInitAbstract,
LSP8CompatibilityForERC721Core
LSP8CompatibleERC721Core
{
function _initialize(
string memory name_,
Expand All @@ -31,7 +31,7 @@ contract LSP8CompatibilityForERC721InitAbstract is
function authorizeOperator(address operator, bytes32 tokenId)
public
virtual
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
{
super.authorizeOperator(operator, tokenId);
}
Expand All @@ -42,7 +42,7 @@ contract LSP8CompatibilityForERC721InitAbstract is
bytes32 tokenId,
bool force,
bytes memory data
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
super._transfer(from, to, tokenId, force, data);
}

Expand All @@ -51,14 +51,14 @@ contract LSP8CompatibilityForERC721InitAbstract is
bytes32 tokenId,
bool force,
bytes memory data
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core) {
) internal virtual override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core) {
super._mint(to, tokenId, force, data);
}

function _burn(bytes32 tokenId, bytes memory data)
internal
virtual
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibilityForERC721Core)
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
{
super._burn(tokenId, data);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {LSP8CompatibleERC721} from "../extensions/LSP8CompatibleERC721.sol";

contract LSP8CompatibleERC721Mintable is LSP8CompatibleERC721 {
/* solhint-disable no-empty-blocks */
constructor(
string memory name_,
string memory symbol_,
address newOwner_
) LSP8CompatibleERC721(name_, symbol_, newOwner_) {}

function mint(
address to,
bytes32 tokenId,
bool force,
bytes memory data
) public onlyOwner {
_mint(to, tokenId, force, data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// modules
import {LSP8CompatibleERC721MintableInitAbstract} from "./LSP8CompatibleERC721MintableInitAbstract.sol";

contract LSP8CompatibleERC721MintableInit is LSP8CompatibleERC721MintableInitAbstract {
/**
* @notice Sets the name, the symbol and the owner of the token
* @param name_ The name of the token
* @param symbol_ The symbol of the token
* @param newOwner_ The owner of the token
*/
function initialize(
string memory name_,
string memory symbol_,
address newOwner_
) public virtual initializer {
LSP8CompatibleERC721MintableInitAbstract._initialize(name_, symbol_, newOwner_);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// modules
import {LSP8CompatibleERC721InitAbstract} from "../extensions/LSP8CompatibleERC721InitAbstract.sol";

contract LSP8CompatibleERC721MintableInitAbstract is LSP8CompatibleERC721InitAbstract {
/**
* @inheritdoc LSP8CompatibleERC721InitAbstract
*/
function _initialize(
string memory name_,
string memory symbol_,
address newOwner_
) internal virtual override onlyInitializing {
LSP8CompatibleERC721InitAbstract._initialize(name_, symbol_, newOwner_);
}

function mint(
address to,
bytes32 tokenId,
bool force,
bytes memory data
) public onlyOwner {
_mint(to, tokenId, force, data);
}
}
6 changes: 4 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ const config: HardhatUserConfig = {
// ERC Compatible tokens
// ------------------
"LSP4Compatibility",
"LSP8CompatibleERC721",
"LSP8CompatibleERC721Init",
"LSP8CompatibleERC721Mintable",
"LSP8CompatibleERC721MintableInit",
"LSP7CompatibleERC20",
"LSP7CompatibleERC20Init",
"LSP7CompatibleERC20Mintable",
"LSP7CompatibleERC20MintableInit",
"LSP8CompatibilityForERC721",
"LSP8CompatibilityForERC721Init",
// Legacy L14
// ------------------
"UniversalReceiverAddressStore",
Expand Down
Loading

0 comments on commit 53e33cc

Please sign in to comment.