From e358e54db3b218f891c433c612cb5fb1b5094eb3 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:56:33 +0000 Subject: [PATCH 1/3] refactor: output transaction more detail values --- app/Models/Transaction.php | 4 ++++ app/ViewModels/TransactionViewModel.php | 15 +++++++++++++++ .../transaction/page/more-details.blade.php | 18 ++++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index eed3ee17e..67338eced 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -22,10 +22,12 @@ * @property string $id * @property array|null $asset * @property BigNumber $amount + * @property BigNumber $gas_limit * @property BigNumber $gas_price * @property int $timestamp * @property int $type * @property int $type_group + * @property int $sequence * @property string $block_id * @property string|null $recipient_address * @property string $sender_public_key @@ -73,9 +75,11 @@ final class Transaction extends Model 'amount' => BigInteger::class, 'asset' => 'array', 'gas_price' => BigInteger::class, + 'gas_limit' => BigInteger::class, 'timestamp' => UnixSeconds::class, 'type_group' => 'int', 'type' => 'int', + 'sequence' => 'int', 'block_height' => 'int', ]; diff --git a/app/ViewModels/TransactionViewModel.php b/app/ViewModels/TransactionViewModel.php index e008da3d6..043c35473 100644 --- a/app/ViewModels/TransactionViewModel.php +++ b/app/ViewModels/TransactionViewModel.php @@ -84,6 +84,21 @@ public function nonce(): int return $this->transaction->nonce; } + public function gasLimit(): float + { + return UnitConverter::formatUnits((string) $this->transaction->gas_limit, 'wei'); + } + + public function gasUsed(): float + { + return UnitConverter::formatUnits((string) $this->transaction->receipt->gas_used, 'wei'); + } + + public function sequence(): int + { + return $this->transaction->sequence; + } + public function fee(): float { return UnitConverter::formatUnits((string) $this->transaction->fee(), 'gwei'); diff --git a/resources/views/components/transaction/page/more-details.blade.php b/resources/views/components/transaction/page/more-details.blade.php index 2c691d14d..eed463272 100644 --- a/resources/views/components/transaction/page/more-details.blade.php +++ b/resources/views/components/transaction/page/more-details.blade.php @@ -13,14 +13,14 @@ class="mt-6 sm:hidden" - 64,004 + {{ ExplorerNumberFormatter::number($transaction->gasLimit()) }} - 63,185 + {{ ExplorerNumberFormatter::number($transaction->gasUsed()) }} @@ -30,7 +30,7 @@ class="pt-3" - 137 + {{ $transaction->sequence() }} @@ -90,16 +90,17 @@ class="mt-4 !px-0" - 63,185 - + allow-empty + /> From 5055de29f774ca31c2c1fe556bbb41a7cc581827 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:57:29 +0000 Subject: [PATCH 2/3] remove unused transaction model properties --- app/Models/Transaction.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 67338eced..204e0cc0a 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -20,13 +20,10 @@ /** * @property string $id - * @property array|null $asset * @property BigNumber $amount * @property BigNumber $gas_limit * @property BigNumber $gas_price * @property int $timestamp - * @property int $type - * @property int $type_group * @property int $sequence * @property string $block_id * @property string|null $recipient_address @@ -73,12 +70,9 @@ final class Transaction extends Model */ protected $casts = [ 'amount' => BigInteger::class, - 'asset' => 'array', 'gas_price' => BigInteger::class, 'gas_limit' => BigInteger::class, 'timestamp' => UnixSeconds::class, - 'type_group' => 'int', - 'type' => 'int', 'sequence' => 'int', 'block_height' => 'int', ]; From eb880763c1cf589204a4c39a705e4d5dfe140d97 Mon Sep 17 00:00:00 2001 From: ItsANameToo Date: Fri, 15 Nov 2024 16:27:19 +0100 Subject: [PATCH 3/3] wip --- app/ViewModels/TransactionViewModel.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/ViewModels/TransactionViewModel.php b/app/ViewModels/TransactionViewModel.php index 043c35473..48176e0da 100644 --- a/app/ViewModels/TransactionViewModel.php +++ b/app/ViewModels/TransactionViewModel.php @@ -91,7 +91,13 @@ public function gasLimit(): float public function gasUsed(): float { - return UnitConverter::formatUnits((string) $this->transaction->receipt->gas_used, 'wei'); + $receipt = $this->transaction->receipt; + + if ($receipt === null) { + return 0; + } + + return UnitConverter::formatUnits((string) $receipt->gas_used, 'wei'); } public function sequence(): int