Skip to content

feat: onramp #323

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 86 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
a48112c
chore: WIP onramp
ignaciosantise Jan 28, 2025
74e753c
chore: wip onramp
ignaciosantise Jan 29, 2025
3e0f0ed
chore: wip onramp
ignaciosantise Jan 29, 2025
47832eb
Merge branch 'develop' into feat/onramp
ignaciosantise Jan 29, 2025
721b527
chore: ui improvements
ignaciosantise Jan 30, 2025
9c3819e
chore: ui improvements
ignaciosantise Jan 30, 2025
278e0c8
chore: removed unused view
ignaciosantise Jan 30, 2025
a4726a0
chore: added loading view, ui improvements
ignaciosantise Jan 31, 2025
8919c54
chore: detect country using timezone
ignaciosantise Jan 31, 2025
40660fa
chore: set default value for currency, added new onramp loading, ux/u…
ignaciosantise Jan 31, 2025
535155f
chore: cache countries, fiat limits, currencies & service providers. …
ignaciosantise Feb 4, 2025
2c276fd
chore: handle keyboard, added error codes, added retry button on load…
ignaciosantise Feb 5, 2025
7257e56
chore: improvements, added ui keyboard, ui changes
ignaciosantise Feb 10, 2025
08dd88b
chore: search modal improvements, flatlist improvement
ignaciosantise Feb 11, 2025
fe2649c
chore: code improvements
ignaciosantise Feb 11, 2025
8a771fc
chore: add event
ignaciosantise Feb 11, 2025
b842b6c
chore: ui changes
ignaciosantise Feb 11, 2025
b1339b3
chore: ui changes
ignaciosantise Feb 13, 2025
e809558
chore: ui improvements
ignaciosantise Feb 14, 2025
5783052
chore: ui improvements
ignaciosantise Feb 14, 2025
8e259ae
chore: added checkout screen + ui changes
ignaciosantise Feb 14, 2025
448144e
chore: added provider image in checkout, added borders in country modal
ignaciosantise Feb 14, 2025
efdb31f
chore: show network name + added fee values check
ignaciosantise Feb 17, 2025
5961003
chore: track evts
ignaciosantise Feb 17, 2025
c7b038b
chore: code improvements
ignaciosantise Feb 17, 2025
93b66be
chore: show payment methods in a row + changed suggested values
ignaciosantise Feb 18, 2025
322112e
chore: set suggested value as default
ignaciosantise Feb 18, 2025
5e0fc56
chore: fixed checkout crash
ignaciosantise Feb 18, 2025
199b133
chore: added cancel button handler
ignaciosantise Feb 18, 2025
cf3ffb8
chore: code style
ignaciosantise Feb 18, 2025
a2ffa47
Merge branch 'develop' into feat/onramp
ignaciosantise Feb 18, 2025
6c218d5
chore: ui changes
ignaciosantise Feb 20, 2025
f5fa43b
chore: general fixes
ignaciosantise Feb 21, 2025
3a84321
Merge branch 'develop' into feat/onramp
ignaciosantise Feb 24, 2025
9c89f00
chore: default payment methods per country, ui details
ignaciosantise Feb 24, 2025
736e457
chore: show network image in asset selector
ignaciosantise Feb 25, 2025
438d402
chore: added active network in token and selector header
ignaciosantise Feb 25, 2025
0d638f1
chore: send address to get quotes
ignaciosantise Feb 25, 2025
325a9f2
chore: loading onramp when user enters that view. Added complete load…
ignaciosantise Feb 25, 2025
ead4927
chore: improved error types
ignaciosantise Feb 25, 2025
8f9d9f0
chore: save preferred fiat currency
ignaciosantise Feb 26, 2025
5da715b
chore: hide fees if not available
ignaciosantise Feb 26, 2025
bfb7cdf
chore: added blockchain api endpoints + ui changes
ignaciosantise Feb 27, 2025
0e4c484
chore: changeset file
ignaciosantise Feb 27, 2025
464b357
chore: added transaction result screen
ignaciosantise Mar 6, 2025
4da3286
chore: use stage url for onramp
ignaciosantise Mar 6, 2025
841a008
chore: fixed widget url generation
ignaciosantise Mar 7, 2025
c5140ff
chore: updated types
ignaciosantise Mar 7, 2025
9fad89b
chore: fixed typo
ignaciosantise Mar 7, 2025
388a85b
chore: added tests
ignaciosantise Mar 7, 2025
7c74ba7
chore: solved issue with network change, general improvements
ignaciosantise Mar 7, 2025
e86f162
fix: improved country detection logic
ignaciosantise Mar 10, 2025
4fb002c
chore: changed suggested values logic
ignaciosantise Mar 10, 2025
946c4a5
chore: solved loading glitch on android
ignaciosantise Mar 10, 2025
8771af3
chore: added OnRamp as OpenOption
ignaciosantise Mar 11, 2025
17facd1
chore: removed widget amount cast to string
ignaciosantise Mar 11, 2025
510a61f
chore: added cursor rule
ignaciosantise Mar 13, 2025
b7a3433
Merge branch 'develop' into feat/onramp
ignaciosantise Mar 13, 2025
3040da1
Merge branch 'develop' into feat/onramp
ignaciosantise Mar 25, 2025
9c827e4
Merge branch 'develop' into feat/onramp
ignaciosantise Mar 31, 2025
c892193
chore: show decimal separator using phone region
ignaciosantise Apr 1, 2025
e611b02
Revert "chore: show decimal separator using phone region"
ignaciosantise Apr 1, 2025
2733c58
chore: cover case where redirectio doesnt have the needed info for tr…
ignaciosantise Apr 1, 2025
d481572
chore: solved lint issues
ignaciosantise Apr 1, 2025
deb3781
chore: removed blockchain stage api
ignaciosantise Apr 1, 2025
fa2632a
chore: ui fixes
ignaciosantise May 19, 2025
186e335
chore: removed suggested onramp values + ui improvements
ignaciosantise May 29, 2025
3a7245d
Merge branch 'develop' into feat/onramp
ignaciosantise May 29, 2025
2a60df9
chore: code styling
ignaciosantise May 29, 2025
2972df0
chore: code styling
ignaciosantise May 29, 2025
ea56d23
chore: code styling + removed extra padding in network button
ignaciosantise May 29, 2025
91d62c5
chore: fixed onramp test
ignaciosantise May 29, 2025
320cf79
chore: code styling
ignaciosantise May 29, 2025
345f995
fix: animation issue with wui image
ignaciosantise Jun 2, 2025
09e71f7
chore: changes in quotes request + UX improvements
ignaciosantise Jun 25, 2025
a890c91
chore: added countries defaults endpoint
ignaciosantise Jun 25, 2025
03e0b85
chore: turned off dot notation rule
ignaciosantise Jun 26, 2025
9c5ff8b
Merge branch 'develop' into feat/onramp
ignaciosantise Jun 26, 2025
70b5edc
chore: improved quotes loading logic
ignaciosantise Jun 26, 2025
889b3a2
chore: check country default payment methods after loading new quotes
ignaciosantise Jun 26, 2025
8e4f6e6
chore: removed custom wallets from sample app
ignaciosantise Jun 26, 2025
71ac4bc
chore: changed size of onramp loading view
ignaciosantise Jun 26, 2025
21cacd5
Merge branch 'develop' into feat/onramp
ignaciosantise Jun 26, 2025
f55195c
chore: changed background color of token image containers
ignaciosantise Jun 27, 2025
2046208
chore: fixed tests
ignaciosantise Jun 27, 2025
28759c7
chore: ui fixes
ignaciosantise Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/slimy-apricots-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@reown/appkit-scaffold-react-native': minor
'@reown/appkit-common-react-native': minor
'@reown/appkit-core-react-native': minor
'@reown/appkit-siwe-react-native': minor
'@reown/appkit-ui-react-native': minor
'@reown/appkit-auth-ethers-react-native': minor
'@reown/appkit-auth-wagmi-react-native': minor
'@reown/appkit-coinbase-ethers-react-native': minor
'@reown/appkit-coinbase-wagmi-react-native': minor
'@reown/appkit-ethers-react-native': minor
'@reown/appkit-ethers5-react-native': minor
'@reown/appkit-scaffold-utils-react-native': minor
'@reown/appkit-wagmi-react-native': minor
'@reown/appkit-wallet-react-native': minor
---

feat: added onramp feature
130 changes: 130 additions & 0 deletions .cursor/rules/appkit-react-native.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
description: This rule gives the overall context of the appkit react native project
globs:
---
React Native SDK Engineering Context:
You are a **world-class Staff Software Engineer** specializing in **React Native SDKs**, with expertise in **performance, modularity, maintainability, and developer experience**.

For every request, you must:

### **1️⃣ Enforce SDK Best Practices**

- **Function-based Component Architecture**: Use functional components with hooks exclusively (e.g., `useState`, `useEffect`) for all UI and logic.
- **TypeScript-first Approach**: Enforce strict TypeScript with `@types/react-native`, adhering to the `tsconfig.json` rules (e.g., `noUncheckedIndexedAccess`, `strict` mode).
- **Valtio or Controller-based State Management**: Use Valtio’s proxy-based reactivity for state management where applicable (e.g., `proxy({ address: '' })`). If using custom controllers (e.g., `AccountController.ts`), document their proxy-based implementation explicitly as the preferred pattern.
- **Follow the SDK package structure**, keeping utilities, controllers, and UI components separate.

### **2️⃣ Optimize for Performance & SDK Usability**

- Ensure efficient rendering with:
- **Efficient Rendering**: Apply `React.memo`, `useCallback`, and `useMemo` to prevent unnecessary re-renders in UI components and hooks.
- **FlatList for Lists**: Use `FlatList` with `keyExtractor` for rendering large datasets (e.g., wallet lists), avoiding array mapping with `map`.
- **Native Animations**: Use React Native’s `Animated` API for animations; avoid external libraries like `react-native-reanimated` to minimize dependencies.
- **Debounce expensive operations** (like API calls) using `lodash.debounce`.

### **3️⃣ Code Consistency & SDK Structure**

- **Directory structure must remain modular**:
```
packages/
core/
src/
controllers/
utils/
index.ts
ui/
src/
components/
hooks/
index.ts
auth/
src/
index.ts
```
- Prefer `@reown/appkit-ui-react-native` components over `react-native` defaults:
- ✅ Use `<Text />` from `@reown/appkit-ui-react-native` instead of `<Text />`
- ✅ Use `<Button />` instead of `<TouchableOpacity />`
- ✅ **Use `FlatList` for rendering lists**, do not wrap it in `<List />`
- **Sort imports**:
1. **External Libraries** (`react`, `valtio`, `viem`)
2. **Internal SDK Modules** (`@reown/appkit-ui-react-native`)
3. **Relative Imports** (`./controllers/RouterController.ts`)

```typescript
import React from 'react';
import { Text } from '@reown/appkit-ui-react-native';
import { RouterController } from './controllers/RouterController';
```

### **4️⃣ Secure & Scalable SDK API**

- Design **developer-friendly APIs** with:
- Strongly typed method signatures (`(config: AppKitConfig) => void`).
- Proper validation on input parameters.
- Error handling to prevent crashes (`try-catch`).
- **Use AsyncStorage sparingly**, only for:
- Caching non-sensitive data (e.g., user preferences, session data).
- Persisting lightweight app settings.
- **Do not store sensitive data in AsyncStorage** (e.g., auth tokens, private keys).

### **5️⃣ Comprehensive Testing & Error Handling**

- **Unit Tests**: Implement tests using Jest and React Native Testing Library for all public APIs, controllers, and UI components, targeting **80%+ coverage**.

```typescript
import { render } from '@testing-library/react-native';
test('renders button', () => {
const { getByText } = render(<Button>Click</Button>);
expect(getByText('Click')).toBeTruthy();
});
```

- **Graceful Failure**: Ensure SDK methods fail safely:
- Use `try-catch` in all async functions (e.g., `connectWallet`).
- Throw `Error` objects with descriptive messages (e.g., `throw new Error('Failed to fetch wallet data')`).
- Leverage `ErrorUtil.ts` for consistent error formatting.

```typescript
import { ErrorUtil } from '../utils/ErrorUtil';
async function connectWallet() {
try {
// Connection logic
} catch (error) {
throw ErrorUtil.formatError(error, 'Wallet connection failed');
}
}
```

### **6️⃣ Maintain High Code Readability & Documentation**

- **Enforce ESLint & Prettier rules** (`.eslintrc.json`).
- **Use JSDoc comments** for:
- Public API methods (`@param`, `@returns`).
- Complex logic explanations.
- **No inline styles**, prefer `@reown/appkit-ui-react-native`’s styling approach.

### **7️⃣ SDK Navigation & Routing**

- **No `react-navigation`** → Use internal SDK router:
- ✅ **Use `RouterController.ts` for navigation**.
- ✅ Use programmatic navigation (`router.push()`, `router.goBack()`).
- ✅ Avoid **deep linking dependencies**.

### **8️⃣ Optimize SDK Extensibility**

- **Make SDK modules easily extendable** via:
- **Hooks & Context API** (`useAccount()`, `useNetwork()`).
- **Custom Configurations** (e.g., passing options in `init()`).
- **Event-driven architecture** (`onConnect`, `onDisconnect`).
- **Separate UI from logic**:
- Business logic → `controllers/`
- UI components → `packages/ui/`

### **🔹 Outcome:**

By following these principles, ensure **a world-class React Native SDK** that is:
✅ Highly performant
✅ Modular & scalable
✅ Secure with blockchain-specific safeguards
✅ Developer-friendly with robust APIs, testing, and documentation
✅ Aligned with AppKit conventions by leveraging its UI kit and controllers.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ignorePatterns": ["node_modules/", "build/", "lib/", "dist/", ".turbo", ".expo", "out/"],
"rules": {
"react/react-in-jsx-scope": 0,
"no-duplicate-imports": "off",
"no-duplicate-imports": "error",
"react-hooks/exhaustive-deps": "warn",
"no-console": ["error", { "allow": ["warn"] }],
"newline-before-return": "error",
Expand Down
3 changes: 3 additions & 0 deletions apps/gallery/utils/PresetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const iconOptions: IconType[] = [
'arrowRight',
'arrowTop',
'browser',
'card',
'checkmark',
'chevronBottom',
'chevronLeft',
Expand All @@ -142,6 +143,7 @@ export const iconOptions: IconType[] = [
'copy',
'copySmall',
'cursor',
'currencyDollar',
'desktop',
'disconnect',
'discord',
Expand All @@ -165,6 +167,7 @@ export const iconOptions: IconType[] = [
'qrCode',
'refresh',
'search',
'settings',
'swapHorizontal',
'swapVertical',
'telegram',
Expand Down
10 changes: 3 additions & 7 deletions apps/native/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { siweConfig } from './src/utils/SiweUtils';

import { AccountView } from './src/views/AccountView';
import { ActionsView } from './src/views/ActionsView';
import { getCustomWallets } from './src/utils/misc';
import { chains } from './src/utils/WagmiUtils';
import { OpenButton } from './src/components/OpenButton';
import { DisconnectButton } from './src/components/DisconnectButton';
Expand All @@ -34,9 +33,8 @@ const metadata = {
url: 'https://reown.com/appkit',
icons: ['https://avatars.githubusercontent.com/u/179229932'],
redirect: {
native: 'redirect://',
universal: 'https://appkit-lab.reown.com/rn_appkit',
linkMode: true
native: 'host.exp.exponent://',
universal: 'https://appkit-lab.reown.com/rn_appkit'
}
};

Expand All @@ -63,14 +61,11 @@ const wagmiConfig = defaultWagmiConfig({

const queryClient = new QueryClient();

const customWallets = getCustomWallets();

createAppKit({
projectId,
wagmiConfig,
siweConfig,
clipboardClient,
customWallets,
enableAnalytics: true,
metadata,
debug: true,
Expand All @@ -79,6 +74,7 @@ createAppKit({
socials: ['x', 'discord', 'apple'],
emailShowWallets: true,
swaps: true
// onramp: true
}
});

Expand Down
2 changes: 1 addition & 1 deletion apps/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"eas:build": "eas build --platform all",
"eas:build:local": "eas build --local --platform all",
"eas:update": "eas update --branch preview",
"playwright:test": "./scripts/replace-ep-test.sh && playwright test",
"playwright:test": "./scripts/replace-ep-test.sh && playwright test tests/basic-tests.spec.ts && playwright test tests/wallet.spec.ts && playwright test tests/onramp.spec.ts",
"playwright:install": "playwright install chromium",
"deploy": "gh-pages --nojekyll -d dist",
"build:web": "expo export -p web"
Expand Down
Loading