Skip to content

Commit 5a48226

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 c997943 commit 5a48226

File tree

366 files changed

+11830
-8783
lines changed

Some content is hidden

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

366 files changed

+11830
-8783
lines changed

frontends/web/src/api/account.ts

+301-184
Large diffs are not rendered by default.

frontends/web/src/api/accountsync.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { subscribe as subscribeLegacy } from '@/utils/event-legacy';
2525
* Returns a method to unsubscribe.
2626
*/
2727
export const syncAccountsList = (
28-
cb: (accounts: accountAPI.IAccount[],) => void
28+
cb: (accounts: accountAPI.IAccount[]) => void,
2929
): TUnsubscribe => {
3030
return subscribeEndpoint('accounts', cb);
3131
};
@@ -36,14 +36,13 @@ export const syncAccountsList = (
3636
* Meant to be used with `useSubscribe`.
3737
*/
3838
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-
) => {
45-
cb(count);
46-
});
39+
return (cb: TSubscriptionCallback<number>) => {
40+
return subscribeEndpoint(
41+
`account/${code}/synced-addresses-count`,
42+
(count: number) => {
43+
cb(count);
44+
},
45+
);
4746
};
4847
};
4948

@@ -55,7 +54,7 @@ export const syncAddressesCount = (code: accountAPI.AccountCode) => {
5554
export const statusChanged = (
5655
cb: (code: accountAPI.AccountCode) => void,
5756
): TUnsubscribe => {
58-
const unsubscribe = subscribeLegacy('statusChanged', event => {
57+
const unsubscribe = subscribeLegacy('statusChanged', (event) => {
5958
if (event.type === 'account' && event.code) {
6059
cb(event.code);
6160
}
@@ -70,7 +69,7 @@ export const statusChanged = (
7069
export const syncdone = (
7170
cb: (code: accountAPI.AccountCode) => void,
7271
): TUnsubscribe => {
73-
return subscribeLegacy('syncdone', event => {
72+
return subscribeLegacy('syncdone', (event) => {
7473
if (event.type === 'account' && event.code) {
7574
cb(event.code);
7675
}

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

+53-36
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@ 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[]> => {
3636
return apiGet('supported-coins');
3737
};
3838

39-
export const setAccountActive = (accountCode: AccountCode, active: boolean): Promise<ISuccess> => {
39+
export const setAccountActive = (
40+
accountCode: AccountCode,
41+
active: boolean,
42+
): Promise<ISuccess> => {
4043
return apiPost('set-account-active', { accountCode, active });
4144
};
4245

@@ -48,7 +51,10 @@ export const setTokenActive = (
4851
return apiPost('set-token-active', { accountCode, tokenCode, active });
4952
};
5053

51-
export const renameAccount = (accountCode: AccountCode, name: string): Promise<ISuccess> => {
54+
export const renameAccount = (
55+
accountCode: AccountCode,
56+
name: string,
57+
): Promise<ISuccess> => {
5258
return apiPost('rename-account', { accountCode, name });
5359
};
5460

@@ -64,7 +70,7 @@ export const getDevServers = (): Promise<boolean> => {
6470
return apiGet('dev-servers');
6571
};
6672

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

6975
export const getQRCode = (data: string) => {
7076
return (): Promise<TQRCode> => {
@@ -82,36 +88,41 @@ export const socksProxyCheck = (proxyAddress: string): Promise<ISuccess> => {
8288

8389
export type TConnectKeystoreErrorCode = 'wrongKeystore' | 'timeout';
8490

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

94103
/**
95104
* Returns a function that subscribes a callback on a "connect-keystore".
96105
* Meant to be used with `useSubscribe`.
97106
*/
98107
export const syncConnectKeystore = () => {
99-
return (
100-
cb: TSubscriptionCallback<TSyncConnectKeystore>
101-
) => {
102-
return subscribeEndpoint('connect-keystore', (
103-
obj: TSyncConnectKeystore,
104-
) => {
105-
cb(obj);
106-
});
108+
return (cb: TSubscriptionCallback<TSyncConnectKeystore>) => {
109+
return subscribeEndpoint(
110+
'connect-keystore',
111+
(obj: TSyncConnectKeystore) => {
112+
cb(obj);
113+
},
114+
);
107115
};
108116
};
109117

110118
export const cancelConnectKeystore = (): Promise<void> => {
111119
return apiPost('cancel-connect-keystore');
112120
};
113121

114-
export const setWatchonly = (rootFingerprint: string, watchonly: boolean): Promise<ISuccess> => {
122+
export const setWatchonly = (
123+
rootFingerprint: string,
124+
watchonly: boolean,
125+
): Promise<ISuccess> => {
115126
return apiPost('set-watchonly', { rootFingerprint, watchonly });
116127
};
117128

@@ -124,14 +135,16 @@ export const forceAuth = (): Promise<void> => {
124135
};
125136

126137
export type TAuthEventObject = {
127-
typ: 'auth-required' | 'auth-forced' | 'auth-canceled' | 'auth-ok' | 'auth-err' ;
138+
typ:
139+
| 'auth-required'
140+
| 'auth-forced'
141+
| 'auth-canceled'
142+
| 'auth-ok'
143+
| 'auth-err';
128144
};
129145

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

136149
export const onAuthSettingChanged = (): Promise<void> => {
137150
return apiPost('on-auth-setting-changed');
@@ -141,7 +154,9 @@ export const exportLogs = (): Promise<ISuccess> => {
141154
return apiPost('export-log');
142155
};
143156

144-
export const exportNotes = (): Promise<(FailResponse & { aborted: boolean; }) | SuccessResponse> => {
157+
export const exportNotes = (): Promise<
158+
(FailResponse & { aborted: boolean }) | SuccessResponse
159+
> => {
145160
return apiPost('notes/export');
146161
};
147162

@@ -150,9 +165,11 @@ export type TImportNotes = {
150165
transactionCount: number;
151166
};
152167

153-
export const importNotes = (fileContents: ArrayBuffer): Promise<FailResponse | (SuccessResponse & { data: TImportNotes; })> => {
168+
export const importNotes = (
169+
fileContents: ArrayBuffer,
170+
): Promise<FailResponse | (SuccessResponse & { data: TImportNotes })> => {
154171
const hexString = Array.from(new Uint8Array(fileContents))
155-
.map(byte => byte.toString(16).padStart(2, '0'))
172+
.map((byte) => byte.toString(16).padStart(2, '0'))
156173
.join('');
157174
return apiPost('notes/import', hexString);
158175
};

frontends/web/src/api/backup.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ 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

1616
export const getBackupList = (
17-
deviceID: string
17+
deviceID: string,
1818
): Promise<BackupResponse | FailResponse> => {
1919
return apiGet(`devices/bitbox02/${deviceID}/backups/list`);
2020
};
2121

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

frontends/web/src/api/banners.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ 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}`);

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)