-
Notifications
You must be signed in to change notification settings - Fork 14
/
grpc_query.go
508 lines (475 loc) · 20.4 KB
/
grpc_query.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
// nolint:staticcheck
package keeper
import (
"context"
fxtypes "github.com/functionx/fx-core/v5/types"
crosschainkeeper "github.com/functionx/fx-core/v5/x/crosschain/keeper"
crosschaintypes "github.com/functionx/fx-core/v5/x/crosschain/types"
ethtypes "github.com/functionx/fx-core/v5/x/eth/types"
"github.com/functionx/fx-core/v5/x/gravity/types"
)
type queryServer struct {
crosschainkeeper.Keeper
}
func NewQueryServerImpl(keeper crosschainkeeper.Keeper) types.QueryServer {
return &queryServer{Keeper: keeper}
}
var _ types.QueryServer = queryServer{}
func (k queryServer) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
response, err := k.Keeper.Params(c, &crosschaintypes.QueryParamsRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
return &types.QueryParamsResponse{Params: types.Params{
GravityId: response.Params.GravityId,
BridgeChainId: 1,
SignedValsetsWindow: response.Params.SignedWindow,
SignedBatchesWindow: response.Params.SignedWindow,
SignedClaimsWindow: response.Params.SignedWindow,
TargetBatchTimeout: response.Params.ExternalBatchTimeout,
AverageBlockTime: response.Params.AverageBlockTime,
AverageEthBlockTime: response.Params.AverageExternalBlockTime,
SlashFractionValset: response.Params.SlashFraction,
SlashFractionBatch: response.Params.SlashFraction,
SlashFractionClaim: response.Params.SlashFraction,
SlashFractionConflictingClaim: response.Params.SlashFraction,
UnbondSlashingValsetsWindow: response.Params.SignedWindow,
IbcTransferTimeoutHeight: response.Params.IbcTransferTimeoutHeight,
ValsetUpdatePowerChangePercent: response.Params.OracleSetUpdatePowerChangePercent,
}}, nil
}
func (k queryServer) CurrentValset(c context.Context, _ *types.QueryCurrentValsetRequest) (*types.QueryCurrentValsetResponse, error) {
response, err := k.Keeper.CurrentOracleSet(c, &crosschaintypes.QueryCurrentOracleSetRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
valset := &types.Valset{
Nonce: response.OracleSet.Nonce,
Members: make([]*types.BridgeValidator, len(response.OracleSet.Members)),
Height: response.OracleSet.Height,
}
for i := 0; i < len(response.OracleSet.Members); i++ {
valset.Members[i] = &types.BridgeValidator{
Power: response.OracleSet.Members[i].Power,
EthAddress: response.OracleSet.Members[i].ExternalAddress,
}
}
return &types.QueryCurrentValsetResponse{Valset: valset}, nil
}
func (k queryServer) ValsetRequest(c context.Context, req *types.QueryValsetRequestRequest) (*types.QueryValsetRequestResponse, error) {
response, err := k.Keeper.OracleSetRequest(c, &crosschaintypes.QueryOracleSetRequestRequest{
ChainName: ethtypes.ModuleName,
Nonce: req.Nonce,
})
if err != nil {
return nil, err
}
valset := &types.Valset{
Nonce: response.OracleSet.Nonce,
Members: make([]*types.BridgeValidator, len(response.OracleSet.Members)),
Height: response.OracleSet.Height,
}
for i := 0; i < len(response.OracleSet.Members); i++ {
valset.Members[i] = &types.BridgeValidator{
Power: response.OracleSet.Members[i].Power,
EthAddress: response.OracleSet.Members[i].ExternalAddress,
}
}
return &types.QueryValsetRequestResponse{Valset: valset}, nil
}
func (k queryServer) ValsetConfirm(c context.Context, req *types.QueryValsetConfirmRequest) (*types.QueryValsetConfirmResponse, error) {
response, err := k.Keeper.OracleSetConfirm(c, &crosschaintypes.QueryOracleSetConfirmRequest{
ChainName: ethtypes.ModuleName,
BridgerAddress: req.Address,
Nonce: req.Nonce,
})
if err != nil {
return nil, err
}
return &types.QueryValsetConfirmResponse{Confirm: &types.MsgValsetConfirm{
Nonce: response.Confirm.Nonce,
Orchestrator: response.Confirm.BridgerAddress,
EthAddress: response.Confirm.ExternalAddress,
Signature: response.Confirm.Signature,
}}, nil
}
func (k queryServer) ValsetConfirmsByNonce(c context.Context, req *types.QueryValsetConfirmsByNonceRequest) (*types.QueryValsetConfirmsByNonceResponse, error) {
response, err := k.Keeper.OracleSetConfirmsByNonce(c, &crosschaintypes.QueryOracleSetConfirmsByNonceRequest{
ChainName: ethtypes.ModuleName,
Nonce: req.Nonce,
})
if err != nil {
return nil, err
}
confirms := make([]*types.MsgValsetConfirm, len(response.Confirms))
for i := 0; i < len(response.Confirms); i++ {
confirms[i] = &types.MsgValsetConfirm{
Nonce: response.Confirms[i].Nonce,
Orchestrator: response.Confirms[i].BridgerAddress,
EthAddress: response.Confirms[i].ExternalAddress,
Signature: response.Confirms[i].Signature,
}
}
return &types.QueryValsetConfirmsByNonceResponse{Confirms: confirms}, nil
}
func (k queryServer) LastValsetRequests(c context.Context, _ *types.QueryLastValsetRequestsRequest) (*types.QueryLastValsetRequestsResponse, error) {
response, err := k.Keeper.LastOracleSetRequests(c, &crosschaintypes.QueryLastOracleSetRequestsRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
valsets := make([]*types.Valset, len(response.OracleSets))
for i := 0; i < len(response.OracleSets); i++ {
valsets[i] = &types.Valset{
Nonce: response.OracleSets[i].Nonce,
Members: make([]*types.BridgeValidator, len(response.OracleSets[i].Members)),
Height: response.OracleSets[i].Height,
}
for j := 0; j < len(response.OracleSets[i].Members); j++ {
valsets[i].Members[j] = &types.BridgeValidator{
Power: response.OracleSets[i].Members[j].Power,
EthAddress: response.OracleSets[i].Members[j].ExternalAddress,
}
}
}
return &types.QueryLastValsetRequestsResponse{Valsets: valsets}, nil
}
func (k queryServer) LastPendingValsetRequestByAddr(c context.Context, req *types.QueryLastPendingValsetRequestByAddrRequest) (*types.QueryLastPendingValsetRequestByAddrResponse, error) {
response, err := k.Keeper.LastPendingOracleSetRequestByAddr(c, &crosschaintypes.QueryLastPendingOracleSetRequestByAddrRequest{
ChainName: ethtypes.ModuleName,
BridgerAddress: req.Address,
})
if err != nil {
return nil, err
}
valsets := make([]*types.Valset, len(response.OracleSets))
for i := 0; i < len(response.OracleSets); i++ {
valsets[i] = &types.Valset{
Nonce: response.OracleSets[i].Nonce,
Members: make([]*types.BridgeValidator, len(response.OracleSets[i].Members)),
Height: response.OracleSets[i].Height,
}
for j := 0; j < len(response.OracleSets[i].Members); j++ {
valsets[i].Members[j] = &types.BridgeValidator{
Power: response.OracleSets[i].Members[j].Power,
EthAddress: response.OracleSets[i].Members[j].ExternalAddress,
}
}
}
return &types.QueryLastPendingValsetRequestByAddrResponse{Valsets: valsets}, nil
}
func (k queryServer) BatchFees(c context.Context, req *types.QueryBatchFeeRequest) (*types.QueryBatchFeeResponse, error) {
minBatchFees := make([]crosschaintypes.MinBatchFee, len(req.MinBatchFees))
for i := 0; i < len(req.MinBatchFees); i++ {
minBatchFees[i] = crosschaintypes.MinBatchFee{
TokenContract: req.MinBatchFees[i].TokenContract,
BaseFee: req.MinBatchFees[i].BaseFee,
}
}
response, err := k.Keeper.BatchFees(c, &crosschaintypes.QueryBatchFeeRequest{
ChainName: ethtypes.ModuleName,
MinBatchFees: minBatchFees,
})
if err != nil {
return nil, err
}
batchFees := make([]*types.BatchFees, len(response.BatchFees))
for i := 0; i < len(response.BatchFees); i++ {
batchFees[i] = &types.BatchFees{
TokenContract: response.BatchFees[i].TokenContract,
TotalFees: response.BatchFees[i].TotalFees,
TotalTxs: response.BatchFees[i].TotalTxs,
TotalAmount: response.BatchFees[i].TotalAmount,
}
}
return &types.QueryBatchFeeResponse{BatchFees: batchFees}, nil
}
func (k queryServer) LastPendingBatchRequestByAddr(c context.Context, req *types.QueryLastPendingBatchRequestByAddrRequest) (*types.QueryLastPendingBatchRequestByAddrResponse, error) {
response, err := k.Keeper.LastPendingBatchRequestByAddr(c, &crosschaintypes.QueryLastPendingBatchRequestByAddrRequest{
ChainName: ethtypes.ModuleName,
BridgerAddress: req.Address,
})
if err != nil {
return nil, err
}
outgoingTxBatch := &types.OutgoingTxBatch{
BatchNonce: response.Batch.BatchNonce,
BatchTimeout: response.Batch.BatchTimeout,
Transactions: make([]*types.OutgoingTransferTx, len(response.Batch.Transactions)),
TokenContract: response.Batch.TokenContract,
Block: response.Batch.Block,
FeeReceive: response.Batch.FeeReceive,
}
for i := 0; i < len(response.Batch.Transactions); i++ {
outgoingTxBatch.Transactions[i] = &types.OutgoingTransferTx{
Id: response.Batch.Transactions[i].Id,
Sender: response.Batch.Transactions[i].Sender,
DestAddress: response.Batch.Transactions[i].DestAddress,
Erc20Token: &types.ERC20Token{
Contract: response.Batch.Transactions[i].Token.Contract,
Amount: response.Batch.Transactions[i].Token.Amount,
},
Erc20Fee: &types.ERC20Token{
Contract: response.Batch.Transactions[i].Fee.Contract,
Amount: response.Batch.Transactions[i].Fee.Amount,
},
}
}
return &types.QueryLastPendingBatchRequestByAddrResponse{Batch: outgoingTxBatch}, nil
}
func (k queryServer) OutgoingTxBatches(c context.Context, _ *types.QueryOutgoingTxBatchesRequest) (*types.QueryOutgoingTxBatchesResponse, error) {
response, err := k.Keeper.OutgoingTxBatches(c, &crosschaintypes.QueryOutgoingTxBatchesRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
batches := make([]*types.OutgoingTxBatch, len(response.Batches))
for i := 0; i < len(response.Batches); i++ {
batches[i] = &types.OutgoingTxBatch{
BatchNonce: response.Batches[i].BatchNonce,
BatchTimeout: response.Batches[i].BatchTimeout,
Transactions: make([]*types.OutgoingTransferTx, len(response.Batches[i].Transactions)),
TokenContract: response.Batches[i].TokenContract,
Block: response.Batches[i].Block,
FeeReceive: response.Batches[i].FeeReceive,
}
for j := 0; j < len(response.Batches[i].Transactions); j++ {
batches[i].Transactions[j] = &types.OutgoingTransferTx{
Id: response.Batches[i].Transactions[j].Id,
Sender: response.Batches[i].Transactions[j].Sender,
DestAddress: response.Batches[i].Transactions[j].DestAddress,
Erc20Token: &types.ERC20Token{
Contract: response.Batches[i].Transactions[j].Token.Contract,
Amount: response.Batches[i].Transactions[j].Token.Amount,
},
Erc20Fee: &types.ERC20Token{
Contract: response.Batches[i].Transactions[j].Fee.Contract,
Amount: response.Batches[i].Transactions[j].Fee.Amount,
},
}
}
}
return &types.QueryOutgoingTxBatchesResponse{Batches: batches}, nil
}
func (k queryServer) BatchRequestByNonce(c context.Context, req *types.QueryBatchRequestByNonceRequest) (*types.QueryBatchRequestByNonceResponse, error) {
response, err := k.Keeper.BatchRequestByNonce(c, &crosschaintypes.QueryBatchRequestByNonceRequest{
ChainName: ethtypes.ModuleName,
TokenContract: req.TokenContract,
Nonce: req.Nonce,
})
if err != nil {
return nil, err
}
outgoingTxBatch := &types.OutgoingTxBatch{
BatchNonce: response.Batch.BatchNonce,
BatchTimeout: response.Batch.BatchTimeout,
Transactions: make([]*types.OutgoingTransferTx, len(response.Batch.Transactions)),
TokenContract: response.Batch.TokenContract,
Block: response.Batch.Block,
FeeReceive: response.Batch.FeeReceive,
}
for i := 0; i < len(response.Batch.Transactions); i++ {
outgoingTxBatch.Transactions[i] = &types.OutgoingTransferTx{
Id: response.Batch.Transactions[i].Id,
Sender: response.Batch.Transactions[i].Sender,
DestAddress: response.Batch.Transactions[i].DestAddress,
Erc20Token: &types.ERC20Token{
Contract: response.Batch.Transactions[i].Token.Contract,
Amount: response.Batch.Transactions[i].Token.Amount,
},
Erc20Fee: &types.ERC20Token{
Contract: response.Batch.Transactions[i].Fee.Contract,
Amount: response.Batch.Transactions[i].Fee.Amount,
},
}
}
return &types.QueryBatchRequestByNonceResponse{Batch: outgoingTxBatch}, nil
}
func (k queryServer) BatchConfirm(c context.Context, req *types.QueryBatchConfirmRequest) (*types.QueryBatchConfirmResponse, error) {
response, err := k.Keeper.BatchConfirm(c, &crosschaintypes.QueryBatchConfirmRequest{
ChainName: ethtypes.ModuleName,
TokenContract: req.TokenContract,
BridgerAddress: req.Address,
Nonce: req.Nonce,
})
if err != nil {
return nil, err
}
return &types.QueryBatchConfirmResponse{Confirm: &types.MsgConfirmBatch{
Nonce: response.Confirm.Nonce,
TokenContract: response.Confirm.TokenContract,
EthSigner: response.Confirm.ExternalAddress,
Orchestrator: response.Confirm.BridgerAddress,
Signature: response.Confirm.Signature,
}}, nil
}
func (k queryServer) BatchConfirms(c context.Context, req *types.QueryBatchConfirmsRequest) (*types.QueryBatchConfirmsResponse, error) {
response, err := k.Keeper.BatchConfirms(c, &crosschaintypes.QueryBatchConfirmsRequest{
ChainName: ethtypes.ModuleName,
TokenContract: req.TokenContract,
Nonce: req.Nonce,
})
if err != nil {
return nil, err
}
confirms := make([]*types.MsgConfirmBatch, len(response.Confirms))
for i := 0; i < len(response.Confirms); i++ {
confirms[i] = &types.MsgConfirmBatch{
Nonce: response.Confirms[i].Nonce,
TokenContract: response.Confirms[i].TokenContract,
EthSigner: response.Confirms[i].ExternalAddress,
Orchestrator: response.Confirms[i].BridgerAddress,
Signature: response.Confirms[i].Signature,
}
}
return &types.QueryBatchConfirmsResponse{Confirms: confirms}, nil
}
func (k queryServer) LastEventNonceByAddr(c context.Context, req *types.QueryLastEventNonceByAddrRequest) (*types.QueryLastEventNonceByAddrResponse, error) {
response, err := k.Keeper.LastEventNonceByAddr(c, &crosschaintypes.QueryLastEventNonceByAddrRequest{
ChainName: ethtypes.ModuleName,
BridgerAddress: req.Address,
})
if err != nil {
return nil, err
}
return &types.QueryLastEventNonceByAddrResponse{EventNonce: response.EventNonce}, nil
}
func (k queryServer) DenomToERC20(c context.Context, req *types.QueryDenomToERC20Request) (*types.QueryDenomToERC20Response, error) {
response, err := k.Keeper.DenomToToken(c, &crosschaintypes.QueryDenomToTokenRequest{
ChainName: ethtypes.ModuleName,
Denom: req.Denom,
})
if err != nil {
return nil, err
}
return &types.QueryDenomToERC20Response{Erc20: response.Token, FxOriginated: req.Denom == fxtypes.DefaultDenom}, err
}
func (k queryServer) ERC20ToDenom(c context.Context, req *types.QueryERC20ToDenomRequest) (*types.QueryERC20ToDenomResponse, error) {
response, err := k.Keeper.TokenToDenom(c, &crosschaintypes.QueryTokenToDenomRequest{
ChainName: ethtypes.ModuleName,
Token: req.Erc20,
})
if err != nil {
return nil, err
}
return &types.QueryERC20ToDenomResponse{Denom: response.Denom, FxOriginated: response.Denom == fxtypes.DefaultDenom}, nil
}
func (k queryServer) GetDelegateKeyByValidator(c context.Context, req *types.QueryDelegateKeyByValidatorRequest) (*types.QueryDelegateKeyByValidatorResponse, error) {
response, err := k.Keeper.GetOracleByAddr(c, &crosschaintypes.QueryOracleByAddrRequest{
ChainName: ethtypes.ModuleName,
OracleAddress: req.ValidatorAddress,
})
if err != nil {
return nil, err
}
return &types.QueryDelegateKeyByValidatorResponse{
EthAddress: response.Oracle.ExternalAddress,
OrchestratorAddress: response.Oracle.BridgerAddress,
}, nil
}
func (k queryServer) GetDelegateKeyByOrchestrator(c context.Context, req *types.QueryDelegateKeyByOrchestratorRequest) (*types.QueryDelegateKeyByOrchestratorResponse, error) {
response, err := k.Keeper.GetOracleByBridgerAddr(c, &crosschaintypes.QueryOracleByBridgerAddrRequest{
ChainName: ethtypes.ModuleName,
BridgerAddress: req.OrchestratorAddress,
})
if err != nil {
return nil, err
}
return &types.QueryDelegateKeyByOrchestratorResponse{
ValidatorAddress: response.Oracle.OracleAddress,
EthAddress: response.Oracle.ExternalAddress,
}, nil
}
func (k queryServer) GetDelegateKeyByEth(c context.Context, req *types.QueryDelegateKeyByEthRequest) (*types.QueryDelegateKeyByEthResponse, error) {
response, err := k.Keeper.GetOracleByExternalAddr(c, &crosschaintypes.QueryOracleByExternalAddrRequest{
ChainName: ethtypes.ModuleName,
ExternalAddress: req.EthAddress,
})
if err != nil {
return nil, err
}
return &types.QueryDelegateKeyByEthResponse{
ValidatorAddress: response.Oracle.OracleAddress,
OrchestratorAddress: response.Oracle.BridgerAddress,
}, nil
}
func (k queryServer) GetPendingSendToEth(c context.Context, req *types.QueryPendingSendToEthRequest) (*types.QueryPendingSendToEthResponse, error) {
response, err := k.Keeper.GetPendingSendToExternal(c, &crosschaintypes.QueryPendingSendToExternalRequest{
ChainName: ethtypes.ModuleName,
SenderAddress: req.SenderAddress,
})
if err != nil {
return nil, err
}
res := &types.QueryPendingSendToEthResponse{
TransfersInBatches: make([]*types.OutgoingTransferTx, len(response.TransfersInBatches)),
UnbatchedTransfers: make([]*types.OutgoingTransferTx, len(response.UnbatchedTransfers)),
}
for i := 0; i < len(response.TransfersInBatches); i++ {
res.TransfersInBatches[i] = &types.OutgoingTransferTx{
Id: response.TransfersInBatches[i].Id,
Sender: response.TransfersInBatches[i].Sender,
DestAddress: response.TransfersInBatches[i].DestAddress,
Erc20Token: &types.ERC20Token{
Contract: response.TransfersInBatches[i].Token.Contract,
Amount: response.TransfersInBatches[i].Token.Amount,
},
Erc20Fee: &types.ERC20Token{
Contract: response.TransfersInBatches[i].Fee.Contract,
Amount: response.TransfersInBatches[i].Fee.Amount,
},
}
}
for i := 0; i < len(response.UnbatchedTransfers); i++ {
res.UnbatchedTransfers[i] = &types.OutgoingTransferTx{
Id: response.UnbatchedTransfers[i].Id,
Sender: response.UnbatchedTransfers[i].Sender,
DestAddress: response.UnbatchedTransfers[i].DestAddress,
Erc20Token: &types.ERC20Token{
Contract: response.UnbatchedTransfers[i].Token.Contract,
Amount: response.UnbatchedTransfers[i].Token.Amount,
},
Erc20Fee: &types.ERC20Token{
Contract: response.UnbatchedTransfers[i].Fee.Contract,
Amount: response.UnbatchedTransfers[i].Fee.Amount,
},
}
}
return res, nil
}
func (k queryServer) LastObservedBlockHeight(c context.Context, _ *types.QueryLastObservedBlockHeightRequest) (*types.QueryLastObservedBlockHeightResponse, error) {
response, err := k.Keeper.LastObservedBlockHeight(c, &crosschaintypes.QueryLastObservedBlockHeightRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
return &types.QueryLastObservedBlockHeightResponse{BlockHeight: response.BlockHeight, EthBlockHeight: response.ExternalBlockHeight}, nil
}
func (k queryServer) LastEventBlockHeightByAddr(c context.Context, req *types.QueryLastEventBlockHeightByAddrRequest) (*types.QueryLastEventBlockHeightByAddrResponse, error) {
response, err := k.Keeper.LastEventBlockHeightByAddr(c, &crosschaintypes.QueryLastEventBlockHeightByAddrRequest{
ChainName: ethtypes.ModuleName,
BridgerAddress: req.Address,
})
if err != nil {
return nil, err
}
return &types.QueryLastEventBlockHeightByAddrResponse{BlockHeight: response.BlockHeight}, nil
}
func (k queryServer) ProjectedBatchTimeoutHeight(c context.Context, _ *types.QueryProjectedBatchTimeoutHeightRequest) (*types.QueryProjectedBatchTimeoutHeightResponse, error) {
response, err := k.Keeper.ProjectedBatchTimeoutHeight(c, &crosschaintypes.QueryProjectedBatchTimeoutHeightRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
return &types.QueryProjectedBatchTimeoutHeightResponse{TimeoutHeight: response.TimeoutHeight}, nil
}
func (k queryServer) BridgeTokens(c context.Context, _ *types.QueryBridgeTokensRequest) (*types.QueryBridgeTokensResponse, error) {
response, err := k.Keeper.BridgeTokens(c, &crosschaintypes.QueryBridgeTokensRequest{ChainName: ethtypes.ModuleName})
if err != nil {
return nil, err
}
bridgeTokens := make([]*types.ERC20ToDenom, len(response.BridgeTokens))
for i := 0; i < len(response.BridgeTokens); i++ {
bridgeTokens[i] = &types.ERC20ToDenom{
Erc20: response.BridgeTokens[i].Token,
Denom: response.BridgeTokens[i].Denom,
}
}
return &types.QueryBridgeTokensResponse{BridgeTokens: bridgeTokens}, nil
}