-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
sendTransaction
and sendSignedTransaction
Error Refactors
#5854
Conversation
@@ -55,16 +65,24 @@ export class ResponseError<ErrorType = unknown> extends BaseWeb3Error { | |||
? response.map(r => r.error?.data as ErrorType) | |||
: response?.error?.data; | |||
} | |||
|
|||
this.request = request; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added request to the error object as I wanted to add sent transaction details to failed transaction errors to give the user more context (e.g. the sending account when the error Unknown account
or Insufficient funds
is thrown) on what exactly was sent to provider
if (web3Context.handleRevert) { | ||
// eslint-disable-next-line no-use-before-define | ||
await getRevertReason( | ||
web3Context, | ||
transactionFormatted as TransactionCall, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of addressing #5839, the revert reason is retrieved after the transaction has been processed by the network and when transactionReceipt.status === BigInt(0)
promiEvent.emit( | ||
'error', | ||
new TransactionError( | ||
'Transaction failed', | ||
transactionReceiptFormatted, | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the cause of #5837
if (error instanceof ContractExecutionError) { | ||
promiEvent.emit('contractExecutionError', error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that it's being using in web3-eth-contract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
web3-eth-contract
was updated to check for error instanceof ContractExecutionError
instead of relying on an emission of contractExecutionError
event
@@ -25,6 +25,45 @@ import { DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-utils'; | |||
import { call } from '../rpc_method_wrappers'; | |||
import { RevertReason, RevertReasonWithCustomError } from '../types'; | |||
|
|||
export const parseTransactionError = (error: unknown, contractAbi?: ContractAbi) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to it's own function so it could make getRevertReason
more concise and because the new util method getTransactionError
uses it
…to SendTransactionOptions
Bundle StatsHey there, this message comes from a github action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
View detailed bundle breakdownAdded
Removed No assets were removed Bigger
Smaller
Unchanged
|
Deploying with
|
Latest commit: |
c216751
|
Status: | ✅ Deploy successful! |
Preview URL: | https://4e10d048.web3-js-docs.pages.dev |
Branch Preview URL: | https://wyatt-4-x-5840-requstmanger-.web3-js-docs.pages.dev |
…scendants (#5891) * rename `_providerOptions` to `_socketOptions` * pass `_socketOptions` from IpcProvider constructor to the underlying connection * move a comment to its correct position at `SocketProvider` * expose the getter of `SocketConnection` from `SocketProvider`. * update CHANGELOG.md files * add extremely simple unit test for SocketProvider
* version fix * use geth binary * try 1.11.2
679d2fa
to
2662eaf
Compare
Added
web3-errors
request
property toResponseError
(sendTransaction
andsendSignedTransaction
Error Refactors #5854)data
property toTransactionRevertInstructionError
(sendTransaction
andsendSignedTransaction
Error Refactors #5854)TransactionRevertWithCustomError
was added to handle custom solidity errors (sendTransaction
andsendSignedTransaction
Error Refactors #5854)web3-eth
contractAbi
option toSendTransactionOptions
andSendSignedTransactionOptions
to added the ability to parse custom solidity errors (sendTransaction
andsendSignedTransaction
Error Refactors #5854)Changed
web3-errors
TransactionRevertError
toTransactionRevertInstructionError
to remain consistent with1.x
(sendTransaction
andsendSignedTransaction
Error Refactors #5854)web3-eth
sendTransaction
andsendSignedTransaction
now errors with (anderror
event emits) the following possible errors:TransactionRevertedWithoutReasonError
,TransactionRevertInstructionError
,TransactionRevertWithCustomError
,InvalidResponseError
, orContractExecutionError
(sendTransaction
andsendSignedTransaction
Error Refactors #5854)