Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:lukso-network/lsp-smart-contract…
Browse files Browse the repository at this point in the history
…s into DEV-7694
  • Loading branch information
skimaharvey committed Aug 22, 2023
2 parents f0372f8 + ade0b2e commit 04a109b
Show file tree
Hide file tree
Showing 31 changed files with 1,199 additions and 985 deletions.
9 changes: 8 additions & 1 deletion contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,16 @@ abstract contract LSP0ERC725AccountCore is
// Depending on the magicValue returned, a second call is done after transferring ownership
bool verifyAfter = _verifyCall(_owner);

// set the pending owner
address previousOwner = owner();
LSP14Ownable2Step._renounceOwnership();

if (owner() == address(0)) {
previousOwner.tryNotifyUniversalReceiver(
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
""
);
}

// If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
// The transferOwnership function does not return, second parameter of {_verifyCallResult} will be empty
if (verifyAfter) {
Expand Down
47 changes: 0 additions & 47 deletions contracts/LSP0ERC725Account/LSP0Utils.sol

This file was deleted.

8 changes: 8 additions & 0 deletions contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
override(OwnableUnset, ILSP14Ownable2Step)
onlyOwner
{
address previousOwner = owner();
_renounceOwnership();

if (owner() == address(0)) {
previousOwner.tryNotifyUniversalReceiver(
_TYPEID_LSP14_OwnershipTransferred_SenderNotification,
""
);
}
}

// --- Internal methods
Expand Down
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
2 changes: 1 addition & 1 deletion contracts/LSP20CallVerification/LSP20CallVerification.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract contract LSP20CallVerification {
if (bytes3(magicValue) != bytes3(ILSP20.lsp20VerifyCall.selector))
revert LSP20InvalidMagicValue(false, returnedData);

return bytes1(magicValue[3]) == 0x01 ? true : false;
return magicValue[3] == 0x01 ? true : false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
pragma solidity ^0.8.4;

interface ILSP23LinkedContractsFactory {
/**
* @dev Emitted when a primary and secondary contract are deployed.
* @param primaryContract Address of the deployed primary contract.
* @param secondaryContract Address of the deployed secondary contract.
* @param primaryContractDeployment Parameters used for the primary contract deployment.
* @param secondaryContractDeployment Parameters used for the secondary contract deployment.
* @param postDeploymentModule Address of the post-deployment module.
* @param postDeploymentModuleCalldata Calldata passed to the post-deployment module.
*/
event DeployedContracts(
address indexed primaryContract,
address indexed secondaryContract,
Expand All @@ -11,6 +20,15 @@ interface ILSP23LinkedContractsFactory {
bytes postDeploymentModuleCalldata
);

/**
* @dev Emitted when proxies of a primary and secondary contract are deployed.
* @param primaryContract Address of the deployed primary contract proxy.
* @param secondaryContract Address of the deployed secondary contract proxy.
* @param primaryContractDeploymentInit Parameters used for the primary contract proxy deployment.
* @param secondaryContractDeploymentInit Parameters used for the secondary contract proxy deployment.
* @param postDeploymentModule Address of the post-deployment module.
* @param postDeploymentModuleCalldata Calldata passed to the post-deployment module.
*/
event DeployedERC1167Proxies(
address indexed primaryContract,
address indexed secondaryContract,
Expand Down
10 changes: 6 additions & 4 deletions contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,14 @@ abstract contract LSP6SetDataModule {
* The length of a data key is 32 bytes.
* Therefore we can have a fixed allowed data key which has
* a length of 32 bytes or we can have a dynamic data key
* which can have a length of up to 31 bytes.
* which can have a length from 1 up to 31 bytes.
*/
if (length > 32)
if (length == 0 || length > 32) {
revert InvalidEncodedAllowedERC725YDataKeys(
allowedERC725YDataKeysCompacted,
"couldn't DECODE from storage"
);
}

/**
* The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
Expand Down Expand Up @@ -690,13 +691,14 @@ abstract contract LSP6SetDataModule {
* The length of a data key is 32 bytes.
* Therefore we can have a fixed allowed data key which has
* a length of 32 bytes or we can have a dynamic data key
* which can have a length of up to 31 bytes.
* which can have a length from 1 up to 31 bytes.
*/
if (length > 32)
if (length == 0 || length > 32) {
revert InvalidEncodedAllowedERC725YDataKeys(
allowedERC725YDataKeysCompacted,
"couldn't DECODE from storage"
);
}

/**
* The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
Expand Down
8 changes: 8 additions & 0 deletions contracts/LSP9Vault/LSP9VaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,15 @@ contract LSP9VaultCore is
override(LSP14Ownable2Step, OwnableUnset)
onlyOwner
{
address previousOwner = owner();
LSP14Ownable2Step._renounceOwnership();

if (owner() == address(0)) {
previousOwner.tryNotifyUniversalReceiver(
_TYPEID_LSP9_OwnershipTransferred_SenderNotification,
""
);
}
}

/**
Expand Down
4 changes: 1 addition & 3 deletions contracts/Mocks/Tokens/TokenReceiverWithLSP1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
import {_INTERFACEID_LSP1} from "../../LSP1UniversalReceiver/LSP1Constants.sol";

contract TokenReceiverWithLSP1 is ERC165Storage, ILSP1UniversalReceiver {
event UniversalReceiverCalled(bytes32 typeId, bytes data);

constructor() {
_registerInterface(_INTERFACEID_LSP1);
}
Expand All @@ -25,7 +23,7 @@ contract TokenReceiverWithLSP1 is ERC165Storage, ILSP1UniversalReceiver {
bytes32 typeId,
bytes memory data
) external payable override returns (bytes memory returnValue) {
emit UniversalReceiverCalled(typeId, data);
emit UniversalReceiver(msg.sender, msg.value, typeId, data, "");

return "thanks for calling";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ contract TokenReceiverWithLSP1WithERC721Received is
ILSP1UniversalReceiver,
ERC721Holder
{
event UniversalReceiverCalled(bytes32 typeId, bytes data);

constructor() {
_registerInterface(_INTERFACEID_LSP1);
}
Expand All @@ -36,7 +34,7 @@ contract TokenReceiverWithLSP1WithERC721Received is
bytes32 typeId,
bytes memory data
) external payable override returns (bytes memory returnValue) {
emit UniversalReceiverCalled(typeId, data);
emit UniversalReceiver(msg.sender, msg.value, typeId, data, "");

return "thanks for calling";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ contract TokenReceiverWithLSP1WithERC721ReceivedInvalid is
ILSP1UniversalReceiver,
ERC721Holder
{
event UniversalReceiverCalled(bytes32 typeId, bytes data);

constructor() {
_registerInterface(_INTERFACEID_LSP1);
}
Expand All @@ -36,7 +34,7 @@ contract TokenReceiverWithLSP1WithERC721ReceivedInvalid is
bytes32 typeId,
bytes memory data
) external payable override returns (bytes memory returnValue) {
emit UniversalReceiverCalled(typeId, data);
emit UniversalReceiver(msg.sender, msg.value, typeId, data, "");

return "thanks for calling";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ contract TokenReceiverWithLSP1WithERC721ReceivedRevert is
ILSP1UniversalReceiver,
ERC721Holder
{
event UniversalReceiverCalled(bytes32 typeId, bytes data);

constructor() {
_registerInterface(_INTERFACEID_LSP1);
}
Expand All @@ -36,7 +34,7 @@ contract TokenReceiverWithLSP1WithERC721ReceivedRevert is
bytes32 typeId,
bytes memory data
) external payable override returns (bytes memory returnValue) {
emit UniversalReceiverCalled(typeId, data);
emit UniversalReceiver(msg.sender, msg.value, typeId, data, "");

return "thanks for calling";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
import {_INTERFACEID_LSP1} from "../../LSP1UniversalReceiver/LSP1Constants.sol";

contract TokenReceiverWithoutLSP1WithERC721Received is ERC721Holder {
event UniversalReceiverCalled(bytes32 typeId, bytes data);

receive() external payable {}

fallback() external payable {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
import {_INTERFACEID_LSP1} from "../../LSP1UniversalReceiver/LSP1Constants.sol";

contract TokenReceiverWithoutLSP1WithERC721ReceivedInvalid is ERC721Holder {
event UniversalReceiverCalled(bytes32 typeId, bytes data);

receive() external payable {}

fallback() external payable {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
import {_INTERFACEID_LSP1} from "../../LSP1UniversalReceiver/LSP1Constants.sol";

contract TokenReceiverWithoutLSP1WithERC721ReceivedRevert is ERC721Holder {
event UniversalReceiverCalled(bytes32 typeId, bytes data);

receive() external payable {}

fallback() external payable {}
Expand Down
Loading

0 comments on commit 04a109b

Please sign in to comment.