Skip to content

Commit

Permalink
update issue collection tx builder with validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Jan 16, 2022
1 parent fbafc59 commit d611334
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/PreparedTxs/IssueNftCollectionTxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

use InvalidArgumentException;
use Superciety\ElrondSdk\Domain\PreparedTx;
use Illuminate\Validation\ValidationException;
use Superciety\ElrondSdk\Domain\TransactionPayload;
use Superciety\ElrondSdk\PreparedTxs\IPreparedTxBuilder;

class IssueNftCollectionTxBuilder implements IPreparedTxBuilder
{
public function build(array $input): PreparedTx
{
$type = $input['type'] ?? throw new InvalidArgumentException('type is required');
$name = $input['name'] ?? throw new InvalidArgumentException('name is required');
$ticker = $input['ticker'] ?? throw new InvalidArgumentException('ticker is required');
$properties = $input['properties'] ?? throw new InvalidArgumentException('properties is required');
$type = $input['type'] ?? throw ValidationException::withMessages(['collection' => 'type is required']);
$name = $input['name'] ?? throw ValidationException::withMessages(['collection' => 'name is required']);
$ticker = $input['ticker'] ?? throw ValidationException::withMessages(['collection' => 'ticker is required']);
$properties = $input['properties'] ?? throw ValidationException::withMessages(['collection' => 'properties are required']);

return PreparedTx::issueNonFungible(match ($type) {
'nft' => TransactionPayload::issueNonFungible($name, $ticker, $properties),
Expand Down

0 comments on commit d611334

Please sign in to comment.