Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit d33da4d

Browse files
committed
Upgrade typescript, refactorings
1 parent 649fe18 commit d33da4d

21 files changed

+102
-60
lines changed

ts/blockchain.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ export class Blockchain {
579579
if (injectedProviderIfExists.enable !== undefined) {
580580
try {
581581
await injectedProviderIfExists.enable();
582-
} catch (err) {
582+
} catch (e) {
583+
const err = utils.maybeWrapInError(e);
583584
errorReporter.report(err);
584585
}
585586
}
@@ -917,7 +918,8 @@ export class Blockchain {
917918
try {
918919
const contractInstance = address === undefined ? await c.deployed() : await c.at(address);
919920
return contractInstance;
920-
} catch (err) {
921+
} catch (e) {
922+
const err = utils.maybeWrapInError(e);
921923
const errMsg = `${err}`;
922924
logUtils.log(`Notice: Error encountered: ${err} ${err.stack}`);
923925
if (_.includes(errMsg, 'not been deployed to detected network')) {

ts/components/eth_weth_conversion_button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export class EthWethConversionButton extends React.Component<
106106
await this.props.refetchEthTokenStateAsync();
107107
}
108108
this.props.onConversionSuccessful();
109-
} catch (err) {
109+
} catch (e) {
110+
const err = utils.maybeWrapInError(e);
110111
const errMsg = `${err}`;
111112
if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
112113
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);

ts/components/inputs/allowance_state_toggle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ export class AllowanceStateToggle extends React.Component<AllowanceStateTogglePr
139139
await this.props.blockchain.setProxyAllowanceAsync(this.props.token, newAllowanceAmountInBaseUnits);
140140
analytics.track('Set Allowances Success', logData);
141141
await this.props.refetchTokenStateAsync();
142-
} catch (err) {
142+
} catch (e) {
143+
const err = utils.maybeWrapInError(e);
143144
analytics.track('Set Allowance Failure', logData);
144145
this.setState({
145146
allowanceState: AllowanceStateToggle._getAllowanceState(this.state.prevTokenState),

ts/components/newsletter_form.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import styled from 'styled-components';
33
import { fadeIn } from 'ts/style/keyframes';
44
import { errorReporter } from 'ts/utils/error_reporter';
5+
import { utils } from 'ts/utils/utils';
56

67
interface IFormProps {
78
color?: string;
@@ -46,7 +47,8 @@ export const NewsletterForm: React.FC<IFormProps> = ({ color }) => {
4647
method: 'POST',
4748
});
4849
} catch (e) {
49-
errorReporter.report(e);
50+
const err = utils.maybeWrapInError(e);
51+
errorReporter.report(err);
5052
}
5153
};
5254

ts/components/relayer_index/relayer_index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { RelayerGridTile, RelayerGridTileStyle } from 'ts/components/relayer_ind
77
import { Retry } from 'ts/components/ui/retry';
88
import { ScreenWidths, WebsiteBackendRelayerInfo } from 'ts/types';
99
import { backendClient } from 'ts/utils/backend_client';
10+
import { utils } from 'ts/utils/utils';
1011

1112
export enum RelayerIndexCellStyle {
1213
Expanded = 0,
@@ -104,10 +105,11 @@ export class RelayerIndex extends React.Component<RelayerIndexProps, RelayerInde
104105
relayerInfos,
105106
});
106107
}
107-
} catch (error) {
108+
} catch (e) {
109+
const err = utils.maybeWrapInError(e);
108110
if (!this._isUnmounted) {
109111
this.setState({
110-
error,
112+
error: err,
111113
});
112114
}
113115
}

ts/components/send_button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export class SendButton extends React.Component<SendButtonProps, SendButtonState
7575
await this.props.blockchain.transferAsync(token, recipient, value);
7676
await this.props.refetchTokenStateAsync(token.address);
7777
}
78-
} catch (err) {
78+
} catch (e) {
79+
const err = utils.maybeWrapInError(e);
7980
const errMsg = `${err}`;
8081
if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
8182
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);

ts/components/staking/add_pool_dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styled from 'styled-components';
66
import { Button } from 'ts/components/button';
77
import { Icon } from 'ts/components/icon';
88
import { Input } from 'ts/components/modals/input';
9-
import { Thumbnail } from 'ts/components/staking/thumbnail.tsx';
9+
import { Thumbnail } from 'ts/components/staking/thumbnail';
1010
import { Heading, Paragraph } from 'ts/components/text';
1111

1212
import { useSearch } from 'ts/hooks/use_search';

ts/components/staking/change_pool_dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import styled from 'styled-components';
77
import { Button } from 'ts/components/button';
88
import { Icon } from 'ts/components/icon';
99
import { Input } from 'ts/components/modals/input';
10-
import { Thumbnail } from 'ts/components/staking/thumbnail.tsx';
10+
import { Thumbnail } from 'ts/components/staking/thumbnail';
1111
import { Heading, Paragraph } from 'ts/components/text';
1212

1313
import { useSearch } from 'ts/hooks/use_search';

ts/components/token_balances.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
475475
const amount = Web3Wrapper.toUnitAmount(constants.MINT_AMOUNT, token.decimals);
476476
this.props.dispatcher.showFlashMessage(`Successfully minted ${amount.toString(10)} ${token.symbol}`);
477477
return true;
478-
} catch (err) {
478+
} catch (e) {
479+
const err = utils.maybeWrapInError(e);
479480
const errMsg = `${err}`;
480481
if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
481482
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);

ts/components/wallet/wrap_ether_item.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ export class WrapEtherItem extends React.Component<WrapEtherItemProps, WrapEther
201201
}
202202
await this.props.refetchEthTokenStateAsync();
203203
this.props.onConversionSuccessful();
204-
} catch (err) {
204+
} catch (e) {
205+
const err = utils.maybeWrapInError(e);
205206
const errMsg = `${err}`;
206207
if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
207208
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);

0 commit comments

Comments
 (0)