Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 54dd289

Browse files
committed
improve readibility
1 parent 187724f commit 54dd289

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

docs/hooks/useScaffoldEventHistory.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This example configures the hook to read events from the `YourEvent` event of th
4646

4747
Filters can only be applied to event keys, which are event fields annotated with `#[key]`. For example, consider an event defined in a contract as follows:
4848

49-
```cairo
49+
```rust
5050
#[derive(Drop, starknet::Event)]
5151
struct GreetingChanged {
5252
#[key]
@@ -59,31 +59,30 @@ struct GreetingChanged {
5959

6060
The event data will include a `keys` array:
6161

62-
```
62+
```javascript
6363
[
64+
// The first element is the hash of the event name.
6465
"0x30a5b63b12d63c3c34bd7145a56f903aa6e641b727d42ff159af4372c62e008",
66+
// The second element is the serialized result of the first key `setter`.
6567
"0x65dc4a1c484bcde864e7eebc55f033f2baf57dc6e2f4eae14c6860836cfcd0e",
68+
// The third and fourth elements are the serialized results of the second key `event_type`.
6669
"0x2703",
6770
"0x0",
68-
]
71+
];
6972
```
7073

71-
- The first element is the hash of the event name.
72-
- The second element is the serialized result of the first key `setter`.
73-
- The third and fourth elements are the serialized results of the second key `event_type`.
74-
7574
> For serialization reference, see: https://docs.starknet.io/architecture-and-concepts/smart-contracts/serialization-of-cairo-types/#additional_resources
7675
7776
Here is an example of how to use `filters`, where the key corresponds to the event variable name:
7877

79-
```
78+
```javascript
8079
useScaffoldEventHistory({
8180
contractName: "YourContract",
8281
eventName: "contracts::YourContract::YourContract::GreetingChanged",
8382
fromBlock: 0n,
8483
filters: {
8584
setter: "0x00daC9BCF0bC21a9f3483D47A8Ade4764EE5c0377B3bCDDf2df477E3C1e55810",
86-
event_type: 9987n
85+
event_type: 9987n,
8786
},
8887
});
8988
```
@@ -93,18 +92,18 @@ Key Points to Consider
9392
1. Filter Keys: The keys in the `filters` object must correspond to event fields annotated with `#[key]`.
9493
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:
9594

96-
```
95+
```javascript
9796
{
9897
setter: [
9998
"0x00daC9BCF0bC21a9f3483D47A8Ade4764EE5c0377B3bCDDf2df477E3C1e55810",
10099
"0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
101-
]
100+
];
102101
}
103102
```
104103

105104
3. Handling Variable-Length Event Keys: For events with variable-length keys annotated with #[key], such as new_greeting in the GreetingChanged event:
106105

107-
```
106+
```rust
108107
#[derive(Drop, starknet::Event)]
109108
struct GreetingChanged {
110109
#[key]

0 commit comments

Comments
 (0)