feat: maskWebhookUrl helper, webhook payload builder, structured logs, and wallet holdings endpoint#453
Open
chinelo002 wants to merge 4 commits into
Conversation
|
@chinelo002 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
44f8ab4 to
d4d3172
Compare
…URLs (accesslayerorg#444) Returns scheme://host only; removes path, query string, and fragment. Returns '[invalid url]' on parse failure.
…ation/deletion logs (accesslayerorg#449 accesslayerorg#450) - buildWebhookPayload(TradeEvent) centralises the TradeEvent→WebhookEventPayload mapping; used in dispatchWebhookEvent to replace the inline object literal - logger.info emitted on successful webhook creation and deletion with creator_id, webhook_id, event_types/deleted_at; callback URL is never logged
…wallet integration test (accesslayerorg#442) Add wallet-holdings.service.ts, wallet-holdings.controllers.ts, and register GET /:address/holdings in wallets.routes.ts. Integration test covers empty wallet returning 200+[] and malformed address returning 400.
Add masked callback URL to warn and error log fields so delivery failures include the endpoint origin without leaking tokens embedded in paths or query strings.
858c32c to
cad9fb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds four features: a URL masking utility for webhook callback URLs, a buildWebhookPayload helper for serialising trade events, structured info logs on webhook registration/deletion, and a new
GET /wallets/:address/holdingsendpoint with an integration test for the empty-wallet case.closes #442
closes #444
closes #449
closes #450
Changes
Add helper for masking webhook callback URLs in logs and error responses #444 — maskWebhookUrl helper: Added
src/utils/webhook-mask.utils.tswithmaskWebhookUrl(url): string— returnsscheme://hostonly usingnew URL(url).origin, stripping path, query string, and fragment. Returns'[invalid url]'on parse failure. 7 unit tests cover: query string stripped, path stripped, no-path URL, invalid input, empty string, non-standard port preserved, fragment stripped.Add helper for building the trade webhook POST payload from an indexed trade event #450 — buildWebhookPayload helper: Added
src/modules/webhooks/webhook-payload.utils.tswithbuildWebhookPayload(TradeEvent): WebhookEventPayloadthat maps camelCase event fields to the snake_case payload contract. Updatedwebhook.service.tsto replace the inline payload object literal indispatchWebhookEventwith this helper. 3 unit tests confirm buy/sell event mapping and exact output key set.Add structured log for creator trade webhook registration with creator ID and event types #449 — Structured webhook registration/deletion logs: Edited
webhook.service.tsto emitlogger.info({ creator_id, webhook_id, event_types, registered_at }, 'Webhook registered')after a successfulcreateWebhookandlogger.info({ creator_id, webhook_id, deleted_at }, 'Webhook deleted')afterdeleteWebhook. The callback URL does not appear in any log line.Add integration test for wallet holdings endpoint returning empty array for wallet with no keys #442 — Wallet holdings endpoint + empty-wallet integration test: Added
wallet-holdings.service.ts(callsfetchOwnershipand maps toHoldingItem[]),wallet-holdings.controllers.ts(validates address, calls service, returns 200), and registeredGET /:address/holdingsinwallets.routes.ts. Integration test (wallet-holdings.integration.test.ts) covers: valid address with no holdings → 200 +holdings: []+total_portfolio_value: '0'; valid address with holdings → 200 + populated data; malformed address → 400 +VALIDATION_ERROR; service error forwarded tonext().Test plan
pnpm testorjestfor all new test files.