Skip to content

Commit 5ee197d

Browse files
replace hardcoded chain info and remove walletconnect
1 parent dccd39b commit 5ee197d

File tree

8 files changed

+173
-96
lines changed

8 files changed

+173
-96
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/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/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/lib/constants.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const ABIS = {
7373

7474
export const CHAINDATA = {
7575
31338: {
76+
name: 'Local Chain',
7677
label: 'localhost',
78+
rpc: 'http://localhost:8555',
7779
router: CONTRACT_ADDRESSES.dexes.cap.router,
7880
explorer: 'http://localhost:8555',
7981
currencies: {
@@ -87,22 +89,4 @@ export const CHAINDATA = {
8789
},
8890
cap: CONTRACT_ADDRESSES.dexes.cap.token.cap
8991
}
90-
// 42161: {
91-
// label: 'Arbitrum',
92-
// router: '0x5ABFF8F8D5b13253dCAB1e427Fdb3305cA620119',
93-
// explorer: 'https://arbiscan.io',
94-
// rpc: 'https://arb1.arbitrum.io/rpc', // for walletconnect
95-
// currencies: {
96-
// weth: ADDRESS_ZERO,
97-
// usdc: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'
98-
// },
99-
// poolInception: {
100-
// weth: 1637154307000,
101-
// usdc: 1637154307000,
102-
// cap: 1637154307000
103-
// },
104-
// cap: '0x031d35296154279DC1984dCD93E392b1f946737b'
105-
// }
10692
}
107-
108-
console.log('chain data: ', CHAINDATA);

0 commit comments

Comments
 (0)