Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: disable signature requirement for refresh actions #314

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useState } from "react";
import { useTranslation } from "react-i18next";
import { IconButton } from "@/Components/Buttons";
import { Tooltip } from "@/Components/Tooltip";
import { useAuthorizedAction } from "@/Hooks/useAuthorizedAction";
import { useToasts } from "@/Hooks/useToasts";
import { isTruthy } from "@/Utils/is-truthy";

Expand All @@ -11,11 +10,10 @@ export const RefreshButton = ({ wallet }: { wallet: App.Data.Wallet.WalletData |
const [disabled, setDisabled] = useState(false);
const { t } = useTranslation();

const { signedAction } = useAuthorizedAction();
const { showToast } = useToasts();

const refresh = (): void => {
void signedAction(async () => {
void (async (): Promise<void> => {
crnkovic marked this conversation as resolved.
Show resolved Hide resolved
setLoading(true);

await window.axios.post(route("refresh-collections"));
Expand All @@ -28,7 +26,7 @@ export const RefreshButton = ({ wallet }: { wallet: App.Data.Wallet.WalletData |
message: t("pages.collections.refresh.toast"),
isExpanded: true,
});
});
})();
};

const tooltipContent = (): JSX.Element => {
Expand Down
6 changes: 2 additions & 4 deletions resources/js/Pages/Collections/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { CollectionHiddenModal } from "@/Components/Collections/CollectionHidden
import { EmptyBlock } from "@/Components/EmptyBlock/EmptyBlock";
import { SearchInput } from "@/Components/Form/SearchInput";
import { ExternalLinkContextProvider } from "@/Contexts/ExternalLinkContext";
import { useAuthorizedAction } from "@/Hooks/useAuthorizedAction";
import { useToasts } from "@/Hooks/useToasts";
import { useWalletActivity } from "@/Hooks/useWalletActivity";
import { DefaultLayout } from "@/Layouts/DefaultLayout";
Expand Down Expand Up @@ -84,7 +83,6 @@ const CollectionsView = ({

const [showCollectionFilterSlider, setShowCollectionFilterSlider] = useState(false);
const { requestActivityUpdate } = useWalletActivity();
const { signedAction } = useAuthorizedAction();

const { showToast } = useToasts();

Expand Down Expand Up @@ -266,7 +264,7 @@ const CollectionsView = ({
};

const handleRefreshActivity = (): void => {
void signedAction(async () => {
void (async (): Promise<void> => {
crnkovic marked this conversation as resolved.
Show resolved Hide resolved
setIsLoadingActivity(true);
requestActivityUpdate(collection.address);

Expand All @@ -280,7 +278,7 @@ const CollectionsView = ({
collection: collection.slug,
}),
);
});
})();
};

return (
Expand Down
4 changes: 1 addition & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
Route::get('/tokens/breakdown', [Controllers\TokenController::class, 'breakdown'])->name('tokens.breakdown');
Route::get('/tokens/search', [Controllers\TokenController::class, 'searchTokens'])->name('tokens.search');

Route::post('/refreshed-collections', [Controllers\RefreshedCollectionController::class, 'store'])
->name('refresh-collections')
->middleware('signed_wallet');
Route::post('/refreshed-collections', [Controllers\RefreshedCollectionController::class, 'store'])->name('refresh-collections');

Route::post('/transaction-success', Controllers\TransactionSuccessController::class)
->name('transaction-success');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Jobs\RefreshWalletCollections;
use App\Models\Nft;
use App\Support\Facades\Signature;
use Illuminate\Support\Facades\Bus;

it('can dispatch jobs to refresh all collections for a wallet', function () {
Expand All @@ -15,8 +14,6 @@
'onboarded_at' => now(),
]);

Signature::setWalletIsSigned($user->wallet->id);

Nft::factory()->for($user->wallet)->create();
Nft::factory()->for($user->wallet)->create();

Expand Down
Loading