transaction not happenning and chart is not showinng
Browse files- index.html +152 -16
index.html
CHANGED
|
@@ -8,9 +8,12 @@
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
.gradient-bg {
|
| 15 |
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
| 16 |
}
|
|
@@ -126,11 +129,11 @@
|
|
| 126 |
<div class="card-glass p-4">
|
| 127 |
<div id="transactionsList">
|
| 128 |
<!-- Transactions will be populated here -->
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
</div>
|
| 133 |
</div>
|
|
|
|
| 134 |
</div>
|
| 135 |
</section>
|
| 136 |
</main>
|
|
@@ -217,10 +220,10 @@
|
|
| 217 |
<i data-feather="user"></i>
|
| 218 |
<span class="text-xs mt-1">Profile</span>
|
| 219 |
</a>
|
| 220 |
-
</div>
|
| 221 |
</div>
|
| 222 |
</nav>
|
| 223 |
-
|
| 224 |
|
| 225 |
<script>
|
| 226 |
// Initialize Vanta.js background
|
|
@@ -239,12 +242,103 @@
|
|
| 239 |
waveSpeed: 0.50,
|
| 240 |
zoom: 0.75
|
| 241 |
});
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
const assets = [
|
| 249 |
{ name: 'Ethereum', symbol: 'ETH', balance: 1.42, price: 1850.32, change24h: 2.4, icon: 'activity' },
|
| 250 |
{ name: 'Bitcoin', symbol: 'BTC', balance: 0.042, price: 29500.75, change24h: -1.2, icon: 'bitcoin' },
|
|
@@ -337,10 +431,52 @@
|
|
| 337 |
alert('Please install MetaMask or another Ethereum wallet');
|
| 338 |
}
|
| 339 |
});
|
| 340 |
-
|
| 341 |
// Refresh icons after dynamic content
|
| 342 |
feather.replace();
|
| 343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
</script>
|
| 345 |
</body>
|
| 346 |
</html>
|
|
|
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.waves.min.js"></script>
|
| 13 |
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 14 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
|
| 15 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
|
| 16 |
+
<style>
|
| 17 |
.gradient-bg {
|
| 18 |
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
| 19 |
}
|
|
|
|
| 129 |
<div class="card-glass p-4">
|
| 130 |
<div id="transactionsList">
|
| 131 |
<!-- Transactions will be populated here -->
|
| 132 |
+
<div id="transactionsChart" class="h-64 mb-6"></div>
|
| 133 |
+
<div id="transactionHistory" class="space-y-3">
|
| 134 |
+
<!-- Transactions will be populated here -->
|
|
|
|
| 135 |
</div>
|
| 136 |
+
</div>
|
| 137 |
</div>
|
| 138 |
</section>
|
| 139 |
</main>
|
|
|
|
| 220 |
<i data-feather="user"></i>
|
| 221 |
<span class="text-xs mt-1">Profile</span>
|
| 222 |
</a>
|
| 223 |
+
</div>
|
| 224 |
</div>
|
| 225 |
</nav>
|
| 226 |
+
</div>
|
| 227 |
|
| 228 |
<script>
|
| 229 |
// Initialize Vanta.js background
|
|
|
|
| 242 |
waveSpeed: 0.50,
|
| 243 |
zoom: 0.75
|
| 244 |
});
|
| 245 |
+
// Initialize Feather Icons
|
| 246 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 247 |
+
feather.replace();
|
| 248 |
|
| 249 |
+
// Initialize Chart
|
| 250 |
+
const ctx = document.getElementById('transactionsChart').getContext('2d');
|
| 251 |
+
const chart = new Chart(ctx, {
|
| 252 |
+
type: 'line',
|
| 253 |
+
data: {
|
| 254 |
+
datasets: [{
|
| 255 |
+
label: 'Portfolio Value',
|
| 256 |
+
data: [
|
| 257 |
+
{x: '2023-01-01', y: 1000},
|
| 258 |
+
{x: '2023-02-01', y: 1200},
|
| 259 |
+
{x: '2023-03-01', y: 950},
|
| 260 |
+
{x: '2023-04-01', y: 1500},
|
| 261 |
+
{x: '2023-05-01', y: 1800},
|
| 262 |
+
{x: '2023-06-01', y: 2000},
|
| 263 |
+
{x: '2023-07-01', y: 2200}
|
| 264 |
+
],
|
| 265 |
+
borderColor: '#3b82f6',
|
| 266 |
+
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
| 267 |
+
tension: 0.3,
|
| 268 |
+
fill: true
|
| 269 |
+
}]
|
| 270 |
+
},
|
| 271 |
+
options: {
|
| 272 |
+
responsive: true,
|
| 273 |
+
scales: {
|
| 274 |
+
x: {
|
| 275 |
+
type: 'time',
|
| 276 |
+
time: {
|
| 277 |
+
unit: 'month'
|
| 278 |
+
}
|
| 279 |
+
},
|
| 280 |
+
y: {
|
| 281 |
+
beginAtZero: false
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
});
|
| 286 |
+
|
| 287 |
+
// Sample transactions data
|
| 288 |
+
const transactions = [
|
| 289 |
+
{
|
| 290 |
+
type: 'send',
|
| 291 |
+
asset: 'ETH',
|
| 292 |
+
amount: 0.5,
|
| 293 |
+
address: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7',
|
| 294 |
+
date: '2023-06-15',
|
| 295 |
+
status: 'completed'
|
| 296 |
+
},
|
| 297 |
+
{
|
| 298 |
+
type: 'receive',
|
| 299 |
+
asset: 'BTC',
|
| 300 |
+
amount: 0.02,
|
| 301 |
+
address: '0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7',
|
| 302 |
+
date: '2023-06-10',
|
| 303 |
+
status: 'completed'
|
| 304 |
+
},
|
| 305 |
+
{
|
| 306 |
+
type: 'swap',
|
| 307 |
+
asset: 'ETH to USDC',
|
| 308 |
+
amount: 1.2,
|
| 309 |
+
address: 'Exchange',
|
| 310 |
+
date: '2023-05-28',
|
| 311 |
+
status: 'completed'
|
| 312 |
+
}
|
| 313 |
+
];
|
| 314 |
+
|
| 315 |
+
// Populate transactions
|
| 316 |
+
const transactionsList = document.getElementById('transactionHistory');
|
| 317 |
+
transactions.forEach(tx => {
|
| 318 |
+
const txType = tx.type === 'send' ? 'Sent' : tx.type === 'receive' ? 'Received' : 'Swapped';
|
| 319 |
+
const txIcon = tx.type === 'send' ? 'arrow-up-right' : tx.type === 'receive' ? 'arrow-down-left' : 'repeat';
|
| 320 |
+
const txColor = tx.type === 'send' ? 'text-red-400' : tx.type === 'receive' ? 'text-green-400' : 'text-purple-400';
|
| 321 |
+
|
| 322 |
+
const txElement = document.createElement('div');
|
| 323 |
+
txElement.className = 'transaction-item p-4 rounded-lg bg-gray-800 flex justify-between items-center';
|
| 324 |
+
txElement.innerHTML = `
|
| 325 |
+
<div class="flex items-center">
|
| 326 |
+
<div class="mr-3 p-2 rounded-full ${tx.type === 'send' ? 'bg-red-900' : tx.type === 'receive' ? 'bg-green-900' : 'bg-purple-900'}">
|
| 327 |
+
<i data-feather="${txIcon}" class="${txColor}"></i>
|
| 328 |
+
</div>
|
| 329 |
+
<div>
|
| 330 |
+
<p class="font-medium">${txType} ${tx.asset}</p>
|
| 331 |
+
<p class="text-sm text-gray-400">${tx.address.substring(0, 6)}...${tx.address.substring(tx.address.length - 4)}</p>
|
| 332 |
+
</div>
|
| 333 |
+
</div>
|
| 334 |
+
<div class="text-right">
|
| 335 |
+
<p class="font-medium">${tx.type === 'send' ? '-' : '+'}${tx.amount} ${tx.asset.split(' ')[0]}</p>
|
| 336 |
+
<p class="text-sm text-gray-400">${new Date(tx.date).toLocaleDateString()}</p>
|
| 337 |
+
</div>
|
| 338 |
+
`;
|
| 339 |
+
transactionsList.appendChild(txElement);
|
| 340 |
+
});
|
| 341 |
+
// Sample data for assets
|
| 342 |
const assets = [
|
| 343 |
{ name: 'Ethereum', symbol: 'ETH', balance: 1.42, price: 1850.32, change24h: 2.4, icon: 'activity' },
|
| 344 |
{ name: 'Bitcoin', symbol: 'BTC', balance: 0.042, price: 29500.75, change24h: -1.2, icon: 'bitcoin' },
|
|
|
|
| 431 |
alert('Please install MetaMask or another Ethereum wallet');
|
| 432 |
}
|
| 433 |
});
|
|
|
|
| 434 |
// Refresh icons after dynamic content
|
| 435 |
feather.replace();
|
| 436 |
+
|
| 437 |
+
// Connect wallet handler with transaction simulation
|
| 438 |
+
document.getElementById('connectWallet').addEventListener('click', async () => {
|
| 439 |
+
if (window.ethereum) {
|
| 440 |
+
try {
|
| 441 |
+
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
|
| 442 |
+
console.log('Connected:', accounts[0]);
|
| 443 |
+
document.getElementById('connectWallet').innerHTML = `
|
| 444 |
+
<i data-feather="check-circle" class="mr-2"></i> ${accounts[0].substring(0, 6)}...${accounts[0].substring(38)}
|
| 445 |
+
`;
|
| 446 |
+
|
| 447 |
+
// Simulate receiving ETH after connection
|
| 448 |
+
setTimeout(() => {
|
| 449 |
+
const transactionsList = document.getElementById('transactionHistory');
|
| 450 |
+
const newTx = document.createElement('div');
|
| 451 |
+
newTx.className = 'transaction-item p-4 rounded-lg bg-gray-800 flex justify-between items-center';
|
| 452 |
+
newTx.innerHTML = `
|
| 453 |
+
<div class="flex items-center">
|
| 454 |
+
<div class="mr-3 p-2 rounded-full bg-green-900">
|
| 455 |
+
<i data-feather="arrow-down-left" class="text-green-400"></i>
|
| 456 |
+
</div>
|
| 457 |
+
<div>
|
| 458 |
+
<p class="font-medium">Received ETH</p>
|
| 459 |
+
<p class="text-sm text-gray-400">${accounts[0].substring(0, 6)}...${accounts[0].substring(accounts[0].length - 4)}</p>
|
| 460 |
+
</div>
|
| 461 |
+
</div>
|
| 462 |
+
<div class="text-right">
|
| 463 |
+
<p class="font-medium">+0.1 ETH</p>
|
| 464 |
+
<p class="text-sm text-gray-400">Just now</p>
|
| 465 |
+
</div>
|
| 466 |
+
`;
|
| 467 |
+
transactionsList.prepend(newTx);
|
| 468 |
+
feather.replace();
|
| 469 |
+
}, 1500);
|
| 470 |
+
|
| 471 |
+
feather.replace();
|
| 472 |
+
} catch (error) {
|
| 473 |
+
console.error('User rejected request:', error);
|
| 474 |
+
}
|
| 475 |
+
} else {
|
| 476 |
+
alert('Please install MetaMask or another Ethereum wallet');
|
| 477 |
+
}
|
| 478 |
+
});
|
| 479 |
+
});
|
| 480 |
</script>
|
| 481 |
</body>
|
| 482 |
</html>
|