Skip to content
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

feat: ping wallet connect on focus #224

Merged
merged 8 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/dapp-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@vechain/connex-framework": "2.1.0",
"@vechain/connex-types": "^2.1.0",
"@walletconnect/modal": "2.6.2",
"@walletconnect/sign-client": "2.10.2",
"@walletconnect/utils": "2.10.2",
"@walletconnect/sign-client": "2.11.3",
"@walletconnect/utils": "2.11.3",
"events": "^3.3.0",
"thor-devkit": "2.0.5",
"valtio": "1.11.2"
Expand All @@ -39,7 +39,7 @@
"@types/react-dom": "^18.2.13",
"@vechain/repo-config": "https://github.com/vechain/repo-config#v0.0.1",
"@vitest/coverage-v8": "^0.34.6",
"@walletconnect/types": "2.10.2",
"@walletconnect/types": "2.11.3",
"eslint": "*",
"happy-dom": "^12.10.3",
"lokijs": "^1.5.12",
Expand Down
14 changes: 14 additions & 0 deletions packages/dapp-kit/src/utils/create-wc-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ export const createWcSigner = ({
throw new Error(`Failed to get the wallet connect sign client`);
});

/**
* Ping the session when the window is focused
* if (window) to prevent SSR errors
*/
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window) {
window.onfocus = async (): Promise<void> => {
if (session) {
const signClient = await wcClient.get();
await signClient.ping({ topic: session.topic });
}
};
}

// listen for session updates
const listenToEvents = (_client: SignClient): void => {
_client.on('session_update', ({ topic, params }): void => {
Expand Down
108 changes: 49 additions & 59 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5337,32 +5337,33 @@
eventemitter3 "^4.0.7"
zustand "^4.3.1"

"@walletconnect/core@2.10.2":
version "2.10.2"
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.2.tgz#a1bf6e3e87b33f9df795ce0970d8ddd400fdc8a3"
integrity sha512-JQz/xp3SLEpTeRQctdck2ugSBVEpMxoSE+lFi2voJkZop1hv6P+uqr6E4PzjFluAjeAnKlT1xvra0aFWjPWVcw==
"@walletconnect/core@2.11.0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.11.0.tgz#3a4e301077b2f858fd916b7a20b5b984d1afce63"
integrity sha512-2Tjp5BCevI7dbmqo/OrCjX4tqgMqwJNQLlQAlphqPfvwlF9+tIu6pGcVbSN3U9zyXzWIZCeleqEaWUeSeET4Ew==
dependencies:
"@walletconnect/heartbeat" "1.2.1"
"@walletconnect/jsonrpc-provider" "1.0.13"
"@walletconnect/jsonrpc-types" "1.0.3"
"@walletconnect/jsonrpc-utils" "1.0.8"
"@walletconnect/jsonrpc-ws-connection" "1.0.13"
"@walletconnect/keyvaluestorage" "^1.0.2"
"@walletconnect/jsonrpc-ws-connection" "1.0.14"
"@walletconnect/keyvaluestorage" "^1.1.1"
"@walletconnect/logger" "^2.0.1"
"@walletconnect/relay-api" "^1.0.9"
"@walletconnect/relay-auth" "^1.0.4"
"@walletconnect/safe-json" "^1.0.2"
"@walletconnect/time" "^1.0.2"
"@walletconnect/types" "2.10.2"
"@walletconnect/utils" "2.10.2"
"@walletconnect/types" "2.11.0"
"@walletconnect/utils" "2.11.0"
events "^3.3.0"
isomorphic-unfetch "3.1.0"
lodash.isequal "4.5.0"
uint8arrays "^3.1.0"

"@walletconnect/[email protected].0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.11.0.tgz#3a4e301077b2f858fd916b7a20b5b984d1afce63"
integrity sha512-2Tjp5BCevI7dbmqo/OrCjX4tqgMqwJNQLlQAlphqPfvwlF9+tIu6pGcVbSN3U9zyXzWIZCeleqEaWUeSeET4Ew==
"@walletconnect/[email protected].3":
version "2.11.3"
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.11.3.tgz#c81855722cb9afd411f91f5345c7874f48bade0b"
integrity sha512-/9m4EqiggFUwkQDv5PDWbcTI+yCVnBd/iYW5iIHEkivg2/mnBr2bQz2r/vtPjp19r/ZK62Dx0+UN3U+BWP8ulQ==
dependencies:
"@walletconnect/heartbeat" "1.2.1"
"@walletconnect/jsonrpc-provider" "1.0.13"
Expand All @@ -5375,8 +5376,8 @@
"@walletconnect/relay-auth" "^1.0.4"
"@walletconnect/safe-json" "^1.0.2"
"@walletconnect/time" "^1.0.2"
"@walletconnect/types" "2.11.0"
"@walletconnect/utils" "2.11.0"
"@walletconnect/types" "2.11.3"
"@walletconnect/utils" "2.11.3"
events "^3.3.0"
isomorphic-unfetch "3.1.0"
lodash.isequal "4.5.0"
Expand Down Expand Up @@ -5479,17 +5480,6 @@
"@walletconnect/jsonrpc-types" "^1.0.3"
tslib "1.14.1"

"@walletconnect/[email protected]":
version "1.0.13"
resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.13.tgz#23b0cdd899801bfbb44a6556936ec2b93ef2adf4"
integrity sha512-mfOM7uFH4lGtQxG+XklYuFBj6dwVvseTt5/ahOkkmpcAEgz2umuzu7fTR+h5EmjQBdrmYyEBOWADbeaFNxdySg==
dependencies:
"@walletconnect/jsonrpc-utils" "^1.0.6"
"@walletconnect/safe-json" "^1.0.2"
events "^3.3.0"
tslib "1.14.1"
ws "^7.5.1"

"@walletconnect/[email protected]":
version "1.0.14"
resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.14.tgz#eec700e74766c7887de2bd76c91a0206628732aa"
Expand All @@ -5500,7 +5490,7 @@
events "^3.3.0"
ws "^7.5.1"

"@walletconnect/keyvaluestorage@^1.0.2", "@walletconnect/keyvaluestorage@^1.1.1":
"@walletconnect/keyvaluestorage@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@walletconnect/keyvaluestorage/-/keyvaluestorage-1.1.1.tgz#dd2caddabfbaf80f6b8993a0704d8b83115a1842"
integrity sha512-V7ZQq2+mSxAq7MrRqDxanTzu2RcElfK1PfNYiaVnJgJ7Q7G7hTVwF8voIBx92qsRyGHZihrwNPHuZd1aKkd0rA==
Expand Down Expand Up @@ -5639,34 +5629,34 @@
dependencies:
tslib "1.14.1"

"@walletconnect/sign-client@2.10.2":
version "2.10.2"
resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.10.2.tgz#33300a9cfe42487473f66b73c99535f6b26f8c54"
integrity sha512-vviSLV3f92I0bReX+OLr1HmbH0uIzYEQQFd1MzIfDk9PkfFT/LLAHhUnDaIAMkIdippqDcJia+5QEtT4JihL3Q==
"@walletconnect/sign-client@2.11.0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.11.0.tgz#de10f976cc1b8ab04b7f7c27f6a298e4e083ab25"
integrity sha512-H2ukscibBS+6WrzQWh+WyVBqO5z4F5et12JcwobdwgHnJSlqIoZxqnUYYWNCI5rUR5UKsKWaUyto4AE9N5dw4Q==
dependencies:
"@walletconnect/core" "2.10.2"
"@walletconnect/core" "2.11.0"
"@walletconnect/events" "^1.0.1"
"@walletconnect/heartbeat" "1.2.1"
"@walletconnect/jsonrpc-utils" "1.0.8"
"@walletconnect/logger" "^2.0.1"
"@walletconnect/time" "^1.0.2"
"@walletconnect/types" "2.10.2"
"@walletconnect/utils" "2.10.2"
"@walletconnect/types" "2.11.0"
"@walletconnect/utils" "2.11.0"
events "^3.3.0"

"@walletconnect/[email protected].0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.11.0.tgz#de10f976cc1b8ab04b7f7c27f6a298e4e083ab25"
integrity sha512-H2ukscibBS+6WrzQWh+WyVBqO5z4F5et12JcwobdwgHnJSlqIoZxqnUYYWNCI5rUR5UKsKWaUyto4AE9N5dw4Q==
"@walletconnect/[email protected].3":
version "2.11.3"
resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.11.3.tgz#3ea7b3acf92ee31cc42b45d42e66c44b4720b28b"
integrity sha512-JVjLTxN/3NjMXv5zalSGKuSYLRyU2yX6AWEdq17cInlrwODpbWZr6PS1uxMWdH4r90DXBLhdtwDbEq/pfd0BPg==
dependencies:
"@walletconnect/core" "2.11.0"
"@walletconnect/core" "2.11.3"
"@walletconnect/events" "^1.0.1"
"@walletconnect/heartbeat" "1.2.1"
"@walletconnect/jsonrpc-utils" "1.0.8"
"@walletconnect/logger" "^2.0.1"
"@walletconnect/time" "^1.0.2"
"@walletconnect/types" "2.11.0"
"@walletconnect/utils" "2.11.0"
"@walletconnect/types" "2.11.3"
"@walletconnect/utils" "2.11.3"
events "^3.3.0"

"@walletconnect/time@^1.0.2":
Expand All @@ -5676,22 +5666,22 @@
dependencies:
tslib "1.14.1"

"@walletconnect/types@2.10.2":
version "2.10.2"
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.2.tgz#68e433a29ec2cf42d79d8b50c77bd5c1d91db721"
integrity sha512-luNV+07Wdla4STi9AejseCQY31tzWKQ5a7C3zZZaRK/di+rFaAAb7YW04OP4klE7tw/mJRGPTlekZElmHxO8kQ==
"@walletconnect/types@2.11.0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.11.0.tgz#474a009c56faa9ef4063b76ed84415c801dc9f1e"
integrity sha512-AB5b1lrEbCGHxqS2vqfCkIoODieH+ZAUp9rA1O2ftrhnqDJiJK983Df87JhYhECsQUBHHfALphA8ydER0q+9sw==
dependencies:
"@walletconnect/events" "^1.0.1"
"@walletconnect/heartbeat" "1.2.1"
"@walletconnect/jsonrpc-types" "1.0.3"
"@walletconnect/keyvaluestorage" "^1.0.2"
"@walletconnect/keyvaluestorage" "^1.1.1"
"@walletconnect/logger" "^2.0.1"
events "^3.3.0"

"@walletconnect/[email protected].0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.11.0.tgz#474a009c56faa9ef4063b76ed84415c801dc9f1e"
integrity sha512-AB5b1lrEbCGHxqS2vqfCkIoODieH+ZAUp9rA1O2ftrhnqDJiJK983Df87JhYhECsQUBHHfALphA8ydER0q+9sw==
"@walletconnect/[email protected].3":
version "2.11.3"
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.11.3.tgz#8ce43cb77e8fd9d5269847cdd73bcfa7cce7dd1a"
integrity sha512-JY4wA9MVosDW9dcJMTpnwliste0aJGJ1X6Q4ulLsQsgWRSEBRkLila0oUT01TDBW9Yq8uUp7uFOUTaKx6KWVAg==
dependencies:
"@walletconnect/events" "^1.0.1"
"@walletconnect/heartbeat" "1.2.1"
Expand All @@ -5715,10 +5705,10 @@
"@walletconnect/utils" "2.11.0"
events "^3.3.0"

"@walletconnect/utils@2.10.2":
version "2.10.2"
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.2.tgz#1f2c6a2f1bb95bcc4517b1e94aa7164c9286eb46"
integrity sha512-syxXRpc2yhSknMu3IfiBGobxOY7fLfLTJuw+ppKaeO6WUdZpIit3wfuGOcc0Ms3ZPFCrGfyGOoZsCvgdXtptRg==
"@walletconnect/utils@2.11.0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.11.0.tgz#31c95151c823022077883dda61800cdea71879b7"
integrity sha512-hxkHPlTlDQILHfIKXlmzgNJau/YcSBC3XHUSuZuKZbNEw3duFT6h6pm3HT/1+j1a22IG05WDsNBuTCRkwss+BQ==
dependencies:
"@stablelib/chacha20poly1305" "1.0.1"
"@stablelib/hkdf" "1.0.1"
Expand All @@ -5728,17 +5718,17 @@
"@walletconnect/relay-api" "^1.0.9"
"@walletconnect/safe-json" "^1.0.2"
"@walletconnect/time" "^1.0.2"
"@walletconnect/types" "2.10.2"
"@walletconnect/types" "2.11.0"
"@walletconnect/window-getters" "^1.0.1"
"@walletconnect/window-metadata" "^1.0.1"
detect-browser "5.3.0"
query-string "7.1.3"
uint8arrays "^3.1.0"

"@walletconnect/[email protected].0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.11.0.tgz#31c95151c823022077883dda61800cdea71879b7"
integrity sha512-hxkHPlTlDQILHfIKXlmzgNJau/YcSBC3XHUSuZuKZbNEw3duFT6h6pm3HT/1+j1a22IG05WDsNBuTCRkwss+BQ==
"@walletconnect/[email protected].3":
version "2.11.3"
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.11.3.tgz#3731809b54902655cf202e0bf0e8f268780e8b54"
integrity sha512-jsdNkrl/IcTkzWFn0S2d0urzBXg6RxVJtUYRsUx3qI3wzOGiABP9ui3yiZ3SgZOv9aRe62PaNp1qpbYZ+zPb8Q==
dependencies:
"@stablelib/chacha20poly1305" "1.0.1"
"@stablelib/hkdf" "1.0.1"
Expand All @@ -5748,7 +5738,7 @@
"@walletconnect/relay-api" "^1.0.9"
"@walletconnect/safe-json" "^1.0.2"
"@walletconnect/time" "^1.0.2"
"@walletconnect/types" "2.11.0"
"@walletconnect/types" "2.11.3"
"@walletconnect/window-getters" "^1.0.1"
"@walletconnect/window-metadata" "^1.0.1"
detect-browser "5.3.0"
Expand Down
Loading