Skip to content

Commit

Permalink
add gas_price to model to replace fee
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley committed Nov 6, 2024
1 parent 34119cb commit 8b650ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @property string $id
* @property array|null $asset
* @property BigNumber $amount
* @property BigNumber $gas_price
* @property int $timestamp
* @property int $type
* @property int $type_group
Expand Down Expand Up @@ -98,7 +99,7 @@ final class Transaction extends Model
protected $casts = [
'amount' => BigInteger::class,
'asset' => 'array',
'fee' => BigInteger::class,
'gas_price' => BigInteger::class,
'timestamp' => UnixSeconds::class,
'type_group' => 'int',
'type' => 'int',
Expand Down Expand Up @@ -128,6 +129,7 @@ public function toSearchableArray(): array
// To get the amount for single payments
// Using `__toString` since are instances of `BigNumber`
'amount' => $this->amount->__toString(),
'fee' => $this->gas_price->__toString(),
// used to build the payments and sortable
'timestamp' => $this->timestamp,
];
Expand All @@ -146,6 +148,7 @@ public static function getSearchableQuery(): Builder
'sender_public_key',
'recipient_address',
'amount',
'gas_price',
'timestamp',
])
->when(true, function ($query) use ($self) {
Expand Down
4 changes: 2 additions & 2 deletions app/ViewModels/TransactionViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public function nonce(): int

public function fee(): float
{
return $this->transaction->fee->toFloat();
return $this->transaction->gas_price->toFloat();
}

public function feeFiat(bool $showSmallAmounts = false): string
{
return ExchangeRate::convert($this->transaction->fee->toFloat(), $this->transaction->timestamp, $showSmallAmounts);
return ExchangeRate::convert($this->transaction->gas_price->toFloat(), $this->transaction->timestamp, $showSmallAmounts);
}

public function amountForItself(): float
Expand Down

0 comments on commit 8b650ce

Please sign in to comment.