Skip to content

Commit be91240

Browse files
chore: code improvements
1 parent 278023f commit be91240

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/core/src/controllers/SwapController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ export const SwapController = {
718718
const error = err as TransactionError;
719719
state.transactionError = error?.shortMessage as unknown as string;
720720
state.loadingApprovalTransaction = false;
721-
SnackController.showError(error?.shortMessage || 'Transaction error');
721+
SnackController.showError(error?.shortMessage ?? 'Transaction error');
722722
}
723723
},
724724

@@ -795,12 +795,12 @@ export const SwapController = {
795795
const error = err as TransactionError;
796796
state.transactionError = error?.shortMessage;
797797
state.loadingTransaction = false;
798-
SnackController.showError(error?.shortMessage || 'Transaction error');
798+
SnackController.showError(error?.shortMessage ?? 'Transaction error');
799799
EventsController.sendEvent({
800800
type: 'track',
801801
event: 'SWAP_ERROR',
802802
properties: {
803-
message: error?.shortMessage || error?.message || 'Unknown',
803+
message: error?.shortMessage ?? error?.message ?? 'Unknown',
804804
network: NetworkController.state.caipNetwork?.id || '',
805805
swapFromToken: this.state.sourceToken?.symbol || '',
806806
swapToToken: this.state.toToken?.symbol || '',

packages/core/src/utils/SwapCalculationUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const SwapCalculationUtil = {
6363
},
6464

6565
isInsufficientNetworkTokenForGas(networkBalanceInUSD: string, gasPriceInUSD: number | undefined) {
66-
const gasPrice = gasPriceInUSD || '0';
66+
const gasPrice = gasPriceInUSD ?? '0';
6767

6868
if (NumberUtil.bigNumber(networkBalanceInUSD).isZero()) {
6969
return true;
@@ -80,7 +80,7 @@ export const SwapCalculationUtil = {
8080
const sourceTokenBalance = balance?.find(token => token.address === sourceTokenAddress)
8181
?.quantity?.numeric;
8282

83-
const isInSufficientBalance = NumberUtil.bigNumber(sourceTokenBalance || '0').isLessThan(
83+
const isInSufficientBalance = NumberUtil.bigNumber(sourceTokenBalance ?? '0').isLessThan(
8484
sourceTokenAmount
8585
);
8686

packages/core/src/utils/TypeUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ export type Event =
654654

655655
// -- Send Controller Types -------------------------------------
656656
export type EstimateGasTransactionArgs = {
657-
chainNamespace?: undefined | 'eip155';
657+
chainNamespace?: 'eip155';
658658
address: `0x${string}`;
659659
to: `0x${string}`;
660660
data: `0x${string}`;

0 commit comments

Comments
 (0)