Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update events #282

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/SmartTransactionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
import { EventEmitter } from 'events';
import cloneDeep from 'lodash/cloneDeep';

import { CHAIN_IDS } from './constants';
import {
CHAIN_IDS,
MetaMetricsEventCategory,
MetaMetricsEventName,
} from './constants';
import type {
SmartTransaction,
SignedTransaction,
Expand Down Expand Up @@ -202,9 +206,9 @@
isSmartTransactionPending,
);
if (!this.timeoutHandle && pendingTransactions?.length > 0) {
this.poll();

Check warning on line 209 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 209 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
} else if (this.timeoutHandle && pendingTransactions?.length === 0) {
this.stop();

Check warning on line 211 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 211 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
}

Expand Down Expand Up @@ -234,7 +238,7 @@
}
await safelyExecute(async () => this.updateSmartTransactions());
this.timeoutHandle = setInterval(() => {
safelyExecute(async () => this.updateSmartTransactions());

Check warning on line 241 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 241 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}, this.config.interval);
}

Expand Down Expand Up @@ -285,8 +289,8 @@
};

this.trackMetaMetricsEvent({
event: 'STX Status Updated',
category: 'swaps',
event: MetaMetricsEventName.StxStatusUpdated,
category: MetaMetricsEventCategory.Transactions,
sensitiveProperties,
});
}
Expand Down Expand Up @@ -390,7 +394,7 @@
...smartTransaction,
};
if (!smartTransaction.skipConfirm) {
this.#confirmSmartTransaction(nextSmartTransaction, {

Check warning on line 397 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 397 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
chainId,
ethQuery,
});
Expand Down Expand Up @@ -428,7 +432,7 @@
.map((smartTransaction) => smartTransaction.uuid);

if (transactionsToUpdate.length > 0) {
this.fetchSmartTransactionsStatus(transactionsToUpdate, {

Check warning on line 435 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 435 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
networkClientId,
});
}
Expand Down Expand Up @@ -507,8 +511,8 @@
);

this.trackMetaMetricsEvent({
event: 'STX Confirmed',
category: 'swaps',
event: MetaMetricsEventName.StxConfirmed,
category: MetaMetricsEventCategory.Transactions,
});

this.#updateSmartTransaction(
Expand All @@ -521,8 +525,8 @@
}
} catch (error) {
this.trackMetaMetricsEvent({
event: 'STX Confirmation Failed',
category: 'swaps',
event: MetaMetricsEventName.StxConfirmationFailed,
category: MetaMetricsEventCategory.Transactions,
});
console.error('confirm error', error);
}
Expand Down Expand Up @@ -570,7 +574,7 @@
}

async addNonceToTransaction(
transaction: UnsignedTransaction,

Check warning on line 577 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Invalid type "any" of template literal expression

Check warning on line 577 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Invalid type "any" of template literal expression
): Promise<UnsignedTransaction> {
const nonceLock = await this.getNonceLock(transaction.from);
const nonce = nonceLock.nextNonce;
Expand Down
10 changes: 10 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ export const CHAIN_IDS = {
RINKEBY: '0x4',
BSC: '0x38',
} as const;

export enum MetaMetricsEventName {
StxStatusUpdated = 'STX Status Updated',
StxConfirmed = 'STX Confirmed',
StxConfirmationFailed = 'STX Confirmation Failed',
}

export enum MetaMetricsEventCategory {
Transactions = 'Transactions',
}
Loading