From a7b55ceed7784eeca1d2af191a072f54775088be Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 3 Mar 2021 12:29:56 +0100 Subject: [PATCH 1/6] wallet select on multisig --- src/context/Wallet/WalletProvider.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/context/Wallet/WalletProvider.tsx b/src/context/Wallet/WalletProvider.tsx index 898be9d8..b96eb835 100644 --- a/src/context/Wallet/WalletProvider.tsx +++ b/src/context/Wallet/WalletProvider.tsx @@ -87,6 +87,11 @@ class WalletProvider extends React.Component { } multisigInfo = await wallet.api.multisigInfo(multisigID) multisigActor = await wallet.api.actorKey(multisigInfo.signers[0]) + // select account if found + const index = accounts.findIndex((account) => account === multisigActor) + if (index !== -1) { + lastWallet = accounts[index] + } } catch (e) { this.state.dispatchNotification('Multisig not found') return false @@ -165,6 +170,11 @@ class WalletProvider extends React.Component { } multisigInfo = await wallet.api.multisigInfo(multisigID) multisigActor = await wallet.api.actorKey(multisigInfo.signers[0]) + // select account if found + const index = accounts.findIndex((account) => account === multisigActor) + if (index !== -1) { + lastWallet = accounts[index] + } } catch (e) { this.state.dispatchNotification('Multisig not found') return false From 1d48ece2c17a01daee006af84b1e960608cdbe20 Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 3 Mar 2021 13:58:30 +0100 Subject: [PATCH 2/6] cancel on not found --- src/context/Wallet/WalletProvider.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/context/Wallet/WalletProvider.tsx b/src/context/Wallet/WalletProvider.tsx index b96eb835..a818ced0 100644 --- a/src/context/Wallet/WalletProvider.tsx +++ b/src/context/Wallet/WalletProvider.tsx @@ -91,6 +91,9 @@ class WalletProvider extends React.Component { const index = accounts.findIndex((account) => account === multisigActor) if (index !== -1) { lastWallet = accounts[index] + } else { + this.state.dispatchNotification('Multisig address not found in wallet') + return false } } catch (e) { this.state.dispatchNotification('Multisig not found') @@ -174,6 +177,9 @@ class WalletProvider extends React.Component { const index = accounts.findIndex((account) => account === multisigActor) if (index !== -1) { lastWallet = accounts[index] + } else { + this.state.dispatchNotification('Multisig address not found in wallet') + return false } } catch (e) { this.state.dispatchNotification('Multisig not found') From 70f31f31f292406cde824cabac559f8330250ca0 Mon Sep 17 00:00:00 2001 From: josepablofm78 Date: Wed, 3 Mar 2021 14:40:41 +0100 Subject: [PATCH 3/6] v1.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dbccfbb2..f5899fde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "filecoin-verifier-frontend", - "version": "1.3.3", + "version": "1.3.4", "private": true, "dependencies": { "@emotion/react": "^11.0.0-next.13", From 9332fdc23c8a52a826bcd06792586c980b3ae23b Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Thu, 4 Mar 2021 09:56:53 +0100 Subject: [PATCH 4/6] signers check --- src/context/Wallet/WalletProvider.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/context/Wallet/WalletProvider.tsx b/src/context/Wallet/WalletProvider.tsx index a818ced0..1fec1d83 100644 --- a/src/context/Wallet/WalletProvider.tsx +++ b/src/context/Wallet/WalletProvider.tsx @@ -29,7 +29,6 @@ interface WalletProviderStates { dispatchNotification: any multisig: boolean multisigAddress: string - multisigActor: string multisigID: string } @@ -76,7 +75,6 @@ class WalletProvider extends React.Component { } } let multisigInfo: any = {} - let multisigActor: string = '' let multisigID: string = '' if (options.multisig) { try { @@ -86,9 +84,13 @@ class WalletProvider extends React.Component { multisigID = options.multisigAddress } multisigInfo = await wallet.api.multisigInfo(multisigID) - multisigActor = await wallet.api.actorKey(multisigInfo.signers[0]) // select account if found - const index = accounts.findIndex((account) => account === multisigActor) + const multisigActors: any[] = [] + for (let index = 0; index < multisigInfo.signers.length; index++) { + const actor = await wallet.api.actorKey(multisigInfo.signers[index]) + multisigActors.push(actor) + } + const index = accounts.findIndex((account) => multisigActors.includes(account)) if (index !== -1) { lastWallet = accounts[index] } else { @@ -127,7 +129,6 @@ class WalletProvider extends React.Component { accountsActive, multisig: options.multisig ? true : false, multisigAddress: options.multisig ? options.multisigAddress : '', - multisigActor: options.multisig ? multisigActor : '', multisigID: multisigID }) // this.loadGithub() @@ -162,7 +163,6 @@ class WalletProvider extends React.Component { } } let multisigInfo: any = {} - let multisigActor: string = '' let multisigID: string = '' if (options.multisig) { try { @@ -172,9 +172,13 @@ class WalletProvider extends React.Component { multisigID = options.multisigAddress } multisigInfo = await wallet.api.multisigInfo(multisigID) - multisigActor = await wallet.api.actorKey(multisigInfo.signers[0]) // select account if found - const index = accounts.findIndex((account) => account === multisigActor) + const multisigActors: any[] = [] + for (let index = 0; index < multisigInfo.signers.length; index++) { + const actor = await wallet.api.actorKey(multisigInfo.signers[index]) + multisigActors.push(actor) + } + const index = accounts.findIndex((account) => multisigActors.includes(account)) if (index !== -1) { lastWallet = accounts[index] } else { @@ -199,7 +203,6 @@ class WalletProvider extends React.Component { accountsActive, multisig: options.multisig ? true : false, multisigAddress: options.multisig ? options.multisigAddress : '', - multisigActor: options.multisig ? multisigActor : '', multisigID: multisigID }) return true From a4019b383d3c7aa2fa825dd21929f81586139b28 Mon Sep 17 00:00:00 2001 From: josepablofm78 Date: Thu, 4 Mar 2021 10:10:58 +0100 Subject: [PATCH 5/6] v1.3.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5899fde..8b58fb5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "filecoin-verifier-frontend", - "version": "1.3.4", + "version": "1.3.5", "private": true, "dependencies": { "@emotion/react": "^11.0.0-next.13", From 7b80b8703fb1322554380d2e155958325144dd1c Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Fri, 5 Mar 2021 10:32:49 +0100 Subject: [PATCH 6/6] wallet index fix --- src/context/Wallet/WalletProvider.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/context/Wallet/WalletProvider.tsx b/src/context/Wallet/WalletProvider.tsx index 1fec1d83..e51db949 100644 --- a/src/context/Wallet/WalletProvider.tsx +++ b/src/context/Wallet/WalletProvider.tsx @@ -64,12 +64,12 @@ class WalletProvider extends React.Component { const { cookies } = this.props; const walletCookie = cookies.get('wallet') let lastWallet - let walletCookieIndex = - 1 + let walletIndex = - 1 if (walletCookie) { for (let index = 0; index < accounts.length; index++) { if (accounts[index] === walletCookie) { lastWallet = accounts[index] - walletCookieIndex = index + walletIndex = index break; } } @@ -93,6 +93,7 @@ class WalletProvider extends React.Component { const index = accounts.findIndex((account) => multisigActors.includes(account)) if (index !== -1) { lastWallet = accounts[index] + walletIndex = index } else { this.state.dispatchNotification('Multisig address not found in wallet') return false @@ -107,7 +108,7 @@ class WalletProvider extends React.Component { isLoading: false, wallet: 'ledger', api: wallet.api, - walletIndex: walletCookieIndex !== -1 ? walletCookieIndex : 0, + walletIndex: walletIndex !== -1 ? walletIndex : 0, sign: async (param1: any, param2: any) => { try { const ret = await wallet.sign(param1, param2) @@ -152,12 +153,12 @@ class WalletProvider extends React.Component { const { cookies } = this.props; const walletCookie = cookies.get('wallet') let lastWallet - let walletCookieIndex = - 1 + let walletIndex = - 1 if (walletCookie) { for (let index = 0; index < accounts.length; index++) { if (accounts[index] === walletCookie) { lastWallet = accounts[index] - walletCookieIndex = index + walletIndex = index break; } } @@ -181,6 +182,7 @@ class WalletProvider extends React.Component { const index = accounts.findIndex((account) => multisigActors.includes(account)) if (index !== -1) { lastWallet = accounts[index] + walletIndex = index } else { this.state.dispatchNotification('Multisig address not found in wallet') return false @@ -197,7 +199,7 @@ class WalletProvider extends React.Component { api: wallet.api, sign: wallet.sign, getAccounts: wallet.getAccounts, - walletIndex: walletCookieIndex !== -1 ? walletCookieIndex : 0, + walletIndex: walletIndex !== -1 ? walletIndex : 0, activeAccount: lastWallet ? lastWallet : accounts[0], accounts, accountsActive,