• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marscoin / martianrepublic / 23804883405

31 Mar 2026 03:14PM UTC coverage: 11.195% (+1.8%) from 9.347%
23804883405

push

github

Martian Congress
refactor: Tier 1 — security fixes, route standardization, code style, docs

S9:  File upload path traversal — assert realpath() within allowed dirs,
     sanitize citizen address in file paths
S11: Citizen registry queries capped with LIMIT 100
S12: External HTTP calls — replaced file_get_contents with Http::timeout()
     in CongressController, Wallet/ApiController, AppHelper
A8:  All routes converted to Laravel 9+ array notation
     [Controller::class, 'method']
D2:  Created DEVELOPMENT.md — complete setup guide for contributors
D4:  Laravel Pint code style enforced across 211 files

Tests updated: public route assertions corrected after route syntax
standardization exposed that old string-notation routes never resolved
properly in tests.

127 tests, 251 assertions, 0 PHPStan errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

302 of 3262 new or added lines in 58 files covered. (9.26%)

139 existing lines in 24 files now uncovered.

620 of 5538 relevant lines covered (11.2%)

1.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Livewire/BlockDisplay.php
1
<?php
2

3
namespace App\Livewire;
4

5
use Carbon\Carbon;
6
use Illuminate\Support\Facades\Http;
7
use Illuminate\Support\Facades\Process;
8
use Livewire\Component;
9

10
class BlockDisplay extends Component
11
{
12
    public $blockNumber = 'Loading...';
13

14
    public $timeSinceLastBlock = 'n/a';
15

16
    public $lastBlockMinedAt;
17

18
    public function mount()
×
19
    {
20
        $this->fetchBlockNumber();
×
21
    }
22

23
    public function fetchBlockNumber()
×
24
    {
25
        $cli = config('blockchain.rpc.cli_path');
×
26
        $dataDir = config('blockchain.rpc.data_dir');
×
27

28
        try {
NEW
29
            $result = Process::timeout(10)->run([$cli, '-datadir='.$dataDir, 'getblockcount']);
×
30
            if ($result->successful() && is_numeric(trim($result->output()))) {
×
31
                $height = (int) trim($result->output());
×
32

NEW
33
                $result = Process::timeout(10)->run([$cli, '-datadir='.$dataDir, 'getblockhash', (string) $height]);
×
34
                $hash = trim($result->output());
×
35
                if ($result->successful() && $hash) {
×
NEW
36
                    $result = Process::timeout(10)->run([$cli, '-datadir='.$dataDir, 'getblock', $hash]);
×
37
                    $block = json_decode($result->output(), true);
×
38
                    if ($block && isset($block['time'])) {
×
39
                        $this->blockNumber = $height;
×
40
                        $this->lastBlockMinedAt = Carbon::createFromTimestamp($block['time']);
×
41
                        $this->updateTimeSinceLastBlock();
×
42
                        $this->dispatch('block-update');
×
43

UNCOV
44
                        return;
×
45
                    }
46
                }
47
            }
48
        } catch (\Exception $e) {
×
49
            // Fall through to explorer
50
        }
51

52
        // Fallback: explorer API
53
        try {
NEW
54
            $response = Http::timeout(10)->get(config('blockchain.explorer.fallback_url').'/api/status?q=getInfo');
×
55
            if ($response->successful()) {
×
56
                $this->blockNumber = $response->json()['info']['blocks'] ?? '---';
×
57
                $this->dispatch('block-update');
×
58
            }
59
        } catch (\Exception $e) {
×
60
            $this->blockNumber = '---';
×
61
        }
62
    }
63

64
    public function updateTimeSinceLastBlock()
×
65
    {
66
        if ($this->lastBlockMinedAt instanceof Carbon) {
×
67
            $this->timeSinceLastBlock = $this->lastBlockMinedAt->diffForHumans(null, true);
×
68
        }
69
    }
70

71
    public function render()
×
72
    {
73
        return view('livewire.block-display');
×
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc