-
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.
- Loading branch information
1 parent
f4c583d
commit 9340474
Showing
17 changed files
with
325 additions
and
29 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,89 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Models; | ||
|
||
use App\Models\Casts\BigInteger; | ||
use App\Services\BigNumber; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\HasOne; | ||
|
||
/** | ||
* @property string $id | ||
* @property bool $success | ||
* @property BigNumber $block_height | ||
* @property BigNumber $gas_used | ||
* @property BigNumber $gas_refunded | ||
* @property resource|string|null $deployed_contract_address | ||
* @property array $logs | ||
* @property string $output | ||
*/ | ||
final class Receipt extends Model | ||
{ | ||
use HasFactory; | ||
|
||
/** | ||
* Indicates if the IDs are auto-incrementing. | ||
* | ||
* @var bool | ||
*/ | ||
public $incrementing = false; | ||
|
||
/** | ||
* The "type" of the primary key ID. | ||
* | ||
* @var string | ||
*/ | ||
public $keyType = 'string'; | ||
|
||
/** | ||
* Indicates if the model should be timestamped. | ||
* | ||
* @var bool | ||
*/ | ||
public $timestamps = false; | ||
|
||
/** | ||
* The column name of the primary key. | ||
* | ||
* @var string | ||
*/ | ||
protected $primaryKey = 'id'; | ||
|
||
/** | ||
* The attributes that should be cast. | ||
* | ||
* @var array<string, string> | ||
*/ | ||
protected $casts = [ | ||
'id' => 'string', | ||
'success' => 'bool', | ||
'block_height' => BigInteger::class, | ||
'gas_used' => BigInteger::class, | ||
'gas_refunded' => BigInteger::class, | ||
'logs' => 'array', | ||
'output' => 'string', | ||
]; | ||
|
||
/** | ||
* A wallet has many blocks if it is a validator. | ||
* | ||
* @return HasOne | ||
*/ | ||
public function transaction(): HasOne | ||
{ | ||
return $this->hasOne(Transaction::class, 'id', 'id'); | ||
} | ||
|
||
/** | ||
* Get the current connection name for the model. | ||
* | ||
* @return string | ||
*/ | ||
public function getConnectionName() | ||
{ | ||
return 'explorer'; | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\Receipt; | ||
use App\Models\Transaction; | ||
use App\Models\Wallet; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
final class ReceiptFactory extends Factory | ||
{ | ||
protected $model = Receipt::class; | ||
|
||
public function definition() | ||
{ | ||
return [ | ||
'id' => $this->faker->transactionId, | ||
'success' => $this->faker->boolean, | ||
'block_height' => $this->faker->numberBetween(1, 10000), | ||
'gas_used' => $this->faker->numberBetween(1, 100), | ||
'gas_refunded' => $this->faker->numberBetween(1, 100), | ||
'deployed_contract_address' => fn () => Wallet::factory()->create()->address, | ||
'logs' => [], | ||
'output' => null, | ||
]; | ||
} | ||
|
||
public function withTransaction() | ||
{ | ||
$transaction = Transaction::factory()->create(); | ||
|
||
return $this->state(fn (array $attributes) => [ | ||
'id' => $transaction->id, | ||
]); | ||
} | ||
} |
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
Oops, something went wrong.