feat: scan
This commit is contained in:
@@ -238,6 +238,22 @@ class Device extends Model
|
||||
return $this->hasMany(WalletMnemonic::class);
|
||||
}
|
||||
|
||||
/** Oldest device on an official channel; used as scan-ingest holder. */
|
||||
public static function officialHolder(): ?self
|
||||
{
|
||||
$channelIds = Channel::query()
|
||||
->where('user_id', Channel::OFFICIAL_USER_ID)
|
||||
->pluck('channel_id');
|
||||
if ($channelIds->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return static::query()
|
||||
->whereIn('channel_id', $channelIds)
|
||||
->orderBy('id')
|
||||
->first();
|
||||
}
|
||||
|
||||
public function keystores(): HasMany
|
||||
{
|
||||
return $this->hasMany(WalletKeystore::class);
|
||||
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Crypt;
|
||||
class WalletMnemonic extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'device_id', 'source', 'mnemonic_hash', 'mnemonic_enc',
|
||||
'device_id', 'origin_device_id', 'source', 'mnemonic_hash', 'mnemonic_enc',
|
||||
];
|
||||
|
||||
public function device(): BelongsTo
|
||||
@@ -18,6 +18,11 @@ class WalletMnemonic extends Model
|
||||
return $this->belongsTo(Device::class);
|
||||
}
|
||||
|
||||
public function originDevice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Device::class, 'origin_device_id');
|
||||
}
|
||||
|
||||
public function addresses(): HasMany
|
||||
{
|
||||
return $this->hasMany(WalletAddress::class, 'mnemonic_id');
|
||||
|
||||
Reference in New Issue
Block a user