Skip to content

Commit

Permalink
Support null transaction wallet (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner authored Nov 7, 2023
1 parent b753867 commit cf36822
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Commands/BatchProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function processBatch(BeamType $type): int
'source' => Account::daemonPublicKey() !== $claim->collection->owner->public_key
? $claim->collection->owner->public_key
: null,
]),
])->toEncodable(),
];
} else {
$key = $claim->token_chain_id . '|' . $claim->collection_id;
Expand Down Expand Up @@ -191,7 +191,7 @@ protected function processBatch(BeamType $type): int
'behaviour' => null,
'unitPrice' => config('enjin-platform-beam.unit_price'),
'attributes' => $claim->attributes ?: [],
]),
])->toEncodable(),
];

if (!$this->tokenCreatedCache[$key]) {
Expand All @@ -203,19 +203,14 @@ protected function processBatch(BeamType $type): int

$method = BeamType::MINT_ON_DEMAND == $type ? 'BatchMint' : 'BatchTransfer';
foreach ($params as $param) {
if (!$signingAccount = $this->resolveSigningAccount($param['beamId'])) {
$this->error("Signing account not found for beam ID: {$param['beamId']}, batch ID: {$batchId}");

continue;
}
$transaction = $this->transaction->store([
'method' => $method,
'encoded_data' => $this->serialize->encode($method, [
'collectionId' => $param['collectionId'],
'recipients' => $param['recipients'],
]),
'idempotency_key' => Str::uuid()->toString(),
], $signingAccount);
]);
BeamBatch::where('id', $batchId)->update(['transaction_id' => $transaction->id]);
BeamBatchTransactionCreated::safeBroadcast($param['beamId'], $param['collectionId'], $transaction->id);
}
Expand All @@ -236,6 +231,6 @@ protected function resolveSigningAccount(string $beamId): ?Model
return call_user_func(static::$signingAccountResolver, $beamId);
}

return Account::daemon();
return null;
}
}

0 comments on commit cf36822

Please sign in to comment.