@pioneer-platform/pioneer-cache 1.1.9 → 1.1.11
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/CHANGELOG.md +14 -0
- package/dist/stores/price-cache.js +17 -2
- package/package.json +2 -2
- package/src/stores/price-cache.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pioneer-platform/pioneer-cache
|
|
2
2
|
|
|
3
|
+
## 1.1.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: move @types/pdfkit to dependencies for Docker --production build
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @pioneer-platform/redis-queue@8.12.1
|
|
10
|
+
|
|
11
|
+
## 1.1.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- chore: - This was causing production Pioneer API to return balances with empty CAIPs that would crash the vault on startup
|
|
16
|
+
|
|
3
17
|
## 1.1.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -167,12 +167,27 @@ class PriceCache extends base_cache_1.BaseCache {
|
|
|
167
167
|
const startTime = Date.now();
|
|
168
168
|
try {
|
|
169
169
|
log.info(tag, `Batch request for ${caips.length} prices`);
|
|
170
|
+
// Validate and filter out invalid CAIPs
|
|
171
|
+
const validCaips = caips.filter((caip, index) => {
|
|
172
|
+
if (!caip || typeof caip !== 'string') {
|
|
173
|
+
log.warn(tag, `Invalid CAIP at index ${index}:`, caip);
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return true;
|
|
177
|
+
});
|
|
178
|
+
if (validCaips.length < caips.length) {
|
|
179
|
+
log.warn(tag, `Filtered ${caips.length - validCaips.length} invalid CAIPs from batch request`);
|
|
180
|
+
}
|
|
181
|
+
if (validCaips.length === 0) {
|
|
182
|
+
log.warn(tag, 'No valid CAIPs in batch request');
|
|
183
|
+
return new Map();
|
|
184
|
+
}
|
|
170
185
|
// Get all prices in parallel
|
|
171
|
-
const promises =
|
|
186
|
+
const promises = validCaips.map(caip => this.getPrice(caip, waitForFresh));
|
|
172
187
|
const results = await Promise.all(promises);
|
|
173
188
|
// Build map of caip -> price
|
|
174
189
|
const priceMap = new Map();
|
|
175
|
-
|
|
190
|
+
validCaips.forEach((caip, index) => {
|
|
176
191
|
priceMap.set(caip, results[index]);
|
|
177
192
|
});
|
|
178
193
|
const responseTime = Date.now() - startTime;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer-cache",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Unified caching system for Pioneer platform with Redis backend",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
24
|
-
"@pioneer-platform/redis-queue": "^8.12.
|
|
24
|
+
"@pioneer-platform/redis-queue": "^8.12.1",
|
|
25
25
|
"@pioneer-platform/default-redis": "^8.11.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -203,13 +203,31 @@ export class PriceCache extends BaseCache<PriceData> {
|
|
|
203
203
|
try {
|
|
204
204
|
log.info(tag, `Batch request for ${caips.length} prices`);
|
|
205
205
|
|
|
206
|
+
// Validate and filter out invalid CAIPs
|
|
207
|
+
const validCaips = caips.filter((caip, index) => {
|
|
208
|
+
if (!caip || typeof caip !== 'string') {
|
|
209
|
+
log.warn(tag, `Invalid CAIP at index ${index}:`, caip);
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (validCaips.length < caips.length) {
|
|
216
|
+
log.warn(tag, `Filtered ${caips.length - validCaips.length} invalid CAIPs from batch request`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (validCaips.length === 0) {
|
|
220
|
+
log.warn(tag, 'No valid CAIPs in batch request');
|
|
221
|
+
return new Map();
|
|
222
|
+
}
|
|
223
|
+
|
|
206
224
|
// Get all prices in parallel
|
|
207
|
-
const promises =
|
|
225
|
+
const promises = validCaips.map(caip => this.getPrice(caip, waitForFresh));
|
|
208
226
|
const results = await Promise.all(promises);
|
|
209
227
|
|
|
210
228
|
// Build map of caip -> price
|
|
211
229
|
const priceMap = new Map<string, number>();
|
|
212
|
-
|
|
230
|
+
validCaips.forEach((caip, index) => {
|
|
213
231
|
priceMap.set(caip, results[index]);
|
|
214
232
|
});
|
|
215
233
|
|