Skip to content

Commit

Permalink
docs: update LSP4 Natspecs + add LSP4 auto-generated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Jul 18, 2023
1 parent 32ad32f commit ae00206
Show file tree
Hide file tree
Showing 4 changed files with 386 additions and 18 deletions.
20 changes: 12 additions & 8 deletions contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ import {
} from "./LSP4Errors.sol";

/**
* @title LSP4DigitalAssetMetadata
* @title Implementation of a LSP4DigitalAssetMetadata contract that stores the **Token-Metadata** (`LSP4TokenName` and `LSP4TokenSymbol`) in its ERC725Y data store.
* @author Matthew Stevens
* @dev Implementation of a LSP8 compliant contract.
* @dev Standard Implementation of the LSP4 standard.
*/
abstract contract LSP4DigitalAssetMetadata is ERC725Y {
/**
* @notice Sets the name, symbol of the token and the owner, and sets the SupportedStandards:LSP4DigitalAsset key
* @notice Set `initialOwner` as the contract owner and set the following data key values pairs under the ERC725Y storage of the contract:
* - `LSP4TokenName`: `name_`,
* - `LSP4TokenSymbol`: `symbol_`,
* - `SupportedStandards:LSP4DigitalAsset`: `0xa4d96624`
*
* @param name_ The name of the token
* @param symbol_ The symbol of the token
* @param newOwner_ The owner of the token contract
* @param initialOwner_ The owner of the token contract
*/
constructor(
string memory name_,
string memory symbol_,
address newOwner_
) ERC725Y(newOwner_) {
// set key SupportedStandards:LSP4DigitalAsset
address initialOwner_
) ERC725Y(initialOwner_) {
// set data key SupportedStandards:LSP4DigitalAsset
super._setData(
_LSP4_SUPPORTED_STANDARDS_KEY,
_LSP4_SUPPORTED_STANDARDS_VALUE
Expand All @@ -47,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.
*
* @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
* @dev Save gas by emitting the {DataChanged} event with only the first 256 bytes of dataValue
*/
function _setData(
bytes32 dataKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,29 @@ import {
} from "./LSP4Errors.sol";

/**
* @title LSP4DigitalAssetMetadata
* @title Implementation of a LSP4DigitalAssetMetadata contract that stores the **Token-Metadata** (`LSP4TokenName` and `LSP4TokenSymbol`) in its ERC725Y data store.
* @author Matthew Stevens
* @dev Inheritable Proxy Implementation of a LSP8 compliant contract.
* @dev Inheritable Proxy Implementation of the LSP4 standard.
*/
abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
/**
* @notice Set `initialOwner` as the contract owner and set the following data key values pairs under the ERC725Y storage of the contract:
* - `LSP4TokenName`: `name_`,
* - `LSP4TokenSymbol`: `symbol_`,
* - `SupportedStandards:LSP4DigitalAsset`: `0xa4d96624`
*
* @param name_ The name of the token
* @param symbol_ The symbol of the token
* @param initialOwner_ The owner of the token contract
*/
function _initialize(
string memory name_,
string memory symbol_,
address newOwner_
address initialOwner_
) internal virtual onlyInitializing {
ERC725YInitAbstract._initialize(newOwner_);
ERC725YInitAbstract._initialize(initialOwner_);

// set SupportedStandards:LSP4DigitalAsset
// set data key SupportedStandards:LSP4DigitalAsset
super._setData(
_LSP4_SUPPORTED_STANDARDS_KEY,
_LSP4_SUPPORTED_STANDARDS_VALUE
Expand All @@ -45,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.
*
* @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
* @dev Save gas by emitting the {DataChanged} event with only the first 256 bytes of dataValue
*/
function _setData(
bytes32 dataKey,
Expand Down
8 changes: 4 additions & 4 deletions contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ pragma solidity ^0.8.4;

/**
* @dev Reverts when trying to edit the data key `LSP4TokenName` after the digital asset contract has been deployed.
* The `LSP4TokenName` data key is located inside the ERC725Y Data key-value store of the digital asset contract.
* It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
* The `LSP4TokenName` data key is located inside the ERC725Y Data key-value store of the digital asset contract.
* It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
*/
error LSP4TokenNameNotEditable();

/**
* @dev Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital asset contract has been deployed.
* The `LSP4TokenSymbol` data key is located inside the ERC725Y Data key-value store of the digital asset contract.
* It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
* The `LSP4TokenSymbol` data key is located inside the ERC725Y Data key-value store of the digital asset contract.
* It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
*/
error LSP4TokenSymbolNotEditable();
Loading

0 comments on commit ae00206

Please sign in to comment.