@slvr-labs/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +849 -0
  3. package/dist/connect.d.ts +47 -0
  4. package/dist/connect.d.ts.map +1 -0
  5. package/dist/connect.js +56 -0
  6. package/dist/connect.js.map +1 -0
  7. package/dist/contracts/autoCommit.d.ts +151 -0
  8. package/dist/contracts/autoCommit.d.ts.map +1 -0
  9. package/dist/contracts/autoCommit.js +426 -0
  10. package/dist/contracts/autoCommit.js.map +1 -0
  11. package/dist/contracts/hub.d.ts +50 -0
  12. package/dist/contracts/hub.d.ts.map +1 -0
  13. package/dist/contracts/hub.js +118 -0
  14. package/dist/contracts/hub.js.map +1 -0
  15. package/dist/contracts/index.d.ts +8 -0
  16. package/dist/contracts/index.d.ts.map +1 -0
  17. package/dist/contracts/index.js +18 -0
  18. package/dist/contracts/index.js.map +1 -0
  19. package/dist/contracts/jackpot.d.ts +21 -0
  20. package/dist/contracts/jackpot.d.ts.map +1 -0
  21. package/dist/contracts/jackpot.js +44 -0
  22. package/dist/contracts/jackpot.js.map +1 -0
  23. package/dist/contracts/lottery.d.ts +256 -0
  24. package/dist/contracts/lottery.d.ts.map +1 -0
  25. package/dist/contracts/lottery.js +767 -0
  26. package/dist/contracts/lottery.js.map +1 -0
  27. package/dist/contracts/registry.d.ts +53 -0
  28. package/dist/contracts/registry.d.ts.map +1 -0
  29. package/dist/contracts/registry.js +143 -0
  30. package/dist/contracts/registry.js.map +1 -0
  31. package/dist/contracts/staking.d.ts +101 -0
  32. package/dist/contracts/staking.d.ts.map +1 -0
  33. package/dist/contracts/staking.js +306 -0
  34. package/dist/contracts/staking.js.map +1 -0
  35. package/dist/contracts/token.d.ts +95 -0
  36. package/dist/contracts/token.d.ts.map +1 -0
  37. package/dist/contracts/token.js +273 -0
  38. package/dist/contracts/token.js.map +1 -0
  39. package/dist/deployments.d.ts +117 -0
  40. package/dist/deployments.d.ts.map +1 -0
  41. package/dist/deployments.js +74 -0
  42. package/dist/deployments.js.map +1 -0
  43. package/dist/errors.d.ts +39 -0
  44. package/dist/errors.d.ts.map +1 -0
  45. package/dist/errors.js +67 -0
  46. package/dist/errors.js.map +1 -0
  47. package/dist/ev.d.ts +123 -0
  48. package/dist/ev.d.ts.map +1 -0
  49. package/dist/ev.js +111 -0
  50. package/dist/ev.js.map +1 -0
  51. package/dist/events.d.ts +418 -0
  52. package/dist/events.d.ts.map +1 -0
  53. package/dist/events.js +87 -0
  54. package/dist/events.js.map +1 -0
  55. package/dist/index.d.ts +248 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +436 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/oracle.d.ts +48 -0
  60. package/dist/oracle.d.ts.map +1 -0
  61. package/dist/oracle.js +77 -0
  62. package/dist/oracle.js.map +1 -0
  63. package/dist/price.d.ts +52 -0
  64. package/dist/price.d.ts.map +1 -0
  65. package/dist/price.js +78 -0
  66. package/dist/price.js.map +1 -0
  67. package/dist/transaction.d.ts +54 -0
  68. package/dist/transaction.d.ts.map +1 -0
  69. package/dist/transaction.js +105 -0
  70. package/dist/transaction.js.map +1 -0
  71. package/dist/types.d.ts +162 -0
  72. package/dist/types.d.ts.map +1 -0
  73. package/dist/types.js +23 -0
  74. package/dist/types.js.map +1 -0
  75. package/dist/utils.d.ts +58 -0
  76. package/dist/utils.d.ts.map +1 -0
  77. package/dist/utils.js +110 -0
  78. package/dist/utils.js.map +1 -0
  79. package/examples/.env.example +22 -0
  80. package/examples/README.md +417 -0
  81. package/examples/automated-betting.ts +232 -0
  82. package/examples/combined-strategy.ts +227 -0
  83. package/examples/constants.ts +35 -0
  84. package/examples/custom-strategy-example.ts +231 -0
  85. package/examples/expected-value-strategy.ts +255 -0
  86. package/examples/fixed-squares-strategy.ts +176 -0
  87. package/examples/index.ts +30 -0
  88. package/examples/least-allocated-strategy.ts +224 -0
  89. package/examples/local-test.ts +172 -0
  90. package/examples/quickstart-bet.ts +72 -0
  91. package/examples/quickstart-read.ts +87 -0
  92. package/examples/simple-example.ts +122 -0
  93. package/examples/strategy-base.ts +283 -0
  94. package/package.json +71 -0
  95. package/skills/slvr-bot/SKILL.md +193 -0
  96. package/skills/slvr-bot/references/api.md +117 -0
@@ -0,0 +1,418 @@
1
+ import { Address, Log } from 'viem';
2
+ /**
3
+ * Event ABIs for Slvr contracts
4
+ */
5
+ export declare const SlvrGridLotteryEvents: readonly [{
6
+ readonly name: "BetPlaced";
7
+ readonly type: "event";
8
+ readonly inputs: readonly [{
9
+ readonly type: "uint256";
10
+ readonly name: "roundId";
11
+ readonly indexed: true;
12
+ }, {
13
+ readonly type: "address";
14
+ readonly name: "beneficiary";
15
+ readonly indexed: true;
16
+ }, {
17
+ readonly type: "uint256";
18
+ readonly name: "total";
19
+ }, {
20
+ readonly type: "uint8[]";
21
+ readonly name: "squares";
22
+ }];
23
+ }, {
24
+ readonly name: "Claimed";
25
+ readonly type: "event";
26
+ readonly inputs: readonly [{
27
+ readonly type: "uint256";
28
+ readonly name: "roundId";
29
+ readonly indexed: true;
30
+ }, {
31
+ readonly type: "address";
32
+ readonly name: "user";
33
+ readonly indexed: true;
34
+ }, {
35
+ readonly type: "uint256";
36
+ readonly name: "nativeOut";
37
+ }, {
38
+ readonly type: "uint256";
39
+ readonly name: "slvrOut";
40
+ }, {
41
+ readonly type: "uint256";
42
+ readonly name: "refinedOut";
43
+ }, {
44
+ readonly type: "uint256";
45
+ readonly name: "refiningFee";
46
+ }];
47
+ }, {
48
+ readonly name: "RoundResolved";
49
+ readonly type: "event";
50
+ readonly inputs: readonly [{
51
+ readonly type: "uint256";
52
+ readonly name: "roundId";
53
+ readonly indexed: true;
54
+ }, {
55
+ readonly type: "uint8";
56
+ readonly name: "winningSquare";
57
+ }, {
58
+ readonly type: "bool";
59
+ readonly name: "jackpotHit";
60
+ }, {
61
+ readonly type: "bool";
62
+ readonly name: "singleMinerRound";
63
+ }, {
64
+ readonly type: "address";
65
+ readonly name: "singleMinerWinner";
66
+ readonly indexed: true;
67
+ }, {
68
+ readonly type: "uint256";
69
+ readonly name: "winnerTotal";
70
+ }, {
71
+ readonly type: "uint256";
72
+ readonly name: "potForWinners";
73
+ }, {
74
+ readonly type: "uint256";
75
+ readonly name: "slvrForWinners";
76
+ }, {
77
+ readonly type: "uint256";
78
+ readonly name: "totalUnclaimedSlvr";
79
+ }];
80
+ }, {
81
+ readonly name: "RandomnessRequested";
82
+ readonly type: "event";
83
+ readonly inputs: readonly [{
84
+ readonly type: "uint256";
85
+ readonly name: "roundId";
86
+ readonly indexed: true;
87
+ }, {
88
+ readonly type: "bytes32";
89
+ readonly name: "randomnessId";
90
+ }];
91
+ }];
92
+ /**
93
+ * Events for the veNFT staker (`SlvrVoteEscrowStaking`). All staking events are
94
+ * keyed by the veNFT `tokenId`; there are no raw-ERC20-amount stake events.
95
+ */
96
+ export declare const SlvrStakingEvents: readonly [{
97
+ readonly name: "Staked";
98
+ readonly type: "event";
99
+ readonly inputs: readonly [{
100
+ readonly type: "uint256";
101
+ readonly name: "tokenId";
102
+ readonly indexed: true;
103
+ }, {
104
+ readonly type: "address";
105
+ readonly name: "user";
106
+ readonly indexed: true;
107
+ }, {
108
+ readonly type: "uint256";
109
+ readonly name: "weight";
110
+ }];
111
+ }, {
112
+ readonly name: "Unstaked";
113
+ readonly type: "event";
114
+ readonly inputs: readonly [{
115
+ readonly type: "uint256";
116
+ readonly name: "tokenId";
117
+ readonly indexed: true;
118
+ }, {
119
+ readonly type: "address";
120
+ readonly name: "user";
121
+ readonly indexed: true;
122
+ }, {
123
+ readonly type: "uint256";
124
+ readonly name: "weight";
125
+ }];
126
+ }, {
127
+ readonly name: "RewardClaimed";
128
+ readonly type: "event";
129
+ readonly inputs: readonly [{
130
+ readonly type: "uint256";
131
+ readonly name: "tokenId";
132
+ readonly indexed: true;
133
+ }, {
134
+ readonly type: "address";
135
+ readonly name: "user";
136
+ readonly indexed: true;
137
+ }, {
138
+ readonly type: "uint256";
139
+ readonly name: "amount";
140
+ }];
141
+ }, {
142
+ readonly name: "RewardDistributed";
143
+ readonly type: "event";
144
+ readonly inputs: readonly [{
145
+ readonly type: "uint256";
146
+ readonly name: "amount";
147
+ }];
148
+ }, {
149
+ readonly name: "Checkpoint";
150
+ readonly type: "event";
151
+ readonly inputs: readonly [{
152
+ readonly type: "uint256";
153
+ readonly name: "tokenId";
154
+ readonly indexed: true;
155
+ }, {
156
+ readonly type: "uint256";
157
+ readonly name: "oldWeight";
158
+ }, {
159
+ readonly type: "uint256";
160
+ readonly name: "newWeight";
161
+ }];
162
+ }, {
163
+ readonly name: "RewardsSettledOnBurn";
164
+ readonly type: "event";
165
+ readonly inputs: readonly [{
166
+ readonly type: "uint256";
167
+ readonly name: "tokenId";
168
+ readonly indexed: true;
169
+ }, {
170
+ readonly type: "address";
171
+ readonly name: "owner";
172
+ readonly indexed: true;
173
+ }, {
174
+ readonly type: "uint256";
175
+ readonly name: "amount";
176
+ }];
177
+ }, {
178
+ readonly name: "PendingRewardsClaimed";
179
+ readonly type: "event";
180
+ readonly inputs: readonly [{
181
+ readonly type: "address";
182
+ readonly name: "user";
183
+ readonly indexed: true;
184
+ }, {
185
+ readonly type: "uint256";
186
+ readonly name: "amount";
187
+ }];
188
+ }];
189
+ export declare const SlvrTokenEvents: readonly [{
190
+ readonly name: "Transfer";
191
+ readonly type: "event";
192
+ readonly inputs: readonly [{
193
+ readonly type: "address";
194
+ readonly name: "from";
195
+ readonly indexed: true;
196
+ }, {
197
+ readonly type: "address";
198
+ readonly name: "to";
199
+ readonly indexed: true;
200
+ }, {
201
+ readonly type: "uint256";
202
+ readonly name: "value";
203
+ }];
204
+ }, {
205
+ readonly name: "Approval";
206
+ readonly type: "event";
207
+ readonly inputs: readonly [{
208
+ readonly type: "address";
209
+ readonly name: "owner";
210
+ readonly indexed: true;
211
+ }, {
212
+ readonly type: "address";
213
+ readonly name: "spender";
214
+ readonly indexed: true;
215
+ }, {
216
+ readonly type: "uint256";
217
+ readonly name: "value";
218
+ }];
219
+ }];
220
+ export declare const SlvrAutoCommitEvents: readonly [{
221
+ readonly name: "PlanConfigured";
222
+ readonly type: "event";
223
+ readonly inputs: readonly [{
224
+ readonly type: "address";
225
+ readonly name: "user";
226
+ readonly indexed: true;
227
+ }, {
228
+ readonly type: "uint256";
229
+ readonly name: "nextRoundId";
230
+ }, {
231
+ readonly type: "uint32";
232
+ readonly name: "plays";
233
+ }, {
234
+ readonly type: "uint256";
235
+ readonly name: "amountPerPlay";
236
+ }, {
237
+ readonly type: "bool";
238
+ readonly name: "autoClaim";
239
+ }];
240
+ }, {
241
+ readonly name: "PlanDisabled";
242
+ readonly type: "event";
243
+ readonly inputs: readonly [{
244
+ readonly type: "address";
245
+ readonly name: "user";
246
+ readonly indexed: true;
247
+ }];
248
+ }, {
249
+ readonly name: "PlanCancelled";
250
+ readonly type: "event";
251
+ readonly inputs: readonly [{
252
+ readonly type: "address";
253
+ readonly name: "user";
254
+ readonly indexed: true;
255
+ }, {
256
+ readonly type: "uint256";
257
+ readonly name: "refundAmount";
258
+ }];
259
+ }, {
260
+ readonly name: "Deposited";
261
+ readonly type: "event";
262
+ readonly inputs: readonly [{
263
+ readonly type: "address";
264
+ readonly name: "user";
265
+ readonly indexed: true;
266
+ }, {
267
+ readonly type: "uint256";
268
+ readonly name: "amount";
269
+ }];
270
+ }, {
271
+ readonly name: "Withdrawn";
272
+ readonly type: "event";
273
+ readonly inputs: readonly [{
274
+ readonly type: "address";
275
+ readonly name: "user";
276
+ readonly indexed: true;
277
+ }, {
278
+ readonly type: "uint256";
279
+ readonly name: "amount";
280
+ }, {
281
+ readonly type: "address";
282
+ readonly name: "to";
283
+ }];
284
+ }, {
285
+ readonly name: "RoundExecuted";
286
+ readonly type: "event";
287
+ readonly inputs: readonly [{
288
+ readonly type: "address";
289
+ readonly name: "user";
290
+ readonly indexed: true;
291
+ }, {
292
+ readonly type: "uint256";
293
+ readonly name: "roundId";
294
+ readonly indexed: true;
295
+ }, {
296
+ readonly type: "uint32";
297
+ readonly name: "playsRemaining";
298
+ }];
299
+ }, {
300
+ readonly name: "Claimed";
301
+ readonly type: "event";
302
+ readonly inputs: readonly [{
303
+ readonly type: "address";
304
+ readonly name: "user";
305
+ readonly indexed: true;
306
+ }, {
307
+ readonly type: "uint256";
308
+ readonly name: "roundId";
309
+ readonly indexed: true;
310
+ }, {
311
+ readonly type: "uint256";
312
+ readonly name: "nativeAmount";
313
+ }, {
314
+ readonly type: "uint256";
315
+ readonly name: "addedToBalance";
316
+ }];
317
+ }, {
318
+ readonly name: "BalanceUpdated";
319
+ readonly type: "event";
320
+ readonly inputs: readonly [{
321
+ readonly type: "address";
322
+ readonly name: "user";
323
+ readonly indexed: true;
324
+ }, {
325
+ readonly type: "uint256";
326
+ readonly name: "newBalance";
327
+ }, {
328
+ readonly type: "uint256";
329
+ readonly name: "amountAdded";
330
+ }];
331
+ }, {
332
+ readonly name: "ExecutorFeePaid";
333
+ readonly type: "event";
334
+ readonly inputs: readonly [{
335
+ readonly type: "address";
336
+ readonly name: "user";
337
+ readonly indexed: true;
338
+ }, {
339
+ readonly type: "address";
340
+ readonly name: "executor";
341
+ readonly indexed: true;
342
+ }, {
343
+ readonly type: "uint256";
344
+ readonly name: "fee";
345
+ }, {
346
+ readonly type: "uint256";
347
+ readonly name: "gasUsed";
348
+ }];
349
+ }];
350
+ /**
351
+ * Decode a log using the provided ABI
352
+ * @param abi Contract ABI
353
+ * @param log Log to decode
354
+ * @returns Decoded event or null if decoding fails
355
+ */
356
+ export declare function decodeEvent<T = unknown>(abi: readonly unknown[], log: Log): T | null;
357
+ /**
358
+ * Filter and decode events from logs
359
+ * @param abi Contract ABI
360
+ * @param logs Array of logs
361
+ * @param eventName Optional event name to filter by
362
+ * @returns Array of decoded events
363
+ */
364
+ export declare function decodeEvents<T = unknown>(abi: readonly unknown[], logs: Log[], eventName?: string): T[];
365
+ /**
366
+ * BetPlaced event data
367
+ */
368
+ export interface BetPlacedEvent {
369
+ eventName: 'BetPlaced';
370
+ args: {
371
+ roundId: bigint;
372
+ beneficiary: Address;
373
+ total: bigint;
374
+ squares: readonly number[];
375
+ };
376
+ }
377
+ /**
378
+ * Claimed event data
379
+ */
380
+ export interface ClaimedEvent {
381
+ eventName: 'Claimed';
382
+ args: {
383
+ roundId: bigint;
384
+ user: Address;
385
+ nativeOut: bigint;
386
+ slvrOut: bigint;
387
+ refinedOut: bigint;
388
+ refiningFee: bigint;
389
+ };
390
+ }
391
+ /**
392
+ * Round resolved event data
393
+ */
394
+ export interface RoundResolvedEvent {
395
+ eventName: 'RoundResolved';
396
+ args: {
397
+ roundId: bigint;
398
+ winningSquare: number;
399
+ jackpotHit: boolean;
400
+ singleMinerRound: boolean;
401
+ singleMinerWinner: Address;
402
+ winnerTotal: bigint;
403
+ potForWinners: bigint;
404
+ slvrForWinners: bigint;
405
+ totalUnclaimedSlvr: bigint;
406
+ };
407
+ }
408
+ /**
409
+ * RandomnessRequested event data
410
+ */
411
+ export interface RandomnessRequestedEvent {
412
+ eventName: 'RandomnessRequested';
413
+ args: {
414
+ roundId: bigint;
415
+ randomnessId: `0x${string}`;
416
+ };
417
+ }
418
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,GAAG,EAAE,MAAM,MAAM,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,OAAO,CAAC;QACpB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,qBAAqB,CAAC;IACjC,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;KAC7B,CAAC;CACH"}
package/dist/events.js ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlvrAutoCommitEvents = exports.SlvrTokenEvents = exports.SlvrStakingEvents = exports.SlvrGridLotteryEvents = void 0;
4
+ exports.decodeEvent = decodeEvent;
5
+ exports.decodeEvents = decodeEvents;
6
+ const viem_1 = require("viem");
7
+ /**
8
+ * Event ABIs for Slvr contracts
9
+ */
10
+ exports.SlvrGridLotteryEvents = (0, viem_1.parseAbi)([
11
+ 'event BetPlaced(uint256 indexed roundId, address indexed beneficiary, uint256 total, uint8[] squares)',
12
+ 'event Claimed(uint256 indexed roundId, address indexed user, uint256 nativeOut, uint256 slvrOut, uint256 refinedOut, uint256 refiningFee)',
13
+ 'event RoundResolved(uint256 indexed roundId, uint8 winningSquare, bool jackpotHit, bool singleMinerRound, address indexed singleMinerWinner, uint256 winnerTotal, uint256 potForWinners, uint256 slvrForWinners, uint256 totalUnclaimedSlvr)',
14
+ 'event RandomnessRequested(uint256 indexed roundId, bytes32 randomnessId)',
15
+ ]);
16
+ /**
17
+ * Events for the veNFT staker (`SlvrVoteEscrowStaking`). All staking events are
18
+ * keyed by the veNFT `tokenId`; there are no raw-ERC20-amount stake events.
19
+ */
20
+ exports.SlvrStakingEvents = (0, viem_1.parseAbi)([
21
+ 'event Staked(uint256 indexed tokenId, address indexed user, uint256 weight)',
22
+ 'event Unstaked(uint256 indexed tokenId, address indexed user, uint256 weight)',
23
+ 'event RewardClaimed(uint256 indexed tokenId, address indexed user, uint256 amount)',
24
+ 'event RewardDistributed(uint256 amount)',
25
+ 'event Checkpoint(uint256 indexed tokenId, uint256 oldWeight, uint256 newWeight)',
26
+ 'event RewardsSettledOnBurn(uint256 indexed tokenId, address indexed owner, uint256 amount)',
27
+ 'event PendingRewardsClaimed(address indexed user, uint256 amount)',
28
+ ]);
29
+ exports.SlvrTokenEvents = (0, viem_1.parseAbi)([
30
+ 'event Transfer(address indexed from, address indexed to, uint256 value)',
31
+ 'event Approval(address indexed owner, address indexed spender, uint256 value)',
32
+ ]);
33
+ exports.SlvrAutoCommitEvents = (0, viem_1.parseAbi)([
34
+ 'event PlanConfigured(address indexed user, uint256 nextRoundId, uint32 plays, uint256 amountPerPlay, bool autoClaim)',
35
+ 'event PlanDisabled(address indexed user)',
36
+ 'event PlanCancelled(address indexed user, uint256 refundAmount)',
37
+ 'event Deposited(address indexed user, uint256 amount)',
38
+ 'event Withdrawn(address indexed user, uint256 amount, address to)',
39
+ 'event RoundExecuted(address indexed user, uint256 indexed roundId, uint32 playsRemaining)',
40
+ 'event Claimed(address indexed user, uint256 indexed roundId, uint256 nativeAmount, uint256 addedToBalance)',
41
+ 'event BalanceUpdated(address indexed user, uint256 newBalance, uint256 amountAdded)',
42
+ 'event ExecutorFeePaid(address indexed user, address indexed executor, uint256 fee, uint256 gasUsed)',
43
+ ]);
44
+ /**
45
+ * Decode a log using the provided ABI
46
+ * @param abi Contract ABI
47
+ * @param log Log to decode
48
+ * @returns Decoded event or null if decoding fails
49
+ */
50
+ function decodeEvent(abi, log) {
51
+ try {
52
+ const decoded = (0, viem_1.decodeEventLog)({
53
+ abi,
54
+ data: log.data,
55
+ topics: log.topics,
56
+ });
57
+ return decoded;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
63
+ /**
64
+ * Filter and decode events from logs
65
+ * @param abi Contract ABI
66
+ * @param logs Array of logs
67
+ * @param eventName Optional event name to filter by
68
+ * @returns Array of decoded events
69
+ */
70
+ function decodeEvents(abi, logs, eventName) {
71
+ const decoded = [];
72
+ for (const log of logs) {
73
+ try {
74
+ const decodedEvent = decodeEvent(abi, log);
75
+ if (decodedEvent) {
76
+ if (!eventName || decodedEvent.eventName === eventName) {
77
+ decoded.push(decodedEvent);
78
+ }
79
+ }
80
+ }
81
+ catch {
82
+ // Skip invalid logs
83
+ }
84
+ }
85
+ return decoded;
86
+ }
87
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAiDA,kCAWC;AASD,oCAqBC;AA1FD,+BAA8D;AAE9D;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,eAAQ,EAAC;IAC5C,uGAAuG;IACvG,2IAA2I;IAC3I,8OAA8O;IAC9O,0EAA0E;CAC3E,CAAC,CAAC;AAEH;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,eAAQ,EAAC;IACxC,6EAA6E;IAC7E,+EAA+E;IAC/E,oFAAoF;IACpF,yCAAyC;IACzC,iFAAiF;IACjF,4FAA4F;IAC5F,mEAAmE;CACpE,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,IAAA,eAAQ,EAAC;IACtC,yEAAyE;IACzE,+EAA+E;CAChF,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,IAAA,eAAQ,EAAC;IAC3C,sHAAsH;IACtH,0CAA0C;IAC1C,iEAAiE;IACjE,uDAAuD;IACvD,mEAAmE;IACnE,2FAA2F;IAC3F,4GAA4G;IAC5G,qFAAqF;IACrF,qGAAqG;CACtG,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,WAAW,CAAc,GAAuB,EAAE,GAAQ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