Spaces:
Running
Running
Upload 17 files
Browse files- App (1).tsx +28 -0
- App.tsx +18 -0
- HomeScreen.tsx +35 -0
- README.md +30 -24
- WalletScreen.tsx +25 -0
- app-projeto-ivano.zip +0 -0
- eas.json +12 -0
- firebase.json +6 -0
- index.html +12 -0
- jest.config.js +16 -0
- main.tsx +5 -0
- market (1).ts +7 -0
- market.ts +12 -0
- package (1).json +24 -0
- package.json +24 -52
- tsconfig.json +7 -21
- walletConnect.ts +34 -0
App (1).tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, {useEffect, useState} from 'react';
|
| 2 |
+
import { getSimplePrice } from './services/market';
|
| 3 |
+
|
| 4 |
+
export default function App() {
|
| 5 |
+
const [prices, setPrices] = useState<any>({});
|
| 6 |
+
useEffect(() => {
|
| 7 |
+
(async () => {
|
| 8 |
+
try {
|
| 9 |
+
const data = await getSimplePrice(['bitcoin','ethereum']);
|
| 10 |
+
setPrices(data);
|
| 11 |
+
} catch (e) {
|
| 12 |
+
console.error(e);
|
| 13 |
+
}
|
| 14 |
+
})();
|
| 15 |
+
}, []);
|
| 16 |
+
return (
|
| 17 |
+
<div style={{padding:20}}>
|
| 18 |
+
<h1>Ivano Crypto - Web</h1>
|
| 19 |
+
<ul>
|
| 20 |
+
{Object.keys(prices).map(k => (
|
| 21 |
+
<li key={k}>
|
| 22 |
+
<strong>{k.toUpperCase()}</strong>: ${prices[k].usd} ({prices[k].usd_24h_change.toFixed(2)}%)
|
| 23 |
+
</li>
|
| 24 |
+
))}
|
| 25 |
+
</ul>
|
| 26 |
+
</div>
|
| 27 |
+
);
|
| 28 |
+
}
|
App.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { NavigationContainer } from '@react-navigation/native';
|
| 3 |
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
| 4 |
+
import HomeScreen from './src/screens/HomeScreen';
|
| 5 |
+
import WalletScreen from './src/screens/WalletScreen';
|
| 6 |
+
|
| 7 |
+
const Stack = createNativeStackNavigator();
|
| 8 |
+
|
| 9 |
+
export default function App() {
|
| 10 |
+
return (
|
| 11 |
+
<NavigationContainer>
|
| 12 |
+
<Stack.Navigator>
|
| 13 |
+
<Stack.Screen name="Home" component={HomeScreen} />
|
| 14 |
+
<Stack.Screen name="Wallet" component={WalletScreen} />
|
| 15 |
+
</Stack.Navigator>
|
| 16 |
+
</NavigationContainer>
|
| 17 |
+
);
|
| 18 |
+
}
|
HomeScreen.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useEffect, useState } from 'react';
|
| 2 |
+
import { View, Text, FlatList } from 'react-native';
|
| 3 |
+
import { getSimplePrice } from '../services/market';
|
| 4 |
+
|
| 5 |
+
export default function HomeScreen() {
|
| 6 |
+
const [prices, setPrices] = useState<any>({});
|
| 7 |
+
|
| 8 |
+
useEffect(() => {
|
| 9 |
+
(async () => {
|
| 10 |
+
try {
|
| 11 |
+
const data = await getSimplePrice(['bitcoin','ethereum']);
|
| 12 |
+
setPrices(data);
|
| 13 |
+
} catch (e) {
|
| 14 |
+
console.error(e);
|
| 15 |
+
}
|
| 16 |
+
})();
|
| 17 |
+
}, []);
|
| 18 |
+
|
| 19 |
+
return (
|
| 20 |
+
<View style={{flex:1, padding:20}}>
|
| 21 |
+
<Text style={{fontSize:20}}>Crypto Prices</Text>
|
| 22 |
+
<FlatList
|
| 23 |
+
data={Object.keys(prices)}
|
| 24 |
+
keyExtractor={(i) => i}
|
| 25 |
+
renderItem={({item}) => (
|
| 26 |
+
<View style={{padding:12, borderBottomWidth:1, borderColor:'#eee'}}>
|
| 27 |
+
<Text style={{fontSize:16}}>{item.toUpperCase()}</Text>
|
| 28 |
+
<Text>USD: {prices[item]?.usd}</Text>
|
| 29 |
+
<Text>24h: {prices[item]?.usd_24h_change?.toFixed(2)}%</Text>
|
| 30 |
+
</View>
|
| 31 |
+
)}
|
| 32 |
+
/>
|
| 33 |
+
</View>
|
| 34 |
+
);
|
| 35 |
+
}
|
README.md
CHANGED
|
@@ -1,26 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
title: DeepSite v3
|
| 3 |
-
emoji: 🐳
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: true
|
| 8 |
-
app_port: 3000
|
| 9 |
-
license: mit
|
| 10 |
-
short_description: Generate any application by Vibe Coding
|
| 11 |
-
models:
|
| 12 |
-
- deepseek-ai/DeepSeek-V3-0324
|
| 13 |
-
- deepseek-ai/DeepSeek-R1-0528
|
| 14 |
-
- deepseek-ai/DeepSeek-V3.1
|
| 15 |
-
- deepseek-ai/DeepSeek-V3.1-Terminus
|
| 16 |
-
- deepseek-ai/DeepSeek-V3.2-Exp
|
| 17 |
-
- Qwen/Qwen3-Coder-480B-A35B-Instruct
|
| 18 |
-
- moonshotai/Kimi-K2-Instruct
|
| 19 |
-
- moonshotai/Kimi-K2-Instruct-0905
|
| 20 |
-
- zai-org/GLM-4.6
|
| 21 |
-
- MiniMaxAI/MiniMax-M2
|
| 22 |
-
---
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app-projeto-ivano
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
Pacote contendo duas versões do starter app:
|
| 4 |
+
- mobile/ -> Expo (React Native + TypeScript)
|
| 5 |
+
- web/ -> Vite + React (TypeScript)
|
| 6 |
|
| 7 |
+
Também inclui configuração de CI (GitHub Actions) com:
|
| 8 |
+
- Jest + ESLint
|
| 9 |
+
- Build web + deploy Firebase
|
| 10 |
+
- EAS Build (Android/iOS) (disparado em releases)
|
| 11 |
+
- Notificações simples pro Discord (via secret DISCORD_WEBHOOK_URL)
|
| 12 |
+
|
| 13 |
+
## Como usar
|
| 14 |
+
|
| 15 |
+
### Mobile (Expo)
|
| 16 |
+
1. No diretório `mobile` rode:
|
| 17 |
+
```
|
| 18 |
+
npm install
|
| 19 |
+
npx expo start
|
| 20 |
+
```
|
| 21 |
+
2. Para testar no celular use Expo Go ou EAS.
|
| 22 |
+
|
| 23 |
+
### Web
|
| 24 |
+
1. No diretório `web` rode:
|
| 25 |
+
```
|
| 26 |
+
npm install
|
| 27 |
+
npm run dev
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## Observações
|
| 31 |
+
- Substitua `your-firebase-project-id` em `.firebaserc` pelo seu ID do Firebase antes de usar o deploy.
|
| 32 |
+
- Adicione os secrets no GitHub: FIREBASE_TOKEN, EAS_TOKEN, DISCORD_WEBHOOK_URL.
|
WalletScreen.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, {useState} from 'react';
|
| 2 |
+
import {View, Text, Button} from 'react-native';
|
| 3 |
+
import {connect} from '../services/walletConnect';
|
| 4 |
+
|
| 5 |
+
export default function WalletScreen() {
|
| 6 |
+
const [account, setAccount] = useState<string | null>(null);
|
| 7 |
+
|
| 8 |
+
async function handleConnect() {
|
| 9 |
+
try {
|
| 10 |
+
const res: any = await connect();
|
| 11 |
+
const accounts = res.accounts as string[];
|
| 12 |
+
setAccount(accounts[0]);
|
| 13 |
+
} catch (e) {
|
| 14 |
+
console.error(e);
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<View style={{flex:1, padding:20}}>
|
| 20 |
+
<Text style={{fontSize:18}}>Wallet</Text>
|
| 21 |
+
<Text>{account ?? 'Nenhuma carteira conectada'}</Text>
|
| 22 |
+
<Button title="Conectar Wallet" onPress={handleConnect} />
|
| 23 |
+
</View>
|
| 24 |
+
);
|
| 25 |
+
}
|
app-projeto-ivano.zip
ADDED
|
Binary file (7.67 kB). View file
|
|
|
eas.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"build": {
|
| 3 |
+
"production": {
|
| 4 |
+
"android": {
|
| 5 |
+
"buildType": "app-bundle"
|
| 6 |
+
},
|
| 7 |
+
"ios": {
|
| 8 |
+
"simulator": false
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
}
|
| 12 |
+
}
|
firebase.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"hosting": {
|
| 3 |
+
"public": "web/dist",
|
| 4 |
+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
|
| 5 |
+
}
|
| 6 |
+
}
|
index.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>Ivano Web</title>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<div id="root"></div>
|
| 10 |
+
<script type="module" src="/src/main.tsx"></script>
|
| 11 |
+
</body>
|
| 12 |
+
</html>
|
jest.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = {
|
| 2 |
+
preset: 'jest-expo',
|
| 3 |
+
transformIgnorePatterns: [
|
| 4 |
+
'node_modules/(?!(jest-)?react-native|@react-native|expo|@expo|@unimodules)'
|
| 5 |
+
],
|
| 6 |
+
collectCoverage: true,
|
| 7 |
+
collectCoverageFrom: ['**/src/**/*.{ts,tsx}'],
|
| 8 |
+
coverageThreshold: {
|
| 9 |
+
global: {
|
| 10 |
+
branches: 80,
|
| 11 |
+
functions: 80,
|
| 12 |
+
lines: 80,
|
| 13 |
+
statements: 80,
|
| 14 |
+
},
|
| 15 |
+
},
|
| 16 |
+
};
|
main.tsx
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { createRoot } from 'react-dom/client';
|
| 3 |
+
import App from './App';
|
| 4 |
+
|
| 5 |
+
createRoot(document.getElementById('root')!).render(<App />);
|
market (1).ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import axios from 'axios';
|
| 2 |
+
export async function getSimplePrice(ids: string[]) {
|
| 3 |
+
const res = await axios.get('https://api.coingecko.com/api/v3/simple/price', {
|
| 4 |
+
params: { ids: ids.join(','), vs_currencies: 'usd', include_24hr_change: 'true' }
|
| 5 |
+
});
|
| 6 |
+
return res.data;
|
| 7 |
+
}
|
market.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import axios from 'axios';
|
| 2 |
+
|
| 3 |
+
export async function getSimplePrice(ids: string[]) {
|
| 4 |
+
const res = await axios.get('https://api.coingecko.com/api/v3/simple/price', {
|
| 5 |
+
params: {
|
| 6 |
+
ids: ids.join(','),
|
| 7 |
+
vs_currencies: 'usd',
|
| 8 |
+
include_24hr_change: 'true'
|
| 9 |
+
}
|
| 10 |
+
});
|
| 11 |
+
return res.data;
|
| 12 |
+
}
|
package (1).json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "ivano-web",
|
| 3 |
+
"version": "0.0.1",
|
| 4 |
+
"private": true,
|
| 5 |
+
"scripts": {
|
| 6 |
+
"dev": "vite",
|
| 7 |
+
"build": "vite build",
|
| 8 |
+
"preview": "vite preview",
|
| 9 |
+
"lint": "eslint . --ext .ts,.tsx",
|
| 10 |
+
"test": "jest --coverage"
|
| 11 |
+
},
|
| 12 |
+
"dependencies": {
|
| 13 |
+
"react": "18.2.0",
|
| 14 |
+
"react-dom": "18.2.0",
|
| 15 |
+
"axios": "^1.4.0"
|
| 16 |
+
},
|
| 17 |
+
"devDependencies": {
|
| 18 |
+
"typescript": "^5.0.0",
|
| 19 |
+
"vite": "^4.0.0",
|
| 20 |
+
"@vitejs/plugin-react": "^3.0.0",
|
| 21 |
+
"eslint": "^8.0.0",
|
| 22 |
+
"jest": "^29.0.0"
|
| 23 |
+
}
|
| 24 |
+
}
|
package.json
CHANGED
|
@@ -1,60 +1,32 @@
|
|
| 1 |
{
|
| 2 |
-
"name": "
|
| 3 |
-
"version": "0.1
|
| 4 |
"private": true,
|
|
|
|
| 5 |
"scripts": {
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"
|
|
|
|
|
|
|
|
|
|
| 9 |
},
|
| 10 |
"dependencies": {
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"@
|
| 18 |
-
"@
|
| 19 |
-
"@
|
| 20 |
-
"@
|
| 21 |
-
"@radix-ui/react-slot": "^1.2.3",
|
| 22 |
-
"@radix-ui/react-switch": "^1.2.6",
|
| 23 |
-
"@radix-ui/react-tabs": "^1.1.13",
|
| 24 |
-
"@radix-ui/react-toggle": "^1.1.10",
|
| 25 |
-
"@radix-ui/react-toggle-group": "^1.1.11",
|
| 26 |
-
"@radix-ui/react-tooltip": "^1.2.8",
|
| 27 |
-
"@tanstack/eslint-plugin-query": "^5.86.0",
|
| 28 |
-
"@tanstack/react-query": "^5.86.0",
|
| 29 |
-
"@tanstack/react-query-devtools": "^5.86.0",
|
| 30 |
-
"axios": "^1.11.0",
|
| 31 |
-
"class-variance-authority": "^0.7.1",
|
| 32 |
-
"classnames": "^2.5.1",
|
| 33 |
-
"clsx": "^2.1.1",
|
| 34 |
-
"date-fns": "^4.1.0",
|
| 35 |
-
"framer-motion": "^12.23.22",
|
| 36 |
-
"log4js": "^6.9.1",
|
| 37 |
-
"log4js-json-layout": "^2.2.3",
|
| 38 |
-
"lucide-react": "^0.542.0",
|
| 39 |
-
"monaco-editor": "^0.52.2",
|
| 40 |
-
"mongoose": "^8.18.0",
|
| 41 |
-
"next": "15.5.2",
|
| 42 |
-
"react": "19.1.0",
|
| 43 |
-
"react-dom": "19.1.0",
|
| 44 |
-
"react-use": "^17.6.0",
|
| 45 |
-
"sonner": "^2.0.7",
|
| 46 |
-
"tailwind-merge": "^3.3.1",
|
| 47 |
-
"tailwindcss-animate": "^1.0.7",
|
| 48 |
-
"tw-animate-css": "^1.3.8",
|
| 49 |
-
"url-loader": "^4.1.1",
|
| 50 |
-
"zod": "^4.1.5"
|
| 51 |
},
|
| 52 |
"devDependencies": {
|
| 53 |
-
"
|
| 54 |
-
"@types/
|
| 55 |
-
"@types/react": "^
|
| 56 |
-
"
|
| 57 |
-
"tailwindcss": "^4.1.13",
|
| 58 |
-
"typescript": "^5"
|
| 59 |
}
|
| 60 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"name": "ivano-mobile",
|
| 3 |
+
"version": "0.0.1",
|
| 4 |
"private": true,
|
| 5 |
+
"main": "node_modules/expo/AppEntry.js",
|
| 6 |
"scripts": {
|
| 7 |
+
"start": "expo start",
|
| 8 |
+
"android": "expo start --android",
|
| 9 |
+
"ios": "expo start --ios",
|
| 10 |
+
"web": "expo start --web",
|
| 11 |
+
"lint": "eslint . --ext .ts,.tsx",
|
| 12 |
+
"test": "jest --coverage"
|
| 13 |
},
|
| 14 |
"dependencies": {
|
| 15 |
+
"expo": "~48.0.0",
|
| 16 |
+
"expo-status-bar": "1.4.0",
|
| 17 |
+
"react": "18.2.0",
|
| 18 |
+
"react-native": "0.71.8",
|
| 19 |
+
"axios": "^1.4.0",
|
| 20 |
+
"ethers": "^6.0.0",
|
| 21 |
+
"@walletconnect/client": "^1.9.0",
|
| 22 |
+
"@react-native-async-storage/async-storage": "^1.17.11",
|
| 23 |
+
"@react-navigation/native": "^6.0.13",
|
| 24 |
+
"@react-navigation/native-stack": "^6.9.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
},
|
| 26 |
"devDependencies": {
|
| 27 |
+
"typescript": "^5.0.0",
|
| 28 |
+
"@types/react": "^18.0.0",
|
| 29 |
+
"@types/react-native": "^0.71.0",
|
| 30 |
+
"jest-expo": "48.0.0"
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
+
}
|
tsconfig.json
CHANGED
|
@@ -1,27 +1,13 @@
|
|
| 1 |
{
|
| 2 |
"compilerOptions": {
|
| 3 |
-
"target": "ES2017",
|
| 4 |
-
"lib": ["dom", "dom.iterable", "esnext"],
|
| 5 |
-
"allowJs": true,
|
| 6 |
-
"skipLibCheck": true,
|
| 7 |
"strict": true,
|
| 8 |
-
"
|
| 9 |
-
"
|
|
|
|
|
|
|
| 10 |
"module": "esnext",
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"isolatedModules": true,
|
| 14 |
-
"jsx": "preserve",
|
| 15 |
-
"incremental": true,
|
| 16 |
-
"plugins": [
|
| 17 |
-
{
|
| 18 |
-
"name": "next"
|
| 19 |
-
}
|
| 20 |
-
],
|
| 21 |
-
"paths": {
|
| 22 |
-
"@/*": ["./*"]
|
| 23 |
-
}
|
| 24 |
},
|
| 25 |
-
"include": ["
|
| 26 |
-
"exclude": ["node_modules"]
|
| 27 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"compilerOptions": {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"strict": true,
|
| 4 |
+
"noImplicitAny": true,
|
| 5 |
+
"forceConsistentCasingInFileNames": true,
|
| 6 |
+
"skipLibCheck": true,
|
| 7 |
+
"jsx": "react-native",
|
| 8 |
"module": "esnext",
|
| 9 |
+
"target": "es2017",
|
| 10 |
+
"esModuleInterop": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
},
|
| 12 |
+
"include": ["src"]
|
|
|
|
| 13 |
}
|
walletConnect.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import WalletConnect from '@walletconnect/client';
|
| 2 |
+
import QRCodeModal from '@walletconnect/qrcode-modal';
|
| 3 |
+
|
| 4 |
+
let connector: WalletConnect | null = null;
|
| 5 |
+
|
| 6 |
+
export function createConnector() {
|
| 7 |
+
if (!connector) {
|
| 8 |
+
connector = new WalletConnect({
|
| 9 |
+
bridge: 'https://bridge.walletconnect.org'
|
| 10 |
+
});
|
| 11 |
+
}
|
| 12 |
+
return connector;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export async function connect() {
|
| 16 |
+
const c = createConnector();
|
| 17 |
+
if (!c.connected) {
|
| 18 |
+
await c.createSession();
|
| 19 |
+
QRCodeModal.open(c.uri, () => {});
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
return new Promise((resolve, reject) => {
|
| 23 |
+
c.on('connect', (error: any, payload: any) => {
|
| 24 |
+
if (error) return reject(error);
|
| 25 |
+
QRCodeModal.close();
|
| 26 |
+
const { accounts, chainId } = payload.params[0];
|
| 27 |
+
resolve({ accounts, chainId });
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
c.on('disconnect', (err: any) => {
|
| 31 |
+
console.log('Disconnected', err);
|
| 32 |
+
});
|
| 33 |
+
});
|
| 34 |
+
}
|