From 7f11a5547871ab4efd93192cdc6e2c2a70944b6a Mon Sep 17 00:00:00 2001
From: bartosz-lipinski <264380+bartosz-lipinski@users.noreply.github.com>
Date: Fri, 30 Apr 2021 15:41:44 -0500
Subject: [PATCH] feat: update torus
---
.../bridge/src/components/Layout/index.tsx | 2 +-
packages/common/src/contexts/accounts.tsx | 34 +++++++----
.../src/wallet-adapters/torus/index.tsx | 4 +-
packages/metavinci/package.json | 8 +--
yarn.lock | 61 +++++++++++++------
5 files changed, 69 insertions(+), 40 deletions(-)
diff --git a/packages/bridge/src/components/Layout/index.tsx b/packages/bridge/src/components/Layout/index.tsx
index 2544222..69034b8 100644
--- a/packages/bridge/src/components/Layout/index.tsx
+++ b/packages/bridge/src/components/Layout/index.tsx
@@ -25,7 +25,7 @@ export const AppLayout = React.memo((props: any) => {
diff --git a/packages/common/src/contexts/accounts.tsx b/packages/common/src/contexts/accounts.tsx
index 8a456b3..f4e84f9 100644
--- a/packages/common/src/contexts/accounts.tsx
+++ b/packages/common/src/contexts/accounts.tsx
@@ -328,22 +328,30 @@ const UseNativeAccount = () => {
);
useEffect(() => {
- if (!connection || !wallet?.publicKey) {
- return;
- }
+ let subId = 0;
+ const updateAccount = (account: AccountInfo | null) => {
+ if (account) {
+ updateCache(account);
+ setNativeAccount(account);
+ }
+ };
- connection.getAccountInfo(wallet.publicKey).then(acc => {
- if (acc) {
- updateCache(acc);
- setNativeAccount(acc);
+ (async () => {
+ if (!connection || !wallet?.publicKey) {
+ return;
}
- });
- connection.onAccountChange(wallet.publicKey, acc => {
- if (acc) {
- updateCache(acc);
- setNativeAccount(acc);
+
+ const account = await connection.getAccountInfo(wallet.publicKey)
+ updateAccount(account);
+
+ subId = connection.onAccountChange(wallet.publicKey, updateAccount);
+ })();
+
+ return () => {
+ if (subId) {
+ connection.removeAccountChangeListener(subId);
}
- });
+ }
}, [setNativeAccount, wallet, wallet?.publicKey, connection, updateCache]);
return { nativeAccount };
diff --git a/packages/common/src/wallet-adapters/torus/index.tsx b/packages/common/src/wallet-adapters/torus/index.tsx
index 80e0ad5..ca159e5 100644
--- a/packages/common/src/wallet-adapters/torus/index.tsx
+++ b/packages/common/src/wallet-adapters/torus/index.tsx
@@ -49,9 +49,7 @@ export class TorusWalletAdapter extends EventEmitter implements WalletAdapter {
this._provider = new OpenLogin({
clientId: process.env.REACT_APP_CLIENT_ID || 'BNxdRWx08cSTPlzMAaShlM62d4f8Tp6racfnCg_gaH0XQ1NfSGo3h5B_IkLtgSnPMhlxsSvhqugWm0x8x-VkUXA',
network: "mainnet", // mainnet, testnet, development
-
- // TODO: doesnt work
- // uxMode: 'popup'
+ uxMode: 'popup'
});
try {
diff --git a/packages/metavinci/package.json b/packages/metavinci/package.json
index 9a00549..8921fd0 100644
--- a/packages/metavinci/package.json
+++ b/packages/metavinci/package.json
@@ -18,10 +18,10 @@
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
- "@toruslabs/openlogin": "^0.7.8",
- "@toruslabs/openlogin-ed25519": "^0.7.0",
- "@toruslabs/openlogin-utils": "^0.7.0",
- "@toruslabs/torus-embed": "^1.9.10",
+ "@toruslabs/openlogin": "^0.8.0",
+ "@toruslabs/openlogin-ed25519": "^0.8.0",
+ "@toruslabs/openlogin-utils": "^0.8.0",
+ "@toruslabs/torus-embed": "^1.10.9",
"@types/animejs": "^3.1.3",
"@types/chart.js": "^2.9.29",
"@types/react-router-dom": "^5.1.6",
diff --git a/yarn.lock b/yarn.lock
index f0f1e58..cf06f0d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3391,44 +3391,67 @@
dependencies:
deepmerge "^4.2.2"
-"@toruslabs/openlogin-ed25519@^0.7.0":
- version "0.7.0"
- resolved "https://registry.yarnpkg.com/@toruslabs/openlogin-ed25519/-/openlogin-ed25519-0.7.0.tgz#836bb22b2daf0034e73d3666ad0c98227d342f36"
- integrity sha512-+JjCadlbBI1sBie+Z/CS5EHVjjCThxq0imj0VNEcNDJUqdF91uJJghyWx46GllSHoJhWh7BsZUpVU0WZZMBPmw==
+"@toruslabs/openlogin-ed25519@^0.8.0":
+ version "0.8.0"
+ resolved "https://registry.yarnpkg.com/@toruslabs/openlogin-ed25519/-/openlogin-ed25519-0.8.0.tgz#e2313e7f05439c8fb001c87089ca6dc8b036f766"
+ integrity sha512-cTWs9I4B6Sue77mMTRFiz5i9mQnMsFUUduXCpb516ufvIerWac5Pru06QtXIqM4kmVlVcQS8SYagSkWAmwu6Lg==
dependencies:
"@toruslabs/tweetnacl-js" "^1.0.3"
-"@toruslabs/openlogin-jrpc@^0.7.0":
- version "0.7.0"
- resolved "https://registry.yarnpkg.com/@toruslabs/openlogin-jrpc/-/openlogin-jrpc-0.7.0.tgz#72fee3a94e9488ae133b0595bdf4d272ca01010d"
- integrity sha512-BO6QnMQoZDp6O/JPVRj216es2m+10JcvtvudNhtfeCBPEXw/uc/OBRBBM0CC002zAHDgivSlPCc+8KOvNRXl1w==
+"@toruslabs/openlogin-jrpc@^0.8.0":
+ version "0.8.0"
+ resolved "https://registry.yarnpkg.com/@toruslabs/openlogin-jrpc/-/openlogin-jrpc-0.8.0.tgz#0931b41789158b33556b3cd5700abbc76fd5eb9e"
+ integrity sha512-bQAbFHSD+ZOhRtUd1hbNYn44vpuoCPp/2QcqklM0fMqhgCLIsuVXtT7BYeI3nNmD6UHC6VFCAZhkbrNpg+nC0A==
dependencies:
- "@toruslabs/openlogin-utils" "^0.7.0"
+ "@toruslabs/openlogin-utils" "^0.8.0"
end-of-stream "^1.4.4"
fast-safe-stringify "^2.0.7"
once "^1.4.0"
pump "^3.0.0"
-"@toruslabs/openlogin-utils@^0.7.0":
- version "0.7.0"
- resolved "https://registry.yarnpkg.com/@toruslabs/openlogin-utils/-/openlogin-utils-0.7.0.tgz#d612aacd0daaaf48734c7512335777569113902b"
- integrity sha512-6caBBLGKjcDulU6oD0p7obtg0dTQlCLTAkDStkwSK9VObMOA/eR92jn3ivjE+r+epiU0LH7kFLAE8/ZFbtpNCw==
+"@toruslabs/openlogin-utils@^0.8.0":
+ version "0.8.0"
+ resolved "https://registry.yarnpkg.com/@toruslabs/openlogin-utils/-/openlogin-utils-0.8.0.tgz#21c9d7847e05176a20f770671e6dfd051b79ff9b"
+ integrity sha512-jQQmnN4iqO6HWT39vDaln1WTvZDQYV8GO0k1RvN6xGOvVzyPeaF9yYpsjQ8zvJvaWt1kZcq1b7qsoKsFpxuY/A==
dependencies:
base64url "^3.0.1"
keccak "^3.0.1"
randombytes "^2.1.0"
-"@toruslabs/openlogin@^0.7.8":
- version "0.7.8"
- resolved "https://registry.yarnpkg.com/@toruslabs/openlogin/-/openlogin-0.7.8.tgz#e77b2e0280289f3f374e489ceff9400e505e26e7"
- integrity sha512-mHXZiODDMsU+GNcnvuEpYASnaIqlyLBZe+yHbpBoOeihq4h5s7mS8SK8Vx88DiHIHsdppVFl9J4IA56S2oGIYg==
+"@toruslabs/openlogin@^0.8.0":
+ version "0.8.0"
+ resolved "https://registry.yarnpkg.com/@toruslabs/openlogin/-/openlogin-0.8.0.tgz#fa04795db20390c23a131292535872e76642bf42"
+ integrity sha512-5GUJZnylXAGbZZLJUFk9eVwYri/GBQkPZQH/1pCw5MDuIF/DBWEsY6id44zXpS4KCnr54KoLvpQpkXkOMYtgTA==
dependencies:
"@toruslabs/eccrypto" "^1.1.6"
- "@toruslabs/openlogin-jrpc" "^0.7.0"
- "@toruslabs/openlogin-utils" "^0.7.0"
+ "@toruslabs/openlogin-jrpc" "^0.8.0"
+ "@toruslabs/openlogin-utils" "^0.8.0"
lodash.merge "^4.6.2"
pump "^3.0.0"
+"@toruslabs/torus-embed@^1.10.9":
+ version "1.10.9"
+ resolved "https://registry.yarnpkg.com/@toruslabs/torus-embed/-/torus-embed-1.10.9.tgz#1a40d9592131776d26563e3fbdd6a4dd1f0a3156"
+ integrity sha512-Nm2pBNbQNDgvCU0n0WelDzQSvJwU/cSKSXl9g/lWrcqOTmDiSGtnIn+oGtfVSgWa9oaUbD7eIKBHNTdiDMf8Bw==
+ dependencies:
+ "@chaitanyapotti/random-id" "^1.0.3"
+ "@toruslabs/fetch-node-details" "^2.4.0"
+ "@toruslabs/http-helpers" "^1.3.7"
+ "@toruslabs/torus.js" "^2.3.0"
+ create-hash "^1.2.0"
+ deepmerge "^4.2.2"
+ eth-rpc-errors "^4.0.3"
+ fast-deep-equal "^3.1.3"
+ is-stream "^2.0.0"
+ json-rpc-engine "^6.1.0"
+ json-rpc-middleware-stream "^3.0.0"
+ loglevel "^1.7.1"
+ obj-multiplex "^1.0.0"
+ obs-store "^4.0.3"
+ post-message-stream "^3.0.0"
+ pump "^3.0.0"
+ safe-event-emitter "^1.0.1"
+
"@toruslabs/torus-embed@^1.8.0", "@toruslabs/torus-embed@^1.9.10":
version "1.9.14"
resolved "https://registry.yarnpkg.com/@toruslabs/torus-embed/-/torus-embed-1.9.14.tgz#6d487a735ec6e570d62a044069581dc372ab193e"