-
Notifications
You must be signed in to change notification settings - Fork 597
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
Enhance abstraction: Reassign roles of Connection and WebSocket classes #1061
Conversation
# Conflicts: # packages/wallet-sdk/src/connection/WalletLinkConnection.ts
45c9214
to
fda6484
Compare
case ConnectionState.CONNECTING: | ||
break; |
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.
no-op
|
||
this.http = new WalletLinkHTTP(linkAPIUrl, session.id, session.key); | ||
} |
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.
@@ -17,7 +16,7 @@ export type LogProperties = { | |||
onlineGuests?: number; // number of online guests (should be 0 or 1) | |||
sessionIdHash?: string; // anonymous session id for debugging specific sessions | |||
sessionMetadataChange?: string; // change in session metadata | |||
state?: ConnectionState; | |||
state?: boolean; |
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.
btw, in case you're wondering,
the change maintains functional integrity for logging purposes, because
ConnectionState
was an enum with DISCONNECTED as its first value => having a raw value of 0
@@ -17,7 +16,7 @@ export type LogProperties = { | |||
onlineGuests?: number; // number of online guests (should be 0 or 1) | |||
sessionIdHash?: string; // anonymous session id for debugging specific sessions | |||
sessionMetadataChange?: string; // change in session metadata | |||
state?: ConnectionState; |
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.
Logger
should not depend on ConnectionState
2dd3ebc
to
ad5d71c
Compare
export enum ConnectionState { | ||
DISCONNECTED, | ||
CONNECTING, | ||
CONNECTED, |
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.
it was arbitrary client-side-only concept
we can manage connection state
without this enum
582c917
to
b5987fd
Compare
b5987fd
to
a6bd0a3
Compare
/** | ||
* This section of code implements a reconnect behavior that was ported from a legacy system. | ||
* Preserving original comments to maintain the rationale and context provided by the original author. | ||
* https://github.com/coinbase/coinbase-wallet-sdk/commit/2087ee4a7d40936cd965011bfacdb76ce3462894#diff-dd71e86752e2c20c0620eb0ba4c4b21674e55ae8afeb005b82906a3821e5023cR84 | ||
* TOOD: revisit this logic to assess its validity in the current system context. | ||
*/ | ||
|
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.
it's ~4 year old logic. will revisit later to see if we can improve this
2087ee4#diff-dd71e86752e2c20c0620eb0ba4c4b21674e55ae8afeb005b82906a3821e5023cR84
setIncomingDataListener(listener: (_: ServerMessage) => void): void { | ||
this.incomingDataListener = listener; | ||
} | ||
private pendingData: ClientMessage[] = []; |
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.
pendingData now stores ClientMessage
s instead of raw request value
0eafafd
to
74f368f
Compare
// perform authentication upon connection | ||
try { | ||
// if CONNECTED, authenticate, and then check link status | ||
await this.authenticate(); | ||
this.sendIsLinked(); | ||
this.sendGetSessionConfig(); | ||
connected = true; | ||
} catch { | ||
/* empty */ | ||
} | ||
|
||
// send heartbeat every n seconds while connected | ||
// if CONNECTED, start the heartbeat timer | ||
// first timer event updates lastHeartbeat timestamp | ||
// subsequent calls send heartbeat message | ||
this.updateLastHeartbeat(); | ||
setInterval(() => { | ||
this.heartbeat(); | ||
}, HEARTBEAT_INTERVAL); |
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.
auth, heartbeat management stuff has been migrated to WalletLinkWebSocket class
session, | ||
WebSocketClass, | ||
listener: this, | ||
}); |
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.
b037004
to
4c02a75
Compare
4c02a75
to
ed795fe
Compare
commit 467fafe Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:40:57 2023 -0800 apply to HTTP API commit 883715a Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:40:47 2023 -0800 cleanup commit d01912a Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:25:30 2023 -0800 fi xWalletUI commit 0228706 Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:22:27 2023 -0800 cleanup commit 620216f Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:16:15 2023 -0800 WalletLinkEventType commit ea54a0c Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:07:40 2023 -0800 apply change to selectProvider commit 577e596 Author: Jungho Bang <[email protected]> Date: Wed Nov 15 12:00:47 2023 -0800 clarify param commit 66cbeb8 Author: Jungho Bang <[email protected]> Date: Wed Nov 15 11:45:37 2023 -0800 revert rename commit 6f3b4bd Author: Jungho Bang <[email protected]> Date: Wed Nov 15 11:36:45 2023 -0800 fix tests commit b709f69 Author: Jungho Bang <[email protected]> Date: Wed Nov 15 10:26:08 2023 -0800 rename relay message to be `WalletLinkEventData` commit cf0ad57 Author: Jungho Bang <[email protected]> Date: Wed Nov 15 00:25:21 2023 -0800 cleaner commit bfafff9 Author: Jungho Bang <[email protected]> Date: Wed Nov 15 00:14:57 2023 -0800 fix provider commit 90feb0e Author: Jungho Bang <[email protected]> Date: Tue Nov 14 23:48:07 2023 -0800 no error on relay commit cb90fd1 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 23:17:51 2023 -0800 wtf commit 17c67b5 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 23:06:32 2023 -0800 consolidate RelayMessage commit f636d5f Author: Jungho Bang <[email protected]> Date: Tue Nov 14 22:12:25 2023 -0800 support case of request and response having different method commit a95e96e Author: Jungho Bang <[email protected]> Date: Tue Nov 14 22:04:19 2023 -0800 comment commit 8f07056 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 22:00:18 2023 -0800 sync commit c478f1e Author: Jungho Bang <[email protected]> Date: Tue Nov 14 21:57:26 2023 -0800 no need to be exported RelayMessageType commit 7c9cb7b Author: Jungho Bang <[email protected]> Date: Tue Nov 14 21:57:08 2023 -0800 apply Web3Response changes commit e2232a8 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 21:49:44 2023 -0800 cleanup RelayMessage commit c5a93d6 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 19:54:54 2023 -0800 introducing SupportedWeb3Methods commit 99176c8 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 19:26:24 2023 -0800 improvements commit 9ceab2a Author: Jungho Bang <[email protected]> Date: Tue Nov 14 19:10:11 2023 -0800 help git commit 6c86f5a Author: Jungho Bang <[email protected]> Date: Tue Nov 14 19:04:53 2023 -0800 Web3Response commit 93edb63 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 18:16:33 2023 -0800 refactoring Web3Request commit 154ba57 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 17:51:49 2023 -0800 lfg commit 2bcc7a7 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 17:12:40 2023 -0800 apply changes commit 911c669 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 16:51:58 2023 -0800 apply it to ClientMessage commit 20f7612 Author: Jungho Bang <[email protected]> Date: Tue Nov 14 15:48:09 2023 -0800 refactor ServerMessage type
# Conflicts: # packages/wallet-sdk/src/connection/DiagnosticLogger.ts # packages/wallet-sdk/src/connection/WalletLinkConnection.ts
Summary
How did you test your changes?