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

Uniswap trade as a standalone functionality #10396

Open
wants to merge 2 commits into
base: malik.10233.pinned-token-community-widget
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -27,7 +27,8 @@ const featureFlags = {
),
farcasterContest: buildFlag(process.env.FLAG_FARCASTER_CONTEST),
newEditor: buildFlag(process.env.FLAG_NEW_EDITOR),
tokenizedCommunity: buildFlag(process.env.FLAG_TOKENIZED_COMMUNITY),
launchpad: buildFlag(process.env.FLAG_LAUNCHPAD),
uniswapTrade: buildFlag(process.env.FLAG_UNISWAP_TRADE),
manageApiKeys: buildFlag(process.env.FLAG_MANAGE_API_KEYS),
referrals: buildFlag(process.env.FLAG_REFERRALS),
stickyEditor: buildFlag(process.env.FLAG_STICKY_EDITOR),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ const CommunityNotFoundPage = lazy(
() => import('views/pages/CommunityNotFoundPage'),
);

const CommonDomainRoutes = ({
tokenizedCommunityEnabled,
}: RouteFeatureFlags) => [
const CommonDomainRoutes = ({ launchpadEnabled }: RouteFeatureFlags) => [
<Route
key="/_internal/quill"
path="/_internal/quill"
Expand Down Expand Up @@ -154,7 +152,7 @@ const CommonDomainRoutes = ({
path="/createCommunity"
element={withLayout(CreateCommunityPage, { type: 'common' })}
/>,
...(tokenizedCommunityEnabled
...(launchpadEnabled
? [
<Route
key="/createTokenCommunity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ const NewProfilePage = lazy(() => import('views/pages/new_profile'));
const EditNewProfilePage = lazy(() => import('views/pages/edit_new_profile'));
const ProfilePageRedirect = lazy(() => import('views/pages/profile_redirect'));

const CustomDomainRoutes = ({
tokenizedCommunityEnabled,
}: RouteFeatureFlags) => {
const CustomDomainRoutes = ({ launchpadEnabled }: RouteFeatureFlags) => {
return [
<Route
key="/"
Expand All @@ -119,7 +117,7 @@ const CustomDomainRoutes = ({
path="/createCommunity"
element={withLayout(CreateCommunityPage, { type: 'common' })}
/>,
...(tokenizedCommunityEnabled
...(launchpadEnabled
? [
<Route
key="/createTokenCommunity"
Expand Down
9 changes: 3 additions & 6 deletions packages/commonwealth/client/scripts/navigation/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@ import CommonDomainRoutes from './CommonDomainRoutes';
import GeneralRoutes from './GeneralRoutes';

export type RouteFeatureFlags = {
tokenizedCommunityEnabled: boolean;
launchpadEnabled: boolean;
};

const Router = () => {
const client = OpenFeature.getClient();

const tokenizedCommunityEnabled = client.getBooleanValue(
'tokenizedCommunity',
false,
);
const launchpadEnabled = client.getBooleanValue('launchpadEnabled', false);

const flags = {
tokenizedCommunityEnabled,
launchpadEnabled,
};

const { isCustomDomain } = fetchCachedCustomDomain() || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CreateContentDrawer = ({ onClose }: CreateContentDrawerProps) => {
const user = useUserStore();
const scopedPage = app.activeChainId();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

const handleCreateThread = () => {
navigate('/new/discussion');
Expand Down Expand Up @@ -58,7 +58,7 @@ const CreateContentDrawer = ({ onClose }: CreateContentDrawerProps) => {
<CWIcon iconName="peopleNew" />
<CWText>Create community</CWText>
</div>
{tokenizedCommunityEnabled && (
{launchpadEnabled && (
<div className="item" onClick={handleCreateTokenCommunity}>
<CWIcon iconName="rocketLaunch" />
<CWText>Launch Token</CWText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ interface CommunitySectionProps {
}

export const CommunitySection = ({ showSkeleton }: CommunitySectionProps) => {
const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');
const uniswapTradeEnabled = useFlag('uniswapTrade');

const user = useUserStore();
const {
Expand Down Expand Up @@ -97,7 +98,7 @@ export const CommunitySection = ({ showSkeleton }: CommunitySectionProps) => {
</>
)}

{tokenizedCommunityEnabled && <TokenTradeWidget />}
{(launchpadEnabled || uniswapTradeEnabled) && <TokenTradeWidget />}

<CreateCommunityButton />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { LaunchpadToken } from 'views/modals/TradeTokenModel/CommonTradeModal/ty
import { ExternalToken } from 'views/modals/TradeTokenModel/UniswapTradeModal/types';

export const useTokenTradeWidget = () => {
const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');
const uniswapTradeEnabled = useFlag('uniswapTrade');
const [
generatedFallbackImageForPinnedToken,
setGeneratedFallbackImageForPinnedToken,
Expand All @@ -23,24 +24,23 @@ export const useTokenTradeWidget = () => {
useGetTokenByCommunityId({
community_id: communityId,
with_stats: true,
enabled: !!communityId && tokenizedCommunityEnabled,
enabled: !!communityId && launchpadEnabled,
});

const { data: communityPinnedTokens, isLoading: isLoadingPinnedToken } =
useGetPinnedTokenByCommunityId({
community_ids: [communityId],
with_chain_node: true,
with_price: true,
enabled: !!communityId && tokenizedCommunityEnabled,
enabled: !!communityId && uniswapTradeEnabled,
});
const communityPinnedToken = communityPinnedTokens?.[0];
const { data: tokenMetadata, isLoading: isLoadingTokenMetadata } =
useTokenMetadataQuery({
tokenId: communityPinnedToken?.contract_address || '',
nodeEthChainId: communityPinnedToken?.ChainNode?.eth_chain_id || 0,
apiEnabled:
!!(communityPinnedToken?.contract_address || '') &&
tokenizedCommunityEnabled,
!!(communityPinnedToken?.contract_address || '') && uniswapTradeEnabled,
});
const communityPinnedTokenWithMetadata =
communityPinnedToken && tokenMetadata
Expand All @@ -51,9 +51,10 @@ export const useTokenTradeWidget = () => {
: null;

const isLoadingToken =
isLoadingLaunchpadToken ||
(isLoadingPinnedToken && !communityLaunchpadToken) ||
(isLoadingTokenMetadata && communityPinnedToken);
(launchpadEnabled && isLoadingLaunchpadToken) ||
(uniswapTradeEnabled &&
((isLoadingPinnedToken && !communityLaunchpadToken) ||
(isLoadingTokenMetadata && communityPinnedToken)));

const communityToken: LaunchpadToken | ExternalToken | undefined =
communityLaunchpadToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const getCreateContentMenuItems = (
options?: NavigateOptions & { action?: string },
prefix?: null | string,
) => void,
tokenizedCommunityEnabled: boolean,
launchpadEnabled: boolean,
createDiscordBotConfig?: ReturnType<
typeof useCreateDiscordBotConfigMutation
>['mutateAsync'],
Expand Down Expand Up @@ -105,7 +105,7 @@ const getCreateContentMenuItems = (
navigate('/createCommunity', {}, null);
},
},
...(tokenizedCommunityEnabled
...(launchpadEnabled
? [
{
type: 'element',
Expand Down Expand Up @@ -202,7 +202,7 @@ export const CreateContentSidebar = ({
const { mutateAsync: createDiscordBotConfig } =
useCreateDiscordBotConfigMutation();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

return (
<CWSidebarMenu
Expand Down Expand Up @@ -230,7 +230,7 @@ export const CreateContentSidebar = ({
}}
menuItems={getCreateContentMenuItems(
navigate,
tokenizedCommunityEnabled,
launchpadEnabled,
createDiscordBotConfig,
)}
/>
Expand All @@ -242,7 +242,7 @@ export const CreateContentPopover = () => {
const navigate = useCommonNavigate();
const user = useUserStore();

const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

if (
!user.isLoggedIn ||
Expand All @@ -255,7 +255,7 @@ export const CreateContentPopover = () => {

return (
<PopoverMenu
menuItems={getCreateContentMenuItems(navigate, tokenizedCommunityEnabled)}
menuItems={getCreateContentMenuItems(navigate, launchpadEnabled)}
className="create-content-popover"
renderTrigger={(onClick, isMenuOpen) => (
<CWTooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ interface NewCommunityAdminModalProps {
handleClickConnectNewWallet: () => void;
handleClickContinue: (selectedAddress: string) => void;
selectedCommunity: SelectedCommunity;
isTokenizedCommunity?: boolean;
isLaunchpadCommunity?: boolean;
}

const NewCommunityAdminModal = ({
onModalClose,
handleClickConnectNewWallet,
handleClickContinue,
selectedCommunity,
isTokenizedCommunity,
isLaunchpadCommunity,
}: NewCommunityAdminModalProps) => {
const user = useUserStore();
const availableAddressesOnSelectedChain = user.addresses?.filter(
Expand Down Expand Up @@ -71,22 +71,22 @@ const NewCommunityAdminModal = ({
return (
<div className="NewCommunityAdminModal">
<CWModalHeader
label={`New ${isTokenizedCommunity ? 'token and' : ''} community admin`}
label={`New ${isLaunchpadCommunity ? 'token and' : ''} community admin`}
onModalClose={onModalClose}
/>
<CWModalBody>
<CWText type="b1" className="description">
{walletsAvailable
? `${isTokenizedCommunity ? 'Token creators and' : ''} Community admins are associated with a wallet. ` +
? `${isLaunchpadCommunity ? 'Token creators and' : ''} Community admins are associated with a wallet. ` +
`Which wallet would you like to serve as the ${
isTokenizedCommunity ? 'author/' : ''
isLaunchpadCommunity ? 'author/' : ''
}admin of the new community?`
: `In order to launch a ${
isTokenizedCommunity ? 'token and' : ''
isLaunchpadCommunity ? 'token and' : ''
} community within ${
isTokenizedCommunity ? 'the BASE' : 'an'
isLaunchpadCommunity ? 'the BASE' : 'an'
} ecosystem you must have a compatible wallet connected. ` +
`How would you like to create your ${isTokenizedCommunity ? 'token and' : ''} community?`}
`How would you like to create your ${isLaunchpadCommunity ? 'token and' : ''} community?`}
</CWText>
{walletsAvailable && (
<CWSelectList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ExtendedCommunitySliceType = [

const CommunitiesPage = () => {
const containerRef = useRef();
const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

const {
setModeOfManageCommunityStakeModal,
Expand Down Expand Up @@ -226,9 +226,9 @@ const CommunitiesPage = () => {
<div className="description">
<CWText
type="h1"
{...(tokenizedCommunityEnabled && { fontWeight: 'semiBold' })}
{...(launchpadEnabled && { fontWeight: 'semiBold' })}
>
Explore {tokenizedCommunityEnabled ? '' : 'Communities'}
Explore {launchpadEnabled ? '' : 'Communities'}
</CWText>
{isWindowSmallInclusive ? communitiesCount : <></>}
<div className="actions">
Expand Down Expand Up @@ -324,7 +324,7 @@ const CommunitiesPage = () => {
</div>
<TokensList filters={filters} />
<ExploreContestList />
{tokenizedCommunityEnabled && <CWText type="h2">Communities</CWText>}
{launchpadEnabled && <CWText type="h2">Communities</CWText>}
{isLoading && communitiesList.length === 0 ? (
<CWCircleMultiplySpinner />
) : (
Expand Down Expand Up @@ -390,7 +390,7 @@ const CommunitiesPage = () => {
EmptyPlaceholder: () => (
<section
className={clsx('empty-placeholder', {
'my-16': tokenizedCommunityEnabled,
'my-16': launchpadEnabled,
})}
>
<CWText type="h2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const FiltersDrawer = ({
onFiltersChange,
}: FiltersDrawerProps) => {
const { data: tags } = useFetchTagsQuery();
const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

const onStakeFilterChange = () => {
onFiltersChange({
Expand Down Expand Up @@ -137,7 +137,7 @@ export const FiltersDrawer = ({
/>
</div>

{tokenizedCommunityEnabled && (
{launchpadEnabled && (
<>
<CWAccordion
header="Sort By"
Expand Down Expand Up @@ -247,7 +247,7 @@ export const FiltersDrawer = ({
}
/>
))}
{tokenizedCommunityEnabled &&
{launchpadEnabled &&
Object.keys(communityChains).map((chain) => (
<CWRadioButton
key={chain}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TokenLaunchDrawer from './TokenLaunchDrawer';
const IdeaLaunchpad = () => {
const user = useUserStore();
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

const [initialIdeaPrompt, setInitialIdeaPrompt] = useState<string>();
const [shouldGenerateIdeaOnDrawerOpen, setShouldGenerateIdeaOnDrawerOpen] =
Expand All @@ -29,7 +29,7 @@ const IdeaLaunchpad = () => {
}
};

if (!tokenizedCommunityEnabled) return <></>;
if (!launchpadEnabled) return <></>;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type TokensListProps = {
const TokensList = ({ filters }: TokensListProps) => {
const user = useUserStore();
const navigate = useCommonNavigate();
const tokenizedCommunityEnabled = useFlag('tokenizedCommunity');
const launchpadEnabled = useFlag('launchpad');

const [tokenLaunchModalConfig, setTokenLaunchModalConfig] = useState<{
isOpen: boolean;
Expand Down Expand Up @@ -75,7 +75,7 @@ const TokensList = ({ filters }: TokensListProps) => {

return undefined;
})(),
enabled: tokenizedCommunityEnabled,
enabled: launchpadEnabled,
});
const tokens = (tokensList?.pages || []).flatMap((page) => page.results);

Expand Down Expand Up @@ -115,7 +115,7 @@ const TokensList = ({ filters }: TokensListProps) => {
});
};

if (!tokenizedCommunityEnabled) return <></>;
if (!launchpadEnabled) return <></>;

return (
<div className="TokensList">
Expand All @@ -125,7 +125,7 @@ const TokensList = ({ filters }: TokensListProps) => {
) : tokens.length === 0 ? (
<div
className={clsx('empty-placeholder', {
'my-16': tokenizedCommunityEnabled,
'my-16': launchpadEnabled,
})}
>
<CWText type="h2">
Expand Down
Loading