Skip to content

feat(checkout): Migrate to v2 sanction API and add token info #2670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

fang377
Copy link

@fang377 fang377 commented Jul 22, 2025

Hi👋, please ensure the PR title follows the below standards:

  • PR is titled with conventional commit style naming: type(scope): message. For example: feat(passport): my new feature
  • If you have introduced modification that necessitates immediate adjustments by this SDK's users to their applications, clients, or integrations to avert disruptions to existing features or functionalities, add a ! after the type(scope), for example feat(passport)!: my new breaking feature

Summary

What Changed

  • Endpoint: /v1/sanctions/check → /v2/sanctions/check
  • Request Format: { addresses: string[] } → [{ address, token_addr?, amount? }]
  • Enhanced Data: Now supports token address and amount per address

Key Updates (under checkout)

  • Core API: Updated fetchRiskAssessment() with optional tokenData parameter
  • Widgets: BridgeForm, OnRamp, Swap, AddTokens with token/amount data
  • SDK: Updated getRiskAssessment() method signature

Backward Compatibility: yes -> All existing code continues to work

Detail and impact of the change

Added

Changed

Deprecated

Removed

Fixed

Security

Anything else worth calling out?

@fang377 fang377 requested a review from a team as a code owner July 22, 2025 05:08
Copy link

nx-cloud bot commented Jul 22, 2025

View your CI Pipeline Execution ↗ for commit d689bb3

Command Status Duration Result
nx affected -t build,lint,test ✅ Succeeded 2m 6s View ↗
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 1m 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-28 06:36:49 UTC

@fang377 fang377 changed the title Migrate to v2 sanction API and add token info feat(checkout): Migrate to v2 sanction API and add token info Jul 22, 2025
const requestPayload: SanctionsCheckV2RequestItem[] = addresses.map((address) => {
const item: SanctionsCheckV2RequestItem = { address };

// Add token and amount data if available
Copy link
Contributor

Choose a reason for hiding this comment

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

In what scenario would the token and amount data not be available?

Should we still send through a request to the sanctions service without this information?

Copy link
Author

Choose a reason for hiding this comment

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

yea the request should still be sent even when token and amount data are not available,

In what scenario would the token and amount data not be available?

like the sale context (where token/amount are determined later in the flow), early-stage widget initialization (before user selects token/amount), and generic address validation (where we just want to check if an address is sanctioned regardless of specific transaction details) etc

};

// Add token and amount data
const tokenInfo = tokenData.find((t) => t.address.toLowerCase() === address.toLowerCase());
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like if tokenInfo can't be found, we'll send

        token_addr: '',
        amount: '0',

to the API.. what will happen? Will this cause an error for the user?

Copy link
Author

Choose a reason for hiding this comment

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

the token_addr and amount are not used in determining the risk level actually so there should not be any impact, but let me update the logic here to only call api when token info's valid

export const fetchRiskAssessment = async (
addresses: string[],
config: CheckoutConfiguration,
tokenData: Array<{ address: string; tokenAddr: string; amount: string }>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is address here the same as the address is addresses - can we remove one of them so that the caller doesn't have the provide the same info twice?

Copy link
Author

Choose a reason for hiding this comment

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

yep will update

checkout.config,
[{
address: toAddress,
tokenAddr: selectedToken?.address || '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be checking that a token has been selected before calling this - rather than going ahead with the empty string?

Copy link
Author

Choose a reason for hiding this comment

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

yep good callout, updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants