Skip to content

Commit 451a580

Browse files
Merge pull request #6 from vacuumlabs/refactor-fe
Refactor CAP related things
2 parents dccd39b + 8967f1b commit 451a580

File tree

15 files changed

+227
-168
lines changed

15 files changed

+227
-168
lines changed

package-lock.json

Lines changed: 133 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"@rollup/plugin-commonjs": "^21.0.1",
2424
"@rollup/plugin-node-resolve": "^13.0.6",
25+
"@rollup/plugin-replace": "^6.0.2",
2526
"ethers": "^5.5.1",
2627
"rollup": "^2.58.0",
2728
"rollup-plugin-copy": "^3.4.0",

rollup.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import css from 'rollup-plugin-css-only';
77
import copy from 'rollup-plugin-copy';
88
import gzipPlugin from 'rollup-plugin-gzip';
99
import { brotliCompressSync } from 'zlib';
10+
import replace from '@rollup/plugin-replace';
1011

1112
const production = !process.env.ROLLUP_WATCH;
1213
const hash = String(require('child_process').execSync('git rev-parse --short HEAD')).trim(); // append short git commit to bundles
@@ -48,6 +49,12 @@ export default {
4849
}
4950
}),
5051

52+
replace({
53+
preventAssignment: true,
54+
'process.env.DEFAULT_CHAIN_ID': process.env.DEFAULT_CHAIN_ID || 31338,
55+
'process.env.DEFAULT_RPC_URL': JSON.stringify(process.env.DEFAULT_RPC_URL || 'http://localhost:8555'),
56+
}),
57+
5158
production && gzipPlugin(),
5259
production && gzipPlugin({
5360
customCompression: content =>

src/App.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@
116116
117117
</style>
118118

119-
<div class='notice'>PLEASE DO NOT USE THIS WEBSITE. A new version of CAP is now available. Check it out <a href='https://cap.io'>here</a>.</div>
120-
121119
<Modals />
122120
<Toasts />
123121

src/components/Order.svelte

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,4 @@
287287

288288
</div>
289289

290-
{#if !$address}
291-
<div class='note'>CAP is an open protocol to trade crypto perpetuals with low fees. <a data-intercept="true" on:click={() => {showModal('Connect')}}>Connect your wallet</a> on Arbitrum to get started.</div>
292-
{:else if $address && balance * 1 == 0}
293-
<div class='note'><a href='https://docs.cap.finance/setting-up-your-wallet' target='_blank'>Bridge funds</a> to Arbitrum to start trading.</div>
294-
{/if}
295-
296-
297290
</div>

src/components/Wallet.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@
1111
1212
import { shortAddress, showModal } from '../lib/utils'
1313
14+
import {CHAINDATA} from '../lib/constants'
15+
1416
onMount(async () => {
1517
await checkMetamaskSession();
1618
});
1719
20+
// TODO (autonom): Find another solution when we support multiple L2 chains
21+
const DEFAULT_CHAIN_ID = Number(process.env.DEFAULT_CHAIN_ID);
22+
const CHAIN_NAME = CHAINDATA[DEFAULT_CHAIN_ID]?.name;
23+
1824
</script>
1925
2026
<style>
@@ -56,7 +62,7 @@
5662
<div class='wallet'>
5763
5864
{#if $address && $wrongNetwork}
59-
<div class='wrong-network' on:click={() => {switchChains()}}>Switch to Arbitrum</div>
65+
<div class='wrong-network' on:click={() => {switchChains()}}>Switch to {CHAIN_NAME}</div>
6066
{/if}
6167
6268
{#if $address}

src/components/layout/Header.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,9 @@
8383
<div class='inner' class:home={!$currentPage || $currentPage == 'home'}>
8484

8585
<div class='left'>
86-
<a class='logo' class:active={!$currentPage || $currentPage == 'home'} href='/'>
87-
<img src='/logos/CAP.svg' title='CAP Home' alt='CAP Home' />
88-
</a>
86+
<!-- TODO (autonom): add Autonom logo here -->
8987
<a class='link' class:active={$currentPage == 'trade'} href='#/trade'>Trade</a>
9088
<a class='link' class:active={$currentPage == 'pool'} href='#/pool'>Pool</a>
91-
<a class='link' href='https://docs.cap.finance' target='_blank'>Docs</a>
9289
</div>
9390

9491
<div class='right'>

src/components/modals/Connect.svelte

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
import Modal from '../modals/Modal.svelte'
3-
import { connectMetamask, connectWalletConnect } from '../../lib/wallet'
3+
import { connectMetamask } from '../../lib/wallet'
44
55
</script>
66

@@ -50,9 +50,4 @@
5050
<div>MetaMask</div>
5151
</div>
5252

53-
<div class='row' on:click={() => {connectWalletConnect()}} data-intercept="true">
54-
<img src='https://raw.githubusercontent.com/WalletConnect/walletconnect-assets/master/Icon/Blue%20(Default)/Icon.svg'>
55-
<div>WalletConnect</div>
56-
</div>
57-
5853
</Modal>

src/components/modals/Network.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import Button from '../layout/Button.svelte'
44
55
import { switchChains } from '../../lib/wallet'
6+
7+
import {CHAINDATA} from '../../lib/constants'
8+
9+
// TODO (autonom): Find another solution when we support multiple L2 chains
10+
const DEFAULT_CHAIN_ID = Number(process.env.DEFAULT_CHAIN_ID);
11+
const CHAIN_NAME = CHAINDATA[DEFAULT_CHAIN_ID]?.name;
612
</script>
713
814
<style>
@@ -17,9 +23,9 @@
1723
<Modal title='Invalid Network' showHeader={true} showCancel={true}>
1824
1925
<div class='note'>
20-
Select Arbitrum as your wallet's network to trade or pool on CAP.
26+
Select {CHAIN_NAME} as your wallet's network to trade or pool on CAP.
2127
</div>
2228
23-
<Button wrap={true} onClick={() => {switchChains()}} label={`Switch to Arbitrum`} />
29+
<Button wrap={true} onClick={() => {switchChains()}} label={`Switch to ${CHAIN_NAME}`} />
2430
2531
</Modal>

src/components/pages/Trade.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
grid-template-rows: calc(var(--ticker-height) + var(--chart-resolution-height) + var(--chart-height) + 3 * var(--grid-gap)) auto;
2727
background-color: var(--rich-black-fogra);
2828
position: absolute;
29-
top: calc(var(--header-height) + var(--grid-gap) + 44px);
29+
top: calc(var(--header-height) + var(--grid-gap));
3030
bottom: 0;
3131
left: 0;
3232
right: 0;

0 commit comments

Comments
 (0)