-
Notifications
You must be signed in to change notification settings - Fork 13
/
types.go
215 lines (176 loc) · 5.33 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package cosmos
import (
"context"
"time"
"github.com/icon-project/ibc-integration/test/chains"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
rpcclient "github.com/cometbft/cometbft/rpc/client"
"github.com/icon-project/icon-bridge/common/codec"
)
type CosmosLocalnet struct {
*cosmos.CosmosChain
cfg ibc.ChainConfig
keyName string
filepath map[string]string
IBCAddresses map[string]string
}
func (c *CosmosLocalnet) Config() ibc.ChainConfig {
return c.cfg
}
func (c *CosmosLocalnet) OverrideConfig(key string, value any) {
if value == nil {
return
}
c.cfg.ConfigFileOverrides[key] = value
}
type Query struct {
GetAdmin *GetAdmin `json:"get_admin,omitempty"`
GetProtocolFee *GetProtocolFee `json:"get_protocol_fee,omitempty"`
}
type SetAdmin struct {
SetAdmin struct {
Address string `json:"address"`
} `json:"set_admin"`
}
type UpdateAdmin struct {
UpdateAdmin struct {
Address string `json:"address"`
} `json:"update_admin"`
}
type XcallInit struct {
TimeoutHeight int `json:"timeout_height"`
IbcHost string `json:"ibc_host"`
}
type DappInit struct {
Address string `json:"address"`
}
type GetProtocolFee struct{}
type GetAdmin struct{}
type CosmosTestnet struct {
bin string
keystorePath string
keyPassword string
scorePaths map[string]string
defaultStepLimit string
url string
Client rpcclient.Client
ChainID string
}
func (it *CosmosTestnet) DeployXCallMockApp(ctx context.Context, connection chains.XCallConnection) error {
//TODO implement me
panic("implement me")
}
func (c *CosmosTestnet) GetIBCAddress(key string) string {
//TODO implement me
panic("implement me")
}
func (c *CosmosTestnet) SetupXCall(ctx context.Context, portId, keyName string) error {
//TODO implement me
panic("implement me")
}
type Result struct {
NodeInfo struct {
ProtocolVersion struct {
P2P string `json:"p2p"`
Block string `json:"block"`
App string `json:"app"`
} `json:"protocol_version"`
ID string `json:"id"`
ListenAddr string `json:"listen_addr"`
Network string `json:"network"`
Version string `json:"version"`
Channels string `json:"channels"`
Moniker string `json:"moniker"`
Other struct {
TxIndex string `json:"tx_index"`
RPCAddress string `json:"rpc_address"`
} `json:"other"`
} `json:"NodeInfo"`
SyncInfo struct {
LatestBlockHash string `json:"latest_block_hash"`
LatestAppHash string `json:"latest_app_hash"`
LatestBlockHeight string `json:"latest_block_height"`
LatestBlockTime time.Time `json:"latest_block_time"`
EarliestBlockHash string `json:"earliest_block_hash"`
EarliestAppHash string `json:"earliest_app_hash"`
EarliestBlockHeight string `json:"earliest_block_height"`
EarliestBlockTime time.Time `json:"earliest_block_time"`
CatchingUp bool `json:"catching_up"`
} `json:"SyncInfo"`
ValidatorInfo struct {
Address string `json:"Address"`
PubKey struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"PubKey"`
VotingPower string `json:"VotingPower"`
} `json:"ValidatorInfo"`
}
type TxResul struct {
Height string `json:"height"`
Txhash string `json:"txhash"`
Codespace string `json:"codespace"`
Code int `json:"code"`
Data string `json:"data"`
RawLog string `json:"raw_log"`
Logs []interface{} `json:"logs"`
Info string `json:"info"`
GasWanted string `json:"gas_wanted"`
GasUsed string `json:"gas_used"`
Tx interface{} `json:"tx"`
Timestamp string `json:"timestamp"`
Events []struct {
Type string `json:"type"`
Attributes []struct {
Key string `json:"key"`
Value string `json:"value"`
Index bool `json:"index"`
} `json:"attributes"`
} `json:"events"`
}
type CallServiceMessageType int64
const (
CallServiceRequest CallServiceMessageType = 0
CallServiceResponse CallServiceMessageType = 1
)
type CSMessageResponseType int64
const (
SUCCESS CSMessageResponseType = 0
FAILURE CSMessageResponseType = -1
IBC_ERROR CSMessageResponseType = -2
)
type CallServiceMessage struct {
MessageType CallServiceMessageType
Payload []byte
}
func RlpEncodeRequest(request CallServiceMessageRequest, callType CallServiceMessageType) ([]byte, error) {
data := CallServiceMessage{
MessageType: CallServiceRequest,
Payload: codec.RLP.MustMarshalToBytes(request),
}
return codec.RLP.MarshalToBytes(data)
}
func RlpDecode(raw_data []byte) (CallServiceMessage, error) {
var callservicemessage = CallServiceMessage{}
codec.RLP.UnmarshalFromBytes(raw_data, &callservicemessage)
return CallServiceMessage{}, nil
}
type CallServiceMessageRequest struct {
From string `json:"from"`
To string `json:"to"`
SequenceNo uint64 `json:"sequence_no"`
Rollback bool `json:"rollback"`
Data []byte `json:"data"`
}
func (cr *CallServiceMessageRequest) RlpEncode() ([]byte, error) {
return codec.RLP.MarshalToBytes(cr)
}
type CallServiceMessageResponse struct {
SequenceNo uint64
Code CSMessageResponseType
Msg string
}
func (csr *CallServiceMessageResponse) RlpEncode() ([]byte, error) {
return codec.RLP.MarshalToBytes(csr)
}