From becc1675d35a4e6fdaa1df793c24d64f40c13049 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Wed, 15 May 2024 15:01:35 +0900 Subject: [PATCH] mkdir clients/{09-localhost,ibft2,mock} and move implementations into the directories respectively Signed-off-by: Jun Kimura --- .../{ => 09-localhost}/LocalhostClient.sol | 16 ++++++------- .../09-localhost}/LocalhostHelper.sol | 24 +++++++++---------- contracts/clients/{ => ibft2}/IBFT2Client.sol | 14 +++++------ contracts/clients/{ => mock}/MockClient.sol | 14 +++++------ tests/foundry/src/Deploy.s.sol | 4 ++-- tests/foundry/src/IBC.t.sol | 2 +- tests/foundry/src/IBCMockApp.t.sol | 4 ++-- tests/foundry/src/ICS02.t.sol | 2 +- tests/foundry/src/ICS04Upgrade.t.sol | 4 ++-- tests/foundry/src/ICS04UpgradeApp.t.sol | 4 ++-- tests/foundry/src/helpers/IBCTestHelper.t.sol | 2 +- .../src/helpers/MockClientTestHelper.t.sol | 2 +- 12 files changed, 46 insertions(+), 46 deletions(-) rename contracts/clients/{ => 09-localhost}/LocalhostClient.sol (95%) rename contracts/{helpers => clients/09-localhost}/LocalhostHelper.sol (92%) rename contracts/clients/{ => ibft2}/IBFT2Client.sol (97%) rename contracts/clients/{ => mock}/MockClient.sol (96%) diff --git a/contracts/clients/LocalhostClient.sol b/contracts/clients/09-localhost/LocalhostClient.sol similarity index 95% rename from contracts/clients/LocalhostClient.sol rename to contracts/clients/09-localhost/LocalhostClient.sol index 035c907d..5c99fe80 100644 --- a/contracts/clients/LocalhostClient.sol +++ b/contracts/clients/09-localhost/LocalhostClient.sol @@ -1,18 +1,18 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; -import {ILightClient} from "../core/02-client/ILightClient.sol"; -import {ILightClientErrors} from "../core/02-client/ILightClientErrors.sol"; -import {IBCHeight} from "../core/02-client/IBCHeight.sol"; -import {IIBCHandler} from "../core/25-handler/IIBCHandler.sol"; -import {Height} from "../proto/Client.sol"; -import {IbcLightclientsLocalhostV2ClientState as ClientState} from "../proto/Localhost.sol"; -import {GoogleProtobufAny as Any} from "../proto/GoogleProtobufAny.sol"; +import {ILightClient} from "../../core/02-client/ILightClient.sol"; +import {ILightClientErrors} from "../../core/02-client/ILightClientErrors.sol"; +import {IBCHeight} from "../../core/02-client/IBCHeight.sol"; +import {IIBCHandler} from "../../core/25-handler/IIBCHandler.sol"; +import {Height} from "../../proto/Client.sol"; +import {IbcLightclientsLocalhostV2ClientState as ClientState} from "../../proto/Localhost.sol"; +import {GoogleProtobufAny as Any} from "../../proto/GoogleProtobufAny.sol"; /** * @title LocalhostClient * @notice LocalhostClient is a light client to facilitate testing of IBC Apps on a single chain - * @dev LocalhostClient implements [09-localhost](https://github.com/cosmos/ibc/tree/main/spec/client/ics-009-loopback-cilent), but the following differences: + * @dev LocalhostClient implements [09-localhost](https://github.com/cosmos/ibc/tree/main/spec/client/ics-009-loopback-cilent), but there are some differences: * - The client identifier is `09-localhost-0`, not `09-localhost` * - `getLatestHeight` always returns the current block number * - `verifyMembership` checks the proof height is not greater than the current block height diff --git a/contracts/helpers/LocalhostHelper.sol b/contracts/clients/09-localhost/LocalhostHelper.sol similarity index 92% rename from contracts/helpers/LocalhostHelper.sol rename to contracts/clients/09-localhost/LocalhostHelper.sol index d2a9ea68..b406ea9f 100644 --- a/contracts/helpers/LocalhostHelper.sol +++ b/contracts/clients/09-localhost/LocalhostHelper.sol @@ -1,18 +1,18 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; -import {IIBCHandler} from "../core/25-handler/IIBCHandler.sol"; -import {LocalhostClient, LocalhostClientLib} from "../clients/LocalhostClient.sol"; -import {Version, Counterparty, MerklePrefix} from "../proto/Connection.sol"; -import {IBCConnectionLib} from "../core/03-connection/IBCConnectionLib.sol"; -import {IIBCClient} from "../core/02-client/IIBCClient.sol"; -import {IIBCClientErrors} from "../core/02-client/IIBCClientErrors.sol"; -import {IIBCConnection} from "../core/03-connection/IIBCConnection.sol"; -import {Height} from "../proto/Client.sol"; -import {Channel, ChannelCounterparty} from "../proto/Channel.sol"; -import {IbcLightclientsLocalhostV2ClientState as ClientState} from "../proto/Localhost.sol"; -import {GoogleProtobufAny as Any} from "../proto/GoogleProtobufAny.sol"; -import {IIBCChannelHandshake} from "../core/04-channel/IIBCChannel.sol"; +import {IIBCHandler} from "../../core/25-handler/IIBCHandler.sol"; +import {LocalhostClient, LocalhostClientLib} from "./LocalhostClient.sol"; +import {Version, Counterparty, MerklePrefix} from "../../proto/Connection.sol"; +import {IBCConnectionLib} from "../../core/03-connection/IBCConnectionLib.sol"; +import {IIBCClient} from "../../core/02-client/IIBCClient.sol"; +import {IIBCClientErrors} from "../../core/02-client/IIBCClientErrors.sol"; +import {IIBCConnection} from "../../core/03-connection/IIBCConnection.sol"; +import {Height} from "../../proto/Client.sol"; +import {Channel, ChannelCounterparty} from "../../proto/Channel.sol"; +import {IbcLightclientsLocalhostV2ClientState as ClientState} from "../../proto/Localhost.sol"; +import {GoogleProtobufAny as Any} from "../../proto/GoogleProtobufAny.sol"; +import {IIBCChannelHandshake} from "../../core/04-channel/IIBCChannel.sol"; /** * @title LocalhostHelper diff --git a/contracts/clients/IBFT2Client.sol b/contracts/clients/ibft2/IBFT2Client.sol similarity index 97% rename from contracts/clients/IBFT2Client.sol rename to contracts/clients/ibft2/IBFT2Client.sol index 3f5e5858..5c16f17b 100644 --- a/contracts/clients/IBFT2Client.sol +++ b/contracts/clients/ibft2/IBFT2Client.sol @@ -1,17 +1,17 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.20; -import {ILightClient} from "../core/02-client/ILightClient.sol"; -import {ILightClientErrors} from "../core/02-client/ILightClientErrors.sol"; -import {IBCHeight} from "../core/02-client/IBCHeight.sol"; -import {IIBCHandler} from "../core/25-handler/IIBCHandler.sol"; -import {Height} from "../proto/Client.sol"; +import {ILightClient} from "../../core/02-client/ILightClient.sol"; +import {ILightClientErrors} from "../../core/02-client/ILightClientErrors.sol"; +import {IBCHeight} from "../../core/02-client/IBCHeight.sol"; +import {IIBCHandler} from "../../core/25-handler/IIBCHandler.sol"; +import {Height} from "../../proto/Client.sol"; import { IbcLightclientsIbft2V1ClientState as ClientState, IbcLightclientsIbft2V1ConsensusState as ConsensusState, IbcLightclientsIbft2V1Header as Header -} from "../proto/IBFT2.sol"; -import {GoogleProtobufAny as Any} from "../proto/GoogleProtobufAny.sol"; +} from "../../proto/IBFT2.sol"; +import {GoogleProtobufAny as Any} from "../../proto/GoogleProtobufAny.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {RLPReader} from "solidity-rlp/contracts/RLPReader.sol"; import {MPTProof} from "solidity-mpt/src/MPTProof.sol"; diff --git a/contracts/clients/MockClient.sol b/contracts/clients/mock/MockClient.sol similarity index 96% rename from contracts/clients/MockClient.sol rename to contracts/clients/mock/MockClient.sol index ab19f2b8..3be92273 100644 --- a/contracts/clients/MockClient.sol +++ b/contracts/clients/mock/MockClient.sol @@ -2,17 +2,17 @@ pragma solidity ^0.8.20; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -import {ILightClient} from "../core/02-client/ILightClient.sol"; -import {ILightClientErrors} from "../core/02-client/ILightClientErrors.sol"; -import {IBCHeight} from "../core/02-client/IBCHeight.sol"; -import {IIBCHandler} from "../core/25-handler/IIBCHandler.sol"; -import {Height} from "../proto/Client.sol"; +import {ILightClient} from "../../core/02-client/ILightClient.sol"; +import {ILightClientErrors} from "../../core/02-client/ILightClientErrors.sol"; +import {IBCHeight} from "../../core/02-client/IBCHeight.sol"; +import {IIBCHandler} from "../../core/25-handler/IIBCHandler.sol"; +import {Height} from "../../proto/Client.sol"; import { IbcLightclientsMockV1ClientState as ClientState, IbcLightclientsMockV1ConsensusState as ConsensusState, IbcLightclientsMockV1Header as Header -} from "../proto/MockClient.sol"; -import {GoogleProtobufAny as Any} from "../proto/GoogleProtobufAny.sol"; +} from "../../proto/MockClient.sol"; +import {GoogleProtobufAny as Any} from "../../proto/GoogleProtobufAny.sol"; /// @notice MockClient implements https://github.com/datachainlab/ibc-mock-client /// WARNING: This client is intended to be used for testing purpose. diff --git a/tests/foundry/src/Deploy.s.sol b/tests/foundry/src/Deploy.s.sol index b7cf697e..6276639a 100644 --- a/tests/foundry/src/Deploy.s.sol +++ b/tests/foundry/src/Deploy.s.sol @@ -14,8 +14,8 @@ import { } from "../../../contracts/core/04-channel/IBCChannelUpgrade.sol"; import {IIBCHandler} from "../../../contracts/core/25-handler/IIBCHandler.sol"; import {OwnableIBCHandler} from "../../../contracts/core/25-handler/OwnableIBCHandler.sol"; -import {MockClient} from "../../../contracts/clients/MockClient.sol"; -import {IBFT2Client} from "../../../contracts/clients/IBFT2Client.sol"; +import {MockClient} from "../../../contracts/clients/mock/MockClient.sol"; +import {IBFT2Client} from "../../../contracts/clients/ibft2/IBFT2Client.sol"; import {ICS20Bank} from "../../../contracts/apps/20-transfer/ICS20Bank.sol"; import {ICS20TransferBank} from "../../../contracts/apps/20-transfer/ICS20TransferBank.sol"; import {ERC20Token} from "../../../contracts/apps/20-transfer/ERC20Token.sol"; diff --git a/tests/foundry/src/IBC.t.sol b/tests/foundry/src/IBC.t.sol index 2e515891..645c8fb2 100644 --- a/tests/foundry/src/IBC.t.sol +++ b/tests/foundry/src/IBC.t.sol @@ -10,7 +10,7 @@ import "../../../contracts/core/04-channel/IBCChannelPacketSendRecv.sol"; import "../../../contracts/core/04-channel/IBCChannelPacketTimeout.sol"; import "../../../contracts/core/04-channel/IBCChannelUpgrade.sol"; import "../../../contracts/core/24-host/IBCCommitment.sol"; -import "../../../contracts/clients/MockClient.sol"; +import "../../../contracts/clients/mock/MockClient.sol"; import "../../../contracts/proto/MockClient.sol"; import "../../../contracts/proto/Connection.sol"; import "../../../contracts/proto/Channel.sol"; diff --git a/tests/foundry/src/IBCMockApp.t.sol b/tests/foundry/src/IBCMockApp.t.sol index 8564a72c..2bb10238 100644 --- a/tests/foundry/src/IBCMockApp.t.sol +++ b/tests/foundry/src/IBCMockApp.t.sol @@ -6,8 +6,8 @@ import {Vm} from "forge-std/Test.sol"; import {IBCMockApp} from "../../../contracts/apps/mock/IBCMockApp.sol"; import {IBCMockLib} from "../../../contracts/apps/mock/IBCMockLib.sol"; import {IIBCChannelRecvPacket, IIBCChannelAcknowledgePacket} from "../../../contracts/core/04-channel/IIBCChannel.sol"; -import {LocalhostClientLib} from "../../../contracts/clients/LocalhostClient.sol"; -import {LocalhostHelper} from "../../../contracts/helpers/LocalhostHelper.sol"; +import {LocalhostClientLib} from "../../../contracts/clients/09-localhost/LocalhostClient.sol"; +import {LocalhostHelper} from "../../../contracts/clients/09-localhost/LocalhostHelper.sol"; import {ICS04PacketEventTestHelper} from "./helpers/ICS04PacketTestHelper.t.sol"; contract IBCMockAppTest is IBCTestHelper, ICS04PacketEventTestHelper { diff --git a/tests/foundry/src/ICS02.t.sol b/tests/foundry/src/ICS02.t.sol index eb361f81..fbcf25bb 100644 --- a/tests/foundry/src/ICS02.t.sol +++ b/tests/foundry/src/ICS02.t.sol @@ -13,7 +13,7 @@ import "../../../contracts/proto/MockClient.sol"; import "../../../contracts/proto/Connection.sol"; import "../../../contracts/proto/Channel.sol"; import "../../../contracts/apps/mock/IBCMockApp.sol"; -import "../../../contracts/clients/MockClient.sol"; +import "../../../contracts/clients/mock/MockClient.sol"; import "./helpers/TestableIBCHandler.t.sol"; import "./helpers/IBCTestHelper.t.sol"; import "./helpers/MockClientTestHelper.t.sol"; diff --git a/tests/foundry/src/ICS04Upgrade.t.sol b/tests/foundry/src/ICS04Upgrade.t.sol index 330652ba..0b7a0aa1 100644 --- a/tests/foundry/src/ICS04Upgrade.t.sol +++ b/tests/foundry/src/ICS04Upgrade.t.sol @@ -5,8 +5,8 @@ import "./helpers/IBCTestHelper.t.sol"; import {Vm} from "forge-std/Test.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {Upgrade, UpgradeFields, Timeout} from "../../../contracts/proto/Channel.sol"; -import {LocalhostClientLib} from "../../../contracts/clients/LocalhostClient.sol"; -import {LocalhostHelper} from "../../../contracts/helpers/LocalhostHelper.sol"; +import {LocalhostClientLib} from "../../../contracts/clients/09-localhost/LocalhostClient.sol"; +import {LocalhostHelper} from "../../../contracts/clients/09-localhost/LocalhostHelper.sol"; import {IIBCChannelRecvPacket, IIBCChannelAcknowledgePacket} from "../../../contracts/core/04-channel/IIBCChannel.sol"; import {IIBCChannelUpgrade, IIBCChannelUpgradeBase} from "../../../contracts/core/04-channel/IIBCChannelUpgrade.sol"; import {TestIBCChannelUpgradableMockApp} from "./helpers/TestIBCChannelUpgradableMockApp.t.sol"; diff --git a/tests/foundry/src/ICS04UpgradeApp.t.sol b/tests/foundry/src/ICS04UpgradeApp.t.sol index ab9de48a..4f449556 100644 --- a/tests/foundry/src/ICS04UpgradeApp.t.sol +++ b/tests/foundry/src/ICS04UpgradeApp.t.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.20; import "./helpers/IBCTestHelper.t.sol"; import {Vm} from "forge-std/Test.sol"; import {Upgrade, UpgradeFields, Timeout} from "../../../contracts/proto/Channel.sol"; -import {LocalhostClientLib} from "../../../contracts/clients/LocalhostClient.sol"; -import {LocalhostHelper} from "../../../contracts/helpers/LocalhostHelper.sol"; +import {LocalhostClientLib} from "../../../contracts/clients/09-localhost/LocalhostClient.sol"; +import {LocalhostHelper} from "../../../contracts/clients/09-localhost/LocalhostHelper.sol"; import {IIBCChannelUpgrade} from "../../../contracts/core/04-channel/IIBCChannelUpgrade.sol"; import {TestIBCChannelUpgradableMockApp} from "./helpers/TestIBCChannelUpgradableMockApp.t.sol"; import { diff --git a/tests/foundry/src/helpers/IBCTestHelper.t.sol b/tests/foundry/src/helpers/IBCTestHelper.t.sol index 60cdd254..1cbb4c31 100644 --- a/tests/foundry/src/helpers/IBCTestHelper.t.sol +++ b/tests/foundry/src/helpers/IBCTestHelper.t.sol @@ -13,7 +13,7 @@ import "../../../../contracts/proto/MockClient.sol"; import "../../../../contracts/proto/Connection.sol"; import "../../../../contracts/proto/Channel.sol"; import "../../../../contracts/apps/mock/IBCMockApp.sol"; -import "../../../../contracts/clients/MockClient.sol"; +import "../../../../contracts/clients/mock/MockClient.sol"; import {TestableIBCHandler} from "./TestableIBCHandler.t.sol"; abstract contract IBCTestHelper is Test { diff --git a/tests/foundry/src/helpers/MockClientTestHelper.t.sol b/tests/foundry/src/helpers/MockClientTestHelper.t.sol index b93d220d..b808e96a 100644 --- a/tests/foundry/src/helpers/MockClientTestHelper.t.sol +++ b/tests/foundry/src/helpers/MockClientTestHelper.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.20; import {Height} from "../../../../contracts/proto/Client.sol"; import {IBCHeight} from "../../../../contracts/core/02-client/IBCHeight.sol"; -import {MockClient} from "../../../../contracts/clients/MockClient.sol"; +import {MockClient} from "../../../../contracts/clients/mock/MockClient.sol"; import "./IBCTestHelper.t.sol"; abstract contract MockClientTestHelper is IBCTestHelper {