@glowlabs-org/events-sdk 1.0.7 → 1.0.9
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
@@ -90,7 +90,7 @@ Use these in your code to avoid hardcoding event names and to benefit from autoc
|
|
90
90
|
```ts
|
91
91
|
export interface AuditPushedV1Payload {
|
92
92
|
farmId: string; // UUID string
|
93
|
-
|
93
|
+
protocolFeeUSDPrice_6Decimals: string; // uint256 (decimal) − 12 implied decimals
|
94
94
|
expectedProduction_12Decimals: string; // uint256 (decimal) − 12 implied decimals
|
95
95
|
txHash: string; // bytes32 hex string (0x...)
|
96
96
|
}
|
@@ -99,7 +99,7 @@ export interface AuditPushedV1Payload {
|
|
99
99
|
**Validation:**
|
100
100
|
|
101
101
|
- `farmId` must be a valid UUID string (e.g., `afbc56b6-0b16-4119-b144-025728067ba6`).
|
102
|
-
- `
|
102
|
+
- `protocolFeeUSDPrice_6Decimals` and `expectedProduction_12Decimals` must be decimal strings representing unsigned big integers.
|
103
103
|
- `txHash` must be a 32-byte hex string (e.g., `0x...`).
|
104
104
|
|
105
105
|
### `audit.slashed` v1
|
@@ -283,7 +283,7 @@ await emitter.emit({
|
|
283
283
|
schemaVersion: "v1",
|
284
284
|
payload: {
|
285
285
|
farmId: "afbc56b6-0b16-4119-b144-025728067ba6", // UUID string
|
286
|
-
|
286
|
+
protocolFeeUSDPrice_6Decimals: "...",
|
287
287
|
expectedProduction_12Decimals: "...",
|
288
288
|
txHash: "0x...",
|
289
289
|
},
|
package/dist/emitter.js
CHANGED
@@ -20,7 +20,12 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
|
|
20
20
|
async function connectIfNeeded() {
|
21
21
|
if (!amqpConnection) {
|
22
22
|
amqpConnection = (await amqplib_1.default.connect(buildUrl()));
|
23
|
-
|
23
|
+
// create a confirm channel so we can wait for broker acknowledgements
|
24
|
+
amqpChannel = (await amqpConnection.createConfirmChannel());
|
25
|
+
// if a message is unroutable this handler will fire
|
26
|
+
amqpChannel.on("return", (msg) => {
|
27
|
+
console.error("❌ UNROUTABLE:", msg.fields.routingKey);
|
28
|
+
});
|
24
29
|
}
|
25
30
|
if (amqpChannel) {
|
26
31
|
await amqpChannel.assertExchange(globalExchangeName, "topic", {
|
@@ -52,8 +57,12 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
|
|
52
57
|
const routingKey = `${event.eventType}.${event.schemaVersion.toString()}`;
|
53
58
|
await connectIfNeeded();
|
54
59
|
// Emit to both the global and the specific zone exchange
|
55
|
-
amqpChannel.publish(globalExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
|
56
|
-
amqpChannel.publish(zoneExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
|
60
|
+
const globalPublish = amqpChannel.publish(globalExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true, mandatory: true });
|
61
|
+
const zonePublish = amqpChannel.publish(zoneExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true, mandatory: true });
|
62
|
+
console.log("globalPublish", globalPublish);
|
63
|
+
console.log("zonePublish", zonePublish);
|
64
|
+
// Wait for broker to acknowledge publishes; rejects on nack
|
65
|
+
await amqpChannel.waitForConfirms();
|
57
66
|
}
|
58
67
|
async function disconnect() {
|
59
68
|
if (amqpConnection) {
|
package/dist/listener.js
CHANGED
@@ -52,6 +52,12 @@ function createGlowEventListener({ username, password, zoneId, queueName, exchan
|
|
52
52
|
throw new Error("Queue not initialized");
|
53
53
|
consumerTag = (await amqpChannel.consume(internalQueueName, (msg) => {
|
54
54
|
if (msg) {
|
55
|
+
// Only process messages that originated from the exchange that matches the requested zoneId.
|
56
|
+
// This prevents duplicate handling when the queue is bound to multiple exchanges.
|
57
|
+
if (msg.fields.exchange !== exchangeName) {
|
58
|
+
amqpChannel.ack(msg);
|
59
|
+
return;
|
60
|
+
}
|
55
61
|
try {
|
56
62
|
const decoded = JSON.parse(msg.content.toString());
|
57
63
|
const [eventType, versionStr] = msg.fields.routingKey.split(".v");
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import { z } from "zod";
|
2
2
|
export declare const auditPushedV1PayloadZ: z.ZodObject<{
|
3
3
|
farmId: z.ZodString;
|
4
|
-
|
4
|
+
protocolFeeUSDPrice_6Decimals: z.ZodString;
|
5
5
|
expectedProduction_12Decimals: z.ZodString;
|
6
6
|
txHash: z.ZodString;
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
8
8
|
farmId: string;
|
9
|
-
|
9
|
+
protocolFeeUSDPrice_6Decimals: string;
|
10
10
|
expectedProduction_12Decimals: string;
|
11
11
|
txHash: string;
|
12
12
|
}, {
|
13
13
|
farmId: string;
|
14
|
-
|
14
|
+
protocolFeeUSDPrice_6Decimals: string;
|
15
15
|
expectedProduction_12Decimals: string;
|
16
16
|
txHash: string;
|
17
17
|
}>;
|
@@ -5,9 +5,9 @@ const zod_1 = require("zod");
|
|
5
5
|
const patterns_1 = require("../patterns");
|
6
6
|
exports.auditPushedV1PayloadZ = zod_1.z.object({
|
7
7
|
farmId: zod_1.z.string().uuid(),
|
8
|
-
|
8
|
+
protocolFeeUSDPrice_6Decimals: zod_1.z
|
9
9
|
.string()
|
10
|
-
.regex(patterns_1.uint256, "uint256 (decimal) −
|
10
|
+
.regex(patterns_1.uint256, "uint256 (decimal) − 6 implied decimals"),
|
11
11
|
expectedProduction_12Decimals: zod_1.z.string().regex(patterns_1.uint256),
|
12
12
|
txHash: zod_1.z.string().regex(patterns_1.hexBytes32, "bytes32 hex string"),
|
13
13
|
});
|
@@ -6,13 +6,13 @@ export declare const auditPushedV2PayloadZ: z.ZodObject<{
|
|
6
6
|
txHash: z.ZodString;
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
8
8
|
farmId: string;
|
9
|
-
protocolFeeUSDPrice_12Decimals: string;
|
10
9
|
expectedProduction_12Decimals: string;
|
11
10
|
txHash: string;
|
11
|
+
protocolFeeUSDPrice_12Decimals: string;
|
12
12
|
}, {
|
13
13
|
farmId: string;
|
14
|
-
protocolFeeUSDPrice_12Decimals: string;
|
15
14
|
expectedProduction_12Decimals: string;
|
16
15
|
txHash: string;
|
16
|
+
protocolFeeUSDPrice_12Decimals: string;
|
17
17
|
}>;
|
18
18
|
export type AuditPushedV2Payload = z.infer<typeof auditPushedV2PayloadZ>;
|