Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: add salt parameter to the ContractCreated event in ERC725X #183

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/ERC-725.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
YamenMerhi marked this conversation as resolved.
Show resolved Hide resolved
```

Function Selector: `0x44c028fe`
Expand Down Expand Up @@ -109,7 +109,7 @@ data = <contract-creation-code> + <abi-encoded-constructor-arguments> + <bytes32
#### execute (Array)

```solidity
function execute(uint256[] memory operationsType, address[] memory targets, uint256[] memory values, bytes[] memory datas) public payable returns(bytes[] memory)
function execute(uint256[] memory operationsType, address[] memory targets, uint256[] memory values, bytes[] memory datas) external payable returns(bytes[] memory)
```

Function Selector: `0x13ced88d`
Expand Down Expand Up @@ -191,7 +191,7 @@ Smart contracts implementing the ERC725Y standard MUST implement all of the func
#### getData

```solidity
function getData(bytes32 dataKey) public view returns(bytes memory)
function getData(bytes32 dataKey) external view returns(bytes memory)
```

Function Selector: `0x54f6127f`
Expand All @@ -207,7 +207,7 @@ _Returns:_ `bytes` , The data for the requested data key.
#### getData (Array)

```solidity
function getData(bytes32[] memory dataKeys) public view returns(bytes[] memory)
function getData(bytes32[] memory dataKeys) external view returns(bytes[] memory)
```

Function Selector: `0x4e3e6e9c`
Expand All @@ -223,7 +223,7 @@ _Returns:_ `bytes[]` , array of data values for the requested data keys.
#### setData

```solidity
function setData(bytes32 dataKey, bytes memory dataValue) public
function setData(bytes32 dataKey, bytes memory dataValue) external
```

Function Selector: `0x7f23690c`
Expand All @@ -244,7 +244,7 @@ _Requirements:_
#### setData (Array)

```solidity
function setData(bytes32[] memory dataKeys, bytes[] memory dataValues) public
function setData(bytes32[] memory dataKeys, bytes[] memory dataValues) external
```

Function Selector: `0x14a6e293`
Expand Down Expand Up @@ -328,7 +328,7 @@ pragma solidity >=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);
Expand Down
4 changes: 2 additions & 2 deletions implementations/contracts/ERC725XCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand All @@ -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);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion implementations/contracts/interfaces/IERC725X.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ interface IERC725X is IERC165 {
event ContractCreated(
uint256 indexed operationType,
address indexed contractAddress,
uint256 indexed value
uint256 indexed value,
bytes32 salt
);

/**
Expand Down
36 changes: 24 additions & 12 deletions implementations/test/ERC725X.behaviour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
ethers.utils.hexZeroPad("0x00", 32)
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -913,7 +914,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
ethers.utils.hexZeroPad("0x00", 32)
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -962,7 +964,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
ethers.utils.hexZeroPad("0x00", 32)
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -1064,7 +1067,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
ethers.utils.hexZeroPad("0x00", 32)
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -1179,7 +1183,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
salt
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -1241,7 +1246,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
salt
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -1294,7 +1300,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
salt
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -1431,7 +1438,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
salt
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -1542,7 +1550,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operation,
addressContractCreatedChecksumed,
txParams.value
txParams.value,
salt
);

const codeRetreived = await provider.getCode(
Expand Down Expand Up @@ -2275,7 +2284,8 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operations[1],
contractAddress,
txParams.values[1]
txParams.values[1],
ethers.utils.hexZeroPad("0x00", 32)
);

const codeOfContractCreated = await provider.getCode(
Expand Down Expand Up @@ -2400,13 +2410,15 @@ export const shouldBehaveLikeERC725X = (
.withArgs(
txParams.Operations[0],
ethers.utils.getAddress(contractsAddresses[0]),
txParams.values[0]
txParams.values[0],
ethers.utils.hexZeroPad("0x00", 32)
)
.to.emit(context.erc725X, "ContractCreated")
.withArgs(
txParams.Operations[1],
ethers.utils.getAddress(contractsAddresses[1]),
txParams.values[1]
txParams.values[1],
ethers.utils.hexZeroPad("0x00", 32)
);

const codeOfContractCreated1 = await provider.getCode(
Expand Down