diff --git a/examples/dapp/package.json b/examples/dapp/package.json index c7d80a1..faf9a59 100644 --- a/examples/dapp/package.json +++ b/examples/dapp/package.json @@ -30,10 +30,10 @@ "dependencies": { "@ethereumjs/tx": "^3.5.0", "@walletconnect/encoding": "^1.0.1", - "@walletconnect/ethereum-provider": "2.11.0", + "@walletconnect/ethereum-provider": "2.11.2", "@walletconnect/modal": "^2.5.4", - "@walletconnect/types": "2.11.0", - "@walletconnect/utils": "2.11.0", + "@walletconnect/types": "2.11.2", + "@walletconnect/utils": "2.11.2", "axios": "^0.21.1", "blockies-ts": "^1.0.0", "cosmos-wallet": "^1.1.0", diff --git a/examples/dapp/yarn.lock b/examples/dapp/yarn.lock index 2761824..da44759 100644 --- a/examples/dapp/yarn.lock +++ b/examples/dapp/yarn.lock @@ -3055,10 +3055,10 @@ "@typescript-eslint/types" "4.33.0" eslint-visitor-keys "^2.0.0" -"@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== +"@walletconnect/core@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.11.2.tgz#35286be92c645fa461fecc0dfe25de9f076fca8f" + integrity sha512-bB4SiXX8hX3/hyBfVPC5gwZCXCl+OPj+/EDVM71iAO3TDsh78KPbrVAbDnnsbHzZVHlsMohtXX3j5XVsheN3+g== dependencies: "@walletconnect/heartbeat" "1.2.1" "@walletconnect/jsonrpc-provider" "1.0.13" @@ -3071,8 +3071,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.2" + "@walletconnect/utils" "2.11.2" events "^3.3.0" isomorphic-unfetch "3.1.0" lodash.isequal "4.5.0" @@ -3094,20 +3094,20 @@ dependencies: tslib "1.14.1" -"@walletconnect/ethereum-provider@2.11.0": - version "2.11.0" - resolved "https://registry.yarnpkg.com/@walletconnect/ethereum-provider/-/ethereum-provider-2.11.0.tgz#feb90368d8b2608d7d120ac8feeb3e26eac8c709" - integrity sha512-YrTeHVjuSuhlUw7SQ6xBJXDuJ6iAC+RwINm9nVhoKYJSHAy3EVSJZOofMKrnecL0iRMtD29nj57mxAInIBRuZA== +"@walletconnect/ethereum-provider@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/ethereum-provider/-/ethereum-provider-2.11.2.tgz#914f773e37a879bc00cf367437c4e98a826247b1" + integrity sha512-BUDqee0Uy2rCZVkW5Ao3q6Ado/3fePYnFdryVF+YL6bPhj+xQZ5OfKodl+uvs7Rwq++O5wTX2RqOTzpW7+v+Mg== dependencies: "@walletconnect/jsonrpc-http-connection" "^1.0.7" "@walletconnect/jsonrpc-provider" "^1.0.13" "@walletconnect/jsonrpc-types" "^1.0.3" "@walletconnect/jsonrpc-utils" "^1.0.8" "@walletconnect/modal" "^2.6.2" - "@walletconnect/sign-client" "2.11.0" - "@walletconnect/types" "2.11.0" - "@walletconnect/universal-provider" "2.11.0" - "@walletconnect/utils" "2.11.0" + "@walletconnect/sign-client" "2.11.2" + "@walletconnect/types" "2.11.2" + "@walletconnect/universal-provider" "2.11.2" + "@walletconnect/utils" "2.11.2" events "^3.3.0" "@walletconnect/events@^1.0.1": @@ -3292,19 +3292,19 @@ dependencies: tslib "1.14.1" -"@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== +"@walletconnect/sign-client@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.11.2.tgz#855609653855f0d23b0502cdbdcf43402e34c459" + integrity sha512-MfBcuSz2GmMH+P7MrCP46mVE5qhP0ZyWA0FyIH6/WuxQ6G+MgKsGfaITqakpRPsykWOJq8tXMs3XvUPDU413OQ== dependencies: - "@walletconnect/core" "2.11.0" + "@walletconnect/core" "2.11.2" "@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.2" + "@walletconnect/utils" "2.11.2" events "^3.3.0" "@walletconnect/time@^1.0.2": @@ -3314,10 +3314,10 @@ dependencies: tslib "1.14.1" -"@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== +"@walletconnect/types@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.11.2.tgz#d0359dd4106fcaa1634241a00428d3ea08d0d3c7" + integrity sha512-p632MFB+lJbip2cvtXPBQslpUdiw1sDtQ5y855bOlAGquay+6fZ4h1DcDePeKQDQM3P77ax2a9aNPZxV6y/h1Q== dependencies: "@walletconnect/events" "^1.0.1" "@walletconnect/heartbeat" "1.2.1" @@ -3326,25 +3326,25 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@walletconnect/universal-provider@2.11.0": - version "2.11.0" - resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.11.0.tgz#89053c2360b5ce766c213ca4e33bb4ce4976b0be" - integrity sha512-zgJv8jDvIMP4Qse/D9oIRXGdfoNqonsrjPZanQ/CHNe7oXGOBiQND2IIeX+tS0H7uNA0TPvctljCLiIN9nw4eA== +"@walletconnect/universal-provider@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/universal-provider/-/universal-provider-2.11.2.tgz#bec3038f51445d707bbec75f0cb8af0a1f1e04db" + integrity sha512-cNtIn5AVoDxKAJ4PmB8m5adnf5mYQMUamEUPKMVvOPscfGtIMQEh9peKsh2AN5xcRVDbgluC01Id545evFyymw== dependencies: "@walletconnect/jsonrpc-http-connection" "^1.0.7" "@walletconnect/jsonrpc-provider" "1.0.13" "@walletconnect/jsonrpc-types" "^1.0.2" "@walletconnect/jsonrpc-utils" "^1.0.7" "@walletconnect/logger" "^2.0.1" - "@walletconnect/sign-client" "2.11.0" - "@walletconnect/types" "2.11.0" - "@walletconnect/utils" "2.11.0" + "@walletconnect/sign-client" "2.11.2" + "@walletconnect/types" "2.11.2" + "@walletconnect/utils" "2.11.2" events "^3.3.0" -"@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== +"@walletconnect/utils@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.11.2.tgz#dee0f19adf5e38543612cbe9fa4de7ed28eb7e85" + integrity sha512-LyfdmrnZY6dWqlF4eDrx5jpUwsB2bEPjoqR5Z6rXPiHJKUOdJt7az+mNOn5KTSOlRpd1DmozrBrWr+G9fFLYVw== dependencies: "@stablelib/chacha20poly1305" "1.0.1" "@stablelib/hkdf" "1.0.1" @@ -3354,7 +3354,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.2" "@walletconnect/window-getters" "^1.0.1" "@walletconnect/window-metadata" "^1.0.1" detect-browser "5.3.0" diff --git a/examples/wallet/package.json b/examples/wallet/package.json index 24ab680..ea86e88 100644 --- a/examples/wallet/package.json +++ b/examples/wallet/package.json @@ -13,9 +13,9 @@ "dependencies": { "@json-rpc-tools/utils": "1.7.6", "@nextui-org/react": "1.0.0-beta.12", - "@walletconnect/core": "2.10.3", - "@walletconnect/se-sdk": "1.7.0-rc.0", - "@walletconnect/utils": "2.10.3", + "@walletconnect/core": "2.11.2", + "@walletconnect/se-sdk": "1.7.1-canary.1", + "@walletconnect/utils": "2.11.2", "ethers": "5.7.2", "framer-motion": "9.0.2", "next": "12.2.0", @@ -28,7 +28,7 @@ "devDependencies": { "@types/node": "18.13.0", "@types/react": "18.0.28", - "@walletconnect/types": "2.10.3", + "@walletconnect/types": "2.11.2", "eslint": "8.34.0", "eslint-config-next": "13.1.6", "eslint-config-prettier": "8.6.0", diff --git a/examples/wallet/src/views/SwitchChainModal.tsx b/examples/wallet/src/views/SwitchChainModal.tsx index 27bd6f9..64a42ad 100644 --- a/examples/wallet/src/views/SwitchChainModal.tsx +++ b/examples/wallet/src/views/SwitchChainModal.tsx @@ -33,6 +33,7 @@ export default function SwitchChainModal() { id: requestEvent.id, result: {}, }); + SettingsStore.setActiveChainId(parseInt(hexChain)); await web3wallet.updateSession({ topic, chainId: parseInt(hexChain), diff --git a/examples/wallet/yarn.lock b/examples/wallet/yarn.lock index 9cbee3a..1370b0e 100644 --- a/examples/wallet/yarn.lock +++ b/examples/wallet/yarn.lock @@ -1898,32 +1898,33 @@ events "^3.3.0" isomorphic-unfetch "^3.1.0" -"@walletconnect/core@2.10.3": - version "2.10.3" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.3.tgz#413d4acfcf3ca831b2f072a083a830194ebbfd82" - integrity sha512-zvV7Rr48Mftm1+eWr+eTyriV3BFhhY703hGmi2+dA1qMe/5FuIQZs24anBWQapfJuL+CgdGczb/BI9/x3NX7jA== +"@walletconnect/core@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.11.2.tgz#35286be92c645fa461fecc0dfe25de9f076fca8f" + integrity sha512-bB4SiXX8hX3/hyBfVPC5gwZCXCl+OPj+/EDVM71iAO3TDsh78KPbrVAbDnnsbHzZVHlsMohtXX3j5XVsheN3+g== 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.3" - "@walletconnect/utils" "2.10.3" + "@walletconnect/types" "2.11.2" + "@walletconnect/utils" "2.11.2" events "^3.3.0" + isomorphic-unfetch "3.1.0" lodash.isequal "4.5.0" uint8arrays "^3.1.0" -"@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== +"@walletconnect/core@2.11.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" @@ -1936,8 +1937,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" @@ -2088,26 +2089,26 @@ dependencies: tslib "1.14.1" -"@walletconnect/se-sdk@1.7.0-rc.0": - version "1.7.0-rc.0" - resolved "https://registry.yarnpkg.com/@walletconnect/se-sdk/-/se-sdk-1.7.0-rc.0.tgz#599a9748f897fb920b96d032ced5dc853ed20047" - integrity sha512-PSbf9pVFN4EvpTz6M0vKBS5B6p9UKVbyau1NDSE8Pz8F0I8BPHZQaIM2mHJg/ZcCW98hVKNwETU+oT0K7ItCxw== +"@walletconnect/se-sdk@1.7.1-canary.1": + version "1.7.1-canary.1" + resolved "https://registry.yarnpkg.com/@walletconnect/se-sdk/-/se-sdk-1.7.1-canary.1.tgz#9b50fd5c36bc953e5de5bbf249b15112475791f3" + integrity sha512-FZx1a66VW7U07iUq0SwJH/dyEnX88GQIUHl1ceN5wSfL2HDAvJEjqHVWm4cLvozTLSA3Fd2ZU9iG3q7FQSmOwA== dependencies: - "@walletconnect/web3wallet" "1.10.0" + "@walletconnect/web3wallet" "1.10.3" -"@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== +"@walletconnect/sign-client@2.11.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": @@ -2129,22 +2130,22 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@walletconnect/types@2.10.3": - version "2.10.3" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.3.tgz#e32adaf6ca921f4c08e1331fc5f919b5baad8120" - integrity sha512-HcLR4JKTQyVoconQ8CqxtPrIVYHMQwZtvBq5RD0InuhxChabu2GsxtSfmz+M7ShzKWItohZx1EQJKYZKYw9ekA== +"@walletconnect/types@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.11.2.tgz#d0359dd4106fcaa1634241a00428d3ea08d0d3c7" + integrity sha512-p632MFB+lJbip2cvtXPBQslpUdiw1sDtQ5y855bOlAGquay+6fZ4h1DcDePeKQDQM3P77ax2a9aNPZxV6y/h1Q== 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/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== +"@walletconnect/types@2.11.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" @@ -2173,10 +2174,10 @@ query-string "7.1.3" uint8arrays "^3.1.0" -"@walletconnect/utils@2.10.3": - version "2.10.3" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.3.tgz#56fb9a6ab96a3c85f952205dc5042f1c0f1e9f6c" - integrity sha512-9FTujY4t+SrENgvyT84TFsO1iFvix2dWH5C9PmJ3/LMrkYytjszJVMPY5bDG73RBwph9wbeYzPgkGvid2RP63A== +"@walletconnect/utils@2.11.2": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.11.2.tgz#dee0f19adf5e38543612cbe9fa4de7ed28eb7e85" + integrity sha512-LyfdmrnZY6dWqlF4eDrx5jpUwsB2bEPjoqR5Z6rXPiHJKUOdJt7az+mNOn5KTSOlRpd1DmozrBrWr+G9fFLYVw== dependencies: "@stablelib/chacha20poly1305" "1.0.1" "@stablelib/hkdf" "1.0.1" @@ -2186,17 +2187,17 @@ "@walletconnect/relay-api" "^1.0.9" "@walletconnect/safe-json" "^1.0.2" "@walletconnect/time" "^1.0.2" - "@walletconnect/types" "2.10.3" + "@walletconnect/types" "2.11.2" "@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/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== +"@walletconnect/utils@2.11.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" @@ -2206,26 +2207,26 @@ "@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" query-string "7.1.3" uint8arrays "^3.1.0" -"@walletconnect/web3wallet@1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@walletconnect/web3wallet/-/web3wallet-1.10.0.tgz#5a7f181bbea213e8fb5961900a0069e58da36d18" - integrity sha512-JyaYdnBKL1hVpsE5hpjZhohpX1Ak2mwai3GYr8nI1FfK8Z3IPIh+4ImeDMnEao1cQFoItQNompp5y5C7WlI69A== +"@walletconnect/web3wallet@1.10.3": + version "1.10.3" + resolved "https://registry.yarnpkg.com/@walletconnect/web3wallet/-/web3wallet-1.10.3.tgz#8195308757bd298ccc9caa6e3fe9f4ff82b94607" + integrity sha512-1Dr2P8KIDCqEWZ+s4coKGJz/+pj87ogFs+icPDXPu9QpzTgY5Y1WSzuAHaqoY5gTlL7WS58YP49s0E7iacUz4g== dependencies: "@walletconnect/auth-client" "2.1.2" - "@walletconnect/core" "2.11.0" + "@walletconnect/core" "2.11.3" "@walletconnect/jsonrpc-provider" "1.0.13" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.0.1" - "@walletconnect/sign-client" "2.11.0" - "@walletconnect/types" "2.11.0" - "@walletconnect/utils" "2.11.0" + "@walletconnect/sign-client" "2.11.3" + "@walletconnect/types" "2.11.3" + "@walletconnect/utils" "2.11.3" "@walletconnect/window-getters@^1.0.1": version "1.0.1" diff --git a/package.json b/package.json index c129743..1394b7b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@walletconnect/se-sdk", "description": "Single-Ethreum-SDK for WalletConnect Protocol", "private": false, - "version": "1.7.0", + "version": "1.7.1", "author": "WalletConnect, Inc. ", "homepage": "https://github.com/walletconnect/walletconnect-monorepo/", "license": "Apache-2.0", @@ -33,7 +33,7 @@ "install:all": "yarn && cd ./examples/dapp && yarn && cd ./../wallet && yarn" }, "dependencies": { - "@walletconnect/web3wallet": "1.10.0" + "@walletconnect/web3wallet": "1.10.3" }, "devDependencies": { "@ethersproject/wallet": "^5.7.0", diff --git a/src/controllers/engine.ts b/src/controllers/engine.ts index fa2793a..032e50f 100644 --- a/src/controllers/engine.ts +++ b/src/controllers/engine.ts @@ -26,6 +26,8 @@ export class Engine extends ISingleEthereumEngine { reject: (value?: T | PromiseLike) => void; }[] = []; + private switchChainTimeout: NodeJS.Timeout | undefined; + constructor(client: ISingleEthereumEngine["client"]) { super(client); // initialized in init() @@ -41,7 +43,7 @@ export class Engine extends ISingleEthereumEngine { }; public pair: ISingleEthereumEngine["pair"] = async (params) => { - await this.client.core.pairing.pair(params); + await this.web3wallet.pair(params); }; public approveSession: ISingleEthereumEngine["approveSession"] = async (params) => { @@ -49,14 +51,16 @@ export class Engine extends ISingleEthereumEngine { const proposal = this.web3wallet.engine.signClient.proposal.get(id); const normalizedRequired = normalizeNamespaces(proposal.requiredNamespaces); const normalizedOptional = normalizeNamespaces(proposal.optionalNamespaces); - const requiredChain = normalizedRequired[EVM_IDENTIFIER]?.chains?.[0]; - const requiredParsed = requiredChain ? parseInt(parseChain(requiredChain)) : chainId; - const approvedChains = [requiredParsed]; - - if (requiredParsed !== chainId) { - approvedChains.push(chainId); - } + const requiredChains = (normalizedRequired[EVM_IDENTIFIER]?.chains || []).map((chain) => { + const parsed = parseChain(chain); + return parseInt(parsed); + }); + const optionalChains = (normalizedOptional[EVM_IDENTIFIER]?.chains || []).map((chain) => { + const parsed = parseChain(chain); + return parseInt(parsed); + }); + const approvedChains = [...new Set([chainId, ...requiredChains, ...optionalChains])]; const approveParams = { id, namespaces: { @@ -86,8 +90,8 @@ export class Engine extends ISingleEthereumEngine { const session = await this.web3wallet.approveSession(approveParams); this.chainId = chainId; // emit chainChanged if a different chain is approved other than the required - if (approvedChains.length > 1) { - setTimeout(() => this.changeChain(session.topic, chainId), 2_000); + if (chainId !== requiredChains?.[0]) { + this.switchChainTimeout = setTimeout(() => this.changeChain(session.topic, chainId), 2_000); } return session; @@ -102,38 +106,62 @@ export class Engine extends ISingleEthereumEngine { public updateSession: ISingleEthereumEngine["updateSession"] = async (params) => { const { topic, chainId, accounts } = params; + if (chainId < 1) { + // eslint-disable-next-line no-console + return console.error("se-sdk, updateSession Invalid chainId", chainId); + } const session = this.web3wallet.engine.signClient.session.get(topic); const formattedChain = prefixChainWithNamespace(chainId); const formattedAccounts = formatAccounts(accounts, chainId); const namespaces = session.namespaces[EVM_IDENTIFIER]; + let shouldUpdateSession = false; if (!chainAlreadyInSession(session, chainId)) { namespaces?.chains?.push(formattedChain); + shouldUpdateSession = true; } if (!accountsAlreadyInSession(session, formattedAccounts)) { namespaces.accounts = namespaces.accounts.concat(formattedAccounts); + shouldUpdateSession = true; } - await this.web3wallet.updateSession({ - topic, - namespaces: { - [EVM_IDENTIFIER]: namespaces, - }, - }); + if (shouldUpdateSession) { + await Promise.all([ + new Promise((resolve) => { + // wait for relayer to publish the update before emitting events + const onPublish = (params: { topic: string }) => { + if (params.topic === topic) { + this.web3wallet.core.relayer.off("relayer_publish", onPublish); + resolve(); + } + }; + this.web3wallet.core.relayer.on("relayer_publish", onPublish); + }), + this.web3wallet.updateSession({ + topic, + namespaces: { + [EVM_IDENTIFIER]: namespaces, + }, + }), + ]); + } if (this.chainId !== chainId) { await this.changeChain(topic, chainId); this.chainId = chainId; } - - await this.web3wallet.emitSessionEvent({ - topic, - event: { - name: "accountsChanged", - data: formattedAccounts, - }, - chainId: formattedChain, - }); + try { + await this.web3wallet.emitSessionEvent({ + topic, + event: { + name: "accountsChanged", + data: formattedAccounts, + }, + chainId: formattedChain, + }); + } catch (e) { + this.client.logger.warn(e); + } }; public approveRequest: ISingleEthereumEngine["approveRequest"] = async (params) => { @@ -225,9 +253,13 @@ export class Engine extends ISingleEthereumEngine { this.client.logger.info( `Session request chainId ${event.params.chainId} does not match current chainId ${this.chainId}. Attempting to switch`, ); - await this.switchEthereumChain(event).catch((e) => { + try { + await this.switchEthereumChain(event); + } catch (e) { this.client.logger.warn(e); - }); + const error = getSdkError("USER_REJECTED"); + return this.rejectRequest({ id: event.id, topic: event.topic, error }); + } } // delay session request to allow for chain switch to complete setTimeout(() => this.client.events.emit("session_request", event), 1_000); @@ -293,15 +325,19 @@ export class Engine extends ISingleEthereumEngine { }; private changeChain = async (topic: string, chainId: number) => { - await this.web3wallet.engine.signClient.ping({ topic }); - await this.web3wallet.emitSessionEvent({ - topic, - event: { - name: "chainChanged", - data: chainId, - }, - chainId: prefixChainWithNamespace(chainId), - }); + try { + clearTimeout(this.switchChainTimeout); + await this.web3wallet.emitSessionEvent({ + topic, + event: { + name: "chainChanged", + data: chainId, + }, + chainId: prefixChainWithNamespace(chainId), + }); + } catch (e) { + this.client.logger.warn(e); + } }; private switchEthereumChain = async (event: SingleEthereumTypes.SessionRequest) => { diff --git a/test/sign.spec.ts b/test/sign.spec.ts index 3227b1d..048f080 100644 --- a/test/sign.spec.ts +++ b/test/sign.spec.ts @@ -188,7 +188,15 @@ describe("Sign Integration", () => { new Promise((resolve) => { dapp.events.on("session_update", (session) => { const { params } = session; - expect(params.namespaces).to.toMatchObject(TEST_UPDATED_NAMESPACES); + expect(params.namespaces.eip155.accounts).to.toMatchObject( + TEST_UPDATED_NAMESPACES.eip155.accounts, + ); + expect(params.namespaces.eip155.methods).to.toMatchObject( + TEST_UPDATED_NAMESPACES.eip155.methods, + ); + expect(params.namespaces.eip155.events).to.toMatchObject( + TEST_UPDATED_NAMESPACES.eip155.events, + ); resolve(session); }); }), @@ -261,6 +269,76 @@ describe("Sign Integration", () => { ]); }); + it.skip("should replace approved chainId on update", async () => { + dapp = await SignClient.init({ + ...TEST_CORE_OPTIONS, + name: "Dapp", + }); + const { uri, approval } = await dapp.connect({ + optionalNamespaces: TEST_OPTIONAL_NAMESPACES, + }); + sessionApproval = approval; + uriString = uri || ""; + let session; + wallet = await SingleEthereum.init({ + core, + name: "wallet", + metadata: {} as any, + }); + + // first pair and approve session + await Promise.all([ + new Promise((resolve) => { + wallet.on("session_proposal", async (sessionProposal) => { + const { id, params } = sessionProposal; + session = await wallet.approveSession({ + id, + chainId: TEST_ETHEREUM_CHAIN_PARSED, + accounts: [cryptoWallet.address], + }); + resolve(session); + }); + }), + sessionApproval(), + wallet.pair({ uri: uriString }), + ]); + await Promise.all([ + new Promise((resolve) => { + dapp.events.once("session_update", (session) => { + const { params } = session; + expect(params.namespaces.eip155.chains).to.toMatchObject([ + `${EVM_IDENTIFIER}:${TEST_GOERLI_CHAIN_PARSED}`, + ]); + resolve(session); + }); + }), + wallet.updateSession({ + topic: session.topic, + chainId: TEST_GOERLI_CHAIN_PARSED, + accounts: [TEST_ETHEREUM_ADDRESS], + }), + ]); + await new Promise((resolve) => setTimeout(resolve, 1000)); + await Promise.all([ + new Promise((resolve) => { + dapp.events.once("session_update", (session) => { + const { params } = session; + expect(params.namespaces.eip155.chains).to.toMatchObject([ + `${EVM_IDENTIFIER}:${TEST_ETHEREUM_CHAIN_PARSED}`, + ]); + resolve(session); + }); + }), + wallet.updateSession({ + topic: session.topic, + chainId: TEST_ETHEREUM_CHAIN_PARSED, + accounts: [TEST_ETHEREUM_ADDRESS], + }), + ]); + + await new Promise((resolve) => setTimeout(resolve, 1000)); + }); + it("should request wallet_switchEthereumChain to session request in different chain", async () => { // first pair and approve session await Promise.all([ @@ -385,44 +463,32 @@ describe("Sign Integration", () => { resolve(); } }); - wallet.on("session_request", async (sessionRequest) => { - const { id, params, verifyContext } = sessionRequest; - if (params.request.method === "wallet_switchEthereumChain") return; - expect(verifyContext).to.be.exist; - expect(verifyContext.verified.validation).to.eq("UNKNOWN"); - const requestParams = params.request.params as TransactionRequest[]; - const signTransaction = requestParams[0]; - const signature = await cryptoWallet.signTransaction(signTransaction); - const response = await wallet.approveRequest({ - id, - topic: session.topic, - result: signature, - }); - resolve(response); - }); }), new Promise(async (resolve) => { - const result = await dapp.request({ - topic: session.topic, - request: { - method: "eth_signTransaction", - params: [ - { - from: cryptoWallet.address, - to: cryptoWallet.address, - data: "0x", - nonce: "0x01", - gasPrice: "0x020a7ac094", - gasLimit: "0x5208", - value: "0x00", - }, - ], - }, - chainId: TEST_ETHEREUM_CHAIN, - }); - expect(result).to.be.exist; - expect(result).to.be.a("string"); - resolve(); + try { + await dapp.request({ + topic: session.topic, + request: { + method: "eth_signTransaction", + params: [ + { + from: cryptoWallet.address, + to: cryptoWallet.address, + data: "0x", + nonce: "0x01", + gasPrice: "0x020a7ac094", + gasLimit: "0x5208", + value: "0x00", + }, + ], + }, + chainId: TEST_ETHEREUM_CHAIN, + }); + } catch (e) { + expect(e).to.be.exist; + expect(e).to.toMatchObject(getSdkError("USER_REJECTED")); + resolve(); + } }), ]); // chain was not updated so should stay the same diff --git a/yarn.lock b/yarn.lock index bbc405c..83c5eed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -918,10 +918,10 @@ events "^3.3.0" isomorphic-unfetch "^3.1.0" -"@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== +"@walletconnect/core@2.11.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" @@ -934,8 +934,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" @@ -1086,19 +1086,19 @@ dependencies: tslib "1.14.1" -"@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== +"@walletconnect/sign-client@2.11.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": @@ -1120,10 +1120,10 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@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== +"@walletconnect/types@2.11.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" @@ -1152,10 +1152,10 @@ query-string "7.1.3" uint8arrays "^3.1.0" -"@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== +"@walletconnect/utils@2.11.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" @@ -1165,26 +1165,26 @@ "@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" query-string "7.1.3" uint8arrays "^3.1.0" -"@walletconnect/web3wallet@1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@walletconnect/web3wallet/-/web3wallet-1.10.0.tgz#5a7f181bbea213e8fb5961900a0069e58da36d18" - integrity sha512-JyaYdnBKL1hVpsE5hpjZhohpX1Ak2mwai3GYr8nI1FfK8Z3IPIh+4ImeDMnEao1cQFoItQNompp5y5C7WlI69A== +"@walletconnect/web3wallet@1.10.3": + version "1.10.3" + resolved "https://registry.yarnpkg.com/@walletconnect/web3wallet/-/web3wallet-1.10.3.tgz#8195308757bd298ccc9caa6e3fe9f4ff82b94607" + integrity sha512-1Dr2P8KIDCqEWZ+s4coKGJz/+pj87ogFs+icPDXPu9QpzTgY5Y1WSzuAHaqoY5gTlL7WS58YP49s0E7iacUz4g== dependencies: "@walletconnect/auth-client" "2.1.2" - "@walletconnect/core" "2.11.0" + "@walletconnect/core" "2.11.3" "@walletconnect/jsonrpc-provider" "1.0.13" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "2.0.1" - "@walletconnect/sign-client" "2.11.0" - "@walletconnect/types" "2.11.0" - "@walletconnect/utils" "2.11.0" + "@walletconnect/sign-client" "2.11.3" + "@walletconnect/types" "2.11.3" + "@walletconnect/utils" "2.11.3" "@walletconnect/window-getters@^1.0.1": version "1.0.1"