Commit 1f776e6
feat: implement configuration to pre-populate the cache with spending plans (#3058)
* chore: refactor configurations of `HbarLimitService`
Signed-off-by: Victor Yanev <[email protected]>
* chore: fix ts errors
Signed-off-by: Victor Yanev <[email protected]>
* chore: revert formatting of table
Signed-off-by: Victor Yanev <[email protected]>
* refactor: configurations of `HbarLimitService`
Signed-off-by: Victor Yanev <[email protected]>
* Merge branch 'main' into 2970-Note-what-configurations-are-used
Signed-off-by: Victor Yanev <[email protected]>
# Conflicts:
# packages/relay/src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository.ts
# packages/relay/src/lib/services/hbarLimitService/index.ts
# packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts
* docs: add configuration subsections to table of contents
Signed-off-by: Victor Yanev <[email protected]>
* docs: make descriptions of configurations consistent
Signed-off-by: Victor Yanev <[email protected]>
* chore: revert changes to localLRUCache.ts and redisCache.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: moves TODO comment to constants.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: optimize resetDate calculation
Signed-off-by: Victor Yanev <[email protected]>
* chore: remove unused imports
Signed-off-by: Victor Yanev <[email protected]>
* Merge branch 'main' into 2970-Note-what-configurations-are-used
Signed-off-by: Victor Yanev <[email protected]>
# Conflicts:
# packages/relay/src/lib/db/repositories/hbarLimiter/ethAddressHbarSpendingPlanRepository.ts
# packages/relay/src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository.ts
# packages/relay/src/lib/db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository.ts
# packages/relay/src/lib/services/hbarLimitService/index.ts
# packages/relay/tests/lib/repositories/hbarLimiter/hbarSpendingPlanRepository.spec.ts
# packages/relay/tests/lib/sdkClient.spec.ts
# packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts
* feat: Implement configuration to pre-populate the cache with spending plans
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments + added improvements to logic
Signed-off-by: Victor Yanev <[email protected]>
* chore: added tests + improvements to logic
Signed-off-by: Victor Yanev <[email protected]>
* docs: update docs
Signed-off-by: Victor Yanev <[email protected]>
* docs: reformat table
Signed-off-by: Victor Yanev <[email protected]>
* chore: improvements to hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: fix typo
Signed-off-by: Victor Yanev <[email protected]>
* chore: revert unneeded changes
Signed-off-by: Victor Yanev <[email protected]>
* chore: censor IP addresses in logs of localLRUCache.ts and redisCache.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: censor IP addresses in logs of localLRUCache.ts and redisCache.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: hbarSpendingPlanRepository.spec.ts after resolving conflicts from main branch
Signed-off-by: Victor Yanev <[email protected]>
* fix: metricService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: fix wrong value for limit duration in `hbar-limiter.md`
Co-authored-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
* chore: fix jsdocs
Co-authored-by: Logan Nguyen <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
* fix: hbarSpendingPlanRepository.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: ethAddressHbarSpendingPlanRepository.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: ipAddressHbarSpendingPlanRepository.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: jsdocs in hbarLimitService/index.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: do not reset metrics
Signed-off-by: Victor Yanev <[email protected]>
* Merge branch '2970-Note-what-configurations-are-used' into 3055-Implement-configuration-to-pre-populate-the-cache-with-spending-plans
Signed-off-by: Victor Yanev <[email protected]>
# Conflicts:
# packages/relay/src/lib/db/repositories/hbarLimiter/hbarSpendingPlanRepository.ts
# packages/relay/tests/lib/repositories/hbarLimiter/hbarSpendingPlanRepository.spec.ts
* chore: remove mocks from hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: remove mocks from hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: delete obsolete IP and ETH address associations from the cache
Signed-off-by: Victor Yanev <[email protected]>
* chore: rename `SubscriptionType` to `SubscriptionTier`
Signed-off-by: Victor Yanev <[email protected]>
* chore: add jsdocs in hbarSpendingPlanConfigService.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: address sonar issue
Signed-off-by: Victor Yanev <[email protected]>
* chore: extend tests in relay.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: extend tests in server.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: extend tests in hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: extend tests in hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: reduce code duplication in hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: remove unneeded mocks from hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: extend tests in hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: remove unused argument of helper method in hbarSpendingPlanConfigService.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: move call of populatePreconfiguredSpendingPlans() back to constructor
Signed-off-by: Victor Yanev <[email protected]>
* chore: remove unused import
Signed-off-by: Victor Yanev <[email protected]>
* chore: address comments
Signed-off-by: Victor Yanev <[email protected]>
* chore: extend tests in localLRUCache.spec.ts and redisCache.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: case sensitivity in ethAddressHbarSpendingPlanRepository.ts
Signed-off-by: Victor Yanev <[email protected]>
* chore: only trace log when configuration file is missing
Signed-off-by: Victor Yanev <[email protected]>
* chore: log `Pre-configured spending plans populated successfully` only if any spending plans have been deleted or added
Signed-off-by: Victor Yanev <[email protected]>
* test: extend repository tests with new methods
Signed-off-by: Victor Yanev <[email protected]>
* test: extend relay.spec.ts
Signed-off-by: Victor Yanev <[email protected]>
* fix: failing unit tests
Signed-off-by: Victor Yanev <[email protected]>
* chore: use override envs helper method in tests
Signed-off-by: Victor Yanev <[email protected]>
---------
Signed-off-by: Victor Yanev <[email protected]>
Signed-off-by: Victor Yanev <[email protected]>
Co-authored-by: Logan Nguyen <[email protected]>1 parent 2e2fc07 commit 1f776e6
File tree
27 files changed
+1792
-291
lines changed- docs
- design
- packages
- relay
- src
- lib
- clients/cache
- config
- db
- entities/hbarLimiter
- repositories/hbarLimiter
- types/hbarLimiter
- services/hbarLimitService
- types
- tests/lib
- clients
- config
- repositories/hbarLimiter
- services
- cacheService
- hbarLimitService
- server/tests/integration
- tools/wagmi-example
27 files changed
+1792
-291
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
| |||
172 | 181 | | |
173 | 182 | | |
174 | 183 | | |
175 | | - | |
| 184 | + | |
176 | 185 | | |
177 | 186 | | |
178 | 187 | | |
| |||
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
214 | | - | |
| 223 | + | |
215 | 224 | | |
216 | 225 | | |
217 | 226 | | |
| |||
233 | 242 | | |
234 | 243 | | |
235 | 244 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
241 | 250 | | |
242 | | - | |
| 251 | + | |
243 | 252 | | |
244 | 253 | | |
245 | 254 | | |
| |||
306 | 315 | | |
307 | 316 | | |
308 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
309 | 326 | | |
310 | 327 | | |
311 | 328 | | |
| 329 | + | |
312 | 330 | | |
313 | 331 | | |
314 | 332 | | |
315 | | - | |
| 333 | + | |
316 | 334 | | |
317 | 335 | | |
| 336 | + | |
318 | 337 | | |
319 | 338 | | |
320 | | - | |
| 339 | + | |
321 | 340 | | |
322 | 341 | | |
| 342 | + | |
323 | 343 | | |
324 | 344 | | |
325 | 345 | | |
326 | | - | |
| 346 | + | |
327 | 347 | | |
328 | 348 | | |
| 349 | + | |
329 | 350 | | |
330 | 351 | | |
331 | | - | |
| 352 | + | |
332 | 353 | | |
333 | 354 | | |
334 | 355 | | |
335 | 356 | | |
336 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
337 | 362 | | |
338 | | - | |
| 363 | + | |
339 | 364 | | |
340 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
341 | 374 | | |
342 | | - | |
| 375 | + | |
| 376 | + | |
343 | 377 | | |
| 378 | + | |
344 | 379 | | |
345 | 380 | | |
346 | 381 | | |
347 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
348 | 419 | | |
349 | 420 | | |
350 | 421 | | |
351 | 422 | | |
352 | 423 | | |
353 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
354 | 430 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
358 | 434 | | |
359 | 435 | | |
360 | 436 | | |
361 | | - | |
362 | | - | |
363 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
364 | 440 | | |
365 | 441 | | |
366 | 442 | | |
| |||
369 | 445 | | |
370 | 446 | | |
371 | 447 | | |
372 | | - | |
| 448 | + | |
373 | 449 | | |
374 | 450 | | |
375 | 451 | | |
376 | | - | |
| 452 | + | |
377 | 453 | | |
378 | | - | |
379 | | - | |
| 454 | + | |
| 455 | + | |
380 | 456 | | |
381 | 457 | | |
382 | 458 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
151 | 161 | | |
152 | | - | |
| 162 | + | |
153 | 163 | | |
154 | | - | |
155 | 164 | | |
156 | 165 | | |
157 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
167 | 172 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
192 | 199 | | |
193 | 200 | | |
194 | 201 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 202 | + | |
| 203 | + | |
201 | 204 | | |
202 | 205 | | |
203 | 206 | | |
| |||
0 commit comments