File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,16 @@ pub(crate) enum Subcommand {
7979 #[ clap( long) ]
8080 page : Option < u64 > ,
8181 } ,
82+ /// List transactions against a given contract
83+ ListContractTxs {
84+ contract : Address ,
85+ /// Maximum number of transactions to return
86+ #[ clap( long) ]
87+ limit : Option < u64 > ,
88+ /// Page
89+ #[ clap( long) ]
90+ page : Option < u64 > ,
91+ } ,
8292 /// Perform a query for transactions
8393 QueryTxs {
8494 query : String ,
@@ -235,6 +245,19 @@ pub(crate) async fn go(Opt { sub }: Opt, opt: crate::cli::Opt) -> Result<()> {
235245 println ! ( "{txhash}" ) ;
236246 }
237247 }
248+ Subcommand :: ListContractTxs {
249+ contract,
250+ limit,
251+ page,
252+ } => {
253+ let cosmos = opt. network_opt . build ( ) . await ?;
254+ for txhash in cosmos
255+ . list_contract_transactions ( contract, limit, page)
256+ . await ?
257+ {
258+ println ! ( "{txhash}" ) ;
259+ }
260+ }
238261 Subcommand :: QueryTxs {
239262 query,
240263 limit,
Original file line number Diff line number Diff line change @@ -1108,6 +1108,36 @@ impl Cosmos {
11081108 } )
11091109 }
11101110
1111+ /// Get a list of txhashes for transactions against the given contract.
1112+ pub async fn list_contract_transactions (
1113+ & self ,
1114+ address : Address ,
1115+ limit : Option < u64 > ,
1116+ page : Option < u64 > ,
1117+ ) -> Result < Vec < String > , QueryError > {
1118+ // The pagination field within this struct is
1119+ // deprecated. https://docs.rs/cosmos-sdk-proto/0.21.1/cosmos_sdk_proto/cosmos/tx/v1beta1/struct.GetTxsEventRequest.html#structfield.pagination
1120+ #[ allow( deprecated) ]
1121+ let req = GetTxsEventRequest {
1122+ events : vec ! [ ] ,
1123+ pagination : None ,
1124+ order_by : OrderBy :: Asc as i32 ,
1125+ page : page. unwrap_or ( 1 ) ,
1126+ limit : limit. unwrap_or ( 10 ) ,
1127+ query : format ! ( "execute._contract_address='{address}'" ) ,
1128+ } ;
1129+ self . perform_query ( req, Action :: ListTransactionsFor ( address) )
1130+ . run ( )
1131+ . await
1132+ . map ( |x| {
1133+ x. into_inner ( )
1134+ . tx_responses
1135+ . into_iter ( )
1136+ . map ( |x| x. txhash )
1137+ . collect ( )
1138+ } )
1139+ }
1140+
11111141 /// Get transactions meeting the given query.
11121142 pub async fn query_transactions (
11131143 & self ,
You can’t perform that action at this time.
0 commit comments