Skip to content

Commit 56981f6

Browse files
committed
refactor: improve import formatting and function definitions for clarity
1 parent 933d637 commit 56981f6

File tree

5 files changed

+66
-39
lines changed

5 files changed

+66
-39
lines changed

script/DeployAll.s.sol

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,25 @@ import {Config} from "forge-std/src/Config.sol";
77

88
// === Core ===
99
import {IBCClient} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/02-client/IBCClient.sol";
10-
import {IBCConnectionSelfStateNoValidation as IBCConnection} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/03-connection/IBCConnectionSelfStateNoValidation.sol";
11-
import {IBCChannelHandshake} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelHandshake.sol";
12-
import {IBCChannelPacketSendRecv} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelPacketSendRecv.sol";
13-
import {IBCChannelPacketTimeout} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelPacketTimeout.sol";
10+
import {
11+
IBCConnectionSelfStateNoValidation as IBCConnection
12+
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/03-connection/IBCConnectionSelfStateNoValidation.sol";
13+
import {
14+
IBCChannelHandshake
15+
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelHandshake.sol";
16+
import {
17+
IBCChannelPacketSendRecv
18+
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelPacketSendRecv.sol";
19+
import {
20+
IBCChannelPacketTimeout
21+
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelPacketTimeout.sol";
1422
import {
1523
IBCChannelUpgradeInitTryAck,
1624
IBCChannelUpgradeConfirmOpenTimeoutCancel
1725
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelUpgrade.sol";
18-
import {OwnableIBCHandler as IBCHandler} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/25-handler/OwnableIBCHandler.sol";
26+
import {
27+
OwnableIBCHandler as IBCHandler
28+
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/25-handler/OwnableIBCHandler.sol";
1929

2030
// === App ===
2131
import {IContractModule} from "src/core/IContractModule.sol";

src/core/CrossModule.sol

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ pragma solidity ^0.8.20;
33

44
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
55
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6-
import {IIBCModule, IIBCModuleInitializer} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/26-router/IIBCModule.sol";
6+
import {
7+
IIBCModule,
8+
IIBCModuleInitializer
9+
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/26-router/IIBCModule.sol";
710
import {IIBCHandler} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/25-handler/IIBCHandler.sol";
811
import {Packet} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IIBCChannel.sol";
912

@@ -17,21 +20,15 @@ abstract contract CrossModule is AccessControl, IIBCModule, IBCKeeper, PacketHan
1720
_grantRole(IBC_ROLE, address(ibcHandler_));
1821
}
1922

20-
// ---- ERC165 ----
21-
function supportsInterface(bytes4 interfaceId)
22-
public
23-
view
24-
virtual
25-
override(AccessControl, IERC165)
26-
returns (bool)
27-
{
28-
return
29-
interfaceId == type(IIBCModule).interfaceId ||
30-
interfaceId == type(IIBCModuleInitializer).interfaceId ||
31-
super.supportsInterface(interfaceId);
23+
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, IERC165) returns (bool) {
24+
return interfaceId == type(IIBCModule).interfaceId || interfaceId == type(IIBCModuleInitializer).interfaceId
25+
|| super.supportsInterface(interfaceId);
3226
}
3327

34-
// ---- Packet callbacks (ICS-04) ----
28+
// function initiateTx() external {}
29+
30+
/// Module callbacks ///
31+
3532
function onRecvPacket(Packet calldata packet, address relayer)
3633
public
3734
virtual
@@ -51,16 +48,11 @@ abstract contract CrossModule is AccessControl, IIBCModule, IBCKeeper, PacketHan
5148
handleAcknowledgement(packet, acknowledgement);
5249
}
5350

54-
function onTimeoutPacket(Packet calldata packet, address relayer)
55-
public
56-
virtual
57-
override
58-
{
51+
function onTimeoutPacket(Packet calldata packet, address relayer) public virtual override {
5952
require(hasRole(IBC_ROLE, _msgSender()), "caller must have the IBC role");
6053
handleTimeout(packet);
6154
}
6255

63-
// ---- Channel handshake (ICS-26) ----
6456
function onChanOpenInit(IIBCModuleInitializer.MsgOnChanOpenInit calldata msg_)
6557
external
6658
virtual

src/core/CrossSimpleModule.sol

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,30 @@ contract CrossSimpleModule is CrossModule, SimpleContractRegistry, TxAtomicSimpl
3232
return (address(this), msg_.counterpartyVersion);
3333
}
3434

35-
function onChanOpenAck(IIBCModule.MsgOnChanOpenAck calldata /*msg_*/) external override {}
36-
function onChanOpenConfirm(IIBCModule.MsgOnChanOpenConfirm calldata /*msg_*/) external override {}
37-
function onChanCloseInit(IIBCModule.MsgOnChanCloseInit calldata /*msg_*/) external override {}
38-
function onChanCloseConfirm(IIBCModule.MsgOnChanCloseConfirm calldata /*msg_*/) external override {}
35+
function onChanOpenAck(
36+
IIBCModule.MsgOnChanOpenAck calldata /*msg_*/
37+
)
38+
external
39+
override
40+
{}
41+
function onChanOpenConfirm(
42+
IIBCModule.MsgOnChanOpenConfirm calldata /*msg_*/
43+
)
44+
external
45+
override
46+
{}
47+
function onChanCloseInit(
48+
IIBCModule.MsgOnChanCloseInit calldata /*msg_*/
49+
)
50+
external
51+
override
52+
{}
53+
function onChanCloseConfirm(
54+
IIBCModule.MsgOnChanCloseConfirm calldata /*msg_*/
55+
)
56+
external
57+
override
58+
{}
3959

4060
// ---- debug for serialization ----
4161
function getPacketAcknowledgementCall(PacketAcknowledgementCall.CommitStatus status)

src/core/SimpleContractRegistry.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ abstract contract SimpleContractRegistry is ContractRegistry {
1515
contractModule = module;
1616
}
1717

18-
function getModule(Packet memory /*packet*/) internal virtual override returns (IContractModule) {
18+
function getModule(
19+
Packet memory /*packet*/
20+
)
21+
internal
22+
virtual
23+
override
24+
returns (IContractModule)
25+
{
1926
require(address(contractModule) != address(0), "contractModule is not initialized yet");
2027
return contractModule;
2128
}

src/core/TxAtomicSimple.sol

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ abstract contract TxAtomicSimple is IBCKeeper, PacketHandler, ContractRegistry {
2323
event OnTimeoutPacket(bytes tx_id, uint8 tx_index, uint64 sequence);
2424

2525
/// @inheritdoc PacketHandler
26-
function handlePacket(Packet memory packet)
27-
internal
28-
virtual
29-
override
30-
returns (bytes memory acknowledgement)
31-
{
26+
function handlePacket(Packet memory packet) internal virtual override returns (bytes memory acknowledgement) {
3227
// ルーティング先モジュール解決(1回だけ)
3328
IContractModule module = getModule(packet);
3429

@@ -49,8 +44,7 @@ abstract contract TxAtomicSimple is IBCKeeper, PacketHandler, ContractRegistry {
4944
// コール実行 & ACK 生成
5045
PacketAcknowledgementCall.Data memory ack;
5146
try module.onContractCall(
52-
CrossContext(pdc.tx_id, txIndexParticipant, pdc.tx.signers),
53-
pdc.tx.call_info
47+
CrossContext(pdc.tx_id, txIndexParticipant, pdc.tx.signers), pdc.tx.call_info
5448
) returns (bytes memory ret) {
5549
ack.status = PacketAcknowledgementCall.CommitStatus.COMMIT_STATUS_OK;
5650
emit OnContractCall(pdc.tx_id, txIndexParticipant, true, ret);
@@ -63,7 +57,11 @@ abstract contract TxAtomicSimple is IBCKeeper, PacketHandler, ContractRegistry {
6357
}
6458

6559
/// @inheritdoc PacketHandler
66-
function handleAcknowledgement(Packet memory /*packet*/, bytes memory /*acknowledgement*/)
60+
function handleAcknowledgement(
61+
Packet memory,
62+
/*packet*/
63+
bytes memory /*acknowledgement*/
64+
)
6765
internal
6866
virtual
6967
override

0 commit comments

Comments
 (0)