-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: recipient contract badge (#1012)
- Loading branch information
1 parent
b74b0da
commit ddf5de7
Showing
10 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Receipt; | ||
use App\Services\Cache\WalletCache; | ||
use Illuminate\Console\Command; | ||
|
||
class CacheContractAddresses extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'explorer:cache-contract-addresses'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string|null | ||
*/ | ||
protected $description = 'Cache contract addresses'; | ||
|
||
public function handle(): void | ||
{ | ||
$addresses = Receipt::where('deployed_contract_address', '!=', null) | ||
->distinct() | ||
->pluck('deployed_contract_address') | ||
->toArray(); | ||
|
||
(new WalletCache())->setContractAddresses($addresses); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 33 additions & 7 deletions
40
resources/views/components/transaction/page/section-detail/address.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,51 @@ | ||
@props([ | ||
'address', | ||
'isContract' => false, | ||
]) | ||
|
||
<span class="inline-flex items-center"> | ||
<div class="flex items-center"> | ||
<a | ||
href="{{ route('wallet', $address) }}" | ||
class="link" | ||
class="min-w-0 link" | ||
> | ||
<div class="hidden md:inline"> | ||
{{ $address }} | ||
<x-truncate-dynamic>{{ $address }}</x-truncate-dynamic> | ||
</div> | ||
|
||
<div class="md:hidden"> | ||
<x-truncate-middle> | ||
{{ $address }} | ||
</x-truncate-middle> | ||
@unless ($isContract) | ||
<x-truncate-middle> | ||
{{ $address }} | ||
</x-truncate-middle> | ||
@else | ||
@lang('general.contract') | ||
@endif | ||
</div> | ||
</a> | ||
|
||
@if ($isContract) | ||
<div class="ml-3 w-5 h-5 md:hidden ark-info-element"> | ||
<x-ark-info | ||
:tooltip="$address" | ||
type="info" | ||
/> | ||
</div> | ||
@endif | ||
|
||
<x-clipboard | ||
:value="$address" | ||
:tooltip="trans('pages.wallet.address_copied')" | ||
/> | ||
</span> | ||
|
||
@if ($isContract) | ||
<div class="hidden items-center md:flex"> | ||
<div class="mx-2 border-l border-theme-secondary-300 h-[17px] dark:border-theme-dark-700"></div> | ||
|
||
<div class="flex items-center px-1 space-x-1.5 text-xs rounded h-[21px] bg-theme-secondary-200 leading-3.75 text-theme-secondary-700 dark:bg-theme-dark-950 dark:text-theme-dark-200"> | ||
<x-ark-icon name="transaction.contract" size="xs" /> | ||
|
||
<span>@lang('general.contract')</span> | ||
</div> | ||
</div> | ||
@endif | ||
</div> |
31 changes: 31 additions & 0 deletions
31
tests/Unit/Console/Commands/CacheContractAddressesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Console\Commands\CacheContractAddresses; | ||
use App\Models\Receipt; | ||
use App\Services\Cache\WalletCache; | ||
|
||
it('should execute the command', function () { | ||
(new CacheContractAddresses())->handle(); | ||
|
||
$cache = new WalletCache(); | ||
|
||
expect($cache->getContractAddresses())->toEqual([]); | ||
}); | ||
|
||
it('should cache contract addresses', function () { | ||
$cache = new WalletCache(); | ||
|
||
expect($cache->getContractAddresses())->toEqual([]); | ||
|
||
(new CacheContractAddresses())->handle(); | ||
|
||
Receipt::factory()->create([ | ||
'deployed_contract_address' => '0x522B3294E6d06aA25Ad0f1B8891242E335D3B459', | ||
]); | ||
|
||
(new CacheContractAddresses())->handle(); | ||
|
||
expect($cache->getContractAddresses())->toEqual(['0x522B3294E6d06aA25Ad0f1B8891242E335D3B459']); | ||
}); |