You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/hooks/useScaffoldEventHistory.md
+69-1Lines changed: 69 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,9 @@ useScaffoldEventHistory({
87
87
});
88
88
```
89
89
90
-
Key Points to Consider
90
+
In this example, we added two filters. The hook will then send an RPC request to the target network with these filter parameters. The response will only include the events that match the filters. (setter is `0x00daC9BCF0bC21a9f3483D47A8Ade4764EE5c0377B3bCDDf2df477E3C1e55810` and event_type is `9987n`)
91
+
92
+
**Key Points to Consider**
91
93
92
94
1. Filter Keys: The keys in the `filters` object must correspond to event fields annotated with `#[key]`.
93
95
2. Filter Values: The value of a filter can be an array, meaning the event value can match any element in the array. For example:
@@ -120,3 +122,69 @@ struct GreetingChanged {
120
122
```
121
123
122
124
During serialization, keys are serialized in the order they are defined in the event. When applying filters, if new_greeting is not provided but bool_val and size_val are, these filter conditions will be ignored.
125
+
126
+
Then let's see a more complex example. the event defined with complex data type.
127
+
128
+
```rust
129
+
#[derive(Drop, starknet::Event)]
130
+
structGreetingChanged {
131
+
#[key]
132
+
greeting_setter:ContractAddress,
133
+
#[key]
134
+
new_greeting:ByteArray,
135
+
#[key]
136
+
event_type:u256,
137
+
premium:bool,
138
+
value:u256,
139
+
#[key]
140
+
addresses:Array<ContractAddress>,
141
+
arr:Array<u256>,
142
+
#[key]
143
+
tup: (u32, u64, bool, ContractAddress),
144
+
#[key]
145
+
st:SomeStruct,
146
+
#[key]
147
+
enum_val:SomeEnum,
148
+
#[key]
149
+
bool_val:bool,
150
+
}
151
+
```
152
+
153
+
If we want to add all the filters, the hook definition will be:
Please pay attention to how tuples, structs, and enum types are defined on the web side.
189
+
190
+
> There is a limitation on the filter count. The count here refers to the number of elements in the serialization result of the filter object. The maximum allowed count is 16.
0 commit comments