Skip to content

Commit

Permalink
Merge branch 'develop' into update-lsp0-natspec
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 authored Aug 22, 2023
2 parents 7993a40 + 297302d commit 66afd96
Show file tree
Hide file tree
Showing 29 changed files with 9,583 additions and 260 deletions.
47 changes: 0 additions & 47 deletions contracts/LSP0ERC725Account/LSP0Utils.sol

This file was deleted.

45 changes: 44 additions & 1 deletion contracts/LSP1UniversalReceiver/LSP1Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {
ERC165Checker
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";

// constants
import "./ILSP1UniversalReceiver.sol";
import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";

// constants
import {
_INTERFACEID_LSP1,
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY,
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
import "../LSP0ERC725Account/LSP0Constants.sol";
import "../LSP5ReceivedAssets/LSP5Constants.sol";
import "../LSP7DigitalAsset/LSP7Constants.sol";
Expand Down Expand Up @@ -92,6 +99,42 @@ library LSP1Utils {
return result.length != 0 ? abi.decode(result, (bytes)) : result;
}

/**
* @notice Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate`.
*
* @dev Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve
* the value set under the `LSP1UniversalReceiverDelegate` data key.
*
* @param erc725YStorage A reference to the ERC725Y storage mapping of the contract.
* @return The bytes value stored under the `LSP1UniversalReceiverDelegate` data key.
*/
function getLSP1DelegateValue(
mapping(bytes32 => bytes) storage erc725YStorage
) internal view returns (bytes memory) {
return erc725YStorage[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY];
}

/**
* @notice Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate:<type-id>` for a specific `typeId`.
*
* @dev Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve
* the value set under the `LSP1UniversalReceiverDelegate:<bytes32>` data key for a specific LSP1 `typeId`.
*
* @param erc725YStorage A reference to the ERC725Y storage mapping of the contract.
* @param typeId A bytes32 LSP1 `typeId`;
* @return The bytes value stored under the `LSP1UniversalReceiverDelegate:<bytes32>` data key.
*/
function getLSP1DelegateValueForTypeId(
mapping(bytes32 => bytes) storage erc725YStorage,
bytes32 typeId
) internal view returns (bytes memory) {
bytes32 lsp1TypeIdDataKey = LSP2Utils.generateMappingKey(
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
bytes20(typeId)
);
return erc725YStorage[lsp1TypeIdDataKey];
}

/**
* @dev Gets all the transfer details based on the provided `bytes32 typeId`.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ILSP7CompatibleERC20 is ILSP7DigitalAsset {
* @param to The address receiving tokens.
* @param amount The amount of tokens to transfer.
*
* @return `true` on successful transfer.
*/
function transfer(address to, uint256 amount) external returns (bool);
Expand Down
1 change: 1 addition & 0 deletions contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {

/**
* @notice The maximum supply amount of tokens allowed to exist is `_tokenSupplyCap`.
*
* @dev Get the maximum number of tokens that can exist to circulate. Once {totalSupply} reaches
* reaches {totalSuuplyCap}, it is not possible to mint more tokens.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "../LSP7DigitalAssetInitAbstract.sol";

/**
* @dev LSP7 extension, mintable.
* @dev LSP7DigitalAsset deployable preset contract (inheritable proxy version) with a public {mint} function callable only by the contract {owner}.
*/
abstract contract LSP7MintableInitAbstract is
LSP7DigitalAssetInitAbstract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ bytes4 constant _INTERFACEID_ERC721METADATA = 0x5b5e139f;
*/
interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
/**
* @notice To provide compatibility with indexing ERC721 events.
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
* @param from The sending address
* @param to The receiving address
* @param tokenId The tokenId to transfer
* @notice ERC721 `Transfer` compatible event emitted. Successfully transferred tokenId `tokenId` from `from` to `to`.
*
* @dev ERC721 `Transfer` event emitted when `tokenId` token is transferred from `from` to `to`.
* To provide compatibility with indexing ERC721 events.
*
* @param from The sending address.
* @param to The receiving address.
* @param tokenId The tokenId to transfer.
*/
event Transfer(
address indexed from,
Expand All @@ -28,21 +31,30 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
);

/**
* @notice To provide compatibility with indexing ERC721 events.
* @dev Emitted when `owner` enables `approved` for `tokenId`.
* @param owner The address of the owner of the `tokenId`
* @param approved The address set as operator
* @param tokenId The approved tokenId
* @notice ERC721 `Approval` compatible event emitted. Successfully approved operator `operator` to operate on tokenId `tokenId` on behalf of token owner `owner`.
*
* @dev ERC721 `Approval` event emitted when `owner` enables `operator` for `tokenId`.
* To provide compatibility with indexing ERC721 events.
*
* @param owner The address of the owner of the `tokenId`.
* @param operator The address set as operator.
* @param tokenId The approved tokenId.
*/
event Approval(
address indexed owner,
address indexed approved,
address indexed operator,
uint256 indexed tokenId
);

/**
* @dev This emits when an operator is enabled or disabled for an owner.
* The operator can manage all NFTs of the owner.
* @notice ERC721 `ApprovalForAll` compatible event emitted. Successfully set "approved for all" status to `approved` for operator `operator` for token owner `owner`.
*
* @dev ERC721 `ApprovalForAll` event emitted when an `operator` is enabled or disabled for an owner
* to transfer any of its tokenIds. The operator can manage all NFTs of the owner.
*
* @param owner The address of the owner of tokenIds.
* @param operator The address set as operator.
* @param approved If `operator` is approved for all NFTs or not.
*/
event ApprovalForAll(
address indexed owner,
Expand All @@ -51,18 +63,24 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
);

/**
* @dev Compatible with ERC721 transferFrom.
* @param from The sending address
* @param to The receiving address
* @param tokenId The tokenId to transfer
* @notice Calling `transferFrom` function on `ILSP8CompatibleERC721` contract. Transferring tokenId `tokenId` from address `from` to address `to`.
*
* @dev Transfer functions from the ERC721 standard interface.
*
* @param from The sending address.
* @param to The receiving address.
* @param tokenId The tokenId to transfer.
*/
function transferFrom(address from, address to, uint256 tokenId) external;

/**
* @dev Compatible with ERC721 transferFrom.
* @param from The sending address
* @param to The receiving address
* @param tokenId The tokenId to transfer
* @notice Calling `safeTransferFrom` function on `ILSP8CompatibleERC721` contract. Transferring tokenId `tokenId` from address `from` to address `to`.
*
* @dev Safe Transfer function without optional data from the ERC721 standard interface.
*
* @param from The sending address.
* @param to The receiving address.
* @param tokenId The tokenId to transfer.
*/
function safeTransferFrom(
address from,
Expand All @@ -71,11 +89,14 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
) external;

/**
* @dev Compatible with ERC721 safeTransferFrom.
* @param from The sending address
* @param to The receiving address
* @param tokenId The tokenId to transfer
* @param data The data to be sent with the transfer
* @notice Calling `safeTransferFrom` function with `data` on `ILSP8CompatibleERC721` contract. Transferring tokenId `tokenId` from address `from` to address `to`.
*
* @dev Safe Transfer function with optional data from the ERC721 standard interface.
*
* @param from The sending address.
* @param to The receiving address.
* @param tokenId The tokenId to transfer.
* @param data The data to be sent with the transfer.
*/
function safeTransferFrom(
address from,
Expand All @@ -85,38 +106,55 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
) external;

/**
* @notice Retrieving the address that own tokenId `tokenId`.
*
* @dev Compatible with ERC721 ownerOf.
* @param tokenId The tokenId to query
* @return The owner of the tokenId
*
* @param tokenId The tokenId to query.
* @return The owner of the tokenId.
*/
function ownerOf(uint256 tokenId) external view returns (address);

/**
* @dev Compatible with ERC721 approve.
* @param operator The address to approve for `tokenId`
* @param tokenId The tokenId to approve
* @notice Calling `approve` function on `ILSP8CompatibleERC721` contract. Approving operator at address `operator` to transfer tokenId `tokenId` on behalf of its owner.
*
* @dev Approval function compatible with ERC721 `approve(address,uint256)`.
*
* @param operator The address to approve for `tokenId`.
* @param tokenId The tokenId to approve.
*/
function approve(address operator, uint256 tokenId) external;

/**
* @notice Enable or disable approval for a third party ("operator") to manage all of `msg.sender`'s assets
* @dev Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
* @param _operator Address to add to the set of authorized operators
* @param _approved True if the operator is approved, false to revoke approval
* @notice Setting the "approval for all" status of operator `_operator` to `_approved` to allow it to transfer any tokenIds on behalf of `msg.sender`.
*
* @dev Enable or disable approval for a third party ("operator") to manage all of `msg.sender`'s assets. The contract MUST allow multiple operators per owner.
*
* @param _operator Address to add to the set of authorized operators.
* @param _approved True if the operator is approved, false to revoke approval.
*
* @custom:events {ApprovalForAll} event
*/
function setApprovalForAll(address _operator, bool _approved) external;

/**
* @notice Retrieving the address other than the token owner that is approved to transfer tokenId `tokenId` on behalf of its owner.
*
* @dev Compatible with ERC721 getApproved.
* @param tokenId The tokenId to query
* @return The address of the operator for `tokenId`
*
* @param tokenId The tokenId to query.
* @return The address of the operator for `tokenId`.
*/
function getApproved(uint256 tokenId) external view returns (address);

/*
* @notice Checking if address `operator` is approved to transfer any tokenId owned by address `owner`.
*
* @dev Compatible with ERC721 isApprovedForAll.
* @param owner The tokenOwner address to query
* @param operator The operator address to query
*
* @param owner The tokenOwner address to query.
* @param operator The operator address to query.
*
* @return Returns if the `operator` is allowed to manage all of the assets of `owner`
*/
function isApprovedForAll(
Expand All @@ -125,9 +163,13 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
) external view returns (bool);

/*
* @notice Retrieving the token URI of tokenId `tokenId`.
*
* @dev Compatible with ERC721Metadata tokenURI.
* @param tokenId The tokenId to query
* @return The token URI
*
* @param tokenId The tokenId to query.
*
* @return The token URI.
*/
function tokenURI(uint256 tokenId) external returns (string memory);
}
12 changes: 10 additions & 2 deletions contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ import {
import {LSP8NotTokenOperator} from "../LSP8Errors.sol";

/**
* @dev LSP8 extension (standard version) that allows token holders to destroy both
* @dev LSP8 token extension that allows token holders to destroy both
* their own tokens and those that they have an allowance for as an operator.
*/
abstract contract LSP8Burnable is LSP8IdentifiableDigitalAsset {
function burn(bytes32 tokenId, bytes memory data) public virtual {
/**
* @notice Burning tokenId `tokenId`. This tokenId will not be recoverable! (additional data sent: `data`).
*
* @dev See internal {_burn} function for details.
*
* @param tokenId The tokenId to burn.
* @param data Any extra data to be sent alongside burning the tokenId.
*/
function burn(bytes32 tokenId, bytes memory data) public {
if (!_isOperatorOrOwner(msg.sender, tokenId)) {
revert LSP8NotTokenOperator(tokenId, msg.sender);
}
Expand Down
Loading

0 comments on commit 66afd96

Please sign in to comment.