Skip to content

Commit

Permalink
chore(release): 0.11.0-rc.0 (#653)
Browse files Browse the repository at this point in the history
* Add virtual (#644)

* chore: add missing virtual keyword in LSP6

* chore: add missing virtual keyword in LSP7

* chore: add missing virtual keyword in LSP8

* chore: add missing virtual keyword in LSP9

* chore: add missing virtual keyword in LSP20

* chore: add missing virtual keyword in LSP0

* refactor: add virtual to target() in LSP6 core

* chore: rename _revert in LSP20CallVerification

* refactor: add virtual to all LSP6 _isAllowed checks

* feat: create LSP23MultiChainDeployment (#649)

* feat: create LSP23MultiChainDeployment

* refactor: improve LSP23 readability (#650)

* refactor: improve LSP23 readability

* tests: create helper to calculate deployed addresses

* tests: add test for lsp23

* refactor: add suggested changes & surther simplify

* refactor: remove event split, restore the initial events.

* refactor: fix generation of salt

* refactor: make salt generation functions virtual

* chore: fix typo

* refactor: move `emit` before external call to `IPostDeploymentModule`

* chore: add suggested changes

* docs: improve Natspec as suggetsed

* docs: fix Natspec typo

* chore: remove unrelated file

---------

Co-authored-by: maxvia87 <maximeviard@hotmail.fr>

---------

Co-authored-by: b00ste.lyx <62855857+b00ste@users.noreply.github.com>
Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>

* feat!: make reentracy status internal (#651)

* chore(release): 0.11.0-rc.0 (#652)

* fix: failing tests for lsp23 + add LSP23 test suite in CI (#657)

* tests: fix lsp23 tests

* ci: add lsp23 tests to lint workflow

---------

Co-authored-by: Callum Grindle <callumgrindle@gmail.com>
Co-authored-by: Skima Harvey <64636974+skimaharvey@users.noreply.github.com>
Co-authored-by: b00ste.lyx <62855857+b00ste@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 7, 2023
1 parent 8bf3a12 commit 80b85d1
Show file tree
Hide file tree
Showing 26 changed files with 953 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
"lsp11init",
"lsp20",
"lsp20init",
"lsp23",
"universalfactory",
"reentrancy",
"reentrancyinit",
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.11.0-rc.0](https://github.com/lukso-network/lsp-smart-contracts/compare/v0.10.3...v0.11.0-rc.0) (2023-08-04)

### ⚠ BREAKING CHANGES

- change visibility of `_reentrancyStatus` state variable from `private` to `internal` ([#651](https://github.com/lukso-network/lsp-smart-contracts/pull/651))

### Features

- create LSP23MultiChainDeployment ([#649](https://github.com/lukso-network/lsp-smart-contracts/issues/649)) ([01fd820](https://github.com/lukso-network/lsp-smart-contracts/commit/01fd82038811ba65798f3ff8fe8273fd191dcb38)), closes [#650](https://github.com/lukso-network/lsp-smart-contracts/issues/650)
- change visibility of `_reentrancyStatus` state variable from `private` to `internal` ([#651](https://github.com/lukso-network/lsp-smart-contracts/pull/651))

## [0.10.3](https://github.com/lukso-network/lsp-smart-contracts/compare/v0.10.2...v0.10.3) (2023-07-20)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ abstract contract LSP0ERC725AccountCore is
*/
function batchCalls(
bytes[] calldata data
) public returns (bytes[] memory results) {
) public virtual returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i; i < data.length; ) {
(bool success, bytes memory result) = address(this).delegatecall(
Expand Down
9 changes: 6 additions & 3 deletions contracts/LSP20CallVerification/LSP20CallVerification.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ abstract contract LSP20CallVerification {
bool postCall,
bool success,
bytes memory returnedData
) internal pure {
if (!success) _revert(postCall, returnedData);
) internal pure virtual {
if (!success) _revertWithLSP20DefaultError(postCall, returnedData);

// check if the returned data contains at least 32 bytes, potentially an abi encoded bytes4 value
// check if the returned data has in the first 32 bytes an abi encoded bytes4 value
Expand All @@ -81,7 +81,10 @@ abstract contract LSP20CallVerification {
) revert LSP20InvalidMagicValue(postCall, returnedData);
}

function _revert(bool postCall, bytes memory returnedData) internal pure {
function _revertWithLSP20DefaultError(
bool postCall,
bytes memory returnedData
) internal pure virtual {
// Look for revert reason and bubble it up if present
if (returnedData.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IOwnerControlledContractDeployer {
event DeployedContracts(
address indexed controlledContract,
address indexed ownerContract,
ControlledContractDeployment controlledContractDeployment,
OwnerContractDeployment ownerContractDeployment,
address postDeploymentModule,
bytes postDeploymentModuleCalldata
);

event DeployedERC1167Proxies(
address indexed controlledContract,
address indexed ownerContract,
ControlledContractDeploymentInit controlledContractDeploymentInit,
OwnerContractDeploymentInit ownerContractDeploymentInit,
address postDeploymentModule,
bytes postDeploymentModuleCalldata
);

/**
* @param salt A unique value used to ensure each created proxies are unique. (Can be used to deploy the contract at a desired address.)
* @param fundingAmount The value to be sent with the deployment transaction.
* @param creationBytecode The bytecode of the contract with the constructor params.
*/
struct ControlledContractDeployment {
bytes32 salt;
uint256 fundingAmount;
bytes creationBytecode;
}

/**
* @param fundingAmount The value to be sent with the deployment transaction.
* @param creationBytecode The constructor + runtime bytecode (without the controlled contract's address as param)
* @param addControlledContractAddress If set to `true`, this will append the controlled contract's address + the `extraConstructorParams` to the `creationBytecode`.
* @param extraConstructorParams Params to be appended to the `creationBytecode` (after the controlled contract address) if `addControlledContractAddress` is set to `true`.
*/
struct OwnerContractDeployment {
uint256 fundingAmount;
bytes creationBytecode;
bool addControlledContractAddress;
bytes extraConstructorParams;
}

/**
* @param salt A unique value used to ensure each created proxies are unique. (Can be used to deploy the contract at a desired address.)
* @param fundingAmount The value to be sent with the deployment transaction.
* @param implementationContract The address of the contract that will be used as a base contract for the proxy.
* @param initializationCalldata The calldata used to initialise the contract. (initialization should be similar to a constructor in a normal contract.)
*/
struct ControlledContractDeploymentInit {
bytes32 salt;
uint256 fundingAmount;
address implementationContract;
bytes initializationCalldata;
}

/**
* @param fundingAmount The value to be sent with the deployment transaction.
* @param implementationContract The address of the contract that will be used as a base contract for the proxy.
* @param initializationCalldata The first part of the initialisation calldata, everything before the controlled contract address.
* @param addControlledContractAddress If set to `true`, this will append the controlled contract's address + the `extraInitializationParams` to the `initializationCalldata`.
* @param extraInitializationParams Params to be appended to the `initializationCalldata` (after the controlled contract address) if `addControlledContractAddress` is set to `true`
*/
struct OwnerContractDeploymentInit {
uint256 fundingAmount;
address implementationContract;
bytes initializationCalldata;
bool addControlledContractAddress;
bytes extraInitializationParams;
}

/**
* @dev Deploys a contract and its owner contract.
* @notice Contracts deployed. Contract Address: `controlledContractAddress`. Owner Contract Address: `ownerContractAddress`
*
* @param controlledContractDeployment Contains the needed parameter to deploy a contract. (`salt`, `fundingAmount`, `creationBytecode`)
* @param ownerContractDeployment Contains the needed parameter to deploy the owner contract. (`fundingAmount`, `creationBytecode`, `addControlledContractAddress`, `extraConstructorParams`)
* @param postDeploymentModule The module to be executed after deployment
* @param postDeploymentModuleCalldata The data to be passed to the post deployment module
*
* @return controlledContractAddress The address of the deployed controlled contract.
* @return ownerContractAddress The address of the deployed owner contract.
*/
function deployContracts(
ControlledContractDeployment calldata controlledContractDeployment,
OwnerContractDeployment calldata ownerContractDeployment,
address postDeploymentModule,
bytes calldata postDeploymentModuleCalldata
)
external
payable
returns (
address controlledContractAddress,
address ownerContractAddress
);

/**
* @dev Deploys proxies of a contract and its owner contract
* @notice Contract proxies deployed. Contract Proxy Address: `controlledContractAddress`. Owner Contract Proxy Address: `ownerContractAddress`
*
* @param controlledContractDeploymentInit Contains the needed parameter to deploy a proxy contract. (`salt`, `fundingAmount`, `implementationContract`, `initializationCalldata`)
* @param ownerContractDeploymentInit Contains the needed parameter to deploy the owner proxy contract. (`fundingAmount`, `implementationContract`, `addControlledContractAddress`, `initializationCalldata`, `extraInitializationParams`)
* @param postDeploymentModule The module to be executed after deployment.
* @param postDeploymentModuleCalldata The data to be passed to the post deployment module.
*
* @return controlledContractAddress The address of the deployed controlled contract proxy
* @return ownerContractAddress The address of the deployed owner contract proxy
*/
function deployERC1167Proxies(
ControlledContractDeploymentInit
calldata controlledContractDeploymentInit,
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
address postDeploymentModule,
bytes calldata postDeploymentModuleCalldata
)
external
payable
returns (
address controlledContractAddress,
address ownerContractAddress
);

/**
* @dev Computes the addresses of the controlled and owner contracts to be created
*
* @param controlledContractDeployment Contains the needed parameter to deploy a contract. (`salt`, `fundingAmount`, `creationBytecode`)
* @param ownerContractDeployment Contains the needed parameter to deploy the owner contract. (`fundingAmount`, `creationBytecode`, `addControlledContractAddress`, `extraConstructorParams`)
* @param postDeploymentModule The module to be executed after deployment
* @param postDeploymentModuleCalldata The data to be passed to the post deployment module
*
* @return controlledContractAddress The address of the deployed controlled contract.
* @return ownerContractAddress The address of the deployed owner contract.
*/
function computeAddresses(
ControlledContractDeployment calldata controlledContractDeployment,
OwnerContractDeployment calldata ownerContractDeployment,
address postDeploymentModule,
bytes calldata postDeploymentModuleCalldata
)
external
view
returns (
address controlledContractAddress,
address ownerContractAddress
);

/**
* @dev Computes the addresses of the controlled and owner contract proxies to be created.
*
* @param controlledContractDeploymentInit Contains the needed parameter to deploy a proxy contract. (`salt`, `fundingAmount`, `implementationContract`, `initializationCalldata`)
* @param ownerContractDeploymentInit Contains the needed parameter to deploy the owner proxy contract. (`fundingAmount`, `implementationContract`, `addControlledContractAddress`, `initializationCalldata`, `extraInitializationParams`)
* @param postDeploymentModule The module to be executed after deployment.
* @param postDeploymentModuleCalldata The data to be passed to the post deployment module.
*
* @return controlledContractAddress The address of the deployed controlled contract proxy
* @return ownerContractAddress The address of the deployed owner contract proxy
*/
function computeERC1167Addresses(
ControlledContractDeploymentInit
calldata controlledContractDeploymentInit,
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
address postDeploymentModule,
bytes calldata postDeploymentModuleCalldata
)
external
view
returns (
address controlledContractAddress,
address ownerContractAddress
);
}
10 changes: 10 additions & 0 deletions contracts/LSP23MultiChainDeployment/IPostDeploymentModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IPostDeploymentModule {
function executePostDeployment(
address ownerControlledContract,
address ownerContract,
bytes calldata calldataToPostDeploymentModule
) external;
}
24 changes: 24 additions & 0 deletions contracts/LSP23MultiChainDeployment/LSP23Errors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/**
* @dev Reverts when the `msg.value` sent is not equal to the sum of value used for the deployment of the contract & its owner contract.
* @notice Invalid value sent.
*/
error InvalidValueSum();

/**
* @dev Reverts when the deployment & intialisation of the contract has failed.
* @notice Failed to deploy & initialise the Controlled Contract Proxy. Error: `errorData`.
*
* @param errorData Potentially information about why the deployment & intialisation have failed.
*/
error ControlledContractProxyInitFailureError(bytes errorData);

/**
* @dev Reverts when the deployment & intialisation of the owner contract has failed.
* @notice Failed to deploy & initialise the Owner Contract Proxy. Error: `errorData`.
*
* @param errorData Potentially information about why the deployment & intialisation have failed.
*/
error OwnerContractProxyInitFailureError(bytes errorData);
Loading

0 comments on commit 80b85d1

Please sign in to comment.