Skip to content

Commit

Permalink
Merge pull request #40 from tonkeeper/feature/pro-dashboard
Browse files Browse the repository at this point in the history
PRO Dashboard
  • Loading branch information
KuznetsovNikita authored Mar 12, 2024
2 parents a604d52 + fcbd946 commit 7819fd2
Show file tree
Hide file tree
Showing 70 changed files with 4,309 additions and 421 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
REACT_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }}
REACT_APP_TONCONSOLE_API: https://pro.tonconsole.com
REACT_APP_TG_BOT_ORIGIN: https://tonkeeper.com
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron*

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
REACT_APP_AMPLITUDE: ${{ secrets.REACT_APP_AMPLITUDE }}
REACT_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }}
REACT_APP_TONCONSOLE_API: https://pro.tonconsole.com
REACT_APP_TG_BOT_ORIGIN: https://tonkeeper.com
DEBUG: electron*

steps:
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REACT_APP_TONCONSOLE_API=https://dev-pro.tonconsole.com
REACT_APP_TG_BOT_ID=6345183204
REACT_APP_TG_BOT_ORIGIN=https://tonkeeper.com
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tonkeeper/desktop",
"license": "Apache-2.0",
"version": "3.7.1",
"version": "3.8.0",
"description": "Your desktop wallet on The Open Network",
"main": ".webpack/main",
"repository": {
Expand Down
20 changes: 16 additions & 4 deletions apps/desktop/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const langs = 'en,zh_CN,ru,it,tr';
const listOfAuth: AuthState['kind'][] = ['keychain'];

declare const REACT_APP_TONCONSOLE_API: string;
declare const REACT_APP_TG_BOT_ID: string;

export const App = () => {
const { t, i18n } = useTranslation();
Expand Down Expand Up @@ -179,7 +180,7 @@ const WideLayout = styled.div`
display: flex;
& > *:first-child {
width: 200px;
width: 250px;
}
`;

Expand Down Expand Up @@ -268,8 +269,11 @@ export const Loader: FC = () => {
tonendpoint,
standalone: true,
extension: false,
proFeatures: false, // TODO: enable
ios: false
proFeatures: true,
ios: false,
env: {
tgAuthBotId: REACT_APP_TG_BOT_ID
}
};

return (
Expand Down Expand Up @@ -332,6 +336,7 @@ export const Content: FC<{
<Route path="*" element={<WalletContent />} />
</Routes>
</WideContent>
<BackgroundElements />
</WideLayout>
</WalletStateContext.Provider>
);
Expand Down Expand Up @@ -366,6 +371,13 @@ const OldAppRouting = () => {
<Wrapper>
<Outlet />
<MemoryScroll />
</Wrapper>
);
};

const BackgroundElements = () => {
return (
<>
<SendActionNotification />
<ReceiveNotification />
<TonConnectSubscription />
Expand All @@ -374,6 +386,6 @@ const OldAppRouting = () => {
<AddFavoriteNotification />
<EditFavoriteNotification />
<DeepLinkSubscription />
</Wrapper>
</>
);
};
30 changes: 23 additions & 7 deletions apps/desktop/src/electron/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export abstract class MainWindow {
static mainWindow: BrowserWindow | undefined = undefined;

static async openMainWindow() {
if (this.mainWindow != undefined) return this.mainWindow;
if (this.mainWindow !== undefined) return this.mainWindow;

const icon = (() => {
switch (process.platform) {
Expand All @@ -43,9 +43,7 @@ export abstract class MainWindow {
height: 750,
minHeight: 700,
resizable: isDev,
autoHideMenuBar: process.platform != 'darwin',
webPreferences: {
zoomFactor: process.platform !== 'linux' ? 0.8 : undefined,
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY
}
});
Expand Down Expand Up @@ -80,11 +78,20 @@ export abstract class MainWindow {
}
const result = cookies
.map(cookie => `${cookie.key}=${cookie.value}`)
.join(', ');
.join('; ');

/* patch tg auth headers */
if (details.url === 'https://oauth.telegram.org/auth/get') {
details.requestHeaders.origin = 'https://tonkeeper.com';
details.requestHeaders.referer = 'https://tonkeeper.com';
}

callback({
requestHeaders: Object.assign(details.requestHeaders, {
...details,
requestHeaders: {
...details.requestHeaders,
cookie: result
})
}
});
});
}
Expand All @@ -93,12 +100,21 @@ export abstract class MainWindow {
this.mainWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => {
const setCookie = details.responseHeaders['set-cookie'] ?? [];

/* patch tg auth headers cors */
if (details.url === 'https://oauth.telegram.org/auth/get') {
const corsHeader =
Object.keys(details.responseHeaders).find(
k => k.toLowerCase() === 'access-control-allow-origin'
) || 'access-control-allow-origin';
details.responseHeaders[corsHeader] = ['*'];
}

Promise.all(
setCookie.map(cookieRaw =>
cookieJar.setCookie(Cookie.parse(cookieRaw), details.url)
)
).finally(() => {
callback({});
callback(details);
});
});

Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&amp;display=swap"
rel="stylesheet"
/>

</head>
<body style="background:#10161F">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
</html>
1 change: 1 addition & 0 deletions apps/desktop/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ log.info('UI Start-up');
Object.assign(console, log.functions);
console.log('👋 This message is being logged by "renderer.js", included via webpack');

import './telegram-widget';
import './react';
Loading

0 comments on commit 7819fd2

Please sign in to comment.