-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ration/pi_network/pi-network-layer2-scaling/contracts/state-channels/ChannelValidator.sol
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: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "./StateChannel.sol"; | ||
|
||
contract ChannelValidator { | ||
event ChannelValidated(address indexed channel, address indexed participant); | ||
|
||
function validateChannel(StateChannel _channel) external { | ||
require(!_channel.isOpen(), "Channel is still open"); | ||
emit ChannelValidated(address(_channel), msg.sender); | ||
} | ||
|
||
function validateFinalBalances(StateChannel _channel, uint256 _finalBalanceA, uint256 _finalBalanceB) external { | ||
require(!_channel.isOpen(), "Channel is still open"); | ||
require(_finalBalanceA + _finalBalanceB == address(_channel).balance, "Invalid final balances"); | ||
emit ChannelValidated(address(_channel), msg.sender); | ||
} | ||
} |