mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 18:31:44 +03:00
Merge pull request #5099 from finned-palmer/show-wallet-scan-progress
btc-wallet: Show wallet scan progress
This commit is contained in:
commit
3992fc1ee9
@ -16,10 +16,12 @@ const Balance = () => {
|
|||||||
setPsbt,
|
setPsbt,
|
||||||
setFee,
|
setFee,
|
||||||
setError,
|
setError,
|
||||||
|
scanProgress,
|
||||||
} = useSettings();
|
} = useSettings();
|
||||||
const [sending, setSending] = useState(false);
|
const [sending, setSending] = useState(false);
|
||||||
const [copiedButton, setCopiedButton] = useState(false);
|
const [copiedButton, setCopiedButton] = useState(false);
|
||||||
const [copiedString, setCopiedString] = useState(false);
|
const [copiedString, setCopiedString] = useState(false);
|
||||||
|
const scanning = scanProgress?.main !== null || scanProgress?.change !== null;
|
||||||
|
|
||||||
const copyAddress = (arg) => {
|
const copyAddress = (arg) => {
|
||||||
navigator.clipboard.writeText(address);
|
navigator.clipboard.writeText(address);
|
||||||
@ -93,10 +95,26 @@ const Balance = () => {
|
|||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
</Text>
|
</Text>
|
||||||
|
{scanning ? (
|
||||||
|
<Col alignItems="center">
|
||||||
|
<Row>
|
||||||
|
<Text fontSize={1} color="orange">
|
||||||
|
Balance will be updated shortly:
|
||||||
|
</Text>
|
||||||
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Text fontSize={1} color="orange">
|
||||||
|
{scanProgress.main} main wallet addresses scanned
|
||||||
|
{scanProgress.change} change wallet addresses scanned
|
||||||
|
</Text>
|
||||||
|
</Row>
|
||||||
|
</Col>
|
||||||
|
) : (
|
||||||
<Text
|
<Text
|
||||||
fontSize={1}
|
fontSize={1}
|
||||||
color="orange"
|
color="orange"
|
||||||
>{`${sats}${unconfirmedString} sats`}</Text>
|
>{`${sats}${unconfirmedString} sats`}</Text>
|
||||||
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Row flexDirection="row-reverse">
|
<Row flexDirection="row-reverse">
|
||||||
<Button
|
<Button
|
||||||
|
@ -201,6 +201,7 @@ const WalletModal = () => {
|
|||||||
Extended Public Key (XPub)
|
Extended Public Key (XPub)
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Row alignItems="center">
|
||||||
<StatelessTextInput
|
<StatelessTextInput
|
||||||
value={xpub}
|
value={xpub}
|
||||||
disabled={inputDisabled}
|
disabled={inputDisabled}
|
||||||
@ -210,7 +211,10 @@ const WalletModal = () => {
|
|||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect="off"
|
autoCorrect="off"
|
||||||
onChange={(e) => checkXPub(e)}
|
onChange={(e) => checkXPub(e)}
|
||||||
|
mr={1}
|
||||||
/>
|
/>
|
||||||
|
{!inputDisabled ? null : <LoadingSpinner />}
|
||||||
|
</Row>
|
||||||
<Box mt={3} mb={3}>
|
<Box mt={3} mb={3}>
|
||||||
<Text
|
<Text
|
||||||
fontSize="14px"
|
fontSize="14px"
|
||||||
|
@ -8,14 +8,15 @@ import Body from './lib/body.js';
|
|||||||
import { useSettings } from '../hooks/useSettings.js';
|
import { useSettings } from '../hooks/useSettings.js';
|
||||||
|
|
||||||
const Root = () => {
|
const Root = () => {
|
||||||
const { loaded, wallet, provider } = useSettings();
|
const { loaded, wallet, provider, scanProgress } = useSettings();
|
||||||
const blur = !loaded ? false : !(wallet && provider);
|
const scanning = scanProgress?.main !== null || scanProgress?.change !== null;
|
||||||
|
const blur = !loaded || scanning ? false : !(wallet && provider);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<ThemeProvider theme={light}>
|
<ThemeProvider theme={light}>
|
||||||
<Reset />
|
<Reset />
|
||||||
{loaded ? <StartupModal /> : null}
|
{loaded && !scanning ? <StartupModal /> : null}
|
||||||
<Box
|
<Box
|
||||||
display="flex"
|
display="flex"
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
@ -23,8 +24,8 @@ const Root = () => {
|
|||||||
alignItems="center"
|
alignItems="center"
|
||||||
backgroundColor="lightOrange"
|
backgroundColor="lightOrange"
|
||||||
width="100%"
|
width="100%"
|
||||||
minHeight={loaded ? '100%' : 'none'}
|
minHeight={loaded && !scanning ? '100%' : 'none'}
|
||||||
height={loaded ? 'none' : '100%'}
|
height={loaded && !scanning ? 'none' : '100%'}
|
||||||
style={{ filter: blur ? 'blur(8px)' : 'none' }}
|
style={{ filter: blur ? 'blur(8px)' : 'none' }}
|
||||||
px={[0, 4]}
|
px={[0, 4]}
|
||||||
pb={[0, 4]}
|
pb={[0, 4]}
|
||||||
|
@ -43,6 +43,8 @@ export const SettingsContext = createContext({
|
|||||||
setError: () => {},
|
setError: () => {},
|
||||||
broadcastSuccess: false,
|
broadcastSuccess: false,
|
||||||
setBroadcastSuccess: () => {},
|
setBroadcastSuccess: () => {},
|
||||||
|
scanProgress: { main: null, change: null },
|
||||||
|
setScanProgress: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const SettingsProvider = ({ channel, children }) => {
|
export const SettingsProvider = ({ channel, children }) => {
|
||||||
@ -69,6 +71,10 @@ export const SettingsProvider = ({ channel, children }) => {
|
|||||||
const [showWarning, setShowWarning] = useState(false);
|
const [showWarning, setShowWarning] = useState(false);
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
const [broadcastSuccess, setBroadcastSuccess] = useState(false);
|
const [broadcastSuccess, setBroadcastSuccess] = useState(false);
|
||||||
|
const [scanProgress, setScanProgress] = useState({
|
||||||
|
main: null,
|
||||||
|
change: null,
|
||||||
|
});
|
||||||
|
|
||||||
const { Provider } = SettingsContext;
|
const { Provider } = SettingsContext;
|
||||||
|
|
||||||
@ -185,6 +191,7 @@ export const SettingsProvider = ({ channel, children }) => {
|
|||||||
const errorData = channelData?.data?.error;
|
const errorData = channelData?.data?.error;
|
||||||
const broadcastSuccessData = channelData?.data?.['broadcast-success'];
|
const broadcastSuccessData = channelData?.data?.['broadcast-success'];
|
||||||
const broadcastFailData = channelData?.data?.['broadcast-fail'];
|
const broadcastFailData = channelData?.data?.['broadcast-fail'];
|
||||||
|
const scanProgressData = channelData?.data?.['scan-progress'];
|
||||||
if (initialData) {
|
if (initialData) {
|
||||||
setProvider(initialData.provider);
|
setProvider(initialData.provider);
|
||||||
setWallet(initialData.wallet);
|
setWallet(initialData.wallet);
|
||||||
@ -254,6 +261,9 @@ export const SettingsProvider = ({ channel, children }) => {
|
|||||||
if (broadcastFailData) {
|
if (broadcastFailData) {
|
||||||
setBroadcastSuccess(false);
|
setBroadcastSuccess(false);
|
||||||
}
|
}
|
||||||
|
if (scanProgressData) {
|
||||||
|
setScanProgress(scanProgressData);
|
||||||
|
}
|
||||||
}, [channelData]);
|
}, [channelData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -306,6 +316,8 @@ export const SettingsProvider = ({ channel, children }) => {
|
|||||||
setError,
|
setError,
|
||||||
broadcastSuccess,
|
broadcastSuccess,
|
||||||
setBroadcastSuccess,
|
setBroadcastSuccess,
|
||||||
|
scanProgress,
|
||||||
|
setScanProgress,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
Loading…
Reference in New Issue
Block a user