Skip to content

Commit

Permalink
chore: merge rc into main (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsANameToo authored Oct 12, 2023
2 parents b495aad + 26b0bb1 commit edd3376
Show file tree
Hide file tree
Showing 197 changed files with 6,088 additions and 3,003 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ ALCHEMY_MAX_REQUESTS_SECONDS=60
SLACK_REPORTS_WEBHOOK_URL=
SLACK_REPORTS_ENABLED=false

SLACK_GALLERY_LOGS_WEBHOOK_URL=
SLACK_GALLERY_LOGS_ENABLED=false

VITE_TRANSACTION_HISTORY_POLLING_FREQUENCY=2000

# Max supply cap for FetchCollectionNft job
Expand Down
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ module.exports = {
"sonarjs/cognitive-complexity": "error",
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-collapsible-if": "error",
"sonarjs/no-duplicate-string": ["error", 5],
"sonarjs/no-identical-expressions": "error",
"sonarjs/no-identical-functions": "error",
"sonarjs/no-redundant-jump": "error",
Expand Down
3 changes: 2 additions & 1 deletion app/Console/Commands/FetchCollectionNfts.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function handle(): int
if (! $collection->isBlacklisted()) {
FetchCollectionNftsJob::dispatch(
$collection,
$this->option('start-token') ?? $collection->last_indexed_token_number
$this->option('start-token') ?? $collection->last_indexed_token_number,
skipIfPotentiallyFull: true,
);
}
},
Expand Down
6 changes: 3 additions & 3 deletions app/Data/Collections/CollectionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App\Data\Collections;

use App\Data\Collections\Concerns\QueriesCollectionNfts;
use App\Models\Collection;
use App\Transformers\IpfsGatewayUrlTransformer;
use Spatie\LaravelData\Attributes\WithTransformer;
Expand All @@ -15,8 +14,6 @@
#[TypeScript]
class CollectionData extends Data
{
use QueriesCollectionNfts;

public function __construct(
public int $id,
public string $name,
Expand All @@ -31,6 +28,7 @@ public function __construct(
#[WithTransformer(IpfsGatewayUrlTransformer::class)]
public ?string $image,
public ?string $banner,
public ?string $openSeaSlug,
public string $website,
public int $nftsCount,
) {
Expand All @@ -56,6 +54,7 @@ public static function fromModel(Collection $collection): self
* floor_price_decimals: int | null,
* image: string | null,
* banner: string | null,
* opensea_slug: string | null,
* website: string,
* nfts_count: int,
* } $collection
Expand All @@ -72,6 +71,7 @@ public static function fromModel(Collection $collection): self
floorPriceDecimals: $collection->floor_price_decimals,
image: $collection->image,
banner: $collection->banner,
openSeaSlug: $collection->opensea_slug,
website: $collection->website,
nftsCount: $collection->nfts_count,
);
Expand Down
12 changes: 3 additions & 9 deletions app/Data/Collections/CollectionDetailData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App\Data\Collections;

use App\Data\Collections\Concerns\QueriesCollectionNfts;
use App\Enums\CurrencyCode;
use App\Models\Collection;
use App\Models\User;
Expand All @@ -18,8 +17,6 @@
#[TypeScript]
class CollectionDetailData extends Data
{
use QueriesCollectionNfts;

public function __construct(
public string $name,
public string $slug,
Expand All @@ -35,6 +32,7 @@ public function __construct(
public ?string $image,
public ?string $banner,
public ?string $bannerUpdatedAt,
public ?string $openSeaSlug,
public ?string $website,
public ?string $twitter,
public ?string $discord,
Expand All @@ -43,13 +41,11 @@ public function __construct(
public ?int $owners,
public int $nftsCount,
public ?int $mintedAt,
public CollectionNftsData $nfts,
) {
}

public static function fromModel(Collection $collection, CurrencyCode $currencyCode = null, User $user = null): self
{
$nftsQuery = self::getCollectionNftsQuery($collection, $user);
$symbol = $collection->floorPriceToken?->symbol;

return new self(
Expand All @@ -65,17 +61,15 @@ public static function fromModel(Collection $collection, CurrencyCode $currencyC
image: $collection->extra_attributes->get('image'),
banner: $collection->extra_attributes->get('banner'),
bannerUpdatedAt: $collection->extra_attributes->get('banner_updated_at'),
openSeaSlug: $collection->extra_attributes->get('opensea_slug'),
website: $collection->website(defaultToExplorer: false),
twitter: $collection->twitter(),
discord: $collection->discord(),
supply: $collection->supply,
volume: $collection->volume,
owners: $collection->owners,
nftsCount: $nftsQuery->count(),
nftsCount: $collection->nfts()->when($user !== null, fn ($q) => $q->ownedBy($user))->count(),
mintedAt: $collection->minted_at?->getTimestampMs(),
nfts: new CollectionNftsData(
CollectionNftData::collection($user ? $nftsQuery->get() : [])
),
);
}
}
23 changes: 0 additions & 23 deletions app/Data/Collections/CollectionNftsData.php

This file was deleted.

28 changes: 0 additions & 28 deletions app/Data/Collections/Concerns/QueriesCollectionNfts.php

This file was deleted.

2 changes: 2 additions & 0 deletions app/Data/Gallery/GalleryCollectionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function __construct(
public ?string $image,
public ?string $banner,
public ?string $bannerUpdatedAt,
public ?string $openSeaSlug,
public ?string $website,
public ?int $nftsCount,
) {
Expand All @@ -52,6 +53,7 @@ public static function fromModel(Collection $collection, CurrencyCode $currencyC
image: $collection->extra_attributes->get('image'),
banner: $collection->extra_attributes->get('banner'),
bannerUpdatedAt: $collection->extra_attributes->get('banner_updated_at'),
openSeaSlug: $collection->extra_attributes->get('opensea_slug'),
website: $collection->website(),
nftsCount: $collection->nfts_count ?? null,
);
Expand Down
4 changes: 3 additions & 1 deletion app/Data/Gallery/GalleryNftData.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public function __construct(
public ?int $floorPriceDecimals,
public ?DateTime $lastActivityFetchedAt,
public ?DateTime $lastViewedAt,
public bool $ownedByCurrentUser = false,
) {
}

public static function fromModel(Nft $nft): self
public static function fromModel(Nft $nft, bool $ownedByCurrentUser = false): self
{
/** @var Collection $collection */
$collection = $nft->collection;
Expand All @@ -59,6 +60,7 @@ public static function fromModel(Nft $nft): self
floorPriceDecimals: $collection->floorPriceToken?->decimals,
lastActivityFetchedAt: $nft->last_activity_fetched_at,
lastViewedAt: $nft->last_viewed_at,
ownedByCurrentUser: $ownedByCurrentUser,
);
}
}
56 changes: 56 additions & 0 deletions app/Data/Network/NetworkWithCollectionsData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace App\Data\Network;

use App\Models\Network;
use App\Models\User;
use Illuminate\Support\Collection;
use Spatie\LaravelData\Data;
use Spatie\TypeScriptTransformer\Attributes\LiteralTypeScriptType;
use Spatie\TypeScriptTransformer\Attributes\TypeScript;

#[TypeScript]
class NetworkWithCollectionsData extends Data
{
public function __construct(
public int $id,
public string $name,
public bool $isMainnet,
#[LiteralTypeScriptType('App.Enums.Chains')]
public int $chainId,
public string $publicRpcProvider,
public string $explorerUrl,
public int $collectionsCount,
) {
}

/**
* @return Collection<int, NetworkWithCollectionsData>
*/
public static function fromModel(User $user, bool $showHidden)
{
$networks = Network::onlyActive()->get();

return $networks->map(function ($network) use ($user, $showHidden) {
$collectionCount = $user->collections()
->where('network_id', $network->id)
->where(
fn ($q) => $showHidden
? $q->whereIn('collections.id', $user->hiddenCollections->modelKeys())
: $q->whereNotIn('collections.id', $user->hiddenCollections->modelKeys())
)->count();

return new NetworkWithCollectionsData(
$network->id,
$network->name,
$network->is_mainnet,
$network->chain_id,
$network->public_rpc_provider,
$network->explorer_url,
$collectionCount
);
});
}
}
2 changes: 2 additions & 0 deletions app/Data/Nfts/NftCollectionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
public string $website,
#[WithTransformer(IpfsGatewayUrlTransformer::class)]
public ?string $image,
public ?string $openSeaSlug,
) {
}

Expand All @@ -40,6 +41,7 @@ public static function fromModel(Collection $collection, CurrencyCode $currencyC
floorPrice: $collection->floor_price,
website: $collection->website(),
image: $collection->extra_attributes->get('image'),
openSeaSlug: $collection->extra_attributes->get('opensea_slug'),
);
}
}
1 change: 0 additions & 1 deletion app/Data/TokenListItemData.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function __construct(
}

/**
* @param int $currentPage
* @param Collection<int, int> $chainIds
* @return PaginatedDataCollection<int, TokenListItemData>
*/
Expand Down
Loading

0 comments on commit edd3376

Please sign in to comment.