Skip to content

Commit fe27920

Browse files
committed
feat(ramp): add new plugin architecture for fiat on/off ramps
- Implement TradeCreateScene and TradeOptionSelectScene for buy/sell flow - Add Paybis as first ramp plugin with full API integration - Create reusable hooks for ramp plugin management (useRampPlugins, useRampQuotes) - Add payment type icon system with comprehensive mappings - Implement quote fetching and comparison across multiple providers - Add best rate badge component for quote comparison - Create ramp plugin type definitions and store utilities - Add comprehensive documentation for migration and architecture - Include unit tests for payment types and store IDs - Update navigation and deeplink handlers for ramp flows BREAKING CHANGE: Replaces legacy FiatPluginUi with new ramp plugin system
1 parent 6b8e980 commit fe27920

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5883
-64
lines changed

AGENTS.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
## Build/Test/Lint Commands
2323

24-
- `yarn lint` - Run ESLint on entire codebase
24+
- `yarn lint` - Run ESLint on entire codebase (only use when working on warning cleanup)
25+
- `yarn lint --quiet` - Run ESLint on entire codebase and only get error (Prefer this usage always)
2526
- `yarn fix` - Auto-fix linting issues and deduplicate yarn
2627
- `yarn test` - Run Jest tests (single run)
2728
- `yarn watch` - Run Jest tests in watch mode
@@ -92,3 +93,13 @@ The following documentation files provide detailed guidance for specific areas o
9293

9394
**When to read**: Before creating new scenes or modifying existing scene components
9495
**Summary**: Critical architectural patterns for Edge scenes. Covers the fundamental rule that scenes must never implement custom headers (managed by react-navigation), proper SceneWrapper usage, and navigation configuration patterns. Includes TradeCreateScene case study showing common architectural violations to avoid.
96+
97+
### `docs/payment-type-icons.md`
98+
99+
**When to read**: When working with payment type icons in fiat plugins or payment method displays
100+
**Summary**: Explains the payment type icon mapping system for displaying appropriate icons for different payment methods. Covers usage with `getPaymentTypeIcon` utility, integration with PaymentOptionCard, direct and fallback mappings, and how to add new payment types.
101+
102+
### `docs/ramp-plugin-migration-guide.md`
103+
104+
**When to read**: Before migrating ramp plugins from legacy provider architecture to new ramp plugin architecture or when creating new ramp plugins
105+
**Summary**: Comprehensive migration guide for removing FiatPluginUi abstraction and using direct API imports. Covers migration of toasts, modals, navigation, permissions (with important boolean logic inversion note), wallet operations, and environment configuration requirements. Includes detailed steps for creating init options cleaners, validating plugin initialization, and registering plugins in envConfig. Also explains how to migrate getSupportedAssets initialization logic to an internal fetchProviderConfig function with 2-minute TTL caching. Essential for converting legacy fiat providers to new ramp plugins and ensuring proper type safety.

design.png

541 KB
Loading

docs/component-styling-guidelines.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
- **Types first**: Type definitions at the top serve as documentation
66
- **Exports second**: Component exports immediately after types for visibility
7-
- **Styled components third**: All styled components after the main export
7+
- **Styled components third**: All styled components after the main export (more relevant to component structure)
8+
- **Utility functions fourth**: Helper functions and components scoped to the file come after styled components
89
- **Styles last**: cacheStyles objects at the bottom of the file
910

1011
## Styling Patterns
@@ -27,12 +28,12 @@ interface Props {
2728
export const MyComponent = (props: Props) => {
2829
return (
2930
<Container>
30-
<StyledText>Hello</StyledText>
31+
<StyledText>{formatText('Hello')}</StyledText>
3132
</Container>
3233
)
3334
}
3435

35-
// Styled components third
36+
// Styled components third (more relevant to component structure)
3637
const Container = styled(View)({
3738
// styles
3839
})
@@ -41,6 +42,11 @@ const StyledText = styled(EdgeText)({
4142
// styles
4243
})
4344

45+
// Utility functions fourth (scoped to this file)
46+
const formatText = (text: string): string => {
47+
return text.toUpperCase()
48+
}
49+
4450
// Styles last (if needed for complex cases)
4551
const styles = cacheStyles({
4652
// fallback styles

docs/payment-type-icons.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Payment Type Icons
2+
3+
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.
4+
5+
## Overview
6+
7+
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.
8+
9+
## Usage
10+
11+
### Basic Usage
12+
13+
```typescript
14+
import { getPaymentTypeIcon } from '../util/paymentTypeIcons'
15+
import { useTheme } from '../services/ThemeContext'
16+
17+
const MyComponent = () => {
18+
const theme = useTheme()
19+
const paymentType = 'applepay' // FiatPaymentType
20+
21+
const icon = getPaymentTypeIcon(paymentType, theme)
22+
// Returns: { uri: 'path/to/apple-pay-icon.png' }
23+
}
24+
```
25+
26+
### Integration with PaymentOptionCard
27+
28+
When rendering payment options from quotes, use the first payment type to determine the icon:
29+
30+
```typescript
31+
const QuoteResult = ({ quote }) => {
32+
const theme = useTheme()
33+
34+
// Get icon for the first payment type, fallback to partner icon
35+
const paymentTypeIcon = quote.paymentTypes[0]
36+
? getPaymentTypeIcon(quote.paymentTypes[0], theme)
37+
: undefined
38+
const icon = paymentTypeIcon ?? { uri: quote.partnerIcon }
39+
40+
return (
41+
<PaymentOptionCard
42+
title={quote.paymentTypes.join(', ')}
43+
icon={icon}
44+
// ... other props
45+
/>
46+
)
47+
}
48+
```
49+
50+
## Payment Type Mappings
51+
52+
### Direct Mappings
53+
54+
These payment types have dedicated icons in the theme:
55+
56+
- `applepay``paymentTypeLogoApplePay`
57+
- `credit``paymentTypeLogoCreditCard`
58+
- `fasterpayments``paymentTypeLogoFasterPayments`
59+
- `googlepay``paymentTypeLogoGooglePay`
60+
- `ideal``paymentTypeLogoIdeal`
61+
- `interac``paymentTypeLogoInterac`
62+
- `payid``paymentTypeLogoPayid`
63+
- `paypal``paymentTypeLogoPaypal`
64+
- `pix``paymentTypeLogoPix`
65+
- `revolut``paymentTypeLogoRevolut`
66+
- `venmo``paymentTypeLogoVenmo`
67+
68+
### Fallback Mappings
69+
70+
These payment types use the generic bank transfer icon as a fallback:
71+
72+
- `ach``paymentTypeLogoBankTransfer`
73+
- `colombiabank``paymentTypeLogoBankTransfer`
74+
- `directtobank``paymentTypeLogoBankTransfer`
75+
- `iach``paymentTypeLogoBankTransfer`
76+
- `iobank``paymentTypeLogoBankTransfer`
77+
- `mexicobank``paymentTypeLogoBankTransfer`
78+
- `pse``paymentTypeLogoBankTransfer`
79+
- `sepa``paymentTypeLogoBankTransfer`
80+
- `spei``paymentTypeLogoBankTransfer`
81+
- `turkishbank``paymentTypeLogoBankTransfer`
82+
- `wire``paymentTypeLogoBankTransfer`
83+
84+
## API Reference
85+
86+
### `getPaymentTypeIcon(paymentType: FiatPaymentType, theme: Theme): ImageProp | undefined`
87+
88+
Returns the theme icon for a given payment type.
89+
90+
**Parameters:**
91+
- `paymentType`: The payment type to get the icon for
92+
- `theme`: The theme object containing the icon images
93+
94+
**Returns:**
95+
- `ImageProp`: The icon image object (`{ uri: string } | number`)
96+
- `undefined`: If the payment type doesn't have a corresponding icon
97+
98+
### `getPaymentTypeThemeKey(paymentType: FiatPaymentType): keyof Theme | null`
99+
100+
Returns just the theme key for a payment type without requiring the theme object.
101+
102+
**Parameters:**
103+
- `paymentType`: The payment type to get the theme key for
104+
105+
**Returns:**
106+
- `keyof Theme`: The theme key string
107+
- `null`: If the payment type doesn't have a corresponding theme key
108+
109+
## Adding New Payment Types
110+
111+
To add support for a new payment type:
112+
113+
1. Add the payment type to the `FiatPaymentType` union in `fiatPluginTypes.ts`
114+
2. Add the corresponding icon to the theme in `types/Theme.ts`
115+
3. Update the `paymentTypeToThemeKey` mapping in `util/paymentTypeIcons.ts`
116+
4. Add the icon assets to all theme variations (edgeLight, edgeDark, etc.)
117+
118+
## Notes
119+
120+
- Payment types that are primarily bank-based use the generic bank transfer icon as a reasonable fallback
121+
- The system is designed to be extensible - new payment types can be added without breaking existing functionality
122+
- Always provide a fallback (like the partner icon) when using payment type icons in case the mapping returns undefined

0 commit comments

Comments
 (0)