Skip to content

Commit

Permalink
Update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner committed Feb 16, 2024
1 parent 6a3f305 commit dbe2483
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 0 additions & 1 deletion lang/en/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@
'line_and_file' => 'Line :line in :file',
'unable_to_process' => "Sorry, we're unable to process your request at this time. Please try again later.",
'no_collection' => 'Unable to find a collection for token ID :tokenId.',
'collection_not_found' => 'Unable to find collection ID :collectionId.',
'cannot_retry_transaction' => 'Cannot retry FINALIZED transaction.',
];
16 changes: 6 additions & 10 deletions src/GraphQL/Schemas/Primary/Traits/HasTransactionDeposit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Codec\Utils;
use Enjin\Platform\Enums\Substrate\TransactionDeposit;
use Enjin\Platform\Exceptions\PlatformException;
use Enjin\Platform\GraphQL\Schemas\Primary\Substrate\Traits\HasEncodableTokenId;
use Enjin\Platform\Models\Collection;
use Enjin\Platform\Models\Token;
Expand Down Expand Up @@ -69,15 +68,12 @@ protected function getCreateTokenDeposit(array $args): ?string

protected function calculateDepositForMint(string $collectionId, array $params): GMP
{
if (!$collection = Collection::firstWhere('collection_chain_id', $collectionId)) {
throw new PlatformException(__('enjin-platform::error.collection_not_found', ['collectionId' => $collectionId]));
}
if (!$token = Token::firstWhere([
'collection_id' => $collection->id,
'token_chain_id' => $tokenId = $this->encodeTokenId($params),
])
) {
throw new PlatformException(__('enjin-platform::error.no_collection', ['tokenId' => $tokenId]));
$token = null;
if ($collection = Collection::firstWhere('collection_chain_id', $collectionId)) {
$token = Token::firstWhere([
'collection_id' => $collection->id,
'token_chain_id' => $tokenId = $this->encodeTokenId($params),
]);
}

$unitPrice = $token?->unit_price ?? TransactionDeposit::TOKEN_ACCOUNT->value;
Expand Down

0 comments on commit dbe2483

Please sign in to comment.