Skip to content

Commit 8d9fe79

Browse files
authored
feat: terms of use (#141)
1 parent b071093 commit 8d9fe79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1171
-272
lines changed

.env.development

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REACT_APP_URL=https://devnet-goerli.starkgate.starknet.io
12
REACT_APP_AUTO_CONNECT=false
23
# 20 seconds
34
REACT_APP_POLL_BLOCK_NUMBER_INTERVAL=20000
@@ -8,5 +9,6 @@ REACT_APP_ETHERSCAN_URL=https://goerli.etherscan.io
89
REACT_APP_VOYAGER_URL=https://goerli.voyager.online
910
REACT_APP_LOCAL_STORAGE_TRANSFERS_LOG_KEY=STARKGATE_TRANSFERS
1011
REACT_APP_LOCAL_STORAGE_ONBOARDING_TIMESTAMP_KEY=STARKGATE_ONBOARDING_TIMESTAMP
12+
REACT_APP_LOCAL_STORAGE_ACCEPT_TERMS=STARKGATE_ACCEPT_TERMS
1113
REACT_APP_ONBOARDING_MODAL_TIMEOUT_HRS=24
1214
REACT_APP_SUPPORTED_TOKENS=ETH,WBTC,USDC,USDT,DAI,SLF

.env.production

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REACT_APP_URL=https://starkgate.starknet.io
12
REACT_APP_AUTO_CONNECT=false
23
# 30 seconds
34
REACT_APP_POLL_BLOCK_NUMBER_INTERVAL=30000
@@ -8,5 +9,6 @@ REACT_APP_ETHERSCAN_URL=https://etherscan.io
89
REACT_APP_VOYAGER_URL=https://voyager.online
910
REACT_APP_LOCAL_STORAGE_TRANSFERS_LOG_KEY=STARKGATE_TRANSFERS
1011
REACT_APP_LOCAL_STORAGE_ONBOARDING_TIMESTAMP_KEY=STARKGATE_ONBOARDING_TIMESTAMP
12+
REACT_APP_LOCAL_STORAGE_ACCEPT_TERMS=STARKGATE_ACCEPT_TERMS
1113
REACT_APP_ONBOARDING_MODAL_TIMEOUT_HRS=24
1214
REACT_APP_SUPPORTED_TOKENS=ETH

.env.testing

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REACT_APP_URL=https://goerli.starkgate.starknet.io
12
REACT_APP_AUTO_CONNECT=false
23
# 20 seconds
34
REACT_APP_POLL_BLOCK_NUMBER_INTERVAL=20000
@@ -7,4 +8,5 @@ REACT_APP_STARKNET_CONTRACT_ADDRESS=0xde29d060D45901Fb19ED6C6e959EB22d8626708e
78
REACT_APP_ETHERSCAN_URL=https://goerli.etherscan.io
89
REACT_APP_VOYAGER_URL=https://goerli.voyager.online
910
REACT_APP_LOCAL_STORAGE_TRANSFERS_LOG_KEY=STARKGATE_TRANSFERS
11+
REACT_APP_LOCAL_STORAGE_ACCEPT_TERMS=STARKGATE_ACCEPT_TERMS
1012
REACT_APP_SUPPORTED_TOKENS=ETH,WBTC,USDC,USDT,DAI,SLF

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
"react": "^17.0.2",
6666
"react-dom": "^17.0.2",
6767
"react-hot-toast": "^2.2.0",
68+
"react-router": "^6.3.0",
69+
"react-router-dom": "6",
6870
"react-scripts": "4.0.3",
6971
"starknet": "^3.7.0",
7072
"use-async-memo": "^1.2.3",

src/App.js

+35-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
import React from 'react';
2+
import {Route, Routes, useLocation} from 'react-router-dom';
23

34
import styles from './App.module.scss';
4-
import {Footer, Header, Main} from './components/Containers';
5+
import {Footer, Header} from './components/Containers';
6+
import {StyledBackground} from './components/UI';
7+
import {useApp} from './providers/AppProvider';
8+
import {Faq, Bridge, Login, ProtectedRoute, Terms} from './routes';
59

6-
export const App = () => (
7-
<div className={styles.app}>
8-
<Header />
9-
<Main />
10-
<Footer />
11-
</div>
12-
);
10+
export const App = () => {
11+
const {isLoggedIn, isAcceptTerms} = useApp();
12+
const {pathname} = useLocation();
13+
const informativeRoutes = ['/terms', '/faq'];
14+
15+
return (
16+
<div className={styles.app}>
17+
<Header />
18+
<StyledBackground withLightAccent={!informativeRoutes.includes(pathname)}>
19+
<Routes>
20+
<Route
21+
element={
22+
<ProtectedRoute
23+
isAllowed={isLoggedIn && isAcceptTerms}
24+
redirectPath={isLoggedIn ? '/terms' : '/login'}
25+
>
26+
<Bridge />
27+
</ProtectedRoute>
28+
}
29+
path="/"
30+
/>
31+
<Route element={<Terms />} path="/terms" />
32+
<Route element={<Login />} path="/login" />
33+
<Route element={<Faq />} path="/faq" />
34+
</Routes>
35+
</StyledBackground>
36+
<Footer />
37+
</div>
38+
);
39+
};

src/App.module.scss

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
.app {
2-
overflow: hidden;
3-
flex-direction: column;
42
display: flex;
5-
background-image: url('assets/img/stars.png');
6-
background-size: cover;
7-
background-repeat: no-repeat;
8-
background-position: center center;
3+
flex-direction: column;
94
}

src/analytics/track-event.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const TrackEvent = {
55
SELECT_TOKEN_MENU: 'SELECT_TOKEN_MENU',
66
ACCOUNT_MENU: 'ACCOUNT_MENU',
77
TRANSFER_MENU: 'TRANSFER_MENU',
8-
FAQ_MENU: 'FAQ_MENU',
98

109
/**
1110
* Transfer menu
@@ -55,6 +54,16 @@ export const TrackEvent = {
5554
LOGIN_ERROR: 'LOGIN_SCREEN/login_error'
5655
},
5756

57+
/**
58+
* Terms screen
59+
*/
60+
TERMS_SCREEN: 'TERMS_SCREEN',
61+
TERMS: {
62+
ACCEPT_CLICK: 'TERMS_SCREEN/accept_click'
63+
},
64+
65+
FAQ_SCREEN: 'FAQ_SCREEN',
66+
5867
/**
5968
* Tabs
6069
*/

src/components/Containers/Footer/Footer.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ export const Footer = () => {
1010

1111
return !isMobile(breakpoint) ? (
1212
<footer className={styles.footer}>
13-
<div className={styles.copyright}>
14-
<center>{RIGHTS_TXT}</center>
15-
</div>
13+
<div className={styles.copyright}>{RIGHTS_TXT}</div>
1614
</footer>
1715
) : null;
1816
};

src/components/Containers/Footer/Footer.module.scss

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ $copyright-color: $--color-beta;
77
font-size: 13px;
88
height: #{$height}px;
99
border-top: 1px solid transparent;
10+
width: 100%;
11+
display: flex;
12+
justify-content: space-around;
13+
align-items: center;
14+
position: absolute;
15+
bottom: 0;
16+
left: 0;
17+
right: 0;
18+
overflow: hidden;
19+
background: transparent;
1020

1121
.copyright {
1222
color: $copyright-color;
13-
display: flex;
1423
font-size: 12px;
1524
line-height: 24px;
16-
margin: auto;
1725
}
1826
}

src/components/Containers/Header/Header.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,65 @@
11
import React from 'react';
2+
import {useNavigate, useLocation} from 'react-router-dom';
23
import useBreakpoint from 'use-breakpoint';
34

45
import {track} from '../../../analytics';
56
import {ReactComponent as StarkGateLogo} from '../../../assets/img/starkgate.svg';
67
import constants from '../../../config/constants';
78
import {Breakpoint} from '../../../enums';
89
import {useColors} from '../../../hooks';
10+
import {useLogin} from '../../../providers/AppProvider';
911
import {useMenu} from '../../../providers/MenuProvider';
1012
import {useIsL1, useIsL2} from '../../../providers/TransferProvider';
1113
import {useL1Wallet, useL2Wallet, useWallets} from '../../../providers/WalletsProvider';
1214
import utils from '../../../utils';
1315
import {Tab, WalletButton} from '../../UI';
1416
import styles from './Header.module.scss';
15-
import {CHAIN_TXT, TAB_DISCORD_TXT, TAB_FAQ_TXT} from './Header.strings';
17+
import {CHAIN_TXT, TAB_DISCORD_TXT, TAB_FAQ_TXT, TAB_TERMS_TXT} from './Header.strings';
1618

1719
const {DISCORD_LINK_URL} = constants;
1820

1921
export const Header = () => {
20-
const {chainName, isConnected} = useWallets();
21-
const {showAccountMenu, showTransferMenu, showFaqMenu} = useMenu();
22+
const navigate = useNavigate();
23+
const {pathname} = useLocation();
24+
const {chainName} = useWallets();
25+
const {showAccountMenu, showTransferMenu} = useMenu();
2226
const [, swapToL1] = useIsL1();
2327
const [, swapToL2] = useIsL2();
2428
const {account: l1Account, isConnected: isL1AccountConnected, config: l1Config} = useL1Wallet();
2529
const {account: l2Account, isConnected: isL2AccountConnected, config: l2Config} = useL2Wallet();
2630
const {breakpoint} = useBreakpoint(Breakpoint);
2731
const {colorDiscord, colorWhiteOp50} = useColors();
32+
const {isLoggedIn} = useLogin();
33+
34+
const maybeNavigateToIndex = () => {
35+
pathname !== '/' && navigate('/');
36+
};
2837

2938
const onL2WalletButtonClick = () => {
39+
maybeNavigateToIndex();
3040
swapToL2();
3141
showAccountMenu();
3242
};
3343

3444
const onL1WalletButtonClick = () => {
45+
maybeNavigateToIndex();
3546
swapToL1();
3647
showAccountMenu();
3748
};
3849

3950
const onLogoClick = () => {
51+
maybeNavigateToIndex();
4052
showTransferMenu();
4153
};
4254

55+
const onTabFaqClick = () => {
56+
navigate('faq', {replace: true});
57+
};
58+
59+
const onTabTermsClick = () => {
60+
navigate('terms', {replace: true});
61+
};
62+
4363
const onTabDiscordClick = () => {
4464
track(TrackEvent.DISCORD_TAB_CLICK);
4565
utils.browser.openInNewTab(DISCORD_LINK_URL);
@@ -51,13 +71,14 @@ export const Header = () => {
5171
<div className={utils.object.toClasses(styles.logo, 'row')} onClick={onLogoClick}>
5272
<StarkGateLogo />
5373
</div>
54-
{isConnected && (
74+
{isLoggedIn && (
5575
<div className={utils.object.toClasses(styles.chain, 'row')}>{CHAIN_TXT(chainName)}</div>
5676
)}
5777
</div>
5878

5979
<div className={utils.object.toClasses(styles.right, 'row')}>
60-
<Tab color={colorWhiteOp50} label={TAB_FAQ_TXT} onClick={showFaqMenu} />
80+
<Tab color={colorWhiteOp50} label={TAB_TERMS_TXT} onClick={onTabTermsClick} />
81+
<Tab color={colorWhiteOp50} label={TAB_FAQ_TXT} onClick={onTabFaqClick} />
6182
<Tab color={colorDiscord} label={TAB_DISCORD_TXT} onClick={onTabDiscordClick} />
6283
{isL1AccountConnected && (
6384
<WalletButton

src/components/Containers/Header/Header.module.scss

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ $chain-color: $--color-white-1;
88
height: #{$height}px;
99
border-bottom: 1px solid transparent;
1010
justify-content: space-between;
11-
padding: 0 40px;
1211
background: $background-color;
1312
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
1413
transition: 0.3s ease-in-out;
14+
position: absolute;
15+
top: 0;
16+
left: 0;
17+
right: 0;
18+
overflow: hidden;
1519

1620
.left {
21+
padding: 30px;
1722
display: flex;
1823
flex-direction: column;
1924
align-items: flex-start;
@@ -39,6 +44,7 @@ $chain-color: $--color-white-1;
3944
}
4045

4146
.right {
47+
padding: 30px;
4248
display: flex;
4349
flex-direction: row;
4450

@@ -51,7 +57,6 @@ $chain-color: $--color-white-1;
5157

5258
&.mobile {
5359
height: #{$height - 10}px;
54-
padding: 0 30px;
5560

5661
.left {
5762
.logo {

src/components/Containers/Header/Header.strings.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ export const CHAIN_TXT = chainName =>
77

88
export const TAB_DISCORD_TXT = utils.getTranslation('containers.header.tab_discord_txt');
99

10-
export const TAB_FAQ_TXT = utils.getTranslation('containers.header.tab_faq');
10+
export const TAB_FAQ_TXT = utils.getTranslation('containers.header.tab_faq_txt');
11+
12+
export const TAB_TERMS_TXT = utils.getTranslation('containers.header.tab_terms_txt');

src/components/Containers/Main/Main.js

-34
This file was deleted.

src/components/Containers/Main/Main.module.scss

-5
This file was deleted.

src/components/Containers/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export * from './Main/Main';
21
export * from './Footer/Footer';
32
export * from './Header/Header';

src/components/Features/Bridge/Bridge.module.scss

-15
This file was deleted.

src/components/Features/Faq/Faq.js

-30
This file was deleted.

0 commit comments

Comments
 (0)