Skip to content

Commit

Permalink
Merge pull request #1638 from bancorprotocol/issue-#1637
Browse files Browse the repository at this point in the history
Hide terms & privacy if not carbon
  • Loading branch information
GrandSchtroumpf authored Jan 30, 2025
2 parents 07f0b53 + 9897b5f commit 4748c6f
Show file tree
Hide file tree
Showing 25 changed files with 170 additions and 38 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ where `spread` (fee tier in the UI) is in percentage, and `value` is the number

## Change Network

1. Create a new folder under `src/config` with the name of the network (ex: "polygon")
2. Copy and paste the files from `src/config/ethereum` into your folder
1. Create a new folder under [`src/config`](src/config) with the name of the network (ex: "polygon")
2. Copy and paste the files from [`src/config/demo`](src/config/demo) into your folder
3. Update the `common.ts`, `production.ts` & `development.ts` files with your config, pointing to the CarbonDeFi contracts in that network, as well as setting the rpc.url and rpc.headers (rpc.url must match the one found in [Chain Lists](https://chainlist.org/)).
4. Update the `src/config/index.ts` files to import your files
4. Update the [`src/config/index.ts`](src/config/index.ts) files to import your files
`index.ts`

As an example on adding Polygon network:
Expand Down Expand Up @@ -272,6 +272,8 @@ The file `common.ts` with type [`AppConfig`](src/config/types.ts) contains impor
- `useGradientBranding`: Flag to enable gradient styles for buttons.
- `tradeCount`: Display the amount of trades in the explorer page.
- `currencyMenu`: Display the currency menu to switch between currencies.
- `showTerms`: Display the terms page & links. ⚠️ If you set it to true, you need to change the content of the page ⚠️
- `showPrivacy`: Display the privacy page & links. ⚠️ If you set it to true, you need to change the content of the page ⚠️

#### Gas token different than native token

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,57 +53,62 @@ export const useBurgerMenuItems = () => {
</NewTabLink>
),
},
{
];
if (config.ui.showTerms) {
mainItems.push({
content: (
<Link className="flex" to="/terms">
Terms of Use
</Link>
),
},
{
});
}
if (config.ui.showPrivacy) {
mainItems.push({
content: (
<Link className="flex" to="/privacy">
Privacy Policy
</Link>
),
},
{
content: (
<div className="flex w-full items-center justify-between">
<NewTabLink
to={externalLinks.x}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconX className={iconStyles} />
</NewTabLink>
<NewTabLink
to={externalLinks.youtube}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconYoutube className={iconStyles} />
</NewTabLink>
<NewTabLink
to={externalLinks.discord}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconDiscord className={iconStyles} />
</NewTabLink>
<NewTabLink
to={externalLinks.telegram}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconTelegram className={iconStyles} />
</NewTabLink>
</div>
),
},
];
});
}
mainItems.push({
content: (
<div className="flex w-full items-center justify-between">
<NewTabLink
to={externalLinks.x}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconX className={iconStyles} />
</NewTabLink>
<NewTabLink
to={externalLinks.youtube}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconYoutube className={iconStyles} />
</NewTabLink>
<NewTabLink
to={externalLinks.discord}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconDiscord className={iconStyles} />
</NewTabLink>
<NewTabLink
to={externalLinks.telegram}
className="rounded-6 p-6 md:hover:bg-black"
>
<IconTelegram className={iconStyles} />
</NewTabLink>
</div>
),
});
if (config.ui.currencyMenu) {
mainItems.unshift({
subMenu: 'currency',
content: <CurrencyMenuItemContent />,
});
}

menuMap.set('main', { items: mainItems });

const currencyItems = useMemo(
Expand Down
2 changes: 2 additions & 0 deletions src/config/blast/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,7 @@ export const commonConfig: AppConfig = {
useGradientBranding: true,
tradeCount: false,
currencyMenu: false,
showTerms: false,
showPrivacy: false,
},
};
2 changes: 2 additions & 0 deletions src/config/celo/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ export const commonConfig: AppConfig = {
useGradientBranding: true,
tradeCount: true,
currencyMenu: false,
showTerms: true,
showPrivacy: true,
},
};
2 changes: 2 additions & 0 deletions src/config/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@ export const AppConfigSchema = v.object({
useGradientBranding: v.optional(v.boolean()),
tradeCount: v.optional(v.boolean()),
currencyMenu: v.optional(v.boolean()),
showTerms: v.optional(v.boolean()),
showPrivacy: v.optional(v.boolean()),
}),
});
96 changes: 96 additions & 0 deletions src/config/demo/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { AppConfig } from 'config/types';

const addresses = {
ZERO: '0x0000000000000000000000000000000000000000',
};

export const commonConfig: AppConfig = {
hidden: true,
mode: 'development',
appName: '',
appUrl: '',
carbonApi: '',
selectedConnectors: ['MetaMask'],
blockedConnectors: [],
walletConnectProjectId: '',
isSimulatorEnabled: false,
policiesLastUpdated: '',
network: {
name: 'Demo Network',
logoUrl: '',
chainId: 0,
blockExplorer: {
name: '',
url: '',
},
rpc: {
url: import.meta.env.VITE_CHAIN_RPC_URL,
},
defaultLimitedApproval: true,
gasToken: {
name: '',
symbol: '',
decimals: 18,
address: '',
logoURI: '',
},
},
sdk: {
cacheTTL: 0,
},
defaultTokenPair: ['', ''],
popularPairs: [],
popularTokens: {
base: [],
quote: [],
},
addresses: {
tokens: addresses,
carbon: {
carbonController: '',
voucher: '',
},
},
utils: {
multicall3: {
address: '0x...',
blockCreated: 0,
},
},
tokenListOverride: [],
tokenLists: [],
tenderly: {
nativeTokenDonorAccount: '',
faucetAmount: 1000,
faucetTokens: [
{
donorAccount: '',
tokenContract: '',
decimals: 18,
symbol: '',
},
{
donorAccount: '',
tokenContract: '',
decimals: 6,
symbol: '',
},
{
donorAccount: '',
tokenContract: '',
decimals: 6,
symbol: '',
},
],
},
ui: {
priceChart: 'tradingView',
useGradientBranding: false,
tradeCount: false,
currencyMenu: false,
/* ⚠️ If you set it to true, you need to change the content of the page 'src/pages/terms/index.tsx' ⚠️ */
showTerms: false,
/* ⚠️ If you set it to true, you need to change the content of the page 'src/pages/privacy/index.tsx' ⚠️ */
showPrivacy: false,
},
};
8 changes: 8 additions & 0 deletions src/config/demo/development.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AppConfig } from '../types';
import { commonConfig } from './common';

const config: AppConfig = {
...commonConfig,
mode: 'development',
};
export default config;
9 changes: 9 additions & 0 deletions src/config/demo/production.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AppConfig } from '../types';
import { commonConfig } from './common';

const config: AppConfig = {
...commonConfig,
mode: 'production',
sentryDSN: '',
};
export default config;
2 changes: 2 additions & 0 deletions src/config/ethereum/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,7 @@ export const commonConfig: AppConfig = {
useGradientBranding: true,
tradeCount: false,
currencyMenu: true,
showTerms: true,
showPrivacy: true,
},
};
2 changes: 2 additions & 0 deletions src/config/sei/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ export const commonConfig: AppConfig = {
useGradientBranding: true,
tradeCount: true,
currencyMenu: false,
showTerms: true,
showPrivacy: true,
},
};
1 change: 1 addition & 0 deletions src/pages/privacy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ const content = [
];

export const PrivacyPage = () => {
if (!config.ui.showPrivacy) return;
return (
<Page title={'Privacy Policy'}>
<>
Expand Down
1 change: 1 addition & 0 deletions src/pages/terms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ const content = [
];

export const TermsPage = () => {
if (!config.ui.showTerms) return;
return (
<Page title="Terms of Use">
<>
Expand Down

0 comments on commit 4748c6f

Please sign in to comment.