SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "explorer-transactions.js")
31 STORE("descrHdr", "Transaction explorer page loader")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "23c1b275d1822dfeb46a889bd732fbdb5b36e3fe38e504e548c8f193046bc17f")
37 STORE("fileCheckS", "22fe8533d8a2f00ee2547fdfa6a5e9d5f0b603053e835bedb267e491c5411007")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
// TELA Explorer - Transaction Functions Module (< 18KB)
async function loadTransactions() {
currentRoute = 'transactions';
const c = document.getElementById('main-content');
c.innerHTML = '<div class="loading-progress">Loading transaction explorer...<div class="progress-bar"></div></div>';
if (!xswdCore?.isConnected) {
c.innerHTML = '<div class="enhanced-card"><h3>TELA connection required</h3></div>';
return;
}
try {
// Get comprehensive transaction data
const [poolData, networkInfo, recentBlocks] = await Promise.all([
getPoolData(),
xswdCore.call('DERO.GetInfo'),
getRecentBlocks(5) // Get last 5 blocks for recent transactions
]);
// Load render module and render
const renderModule = await lm('explorer-render');
if (!renderModule) throw new Error('Failed to load render module');
c.innerHTML = renderModule.renderTransactionExplorer(poolData, networkInfo, recentBlocks);
} catch (error) {
console.error('Transaction explorer loading failed:', error);
c.innerHTML = `<div class="enhanced-card">
<h3>Transaction Explorer Loading Failed</h3>
<p style="color:#888;margin-top:1rem">${error.message}</p>
<button onclick="loadTransactions()" style="margin-top:1rem;padding:0.5rem 1rem;background:#52c8db;color:#000;border:none;border-radius:4px;cursor:pointer;">Retry</button>
</div>`;
}
}
async function loadTransaction(txid) {
currentRoute = 'tx';
const c = document.getElementById('main-content');
c.innerHTML = '<div class="loading-progress">Loading transaction details...<div class="progress-bar"></div></div>';
if (!xswdCore?.isConnected) {
c.innerHTML = '<div class="enhanced-card"><h3>TELA connection required</h3></div>';
return;
}
try {
const core = await lm('transactions-core');
if (!core) throw new Error('Failed to load transactions-core module');
const result = await core.renderEnhancedTransaction(txid, xswdCore.call.bind(xswdCore));
c.innerHTML = result;
} catch (error) {
console.error('Transaction details failed:', error);
c.innerHTML = `<div class="enhanced-card"><h3>Error Loading Transaction</h3><p>${error.message}</p></div>`;
}
}
async function getPoolData() {
try {
const enhancedPool = await window.xswd?.getTxPoolWithStats?.();
return enhancedPool;
} catch(e) {
const rawPool = await xswdCore.call('DERO.GetTxPool');
if (rawPool?.txs) {
const processedPool = {
txs: rawPool.txs,
stats: {
total_count: rawPool.txs.length,
total_size: rawPool.txs.reduce((acc,tx) => acc + (tx.size||0), 0),
avg_fee: rawPool.txs.length > 0 ? rawPool.txs.reduce((acc,tx) => acc + (tx.fee||0), 0) / rawPool.txs.length : 0
}
};
return processedPool;
}
return null;
}
}
async function getRecentBlocks(count = 5) {
try {
const info = await xswdCore.call('DERO.GetInfo');
const currentHeight = info.height;
const blocks = [];
for (let i = 0; i < count; i++) {
const height = currentHeight - i;
if (height > 0) {
try {
const block = await xswdCore.call('DERO.GetBlock', { height: height });
if (block) {
// Parse the JSON field to get the actual block structure
let parsedBlock = block;
if (block.json) {
try {
const blockData = JSON.parse(block.json);
parsedBlock = { ...block, ...blockData, height: height };
} catch (e) {
console.warn(`Failed to parse JSON for block ${height}:`, e);
parsedBlock = { ...block, height: height };
}
}
blocks.push(parsedBlock);
}
} catch (e) {
console.warn(`Failed to get block ${height}:`, e);
}
}
}
return blocks;
} catch (error) {
console.error('Failed to get recent blocks:', error);
return [];
}
}
// Export for module loading
window.explorerTransactions = {
loadTransactions,
loadTransaction,
getPoolData,
getRecentBlocks
};
*/ |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "explorer-transactions.js")
31 STORE("descrHdr", "Transaction explorer page loader")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "23c1b275d1822dfeb46a889bd732fbdb5b36e3fe38e504e548c8f193046bc17f")
37 STORE("fileCheckS", "22fe8533d8a2f00ee2547fdfa6a5e9d5f0b603053e835bedb267e491c5411007")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
// TELA Explorer - Transaction Functions Module (< 18KB)
async function loadTransactions() {
currentRoute = 'transactions';
const c = document.getElementById('main-content');
c.innerHTML = '<div class="loading-progress">Loading transaction explorer...<div class="progress-bar"></div></div>';
if (!xswdCore?.isConnected) {
c.innerHTML = '<div class="enhanced-card"><h3>TELA connection required</h3></div>';
return;
}
try {
// Get comprehensive transaction data
const [poolData, networkInfo, recentBlocks] = await Promise.all([
getPoolData(),
xswdCore.call('DERO.GetInfo'),
getRecentBlocks(5) // Get last 5 blocks for recent transactions
]);
// Load render module and render
const renderModule = await lm('explorer-render');
if (!renderModule) throw new Error('Failed to load render module');
c.innerHTML = renderModule.renderTransactionExplorer(poolData, networkInfo, recentBlocks);
} catch (error) {
console.error('Transaction explorer loading failed:', error);
c.innerHTML = `<div class="enhanced-card">
<h3>Transaction Explorer Loading Failed</h3>
<p style="color:#888;margin-top:1rem">${error.message}</p>
<button onclick="loadTransactions()" style="margin-top:1rem;padding:0.5rem 1rem;background:#52c8db;color:#000;border:none;border-radius:4px;cursor:pointer;">Retry</button>
</div>`;
}
}
async function loadTransaction(txid) {
currentRoute = 'tx';
const c = document.getElementById('main-content');
c.innerHTML = '<div class="loading-progress">Loading transaction details...<div class="progress-bar"></div></div>';
if (!xswdCore?.isConnected) {
c.innerHTML = '<div class="enhanced-card"><h3>TELA connection required</h3></div>';
return;
}
try {
const core = await lm('transactions-core');
if (!core) throw new Error('Failed to load transactions-core module');
const result = await core.renderEnhancedTransaction(txid, xswdCore.call.bind(xswdCore));
c.innerHTML = result;
} catch (error) {
console.error('Transaction details failed:', error);
c.innerHTML = `<div class="enhanced-card"><h3>Error Loading Transaction</h3><p>${error.message}</p></div>`;
}
}
async function getPoolData() {
try {
const enhancedPool = await window.xswd?.getTxPoolWithStats?.();
return enhancedPool;
} catch(e) {
const rawPool = await xswdCore.call('DERO.GetTxPool');
if (rawPool?.txs) {
const processedPool = {
txs: rawPool.txs,
stats: {
total_count: rawPool.txs.length,
total_size: rawPool.txs.reduce((acc,tx) => acc + (tx.size||0), 0),
avg_fee: rawPool.txs.length > 0 ? rawPool.txs.reduce((acc,tx) => acc + (tx.fee||0), 0) / rawPool.txs.length : 0
}
};
return processedPool;
}
return null;
}
}
async function getRecentBlocks(count = 5) {
try {
const info = await xswdCore.call('DERO.GetInfo');
const currentHeight = info.height;
const blocks = [];
for (let i = 0; i < count; i++) {
const height = currentHeight - i;
if (height > 0) {
try {
const block = await xswdCore.call('DERO.GetBlock', { height: height });
if (block) {
// Parse the JSON field to get the actual block structure
let parsedBlock = block;
if (block.json) {
try {
const blockData = JSON.parse(block.json);
parsedBlock = { ...block, ...blockData, height: height };
} catch (e) {
console.warn(`Failed to parse JSON for block ${height}:`, e);
parsedBlock = { ...block, height: height };
}
}
blocks.push(parsedBlock);
}
} catch (e) {
console.warn(`Failed to get block ${height}:`, e);
}
}
}
return blocks;
} catch (error) {
console.error('Failed to get recent blocks:', error);
return [];
}
}
// Export for module loading
window.explorerTransactions = {
loadTransactions,
loadTransaction,
getPoolData,
getRecentBlocks
};
*/'] |