@@ -3,13 +3,12 @@ import { EventFilter } from "./filter";
33
44import { type Abi , EventAbi , hash } from "starknet" ;
55
6- // The Contract class implements the EventFilterParser interface.
6+ /** Build a stream filter from a contract ABI. */
77export class Contract {
88 // Read-only properties for the contract's address and its ABI.
99 readonly contractAddress : FieldElement ;
1010 readonly contractAbi : Abi ;
1111
12- // Constructor to initialize a Contract instance with a contract address and ABI.
1312 constructor ( contractAddress : FieldElement , contractAbi : Abi ) {
1413 this . contractAddress = contractAddress ;
1514 this . contractAbi = contractAbi ;
@@ -24,8 +23,14 @@ export class Contract {
2423 return event ;
2524 }
2625
27- // Method to filter events based on their name from the contract's ABI.
28- eventFilter ( name : string ) : EventFilter {
26+ /** Filter events based on their name from the contract's ABI. */
27+ eventFilter (
28+ name : string ,
29+ opts : Pick <
30+ EventFilter ,
31+ "includeReceipt" | "includeTransaction" | "includeReverted"
32+ > = { } ,
33+ ) : EventFilter {
2934 const event = this . _findEvent ( name ) ;
3035
3136 // Throw an error if the event is not found in the ABI
@@ -37,8 +42,9 @@ export class Contract {
3742 return {
3843 fromAddress : this . contractAddress ,
3944 keys : [ hash . getSelectorFromName ( event . name ) as `0x${string } `] ,
40- includeTransaction : false ,
41- includeReceipt : false ,
45+ includeTransaction : opts . includeTransaction ?? false ,
46+ includeReceipt : opts . includeReceipt ?? false ,
47+ includeReverted : opts . includeReverted ?? false ,
4248 } ;
4349 }
4450}
0 commit comments