From 53f94b2dcacd70d99fe4bc2b199c136a28ff9f7c Mon Sep 17 00:00:00 2001 From: Juan Patricio Marroquin Date: Thu, 5 Oct 2023 09:11:42 -0500 Subject: [PATCH 01/55] parent e50dae58558be5cf87b8b85cf32d5c47b2292ec5 author Juan Patricio Marroquin 1696515102 -0500 committer ItsANameToo 1696926888 +0200 refactor: use abortController for axios instead of axios-cancel (#186) --- package.json | 2 -- pnpm-lock.yaml | 58 +++++++------------------------------------- resources/js/app.tsx | 18 +++++++++----- 3 files changed, 21 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index d0c7b2dd9..1e0daea8e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^14.5.1", "@tippyjs/react": "^4.2.6", - "@types/axios-cancel": "^0.2.2", "@types/body-scroll-lock": "^3.1.0", "@types/file-saver": "^2.0.5", "@types/lodash": "^4.14.199", @@ -125,7 +124,6 @@ "@testing-library/jest-dom": "^6.1.3", "@types/string-hash": "^1.1.1", "assert": "^2.1.0", - "axios-cancel": "^0.2.2", "body-scroll-lock": "4.0.0-beta.0", "browser-fs-access": "^0.35.0", "chart.js": "^4.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c30843aa7..61e845c9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ dependencies: assert: specifier: ^2.1.0 version: 2.1.0 - axios-cancel: - specifier: ^0.2.2 - version: 0.2.2 body-scroll-lock: specifier: 4.0.0-beta.0 version: 4.0.0-beta.0 @@ -166,9 +163,6 @@ devDependencies: '@tippyjs/react': specifier: ^4.2.6 version: 4.2.6(react-dom@18.2.0)(react@18.2.0) - '@types/axios-cancel': - specifier: ^0.2.2 - version: 0.2.2 '@types/body-scroll-lock': specifier: ^3.1.0 version: 3.1.0 @@ -4978,14 +4972,6 @@ packages: resolution: {integrity: sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==} dev: true - /@types/axios-cancel@0.2.2: - resolution: {integrity: sha512-zuSzeBdYgfkyztlURbgDvFZtO9L7r0b8x+uUQJNR8Pa7PbZAirK+2aYBXOe/JamVrvOTw5/E6kOAZytNhw5XQw==} - dependencies: - axios: 0.15.2 - transitivePeerDependencies: - - supports-color - dev: true - /@types/babel__core@7.20.1: resolution: {integrity: sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==} dependencies: @@ -5031,7 +5017,7 @@ packages: resolution: {integrity: sha512-oyl4jvAfTGX9Bt6Or4H9ni1Z447/tQuxnZsytsCaExKlmJiU8sFgnIBRzJUpKwB5eWn9HuBYlUlVA74q/yN0eQ==} dependencies: '@types/connect': 3.4.36 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/body-scroll-lock@3.1.0: @@ -5061,7 +5047,7 @@ packages: /@types/connect@3.4.36: resolution: {integrity: sha512-P63Zd/JUGq+PdrM1lv0Wv5SBYeA2+CORvbrXbngriYY0jzLUWfQMQQxOhjONEz/wlHOAxOdY7CY65rgQdTjq2w==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/cookie@0.4.1: @@ -5071,7 +5057,7 @@ packages: /@types/cross-spawn@6.0.3: resolution: {integrity: sha512-BDAkU7WHHRHnvBf5z89lcvACsvkz/n7Tv+HyD/uW76O29HoH1Tk/W6iQrepaZVbisvlEek4ygwT8IW7ow9XLAA==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/debug@4.1.8: @@ -5136,7 +5122,7 @@ packages: /@types/express-serve-static-core@4.17.37: resolution: {integrity: sha512-ZohaCYTgGFcOP7u6aJOhY9uIZQgZ2vxC2yWoArY+FeDXlqeH66ZVBjgvg+RLVAS/DWNq4Ap9ZXu1+SUQiiWYMg==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 '@types/qs': 6.9.8 '@types/range-parser': 1.2.5 '@types/send': 0.17.2 @@ -5180,7 +5166,7 @@ packages: resolution: {integrity: sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==} dependencies: '@types/jsonfile': 6.1.2 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/glob@7.2.0: @@ -5242,7 +5228,7 @@ packages: /@types/jsonfile@6.1.2: resolution: {integrity: sha512-8t92P+oeW4d/CRQfJaSqEwXujrhH4OEeHRjGU3v1Q8mUS8GPF3yiX26sw4svv6faL2HfBtGTe2xWIoVgN3dy9w==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/lodash@4.14.199: @@ -5293,7 +5279,7 @@ packages: /@types/node-fetch@2.6.6: resolution: {integrity: sha512-95X8guJYhfqiuVVhRFxVQcf4hW/2bCuoPwDasMf/531STFoNoWTT7YDnWdXHEZKqAGUigmpG31r2FE70LwnzJw==} dependencies: - '@types/node': 18.17.19 + '@types/node': 18.18.3 form-data: 4.0.0 dev: true @@ -5384,7 +5370,7 @@ packages: resolution: {integrity: sha512-aAG6yRf6r0wQ29bkS+x97BIs64ZLxeE/ARwyS6wrldMm3C1MdKwCcnnEwMC1slI8wuxJOpiUH9MioC0A0i+GJw==} dependencies: '@types/mime': 1.3.3 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/serve-static@1.15.2: @@ -5399,7 +5385,7 @@ packages: dependencies: '@types/http-errors': 2.0.2 '@types/mime': 3.0.2 - '@types/node': 18.17.19 + '@types/node': 18.18.3 dev: true /@types/set-cookie-parser@2.4.3: @@ -6229,19 +6215,6 @@ packages: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} - /axios-cancel@0.2.2: - resolution: {integrity: sha512-YOArJ6aaK1c2W0uuxDSxTQbdNUwOpSNZeWM7u3K79tzfdzNicM5UzQ61zn1OolECU9fAd4A7fNV8hqnddK4Mdg==} - dev: false - - /axios@0.15.2: - resolution: {integrity: sha512-RCFd+A1fO/DVvW7NvbMN7qjADYnRMQAl/sEOARHPV7g+vxye4W3WOKQ5eVC2iuFB9H9Il6v9cSVRB0sqfFPUHw==} - deprecated: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410 - dependencies: - follow-redirects: 0.0.7 - transitivePeerDependencies: - - supports-color - dev: true - /axios@1.5.0: resolution: {integrity: sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==} dependencies: @@ -8301,15 +8274,6 @@ packages: engines: {node: '>=0.4.0'} dev: true - /follow-redirects@0.0.7: - resolution: {integrity: sha512-RxpX808lAA4IZ2cNqzRedcsPfVuo2AJEL8mmGvGeN0KGLJWZf5fidmUkcB0DWUCrmLD+GAQ0J2WOBORw8BS/Uw==} - dependencies: - debug: 2.6.9 - stream-consume: 0.1.1 - transitivePeerDependencies: - - supports-color - dev: true - /follow-redirects@1.15.2: resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} engines: {node: '>=4.0'} @@ -11762,10 +11726,6 @@ packages: - utf-8-validate dev: true - /stream-consume@0.1.1: - resolution: {integrity: sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg==} - dev: true - /stream-shift@1.0.1: resolution: {integrity: sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==} dev: true diff --git a/resources/js/app.tsx b/resources/js/app.tsx index 04e97537b..f88d160c2 100644 --- a/resources/js/app.tsx +++ b/resources/js/app.tsx @@ -6,7 +6,6 @@ import "../css/app.css"; import { createInertiaApp } from "@inertiajs/react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import axios, { type AxiosError } from "axios"; -import axiosCancel from "axios-cancel"; import { ArcElement, CategoryScale, @@ -20,7 +19,6 @@ import { Tooltip, } from "chart.js"; import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers"; -import get from "lodash/get"; import { createRoot } from "react-dom/client"; import { I18nextProvider } from "react-i18next"; import DarkModeContextProvider from "./Contexts/DarkModeContex"; @@ -34,16 +32,24 @@ import { i18n } from "@/I18n"; // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access (window as any).CookieConsent = CookieConsent; -// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any -axiosCancel(axios as any); +const abortController = new AbortController(); +const { signal } = abortController; + +axios.interceptors.request.use((config) => { + config.signal = signal; + return config; +}); axios.interceptors.response.use( (response) => response, async (error: AxiosError) => { - const status = get(error, "response.status"); + const { status } = error.response ?? {}; if (status === 419) { - await axios.get(route("refresh-csrf-token")); + abortController.abort(); + await axios.get(route("refresh-csrf-token"), { + signal, + }); if (error.response != null) { return await axios(error.response.config); From 9c50c93897c28e702ca7d9f917296b825606d9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Crnkovi=C4=87?= <6536260+crnkovic@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:53:52 +0200 Subject: [PATCH 02/55] refactor: use EXISTS instead of JOIN when checking for a collection's spam contract existence (#185) --- .../Commands/FetchCollectionBannerBatch.php | 4 ++-- app/Models/Collection.php | 17 +++++++++---- tests/App/Models/CollectionTest.php | 24 +++++++++++++------ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/Console/Commands/FetchCollectionBannerBatch.php b/app/Console/Commands/FetchCollectionBannerBatch.php index d5f346aee..2ac2990e1 100644 --- a/app/Console/Commands/FetchCollectionBannerBatch.php +++ b/app/Console/Commands/FetchCollectionBannerBatch.php @@ -41,8 +41,8 @@ public function handle(): int $networks->map(function ($network) { Collection::query() - ->select(['collections.id', 'collections.address']) - ->where('collections.network_id', '=', $network->id) + ->select('id', 'address') + ->where('network_id', $network->id) ->withoutSpamContracts() ->when($this->option('missing-only'), function (Builder $query) { $query->whereNull('extra_attributes->banner'); diff --git a/app/Models/Collection.php b/app/Models/Collection.php index d4971577b..30ad687bb 100644 --- a/app/Models/Collection.php +++ b/app/Models/Collection.php @@ -319,16 +319,25 @@ public function scopeWithUserNftsCount(Builder $query, User $user): Builder ]); } + /** + * @return HasOne + */ + public function spamContract(): HasOne + { + return $this->hasOne(SpamContract::class, 'address', 'address')->when( + $this->network_id !== null, fn ($query) => $query->where('network_id', $this->network_id) + ); + } + /** * @param Builder $query * @return Builder */ public function scopeWithoutSpamContracts(Builder $query): Builder { - return $query->leftJoin('spam_contracts', function ($join) { - $join->on('collections.network_id', '=', 'spam_contracts.network_id') - ->on('collections.address', '=', 'spam_contracts.address'); - })->whereNull('spam_contracts.address'); + return $query->whereDoesntHave('spamContract', function ($query) { + $query->whereColumn('collections.network_id', 'spam_contracts.network_id'); + }); } /** diff --git a/tests/App/Models/CollectionTest.php b/tests/App/Models/CollectionTest.php index b3a5fa341..b0950d6bf 100644 --- a/tests/App/Models/CollectionTest.php +++ b/tests/App/Models/CollectionTest.php @@ -1031,17 +1031,27 @@ it('should exclude spam contracts', function () { $network = Network::factory()->create(); - $collections = Collection::factory(2)->create(['network_id' => $network->id]); + [$collection, $other] = Collection::factory(2)->create([ + 'network_id' => $network->id, + ]); - SpamContract::query()->insert([ - 'address' => $collections->first()->address, - 'network_id' => $collections->first()->network_id, + $spamContract = SpamContract::create([ + 'address' => $collection->address, + 'network_id' => $collection->network_id, ]); - $validCollections = Collection::query()->withoutSpamContracts()->get(); + $otherSpamContract = SpamContract::create([ + 'address' => $other->address, + 'network_id' => Network::factory()->create()->id, + ]); - expect($validCollections->count())->toBe(1) - ->and($validCollections->first()->slug)->toBe($collections[1]->slug); + expect($collection->spamContract->is($spamContract))->toBeTrue(); + expect($other->spamContract)->toBeNull(); + + $collections = Collection::withoutSpamContracts()->get(); + + expect($collections->count())->toBe(1); + expect($collections->first()->slug)->toBe($other->slug); }); it('should exclude collections with an invalid supply', function () { From 6623d38c7b885131b0dcf4f3fe5142aa09da2e64 Mon Sep 17 00:00:00 2001 From: Patricio Marroquin <55117912+patricio0312rev@users.noreply.github.com> Date: Tue, 10 Oct 2023 03:55:12 -0500 Subject: [PATCH 03/55] fix: update overlay styles when switching address (#180) --- .../js/Components/Layout/LayoutWrapper.tsx | 18 +++++++++++------- .../js/Pages/Galleries/MyGalleries/Create.tsx | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/js/Components/Layout/LayoutWrapper.tsx b/resources/js/Components/Layout/LayoutWrapper.tsx index e4da704a5..e1ff31ff8 100644 --- a/resources/js/Components/Layout/LayoutWrapper.tsx +++ b/resources/js/Components/Layout/LayoutWrapper.tsx @@ -15,6 +15,7 @@ interface LayoutWrapperProperties extends HTMLAttributes { isMaintenanceModeActive?: boolean; belowHeader?: React.ReactNode; mustBeSigned?: boolean; + displayAuthOverlay?: boolean; showBackButton?: boolean; } @@ -27,6 +28,7 @@ export const LayoutWrapper = ({ toastMessage, isMaintenanceModeActive, mustBeSigned = false, + displayAuthOverlay = true, showBackButton = false, }: LayoutWrapperProperties): JSX.Element => { const { authenticated, showAuthOverlay, wallet, user, showCloseButton, closeOverlay } = useAuth({ @@ -52,13 +54,15 @@ export const LayoutWrapper = ({ /> - + {displayAuthOverlay && ( + + )} {belowHeader} diff --git a/resources/js/Pages/Galleries/MyGalleries/Create.tsx b/resources/js/Pages/Galleries/MyGalleries/Create.tsx index e32d9dbbe..0948b5614 100644 --- a/resources/js/Pages/Galleries/MyGalleries/Create.tsx +++ b/resources/js/Pages/Galleries/MyGalleries/Create.tsx @@ -14,6 +14,7 @@ import { GalleryNfts } from "@/Components/Galleries/Hooks/useGalleryNftsContext" import { NftGridEditable } from "@/Components/Galleries/NftGridEditable"; import { LayoutWrapper } from "@/Components/Layout/LayoutWrapper"; import { NoNftsOverlay } from "@/Components/Layout/NoNftsOverlay"; +import { useMetaMaskContext } from "@/Contexts/MetaMaskContext"; import { useAuthorizedAction } from "@/Hooks/useAuthorizedAction"; import { GalleryNameInput } from "@/Pages/Galleries/Components/GalleryNameInput"; import { useGalleryForm } from "@/Pages/Galleries/hooks/useGalleryForm"; @@ -46,6 +47,7 @@ const Create = ({ const { props } = usePage(); const { signedAction } = useAuthorizedAction(); + const { initialized } = useMetaMaskContext(); const [isGalleryFormSliderOpen, setIsGalleryFormSliderOpen] = useState(false); const [gallerySliderActiveTab, setGallerySliderActiveTab] = useState(); @@ -103,6 +105,7 @@ const Create = ({ withSlider toastMessage={props.toast} belowHeader={} + displayAuthOverlay={paginatedNfts.length > 0 && initialized} > From 7a9774431073672f4f84d267402fd0ddba689672 Mon Sep 17 00:00:00 2001 From: Patricio Marroquin <55117912+patricio0312rev@users.noreply.github.com> Date: Tue, 10 Oct 2023 03:55:59 -0500 Subject: [PATCH 04/55] fix: update nft pagination arguments in gallery overview page (#197) --- app/Data/Gallery/GalleryData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Data/Gallery/GalleryData.php b/app/Data/Gallery/GalleryData.php index 3c64181cb..9df52763a 100644 --- a/app/Data/Gallery/GalleryData.php +++ b/app/Data/Gallery/GalleryData.php @@ -63,7 +63,7 @@ public static function fromModel(Gallery $gallery, ?int $limit = 6): self value: $gallery->value($currency), coverImage: $gallery->cover_image, wallet: GalleryWalletData::fromModel($gallery->user->wallet), - nfts: new GalleryNftsData(GalleryNftData::collection($gallery->nfts()->orderByPivot('order_index', 'asc')->paginate($limit))), + nfts: new GalleryNftsData(GalleryNftData::collection($gallery->nfts()->orderByPivot('order_index', 'asc')->paginate($limit, ['*'], 'page', 1))), isOwner: $isOwner, hasLiked: $hasLiked, ); From 69c8bbff6c82c7033182d20d7bdfebdf88eb06fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Crnkovi=C4=87?= Date: Tue, 10 Oct 2023 11:02:34 +0200 Subject: [PATCH 05/55] refactor: remove unnecessary database queries from wallet data (#190) --- app/Data/Token/TokenData.php | 5 +-- app/Data/Wallet/WalletData.php | 41 ++++++------------- app/Data/Wallet/WalletNftData.php | 31 -------------- app/Support/Cache/UserCache.php | 6 +-- .../Tests/Factories/Wallet/WalletFactory.ts | 4 -- .../Factories/Wallet/WalletNftDataFactory.ts | 12 ------ resources/types/generated.d.ts | 7 ---- .../Middleware/HandleInertiaRequestsTest.php | 6 --- 8 files changed, 16 insertions(+), 96 deletions(-) delete mode 100644 app/Data/Wallet/WalletNftData.php delete mode 100644 resources/js/Tests/Factories/Wallet/WalletNftDataFactory.ts diff --git a/app/Data/Token/TokenData.php b/app/Data/Token/TokenData.php index 10b316fd4..fc8423301 100644 --- a/app/Data/Token/TokenData.php +++ b/app/Data/Token/TokenData.php @@ -50,10 +50,7 @@ public function __construct( public static function fromModel(Token $token): self { - $currency = CurrencyCode::USD; - if (Auth::hasUser()) { - $currency = Auth::user()->currency(); - } + $currency = Auth::user()?->currency() ?? CurrencyCode::USD; return new self( address: $token->address, diff --git a/app/Data/Wallet/WalletData.php b/app/Data/Wallet/WalletData.php index fde9da527..cbbb2c0d9 100644 --- a/app/Data/Wallet/WalletData.php +++ b/app/Data/Wallet/WalletData.php @@ -18,10 +18,7 @@ 'totalUsd' => 'number', 'totalBalanceInCurrency' => 'string', 'totalTokens' => 'number', - 'nfts' => 'WalletNftData[]', - 'nftCount' => 'number', 'collectionCount' => 'number', - 'collectionsValue' => 'number | null', 'galleryCount' => 'number', 'timestamps' => '{tokens_fetched_at: number|null, native_balances_fetched_at: number|null}', ])] @@ -35,16 +32,9 @@ public function __construct( public float $totalUsd, public string $totalBalanceInCurrency, public int $totalTokens, - /** - * @var WalletNftData[] - */ - public array $nfts, - public int $nftCount, public int $collectionCount, - public ?float $collectionsValue, public int $galleryCount, public int $userId, - public bool $isLocalTestingAddress, /** * @var array{tokens_fetched_at: int|null, native_balances_fetched_at: int|null} $timestamps @@ -55,28 +45,21 @@ public function __construct( public static function fromModel(Wallet $wallet): self { - $domain = $wallet->details?->domain; - $avatarData = WalletAvatarData::fromModel($wallet); $userCache = UserCache::from($wallet->user); - $user = $wallet->user; - return new self( - $wallet['id'], - $wallet['address'], - $domain, - $avatarData, - $wallet['total_usd'], - $wallet->totalBalanceInCurrency(), - $wallet->totalTokens(), - $userCache->userDetailNfts()->filter(fn ($nft) => ! is_null($nft->collection))->map(fn ($nft) => WalletNftData::fromModel($nft))->all(), - $userCache->nftsCount(), - $userCache->collectionsCount(), - $user->collectionsValue($user->currency()), - $userCache->galleriesCount(), - $user->id, - $wallet->isLocalTestingAddress(), - [ + id: $wallet->id, + address: $wallet->address, + domain: $wallet->details?->domain, + avatar: WalletAvatarData::fromModel($wallet), + totalUsd: $wallet->total_usd, + totalBalanceInCurrency: $wallet->totalBalanceInCurrency(), + totalTokens: $wallet->totalTokens(), + collectionCount: $userCache->collectionsCount(), + galleryCount: $userCache->galleriesCount(), + userId: $wallet->user_id, + isLocalTestingAddress: $wallet->isLocalTestingAddress(), + timestamps: [ 'tokens_fetched_at' => $wallet->tokensFetchedAt()?->getTimestampMs(), 'native_balances_fetched_at' => $wallet->nativeBalancesFetchedAt()?->getTimestampMs(), ] diff --git a/app/Data/Wallet/WalletNftData.php b/app/Data/Wallet/WalletNftData.php deleted file mode 100644 index cd62d08c2..000000000 --- a/app/Data/Wallet/WalletNftData.php +++ /dev/null @@ -1,31 +0,0 @@ -id, - images: ImagesData::from($nft->images()), - ); - } -} diff --git a/app/Support/Cache/UserCache.php b/app/Support/Cache/UserCache.php index a758f1118..7307ad9f5 100644 --- a/app/Support/Cache/UserCache.php +++ b/app/Support/Cache/UserCache.php @@ -91,7 +91,7 @@ private static function getShownNftsCountKey(int $userId): string public function collectionsCount(): int { return (int) $this->fromCache( - fn () => $this->user->nfts->unique('collection_id')->count(), + fn () => $this->user->nfts()->distinct('collection_id')->count(), self::getCollectionsCountKey($this->user->id), ); } @@ -99,7 +99,7 @@ public function collectionsCount(): int public function hiddenCollectionsCount(): int { return (int) $this->fromCache( - fn () => $this->user->nfts->unique('collection_id')->whereIn('collection_id', $this->user->hiddenCollections->modelKeys())->count(), + fn () => $this->user->nfts()->distinct('collection_id')->whereIn('collection_id', $this->user->hiddenCollections->modelKeys())->count(), self::getHiddenCollectionsCountKey($this->user->id), ); } @@ -107,7 +107,7 @@ public function hiddenCollectionsCount(): int public function shownCollectionsCount(): int { return (int) $this->fromCache( - fn () => $this->user->nfts->unique('collection_id')->whereNotIn('collection_id', $this->user->hiddenCollections->modelKeys())->count(), + fn () => $this->user->nfts()->distinct('collection_id')->whereNotIn('collection_id', $this->user->hiddenCollections->modelKeys())->count(), self::getShownCollectionsCountKey($this->user->id), ); } diff --git a/resources/js/Tests/Factories/Wallet/WalletFactory.ts b/resources/js/Tests/Factories/Wallet/WalletFactory.ts index 1982e235b..1c448ee57 100644 --- a/resources/js/Tests/Factories/Wallet/WalletFactory.ts +++ b/resources/js/Tests/Factories/Wallet/WalletFactory.ts @@ -1,6 +1,5 @@ import { faker } from "@faker-js/faker"; import WalletAvatarDataFactory from "./WalletAvatarDataFactory"; -import WalletNftDataFactory from "./WalletNftDataFactory"; import ModelFactory from "@/Tests/Factories/ModelFactory"; export default class WalletFactory extends ModelFactory { @@ -12,10 +11,7 @@ export default class WalletFactory extends ModelFactory { - protected factory(): App.Data.Wallet.WalletNftData { - return { - id: faker.datatype.number({ min: 1, max: 100000 }), - images: new ImagesDataFactory().create(), - }; - } -} diff --git a/resources/types/generated.d.ts b/resources/types/generated.d.ts index 38f1e624a..aeb77cc58 100644 --- a/resources/types/generated.d.ts +++ b/resources/types/generated.d.ts @@ -422,17 +422,10 @@ declare namespace App.Data.Wallet { totalUsd: number; totalBalanceInCurrency: string; totalTokens: number; - nfts: WalletNftData[]; - nftCount: number; collectionCount: number; - collectionsValue: number | null; galleryCount: number; timestamps: { tokens_fetched_at: number | null; native_balances_fetched_at: number | null }; }; - export type WalletNftData = { - id: number; - images: App.Data.ImagesData; - }; } declare namespace App.Data.Web3 { export type Web3ContractMetadata = { diff --git a/tests/App/Http/Middleware/HandleInertiaRequestsTest.php b/tests/App/Http/Middleware/HandleInertiaRequestsTest.php index f72ce5f61..f969b0e0d 100644 --- a/tests/App/Http/Middleware/HandleInertiaRequestsTest.php +++ b/tests/App/Http/Middleware/HandleInertiaRequestsTest.php @@ -53,10 +53,8 @@ $middlewareResponse = $middleware->share($request); - expect($middlewareResponse['auth']()->wallet->nftCount)->toBe(4); expect($middlewareResponse['auth']()->wallet->collectionCount)->toBe(1); expect($middlewareResponse['auth']()->wallet->galleryCount)->toBe(1); - expect(count($middlewareResponse['auth']()->wallet->nfts))->toBe(4); Nft::factory(4)->create([ 'wallet_id' => $wallet->id, @@ -71,10 +69,8 @@ $middlewareResponse = $middleware->share($request); - expect(($middlewareResponse['auth']())->wallet->nftCount)->toBe(4); expect($middlewareResponse['auth']()->wallet->collectionCount)->toBe(1); expect($middlewareResponse['auth']()->wallet->galleryCount)->toBe(1); - expect(count($middlewareResponse['auth']()->wallet->nfts))->toBe(4); $userCache->clearUserDetailNfts(); $userCache->clearNftsCount(); @@ -83,8 +79,6 @@ $middlewareResponse = $middleware->share($request); - expect($middlewareResponse['auth']()->wallet->nftCount)->toBe(8); expect($middlewareResponse['auth']()->wallet->collectionCount)->toBe(2); expect($middlewareResponse['auth']()->wallet->galleryCount)->toBe(2); - expect(count($middlewareResponse['auth']()->wallet->nfts))->toBe(4); }); From ade428d6f5eb7feadb351c368a8587c4fb9e36dd Mon Sep 17 00:00:00 2001 From: ItsANameToo <35610748+ItsANameToo@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:09:14 +0200 Subject: [PATCH 06/55] chore: use "password" password for filament in local env (#201) --- database/seeders/AdminUserSeeder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/seeders/AdminUserSeeder.php b/database/seeders/AdminUserSeeder.php index f58163f69..1b249743e 100644 --- a/database/seeders/AdminUserSeeder.php +++ b/database/seeders/AdminUserSeeder.php @@ -18,7 +18,7 @@ public function run(): void $users = array_keys(config('permission.user_role')); foreach ($users as $email) { - $password = Str::random(10); + $password = app()->isLocal() ? 'password' : Str::random(10); $this->command->info("Password for $email: $password"); From 03126c6f0a84ee4b5e53922fb45f845c11984530 Mon Sep 17 00:00:00 2001 From: Patricio Marroquin <55117912+patricio0312rev@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:27:23 -0500 Subject: [PATCH 07/55] feat: dark mode for error pages and filters (#199) --- resources/images/errors/401.svg | 2 +- resources/images/errors/403.svg | 2 +- resources/images/errors/404.svg | 2 +- resources/images/errors/419.svg | 2 +- resources/images/errors/429.svg | 2 +- resources/images/errors/500.svg | 2 +- resources/images/errors/503.svg | 2 +- resources/js/Components/Dropdown.tsx | 2 +- .../js/Components/ErrorBlock/ErrorBlock.blocks.tsx | 2 +- .../js/Components/Form/Listbox/Listbox.blocks.tsx | 8 ++++---- resources/js/Components/Popover.tsx | 6 +++++- .../CollectionsFilter/CollectionsFilterPopover.tsx | 6 +++--- .../CollectionsNetworksFilter.tsx | 14 +++++++------- .../CollectionsFilter/CollectionsSorting.tsx | 6 +++--- .../Components/GalleryListbox/GalleryListbox.tsx | 4 +++- .../Components/GalleryPage/GalleryPage.tsx | 2 +- tailwind.config.js | 1 + 17 files changed, 36 insertions(+), 29 deletions(-) diff --git a/resources/images/errors/401.svg b/resources/images/errors/401.svg index 11d044ace..06ecc42bd 100644 --- a/resources/images/errors/401.svg +++ b/resources/images/errors/401.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/errors/403.svg b/resources/images/errors/403.svg index 258d48bdb..005a5ff6f 100644 --- a/resources/images/errors/403.svg +++ b/resources/images/errors/403.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/errors/404.svg b/resources/images/errors/404.svg index be401f56b..3d5c2374e 100644 --- a/resources/images/errors/404.svg +++ b/resources/images/errors/404.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/errors/419.svg b/resources/images/errors/419.svg index 1eee6f315..0301ffaae 100644 --- a/resources/images/errors/419.svg +++ b/resources/images/errors/419.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/errors/429.svg b/resources/images/errors/429.svg index e841e50f8..144c9ec9c 100644 --- a/resources/images/errors/429.svg +++ b/resources/images/errors/429.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/errors/500.svg b/resources/images/errors/500.svg index 8b9c4de89..8f53e520a 100644 --- a/resources/images/errors/500.svg +++ b/resources/images/errors/500.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/images/errors/503.svg b/resources/images/errors/503.svg index b495f0137..68d1549ab 100644 --- a/resources/images/errors/503.svg +++ b/resources/images/errors/503.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/js/Components/Dropdown.tsx b/resources/js/Components/Dropdown.tsx index dbb11147f..d2384a3d6 100644 --- a/resources/js/Components/Dropdown.tsx +++ b/resources/js/Components/Dropdown.tsx @@ -225,7 +225,7 @@ const ContentWrapper = ({ children, withPortal }: { children: JSX.Element; withP const Content = ({ align = "left", className = "", - contentClasses = "ring-1 ring-black ring-opacity-5 py-1 bg-white", + contentClasses = "ring-1 ring-black ring-opacity-5 py-1 bg-white dark:bg-theme-dark-900", children, ...properties }: ContentProperties): JSX.Element => { diff --git a/resources/js/Components/ErrorBlock/ErrorBlock.blocks.tsx b/resources/js/Components/ErrorBlock/ErrorBlock.blocks.tsx index 55ac19c25..6e478a1b8 100644 --- a/resources/js/Components/ErrorBlock/ErrorBlock.blocks.tsx +++ b/resources/js/Components/ErrorBlock/ErrorBlock.blocks.tsx @@ -22,7 +22,7 @@ export const ErrorContent = ({ data-testid="ErrorContent" > {title} -

{description}

+

{description}

{showActionButtons && (
diff --git a/resources/js/Components/Form/Listbox/Listbox.blocks.tsx b/resources/js/Components/Form/Listbox/Listbox.blocks.tsx index a8455252a..f2cee273b 100644 --- a/resources/js/Components/Form/Listbox/Listbox.blocks.tsx +++ b/resources/js/Components/Form/Listbox/Listbox.blocks.tsx @@ -175,21 +175,21 @@ export const ListboxGradientButton = ({ children }: HTMLAttributes {({ open }) => (
- + {children} -
+