Skip to content

Commit

Permalink
Merge branch 'develop' into lsp1-data-in-lsp0
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 authored Nov 6, 2023
2 parents 5e302d3 + e7ef125 commit c76896f
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 53 deletions.
6 changes: 5 additions & 1 deletion contracts/LSP0ERC725Account/LSP0ERC725Account.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import {_TYPEID_LSP0_VALUE_RECEIVED} from "./LSP0Constants.sol";
contract LSP0ERC725Account is LSP0ERC725AccountCore {
/**
* @notice Deploying a LSP0ERC725Account contract with owner set to address `initialOwner`.
* @dev Set `initialOwner` as the contract owner. The `constructor` also allows funding the contract on deployment.
*
* @dev Set `initialOwner` as the contract owner.
* - The `constructor` also allows funding the contract on deployment.
* - The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
*
* @param initialOwner The owner of the contract.
*
* @custom:events
Expand Down
7 changes: 6 additions & 1 deletion contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ abstract contract LSP0ERC725AccountCore is
* - When notifying the previous owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_SenderNotification].
* - When notifying the new owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_RecipientNotification].
*/
function acceptOwnership() public virtual override NotInTransferOwnership {
function acceptOwnership() public virtual override notInTransferOwnership {
address previousOwner = owner();
address pendingOwnerAddress = pendingOwner();

Expand Down Expand Up @@ -726,6 +726,11 @@ abstract contract LSP0ERC725AccountCore is
* @param signature A signature that can validate the previous parameter (Hash).
*
* @return returnedStatus A `bytes4` value that indicates if the signature is valid or not.
*
* @custom:warning This function does not enforce by default the inclusion of the address of this contract in the signature digest.
* It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign.
* To ensure that a signature is valid for a specific LSP0ERC725Account and prevent signatures from the same EOA to be replayed
* across different LSP0ERC725Accounts.
*/
function isValidSignature(
bytes32 dataHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ abstract contract LSP0ERC725AccountInitAbstract is
{
/**
* @dev Set `initialOwner` as the contract owner.
* The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
*
* @param initialOwner The owner of the contract.
*
* @custom:warning ERC725X & ERC725Y parent contracts are not initialised as they don't have non-zero initial state. If you decide to add non-zero initial state to any of those contracts, you must initialize them here.
* @custom:warning ERC725X & ERC725Y parent contracts are not initialixed as they don't have non-zero initial state.
* If you decide to add non-zero initial state to any of those contracts, you MUST initialize them here.
*
* @custom:events
* - {UniversalReceiver} event when funding the contract on deployment.
Expand Down
4 changes: 2 additions & 2 deletions contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
/**
* @dev reverts when {_inTransferOwnership} variable is true
*/
modifier NotInTransferOwnership() virtual {
modifier notInTransferOwnership() virtual {
if (_inTransferOwnership) {
revert LSP14MustAcceptOwnershipInSeparateTransaction();
}
Expand Down Expand Up @@ -111,7 +111,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
*
* @custom:requirements This function can only be called by the {pendingOwner()}.
*/
function acceptOwnership() public virtual override NotInTransferOwnership {
function acceptOwnership() public virtual override notInTransferOwnership {
address previousOwner = owner();

_acceptOwnership();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract LSP1UniversalReceiverDelegateUP is
*
* @param notifier The address that notified.
*/
modifier NotEOA(address notifier) {
modifier notEOA(address notifier) {
// solhint-disable-next-line avoid-tx-origin
if (notifier == tx.origin) {
revert CannotRegisterEOAsAsAssets(notifier);
Expand Down Expand Up @@ -145,7 +145,7 @@ contract LSP1UniversalReceiverDelegateUP is
*/
function _tokenSender(
address notifier
) internal NotEOA(notifier) returns (bytes memory) {
) internal notEOA(notifier) returns (bytes memory) {
// if the amount sent is not the full balance, then do not update the keys
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
uint256 balance
Expand Down Expand Up @@ -183,7 +183,7 @@ contract LSP1UniversalReceiverDelegateUP is
function _tokenRecipient(
address notifier,
bytes4 interfaceId
) internal NotEOA(notifier) returns (bytes memory) {
) internal notEOA(notifier) returns (bytes memory) {
// CHECK balance only when the Token contract is already deployed,
// not when tokens are being transferred on deployment through the `constructor`
if (notifier.code.length != 0) {
Expand Down Expand Up @@ -223,7 +223,7 @@ contract LSP1UniversalReceiverDelegateUP is
*/
function _vaultSender(
address notifier
) internal NotEOA(notifier) returns (bytes memory) {
) internal notEOA(notifier) returns (bytes memory) {
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
.generateSentVaultKeys(msg.sender, notifier);

Expand All @@ -248,7 +248,7 @@ contract LSP1UniversalReceiverDelegateUP is
*/
function _vaultRecipient(
address notifier
) internal NotEOA(notifier) returns (bytes memory) {
) internal notEOA(notifier) returns (bytes memory) {
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
.generateReceivedVaultKeys(msg.sender, notifier);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract LSP1UniversalReceiverDelegateVault is
*
* @param notifier The address that notified.
*/
modifier NotEOA(address notifier) {
modifier notEOA(address notifier) {
// solhint-disable-next-line avoid-tx-origin
if (notifier == tx.origin) {
revert CannotRegisterEOAsAsAssets(notifier);
Expand Down Expand Up @@ -120,7 +120,7 @@ contract LSP1UniversalReceiverDelegateVault is
*/
function _tokenSender(
address notifier
) internal NotEOA(notifier) returns (bytes memory) {
) internal notEOA(notifier) returns (bytes memory) {
// if the amount sent is not the full balance, then do not update the keys
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
uint256 balance
Expand Down Expand Up @@ -158,7 +158,7 @@ contract LSP1UniversalReceiverDelegateVault is
function _tokenRecipient(
address notifier,
bytes4 interfaceId
) internal NotEOA(notifier) returns (bytes memory) {
) internal notEOA(notifier) returns (bytes memory) {
// CHECK balance only when the Token contract is already deployed,
// not when tokens are being transferred on deployment through the `constructor`
if (notifier.code.length != 0) {
Expand Down
17 changes: 12 additions & 5 deletions contracts/LSP6KeyManager/LSP6KeyManagerCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ abstract contract LSP6KeyManagerCore is
* If the signer is a controller with the permission `SIGN`, it will return the ERC1271 success value.
*
* @return returnedStatus `0x1626ba7e` on success, or `0xffffffff` on failure.
*
* @custom:warning This function does not enforce by default the inclusion of the address of this contract in the signature digest.
* It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign.
* To ensure that a signature is valid for a specific LSP6KeyManager and prevent signatures from the same EOA to be replayed
* across different LSP6KeyManager.
*/
function isValidSignature(
bytes32 dataHash,
Expand Down Expand Up @@ -636,9 +641,11 @@ abstract contract LSP6KeyManagerCore is
}

/**
* @dev Update the status from `_NON_ENTERED` to `_ENTERED` and checks if
* the status is `_ENTERED` in order to revert the call unless the caller has the REENTRANCY permission
* Used in the beginning of the `nonReentrant` modifier, before the method execution starts.
* @dev Check if we are in the context of a reentrant call, by checking if the reentrancy status is `true`.
* - If the status is `true`, the caller (or signer for relay call) MUST have the `REENTRANCY` permission. Otherwise, the call is reverted.
* - If the status is `false`, it is set to `true` only if we are not dealing with a call to the functions `setData` or `setDataBatch`.
* Used at the beginning of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions, before the methods execution starts.
*
*/
function _nonReentrantBefore(
address targetContract,
Expand All @@ -662,8 +669,8 @@ abstract contract LSP6KeyManagerCore is
}

/**
* @dev Resets the status to `false`
* Used in the end of the `nonReentrant` modifier after the method execution is terminated
* @dev Resets the reentrancy status to `false`
* Used at the end of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions after the functions' execution is terminated.
*/
function _nonReentrantAfter(address targetContract) internal virtual {
// By storing the original value once again, a refund is triggered (see
Expand Down
4 changes: 2 additions & 2 deletions contracts/LSP9Vault/LSP9VaultCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ contract LSP9VaultCore is
* - When notifying the previous owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_SenderNotification].
* - When notifying the new owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_RecipientNotification].
*/
function acceptOwnership() public virtual override NotInTransferOwnership {
function acceptOwnership() public virtual override notInTransferOwnership {
address previousOwner = owner();

_acceptOwnership();
Expand Down Expand Up @@ -625,7 +625,7 @@ contract LSP9VaultCore is
}

/**
* @dev Modifier restricting the call to the owner of the contract and the UniversalReceiverDelegate
* @dev Internal method restricting the call to the owner of the contract and the UniversalReceiverDelegate
*/
function _validateAndIdentifyCaller()
internal
Expand Down
6 changes: 2 additions & 4 deletions contracts/Mocks/Executor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ contract Executor {
LSP6KeyManager private _keyManager;
UniversalProfile private _universalProfile;

// payable modifier is required as _account is non-payable by default
// but UniversalProfile has a payable fallback function
constructor(address payable account_, address keyManager_) {
_universalProfile = UniversalProfile(account_);
constructor(UniversalProfile account_, address keyManager_) {
_universalProfile = account_;
_keyManager = LSP6KeyManager(keyManager_);
}

Expand Down
6 changes: 2 additions & 4 deletions contracts/Mocks/ExecutorLSP20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ contract ExecutorLSP20 {

UniversalProfile private _universalProfile;

// payable modifier is required as _account is non-payable by default
// but UniversalProfile has a payable fallback function
constructor(address payable account_) {
_universalProfile = UniversalProfile(account_);
constructor(UniversalProfile account_) {
_universalProfile = account_;
}

// contract calls
Expand Down
4 changes: 3 additions & 1 deletion contracts/UniversalProfile.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ contract UniversalProfile is LSP0ERC725Account {
/**
* @notice Deploying a UniversalProfile contract with owner set to address `initialOwner`.
*
* @dev Set `initialOwner` as the contract owner and the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store. The `constructor` also allows funding the contract on deployment.
* @dev Set `initialOwner` as the contract owner and the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store.
* - The `constructor` is payable and allows funding the contract on deployment.
* - The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
*
* @param initialOwner the owner of the contract
*
Expand Down
10 changes: 6 additions & 4 deletions contracts/UniversalProfileInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import {UniversalProfileInitAbstract} from "./UniversalProfileInitAbstract.sol";
contract UniversalProfileInit is UniversalProfileInitAbstract {
/**
* @notice deploying a `UniversalProfileInit` base contract to be used behind proxy
* @dev Locks the base contract on deployment, so that it cannot be initialized, owned and controlled by anyone
* after it has been deployed. This is intended so that the sole purpose of this contract is to be used as a base
* contract behind a proxy.
* @dev Locks the base contract on deployment, so that it cannot be initialized, owned and controlled by anyone after it has been deployed.
* This is intended so that the sole purpose of this contract is to be used as a base contract behind a proxy.
*/
constructor() {
_disableInitializers();
Expand All @@ -23,13 +22,16 @@ contract UniversalProfileInit is UniversalProfileInitAbstract {
/**
* @notice Initializing a UniversalProfile contract with owner set to address `initialOwner`.
*
* @dev Set `initialOwner` as the contract owner and the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store. The `constructor` also allows funding the contract on deployment. The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier. The `initialize(address)` function also allows funding the contract on initialization.
* @dev Set `initialOwner` as the contract owner and the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store.
* - The `initialize(address)` function is payable and allows funding the contract on initialization.
* - The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
*
* @param initialOwner the owner of the contract
*
* @custom:events
* - {UniversalReceiver} event when funding the contract on deployment.
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
* - {DataChanged} event when setting the {_LSP3_SUPPORTED_STANDARDS_KEY}.
*/
function initialize(
address initialOwner
Expand Down
2 changes: 2 additions & 0 deletions contracts/UniversalProfileInitAbstract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ abstract contract UniversalProfileInitAbstract is
{
/**
* @dev Set `initialOwner` as the contract owner and the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store.
* The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
*
* @param initialOwner The owner of the contract.
*
Expand All @@ -30,6 +31,7 @@ abstract contract UniversalProfileInitAbstract is
* @custom:events
* - {UniversalReceiver} event when funding the contract on deployment.
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
* - {DataChanged} event when setting the {_LSP3_SUPPORTED_STANDARDS_KEY}.
*/
function _initialize(
address initialOwner
Expand Down
4 changes: 3 additions & 1 deletion deploy/001_deploy_universal_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const deployUniversalProfile: DeployFunction = async ({
const { deploy } = deployments;
const { owner } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('UniversalProfile', {
from: owner,
args: [owner],
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei
gasPrice,
log: true,
});
};
Expand Down
4 changes: 3 additions & 1 deletion deploy/002_deploy_key_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const deployKeyManager: DeployFunction = async ({

const UniversalProfile = await deployments.get('UniversalProfile');

const gasPrice = await ethers.provider.getGasPrice();

await deploy('LSP6KeyManager', {
from: owner,
args: [UniversalProfile.address],
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei
gasPrice,
log: true,
});
};
Expand Down
4 changes: 3 additions & 1 deletion deploy/003_deploy_universal_receiver_delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const deployUniversalReceiverDelegateUPDeterministic: DeployFunction = async ({
const { deploy } = deployments;
const { owner: deployer } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('LSP1UniversalReceiverDelegateUP', {
from: deployer,
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei
gasPrice,
log: true,
deterministicDeployment: SALT,
});
Expand Down
4 changes: 3 additions & 1 deletion deploy/005_deploy_universal_receiver_delegate_vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const deployUniversalReceiverDelegateVaultDeterministic: DeployFunction = async
const { deploy } = deployments;
const { owner: deployer } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('LSP1UniversalReceiverDelegateVault', {
from: deployer,
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei
gasPrice,
log: true,
deterministicDeployment: SALT,
});
Expand Down
4 changes: 3 additions & 1 deletion deploy/006_deploy_base_universal_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ const deployBaseUniversalProfileDeterministic: DeployFunction = async ({
const { deploy } = deployments;
const { owner: deployer } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('UniversalProfileInit', {
from: deployer,
log: true,
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei
gasPrice,
deterministicDeployment: SALT,
});
};
Expand Down
4 changes: 3 additions & 1 deletion deploy/007_deploy_base_key_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const deployBaseKeyManagerDeterministic: DeployFunction = async ({
const { deploy } = deployments;
const { owner: deployer } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('LSP6KeyManagerInit', {
from: deployer,
log: true,
gasLimit: 5_000_000,
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei
gasPrice,
deterministicDeployment: SALT,
});
};
Expand Down
4 changes: 3 additions & 1 deletion deploy/008_deploy_lsp7_mintable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const deployLSP7Mintable: DeployFunction = async ({
const { deploy } = deployments;
const { owner } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('LSP7Mintable', {
from: owner,
args: ['LSP7 Mintable', 'LSP7M', owner, false],
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei,
gasPrice,
log: true,
});
};
Expand Down
4 changes: 3 additions & 1 deletion deploy/009_deploy_lsp8_mintable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const deployLSP8MintableDeterministic: DeployFunction = async ({
const { deploy } = deployments;
const { owner: deployer } = await getNamedAccounts();

const gasPrice = await ethers.provider.getGasPrice();

await deploy('LSP8Mintable', {
from: deployer,
args: ['LSP8 Mintable', 'LSP8M', deployer],
gasPrice: ethers.BigNumber.from(20_000_000_000), // in wei,
gasPrice,
log: true,
deterministicDeployment: true,
});
Expand Down
Loading

0 comments on commit c76896f

Please sign in to comment.