From d1db2b20ec22ca4f6b055a17f7c5bbaabd816b4d Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Thu, 10 Oct 2024 20:58:35 -0300 Subject: [PATCH 1/8] Change --- composer.json | 2 +- .../Events/Implementations/Marketplace/ListingCreated.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c7c5dbc..3a48e4d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^8.2|^8.3", + "php": "^8.3", "ext-bcmath": "*", "ext-json": "*", "ext-openssl": "*", diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php index 2897f5c..c80ace7 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php @@ -7,7 +7,7 @@ use Enjin\Platform\Marketplace\Enums\ListingState; use Enjin\Platform\Marketplace\Enums\ListingType; use Enjin\Platform\Marketplace\Events\Substrate\Marketplace\ListingCreated as ListingCreatedEvent; -use Enjin\Platform\Marketplace\Models\MarketplaceListing; +use Enjin\Platform\Marketplace\Models\Laravel\MarketplaceListing; use Enjin\Platform\Marketplace\Models\MarketplaceState; use Enjin\Platform\Marketplace\Services\Processor\Substrate\Events\Implementations\MarketplaceSubstrateEvent; use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\Marketplace\ListingCreated as ListingCreatedPolkadart; From 344eefc4ea4d7793e3ee9c56b0b7c5046143783c Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Fri, 11 Oct 2024 15:42:08 -0300 Subject: [PATCH 2/8] Changes --- .../factories/MarketplaceListingFactory.php | 6 +- ...ing_type_to_marketplace_listings_table.php | 32 ++++++ src/Enums/ListingType.php | 2 + .../Mutations/CreateListingMutation.php | 107 ++++++++++-------- src/GraphQL/Types/AuctionDataType.php | 4 +- ...putType.php => AuctionParamsInputType.php} | 11 +- .../Types/Input/ListingDataInputType.php | 41 +++++++ .../Types/Input/OfferParamsInputType.php | 33 ++++++ src/GraphQL/Types/OfferDataType.php | 37 ++++++ src/GraphQL/Types/OfferStateType.php | 37 ++++++ src/GraphQL/Unions/ListingDataUnion.php | 2 + src/GraphQL/Unions/ListingStateUnion.php | 2 + src/MarketplaceServiceProvider.php | 1 + src/Models/Laravel/MarketplaceListing.php | 6 +- .../Laravel/Traits/EagerLoadSelectFields.php | 5 +- src/Models/Substrate/AuctionDataParams.php | 2 +- src/Models/Substrate/ListingDataParams.php | 33 ++++++ src/Models/Substrate/OfferDataParams.php | 21 ++++ .../Processor/Substrate/Codec/Decoder.php | 6 +- .../Processor/Substrate/Codec/Encoder.php | 1 - .../Marketplace/ListingCreated.php | 5 +- src/Services/Processor/Substrate/Parser.php | 9 +- .../GraphQL/Mutations/CreateListingTest.php | 82 ++++++++------ .../GraphQL/Queries/GetListingsTest.php | 1 + .../GraphQL/Resources/CreateListing.graphql | 4 +- .../GraphQL/Resources/GetListing.graphql | 10 +- .../GraphQL/Resources/GetListings.graphql | 10 +- .../GraphQL/Traits/CreateCollectionData.php | 10 +- .../Traits/CreateListingParameters.php | 11 +- tests/Unit/EncodingTest.php | 9 +- 30 files changed, 418 insertions(+), 122 deletions(-) create mode 100644 database/migrations/2024_10_11_143012_new_listing_type_to_marketplace_listings_table.php rename src/GraphQL/Types/Input/{AuctionDataInputType.php => AuctionParamsInputType.php} (69%) create mode 100644 src/GraphQL/Types/Input/ListingDataInputType.php create mode 100644 src/GraphQL/Types/Input/OfferParamsInputType.php create mode 100644 src/GraphQL/Types/OfferDataType.php create mode 100644 src/GraphQL/Types/OfferStateType.php create mode 100644 src/Models/Substrate/ListingDataParams.php create mode 100644 src/Models/Substrate/OfferDataParams.php diff --git a/database/factories/MarketplaceListingFactory.php b/database/factories/MarketplaceListingFactory.php index 13aedf8..eda593a 100644 --- a/database/factories/MarketplaceListingFactory.php +++ b/database/factories/MarketplaceListingFactory.php @@ -35,8 +35,10 @@ public function definition() 'deposit' => fake()->numberBetween(1, 100), 'salt' => fake()->text(), 'type' => $state = ListingType::caseNamesAsCollection()->random(), - 'start_block' => $state == ListingType::AUCTION->name ? fake()->numberBetween(1, 100) : null, - 'end_block' => $state == ListingType::AUCTION->name ? fake()->numberBetween(100, 200) : null, + 'auction_start_block' => $state == ListingType::AUCTION->name ? fake()->numberBetween(1, 100) : null, + 'auction_end_block' => $state == ListingType::AUCTION->name ? fake()->numberBetween(100, 200) : null, + 'offer_expiration' => $state == ListingType::OFFER->name ? fake()->numberBetween(100, 200) : null, + 'counter_offer_count' => $state == ListingType::OFFER->name ? fake()->numberBetween(0, 10) : null, 'amount_filled' => $state == ListingType::FIXED_PRICE->name ? fake()->numberBetween(1000, 2000) : null, ]; } diff --git a/database/migrations/2024_10_11_143012_new_listing_type_to_marketplace_listings_table.php b/database/migrations/2024_10_11_143012_new_listing_type_to_marketplace_listings_table.php new file mode 100644 index 0000000..af6c1cb --- /dev/null +++ b/database/migrations/2024_10_11_143012_new_listing_type_to_marketplace_listings_table.php @@ -0,0 +1,32 @@ +renameColumn('start_block', 'auction_start_block'); + $table->renameColumn('end_block', 'auction_end_block'); + $table->unsignedInteger('offer_expiration')->nullable()->after('auction_end_block'); + $table->unsignedInteger('counter_offer_count')->nullable()->after('offer_expiration'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('marketplace_listings', function (Blueprint $table) { + $table->renameColumn('auction_start_block', 'start_block'); + $table->renameColumn('auction_end_block', 'end_block'); + $table->dropColumn(['offer_expiration', 'counter_offer_count']); + }); + } +}; diff --git a/src/Enums/ListingType.php b/src/Enums/ListingType.php index 14687c6..cd7cbe0 100644 --- a/src/Enums/ListingType.php +++ b/src/Enums/ListingType.php @@ -10,4 +10,6 @@ enum ListingType: string case FIXED_PRICE = 'FixedPrice'; case AUCTION = 'Auction'; + + case OFFER = 'Offer'; } diff --git a/src/GraphQL/Mutations/CreateListingMutation.php b/src/GraphQL/Mutations/CreateListingMutation.php index 7a127d6..9aeaf69 100644 --- a/src/GraphQL/Mutations/CreateListingMutation.php +++ b/src/GraphQL/Mutations/CreateListingMutation.php @@ -13,8 +13,11 @@ use Enjin\Platform\GraphQL\Types\Input\Substrate\Traits\HasSigningAccountField; use Enjin\Platform\GraphQL\Types\Input\Substrate\Traits\HasSimulateField; use Enjin\Platform\Interfaces\PlatformBlockchainTransaction; +use Enjin\Platform\Marketplace\Enums\ListingType; use Enjin\Platform\Marketplace\Models\Substrate\AuctionDataParams; +use Enjin\Platform\Marketplace\Models\Substrate\ListingDataParams; use Enjin\Platform\Marketplace\Models\Substrate\MultiTokensTokenAssetIdParams; +use Enjin\Platform\Marketplace\Models\Substrate\OfferDataParams; use Enjin\Platform\Marketplace\Rules\EnoughTokenSupply; use Enjin\Platform\Marketplace\Rules\FutureBlock; use Enjin\Platform\Marketplace\Rules\TokenExistsInCollection; @@ -85,14 +88,9 @@ public function args(): array 'type' => GraphQL::type('String'), 'description' => __('enjin-platform-marketplace::type.marketplace_listing.field.salt'), ], - // TODO: We should remove `auctionData` and replace it with `listingData` - // listingData = FixedPrice, Auction, Offer - // FixedPrice => null, - // Auction => { startBlock, endBlock }, - // Offer => { expiration } - 'auctionData' => [ - 'type' => GraphQL::type('AuctionDataInputType'), - 'description' => __('enjin-platform-marketplace::input_type.auction_data.description'), + 'listingData' => [ + 'type' => GraphQL::type('ListingDataInput'), + 'description' => __('enjin-platform-marketplace::input_type.listing_data.description'), ], ...$this->getSigningAccountField(), ...$this->getIdempotencyField(), @@ -111,8 +109,7 @@ public function resolve( ResolveInfo $resolveInfo, Closure $getSelectFields, ) { - $method = isRunningLatest() ? $this->getMutationName() . 'V1010' : $this->getMutationName(); - $encodedData = TransactionSerializer::encode($method, static::getEncodableParams( + $encodedData = TransactionSerializer::encode($this->getMutationName(), static::getEncodableParams( makeAssetId: new MultiTokensTokenAssetIdParams( Arr::get($args, 'makeAssetId.collectionId'), $this->encodeTokenId(Arr::get($args, 'makeAssetId')) @@ -124,9 +121,7 @@ public function resolve( amount: Arr::get($args, 'amount'), price: Arr::get($args, 'price'), salt: Arr::get($args, 'salt', Str::random(10)), - auctionData: ($data = Arr::get($args, 'auctionData')) - ? new AuctionDataParams(Arr::get($data, 'startBlock'), Arr::get($data, 'endBlock')) - : null + listingData: Arr::get($args, 'listingData'), )); return Transaction::lazyLoadSelectFields( @@ -142,17 +137,18 @@ public static function getEncodableParams(...$params): array $amount = Arr::get($params, 'amount', 0); $price = Arr::get($params, 'price', 0); $salt = Arr::get($params, 'salt', Str::random(10)); - $auctionData = Arr::get($params, 'auctionData'); - - $extra = isRunningLatest() ? [ - 'listingData' => $auctionData ? [ - 'Auction' => $auctionData->toEncodable(), - ] : [ - 'FixedPrice' => null, - ], - ] : [ - 'auctionData' => $auctionData?->toEncodable(), - ]; + $listingType = ListingType::getEnumCase(Arr::get($params, 'listingData.type')); + $listingData = match ($listingType) { + ListingType::AUCTION => new ListingDataParams( + ListingType::AUCTION, + auctionParams: new AuctionDataParams(...Arr::get($params, 'listingData.auctionParams')), + ), + ListingType::OFFER => new ListingDataParams( + ListingType::OFFER, + offerParams: new OfferDataParams(...Arr::get($params, 'listingData.offerParams')) + ), + default => new ListingDataParams(ListingType::FIXED_PRICE), + }; return [ 'makeAssetId' => $makeAsset->toEncodable(), @@ -160,7 +156,7 @@ public static function getEncodableParams(...$params): array 'amount' => gmp_init($amount), 'price' => gmp_init($price), 'salt' => HexConverter::stringToHexPrefixed($salt), - ...$extra, + 'listingData' => $listingData->toEncodable(), 'depositor' => null, ]; } @@ -210,13 +206,7 @@ protected function rulesCommon(array $args): array new MaxBigInt(), ], 'salt' => ['bail', 'filled', 'max:255'], - 'auctionData.endBlock' => [ - 'bail', - 'required_with:auctionData.startBlock', - new MinBigInt(), - new MaxBigInt(Hex::MAX_UINT32), - 'gt:auctionData.startBlock', - ], + 'listingData.type' => ['required'], ]; } @@ -227,6 +217,24 @@ protected function rulesWithValidation(array $args): array { $makeRule = $this->makeOrTakeRuleExist($makeCollection = Arr::get($args, 'makeAssetId.collectionId')); $takeRule = $this->makeOrTakeRuleExist($takeCollection = Arr::get($args, 'takeAssetId.collectionId'), false); + $listingDataType = ListingType::getEnumCase(Arr::get($args, 'listingData.type')); + $extras = match ($listingDataType) { + ListingType::AUCTION => [ + 'listingData.auctionParams' => ['required'], + 'listingData.offerParams' => ['prohibited'], + 'listingData.auctionParams.startBlock' => ['bail', 'required', new MinBigInt(), new MaxBigInt(Hex::MAX_UINT32), new FutureBlock()], + 'listingData.auctionParams.endBlock' => ['bail', 'required', new MinBigInt(), new MaxBigInt(Hex::MAX_UINT32), 'gt:listingData.auctionParams.startBlock', new FutureBlock()], + ], + ListingType::OFFER => [ + 'listingData.offerParams' => ['required'], + 'listingData.auctionParams' => ['prohibited'], + 'listingData.offerParams.expiration' => ['bail', 'nullable', new MinBigInt(), new MaxBigInt(Hex::MAX_UINT32), new FutureBlock()], + ], + default => [ + 'listingData.auctionParams' => ['prohibited'], + 'listingData.offerParams' => ['prohibited'], + ], + }; return [ 'makeAssetId' => new TokenExistsInCollection($makeCollection), @@ -241,14 +249,7 @@ protected function rulesWithValidation(array $args): array new MaxBigInt(), new EnoughTokenSupply(), ], - 'auctionData.startBlock' => [ - 'bail', - 'required_with:auctionData.endBlock', - new MinBigInt(), - new MaxBigInt(Hex::MAX_UINT32), - new FutureBlock(), - 'lte:auctionData.endBlock', - ], + ...$extras, ]; } @@ -259,6 +260,24 @@ protected function rulesWithoutValidation(array $args): array { $makeRule = $this->makeOrTakeRule(Arr::get($args, 'makeAssetId.collectionId')); $takeRule = $this->makeOrTakeRule(Arr::get($args, 'takeAssetId.collectionId'), false); + $listingDataType = ListingType::getEnumCase(Arr::get($args, 'listingData.type')); + $extras = match ($listingDataType) { + ListingType::AUCTION => [ + 'listingData.auctionParams' => ['required'], + 'listingData.offerParams' => ['prohibited'], + 'listingData.auctionParams.startBlock' => ['bail', 'required', new MinBigInt(), new MaxBigInt(Hex::MAX_UINT32)], + 'listingData.auctionParams.endBlock' => ['bail', 'required', new MinBigInt(), new MaxBigInt(Hex::MAX_UINT32), 'gt:listingData.auctionParams.startBlock'], + ], + ListingType::OFFER => [ + 'listingData.offerParams' => ['required'], + 'listingData.auctionParams' => ['prohibited'], + 'listingData.offerParams.expiration' => ['bail', 'nullable', new MinBigInt(), new MaxBigInt(Hex::MAX_UINT32)], + ], + default => [ + 'listingData.auctionParams' => ['prohibited'], + 'listingData.offerParams' => ['prohibited'], + ], + }; return [ ...$makeRule, @@ -270,13 +289,7 @@ protected function rulesWithoutValidation(array $args): array new MinBigInt(1), new MaxBigInt(), ], - 'auctionData.startBlock' => [ - 'bail', - 'required_with:auctionData.endBlock', - new MinBigInt(), - new MaxBigInt(Hex::MAX_UINT32), - 'lte:auctionData.endBlock', - ], + ...$extras, ]; } } diff --git a/src/GraphQL/Types/AuctionDataType.php b/src/GraphQL/Types/AuctionDataType.php index a0648e4..82867af 100644 --- a/src/GraphQL/Types/AuctionDataType.php +++ b/src/GraphQL/Types/AuctionDataType.php @@ -30,12 +30,12 @@ public function fields(): array 'startBlock' => [ 'type' => GraphQL::type('Int!'), 'description' => __('enjin-platform-marketplace::type.auction_data.field.startBlock'), - 'alias' => 'start_block', + 'alias' => 'auction_start_block', ], 'endBlock' => [ 'type' => GraphQL::type('Int!'), 'description' => __('enjin-platform-marketplace::type.auction_data.field.endBlock'), - 'alias' => 'end_block', + 'alias' => 'auction_end_block', ], ]; } diff --git a/src/GraphQL/Types/Input/AuctionDataInputType.php b/src/GraphQL/Types/Input/AuctionParamsInputType.php similarity index 69% rename from src/GraphQL/Types/Input/AuctionDataInputType.php rename to src/GraphQL/Types/Input/AuctionParamsInputType.php index 39d7c26..059e4ee 100644 --- a/src/GraphQL/Types/Input/AuctionDataInputType.php +++ b/src/GraphQL/Types/Input/AuctionParamsInputType.php @@ -2,23 +2,24 @@ namespace Enjin\Platform\Marketplace\GraphQL\Types\Input; +use Enjin\Platform\Marketplace\GraphQL\Types\Type; use Rebing\GraphQL\Support\Facades\GraphQL; -class AuctionDataInputType extends InputType +class AuctionParamsInputType extends InputType { /** - * Get the input type's attributes. + * Get the type's attributes. */ public function attributes(): array { return [ - 'name' => 'AuctionDataInputType', - 'description' => __('enjin-platform-marketplace::input_type.auction_data.description'), + 'name' => 'AuctionParamsInput', + 'description' => __('enjin-platform-marketplace::type.listing_data.description'), ]; } /** - * Get the input type's fields. + * Get the type's fields. */ public function fields(): array { diff --git a/src/GraphQL/Types/Input/ListingDataInputType.php b/src/GraphQL/Types/Input/ListingDataInputType.php new file mode 100644 index 0000000..f49afaf --- /dev/null +++ b/src/GraphQL/Types/Input/ListingDataInputType.php @@ -0,0 +1,41 @@ + 'ListingDataInput', + 'description' => __('enjin-platform-marketplace::type.listing_data.description'), + ]; + } + + /** + * Get the type's fields. + */ + public function fields(): array + { + return [ + 'type' => [ + 'type' => GraphQL::type('ListingType!'), + 'description' => __('enjin-platform-marketplace::enum.listing_type.description'), + ], + 'auctionParams' => [ + 'type' => GraphQL::type('AuctionParamsInput'), + 'description' => __('enjin-platform-marketplace::type.listing_data.field.auctionParams'), + ], + 'offerParams' => [ + 'type' => GraphQL::type('OfferParamsInput'), + 'description' => __('enjin-platform-marketplace::type.listing_data.field.offerParams'), + ], + ]; + } +} diff --git a/src/GraphQL/Types/Input/OfferParamsInputType.php b/src/GraphQL/Types/Input/OfferParamsInputType.php new file mode 100644 index 0000000..a28e888 --- /dev/null +++ b/src/GraphQL/Types/Input/OfferParamsInputType.php @@ -0,0 +1,33 @@ + 'OfferParamsInput', + 'description' => __('enjin-platform-marketplace::type.listing_data.description'), + ]; + } + + /** + * Get the type's fields. + */ + public function fields(): array + { + return [ + 'expiration' => [ + 'type' => GraphQL::type('Int'), + 'description' => __('enjin-platform-marketplace::type.auction_data.field.startBlock'), + ], + ]; + } +} diff --git a/src/GraphQL/Types/OfferDataType.php b/src/GraphQL/Types/OfferDataType.php new file mode 100644 index 0000000..b5d0a5a --- /dev/null +++ b/src/GraphQL/Types/OfferDataType.php @@ -0,0 +1,37 @@ + 'OfferData', + 'description' => __('enjin-platform-marketplace::type.offer_data.description'), + ]; + } + + /** + * Get the type's fields. + */ + public function fields(): array + { + return [ + 'type' => [ + 'type' => GraphQL::type('ListingType!'), + 'description' => __('enjin-platform-marketplace::enum.listing_type.description'), + ], + 'expiration' => [ + 'type' => GraphQL::type('Int'), + 'description' => __('enjin-platform-marketplace::type.offer_data.field.expiration'), + 'alias' => 'offer_expiration', + ], + ]; + } +} diff --git a/src/GraphQL/Types/OfferStateType.php b/src/GraphQL/Types/OfferStateType.php new file mode 100644 index 0000000..1d47a6e --- /dev/null +++ b/src/GraphQL/Types/OfferStateType.php @@ -0,0 +1,37 @@ + 'OfferState', + 'description' => __('enjin-platform-marketplace::type.offer_state.description'), + ]; + } + + /** + * Get the type's fields. + */ + public function fields(): array + { + return [ + 'type' => [ + 'type' => GraphQL::type('ListingType!'), + 'description' => __('enjin-platform-marketplace::enum.listing_type.description'), + ], + 'counterOfferCount' => [ + 'type' => GraphQL::type('Int!'), + 'description' => __('enjin-platform-marketplace::type.offer_state.field.counterOfferCount'), + 'alias' => 'counter_offer_count', + ], + ]; + } +} diff --git a/src/GraphQL/Unions/ListingDataUnion.php b/src/GraphQL/Unions/ListingDataUnion.php index 59b8b82..c5a595d 100644 --- a/src/GraphQL/Unions/ListingDataUnion.php +++ b/src/GraphQL/Unions/ListingDataUnion.php @@ -29,6 +29,7 @@ public function types(): array return [ GraphQL::type('FixedPriceData'), GraphQL::type('AuctionData'), + GraphQL::type('OfferData'), ]; } @@ -40,6 +41,7 @@ public function resolveType($objectValue, $context, ResolveInfo $info) return match ($objectValue?->type) { ListingType::FIXED_PRICE->name => GraphQL::type('FixedPriceData'), ListingType::AUCTION->name => GraphQL::type('AuctionData'), + ListingType::OFFER->name => GraphQL::type('OfferData'), default => null, }; } diff --git a/src/GraphQL/Unions/ListingStateUnion.php b/src/GraphQL/Unions/ListingStateUnion.php index 998cea4..67ca313 100644 --- a/src/GraphQL/Unions/ListingStateUnion.php +++ b/src/GraphQL/Unions/ListingStateUnion.php @@ -29,6 +29,7 @@ public function types(): array return [ GraphQL::type('FixedPriceState'), GraphQL::type('AuctionState'), + GraphQL::type('OfferState'), ]; } @@ -40,6 +41,7 @@ public function resolveType($objectValue, $context, ResolveInfo $info) return match ($objectValue?->type) { ListingType::FIXED_PRICE->name => GraphQL::type('FixedPriceState'), ListingType::AUCTION->name => GraphQL::type('AuctionState'), + ListingType::OFFER->name => GraphQL::type('OfferState'), default => null, }; } diff --git a/src/MarketplaceServiceProvider.php b/src/MarketplaceServiceProvider.php index 6053bda..f80bfd6 100644 --- a/src/MarketplaceServiceProvider.php +++ b/src/MarketplaceServiceProvider.php @@ -25,6 +25,7 @@ public function configurePackage(Package $package): void ->hasMigration('add_listing_id_to_marketplace_sales_table') ->hasMigration('drop_market_place_listing_id_in_marketplace_sales_table') ->hasMigration('nullable_listing_on_marketplace_sales_table') + ->hasMigration('new_listing_type_to_marketplace_listings_table') ->hasTranslations(); } diff --git a/src/Models/Laravel/MarketplaceListing.php b/src/Models/Laravel/MarketplaceListing.php index 7984c13..2989299 100644 --- a/src/Models/Laravel/MarketplaceListing.php +++ b/src/Models/Laravel/MarketplaceListing.php @@ -41,8 +41,10 @@ class MarketplaceListing extends BaseModel 'deposit', 'salt', 'type', - 'start_block', - 'end_block', + 'auction_start_block', + 'auction_end_block', + 'offer_expiration', + 'counter_offer_count', 'amount_filled', ]; diff --git a/src/Models/Laravel/Traits/EagerLoadSelectFields.php b/src/Models/Laravel/Traits/EagerLoadSelectFields.php index 7a19839..abbf4c1 100644 --- a/src/Models/Laravel/Traits/EagerLoadSelectFields.php +++ b/src/Models/Laravel/Traits/EagerLoadSelectFields.php @@ -69,13 +69,14 @@ public static function loadListings( bool $isParent = false ): array { $fields = Arr::get($selections, $attribute, $selections); + $select = array_filter([ 'id', 'listing_chain_id', isset($fields['seller']) ? 'seller_wallet_id' : null, isset($fields['state']) || isset($fields['data']) ? 'type' : null, - ...(isset($fields['state']) ? ['amount_filled', 'type'] : []), - ...(isset($fields['data']) ? ['start_block', 'end_block', 'type'] : []), + ...(isset($fields['state']) ? ['amount_filled', 'counter_offer_count', 'type'] : []), + ...(isset($fields['data']) ? ['auction_start_block', 'auction_end_block', 'offer_expiration', 'type'] : []), ...(isset($fields['makeAssetId']) ? ['make_collection_chain_id', 'make_token_chain_id'] : []), ...(isset($fields['takeAssetId']) ? ['take_collection_chain_id', 'take_token_chain_id'] : []), ...MarketplaceListingType::getSelectFields($fieldKeys = array_keys($fields)), diff --git a/src/Models/Substrate/AuctionDataParams.php b/src/Models/Substrate/AuctionDataParams.php index 7bd5866..20d5d65 100644 --- a/src/Models/Substrate/AuctionDataParams.php +++ b/src/Models/Substrate/AuctionDataParams.php @@ -9,7 +9,7 @@ class AuctionDataParams */ public function __construct( public int $startBlock, - public int $endBlock + public int $endBlock, ) {} /** diff --git a/src/Models/Substrate/ListingDataParams.php b/src/Models/Substrate/ListingDataParams.php new file mode 100644 index 0000000..8c313ab --- /dev/null +++ b/src/Models/Substrate/ListingDataParams.php @@ -0,0 +1,33 @@ +type) { + ListingType::AUCTION => $this->auctionParams->toEncodable(), + ListingType::OFFER => $this->offerParams->toEncodable(), + default => null, + }; + + return [ + $this->type->value => $params, + ]; + } +} diff --git a/src/Models/Substrate/OfferDataParams.php b/src/Models/Substrate/OfferDataParams.php new file mode 100644 index 0000000..e80f599 --- /dev/null +++ b/src/Models/Substrate/OfferDataParams.php @@ -0,0 +1,21 @@ + $this->startBlock, 'endBlock' => $this->endBlock]; + } +} diff --git a/src/Services/Processor/Substrate/Codec/Decoder.php b/src/Services/Processor/Substrate/Codec/Decoder.php index 6ee747a..34f84c4 100644 --- a/src/Services/Processor/Substrate/Codec/Decoder.php +++ b/src/Services/Processor/Substrate/Codec/Decoder.php @@ -28,11 +28,7 @@ public function listingStorageKey(string $data): array */ public function listingStorageData(string $data): array { - try { - $decoded = $this->codec->process('ListingStorageDataV1010', new ScaleBytes($data)); - } catch (\Exception) { - $decoded = $this->codec->process('ListingStorageData', new ScaleBytes($data)); - } + $decoded = $this->codec->process('ListingStorageData', new ScaleBytes($data)); return [ 'seller' => ($seller = $this->getValue($decoded, ['seller', 'creator'])) !== null ? HexConverter::prefix($seller) : null, diff --git a/src/Services/Processor/Substrate/Codec/Encoder.php b/src/Services/Processor/Substrate/Codec/Encoder.php index 56cdab3..a681691 100644 --- a/src/Services/Processor/Substrate/Codec/Encoder.php +++ b/src/Services/Processor/Substrate/Codec/Encoder.php @@ -8,7 +8,6 @@ class Encoder extends BaseEncoder { protected static array $callIndexKeys = [ 'CreateListing' => 'Marketplace.create_listing', - 'CreateListingV1010' => 'Marketplace.create_listing', 'CancelListing' => 'Marketplace.cancel_listing', 'FillListing' => 'Marketplace.fill_listing', 'FinalizeAuction' => 'Marketplace.finalize_auction', diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php index c80ace7..ed375ac 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php @@ -49,8 +49,9 @@ public function run(): void 'deposit' => $this->event->deposit, 'salt' => $this->event->salt, 'type' => ListingType::from(array_key_first($this->event->state))->name, - 'start_block' => Arr::get($this->event->data, 'Auction.start_block'), - 'end_block' => Arr::get($this->event->data, 'Auction.end_block'), + 'auction_start_block' => Arr::get($this->event->data, 'Auction.start_block'), + 'auction_end_block' => Arr::get($this->event->data, 'Auction.end_block'), + 'offer_expiration' => Arr::get($this->event->data, 'Offer.expiration'), 'amount_filled' => $this->getValue($this->event->state, ['FixedPrice.amount_filled', 'FixedPrice']), 'created_at' => $now = Carbon::now(), 'updated_at' => $now, diff --git a/src/Services/Processor/Substrate/Parser.php b/src/Services/Processor/Substrate/Parser.php index 4d08da0..b99712f 100644 --- a/src/Services/Processor/Substrate/Parser.php +++ b/src/Services/Processor/Substrate/Parser.php @@ -4,6 +4,7 @@ use Closure; use Enjin\Platform\Marketplace\Enums\ListingState; +use Enjin\Platform\Marketplace\Enums\ListingType; use Enjin\Platform\Marketplace\Models\MarketplaceBid; use Enjin\Platform\Marketplace\Models\MarketplaceListing; use Enjin\Platform\Marketplace\Models\MarketplaceState; @@ -85,9 +86,11 @@ public function listingsStorages(array $data): void 'creation_block' => $creationBlock, 'deposit' => Arr::get($listingData, 'deposit'), 'salt' => Arr::get($listingData, 'salt'), - 'type' => Arr::exists($listingData, 'data.Auction') ? 'AUCTION' : 'FIXED_PRICE', - 'start_block' => Arr::get($listingData, 'data.Auction.startBlock'), - 'end_block' => Arr::get($listingData, 'data.Auction.endBlock'), + 'type' => ListingType::tryFrom(array_key_first(Arr::get($listingData, 'data'))), + 'auction_start_block' => Arr::get($listingData, 'data.Auction.startBlock'), + 'auction_end_block' => Arr::get($listingData, 'data.Auction.endBlock'), + 'offer_expiration' => Arr::get($listingData, 'data.Offer.expiration'), + 'counter_offer_count' => ($counterOfferCount = Arr::get($listingData, 'state.Offer.counterOfferCount')) !== null ? gmp_strval($counterOfferCount) : null, 'amount_filled' => ($amountFilled = Arr::get($listingData, 'state.FixedPrice.amountFilled')) !== null ? gmp_strval($amountFilled) : null, ]; } diff --git a/tests/Feature/GraphQL/Mutations/CreateListingTest.php b/tests/Feature/GraphQL/Mutations/CreateListingTest.php index c410f67..31b18bf 100644 --- a/tests/Feature/GraphQL/Mutations/CreateListingTest.php +++ b/tests/Feature/GraphQL/Mutations/CreateListingTest.php @@ -4,8 +4,9 @@ use Enjin\Platform\Facades\TransactionSerializer; use Enjin\Platform\GraphQL\Schemas\Primary\Substrate\Traits\HasEncodableTokenId; +use Enjin\Platform\Marketplace\Enums\ListingType; use Enjin\Platform\Marketplace\GraphQL\Mutations\CreateListingMutation; -use Enjin\Platform\Marketplace\Models\Substrate\AuctionDataParams; +use Enjin\Platform\Marketplace\Models\Substrate\ListingDataParams; use Enjin\Platform\Marketplace\Models\Substrate\MultiTokensTokenAssetIdParams; use Enjin\Platform\Marketplace\Tests\Feature\GraphQL\TestCaseGraphQL; use Enjin\Platform\Models\Block; @@ -47,9 +48,6 @@ public function test_it_can_create_listing(): void Arr::get($params, 'takeAssetId.collectionId'), $this->encodeTokenId(Arr::get($params, 'takeAssetId')) ); - $params['auctionData'] = (Arr::get($params, 'auctionData')) - ? new AuctionDataParams(Arr::get($params, 'auctionData.startBlock'), Arr::get($params, 'auctionData.endBlock')) - : null; $this->assertEquals( $response['encodedData'], @@ -75,9 +73,11 @@ public function test_it_can_skip_validation(): void 'amount' => fake()->numberBetween(1, 1000), 'price' => fake()->numberBetween(1, 1000), 'salt' => fake()->text(10), - 'auctionData' => [ - 'startBlock' => fake()->numberBetween(1011, 5000), - 'endBlock' => fake()->numberBetween(5001, 10000), + 'listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => ['startBlock' => fake()->numberBetween(1011, 5000), + 'endBlock' => fake()->numberBetween(5001, 10000), + ], ], 'skipValidation' => true, ] @@ -92,7 +92,7 @@ public function test_it_can_skip_validation(): void $this->encodeTokenId(Arr::get($params, 'takeAssetId')) ); $params['auctionData'] = (Arr::get($params, 'auctionData')) - ? new AuctionDataParams(Arr::get($params, 'auctionData.startBlock'), Arr::get($params, 'auctionData.endBlock')) + ? new ListingDataParams(Arr::get($params, 'auctionData.startBlock'), Arr::get($params, 'auctionData.endBlock')) : null; $this->assertEquals( @@ -122,7 +122,7 @@ public function test_it_can_create_listing_with_signing_account(): void $this->encodeTokenId(Arr::get($params, 'takeAssetId')) ); $params['auctionData'] = ($data = Arr::get($params, 'auctionData')) - ? new AuctionDataParams(Arr::get($params, 'auctionData.startBlock'), Arr::get($params, 'auctionData.endBlock')) + ? new ListingDataParams(Arr::get($params, 'auctionData.startBlock'), Arr::get($params, 'auctionData.endBlock')) : null; $this->assertEquals( @@ -374,79 +374,95 @@ public function test_it_will_fail_with_invalid_parameter_auction_data(): void $data = $this->generateParams(); $response = $this->graphql( $this->method, - array_merge($data, ['auctionData' => null]), + array_merge($data, ['listingData' => null]), true ); - $this->assertNotEmpty($response['data']); + $this->assertStringContainsString( + 'Variable "$listingData" of non-null type "ListingDataInput!" must not be null.', + $response['error'] + ); $response = $this->graphql( $this->method, - array_merge($data, ['auctionData' => [ - 'startBlock' => fake()->numberBetween(1011, 2000), - 'endBlock' => null, + array_merge($data, ['listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => ['startBlock' => fake()->numberBetween(1011, 5000)], ]]), true ); $this->assertStringContainsString( - 'Variable "$auctionData" got invalid value null at "auctionData.endBlock"; Expected non-nullable type "Int!" not to be null.', + 'Field "endBlock" of required type "Int!" was not provided', $response['error'] ); $response = $this->graphql( $this->method, - array_merge($data, ['auctionData' => [ - 'startBlock' => null, - 'endBlock' => fake()->numberBetween(1011, 2000), + array_merge($data, ['listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => [ + 'startBlock' => null, + 'endBlock' => fake()->numberBetween(1011, 2000), + ], ]]), true ); $this->assertStringContainsString( - 'Variable "$auctionData" got invalid value null at "auctionData.startBlock"; Expected non-nullable type "Int!" not to be null.', + 'invalid value null at "listingData.auctionParams.startBlock"', $response['error'] ); $response = $this->graphql( $this->method, - array_merge($data, ['auctionData' => [ - 'startBlock' => Hex::MAX_UINT128 + 1, - 'endBlock' => Hex::MAX_UINT128 + 1, + array_merge($data, ['listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => [ + 'startBlock' => Hex::MAX_UINT128 + 1, + 'endBlock' => Hex::MAX_UINT128 + 1, + ], ]]), true ); $this->assertStringContainsString( - 'Variable "$auctionData" got invalid value 3.4028236692094E+38 at "auctionData.startBlock"; Int cannot represent non 32-bit signed integer value: 3.4028236692094E+38', + '"listingData.auctionParams.startBlock"; Int cannot represent non', $response['errors'][0]['message'] ); $this->assertStringContainsString( - 'Variable "$auctionData" got invalid value 3.4028236692094E+38 at "auctionData.endBlock"; Int cannot represent non 32-bit signed integer value: 3.4028236692094E+38', + '"listingData.auctionParams.endBlock"; Int cannot represent non', $response['errors'][1]['message'] ); $response = $this->graphql( $this->method, - array_merge($data, ['auctionData' => [ - 'startBlock' => 1, - 'endBlock' => 2, + array_merge($data, ['listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => [ + 'startBlock' => 1, + 'endBlock' => 2, + ], ]]), true ); $this->assertArraySubset( - ['auctionData.startBlock' => ['The auction data.start block must be at least 1010.']], + ['listingData.auctionParams.startBlock' => ['The listing data.auction params.start block must be at least 1010.']], $response['error'] ); $response = $this->graphql( $this->method, - array_merge($data, ['auctionData' => [ - 'startBlock' => 1012, - 'endBlock' => 1011, + array_merge($data, ['listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => [ + 'startBlock' => 1012, + 'endBlock' => 1011, + ], ]]), true ); $this->assertArraySubset( [ - 'auctionData.startBlock' => ['The auction data.start block field must be less than or equal to 1011.'], - 'auctionData.endBlock' => ['The auction data.end block field must be greater than 1012.'], + 'listingData.auctionParams.endBlock' => [ + 'The listing data.auction params.end block field must be greater than 1012.', + ], ], $response['error'] ); diff --git a/tests/Feature/GraphQL/Queries/GetListingsTest.php b/tests/Feature/GraphQL/Queries/GetListingsTest.php index b78f47f..48e9f8e 100644 --- a/tests/Feature/GraphQL/Queries/GetListingsTest.php +++ b/tests/Feature/GraphQL/Queries/GetListingsTest.php @@ -17,6 +17,7 @@ class GetListingsTest extends TestCaseGraphQL public function test_it_can_get_listings(): void { $listings = $this->createListing(fake()->numberBetween(1, 100)); + $response = $this->graphql( $this->method, ['account' => $this->wallet->address], diff --git a/tests/Feature/GraphQL/Resources/CreateListing.graphql b/tests/Feature/GraphQL/Resources/CreateListing.graphql index 0a9d5a6..6c91ffc 100644 --- a/tests/Feature/GraphQL/Resources/CreateListing.graphql +++ b/tests/Feature/GraphQL/Resources/CreateListing.graphql @@ -4,7 +4,7 @@ mutation CreateListing( $amount: BigInt! $price: BigInt! $salt: String! - $auctionData: AuctionDataInputType + $listingData: ListingDataInput! $signingAccount: String $skipValidation: Boolean ) { @@ -14,7 +14,7 @@ mutation CreateListing( amount: $amount price: $price salt: $salt - auctionData: $auctionData + listingData: $listingData signingAccount: $signingAccount skipValidation: $skipValidation ) { diff --git a/tests/Feature/GraphQL/Resources/GetListing.graphql b/tests/Feature/GraphQL/Resources/GetListing.graphql index fdb63ee..0fbfb26 100644 --- a/tests/Feature/GraphQL/Resources/GetListing.graphql +++ b/tests/Feature/GraphQL/Resources/GetListing.graphql @@ -18,12 +18,16 @@ query GetListing($id: BigInt, $listingId: String) { salt state { ... on FixedPriceState { - amountFilled type + amountFilled } ... on AuctionState { type } + ... on OfferState { + type + counterOfferCount + } } data { ... on FixedPriceData { @@ -34,6 +38,10 @@ query GetListing($id: BigInt, $listingId: String) { startBlock endBlock } + ... on OfferData { + type + expiration + } } seller { account { diff --git a/tests/Feature/GraphQL/Resources/GetListings.graphql b/tests/Feature/GraphQL/Resources/GetListings.graphql index a9d843d..3868912 100644 --- a/tests/Feature/GraphQL/Resources/GetListings.graphql +++ b/tests/Feature/GraphQL/Resources/GetListings.graphql @@ -43,12 +43,16 @@ query GetListings( salt state { ... on FixedPriceState { - amountFilled type + amountFilled } ... on AuctionState { type } + ... on OfferState { + type + counterOfferCount + } } data { ... on FixedPriceData { @@ -59,6 +63,10 @@ query GetListings( startBlock endBlock } + ... on OfferData { + type + expiration + } } seller { account { diff --git a/tests/Feature/GraphQL/Traits/CreateCollectionData.php b/tests/Feature/GraphQL/Traits/CreateCollectionData.php index 8d2b970..572bf09 100644 --- a/tests/Feature/GraphQL/Traits/CreateCollectionData.php +++ b/tests/Feature/GraphQL/Traits/CreateCollectionData.php @@ -2,7 +2,6 @@ namespace Enjin\Platform\Marketplace\Tests\Feature\GraphQL\Traits; -use Enjin\Platform\Enums\Substrate\TokenMintCapType; use Enjin\Platform\Models\Collection; use Enjin\Platform\Models\Token; use Enjin\Platform\Models\Wallet; @@ -46,7 +45,7 @@ public function createCollectionData(?string $publicKey = null): void 'owner_wallet_id' => $this->wallet->id, 'max_token_count' => fake()->numberBetween(1), 'max_token_supply' => (string) fake()->numberBetween(1), - 'force_single_mint' => fake()->boolean(), + 'force_collapsing_supply' => fake()->boolean(), 'is_frozen' => false, 'token_count' => '0', 'attribute_count' => '0', @@ -57,13 +56,10 @@ public function createCollectionData(?string $publicKey = null): void $this->token = Token::create([ 'collection_id' => $this->collection->id, 'token_chain_id' => (string) fake()->unique()->numberBetween(2000), - 'supply' => (string) $supply = fake()->numberBetween(1), - 'cap' => TokenMintCapType::INFINITE->name, + 'supply' => (string) fake()->numberBetween(1), + 'cap' => null, 'cap_supply' => null, 'is_frozen' => false, - 'unit_price' => (string) $unitPrice = fake()->numberBetween(1 / $supply * 10 ** 17), - 'mint_deposit' => (string) ($unitPrice * $supply), - 'minimum_balance' => '1', 'attribute_count' => '0', ]); } diff --git a/tests/Feature/GraphQL/Traits/CreateListingParameters.php b/tests/Feature/GraphQL/Traits/CreateListingParameters.php index 299f4f6..cf3a63a 100644 --- a/tests/Feature/GraphQL/Traits/CreateListingParameters.php +++ b/tests/Feature/GraphQL/Traits/CreateListingParameters.php @@ -2,6 +2,8 @@ namespace Enjin\Platform\Marketplace\Tests\Feature\GraphQL\Traits; +use Enjin\Platform\Marketplace\Enums\ListingType; + trait CreateListingParameters { /** @@ -21,9 +23,12 @@ protected function generateParams(): array 'amount' => fake()->numberBetween(1, 1000), 'price' => fake()->numberBetween(1, 1000), 'salt' => fake()->text(10), - 'auctionData' => [ - 'startBlock' => fake()->numberBetween(1011, 5000), - 'endBlock' => fake()->numberBetween(5001, 10000), + 'listingData' => [ + 'type' => ListingType::AUCTION->name, + 'auctionParams' => [ + 'startBlock' => fake()->numberBetween(1011, 5000), + 'endBlock' => fake()->numberBetween(5001, 10000), + ], ], ]; } diff --git a/tests/Unit/EncodingTest.php b/tests/Unit/EncodingTest.php index 6c87b24..5fa9c42 100644 --- a/tests/Unit/EncodingTest.php +++ b/tests/Unit/EncodingTest.php @@ -3,12 +3,12 @@ namespace Enjin\Platform\Marketplace\Tests\Unit; use Enjin\Platform\Facades\TransactionSerializer; +use Enjin\Platform\Marketplace\Enums\ListingType; use Enjin\Platform\Marketplace\GraphQL\Mutations\CancelListingMutation; use Enjin\Platform\Marketplace\GraphQL\Mutations\CreateListingMutation; use Enjin\Platform\Marketplace\GraphQL\Mutations\FillListingMutation; use Enjin\Platform\Marketplace\GraphQL\Mutations\FinalizeAuctionMutation; use Enjin\Platform\Marketplace\GraphQL\Mutations\PlaceBidMutation; -use Enjin\Platform\Marketplace\Models\Substrate\AuctionDataParams; use Enjin\Platform\Marketplace\Models\Substrate\MultiTokensTokenAssetIdParams; use Enjin\Platform\Marketplace\Services\Processor\Substrate\Codec\Codec; use Enjin\Platform\Marketplace\Tests\TestCase; @@ -32,12 +32,15 @@ public function test_it_can_encode_create_listing() amount: 1, price: 1, salt: 'test', - auctionData: new AuctionDataParams(100, 1000) + listingData: ['type' => ListingType::AUCTION->name, 'auctionParams' => [ + 'startBlock' => 100, + 'endBlock' => 1000, + ]], )); $callIndex = $this->codec->encoder()->getCallIndex('Marketplace.create_listing', true); $this->assertEquals( - "0x{$callIndex}4277010004427701000404041074657374019101a10f", + "0x{$callIndex}4277010004427701000404041074657374019101a10f00", $data ); } From 6695d5e971733aa7b4983f9cc79a758c10f31667 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Fri, 11 Oct 2024 15:45:05 -0300 Subject: [PATCH 3/8] Use php 8.3 --- .github/workflows/run_tests.yml | 2 +- .github/workflows/sast.yml | 2 +- .github/workflows/security_checker.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index a076515..001254b 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2] + php: [8.3] name: PHP ${{ matrix.php }} diff --git a/.github/workflows/sast.yml b/.github/workflows/sast.yml index 923c947..06f6fd4 100644 --- a/.github/workflows/sast.yml +++ b/.github/workflows/sast.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2] + php: [8.3] name: PHP ${{ matrix.php }} diff --git a/.github/workflows/security_checker.yml b/.github/workflows/security_checker.yml index 8b51153..5bce83f 100644 --- a/.github/workflows/security_checker.yml +++ b/.github/workflows/security_checker.yml @@ -20,7 +20,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.3 tools: composer:v2 coverage: none From f7152b44c25fa5d1506dc0d870d01dacef9a4f6c Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Sat, 12 Oct 2024 16:18:26 -0300 Subject: [PATCH 4/8] Adds translations --- lang/en/mutation.php | 1 + lang/en/type.php | 8 ++++++++ src/GraphQL/Mutations/CreateListingMutation.php | 2 +- src/GraphQL/Types/Input/AuctionParamsInputType.php | 2 +- src/GraphQL/Types/Input/ListingDataInputType.php | 2 +- src/GraphQL/Types/Input/OfferParamsInputType.php | 4 ++-- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lang/en/mutation.php b/lang/en/mutation.php index ac3239a..7f0a1bd 100644 --- a/lang/en/mutation.php +++ b/lang/en/mutation.php @@ -5,6 +5,7 @@ 'create_listing.args.account' => 'The seller account.', 'create_listing.args.makeAssetId' => 'Ids for the asset being sold.', 'create_listing.args.takeAssetId' => 'Ids for the asset requested.', + 'create_listing.args.listingData' => 'The listing data parameters.', 'cancel_listing.description' => 'Cancels the listing.', 'fill_listing.description' => 'Fills a fixed price listing.', 'finalize_auction.description' => 'This will end the auction and transfer funds. It fails if the auction is not over.', diff --git a/lang/en/type.php b/lang/en/type.php index 6654f35..e8ba18e 100644 --- a/lang/en/type.php +++ b/lang/en/type.php @@ -31,4 +31,12 @@ 'marketplace_sale.description' => 'The listing sale.', 'marketplace_state.description' => 'The state of the marketplace listing.', 'marketplace_state.field.height' => 'The block height.', + 'listing_data.description' => 'The data for a listing.', + 'listing_data.field.type' => 'The type of listing.', + 'listing_data.field.auctionParams' => 'The parameters for an auction listing.', + 'listing_data.field.offerParams' => 'The parameters for an offer.', + 'offer_data.description' => 'The parameters for an offer.', + 'offer_data.field.expiration' => 'The expiration time for the offer.', + 'offer_state.description' => 'The state of an offer.', + 'offer_state.field.counterOfferCount' => 'The number of counter offers.', ]; diff --git a/src/GraphQL/Mutations/CreateListingMutation.php b/src/GraphQL/Mutations/CreateListingMutation.php index 9aeaf69..87362d3 100644 --- a/src/GraphQL/Mutations/CreateListingMutation.php +++ b/src/GraphQL/Mutations/CreateListingMutation.php @@ -90,7 +90,7 @@ public function args(): array ], 'listingData' => [ 'type' => GraphQL::type('ListingDataInput'), - 'description' => __('enjin-platform-marketplace::input_type.listing_data.description'), + 'description' => __('enjin-platform-marketplace::mutation.create_listing.args.listingData'), ], ...$this->getSigningAccountField(), ...$this->getIdempotencyField(), diff --git a/src/GraphQL/Types/Input/AuctionParamsInputType.php b/src/GraphQL/Types/Input/AuctionParamsInputType.php index 059e4ee..c431c33 100644 --- a/src/GraphQL/Types/Input/AuctionParamsInputType.php +++ b/src/GraphQL/Types/Input/AuctionParamsInputType.php @@ -14,7 +14,7 @@ public function attributes(): array { return [ 'name' => 'AuctionParamsInput', - 'description' => __('enjin-platform-marketplace::type.listing_data.description'), + 'description' => __('enjin-platform-marketplace::type.auction_data.description'), ]; } diff --git a/src/GraphQL/Types/Input/ListingDataInputType.php b/src/GraphQL/Types/Input/ListingDataInputType.php index f49afaf..3e784a9 100644 --- a/src/GraphQL/Types/Input/ListingDataInputType.php +++ b/src/GraphQL/Types/Input/ListingDataInputType.php @@ -26,7 +26,7 @@ public function fields(): array return [ 'type' => [ 'type' => GraphQL::type('ListingType!'), - 'description' => __('enjin-platform-marketplace::enum.listing_type.description'), + 'description' => __('enjin-platform-marketplace::type.listing_data.field.type'), ], 'auctionParams' => [ 'type' => GraphQL::type('AuctionParamsInput'), diff --git a/src/GraphQL/Types/Input/OfferParamsInputType.php b/src/GraphQL/Types/Input/OfferParamsInputType.php index a28e888..89c075f 100644 --- a/src/GraphQL/Types/Input/OfferParamsInputType.php +++ b/src/GraphQL/Types/Input/OfferParamsInputType.php @@ -14,7 +14,7 @@ public function attributes(): array { return [ 'name' => 'OfferParamsInput', - 'description' => __('enjin-platform-marketplace::type.listing_data.description'), + 'description' => __('enjin-platform-marketplace::type.offer_data.description'), ]; } @@ -26,7 +26,7 @@ public function fields(): array return [ 'expiration' => [ 'type' => GraphQL::type('Int'), - 'description' => __('enjin-platform-marketplace::type.auction_data.field.startBlock'), + 'description' => __('enjin-platform-marketplace::type.offer_data.field.expiration'), ], ]; } From f22e2affadcc7ab52b6282551ef3489aa44a1eab Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Sun, 13 Oct 2024 14:06:50 -0300 Subject: [PATCH 5/8] Update CreateListingTest.php Co-authored-by: Simon Evans --- tests/Feature/GraphQL/Mutations/CreateListingTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Feature/GraphQL/Mutations/CreateListingTest.php b/tests/Feature/GraphQL/Mutations/CreateListingTest.php index 31b18bf..e9734dc 100644 --- a/tests/Feature/GraphQL/Mutations/CreateListingTest.php +++ b/tests/Feature/GraphQL/Mutations/CreateListingTest.php @@ -75,7 +75,8 @@ public function test_it_can_skip_validation(): void 'salt' => fake()->text(10), 'listingData' => [ 'type' => ListingType::AUCTION->name, - 'auctionParams' => ['startBlock' => fake()->numberBetween(1011, 5000), + 'auctionParams' => [ + 'startBlock' => fake()->numberBetween(1011, 5000), 'endBlock' => fake()->numberBetween(5001, 10000), ], ], From 2d77d931d8cb9b869b75c4347b2f6f12efd4b193 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Sun, 13 Oct 2024 16:10:02 -0300 Subject: [PATCH 6/8] Changes --- src/Models/Substrate/OfferDataParams.php | 4 +- .../GraphQL/Mutations/CreateListingTest.php | 57 ++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/Models/Substrate/OfferDataParams.php b/src/Models/Substrate/OfferDataParams.php index e80f599..8e3a941 100644 --- a/src/Models/Substrate/OfferDataParams.php +++ b/src/Models/Substrate/OfferDataParams.php @@ -16,6 +16,8 @@ public function __construct( */ public function toEncodable(): array { - return ['startBlock' => $this->startBlock, 'endBlock' => $this->endBlock]; + return [ + 'expiration' => $this->expiration, + ]; } } diff --git a/tests/Feature/GraphQL/Mutations/CreateListingTest.php b/tests/Feature/GraphQL/Mutations/CreateListingTest.php index 31b18bf..9cfd458 100644 --- a/tests/Feature/GraphQL/Mutations/CreateListingTest.php +++ b/tests/Feature/GraphQL/Mutations/CreateListingTest.php @@ -33,7 +33,7 @@ protected function setUp(): void Block::updateOrCreate(['number' => 1000]); } - public function test_it_can_create_listing(): void + public function test_it_can_create_listing_auction(): void { $response = $this->graphql( $this->method, @@ -57,6 +57,61 @@ public function test_it_can_create_listing(): void $this->assertNull(Arr::get($response, 'wallet.account.publicKey')); } + public function test_it_can_create_listing_fixed_price(): void + { + $params = $this->generateParams(); + $params['listingData'] = [ + 'type' => ListingType::FIXED_PRICE->name, + ]; + + $response = $this->graphql($this->method, $params); + + $params['makeAssetId'] = new MultiTokensTokenAssetIdParams( + Arr::get($params, 'makeAssetId.collectionId'), + $this->encodeTokenId(Arr::get($params, 'makeAssetId')) + ); + $params['takeAssetId'] = new MultiTokensTokenAssetIdParams( + Arr::get($params, 'takeAssetId.collectionId'), + $this->encodeTokenId(Arr::get($params, 'takeAssetId')) + ); + + $this->assertEquals( + $response['encodedData'], + TransactionSerializer::encode($this->method, CreateListingMutation::getEncodableParams(...$params)) + ); + + $this->assertNull(Arr::get($response, 'wallet.account.publicKey')); + } + + public function test_it_can_create_listing_offer(): void + { + $params = $this->generateParams(); + $params['listingData'] = [ + 'type' => ListingType::OFFER->name, + 'offerParams' => [ + 'expiration' => 50000, + ], + ]; + + $response = $this->graphql($this->method, $params); + + $params['makeAssetId'] = new MultiTokensTokenAssetIdParams( + Arr::get($params, 'makeAssetId.collectionId'), + $this->encodeTokenId(Arr::get($params, 'makeAssetId')) + ); + $params['takeAssetId'] = new MultiTokensTokenAssetIdParams( + Arr::get($params, 'takeAssetId.collectionId'), + $this->encodeTokenId(Arr::get($params, 'takeAssetId')) + ); + + $this->assertEquals( + $response['encodedData'], + TransactionSerializer::encode($this->method, CreateListingMutation::getEncodableParams(...$params)) + ); + + $this->assertNull(Arr::get($response, 'wallet.account.publicKey')); + } + public function test_it_can_skip_validation(): void { $response = $this->graphql( From 1e37b2b67cf982b110bff0d7b35cdebf5f45630d Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Sun, 13 Oct 2024 16:20:02 -0300 Subject: [PATCH 7/8] pin rector to 1.2.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a48e4d..56eb879 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "phpstan/phpstan-phpunit": "^1.0", "phpunit/php-code-coverage": "^10.0", "phpunit/phpunit": "^10.0", - "rector/rector": "^1.0", + "rector/rector": "1.2.6", "roave/security-advisories": "dev-latest" }, "autoload": { From 2e0bf09bb0106e9c5d57fe19fb5407cf2e118698 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Sun, 13 Oct 2024 16:44:00 -0300 Subject: [PATCH 8/8] Update --- composer.json | 2 +- rector.php | 2 +- src/Exceptions/MarketplaceException.php | 1 + src/GraphQL/Enums/FeeSideEnum.php | 1 + src/GraphQL/Enums/ListingStateEnum.php | 1 + src/GraphQL/Enums/ListingTypeEnum.php | 1 + src/GraphQL/Mutations/CancelListingMutation.php | 4 ++++ src/GraphQL/Mutations/CreateListingMutation.php | 4 ++++ src/GraphQL/Mutations/FillListingMutation.php | 4 ++++ src/GraphQL/Mutations/FinalizeAuctionMutation.php | 4 ++++ src/GraphQL/Mutations/Mutation.php | 1 + src/GraphQL/Mutations/PlaceBidMutation.php | 4 ++++ src/GraphQL/Queries/GetBidQuery.php | 4 ++++ src/GraphQL/Queries/GetBidsQuery.php | 4 ++++ src/GraphQL/Queries/GetListingQuery.php | 4 ++++ src/GraphQL/Queries/GetListingsQuery.php | 4 ++++ src/GraphQL/Queries/GetSaleQuery.php | 4 ++++ src/GraphQL/Queries/GetSalesQuery.php | 4 ++++ src/GraphQL/Types/AssetType.php | 2 ++ src/GraphQL/Types/AuctionDataType.php | 2 ++ src/GraphQL/Types/AuctionStateType.php | 2 ++ src/GraphQL/Types/FixedPriceDataType.php | 2 ++ src/GraphQL/Types/FixedPriceStateType.php | 2 ++ src/GraphQL/Types/Input/AssetInputType.php | 2 ++ src/GraphQL/Types/Input/AuctionParamsInputType.php | 2 ++ src/GraphQL/Types/Input/ListingDataInputType.php | 2 ++ src/GraphQL/Types/Input/OfferParamsInputType.php | 2 ++ src/GraphQL/Types/MarketplaceBidType.php | 2 ++ src/GraphQL/Types/MarketplaceListingType.php | 2 ++ src/GraphQL/Types/MarketplaceSaleType.php | 2 ++ src/GraphQL/Types/MarketplaceStateType.php | 2 ++ src/GraphQL/Types/OfferDataType.php | 2 ++ src/GraphQL/Types/OfferStateType.php | 2 ++ src/GraphQL/Unions/ListingDataUnion.php | 2 ++ src/GraphQL/Unions/ListingStateUnion.php | 2 ++ src/MarketplaceServiceProvider.php | 4 ++++ src/Models/Laravel/MarketplaceBid.php | 2 ++ src/Models/Laravel/MarketplaceListing.php | 2 ++ src/Models/Laravel/MarketplaceSale.php | 2 ++ src/Package.php | 1 + src/Rules/BidExists.php | 1 + src/Rules/EnoughTokenSupply.php | 2 ++ src/Rules/FutureBlock.php | 1 + src/Rules/ListingExists.php | 1 + src/Rules/ListingNotCancelled.php | 1 + src/Rules/MinimumPrice.php | 2 ++ src/Rules/SaleExists.php | 1 + src/Rules/TokenExistsInCollection.php | 1 + src/Services/Processor/Substrate/Codec/Codec.php | 2 ++ .../Events/Implementations/Marketplace/AuctionFinalized.php | 3 +++ .../Events/Implementations/Marketplace/BidPlaced.php | 3 +++ .../Events/Implementations/Marketplace/ListingCancelled.php | 3 +++ .../Events/Implementations/Marketplace/ListingCreated.php | 3 +++ .../Events/Implementations/Marketplace/ListingFilled.php | 3 +++ tests/Feature/GraphQL/Mutations/CreateListingTest.php | 1 + tests/Feature/GraphQL/TestCaseGraphQL.php | 4 ++++ tests/TestCase.php | 2 ++ tests/Unit/EncodingTest.php | 1 + tests/Unit/MarketplaceServiceTest.php | 1 + 59 files changed, 132 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 56eb879..3a48e4d 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "phpstan/phpstan-phpunit": "^1.0", "phpunit/php-code-coverage": "^10.0", "phpunit/phpunit": "^10.0", - "rector/rector": "1.2.6", + "rector/rector": "^1.0", "roave/security-advisories": "dev-latest" }, "autoload": { diff --git a/rector.php b/rector.php index 8b98d80..55783b4 100644 --- a/rector.php +++ b/rector.php @@ -11,7 +11,7 @@ __DIR__ . '/src', __DIR__ . '/tests', ]) - ->withPhpSets(php82: true) + ->withPhpSets(php83: true) ->withPreparedSets(deadCode: true) ->withRules([Spatie\Ray\Rector\RemoveRayCallRector::class]) ->withTypeCoverageLevel(0); diff --git a/src/Exceptions/MarketplaceException.php b/src/Exceptions/MarketplaceException.php index 7c4a546..409fc69 100644 --- a/src/Exceptions/MarketplaceException.php +++ b/src/Exceptions/MarketplaceException.php @@ -9,6 +9,7 @@ class MarketplaceException extends PlatformException /** * Get the exception's category. */ + #[\Override] public function getCategory(): string { return 'Platform Marketplace'; diff --git a/src/GraphQL/Enums/FeeSideEnum.php b/src/GraphQL/Enums/FeeSideEnum.php index 22e4c5c..2f4e98f 100644 --- a/src/GraphQL/Enums/FeeSideEnum.php +++ b/src/GraphQL/Enums/FeeSideEnum.php @@ -11,6 +11,7 @@ class FeeSideEnum extends EnumType implements PlatformGraphQlEnum /** * Get the enum's attributes. */ + #[\Override] public function attributes(): array { return [ diff --git a/src/GraphQL/Enums/ListingStateEnum.php b/src/GraphQL/Enums/ListingStateEnum.php index 955ddc1..878b634 100644 --- a/src/GraphQL/Enums/ListingStateEnum.php +++ b/src/GraphQL/Enums/ListingStateEnum.php @@ -11,6 +11,7 @@ class ListingStateEnum extends EnumType implements PlatformGraphQlEnum /** * Get the enum's attributes. */ + #[\Override] public function attributes(): array { return [ diff --git a/src/GraphQL/Enums/ListingTypeEnum.php b/src/GraphQL/Enums/ListingTypeEnum.php index a70e8f6..9698857 100644 --- a/src/GraphQL/Enums/ListingTypeEnum.php +++ b/src/GraphQL/Enums/ListingTypeEnum.php @@ -11,6 +11,7 @@ class ListingTypeEnum extends EnumType implements PlatformGraphQlEnum /** * Get the enum's attributes. */ + #[\Override] public function attributes(): array { return [ diff --git a/src/GraphQL/Mutations/CancelListingMutation.php b/src/GraphQL/Mutations/CancelListingMutation.php index f8eb8a5..99c851d 100644 --- a/src/GraphQL/Mutations/CancelListingMutation.php +++ b/src/GraphQL/Mutations/CancelListingMutation.php @@ -33,6 +33,7 @@ class CancelListingMutation extends Mutation implements PlatformBlockchainTransa /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -44,6 +45,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('Transaction!'); @@ -52,6 +54,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -84,6 +87,7 @@ public function resolve( ); } + #[\Override] public static function getEncodableParams(...$params): array { return [ diff --git a/src/GraphQL/Mutations/CreateListingMutation.php b/src/GraphQL/Mutations/CreateListingMutation.php index 87362d3..440f798 100644 --- a/src/GraphQL/Mutations/CreateListingMutation.php +++ b/src/GraphQL/Mutations/CreateListingMutation.php @@ -46,6 +46,7 @@ class CreateListingMutation extends Mutation implements PlatformBlockchainTransa /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -57,6 +58,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('Transaction!'); @@ -65,6 +67,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -130,6 +133,7 @@ public function resolve( ); } + #[\Override] public static function getEncodableParams(...$params): array { $makeAsset = Arr::get($params, 'makeAssetId', new MultiTokensTokenAssetIdParams('0', '0')); diff --git a/src/GraphQL/Mutations/FillListingMutation.php b/src/GraphQL/Mutations/FillListingMutation.php index c7852a5..bab68ce 100644 --- a/src/GraphQL/Mutations/FillListingMutation.php +++ b/src/GraphQL/Mutations/FillListingMutation.php @@ -35,6 +35,7 @@ class FillListingMutation extends Mutation implements PlatformBlockchainTransact /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -46,6 +47,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('Transaction!'); @@ -54,6 +56,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -90,6 +93,7 @@ public function resolve( ); } + #[\Override] public static function getEncodableParams(...$params): array { return [ diff --git a/src/GraphQL/Mutations/FinalizeAuctionMutation.php b/src/GraphQL/Mutations/FinalizeAuctionMutation.php index 4c84697..01b1b63 100644 --- a/src/GraphQL/Mutations/FinalizeAuctionMutation.php +++ b/src/GraphQL/Mutations/FinalizeAuctionMutation.php @@ -33,6 +33,7 @@ class FinalizeAuctionMutation extends Mutation implements PlatformBlockchainTran /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -44,6 +45,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('Transaction!'); @@ -52,6 +54,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -84,6 +87,7 @@ public function resolve( ); } + #[\Override] public static function getEncodableParams(...$params): array { return [ diff --git a/src/GraphQL/Mutations/Mutation.php b/src/GraphQL/Mutations/Mutation.php index d6bc2b0..363e674 100644 --- a/src/GraphQL/Mutations/Mutation.php +++ b/src/GraphQL/Mutations/Mutation.php @@ -36,6 +36,7 @@ public function getMutationName(): string /** * Get validation rules. */ + #[\Override] public function getRules(array $arguments = []): array { return collect(parent::getRules($arguments))->mergeRecursive(static::$adhocRules)->all(); diff --git a/src/GraphQL/Mutations/PlaceBidMutation.php b/src/GraphQL/Mutations/PlaceBidMutation.php index fef4c7e..7c2013f 100644 --- a/src/GraphQL/Mutations/PlaceBidMutation.php +++ b/src/GraphQL/Mutations/PlaceBidMutation.php @@ -36,6 +36,7 @@ class PlaceBidMutation extends Mutation implements PlatformBlockchainTransaction /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -47,6 +48,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('Transaction!'); @@ -55,6 +57,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -91,6 +94,7 @@ public function resolve( ); } + #[\Override] public static function getEncodableParams(...$params): array { return [ diff --git a/src/GraphQL/Queries/GetBidQuery.php b/src/GraphQL/Queries/GetBidQuery.php index 198fe53..310fec4 100644 --- a/src/GraphQL/Queries/GetBidQuery.php +++ b/src/GraphQL/Queries/GetBidQuery.php @@ -16,6 +16,7 @@ class GetBidQuery extends Query /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -27,6 +28,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('MarketplaceBid!'); @@ -35,6 +37,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -61,6 +64,7 @@ public function resolve( /** * Get the mutation's request validation rules. */ + #[\Override] protected function rules(array $args = []): array { return [ diff --git a/src/GraphQL/Queries/GetBidsQuery.php b/src/GraphQL/Queries/GetBidsQuery.php index f1b2b26..7b31a0d 100644 --- a/src/GraphQL/Queries/GetBidsQuery.php +++ b/src/GraphQL/Queries/GetBidsQuery.php @@ -24,6 +24,7 @@ class GetBidsQuery extends Query /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -35,6 +36,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::paginate('MarketplaceBid', 'MarketplaceBidConnection'); @@ -43,6 +45,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return ConnectionInput::args([ @@ -96,6 +99,7 @@ public function resolve( /** * Get the mutation's request validation rules. */ + #[\Override] protected function rules(array $args = []): array { return [ diff --git a/src/GraphQL/Queries/GetListingQuery.php b/src/GraphQL/Queries/GetListingQuery.php index 0882552..0121aa9 100644 --- a/src/GraphQL/Queries/GetListingQuery.php +++ b/src/GraphQL/Queries/GetListingQuery.php @@ -17,6 +17,7 @@ class GetListingQuery extends Query /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -28,6 +29,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('MarketplaceListing!'); @@ -36,6 +38,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -73,6 +76,7 @@ public function resolve( /** * Get the mutation's request validation rules. */ + #[\Override] protected function rules(array $args = []): array { return [ diff --git a/src/GraphQL/Queries/GetListingsQuery.php b/src/GraphQL/Queries/GetListingsQuery.php index 0253c38..99ea21f 100644 --- a/src/GraphQL/Queries/GetListingsQuery.php +++ b/src/GraphQL/Queries/GetListingsQuery.php @@ -30,6 +30,7 @@ class GetListingsQuery extends Query /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -41,6 +42,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::paginate('MarketplaceListing', 'MarketplaceListingConnection'); @@ -49,6 +51,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return ConnectionInput::args([ @@ -136,6 +139,7 @@ public function resolve( /** * Get the mutation's request validation rules. */ + #[\Override] protected function rules(array $args = []): array { return [ diff --git a/src/GraphQL/Queries/GetSaleQuery.php b/src/GraphQL/Queries/GetSaleQuery.php index 74e68cb..e02ff42 100644 --- a/src/GraphQL/Queries/GetSaleQuery.php +++ b/src/GraphQL/Queries/GetSaleQuery.php @@ -16,6 +16,7 @@ class GetSaleQuery extends Query /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -27,6 +28,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::type('MarketplaceSale!'); @@ -35,6 +37,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return [ @@ -61,6 +64,7 @@ public function resolve( /** * Get the mutation's request validation rules. */ + #[\Override] protected function rules(array $args = []): array { return [ diff --git a/src/GraphQL/Queries/GetSalesQuery.php b/src/GraphQL/Queries/GetSalesQuery.php index 1af5334..eda123c 100644 --- a/src/GraphQL/Queries/GetSalesQuery.php +++ b/src/GraphQL/Queries/GetSalesQuery.php @@ -24,6 +24,7 @@ class GetSalesQuery extends Query /** * Get the mutation's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -35,6 +36,7 @@ public function attributes(): array /** * Get the mutation's return type. */ + #[\Override] public function type(): Type { return GraphQL::paginate('MarketplaceSale', 'MarketplaceSaleConnection'); @@ -43,6 +45,7 @@ public function type(): Type /** * Get the mutation's arguments definition. */ + #[\Override] public function args(): array { return ConnectionInput::args([ @@ -96,6 +99,7 @@ public function resolve( /** * Get the mutation's request validation rules. */ + #[\Override] protected function rules(array $args = []): array { return [ diff --git a/src/GraphQL/Types/AssetType.php b/src/GraphQL/Types/AssetType.php index 97ff877..662e8a4 100644 --- a/src/GraphQL/Types/AssetType.php +++ b/src/GraphQL/Types/AssetType.php @@ -9,6 +9,7 @@ class AssetType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/AuctionDataType.php b/src/GraphQL/Types/AuctionDataType.php index 82867af..d05eacd 100644 --- a/src/GraphQL/Types/AuctionDataType.php +++ b/src/GraphQL/Types/AuctionDataType.php @@ -9,6 +9,7 @@ class AuctionDataType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/AuctionStateType.php b/src/GraphQL/Types/AuctionStateType.php index 76172ec..8a3bd9b 100644 --- a/src/GraphQL/Types/AuctionStateType.php +++ b/src/GraphQL/Types/AuctionStateType.php @@ -9,6 +9,7 @@ class AuctionStateType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/FixedPriceDataType.php b/src/GraphQL/Types/FixedPriceDataType.php index 41c8dc1..12964ba 100644 --- a/src/GraphQL/Types/FixedPriceDataType.php +++ b/src/GraphQL/Types/FixedPriceDataType.php @@ -9,6 +9,7 @@ class FixedPriceDataType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/FixedPriceStateType.php b/src/GraphQL/Types/FixedPriceStateType.php index c3683c4..6ce54f9 100644 --- a/src/GraphQL/Types/FixedPriceStateType.php +++ b/src/GraphQL/Types/FixedPriceStateType.php @@ -9,6 +9,7 @@ class FixedPriceStateType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/Input/AssetInputType.php b/src/GraphQL/Types/Input/AssetInputType.php index d2cd9fa..e03f569 100644 --- a/src/GraphQL/Types/Input/AssetInputType.php +++ b/src/GraphQL/Types/Input/AssetInputType.php @@ -9,6 +9,7 @@ class AssetInputType extends InputType /** * Get the input type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the input type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/Input/AuctionParamsInputType.php b/src/GraphQL/Types/Input/AuctionParamsInputType.php index c431c33..0ba1e94 100644 --- a/src/GraphQL/Types/Input/AuctionParamsInputType.php +++ b/src/GraphQL/Types/Input/AuctionParamsInputType.php @@ -10,6 +10,7 @@ class AuctionParamsInputType extends InputType /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -21,6 +22,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/Input/ListingDataInputType.php b/src/GraphQL/Types/Input/ListingDataInputType.php index 3e784a9..caa785a 100644 --- a/src/GraphQL/Types/Input/ListingDataInputType.php +++ b/src/GraphQL/Types/Input/ListingDataInputType.php @@ -10,6 +10,7 @@ class ListingDataInputType extends InputType /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -21,6 +22,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/Input/OfferParamsInputType.php b/src/GraphQL/Types/Input/OfferParamsInputType.php index 89c075f..3a9299a 100644 --- a/src/GraphQL/Types/Input/OfferParamsInputType.php +++ b/src/GraphQL/Types/Input/OfferParamsInputType.php @@ -10,6 +10,7 @@ class OfferParamsInputType extends InputType /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -21,6 +22,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/MarketplaceBidType.php b/src/GraphQL/Types/MarketplaceBidType.php index 794f658..8541d20 100644 --- a/src/GraphQL/Types/MarketplaceBidType.php +++ b/src/GraphQL/Types/MarketplaceBidType.php @@ -12,6 +12,7 @@ class MarketplaceBidType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -23,6 +24,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/MarketplaceListingType.php b/src/GraphQL/Types/MarketplaceListingType.php index 2d76bb3..0734b29 100644 --- a/src/GraphQL/Types/MarketplaceListingType.php +++ b/src/GraphQL/Types/MarketplaceListingType.php @@ -16,6 +16,7 @@ class MarketplaceListingType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -27,6 +28,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/MarketplaceSaleType.php b/src/GraphQL/Types/MarketplaceSaleType.php index fea1374..566df5d 100644 --- a/src/GraphQL/Types/MarketplaceSaleType.php +++ b/src/GraphQL/Types/MarketplaceSaleType.php @@ -12,6 +12,7 @@ class MarketplaceSaleType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -23,6 +24,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/MarketplaceStateType.php b/src/GraphQL/Types/MarketplaceStateType.php index f3caa71..8a47657 100644 --- a/src/GraphQL/Types/MarketplaceStateType.php +++ b/src/GraphQL/Types/MarketplaceStateType.php @@ -12,6 +12,7 @@ class MarketplaceStateType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -23,6 +24,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/OfferDataType.php b/src/GraphQL/Types/OfferDataType.php index b5d0a5a..2568f5e 100644 --- a/src/GraphQL/Types/OfferDataType.php +++ b/src/GraphQL/Types/OfferDataType.php @@ -9,6 +9,7 @@ class OfferDataType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Types/OfferStateType.php b/src/GraphQL/Types/OfferStateType.php index 1d47a6e..6376121 100644 --- a/src/GraphQL/Types/OfferStateType.php +++ b/src/GraphQL/Types/OfferStateType.php @@ -9,6 +9,7 @@ class OfferStateType extends Type /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -20,6 +21,7 @@ public function attributes(): array /** * Get the type's fields. */ + #[\Override] public function fields(): array { return [ diff --git a/src/GraphQL/Unions/ListingDataUnion.php b/src/GraphQL/Unions/ListingDataUnion.php index c5a595d..b2c5829 100644 --- a/src/GraphQL/Unions/ListingDataUnion.php +++ b/src/GraphQL/Unions/ListingDataUnion.php @@ -13,6 +13,7 @@ class ListingDataUnion extends UnionType implements PlatformGraphQlUnion /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -24,6 +25,7 @@ public function attributes(): array /** * The possible types that this union can be. */ + #[\Override] public function types(): array { return [ diff --git a/src/GraphQL/Unions/ListingStateUnion.php b/src/GraphQL/Unions/ListingStateUnion.php index 67ca313..517ec6e 100644 --- a/src/GraphQL/Unions/ListingStateUnion.php +++ b/src/GraphQL/Unions/ListingStateUnion.php @@ -13,6 +13,7 @@ class ListingStateUnion extends UnionType implements PlatformGraphQlUnion /** * Get the type's attributes. */ + #[\Override] public function attributes(): array { return [ @@ -24,6 +25,7 @@ public function attributes(): array /** * The possible types that this union can be. */ + #[\Override] public function types(): array { return [ diff --git a/src/MarketplaceServiceProvider.php b/src/MarketplaceServiceProvider.php index f80bfd6..7490eb8 100644 --- a/src/MarketplaceServiceProvider.php +++ b/src/MarketplaceServiceProvider.php @@ -13,6 +13,7 @@ class MarketplaceServiceProvider extends PackageServiceProvider /** * Configure provider. */ + #[\Override] public function configurePackage(Package $package): void { $package @@ -34,6 +35,7 @@ public function configurePackage(Package $package): void * * @return void */ + #[\Override] public function register() { if (app()->runningUnitTests()) { @@ -50,12 +52,14 @@ public function register() * * @return void */ + #[\Override] public function boot() { parent::boot(); $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); } + #[\Override] public function packageRegistered() { $this->loadTranslationsFrom(__DIR__ . '/../lang', 'enjin-platform-marketplace'); diff --git a/src/Models/Laravel/MarketplaceBid.php b/src/Models/Laravel/MarketplaceBid.php index e5f4452..3fe300f 100644 --- a/src/Models/Laravel/MarketplaceBid.php +++ b/src/Models/Laravel/MarketplaceBid.php @@ -68,6 +68,7 @@ protected static function newFactory() return MarketplaceBidFactory::new(); } + #[\Override] protected function pivotIdentifier(): Attribute { return new Attribute( @@ -75,6 +76,7 @@ protected function pivotIdentifier(): Attribute ); } + #[\Override] protected function ownerId(): Attribute { return Attribute::make( diff --git a/src/Models/Laravel/MarketplaceListing.php b/src/Models/Laravel/MarketplaceListing.php index 2989299..d0564f7 100644 --- a/src/Models/Laravel/MarketplaceListing.php +++ b/src/Models/Laravel/MarketplaceListing.php @@ -116,6 +116,7 @@ protected static function newFactory() return MarketplaceListingFactory::new(); } + #[\Override] protected function pivotIdentifier(): Attribute { return new Attribute( @@ -123,6 +124,7 @@ protected function pivotIdentifier(): Attribute ); } + #[\Override] protected function ownerId(): Attribute { return Attribute::make( diff --git a/src/Models/Laravel/MarketplaceSale.php b/src/Models/Laravel/MarketplaceSale.php index 6a77bca..fe603e5 100644 --- a/src/Models/Laravel/MarketplaceSale.php +++ b/src/Models/Laravel/MarketplaceSale.php @@ -68,6 +68,7 @@ protected static function newFactory() return MarketplaceSaleFactory::new(); } + #[\Override] protected function pivotIdentifier(): Attribute { return new Attribute( @@ -75,6 +76,7 @@ protected function pivotIdentifier(): Attribute ); } + #[\Override] protected function ownerId(): Attribute { return Attribute::make( diff --git a/src/Package.php b/src/Package.php index 0173fa6..7f8713e 100644 --- a/src/Package.php +++ b/src/Package.php @@ -9,6 +9,7 @@ class Package extends CorePackage /** * Get any routes that have been set up for this package. */ + #[\Override] public static function getPackageRoutes(): array { return []; diff --git a/src/Rules/BidExists.php b/src/Rules/BidExists.php index 4056cf2..67ed3e9 100644 --- a/src/Rules/BidExists.php +++ b/src/Rules/BidExists.php @@ -13,6 +13,7 @@ class BidExists implements ValidationRule * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { if (!MarketplaceBid::where('id', $value)->exists()) { diff --git a/src/Rules/EnoughTokenSupply.php b/src/Rules/EnoughTokenSupply.php index 08c3e3d..ff7a619 100644 --- a/src/Rules/EnoughTokenSupply.php +++ b/src/Rules/EnoughTokenSupply.php @@ -28,6 +28,7 @@ class EnoughTokenSupply implements DataAwareRule, ValidationRule * @param array $data * @return $this */ + #[\Override] public function setData($data) { $this->data = $data; @@ -40,6 +41,7 @@ public function setData($data) * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { $collectionId = Arr::get($this->data, 'makeAssetId.collectionId'); diff --git a/src/Rules/FutureBlock.php b/src/Rules/FutureBlock.php index 956a0ea..7cf750c 100644 --- a/src/Rules/FutureBlock.php +++ b/src/Rules/FutureBlock.php @@ -14,6 +14,7 @@ class FutureBlock implements ValidationRule * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { $latestBlock = app()->runningUnitTests() diff --git a/src/Rules/ListingExists.php b/src/Rules/ListingExists.php index 0df1000..635c65e 100644 --- a/src/Rules/ListingExists.php +++ b/src/Rules/ListingExists.php @@ -15,6 +15,7 @@ public function __construct(protected string $column = 'listing_chain_id') {} * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { if (!MarketplaceListing::where($this->column, $value)->exists()) { diff --git a/src/Rules/ListingNotCancelled.php b/src/Rules/ListingNotCancelled.php index feeac10..c24667f 100644 --- a/src/Rules/ListingNotCancelled.php +++ b/src/Rules/ListingNotCancelled.php @@ -14,6 +14,7 @@ class ListingNotCancelled implements ValidationRule * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { if (!$listing = MarketplaceListing::where('listing_chain_id', $value)->with('state')->first()) { diff --git a/src/Rules/MinimumPrice.php b/src/Rules/MinimumPrice.php index 6b580c7..b6a7c1d 100644 --- a/src/Rules/MinimumPrice.php +++ b/src/Rules/MinimumPrice.php @@ -23,6 +23,7 @@ class MinimumPrice implements DataAwareRule, ValidationRule * @param array $data * @return $this */ + #[\Override] public function setData($data) { $this->data = $data; @@ -35,6 +36,7 @@ public function setData($data) * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { if ($listingId = Arr::get($this->data, 'listingId')) { diff --git a/src/Rules/SaleExists.php b/src/Rules/SaleExists.php index d0d9982..dfffa40 100644 --- a/src/Rules/SaleExists.php +++ b/src/Rules/SaleExists.php @@ -13,6 +13,7 @@ class SaleExists implements ValidationRule * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { if (!MarketplaceSale::where('id', $value)->exists()) { diff --git a/src/Rules/TokenExistsInCollection.php b/src/Rules/TokenExistsInCollection.php index 210496d..c0ce696 100644 --- a/src/Rules/TokenExistsInCollection.php +++ b/src/Rules/TokenExistsInCollection.php @@ -21,6 +21,7 @@ public function __construct(protected ?string $collectionId) {} * * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail */ + #[\Override] public function validate(string $attribute, mixed $value, Closure $fail): void { if (is_null($this->collectionId)) { diff --git a/src/Services/Processor/Substrate/Codec/Codec.php b/src/Services/Processor/Substrate/Codec/Codec.php index e77ddb0..60310bd 100644 --- a/src/Services/Processor/Substrate/Codec/Codec.php +++ b/src/Services/Processor/Substrate/Codec/Codec.php @@ -22,6 +22,7 @@ public function __construct() /** * Returns the marketplace encoder. */ + #[\Override] public function encoder(): MarketplaceEncoder { return $this->encoder; @@ -30,6 +31,7 @@ public function encoder(): MarketplaceEncoder /** * Returns the marketplace decoder. */ + #[\Override] public function decoder(): MarketplaceDecoder { return $this->decoder; diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/AuctionFinalized.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/AuctionFinalized.php index ff53414..0d0803b 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/AuctionFinalized.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/AuctionFinalized.php @@ -23,6 +23,7 @@ class AuctionFinalized extends MarketplaceSubstrateEvent /** * Handles the auction finalized event. */ + #[\Override] public function run(): void { try { @@ -62,6 +63,7 @@ public function run(): void } } + #[\Override] public function log(): void { Log::debug( @@ -74,6 +76,7 @@ public function log(): void } + #[\Override] public function broadcast(): void { AuctionFinalizedEvent::safeBroadcast( diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/BidPlaced.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/BidPlaced.php index 19faa6b..c418863 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/BidPlaced.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/BidPlaced.php @@ -21,6 +21,7 @@ class BidPlaced extends MarketplaceSubstrateEvent /** * Handles the bid placed event. */ + #[\Override] public function run(): void { try { @@ -53,6 +54,7 @@ public function run(): void } } + #[\Override] public function log(): void { Log::debug( @@ -64,6 +66,7 @@ public function log(): void ); } + #[\Override] public function broadcast(): void { BidPlacedEvent::safeBroadcast( diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCancelled.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCancelled.php index 320c7d0..5c390ba 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCancelled.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCancelled.php @@ -20,6 +20,7 @@ class ListingCancelled extends MarketplaceSubstrateEvent /** * Handles the listing cancelled event. */ + #[\Override] public function run(): void { try { @@ -50,6 +51,7 @@ public function run(): void } } + #[\Override] public function log(): void { Log::debug( @@ -60,6 +62,7 @@ public function log(): void ); } + #[\Override] public function broadcast(): void { ListingCancelledEvent::safeBroadcast( diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php index ed375ac..baca5fe 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingCreated.php @@ -25,6 +25,7 @@ class ListingCreated extends MarketplaceSubstrateEvent /** * Handles the listing created event. */ + #[\Override] public function run(): void { if (!$this->shouldSyncCollection(Arr::get($this->event->makeAssetId, 'collection_id')) @@ -72,6 +73,7 @@ public function run(): void ]; } + #[\Override] public function log(): void { Log::debug( @@ -82,6 +84,7 @@ public function log(): void ); } + #[\Override] public function broadcast(): void { ListingCreatedEvent::safeBroadcast( diff --git a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingFilled.php b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingFilled.php index aace29e..50dbc35 100644 --- a/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingFilled.php +++ b/src/Services/Processor/Substrate/Events/Implementations/Marketplace/ListingFilled.php @@ -19,6 +19,7 @@ class ListingFilled extends MarketplaceSubstrateEvent /** * Handles the listing filled event. */ + #[\Override] public function run(): void { try { @@ -51,6 +52,7 @@ public function run(): void } } + #[\Override] public function log(): void { Log::debug( @@ -63,6 +65,7 @@ public function log(): void ); } + #[\Override] public function broadcast(): void { ListingFilledEvent::safeBroadcast( diff --git a/tests/Feature/GraphQL/Mutations/CreateListingTest.php b/tests/Feature/GraphQL/Mutations/CreateListingTest.php index da8aad6..bcd6a01 100644 --- a/tests/Feature/GraphQL/Mutations/CreateListingTest.php +++ b/tests/Feature/GraphQL/Mutations/CreateListingTest.php @@ -27,6 +27,7 @@ class CreateListingTest extends TestCaseGraphQL /** * Setup test case. */ + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/GraphQL/TestCaseGraphQL.php b/tests/Feature/GraphQL/TestCaseGraphQL.php index 64914e7..14fb2fd 100644 --- a/tests/Feature/GraphQL/TestCaseGraphQL.php +++ b/tests/Feature/GraphQL/TestCaseGraphQL.php @@ -46,6 +46,7 @@ class TestCaseGraphQL extends BaseTestCase /** * Setup test case. */ + #[\Override] protected function setUp(): void { parent::setUp(); @@ -228,6 +229,7 @@ protected function loadQueries(): void * * @param mixed $app */ + #[\Override] protected function getPackageProviders($app): array { return [ @@ -241,6 +243,7 @@ protected function getPackageProviders($app): array * * @param mixed $app */ + #[\Override] protected function getPackageAliases($app): array { return []; @@ -251,6 +254,7 @@ protected function getPackageAliases($app): array * * @param mixed $app */ + #[\Override] protected function defineEnvironment($app): void { $app->useEnvironmentPath(__DIR__ . '/..'); diff --git a/tests/TestCase.php b/tests/TestCase.php index e2eb46d..9d78569 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -18,6 +18,7 @@ abstract class TestCase extends BaseTestCase /** * The package providers. */ + #[\Override] protected function getPackageProviders($app) { return [ @@ -29,6 +30,7 @@ protected function getPackageProviders($app) /** * Define environment. */ + #[\Override] protected function defineEnvironment($app) { // Make sure, our .env file is loaded for local tests diff --git a/tests/Unit/EncodingTest.php b/tests/Unit/EncodingTest.php index 5fa9c42..d2bebb0 100644 --- a/tests/Unit/EncodingTest.php +++ b/tests/Unit/EncodingTest.php @@ -17,6 +17,7 @@ class EncodingTest extends TestCase { protected Codec $codec; + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/Unit/MarketplaceServiceTest.php b/tests/Unit/MarketplaceServiceTest.php index 3cda294..564dbcb 100644 --- a/tests/Unit/MarketplaceServiceTest.php +++ b/tests/Unit/MarketplaceServiceTest.php @@ -11,6 +11,7 @@ class MarketplaceServiceTest extends TestCase { use CreateCollectionData; + #[\Override] protected function setUp(): void { parent::setUp();