@glowlabs-org/events-sdk 1.0.0 → 1.0.2

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.
package/README.md CHANGED
@@ -24,8 +24,8 @@ The following zones are currently available:
24
24
  | 1 | Clean Grid Project |
25
25
  | 2 | Coming Soon Zone |
26
26
 
27
- - Use `zoneId: 0` (with `zoneName: "All Zones"`) to emit to or listen to all zones.
28
- - The SDK types and runtime validation now officially support `zoneId: 0` and `zoneName: "All Zones"` everywhere (emitter, listener, event types).
27
+ - Use `zoneId: 0` (with `zoneName: "All Zones"`) to listen to all zones. **Emitters must be constructed with a specific zoneId (not 0).**
28
+ - The SDK types and runtime validation now officially support `zoneId: 0` and `zoneName: "All Zones"` everywhere for listeners, but not for emitters.
29
29
 
30
30
  ---
31
31
 
@@ -33,11 +33,13 @@ The following zones are currently available:
33
33
 
34
34
  Currently supported event types and versions:
35
35
 
36
- | Event Name | Version | Payload Type | Description |
37
- | ------------------ | ------- | ------------------------- | ----------------------------------- |
38
- | `audit.pushed` | 1 | `AuditPushedV1Payload` | Emitted when an audit is pushed |
39
- | `audit.slashed` | 1 | `AuditSlashedV1Payload` | Emitted when a farm is slashed |
40
- | `audit.pfees.paid` | 1 | `AuditPfeesPaidV1Payload` | Emitted when protocol fees are paid |
36
+ | Event Name | Version | Payload Type | Description |
37
+ | --------------------- | ------- | ----------------------------- | -------------------------------------- |
38
+ | `audit.pushed` | 1 | `AuditPushedV1Payload` | Emitted when an audit is pushed |
39
+ | `audit.slashed` | 1 | `AuditSlashedV1Payload` | Emitted when a farm is slashed |
40
+ | `audit.pfees.paid` | 1 | `AuditPfeesPaidV1Payload` | Paid (by applicationId) |
41
+ | `audit.pfees.paid` | 2 | `AuditPfeesPaidV2Payload` | Paid (by farmId) |
42
+ | `application.created` | 1 | `ApplicationCreatedV1Payload` | Emitted when an application is created |
41
43
 
42
44
  ---
43
45
 
@@ -50,6 +52,7 @@ export interface AuditPushedV1Payload {
50
52
  farmId: string; // bytes32 hex string (0x...)
51
53
  protocolFeeUSDPrice_12Decimals: string; // uint256 (decimal) − 12 implied decimals
52
54
  expectedProduction_12Decimals: string; // uint256 (decimal) − 12 implied decimals
55
+ txHash: string; // bytes32 hex string (0x...)
53
56
  }
54
57
  ```
55
58
 
@@ -57,6 +60,7 @@ export interface AuditPushedV1Payload {
57
60
 
58
61
  - `farmId` must be a 32-byte hex string (e.g., `0x...`).
59
62
  - `protocolFeeUSDPrice_12Decimals` and `expectedProduction_12Decimals` must be decimal strings representing unsigned big integers.
63
+ - `txHash` must be a 32-byte hex string (e.g., `0x...`).
60
64
 
61
65
  ### `audit.slashed` v1
62
66
 
@@ -64,6 +68,7 @@ export interface AuditPushedV1Payload {
64
68
  export interface AuditSlashedV1Payload {
65
69
  farmId: string; // bytes32 hex string (0x...)
66
70
  slasher: string; // Ethereum address (0x...)
71
+ txHash: string; // bytes32 hex string (0x...)
67
72
  }
68
73
  ```
69
74
 
@@ -71,14 +76,34 @@ export interface AuditSlashedV1Payload {
71
76
 
72
77
  - `farmId` must be a 32-byte hex string (e.g., `0x...`).
73
78
  - `slasher` must be a valid Ethereum address (0x...40 hex chars).
79
+ - `txHash` must be a 32-byte hex string (e.g., `0x...`).
74
80
 
75
- ### `audit.pfees.paid` v1
81
+ ### `audit.pfees.paid` v1 (by applicationId)
76
82
 
77
83
  ```ts
78
84
  export interface AuditPfeesPaidV1Payload {
85
+ applicationId: string; // bytes32 hex string (0x...)
86
+ payer: string; // Ethereum address (0x...)
87
+ amount_12Decimals: string; // uint256 (decimal) − 12 implied decimals
88
+ txHash: string; // bytes32 hex string (0x...)
89
+ }
90
+ ```
91
+
92
+ **Validation:**
93
+
94
+ - `applicationId` must be a 32-byte hex string (e.g., `0x...`).
95
+ - `payer` must be a valid Ethereum address (0x...40 hex chars).
96
+ - `amount_12Decimals` must be a decimal string representing an unsigned big integer (12 implied decimals).
97
+ - `txHash` must be a 32-byte hex string (e.g., `0x...`).
98
+
99
+ ### `audit.pfees.paid` v2 (by farmId)
100
+
101
+ ```ts
102
+ export interface AuditPfeesPaidV2Payload {
79
103
  farmId: string; // bytes32 hex string (0x...)
80
104
  payer: string; // Ethereum address (0x...)
81
105
  amount_12Decimals: string; // uint256 (decimal) − 12 implied decimals
106
+ txHash: string; // bytes32 hex string (0x...)
82
107
  }
83
108
  ```
84
109
 
@@ -87,6 +112,27 @@ export interface AuditPfeesPaidV1Payload {
87
112
  - `farmId` must be a 32-byte hex string (e.g., `0x...`).
88
113
  - `payer` must be a valid Ethereum address (0x...40 hex chars).
89
114
  - `amount_12Decimals` must be a decimal string representing an unsigned big integer (12 implied decimals).
115
+ - `txHash` must be a 32-byte hex string (e.g., `0x...`).
116
+
117
+ ### `application.created` v1
118
+
119
+ ```ts
120
+ export interface ApplicationCreatedV1Payload {
121
+ gcaAddress: string; // Ethereum address (0x...)
122
+ lat: number;
123
+ lng: number;
124
+ estimatedCostOfPowerPerKWh: number;
125
+ estimatedKWhGeneratedPerYear: number;
126
+ installerCompanyName: string;
127
+ }
128
+ ```
129
+
130
+ **Validation:**
131
+
132
+ - `gcaAddress` must be a valid Ethereum address (0x...40 hex chars).
133
+ - `lat` and `lng` are numbers (coordinates).
134
+ - `estimatedCostOfPowerPerKWh` and `estimatedKWhGeneratedPerYear` are numbers.
135
+ - `installerCompanyName` is a string.
90
136
 
91
137
  ---
92
138
 
@@ -115,12 +161,33 @@ listener.onEvent("audit.slashed", 1, (event) => {
115
161
  listener.onEvent("audit.pfees.paid", 1, (event) => {
116
162
  console.log(
117
163
  "Received audit.pfees.paid v1:",
164
+ event.applicationId,
165
+ event.payer,
166
+ event.amount_12Decimals
167
+ );
168
+ });
169
+
170
+ listener.onEvent("audit.pfees.paid", 2, (event) => {
171
+ console.log(
172
+ "Received audit.pfees.paid v2:",
118
173
  event.farmId,
119
174
  event.payer,
120
175
  event.amount_12Decimals
121
176
  );
122
177
  });
123
178
 
179
+ listener.onEvent("application.created", 1, (event) => {
180
+ console.log(
181
+ "Received application.created v1:",
182
+ event.gcaAddress,
183
+ event.lat,
184
+ event.lng,
185
+ event.estimatedCostOfPowerPerKWh,
186
+ event.estimatedKWhGeneratedPerYear,
187
+ event.installerCompanyName
188
+ );
189
+ });
190
+
124
191
  await listener.start();
125
192
  // To stop listening:
126
193
  // await listener.stop();
@@ -131,10 +198,11 @@ await listener.start();
131
198
  ```ts
132
199
  import { createGlowEventEmitter } from "@glowlabs-org/events-sdk";
133
200
 
201
+ // You must construct the emitter with a specific zoneId (not 0)
134
202
  const emitter = createGlowEventEmitter({
135
203
  username: "admin",
136
204
  password: "your-password-here",
137
- zoneId: 1,
205
+ zoneId: 1, // must be a specific zone
138
206
  });
139
207
 
140
208
  await emitter.emit({
@@ -160,62 +228,47 @@ await emitter.emit({
160
228
  eventType: "audit.pfees.paid",
161
229
  schemaVersion: 1,
162
230
  payload: {
163
- farmId: "0x...",
231
+ applicationId: "0x...",
164
232
  payer: "0x...",
165
233
  amount_12Decimals: "1000000000000",
166
234
  },
167
235
  });
168
236
 
169
- await emitter.disconnect();
170
- ```
171
-
172
- ### 🌐 Emitting or Listening to All Zones
173
-
174
- You can emit to or listen to **all zones at once** by passing `zoneId: 0` to the emitter or listener.
175
-
176
- #### Emit to All Zones
177
-
178
- ```ts
179
- import { createGlowEventEmitter } from "@glowlabs-org/events-sdk";
180
-
181
- const emitter = createGlowEventEmitter({
182
- username: "admin",
183
- password: "your-password-here",
184
- zoneId: 0, // special value for all zones
185
- });
186
-
187
- await emitter.emit({
188
- eventType: "audit.pushed",
189
- schemaVersion: 1,
190
- payload: {
191
- farmId: "0x...",
192
- protocolFeeUSDPrice_12Decimals: "...",
193
- expectedProduction_12Decimals: "...",
194
- },
195
- });
196
-
197
237
  await emitter.emit({
198
- eventType: "audit.slashed",
199
- schemaVersion: 1,
238
+ eventType: "audit.pfees.paid",
239
+ schemaVersion: 2,
200
240
  payload: {
201
241
  farmId: "0x...",
202
- slasher: "0x...",
242
+ payer: "0x...",
243
+ amount_12Decimals: "1000000000000",
203
244
  },
204
245
  });
205
246
 
206
247
  await emitter.emit({
207
- eventType: "audit.pfees.paid",
248
+ eventType: "application.created",
208
249
  schemaVersion: 1,
209
250
  payload: {
210
- farmId: "0x...",
211
- payer: "0x...",
212
- amount_12Decimals: "1000000000000",
251
+ gcaAddress: "0x...",
252
+ lat: 45.5017,
253
+ lng: -73.5673,
254
+ estimatedCostOfPowerPerKWh: 0.12,
255
+ estimatedKWhGeneratedPerYear: 10000,
256
+ installerCompanyName: "SolarCo",
213
257
  },
214
258
  });
215
259
 
216
260
  await emitter.disconnect();
217
261
  ```
218
262
 
263
+ > **Note:**
264
+ >
265
+ > - The emitter will automatically publish each event to both the global (zone 0) and the specific zone exchange.
266
+ > - You cannot construct an emitter for zoneId: 0, and you cannot specify zoneId per emit call.
267
+
268
+ ### 🌐 Listening to All Zones
269
+
270
+ You can listen to **all zones at once** by passing `zoneId: 0` to the listener. **Emitters must always use a specific zone.**
271
+
219
272
  #### Listen to All Zones
220
273
 
221
274
  ```ts
@@ -243,12 +296,33 @@ listener.onEvent("audit.slashed", 1, (event) => {
243
296
  listener.onEvent("audit.pfees.paid", 1, (event) => {
244
297
  console.log(
245
298
  "Received audit.pfees.paid v1 from any zone:",
299
+ event.applicationId,
300
+ event.payer,
301
+ event.amount_12Decimals
302
+ );
303
+ });
304
+
305
+ listener.onEvent("audit.pfees.paid", 2, (event) => {
306
+ console.log(
307
+ "Received audit.pfees.paid v2 from any zone:",
246
308
  event.farmId,
247
309
  event.payer,
248
310
  event.amount_12Decimals
249
311
  );
250
312
  });
251
313
 
314
+ listener.onEvent("application.created", 1, (event) => {
315
+ console.log(
316
+ "Received application.created v1 from any zone:",
317
+ event.gcaAddress,
318
+ event.lat,
319
+ event.lng,
320
+ event.estimatedCostOfPowerPerKWh,
321
+ event.estimatedKWhGeneratedPerYear,
322
+ event.installerCompanyName
323
+ );
324
+ });
325
+
252
326
  await listener.start();
253
327
  // To stop listening:
254
328
  // await listener.stop();
@@ -4,29 +4,62 @@ export declare const baseEventZ: z.ZodObject<{
4
4
  id: z.ZodString;
5
5
  zoneId: z.ZodEffects<z.ZodNumber, number, number>;
6
6
  zoneName: z.ZodEnum<[string, ...string[]]>;
7
- schemaVersion: z.ZodLiteral<1>;
7
+ schemaVersion: z.ZodEffects<z.ZodNumber, 1 | 2, number>;
8
8
  eventType: z.ZodEnum<["audit.pushed", "audit.slashed", "audit.pfees.paid"]>;
9
9
  timeStamp: z.ZodNumber;
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  id: string;
12
12
  zoneId: number;
13
13
  zoneName: string;
14
- schemaVersion: 1;
14
+ schemaVersion: 1 | 2;
15
15
  eventType: "audit.pushed" | "audit.slashed" | "audit.pfees.paid";
16
16
  timeStamp: number;
17
17
  }, {
18
18
  id: string;
19
19
  zoneId: number;
20
20
  zoneName: string;
21
- schemaVersion: 1;
21
+ schemaVersion: number;
22
22
  eventType: "audit.pushed" | "audit.slashed" | "audit.pfees.paid";
23
23
  timeStamp: number;
24
24
  }>;
25
- export interface BaseEvent {
25
+ export interface BaseEventAuditPushedV1 {
26
26
  id: string;
27
27
  zoneId: number;
28
28
  zoneName: ZoneName;
29
29
  schemaVersion: 1;
30
- eventType: "audit.pushed" | "audit.slashed" | "audit.pfees.paid";
30
+ eventType: "audit.pushed";
31
+ timeStamp: number;
32
+ }
33
+ export interface BaseEventAuditSlashedV1 {
34
+ id: string;
35
+ zoneId: number;
36
+ zoneName: ZoneName;
37
+ schemaVersion: 1;
38
+ eventType: "audit.slashed";
39
+ timeStamp: number;
40
+ }
41
+ export interface BaseEventAuditPfeesPaidV1 {
42
+ id: string;
43
+ zoneId: number;
44
+ zoneName: ZoneName;
45
+ schemaVersion: 1;
46
+ eventType: "audit.pfees.paid";
47
+ timeStamp: number;
48
+ }
49
+ export interface BaseEventAuditPfeesPaidV2 {
50
+ id: string;
51
+ zoneId: number;
52
+ zoneName: ZoneName;
53
+ schemaVersion: 2;
54
+ eventType: "audit.pfees.paid";
55
+ timeStamp: number;
56
+ }
57
+ export interface BaseEventApplicationCreatedV1 {
58
+ id: string;
59
+ zoneId: number;
60
+ zoneName: ZoneName;
61
+ schemaVersion: 1;
62
+ eventType: "application.created";
31
63
  timeStamp: number;
32
64
  }
65
+ export type BaseEvent = BaseEventAuditPushedV1 | BaseEventAuditSlashedV1 | BaseEventAuditPfeesPaidV1 | BaseEventAuditPfeesPaidV2 | BaseEventApplicationCreatedV1;
@@ -11,7 +11,12 @@ exports.baseEventZ = zod_1.z.object({
11
11
  message: "Invalid zoneId",
12
12
  }),
13
13
  zoneName: zod_1.z.enum(zoneNames),
14
- schemaVersion: zod_1.z.literal(1),
14
+ schemaVersion: zod_1.z
15
+ .number()
16
+ .int()
17
+ .refine((v) => v === 1 || v === 2, {
18
+ message: "Invalid schemaVersion",
19
+ }),
15
20
  eventType: zod_1.z.enum(["audit.pushed", "audit.slashed", "audit.pfees.paid"]),
16
21
  timeStamp: zod_1.z.number().int(),
17
22
  });
package/dist/emitter.d.ts CHANGED
@@ -8,7 +8,6 @@ interface CreateGlowEventEmitterOptions {
8
8
  interface EmitEventArgs<T extends EventType, V extends EventVersion<T>> {
9
9
  eventType: T;
10
10
  schemaVersion: V;
11
- zoneId: number;
12
11
  payload: EventPayload<T, V>;
13
12
  }
14
13
  export declare function createGlowEventEmitter({ username, password, zoneId, exchangePrefix, }: CreateGlowEventEmitterOptions): {
package/dist/emitter.js CHANGED
@@ -11,8 +11,9 @@ const zones_1 = require("./zones");
11
11
  function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "glow.zone-", }) {
12
12
  let amqpConnection = null;
13
13
  let amqpChannel = null;
14
- // Use a special exchange for all zones if zoneId is 0
15
- const exchangeName = `${exchangePrefix}${zoneId}.events`;
14
+ // Exchanges for global and specific zone
15
+ const globalExchangeName = `${exchangePrefix}0.events`;
16
+ const zoneExchangeName = `${exchangePrefix}${zoneId}.events`;
16
17
  function buildAmqpUrl() {
17
18
  const url = new URL(`amqp://${username}:${password}@turntable.proxy.rlwy.net:50784`);
18
19
  return url.toString();
@@ -23,16 +24,21 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
23
24
  amqpChannel = (await amqpConnection.createChannel());
24
25
  }
25
26
  if (amqpChannel) {
26
- await amqpChannel.assertExchange(exchangeName, "topic", {
27
+ await amqpChannel.assertExchange(globalExchangeName, "topic", {
28
+ durable: true,
29
+ });
30
+ await amqpChannel.assertExchange(zoneExchangeName, "topic", {
27
31
  durable: true,
28
32
  });
29
33
  }
30
34
  }
31
35
  async function emit(args) {
32
- const { eventType, schemaVersion, zoneId, payload } = args;
36
+ const { eventType, schemaVersion, payload } = args;
33
37
  const zoneName = zones_1.zoneMap[String(zoneId)];
34
38
  if (!zoneName)
35
39
  throw new Error(`Invalid zoneId: ${zoneId}`);
40
+ if (zoneId === 0)
41
+ throw new Error("Cannot emit events with zoneId 0. Use a specific zone emitter.");
36
42
  const event = {
37
43
  id: (0, uuid_1.v4)(),
38
44
  eventType,
@@ -46,7 +52,9 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
46
52
  (0, utils_1.validateEventPayload)(event.eventType, event.schemaVersion, event);
47
53
  const routingKey = `${event.eventType}.v${event.schemaVersion}`;
48
54
  await connectIfNeeded();
49
- amqpChannel.publish(exchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
55
+ // Emit to both the global and the specific zone exchange
56
+ amqpChannel.publish(globalExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
57
+ amqpChannel.publish(zoneExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
50
58
  }
51
59
  async function disconnect() {
52
60
  if (amqpConnection) {
@@ -4,13 +4,21 @@ exports.getEventSchema = getEventSchema;
4
4
  const audit_pushed_v1_1 = require("./schemas/audit-pushed.v1");
5
5
  const audit_slashed_v1_1 = require("./schemas/audit-slashed.v1");
6
6
  const audit_pfees_paid_v1_1 = require("./schemas/audit-pfees-paid.v1");
7
+ const audit_pfees_paid_v2_1 = require("./schemas/audit-pfees-paid.v2");
7
8
  const base_event_1 = require("./base-event");
9
+ const application_created_v1_1 = require("./schemas/application-created.v1");
8
10
  const eventTypeRegistry = {
9
11
  "audit.pushed:v1": base_event_1.baseEventZ.extend({ payload: audit_pushed_v1_1.auditPushedV1PayloadZ }),
10
12
  "audit.slashed:v1": base_event_1.baseEventZ.extend({ payload: audit_slashed_v1_1.auditSlashedV1PayloadZ }),
11
13
  "audit.pfees.paid:v1": base_event_1.baseEventZ.extend({
12
14
  payload: audit_pfees_paid_v1_1.auditPfeesPaidV1PayloadZ,
13
15
  }),
16
+ "audit.pfees.paid:v2": base_event_1.baseEventZ.extend({
17
+ payload: audit_pfees_paid_v2_1.auditPfeesPaidV2PayloadZ,
18
+ }),
19
+ "application.created:v1": base_event_1.baseEventZ.extend({
20
+ payload: application_created_v1_1.applicationCreatedV1PayloadZ,
21
+ }),
14
22
  // Add more event types/versions here
15
23
  };
16
24
  function getEventSchema(eventType, version) {
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export declare const applicationCreatedV1PayloadZ: z.ZodObject<{
3
+ gcaAddress: z.ZodString;
4
+ lat: z.ZodNumber;
5
+ lng: z.ZodNumber;
6
+ estimatedCostOfPowerPerKWh: z.ZodNumber;
7
+ estimatedKWhGeneratedPerYear: z.ZodNumber;
8
+ installerCompanyName: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ gcaAddress: string;
11
+ lat: number;
12
+ lng: number;
13
+ estimatedCostOfPowerPerKWh: number;
14
+ estimatedKWhGeneratedPerYear: number;
15
+ installerCompanyName: string;
16
+ }, {
17
+ gcaAddress: string;
18
+ lat: number;
19
+ lng: number;
20
+ estimatedCostOfPowerPerKWh: number;
21
+ estimatedKWhGeneratedPerYear: number;
22
+ installerCompanyName: string;
23
+ }>;
24
+ export interface ApplicationCreatedV1Payload extends z.infer<typeof applicationCreatedV1PayloadZ> {
25
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applicationCreatedV1PayloadZ = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.applicationCreatedV1PayloadZ = zod_1.z.object({
6
+ gcaAddress: zod_1.z.string().regex(/^0x[a-fA-F0-9]{40}$/), // eth address
7
+ lat: zod_1.z.number(),
8
+ lng: zod_1.z.number(),
9
+ estimatedCostOfPowerPerKWh: zod_1.z.number(),
10
+ estimatedKWhGeneratedPerYear: zod_1.z.number(),
11
+ installerCompanyName: zod_1.z.string(),
12
+ });
@@ -1,14 +1,17 @@
1
1
  import { z } from "zod";
2
2
  export declare const auditPfeesPaidV1PayloadZ: z.ZodObject<{
3
- farmId: z.ZodString;
3
+ applicationId: z.ZodString;
4
4
  payer: z.ZodString;
5
5
  amount_12Decimals: z.ZodString;
6
+ txHash: z.ZodString;
6
7
  }, "strip", z.ZodTypeAny, {
7
- farmId: string;
8
+ txHash: string;
9
+ applicationId: string;
8
10
  payer: string;
9
11
  amount_12Decimals: string;
10
12
  }, {
11
- farmId: string;
13
+ txHash: string;
14
+ applicationId: string;
12
15
  payer: string;
13
16
  amount_12Decimals: string;
14
17
  }>;
@@ -6,9 +6,10 @@ const hexBytes32 = /^0x[0-9a-fA-F]{64}$/;
6
6
  const ethAddress = /^0x[0-9a-fA-F]{40}$/;
7
7
  const uint256 = /^[0-9]+$/;
8
8
  exports.auditPfeesPaidV1PayloadZ = zod_1.z.object({
9
- farmId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
9
+ applicationId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
10
10
  payer: zod_1.z.string().regex(ethAddress, "Ethereum address"),
11
11
  amount_12Decimals: zod_1.z
12
12
  .string()
13
13
  .regex(uint256, "uint256 (decimal) − 12 implied decimals"),
14
+ txHash: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
14
15
  });
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ export declare const auditPfeesPaidV2PayloadZ: z.ZodObject<{
3
+ farmId: z.ZodString;
4
+ payer: z.ZodString;
5
+ amount_12Decimals: z.ZodString;
6
+ txHash: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ farmId: string;
9
+ txHash: string;
10
+ payer: string;
11
+ amount_12Decimals: string;
12
+ }, {
13
+ farmId: string;
14
+ txHash: string;
15
+ payer: string;
16
+ amount_12Decimals: string;
17
+ }>;
18
+ export type AuditPfeesPaidV2Payload = z.infer<typeof auditPfeesPaidV2PayloadZ>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.auditPfeesPaidV2PayloadZ = void 0;
4
+ const zod_1 = require("zod");
5
+ const hexBytes32 = /^0x[0-9a-fA-F]{64}$/;
6
+ const ethAddress = /^0x[0-9a-fA-F]{40}$/;
7
+ const uint256 = /^[0-9]+$/;
8
+ exports.auditPfeesPaidV2PayloadZ = zod_1.z.object({
9
+ farmId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
10
+ payer: zod_1.z.string().regex(ethAddress, "Ethereum address"),
11
+ amount_12Decimals: zod_1.z
12
+ .string()
13
+ .regex(uint256, "uint256 (decimal) − 12 implied decimals"),
14
+ txHash: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
15
+ });
@@ -3,13 +3,16 @@ export declare const auditPushedV1PayloadZ: z.ZodObject<{
3
3
  farmId: z.ZodString;
4
4
  protocolFeeUSDPrice_12Decimals: z.ZodString;
5
5
  expectedProduction_12Decimals: z.ZodString;
6
+ txHash: z.ZodString;
6
7
  }, "strip", z.ZodTypeAny, {
7
8
  farmId: string;
8
9
  protocolFeeUSDPrice_12Decimals: string;
9
10
  expectedProduction_12Decimals: string;
11
+ txHash: string;
10
12
  }, {
11
13
  farmId: string;
12
14
  protocolFeeUSDPrice_12Decimals: string;
13
15
  expectedProduction_12Decimals: string;
16
+ txHash: string;
14
17
  }>;
15
18
  export type AuditPushedV1Payload = z.infer<typeof auditPushedV1PayloadZ>;
@@ -10,4 +10,5 @@ exports.auditPushedV1PayloadZ = zod_1.z.object({
10
10
  .string()
11
11
  .regex(uint256, "uint256 (decimal) − 12 implied decimals"),
12
12
  expectedProduction_12Decimals: zod_1.z.string().regex(uint256),
13
+ txHash: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
13
14
  });
@@ -2,11 +2,14 @@ import { z } from "zod";
2
2
  export declare const auditSlashedV1PayloadZ: z.ZodObject<{
3
3
  farmId: z.ZodString;
4
4
  slasher: z.ZodString;
5
+ txHash: z.ZodString;
5
6
  }, "strip", z.ZodTypeAny, {
6
7
  farmId: string;
8
+ txHash: string;
7
9
  slasher: string;
8
10
  }, {
9
11
  farmId: string;
12
+ txHash: string;
10
13
  slasher: string;
11
14
  }>;
12
15
  export type AuditSlashedV1Payload = z.infer<typeof auditSlashedV1PayloadZ>;
@@ -7,4 +7,5 @@ const ethAddress = /^0x[0-9a-fA-F]{40}$/;
7
7
  exports.auditSlashedV1PayloadZ = zod_1.z.object({
8
8
  farmId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
9
9
  slasher: zod_1.z.string().regex(ethAddress, "Ethereum address"),
10
+ txHash: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
10
11
  });
package/dist/types.d.ts CHANGED
@@ -2,8 +2,16 @@ import type { BaseEvent } from "./base-event";
2
2
  import type { AuditPushedV1Payload } from "./schemas/audit-pushed.v1";
3
3
  import type { AuditSlashedV1Payload } from "./schemas/audit-slashed.v1";
4
4
  import type { AuditPfeesPaidV1Payload } from "./schemas/audit-pfees-paid.v1";
5
+ import type { AuditPfeesPaidV2Payload } from "./schemas/audit-pfees-paid.v2";
6
+ import type { ApplicationCreatedV1Payload } from "./schemas/application-created.v1";
5
7
  export type EventType = BaseEvent["eventType"];
6
- export type EventVersion<T extends EventType> = T extends "audit.pushed" ? 1 : T extends "audit.slashed" ? 1 : T extends "audit.pfees.paid" ? 1 : never;
8
+ type EventTypeToVersion = {
9
+ "audit.pushed": 1;
10
+ "audit.slashed": 1;
11
+ "audit.pfees.paid": 1 | 2;
12
+ "application.created": 1;
13
+ };
14
+ export type EventVersion<T extends EventType> = T extends keyof EventTypeToVersion ? EventTypeToVersion[T] : never;
7
15
  export interface EventPayloadMap {
8
16
  "audit.pushed": {
9
17
  1: AuditPushedV1Payload;
@@ -13,9 +21,14 @@ export interface EventPayloadMap {
13
21
  };
14
22
  "audit.pfees.paid": {
15
23
  1: AuditPfeesPaidV1Payload;
24
+ 2: AuditPfeesPaidV2Payload;
25
+ };
26
+ "application.created": {
27
+ 1: ApplicationCreatedV1Payload;
16
28
  };
17
29
  }
18
30
  export type EventPayload<T extends EventType, V extends EventVersion<T>> = T extends keyof EventPayloadMap ? V extends keyof EventPayloadMap[T] ? EventPayloadMap[T][V] : never : never;
19
31
  export interface GlowEvent<TPayload> extends Omit<BaseEvent, "payload"> {
20
32
  payload: TPayload;
21
33
  }
34
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glowlabs-org/events-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Typed event SDK for Glow, powered by RabbitMQ and Zod.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",