-
Notifications
You must be signed in to change notification settings - Fork 7
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
CU-86dt27bzj - Create a WcSdk method to wipe all requests from a dapp #114
Conversation
… -> adding a toast to prevent breaking the app when wiping the requests
@@ -2,6 +2,9 @@ import React, { useState } from 'react' | |||
import { TypeChecker } from '@cityofzion/neon-dappkit-types' | |||
import { NetworkType, useWalletConnect, SignMessageVersion } from '@cityofzion/wallet-connect-sdk-react' | |||
import { dappMethods, networks } from '../Constants' | |||
import 'toastify-js/src/toastify.css' |
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.
Consider importing CSS in a central file or at the root level of your application. This will help to keep all style imports in one place and improve code organization.
@@ -2,6 +2,9 @@ import React, { useState } from 'react' | |||
import { TypeChecker } from '@cityofzion/neon-dappkit-types' | |||
import { NetworkType, useWalletConnect, SignMessageVersion } from '@cityofzion/wallet-connect-sdk-react' | |||
import { dappMethods, networks } from '../Constants' | |||
import 'toastify-js/src/toastify.css' | |||
// @ts-ignore | |||
import Toastify from 'toastify-js' |
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.
Avoid using @ts-ignore
as it suppresses all typescript errors in the next line. If there's a specific error you want to ignore, use @ts-expect-error
instead and provide a comment explaining why the error is being ignored.
signers: [{ scopes: 1 }], | ||
}) | ||
|
||
console.log(resp) |
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.
Avoid using console.log
for debugging in production code.
signers: [{ scopes: 1 }], | ||
}) | ||
|
||
console.log(resp) |
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.
Avoid using window.alert
for debugging in production code.
], | ||
signers: [{ scopes: 1 }], | ||
}) | ||
console.log(resp) |
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.
Avoid using console.log
for debugging in production code.
console.log(resp) | ||
window.alert(JSON.stringify(resp, null, 2)) | ||
} catch (e) { | ||
onError(e) |
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.
Consider providing a more descriptive error message in the onError
function to help with debugging.
@@ -336,46 +390,60 @@ function HelloWorld() { | |||
console.log(resp2) |
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.
Avoid using console.log
for debugging in production code. It's better to use a logging library that can be toggled for development/production.
}, | ||
], | ||
}) | ||
console.log(resp) |
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.
Avoid using console.log
for debugging in production code. It's better to use a logging library that can be toggled for development/production.
setResponse(JSON.stringify(resp, null, 2)) | ||
try { | ||
const resp = await wcSdk.wipeRequests() | ||
console.log(resp) |
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.
Avoid using console.log
for debugging in production code. It's better to use a logging library that can be toggled for development/production.
} | ||
} | ||
|
||
const onError = (error: any) => { |
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.
Consider adding types to your function parameters for better type safety. Instead of any
, use a specific type or create an interface for the error object.
adding a toast to prevent breaking the app when wiping the requests