Skip to content

Commit

Permalink
[PLA-2033] Changes for v2.0.0 on marketplace (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Evans <v16Studios@users.noreply.github.com>
  • Loading branch information
leonardocustodio and v16Studios authored Oct 14, 2024
1 parent 68eb301 commit 6b70a7b
Show file tree
Hide file tree
Showing 80 changed files with 622 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.2]
php: [8.3]

name: PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.2]
php: [8.3]

name: PHP ${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"php": "^8.2|^8.3",
"php": "^8.3",
"ext-bcmath": "*",
"ext-json": "*",
"ext-openssl": "*",
Expand Down
6 changes: 4 additions & 2 deletions database/factories/MarketplaceListingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('marketplace_listings', function (Blueprint $table) {
$table->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']);
});
}
};
1 change: 1 addition & 0 deletions lang/en/mutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
8 changes: 8 additions & 0 deletions lang/en/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
];
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 2 additions & 0 deletions src/Enums/ListingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ enum ListingType: string

case FIXED_PRICE = 'FixedPrice';
case AUCTION = 'Auction';

case OFFER = 'Offer';
}
1 change: 1 addition & 0 deletions src/Exceptions/MarketplaceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MarketplaceException extends PlatformException
/**
* Get the exception's category.
*/
#[\Override]
public function getCategory(): string
{
return 'Platform Marketplace';
Expand Down
1 change: 1 addition & 0 deletions src/GraphQL/Enums/FeeSideEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FeeSideEnum extends EnumType implements PlatformGraphQlEnum
/**
* Get the enum's attributes.
*/
#[\Override]
public function attributes(): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions src/GraphQL/Enums/ListingStateEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ListingStateEnum extends EnumType implements PlatformGraphQlEnum
/**
* Get the enum's attributes.
*/
#[\Override]
public function attributes(): array
{
return [
Expand Down
1 change: 1 addition & 0 deletions src/GraphQL/Enums/ListingTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ListingTypeEnum extends EnumType implements PlatformGraphQlEnum
/**
* Get the enum's attributes.
*/
#[\Override]
public function attributes(): array
{
return [
Expand Down
4 changes: 4 additions & 0 deletions src/GraphQL/Mutations/CancelListingMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CancelListingMutation extends Mutation implements PlatformBlockchainTransa
/**
* Get the mutation's attributes.
*/
#[\Override]
public function attributes(): array
{
return [
Expand All @@ -44,6 +45,7 @@ public function attributes(): array
/**
* Get the mutation's return type.
*/
#[\Override]
public function type(): Type
{
return GraphQL::type('Transaction!');
Expand All @@ -52,6 +54,7 @@ public function type(): Type
/**
* Get the mutation's arguments definition.
*/
#[\Override]
public function args(): array
{
return [
Expand Down Expand Up @@ -84,6 +87,7 @@ public function resolve(
);
}

#[\Override]
public static function getEncodableParams(...$params): array
{
return [
Expand Down
Loading

0 comments on commit 6b70a7b

Please sign in to comment.