Skip to content

Commit

Permalink
Merge branch 'v3' into kunal/aggregation-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aroralanuk authored Aug 29, 2023
2 parents 2fe2df8 + a776131 commit 6a721cc
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 132 deletions.
10 changes: 10 additions & 0 deletions solidity/contracts/Indexed.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

contract Indexed {
uint256 public immutable deployedBlock;

constructor() {
deployedBlock = block.number;
}
}
3 changes: 2 additions & 1 deletion solidity/contracts/Mailbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity >=0.8.0;

// ============ Internal Imports ============
import {Versioned} from "./upgrade/Versioned.sol";
import {Indexed} from "./Indexed.sol";
import {Message} from "./libs/Message.sol";
import {TypeCasts} from "./libs/TypeCasts.sol";
import {IInterchainSecurityModule, ISpecifiesInterchainSecurityModule} from "./interfaces/IInterchainSecurityModule.sol";
Expand All @@ -14,7 +15,7 @@ import {IMailbox} from "./interfaces/IMailbox.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract Mailbox is IMailbox, Versioned, Ownable {
contract Mailbox is IMailbox, Indexed, Versioned, Ownable {
// ============ Libraries ============

using Message for bytes;
Expand Down
69 changes: 0 additions & 69 deletions solidity/contracts/PausableReentrancyGuard.sol

This file was deleted.

3 changes: 2 additions & 1 deletion solidity/contracts/hooks/MerkleTreeHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pragma solidity >=0.8.0;
import {MerkleLib, TREE_DEPTH} from "../libs/Merkle.sol";
import {Message} from "../libs/Message.sol";
import {MailboxClient} from "../client/MailboxClient.sol";
import {Indexed} from "../Indexed.sol";
import {IPostDispatchHook} from "../interfaces/hooks/IPostDispatchHook.sol";

contract MerkleTreeHook is IPostDispatchHook, MailboxClient {
contract MerkleTreeHook is IPostDispatchHook, MailboxClient, Indexed {
using Message for bytes;
using MerkleLib for MerkleLib.Tree;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/igps/InterchainGasPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {IGPMetadata} from "../libs/hooks/IGPMetadata.sol";
import {IGasOracle} from "../interfaces/IGasOracle.sol";
import {IInterchainGasPaymaster} from "../interfaces/IInterchainGasPaymaster.sol";
import {IPostDispatchHook} from "../interfaces/hooks/IPostDispatchHook.sol";
import {Indexed} from "../Indexed.sol";

// ============ External Imports ============
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
Expand All @@ -32,6 +34,7 @@ contract InterchainGasPaymaster is
IInterchainGasPaymaster,
IPostDispatchHook,
IGasOracle,
Indexed,
OwnableUpgradeable
{
using Address for address payable;
Expand Down
60 changes: 0 additions & 60 deletions solidity/test/PausableReentrancyGuard.t.sol

This file was deleted.

7 changes: 7 additions & 0 deletions solidity/test/igps/InterchainGasPaymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ contract InterchainGasPaymasterTest is Test {
address constant testRefundAddress = address(0xc0ffee);
bytes testEncodedMessage;

uint256 blockNumber;

event GasPayment(
bytes32 indexed messageId,
uint256 gasAmount,
Expand All @@ -41,6 +43,7 @@ contract InterchainGasPaymasterTest is Test {
event BeneficiarySet(address beneficiary);

function setUp() public {
blockNumber = block.number;
igp = new InterchainGasPaymaster();
igp.initialize(address(this), beneficiary);
oracle = new StorageGasOracle();
Expand All @@ -55,6 +58,10 @@ contract InterchainGasPaymasterTest is Test {
assertEq(igp.beneficiary(), beneficiary);
}

function testConstructorSetsDeployedBlock() public {
assertEq(igp.deployedBlock(), blockNumber);
}

// ============ initialize ============

function testInitializeRevertsIfCalledTwice() public {
Expand Down
15 changes: 14 additions & 1 deletion solidity/test/mailbox.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { expect } from 'chai';
import { BigNumber } from 'ethers';
import { ethers } from 'hardhat';

import { utils } from '@hyperlane-xyz/utils';
Expand Down Expand Up @@ -31,20 +32,32 @@ describe('Mailbox', async () => {
defaultHook: TestMerkleTreeHook,
module: TestMultisigIsm,
signer: SignerWithAddress,
nonOwner: SignerWithAddress;
nonOwner: SignerWithAddress,
beforeBlock: number;

beforeEach(async () => {
[signer, nonOwner] = await ethers.getSigners();
const moduleFactory = new TestMultisigIsm__factory(signer);
module = await moduleFactory.deploy();
const mailboxFactory = new TestMailbox__factory(signer);
mailbox = await mailboxFactory.deploy(originDomain, signer.address);
beforeBlock = mailbox.deployTransaction.blockNumber!;
const defaultHookFactory = new TestMerkleTreeHook__factory(signer);
defaultHook = await defaultHookFactory.deploy(mailbox.address);
await mailbox.setDefaultIsm(module.address);
await mailbox.setDefaultHook(defaultHook.address);
});

it('#deployedBlock', async () => {
const block = await mailbox.deployedBlock();
expect(block).to.equal(beforeBlock);
});

it('#VERSION', async () => {
const version = await mailbox.VERSION();
expect(version).to.equal(3);
});

describe('#initialize', () => {
it('Sets the owner', async () => {
const mailboxFactory = new TestMailbox__factory(signer);
Expand Down

0 comments on commit 6a721cc

Please sign in to comment.