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

Show a insufficient funds warning #3645

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
22 changes: 16 additions & 6 deletions background/services/chain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,25 @@ export default class ChainService extends BaseService<Events> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const anyError: any = error

if (
"code" in anyError &&
anyError.code === Logger.errors.UNPREDICTABLE_GAS_LIMIT
) {
gasEstimationError = anyError.error ?? "Unknown transaction error."
if ("code" in anyError) {
if (anyError.code === Logger.errors.UNPREDICTABLE_GAS_LIMIT) {
gasEstimationError = anyError.error ?? "Unknown transaction error."
}

if (anyError.code === Logger.errors.INSUFFICIENT_FUNDS) {
gasEstimationError = anyError.error ?? "Insufficient funds error."

if (
"annotation" in transactionRequest &&
transactionRequest.annotation !== undefined
) {
transactionRequest.annotation.warnings ??= []
transactionRequest.annotation.warnings.push("insufficient-funds")
}
Comment on lines +592 to +598
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be pushing annotations anywhere other than the enrichment service…

We also unfortunately have this estimation handling duplicated here and below in populatePartialEIP1559TransactionRequest.

Will think about the best way to tie these together.

}
}
}
}

// We use the estimate as the actual limit only if user did not specify the
// gas explicitly or if it was set below the minimum network-allowed value.
if (
Expand Down
4 changes: 0 additions & 4 deletions background/services/enrichment/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ export default async function resolveTransactionAnnotation(
if (!txAnnotation.warnings.includes("insufficient-funds")) {
txAnnotation.warnings.push("insufficient-funds")
}
} else {
txAnnotation.warnings = txAnnotation.warnings.filter(
(warning) => warning !== "insufficient-funds",
)
}

// If the transaction has been mined, get the block and set the timestamp
Expand Down