create-awarizon-app 1.0.10 → 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.
Files changed (31) hide show
  1. package/package.json +1 -1
  2. package/templates/expo/app/(tabs)/_layout.tsx +3 -1
  3. package/templates/expo/app/(tabs)/index.tsx +39 -68
  4. package/templates/expo/app/(tabs)/nft.tsx +142 -0
  5. package/templates/expo/app/(tabs)/wallet.tsx +151 -0
  6. package/templates/expo/package.json +22 -23
  7. package/templates/expo-js/app/(tabs)/_layout.jsx +3 -1
  8. package/templates/expo-js/app/(tabs)/index.jsx +39 -68
  9. package/templates/expo-js/app/(tabs)/nft.jsx +141 -0
  10. package/templates/expo-js/app/(tabs)/wallet.jsx +152 -0
  11. package/templates/expo-js/package.json +19 -20
  12. package/templates/nextjs/app/layout.tsx +5 -1
  13. package/templates/nextjs/app/nft/page.tsx +140 -0
  14. package/templates/nextjs/app/page.tsx +34 -142
  15. package/templates/nextjs/app/wallet/page.tsx +145 -0
  16. package/templates/nextjs/components/Header.tsx +60 -0
  17. package/templates/nextjs/package.json +15 -16
  18. package/templates/nextjs-js/app/layout.jsx +5 -1
  19. package/templates/nextjs-js/app/nft/page.jsx +139 -0
  20. package/templates/nextjs-js/app/page.jsx +35 -130
  21. package/templates/nextjs-js/app/wallet/page.jsx +145 -0
  22. package/templates/nextjs-js/components/Header.jsx +60 -0
  23. package/templates/nextjs-js/package.json +11 -12
  24. package/templates/react/package.json +14 -15
  25. package/templates/react/src/App.tsx +88 -145
  26. package/templates/react/src/pages/NftPage.tsx +138 -0
  27. package/templates/react/src/pages/WalletPage.tsx +143 -0
  28. package/templates/react-js/package.json +11 -12
  29. package/templates/react-js/src/App.jsx +86 -119
  30. package/templates/react-js/src/pages/NftPage.jsx +137 -0
  31. package/templates/react-js/src/pages/WalletPage.jsx +143 -0
@@ -1,142 +1,47 @@
1
1
  'use client'
2
2
 
3
- import { contract, useRead, usePrice, ConnectButton } from '@awarizon/react'
4
- import { ERC20_ABI } from '@awarizon/web3'
5
- import { Badge } from '@/components/ui/Badge'
6
- import { Button } from '@/components/ui/Button'
7
- import { Card } from '@/components/ui/Card'
3
+ import { usePrices, TokenIcon } from '@awarizon/react'
8
4
  import { Skeleton } from '@/components/ui/Skeleton'
9
- import { StatCard } from '@/components/ui/StatCard'
10
5
 
11
- const USDC_BASE = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'
12
- const USDC = contract(USDC_BASE, ERC20_ABI)
13
-
14
- function DataRow({ label, value, loading }) {
15
- return (
16
- <div className="flex items-center justify-between py-3 border-b border-zinc-800/50 last:border-0">
17
- <code className="text-[11px] text-yellow-400/70 font-mono">{label}</code>
18
- {loading
19
- ? <Skeleton className="h-3.5 w-28" />
20
- : <span className="font-mono text-xs text-zinc-300">{value ?? '—'}</span>}
21
- </div>
22
- )
23
- }
6
+ const TOKENS = [
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
+ ]
24
13
 
25
14
  export default function Home() {
26
- const { data: name, isLoading: l1 } = useRead(USDC.name())
27
- const { data: symbol, isLoading: l2 } = useRead(USDC.symbol())
28
- const { data: decimals, isLoading: l3 } = useRead(USDC.decimals())
29
- const { data: totalSupply, isLoading: l4 } = useRead(USDC.totalSupply())
30
- const { price: ethPrice, isLoading: lp } = usePrice('ETH')
31
-
32
- const formatted =
33
- totalSupply !== undefined && decimals !== undefined
34
- ? (Number(totalSupply) / 10 ** Number(decimals))
35
- .toLocaleString(undefined, { maximumFractionDigits: 2 })
36
- : undefined
37
-
38
- const synced = !l1 && !l2 && !l3 && !l4
15
+ const { prices, isLoading } = usePrices(TOKENS.map(t => t.symbol))
39
16
 
40
17
  return (
41
- <div className="min-h-screen bg-zinc-950 text-zinc-100">
42
-
43
- {/* ── Header ─────────────────────────────────────── */}
44
- <header className="sticky top-0 z-10 border-b border-zinc-800/60 bg-zinc-950/80 backdrop-blur-sm px-6 py-4">
45
- <div className="max-w-4xl mx-auto flex items-center justify-between">
46
- <div className="flex items-center gap-2.5">
47
- <div className="w-5 h-5 rounded-[4px] bg-yellow-400" />
48
- <span className="font-mono text-[11px] tracking-[0.2em] text-zinc-400 uppercase">
49
- {'{{project-name}}'}
50
- </span>
51
- </div>
52
- <div className="flex items-center gap-3">
53
- <Badge variant="outline">Base</Badge>
54
- <Badge variant={synced ? 'success' : 'loading'}>
55
- {synced ? '● Live' : '○ Loading'}
56
- </Badge>
57
- {process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID && <ConnectButton />}
58
- </div>
59
- </div>
60
- </header>
61
-
62
- <main className="max-w-4xl mx-auto px-6 py-12">
63
-
64
- {/* ── Hero ───────────────────────────────────────── */}
65
- <div className="mb-10">
66
- <Badge variant="outline" className="mb-5">Awarizon Web3 SDK · Next.js</Badge>
67
- <h1 className="text-4xl font-bold tracking-tight text-white mb-3">{'{{ProjectName}}'}</h1>
68
- <p className="text-zinc-400 text-base max-w-lg leading-relaxed">
69
- Live on-chain reads from Base — no backend required. Built with{' '}
70
- <code className="font-mono text-[11px] text-yellow-400/80">@awarizon/react</code>.
71
- </p>
72
- </div>
73
-
74
- {/* ── Data grid ──────────────────────────────────── */}
75
- <div className="grid md:grid-cols-3 gap-4 mb-4">
76
-
77
- <Card className="md:col-span-2">
78
- <div className="flex items-start justify-between mb-4">
79
- <div>
80
- <p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-1.5">Contract · Live Read</p>
81
- <code className="font-mono text-xs text-zinc-500">0x8335…2913 · Base</code>
18
+ <main className="max-w-5xl mx-auto px-6 py-10">
19
+ <div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-4">
20
+ {TOKENS.map(({ symbol, name }) => {
21
+ const price = prices[symbol]?.price
22
+ return (
23
+ <div
24
+ key={symbol}
25
+ 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"
26
+ >
27
+ <div className="mb-4">
28
+ <div className="mb-3">
29
+ <TokenIcon symbol={symbol} size={40} radiusFraction={0.28} />
30
+ </div>
31
+ <p className="text-[11px] text-zinc-500 font-medium mb-0.5">{symbol}</p>
32
+ <p className="text-xs text-zinc-600">{name}</p>
33
+ </div>
34
+ <div className="text-lg font-semibold text-white tracking-tight">
35
+ {isLoading
36
+ ? <Skeleton className="h-5 w-20" />
37
+ : price != null
38
+ ? `$${price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
39
+ : '—'}
82
40
  </div>
83
- <Badge variant={synced ? 'success' : 'loading'}>{synced ? 'Synced' : 'Fetching…'}</Badge>
84
- </div>
85
- <DataRow label="name()" value={name} loading={l1} />
86
- <DataRow label="symbol()" value={symbol} loading={l2} />
87
- <DataRow label="decimals()" value={decimals != null ? String(decimals) : undefined} loading={l3} />
88
- <DataRow label="totalSupply()" value={formatted} loading={l4} />
89
- </Card>
90
-
91
- <div className="flex flex-col gap-4">
92
- <StatCard
93
- label="ETH Price"
94
- value={ethPrice != null ? `$${ethPrice.toLocaleString(undefined, { maximumFractionDigits: 2 })}` : undefined}
95
- loading={lp}
96
- sub="via usePrice"
97
- className="flex-1"
98
- />
99
- <StatCard label="Total Supply" value={formatted} loading={l4} sub="USDC · formatted" className="flex-1" />
100
- </div>
101
- </div>
102
-
103
- {/* ── Network info ────────────────────────────────── */}
104
- <div className="grid sm:grid-cols-3 gap-4 mb-4">
105
- {[
106
- { label: 'Network', value: 'Base Mainnet' },
107
- { label: 'Chain ID', value: '8453' },
108
- { label: 'SDK', value: '@awarizon/react' },
109
- ].map(({ label, value }) => (
110
- <div key={label} className="bg-zinc-900/50 border border-zinc-800/40 rounded-xl px-5 py-4 flex items-center justify-between">
111
- <span className="font-mono text-[10px] text-zinc-600 uppercase tracking-widest">{label}</span>
112
- <code className="font-mono text-xs text-zinc-400">{value}</code>
113
41
  </div>
114
- ))}
115
- </div>
116
-
117
- {/* ── Next steps ──────────────────────────────────── */}
118
- <Card>
119
- <p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-4">Next Steps</p>
120
- <ul className="space-y-3 mb-6">
121
- {[
122
- ['01', 'Replace USDC_BASE with your contract address'],
123
- ['02', 'Swap ERC20_ABI for your contract ABI'],
124
- ['03', 'Change chain="base" in components/Providers.jsx to your target network'],
125
- ['04', 'Use useWrite(USDC.transfer) to send transactions'],
126
- ['05', 'Use usePrice("ETH") or usePrices(["ETH","BTC"]) for live token prices'],
127
- ].map(([n, s]) => (
128
- <li key={n} className="flex items-start gap-3">
129
- <span className="font-mono text-[10px] text-yellow-400/50 mt-0.5 shrink-0 select-none">{n}</span>
130
- <span className="text-sm text-zinc-400 leading-relaxed">{s}</span>
131
- </li>
132
- ))}
133
- </ul>
134
- <div className="flex flex-wrap gap-2">
135
- <Button href="https://awarizon.com/docs" target="_blank" rel="noreferrer">Read the docs →</Button>
136
- <Button href="https://awarizon.com/dashboard" target="_blank" rel="noreferrer" variant="secondary">Dashboard</Button>
137
- </div>
138
- </Card>
139
- </main>
140
- </div>
42
+ )
43
+ })}
44
+ </div>
45
+ </main>
141
46
  )
142
47
  }
@@ -0,0 +1,145 @@
1
+ 'use client'
2
+
3
+ import { useWallet, useNativeBalance, usePrices, ConnectButton, TokenIcon, ChainIcon, getChainNativeSymbol, getChainName } from '@awarizon/react'
4
+ import { Badge } from '@/components/ui/Badge'
5
+ import { Card } from '@/components/ui/Card'
6
+ import { Skeleton } from '@/components/ui/Skeleton'
7
+
8
+ const ASSETS = [
9
+ { symbol: 'ETH', name: 'Ethereum' },
10
+ { symbol: 'BTC', name: 'Bitcoin' },
11
+ { symbol: 'USDC', name: 'USD Coin' },
12
+ { symbol: 'BNB', name: 'BNB' },
13
+ { symbol: 'HYPE', name: 'Hyperliquid' },
14
+ ]
15
+
16
+ function DataRow({ label, value, loading }) {
17
+ return (
18
+ <div className="flex items-center justify-between py-3 border-b border-zinc-800/50 last:border-0">
19
+ <span className="font-mono text-[10px] text-zinc-600 uppercase tracking-widest">{label}</span>
20
+ {loading
21
+ ? <Skeleton className="h-3.5 w-32" />
22
+ : <span className="font-mono text-xs text-zinc-300">{value ?? '—'}</span>}
23
+ </div>
24
+ )
25
+ }
26
+
27
+ export default function WalletPage() {
28
+ const { address, isConnected, isChainMismatch, chainId, connectorInfo } = useWallet()
29
+ const nativeSymbol = chainId != null ? getChainNativeSymbol(chainId) : 'ETH'
30
+ const { formatted: nativeBalance, isLoading: balanceLoading } = useNativeBalance(
31
+ address ?? undefined,
32
+ 12_000,
33
+ )
34
+ const { prices, isLoading: pricesLoading } = usePrices(ASSETS.map(a => a.symbol))
35
+
36
+ const ethFiatValue =
37
+ nativeBalance != null && prices['ETH']?.price != null
38
+ ? `$${(parseFloat(nativeBalance) * prices['ETH'].price).toLocaleString(undefined, { maximumFractionDigits: 2 })}`
39
+ : undefined
40
+
41
+ return (
42
+ <main className="max-w-4xl mx-auto px-6 py-12">
43
+
44
+ {/* ── Hero ───────────────────────────────────────── */}
45
+ <div className="mb-10">
46
+ <Badge variant="outline" className="mb-5">Portfolio</Badge>
47
+ <h1 className="text-4xl font-bold tracking-tight text-white mb-3">Wallet</h1>
48
+ <p className="text-zinc-400 text-base max-w-lg leading-relaxed">
49
+ Live balance and portfolio data via{' '}
50
+ <code className="font-mono text-[11px] text-yellow-400/80">useWallet</code>,{' '}
51
+ <code className="font-mono text-[11px] text-yellow-400/80">useNativeBalance</code>, and{' '}
52
+ <code className="font-mono text-[11px] text-yellow-400/80">usePrices</code>.
53
+ </p>
54
+ </div>
55
+
56
+ {!isConnected ? (
57
+ <Card className="py-12 flex flex-col items-center text-center">
58
+ <p className="font-mono text-[10px] tracking-widest text-zinc-600 uppercase mb-3">
59
+ No Wallet Connected
60
+ </p>
61
+ <p className="text-zinc-400 text-sm mb-6 max-w-sm leading-relaxed">
62
+ Connect a wallet to view your address, native balance, and real-time portfolio value.
63
+ </p>
64
+ <ConnectButton />
65
+ </Card>
66
+ ) : (
67
+ <>
68
+ {isChainMismatch && (
69
+ <div className="mb-4 px-4 py-3 bg-amber-500/10 border border-amber-500/20 rounded-xl">
70
+ <span className="font-mono text-xs text-amber-400">
71
+ Wrong network — switch to the chain configured in components/Providers.jsx
72
+ </span>
73
+ </div>
74
+ )}
75
+
76
+ {/* ── Account ──────────────────────────────────── */}
77
+ <Card className="mb-4">
78
+ <p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-4">Account</p>
79
+ <DataRow label="Address" value={address ?? undefined} loading={false} />
80
+ <DataRow label="Chain" value={chainId != null ? getChainName(chainId) : undefined} loading={false} />
81
+ <DataRow label="Connector" value={connectorInfo?.name ?? connectorInfo?.type} loading={false} />
82
+ </Card>
83
+
84
+ {/* ── Balance ──────────────────────────────────── */}
85
+ <Card className="mb-4">
86
+ <p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-3">Balance</p>
87
+ <div className="flex items-center gap-3 py-2">
88
+ {chainId != null
89
+ ? <ChainIcon chainId={chainId} size={36} radiusFraction={0.5} />
90
+ : <TokenIcon symbol={nativeSymbol} size={36} radiusFraction={0.5} />
91
+ }
92
+ <div className="flex-1 min-w-0">
93
+ <p className="text-sm font-medium text-white">{nativeSymbol}</p>
94
+ <p className="text-xs text-zinc-500">{chainId != null ? getChainName(chainId) : 'Native'}</p>
95
+ </div>
96
+ <div className="text-right">
97
+ {balanceLoading
98
+ ? <Skeleton className="h-4 w-28" />
99
+ : <>
100
+ <p className="text-sm font-medium text-white">
101
+ {nativeBalance != null ? `${parseFloat(nativeBalance).toFixed(6)} ${nativeSymbol}` : '—'}
102
+ </p>
103
+ {ethFiatValue && (
104
+ <p className="text-xs text-zinc-500">{ethFiatValue}</p>
105
+ )}
106
+ </>
107
+ }
108
+ </div>
109
+ </div>
110
+ </Card>
111
+
112
+ {/* ── Assets ───────────────────────────────────── */}
113
+ <Card>
114
+ <p className="font-mono text-[9px] tracking-widest text-zinc-600 uppercase mb-3">Assets</p>
115
+ <div className="divide-y divide-zinc-800/50">
116
+ {ASSETS.map(({ symbol, name }) => {
117
+ const price = prices[symbol]?.price
118
+ return (
119
+ <div key={symbol} className="flex items-center gap-3 py-3 first:pt-0 last:pb-0">
120
+ <TokenIcon symbol={symbol} size={36} radiusFraction={0.28} />
121
+ <div className="flex-1 min-w-0">
122
+ <p className="text-sm font-medium text-white">{symbol}</p>
123
+ <p className="text-xs text-zinc-500">{name}</p>
124
+ </div>
125
+ <div className="text-right">
126
+ {pricesLoading
127
+ ? <Skeleton className="h-4 w-20" />
128
+ : <p className="text-sm font-medium text-white">
129
+ {price != null
130
+ ? `$${price.toLocaleString(undefined, { maximumFractionDigits: 2 })}`
131
+ : '—'}
132
+ </p>
133
+ }
134
+ <p className="text-xs text-zinc-600">USD · usePrices</p>
135
+ </div>
136
+ </div>
137
+ )
138
+ })}
139
+ </div>
140
+ </Card>
141
+ </>
142
+ )}
143
+ </main>
144
+ )
145
+ }
@@ -0,0 +1,60 @@
1
+ 'use client'
2
+
3
+ import Link from 'next/link'
4
+ import { usePathname } from 'next/navigation'
5
+ import { ConnectButton, ChainIcon, useWallet, getChainName } from '@awarizon/react'
6
+
7
+ const NAV = [
8
+ { href: '/', label: 'Markets' },
9
+ { href: '/nft', label: 'NFT' },
10
+ { href: '/wallet', label: 'Wallet' },
11
+ ]
12
+
13
+ export function Header() {
14
+ const pathname = usePathname()
15
+ const { chainId } = useWallet()
16
+ const displayChainId = chainId ?? 8453
17
+ const chainName = getChainName(displayChainId)
18
+
19
+ return (
20
+ <header className="sticky top-0 z-50 border-b border-white/[0.06] bg-zinc-950/70 backdrop-blur-2xl">
21
+ <div className="max-w-5xl mx-auto px-6 h-16 flex items-center justify-between gap-8">
22
+
23
+ <div className="flex items-center gap-2.5 shrink-0">
24
+ <div className="w-7 h-7 rounded-lg bg-yellow-400" />
25
+ <span className="text-sm font-semibold text-white">{'{{project-name}}'}</span>
26
+ </div>
27
+
28
+ <nav className="flex items-center">
29
+ {NAV.map(({ href, label }) => {
30
+ const active = pathname === href
31
+ return (
32
+ <Link
33
+ key={href}
34
+ href={href}
35
+ className={[
36
+ 'relative px-4 py-2 text-sm font-medium transition-colors',
37
+ active ? 'text-white' : 'text-zinc-500 hover:text-zinc-300',
38
+ ].join(' ')}
39
+ >
40
+ {label}
41
+ {active && (
42
+ <span className="absolute bottom-0 left-4 right-4 h-px bg-yellow-400" />
43
+ )}
44
+ </Link>
45
+ )
46
+ })}
47
+ </nav>
48
+
49
+ <div className="flex items-center gap-3 shrink-0">
50
+ <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">
51
+ <ChainIcon chainId={displayChainId} size={16} radiusFraction={0.5} />
52
+ {chainName}
53
+ </div>
54
+ {process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID && <ConnectButton />}
55
+ </div>
56
+
57
+ </div>
58
+ </header>
59
+ )
60
+ }
@@ -3,24 +3,23 @@
3
3
  "version": "0.1.0",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "next dev",
6
+ "dev": "next dev",
7
7
  "build": "next build",
8
8
  "start": "next start",
9
- "lint": "next lint"
9
+ "lint": "next lint"
10
10
  },
11
11
  "dependencies": {
12
- "@awarizon/react": "^1.6.1",
13
- "@awarizon/web3": "^1.3.4",
14
- "next": "14.2.5",
15
- "react": "^18",
16
- "react-dom": "^18"
12
+ "@awarizon/react": "^1.6.4",
13
+ "@awarizon/web3": "^1.3.7",
14
+ "next": "14.2.5",
15
+ "react": "^18",
16
+ "react-dom": "^18"
17
17
  },
18
18
  "devDependencies": {
19
- "eslint": "^8",
19
+ "eslint": "^8",
20
20
  "eslint-config-next": "14.2.5",
21
- "autoprefixer": "^10.4.19",
22
- "postcss": "^8.4.38",
23
- "tailwindcss": "^3.4.4"
21
+ "autoprefixer": "^10.4.19",
22
+ "postcss": "^8.4.38",
23
+ "tailwindcss": "^3.4.4"
24
24
  }
25
25
  }
26
-
@@ -4,26 +4,25 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "vite",
8
- "build": "tsc -b && vite build",
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
9
  "preview": "vite preview",
10
- "lint": "eslint ."
10
+ "lint": "eslint ."
11
11
  },
12
12
  "dependencies": {
13
- "@awarizon/react": "^1.6.1",
14
- "@awarizon/web3": "^1.3.4",
15
- "react": "^18.3.1",
16
- "react-dom": "^18.3.1"
13
+ "@awarizon/react": "^1.6.4",
14
+ "@awarizon/web3": "^1.3.7",
15
+ "react": "^18.3.1",
16
+ "react-dom": "^18.3.1"
17
17
  },
18
18
  "devDependencies": {
19
- "@types/react": "^18.3.1",
20
- "@types/react-dom": "^18.3.1",
19
+ "@types/react": "^18.3.1",
20
+ "@types/react-dom": "^18.3.1",
21
21
  "@vitejs/plugin-react": "^4.3.1",
22
- "typescript": "^5.5.3",
23
- "vite": "^5.4.1",
24
- "autoprefixer": "^10.4.19",
25
- "postcss": "^8.4.38",
26
- "tailwindcss": "^3.4.4"
22
+ "typescript": "^5.5.3",
23
+ "vite": "^5.4.1",
24
+ "autoprefixer": "^10.4.19",
25
+ "postcss": "^8.4.38",
26
+ "tailwindcss": "^3.4.4"
27
27
  }
28
28
  }
29
-