-
Notifications
You must be signed in to change notification settings - Fork 277
Sam/ramp plugins #5691
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
Closed
Closed
Sam/ramp plugins #5691
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5ea9d21
Add learning technique to AGENTS.md
samholmes 32d5292
Add comprehensive documentation system and localization guidelines
samholmes c810d05
Add opencode.json
samholmes faf5b39
Document Edge scene architecture patterns and header management rules
samholmes a519144
Added .run.env to .gitignore
samholmes 896f608
Factor out PillButton component from SwapInput
samholmes 130458d
Redesign payment option cards
samholmes 3adfe59
Add DEBUG_LOGBOX to ENV
samholmes 6ef0410
feat(ramp): add new plugin architecture for fiat on/off ramps
samholmes 1ff5bcd
Restructure into Initialization and Workflow sections for clarity
samholmes 2dfd4da
fixup! feat(ramp): add new plugin architecture for fiat on/off ramps
samholmes 12934f3
fixup! feat(ramp): add new plugin architecture for fiat on/off ramps
samholmes 11442e8
fixup! feat(ramp): add new plugin architecture for fiat on/off ramps
samholmes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Component Styling Guidelines | ||
|
|
||
| ## File Structure | ||
|
|
||
| - **Types first**: Type definitions at the top serve as documentation | ||
| - **Exports second**: Component exports immediately after types for visibility | ||
| - **Styled components third**: All styled components after the main export (more relevant to component structure) | ||
| - **Utility functions fourth**: Helper functions and components scoped to the file come after styled components | ||
| - **Styles last**: cacheStyles objects at the bottom of the file | ||
|
|
||
| ## Styling Patterns | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you move these docs to your own personal shared dev docs location (location TBD), add some TODOs to craft new rules/scripts for:
|
||
|
|
||
| - **Always use `styled` HOC** from `@src/components/hoc/styled.tsx` instead of inline styles | ||
| - **Run `yarn eslint --fix`** on all files to format and fix lint errors automatically | ||
| - **EdgeText with styled**: EdgeText can be used with styled HOC since it accepts a `style` prop | ||
| - **Raw text fallback**: If styled EdgeText causes raw text ESLint errors, use regular EdgeText with cacheStyles | ||
| - **Avoid inline styles**: Use styled HOC or cacheStyles, never inline style objects | ||
|
|
||
| ## Example File Structure | ||
|
|
||
| ```tsx | ||
| // Types first | ||
| interface Props { | ||
| // ... | ||
| } | ||
|
|
||
| // Exports second | ||
| export const MyComponent = (props: Props) => { | ||
| return ( | ||
| <Container> | ||
| <StyledText>{formatText('Hello')}</StyledText> | ||
| </Container> | ||
| ) | ||
| } | ||
|
|
||
| // Styled components third (more relevant to component structure) | ||
| const Container = styled(View)({ | ||
| // styles | ||
| }) | ||
|
|
||
| const StyledText = styled(EdgeText)({ | ||
| // styles | ||
| }) | ||
|
|
||
| // Utility functions fourth (scoped to this file) | ||
| const formatText = (text: string): string => { | ||
| return text.toUpperCase() | ||
| } | ||
|
|
||
| // Styles last (if needed for complex cases) | ||
| const styles = cacheStyles({ | ||
| // fallback styles | ||
| }) | ||
| ``` | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # Localization Guidelines | ||
|
|
||
| ## Core Principle | ||
|
|
||
| **ALWAYS put strings displayed in the UI in the `@src/locales/en_US.ts` file for localization.** Use `lstrings.string_name` to access the string. | ||
|
|
||
| ## String Naming Convention | ||
|
|
||
| ### Basic Strings | ||
|
|
||
| - Use descriptive, hierarchical naming: `component_context_description` | ||
| - Example: `trade_region_select_buy_crypto`, `settings_account_title` | ||
|
|
||
| ### Parameterized Strings | ||
|
|
||
| If a string uses sprintf and `%s` or replacements, suffix the string with parameter indicators: | ||
|
|
||
| - **Single parameter**: `_s` suffix | ||
| - Example: `buy_1s: 'Buy %1$s'` | ||
| - **Two parameters**: `_2s` suffix | ||
| - Example: `error_balance_below_minimum_to_stake_2s: 'Your balance of %1$s does not meet the minimum %2$s required to stake.'` | ||
| - **Multiple parameters**: `_ns` suffix (where n is the number) | ||
| - Example: `_3s`, `_4s`, `_5s` etc. | ||
|
|
||
| ## Implementation Steps | ||
|
|
||
| 1. **Identify hardcoded strings** in UI components | ||
| 2. **Add strings to `en_US.ts`** with appropriate naming and parameter suffixes | ||
| 3. **Replace hardcoded strings** with `lstrings.string_name` references | ||
| 4. **Import lstrings** from `'../../locales/strings'` (adjust path as needed) | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Before (Hardcoded) | ||
|
|
||
| ```tsx | ||
| <EdgeText>Buy Crypto</EdgeText> | ||
| <EdgeText>Start in 4 Easy Steps</EdgeText> | ||
| <EdgeText>{`Step 1: Select Your Region`}</EdgeText> | ||
| ``` | ||
|
|
||
| ### After (Localized) | ||
|
|
||
| ```tsx | ||
| // In en_US.ts | ||
| export const strings = { | ||
| trade_region_select_buy_crypto: 'Buy Crypto', | ||
| trade_region_select_start_steps: 'Start in 4 Easy Steps', | ||
| trade_region_select_step_1: ' Select Your Region for personalized options', | ||
| // ... | ||
| } | ||
|
|
||
| // In component | ||
| import { lstrings } from '../../locales/strings' | ||
|
|
||
| <EdgeText>{lstrings.trade_region_select_buy_crypto}</EdgeText> | ||
| <EdgeText>{lstrings.trade_region_select_start_steps}</EdgeText> | ||
| <EdgeText>{lstrings.trade_region_select_step_1}</EdgeText> | ||
| ``` | ||
|
|
||
| ### Parameterized Example | ||
|
|
||
| ```tsx | ||
| // In en_US.ts | ||
| buy_1s: 'Buy %1$s', | ||
| error_balance_below_minimum_2s: 'Balance %1$s below minimum %2$s', | ||
|
|
||
| // In component | ||
| <EdgeText>{sprintf(lstrings.buy_1s, currencyCode)}</EdgeText> | ||
| <EdgeText>{sprintf(lstrings.error_balance_below_minimum_2s, balance, minimum)}</EdgeText> | ||
| ``` | ||
|
|
||
| ## Benefits | ||
|
|
||
| - **Internationalization ready**: All strings can be translated to other languages | ||
| - **Consistency**: Centralized string management prevents duplicates | ||
| - **Maintainability**: Easy to update strings across the entire app | ||
| - **Type safety**: TypeScript ensures string keys exist | ||
|
|
||
| ## Remember | ||
|
|
||
| This is a **mandatory** practice for all UI strings. No exceptions should be made for hardcoded strings in user-facing components. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Payment Type Icons | ||
|
|
||
| This document explains how to use the payment type icon mapping system for displaying appropriate icons for different payment methods in the fiat plugin system. | ||
|
|
||
| ## Overview | ||
|
|
||
| The payment type icon system provides a consistent way to map `FiatPaymentType` values to their corresponding theme icon keys. This ensures that payment methods are displayed with the correct visual representation across the application. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| ```typescript | ||
| import { getPaymentTypeIcon } from '../util/paymentTypeIcons' | ||
| import { useTheme } from '../services/ThemeContext' | ||
|
|
||
| const MyComponent = () => { | ||
| const theme = useTheme() | ||
| const paymentType = 'applepay' // FiatPaymentType | ||
|
|
||
| const icon = getPaymentTypeIcon(paymentType, theme) | ||
| // Returns: { uri: 'path/to/apple-pay-icon.png' } | ||
| } | ||
| ``` | ||
|
|
||
| ### Integration with PaymentOptionCard | ||
|
|
||
| When rendering payment options from quotes, use the first payment type to determine the icon: | ||
|
|
||
| ```typescript | ||
| const QuoteResult = ({ quote }) => { | ||
| const theme = useTheme() | ||
|
|
||
| // Get icon for the first payment type, fallback to partner icon | ||
| const paymentTypeIcon = quote.paymentTypes[0] | ||
| ? getPaymentTypeIcon(quote.paymentTypes[0], theme) | ||
| : undefined | ||
| const icon = paymentTypeIcon ?? { uri: quote.partnerIcon } | ||
|
|
||
| return ( | ||
| <PaymentOptionCard | ||
| title={quote.paymentTypes.join(', ')} | ||
| icon={icon} | ||
| // ... other props | ||
| /> | ||
| ) | ||
| } | ||
| ``` | ||
|
|
||
| ## Payment Type Mappings | ||
|
|
||
| ### Direct Mappings | ||
|
|
||
| These payment types have dedicated icons in the theme: | ||
|
|
||
| - `applepay` → `paymentTypeLogoApplePay` | ||
| - `credit` → `paymentTypeLogoCreditCard` | ||
| - `fasterpayments` → `paymentTypeLogoFasterPayments` | ||
| - `googlepay` → `paymentTypeLogoGooglePay` | ||
| - `ideal` → `paymentTypeLogoIdeal` | ||
| - `interac` → `paymentTypeLogoInterac` | ||
| - `payid` → `paymentTypeLogoPayid` | ||
| - `paypal` → `paymentTypeLogoPaypal` | ||
| - `pix` → `paymentTypeLogoPix` | ||
| - `revolut` → `paymentTypeLogoRevolut` | ||
| - `venmo` → `paymentTypeLogoVenmo` | ||
|
|
||
| ### Fallback Mappings | ||
|
|
||
| These payment types use the generic bank transfer icon as a fallback: | ||
|
|
||
| - `ach` → `paymentTypeLogoBankTransfer` | ||
| - `colombiabank` → `paymentTypeLogoBankTransfer` | ||
| - `directtobank` → `paymentTypeLogoBankTransfer` | ||
| - `iach` → `paymentTypeLogoBankTransfer` | ||
| - `iobank` → `paymentTypeLogoBankTransfer` | ||
| - `mexicobank` → `paymentTypeLogoBankTransfer` | ||
| - `pse` → `paymentTypeLogoBankTransfer` | ||
| - `sepa` → `paymentTypeLogoBankTransfer` | ||
| - `spei` → `paymentTypeLogoBankTransfer` | ||
| - `turkishbank` → `paymentTypeLogoBankTransfer` | ||
| - `wire` → `paymentTypeLogoBankTransfer` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### `getPaymentTypeIcon(paymentType: FiatPaymentType, theme: Theme): ImageProp | undefined` | ||
|
|
||
| Returns the theme icon for a given payment type. | ||
|
|
||
| **Parameters:** | ||
| - `paymentType`: The payment type to get the icon for | ||
| - `theme`: The theme object containing the icon images | ||
|
|
||
| **Returns:** | ||
| - `ImageProp`: The icon image object (`{ uri: string } | number`) | ||
| - `undefined`: If the payment type doesn't have a corresponding icon | ||
|
|
||
| ### `getPaymentTypeThemeKey(paymentType: FiatPaymentType): keyof Theme | null` | ||
|
|
||
| Returns just the theme key for a payment type without requiring the theme object. | ||
|
|
||
| **Parameters:** | ||
| - `paymentType`: The payment type to get the theme key for | ||
|
|
||
| **Returns:** | ||
| - `keyof Theme`: The theme key string | ||
| - `null`: If the payment type doesn't have a corresponding theme key | ||
|
|
||
| ## Adding New Payment Types | ||
|
|
||
| To add support for a new payment type: | ||
|
|
||
| 1. Add the payment type to the `FiatPaymentType` union in `fiatPluginTypes.ts` | ||
| 2. Add the corresponding icon to the theme in `types/Theme.ts` | ||
| 3. Update the `paymentTypeToThemeKey` mapping in `util/paymentTypeIcons.ts` | ||
| 4. Add the icon assets to all theme variations (edgeLight, edgeDark, etc.) | ||
|
|
||
| ## Notes | ||
|
|
||
| - Payment types that are primarily bank-based use the generic bank transfer icon as a reasonable fallback | ||
| - The system is designed to be extensible - new payment types can be added without breaking existing functionality | ||
| - Always provide a fallback (like the partner icon) when using payment type icons in case the mapping returns undefined |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Per long discussion: remove all .md files from the PR, add to
.gitignore