Skip to content

feat: update validate address endpoint#1263

Merged
kaladinlight merged 3 commits intodevelopfrom
update-validate-address
Feb 12, 2026
Merged

feat: update validate address endpoint#1263
kaladinlight merged 3 commits intodevelopfrom
update-validate-address

Conversation

@kaladinlight
Copy link
Collaborator

@kaladinlight kaladinlight commented Feb 12, 2026

Move away from elliptic as it is cost prohibitive and replace with direct SDN list until a more comprehensive AML screening tool can be determined.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added address validation against OFAC SDN sanctions list.
  • Refactor

    • Refactored application initialization to use async startup pattern.

@kaladinlight kaladinlight requested a review from a team as a code owner February 12, 2026 19:29
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

Warning

Rate limit exceeded

@kaladinlight has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The changes replace the Elliptic SDK for address validation with a new OFAC-based implementation. This includes introducing a new Ofac class that fetches and parses OFAC SDN data, swapping runtime dependencies, refactoring app startup into an async flow, and updating the controller to use OFAC validation.

Changes

Cohort / File(s) Summary
Dependency Management
node/proxy/api/package.json
Replaced elliptic-sdk dependency with fast-xml-parser to support OFAC XML parsing.
OFAC Implementation
node/proxy/api/src/ofac.ts
New class implementing OFAC SDN address validation with XML parsing, 24-hour refresh interval, address normalization via viem, and caching logic.
App Integration & Startup Refactoring
node/proxy/api/src/app.ts
Introduced OFAC integration, moved server and middleware initialization into async main() function, exported new ofac public instance, and resequenced initialization to await ofac.initialize() before route setup.
Controller Update
node/proxy/api/src/controller.ts
Replaced Elliptic import and instantiation with OFAC import; updated validateAddress() method to call ofac.validateAddress(address) instead.
Removed Legacy Code
node/proxy/api/src/elliptic.ts
Deleted entire Elliptic API client class including address caching, risk threshold validation, and AML service integration.

Sequence Diagram(s)

sequenceDiagram
    participant App as App Startup
    participant Ofac
    participant HTTP as HTTP Client
    participant Parser as XML Parser
    participant Cache as Address Cache
    participant Controller as Controller

    App->>Ofac: initialize()
    Ofac->>HTTP: fetch OFAC SDN XML
    HTTP-->>Ofac: XML content
    Ofac->>Parser: parse XML
    Parser->>Parser: extract Digital Currency Addresses
    Parser-->>Ofac: sanctioned addresses set
    Ofac->>Cache: store addresses
    Ofac->>Ofac: start 24h refresh interval
    Ofac-->>App: initialized

    Controller->>Ofac: validateAddress(address)
    Ofac->>Cache: check sanctioned set
    alt Address in sanctioned set
        Ofac-->>Controller: { valid: false }
    else Address not found
        Ofac-->>Controller: { valid: true }
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 hops through XML files with glee
Trading Elliptic for OFAC's decree,
Parsing sanctioned addresses with care,
Async startup flows everywhere,
Now validation's compliant and fair! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: update validate address endpoint' is vague and only partially describes the primary change. The main objective is replacing the Elliptic service with OFAC SDN list validation, but the title does not capture this substantive migration or clarify what the update entails. Consider a more descriptive title such as 'feat: replace Elliptic with OFAC SDN list for address validation' to clearly communicate the key architectural change and the reason for the update.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-validate-address

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kaladinlight kaladinlight force-pushed the update-validate-address branch from d2b8ef0 to a55a3df Compare February 12, 2026 19:51
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
node/proxy/api/package.json (1)

14-19: ⚠️ Potential issue | 🟡 Minor

Missing direct dependencies: axios and viem.

node/proxy/api/src/ofac.ts imports axios (line 1) and { getAddress, isAddress } from viem (line 4), but neither is declared in this package.json. While both are currently available via workspace hoisting from the root package.json, this creates a fragility risk: independent deployment of this package or changes to the workspace layout could break the build.

Proposed fix
   "dependencies": {
     "@shapeshiftoss/common-api": "^10.0.0",
     "@shapeshiftoss/prometheus": "^10.0.0",
+    "axios": "^1.6.2",
     "bottleneck": "^2.19.5",
-    "fast-xml-parser": "^4.3.0"
+    "fast-xml-parser": "^4.3.0",
+    "viem": "^2.33.2"
   }
🤖 Fix all issues with AI agents
In `@node/proxy/api/src/app.ts`:
- Line 88: The top-level call to main() currently has no rejection handling;
wrap the invocation so any thrown/rejected error (e.g., from ofac.initialize()
or server bind in main()) is caught, logged, and exits with non-zero status.
Update the bare main() invocation to main().catch(err => { /* log error */
process.exit(1) }); — use the existing logger if available (e.g.,
processLogger.error) or console.error to record err and a clear message before
calling process.exit(1).

In `@node/proxy/api/src/ofac.ts`:
- Around line 49-52: The axios call in fetchAndParseOfacList currently has no
timeout and can hang; update the axios.get in fetchAndParseOfacList to include a
finite timeout option (e.g., timeout: 10000 ms or a configured value) so the
request to OFAC_SDN_URL fails fast on network stalls and then continue to call
this.parseXml(data) only on successful responses; ensure you add the timeout to
the options object passed to axios.get and keep existing responseType: 'text'.
- Around line 35-38: The catch block that currently does "this.logger.error({
err }, 'Failed to initialize OFAC service, failing open')" then "throw err" is
inconsistent; either make it truly fail-open by swallowing the error (remove the
throw), set the internal sanctioned-set/state to empty/allow-all, and ensure the
existing refresh/retry loop (e.g., the OFAC refresh/polling mechanism) will
attempt to reload later, or make it fail-closed by keeping the throw and
changing the log text to accurately say "failing closed" (or similar). Locate
the catch around OFAC initialization (the block with this.logger.error and throw
err) and implement one of these two fixes so log and runtime behavior match.
🧹 Nitpick comments (2)
node/proxy/api/src/ofac.ts (1)

41-47: validateAddress doesn't need to be async.

The method body is fully synchronous — it only reads from an in-memory Set. The async keyword wraps the return value in an unnecessary Promise. If the interface contract requires Promise<{ valid: boolean }> for future extensibility, this is fine, but worth noting.

node/proxy/api/src/controller.ts (1)

4-4: Circular import: controller.ts → app.ts → (routes) → controller.ts.

This works because ofac is a module-level const that's fully initialized before any request arrives, and Node.js module caching breaks the cycle. It's a common Express pattern but worth noting — if app.ts is ever refactored to use the ofac reference at import time (rather than at request time), this could break. Consider extracting ofac into a dedicated module (e.g., ./ofac-instance.ts) to eliminate the cycle entirely.

@kaladinlight kaladinlight merged commit 9510965 into develop Feb 12, 2026
3 checks passed
@kaladinlight kaladinlight deleted the update-validate-address branch February 12, 2026 20:03
@kaladinlight kaladinlight linked an issue Feb 12, 2026 that may be closed by this pull request
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.

Update /validate endpoint

1 participant