File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ use base64:: { engine:: general_purpose, Engine as _} ;
2
+ use cosmrs:: {
3
+ proto:: cosmos:: bank:: v1beta1:: { QueryAllBalancesRequest , QueryAllBalancesResponse } ,
4
+ rpc:: { endpoint:: abci_query, Client , HttpClient } ,
5
+ tx:: MessageExt ,
6
+ } ;
7
+ use hex:: encode;
8
+ use prost:: Message ;
9
+ use tokio:: runtime:: Runtime ;
10
+
11
+ #[ test]
12
+ fn temp_test ( ) {
13
+ // Necessary variable for querying
14
+ let rt = Runtime :: new ( ) . unwrap ( ) ;
15
+ let client = HttpClient :: new ( "https://rpc.osmosis.zone" ) . unwrap ( ) ;
16
+
17
+ // Query content
18
+ let address = "osmo126pr9qp44aft4juw7x4ev4s2qdtnwe38jzwunec9pxt5cpzaaphqyagqpu" . to_string ( ) ;
19
+ let request = QueryAllBalancesRequest {
20
+ address,
21
+ pagination : None ,
22
+ } ;
23
+ let any = request. to_bytes ( ) . unwrap ( ) ;
24
+
25
+ // Querying
26
+ let response = rt
27
+ . block_on ( client. abci_query (
28
+ Some ( "/cosmos.bank.v1beta1.Query/AllBalances" . to_string ( ) ) ,
29
+ any,
30
+ None ,
31
+ true ,
32
+ ) )
33
+ . unwrap ( ) ;
34
+
35
+ // Analysing the response
36
+ let balance_response = QueryAllBalancesResponse :: decode ( response. value . as_slice ( ) ) . unwrap ( ) ;
37
+
38
+ // Printing the response
39
+ panic ! ( "{:?}" , response) ;
40
+ }
You can’t perform that action at this time.
0 commit comments