Skip to content

Commit

Permalink
Merge pull request #815 from lukso-network/develop
Browse files Browse the repository at this point in the history
sync main to release 0.13.0
  • Loading branch information
CJ42 authored Nov 30, 2023
2 parents cab33b2 + 3e1156e commit 4786e50
Show file tree
Hide file tree
Showing 136 changed files with 6,545 additions and 1,309 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
bump-minor-pre-major: true
default-branch: main
changelog-types: '[{"type": "feat!","section":"BREAKING CHANGES","hidden": false},{"type": "refactor!","section":"BREAKING CHANGES","hidden": false},{"type": "build!","section":"BREAKING CHANGES","hidden": false},{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'
command: manifest

# The logic below handles the npm publication.
# The `if` statements ensure that a publication only occurs when
Expand Down
28 changes: 13 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,36 @@ All notable changes to this project will be documented in this file. See [standa

## [0.12.1](https://github.com/lukso-network/lsp-smart-contracts/compare/v0.12.0...v0.12.1) (2023-11-07)


### Bug Fixes

* [L-01] Return `bytes` directly in LSP6 `_executePayload`, to prevent data loss ([#784](https://github.com/lukso-network/lsp-smart-contracts/issues/784)) ([fd23a24](https://github.com/lukso-network/lsp-smart-contracts/commit/fd23a24859f72e3ea9312ae1761ab98709db0142))
* [M-02] reset `_renounceOwnershipStartedAt` on `acceptOwnership(..)` in LSP14 ([#775](https://github.com/lukso-network/lsp-smart-contracts/issues/775)) ([5d8a7af](https://github.com/lukso-network/lsp-smart-contracts/commit/5d8a7af60dc548730688c0895eeb27d402ec5cc5))
* [M-03] allow setting 21 bytes under LSP17Extension data key in LSP6KeyManager ([#777](https://github.com/lukso-network/lsp-smart-contracts/issues/777)) ([8f1fb95](https://github.com/lukso-network/lsp-smart-contracts/commit/8f1fb959f0b9267bc099f774ca9a98fdd8921b97))
* [M-04 + L-02] improve empty call type checks for selector `0x00000000` ([#776](https://github.com/lukso-network/lsp-smart-contracts/issues/776)) ([78bb1e7](https://github.com/lukso-network/lsp-smart-contracts/commit/78bb1e7e32ae8c6ce1decdbfa26fafa72c4c5387))
* Adjust missing verificationData and verificationFunction ([#788](https://github.com/lukso-network/lsp-smart-contracts/issues/788)) ([bff93e7](https://github.com/lukso-network/lsp-smart-contracts/commit/bff93e7878848ac798c60f6c274e64dcb26b2a30))

- [L-01] Return `bytes` directly in LSP6 `_executePayload`, to prevent data loss ([#784](https://github.com/lukso-network/lsp-smart-contracts/issues/784)) ([fd23a24](https://github.com/lukso-network/lsp-smart-contracts/commit/fd23a24859f72e3ea9312ae1761ab98709db0142))
- [M-02] reset `_renounceOwnershipStartedAt` on `acceptOwnership(..)` in LSP14 ([#775](https://github.com/lukso-network/lsp-smart-contracts/issues/775)) ([5d8a7af](https://github.com/lukso-network/lsp-smart-contracts/commit/5d8a7af60dc548730688c0895eeb27d402ec5cc5))
- [M-03] allow setting 21 bytes under LSP17Extension data key in LSP6KeyManager ([#777](https://github.com/lukso-network/lsp-smart-contracts/issues/777)) ([8f1fb95](https://github.com/lukso-network/lsp-smart-contracts/commit/8f1fb959f0b9267bc099f774ca9a98fdd8921b97))
- [M-04 + L-02] improve empty call type checks for selector `0x00000000` ([#776](https://github.com/lukso-network/lsp-smart-contracts/issues/776)) ([78bb1e7](https://github.com/lukso-network/lsp-smart-contracts/commit/78bb1e7e32ae8c6ce1decdbfa26fafa72c4c5387))
- Adjust missing verificationData and verificationFunction ([#788](https://github.com/lukso-network/lsp-smart-contracts/issues/788)) ([bff93e7](https://github.com/lukso-network/lsp-smart-contracts/commit/bff93e7878848ac798c60f6c274e64dcb26b2a30))

### Miscellaneous

* add notice in Natspec for `isValidSignature` ([#787](https://github.com/lukso-network/lsp-smart-contracts/issues/787)) ([c1574a8](https://github.com/lukso-network/lsp-smart-contracts/commit/c1574a8b58ef78a64f3edf086c652ac4ad4a2931))
* adjust Natspec comments + use mixedCase name for `modifier` ([#786](https://github.com/lukso-network/lsp-smart-contracts/issues/786)) ([e7ef125](https://github.com/lukso-network/lsp-smart-contracts/commit/e7ef125a1b77d5b3feb85a2b4133dec314ff917a))
* bootstrap releases for path: . + add `Version.sol` in file to update version for ([#785](https://github.com/lukso-network/lsp-smart-contracts/issues/785)) ([c0090c6](https://github.com/lukso-network/lsp-smart-contracts/commit/c0090c6a6d7e3473702cd85549a1fa2670b00bff))
* Refactor verification ([4ff7b6f](https://github.com/lukso-network/lsp-smart-contracts/commit/4ff7b6fe161f39d579d5a6437fa2ddc580cd7570))
- add notice in Natspec for `isValidSignature` ([#787](https://github.com/lukso-network/lsp-smart-contracts/issues/787)) ([c1574a8](https://github.com/lukso-network/lsp-smart-contracts/commit/c1574a8b58ef78a64f3edf086c652ac4ad4a2931))
- adjust Natspec comments + use mixedCase name for `modifier` ([#786](https://github.com/lukso-network/lsp-smart-contracts/issues/786)) ([e7ef125](https://github.com/lukso-network/lsp-smart-contracts/commit/e7ef125a1b77d5b3feb85a2b4133dec314ff917a))
- bootstrap releases for path: . + add `Version.sol` in file to update version for ([#785](https://github.com/lukso-network/lsp-smart-contracts/issues/785)) ([c0090c6](https://github.com/lukso-network/lsp-smart-contracts/commit/c0090c6a6d7e3473702cd85549a1fa2670b00bff))
- Refactor verification ([4ff7b6f](https://github.com/lukso-network/lsp-smart-contracts/commit/4ff7b6fe161f39d579d5a6437fa2ddc580cd7570))

## [0.12.0](https://github.com/lukso-network/lsp-smart-contracts/compare/v0.12.0-rc.0...v0.12.0) (2023-10-30)

### ⚠ BREAKING CHANGES

- Optional LSP1 Notification on `revokeOperator(..)` #2 ([#767](https://github.com/lukso-network/lsp-smart-contracts/issues/767))
- Optional LSP1 Notification on `revokeOperator(..)` #2 ([#767](https://github.com/lukso-network/lsp-smart-contracts/issues/767))
- replace `ValueReceived` with `UniversalReceiver` ([#759](https://github.com/lukso-network/lsp-smart-contracts/issues/759))
- Allows `ERC725X.executeBatch` path in LSP6 Key Manager ([#760](https://github.com/lukso-network/lsp-smart-contracts/issues/760))
- update LS8 Metadata keys to new LSP8 standard specs ([#762](https://github.com/lukso-network/lsp-smart-contracts/issues/762))
- create `Version` contract and inherit it ([#764](https://github.com/lukso-network/lsp-smart-contracts/issues/764))
- Optional LSP1 Notification on `revokeOperator(..)` ([#763](https://github.com/lukso-network/lsp-smart-contracts/issues/763))
- Optional LSP1 Notification on `revokeOperator(..)` ([#763](https://github.com/lukso-network/lsp-smart-contracts/issues/763))

### Refactor

- Optional LSP1 Notification on `revokeOperator(..)` ([#763](https://github.com/lukso-network/lsp-smart-contracts/issues/763)) ([63c1a0f](https://github.com/lukso-network/lsp-smart-contracts/commit/63c1a0fb68502e11d58f7582e4e849d2f24c4924))
- Optional LSP1 Notification on `revokeOperator(..)` [#2](https://github.com/lukso-network/lsp-smart-contracts/issues/2) ([#767](https://github.com/lukso-network/lsp-smart-contracts/issues/767)) ([1f92ca5](https://github.com/lukso-network/lsp-smart-contracts/commit/1f92ca530fb56cf2b626b0feae311d6c4737b8a0))
- Optional LSP1 Notification on `revokeOperator(..)` ([#763](https://github.com/lukso-network/lsp-smart-contracts/issues/763)) ([63c1a0f](https://github.com/lukso-network/lsp-smart-contracts/commit/63c1a0fb68502e11d58f7582e4e849d2f24c4924))
- Optional LSP1 Notification on `revokeOperator(..)` [#2](https://github.com/lukso-network/lsp-smart-contracts/issues/2) ([#767](https://github.com/lukso-network/lsp-smart-contracts/issues/767)) ([1f92ca5](https://github.com/lukso-network/lsp-smart-contracts/commit/1f92ca530fb56cf2b626b0feae311d6c4737b8a0))
- replace `ValueReceived` with `UniversalReceiver` ([#759](https://github.com/lukso-network/lsp-smart-contracts/issues/759)) ([0c17386](https://github.com/lukso-network/lsp-smart-contracts/commit/0c1738619818bcf2e01636f31782886b26fb91d7))
- update LS8 Metadata keys to new LSP8 standard specs ([#762](https://github.com/lukso-network/lsp-smart-contracts/issues/762)) ([a909926](https://github.com/lukso-network/lsp-smart-contracts/commit/a9099268f63b7a8f60e4304d61098b496ed03de0))

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import {
ERC725YDataKeys,
PERMISSIONS,
ALL_PERMISSIONS,
LSP8_TOKEN_ID_TYPES,
LSP8_TOKEN_ID_SCHEMA,
LSP25_VERSION,
ErrorSelectors,
EventSigHashes,
Expand Down Expand Up @@ -121,7 +121,7 @@ import {
ImageMetadata,
LinkMetadata,
AssetMetadata,
} from "@lukso/lsp-smart-contracts/constants";
} from "@lukso/lsp-smart-contracts";
```

## Audits
Expand Down
58 changes: 38 additions & 20 deletions constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const INTERFACE_IDS = {
LSP1UniversalReceiver: '0x6bb56a14',
LSP1UniversalReceiverDelegate: '0xa245bbda',
LSP6KeyManager: '0x23f34c62',
LSP7DigitalAsset: '0xdaa746b7',
LSP8IdentifiableDigitalAsset: '0x30dc5278',
LSP7DigitalAsset: '0xb3c4928f',
LSP8IdentifiableDigitalAsset: '0xecad9f75',
LSP9Vault: '0x28af17e6',
LSP11BasicSocialRecovery: '0x049a28f1',
LSP14Ownable2Step: '0x94be5999',
Expand Down Expand Up @@ -120,14 +120,16 @@ export type LSP4DigitalAssetMetadata = {
icon: ImageMetadata[];
};

export type Verification = {
method: string;
data: string;
source?: string;
};

export type ImageMetadata = {
width: number;
height: number;
verification?: {
method: string;
data: string;
source?: string;
};
verification?: Verification;
url: string;
};

Expand All @@ -137,11 +139,7 @@ export type LinkMetadata = {
};

export type AssetMetadata = {
verification?: {
method: string;
data: string;
source?: string;
};
verification?: Verification;
url: string;
fileType: string;
};
Expand Down Expand Up @@ -194,6 +192,9 @@ export const ERC725YDataKeys = {
// keccak256('LSP4TokenSymbol')
LSP4TokenSymbol: '0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756',

// keccak256('LSP4TokenType)
LSP4TokenType: '0xe0261fa95db2eb3b5439bd033cda66d56b96f92f243a8228fd87550ed7bdfdb3',

// keccak256('LSP4Metadata')
LSP4Metadata: '0x9afb95cacc9f95858ec44aa8c3b685511002e30ae54415823f406128b85b238e',

Expand Down Expand Up @@ -235,8 +236,7 @@ export const ERC725YDataKeys = {
'AddressPermissions:AllowedCalls': '0x4b80742de2bf393a64c70000',
},
LSP8: {
LSP8TokenIdType: '0x715f248956de7ce65e94d9d836bfead479f7e70d69b718d47bfe7b00e05b4fe4',
LSP8MetadataTokenURI: '0x1339e76a390b7b9ec9010000',
LSP8TokenIdSchema: '0x341bc44e55234544c70af9d37b2cb8cc7ba74685b58526221de2cc977f469924',
LSP8TokenMetadataBaseURI: '0x1a7628600c3bac7101f53697f48df381ddc36b9015e7d7c9c5633d1252aa2843',
LSP8ReferenceContract: '0x708e7b881795f2e6b6c2752108c177ec89248458de3bf69d0d43480b3e5034e6',
},
Expand Down Expand Up @@ -392,19 +392,37 @@ export const LSP1_TYPE_IDS = {
'0xe32c7debcb817925ba4883fdbfc52797187f28f73f860641dab1a68d9b32902c',
};

// LSP4
// ----------

/**
* @dev list of LSP4 Token types to describe the type of token a digital asset contract represents.
* @see for details see: https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-4-DigitalAsset-Metadata.md#lsp4tokentype
*/
export const LSP4_TOKEN_TYPES = {
TOKEN: 0,
NFT: 1,
COLLECTION: 2,
};

// 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
* @dev list of LSP8 Token ID Schemas that can be used to create different types of NFTs and represent each NFT identifiers differently.
* @see for details see: https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidschema
*/
export const LSP8_TOKEN_ID_TYPES = {
export const LSP8_TOKEN_ID_SCHEMA = {
NUMBER: 0,
STRING: 1,
UNIQUE_ID: 2,
HASH: 3,
ADDRESS: 4,
ADDRESS: 2,
UNIQUE_ID: 3,
HASH: 4,
MIXED_DEFAULT_NUMBER: 100,
MIXED_DEFAULT_STRING: 101,
MIXED_DEFAULT_ADDRESS: 102,
MIXED_DEFAULT_UNIQUE_ID: 103,
MIXED_DEFAULT_HASH: 104,
};

// LSP25
Expand Down
23 changes: 1 addition & 22 deletions contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";

// libraries
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {
ERC165Checker
Expand Down Expand Up @@ -128,6 +127,7 @@ abstract contract LSP0ERC725AccountCore is
*
* @custom:events {UniversalReceiver} event when receiving native tokens and extension function selector is not found or not payable.
*/
// solhint-disable-next-line no-complex-fallback
fallback(
bytes calldata callData
) external payable virtual returns (bytes memory) {
Expand Down Expand Up @@ -873,25 +873,4 @@ abstract contract LSP0ERC725AccountCore is

return (address(bytes20(extensionData)), false);
}

/**
* @dev This function overrides the {ERC725YCore} internal {_setData} function to optimize gas usage by emitting only the first 256 bytes of the `dataValue`.
*
* @custom:events {DataChanged} event with only the first 256 bytes of {dataValue}.
*
* @param dataKey The key to store the data value under.
* @param dataValue The data value to be stored.
*/
function _setData(
bytes32 dataKey,
bytes memory dataValue
) internal virtual override {
ERC725YCore._store[dataKey] = dataValue;
emit DataChanged(
dataKey,
dataValue.length <= 256
? dataValue
: BytesLib.slice(dataValue, 0, 256)
);
}
}
27 changes: 26 additions & 1 deletion contracts/LSP17Extensions/Extension4337.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,32 @@ contract Extension4337 is LSP17Extension, IAccount {
}

/**
* @inheritdoc IAccount
* @dev Validate user's signature and nonce.
* The entryPoint will make the call to the recipient only if this validation call returns successfully.
* Signature failure should be reported by returning `SIG_VALIDATION_FAILED` (`1`).
* This allows making a "simulation call" without a valid signature.
* Other failures (_e.g. nonce mismatch, or invalid signature format_) should still revert to signal failure.
*
* The third parameter (not mentioned but `missingAccountFunds` from the `IAccount` interface)
* describes the missing funds on the account's deposit in the entrypoint.
* This is the minimum amount to transfer to the sender(entryPoint) to be able to make the call.
* The excess is left as a deposit in the entrypoint, for future calls. Can be withdrawn anytime using "entryPoint.withdrawTo()"
* In case there is a paymaster in the request (or the current deposit is high enough), this value will be zero.
*
* @return validationData packaged ValidationData structure. use `_packValidationData` and `_unpackValidationData` to encode and decode
* - `<20-byte>` sigAuthorizer - 0 for valid signature, 1 to mark signature failure, otherwise, an address of an "authorizer" contract.
* - `<6-byte>` validUntil - last timestamp this operation is valid. 0 for "indefinite"
* - `<6-byte>` validAfter - first timestamp this operation is valid
* If an account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.
* Note that the validation code cannot use block.timestamp (or block.number) directly.
*
* @custom:info In addition to the logic of the `IAccount` interface from 4337, the permissions of the address that signed the user operation
* are checked to ensure that it has the permission `_4337_PERMISSION`.
*
* @custom:requirements
* - caller MUST be the **entrypoint contract**.
* - the signature and nonce must be valid.
*
*/
function validateUserOp(
UserOperation calldata userOp,
Expand Down
9 changes: 9 additions & 0 deletions contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.4;

// Token types

uint256 constant _LSP4_TOKEN_TYPE_TOKEN = 0;
uint256 constant _LSP4_TOKEN_TYPE_NFT = 1;
uint256 constant _LSP4_TOKEN_TYPE_COLLECTION = 2;

// --- ERC725Y entries

// bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP4DigitalAsset'))
Expand All @@ -15,6 +21,9 @@ bytes32 constant _LSP4_TOKEN_NAME_KEY = 0xdeba1e292f8ba88238e10ab3c7f88bd4be4fac
// keccak256('LSP4TokenSymbol')
bytes32 constant _LSP4_TOKEN_SYMBOL_KEY = 0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756;

// keccak256('LSP4TokenType')
bytes32 constant _LSP4_TOKEN_TYPE_KEY = 0xe0261fa95db2eb3b5439bd033cda66d56b96f92f243a8228fd87550ed7bdfdb3;

// keccak256('LSP4Creators[]')
bytes32 constant _LSP4_CREATORS_ARRAY_KEY = 0x114bd03b3a46d48759680d81ebb2b414fda7d030a7105a851867accf1c2352e7;

Expand Down
54 changes: 20 additions & 34 deletions contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,60 @@ pragma solidity ^0.8.4;

// modules
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";

// libraries
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
import {LSP4DigitalAssetMetadataCore} from "./LSP4DigitalAssetMetadataCore.sol";

// constants
import {
_LSP4_SUPPORTED_STANDARDS_KEY,
_LSP4_SUPPORTED_STANDARDS_VALUE,
_LSP4_TOKEN_NAME_KEY,
_LSP4_TOKEN_SYMBOL_KEY
_LSP4_TOKEN_SYMBOL_KEY,
_LSP4_TOKEN_TYPE_KEY
} from "./LSP4Constants.sol";

// errors
import {
LSP4TokenNameNotEditable,
LSP4TokenSymbolNotEditable
} from "./LSP4Errors.sol";

/**
* @title Implementation of a LSP4DigitalAssetMetadata contract that stores the **Token-Metadata** (`LSP4TokenName` and `LSP4TokenSymbol`) in its ERC725Y data store.
* @author Matthew Stevens
* @dev Standard Implementation of the LSP4 standard.
*/
abstract contract LSP4DigitalAssetMetadata is ERC725Y {
abstract contract LSP4DigitalAssetMetadata is
ERC725Y,
LSP4DigitalAssetMetadataCore
{
/**
* @notice Deploying a digital asset `name_` with the `symbol_` symbol.
*
* @param name_ The name of the token
* @param symbol_ The symbol of the token
* @param initialOwner_ The owner of the token contract
* @param name_ The name of the token.
* @param symbol_ The symbol of the token.
* @param initialOwner_ The owner of the token contract.
* @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
*/
constructor(
string memory name_,
string memory symbol_,
address initialOwner_
address initialOwner_,
uint256 lsp4TokenType_
) ERC725Y(initialOwner_) {
// set data key SupportedStandards:LSP4DigitalAsset
super._setData(
ERC725YCore._setData(
_LSP4_SUPPORTED_STANDARDS_KEY,
_LSP4_SUPPORTED_STANDARDS_VALUE
);

super._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
ERC725YCore._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
ERC725YCore._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
ERC725YCore._setData(_LSP4_TOKEN_TYPE_KEY, abi.encode(lsp4TokenType_));
}

/**
* @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
*/
function _setData(
bytes32 dataKey,
bytes memory dataValue
) internal virtual override {
if (dataKey == _LSP4_TOKEN_NAME_KEY) {
revert LSP4TokenNameNotEditable();
} else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
revert LSP4TokenSymbolNotEditable();
} else {
_store[dataKey] = dataValue;
emit DataChanged(
dataKey,
dataValue.length <= 256
? dataValue
: BytesLib.slice(dataValue, 0, 256)
);
}
) internal virtual override(ERC725YCore, LSP4DigitalAssetMetadataCore) {
LSP4DigitalAssetMetadataCore._setData(dataKey, dataValue);
}
}
Loading

0 comments on commit 4786e50

Please sign in to comment.