Skip to content

Commit 3c2fb43

Browse files
authored
Merge pull request #17 from datachainlab/def-interface-initiator
feat: IInitiator
2 parents bc168cf + cc98902 commit 3c2fb43

File tree

11 files changed

+6383
-9
lines changed

11 files changed

+6383
-9
lines changed

.husky/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33

44
set -e
55

6-
npm run fmt:sol
7-
8-
git add -A
6+
npx lint-staged

.lintstagedrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*.sol": ["npm run fmt:sol"]
3+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"postinstall": "husky && forge build",
88
"clean": "rm -rf build",
99
"test": "forge test -vvv",
10-
"lint:sol": "solhint -f table 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
10+
"lint:sol": "solhint -f table --max-warnings 0 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
1111
"fmt:sol": "forge fmt",
1212
"coverage:sol": "forge coverage --report lcov"
1313
},
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
syntax = "proto3";
2+
3+
import "google/protobuf/any.proto";
4+
import "gogoproto/gogo.proto";
5+
import "ibc/core/client/v1/client.proto";
6+
import "cross/core/tx/Tx.proto";
7+
import "cross/core/auth/Auth.proto";
8+
9+
option go_package = "github.com/datachainlab/cross/x/core/initiator/types";
10+
option (gogoproto.goproto_getters_all) = false;
11+
12+
message MsgInitiateTx {
13+
option (gogoproto.equal) = false;
14+
option (gogoproto.goproto_getters) = false;
15+
16+
string chain_id = 1;
17+
uint64 nonce = 2;
18+
19+
Tx.CommitProtocol commit_protocol = 3;
20+
21+
repeated ContractTransaction contract_transactions = 4 [(gogoproto.nullable) = false];
22+
23+
repeated Account signers = 5 [(gogoproto.nullable) = false];
24+
25+
ibc.core.client.v1.Height timeout_height = 6
26+
[(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false];
27+
28+
uint64 timeout_timestamp = 7
29+
[(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
30+
}
31+
32+
message MsgInitiateTxResponse {
33+
option (gogoproto.equal) = false;
34+
option (gogoproto.goproto_getters) = false;
35+
36+
bytes txID = 1 [(gogoproto.casttype) = "github.com/datachainlab/cross/x/core/types.TxID"];
37+
38+
enum InitiateTxStatus {
39+
option (gogoproto.goproto_enum_prefix) = false;
40+
41+
INITIATE_TX_STATUS_UNKNOWN = 0;
42+
INITIATE_TX_STATUS_PENDING = 1;
43+
INITIATE_TX_STATUS_VERIFIED = 2;
44+
}
45+
46+
InitiateTxStatus status = 2;
47+
}
48+
49+
message QuerySelfXCCRequest {}
50+
51+
message QuerySelfXCCResponse {
52+
google.protobuf.Any xcc = 1 [(gogoproto.nullable) = true];
53+
}
54+
55+
message ContractTransaction {
56+
option (gogoproto.equal) = false;
57+
58+
google.protobuf.Any cross_chain_channel = 1 [(gogoproto.nullable) = true];
59+
repeated Account signers = 2 [(gogoproto.nullable) = false];
60+
bytes call_info = 3 [(gogoproto.casttype) = "github.com/datachainlab/cross/x/core/tx/types.ContractCallInfo"];
61+
ReturnValue return_value = 4;
62+
repeated Link links = 5 [(gogoproto.nullable) = false];
63+
}
64+
65+
message Link {
66+
uint32 src_index = 1;
67+
}
68+
69+
message GenesisState {}
70+
71+
message InitiateTxState {
72+
option (gogoproto.equal) = false;
73+
74+
MsgInitiateTxResponse.InitiateTxStatus status = 1;
75+
76+
MsgInitiateTx msg = 2 [(gogoproto.nullable) = false];
77+
}

proto/cross/core/tx/Tx.proto

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
syntax = "proto3";
2+
3+
import "gogoproto/gogo.proto";
4+
import "google/protobuf/any.proto";
5+
import "ibc/core/client/v1/client.proto";
6+
import "cross/core/auth/Auth.proto";
7+
8+
option go_package = "github.com/datachainlab/cross/x/core/tx/types";
9+
option (gogoproto.goproto_getters_all) = false;
10+
11+
message Tx {
12+
option (gogoproto.equal) = false;
13+
14+
bytes id = 1 [(gogoproto.casttype) = "github.com/datachainlab/cross/x/core/types.TxID"];
15+
16+
enum CommitProtocol {
17+
option (gogoproto.goproto_enum_prefix) = false;
18+
19+
COMMIT_PROTOCOL_UNKNOWN = 0;
20+
COMMIT_PROTOCOL_SIMPLE = 1;
21+
COMMIT_PROTOCOL_TPC = 2;
22+
}
23+
24+
CommitProtocol commit_protocol = 2;
25+
26+
repeated ResolvedContractTransaction contract_transactions = 3 [(gogoproto.nullable) = false];
27+
28+
ibc.core.client.v1.Height timeout_height = 4
29+
[(gogoproto.moretags) = "yaml:\"timeout_height\"", (gogoproto.nullable) = false];
30+
31+
uint64 timeout_timestamp = 5
32+
[(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
33+
}
34+
35+
message ResolvedContractTransaction {
36+
option (gogoproto.equal) = false;
37+
38+
google.protobuf.Any cross_chain_channel = 1 [(gogoproto.nullable) = true];
39+
repeated Account signers = 2 [(gogoproto.nullable) = false];
40+
bytes call_info = 3 [(gogoproto.casttype) = "ContractCallInfo"];
41+
ReturnValue return_value = 4;
42+
repeated google.protobuf.Any call_results = 5 [(gogoproto.nullable) = false];
43+
}
44+
45+
message ReturnValue {
46+
bytes value = 1;
47+
}
48+
49+
message ConstantValueCallResult {
50+
google.protobuf.Any cross_chain_channel = 1 [(gogoproto.nullable) = false];
51+
bytes k = 2;
52+
bytes v = 3;
53+
}
54+
55+
message ContractCallResult {
56+
bytes data = 1;
57+
repeated google.protobuf.Any events = 2 [(gogoproto.nullable) = false];
58+
}

src/core/IInitiator.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
import {MsgInitiateTx, MsgInitiateTxResponse, QuerySelfXCCResponse} from "../proto/cross/core/initiator/Initiator.sol";
5+
6+
interface IInitiator {
7+
event TxInitiated(bytes txId, address indexed proposer);
8+
9+
function initiateTx(MsgInitiateTx.Data calldata msg_) external returns (MsgInitiateTxResponse.Data memory resp);
10+
11+
function selfXCC() external view returns (QuerySelfXCCResponse.Data memory resp);
12+
}

src/proto/cross/core/atomic/simple/AtomicSimple.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.20;
3-
43
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/ProtoBufRuntime.sol";
54
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
65
import "../../auth/Auth.sol";
@@ -599,7 +598,6 @@ library Header {
599598
if (r.fields.length != 0) {
600599
for (i = 0; i < r.fields.length; i++) {
601600
pointer += ProtoBufRuntime._encode_key(1, ProtoBufRuntime.WireType.LengthDelim, pointer, bs);
602-
603601
pointer += HeaderField._encode_nested(r.fields[i], pointer, bs);
604602
}
605603
}
@@ -1434,7 +1432,6 @@ library PacketDataCallResolvedContractTransaction {
14341432
if (r.signers.length != 0) {
14351433
for (i = 0; i < r.signers.length; i++) {
14361434
pointer += ProtoBufRuntime._encode_key(2, ProtoBufRuntime.WireType.LengthDelim, pointer, bs);
1437-
14381435
pointer += Account._encode_nested(r.signers[i], pointer, bs);
14391436
}
14401437
}
@@ -1449,7 +1446,6 @@ library PacketDataCallResolvedContractTransaction {
14491446
if (r.objects.length != 0) {
14501447
for (i = 0; i < r.objects.length; i++) {
14511448
pointer += ProtoBufRuntime._encode_key(5, ProtoBufRuntime.WireType.LengthDelim, pointer, bs);
1452-
14531449
pointer += GoogleProtobufAny._encode_nested(r.objects[i], pointer, bs);
14541450
}
14551451
}

src/proto/cross/core/auth/Auth.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
22
pragma solidity ^0.8.20;
3-
43
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/ProtoBufRuntime.sol";
54
import "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
65

0 commit comments

Comments
 (0)