-
Notifications
You must be signed in to change notification settings - Fork 279
Jon/gift cards #5883
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
Jon/gift cards #5883
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
7a499d1 to
32f616e
Compare
32f616e to
3aa09e2
Compare
572e99f to
6d1303c
Compare
6d1303c to
c76e569
Compare
5c97e0f to
6731b1b
Compare
swansontec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First half.
| ), | ||
| phaze: asOptional( | ||
| asObject({ | ||
| apiKey: asString, | ||
| baseUrl: asString | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this goes in a future commit? Not a big deal, just a tiny optional cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can reorg after approval
| } | null>(null) | ||
|
|
||
| // Fetch allowed tokens from Phaze API | ||
| React.useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Tan Stack or useAsyncValue
929bc99 to
2d055d4
Compare
ddff5a2 to
3f9f177
Compare
3a1753e to
48407c1
Compare
48407c1 to
eca7b00
Compare
swansontec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one question.
| * Convert a JS number's `toString()` exponential form (e.g. "1e-7") into a | ||
| * plain decimal string (e.g. "0.0000001"). | ||
| */ | ||
| const expandExponential = (num: number): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, doesn't biggystring know how to handle 1e1 formatted numbers now? If not, could something simpler like .toFixed be used?
00a472f to
418fe81
Compare
- Replace bit-flag logging with string categories (e.g. 'phaze', 'coinrank') - Add LOG_CONFIG in env.json for enabling categories - Add header masking for sensitive API keys in logs - Improve type safety (unknown instead of any) - Add Phaze plugin API key configuration
- caip19Utils: Convert between EdgeAsset and CAIP-19 identifiers - parseLinkedText: Render HTML links as tappable React elements
- phazeApi: HTTP client with header masking - phazeGiftCardTypes: TypeScript types and cleaners - phazeGiftCardCache: Two-layer cache (memory + disk) for brands - phazeGiftCardOrderStore: Order augments persistence - phazeGiftCardProvider: High-level API for UI consumption - phazeOrderPollingService: Background voucher polling
- useBrand: Lazy-load full brand details on demand - useGiftCardProvider: Provider instance management
- PhazeActions: Start/stop order polling service - LoginActions: Hook polling to login/logout lifecycle
418fe81 to
60a5c03
Compare
60a5c03 to
6a4956c
Compare
UI text for market, purchase, and list scenes
- ThemedIcons: Add GiftCardIcon and GiftIcon - WebViewModal: Support HTML content with external link handling - SideMenu: Add gift card navigation entry - Button/layout component styling updates - Fix lint errors in files removed from exceptions list
Mimics raised/embossed text styling on physical credit cards. Used for gift card display components.
When onPress is undefined, row renders dimmed and non-interactive. Used for conditionally disabled gift card menu options.
- GiftCardDisplayCard: Full card view with PIN, status, shimmer states - GiftCardDetailsCard: Compact card details - GiftCardTile: Grid/list item for market browsing - CircularBrandIcon: Rounded brand logo - GiftCardAmountModal: Denomination picker - GiftCardMenuModal: Card options (redeem, view tx) - GiftCardSearchModal: Brand search with filtering
Required for gift card purchase scene HTML content rendering
- GiftCardListScene: View purchased cards (active/redeemed) - GiftCardMarketScene: Browse available brands with categories - GiftCardPurchaseScene: Select denomination and pay with crypto - Register routes in navigation stack
- Display gift cards in TransactionDetailsScene - Add giftCard action type handling in CategoriesActions - Add sliderTopNode prop to SendScene2 for purchase flow - Add Phaze merchant contact info
6a4956c to
4c8d85e
Compare
| cachedActiveOrders = [] | ||
| cachedRedeemedOrders = [] | ||
| hasLoadedOnce = false | ||
| hasFetchedBrands = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brand cache flag not reset when country changes
The module-level hasFetchedBrands variable is only reset in clearOrderCache() when the account changes, but not when countryCode changes. Since brands are country-specific and loadOrdersFromApi fetches brands based on countryCode, changing countries without resetting this flag causes brands for the new country to not be fetched. The useFocusEffect callback reads !hasFetchedBrands to determine includeBrands, so if brands were previously fetched for another country, they won't be refetched for the new one. This results in brandLookup returning undefined for the new country's product images.
Phaze Gift Card Integration Design
Overview
The Phaze gift card feature allows Edge users to purchase gift cards using cryptocurrency. The integration consists of:
Architecture
Data Storage
Brand Cache (
PhazeGiftCardCache)Purpose: Cache gift card brand data to minimize API calls and provide offline access.
Storage Location:
account.localDisklet(device-local, not synced)phazeGiftCards/brands-{countryCode}.jsonWhy localDisklet?
Cache Structure:
TTL Policy:
Cache Flow:
Order "Augments" (
PhazeGiftCardOrderStore)Purpose: Store local metadata that associates blockchain transactions with gift card orders, and Edge-specific metadata like redeemed date. Also includes brand information like image uri for quick access without API dependencies.
Storage Location:
account.disklet(synced across devices)phazeGiftCardAugments/{orderId}.jsonWhy synced disklet?
Augment Data:
User Identities
Storage Location:
account.disklet(synced)phaze-identity-{uuid}.jsonContents: Phaze user registration data including
userApiKeyMultiple Identities: There should typically only be one identity in most cases. An edge case that can occur from multi-device usage before sync completes. Handled as follows:
getAllOrdersFromAllIdentities()API Integration
Brand Fetching Strategy
Market Display (
getMarketBrands):Full Details (
getBrandDetails):fullDetailProductIdsflagBackground Prefetch:
Order Status Flow
Order Creation:
Payment Broadcast:
saveOrderAugment()persists txid + brand infoVoucher Polling:
PhazeOrderPollingServicepolls for vouchers on open orders (redemption link + code)tx.savedActionwith redemption info, when availableList Scene Display:
Scene Responsibilities
GiftCardListScene
GiftCardMarketScene
GiftCardPurchaseScene
useBrandhook for lazy detail loadingCHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneRequirements
If you have made any visual changes to the GUI. Make sure you have:
Note
Introduces a full gift card experience powered by Phaze, including browsing, purchasing, and managing cards.
GiftCardMarketScene,GiftCardPurchaseScene,GiftCardListScene; wired into navigation and Home “Spend” entrygiftCardsavedActionon send; displays details viaGiftCardDetailsCardinTransactionDetailsSceneSceneContainerandSceneWrapperdock handlingWebViewModal(supports HTML and external links)skipStateProvince), ramp scenes updated to use unified region UIreact-native-render-htmldependency (Podfile + package.json); multiple snapshot updatesWritten by Cursor Bugbot for commit 4c8d85e. This will update automatically on new commits. Configure here.