From 6da5368a828ca9eedb1ecc1b8e47d341e0c8fd4c Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Wed, 7 Dec 2022 16:08:16 +0200 Subject: [PATCH 1/4] feat: add salt to the contractcreated event --- implementations/contracts/ERC725XCore.sol | 4 ++-- implementations/contracts/interfaces/IERC725X.sol | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/implementations/contracts/ERC725XCore.sol b/implementations/contracts/ERC725XCore.sol index e2a6d9c6..e2cf332b 100644 --- a/implementations/contracts/ERC725XCore.sol +++ b/implementations/contracts/ERC725XCore.sol @@ -219,7 +219,7 @@ abstract contract ERC725XCore is OwnableUnset, ERC165, IERC725X { } newContract = abi.encodePacked(contractAddress); - emit ContractCreated(OPERATION_1_CREATE, contractAddress, value); + emit ContractCreated(OPERATION_1_CREATE, contractAddress, value, bytes32(0)); } /** @@ -242,7 +242,7 @@ abstract contract ERC725XCore is OwnableUnset, ERC165, IERC725X { address contractAddress = Create2.deploy(value, salt, bytecode); newContract = abi.encodePacked(contractAddress); - emit ContractCreated(OPERATION_2_CREATE2, contractAddress, value); + emit ContractCreated(OPERATION_2_CREATE2, contractAddress, value, salt); } /** diff --git a/implementations/contracts/interfaces/IERC725X.sol b/implementations/contracts/interfaces/IERC725X.sol index b4d9c718..3f13ae45 100644 --- a/implementations/contracts/interfaces/IERC725X.sol +++ b/implementations/contracts/interfaces/IERC725X.sol @@ -20,7 +20,8 @@ interface IERC725X is IERC165 { event ContractCreated( uint256 indexed operationType, address indexed contractAddress, - uint256 indexed value + uint256 indexed value, + bytes32 salt ); /** From 76c5e5ceb062900ff82b689d185b54278542ab62 Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Wed, 7 Dec 2022 16:08:28 +0200 Subject: [PATCH 2/4] test: adjust the test to support new param of the event --- implementations/test/ERC725X.behaviour.ts | 36 +++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/implementations/test/ERC725X.behaviour.ts b/implementations/test/ERC725X.behaviour.ts index fae89b61..0c586603 100644 --- a/implementations/test/ERC725X.behaviour.ts +++ b/implementations/test/ERC725X.behaviour.ts @@ -855,7 +855,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + "0x" + "0".repeat(64) ); const codeRetreived = await provider.getCode( @@ -913,7 +914,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + "0x" + "0".repeat(64) ); const codeRetreived = await provider.getCode( @@ -962,7 +964,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + "0x" + "0".repeat(64) ); const codeRetreived = await provider.getCode( @@ -1064,7 +1067,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + "0x" + "0".repeat(64) ); const codeRetreived = await provider.getCode( @@ -1179,7 +1183,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + salt ); const codeRetreived = await provider.getCode( @@ -1241,7 +1246,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + salt ); const codeRetreived = await provider.getCode( @@ -1294,7 +1300,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + salt ); const codeRetreived = await provider.getCode( @@ -1431,7 +1438,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + salt ); const codeRetreived = await provider.getCode( @@ -1542,7 +1550,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operation, addressContractCreatedChecksumed, - txParams.value + txParams.value, + salt ); const codeRetreived = await provider.getCode( @@ -2275,7 +2284,8 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operations[1], contractAddress, - txParams.values[1] + txParams.values[1], + "0x" + "0".repeat(64) ); const codeOfContractCreated = await provider.getCode( @@ -2400,13 +2410,15 @@ export const shouldBehaveLikeERC725X = ( .withArgs( txParams.Operations[0], ethers.utils.getAddress(contractsAddresses[0]), - txParams.values[0] + txParams.values[0], + "0x" + "0".repeat(64) ) .to.emit(context.erc725X, "ContractCreated") .withArgs( txParams.Operations[1], ethers.utils.getAddress(contractsAddresses[1]), - txParams.values[1] + txParams.values[1], + "0x" + "0".repeat(64) ); const codeOfContractCreated1 = await provider.getCode( From 5a42a0bf747e73f2efdd3b41e5310c6c414bfb90 Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Wed, 7 Dec 2022 16:08:41 +0200 Subject: [PATCH 3/4] docs: adjust the specification accordingly --- docs/ERC-725.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/ERC-725.md b/docs/ERC-725.md index 342bf6c3..6fbf383f 100644 --- a/docs/ERC-725.md +++ b/docs/ERC-725.md @@ -52,7 +52,7 @@ Smart contracts implementing the ERC725X standard SHOULD implement all of the fu #### execute ```solidity -function execute(uint256 operationType, address target, uint256 value, bytes memory data) public payable returns(bytes memory) +function execute(uint256 operationType, address target, uint256 value, bytes memory data) external payable returns(bytes memory) ``` Function Selector: `0x44c028fe` @@ -109,7 +109,7 @@ data = + + =0.5.0 <0.7.0; // ERC165 identifier: `0x570ef073` interface IERC725X /* is ERC165, ERC173 */ { - event ContractCreated(uint256 indexed operationType, address indexed contractAddress, uint256 indexed value); + event ContractCreated(uint256 indexed operationType, address indexed contractAddress, uint256 indexed value, bytes32 salt); event Executed(uint256 indexed operationType, address indexed target, uint256 indexed value, bytes4 data); function execute(uint256 operationType, address target, uint256 value, bytes memory data) external payable returns(bytes memory); From 525ea2273f1fc7c115ec845080bcd4d54f4b3fe7 Mon Sep 17 00:00:00 2001 From: YamenMerhi Date: Thu, 8 Dec 2022 12:43:34 +0200 Subject: [PATCH 4/4] test: improvement on bytes32(0) constant --- implementations/test/ERC725X.behaviour.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/implementations/test/ERC725X.behaviour.ts b/implementations/test/ERC725X.behaviour.ts index 0c586603..2029cded 100644 --- a/implementations/test/ERC725X.behaviour.ts +++ b/implementations/test/ERC725X.behaviour.ts @@ -856,7 +856,7 @@ export const shouldBehaveLikeERC725X = ( txParams.Operation, addressContractCreatedChecksumed, txParams.value, - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ); const codeRetreived = await provider.getCode( @@ -915,7 +915,7 @@ export const shouldBehaveLikeERC725X = ( txParams.Operation, addressContractCreatedChecksumed, txParams.value, - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ); const codeRetreived = await provider.getCode( @@ -965,7 +965,7 @@ export const shouldBehaveLikeERC725X = ( txParams.Operation, addressContractCreatedChecksumed, txParams.value, - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ); const codeRetreived = await provider.getCode( @@ -1068,7 +1068,7 @@ export const shouldBehaveLikeERC725X = ( txParams.Operation, addressContractCreatedChecksumed, txParams.value, - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ); const codeRetreived = await provider.getCode( @@ -2285,7 +2285,7 @@ export const shouldBehaveLikeERC725X = ( txParams.Operations[1], contractAddress, txParams.values[1], - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ); const codeOfContractCreated = await provider.getCode( @@ -2411,14 +2411,14 @@ export const shouldBehaveLikeERC725X = ( txParams.Operations[0], ethers.utils.getAddress(contractsAddresses[0]), txParams.values[0], - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ) .to.emit(context.erc725X, "ContractCreated") .withArgs( txParams.Operations[1], ethers.utils.getAddress(contractsAddresses[1]), txParams.values[1], - "0x" + "0".repeat(64) + ethers.utils.hexZeroPad("0x00", 32) ); const codeOfContractCreated1 = await provider.getCode(