Skip to content

Commit

Permalink
Laravel pint.
Browse files Browse the repository at this point in the history
  • Loading branch information
v16Studios committed Jun 19, 2024
1 parent d745eae commit f6dd8c5
Show file tree
Hide file tree
Showing 84 changed files with 261 additions and 429 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"scripts": {
"build-sr25519": "cd vendor/gmajor/sr25519-bindings/go && go build -buildmode=c-shared -o sr25519.so . && mv sr25519.so ../src/Crypto/sr25519.so",
"analyse": "vendor/bin/phpstan analyse",
"fix": "vendor/bin/pint",
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html ../../temp/coverage",
"post-autoload-dump": [
Expand All @@ -71,6 +72,7 @@
"prefer-stable": true,
"require-dev": {
"dms/phpunit-arraysubset-asserts": "dev-master",
"laravel/pint": "^1.16",
"nunomaduro/collision": "^8.1",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
return new class() extends Migration
{
/**
* Run the migrations.
*/
Expand Down
3 changes: 2 additions & 1 deletion database/migrations/2022_10_12_115527_create_beams_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
return new class() extends Migration
{
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
return new class() extends Migration
{
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
return new class() extends Migration
{
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
return new class() extends Migration
{
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
return new class() extends Migration
{
/**
* Run the migrations.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/BeamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public function boot()
{
parent::boot();

$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->loadRoutesFrom(__DIR__ . '/../routes/enjin-platform-beam.php');
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadRoutesFrom(__DIR__.'/../routes/enjin-platform-beam.php');
}

public function packageRegistered()
{
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'enjin-platform-beam');
$this->loadTranslationsFrom(__DIR__.'/../lang', 'enjin-platform-beam');
}
}
2 changes: 1 addition & 1 deletion src/Channels/PlatformBeamChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class PlatformBeamChannel extends PlatformAppChannel
public function __construct()
{
parent::__construct();
$this->name = 'beam;' . $this->name;
$this->name = 'beam;'.$this->name;
}
}
19 changes: 10 additions & 9 deletions src/Commands/BatchProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class BatchProcess extends Command
* The signing account resolver.
*/
public static $signingAccountResolver;

/**
* The name and signature of the console command.
*
Expand Down Expand Up @@ -122,10 +123,10 @@ protected function process(): void
$this->info("Total batch completed: {$total}");

$transferedCount = $this->processBatch(BeamType::TRANSFER_TOKEN);
$this->info('Total transfers completed: ' . $transferedCount);
$this->info('Total transfers completed: '.$transferedCount);

$mintedCount = $this->processBatch(BeamType::MINT_ON_DEMAND);
$this->info('Total mints completed: ' . $mintedCount);
$this->info('Total mints completed: '.$mintedCount);
}

/**
Expand All @@ -134,14 +135,14 @@ protected function process(): void
protected function processBatch(BeamType $type): int
{
$batches = $this->batch->getBatchesForProcessing($type)->groupBy('beam_batch_id');
if (!$batches->isEmpty()) {
if (! $batches->isEmpty()) {
$batches->each(function ($claims, $batchId) use ($type) {
$params = [];
$createdTokens = [];
$reassignedClaims = [];
$claims->each(function ($claim) use (&$params, $type, &$createdTokens, &$reassignedClaims) {
$collectionId = Arr::get($claim, 'beam.collection_chain_id');
if (!isset($params[$collectionId])) {
if (! isset($params[$collectionId])) {
$params[$collectionId] = [
'collectionId' => $collectionId,
'recipients' => [],
Expand All @@ -150,7 +151,7 @@ protected function processBatch(BeamType $type): int

$params[$collectionId]['beamId'] = $claim->beam_id;

if (BeamType::TRANSFER_TOKEN == $type) {
if ($type == BeamType::TRANSFER_TOKEN) {
$params[$collectionId]['recipients'][] = [
'accountId' => $claim->wallet_public_key,
'params' => $this->substrate->getTransferParams([
Expand All @@ -163,7 +164,7 @@ protected function processBatch(BeamType $type): int
])->toEncodable(),
];
} else {
$key = $claim->token_chain_id . '|' . $claim->collection_id;
$key = $claim->token_chain_id.'|'.$claim->collection_id;
if (isset($createdTokens[$key])) {
// Succeeding claims should be minted. Reassigning claims to the next batch
$claim->update(['beam_batch_id' => $batchId = $this->batch->getNextBatchId($type, $collectionId)]);
Expand All @@ -173,7 +174,7 @@ protected function processBatch(BeamType $type): int
return;
}

if (!isset($this->tokenCreatedCache[$key])) {
if (! isset($this->tokenCreatedCache[$key])) {
$this->tokenCreatedCache[$key] = Token::where(['token_chain_id' => $claim->token_chain_id, 'collection_id' => $claim->collection_id])->exists();
}

Expand All @@ -194,14 +195,14 @@ protected function processBatch(BeamType $type): int
])->toEncodable(),
];

if (!$this->tokenCreatedCache[$key]) {
if (! $this->tokenCreatedCache[$key]) {
$this->tokenCreatedCache[$key] = true;
$createdTokens[$key] = true;
}
}
});

$method = BeamType::MINT_ON_DEMAND == $type ? 'BatchMint' : 'BatchTransfer';
$method = $type == BeamType::MINT_ON_DEMAND ? 'BatchMint' : 'BatchTransfer';
foreach ($params as $param) {
$transaction = $this->transaction->store([
'method' => $method,
Expand Down
2 changes: 1 addition & 1 deletion src/Enums/PlatformBeamCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum PlatformBeamCache: string implements PlatformCacheable
*/
public function key(?string $suffix = null): string
{
return 'enjin-platform:beam:' . $this->value . ($suffix ? ":{$suffix}" : '');
return 'enjin-platform:beam:'.$this->value.($suffix ? ":{$suffix}" : '');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Events/BeamClaimInProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Enjin\Platform\Beam\Events;

class BeamClaimInProgress extends BeamClaimPending
{
}
class BeamClaimInProgress extends BeamClaimPending {}
2 changes: 1 addition & 1 deletion src/Events/BeamClaimPending.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(array $claim)
);

$this->broadcastChannels = [
new Channel('collection;' . $claim['beam']['collection_chain_id']),
new Channel('collection;'.$claim['beam']['collection_chain_id']),
new PlatformAppChannel(),
new PlatformBeamChannel(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Events/BeamClaimsComplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Enjin\Platform\Beam\Events;

class BeamClaimsComplete extends BeamClaimPending
{
}
class BeamClaimsComplete extends BeamClaimPending {}
4 changes: 1 addition & 3 deletions src/Events/BeamClaimsFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Enjin\Platform\Beam\Events;

class BeamClaimsFailed extends BeamClaimPending
{
}
class BeamClaimsFailed extends BeamClaimPending {}
4 changes: 1 addition & 3 deletions src/Events/BeamDeleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Enjin\Platform\Beam\Events;

class BeamDeleted extends BeamCreated
{
}
class BeamDeleted extends BeamCreated {}
4 changes: 1 addition & 3 deletions src/Events/BeamUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Enjin\Platform\Beam\Events;

class BeamUpdated extends BeamCreated
{
}
class BeamUpdated extends BeamCreated {}
2 changes: 1 addition & 1 deletion src/Events/CreateBeamClaimsCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(array $data)
$this->broadcastData = $data;

$this->broadcastChannels = [
new Channel('beam;' . Arr::get($data, 'code')),
new Channel('beam;'.Arr::get($data, 'code')),
new PlatformAppChannel(),
new PlatformBeamChannel(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Events/TokensRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Enjin\Platform\Beam\Events;

class TokensRemoved extends TokensAdded
{
}
class TokensRemoved extends TokensAdded {}
6 changes: 3 additions & 3 deletions src/GraphQL/Mutations/AddTokensMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function rules(array $args = []): array
'min:1',
'max:10',
new DistinctAttributes(),
Rule::prohibitedIf(BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('attributes', 'type', $attribute)))),
Rule::prohibitedIf(BeamType::getEnumCase(Arr::get($args, str_replace('attributes', 'type', $attribute))) == BeamType::TRANSFER_TOKEN),
];
}),
'tokens.*.attributes.*.key' => 'max:255',
Expand All @@ -116,7 +116,7 @@ protected function rules(array $args = []): array
'required_without:tokens.*.tokenIdDataUpload',
'prohibits:tokens.*.tokenIdDataUpload',
'distinct',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute)))
BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute))) == BeamType::TRANSFER_TOKEN
? new TokensExistInCollection($beam?->collection_chain_id)
: new TokensDoNotExistInCollection($beam?->collection_chain_id),
new TokensDoNotExistInBeam($beam),
Expand All @@ -127,7 +127,7 @@ protected function rules(array $args = []): array
'bail',
'required_without:tokens.*.tokenIds',
'prohibits:tokens.*.tokenIds',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute)))
BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute))) == BeamType::TRANSFER_TOKEN
? new TokenUploadExistInCollection($beam?->collection_chain_id)
: new TokenUploadNotExistInCollection($beam?->collection_chain_id),
new TokenUploadNotExistInBeam($beam),
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Mutations/ClaimBeamMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

class ClaimBeamMutation extends Mutation implements PlatformPublicGraphQlOperation
{
use HasBeamCommonFields;
use HasBeamClaimConditions;
use HasBeamCommonFields;
use HasIdempotencyField;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/GraphQL/Mutations/CreateBeamMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function rules(array $args = []): array
'bail',
'filled',
function (string $attribute, mixed $value, Closure $fail) {
if (!Collection::where('collection_chain_id', $value)->exists()) {
if (! Collection::where('collection_chain_id', $value)->exists()) {
$fail('validation.exists')->translate();
}
},
Expand All @@ -119,7 +119,7 @@ function (string $attribute, mixed $value, Closure $fail) {
'min:1',
'max:10',
new DistinctAttributes(),
Rule::prohibitedIf(BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('attributes', 'type', $attribute)))),
Rule::prohibitedIf(BeamType::getEnumCase(Arr::get($args, str_replace('attributes', 'type', $attribute))) == BeamType::TRANSFER_TOKEN),
];
}),
'tokens.*.attributes.*.key' => 'max:255',
Expand All @@ -130,7 +130,7 @@ function (string $attribute, mixed $value, Closure $fail) {
'required_without:tokens.*.tokenIdDataUpload',
'prohibits:tokens.*.tokenIdDataUpload',
'distinct',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute)))
BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute))) == BeamType::TRANSFER_TOKEN
? new TokensExistInCollection($args['collectionId'])
: new TokensDoNotExistInCollection($args['collectionId']),
new TokensDoNotExistInBeam(),
Expand All @@ -141,7 +141,7 @@ function (string $attribute, mixed $value, Closure $fail) {
'bail',
'required_without:tokens.*.tokenIds',
'prohibits:tokens.*.tokenIds',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute)))
BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute))) == BeamType::TRANSFER_TOKEN
? new TokenUploadExistInCollection($args['collectionId'])
: new TokenUploadNotExistInCollection($args['collectionId']),
new TokenUploadNotExistInBeam(),
Expand Down
6 changes: 3 additions & 3 deletions src/GraphQL/Mutations/UpdateBeamMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function rules(array $args = []): array
'min:1',
'max:10',
new DistinctAttributes(),
Rule::prohibitedIf(BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('attributes', 'type', $attribute)))),
Rule::prohibitedIf(BeamType::getEnumCase(Arr::get($args, str_replace('attributes', 'type', $attribute))) == BeamType::TRANSFER_TOKEN),
];
}),
'tokens.*.attributes.*.key' => 'max:255',
Expand All @@ -135,7 +135,7 @@ protected function rules(array $args = []): array
'required_without:tokens.*.tokenIdDataUpload',
'prohibits:tokens.*.tokenIdDataUpload',
'distinct',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute)))
BeamType::getEnumCase(Arr::get($args, str_replace('tokenIds', 'type', $attribute))) == BeamType::TRANSFER_TOKEN
? new TokensExistInCollection($beam?->collection_chain_id)
: new TokensDoNotExistInCollection($beam?->collection_chain_id),
new TokensDoNotExistInBeam($beam),
Expand All @@ -146,7 +146,7 @@ protected function rules(array $args = []): array
'bail',
'required_without:tokens.*.tokenIds',
'prohibits:tokens.*.tokenIds',
BeamType::TRANSFER_TOKEN == BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute)))
BeamType::getEnumCase(Arr::get($args, str_replace('tokenIdDataUpload', 'type', $attribute))) == BeamType::TRANSFER_TOKEN
? new TokenUploadExistInCollection($beam?->collection_chain_id)
: new TokenUploadNotExistInCollection($beam?->collection_chain_id),
new TokenUploadNotExistInBeam($beam),
Expand Down
10 changes: 5 additions & 5 deletions src/GraphQL/Traits/HasBeamCommonFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ public function getCommonFields(array $exclude = [], bool $updating = false): ar
$required = $updating ? '' : '!';
$fields = [
'name' => [
'type' => GraphQL::type('String' . $required),
'type' => GraphQL::type('String'.$required),
'description' => __('enjin-platform-beam::mutation.common.args.name'),
],
'description' => [
'type' => GraphQL::type('String' . $required),
'type' => GraphQL::type('String'.$required),
'description' => __('enjin-platform-beam::mutation.common.args.description'),
],
'image' => [
'type' => GraphQL::type('String' . $required),
'type' => GraphQL::type('String'.$required),
'description' => __('enjin-platform-beam::mutation.common.args.image'),
],
'start' => [
'type' => GraphQL::type('DateTime' . $required),
'type' => GraphQL::type('DateTime'.$required),
'description' => __('enjin-platform-beam::mutation.common.args.start'),
],
'end' => [
'type' => GraphQL::type('DateTime' . $required),
'type' => GraphQL::type('DateTime'.$required),
'description' => __('enjin-platform-beam::mutation.common.args.end'),
],
];
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Types/BeamClaimType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class BeamClaimType extends Type
{
use HasSelectFields;
use HasAuthorizableFields;
use HasSelectFields;

/**
* Get the type's attributes.
Expand Down
Loading

0 comments on commit f6dd8c5

Please sign in to comment.