-
Notifications
You must be signed in to change notification settings - Fork 38
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
[Gateway] - FE Fixes for non-MM users #1690
Changes from 1 commit
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 | ||||
---|---|---|---|---|---|---|
|
@@ -39,7 +39,7 @@ const typedData = { | |||||
|
||||||
export const switchToTenNetwork = async () => { | ||||||
if (!ethereum) { | ||||||
throw new Error("No ethereum object found"); | ||||||
throw "No ethereum object found"; | ||||||
} | ||||||
try { | ||||||
await ethereum.request({ | ||||||
|
@@ -55,7 +55,7 @@ export const switchToTenNetwork = async () => { | |||||
|
||||||
export const connectAccounts = async () => { | ||||||
if (!ethereum) { | ||||||
throw new Error("No ethereum object found"); | ||||||
throw "No ethereum object found"; | ||||||
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. This comment is the same as the previous one. Ensure that the error handling logic is consistent across the application by throwing - throw "No ethereum object found";
+ throw new Error("No ethereum object found"); Committable suggestion
Suggested change
|
||||||
} | ||||||
try { | ||||||
return await ethereum.request({ | ||||||
|
@@ -69,7 +69,7 @@ export const connectAccounts = async () => { | |||||
|
||||||
export const getSignature = async (account: string, data: any) => { | ||||||
if (!ethereum) { | ||||||
throw new Error("No ethereum object found"); | ||||||
throw "No ethereum object found"; | ||||||
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. As with the previous instances, throwing a string literal here can lead to issues with error handling that expects an - throw "No ethereum object found";
+ throw new Error("No ethereum object found"); Committable suggestion
Suggested change
|
||||||
} | ||||||
try { | ||||||
return await ethereum.request({ | ||||||
|
@@ -78,7 +78,7 @@ export const getSignature = async (account: string, data: any) => { | |||||
}); | ||||||
} catch (error) { | ||||||
console.error(error); | ||||||
throw new Error("Failed to get signature"); | ||||||
throw "Failed to get signature"; | ||||||
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. The thrown string literal here should be replaced with an - throw "Failed to get signature";
+ throw new Error("Failed to get signature"); Committable suggestion
Suggested change
|
||||||
} | ||||||
}; | ||||||
|
||||||
|
@@ -110,7 +110,7 @@ export const getToken = async (provider: ethers.providers.Web3Provider) => { | |||||
|
||||||
export async function addNetworkToMetaMask(rpcUrls: string[]) { | ||||||
if (!ethereum) { | ||||||
throw new Error("No ethereum object found"); | ||||||
throw "No ethereum object found"; | ||||||
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. Again, it's important to throw - throw "No ethereum object found";
+ throw new Error("No ethereum object found"); Committable suggestion
Suggested change
|
||||||
} | ||||||
try { | ||||||
await ethereum.request({ | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -58,7 +58,7 @@ const useGatewayService = () => { | |||||||||||||||
|
||||||||||||||||
await fetchUserAccounts(); | ||||||||||||||||
} catch (error: any) { | ||||||||||||||||
showToast(ToastType.DESTRUCTIVE, `${error.message}`); | ||||||||||||||||
showToast(ToastType.DESTRUCTIVE, `${error}`); | ||||||||||||||||
throw error; | ||||||||||||||||
Comment on lines
60
to
62
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. The - showToast(ToastType.DESTRUCTIVE, `${error}`);
+ showToast(ToastType.DESTRUCTIVE, error.message || 'An unknown error occurred'); Committable suggestion
Suggested change
|
||||||||||||||||
} finally { | ||||||||||||||||
setLoading(false); | ||||||||||||||||
|
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.
The change from throwing an
Error
object to a string literal may impact error handling logic downstream that relies on properties ofError
objects. Consider throwing a newError
with a message instead to maintain consistency with error object properties.Committable suggestion