create-polygon-kit 0.2.0 → 1.0.0
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 +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/nextjs/typescript/app/page.tsx +148 -48
- package/templates/remix/typescript/.env.example +2 -0
- package/templates/remix/typescript/README.md +47 -0
- package/templates/remix/typescript/app/components/client-only.tsx +15 -0
- package/templates/remix/typescript/app/components/dashboard.tsx +285 -0
- package/templates/remix/typescript/app/components/landing-page.tsx +432 -0
- package/templates/remix/typescript/app/providers.tsx +18 -0
- package/templates/remix/typescript/app/root.tsx +44 -0
- package/templates/remix/typescript/app/routes/_index.tsx +25 -0
- package/templates/remix/typescript/package.json +37 -0
- package/templates/remix/typescript/tsconfig.json +30 -0
- package/templates/remix/typescript/vite.config.ts +16 -0
- package/templates/vite/typescript/src/App.tsx +151 -58
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
|
|
2
|
+
Wallet,
|
|
3
|
+
ConnectWallet,
|
|
4
|
+
WalletDropdown,
|
|
5
|
+
Identity,
|
|
6
|
+
Avatar,
|
|
7
|
+
Name,
|
|
8
|
+
TokenBalance,
|
|
9
|
+
TokenIcon,
|
|
10
|
+
TransactionButton,
|
|
11
|
+
Swap,
|
|
12
|
+
usePolygonKit,
|
|
13
|
+
} from '@sanketsaagar/polygon-kit';
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { parseEther } from 'viem';
|
|
16
|
+
|
|
17
|
+
function LandingPage() {
|
|
18
|
+
return (
|
|
19
|
+
<div className="min-h-screen bg-gradient-to-br from-purple-900 via-indigo-900 to-blue-900">
|
|
20
|
+
<div className="container mx-auto px-4 py-16">
|
|
21
|
+
<nav className="flex justify-between items-center mb-20">
|
|
22
|
+
<div className="flex items-center space-x-2">
|
|
23
|
+
<div className="w-10 h-10 bg-gradient-to-br from-purple-400 to-pink-400 rounded-lg" />
|
|
24
|
+
<span className="text-2xl font-bold text-white">PolygonKit</span>
|
|
25
|
+
</div>
|
|
26
|
+
<ConnectWallet />
|
|
27
|
+
</nav>
|
|
28
|
+
|
|
29
|
+
<div className="text-center max-w-4xl mx-auto mb-20">
|
|
30
|
+
<h1 className="text-6xl font-bold text-white mb-6 leading-tight">
|
|
31
|
+
Build Amazing Web3 Apps
|
|
32
|
+
<span className="block bg-gradient-to-r from-purple-400 via-pink-400 to-blue-400 bg-clip-text text-transparent">
|
|
33
|
+
On Polygon
|
|
34
|
+
</span>
|
|
35
|
+
</h1>
|
|
36
|
+
<p className="text-xl text-gray-300 mb-8 max-w-2xl mx-auto">
|
|
37
|
+
The fastest way to create decentralized applications with React components,
|
|
38
|
+
TypeScript utilities, and Web3 primitives.
|
|
39
|
+
</p>
|
|
40
|
+
<div className="flex gap-4 justify-center">
|
|
41
|
+
<ConnectWallet />
|
|
42
|
+
<a
|
|
43
|
+
href="https://polygonlabs.mintlify.app"
|
|
44
|
+
target="_blank"
|
|
45
|
+
rel="noopener noreferrer"
|
|
46
|
+
className="px-8 py-3 bg-white/10 backdrop-blur-sm text-white rounded-lg font-semibold hover:bg-white/20 transition-all duration-200"
|
|
47
|
+
>
|
|
48
|
+
View Docs
|
|
49
|
+
</a>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
{/* Network Badges */}
|
|
54
|
+
<div className="flex flex-wrap justify-center gap-4 mb-20">
|
|
55
|
+
{[
|
|
56
|
+
{ name: 'Polygon PoS', color: 'from-purple-500 to-purple-600' },
|
|
57
|
+
{ name: 'Polygon zkEVM', color: 'from-blue-500 to-blue-600' },
|
|
58
|
+
{ name: 'Amoy Testnet', color: 'from-pink-500 to-pink-600' },
|
|
59
|
+
].map((network) => (
|
|
60
|
+
<div
|
|
61
|
+
key={network.name}
|
|
62
|
+
className={`px-6 py-3 bg-gradient-to-r ${network.color} rounded-full text-white font-semibold shadow-lg`}
|
|
63
|
+
>
|
|
64
|
+
{network.name}
|
|
65
|
+
</div>
|
|
66
|
+
))}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
{/* Features Grid */}
|
|
70
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 mb-20">
|
|
71
|
+
{[
|
|
72
|
+
{
|
|
73
|
+
icon: '⚡',
|
|
74
|
+
title: 'Lightning Fast',
|
|
75
|
+
description: 'Build and deploy in minutes with pre-built components and hooks',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
icon: '🔒',
|
|
79
|
+
title: 'Secure by Default',
|
|
80
|
+
description: 'Battle-tested wallet connections and transaction handling',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
icon: '🎨',
|
|
84
|
+
title: 'Beautiful UI',
|
|
85
|
+
description: 'Modern, responsive components that work out of the box',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
icon: '🔗',
|
|
89
|
+
title: 'Multi-Chain',
|
|
90
|
+
description: 'Support for Polygon PoS, zkEVM, and more chains',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: '📱',
|
|
94
|
+
title: 'Mobile Ready',
|
|
95
|
+
description: 'Responsive design that works on all devices',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
icon: '🛠️',
|
|
99
|
+
title: 'Developer First',
|
|
100
|
+
description: 'TypeScript support, great DX, and detailed documentation',
|
|
101
|
+
},
|
|
102
|
+
].map((feature) => (
|
|
103
|
+
<div
|
|
104
|
+
key={feature.title}
|
|
105
|
+
className="p-8 bg-white/5 backdrop-blur-lg rounded-2xl border border-white/10 hover:bg-white/10 transition-all duration-300 hover:scale-105"
|
|
106
|
+
>
|
|
107
|
+
<div className="text-4xl mb-4">{feature.icon}</div>
|
|
108
|
+
<h3 className="text-xl font-bold text-white mb-2">{feature.title}</h3>
|
|
109
|
+
<p className="text-gray-300">{feature.description}</p>
|
|
110
|
+
</div>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
{/* Stats */}
|
|
115
|
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-8 max-w-4xl mx-auto">
|
|
116
|
+
{[
|
|
117
|
+
{ label: 'Components', value: '20+' },
|
|
118
|
+
{ label: 'Networks', value: '3' },
|
|
119
|
+
{ label: 'Developers', value: '1000+' },
|
|
120
|
+
{ label: 'Open Source', value: '100%' },
|
|
121
|
+
].map((stat) => (
|
|
122
|
+
<div key={stat.label} className="text-center">
|
|
123
|
+
<div className="text-4xl font-bold text-white mb-2">{stat.value}</div>
|
|
124
|
+
<div className="text-gray-400">{stat.label}</div>
|
|
125
|
+
</div>
|
|
126
|
+
))}
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
{/* Footer */}
|
|
131
|
+
<footer className="border-t border-white/10 py-8">
|
|
132
|
+
<div className="container mx-auto px-4 text-center text-gray-400">
|
|
133
|
+
<p>
|
|
134
|
+
Built with ❤️ for the Polygon community •{' '}
|
|
135
|
+
<a
|
|
136
|
+
href="https://github.com/sanketsaagar/polygonKit"
|
|
137
|
+
target="_blank"
|
|
138
|
+
rel="noopener noreferrer"
|
|
139
|
+
className="text-purple-400 hover:text-purple-300"
|
|
140
|
+
>
|
|
141
|
+
View on GitHub
|
|
142
|
+
</a>
|
|
143
|
+
</p>
|
|
144
|
+
</div>
|
|
145
|
+
</footer>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function Dashboard() {
|
|
151
|
+
const { address, isConnected, chainId } = usePolygonKit();
|
|
152
|
+
const [activeTab, setActiveTab] = useState<'overview' | 'components' | 'transactions' | 'swap'>('overview');
|
|
153
|
+
const [txHash, setTxHash] = useState<string>('');
|
|
154
|
+
|
|
155
|
+
const getNetworkName = (chainId?: number) => {
|
|
156
|
+
switch (chainId) {
|
|
157
|
+
case 137:
|
|
158
|
+
return 'Polygon PoS';
|
|
159
|
+
case 1101:
|
|
160
|
+
return 'Polygon zkEVM';
|
|
161
|
+
case 80002:
|
|
162
|
+
return 'Amoy Testnet';
|
|
163
|
+
default:
|
|
164
|
+
return 'Unknown Network';
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
if (!isConnected || !address) {
|
|
169
|
+
return <LandingPage />;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div className="min-h-screen bg-gradient-to-br from-slate-50 via-purple-50 to-indigo-50 dark:from-gray-900 dark:via-purple-900/20 dark:to-indigo-900/20">
|
|
174
|
+
{/* Header */}
|
|
175
|
+
<header className="border-b border-gray-200 dark:border-gray-800 bg-white/50 dark:bg-gray-900/50 backdrop-blur-lg sticky top-0 z-50">
|
|
176
|
+
<div className="container mx-auto px-4 py-4">
|
|
177
|
+
<div className="flex justify-between items-center">
|
|
178
|
+
<div className="flex items-center space-x-3">
|
|
179
|
+
<div className="w-10 h-10 bg-gradient-to-br from-purple-500 to-pink-500 rounded-lg" />
|
|
180
|
+
<div>
|
|
181
|
+
<h1 className="text-xl font-bold text-gray-900 dark:text-white">PolygonKit Showcase</h1>
|
|
182
|
+
<p className="text-sm text-gray-500 dark:text-gray-400">{getNetworkName(chainId)}</p>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
<Wallet>
|
|
186
|
+
<WalletDropdown />
|
|
187
|
+
</Wallet>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</header>
|
|
191
|
+
|
|
192
|
+
<div className="container mx-auto px-4 py-8">
|
|
193
|
+
{/* Tabs */}
|
|
194
|
+
<div className="flex flex-wrap gap-2 mb-8 bg-white/50 dark:bg-gray-800/50 backdrop-blur-sm p-1 rounded-lg w-fit">
|
|
195
|
+
{[
|
|
196
|
+
{ id: 'overview', label: 'Overview', icon: '📊' },
|
|
197
|
+
{ id: 'components', label: 'Components', icon: '🧩' },
|
|
198
|
+
{ id: 'transactions', label: 'Transactions', icon: '💸' },
|
|
199
|
+
{ id: 'swap', label: 'Swap', icon: '🔄' },
|
|
200
|
+
].map((tab) => (
|
|
201
|
+
<button
|
|
202
|
+
key={tab.id}
|
|
203
|
+
onClick={() => setActiveTab(tab.id as typeof activeTab)}
|
|
204
|
+
className={`px-6 py-2 rounded-md font-semibold transition-all duration-200 ${
|
|
205
|
+
activeTab === tab.id
|
|
206
|
+
? 'bg-gradient-to-r from-purple-500 to-pink-500 text-white shadow-lg'
|
|
207
|
+
: 'text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700'
|
|
208
|
+
}`}
|
|
209
|
+
>
|
|
210
|
+
<span className="mr-2">{tab.icon}</span>
|
|
211
|
+
{tab.label}
|
|
212
|
+
</button>
|
|
213
|
+
))}
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
{/* Overview Tab */}
|
|
217
|
+
{activeTab === 'overview' && (
|
|
218
|
+
<div className="space-y-6">
|
|
219
|
+
{/* Wallet Overview */}
|
|
220
|
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
221
|
+
<div className="lg:col-span-2 bg-gradient-to-br from-purple-500 to-pink-500 p-8 rounded-2xl text-white shadow-xl">
|
|
222
|
+
<h2 className="text-lg font-semibold mb-4 opacity-90">Your Wallet</h2>
|
|
223
|
+
<Identity
|
|
224
|
+
address={address}
|
|
225
|
+
showAvatar
|
|
226
|
+
showAddress
|
|
227
|
+
showBalance
|
|
228
|
+
/>
|
|
229
|
+
<div className="mt-6 pt-6 border-t border-white/20">
|
|
230
|
+
<p className="text-sm opacity-75 mb-3">Native Balance</p>
|
|
231
|
+
<TokenBalance address={address} className="text-2xl font-bold" />
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div className="bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg p-6 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
|
|
236
|
+
<h3 className="text-sm font-semibold text-gray-600 dark:text-gray-400 mb-4">Network Status</h3>
|
|
237
|
+
<div className="space-y-4">
|
|
238
|
+
<div className="flex items-center justify-between">
|
|
239
|
+
<span className="text-gray-700 dark:text-gray-300">Status</span>
|
|
240
|
+
<span className="flex items-center gap-2 text-green-600 dark:text-green-400 font-semibold">
|
|
241
|
+
<span className="w-2 h-2 bg-green-500 rounded-full animate-pulse" />
|
|
242
|
+
Connected
|
|
243
|
+
</span>
|
|
244
|
+
</div>
|
|
245
|
+
<div className="flex items-center justify-between">
|
|
246
|
+
<span className="text-gray-700 dark:text-gray-300">Chain ID</span>
|
|
247
|
+
<span className="font-mono font-semibold text-gray-900 dark:text-white">{chainId || 'N/A'}</span>
|
|
248
|
+
</div>
|
|
249
|
+
<div className="flex items-center justify-between">
|
|
250
|
+
<span className="text-gray-700 dark:text-gray-300">Network</span>
|
|
251
|
+
<span className="text-gray-900 dark:text-white font-semibold">{getNetworkName(chainId)}</span>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
{/* Quick Actions */}
|
|
258
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
|
259
|
+
{[
|
|
260
|
+
{ icon: '💸', title: 'Send Tokens', desc: 'Transfer assets', tab: 'transactions' },
|
|
261
|
+
{ icon: '🔄', title: 'Swap', desc: 'Exchange tokens', tab: 'swap' },
|
|
262
|
+
{ icon: '🧩', title: 'Components', desc: 'Explore all features', tab: 'components' },
|
|
263
|
+
{ icon: '📖', title: 'Documentation', desc: 'Learn more', link: 'https://polygonlabs.mintlify.app' },
|
|
264
|
+
].map((action) => (
|
|
265
|
+
<button
|
|
266
|
+
key={action.title}
|
|
267
|
+
onClick={() => action.tab ? setActiveTab(action.tab as typeof activeTab) : window.open(action.link, '_blank')}
|
|
268
|
+
className="p-6 bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg rounded-xl border border-gray-200 dark:border-gray-700 hover:scale-105 transition-all duration-200 text-left group shadow-lg hover:shadow-xl"
|
|
269
|
+
>
|
|
270
|
+
<div className="text-4xl mb-3 group-hover:scale-110 transition-transform">{action.icon}</div>
|
|
271
|
+
<h3 className="font-bold text-gray-900 dark:text-white mb-1">{action.title}</h3>
|
|
272
|
+
<p className="text-sm text-gray-600 dark:text-gray-400">{action.desc}</p>
|
|
273
|
+
</button>
|
|
274
|
+
))}
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
)}
|
|
278
|
+
|
|
279
|
+
{/* Components Showcase Tab */}
|
|
280
|
+
{activeTab === 'components' && (
|
|
281
|
+
<div className="space-y-6">
|
|
282
|
+
<div className="bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg p-8 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
|
|
283
|
+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-6">Identity Components</h2>
|
|
284
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
285
|
+
<div className="p-6 bg-gray-50 dark:bg-gray-700/50 rounded-xl">
|
|
286
|
+
<h3 className="font-semibold mb-4 text-gray-900 dark:text-white">Full Identity</h3>
|
|
287
|
+
<Identity address={address} showAvatar showAddress showBalance />
|
|
288
|
+
</div>
|
|
289
|
+
<div className="p-6 bg-gray-50 dark:bg-gray-700/50 rounded-xl">
|
|
290
|
+
<h3 className="font-semibold mb-4 text-gray-900 dark:text-white">Avatar Only</h3>
|
|
291
|
+
<div className="flex items-center gap-4">
|
|
292
|
+
<Avatar address={address} size={48} />
|
|
293
|
+
<Avatar address={address} size={64} />
|
|
294
|
+
<Avatar address={address} size={80} />
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
<div className="p-6 bg-gray-50 dark:bg-gray-700/50 rounded-xl">
|
|
298
|
+
<h3 className="font-semibold mb-4 text-gray-900 dark:text-white">Name/Address</h3>
|
|
299
|
+
<Name address={address} />
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
|
|
304
|
+
<div className="bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg p-8 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
|
|
305
|
+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-6">Token Components</h2>
|
|
306
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
307
|
+
<div className="p-6 bg-gray-50 dark:bg-gray-700/50 rounded-xl">
|
|
308
|
+
<h3 className="font-semibold mb-4 text-gray-900 dark:text-white">Token Balance</h3>
|
|
309
|
+
<div className="space-y-3">
|
|
310
|
+
<div className="flex items-center justify-between p-3 bg-white dark:bg-gray-800 rounded-lg">
|
|
311
|
+
<span className="text-gray-600 dark:text-gray-400">Native (MATIC)</span>
|
|
312
|
+
<TokenBalance address={address} />
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
<div className="p-6 bg-gray-50 dark:bg-gray-700/50 rounded-xl">
|
|
317
|
+
<h3 className="font-semibold mb-4 text-gray-900 dark:text-white">Token Icons</h3>
|
|
318
|
+
<div className="flex items-center gap-4">
|
|
319
|
+
<div className="text-center">
|
|
320
|
+
<TokenIcon symbol="MATIC" size={32} />
|
|
321
|
+
<p className="text-xs mt-1 text-gray-600 dark:text-gray-400">MATIC</p>
|
|
322
|
+
</div>
|
|
323
|
+
<div className="text-center">
|
|
324
|
+
<TokenIcon symbol="ETH" size={32} />
|
|
325
|
+
<p className="text-xs mt-1 text-gray-600 dark:text-gray-400">ETH</p>
|
|
326
|
+
</div>
|
|
327
|
+
<div className="text-center">
|
|
328
|
+
<TokenIcon symbol="USDC" size={32} />
|
|
329
|
+
<p className="text-xs mt-1 text-gray-600 dark:text-gray-400">USDC</p>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
</div>
|
|
336
|
+
)}
|
|
337
|
+
|
|
338
|
+
{/* Transactions Tab */}
|
|
339
|
+
{activeTab === 'transactions' && (
|
|
340
|
+
<div className="space-y-6">
|
|
341
|
+
<div className="bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg p-8 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
|
|
342
|
+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-6">Send Transaction</h2>
|
|
343
|
+
<p className="text-gray-600 dark:text-gray-400 mb-6">
|
|
344
|
+
Send 0.001 MATIC to a recipient address. Replace the address below with your test address.
|
|
345
|
+
</p>
|
|
346
|
+
<TransactionButton
|
|
347
|
+
text="Send 0.001 MATIC"
|
|
348
|
+
calls={[
|
|
349
|
+
{
|
|
350
|
+
to: address, // Sending to self for demo
|
|
351
|
+
value: parseEther('0.001'),
|
|
352
|
+
},
|
|
353
|
+
]}
|
|
354
|
+
onSuccess={(hash) => {
|
|
355
|
+
console.log('Transaction successful:', hash);
|
|
356
|
+
setTxHash(hash);
|
|
357
|
+
}}
|
|
358
|
+
onError={(error) => {
|
|
359
|
+
console.error('Transaction failed:', error);
|
|
360
|
+
alert('Transaction failed: ' + error.message);
|
|
361
|
+
}}
|
|
362
|
+
className="px-6 py-3 bg-gradient-to-r from-purple-500 to-pink-500 text-white rounded-lg font-semibold hover:from-purple-600 hover:to-pink-600 transition-all"
|
|
363
|
+
/>
|
|
364
|
+
|
|
365
|
+
{txHash && (
|
|
366
|
+
<div className="mt-6 p-4 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800">
|
|
367
|
+
<p className="font-semibold text-green-900 dark:text-green-100 mb-2">Transaction Sent!</p>
|
|
368
|
+
<p className="text-sm text-green-700 dark:text-green-300 break-all">
|
|
369
|
+
Hash: {txHash}
|
|
370
|
+
</p>
|
|
371
|
+
</div>
|
|
372
|
+
)}
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
<div className="bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg p-8 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
|
|
376
|
+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-6">Recent Activity</h2>
|
|
377
|
+
<div className="space-y-4">
|
|
378
|
+
{[
|
|
379
|
+
{ type: 'Received', amount: '100 MATIC', time: '2 mins ago' },
|
|
380
|
+
{ type: 'Sent', amount: '50 MATIC', time: '1 hour ago' },
|
|
381
|
+
{ type: 'Swapped', amount: '25 MATIC → 40 USDC', time: '3 hours ago' },
|
|
382
|
+
].map((tx, idx) => (
|
|
383
|
+
<div key={idx} className="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg">
|
|
384
|
+
<div className="flex items-center gap-4">
|
|
385
|
+
<div className={`w-10 h-10 rounded-full flex items-center justify-center ${
|
|
386
|
+
tx.type === 'Received' ? 'bg-green-100 dark:bg-green-900/30' :
|
|
387
|
+
tx.type === 'Sent' ? 'bg-red-100 dark:bg-red-900/30' :
|
|
388
|
+
'bg-blue-100 dark:bg-blue-900/30'
|
|
389
|
+
}`}>
|
|
390
|
+
{tx.type === 'Received' ? '↓' : tx.type === 'Sent' ? '↑' : '↔'}
|
|
391
|
+
</div>
|
|
392
|
+
<div>
|
|
393
|
+
<p className="font-semibold text-gray-900 dark:text-white">{tx.type}</p>
|
|
394
|
+
<p className="text-sm text-gray-600 dark:text-gray-400">{tx.amount}</p>
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
<div className="text-right">
|
|
398
|
+
<p className="text-sm text-gray-600 dark:text-gray-400">{tx.time}</p>
|
|
399
|
+
<span className="text-xs text-green-600 dark:text-green-400">✓ Confirmed</span>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
))}
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
)}
|
|
407
|
+
|
|
408
|
+
{/* Swap Tab */}
|
|
409
|
+
{activeTab === 'swap' && (
|
|
410
|
+
<div className="max-w-2xl mx-auto">
|
|
411
|
+
<div className="bg-white/80 dark:bg-gray-800/80 backdrop-blur-lg p-8 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
|
|
412
|
+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-6">Token Swap</h2>
|
|
413
|
+
<Swap
|
|
414
|
+
onSuccess={(hash) => {
|
|
415
|
+
console.log('Swap successful:', hash);
|
|
416
|
+
alert('Swap successful! Hash: ' + hash);
|
|
417
|
+
}}
|
|
418
|
+
onError={(error) => {
|
|
419
|
+
console.error('Swap failed:', error);
|
|
420
|
+
alert('Swap failed: ' + error.message);
|
|
421
|
+
}}
|
|
422
|
+
/>
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
)}
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function AppContent() {
|
|
432
|
+
const { isConnected } = usePolygonKit();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PolygonKitProvider } from '@sanketsaagar/polygon-kit';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export function Providers({ children }: { children: ReactNode }) {
|
|
5
|
+
const projectId = typeof window !== 'undefined'
|
|
6
|
+
? (window as any).ENV?.VITE_REOWN_PROJECT_ID
|
|
7
|
+
: undefined;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<PolygonKitProvider
|
|
11
|
+
config={{
|
|
12
|
+
projectId,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</PolygonKitProvider>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Links,
|
|
3
|
+
Meta,
|
|
4
|
+
Outlet,
|
|
5
|
+
Scripts,
|
|
6
|
+
ScrollRestoration,
|
|
7
|
+
} from '@remix-run/react';
|
|
8
|
+
import { Providers } from './providers';
|
|
9
|
+
import type { LinksFunction } from '@remix-run/node';
|
|
10
|
+
|
|
11
|
+
export const links: LinksFunction = () => [
|
|
12
|
+
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
|
|
13
|
+
{
|
|
14
|
+
rel: 'preconnect',
|
|
15
|
+
href: 'https://fonts.gstatic.com',
|
|
16
|
+
crossOrigin: 'anonymous',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export function Layout({ children }: { children: React.ReactNode }) {
|
|
21
|
+
return (
|
|
22
|
+
<html lang="en">
|
|
23
|
+
<head>
|
|
24
|
+
<meta charSet="utf-8" />
|
|
25
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
26
|
+
<Meta />
|
|
27
|
+
<Links />
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
{children}
|
|
31
|
+
<ScrollRestoration />
|
|
32
|
+
<Scripts />
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function App() {
|
|
39
|
+
return (
|
|
40
|
+
<Providers>
|
|
41
|
+
<Outlet />
|
|
42
|
+
</Providers>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MetaFunction } from '@remix-run/node';
|
|
2
|
+
import { ClientOnly } from '~/components/client-only';
|
|
3
|
+
import { Dashboard } from '~/components/dashboard';
|
|
4
|
+
import { LandingPage } from '~/components/landing-page';
|
|
5
|
+
import { usePolygonKit } from '@sanketsaagar/polygon-kit';
|
|
6
|
+
|
|
7
|
+
export const meta: MetaFunction = () => {
|
|
8
|
+
return [
|
|
9
|
+
{ title: 'My Polygon App' },
|
|
10
|
+
{ name: 'description', content: 'Built with PolygonKit' },
|
|
11
|
+
];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function HomeContent() {
|
|
15
|
+
const { isConnected } = usePolygonKit();
|
|
16
|
+
return isConnected ? <Dashboard /> : <LandingPage />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function Index() {
|
|
20
|
+
return (
|
|
21
|
+
<ClientOnly>
|
|
22
|
+
{() => <HomeContent />}
|
|
23
|
+
</ClientOnly>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-polygon-app",
|
|
3
|
+
"private": true,
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "remix vite:build",
|
|
8
|
+
"dev": "remix vite:dev",
|
|
9
|
+
"start": "remix-serve ./build/server/index.js",
|
|
10
|
+
"typecheck": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@remix-run/node": "^2.15.1",
|
|
14
|
+
"@remix-run/react": "^2.15.1",
|
|
15
|
+
"@remix-run/serve": "^2.15.1",
|
|
16
|
+
"@sanketsaagar/polygon-kit": "^0.1.5",
|
|
17
|
+
"wagmi": "^2.12.29",
|
|
18
|
+
"@wagmi/connectors": "^5.5.5",
|
|
19
|
+
"viem": "^2.21.45",
|
|
20
|
+
"@tanstack/react-query": "^5.59.20",
|
|
21
|
+
"isbot": "^4.1.0",
|
|
22
|
+
"react": "^18.3.1",
|
|
23
|
+
"react-dom": "^18.3.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@remix-run/dev": "^2.15.1",
|
|
27
|
+
"@types/react": "^18.3.12",
|
|
28
|
+
"@types/react-dom": "^18.3.1",
|
|
29
|
+
"typescript": "^5.6.2",
|
|
30
|
+
"vite": "^5.4.10",
|
|
31
|
+
"tailwindcss": "^4.0.0",
|
|
32
|
+
"@tailwindcss/vite": "^4.0.0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"**/*.ts",
|
|
4
|
+
"**/*.tsx",
|
|
5
|
+
"**/.server/**/*.ts",
|
|
6
|
+
"**/.server/**/*.tsx",
|
|
7
|
+
"**/.client/**/*.ts",
|
|
8
|
+
"**/.client/**/*.tsx"
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
12
|
+
"types": ["@remix-run/node", "vite/client"],
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
"module": "ESNext",
|
|
17
|
+
"moduleResolution": "Bundler",
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"target": "ES2022",
|
|
20
|
+
"strict": true,
|
|
21
|
+
"allowJs": true,
|
|
22
|
+
"skipLibCheck": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true,
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
"paths": {
|
|
26
|
+
"~/*": ["./app/*"]
|
|
27
|
+
},
|
|
28
|
+
"noEmit": true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { vitePlugin as remix } from '@remix-run/dev';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
remix({
|
|
8
|
+
future: {
|
|
9
|
+
v3_fetcherPersist: true,
|
|
10
|
+
v3_relativeSplatPath: true,
|
|
11
|
+
v3_throwAbortReason: true,
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
tailwindcss(),
|
|
15
|
+
],
|
|
16
|
+
});
|