Compare commits

...

10 Commits

4 changed files with 430 additions and 40 deletions

32
.github/workflows/push-dappbundle.yml vendored Normal file
View File

@ -0,0 +1,32 @@
name: Workflow push to Dappbundle
on: [push]
jobs:
build:
name: Build
runs-on: self-hosted
steps:
- name: Executing remote command
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.R_HOST }}
username: ${{ secrets.P_USERNAME }}
password: ${{ secrets.P_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
if [ -d "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle" ]; then
echo "Folder exists. Skipping Git clone."
else
echo "Folder does not exist. Cloning repository..."
cd ${{ secrets.DEPLOYMENT_LOCATION}}/ && git clone https://github.com/ranchimall/dappbundle.git
fi
if [ -d "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" ]; then
echo "Repository exists. Remove folder "
rm -r "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}"
fi
echo "Cloning repository..."
cd ${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle && git clone https://github.com/ranchimall/${{ github.event.repository.name }}
cd "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" && rm -rf .gitattributes .git .github .gitignore
cd ${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/ && git add . && git commit -m "Workflow updating files of ${{ github.event.repository.name }}" && git push "https://saketongit:${{ secrets.RM_ACCESS_TOKEN }}@github.com/ranchimall/dappbundle.git"

View File

@ -348,7 +348,7 @@
type="text"
id="transactionInput"
class="form-input"
placeholder="Enter TON address, private key, or transaction hash"
placeholder="Enter TON address or private key (TON/FLO/BTC)"
/>
<button
type="button"
@ -382,22 +382,33 @@
style="display: none"
>
<div class="balance-header">
<h3><i class="fas fa-wallet"></i> Address Balance</h3>
<div class="toggle-container">
<h3><i class="fas fa-wallet"></i> Balance</h3>
<div class="balance-actions">
<button
class="toggle-btn active"
data-currency="TON"
onclick="toggleTransactionBalance('TON')"
id="shareAddressBtn"
class="btn-icon share-btn"
onclick="shareAddress()"
title="Share Address Link"
style="display: none"
>
TON
</button>
<button
class="toggle-btn"
data-currency="USDT"
onclick="toggleTransactionBalance('USDT')"
>
USDT
<i class="fas fa-share-alt"></i>
</button>
<div class="toggle-container">
<button
class="toggle-btn active"
data-currency="TON"
onclick="toggleTransactionBalance('TON')"
>
TON
</button>
<button
class="toggle-btn"
data-currency="USDT"
onclick="toggleTransactionBalance('USDT')"
>
USDT
</button>
</div>
</div>
</div>
<div class="balance-display">
@ -1586,7 +1597,11 @@
</div>
<div class="tx-detail-row">
<span class="tx-label">Tx:</span>
<span class="tx-value full-address tx-hash">${hash}</span>
<span class="tx-value full-address tx-hash">
<a href="https://tonviewer.com/transaction/${hash}" target="_blank" class="tx-hash-link" title="View on TON Viewer">
${hash}
</a>
</span>
</div>
</div>
</div>
@ -1641,7 +1656,11 @@
</div>
<div class="tx-detail-row">
<span class="tx-label">Tx:</span>
<span class="tx-value full-address tx-hash">${hash}</span>
<span class="tx-value full-address tx-hash">
<a href="https://tonviewer.com/transaction/${hash}" target="_blank" class="tx-hash-link" title="View on TON Viewer">
${hash}
</a>
</span>
</div>
</div>
</div>
@ -2248,7 +2267,7 @@
<div class="blockchain-section">
<div class="blockchain-header">
<h4><i class="fas fa-receipt"></i> Transaction Details</h4>
<span class="blockchain-badge primary">Hash Lookup</span>
<span class="blockchain-badge primary">Hash</span>
</div>
<div class="detail-row">
@ -2325,6 +2344,7 @@
return true;
}
// Check for TON/FLO/BTC private key format (WIF - Wallet Import Format)
const base58Regex =
/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
if (
@ -2332,18 +2352,18 @@
input.length >= 51 &&
input.length <= 56
) {
return true;
// Only accept private keys with specific prefixes that can be converted to TON
const validPrivateKeyPrefixes = ["R", "K", "L", "T"];
if (
validPrivateKeyPrefixes.some((prefix) => input.startsWith(prefix))
) {
return true;
}
return false; // Reject other Base58 strings (like BTC addresses)
}
if (input.length === 44 && /^[A-Za-z0-9+/]{43}=?$/.test(input)) {
return false;
}
if (input.length < 32 || input.length > 128) {
return false;
}
return true;
// Reject any other input format
return false;
}
// Enhanced transaction loading with multi-chain support
@ -2395,8 +2415,7 @@
<p>The input doesn't appear to be a valid TON address or private key.</p>
<p>Please enter:</p>
<ul style="margin: 0.5rem 0; padding-left: 1.5rem;">
<li>A TON address (starts with EQ, UQ, or kQ)</li>
<li>A hex private key (64 or 128 characters)</li>
<li>A TON address (starts with EQ, UQ)</li>
<li>A TON/FLO/BTC private key</li>
</ul>
</div>
@ -2440,11 +2459,13 @@
tonPrivateKey
);
finalAddress = address.toString(true, true, true);
finalAddress = await convertTob64(finalAddress);
} else {
// Try multi-chain conversion (TON/FLO/BTC)
const walletData = await tonCrypto.recoverFromInput(input);
if (walletData.TON && walletData.TON.address) {
finalAddress = walletData.TON.address;
finalAddress = await convertTob64(finalAddress);
} else {
throw new Error(
"Invalid input: not a valid TON address or private key"
@ -2884,6 +2905,34 @@
}
}
// Validation function for recover wallet (only private keys,)
function isValidRecoverPrivateKey(input) {
// Check if it's a hex private key (64 or 128 characters) - TON format
const hexOnly = /^[0-9a-fA-F]+$/.test(input);
if (hexOnly && (input.length === 64 || input.length === 128)) {
return true;
}
// Check for TON/FLO/BTC private key format (WIF - Wallet Import Format)
const base58Regex =
/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
if (
base58Regex.test(input) &&
input.length >= 51 &&
input.length <= 56
) {
// Only accept private keys with specific prefixes for TON/FLO/BTC
const validPrivateKeyPrefixes = ["R", "K", "L", "T"];
if (
validPrivateKeyPrefixes.some((prefix) => input.startsWith(prefix))
) {
return true;
}
}
return false;
}
// Recover wallet functionality
async function recoverWallet() {
const privateKeyInput = document
@ -2899,6 +2948,27 @@
return;
}
// Validate private key format
if (!isValidRecoverPrivateKey(privateKeyInput)) {
output.innerHTML = `
<div class="error-state">
<div class="error-icon">
<i class="fas fa-exclamation-triangle"></i>
</div>
<div class="error-message">
<h3>Invalid Private Key Format</h3>
<p>Please enter a valid private key (TON/FLO/BTC format).</p>
<p>Addresses and other formats are not supported.</p>
</div>
</div>
`;
showNotification(
"Invalid private key format - only TON/FLO/BTC private keys supported",
"error"
);
return;
}
// Show loading state
const originalHTML = button.innerHTML;
button.disabled = true;
@ -2907,14 +2977,10 @@
try {
let wallet;
if (typeof tonCrypto !== "undefined" && tonCrypto.recoverFromInput) {
if (typeof tonCrypto !== "undefined") {
wallet = await tonCrypto.recoverFromInput(privateKeyInput);
} else {
// Fallback to getSenderWallet with the provided key
wallet = await tonBlockchainAPI.getSenderWallet(privateKeyInput);
}
const tonData = wallet.TON || wallet;
// Pre-convert the TON address to avoid Promise display
const friendlyTonAddress = await convertTob64(tonData.address);
output.innerHTML = `
@ -2923,8 +2989,8 @@
<i class="fas fa-check"></i>
</div>
<div class="success-message">
<h3>Addresses Generated Successfully!</h3>
<p>Your multi-blockchain addresses have been created. All addresses are derived from the same private key.</p>
<h3>Addresses Recovered Successfully!</h3>
<p>Your multi-blockchain addresses have been recovered. All addresses are derived from the same private key.</p>
</div>
</div>
@ -3035,12 +3101,15 @@
</div>
<div class="error-message">
<h3>Recovery Failed</h3>
<p>Failed to recover : ${error.message}</p>
<p>Please check that you've entered a valid private key in the correct format.</p>
<p>Unable to recover address from the provided private key. Please ensure you've entered a valid TON/FLO/BTC private key.</p>
</div>
</div>
`;
showNotification("Failed to recover ", "error");
showNotification(
"Failed to recover address from private key",
"error"
);
} finally {
button.disabled = false;
button.innerHTML = originalHTML;
@ -3125,7 +3194,95 @@
}
});
}
handleSharedLinks();
});
// Shareable link functionality
function shareAddress() {
const currentAddress =
document.getElementById("displayedAddress").textContent;
if (!currentAddress) {
showNotification("No address to share", "error");
return;
}
const shareUrl = `${window.location.origin}${
window.location.pathname
}#transactions?address=${encodeURIComponent(currentAddress)}`;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard
.writeText(shareUrl)
.then(() => {
showNotification(
"Shareable link copied to clipboard!",
"success"
);
})
.catch(() => {
showShareFallback(shareUrl);
});
} else {
showShareFallback(shareUrl);
}
}
function showShareFallback(url) {
const textArea = document.createElement("textarea");
textArea.value = url;
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand("copy");
showNotification("Shareable link copied to clipboard!", "success");
} catch (err) {
showNotification("Please copy this link: " + url, "info");
}
document.body.removeChild(textArea);
}
function handleSharedLinks() {
if (window.location.hash) {
const hash = window.location.hash.substring(1);
if (hash.startsWith("transactions")) {
const params = new URLSearchParams(hash.split("?")[1] || "");
const address = params.get("address");
// Show the transactions page first
showPage("transactions");
if (address) {
// Pre-fill the address and load transactions
document.getElementById("transactionInput").value = address;
showNotification("Loading shared address data...", "info");
setTimeout(() => {
loadTransactions(address);
}, 100);
}
// Clear the hash from URL after processing
history.replaceState(null, null, window.location.pathname);
}
}
}
const originalLoadTransactions = loadTransactions;
window.loadTransactions = async function (inputValue = null) {
await originalLoadTransactions(inputValue);
// Show the share button when balance is displayed
const balanceSection = document.getElementById("transactionBalance");
const shareBtn = document.getElementById("shareAddressBtn");
if (
balanceSection &&
balanceSection.style.display !== "none" &&
shareBtn
) {
shareBtn.style.display = "inline-flex";
}
};
</script>
</body>
</html>

139
style.css
View File

@ -2379,3 +2379,142 @@ body {
padding: 0.75rem;
}
}
/* Transaction Hash Link Styling */
.tx-hash-link {
color: var(--primary-color);
text-decoration: none;
transition: all 0.2s ease;
display: inline-flex;
align-items: center;
gap: 0.25rem;
font-family: "Courier New", monospace;
word-break: break-all;
}
.tx-hash-link:hover {
color: var(--primary-color-dark);
text-decoration: underline;
transform: translateY(-1px);
}
.tx-hash-link:active {
transform: translateY(0);
}
.tx-hash-link:hover::after {
opacity: 1;
}
/* Share Button Styling */
.balance-actions {
display: flex;
align-items: center;
gap: 1rem;
}
.share-btn {
background: var(--bg-color);
border: 1px solid var(--border-color);
color: var(--text-secondary);
border-radius: var(--border-radius-sm);
padding: 0.5rem;
transition: all 0.2s ease;
cursor: pointer;
}
.share-btn:hover {
background: var(--primary-color);
color: white;
border-color: var(--primary-color);
transform: translateY(-1px);
}
@media (max-width: 768px) {
.balance-actions {
flex-direction: row;
align-items: center;
gap: 0.75rem;
justify-content: flex-end;
flex-wrap: nowrap;
}
.share-btn {
padding: 0.4rem 0.6rem;
font-size: 0.75rem;
border-radius: var(--border-radius-sm);
min-width: auto;
min-height: 32px;
display: flex;
align-items: center;
justify-content: center;
gap: 0.3rem;
background: var(--primary-color);
color: white;
border-color: var(--primary-color);
font-weight: 500;
}
.share-btn:hover {
background: var(--primary-color-dark);
}
.toggle-container {
flex-shrink: 1;
min-width: 0;
}
.toggle-btn {
padding: 0.35rem 0.55rem;
font-size: 0.75rem;
min-height: 32px;
white-space: nowrap;
}
.balance-header {
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
flex-wrap: nowrap;
}
.balance-header h3 {
margin-bottom: 0;
flex-shrink: 1;
font-size: 0.9rem;
min-width: 0;
}
.balance-actions {
flex-shrink: 0;
gap: 0.5rem;
max-width: 60%;
}
/* Improve overall balance section on mobile */
.balance-info {
padding: 0.75rem;
margin: 0.5rem;
}
.balance-display {
text-align: center;
margin: 1rem 0;
}
.address-display {
margin-top: 1rem;
padding: 0.75rem;
background: var(--bg-color);
border-radius: var(--border-radius-sm);
}
.address-value {
word-break: break-all;
font-size: 0.85rem;
line-height: 1.4;
}
}

View File

@ -290,6 +290,64 @@
});
};
tonBlockchainAPI.getUQAddress = function (address) {
return new Promise((resolve, reject) => {
try {
if (!address || typeof address !== "string") {
resolve(address);
return;
}
const isValidTonAddress = address.match(/^[EUk]Q[A-Za-z0-9_-]{46}$/);
if (!isValidTonAddress) {
resolve(address);
return;
}
if (address.startsWith("UQ")) {
resolve(address);
return;
}
fetch(
`https://toncenter.com/api/v2/detectAddress?address=${encodeURIComponent(
address
)}`,
{
headers: { "X-API-Key": API_KEY },
}
)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then((data) => {
if (data && data.result) {
const uqAddress =
data.result.non_bounceable?.b64url ||
data.result.non_bounceable?.b64 ||
address;
resolve(uqAddress);
} else {
resolve(address);
}
})
.catch((error) => {
console.warn("Failed to convert address using API:", error);
resolve(address);
});
} catch (error) {
console.error("Error in getUQAddress:", error);
resolve(address);
}
});
};
/**
* Create wallet from private key
* @param {string} privHex - Private key in hexadecimal format
@ -338,7 +396,11 @@
await tonBlockchainAPI.getSenderWallet(privHex);
const seqno = await wallet.methods.seqno().call();
const senderAddr = address.toString(true, true, true);
toAddress=await tonBlockchainAPI.getUQAddress(toAddress);
console.log(
`Sending ${amount} TON from ${senderAddr} to ${toAddress}, seqno: ${seqno}`
);
await wallet.methods
.transfer({
secretKey: keyPair.secretKey,