* refactor(solana): remove support for solana * chore: update @thirdweb-dev/react and @thirdweb-dev/sdk versions * remove unused code & re-update-next-versions * refactor: Remove unused Solana currency metadata * fix build
45 lines
961 B
TypeScript
45 lines
961 B
TypeScript
import {
|
|
useIsAdmin,
|
|
useIsAdminOrSelf,
|
|
} from "@3rdweb-sdk/react/hooks/useContractRoles";
|
|
import { ValidContractInstance } from "@thirdweb-dev/sdk";
|
|
import { ComponentWithChildren } from "types/component-with-children";
|
|
|
|
interface AdminOnlyProps {
|
|
contract?: ValidContractInstance;
|
|
fallback?: JSX.Element;
|
|
}
|
|
|
|
export const AdminOnly: ComponentWithChildren<AdminOnlyProps> = ({
|
|
children,
|
|
contract,
|
|
fallback,
|
|
}) => {
|
|
const isAdmin = useIsAdmin(contract);
|
|
if (!isAdmin) {
|
|
return fallback ?? null;
|
|
}
|
|
return <>{children}</>;
|
|
};
|
|
|
|
interface AdminOrSelfOnlyProps extends AdminOnlyProps {
|
|
/**
|
|
* The address of the account to check against
|
|
*/
|
|
self: string;
|
|
}
|
|
|
|
export const AdminOrSelfOnly: ComponentWithChildren<AdminOrSelfOnlyProps> = ({
|
|
children,
|
|
self,
|
|
fallback,
|
|
contract,
|
|
}) => {
|
|
const isAdminOrSelf = useIsAdminOrSelf(contract, self);
|
|
|
|
if (!isAdminOrSelf) {
|
|
return fallback ?? null;
|
|
}
|
|
return <>{children}</>;
|
|
};
|