Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

set -e

npm run fmt:sol

git add -A
npx lint-staged
Copy link
Contributor Author

@YukiTsuchida YukiTsuchida Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug where files without stage were committed, so fixed it by using lint-staged.

3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.sol": ["npm run fmt:sol"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"postinstall": "husky && forge build",
"clean": "rm -rf build",
"test": "forge test -vvv",
"lint:sol": "solhint -f table 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
"lint:sol": "solhint -f table --max-warnings 0 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treat solhint warnings as errors.

"fmt:sol": "forge fmt",
"coverage:sol": "forge coverage --report lcov"
},
Expand Down
77 changes: 77 additions & 0 deletions proto/cross/core/initiator/Initiator.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
syntax = "proto3";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built with reference to the proto of the cross repository


import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "ibc/core/client/v1/client.proto";
import "cross/core/tx/Tx.proto";
import "cross/core/auth/Auth.proto";

option go_package = "github.com/datachainlab/cross/x/core/initiator/types";
option (gogoproto.goproto_getters_all) = false;

message MsgInitiateTx {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string chain_id = 1;
uint64 nonce = 2;

Tx.CommitProtocol commit_protocol = 3;

repeated ContractTransaction contract_transactions = 4 [(gogoproto.nullable) = false];

repeated Account signers = 5 [(gogoproto.nullable) = false];

ibc.core.client.v1.Height timeout_height = 6
[(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false];

uint64 timeout_timestamp = 7
[(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}

message MsgInitiateTxResponse {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

bytes txID = 1 [(gogoproto.casttype) = "github.com/datachainlab/cross/x/core/types.TxID"];

enum InitiateTxStatus {
option (gogoproto.goproto_enum_prefix) = false;

INITIATE_TX_STATUS_UNKNOWN = 0;
INITIATE_TX_STATUS_PENDING = 1;
INITIATE_TX_STATUS_VERIFIED = 2;
}

InitiateTxStatus status = 2;
}

message QuerySelfXCCRequest {}

message QuerySelfXCCResponse {
google.protobuf.Any xcc = 1 [(gogoproto.nullable) = true];
}

message ContractTransaction {
option (gogoproto.equal) = false;

google.protobuf.Any cross_chain_channel = 1 [(gogoproto.nullable) = true];
repeated Account signers = 2 [(gogoproto.nullable) = false];
bytes call_info = 3 [(gogoproto.casttype) = "github.com/datachainlab/cross/x/core/tx/types.ContractCallInfo"];
ReturnValue return_value = 4;
repeated Link links = 5 [(gogoproto.nullable) = false];
}

message Link {
uint32 src_index = 1;
}

message GenesisState {}

message InitiateTxState {
option (gogoproto.equal) = false;

MsgInitiateTxResponse.InitiateTxStatus status = 1;

MsgInitiateTx msg = 2 [(gogoproto.nullable) = false];
}
58 changes: 58 additions & 0 deletions proto/cross/core/tx/Tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
syntax = "proto3";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built with reference to the proto of the cross repository


import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "ibc/core/client/v1/client.proto";
import "cross/core/auth/Auth.proto";

option go_package = "github.com/datachainlab/cross/x/core/tx/types";
option (gogoproto.goproto_getters_all) = false;

message Tx {
option (gogoproto.equal) = false;

bytes id = 1 [(gogoproto.casttype) = "github.com/datachainlab/cross/x/core/types.TxID"];

enum CommitProtocol {
option (gogoproto.goproto_enum_prefix) = false;

COMMIT_PROTOCOL_UNKNOWN = 0;
COMMIT_PROTOCOL_SIMPLE = 1;
COMMIT_PROTOCOL_TPC = 2;
}

CommitProtocol commit_protocol = 2;

repeated ResolvedContractTransaction contract_transactions = 3 [(gogoproto.nullable) = false];

ibc.core.client.v1.Height timeout_height = 4
[(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false];

uint64 timeout_timestamp = 5
[(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
}

message ResolvedContractTransaction {
option (gogoproto.equal) = false;

google.protobuf.Any cross_chain_channel = 1 [(gogoproto.nullable) = true];
repeated Account signers = 2 [(gogoproto.nullable) = false];
bytes call_info = 3 [(gogoproto.casttype) = "ContractCallInfo"];
ReturnValue return_value = 4;
repeated google.protobuf.Any call_results = 5 [(gogoproto.nullable) = false];
}

message ReturnValue {
bytes value = 1;
}

message ConstantValueCallResult {
google.protobuf.Any cross_chain_channel = 1 [(gogoproto.nullable) = false];
bytes k = 2;
bytes v = 3;
}

message ContractCallResult {
bytes data = 1;
repeated google.protobuf.Any events = 2 [(gogoproto.nullable) = false];
}
12 changes: 12 additions & 0 deletions src/core/IInitiator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import {MsgInitiateTx, MsgInitiateTxResponse, QuerySelfXCCResponse} from "../proto/cross/core/initiator/Initiator.sol";

interface IInitiator {
event TxInitiated(bytes txId, address indexed proposer);

function initiateTx(MsgInitiateTx.Data calldata msg_) external returns (MsgInitiateTxResponse.Data memory resp);

function selfXCC() external view returns (QuerySelfXCCResponse.Data memory resp);
}
4 changes: 0 additions & 4 deletions src/proto/cross/core/atomic/simple/AtomicSimple.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/ProtoBufRuntime.sol";
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
import "../../auth/Auth.sol";
Expand Down Expand Up @@ -599,7 +598,6 @@ library Header {
if (r.fields.length != 0) {
for (i = 0; i < r.fields.length; i++) {
pointer += ProtoBufRuntime._encode_key(1, ProtoBufRuntime.WireType.LengthDelim, pointer, bs);

pointer += HeaderField._encode_nested(r.fields[i], pointer, bs);
}
}
Expand Down Expand Up @@ -1434,7 +1432,6 @@ library PacketDataCallResolvedContractTransaction {
if (r.signers.length != 0) {
for (i = 0; i < r.signers.length; i++) {
pointer += ProtoBufRuntime._encode_key(2, ProtoBufRuntime.WireType.LengthDelim, pointer, bs);

pointer += Account._encode_nested(r.signers[i], pointer, bs);
}
}
Expand All @@ -1449,7 +1446,6 @@ library PacketDataCallResolvedContractTransaction {
if (r.objects.length != 0) {
for (i = 0; i < r.objects.length; i++) {
pointer += ProtoBufRuntime._encode_key(5, ProtoBufRuntime.WireType.LengthDelim, pointer, bs);

pointer += GoogleProtobufAny._encode_nested(r.objects[i], pointer, bs);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/proto/cross/core/auth/Auth.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/ProtoBufRuntime.sol";
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";

Expand Down
Loading