Skip to content

Commit 1e63170

Browse files
committed
fix
1 parent b4c1c9e commit 1e63170

File tree

7 files changed

+45
-25
lines changed

7 files changed

+45
-25
lines changed

netlify.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
[build]
22
command = "npm run build"
33
publish = "dist"
4-
base = "/"
5-
6-
[build.environment]
7-
NODE_VERSION = "20"
84

95
[[redirects]]
106
from = "/*"
@@ -14,8 +10,8 @@
1410
[[headers]]
1511
for = "/*"
1612
[headers.values]
17-
X-Frame-Options = "DENY"
13+
X-Frame-Options = "SAMEORIGIN"
1814
X-XSS-Protection = "1; mode=block"
1915
X-Content-Type-Options = "nosniff"
16+
Content-Security-Policy = "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://bitcoin.atomicwallet.io https://blockchain.info https://api.github.com;"
2017
Referrer-Policy = "strict-origin-when-cross-origin"
21-
Content-Security-Policy = "default-src 'self' https: wss: data: 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https: wss: https://bitcoin.atomicwallet.io https://blockchain.info https://api.github.com ws://ws.blockchain.info wss://ws.blockchain.info;"

server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ app.use((req, res, next) => {
197197
next();
198198
});
199199

200-
// For any request that doesn't match the above, send the index.html file
200+
// Handle client-side routing
201201
app.get('*', (req, res) => {
202202
res.sendFile(path.join(__dirname, '../dist/index.html'));
203203
});

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { HashRouter as Router, Routes, Route, Link, useNavigate } from 'react-router-dom';
2+
import { BrowserRouter as Router, Routes, Route, Link, useNavigate } from 'react-router-dom';
33
import { Home } from './pages/Home';
44
import { Address } from './pages/Address';
55
import { Transaction } from './pages/Transaction';
@@ -77,7 +77,7 @@ function HeaderSearch() {
7777

7878
function App() {
7979
return (
80-
<Router>
80+
<Router basename="/">
8181
<div className="min-h-screen bg-[#0B1017] text-gray-100 flex flex-col">
8282
<nav className="sticky top-0 z-50 bg-[#0E141B] shadow-md border-b border-gray-800">
8383
<div className="max-w-7xl mx-auto px-4">

src/pages/Transaction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const Transaction: React.FC = () => {
8686
const confirmationStatus = data.confirmations > 0 ? (
8787
<div className="flex items-center gap-2 text-green-400">
8888
<CheckCircle2 className="w-5 h-5" />
89-
<span>Confirmed</span>
89+
<span>Confirmed ({data.confirmations} confirmations)</span>
9090
</div>
9191
) : (
9292
<div className="flex items-center gap-2 text-yellow-400">

src/types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,27 @@ export interface BlockchainStatsResponse {
249249
totalbc: number;
250250
}
251251

252+
// Blockchain API response types
253+
export interface BlockchainTransaction {
254+
hash: string;
255+
block_height: number;
256+
time: number;
257+
confirmations: number;
258+
fee: number;
259+
size: number;
260+
total: number;
261+
inputs: Array<{
262+
prev_out: {
263+
addr?: string;
264+
value: number;
265+
};
266+
}>;
267+
out: Array<{
268+
addr?: string;
269+
value: number;
270+
}>;
271+
}
272+
252273
// Bitcoin price types
253274
export interface BitcoinPrice {
254275
USD: {

src/utils/api.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const fetchAddressInfo = async (address: string): Promise<AddressResponse
113113
export const fetchTransactionInfo = async (txid: string): Promise<TransactionResponse> => {
114114
try {
115115
const response = await retryRequest(() =>
116-
bitcoinApi.get(`/tx/${txid}`)
116+
blockchainApi.get(`/rawtx/${txid}?format=json`)
117117
);
118118

119119
if (!response.data) {
@@ -122,23 +122,26 @@ export const fetchTransactionInfo = async (txid: string): Promise<TransactionRes
122122

123123
const data = response.data;
124124

125-
return {
126-
txid: data.txid,
127-
blockHeight: data.blockHeight || 0,
128-
blockTime: data.blockTime || Math.floor(Date.now() / 1000),
125+
// Process the transaction data
126+
const processedData: TransactionResponse = {
127+
txid: data.hash,
128+
blockHeight: data.block_height || 0,
129+
blockTime: data.time || Math.floor(Date.now() / 1000),
129130
confirmations: data.confirmations || 0,
130-
fees: data.fees || '0',
131+
fees: data.fee ? (data.fee / 100000000).toString() : '0', // Convert satoshis to BTC
131132
size: data.size || 0,
132-
value: data.value || '0',
133-
vin: (data.vin || []).map((input: any) => ({
134-
addresses: input.addresses || [],
135-
value: input.value || '0'
133+
value: data.total ? (data.total / 100000000).toString() : '0', // Convert satoshis to BTC
134+
vin: (data.inputs || []).map((input: any) => ({
135+
addresses: input.prev_out?.addr ? [input.prev_out.addr] : [],
136+
value: input.prev_out?.value ? (input.prev_out.value / 100000000).toString() : '0' // Convert satoshis to BTC
136137
})),
137-
vout: (data.vout || []).map((output: any) => ({
138-
addresses: output.addresses || [],
139-
value: output.value || '0'
138+
vout: (data.out || []).map((output: any) => ({
139+
addresses: output.addr ? [output.addr] : [],
140+
value: output.value ? (output.value / 100000000).toString() : '0' // Convert satoshis to BTC
140141
}))
141142
};
143+
144+
return processedData;
142145
} catch (error) {
143146
console.error('Error fetching transaction info:', error);
144147
if (axios.isAxiosError(error)) {

vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export default defineConfig({
5959
build: {
6060
outDir: 'dist',
6161
assetsDir: 'assets',
62-
// Set base path for GitHub Pages deployment
63-
base: './',
62+
// Set base path for production deployment
63+
base: '/',
6464
rollupOptions: {
6565
output: {
6666
entryFileNames: 'assets/js/[name].js',

0 commit comments

Comments
 (0)