This repository has been archived by the owner on Sep 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_ibc.go
596 lines (476 loc) · 20.2 KB
/
query_ibc.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
package ibc
import (
"github.com/Moonyongjung/xpla.go/client/queries"
mibc "github.com/Moonyongjung/xpla.go/core/ibc"
"github.com/Moonyongjung/xpla.go/types"
"github.com/Moonyongjung/xpla.go/types/errors"
"github.com/Moonyongjung/xpla.go/util"
"github.com/gogo/protobuf/proto"
cmclient "github.com/cosmos/cosmos-sdk/client"
ibctransfer "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibcclientutils "github.com/cosmos/ibc-go/v3/modules/core/02-client/client/utils"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
ibcconnection "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"
ibcchannel "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
)
var out []byte
var res proto.Message
var err error
// Query client for gov module.
func QueryIbc(i queries.IXplaClient) (string, error) {
if i.QueryType == types.QueryGrpc {
return queryByGrpcIbc(i)
} else {
return queryByLcdIbc(i)
}
}
func queryByGrpcIbc(i queries.IXplaClient) (string, error) {
ibcclientQueryClient := ibcclient.NewQueryClient(i.Ixplac.GetGrpcClient())
ibcconnectionQueryClient := ibcconnection.NewQueryClient(i.Ixplac.GetGrpcClient())
ibccchannelQueryClient := ibcchannel.NewQueryClient(i.Ixplac.GetGrpcClient())
ibctransferQueryClient := ibctransfer.NewQueryClient(i.Ixplac.GetGrpcClient())
switch {
// IBC client states
case i.Ixplac.GetMsgType() == mibc.IbcClientStatesMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryClientStatesRequest)
res, err = ibcclientQueryClient.ClientStates(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC client state
case i.Ixplac.GetMsgType() == mibc.IbcClientStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryClientStateRequest)
res, err = ibcclientQueryClient.ClientState(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC client status
case i.Ixplac.GetMsgType() == mibc.IbcClientStatusMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryClientStatusRequest)
res, err = ibcclientQueryClient.ClientStatus(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC client consensus states
case i.Ixplac.GetMsgType() == mibc.IbcClientConsensusStatesMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryConsensusStatesRequest)
res, err = ibcclientQueryClient.ConsensusStates(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC client consensus state heights
case i.Ixplac.GetMsgType() == mibc.IbcClientConsensusStateHeightsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryConsensusStateHeightsRequest)
res, err = ibcclientQueryClient.ConsensusStateHeights(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC client consensus state
case i.Ixplac.GetMsgType() == mibc.IbcClientConsensusStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryConsensusStateRequest)
res, err = ibcclientQueryClient.ConsensusState(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC client tendermint header
case i.Ixplac.GetMsgType() == mibc.IbcClientHeaderMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(cmclient.Context)
header, _, err := ibcclientutils.QueryTendermintHeader(convertMsg)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
res = &header
// IBC client self consensus state
case i.Ixplac.GetMsgType() == mibc.IbcClientSelfConsensusStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(cmclient.Context)
state, _, err := ibcclientutils.QuerySelfConsensusState(convertMsg)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
res = state
// IBC client params
case i.Ixplac.GetMsgType() == mibc.IbcClientParamsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryClientParamsRequest)
res, err = ibcclientQueryClient.ClientParams(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC connection connections
case i.Ixplac.GetMsgType() == mibc.IbcConnectionConnectionsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcconnection.QueryConnectionsRequest)
res, err = ibcconnectionQueryClient.Connections(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC connection connection
case i.Ixplac.GetMsgType() == mibc.IbcConnectionConnectionMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcconnection.QueryConnectionRequest)
res, err = ibcconnectionQueryClient.Connection(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC connection a client connections
case i.Ixplac.GetMsgType() == mibc.IbcConnectionClientConnectionsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcconnection.QueryClientConnectionsRequest)
res, err = ibcconnectionQueryClient.ClientConnections(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channels
case i.Ixplac.GetMsgType() == mibc.IbcChannelChannelsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryChannelsRequest)
res, err = ibccchannelQueryClient.Channels(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC a channel
case i.Ixplac.GetMsgType() == mibc.IbcChannelChannelMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryChannelRequest)
res, err = ibccchannelQueryClient.Channel(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel connections
case i.Ixplac.GetMsgType() == mibc.IbcChannelConnectionsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryConnectionChannelsRequest)
res, err = ibccchannelQueryClient.ConnectionChannels(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel client state
case i.Ixplac.GetMsgType() == mibc.IbcChannelClientStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryChannelClientStateRequest)
res, err = ibccchannelQueryClient.ChannelClientState(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel packet commitments
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketCommitmentsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketCommitmentsRequest)
res, err = ibccchannelQueryClient.PacketCommitments(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel packet commitment by sequece
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketCommitmentMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketCommitmentRequest)
res, err = ibccchannelQueryClient.PacketCommitment(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel packet receipt
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketReceiptMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketReceiptRequest)
res, err = ibccchannelQueryClient.PacketReceipt(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel packet ack
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketAckMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketAcknowledgementRequest)
res, err = ibccchannelQueryClient.PacketAcknowledgement(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel unreceived packets
case i.Ixplac.GetMsgType() == mibc.IbcChannelUnreceivedPacketsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryUnreceivedPacketsRequest)
res, err = ibccchannelQueryClient.UnreceivedPackets(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel unreceived acks
case i.Ixplac.GetMsgType() == mibc.IbcChannelUnreceivedAcksMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryUnreceivedAcksRequest)
res, err = ibccchannelQueryClient.UnreceivedAcks(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC channel next sequence receive
case i.Ixplac.GetMsgType() == mibc.IbcChannelNextSequenceMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryNextSequenceReceiveRequest)
res, err = ibccchannelQueryClient.NextSequenceReceive(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC transfer denom traces
case i.Ixplac.GetMsgType() == mibc.IbcTransferDenomTracesMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibctransfer.QueryDenomTracesRequest)
res, err = ibctransferQueryClient.DenomTraces(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC transfer denom trace
case i.Ixplac.GetMsgType() == mibc.IbcTransferDenomTraceMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibctransfer.QueryDenomTraceRequest)
res, err = ibctransferQueryClient.DenomTrace(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC transfer denom hash
case i.Ixplac.GetMsgType() == mibc.IbcTransferDenomHashMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibctransfer.QueryDenomHashRequest)
res, err = ibctransferQueryClient.DenomHash(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
// IBC transfer escrow address
case i.Ixplac.GetMsgType() == mibc.IbcTransferEscrowAddressMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(types.IbcEscrowAddressMsg)
addr := ibctransfer.GetEscrowAddress(convertMsg.PortId, convertMsg.ChannelId)
return addr.String(), nil
// IBC transfer params
case i.Ixplac.GetMsgType() == mibc.IbcTransferParamsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibctransfer.QueryParamsRequest)
res, err = ibctransferQueryClient.Params(
i.Ixplac.GetContext(),
&convertMsg,
)
if err != nil {
return "", util.LogErr(errors.ErrGrpcRequest, err)
}
default:
return "", util.LogErr(errors.ErrInvalidMsgType, i.Ixplac.GetMsgType())
}
out, err = queries.PrintProto(i, res)
if err != nil {
return "", err
}
return string(out), nil
}
const (
ibcclientClientStatesLabel = "client_states"
ibcclientClientStatusLabel = "client_status"
ibcclientClientConsensusStatesLabel = "consensus_states"
ibcclientHeightsLabel = "heights"
ibcclientRevisionNumberLabel = "revision"
ibcclientRevisionHeightLabel = "height"
ibcconnectionConnectionsLabel = "connections"
ibcconnectionClientConnectionsLabel = "client_connections"
ibcchannelChannelsLabel = "channels"
ibcchannelPortsLabel = "ports"
ibcchannelClientStateLabel = "client_state"
ibcchannelPacketCommitmentsLabel = "packet_commitments"
ibcchannelUnreceivedPacketsLabel = "unreceived_packets"
ibcchannelUnreceivedAcksLabel = "unreceived_acks"
ibcchannelPacketReceiptLabel = "packet_receipts"
ibcchannelPacketAckLabel = "packet_acks"
ibcchannelNextSequenceLabel = "next_sequence"
ibctransferDenomTracesLabel = "denom_traces"
ibctransferDenomHashesLabel = "denom_hashes"
ibctransferEscrowAddressLabel = "escrow_address"
)
func queryByLcdIbc(i queries.IXplaClient) (string, error) {
var url string
ibcclientUrl := "/ibc/core/client/v1/"
ibcconnectionUrl := "/ibc/core/connection/v1/"
ibcchannelUrl := "/ibc/core/channel/v1/"
ibctransferUrl := "/ibc/apps/transfer/v1/"
switch {
// IBC client states
case i.Ixplac.GetMsgType() == mibc.IbcClientStatesMsgType:
url = ibcclientUrl + ibcclientClientStatesLabel
// IBC client state
case i.Ixplac.GetMsgType() == mibc.IbcClientStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryClientStateRequest)
url = ibcclientUrl + util.MakeQueryLabels(ibcclientClientStatesLabel, convertMsg.ClientId)
// IBC client status
case i.Ixplac.GetMsgType() == mibc.IbcClientStatusMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryClientStatusRequest)
url = ibcclientUrl + util.MakeQueryLabels(ibcclientClientStatusLabel, convertMsg.ClientId)
// IBC client consensus states
case i.Ixplac.GetMsgType() == mibc.IbcClientConsensusStatesMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryConsensusStatesRequest)
url = ibcclientUrl + util.MakeQueryLabels(ibcclientClientConsensusStatesLabel, convertMsg.ClientId)
// IBC client consensus state heights
case i.Ixplac.GetMsgType() == mibc.IbcClientConsensusStateHeightsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryConsensusStateHeightsRequest)
url = ibcclientUrl + util.MakeQueryLabels(ibcclientClientConsensusStatesLabel, convertMsg.ClientId, ibcclientHeightsLabel)
// IBC client consensus state height
case i.Ixplac.GetMsgType() == mibc.IbcClientConsensusStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcclient.QueryConsensusStateRequest)
url = ibcclientUrl + util.MakeQueryLabels(
ibcclientClientConsensusStatesLabel,
convertMsg.ClientId,
ibcclientRevisionNumberLabel,
util.FromUint64ToString(convertMsg.RevisionNumber),
ibcclientRevisionHeightLabel,
util.FromUint64ToString(convertMsg.RevisionHeight),
)
// IBC client tendermint header
case i.Ixplac.GetMsgType() == mibc.IbcClientHeaderMsgType:
return "", util.LogErr(errors.ErrNotSupport, "unsupported querying IBC client tendermint header by using LCD")
// IBC client self consensus state
case i.Ixplac.GetMsgType() == mibc.IbcClientSelfConsensusStateMsgType:
return "", util.LogErr(errors.ErrNotSupport, "unsupported querying IBC client self consensus state by using LCD")
// IBC client params
case i.Ixplac.GetMsgType() == mibc.IbcClientParamsMsgType:
url = "/ibc/client/v1/params"
// IBC connection connections
case i.Ixplac.GetMsgType() == mibc.IbcConnectionConnectionsMsgType:
url = ibcconnectionUrl + ibcconnectionConnectionsLabel
// IBC connection connection
case i.Ixplac.GetMsgType() == mibc.IbcConnectionConnectionMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcconnection.QueryConnectionRequest)
url = ibcconnectionUrl + util.MakeQueryLabels(ibcconnectionConnectionsLabel, convertMsg.ConnectionId)
// IBC connection a client connections
case i.Ixplac.GetMsgType() == mibc.IbcConnectionClientConnectionsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcconnection.QueryClientConnectionsRequest)
url = ibcconnectionUrl + util.MakeQueryLabels(ibcconnectionClientConnectionsLabel, convertMsg.ClientId)
// IBC channels
case i.Ixplac.GetMsgType() == mibc.IbcChannelChannelsMsgType:
url = ibcchannelUrl + ibcchannelChannelsLabel
// IBC a channel
case i.Ixplac.GetMsgType() == mibc.IbcChannelChannelMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryChannelRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId)
// IBC channel connections
case i.Ixplac.GetMsgType() == mibc.IbcChannelConnectionsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryConnectionChannelsRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcconnectionConnectionsLabel, convertMsg.Connection, ibcchannelChannelsLabel)
// IBC channel client state
case i.Ixplac.GetMsgType() == mibc.IbcChannelClientStateMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryChannelClientStateRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibcchannelClientStateLabel)
// IBC channel packet commitments
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketCommitmentsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketCommitmentsRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibcchannelPacketCommitmentsLabel)
// IBC channel packet commitment by sequece
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketCommitmentMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketCommitmentRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibcchannelPacketCommitmentsLabel, util.FromUint64ToString(convertMsg.Sequence))
// IBC channel packet receipt
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketReceiptMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketReceiptRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibcchannelPacketReceiptLabel, util.FromUint64ToString(convertMsg.Sequence))
// IBC channel packet ack
case i.Ixplac.GetMsgType() == mibc.IbcChannelPacketAckMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryPacketAcknowledgementRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibcchannelPacketAckLabel, util.FromUint64ToString(convertMsg.Sequence))
// IBC channel unreceived packets
case i.Ixplac.GetMsgType() == mibc.IbcChannelUnreceivedPacketsMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryUnreceivedPacketsRequest)
url = ibcchannelUrl + util.MakeQueryLabels(
ibcchannelChannelsLabel,
convertMsg.ChannelId,
ibcchannelPortsLabel,
convertMsg.PortId,
ibcchannelPacketCommitmentsLabel,
util.FromUint64ToString(convertMsg.PacketCommitmentSequences[0]),
ibcchannelUnreceivedPacketsLabel,
)
// IBC channel unreceived acks
case i.Ixplac.GetMsgType() == mibc.IbcChannelUnreceivedAcksMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryUnreceivedAcksRequest)
url = ibcchannelUrl + util.MakeQueryLabels(
ibcchannelChannelsLabel,
convertMsg.ChannelId,
ibcchannelPortsLabel,
convertMsg.PortId,
ibcchannelPacketCommitmentsLabel,
util.FromUint64ToString(convertMsg.PacketAckSequences[0]),
ibcchannelUnreceivedAcksLabel,
)
// IBC channel next sequence receive
case i.Ixplac.GetMsgType() == mibc.IbcChannelNextSequenceMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibcchannel.QueryNextSequenceReceiveRequest)
url = ibcchannelUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibcchannelNextSequenceLabel)
// IBC transfer denom traces
case i.Ixplac.GetMsgType() == mibc.IbcTransferDenomTracesMsgType:
url = ibctransferUrl + ibctransferDenomTracesLabel
// IBC transfer denom trace
case i.Ixplac.GetMsgType() == mibc.IbcTransferDenomTraceMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(ibctransfer.QueryDenomTraceRequest)
url = ibctransferUrl + util.MakeQueryLabels(ibctransferDenomTracesLabel, convertMsg.Hash)
// IBC transfer denom hash
case i.Ixplac.GetMsgType() == mibc.IbcTransferDenomHashMsgType:
return "", util.LogErr(errors.ErrNotSupport, "unsupported querying denom hash by using LCD")
// IBC transfer escrow address
case i.Ixplac.GetMsgType() == mibc.IbcTransferEscrowAddressMsgType:
convertMsg, _ := i.Ixplac.GetMsg().(types.IbcEscrowAddressMsg)
url = ibctransferUrl + util.MakeQueryLabels(ibcchannelChannelsLabel, convertMsg.ChannelId, ibcchannelPortsLabel, convertMsg.PortId, ibctransferEscrowAddressLabel)
// IBC transfer params
case i.Ixplac.GetMsgType() == mibc.IbcTransferParamsMsgType:
url = ibctransferUrl + "/params"
default:
return "", util.LogErr(errors.ErrInvalidMsgType, i.Ixplac.GetMsgType())
}
out, err := util.CtxHttpClient("GET", i.Ixplac.GetLcdURL()+url, nil, i.Ixplac.GetContext())
if err != nil {
return "", err
}
return string(out), nil
}