1- package exchange
1+ package explorer
22
33import (
44 "context"
5- "fmt"
65
6+ log "github.com/InjectiveLabs/suplog"
7+ "github.com/pkg/errors"
8+ "google.golang.org/grpc"
79 "google.golang.org/grpc/credentials/insecure"
810
911 "github.com/InjectiveLabs/sdk-go/client/common"
1012 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"
1413)
1514
1615type ExplorerClient interface {
1716 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 )
2217 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 )
2327 GetPeggyDeposits (ctx context.Context , req * explorerPB.GetPeggyDepositTxsRequest ) (* explorerPB.GetPeggyDepositTxsResponse , error )
2428 GetPeggyWithdrawals (ctx context.Context , req * explorerPB.GetPeggyWithdrawalTxsRequest ) (* explorerPB.GetPeggyWithdrawalTxsResponse , error )
2529 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 )
2830 GetWasmCodes (ctx context.Context , req * explorerPB.GetWasmCodesRequest ) (* explorerPB.GetWasmCodesResponse , error )
2931 GetWasmCodeByID (ctx context.Context , req * explorerPB.GetWasmCodeByIDRequest ) (* explorerPB.GetWasmCodeByIDResponse , error )
3032 GetWasmContracts (ctx context.Context , req * explorerPB.GetWasmContractsRequest ) (* explorerPB.GetWasmContractsResponse , error )
3133 GetWasmContractByAddress (ctx context.Context , req * explorerPB.GetWasmContractByAddressRequest ) (* explorerPB.GetWasmContractByAddressResponse , error )
3234 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 )
3339 Close ()
3440}
3541
@@ -96,7 +102,6 @@ func (c *explorerClient) GetTxByTxHash(ctx context.Context, hash string) (*explo
96102 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetTxByTxHash , & req )
97103
98104 if err != nil {
99- fmt .Println (err )
100105 return & explorerPB.GetTxByTxHashResponse {}, err
101106 }
102107
@@ -107,7 +112,6 @@ func (c *explorerClient) GetAccountTxs(ctx context.Context, req *explorerPB.GetA
107112 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetAccountTxs , req )
108113
109114 if err != nil {
110- fmt .Println (err )
111115 return & explorerPB.GetAccountTxsResponse {}, err
112116 }
113117
@@ -120,7 +124,6 @@ func (c *explorerClient) GetBlocks(ctx context.Context) (*explorerPB.GetBlocksRe
120124 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetBlocks , & req )
121125
122126 if err != nil {
123- fmt .Println (err )
124127 return & explorerPB.GetBlocksResponse {}, err
125128 }
126129
@@ -135,18 +138,62 @@ func (c *explorerClient) GetBlock(ctx context.Context, blockHeight string) (*exp
135138 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetBlock , & req )
136139
137140 if err != nil {
138- fmt .Println (err )
139141 return & explorerPB.GetBlockResponse {}, err
140142 }
141143
142144 return res , nil
143145}
144146
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+
145193func (c * explorerClient ) GetTxs (ctx context.Context , req * explorerPB.GetTxsRequest ) (* explorerPB.GetTxsResponse , error ) {
146194 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetTxs , req )
147195
148196 if err != nil {
149- fmt .Println (err )
150197 return & explorerPB.GetTxsResponse {}, err
151198 }
152199
@@ -157,7 +204,6 @@ func (c *explorerClient) GetPeggyDeposits(ctx context.Context, req *explorerPB.G
157204 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetPeggyDepositTxs , req )
158205
159206 if err != nil {
160- fmt .Println (err )
161207 return & explorerPB.GetPeggyDepositTxsResponse {}, err
162208 }
163209
@@ -168,7 +214,6 @@ func (c *explorerClient) GetPeggyWithdrawals(ctx context.Context, req *explorerP
168214 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetPeggyWithdrawalTxs , req )
169215
170216 if err != nil {
171- fmt .Println (err )
172217 return & explorerPB.GetPeggyWithdrawalTxsResponse {}, err
173218 }
174219
@@ -179,7 +224,6 @@ func (c *explorerClient) GetIBCTransfers(ctx context.Context, req *explorerPB.Ge
179224 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetIBCTransferTxs , req )
180225
181226 if err != nil {
182- fmt .Println (err )
183227 return & explorerPB.GetIBCTransferTxsResponse {}, err
184228 }
185229
@@ -192,7 +236,6 @@ func (c *explorerClient) StreamTxs(ctx context.Context) (explorerPB.InjectiveExp
192236 stream , err := common .ExecuteStreamCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .StreamTxs , & req )
193237
194238 if err != nil {
195- fmt .Println (err )
196239 return nil , err
197240 }
198241
@@ -205,7 +248,6 @@ func (c *explorerClient) StreamBlocks(ctx context.Context) (explorerPB.Injective
205248 stream , err := common .ExecuteStreamCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .StreamBlocks , & req )
206249
207250 if err != nil {
208- fmt .Println (err )
209251 return nil , err
210252 }
211253
@@ -216,7 +258,6 @@ func (c *explorerClient) GetWasmCodes(ctx context.Context, req *explorerPB.GetWa
216258 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmCodes , req )
217259
218260 if err != nil {
219- fmt .Println (err )
220261 return & explorerPB.GetWasmCodesResponse {}, err
221262 }
222263
@@ -227,7 +268,6 @@ func (c *explorerClient) GetWasmCodeByID(ctx context.Context, req *explorerPB.Ge
227268 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmCodeByID , req )
228269
229270 if err != nil {
230- fmt .Println (err )
231271 return & explorerPB.GetWasmCodeByIDResponse {}, err
232272 }
233273
@@ -238,7 +278,6 @@ func (c *explorerClient) GetWasmContracts(ctx context.Context, req *explorerPB.G
238278 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmContracts , req )
239279
240280 if err != nil {
241- fmt .Println (err )
242281 return & explorerPB.GetWasmContractsResponse {}, err
243282 }
244283
@@ -249,7 +288,6 @@ func (c *explorerClient) GetWasmContractByAddress(ctx context.Context, req *expl
249288 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetWasmContractByAddress , req )
250289
251290 if err != nil {
252- fmt .Println (err )
253291 return & explorerPB.GetWasmContractByAddressResponse {}, err
254292 }
255293
@@ -260,13 +298,68 @@ func (c *explorerClient) GetCW20Balance(ctx context.Context, req *explorerPB.Get
260298 res , err := common .ExecuteCall (ctx , c .network .ExplorerCookieAssistant , c .explorerClient .GetCw20Balance , req )
261299
262300 if err != nil {
263- fmt .Println (err )
264301 return & explorerPB.GetCw20BalanceResponse {}, err
265302 }
266303
267304 return res , nil
268305}
269306
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+
270363func (c * explorerClient ) Close () {
271364 c .conn .Close ()
272365}
0 commit comments