From 3942347b5ac6bd1201779d1dfaca278c8750a74e Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 3 Apr 2020 20:01:43 +0400 Subject: [PATCH] v1.9.2 (#734) * Bug: Invalid V in signature with eth_sign (#728) * Fix invalid V with metamask/ledger * DONT FORGET TO REVERT BEFORE MERGING: test deployment * DONT FORGET TO REVERT BEFORE MERGING 2: test deployment * Revert "DONT FORGET TO REVERT BEFORE MERGING 2: test deployment" This reverts commit 8331f2a78f7fc8f53eb893899f16edd8238c68ff. * Revert "DONT FORGET TO REVERT BEFORE MERGING: test deployment" This reverts commit 03b81e31820ce4fe078a7131c2f0caa2af4870ac. * BUG: Only injected providers are cached as last used provider (#733) * cache every used provider, not only injected one * package json update --- package.json | 2 +- src/components/Header/index.jsx | 3 +-- .../transactions/offchainSigner/ethSigner.js | 23 ++++++++++++++++++- src/logic/wallets/getWeb3.js | 7 ------ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index bcefb6c3..efbbab53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "1.9.1", + "version": "1.9.2", "description": "Allowing crypto users manage funds in a safer way", "homepage": "https://github.com/gnosis/safe-react#readme", "bugs": { diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index 8cdfc8e2..c3c66feb 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -13,7 +13,6 @@ import selector, { type SelectorProps } from './selector' import { onboard } from '~/components/ConnectButton' import { NOTIFICATIONS, showSnackbar } from '~/logic/notifications' -import { INJECTED_PROVIDERS } from '~/logic/wallets/getWeb3' import { loadLastUsedProvider } from '~/logic/wallets/store/middlewares/providerWatcher' import { type Info, logComponentStack } from '~/utils/logBoundaries' @@ -38,7 +37,7 @@ class HeaderComponent extends React.PureComponent { async componentDidMount() { const lastUsedProvider = await loadLastUsedProvider() - if (INJECTED_PROVIDERS.includes(lastUsedProvider.toUpperCase()) || process.env.NODE_ENV === 'test') { + if (lastUsedProvider) { const hasSelectedWallet = await onboard.walletSelect(lastUsedProvider) if (hasSelectedWallet) { await onboard.walletCheck() diff --git a/src/logic/safe/transactions/offchainSigner/ethSigner.js b/src/logic/safe/transactions/offchainSigner/ethSigner.js index 42a772cb..2a2d1133 100644 --- a/src/logic/safe/transactions/offchainSigner/ethSigner.js +++ b/src/logic/safe/transactions/offchainSigner/ethSigner.js @@ -53,7 +53,28 @@ export const getEthSigner = async ({ return } - resolve(signature.result.replace(EMPTY_DATA, '')) + const sig = signature.result.replace(EMPTY_DATA, '') + let sigV = parseInt(sig.slice(-2), 16) + + // Metamask with ledger returns v = 01, this is not valid for ethereum + // For ethereum valid V is 27 or 28 + // In case V = 0 or 01 we add it to 27 and then add 4 + // Adding 4 is required to make signature valid for safe contracts: + // https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#eth-sign-signature + switch (sigV) { + case 0: + case 1: + sigV += 31 + break + case 27: + case 28: + sigV += 4 + break + default: + throw new Error('Invalid signature') + } + + resolve(sig.slice(0, -2) + sigV.toString(16)) }, ) }) diff --git a/src/logic/wallets/getWeb3.js b/src/logic/wallets/getWeb3.js index a33ddc03..bc7faad9 100644 --- a/src/logic/wallets/getWeb3.js +++ b/src/logic/wallets/getWeb3.js @@ -34,13 +34,6 @@ export const WALLET_PROVIDER = { TREZOR: 'TREZOR', } -export const INJECTED_PROVIDERS = [ - WALLET_PROVIDER.SAFE, - WALLET_PROVIDER.METAMASK, - WALLET_PROVIDER.OPERA, - WALLET_PROVIDER.DAPPER, -] - export const ETHEREUM_NETWORK_IDS = { // $FlowFixMe 1: ETHEREUM_NETWORK.MAINNET,