1
- package exchange
1
+ package explorer
2
2
3
3
import (
4
4
"context"
5
- "fmt"
6
5
6
+ log "github.com/InjectiveLabs/suplog"
7
+ "github.com/pkg/errors"
8
+ "google.golang.org/grpc"
7
9
"google.golang.org/grpc/credentials/insecure"
8
10
9
11
"github.com/InjectiveLabs/sdk-go/client/common"
10
12
explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb"
11
- log "github.com/InjectiveLabs/suplog"
12
- "github.com/pkg/errors"
13
- "google.golang.org/grpc"
14
13
)
15
14
16
15
type ExplorerClient interface {
17
16
QueryClient () * grpc.ClientConn
18
- GetTxByTxHash (ctx context.Context , hash string ) (* explorerPB.GetTxByTxHashResponse , error )
19
- GetTxs (ctx context.Context , req * explorerPB.GetTxsRequest ) (* explorerPB.GetTxsResponse , error )
20
- GetBlock (ctx context.Context , blockHeight string ) (* explorerPB.GetBlockResponse , error )
21
- GetBlocks (ctx context.Context ) (* explorerPB.GetBlocksResponse , error )
22
17
GetAccountTxs (ctx context.Context , req * explorerPB.GetAccountTxsRequest ) (* explorerPB.GetAccountTxsResponse , error )
18
+ FetchContractTxs (ctx context.Context , req * explorerPB.GetContractTxsRequest ) (* explorerPB.GetContractTxsResponse , error )
19
+ FetchContractTxsV2 (ctx context.Context , req * explorerPB.GetContractTxsV2Request ) (* explorerPB.GetContractTxsV2Response , error )
20
+ GetBlocks (ctx context.Context ) (* explorerPB.GetBlocksResponse , error )
21
+ GetBlock (ctx context.Context , blockHeight string ) (* explorerPB.GetBlockResponse , error )
22
+ FetchValidators (ctx context.Context ) (* explorerPB.GetValidatorsResponse , error )
23
+ FetchValidator (ctx context.Context , address string ) (* explorerPB.GetValidatorResponse , error )
24
+ FetchValidatorUptime (ctx context.Context , address string ) (* explorerPB.GetValidatorUptimeResponse , error )
25
+ GetTxs (ctx context.Context , req * explorerPB.GetTxsRequest ) (* explorerPB.GetTxsResponse , error )
26
+ GetTxByTxHash (ctx context.Context , hash string ) (* explorerPB.GetTxByTxHashResponse , error )
23
27
GetPeggyDeposits (ctx context.Context , req * explorerPB.GetPeggyDepositTxsRequest ) (* explorerPB.GetPeggyDepositTxsResponse , error )
24
28
GetPeggyWithdrawals (ctx context.Context , req * explorerPB.GetPeggyWithdrawalTxsRequest ) (* explorerPB.GetPeggyWithdrawalTxsResponse , error )
25
29
GetIBCTransfers (ctx context.Context , req * explorerPB.GetIBCTransferTxsRequest ) (* explorerPB.GetIBCTransferTxsResponse , error )
26
- StreamTxs (ctx context.Context ) (explorerPB.InjectiveExplorerRPC_StreamTxsClient , error )
27
- StreamBlocks (ctx context.Context ) (explorerPB.InjectiveExplorerRPC_StreamBlocksClient , error )
28
30
GetWasmCodes (ctx context.Context , req * explorerPB.GetWasmCodesRequest ) (* explorerPB.GetWasmCodesResponse , error )
29
31
GetWasmCodeByID (ctx context.Context , req * explorerPB.GetWasmCodeByIDRequest ) (* explorerPB.GetWasmCodeByIDResponse , error )
30
32
GetWasmContracts (ctx context.Context , req * explorerPB.GetWasmContractsRequest ) (* explorerPB.GetWasmContractsResponse , error )
31
33
GetWasmContractByAddress (ctx context.Context , req * explorerPB.GetWasmContractByAddressRequest ) (* explorerPB.GetWasmContractByAddressResponse , error )
32
34
GetCW20Balance (ctx context.Context , req * explorerPB.GetCw20BalanceRequest ) (* explorerPB.GetCw20BalanceResponse , error )
35
+ FetchRelayers (ctx context.Context , marketIDs []string ) (* explorerPB.RelayersResponse , error )
36
+ FetchBankTransfers (ctx context.Context , req * explorerPB.GetBankTransfersRequest ) (* explorerPB.GetBankTransfersResponse , error )
37
+ StreamTxs (ctx context.Context ) (explorerPB.InjectiveExplorerRPC_StreamTxsClient , error )
38
+ StreamBlocks (ctx context.Context ) (explorerPB.InjectiveExplorerRPC_StreamBlocksClient , error )
33
39
Close ()
34
40
}
35
41
@@ -96,7 +102,6 @@ func (c *explorerClient) GetTxByTxHash(ctx context.Context, hash string) (*explo
96
102
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetTxByTxHash , & req )
97
103
98
104
if err != nil {
99
- fmt .Println (err )
100
105
return & explorerPB.GetTxByTxHashResponse {}, err
101
106
}
102
107
@@ -107,7 +112,6 @@ func (c *explorerClient) GetAccountTxs(ctx context.Context, req *explorerPB.GetA
107
112
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetAccountTxs , req )
108
113
109
114
if err != nil {
110
- fmt .Println (err )
111
115
return & explorerPB.GetAccountTxsResponse {}, err
112
116
}
113
117
@@ -120,7 +124,6 @@ func (c *explorerClient) GetBlocks(ctx context.Context) (*explorerPB.GetBlocksRe
120
124
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetBlocks , & req )
121
125
122
126
if err != nil {
123
- fmt .Println (err )
124
127
return & explorerPB.GetBlocksResponse {}, err
125
128
}
126
129
@@ -135,18 +138,62 @@ func (c *explorerClient) GetBlock(ctx context.Context, blockHeight string) (*exp
135
138
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetBlock , & req )
136
139
137
140
if err != nil {
138
- fmt .Println (err )
139
141
return & explorerPB.GetBlockResponse {}, err
140
142
}
141
143
142
144
return res , nil
143
145
}
144
146
147
+ func (c * explorerClient ) FetchValidators (ctx context.Context ) (* explorerPB.GetValidatorsResponse , error ) {
148
+ req := & explorerPB.GetValidatorsRequest {}
149
+
150
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetValidators , req )
151
+
152
+ if err != nil {
153
+ return & explorerPB.GetValidatorsResponse {}, err
154
+ }
155
+
156
+ return res , nil
157
+ }
158
+
159
+ func (c * explorerClient ) FetchValidator (
160
+ ctx context.Context ,
161
+ address string ,
162
+ ) (* explorerPB.GetValidatorResponse , error ) {
163
+ req := & explorerPB.GetValidatorRequest {
164
+ Address : address ,
165
+ }
166
+
167
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetValidator , req )
168
+
169
+ if err != nil {
170
+ return & explorerPB.GetValidatorResponse {}, err
171
+ }
172
+
173
+ return res , nil
174
+ }
175
+
176
+ func (c * explorerClient ) FetchValidatorUptime (
177
+ ctx context.Context ,
178
+ address string ,
179
+ ) (* explorerPB.GetValidatorUptimeResponse , error ) {
180
+ req := & explorerPB.GetValidatorUptimeRequest {
181
+ Address : address ,
182
+ }
183
+
184
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetValidatorUptime , req )
185
+
186
+ if err != nil {
187
+ return & explorerPB.GetValidatorUptimeResponse {}, err
188
+ }
189
+
190
+ return res , nil
191
+ }
192
+
145
193
func (c * explorerClient ) GetTxs (ctx context.Context , req * explorerPB.GetTxsRequest ) (* explorerPB.GetTxsResponse , error ) {
146
194
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetTxs , req )
147
195
148
196
if err != nil {
149
- fmt .Println (err )
150
197
return & explorerPB.GetTxsResponse {}, err
151
198
}
152
199
@@ -157,7 +204,6 @@ func (c *explorerClient) GetPeggyDeposits(ctx context.Context, req *explorerPB.G
157
204
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetPeggyDepositTxs , req )
158
205
159
206
if err != nil {
160
- fmt .Println (err )
161
207
return & explorerPB.GetPeggyDepositTxsResponse {}, err
162
208
}
163
209
@@ -168,7 +214,6 @@ func (c *explorerClient) GetPeggyWithdrawals(ctx context.Context, req *explorerP
168
214
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetPeggyWithdrawalTxs , req )
169
215
170
216
if err != nil {
171
- fmt .Println (err )
172
217
return & explorerPB.GetPeggyWithdrawalTxsResponse {}, err
173
218
}
174
219
@@ -179,7 +224,6 @@ func (c *explorerClient) GetIBCTransfers(ctx context.Context, req *explorerPB.Ge
179
224
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetIBCTransferTxs , req )
180
225
181
226
if err != nil {
182
- fmt .Println (err )
183
227
return & explorerPB.GetIBCTransferTxsResponse {}, err
184
228
}
185
229
@@ -192,7 +236,6 @@ func (c *explorerClient) StreamTxs(ctx context.Context) (explorerPB.InjectiveExp
192
236
stream , err := common .ExecuteStreamCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .StreamTxs , & req )
193
237
194
238
if err != nil {
195
- fmt .Println (err )
196
239
return nil , err
197
240
}
198
241
@@ -205,7 +248,6 @@ func (c *explorerClient) StreamBlocks(ctx context.Context) (explorerPB.Injective
205
248
stream , err := common .ExecuteStreamCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .StreamBlocks , & req )
206
249
207
250
if err != nil {
208
- fmt .Println (err )
209
251
return nil , err
210
252
}
211
253
@@ -216,7 +258,6 @@ func (c *explorerClient) GetWasmCodes(ctx context.Context, req *explorerPB.GetWa
216
258
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmCodes , req )
217
259
218
260
if err != nil {
219
- fmt .Println (err )
220
261
return & explorerPB.GetWasmCodesResponse {}, err
221
262
}
222
263
@@ -227,7 +268,6 @@ func (c *explorerClient) GetWasmCodeByID(ctx context.Context, req *explorerPB.Ge
227
268
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmCodeByID , req )
228
269
229
270
if err != nil {
230
- fmt .Println (err )
231
271
return & explorerPB.GetWasmCodeByIDResponse {}, err
232
272
}
233
273
@@ -238,7 +278,6 @@ func (c *explorerClient) GetWasmContracts(ctx context.Context, req *explorerPB.G
238
278
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmContracts , req )
239
279
240
280
if err != nil {
241
- fmt .Println (err )
242
281
return & explorerPB.GetWasmContractsResponse {}, err
243
282
}
244
283
@@ -249,7 +288,6 @@ func (c *explorerClient) GetWasmContractByAddress(ctx context.Context, req *expl
249
288
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmContractByAddress , req )
250
289
251
290
if err != nil {
252
- fmt .Println (err )
253
291
return & explorerPB.GetWasmContractByAddressResponse {}, err
254
292
}
255
293
@@ -260,13 +298,68 @@ func (c *explorerClient) GetCW20Balance(ctx context.Context, req *explorerPB.Get
260
298
res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetCw20Balance , req )
261
299
262
300
if err != nil {
263
- fmt .Println (err )
264
301
return & explorerPB.GetCw20BalanceResponse {}, err
265
302
}
266
303
267
304
return res , nil
268
305
}
269
306
307
+ func (c * explorerClient ) FetchContractTxs (
308
+ ctx context.Context ,
309
+ req * explorerPB.GetContractTxsRequest ,
310
+ ) (* explorerPB.GetContractTxsResponse , error ) {
311
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetContractTxs , req )
312
+
313
+ if err != nil {
314
+ return & explorerPB.GetContractTxsResponse {}, err
315
+ }
316
+
317
+ return res , nil
318
+ }
319
+
320
+ func (c * explorerClient ) FetchContractTxsV2 (
321
+ ctx context.Context ,
322
+ req * explorerPB.GetContractTxsV2Request ,
323
+ ) (* explorerPB.GetContractTxsV2Response , error ) {
324
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetContractTxsV2 , req )
325
+
326
+ if err != nil {
327
+ return & explorerPB.GetContractTxsV2Response {}, err
328
+ }
329
+
330
+ return res , nil
331
+ }
332
+
333
+ func (c * explorerClient ) FetchRelayers (
334
+ ctx context.Context ,
335
+ marketIDs []string ,
336
+ ) (* explorerPB.RelayersResponse , error ) {
337
+ req := & explorerPB.RelayersRequest {
338
+ MarketIDs : marketIDs ,
339
+ }
340
+
341
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .Relayers , req )
342
+
343
+ if err != nil {
344
+ return & explorerPB.RelayersResponse {}, err
345
+ }
346
+
347
+ return res , nil
348
+ }
349
+
350
+ func (c * explorerClient ) FetchBankTransfers (
351
+ ctx context.Context ,
352
+ req * explorerPB.GetBankTransfersRequest ,
353
+ ) (* explorerPB.GetBankTransfersResponse , error ) {
354
+ res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetBankTransfers , req )
355
+
356
+ if err != nil {
357
+ return & explorerPB.GetBankTransfersResponse {}, err
358
+ }
359
+
360
+ return res , nil
361
+ }
362
+
270
363
func (c * explorerClient ) Close () {
271
364
c .conn .Close ()
272
365
}
0 commit comments