-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(popup): move ConnectWallet route out of Settings (#656)
- Loading branch information
1 parent
fd44364
commit 7244a3d
Showing
4 changed files
with
46 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { ConnectWalletForm } from '@/popup/components/ConnectWalletForm'; | ||
import { useMessage, usePopupState } from '@/popup/lib/context'; | ||
import { getWalletInformation } from '@/shared/helpers'; | ||
|
||
export const Component = () => { | ||
const { state } = usePopupState(); | ||
const message = useMessage(); | ||
|
||
const connectState = state.transientState['connect']; | ||
return ( | ||
<ConnectWalletForm | ||
publicKey={state.publicKey} | ||
state={connectState} | ||
defaultValues={{ | ||
recurring: | ||
localStorage?.getItem('connect.recurring') === 'true' || false, | ||
amount: localStorage?.getItem('connect.amount') || undefined, | ||
walletAddressUrl: | ||
localStorage?.getItem('connect.walletAddressUrl') || undefined, | ||
autoKeyAddConsent: | ||
localStorage?.getItem('connect.autoKeyAddConsent') === 'true', | ||
}} | ||
saveValue={(key, val) => { | ||
localStorage?.setItem(`connect.${key}`, val.toString()); | ||
}} | ||
getWalletInfo={getWalletInformation} | ||
connectWallet={(data) => message.send('CONNECT_WALLET', data)} | ||
onConnect={() => { | ||
// The popup closes due to redirects on connect, so we don't need to | ||
// update any state manually. | ||
// But we reload it, as it's open all-time when running E2E tests | ||
window.location.reload(); | ||
}} | ||
clearConnectState={() => message.send('CONNECT_WALLET', null)} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,9 @@ | ||
import React from 'react'; | ||
import { ConnectWalletForm } from '@/popup/components/ConnectWalletForm'; | ||
import { WalletInformation } from '@/popup/components/WalletInformation'; | ||
import { useMessage, usePopupState } from '@/popup/lib/context'; | ||
import { getWalletInformation } from '@/shared/helpers'; | ||
import { usePopupState } from '@/popup/lib/context'; | ||
|
||
export const Component = () => { | ||
const { state } = usePopupState(); | ||
const message = useMessage(); | ||
|
||
if (state.connected) { | ||
return <WalletInformation info={state} />; | ||
} else { | ||
const connectState = state.transientState['connect']; | ||
return ( | ||
<ConnectWalletForm | ||
publicKey={state.publicKey} | ||
state={connectState} | ||
defaultValues={{ | ||
recurring: | ||
localStorage?.getItem('connect.recurring') === 'true' || false, | ||
amount: localStorage?.getItem('connect.amount') || undefined, | ||
walletAddressUrl: | ||
localStorage?.getItem('connect.walletAddressUrl') || undefined, | ||
autoKeyAddConsent: | ||
localStorage?.getItem('connect.autoKeyAddConsent') === 'true', | ||
}} | ||
saveValue={(key, val) => { | ||
localStorage?.setItem(`connect.${key}`, val.toString()); | ||
}} | ||
getWalletInfo={getWalletInformation} | ||
connectWallet={(data) => message.send('CONNECT_WALLET', data)} | ||
onConnect={() => { | ||
// The popup closes due to redirects on connect, so we don't need to | ||
// update any state manually. | ||
// But we reload it, as it's open all-time when running E2E tests | ||
window.location.reload(); | ||
}} | ||
clearConnectState={() => message.send('CONNECT_WALLET', null)} | ||
/> | ||
); | ||
} | ||
return <WalletInformation info={state} />; | ||
}; |