-
Notifications
You must be signed in to change notification settings - Fork 423
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
Swap failed events: only reject committed txs with code !== 0 #3301
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -373,12 +373,15 @@ export function useSwap( | |||||||||||||||||||||
tokenOutMinAmount, | ||||||||||||||||||||||
undefined, | ||||||||||||||||||||||
signOptions, | ||||||||||||||||||||||
() => { | ||||||||||||||||||||||
resolve(pools.length === 1 ? "exact-in" : "multihop"); | ||||||||||||||||||||||
({ code }) => { | ||||||||||||||||||||||
if (code) | ||||||||||||||||||||||
reject("Failed to send swap exact amount in message"); | ||||||||||||||||||||||
else resolve(pools.length === 1 ? "exact-in" : "multihop"); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
) | ||||||||||||||||||||||
.catch((reason) => { | ||||||||||||||||||||||
reject(reason); | ||||||||||||||||||||||
// broadcast error or tx rejection | ||||||||||||||||||||||
console.error(reason); | ||||||||||||||||||||||
}); | ||||||||||||||||||||||
return pools.length === 1 ? "exact-in" : "multihop"; | ||||||||||||||||||||||
} else if (routes.length > 1) { | ||||||||||||||||||||||
|
@@ -389,14 +392,20 @@ export function useSwap( | |||||||||||||||||||||
tokenOutMinAmount, | ||||||||||||||||||||||
undefined, | ||||||||||||||||||||||
signOptions, | ||||||||||||||||||||||
() => { | ||||||||||||||||||||||
resolve("multiroute"); | ||||||||||||||||||||||
({ code }) => { | ||||||||||||||||||||||
if (code) | ||||||||||||||||||||||
reject( | ||||||||||||||||||||||
"Failed to send split route swap exact amount in message" | ||||||||||||||||||||||
); | ||||||||||||||||||||||
else resolve("multiroute"); | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor error handling for clarity and maintainability. Similar to the previous comment, the error handling here can be improved by providing more information about the failure. - reject("Failed to send split route swap exact amount in message");
+ reject(`Failed to send split route swap exact amount in message with error code: ${code}`); Committable suggestion
Suggested change
|
||||||||||||||||||||||
} | ||||||||||||||||||||||
) | ||||||||||||||||||||||
.catch((reason) => { | ||||||||||||||||||||||
reject(reason); | ||||||||||||||||||||||
// broadcast error or tx rejection | ||||||||||||||||||||||
console.error(reason); | ||||||||||||||||||||||
}); | ||||||||||||||||||||||
} else { | ||||||||||||||||||||||
// should not be possible because button should be disabled | ||||||||||||||||||||||
jonator marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
reject("No routes given"); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
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.
Refactor error handling for clarity and maintainability.
The error handling in the
sendTradeTokenInTx
function could be made clearer by using a more descriptive error message. Consider including details about the error code when the transaction fails.Committable suggestion