Skip to content

Commit

Permalink
feat: arkconnect navbar button (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley authored Mar 26, 2024
1 parent cd0ca11 commit b78097f
Show file tree
Hide file tree
Showing 35 changed files with 1,628 additions and 997 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ ARKSCAN_PRODUCTIVITY_WARNING=99.8
ARKSCAN_PAGINATION_PER_PAGE=25

MIX_NOTIFICATIONS_DISABLED=false

ARKCONNECT_ENABLED=false
2 changes: 1 addition & 1 deletion app/Console/Commands/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class ImportCommand extends LaravelScoutImportCommand
/**
* Execute the console command.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @param Dispatcher $events
* @return void
*/
public function handle(Dispatcher $events)
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class User extends Authenticatable
/**
* The accessors to append to the model's array form.
*
* @var array
* @var array<int, string>
*/
protected $appends = [
'profile_photo_url',
Expand Down
57 changes: 57 additions & 0 deletions app/ViewModels/Concerns/Wallet/CanForge.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace App\ViewModels\Concerns\Wallet;

use App\Actions\CacheNetworkHeight;
use App\Facades\Rounds;
use App\Services\Cache\DelegateCache;
use App\Services\Cache\WalletCache;
use Carbon\Carbon;
use Carbon\CarbonInterval;
use Illuminate\Support\Arr;

trait CanForge
Expand Down Expand Up @@ -117,8 +120,62 @@ public function missedBlocks(): int
return (new WalletCache())->getMissedBlocks($publicKey);
}

public function blocksSinceLastForged(): ?int
{
$lastBlock = $this->lastBlock();
if ($lastBlock === null) {
return null;
}

$height = CacheNetworkHeight::execute();

return $height - $lastBlock['height'];
}

public function durationSinceLastForged(): ?string
{
$lastBlock = $this->lastBlock();
if ($lastBlock === null) {
return null;
}

$difference = CarbonInterval::instance(Carbon::parse($lastBlock['timestamp'])->diff());
$difference->ceilMinutes();
if ($difference->totalHours < 1) {
return trans('general.time.minutes_short', ['minutes' => $difference->minutes]);
}

if ($difference->totalHours >= 1 && $difference->totalDays < 1) {
if ($difference->minutes === 0) {
return trans('general.time.hours_short', ['hours' => $difference->hours]);
}

return trans('general.time.hours_minutes_short', [
'hours' => $difference->hours,
'minutes' => $difference->minutes,
]);
}

return trans('general.time.more_than_a_day');
}

public function currentSlot(): array
{
return Rounds::delegates()->firstWhere('publicKey', $this->publicKey());
}

private function lastBlock(): ?array
{
$publicKey = $this->publicKey();
if (is_null($publicKey)) {
return null;
}

$lastBlock = (new WalletCache())->getLastBlock($publicKey);
if ($lastBlock === []) {
return null;
}

return $lastBlock;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ext-gmp": "*",
"ardenthq/arkvault-url": "^1.1",
"arkecosystem/crypto": "^1.8",
"arkecosystem/foundation": "^13.32",
"arkecosystem/foundation": "^13.35",
"blade-ui-kit/blade-icons": "^1.5",
"brick/math": "^0.11",
"danharrin/livewire-rate-limiting": "1.1.0",
Expand Down
Loading

0 comments on commit b78097f

Please sign in to comment.