diff --git a/lang/en/type.php b/lang/en/type.php index 45f2217..c5d86d2 100644 --- a/lang/en/type.php +++ b/lang/en/type.php @@ -19,6 +19,7 @@ 'beam_claim.field.claimedAt' => 'The claim timestamp.', 'beam_claim.field.token' => 'The token chain ID.', 'beam_claim.field.code' => 'The single use code.', + 'beam_claim.field.identifierCode' => 'The claim identifier code.', 'beam_qr.description' => 'A beam QR which includes the beam host and code in its payload.', 'beam_qr.field.payload' => 'A base64 encoded string containing the beam host and code.', 'beam_qr.field.url' => 'A link to the QR image.', diff --git a/src/Events/BeamClaimPending.php b/src/Events/BeamClaimPending.php index af8790f..e428730 100644 --- a/src/Events/BeamClaimPending.php +++ b/src/Events/BeamClaimPending.php @@ -21,6 +21,7 @@ public function __construct(array $claim) Arr::only($claim['beam'], ['code', 'collection_chain_id']), Arr::only($claim, ['wallet_public_key', 'claimed_at', 'state']) ); + $this->broadcastData['identifierCode'] = Arr::get($claim, 'identifierCode'); $this->broadcastData['beamCode'] = $claim['beam']['code']; $this->broadcastChannels = [ diff --git a/src/GraphQL/Types/BeamClaimType.php b/src/GraphQL/Types/BeamClaimType.php index b19fb01..8a1b8c9 100644 --- a/src/GraphQL/Types/BeamClaimType.php +++ b/src/GraphQL/Types/BeamClaimType.php @@ -75,6 +75,11 @@ public function fields(): array 'description' => __('enjin-platform-beam::type.beam_claim.field.code'), 'resolve' => fn ($claim) => $claim->singleUseCode, ], + 'identifierCode' => [ + 'type' => GraphQL::type('String!'), + 'description' => __('enjin-platform-beam::type.beam_claim.field.identifierCode'), + 'alias' => 'code', + ], 'qr' => [ 'type' => GraphQL::type('BeamQr'), 'description' => __('enjin-platform-beam::type.beam.field.qr'), diff --git a/src/Listeners/UpdateClaimStatus.php b/src/Listeners/UpdateClaimStatus.php index 095b2f8..8dc65b6 100644 --- a/src/Listeners/UpdateClaimStatus.php +++ b/src/Listeners/UpdateClaimStatus.php @@ -29,8 +29,10 @@ public function handle(PlatformBroadcastEvent $event): void $states = [TransactionState::ABANDONED->name, TransactionState::FINALIZED->name]; if (in_array($event->broadcastData['state'], $states)) { $claims = BeamClaim::whereHas('batch', fn ($query) => $query->where('transaction_id', $event->broadcastData['id'])) + ->select('*', 'code as identifierCode') ->with('beam') ->get(); + if (!$claims->isEmpty()) { $state = TransactionState::FINALIZED->name == $event->broadcastData['state'] && $event->broadcastData['result'] == SystemEventType::EXTRINSIC_SUCCESS->name diff --git a/src/Services/BatchService.php b/src/Services/BatchService.php index f5e45c7..697f9e2 100644 --- a/src/Services/BatchService.php +++ b/src/Services/BatchService.php @@ -67,8 +67,17 @@ public function getNextBatchId(BeamType $type, string $collectionid): int */ public function getBatchesForProcessing(BeamType $type): Collection { - return BeamClaim::select('id', 'token_chain_id', 'beam_batch_id', 'wallet_public_key', 'beam_id', 'quantity', 'collection_id', 'attributes') - ->where('state', ClaimStatus::PENDING) + return BeamClaim::select( + 'id', + 'token_chain_id', + 'beam_batch_id', + 'wallet_public_key', + 'beam_id', + 'quantity', + 'collection_id', + 'attributes', + 'code as identifierCode', + )->where('state', ClaimStatus::PENDING) ->with(['beam', 'collection.owner']) ->whereHas('collection') ->whereHas( diff --git a/tests/Feature/GraphQL/Resources/GetClaims.graphql b/tests/Feature/GraphQL/Resources/GetClaims.graphql index 16d4c5e..3a79806 100644 --- a/tests/Feature/GraphQL/Resources/GetClaims.graphql +++ b/tests/Feature/GraphQL/Resources/GetClaims.graphql @@ -21,6 +21,7 @@ query GetClaims( claimedAt claimStatus quantity + identifierCode wallet { account { publicKey