feat: add compliance batch query utilities (Closes #50) - #158
Open
panditdhamdhere wants to merge 1 commit into
Open
feat: add compliance batch query utilities (Closes #50)#158panditdhamdhere wants to merge 1 commit into
panditdhamdhere wants to merge 1 commit into
Conversation
Add checkWhitelistBatch so admin compliance tables can resolve many investor addresses without unbounded RPC fan-out or all-or-nothing failure. Each input yields exactly one typed item in input order. Addresses are validated with StrKey before any RPC call, so invalid, muxed, and contract inputs are rejected per item instead of throwing mid-batch. Query failures carry the existing safe network diagnostic, and the batch roll-up reports counts and classified failure codes only, never addresses or raw provider errors. Concurrency is bounded (default 4) and identical addresses are queried once. No automatic retry is performed, since retrying inside a batch multiplies load exactly when a provider is already rate limiting.
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.
Description
Adds typed batch compliance queries for admin dashboards that need to check
multiple investor whitelist states without unbounded RPC fan-out or
all-or-nothing failure.
ComplianceModule.checkWhitelistBatch()validates each input before RPC,preserves input order, limits concurrency, deduplicates repeated addresses, and
represents failures independently. Batch diagnostics contain only aggregate
counts and classified failure codes—never addresses, raw provider errors, URLs,
headers, or credentials.
Design decisions
4and is bounded between 1 and 20.NetworkFailureDiagnosticdata.non-whitelisted results.
load during rate limiting.
item.index.Files added
src/compliance/batch.tssrc/types/compliance-batch.tssrc/errors/compliance.tssrc/diagnostics/compliance.tstests/compliance-batch.test.tsdocs/compliance-batch-queries.mdFiles updated
src/compliance.tssrc/client-factory.tssrc/index.tssrc/testing/mock-client.tstests/mock-client.test.tsREADME.mdCONTRIBUTING.mddocs/api-reference.mddocs/testing.mddocs/test-first-contribution-guide.mddocs/acceptance-criteria-traceability.mdCloses: #50
Evidence Checklist
1. Issue Reference
Closes #50).2. Implementation Summary
3. Tests
Tests cover:
retryAfterSeconds;4. Commands Run
Command output
5. CI Status
6. Acceptance Criteria Coverage — Traceability Table
src/compliance.ts,src/compliance/batch.ts,src/types/compliance-batch.tstests/compliance-batch.test.ts,tests/mock-client.test.tsdocs/compliance-batch-queries.md,docs/api-reference.mdcheckWhitelistBatch()returns one typed item per input and a batch summary.src/compliance/batch.tsdocs/compliance-batch-queries.mdStrKeyvalidation occurs before RPC; malformed, muxed, and contract addresses receive distinct item codes.src/compliance/batch.ts,src/diagnostics/compliance.tsdocs/compliance-batch-queries.mdtests/compliance-batch.test.tsreturns typed results in input order for mixed valid and invalid inputdocs/test-first-contribution-guide.mdsrc/compliance/batch.tsdocs/compliance-batch-queries.md,README.mdsrc/diagnostics/compliance.ts,src/compliance/batch.tsdocs/compliance-batch-queries.mdReviewer Notes
Existing single-query behavior
The batch path uses a stricter internal query than
checkWhitelist()so anunsuccessful simulation or non-boolean response becomes a per-item failure
instead of being displayed as “not whitelisted.”
The existing public
checkWhitelist()behavior remains fail-closed and returnsfalsefor unsuccessful or non-boolean responses.Retry behavior
The batch utility deliberately does not retry automatically. Applications
should retain successful rows, honor
retryAfterSeconds, and retry only failedrows after backoff.
Diagnostics privacy
Valid addresses remain available on per-item application results because admin
tables need them. Invalid arbitrary input is omitted. The batch-level diagnostic
is address-free and intended for logs, telemetry, and support reports.
Existing tooling limitation
npm run lintandnpm run formatcannot currently run on this branch ormainbecause the scripts invokeeslintandprettier, but those packages arenot listed in
devDependencies. CI runsnpm run check, which passes.