Skip to content

Commit 77760f5

Browse files
committed
frontend/formatting: format files with prettier
`prettier --write "**/*.{ts,tsx,js,jsx}"` launched from frontend/web/src/ Please note that `hooks/api.ts` has been slightly modified, to keep the `react-hooks/exhaustive-deps` lint disable active.
1 parent 25df6ba commit 77760f5

File tree

357 files changed

+7444
-9208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

357 files changed

+7444
-9208
lines changed

frontends/web/src/api/account.ts

+209-166
Large diffs are not rendered by default.

frontends/web/src/api/accountsync.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import { subscribe as subscribeLegacy } from '@/utils/event-legacy';
2424
* list of all available accounts from the backend.
2525
* Returns a method to unsubscribe.
2626
*/
27-
export const syncAccountsList = (
28-
cb: (accounts: accountAPI.IAccount[],) => void
29-
): TUnsubscribe => {
27+
export const syncAccountsList = (cb: (accounts: accountAPI.IAccount[]) => void): TUnsubscribe => {
3028
return subscribeEndpoint('accounts', cb);
3129
};
3230

@@ -36,12 +34,8 @@ export const syncAccountsList = (
3634
* Meant to be used with `useSubscribe`.
3735
*/
3836
export const syncAddressesCount = (code: accountAPI.AccountCode) => {
39-
return (
40-
cb: TSubscriptionCallback<number>
41-
) => {
42-
return subscribeEndpoint(`account/${code}/synced-addresses-count`, (
43-
count: number,
44-
) => {
37+
return (cb: TSubscriptionCallback<number>) => {
38+
return subscribeEndpoint(`account/${code}/synced-addresses-count`, (count: number) => {
4539
cb(count);
4640
});
4741
};
@@ -52,10 +46,8 @@ export const syncAddressesCount = (code: accountAPI.AccountCode) => {
5246
* used as event to call accountAPI.getStatus(code).
5347
* Returns a method to unsubscribe.
5448
*/
55-
export const statusChanged = (
56-
cb: (code: accountAPI.AccountCode) => void,
57-
): TUnsubscribe => {
58-
const unsubscribe = subscribeLegacy('statusChanged', event => {
49+
export const statusChanged = (cb: (code: accountAPI.AccountCode) => void): TUnsubscribe => {
50+
const unsubscribe = subscribeLegacy('statusChanged', (event) => {
5951
if (event.type === 'account' && event.code) {
6052
cb(event.code);
6153
}
@@ -67,10 +59,8 @@ export const statusChanged = (
6759
* Fired when the account is fully synced.
6860
* Returns a method to unsubscribe.
6961
*/
70-
export const syncdone = (
71-
cb: (code: accountAPI.AccountCode) => void,
72-
): TUnsubscribe => {
73-
return subscribeLegacy('syncdone', event => {
62+
export const syncdone = (cb: (code: accountAPI.AccountCode) => void): TUnsubscribe => {
63+
return subscribeLegacy('syncdone', (event) => {
7464
if (event.type === 'account' && event.code) {
7565
cb(event.code);
7666
}

frontends/web/src/api/aopp.ts

+41-30
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,51 @@ import type { TUnsubscribe } from '@/utils/transport-common';
2020
import { subscribeEndpoint } from './subscribe';
2121

2222
export interface Account {
23-
name: string;
24-
code: AccountCode;
23+
name: string;
24+
code: AccountCode;
2525
}
2626

2727
interface Accounts extends Array<Account> {
28-
0: Account,
28+
0: Account;
2929
}
3030

31-
export type Aopp = {
32-
state: 'error';
33-
errorCode: 'aoppUnsupportedAsset' | 'aoppVersion' | 'aoppInvalidRequest' | 'aoppNoAccounts' | 'aoppUnsupportedKeystore' | 'aoppUnknown' | 'aoppSigningAborted' | 'aoppCallback';
34-
callback: string;
35-
} | {
36-
state: 'inactive';
37-
} | {
38-
state: 'user-approval' | 'awaiting-keystore' | 'syncing';
39-
message: string;
40-
callback: string;
41-
xpubRequired: boolean;
42-
} | {
43-
state: 'choosing-account';
44-
accounts: Accounts;
45-
message: string;
46-
callback: string;
47-
} | {
48-
state: 'signing' | 'success';
49-
address: string;
50-
addressID: string;
51-
message: string;
52-
callback: string;
53-
accountCode: AccountCode;
54-
};
31+
export type Aopp =
32+
| {
33+
state: 'error';
34+
errorCode:
35+
| 'aoppUnsupportedAsset'
36+
| 'aoppVersion'
37+
| 'aoppInvalidRequest'
38+
| 'aoppNoAccounts'
39+
| 'aoppUnsupportedKeystore'
40+
| 'aoppUnknown'
41+
| 'aoppSigningAborted'
42+
| 'aoppCallback';
43+
callback: string;
44+
}
45+
| {
46+
state: 'inactive';
47+
}
48+
| {
49+
state: 'user-approval' | 'awaiting-keystore' | 'syncing';
50+
message: string;
51+
callback: string;
52+
xpubRequired: boolean;
53+
}
54+
| {
55+
state: 'choosing-account';
56+
accounts: Accounts;
57+
message: string;
58+
callback: string;
59+
}
60+
| {
61+
state: 'signing' | 'success';
62+
address: string;
63+
addressID: string;
64+
message: string;
65+
callback: string;
66+
accountCode: AccountCode;
67+
};
5568

5669
export const cancel = (): Promise<null> => {
5770
return apiPost('aopp/cancel');
@@ -69,8 +82,6 @@ export const getAOPP = (): Promise<Aopp> => {
6982
return apiGet('aopp');
7083
};
7184

72-
export const subscribeAOPP = (
73-
cb: (aopp: Aopp) => void
74-
): TUnsubscribe => {
85+
export const subscribeAOPP = (cb: (aopp: Aopp) => void): TUnsubscribe => {
7586
return subscribeEndpoint('aopp', cb);
7687
};

frontends/web/src/api/backend.ts

+29-32
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import { apiGet, apiPost } from '@/utils/request';
2020
import { TSubscriptionCallback, subscribeEndpoint } from './subscribe';
2121

2222
export interface ICoin {
23-
coinCode: CoinCode;
24-
name: string;
25-
canAddAccount: boolean;
26-
suggestedAccountName: string;
23+
coinCode: CoinCode;
24+
name: string;
25+
canAddAccount: boolean;
26+
suggestedAccountName: string;
2727
}
2828

2929
export interface ISuccess {
30-
success: boolean;
31-
errorMessage?: string;
32-
errorCode?: string;
30+
success: boolean;
31+
errorMessage?: string;
32+
errorCode?: string;
3333
}
3434

3535
export const getSupportedCoins = (): Promise<ICoin[]> => {
@@ -43,7 +43,7 @@ export const setAccountActive = (accountCode: AccountCode, active: boolean): Pro
4343
export const setTokenActive = (
4444
accountCode: AccountCode,
4545
tokenCode: ERC20CoinCode,
46-
active: boolean,
46+
active: boolean
4747
): Promise<ISuccess> => {
4848
return apiPost('set-token-active', { accountCode, tokenCode, active });
4949
};
@@ -64,7 +64,7 @@ export const getDevServers = (): Promise<boolean> => {
6464
return apiGet('dev-servers');
6565
};
6666

67-
export type TQRCode = FailResponse | (SuccessResponse & { data: string; });
67+
export type TQRCode = FailResponse | (SuccessResponse & { data: string });
6868

6969
export const getQRCode = (data: string) => {
7070
return (): Promise<TQRCode> => {
@@ -82,26 +82,25 @@ export const socksProxyCheck = (proxyAddress: string): Promise<ISuccess> => {
8282

8383
export type TConnectKeystoreErrorCode = 'wrongKeystore' | 'timeout';
8484

85-
export type TSyncConnectKeystore = null | {
86-
typ: 'connect';
87-
keystoreName: string;
88-
} | {
89-
typ: 'error';
90-
errorCode?: TConnectKeystoreErrorCode;
91-
errorMessage: string;
92-
};
85+
export type TSyncConnectKeystore =
86+
| null
87+
| {
88+
typ: 'connect';
89+
keystoreName: string;
90+
}
91+
| {
92+
typ: 'error';
93+
errorCode?: TConnectKeystoreErrorCode;
94+
errorMessage: string;
95+
};
9396

9497
/**
9598
* Returns a function that subscribes a callback on a "connect-keystore".
9699
* Meant to be used with `useSubscribe`.
97100
*/
98101
export const syncConnectKeystore = () => {
99-
return (
100-
cb: TSubscriptionCallback<TSyncConnectKeystore>
101-
) => {
102-
return subscribeEndpoint('connect-keystore', (
103-
obj: TSyncConnectKeystore,
104-
) => {
102+
return (cb: TSubscriptionCallback<TSyncConnectKeystore>) => {
103+
return subscribeEndpoint('connect-keystore', (obj: TSyncConnectKeystore) => {
105104
cb(obj);
106105
});
107106
};
@@ -124,14 +123,10 @@ export const forceAuth = (): Promise<void> => {
124123
};
125124

126125
export type TAuthEventObject = {
127-
typ: 'auth-required' | 'auth-forced' | 'auth-canceled' | 'auth-ok' | 'auth-err' ;
126+
typ: 'auth-required' | 'auth-forced' | 'auth-canceled' | 'auth-ok' | 'auth-err';
128127
};
129128

130-
export const subscribeAuth = (
131-
cb: TSubscriptionCallback<TAuthEventObject>
132-
) => (
133-
subscribeEndpoint('auth', cb)
134-
);
129+
export const subscribeAuth = (cb: TSubscriptionCallback<TAuthEventObject>) => subscribeEndpoint('auth', cb);
135130

136131
export const onAuthSettingChanged = (): Promise<void> => {
137132
return apiPost('on-auth-setting-changed');
@@ -141,7 +136,7 @@ export const exportLogs = (): Promise<ISuccess> => {
141136
return apiPost('export-log');
142137
};
143138

144-
export const exportNotes = (): Promise<(FailResponse & { aborted: boolean; }) | SuccessResponse> => {
139+
export const exportNotes = (): Promise<(FailResponse & { aborted: boolean }) | SuccessResponse> => {
145140
return apiPost('notes/export');
146141
};
147142

@@ -150,9 +145,11 @@ export type TImportNotes = {
150145
transactionCount: number;
151146
};
152147

153-
export const importNotes = (fileContents: ArrayBuffer): Promise<FailResponse | (SuccessResponse & { data: TImportNotes; })> => {
148+
export const importNotes = (
149+
fileContents: ArrayBuffer
150+
): Promise<FailResponse | (SuccessResponse & { data: TImportNotes })> => {
154151
const hexString = Array.from(new Uint8Array(fileContents))
155-
.map(byte => byte.toString(16).padStart(2, '0'))
152+
.map((byte) => byte.toString(16).padStart(2, '0'))
156153
.join('');
157154
return apiPost('notes/import', hexString);
158155
};

frontends/web/src/api/backup.ts

+9-14
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@ import { FailResponse } from './response';
33
import { TSubscriptionCallback, subscribeEndpoint } from './subscribe';
44

55
export type Backup = {
6-
id: string;
7-
date: string;
8-
name: string;
6+
id: string;
7+
date: string;
8+
name: string;
99
};
1010

1111
type BackupResponse = {
12-
success: true;
13-
backups: Backup[];
14-
}
12+
success: true;
13+
backups: Backup[];
14+
};
1515

16-
export const getBackupList = (
17-
deviceID: string
18-
): Promise<BackupResponse | FailResponse> => {
16+
export const getBackupList = (deviceID: string): Promise<BackupResponse | FailResponse> => {
1917
return apiGet(`devices/bitbox02/${deviceID}/backups/list`);
2018
};
2119

22-
export const subscribeBackupList = (deviceID: string) => (
23-
(cb: TSubscriptionCallback<BackupResponse>) => (
24-
subscribeEndpoint(`devices/bitbox02/${deviceID}/backups/list`, cb)
25-
)
26-
);
20+
export const subscribeBackupList = (deviceID: string) => (cb: TSubscriptionCallback<BackupResponse>) =>
21+
subscribeEndpoint(`devices/bitbox02/${deviceID}/backups/list`, cb);

frontends/web/src/api/banners.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,19 @@ import type { TMessageTypes } from '@/utils/types';
2020

2121
export type TBannerInfo = {
2222
id: string;
23-
message: { [key: string]: string; };
23+
message: { [key: string]: string };
2424
link?: {
2525
href: string;
2626
text?: string;
2727
};
2828
dismissible?: boolean;
2929
type?: TMessageTypes;
30-
}
30+
};
3131

3232
export const getBanner = (msgKey: string): Promise<TBannerInfo> => {
3333
return apiGet(`banners/${msgKey}`);
3434
};
3535

36-
export const syncBanner = (
37-
msgKey: string,
38-
cb: (banner: TBannerInfo) => void,
39-
): TUnsubscribe => {
36+
export const syncBanner = (msgKey: string, cb: (banner: TBannerInfo) => void): TUnsubscribe => {
4037
return subscribeEndpoint(`banners/${msgKey}`, cb);
4138
};

frontends/web/src/api/bitbox01.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ export type DeviceInfo = {
3232
version: string;
3333
};
3434

35-
export const getDeviceInfo = (
36-
deviceID: string,
37-
): Promise<DeviceInfo | null> => {
35+
export const getDeviceInfo = (deviceID: string): Promise<DeviceInfo | null> => {
3836
return apiGet(`devices/${deviceID}/info`);
3937
};

0 commit comments

Comments
 (0)