-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
136 lines (123 loc) · 3.42 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { appendFile } from "node:fs";
export const config = {
streamUrl: "https://mainnet.starknet.a5a.ch",
startingBlock: 456282,
network: "starknet",
finality: "DATA_STATUS_ACCEPTED",
filter: {
events: [
{
fromAddress:
"0x03d25473be5a6316f351e8f964d0c303357c006f7107779f648d9879b7c6d58a",
keys: [
"0x9149d2123147c5f43d258257fef0b7b969db78269369ebcf5ebb9eef8592f2",
],
},
{
fromAddress:
"0x00426d4e86913759bcc49b7f992b1fe62e6571e8f8089c23d95fea815dbad471",
keys: [
"0x9149d2123147c5f43d258257fef0b7b969db78269369ebcf5ebb9eef8592f2",
],
},
{
fromAddress:
"0x03afe61732ed9b226309775ac4705129319729d3bee81da5632146ffd72652ae",
keys: [
"0x9149d2123147c5f43d258257fef0b7b969db78269369ebcf5ebb9eef8592f2",
],
},
{
fromAddress:
"0x0324b531f731100b494e2f978a26b20b5870585dd96d9f1166b43a28ebbb8aba",
keys: [
"0x9149d2123147c5f43d258257fef0b7b969db78269369ebcf5ebb9eef8592f2",
],
},
{
fromAddress:
"0x022f40128af9798a0b734874fd993bbab6cf75845f26f844cb151b7041132c6d",
keys: [
"0x9149d2123147c5f43d258257fef0b7b969db78269369ebcf5ebb9eef8592f2",
],
},
{
fromAddress:
"0x04258037980fcc15083cde324abe1861ac00d4d48b7d60d76b5efd6f57e59e73",
keys: [
"0x9149d2123147c5f43d258257fef0b7b969db78269369ebcf5ebb9eef8592f2",
],
},
],
},
sinkType: "console",
};
let fct_map = {
"0x034e55c1cd55f1338241b50d352f0e91c7e4ffad0e4271d64eb347589ebdfd16": "mint",
"0x0099cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9":
"transfer",
};
// This transform does nothing.
export default async function transform(block: BlockData) {
const ret = block.events.forEach((x) => {
const depositer = x.event.data[0];
const yielder = x.event.fromAddress;
appendFile(`yielder_depositers/${yielder}.txt`, depositer + "\n", (err) => {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
});
return ret;
}
// Define the top-level interface for the entire array
interface BlockData {
status: string;
events: Event[];
}
// Define the interface for each event in the events array
interface Event {
transaction: Transaction;
event: EventDetails;
}
// Define the interface for the transaction object
interface Transaction {
meta: TransactionMeta;
invokeV3: InvokeV3;
}
// Define the interface for the transaction metadata
interface TransactionMeta {
hash: string;
signature: string[];
nonce: string;
version: string;
resourceBounds: ResourceBounds;
nonceDataAvailabilityMode: string;
feeDataAvailabilityMode: string;
transactionIndex: string;
}
// Define the interface for resource bounds within the metadata
interface ResourceBounds {
l1Gas: Gas;
l2Gas: Gas;
}
// Define the interface for gas details
interface Gas {
maxAmount?: string; // Optional because l2Gas.maxPricePerUnit is empty
maxPricePerUnit?: PricePerUnit;
}
// Define the interface for price per unit
interface PricePerUnit {
high: string;
}
// Define the interface for invokeV3
interface InvokeV3 {
senderAddress: string;
calldata: string[];
}
// Define the interface for event details
interface EventDetails {
fromAddress: string;
keys: string[];
data: string[];
index: string;
}