Skip to content

Commit ec3dba6

Browse files
authored
Merge pull request #179 from gnosischain/develop
feat: claim both DAI and USDS
2 parents 592858f + 1b2383f commit ec3dba6

20 files changed

Lines changed: 344 additions & 138 deletions

File tree

app/public/images/icons/usds.webp

476 Bytes
Loading

app/src/components/footer/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const ExternalLink = styled.a`
5555
align-items: center;
5656
column-gap: var(--theme-common-space);
5757
display: flex;
58-
font-size: 1.2rem;
58+
font-size: 1.4rem;
5959
text-decoration: none;
6060
6161
&:active {
@@ -106,6 +106,13 @@ export const Footer: React.FC = (props) => {
106106
</ExternalLink>
107107
</Start>
108108
<End>
109+
<ExternalLink
110+
href="https://docs.gnosischain.com/bridges/"
111+
rel="noreferrer"
112+
target="_blank"
113+
>
114+
Documentation
115+
</ExternalLink>
109116
<Link href="/faq">FAQ</Link>
110117
{/* <NextLink href="/privacy" passHref>
111118
<Link>Privacy Policy</Link>

app/src/components/table/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const TR = styled.div<{ $compact?: boolean }>`
4646
row-gap: calc(var(--table-padding-common));
4747
transition: none;
4848
49-
&:hover > * {
49+
&:hover > *:not(:last-child) {
5050
opacity: 0.8;
5151
}
5252

app/src/constants/bridged_tokens.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9762,22 +9762,6 @@
97629762
"symbol": "UDT",
97639763
"total_supply": "9936213363153110036806",
97649764
"type": "ERC-20"
9765-
},
9766-
{
9767-
"bridge_type": "xdai",
9768-
"foreign_address": "0xdC035D45d973E3EC169d2276DDab16f1e407384F",
9769-
"origin_chain_id": "1",
9770-
"address": "",
9771-
"circulating_market_cap": null,
9772-
"decimals": "18",
9773-
"exchange_rate": null,
9774-
"holders": "2281",
9775-
"icon_url": null,
9776-
"is_bridged": true,
9777-
"name": "USDS",
9778-
"symbol": "USDS",
9779-
"total_supply": "3854025994000000000000000000",
9780-
"type": "ERC-20"
97819765
}
97829766
]
97839767
}

app/src/constants/bridges.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1+
import { Chains } from './config/chains'
2+
import { contracts } from './config/contracts'
3+
14
export const bridgeConfig = Object.freeze({
25
XDAI: {
36
bridgeProxy: '0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016',
47
governorMultisig: '0x42F38ec5A75acCEc50054671233dfAC9C0E7A3F6',
58
tokens: {
69
dai: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
10+
usds: '0xdc035d45d973e3ec169d2276ddab16f1e407384f',
711
},
812
protocol: {
913
address: '0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B',
1014
token: '0xc00e94cb662c3520282e6f5717214004a7f26888',
1115
},
16+
bridgeRouter: contracts.BridgeRouter.address[Chains.mainnet],
1217
},
1318
OMNI: {
1419
bridgeProxy: '0x88ad09518695c6c3712AC10a214bE5109a655671',

app/src/constants/usdsToken.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Token } from '@/types/token'
2+
import { getIcon } from '@/src/utils/icons'
3+
import { NATIVE_TOKEN_ADDRESS, USDS_ADDRESS } from '@/src/constants/config/common'
4+
5+
export const usdsToken: Token = {
6+
chainId: 1,
7+
address: USDS_ADDRESS,
8+
decimals: 18,
9+
logoURI: getIcon('usds'),
10+
name: 'USDS',
11+
symbol: 'USDS',
12+
extensions: {
13+
bridgeInfo: {
14+
1: { tokenAddress: USDS_ADDRESS },
15+
100: { tokenAddress: NATIVE_TOKEN_ADDRESS },
16+
},
17+
},
18+
}

app/src/hooks/bridge/useBridgeTokenOutInfo.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const getReceivedTokenInfo = async ({
2727
fromChainId,
2828
omniBridgeInstance,
2929
receiveNativeToken,
30+
receiveUsds,
3031
toChainId,
3132
tokenAddress,
3233
}: {
@@ -35,6 +36,7 @@ const getReceivedTokenInfo = async ({
3536
tokenAddress: string
3637
omniBridgeInstance: HomeOmniMediator
3738
receiveNativeToken: boolean
39+
receiveUsds: boolean
3840
}): Promise<{ tokenOutAddress: string; canReceiveNativeToken?: boolean }> => {
3941
const { isDAI, isFromForeign, isFromHome, isNativeToken } = getBridgeCommonInfo({
4042
fromChainId,
@@ -83,6 +85,12 @@ const getReceivedTokenInfo = async ({
8385

8486
if (isFromHome) {
8587
// xDAI -> DAI
88+
if (receiveUsds) {
89+
return {
90+
tokenOutAddress: USDS_ADDRESS,
91+
}
92+
}
93+
8694
if (isNativeToken) {
8795
return {
8896
tokenOutAddress: chainsConfig[toChainId].bridge.DAI,
@@ -113,10 +121,12 @@ const getReceivedTokenInfo = async ({
113121
export const useBridgeTokenOutInfo = ({
114122
fromChainId,
115123
receiveNativeToken,
124+
receiveUsds,
116125
toChainId,
117126
token,
118127
}: {
119128
receiveNativeToken: boolean
129+
receiveUsds: boolean
120130
toChainId: ChainsValues
121131
fromChainId: ChainsValues
122132
token?: Token
@@ -127,8 +137,10 @@ export const useBridgeTokenOutInfo = ({
127137
const shouldFetch = !!(token && fromChainId && toChainId)
128138

129139
const { data } = useSWR(
130-
shouldFetch ? [token, fromChainId, toChainId, receiveNativeToken, 'bridgeTokenOut'] : null,
131-
async ([_token, _fromChainId, _toChainId, _receiveNativeToken]) => {
140+
shouldFetch
141+
? [token, fromChainId, toChainId, receiveNativeToken, receiveUsds, 'bridgeTokenOut']
142+
: null,
143+
async ([_token, _fromChainId, _toChainId, _receiveNativeToken, _receiveUsds]) => {
132144
if (
133145
_fromChainId === Chains.mainnet &&
134146
_toChainId === Chains.gnosis &&
@@ -161,6 +173,7 @@ export const useBridgeTokenOutInfo = ({
161173
tokenAddress: _token.address,
162174
fromChainId: _fromChainId,
163175
receiveNativeToken: _receiveNativeToken,
176+
receiveUsds: _receiveUsds,
164177
})
165178

166179
// if tokenOutInfo address is ZERO_ADDRESS is a new token on the other chain and we need to handle it
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useContractInstance } from '../useContractInstance'
2+
import { Chains } from '@/src/constants/config/chains'
3+
import { ForeignBridgeErcToNative, ForeignBridgeErcToNative__factory } from '@/types/typechain'
4+
import { useContractCall } from '../useContractCall'
5+
6+
export const useForeignXdaiErc20Address = () => {
7+
const foreignXDAI = useContractInstance(
8+
ForeignBridgeErcToNative__factory,
9+
'XDAIBridge',
10+
Chains.mainnet,
11+
)
12+
13+
const erc20AddressCalls = [foreignXDAI.erc20token] as const
14+
const [{ data: foreignXDAIContext }] = useContractCall<
15+
ForeignBridgeErcToNative,
16+
typeof erc20AddressCalls
17+
>(erc20AddressCalls, [[]], 'foreignXDAIContext')
18+
19+
return {
20+
foreignXdaiErc20Token: foreignXDAIContext?.[0],
21+
}
22+
}

app/src/hooks/useSanitizedQuery.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ const sanitizeQuery = (query: ParsedUrlQuery, tokensByNetwork: TokensByNetwork):
4141

4242
export const useSanitizedQuery = (tokensByNetwork: TokensByNetwork) => {
4343
const router = useRouter()
44+
4445
return useMemo(
45-
() => sanitizeQuery(router.query, { ...tokensByNetwork, ...tokensException }),
46+
() =>
47+
sanitizeQuery(router.query, {
48+
[1]: [...tokensByNetwork[1], ...(tokensException[1] || [])],
49+
[100]: [...tokensByNetwork[100], ...(tokensException[100] || [])],
50+
}),
4651
[router.query, tokensByNetwork],
4752
)
4853
}

app/src/pagePartials/bridge/bridgeForm/ReceiveNativeTokenSwitcher.tsx renamed to app/src/pagePartials/bridge/bridgeForm/ReceiveTokenSwitcher.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ const Wrapper = styled.div`
1111
width: 100%;
1212
`
1313

14-
// const Value = styled.span<{ disabled?: boolean }>`
15-
// font-size: 1.5rem;
16-
// font-weight: 500;
17-
// margin-left: auto;
18-
// opacity: ${({ disabled }) => (disabled ? 0.7 : 1)};
19-
20-
// @media (min-width: ${({ theme }) => theme.breakPoints.tabletLandscapeStart}) {
21-
// font-size: 1.6rem;
22-
// font-weight: 600;
23-
// }
24-
// `
25-
2614
interface IOption {
2715
disabled?: boolean
2816
icon?: string
@@ -35,19 +23,21 @@ interface Props {
3523
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
3624
options: IOption[]
3725
optionsId: string
26+
value: string
3827
}
3928

40-
export const ReceiveNativeTokenSwitcher = ({
29+
export const ReceiveTokenSwitcher = ({
4130
onChange,
4231
options,
4332
optionsId,
33+
value,
4434
...restProps
4535
}: Props) => {
4636
return (
4737
<Wrapper {...restProps}>
4838
{options.map(({ disabled, icon, label, name }, index) => (
4939
<TokenSelectButton
50-
defaultChecked={index === 0}
40+
checked={value === label}
5141
disabled={disabled}
5242
icon={icon}
5343
id={optionsId}

0 commit comments

Comments
 (0)