From e69a8ce1b9287d9832d4c6a4fd21fad81b7e7632 Mon Sep 17 00:00:00 2001 From: Abner Tudtud Date: Mon, 18 Sep 2023 08:37:44 +0800 Subject: [PATCH 1/2] Add transaction hash --- src/Events/BeamClaimPending.php | 9 ++++++--- src/Listeners/UpdateClaimStatus.php | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Events/BeamClaimPending.php b/src/Events/BeamClaimPending.php index 4fa820c..ebf679d 100644 --- a/src/Events/BeamClaimPending.php +++ b/src/Events/BeamClaimPending.php @@ -19,10 +19,13 @@ public function __construct(array $claim) $this->broadcastData = array_merge( Arr::only($claim['beam'], ['code', 'collection_chain_id']), - Arr::only($claim, ['wallet_public_key', 'claimed_at', 'state', 'token_chain_id']) + Arr::only($claim, ['wallet_public_key', 'claimed_at', 'state', 'token_chain_id']), + [ + 'identifierCode' => Arr::get($claim, 'identifierCode'), + 'beamCode' => Arr::get($claim, 'beam.code'), + 'transactionHash' => Arr::get($claim, 'transactionHash'), + ] ); - $this->broadcastData['identifierCode'] = Arr::get($claim, 'identifierCode'); - $this->broadcastData['beamCode'] = $claim['beam']['code']; $this->broadcastChannels = [ new Channel('collection;' . $claim['beam']['collection_chain_id']), diff --git a/src/Listeners/UpdateClaimStatus.php b/src/Listeners/UpdateClaimStatus.php index 8dc65b6..b2fcefb 100644 --- a/src/Listeners/UpdateClaimStatus.php +++ b/src/Listeners/UpdateClaimStatus.php @@ -42,10 +42,12 @@ public function handle(PlatformBroadcastEvent $event): void BeamBatch::where('transaction_id', $event->broadcastData['id'])->update(['processed_at' => now()]); foreach ($claims as $claim) { $claim->state = $state; + $data = [ + ...$claim->toArray(), + 'transactionHash' => $event->broadcastData['transactionHash'], + ]; event( - $state == ClaimStatus::COMPLETED->name - ? new BeamClaimsComplete($claim->toArray()) - : new BeamClaimsFailed($claim->toArray()) + $state == ClaimStatus::COMPLETED->name ? new BeamClaimsComplete($data) : new BeamClaimsFailed($data) ); } } From 2b08d35ddc720b449402ea7199d30e7287551c73 Mon Sep 17 00:00:00 2001 From: Abner Tudtud Date: Mon, 18 Sep 2023 23:07:39 +0800 Subject: [PATCH 2/2] Add transaction Id --- src/Events/BeamClaimPending.php | 1 + src/Listeners/UpdateClaimStatus.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Events/BeamClaimPending.php b/src/Events/BeamClaimPending.php index ebf679d..d14aadf 100644 --- a/src/Events/BeamClaimPending.php +++ b/src/Events/BeamClaimPending.php @@ -24,6 +24,7 @@ public function __construct(array $claim) 'identifierCode' => Arr::get($claim, 'identifierCode'), 'beamCode' => Arr::get($claim, 'beam.code'), 'transactionHash' => Arr::get($claim, 'transactionHash'), + 'transactionId' => Arr::get($claim, 'transactionId'), ] ); diff --git a/src/Listeners/UpdateClaimStatus.php b/src/Listeners/UpdateClaimStatus.php index b2fcefb..74fe570 100644 --- a/src/Listeners/UpdateClaimStatus.php +++ b/src/Listeners/UpdateClaimStatus.php @@ -11,6 +11,7 @@ use Enjin\Platform\Enums\Substrate\SystemEventType; use Enjin\Platform\Events\PlatformBroadcastEvent; use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Support\Arr; class UpdateClaimStatus implements ShouldQueue { @@ -44,7 +45,7 @@ public function handle(PlatformBroadcastEvent $event): void $claim->state = $state; $data = [ ...$claim->toArray(), - 'transactionHash' => $event->broadcastData['transactionHash'], + ...Arr::only($event->broadcastData, ['transactionHash', 'transactionId']), ]; event( $state == ClaimStatus::COMPLETED->name ? new BeamClaimsComplete($data) : new BeamClaimsFailed($data)