-
Notifications
You must be signed in to change notification settings - Fork 26
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
7 changed files
with
163 additions
and
51 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
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,31 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {IbcDispatcher, IbcEventsEmitter} from "./IbcDispatcher.sol"; | ||
|
||
import {L1Header, OpL2StateProof, Ics23Proof} from "./ProofVerifier.sol"; | ||
import {IbcUniversalChannelMW} from "./IbcMiddleware.sol"; | ||
import { | ||
Channel, | ||
ChannelEnd, | ||
ChannelOrder, | ||
IbcPacket, | ||
ChannelState, | ||
AckPacket, | ||
IBCErrors, | ||
IbcUtils, | ||
Ibc | ||
} from "../libs/Ibc.sol"; | ||
|
||
interface IUniversalChannelHandler is IbcUniversalChannelMW { | ||
function registerMwStack(uint256 mwBitmap, address[] calldata mwAddrs) external; | ||
function openChannel( | ||
string calldata version, | ||
ChannelOrder ordering, | ||
bool feeEnabled, | ||
string[] calldata connectionHops, | ||
string calldata counterpartyPortIdentifier | ||
) external; | ||
function closeChannel(bytes32 channelId) external; | ||
function connectedChannels(uint256) external view returns (bytes32); | ||
} |
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,45 @@ | ||
//SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity ^0.8.9; | ||
|
||
import {OwnableUpgradeable} from "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol"; | ||
import {IbcDispatcher} from "./IbcDispatcher.sol"; | ||
import {ChannelOrder, ChannelEnd, IbcPacket, AckPacket} from "../libs/Ibc.sol"; | ||
|
||
contract IbcReceiverBaseUpgradeable is OwnableUpgradeable { | ||
IbcDispatcher public dispatcher; | ||
|
||
error notIbcDispatcher(); | ||
error UnsupportedVersion(); | ||
error ChannelNotFound(); | ||
|
||
/** | ||
* @dev Modifier to restrict access to only the IBC dispatcher. | ||
* Only the address with the IBC_ROLE can execute the function. | ||
* Should add this modifier to all IBC-related callback functions. | ||
*/ | ||
modifier onlyIbcDispatcher() { | ||
if (msg.sender != address(dispatcher)) { | ||
revert notIbcDispatcher(); | ||
} | ||
_; | ||
} | ||
|
||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
/** | ||
* @dev initializer function that takes an IbcDispatcher address and grants the IBC_ROLE to the Polymer IBC | ||
* Dispatcher. | ||
* @param _dispatcher The address of the IbcDispatcher contract. | ||
*/ | ||
function __IbcReceiverBase_init(IbcDispatcher _dispatcher) internal onlyInitializing { | ||
__Ownable_init(); | ||
dispatcher = _dispatcher; | ||
} | ||
|
||
/// This function is called for plain Ether transfers, i.e. for every call with empty calldata. | ||
// An empty function body is sufficient to receive packet fee refunds. | ||
receive() external payable {} | ||
} |
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
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
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
Oops, something went wrong.