This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
catching promise - legacy provider error #7022
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
59f6038
adding data check for revert util method
b08ba9e
fix up tests
5efced4
fix lint
87a164f
change legacy request
e810ab3
revert contract changes, add try catch
f1819bc
fix lint
c6b0618
Merge branch '4.x' into add-check-revert
024de10
fix changes
4a70466
update tests
3ee777a
lint and feedback
ab3d5df
update test
8cc7544
update test
fa2461c
format
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,14 +241,14 @@ export class Web3RequestManager< | |
| payload, | ||
| error as JsonRpcResponse<ResponseType, unknown>, | ||
| { legacy: true, error: true }, | ||
| ), | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| // TODO: This could be deprecated and removed. | ||
| if (isLegacyRequestProvider(provider)) { | ||
| return new Promise<JsonRpcResponse<ResponseType>>((resolve, reject) => { | ||
| const rejectWithError = (err: unknown) => | ||
| const rejectWithError = (err: unknown) =>{ | ||
luu-alex marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| reject( | ||
| this._processJsonRpcResponse( | ||
| payload, | ||
|
|
@@ -257,8 +257,9 @@ export class Web3RequestManager< | |
| legacy: true, | ||
| error: true, | ||
| }, | ||
| ), | ||
| ); | ||
| )) | ||
| } | ||
|
|
||
| const resolveWithResponse = (response: JsonRpcResponse<ResponseType>) => | ||
| resolve( | ||
| this._processJsonRpcResponse(payload, response, { | ||
|
|
@@ -288,7 +289,20 @@ export class Web3RequestManager< | |
| const responsePromise = result as unknown as Promise< | ||
| JsonRpcResponse<ResponseType> | ||
| >; | ||
| responsePromise.then(resolveWithResponse).catch(rejectWithError); | ||
| responsePromise.then(resolveWithResponse).catch(error => { | ||
| try { | ||
| // Attempt to process the error response | ||
| const processedError = this._processJsonRpcResponse( | ||
| payload, | ||
| error as JsonRpcResponse<ResponseType, unknown>, | ||
| { legacy: true, error: true } | ||
| ); | ||
| reject(processedError); | ||
|
||
| } catch (processingError) { | ||
| // Catch any errors that occur during the error processing | ||
| reject(processingError); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -720,4 +720,4 @@ describe('Web3Eth.sendTransaction', () => { | |
| ).rejects.toMatchObject(expectedThrownError); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.