diff --git a/css/style.css b/css/style.css index 0c91d98..5f9afd2 100644 --- a/css/style.css +++ b/css/style.css @@ -1294,7 +1294,7 @@ body { } .tx-direction.offer-create { - color: #87ceeb; + color: #87ceeb; } .transaction-card.offer .tx-direction { @@ -1331,7 +1331,7 @@ body { } .transaction-card.offer .tx-amount { - color: #87ceeb; + color: #87ceeb; } .transaction-card.offer .tx-direction, @@ -2763,7 +2763,7 @@ sm-popup::part(popup) { transform: scale(1.1); } -/* Responsive adjustments for balance info */ + /* Responsive adjustments for balance info */ @media (max-width: 480px) { .detail-row { flex-direction: column; @@ -2791,7 +2791,39 @@ sm-popup::part(popup) { text-overflow: ellipsis; } } - + + /* Resources and fees styling - always display on separate lines */ + .tx-detail-value.resources-list { + display: flex !important; + flex-direction: column !important; + align-items: flex-end !important; /* Right-align the resource items */ + gap: 0.5rem !important; + text-align: right !important; + width: 100% !important; + } + + /* Special styling for resource rows */ + .tx-detail-row.resource-row { + display: flex; + align-items: flex-start; + justify-content: space-between; + } + + .resource-item { + display: block !important; + padding: 0.25rem 0.5rem !important; + background-color: rgba(59, 130, 246, 0.05) !important; + border-radius: 0.25rem !important; + margin-bottom: 0.375rem !important; + font-family: inherit !important; + text-align: right !important; + width: fit-content !important; + margin-left: auto !important; + } + + .resource-item:last-child { + margin-bottom: 0; + } /* Responsive Design */ @media (max-width: 768px) { .hamburger-btn { @@ -4122,7 +4154,6 @@ sm-popup::part(popup) { max-width: 200px; } - @media (max-width: 480px) and (max-height: 740px) { sm-popup::part(popup) { max-height: 95vh !important; @@ -4202,7 +4233,7 @@ sm-popup::part(popup) { padding: 0.75rem 1rem; font-size: 0.8rem; font-weight: 600; - min-height: 44px; + min-height: 44px; } /* Success popup specific adjustments */ @@ -4426,6 +4457,24 @@ sm-popup::part(popup) { .tx-detail-label { min-width: auto; } + + /* Resource items on small screens - left aligned */ + .tx-detail-value.resources-list { + align-items: flex-start !important; + text-align: left !important; + } + + .resource-item { + text-align: left !important; + margin-left: 0 !important; + width: fit-content !important; + } + + /* Keep resource rows stacked on mobile */ + .tx-detail-row.resource-row { + flex-direction: column; + align-items: flex-start; + } } /* Generate Wallet Page Styles */ diff --git a/index.html b/index.html index fd0f947..3084398 100644 --- a/index.html +++ b/index.html @@ -1093,7 +1093,7 @@ __historyAddress = address; const perPageSelect = document.getElementById("perPageSelect"); const limit = perPageSelect ? parseInt(perPageSelect.value, 10) : 10; - const url = `https://api.shasta.trongrid.io/v1/accounts/${address}/transactions?limit=${limit}`; + const url = `https://api.trongrid.io/v1/accounts/${address}/transactions?limit=${limit}`; const section = document.getElementById("transactionSection"); if (section) section.style.display = "block"; resetHistoryState(limit); @@ -1137,7 +1137,7 @@ perSel.addEventListener("change", () => { if (!__historyAddress) return; const limit = parseInt(perSel.value, 10) || 10; - const url = `https://api.shasta.trongrid.io/v1/accounts/${__historyAddress}/transactions?limit=${limit}`; + const url = `https://api.trongrid.io/v1/accounts/${__historyAddress}/transactions?limit=${limit}`; resetHistoryState(limit); transactionHistory(url, __historyAddress); }); diff --git a/scripts/balance.js b/scripts/balance.js index 4be66c5..5729cbc 100644 --- a/scripts/balance.js +++ b/scripts/balance.js @@ -38,7 +38,7 @@ function shareTxLink(txid) { }); } async function getTransactionDetails(txHash) { - const url = "https://api.shasta.trongrid.io/wallet/gettransactionbyid"; + const url = "https://api.trongrid.io/wallet/gettransactionbyid"; const headers = { Accept: "application/json", "Content-Type": "application/json", @@ -64,7 +64,7 @@ async function getTransactionDetails(txHash) { } async function getTransactionInfoById(txHash) { - const url = "https://api.shasta.trongrid.io/wallet/gettransactioninfobyid"; + const url = "https://api.trongrid.io/wallet/gettransactioninfobyid"; const headers = { Accept: "application/json", "Content-Type": "application/json", @@ -168,11 +168,14 @@ async function runBalanceCheck() { `; if (typeof notify === "function") notify("Balance loaded", "success"); loadHistoryFor(tronAddress); - + // Save searched address to IndexedDB - if (typeof searchedAddressDB !== 'undefined') { + if (typeof searchedAddressDB !== "undefined") { try { - await searchedAddressDB.saveSearchedAddress(tronAddress, balance.toLocaleString()); + await searchedAddressDB.saveSearchedAddress( + tronAddress, + balance.toLocaleString() + ); await updateSearchedAddressesList(); } catch (dbError) { console.warn("Failed to save address to IndexedDB:", dbError); @@ -183,8 +186,7 @@ async function runBalanceCheck() { } else { // Treat as private key (WIF or HEX) const { tronAddress, balance } = await getBalanceByPrivKey(inputVal); - - + let sourceInfo = null; if (/^[5KLc9RQ][1-9A-HJ-NP-Za-km-z]{50,}$/.test(inputVal)) { // This is a BTC/FLO WIF key @@ -192,11 +194,10 @@ async function runBalanceCheck() { type: "Private Key", originalKey: inputVal, originalAddress: inputVal, // Store the original private key for toggling - blockchain: /^[KL]/.test(inputVal) ? "BTC" : "FLO" + blockchain: /^[KL]/.test(inputVal) ? "BTC" : "FLO", }; - } - - + } + output.innerHTML = `
Contract: ${contractBase58} - -
`; - - const input = (v.data || "").startsWith("0x") - ? v.data.slice(2) - : v.data || ""; - const method = input.slice(0, 8).toLowerCase(); - - if (method === "a9059cbb" && input.length >= 8 + 64 + 64) { - const addrSlot = input.slice(8, 8 + 64); - const amountSlot = input.slice(8 + 64, 8 + 64 + 64); - - const evmAddrHex = addrSlot.slice(24); - const tronHex = "41" + evmAddrHex.toLowerCase(); - to = tronWeb.address.fromHex(tronHex); - - const raw = BigInt("0x" + amountSlot); - amount = Number(raw) / 1e6 + " USDT"; - } else { - to = "—"; - amount = "—"; - } - } - - const result = tx.ret?.[0]?.contractRet || "UNKNOWN"; - const statusColor = result === "SUCCESS" ? "green" : "red"; - - // create card - const card = document.createElement("div"); - card.className = "tx-card"; - - card.innerHTML = ` -Hash: ${truncate(hash)} -
-Block: ${block}
-Age: ${age}
-Type: ${type}
-From: ${from} -
-To: ${to} -
- ${extraContractLine} -Amount: ${amount}
-Status: ${result}
- `; - - historyDiv.appendChild(card); - }); - - // save nextUrl for pagination if (data.meta && data.meta.fingerprint) { - nextUrl = `https://api.shasta.trongrid.io/v1/accounts/${address}/transactions?limit=10&fingerprint=${encodeURIComponent( + __nextUrl = `https://api.trongrid.io/v1/accounts/${address}/transactions?limit=${__perPage}&fingerprint=${encodeURIComponent( data.meta.fingerprint )}`; } else { - nextUrl = null; + __nextUrl = null; } + __updatePagination(); } - } catch (error) { - console.error(error); + return data; + } catch (e) { + console.error(e); + if (typeof __origTransactionHistory === "function") { + __origTransactionHistory(url, address); + } + throw e; } -} +}; function fetchNext(address) { if (nextUrl) { @@ -126,50 +73,6 @@ let __currentPage = 1; let __currentUrl = null; let __perPage = 10; -const __origTransactionHistory = transactionHistory; -transactionHistory = async function (url, address) { - try { - if (typeof notify === "function") - notify("Loading transactions...", "success", 1500); - const response = await fetch(url, { - method: "GET", - headers: { accept: "application/json" }, - }); - const data = await response.json(); - - const section = document.getElementById("transactionSection"); - if (section) section.style.display = "block"; - - __currentAddress = address; - __currentUrl = url; - window.lastUsedUrl = url; - - if (data && data.data) { - __currentTxs = data.data; - // track current per-page from url - const m = url.match(/limit=(\d+)/); - if (m) __perPage = parseInt(m[1], 10) || __perPage; - __renderTransactions(); - - if (data.meta && data.meta.fingerprint) { - __nextUrl = `https://api.shasta.trongrid.io/v1/accounts/${address}/transactions?limit=${__perPage}&fingerprint=${encodeURIComponent( - data.meta.fingerprint - )}`; - } else { - __nextUrl = null; - } - __updatePagination(); - } - return data; - } catch (e) { - console.error(e); - if (typeof __origTransactionHistory === "function") { - __origTransactionHistory(url, address); - } - throw e; - } -}; - function __renderTransactions() { const list = document.getElementById("txList"); const legacy = document.getElementById("historyOutput"); @@ -247,10 +150,32 @@ function __renderTransactions() { amountText = Number(raw) / 1e6 + " USDT"; } icon = "fa-file-signature"; + } else if ( + type === "DelegateResourceContract" || + type === "UnDelegateResourceContract" + ) { + // Handle resource delegation/undelegation + const v = tx.raw_data.contract[0].parameter.value; + from = tronWeb.address.fromHex(v.owner_address); + to = v.receiver_address + ? tronWeb.address.fromHex(v.receiver_address) + : ""; + amountText = + v.balance / 1e6 + + " TRX (" + + (v.resource ? v.resource : "Bandwidth") + + ")"; + directionClass = "resource"; } // Set direction and icon based on transaction direction - if (from === __currentAddress) { + if (type === "DelegateResourceContract") { + directionClass = "delegate-resource"; + icon = "fa-exchange-alt"; // custom icon for delegate + } else if (type === "UnDelegateResourceContract") { + directionClass = "reclaim-resource"; + icon = "fa-exchange-alt"; // custom icon for undelegate + } else if (from === __currentAddress) { directionClass = "outgoing"; icon = "fa-arrow-up"; // upward arrow for sent } else if (to === __currentAddress) { @@ -272,7 +197,11 @@ function __renderTransactions() {