@@ -22,10 +22,12 @@ contract MasterChild {
2222 }
2323}
2424
25- contract CloneFactory {
25+ contract CloneFactory is NilBase {
2626 address public masterChildAddress;
2727
28- constructor (address _masterChildAddress ) {
28+ event counterCloneCreated (address indexed addr );
29+
30+ constructor (address _masterChildAddress ) payable {
2931 masterChildAddress = _masterChildAddress;
3032 }
3133
@@ -49,14 +51,18 @@ contract CloneFactory {
4951 finalBytecode = code;
5052 }
5153
52- function createCounterClone (uint256 salt ) public returns (address ) {
54+ function createCounterClone (uint256 salt ) public async (2_000_000 ) returns (address ) {
55+ //console.log("createCounterClone 1");
5356 bytes memory cloneBytecode = createCloneBytecode (masterChildAddress);
57+ //console.log("createCounterClone 2: %_", cloneBytecode.length);
5458 uint shardId = Nil.getShardId (masterChildAddress);
59+ //console.log("createCounterClone 3: %_", shardId);
5560 uint shardIdFactory = Nil.getShardId (address (this ));
5661 require (
5762 shardId == shardIdFactory,
5863 "factory and child are not on the same shard! "
5964 );
65+ //console.log("createCounterClone 4");
6066 address result = Nil.asyncDeploy (
6167 shardId,
6268 address (this ),
@@ -67,17 +73,26 @@ contract CloneFactory {
6773 cloneBytecode,
6874 salt
6975 );
76+ emit counterCloneCreated (result);
77+ //console.log("createCounterClone 5");
7078
7179 return result;
7280 }
7381}
7482
75- contract FactoryManager {
83+ contract FactoryManager is NilBase {
7684 mapping (uint => address ) public factories;
7785 mapping (uint => address ) public masterChildren;
7886 bytes private code = type (CloneFactory).creationCode;
7987
80- function deployNewMasterChild (uint shardId , uint256 salt ) public {
88+ event factoryDeployed (address indexed addr );
89+ event masterChildDeployed (address indexed addr );
90+
91+ constructor () payable {}
92+
93+ function deployNewMasterChild (uint shardId , uint256 salt ) public async (2_000_000 ) {
94+ //console.log("deployNewMasterChild 1");
95+
8196 address result = Nil.asyncDeploy (
8297 shardId,
8398 address (this ),
@@ -88,11 +103,12 @@ contract FactoryManager {
88103 type (MasterChild).creationCode,
89104 salt
90105 );
106+ emit masterChildDeployed (result);
91107
92108 masterChildren[shardId] = result;
93109 }
94110
95- function deployNewFactory (uint shardId , uint256 salt ) public {
111+ function deployNewFactory (uint shardId , uint256 salt ) public async ( 2_000_000 ) {
96112 require (factories[shardId] == address (0 ), "factory already exists! " );
97113 bytes memory data = bytes .concat (
98114 type (CloneFactory).creationCode,
@@ -104,10 +120,11 @@ contract FactoryManager {
104120 address (this ),
105121 0 ,
106122 Nil.FORWARD_REMAINING,
107- 0 ,
123+ 5000000 * tx . gasprice ,
108124 data,
109125 salt
110126 );
127+ emit factoryDeployed (result);
111128
112129 factories[shardId] = result;
113130 }
0 commit comments