diff --git a/app/Console/Commands/CacheContractAddresses.php b/app/Console/Commands/CacheContractAddresses.php new file mode 100644 index 000000000..5abd8eb71 --- /dev/null +++ b/app/Console/Commands/CacheContractAddresses.php @@ -0,0 +1,36 @@ +distinct() + ->pluck('deployed_contract_address') + ->toArray(); + + (new WalletCache())->setContractAddresses($addresses); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7ce13454d..2d8e843a4 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -7,6 +7,7 @@ use App\Console\Commands\BuildForgingStats; use App\Console\Commands\CacheAddressStatistics; use App\Console\Commands\CacheAnnualStatistics; +use App\Console\Commands\CacheContractAddresses; use App\Console\Commands\CacheCurrenciesData; use App\Console\Commands\CacheFees; use App\Console\Commands\CacheGasTrackerData; @@ -78,6 +79,8 @@ protected function schedule(Schedule $schedule) $schedule->command(BuildForgingStats::class)->everyMinute(); + $schedule->command(CacheContractAddresses::class)->everyMinute(); + // TODO: enable when the monitor is fixed // $schedule->command(CacheValidatorPerformance::class)->everyMinute(); diff --git a/app/DTO/MemoryWallet.php b/app/DTO/MemoryWallet.php index eb3a2fa5a..b14e72fee 100644 --- a/app/DTO/MemoryWallet.php +++ b/app/DTO/MemoryWallet.php @@ -28,6 +28,15 @@ public function address(): ?string return $this->address; } + public function isContract(): bool + { + if (in_array($this->address(), config('contracts.addresses'), true)) { + return true; + } + + return in_array($this->address(), (new WalletCache())->getContractAddresses(), true); + } + public function publicKey(): ?string { return $this->publicKey; diff --git a/app/Services/Cache/WalletCache.php b/app/Services/Cache/WalletCache.php index ed254e18c..0720a1367 100644 --- a/app/Services/Cache/WalletCache.php +++ b/app/Services/Cache/WalletCache.php @@ -115,6 +115,16 @@ public function setMissedBlocks(string $address, int $value): void $this->put(sprintf('missed_blocks/%s', $address), $value); } + public function getContractAddresses(): array + { + return $this->get('contract_addresses', []); + } + + public function setContractAddresses(array $addresses): void + { + $this->put('contract_addresses', $addresses); + } + public function getCache(): TaggedCache { return Cache::tags('wallet'); diff --git a/composer.lock b/composer.lock index 471657817..0757b481a 100644 --- a/composer.lock +++ b/composer.lock @@ -117,16 +117,16 @@ }, { "name": "arkecosystem/foundation", - "version": "19.0.0", + "version": "19.1.0", "source": { "type": "git", "url": "https://github.com/ArkEcosystem/laravel-foundation.git", - "reference": "89daa75e6a2d48766f8a725747c59de76f6d9a6a" + "reference": "797ca72fa24e67a1fff3c23ebcf7f6c2400f11af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ArkEcosystem/laravel-foundation/zipball/89daa75e6a2d48766f8a725747c59de76f6d9a6a", - "reference": "89daa75e6a2d48766f8a725747c59de76f6d9a6a", + "url": "https://api.github.com/repos/ArkEcosystem/laravel-foundation/zipball/797ca72fa24e67a1fff3c23ebcf7f6c2400f11af", + "reference": "797ca72fa24e67a1fff3c23ebcf7f6c2400f11af", "shasum": "" }, "require": { @@ -202,9 +202,9 @@ "description": "User-Interface Scaffolding for Laravel. Powered by Tailwind CSS.", "support": { "issues": "https://github.com/ArkEcosystem/laravel-foundation/issues", - "source": "https://github.com/ArkEcosystem/laravel-foundation/tree/19.0.0" + "source": "https://github.com/ArkEcosystem/laravel-foundation/tree/19.1.0" }, - "time": "2024-10-23T08:37:26+00:00" + "time": "2024-11-20T09:47:02+00:00" }, { "name": "bacon/bacon-qr-code", diff --git a/resources/css/_general.css b/resources/css/_general.css index b66a38638..d87709269 100644 --- a/resources/css/_general.css +++ b/resources/css/_general.css @@ -420,3 +420,8 @@ input.qr-code-amount[type="number"] { .code-block-custom-scroll::-webkit-scrollbar-thumb { @apply rounded-lg bg-theme-primary-200; } + +/** Tooltips */ +.tippy-box { + @apply break-words; +} diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 4f9d5fddd..a0cb5168f 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -45,6 +45,7 @@ 'filter' => 'Filter', 'now' => 'Now', 'vote_with' => 'Vote With', + 'contract' => 'Contract', 'arkconnect' => [ 'mainnet_network' => 'You\'re viewing data from the main network, but your wallet is connected to test network (ARK Testnet). To use ARK Scan, please switch to test.arkscan.io.', diff --git a/resources/views/components/transaction/page/addressing.blade.php b/resources/views/components/transaction/page/addressing.blade.php index 3a3586a53..f2894318c 100644 --- a/resources/views/components/transaction/page/addressing.blade.php +++ b/resources/views/components/transaction/page/addressing.blade.php @@ -1,6 +1,9 @@ @props(['transaction']) - + diff --git a/resources/views/components/transaction/page/section-detail/address.blade.php b/resources/views/components/transaction/page/section-detail/address.blade.php index 1cd78a341..168275731 100644 --- a/resources/views/components/transaction/page/section-detail/address.blade.php +++ b/resources/views/components/transaction/page/section-detail/address.blade.php @@ -1,25 +1,51 @@ @props([ 'address', + 'isContract' => false, ]) - +
- - {{ $address }} - + @unless ($isContract) + + {{ $address }} + + @else + @lang('general.contract') + @endif
+ @if ($isContract) +
+ +
+ @endif + - + + @if ($isContract) + + @endif +
diff --git a/tests/Unit/Console/Commands/CacheContractAddressesTest.php b/tests/Unit/Console/Commands/CacheContractAddressesTest.php new file mode 100644 index 000000000..e8f21bc4d --- /dev/null +++ b/tests/Unit/Console/Commands/CacheContractAddressesTest.php @@ -0,0 +1,31 @@ +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']); +});