-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
contract Counter { | ||
uint256 public number; | ||
import "socket-poc/contracts/utils/Ownable.sol"; | ||
|
||
function setNumber(uint256 newNumber) public { | ||
number = newNumber; | ||
contract Counter is Ownable(msg.sender) { | ||
address public socket; | ||
uint256 public counter; | ||
|
||
modifier onlySocket() { | ||
require(msg.sender == socket, "not socket"); | ||
_; | ||
} | ||
|
||
function setSocket(address _socket) external onlyOwner { | ||
socket = _socket; | ||
} | ||
|
||
function getSocket() external view returns (address) { | ||
return socket; | ||
} | ||
|
||
function increment() public { | ||
number++; | ||
function increase() external onlySocket { | ||
counter++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
import "socket-poc/contracts/base/AppGatewayBase.sol"; | ||
import "./Counter.sol"; | ||
|
||
contract CounterComposer is AppGatewayBase { | ||
constructor( | ||
address _addressResolver, | ||
address deployerContract_, | ||
FeesData memory feesData_ | ||
) AppGatewayBase(_addressResolver, feesData_) Ownable(msg.sender) { | ||
addressResolver.setContractsToGateways(deployerContract_); | ||
} | ||
|
||
function incrementCounter(address _instance) public queueAndExecute { | ||
Counter(_instance).increase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
import "./Counter.sol"; | ||
import "socket-poc/contracts/base/AppDeployerBase.sol"; | ||
|
||
contract CounterDeployer is AppDeployerBase { | ||
address public counter; | ||
|
||
constructor( | ||
address addressResolver_, | ||
FeesData memory feesData_ | ||
) AppDeployerBase(addressResolver_, feesData_) Ownable(msg.sender) { | ||
counter = address(new Counter()); | ||
creationCodeWithArgs[counter] = type(Counter).creationCode; | ||
} | ||
|
||
function deployContracts( | ||
uint32 chainSlug | ||
) external queueAndDeploy(chainSlug) { | ||
_deploy(counter); | ||
} | ||
|
||
function initialize(uint32 chainSlug) public override queueAndExecute { | ||
address socket = getSocketAddress(chainSlug); | ||
address counterForwarder = forwarderAddresses[counter][chainSlug]; | ||
Counter(counterForwarder).setSocket(socket); | ||
} | ||
} |