Skip to content

Commit b08bf3f

Browse files
authored
Refactor: Centralize URLs in a constant file (#574)
* fix: add url constant file * refactor: align url to constant file * fix: update url constant file * refactor: align url to constant file * fix: update indexer urls * chore: remove unused URLs * fix: replace toke logo by coinmarket cap * fix: remove unused * fix: remove unused * fix: replace toke logo by coinmarket cap * refactor: align url to constant file * fix: remove unused new url * fix: remove encoded from param to avoid misleading values * fix: remove void and added underscore to param * refactor: align urls to use backslash to no replace
1 parent 65dd2c9 commit b08bf3f

27 files changed

Lines changed: 276 additions & 124 deletions

File tree

‎packages/vechain-kit/src/assets/icons/BetterSwapLogo/BetterSwapLogo.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ export const BetterSwapLogo = ({ boxSize = '24px', ...props }: { boxSize?: strin
2323
</svg>
2424
);
2525
};
26-

‎packages/vechain-kit/src/assets/icons/PrivyLogo/PrivyLogo.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Image, ImageProps } from '@chakra-ui/react';
22
import React from 'react';
3+
import { PRIVY_MINTLIFY_ASSETS_S3_BASE_URL } from '@/constants';
34

45
type Props = {
56
isDark?: boolean;
@@ -10,8 +11,14 @@ export const PrivyLogo: React.FC<Props> = ({ isDark = false, ...props }) => {
1011
<Image
1112
src={
1213
isDark
13-
? 'https://mintlify.s3.us-west-1.amazonaws.com/privy-c2af3412/logo/privy-logo-dark.png'
14-
: 'https://mintlify.s3.us-west-1.amazonaws.com/privy-c2af3412/logo/privy-logo-light.png'
14+
? new URL(
15+
'/privy-c2af3412/logo/privy-logo-dark.png',
16+
PRIVY_MINTLIFY_ASSETS_S3_BASE_URL,
17+
).toString()
18+
: new URL(
19+
'/privy-c2af3412/logo/privy-logo-light.png',
20+
PRIVY_MINTLIFY_ASSETS_S3_BASE_URL,
21+
).toString()
1522
}
1623
alt="Privy Logo"
1724
{...props}

‎packages/vechain-kit/src/components/AccountModal/Components/CrossAppConnectionSecurityCard.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { LuExternalLink, LuUserCog, LuShieldCheck } from 'react-icons/lu';
1515
import { useTranslation } from 'react-i18next';
1616
import { useCrossAppConnectionCache } from '@/hooks';
17+
import { VEBETTERDAO_GOVERNANCE_BASE_URL } from '@/constants';
1718

1819
export const CrossAppConnectionSecurityCard = () => {
1920
const { t } = useTranslation();
@@ -112,7 +113,7 @@ export const CrossAppConnectionSecurityCard = () => {
112113
onClick={() => {
113114
window.open(
114115
connectionCache?.ecosystemApp.website ??
115-
'https://governance.vebetterdao.org/',
116+
VEBETTERDAO_GOVERNANCE_BASE_URL,
116117
'_blank',
117118
);
118119
}}

‎packages/vechain-kit/src/components/AccountModal/Contents/Bridge/BridgeContent.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { useTranslation } from 'react-i18next';
1616
import { useVeChainKitConfig } from '@/providers';
1717
import { VechainEnergy } from '@/assets';
1818
import { useAccountModalOptions } from '@/hooks/modals/useAccountModalOptions';
19+
import { VECHAIN_ENERGY_SWAP_BASE_URL } from '@/constants';
1920

2021
type Props = {
2122
setCurrentContent: React.Dispatch<
@@ -29,7 +30,7 @@ export const BridgeContent = ({ setCurrentContent }: Props) => {
2930
const { isolatedView } = useAccountModalOptions();
3031

3132
const handleLaunchVeChainEnergy = () => {
32-
window.open('https://swap.vechain.energy/', '_blank');
33+
window.open(VECHAIN_ENERGY_SWAP_BASE_URL, '_blank');
3334
};
3435

3536
return (

‎packages/vechain-kit/src/components/AccountModal/Contents/Ecosystem/ExploreEcosystemContent.tsx‎

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ import {
3636
} from './Components/CategoryFilterSection';
3737
import { AllowedCategories } from './Components/CategoryLabel';
3838
import { useAccountModalOptions } from '@/hooks/modals/useAccountModalOptions';
39+
import {
40+
VEBETTERDAO_GOVERNANCE_BASE_URL,
41+
VET_DOMAINS_BASE_URL,
42+
COINMARKETCAP_STATIC_BASE_URL,
43+
} from '@/constants';
3944

4045
export type EcosystemWithCategoryProps = {
4146
selectedCategory: CategoryFilter;
@@ -56,48 +61,52 @@ const DEFAULT_APPS: XAppMetadata[] = [
5661
{
5762
name: 'VeBetterDAO',
5863
description: 'Engage, earn and prosper by doing sustainable actions.',
59-
external_url: 'https://governance.vebetterdao.org/',
60-
logo: 'https://i.ibb.co/cgJBj83/vbd.png',
61-
banner: 'https://i.ibb.co/cgJBj83/vbd.png',
64+
external_url: VEBETTERDAO_GOVERNANCE_BASE_URL,
65+
logo: new URL(
66+
'/static/img/coins/64x64/33509.png',
67+
COINMARKETCAP_STATIC_BASE_URL,
68+
).toString(),
69+
banner: new URL(
70+
'/static/img/icons/vbd.png',
71+
COINMARKETCAP_STATIC_BASE_URL,
72+
).toString(),
6273
screenshots: [],
6374
social_urls: [],
6475
app_urls: [],
6576
tweets: [],
6677
ve_world: {
67-
banner: 'https://i.ibb.co/cgJBj83/vbd.png',
78+
banner: new URL(
79+
'/static/img/icons/vbd.png',
80+
COINMARKETCAP_STATIC_BASE_URL,
81+
).toString(),
6882
},
6983
categories: [],
7084
},
7185
{
7286
name: 'vet.domains',
7387
description:
7488
'.vet.domains provides a unique and unchangeable identity for Vechain users by linking information to their wallet addresses. It becomes easier for people to use the blockchain by replacing complicated wallet addresses with easy-to-remember names.',
75-
external_url: 'https://vet.domains',
76-
logo: 'https://vet.domains/assets/walletconnect.png',
77-
banner: 'https://vet.domains/assets/walletconnect.png',
89+
external_url: VET_DOMAINS_BASE_URL,
90+
logo: new URL(
91+
'/assets/walletconnect.png',
92+
VET_DOMAINS_BASE_URL,
93+
).toString(),
94+
banner: new URL(
95+
'/assets/walletconnect.png',
96+
VET_DOMAINS_BASE_URL,
97+
).toString(),
7898
screenshots: [],
7999
social_urls: [],
80100
app_urls: [],
81101
tweets: [],
82102
ve_world: {
83-
banner: 'https://vet.domains/assets/walletconnect.png',
103+
banner: new URL(
104+
'/assets/walletconnect.png',
105+
VET_DOMAINS_BASE_URL,
106+
).toString(),
84107
},
85108
categories: [],
86109
},
87-
// {
88-
// name: 'VeChain Kit',
89-
// description: 'A all-in-one library for building VeChain applications.',
90-
// external_url: 'https://vechainkit.vechain.org/',
91-
// logo: 'https://vechain.org/wp-content/uploads/2025/02/VeChain_Icon_Quartz_300ppi.png',
92-
// banner: '',
93-
// screenshots: [],
94-
// social_urls: [],
95-
// app_urls: [],
96-
// tweets: [],
97-
// ve_world: {
98-
// banner: '',
99-
// },
100-
// },
101110
];
102111

103112
export const ExploreEcosystemContent = ({

‎packages/vechain-kit/src/components/AccountModal/Contents/FAQ/FAQContent.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { FAQAccordion } from './FAQAccordion';
2020
import { useTranslation } from 'react-i18next';
2121
import { supportedLanguages, languageNames } from '../../../../../i18n';
2222
import { useAccountModalOptions } from '@/hooks/modals/useAccountModalOptions';
23+
import { VECHAIN_KIT_DOCS_BASE_URL } from '@/constants';
2324

2425
export type FAQContentProps = {
2526
onGoBack: () => void;
@@ -79,7 +80,7 @@ export const FAQContent = ({
7980

8081
<Button
8182
as={Link}
82-
href="https://docs.vechainkit.vechain.org/"
83+
href={VECHAIN_KIT_DOCS_BASE_URL}
8384
isExternal
8485
variant="vechainKitSecondary"
8586
rightIcon={<Icon as={LuExternalLink} />}

‎packages/vechain-kit/src/components/AccountModal/Contents/SuccessfulOperation/SuccessfulOperationContent.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ export const SuccessfulOperationContent = ({
8181
>
8282
{t('Share on')}
8383
</Text>
84-
<ShareButtons
85-
descriptionEncoded={socialDescription}
86-
/>
84+
<ShareButtons description={socialDescription} />
8785
</VStack>
8886
)}
8987
</VStack>

‎packages/vechain-kit/src/components/TransactionModal/Components/ShareButtons.tsx‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import { FaTelegramPlane, FaWhatsapp } from 'react-icons/fa';
44
import { FaXTwitter } from 'react-icons/fa6';
55
import React from 'react';
66
import { useVeChainKitConfig } from '@/providers';
7-
8-
const TWITTER_INJECT = 'https://twitter.com/intent/tweet?text=';
9-
10-
const WHATSAPP_INJECT = 'https://wa.me/?text=';
11-
12-
const TELEGRAM_INJECT = 'https://telegram.me/share/url?url=';
7+
import { TELEGRAM_BASE_URL, TWITTER_BASE_URL, WHATSAPP_BASE_URL } from '@/constants';
138

149
// bouncing circle button animation provider
1510
const BouncingAnimation = ({ children }: { children: React.ReactNode }) => (
@@ -32,21 +27,28 @@ const BouncingAnimation = ({ children }: { children: React.ReactNode }) => (
3227
);
3328

3429
type Props = {
35-
descriptionEncoded: string;
30+
description: string;
3631
url?: string;
3732
facebookHashtag?: string;
3833
};
3934

40-
export const ShareButtons = ({ descriptionEncoded }: Props) => {
35+
export const ShareButtons = ({ description }: Props) => {
4136
const { darkMode: isDark } = useVeChainKitConfig();
4237

38+
// `description` is treated as raw text; use URLSearchParams so values are encoded.
39+
const twitterUrl = new URL('intent/tweet', TWITTER_BASE_URL);
40+
twitterUrl.searchParams.set('text', description);
41+
42+
const telegramUrl = new URL('share/url', TELEGRAM_BASE_URL);
43+
telegramUrl.searchParams.set('url', description);
44+
45+
const whatsappUrl = new URL('', WHATSAPP_BASE_URL);
46+
whatsappUrl.searchParams.set('text', description);
47+
4348
return (
4449
<HStack gap={2}>
4550
<BouncingAnimation>
46-
<Link
47-
href={`${TWITTER_INJECT}${descriptionEncoded}`}
48-
isExternal
49-
>
51+
<Link href={twitterUrl.toString()} isExternal>
5052
<Box
5153
bg={isDark ? 'blackAlpha.700' : 'lightgrey'}
5254
p={2}
@@ -57,20 +59,14 @@ export const ShareButtons = ({ descriptionEncoded }: Props) => {
5759
</Link>
5860
</BouncingAnimation>
5961
<BouncingAnimation>
60-
<Link
61-
href={`${TELEGRAM_INJECT}${descriptionEncoded}`}
62-
isExternal
63-
>
62+
<Link href={telegramUrl.toString()} isExternal>
6463
<Box bg={'#30abec'} p={2} borderRadius={'full'}>
6564
<FaTelegramPlane color="white" size={22} />
6665
</Box>
6766
</Link>
6867
</BouncingAnimation>
6968
<BouncingAnimation>
70-
<Link
71-
href={`${WHATSAPP_INJECT}${descriptionEncoded}`}
72-
isExternal
73-
>
69+
<Link href={whatsappUrl.toString()} isExternal>
7470
<Box bg={'#01cb37'} p={2} borderRadius={'full'}>
7571
<FaWhatsapp size={22} color="white" />
7672
</Box>

‎packages/vechain-kit/src/components/TransactionModal/TransactionModalContent.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ export const TransactionModalContent = ({
156156
>
157157
{t('Share on')}
158158
</Text>
159-
<ShareButtons
160-
descriptionEncoded={socialDescription}
161-
/>
159+
<ShareButtons description={socialDescription} />
162160
</VStack>
163161
)}
164162

‎packages/vechain-kit/src/components/UpgradeSmartAccountModal/Contents/SuccessfulOperationContent.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ export const SuccessfulOperationContent = ({
8080
{showSocialButtons && txId && (
8181
<VStack mt={2}>
8282
<Text fontSize="xs">{t('Share on')}</Text>
83-
<ShareButtons
84-
descriptionEncoded={socialDescription}
85-
/>
83+
<ShareButtons description={socialDescription} />
8684
</VStack>
8785
)}
8886
</VStack>

0 commit comments

Comments
 (0)