-
Notifications
You must be signed in to change notification settings - Fork 419
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
76 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
/*@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@@@@@@@@@@@@@@@@@ | ||
@@@@@ HYPERLANE @@@@@@@ | ||
@@@@@@@@@@@@@@@@@@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@@ | ||
@@@@@@@@@ @@@@@@@@*/ | ||
|
||
import {Message} from "../libs/Message.sol"; | ||
import {MailboxClient} from "../client/MailboxClient.sol"; | ||
import {Indexed} from "../libs/Indexed.sol"; | ||
import {IPostDispatchHook} from "../interfaces/hooks/IPostDispatchHook.sol"; | ||
import {AbstractPostDispatchHook} from "./libs/AbstractPostDispatchHook.sol"; | ||
import {StandardHookMetadata} from "./libs/StandardHookMetadata.sol"; | ||
|
||
contract LayerZeroHook is AbstractPostDispatchHook, MailboxClient, Indexed { | ||
constructor(address _mailbox) MailboxClient(_mailbox) {} | ||
|
||
// ============ External Functions ============ | ||
|
||
/// @inheritdoc IPostDispatchHook | ||
function hookType() external pure override returns (uint8) { | ||
return uint8(IPostDispatchHook.Types.LAYER_ZERO); | ||
} | ||
|
||
/// @inheritdoc AbstractPostDispatchHook | ||
function _postDispatch( | ||
bytes calldata metadata, | ||
bytes calldata message | ||
) internal virtual override {} | ||
|
||
/// @inheritdoc AbstractPostDispatchHook | ||
function _quoteDispatch( | ||
bytes calldata metadata, | ||
bytes calldata message | ||
) internal view virtual override returns (uint256) {} | ||
} |
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,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.13; | ||
|
||
import {LZEndpointMock} from "@layerzerolabs/solidity-examples/contracts/lzApp/mocks/LZEndpointMock.sol"; | ||
import {Test} from "forge-std/Test.sol"; | ||
import {TestMailbox} from "../../contracts/test/TestMailbox.sol"; | ||
import {LayerZeroHook} from "../../contracts/hooks/LayerZeroHook.sol"; | ||
import {IPostDispatchHook} from "../../contracts/interfaces/hooks/IPostDispatchHook.sol"; | ||
|
||
contract LayerZeroHookTest is Test { | ||
LZEndpointMock lZEndpointMock; | ||
TestMailbox public mailbox; | ||
LayerZeroHook hook; | ||
|
||
function setUp() public { | ||
lZEndpointMock = new LZEndpointMock(uint16(block.chainid)); | ||
mailbox = new TestMailbox(0); | ||
hook = new LayerZeroHook(address(mailbox)); | ||
} | ||
|
||
// function testPostDispatch_emit() public {} | ||
|
||
function testQuoteDispatch() public { | ||
assertEq(hook.quoteDispatch("", ""), 0); | ||
} | ||
|
||
function testHookType() public { | ||
assertEq(hook.hookType(), uint8(IPostDispatchHook.Types.LAYER_ZERO)); | ||
} | ||
} |