Skip to content

Commit b02e97f

Browse files
committed
Merge branch 'frontend-group-providers'
2 parents 174b76f + 6142c20 commit b02e97f

File tree

2 files changed

+83
-53
lines changed

2 files changed

+83
-53
lines changed

frontends/web/src/app.tsx

+44-53
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ import { Sidebar } from './components/sidebar/sidebar';
4040
import { Update } from './components/update/update';
4141
import { RouterWatcher } from './utils/route';
4242
import { Darkmode } from './components/darkmode/darkmode';
43-
import { DarkModeProvider } from './contexts/DarkmodeProvider';
44-
import { AppProvider } from './contexts/AppProvider';
4543
import { AuthRequired } from './components/auth/authrequired';
46-
import { WCWeb3WalletProvider } from './contexts/WCWeb3WalletProvider';
47-
import { RatesProvider } from './contexts/RatesProvider';
4844
import { WCSigningRequest } from './components/wallet-connect/incoming-signing-request';
45+
import { Providers } from './contexts/providers';
4946

5047
export const App = () => {
5148
const { t } = useTranslation();
@@ -148,55 +145,49 @@ export const App = () => {
148145
const activeAccounts = accounts.filter(acct => acct.active);
149146
return (
150147
<ConnectedApp>
151-
<AppProvider>
152-
<DarkModeProvider>
153-
<RatesProvider>
154-
<WCWeb3WalletProvider>
155-
<Darkmode />
156-
<div className="app">
157-
<AuthRequired/>
158-
<Sidebar
159-
accounts={activeAccounts}
160-
deviceIDs={deviceIDs}
161-
/>
162-
<div className="appContent flex flex-column flex-1" style={{ minWidth: 0 }}>
163-
<Update />
164-
<Banner msgKey="bitbox01" />
165-
<Banner msgKey="bitbox02" />
166-
<MobileDataWarning />
167-
<WCSigningRequest />
168-
<Aopp />
169-
<KeystoreConnectPrompt />
170-
{
171-
Object.entries(devices).map(([deviceID, productName]) => {
172-
if (productName === 'bitbox02') {
173-
return (
174-
<Fragment key={deviceID}>
175-
<BitBox02Wizard
176-
deviceID={deviceID}
177-
/>
178-
</Fragment>
179-
);
180-
}
181-
return null;
182-
})
183-
}
184-
<AppRouter
185-
accounts={accounts}
186-
activeAccounts={activeAccounts}
187-
deviceIDs={deviceIDs}
188-
devices={devices}
189-
devicesKey={devicesKey}
190-
/>
191-
<RouterWatcher />
192-
</div>
193-
<Alert />
194-
<Confirm />
195-
</div>
196-
</WCWeb3WalletProvider>
197-
</RatesProvider>
198-
</DarkModeProvider>
199-
</AppProvider>
148+
<Providers>
149+
<Darkmode />
150+
<div className="app">
151+
<AuthRequired/>
152+
<Sidebar
153+
accounts={activeAccounts}
154+
deviceIDs={deviceIDs}
155+
/>
156+
<div className="appContent flex flex-column flex-1" style={{ minWidth: 0 }}>
157+
<Update />
158+
<Banner msgKey="bitbox01" />
159+
<Banner msgKey="bitbox02" />
160+
<MobileDataWarning />
161+
<WCSigningRequest />
162+
<Aopp />
163+
<KeystoreConnectPrompt />
164+
{
165+
Object.entries(devices).map(([deviceID, productName]) => {
166+
if (productName === 'bitbox02') {
167+
return (
168+
<Fragment key={deviceID}>
169+
<BitBox02Wizard
170+
deviceID={deviceID}
171+
/>
172+
</Fragment>
173+
);
174+
}
175+
return null;
176+
})
177+
}
178+
<AppRouter
179+
accounts={accounts}
180+
activeAccounts={activeAccounts}
181+
deviceIDs={deviceIDs}
182+
devices={devices}
183+
devicesKey={devicesKey}
184+
/>
185+
<RouterWatcher />
186+
</div>
187+
<Alert />
188+
<Confirm />
189+
</div>
190+
</Providers>
200191
</ConnectedApp>
201192
);
202193
};
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright 2024 Shift Crypto AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { ReactNode } from 'react';
18+
import { DarkModeProvider } from './DarkmodeProvider';
19+
import { AppProvider } from './AppProvider';
20+
import { WCWeb3WalletProvider } from './WCWeb3WalletProvider';
21+
import { RatesProvider } from './RatesProvider';
22+
23+
type Props = {
24+
children: ReactNode;
25+
};
26+
27+
export const Providers = ({ children }: Props) => {
28+
return (
29+
<AppProvider>
30+
<DarkModeProvider>
31+
<RatesProvider>
32+
<WCWeb3WalletProvider>
33+
{children}
34+
</WCWeb3WalletProvider>
35+
</RatesProvider>
36+
</DarkModeProvider>
37+
</AppProvider>
38+
);
39+
};

0 commit comments

Comments
 (0)