-
Notifications
You must be signed in to change notification settings - Fork 22
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
v1.3.6 Improved Session Handling and Logging #318
Conversation
aed5926
to
fe12330
Compare
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
const signClient = await SignClient.init({ | ||
logger, | ||
relayUrl: 'wss://relay.walletconnect.com', | ||
projectId: this.projectId, | ||
metadata: this.dAppMetadata, | ||
}) | ||
this.walletConnectClient = signClient | ||
const existingSessions = this.walletConnectClient.session.getAll() | ||
|
||
if (existingSessions.length > 0) | ||
if (existingSessions.length > 0) { | ||
this.signers = existingSessions.flatMap((session) => this.createSigners(session)) | ||
else this.checkIframeConnect() | ||
} else { | ||
await this.checkIframeConnect() | ||
} |
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 agree with improving code style and formatting, but these changes should be in a separate commit to avoid any confusion with the purpose of this one.
export interface ILogger { | ||
error(message: string, ...args: any[]): void | ||
warn(message: string, ...args: any[]): void | ||
info(message: string, ...args: any[]): void | ||
debug(message: string, ...args: any[]): void | ||
} | ||
|
||
export class DefaultLogger implements ILogger { | ||
private logLevel: 'error' | 'warn' | 'info' | 'debug' = 'info' | ||
|
||
constructor(logLevel: 'error' | 'warn' | 'info' | 'debug' = 'info') { | ||
this.logLevel = logLevel | ||
} | ||
|
||
setLogLevel(level: 'error' | 'warn' | 'info' | 'debug'): void { | ||
this.logLevel = level | ||
} | ||
|
||
error(message: string, ...args: any[]): void { | ||
if (['error', 'warn', 'info', 'debug'].includes(this.logLevel)) { | ||
console.error(`[ERROR] ${message}`, ...args) | ||
} | ||
} | ||
|
||
warn(message: string, ...args: any[]): void { | ||
if (['warn', 'info', 'debug'].includes(this.logLevel)) { | ||
console.warn(`[WARN] ${message}`, ...args) | ||
} | ||
} | ||
|
||
info(message: string, ...args: any[]): void { | ||
if (['info', 'debug'].includes(this.logLevel)) { | ||
console.info(`[INFO] ${message}`, ...args) | ||
} | ||
} | ||
|
||
debug(message: string, ...args: any[]): void { | ||
if (this.logLevel === 'debug') { | ||
console.debug(`[DEBUG] ${message}`, ...args) | ||
} | ||
} | ||
} |
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 a great idea! However, I'd suggest keeping the logging feature separate from the wallet connect functionality. Putting it in its own commit will keep things clear.
return transaction._makeTransactionBody(nodeAccountId) | ||
} | ||
|
||
export function transactionBodyToBase64String(transactionBody: Uint8Array) { | ||
return Uint8ArrayToBase64String(transactionBody) | ||
export function transactionBodyToBase64String(transactionBody: proto.ITransactionBody) { | ||
return Uint8ArrayToBase64String(proto.TransactionBody.encode(transactionBody).finish()) | ||
} |
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.
Same here, this fixes a reported issue, so it should be committed separately and liked to it.
Great work, @kantorcodes ! This is a fantastic improvement. The only thing I’d suggest is splitting these changes into four parts:
|
Thank you for your feedback. While I generally agree that breaking this out into multiple commits would make this easier in case we must revert something, at the same time the work here provides essential fixes to make HWC more usable for important dApps in the ecosystem. Perhaps prioritizing canary releases would be a good interim solution, as I fear the time to review four separate pull requests would slow things down immensely. Additionally, while logging is not a required dependency here, it did make developing and debugging these improvements easier. My proposed options in order: A) prioritize canary NPM tags so we can allow immediate usage of these improvements to dApps B) Push this one over in light of urgency C) Counter recommendations for two PRs instead of four
|
@kantorcodes i really like the idea of utilizing canary releases (option A). we have to find a balance between urgent response for dApps and plenty of time for reviews and testing. option C is reasonable as well. interested to hear thoughts from @teacoat @valeraOlexienko @jwtong |
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Signed-off-by: Michael Kantor <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #318 +/- ##
=======================================
Coverage ? 36.05%
=======================================
Files ? 14
Lines ? 613
Branches ? 79
=======================================
Hits ? 221
Misses ? 392
Partials ? 0 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Michael Kantor <[email protected]>
After some discovery, we've figured out we can create canary releases now. Per the feedback, I'll be breaking off this PR into separate merges. |
Signed-off-by: Michael Kantor <[email protected]>
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.
@rbarkerSL I think these 3 files look good, but please review as well:
.github/workflows/publish-canary.yml
- new file, definitely review.
package-lock.json
(doesn't really need to be reviewed)
package.json
Description:
This PR suggests a number of fixes to improve the dApp experience:
Related issue(s):
Fixes CON-494
Notes for reviewer:
Checklist