create-awarizon-app 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -0
- package/package.json +8 -8
- package/templates/expo/app/(tabs)/index.tsx +10 -11
- package/templates/expo/app/(tabs)/wallet.tsx +69 -45
- package/templates/expo/package.json +2 -2
- package/templates/expo-js/app/(tabs)/index.jsx +10 -11
- package/templates/expo-js/app/(tabs)/wallet.jsx +69 -45
- package/templates/expo-js/package.json +2 -2
- package/templates/nextjs/app/page.tsx +9 -12
- package/templates/nextjs/app/wallet/page.tsx +66 -37
- package/templates/nextjs/components/Header.tsx +7 -3
- package/templates/nextjs/package.json +2 -2
- package/templates/nextjs-js/app/page.jsx +9 -12
- package/templates/nextjs-js/app/wallet/page.jsx +66 -37
- package/templates/nextjs-js/components/Header.jsx +7 -3
- package/templates/nextjs-js/package.json +2 -2
- package/templates/react/package.json +2 -2
- package/templates/react/src/App.tsx +14 -14
- package/templates/react/src/pages/WalletPage.tsx +66 -37
- package/templates/react-js/package.json +2 -2
- package/templates/react-js/src/App.jsx +14 -14
- package/templates/react-js/src/pages/WalletPage.jsx +66 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import { usePrices, ConnectButton } from '@awarizon/react'
|
|
2
|
+
import { usePrices, ConnectButton, TokenIcon, ChainIcon, useWallet, getChainName } from '@awarizon/react'
|
|
3
3
|
import { Skeleton } from './components/ui/Skeleton'
|
|
4
4
|
import { NftPage } from './pages/NftPage'
|
|
5
5
|
import { WalletPage } from './pages/WalletPage'
|
|
@@ -11,11 +11,11 @@ const NAV = [
|
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
const TOKENS = [
|
|
14
|
-
{ symbol: 'ETH',
|
|
15
|
-
{ symbol: 'BTC',
|
|
16
|
-
{ symbol: 'USDC',
|
|
17
|
-
{ symbol: 'BNB',
|
|
18
|
-
{ symbol: '
|
|
14
|
+
{ symbol: 'ETH', name: 'Ethereum' },
|
|
15
|
+
{ symbol: 'BTC', name: 'Bitcoin' },
|
|
16
|
+
{ symbol: 'USDC', name: 'USD Coin' },
|
|
17
|
+
{ symbol: 'BNB', name: 'BNB' },
|
|
18
|
+
{ symbol: 'HYPE', name: 'Hyperliquid' },
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
function HomePage() {
|
|
@@ -24,7 +24,7 @@ function HomePage() {
|
|
|
24
24
|
return (
|
|
25
25
|
<main className="max-w-5xl mx-auto px-6 py-10">
|
|
26
26
|
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4">
|
|
27
|
-
{TOKENS.map(({ symbol, name
|
|
27
|
+
{TOKENS.map(({ symbol, name }) => {
|
|
28
28
|
const price = prices[symbol]?.price
|
|
29
29
|
return (
|
|
30
30
|
<div
|
|
@@ -32,11 +32,8 @@ function HomePage() {
|
|
|
32
32
|
className="bg-zinc-900/40 border border-zinc-800/40 rounded-2xl p-5 hover:bg-zinc-900/60 hover:border-zinc-700/50 transition-all cursor-default"
|
|
33
33
|
>
|
|
34
34
|
<div className="mb-4">
|
|
35
|
-
<div
|
|
36
|
-
|
|
37
|
-
style={{ backgroundColor: `${color}18`, border: `1px solid ${color}25`, color }}
|
|
38
|
-
>
|
|
39
|
-
{symbol.slice(0, 3)}
|
|
35
|
+
<div className="mb-3">
|
|
36
|
+
<TokenIcon symbol={symbol} size={40} radiusFraction={0.28} />
|
|
40
37
|
</div>
|
|
41
38
|
<p className="text-[11px] text-zinc-500 font-medium mb-0.5">{symbol}</p>
|
|
42
39
|
<p className="text-xs text-zinc-600">{name}</p>
|
|
@@ -58,6 +55,9 @@ function HomePage() {
|
|
|
58
55
|
|
|
59
56
|
export default function App() {
|
|
60
57
|
const [page, setPage] = useState('home')
|
|
58
|
+
const { chainId } = useWallet()
|
|
59
|
+
const displayChainId = chainId ?? 8453
|
|
60
|
+
const chainName = getChainName(displayChainId)
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
63
|
<div className="min-h-screen">
|
|
@@ -90,8 +90,8 @@ export default function App() {
|
|
|
90
90
|
|
|
91
91
|
<div className="flex items-center gap-3 shrink-0">
|
|
92
92
|
<div className="hidden sm:flex items-center gap-1.5 px-3 py-1.5 rounded-full border border-zinc-800 bg-zinc-900/60 text-xs text-zinc-400 font-medium">
|
|
93
|
-
<
|
|
94
|
-
|
|
93
|
+
<ChainIcon chainId={displayChainId} size={16} radiusFraction={0.5} />
|
|
94
|
+
{chainName}
|
|
95
95
|
</div>
|
|
96
96
|
{import.meta.env.VITE_WALLETCONNECT_PROJECT_ID && <ConnectButton />}
|
|
97
97
|
</div>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { useWallet, useNativeBalance, usePrices, ConnectButton } from '@awarizon/react'
|
|
1
|
+
import { useWallet, useNativeBalance, usePrices, ConnectButton, TokenIcon, ChainIcon, getChainNativeSymbol, getChainName } from '@awarizon/react'
|
|
2
2
|
import { Badge } from '../components/ui/Badge'
|
|
3
3
|
import { Card } from '../components/ui/Card'
|
|
4
4
|
import { Skeleton } from '../components/ui/Skeleton'
|
|
5
|
-
import { StatCard } from '../components/ui/StatCard'
|
|
6
5
|
|
|
7
|
-
const
|
|
6
|
+
const ASSETS = [
|
|
7
|
+
{ symbol: 'ETH', name: 'Ethereum' },
|
|
8
|
+
{ symbol: 'BTC', name: 'Bitcoin' },
|
|
9
|
+
{ symbol: 'USDC', name: 'USD Coin' },
|
|
10
|
+
{ symbol: 'BNB', name: 'BNB' },
|
|
11
|
+
{ symbol: 'HYPE', name: 'Hyperliquid' },
|
|
12
|
+
]
|
|
8
13
|
|
|
9
14
|
function DataRow({ label, value, loading }) {
|
|
10
15
|
return (
|
|
@@ -19,16 +24,12 @@ function DataRow({ label, value, loading }) {
|
|
|
19
24
|
|
|
20
25
|
export function WalletPage() {
|
|
21
26
|
const { address, isConnected, isChainMismatch, chainId, connectorInfo } = useWallet()
|
|
27
|
+
const nativeSymbol = chainId != null ? getChainNativeSymbol(chainId) : 'ETH'
|
|
22
28
|
const { formatted: nativeBalance, isLoading: balanceLoading } = useNativeBalance(
|
|
23
29
|
address ?? undefined,
|
|
24
30
|
12_000,
|
|
25
31
|
)
|
|
26
|
-
const { prices, isLoading: pricesLoading } = usePrices(
|
|
27
|
-
|
|
28
|
-
const fmtPrice = (sym) =>
|
|
29
|
-
prices[sym]?.price != null
|
|
30
|
-
? `$${prices[sym].price.toLocaleString(undefined, { maximumFractionDigits: 2 })}`
|
|
31
|
-
: undefined
|
|
32
|
+
const { prices, isLoading: pricesLoading } = usePrices(ASSETS.map(a => a.symbol))
|
|
32
33
|
|
|
33
34
|
const ethFiatValue =
|
|
34
35
|
nativeBalance != null && prices['ETH']?.price != null
|
|
@@ -74,39 +75,67 @@ export function WalletPage() {
|
|
|
74
75
|
<Card className="mb-4">
|
|
75
76
|
<p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-4">Account</p>
|
|
76
77
|
<DataRow label="Address" value={address ?? undefined} loading={false} />
|
|
77
|
-
<DataRow label="Chain
|
|
78
|
+
<DataRow label="Chain" value={chainId != null ? getChainName(chainId) : undefined} loading={false} />
|
|
78
79
|
<DataRow label="Connector" value={connectorInfo?.name ?? connectorInfo?.type} loading={false} />
|
|
79
80
|
</Card>
|
|
80
81
|
|
|
81
82
|
{/* ── Balance ──────────────────────────────────── */}
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
<Card className="mb-4">
|
|
84
|
+
<p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-3">Balance</p>
|
|
85
|
+
<div className="flex items-center gap-3 py-2">
|
|
86
|
+
{chainId != null
|
|
87
|
+
? <ChainIcon chainId={chainId} size={36} radiusFraction={0.5} />
|
|
88
|
+
: <TokenIcon symbol={nativeSymbol} size={36} radiusFraction={0.5} />
|
|
89
|
+
}
|
|
90
|
+
<div className="flex-1 min-w-0">
|
|
91
|
+
<p className="text-sm font-medium text-white">{nativeSymbol}</p>
|
|
92
|
+
<p className="text-xs text-zinc-500">{chainId != null ? getChainName(chainId) : 'Native'}</p>
|
|
93
|
+
</div>
|
|
94
|
+
<div className="text-right">
|
|
95
|
+
{balanceLoading
|
|
96
|
+
? <Skeleton className="h-4 w-28" />
|
|
97
|
+
: <>
|
|
98
|
+
<p className="text-sm font-medium text-white">
|
|
99
|
+
{nativeBalance != null ? `${parseFloat(nativeBalance).toFixed(6)} ${nativeSymbol}` : '—'}
|
|
100
|
+
</p>
|
|
101
|
+
{ethFiatValue && (
|
|
102
|
+
<p className="text-xs text-zinc-500">{ethFiatValue}</p>
|
|
103
|
+
)}
|
|
104
|
+
</>
|
|
105
|
+
}
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</Card>
|
|
97
109
|
|
|
98
|
-
{/* ──
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
{/* ── Assets ───────────────────────────────────── */}
|
|
111
|
+
<Card>
|
|
112
|
+
<p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-3">Assets</p>
|
|
113
|
+
<div className="divide-y divide-zinc-800/50">
|
|
114
|
+
{ASSETS.map(({ symbol, name }) => {
|
|
115
|
+
const price = prices[symbol]?.price
|
|
116
|
+
return (
|
|
117
|
+
<div key={symbol} className="flex items-center gap-3 py-3 first:pt-0 last:pb-0">
|
|
118
|
+
<TokenIcon symbol={symbol} size={36} radiusFraction={0.28} />
|
|
119
|
+
<div className="flex-1 min-w-0">
|
|
120
|
+
<p className="text-sm font-medium text-white">{symbol}</p>
|
|
121
|
+
<p className="text-xs text-zinc-500">{name}</p>
|
|
122
|
+
</div>
|
|
123
|
+
<div className="text-right">
|
|
124
|
+
{pricesLoading
|
|
125
|
+
? <Skeleton className="h-4 w-20" />
|
|
126
|
+
: <p className="text-sm font-medium text-white">
|
|
127
|
+
{price != null
|
|
128
|
+
? `$${price.toLocaleString(undefined, { maximumFractionDigits: 2 })}`
|
|
129
|
+
: '—'}
|
|
130
|
+
</p>
|
|
131
|
+
}
|
|
132
|
+
<p className="text-xs text-zinc-600">USD · usePrices</p>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
})}
|
|
137
|
+
</div>
|
|
138
|
+
</Card>
|
|
110
139
|
</>
|
|
111
140
|
)}
|
|
112
141
|
</main>
|