Skip to content

Commit 12e6e60

Browse files
committed
Merge branch 'frontend-consistent-types'
2 parents a53aaa9 + e8aa5f1 commit 12e6e60

Some content is hidden

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

79 files changed

+503
-443
lines changed

frontends/web/src/api/account.ts

Lines changed: 100 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export type ERC20CoinCode = 'erc20Test' | 'eth-erc20-usdt' | 'eth-erc20-usdc' |
3838
export type CoinCode = NativeCoinCode | ERC20CoinCode;
3939

4040
export type FiatWithDisplayName = {
41-
currency: Fiat,
42-
displayName: string
41+
currency: Fiat;
42+
displayName: string;
4343
}
4444

4545
export type Terc20Token = {
@@ -48,7 +48,7 @@ export type Terc20Token = {
4848
unit: ERC20TokenUnit;
4949
};
5050

51-
export interface IActiveToken {
51+
export type TActiveToken = {
5252
tokenCode: ERC20CoinCode;
5353
accountCode: AccountCode;
5454
}
@@ -61,7 +61,7 @@ export type TKeystore = {
6161
connected: boolean;
6262
};
6363

64-
export interface IAccount {
64+
export type TAccount = {
6565
keystore: TKeystore;
6666
active: boolean;
6767
watch: boolean;
@@ -71,12 +71,12 @@ export interface IAccount {
7171
code: AccountCode;
7272
name: string;
7373
isToken: boolean;
74-
activeTokens?: IActiveToken[];
74+
activeTokens?: TActiveToken[];
7575
blockExplorerTxPrefix: string;
7676
bitsuranceStatus?: TDetailStatus;
7777
}
7878

79-
export const getAccounts = (): Promise<IAccount[]> => {
79+
export const getAccounts = (): Promise<TAccount[]> => {
8080
return apiGet('accounts');
8181
};
8282

@@ -91,9 +91,9 @@ export type TAmountsByCoin = {
9191
};
9292

9393
export type TKeystoreBalance = {
94-
fiatUnit: ConversionUnit;
95-
total: string;
96-
coinsBalance?: TAmountsByCoin;
94+
fiatUnit: ConversionUnit;
95+
total: string;
96+
coinsBalance?: TAmountsByCoin;
9797
};
9898

9999
export type TKeystoresBalance = {
@@ -125,46 +125,46 @@ export const getEthAccountCodeAndNameByAddress = (address: string): Promise<TEth
125125
return apiPost('accounts/eth-account-code', { address });
126126
};
127127

128-
export interface IStatus {
129-
disabled: boolean;
130-
synced: boolean;
131-
fatalError: boolean;
132-
offlineError: string | null;
128+
export type TStatus = {
129+
disabled: boolean;
130+
synced: boolean;
131+
fatalError: boolean;
132+
offlineError: string | null;
133133
}
134134

135-
export const getStatus = (code: AccountCode): Promise<IStatus> => {
135+
export const getStatus = (code: AccountCode): Promise<TStatus> => {
136136
return apiGet(`account/${code}/status`);
137137
};
138138

139139
export type ScriptType = 'p2pkh' | 'p2wpkh-p2sh' | 'p2wpkh' | 'p2tr';
140140

141141
export const allScriptTypes: ScriptType[] = ['p2pkh', 'p2wpkh-p2sh', 'p2wpkh', 'p2tr'];
142142

143-
export interface IKeyInfo {
144-
keypath: string;
145-
rootFingerprint: string;
146-
xpub: string;
143+
type TKeyInfo = {
144+
keypath: string;
145+
rootFingerprint: string;
146+
xpub: string;
147147
}
148148

149149
export type TBitcoinSimple = {
150-
keyInfo: IKeyInfo;
151-
scriptType: ScriptType;
150+
keyInfo: TKeyInfo;
151+
scriptType: ScriptType;
152152
}
153153

154154
export type TEthereumSimple = {
155-
keyInfo: IKeyInfo;
155+
keyInfo: TKeyInfo;
156156
}
157157

158158
export type TSigningConfiguration = {
159-
bitcoinSimple: TBitcoinSimple;
160-
ethereumSimple?: never;
159+
bitcoinSimple: TBitcoinSimple;
160+
ethereumSimple?: never;
161161
} | {
162-
bitcoinSimple?: never;
163-
ethereumSimple: TEthereumSimple;
162+
bitcoinSimple?: never;
163+
ethereumSimple: TEthereumSimple;
164164
}
165165

166166
export type TSigningConfigurationList = null | {
167-
signingConfigurations: TSigningConfiguration[];
167+
signingConfigurations: TSigningConfiguration[];
168168
}
169169

170170
export const getInfo = (code: AccountCode) => {
@@ -183,49 +183,49 @@ export type FormattedLineData = LineData & {
183183

184184
export type ChartData = FormattedLineData[];
185185

186-
export type TChartDataResponse = {
187-
success: true;
188-
data: TChartData;
186+
type TChartDataResponse = {
187+
success: true;
188+
data: TChartData;
189189
} | {
190190
success: false;
191191
}
192192

193193
export type TChartData = {
194-
chartDataMissing: boolean;
195-
chartDataDaily: ChartData;
196-
chartDataHourly: ChartData;
197-
chartFiat: ConversionUnit;
198-
chartTotal: number | null;
199-
formattedChartTotal: string | null;
200-
chartIsUpToDate: boolean; // only valid if chartDataMissing is false
201-
lastTimestamp: number;
194+
chartDataMissing: boolean;
195+
chartDataDaily: ChartData;
196+
chartDataHourly: ChartData;
197+
chartFiat: ConversionUnit;
198+
chartTotal: number | null;
199+
formattedChartTotal: string | null;
200+
chartIsUpToDate: boolean; // only valid if chartDataMissing is false
201+
lastTimestamp: number;
202202
}
203203

204204
export const getChartData = (): Promise<TChartDataResponse> => {
205205
return apiGet('chart-data');
206206
};
207207

208-
export type Conversions = {
209-
[key in Fiat]?: string;
208+
type Conversions = {
209+
[key in Fiat]?: string;
210210
};
211211

212212
export type TAmountWithConversions = {
213-
amount: string;
214-
conversions?: Conversions;
215-
unit: CoinUnit;
216-
estimated: boolean;
213+
amount: string;
214+
conversions?: Conversions;
215+
unit: CoinUnit;
216+
estimated: boolean;
217217
};
218218

219-
export interface IBalance {
220-
hasAvailable: boolean;
221-
available: TAmountWithConversions;
222-
hasIncoming: boolean;
223-
incoming: TAmountWithConversions;
224-
}
219+
export type TBalance = {
220+
hasAvailable: boolean;
221+
available: TAmountWithConversions;
222+
hasIncoming: boolean;
223+
incoming: TAmountWithConversions;
224+
};
225225

226-
export type TBalanceResponse = {
226+
type TBalanceResponse = {
227227
success: true;
228-
balance: IBalance;
228+
balance: TBalance;
229229
} | {
230230
success: false;
231231
}
@@ -237,57 +237,57 @@ export const getBalance = (code: AccountCode): Promise<TBalanceResponse> => {
237237
export type TTransactionStatus = 'complete' | 'pending' | 'failed';
238238
export type TTransactionType = 'send' | 'receive' | 'send_to_self';
239239

240-
export interface ITransaction {
241-
addresses: string[];
242-
amount: TAmountWithConversions;
243-
amountAtTime: TAmountWithConversions;
244-
fee: TAmountWithConversions;
245-
feeRatePerKb: TAmountWithConversions;
246-
deductedAmountAtTime: TAmountWithConversions;
247-
gas: number;
248-
nonce: number | null;
249-
internalID: string;
250-
note: string;
251-
numConfirmations: number;
252-
numConfirmationsComplete: number;
253-
size: number;
254-
status: TTransactionStatus;
255-
time: string | null;
256-
type: TTransactionType;
257-
txID: string;
258-
vsize: number;
259-
weight: number;
240+
export type TTransaction = {
241+
addresses: string[];
242+
amount: TAmountWithConversions;
243+
amountAtTime: TAmountWithConversions;
244+
fee: TAmountWithConversions;
245+
feeRatePerKb: TAmountWithConversions;
246+
deductedAmountAtTime: TAmountWithConversions;
247+
gas: number;
248+
nonce: number | null;
249+
internalID: string;
250+
note: string;
251+
numConfirmations: number;
252+
numConfirmationsComplete: number;
253+
size: number;
254+
status: TTransactionStatus;
255+
time: string | null;
256+
type: TTransactionType;
257+
txID: string;
258+
vsize: number;
259+
weight: number;
260260
}
261261

262-
export type TTransactions = { success: false } | { success: true; list: ITransaction[]; };
262+
export type TTransactions = { success: false } | { success: true; list: TTransaction[]; };
263263

264-
export interface INoteTx {
265-
internalTxID: string;
266-
note: string;
264+
type TNoteTx = {
265+
internalTxID: string;
266+
note: string;
267267
}
268268

269269
export const postNotesTx = (code: AccountCode, {
270270
internalTxID,
271271
note,
272-
}: INoteTx): Promise<null> => {
272+
}: TNoteTx): Promise<null> => {
273273
return apiPost(`account/${code}/notes/tx`, { internalTxID, note });
274274
};
275275

276276
export const getTransactionList = (code: AccountCode): Promise<TTransactions> => {
277277
return apiGet(`account/${code}/transactions`);
278278
};
279279

280-
export const getTransaction = (code: AccountCode, id: ITransaction['internalID']): Promise<ITransaction | null> => {
280+
export const getTransaction = (code: AccountCode, id: TTransaction['internalID']): Promise<TTransaction | null> => {
281281
return apiGet(`account/${code}/transaction?id=${id}`);
282282
};
283283

284-
export interface IExport {
285-
success: boolean;
286-
path: string;
287-
errorMessage: string;
284+
type TExport = {
285+
success: boolean;
286+
path: string;
287+
errorMessage: string;
288288
}
289289

290-
export const exportAccount = (code: AccountCode): Promise<IExport | null> => {
290+
export const exportAccount = (code: AccountCode): Promise<TExport | null> => {
291291
return apiPost(`account/${code}/export`);
292292
};
293293

@@ -298,18 +298,18 @@ export const verifyXPub = (
298298
return apiPost(`account/${code}/verify-extended-public-key`, { signingConfigIndex });
299299
};
300300

301-
export interface IReceiveAddress {
302-
addressID: string;
303-
address: string;
301+
export type TReceiveAddress = {
302+
addressID: string;
303+
address: string;
304304
}
305305

306-
export interface ReceiveAddressList {
307-
scriptType: ScriptType | null;
308-
addresses: NonEmptyArray<IReceiveAddress>;
306+
export type TReceiveAddressList = {
307+
scriptType: ScriptType | null;
308+
addresses: NonEmptyArray<TReceiveAddress>;
309309
}
310310

311311
export const getReceiveAddressList = (code: AccountCode) => {
312-
return (): Promise<NonEmptyArray<ReceiveAddressList> | null> => {
312+
return (): Promise<NonEmptyArray<TReceiveAddressList> | null> => {
313313
return apiGet(`account/${code}/receive-addresses`);
314314
};
315315
};
@@ -368,33 +368,17 @@ export const sendTx = (
368368

369369
export type FeeTargetCode = 'custom' | 'low' | 'economy' | 'normal' | 'high' | 'mHour' | 'mHalfHour' | 'mFastest';
370370

371-
export interface IProposeTxData {
372-
address?: string;
373-
amount?: number;
374-
// data?: string;
375-
feePerByte: string;
376-
feeTarget: FeeTargetCode;
377-
selectedUTXOs: string[];
378-
sendAll: 'yes' | 'no';
379-
}
380-
381-
export interface IProposeTx {
382-
aborted?: boolean;
383-
success?: boolean;
384-
errorMessage?: string;
385-
}
386-
387-
export interface IFeeTarget {
388-
code: FeeTargetCode;
389-
feeRateInfo: string;
371+
export type TFeeTarget = {
372+
code: FeeTargetCode;
373+
feeRateInfo: string;
390374
}
391375

392-
export interface IFeeTargetList {
393-
feeTargets: IFeeTarget[];
394-
defaultFeeTarget: FeeTargetCode;
376+
export type TFeeTargetList = {
377+
feeTargets: TFeeTarget[];
378+
defaultFeeTarget: FeeTargetCode;
395379
}
396380

397-
export const getFeeTargetList = (code: AccountCode): Promise<IFeeTargetList> => {
381+
export const getFeeTargetList = (code: AccountCode): Promise<TFeeTargetList> => {
398382
return apiGet(`account/${code}/fee-targets`);
399383
};
400384

@@ -420,8 +404,8 @@ export const getUTXOs = (code: AccountCode): Promise<TUTXO[]> => {
420404
};
421405

422406
type TSecureOutput = {
423-
hasSecureOutput: boolean;
424-
optional: boolean;
407+
hasSecureOutput: boolean;
408+
optional: boolean;
425409
};
426410

427411
export const hasSecureOutput = (code: AccountCode) => {
@@ -478,7 +462,7 @@ export const ethSignWalletConnectTx = (code: AccountCode, send: boolean, chainId
478462
return apiPost(`account/${code}/eth-sign-wallet-connect-tx`, { send, chainId, tx });
479463
};
480464

481-
export type AddressSignResponse = {
465+
type AddressSignResponse = {
482466
success: true;
483467
signature: string;
484468
address: string;

0 commit comments

Comments
 (0)