Skip to content

Commit 9917134

Browse files
authored
Merge 0b3fe74 into e4d6d35
2 parents e4d6d35 + 0b3fe74 commit 9917134

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/core/IInitiator.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ interface IInitiator {
88
error MessageTimeoutHeight(uint256 blockNumber, uint64 timeoutVersionHeight);
99
error MessageTimeoutTimestamp(uint256 blockTimestamp, uint64 timeoutTimestamp);
1010
error TxIDAlreadyExists(bytes32 txIDHash);
11-
error SelfXCCNotImplemented();
1211

1312
event TxInitiated(bytes txID, address indexed proposer);
1413

src/core/Initiator.sol

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
99
import {MsgInitiateTx, MsgInitiateTxResponse, QuerySelfXCCResponse} from "../proto/cross/core/initiator/Initiator.sol";
1010
import {Account} from "../proto/cross/core/auth/Auth.sol";
1111

12+
import {GoogleProtobufAny} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
13+
import {ChannelInfo} from "../proto/cross/core/xcc/XCC.sol";
14+
1215
abstract contract Initiator is IInitiator, TxAuthManagerBase, TxManagerBase {
1316
bytes32 public immutable CHAIN_ID_HASH;
1417

@@ -62,7 +65,14 @@ abstract contract Initiator is IInitiator, TxAuthManagerBase, TxManagerBase {
6265
}
6366

6467
function selfXCC() external view virtual override returns (QuerySelfXCCResponse.Data memory) {
65-
revert IInitiator.SelfXCCNotImplemented();
68+
ChannelInfo.Data memory selfXCC = ChannelInfo.Data({port: "", channel: ""});
69+
70+
string memory typeURL = "/cross.core.xcc.ChannelInfo";
71+
bytes memory value = ChannelInfo.encode(selfXCC);
72+
73+
GoogleProtobufAny.Data memory anyXCC = GoogleProtobufAny.Data({type_url: typeURL, value: value});
74+
75+
return QuerySelfXCCResponse.Data({xcc: anyXCC});
6676
}
6777

6878
function _getRequiredAccounts(MsgInitiateTx.Data calldata msg_) internal pure returns (Account.Data[] memory out) {

test/Initiator.t.sol

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
1111
import {
1212
MsgInitiateTx,
1313
MsgInitiateTxResponse,
14-
ContractTransaction
14+
ContractTransaction,
15+
QuerySelfXCCResponse
1516
} from "../src/proto/cross/core/initiator/Initiator.sol";
1617
import {Account as AuthAccount, AuthType, TxAuthState} from "../src/proto/cross/core/auth/Auth.sol";
1718
import {GoogleProtobufAny} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
1819
import {Tx} from "../src/proto/cross/core/tx/Tx.sol";
1920
import {IbcCoreClientV1Height} from "../src/proto/ibc/core/client/v1/client.sol";
21+
import {ChannelInfo} from "../src/proto/cross/core/xcc/XCC.sol";
2022

2123
contract MockTxManager is TxManagerBase {
2224
mapping(bytes32 => bool) public txExists;
@@ -128,9 +130,14 @@ contract InitiatorTest is Test {
128130
assertEq(harness.CHAIN_ID_HASH(), expected, "CHAIN_ID_HASH mismatch");
129131
}
130132

131-
function test_selfXCC_RevertWhen_Always() public {
132-
vm.expectRevert(IInitiator.SelfXCCNotImplemented.selector);
133-
harness.selfXCC();
133+
function test_selfXCC_ReturnsCorrectData() public view {
134+
string memory expectedTypeURL = "/cross.core.xcc.ChannelInfo";
135+
bytes memory expectedValue = ChannelInfo.encode(ChannelInfo.Data({port: "", channel: ""}));
136+
137+
QuerySelfXCCResponse.Data memory resp = harness.selfXCC();
138+
139+
assertEq(resp.xcc.type_url, expectedTypeURL, "type_url mismatch");
140+
assertEq(resp.xcc.value, expectedValue, "value mismatch");
134141
}
135142

136143
function test_initiateTx_SucceedsAsPendingWhenSignersNotMet() public {

0 commit comments

Comments
 (0)