Skip to content

Commit d2860bd

Browse files
authored
Merge pull request #159 from DistributedCollective/develop
Develop
2 parents a7067df + a8a2743 commit d2860bd

Some content is hidden

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

75 files changed

+29683
-331
lines changed

packages/dev-frontend/package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"@fortawesome/free-regular-svg-icons": "5.15.2",
1010
"@fortawesome/free-solid-svg-icons": "5.15.2",
1111
"@fortawesome/react-fontawesome": "0.1.14",
12+
"@ledgerhq/devices": "^7.0.0",
1213
"@popperjs/core": "2.9.1",
1314
"@testing-library/dom": "7.30.0",
1415
"@testing-library/jest-dom": "5.11.9",
@@ -23,9 +24,12 @@
2324
"@types/testing-library__jest-dom": "5.9.5",
2425
"@types/testing-library__react": "10.2.0",
2526
"@types/testing-library__user-event": "4.2.0",
26-
"@web3-react/core": "6.1.9",
27-
"@web3-react/injected-connector": "6.0.7",
28-
"@web3-react/types": "6.0.7",
27+
"@web3-onboard/core": "^2.5.0",
28+
"@web3-onboard/injected-wallets": "^2.0.14",
29+
"@web3-onboard/ledger": "^2.1.7",
30+
"@web3-onboard/portis": "^2.0.7",
31+
"@web3-onboard/trezor": "^2.1.7",
32+
"@web3-onboard/walletconnect": "^2.0.8",
2933
"axios": "^0.26.1",
3034
"cross-env": "7.0.3",
3135
"ethereum-blockies": "^0.1.1",
@@ -43,7 +47,7 @@
4347
"source-map-explorer": "2.5.2",
4448
"swr": "^1.3.0",
4549
"theme-ui": "0.6.0-canary.1544.5359f8a1e408a4dfeb74a9ae39688270286e534a.0",
46-
"typescript": "4.1.5"
50+
"typescript": "4.6.2"
4751
},
4852
"scripts": {
4953
"analyze": "source-map-explorer 'build/static/js/*.js'",

packages/dev-frontend/src/App.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from "react";
2-
import { Web3ReactProvider } from "@web3-react/core";
32
import { Flex, Spinner, Heading, ThemeProvider, Paragraph, Link, Image } from "theme-ui";
43

5-
import { BatchedWebSocketAugmentedWeb3Provider } from "@sovryn-zero//providers";
64
import { LiquityProvider } from "./hooks/LiquityContext";
75
import { WalletConnector } from "./components/WalletConnector";
86
import { TransactionProvider } from "./components/Transaction";
@@ -15,6 +13,7 @@ import { LiquityFrontend } from "./LiquityFrontend";
1513
import { BrowserRouter } from "react-router-dom";
1614
import { Header } from "./components/Header";
1715
import { isMainnet } from "./utils";
16+
import { ConnectorContextProvider } from "./components/Connector";
1817

1918
if (window.ethereum) {
2019
// Silence MetaMask warning in console
@@ -37,14 +36,6 @@ getConfig().then(config => {
3736
Object.assign(window, { config });
3837
});
3938

40-
const EthersWeb3ReactProvider: React.FC = ({ children }) => {
41-
return (
42-
<Web3ReactProvider getLibrary={provider => new BatchedWebSocketAugmentedWeb3Provider(provider)}>
43-
{children}
44-
</Web3ReactProvider>
45-
);
46-
};
47-
4839
const UnsupportedLayout: React.FC = ({ children }) => (
4940
<Flex sx={{ flexDirection: "column", minHeight: "100%" }}>
5041
<Header hideDetails />
@@ -80,8 +71,8 @@ const UnsupportedMainnetFallback: React.FC = () => (
8071
</Paragraph>
8172

8273
<Paragraph>
83-
If you'd like to use Zero on {isMainnet ? "mainnet" : "testnet"}, please go{" "}
84-
<Link href={`https://${isMainnet ? "live" : "test"}.sovryn.app/zero`}>
74+
If you'd like to use Zero on {!isMainnet ? "mainnet" : "testnet"}, please go{" "}
75+
<Link href={`https://${!isMainnet ? "live" : "test"}.sovryn.app/zero`}>
8576
here <Icon name="external-link-alt" size="xs" />
8677
</Link>
8778
.
@@ -105,9 +96,9 @@ const App = () => {
10596
);
10697

10798
return (
108-
<EthersWeb3ReactProvider>
109-
<ThemeProvider theme={theme}>
110-
<BrowserRouter>
99+
<ThemeProvider theme={theme}>
100+
<BrowserRouter>
101+
<ConnectorContextProvider>
111102
<WalletConnector loader={loader}>
112103
<LiquityProvider
113104
loader={loader}
@@ -119,9 +110,9 @@ const App = () => {
119110
</TransactionProvider>
120111
</LiquityProvider>
121112
</WalletConnector>
122-
</BrowserRouter>
123-
</ThemeProvider>
124-
</EthersWeb3ReactProvider>
113+
</ConnectorContextProvider>
114+
</BrowserRouter>
115+
</ThemeProvider>
125116
);
126117
};
127118

packages/dev-frontend/src/components/ActionDescription.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { Box, Flex, Text } from "theme-ui";
1+
import { Decimal } from "@sovryn-zero/lib-base";
2+
import Tippy from "@tippyjs/react";
3+
import { useMemo } from "react";
4+
import { Box, Card, Flex, Text, ThemeUIStyleObject } from "theme-ui";
25

36
import { Icon } from "./Icon";
47

@@ -34,6 +37,26 @@ export const ActionDescription: React.FC = ({ children }) => (
3437
</Box>
3538
);
3639

37-
export const Amount: React.FC = ({ children }) => (
38-
<Text sx={{ fontWeight: "bold", whiteSpace: "nowrap" }}>{children}</Text>
39-
);
40+
interface AmountProps {
41+
value?: Decimal;
42+
sx?: ThemeUIStyleObject;
43+
}
44+
export const Amount: React.FC<AmountProps> = ({
45+
children,
46+
value,
47+
sx = { fontWeight: "bold", whiteSpace: "nowrap" }
48+
}) => {
49+
const showTilde = useMemo(() => value && !Decimal.from(value.toString(2)).eq(value), [value]);
50+
return (
51+
<Tippy
52+
interactive={true}
53+
disabled={!showTilde}
54+
content={<Card variant="tooltip">{value?.toString()}</Card>}
55+
>
56+
<Text sx={sx}>
57+
{showTilde && <Text sx={{ fontWeight: "light", opacity: 0.8, flexShrink: 0 }}>~&nbsp;</Text>}
58+
{children}
59+
</Text>
60+
</Tippy>
61+
);
62+
};

packages/dev-frontend/src/components/Aggregator/Convert.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Decimal, LiquityStoreState } from "@sovryn-zero/lib-base";
22
import { useLiquitySelector } from "@sovryn-zero/lib-react";
3-
import { useWeb3React } from "@web3-react/core";
43
import { parseUnits } from "ethers/lib/utils";
54
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
65

@@ -11,6 +10,7 @@ import useZusdAggregator from "../../hooks/useZusdAggregator";
1110
import { COIN, XUSD } from "../../strings";
1211
import { parseBalance } from "../../utils";
1312
import { Card } from "../Card";
13+
import { useConnectorContext } from "../Connector";
1414
import { ErrorDescription } from "../ErrorDescription";
1515
import { EditableRow } from "../Trove/Editor";
1616

@@ -19,14 +19,14 @@ const select = ({ zusdBalance }: LiquityStoreState) => ({
1919
});
2020

2121
export const Convert: React.FC = () => {
22-
const { account } = useWeb3React();
22+
const { walletAddress } = useConnectorContext();
2323
const { zusdBalance } = useLiquitySelector(select);
24-
const { data: xusd, decimals: decimalsXUSD } = useTokenBalance(account!, addresses.xusd);
24+
const { data: xusd, decimals: decimalsXUSD } = useTokenBalance(walletAddress!, addresses.xusd);
2525
const { data: zusd, decimals: decimalsZUSD } = useTokenBalance(
2626
addresses.babelfish,
2727
addresses.zusd
2828
);
29-
const { mint, redeem } = useZusdAggregator(account);
29+
const { mint, redeem } = useZusdAggregator(walletAddress);
3030

3131
const xusdBalance = useMemo(
3232
() => Decimal.from(parseBalance(xusd || 0, decimalsXUSD, decimalsXUSD)),
@@ -117,6 +117,7 @@ export const Convert: React.FC = () => {
117117
ml: 2,
118118
alignSelf: "self-start"
119119
}}
120+
data-action-id="zero-convert-ZUSD"
120121
>
121122
Convert
122123
</Button>
@@ -153,6 +154,7 @@ export const Convert: React.FC = () => {
153154
ml: 2,
154155
alignSelf: "self-start"
155156
}}
157+
data-action-id="zero-convert-XUSD"
156158
>
157159
Convert
158160
</Button>

0 commit comments

Comments
 (0)