Skip to content

Store onramp user country selection#115

Merged
ishantiw merged 9 commits into
developmentfrom
LISK-2728-store-onramp-user-country-selection
Dec 11, 2025
Merged

Store onramp user country selection#115
ishantiw merged 9 commits into
developmentfrom
LISK-2728-store-onramp-user-country-selection

Conversation

@ikem-legend

Copy link
Copy Markdown
Member

Summary

This PR enhances the onramp flow by persisting the user's country/region selection in a cookie. When users return to the buy flow, their previously selected country is automatically restored, improving user experience.

Rationale

Users who frequently use the onramp feature shouldn't need to re-select their country each time they initiate a purchase. By storing the selection in a cookie, we provide a smoother, more personalized experience that remembers user preferences across sessions.

Changes

  • Added react-cookie dependency and created shared cookie configuration (defaultCookieOptions)
  • Wrapped AccountDialog with CookiesProvider in ConnectButton component
  • Updated SelectBuyRegionStep to:
    • Read country from panna_user_country cookie on mount (prioritized over browser detection)
    • Save selected country to cookie when user proceeds to next step
  • Added comprehensive unit tests for cookie logic (shouldSetCookie, getInitialCountry)
  • Refactored siwe-auth.ts to use shared cookie options

Impact

  • No breaking changes to existing functionality
  • Country selection priority is now: cookie > browser detection > default (US) > first available
  • Cookie is set with secure, strict same-site options for security

Testing

  • Added 10 new unit tests for cookie-related logic in select-buy-region-step.test.tsx
  • Tests cover:
    • shouldSetCookie: determining when to set/update cookie
    • getInitialCountry: priority order for initial country selection
  • All 17 tests pass in the test file
  • Lint and format checks pass

Screenshots/Video

N/A - Cookie storage is not visible in UI, but behavior can be verified by:

  1. Opening the buy flow and selecting a country
  2. Closing and reopening the buy flow
  3. Observing the previously selected country is pre-filled

Checklist

  • Code follows the project's coding standards

  • Unit tests covering the new feature have been added

  • All existing tests pass

  • The documentation has been updated to reflect the new feature

Additional Notes

Cookie name: panna_user_country
Cookie options: { path: '/', secure: true, sameSite: 'strict' }

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds cookie persistence for user country/region selection in the onramp flow, allowing users' country preferences to be remembered across sessions. The implementation uses the react-cookie library and introduces shared cookie configuration.

  • Added react-cookie dependency and created centralized cookie configuration
  • Wrapped AccountDialog with CookiesProvider to enable cookie access
  • Updated country selection logic to read from and write to panna_user_country cookie

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-lock.yaml Added react-cookie@8.0.1 dependency and its type definitions
packages/panna-sdk/package.json Added react-cookie to package dependencies
packages/panna-sdk/src/react/consts/cookies.ts Created shared cookie configuration with secure defaults
packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Integrated cookie storage for country selection with priority logic
packages/panna-sdk/src/react/components/buy/select-buy-region-step.test.tsx Added unit tests for cookie helper logic
packages/panna-sdk/src/react/components/auth/connect-button.tsx Wrapped AccountDialog with CookiesProvider for cookie access
packages/panna-sdk/src/core/auth/siwe-auth.ts Refactored to use shared cookie configuration
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/panna-sdk/src/core/auth/siwe-auth.ts Outdated
Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Outdated
Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Outdated
Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Outdated
Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.test.tsx Outdated
Comment thread packages/panna-sdk/src/core/consts/cookies.ts Outdated
Comment thread packages/panna-sdk/src/core/auth/siwe-auth.ts Outdated
Comment thread packages/panna-sdk/src/core/consts/cookies.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Outdated
Comment thread packages/panna-sdk/src/core/auth/siwe-auth.ts Outdated
Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Outdated
Comment thread packages/panna-sdk/src/react/components/buy/select-buy-region-step.tsx Outdated
@ishantiw ishantiw enabled auto-merge (squash) December 11, 2025 10:10
@ishantiw ishantiw merged commit 901e96d into development Dec 11, 2025
2 checks passed
@ishantiw ishantiw deleted the LISK-2728-store-onramp-user-country-selection branch December 11, 2025 10:13
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.

4 participants