SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "blocks-core.js")
31 STORE("descrHdr", "Core block functionality")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "643330613703eb054a46661d615128685d4efa6f6a08e808639136307ca42b3")
37 STORE("fileCheckS", "155a49f94cbbbeb7d62c8afe1b62b2d31433bd804f5508a1d4dacd324523383b")
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
/*
({
name: 'blocks',
version: '1.0.0',
// Module references
blocksList: null,
blocksDetails: null,
async initModules() {
if (!this.blocksList) {
this.blocksList = await window.lm('blocks-list');
}
if (!this.blocksDetails) {
this.blocksDetails = await window.lm('blocks-details');
}
},
async renderBlocksExplorer(x) {
// Check connection before attempting to load
if (!x || !window.xswd || !window.xswd.isConnected) {
if (window.updateAllStatusIndicators) {
window.updateAllStatusIndicators('disconnected');
}
return '<div class="enhanced-card"><div class="card-header"><h2 style="color: #ef4444; font-size: 1.6rem; font-weight: 700; margin: 0;">🚫 Connection Required</h2></div><div class="card-content"><div style="background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: 8px; padding: 2rem; text-align: center; border-left: 4px solid #ef4444;"><div style="color: #ef4444; font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem;">XSWD Connection Required</div><div style="color: #b3b3b3; font-size: 0.9rem; margin-bottom: 1.5rem;">Unable to load blocks without connection to DERO daemon</div><button onclick="window.reconnectXSWD?.()" style="background: rgba(239,68,68,0.1); border: 1px solid #ef4444; color: #ef4444; padding: 0.75rem 1.5rem; border-radius: 6px; cursor: pointer; font-weight: 500;">🔄 Reconnect</button></div></div></div>';
}
await this.initModules();
if (this.blocksList) {
return this.blocksList.renderBlocksExplorer(x);
}
return '<div class="card"><div class="error-card"><h3>Error</h3><p>Failed to load blocks list module</p></div></div>';
},
async renderBlock(blockHeight, x) {
await this.initModules();
if (this.blocksDetails) {
return this.blocksDetails.renderBlock(blockHeight, x);
}
return '<div class="card"><div class="error-card"><h3>Error</h3><p>Failed to load block details module</p></div></div>';
},
async renderRecentBlocksList(x, h, c = 15) {
await this.initModules();
if (this.blocksDetails) {
return this.blocksDetails.renderRecentBlocksList(x, h, c);
}
return '<tr><td colspan="6" style="text-align:center;padding:2rem;color:var(--text-secondary)">Failed to load blocks module</td></tr>';
},
async loadBlocksPage(page, xswdCall) {
await this.initModules();
if (this.blocksList) {
return this.blocksList.loadBlocksPage(page, xswdCall);
}
},
// Global function exports for backwards compatibility
async loadMoreBlocks(xswdCall) {
await this.initModules();
if (this.blocksList && this.blocksList.loadMoreBlocks) {
return this.blocksList.loadMoreBlocks(xswdCall);
}
},
formatAge(seconds) {
if (isNaN(seconds) || seconds < 0 || seconds > 31536000) return '0s';
if (seconds < 60) return Math.floor(seconds) + 's';
if (seconds < 3600) return Math.floor(seconds / 60) + 'm';
if (seconds < 86400) return Math.floor(seconds / 3600) + 'h';
return Math.floor(seconds / 86400) + 'd';
}
})
*/ |
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", "blocks-core.js")
31 STORE("descrHdr", "Core block functionality")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "explorer.tela")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "643330613703eb054a46661d615128685d4efa6f6a08e808639136307ca42b3")
37 STORE("fileCheckS", "155a49f94cbbbeb7d62c8afe1b62b2d31433bd804f5508a1d4dacd324523383b")
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
/*
({
name: 'blocks',
version: '1.0.0',
// Module references
blocksList: null,
blocksDetails: null,
async initModules() {
if (!this.blocksList) {
this.blocksList = await window.lm('blocks-list');
}
if (!this.blocksDetails) {
this.blocksDetails = await window.lm('blocks-details');
}
},
async renderBlocksExplorer(x) {
// Check connection before attempting to load
if (!x || !window.xswd || !window.xswd.isConnected) {
if (window.updateAllStatusIndicators) {
window.updateAllStatusIndicators('disconnected');
}
return '<div class="enhanced-card"><div class="card-header"><h2 style="color: #ef4444; font-size: 1.6rem; font-weight: 700; margin: 0;">🚫 Connection Required</h2></div><div class="card-content"><div style="background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: 8px; padding: 2rem; text-align: center; border-left: 4px solid #ef4444;"><div style="color: #ef4444; font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem;">XSWD Connection Required</div><div style="color: #b3b3b3; font-size: 0.9rem; margin-bottom: 1.5rem;">Unable to load blocks without connection to DERO daemon</div><button onclick="window.reconnectXSWD?.()" style="background: rgba(239,68,68,0.1); border: 1px solid #ef4444; color: #ef4444; padding: 0.75rem 1.5rem; border-radius: 6px; cursor: pointer; font-weight: 500;">🔄 Reconnect</button></div></div></div>';
}
await this.initModules();
if (this.blocksList) {
return this.blocksList.renderBlocksExplorer(x);
}
return '<div class="card"><div class="error-card"><h3>Error</h3><p>Failed to load blocks list module</p></div></div>';
},
async renderBlock(blockHeight, x) {
await this.initModules();
if (this.blocksDetails) {
return this.blocksDetails.renderBlock(blockHeight, x);
}
return '<div class="card"><div class="error-card"><h3>Error</h3><p>Failed to load block details module</p></div></div>';
},
async renderRecentBlocksList(x, h, c = 15) {
await this.initModules();
if (this.blocksDetails) {
return this.blocksDetails.renderRecentBlocksList(x, h, c);
}
return '<tr><td colspan="6" style="text-align:center;padding:2rem;color:var(--text-secondary)">Failed to load blocks module</td></tr>';
},
async loadBlocksPage(page, xswdCall) {
await this.initModules();
if (this.blocksList) {
return this.blocksList.loadBlocksPage(page, xswdCall);
}
},
// Global function exports for backwards compatibility
async loadMoreBlocks(xswdCall) {
await this.initModules();
if (this.blocksList && this.blocksList.loadMoreBlocks) {
return this.blocksList.loadMoreBlocks(xswdCall);
}
},
formatAge(seconds) {
if (isNaN(seconds) || seconds < 0 || seconds > 31536000) return '0s';
if (seconds < 60) return Math.floor(seconds) + 's';
if (seconds < 3600) return Math.floor(seconds / 60) + 'm';
if (seconds < 86400) return Math.floor(seconds / 3600) + 'h';
return Math.floor(seconds / 86400) + 'd';
}
})
*/'] |