Skip to content
Merged
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
27 changes: 12 additions & 15 deletions src/apps/pillarx-app/api/homeFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@ import { addMiddleware } from '../../../store';
import { ApiResponse, WalletData } from '../../../types/api';

// utils
import { CompatibleChains } from '../../../utils/blockchain';
import { CompatibleChains, isTestnet } from '../../../utils/blockchain';

const chainIds =
process.env.REACT_APP_USE_TESTNETS === 'true'
? [11155111]
: CompatibleChains.map((chain) => chain.chainId);
const chainIds = isTestnet
? [11155111]
: CompatibleChains.map((chain) => chain.chainId);

const chainIdsQuery = chainIds.map((id) => `chainIds=${id}`).join('&');

export const homeFeedApi = createApi({
reducerPath: 'homeFeedApi',
baseQuery: fetchBaseQuery({
baseUrl:
process.env.REACT_APP_USE_TESTNETS === 'true'
? 'https://feed-nubpgwxpiq-uc.a.run.app'
: 'https://feed-7eu4izffpa-uc.a.run.app',
baseUrl: isTestnet
? 'https://feed-nubpgwxpiq-uc.a.run.app'
: 'https://feed-7eu4izffpa-uc.a.run.app',
}),
endpoints: (builder) => ({
getTilesInfo: builder.query<ApiResponse, { page: number; address: string }>(
{
query: ({ page, address }) =>
`?page=${page}&address=${address}&${chainIdsQuery}&testnets=${process.env.REACT_APP_USE_TESTNETS || 'true'}`,
`?page=${page}&address=${address}&${chainIdsQuery}&testnets=${String(isTestnet)}`,
}
),
}),
Expand All @@ -38,10 +36,9 @@ export const homeFeedApi = createApi({
// maxRetries: 5 is the default, and can be omitted. Shown for documentation purposes.
const staggeredBaseQuery = retry(
fetchBaseQuery({
baseUrl:
process.env.REACT_APP_USE_TESTNETS === 'true'
? 'https://walletportfolio-nubpgwxpiq-uc.a.run.app'
: 'https://walletportfolio-7eu4izffpa-uc.a.run.app',
baseUrl: isTestnet
? 'https://walletportfolio-nubpgwxpiq-uc.a.run.app'
: 'https://walletportfolio-7eu4izffpa-uc.a.run.app',
}),
{
maxRetries: 5,
Expand All @@ -54,7 +51,7 @@ export const walletPortfolioTileApi = createApi({
endpoints: (builder) => ({
getWalletInfo: builder.query<WalletData, { address: string }>({
query: ({ address }) =>
`?address=${address}&${chainIdsQuery}&testnets=${process.env.REACT_APP_USE_TESTNETS || 'true'}`,
`?address=${address}&${chainIdsQuery}&testnets=${String(isTestnet)}`,
}),
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,69 +23,67 @@ exports[`<DisplayCollectionImage /> renders correctly and matches snapshot witho
data-testid="random-avatar"
fill="none"
role="img"
viewBox="0 0 80 80"
viewBox="0 0 36 36"
xmlns="http://www.w3.org/2000/svg"
>
<mask
height={80}
height={36}
id=":r0:"
maskUnits="userSpaceOnUse"
width={80}
width={36}
x={0}
y={0}
>
<rect
fill="#FFFFFF"
height={80}
width={80}
height={36}
width={36}
/>
</mask>
<g
mask="url(#:r0:)"
>
<path
d="M0 0h80v40H0z"
fill="url(#gradient_paint0_linear_image-name)"
<rect
fill="#92A1C6"
height={36}
width={36}
/>
<path
d="M0 40h80v40H0z"
fill="url(#gradient_paint1_linear_image-name)"
<rect
fill="#F0AB3D"
height={36}
rx={36}
transform="translate(-3 7) rotate(307 18 18) scale(1.1)"
width={36}
x="0"
y="0"
/>
</g>
<defs>
<linearGradient
gradientUnits="userSpaceOnUse"
id="gradient_paint0_linear_image-name"
x1={40}
x2={40}
y1={0}
y2={40}
<g
transform="translate(-3 3.5) rotate(-7 18 18)"
>
<stop
stopColor="#F0AB3D"
<path
d="M13,20 a1,0.75 0 0,0 10,0"
fill="#000000"
/>
<stop
offset={1}
stopColor="#C271B4"
<rect
fill="#000000"
height={2}
rx={1}
stroke="none"
width={1.5}
x={12}
y={14}
/>
</linearGradient>
<linearGradient
gradientUnits="userSpaceOnUse"
id="gradient_paint1_linear_image-name"
x1={40}
x2={40}
y1={40}
y2={80}
>
<stop
stopColor="#C20D90"
/>
<stop
offset={1}
stopColor="#92A1C6"
<rect
fill="#000000"
height={2}
rx={1}
stroke="none"
width={1.5}
x={22}
y={14}
/>
</linearGradient>
</defs>
</g>
</g>
</svg>
</div>
`;
97 changes: 96 additions & 1 deletion src/apps/pillarx-app/components/PillarXLogo/PillarXLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,105 @@
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
import { useEffect, useState } from 'react';

// images
import CloseIcon from '../../images/add.png';

// components
import { isTestnet } from '../../../../utils/blockchain';
import Body from '../Typography/Body';
import BodySmall from '../Typography/BodySmall';

type PillarXLogoProps = {
src: string;
className?: string;
};

export const PillarXLogo = ({ src, className }: PillarXLogoProps) => {
return <img src={src} alt="pillar-x-logo" className={`w-min ${className}`} />;
const [clickCount, setClickCount] = useState(0);
const [isModalOpen, setIsModalOpen] = useState(false);
const [timer, setTimer] = useState<NodeJS.Timeout | null>(null);
const [isTestnetSwitch, setIsTestnetSwitch] = useState<string>(
String(isTestnet)
);

const handleLogoClick = () => {
if (clickCount === 0) {
const newTimer = setTimeout(() => {
setClickCount(0);
}, 4000);
setTimer(newTimer);
}

setClickCount((prevCount) => prevCount + 1);

if (clickCount + 1 === 7) {
setIsModalOpen(true);
setClickCount(0);
if (timer) clearTimeout(timer);
}
};

const closeModal = () => {
setIsModalOpen(false);
};

useEffect(() => {
localStorage.setItem('isTestnet', isTestnetSwitch);
}, [isTestnetSwitch]);

const handleToggle = () => {
setIsTestnetSwitch((prevState) => {
const newState = prevState === 'true' ? 'false' : 'true';
setTimeout(() => {
window.location.reload();
}, 500);
return newState;
});
};

return (
<>
<img
src={src}
alt="pillar-x-logo"
className={`w-min ${className}`}
onClick={handleLogoClick}
/>
{isModalOpen && (
<div className="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50">
<div className="flex flex-col items-center gap-6 bg-container_grey rounded-lg p-8 w-full max-w-md desktop:mx-12 tablet:mx-12 mobile:mx-6">
<img
src={CloseIcon}
alt="close-modal-button"
className="fixed top-0 right-0 w-[40px] h-[40px] mt-6 mr-4 mb-20 desktop:mr-14 desktop:mb-28"
onClick={closeModal}
/>
<Body>Switch network</Body>
<div className="flex w-full gap-4 items-center justify-center">
<BodySmall>Mainnet</BodySmall>
<div
onClick={handleToggle}
className={`relative inline-flex w-8 h-[18px] rounded-[20px] p-0.5 cursor-pointer transition-colors duration-300 ${
isTestnetSwitch === 'true'
? 'bg-purple_medium'
: 'bg-[#5F5C6E]'
}`}
>
<span
className={`absolute top-[2px] bottom-0 h-3.5 w-3.5 rounded-full bg-white shadow-md transform transition-transform duration-300 ${
isTestnetSwitch === 'true'
? 'translate-x-3.5'
: 'translate-x-0'
}`}
/>
</div>
<BodySmall>Testnet</BodySmall>
</div>
</div>
</div>
)}
</>
);
};

export default PillarXLogo;
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ exports[`<PillarXLogo /> renders correctly and matches snapshot 1`] = `
<img
alt="pillar-x-logo"
className="w-min undefined"
onClick={[Function]}
src="https://example.com/logo.png"
/>,
<img
alt="pillar-x-logo"
className="w-min custom-class"
onClick={[Function]}
src="https://example.com/logo.png"
/>,
]
Expand Down
Binary file added src/apps/pillarx-app/images/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 20 additions & 27 deletions src/apps/token-atlas/api/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ import {
} from '../../../types/api';

// utils
import { CompatibleChains } from '../../../utils/blockchain';
import { CompatibleChains, isTestnet } from '../../../utils/blockchain';

const chainIds =
process.env.REACT_APP_USE_TESTNETS === 'true'
? [11155111]
: CompatibleChains.map((chain) => chain.chainId);
const chainIds = isTestnet
? [11155111]
: CompatibleChains.map((chain) => chain.chainId);
const chainIdsQuery = chainIds.map((id) => `chainIds=${id}`).join('&');

export const tokenInfoApi = createApi({
reducerPath: 'tokenInfoApi',
baseQuery: fetchBaseQuery({
baseUrl:
process.env.REACT_APP_USE_TESTNETS === 'true'
? 'https://token-nubpgwxpiq-uc.a.run.app'
: 'https://token-7eu4izffpa-uc.a.run.app',
baseUrl: isTestnet
? 'https://token-nubpgwxpiq-uc.a.run.app'
: 'https://token-7eu4izffpa-uc.a.run.app',
}),
endpoints: (builder) => ({
getTokenInfo: builder.query<
Expand All @@ -36,7 +34,7 @@ export const tokenInfoApi = createApi({
query: ({ asset, blockchain, symbol }) => {
const blockchainParam =
blockchain !== undefined ? `&blockchain=${blockchain}` : '';
return `?asset=${asset}&symbol=${symbol}${blockchainParam}&${chainIdsQuery}&testnets=${process.env.REACT_APP_USE_TESTNETS || 'true'}`;
return `?asset=${asset}&symbol=${symbol}${blockchainParam}&${chainIdsQuery}&testnets=${String(isTestnet)}`;
},
}),
}),
Expand All @@ -45,10 +43,9 @@ export const tokenInfoApi = createApi({
export const tokenGraphApi = createApi({
reducerPath: 'tokenGraphApi',
baseQuery: fetchBaseQuery({
baseUrl:
process.env.REACT_APP_USE_TESTNETS === 'true'
? 'https://tokenpricehistory-nubpgwxpiq-uc.a.run.app'
: 'https://tokenpricehistory-7eu4izffpa-uc.a.run.app',
baseUrl: isTestnet
? 'https://tokenpricehistory-nubpgwxpiq-uc.a.run.app'
: 'https://tokenpricehistory-7eu4izffpa-uc.a.run.app',
}),
endpoints: (builder) => ({
getTokenGraph: builder.query<
Expand All @@ -60,7 +57,7 @@ export const tokenGraphApi = createApi({
const blockchainParam =
blockchain !== undefined ? `&blockchain=${blockchain}` : '';
const assetParam = asset.split(' ')[0];
return `?asset=${assetParam}&from=${from * 1000}${toParam}${blockchainParam}&${chainIdsQuery}&testnets=${process.env.REACT_APP_USE_TESTNETS || 'true'}`;
return `?asset=${assetParam}&from=${from * 1000}${toParam}${blockchainParam}&${chainIdsQuery}&testnets=${String(isTestnet)}`;
},
}),
}),
Expand All @@ -69,31 +66,27 @@ export const tokenGraphApi = createApi({
export const trendingTokensApi = createApi({
reducerPath: 'trendingTokensApi',
baseQuery: fetchBaseQuery({
baseUrl:
process.env.REACT_APP_USE_TESTNETS === 'true'
? 'https://trendingtokens-nubpgwxpiq-uc.a.run.app'
: 'https://trendingtokens-7eu4izffpa-uc.a.run.app',
baseUrl: isTestnet
? 'https://trendingtokens-nubpgwxpiq-uc.a.run.app'
: 'https://trendingtokens-7eu4izffpa-uc.a.run.app',
}),
endpoints: (builder) => ({
getTrendingTokens: builder.query<TrendingTokens, void>({
query: () =>
`?${chainIdsQuery}&testnets=${process.env.REACT_APP_USE_TESTNETS || 'true'}`,
query: () => `?${chainIdsQuery}&testnets=${String(isTestnet)}`,
}),
}),
});

export const blockchainsListApi = createApi({
reducerPath: 'blockchainsListApi',
baseQuery: fetchBaseQuery({
baseUrl:
process.env.REACT_APP_USE_TESTNETS === 'true'
? 'https://blockchains-nubpgwxpiq-uc.a.run.app'
: 'https://blockchains-7eu4izffpa-uc.a.run.app',
baseUrl: isTestnet
? 'https://blockchains-nubpgwxpiq-uc.a.run.app'
: 'https://blockchains-7eu4izffpa-uc.a.run.app',
}),
endpoints: (builder) => ({
getBlockchainsList: builder.query<BlockchainList, void>({
query: () =>
`?${chainIdsQuery}&testnets=${process.env.REACT_APP_USE_TESTNETS || 'true'}`,
query: () => `?${chainIdsQuery}&testnets=${String(isTestnet)}`,
}),
}),
});
Expand Down
Loading