Skip to content

feat(gists): add POST /v1/gists/:id/report endpoint - #1057

Merged
BigBen-7 merged 1 commit into
PinSpace-Org:mainfrom
JoeX17:JoeX17/issue-1039-report-endpoint
Aug 16, 2026
Merged

feat(gists): add POST /v1/gists/:id/report endpoint#1057
BigBen-7 merged 1 commit into
PinSpace-Org:mainfrom
JoeX17:JoeX17/issue-1039-report-endpoint

Conversation

@JoeX17

@JoeX17 JoeX17 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Closes #1039

Summary

Adds a throttled POST /v1/gists/:id/report endpoint that calls the GistRegistry contract's report_gist method and returns the new report count. This lets the frontend report gists without talking to Soroban directly.

Changes

SorobanService (soroban.service.ts)

  • Added reportGist(gistId) public method with mock + live paths
  • Added reportGistLive() private method — builds a transaction calling report_gist, signs, submits, waits for confirmation, extracts the returned u32 count
  • Added scValToNumber() helper for extracting numeric return values

GistsService (gists.service.ts)

  • Added report(id) — validates the gist exists (404 if not), calls sorobanService.reportGist(), returns { count }

GistsController (gists.controller.ts)

  • Added POST /:id/report route
  • Throttled at 5 requests per 60 seconds (tighter than reads, matches write-level protection)
  • Swagger-decorated with @ApiOperation and @ApiParam

Tests (gists.service.spec.ts)

  • report returns the on-chain report count when the gist exists
  • report throws NotFoundException when the gist does not exist
  • All 12 tests pass (10 existing + 2 new)

Verification

  • npx tsc --noEmit — clean
  • npx jest --testPathPattern=gists.service.spec — 12/12 pass
  • The route is throttled (@Throttle({ default: { limit: 5, ttl: 60000 } }))
  • Missing gist returns 404 (NotFoundException), not 500
  • Mock mode returns { count: 1, mock: true } for local dev without a funded key

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, JoeX17 — the endpoint, throttling, 404 handling, and mock-mode support all look solid, and the tests are good.

There's a merge conflict against main in soroban.service.ts (GitHub shows this as CONFLICTING) — your reportGist method landed in the same spot where #1032 (merged after your branch was created) added isActive and listGistsByCell. It's a simple adjacency conflict, not a real logical clash — both sets of methods are independent and can coexist as-is. Could you rebase onto current main and keep both blocks (your reportGist/reportGistLive/scValToNumber alongside the existing isActive/listGistsByCell)? Should be a quick resolve.

Once it's rebased clean, this is good to merge.

@JoeX17
JoeX17 force-pushed the JoeX17/issue-1039-report-endpoint branch from 44b1045 to cc96615 Compare August 16, 2026 23:11

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase confirmed clean — no conflict markers, and reportGist/reportGistLive coexist cleanly alongside isActive/listGistsByCell from #1032, exactly as expected for a pure adjacency conflict.

Verified locally: npm run build clean, full suite 13 suites, 113 passed + 1 todo, 0 failures. CI is also green.

Approving and merging. Thanks, JoeX17.

@BigBen-7

Copy link
Copy Markdown
Contributor

Sorry for the back-and-forth — this is timing, not anything you did wrong: #1058 (event decoding) merged just a few minutes ago and changed getEventsSince's return type to GistRegistryEvent[], which now sits right next to where your reportGist method was added. Same trivial adjacency situation as before, nothing logically conflicting — just needs one more rebase onto current main.

This should be the last one — main is stable now that #1032, #1033, #1037, #1041, and #1043 are all merged. Once rebased and green, this is ready to go.

Add a throttled report endpoint that calls the GistRegistry contract's
report_gist method and returns the new count.

- SorobanService: add reportGist() with mock + live paths
- GistsService: add report() with 404 on missing gist
- GistsController: POST /:id/report, throttled at 5/min, Swagger docs
- Unit tests: success + not-found cases

Closes PinSpace-Org#1039
@JoeX17
JoeX17 force-pushed the JoeX17/issue-1039-report-endpoint branch from cc96615 to dd0526c Compare August 16, 2026 23:27

@BigBen-7 BigBen-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed fully rebased onto current main — no conflict markers, and git merge reports "already up to date." reportGist/reportGistLive coexist cleanly with #1058's updated getEventsSince(GistRegistryEvent[]).

Verified locally: npm run build clean, full suite 14 suites, 124 passed + 1 todo, 0 failures.

Approving and merging — thanks for sticking with the back-and-forth, JoeX17, that was entirely a sequencing issue on our end, not anything you did wrong.

@BigBen-7
BigBen-7 merged commit 64d8f14 into PinSpace-Org:main Aug 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add POST /v1/gists/:id/report endpoint

3 participants