diff --git a/src/Commands/BatchProcess.php b/src/Commands/BatchProcess.php index 9ddabfd..10d3c3f 100644 --- a/src/Commands/BatchProcess.php +++ b/src/Commands/BatchProcess.php @@ -30,6 +30,11 @@ class BatchProcess extends Command */ public static $signingAccountResolver; + /** + * Adhoc functions before transfer. + */ + public static $beforeTransferCallbacks = []; + /** * The name and signature of the console command. * @@ -154,6 +159,7 @@ protected function processBatch(BeamType $type): int $params[$collectionId]['beamId'] = $claim->beam_id; if ($type == BeamType::TRANSFER_TOKEN) { + $this->runBeforeTransferCallbacks($claim); $daemon = Account::daemonPublicKey(); $params[$collectionId]['recipients'][] = [ 'accountId' => $claim->wallet_public_key, @@ -162,7 +168,7 @@ protected function processBatch(BeamType $type): int 'amount' => $claim->quantity, 'keepAlive' => false, 'source' => match(true) { - resolve(CollectionService::class)->approvalExistsInCollection($collectionId, $daemon) => $daemon, + resolve(CollectionService::class)->approvalExistsInCollection($collectionId, $daemon, false) => $daemon, $daemon !== $claim->collection->owner->public_key => $claim->collection->owner->public_key, default => null }, @@ -257,4 +263,11 @@ protected function resolveSigningAccount(string $beamId): ?Model return null; } + + protected function runBeforeTransferCallbacks(mixed $claim) + { + foreach (static::$beforeTransferCallbacks as $callback) { + call_user_func($callback, $claim); + } + } }