@axxel/event-bus 1.0.5 → 1.0.7
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 +44 -6
- package/dist/config/kafka.d.ts +0 -0
- package/dist/config/kafka.d.ts.map +0 -0
- package/dist/config/kafka.js +0 -0
- package/dist/consumers/index.d.ts +0 -0
- package/dist/consumers/index.d.ts.map +0 -0
- package/dist/consumers/index.js +0 -0
- package/dist/consumers/tokenPriceConsumer.d.ts +0 -0
- package/dist/consumers/tokenPriceConsumer.d.ts.map +0 -0
- package/dist/consumers/tokenPriceConsumer.js +0 -0
- package/dist/consumers/tradeExecutionConsumer.d.ts +0 -0
- package/dist/consumers/tradeExecutionConsumer.d.ts.map +0 -0
- package/dist/consumers/tradeExecutionConsumer.js +0 -0
- package/dist/consumers/walletTransactionConsumer.d.ts +0 -0
- package/dist/consumers/walletTransactionConsumer.d.ts.map +0 -0
- package/dist/consumers/walletTransactionConsumer.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.d.ts.map +0 -0
- package/dist/index.js +0 -0
- package/dist/producers/index.d.ts +0 -0
- package/dist/producers/index.d.ts.map +0 -0
- package/dist/producers/index.js +0 -0
- package/dist/producers/tokenPriceProducer.d.ts +0 -0
- package/dist/producers/tokenPriceProducer.d.ts.map +0 -0
- package/dist/producers/tokenPriceProducer.js +0 -0
- package/dist/producers/tradeExecutionProducer.d.ts +0 -0
- package/dist/producers/tradeExecutionProducer.d.ts.map +0 -0
- package/dist/producers/tradeExecutionProducer.js +0 -0
- package/dist/producers/walletTransactionProducer.d.ts +0 -0
- package/dist/producers/walletTransactionProducer.d.ts.map +0 -0
- package/dist/producers/walletTransactionProducer.js +0 -0
- package/dist/topics.d.ts +0 -0
- package/dist/topics.d.ts.map +0 -0
- package/dist/topics.js +0 -0
- package/dist/types/TokenPriceEvent.d.ts +2 -1
- package/dist/types/TokenPriceEvent.d.ts.map +1 -1
- package/dist/types/TokenPriceEvent.js +0 -0
- package/dist/types/TradeExecutionEvent.d.ts +0 -0
- package/dist/types/TradeExecutionEvent.d.ts.map +0 -0
- package/dist/types/TradeExecutionEvent.js +0 -0
- package/dist/types/WalletTransactionEvent.d.ts +0 -0
- package/dist/types/WalletTransactionEvent.d.ts.map +0 -0
- package/dist/types/WalletTransactionEvent.js +0 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.d.ts.map +0 -0
- package/dist/types/index.js +0 -0
- package/dist/validation/common.d.ts +0 -0
- package/dist/validation/common.d.ts.map +0 -0
- package/dist/validation/common.js +0 -0
- package/dist/validation/tokenPriceEvent.schema.d.ts +2 -1
- package/dist/validation/tokenPriceEvent.schema.d.ts.map +1 -1
- package/dist/validation/tokenPriceEvent.schema.js +2 -1
- package/dist/validation/walletTransactionEvent.schema.d.ts +0 -0
- package/dist/validation/walletTransactionEvent.schema.d.ts.map +0 -0
- package/dist/validation/walletTransactionEvent.schema.js +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,7 +40,12 @@ KAFKA_BROKER="localhost:9092"
|
|
|
40
40
|
### 1️⃣ Producing messages
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
produceTokenPrice,
|
|
45
|
+
produceWalletTransaction,
|
|
46
|
+
ensureTokenPriceEvent,
|
|
47
|
+
ensureWalletTransactionEvent,
|
|
48
|
+
} from '@axxel/event-bus';
|
|
44
49
|
|
|
45
50
|
await produceTokenPrice({
|
|
46
51
|
chainId: 1,
|
|
@@ -49,7 +54,8 @@ await produceTokenPrice({
|
|
|
49
54
|
price: {
|
|
50
55
|
USD: { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 },
|
|
51
56
|
},
|
|
52
|
-
|
|
57
|
+
priceUsd: 3250.42,
|
|
58
|
+
fdv: 1234567890,
|
|
53
59
|
symbol: 'WETH',
|
|
54
60
|
updatedAt: Math.floor(Date.now() / 1000),
|
|
55
61
|
});
|
|
@@ -71,6 +77,19 @@ await produceWalletTransaction({
|
|
|
71
77
|
marketcap: 500000000,
|
|
72
78
|
totalSupply: 1000000,
|
|
73
79
|
});
|
|
80
|
+
|
|
81
|
+
// Optional: validate and normalize before producing
|
|
82
|
+
const safePricePayload = ensureTokenPriceEvent({
|
|
83
|
+
chainId: 1,
|
|
84
|
+
tokenAddress: '0xC02a...',
|
|
85
|
+
blockNumber: 21345678,
|
|
86
|
+
price: new Map([
|
|
87
|
+
['USD', { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 }],
|
|
88
|
+
]),
|
|
89
|
+
priceUsd: 3250.42,
|
|
90
|
+
fdv: 1234567890,
|
|
91
|
+
});
|
|
92
|
+
await produceTokenPrice(safePricePayload);
|
|
74
93
|
```
|
|
75
94
|
|
|
76
95
|
---
|
|
@@ -89,7 +108,9 @@ await startTokenPriceConsumer('limit-orders', async (priceEvent) => {
|
|
|
89
108
|
? priceEvent.price.get('USD')
|
|
90
109
|
: priceEvent.price['USD'];
|
|
91
110
|
console.log(
|
|
92
|
-
`📈 ${priceEvent.symbol ?? priceEvent.tokenAddress} @ $${
|
|
111
|
+
`📈 ${priceEvent.symbol ?? priceEvent.tokenAddress} @ $${
|
|
112
|
+
usdInfo?.price ?? 'n/a'
|
|
113
|
+
} (chain ${priceEvent.chainId})`,
|
|
93
114
|
);
|
|
94
115
|
});
|
|
95
116
|
|
|
@@ -107,8 +128,8 @@ Multiple instances with the same group ID will automatically load-balance partit
|
|
|
107
128
|
|
|
108
129
|
## 🧠 Topics Overview
|
|
109
130
|
|
|
110
|
-
| Topic | Description | Partition Key
|
|
111
|
-
| --------------------- | ------------------------------------------ |
|
|
131
|
+
| Topic | Description | Partition Key |
|
|
132
|
+
| --------------------- | ------------------------------------------ | ----------------------- |
|
|
112
133
|
| `token-prices` | Live token price updates across all chains | `chainId:tokenAddress` |
|
|
113
134
|
| `wallet-transactions` | Wallet buy/sell/transfer events | `chainId:walletAddress` |
|
|
114
135
|
|
|
@@ -126,7 +147,8 @@ interface TokenPriceEvent {
|
|
|
126
147
|
tokenAddress: string;
|
|
127
148
|
blockNumber: number;
|
|
128
149
|
price: Record<string, PriceInfo> | Map<string, PriceInfo>;
|
|
129
|
-
|
|
150
|
+
priceUsd?: number | null;
|
|
151
|
+
fdv?: number | null;
|
|
130
152
|
symbol?: string | null;
|
|
131
153
|
updatedAt?: number;
|
|
132
154
|
}
|
|
@@ -154,6 +176,22 @@ interface WalletTransactionEvent {
|
|
|
154
176
|
}
|
|
155
177
|
```
|
|
156
178
|
|
|
179
|
+
### Runtime validation helpers
|
|
180
|
+
|
|
181
|
+
Shared Zod schemas are exported to normalize inputs consistently:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import {
|
|
185
|
+
ensureTokenPriceEvent,
|
|
186
|
+
ensureWalletTransactionEvent,
|
|
187
|
+
} from '@axxel/event-bus';
|
|
188
|
+
|
|
189
|
+
const normalizedPrice = ensureTokenPriceEvent(rawPricePayload);
|
|
190
|
+
const normalizedTx = ensureWalletTransactionEvent(rawTxPayload);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`ensureTokenPriceEvent` accepts either a `Record` or `Map` for `price`, and both helpers lowercase EVM addresses / tx hashes while rejecting malformed numeric fields.
|
|
194
|
+
|
|
157
195
|
---
|
|
158
196
|
|
|
159
197
|
## ⚙️ Environment Variables
|
package/dist/config/kafka.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/config/kafka.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/consumers/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.d.ts.map
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/producers/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/topics.d.ts
CHANGED
|
File without changes
|
package/dist/topics.d.ts.map
CHANGED
|
File without changes
|
package/dist/topics.js
CHANGED
|
File without changes
|
|
@@ -8,7 +8,8 @@ export interface TokenPriceEvent {
|
|
|
8
8
|
tokenAddress: string;
|
|
9
9
|
blockNumber: number;
|
|
10
10
|
price: Record<string, PriceInfo> | Map<string, PriceInfo>;
|
|
11
|
-
|
|
11
|
+
priceUsd?: number | null;
|
|
12
|
+
fdv?: number | null;
|
|
12
13
|
symbol?: string | null;
|
|
13
14
|
updatedAt?: number;
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenPriceEvent.d.ts","sourceRoot":"","sources":["../../src/types/TokenPriceEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1D,
|
|
1
|
+
{"version":3,"file":"TokenPriceEvent.d.ts","sourceRoot":"","sources":["../../src/types/TokenPriceEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/types/index.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/types/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,7 +8,8 @@ export declare const tokenPriceEventSchema: z.ZodObject<{
|
|
|
8
8
|
exchange: z.ZodString;
|
|
9
9
|
liquidity: z.ZodNumber;
|
|
10
10
|
}, z.core.$strip>>>>;
|
|
11
|
-
|
|
11
|
+
priceUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
12
|
+
fdv: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
12
13
|
symbol: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
14
|
updatedAt: z.ZodOptional<z.ZodNumber>;
|
|
14
15
|
}, z.core.$strip>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenPriceEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/tokenPriceEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiDxB,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"tokenPriceEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/tokenPriceEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiDxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAShC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAE3E"}
|
|
@@ -42,7 +42,8 @@ exports.tokenPriceEventSchema = zod_1.z.object({
|
|
|
42
42
|
tokenAddress: common_1.addressSchema,
|
|
43
43
|
blockNumber: zod_1.z.number().int().min(0),
|
|
44
44
|
price: priceRecordSchema,
|
|
45
|
-
|
|
45
|
+
priceUsd: zod_1.z.number().nullable().optional(),
|
|
46
|
+
fdv: zod_1.z.number().nullable().optional(),
|
|
46
47
|
symbol: zod_1.z.string().nullable().optional(),
|
|
47
48
|
updatedAt: zod_1.z.number().int().min(0).optional(),
|
|
48
49
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axxel/event-bus",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Axxel Kafka Event Bus SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
"tsx": "^4.20.6",
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|