-
Notifications
You must be signed in to change notification settings - Fork 138
/
NoncesExternalization.sol
64 lines (49 loc) · 1.83 KB
/
NoncesExternalization.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ChildContract {
constructor() {}
}
contract ParentContract {
constructor() {}
function deployChildContract() external returns(address) {
return address(new ChildContract());
}
}
contract NoncesExternalization {
address[] deployedParentContracts;
address[] deployedChildContracts;
constructor() {
deployedParentContracts.push(address(new ParentContract()));
deployedParentContracts.push(address(new ParentContract()));
deployedParentContracts.push(address(new ParentContract()));
}
function deployParentContract() external {
address parentContract = address(new ParentContract());
deployedParentContracts.push(parentContract);
}
function deployParentContractAndRevert() external {
address parentContract = address(new ParentContract());
deployedParentContracts.push(parentContract);
revert();
}
function deployChildFromParentContract(uint256 _index) external {
ParentContract parentContract = ParentContract(deployedParentContracts[_index]);
address childContract = address(parentContract.deployChildContract());
deployedChildContracts.push(childContract);
}
/**
Log functions
*/
function getParentContractsByIndex(uint256 _index) public view returns(address) {
return address(deployedParentContracts[_index]);
}
function getChildContractsByIndex(uint256 _index) public view returns(address) {
return address(deployedChildContracts[_index]);
}
function getParentContractsSize() external view returns(uint256) {
return deployedParentContracts.length;
}
function getChildContractsSize() external view returns(uint256) {
return deployedChildContracts.length;
}
}