From f8ccbca6cce19dd2e8c81abb1b6e0b4cab9ce7b2 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sat, 9 Nov 2019 11:53:31 +0100 Subject: [PATCH] [Wallet] Fix notifications (#1637) * Lowercase account address in redux state and getter * Fix `this` issue at update payment request See here why: https://github.com/invertase/react-native-firebase/blob/ea901386db3d2414c124b208b5f8538175528c9d/src/modules/database/Reference.js#L193 * Fix tests --- packages/mobile/src/app/__snapshots__/Debug.test.tsx.snap | 2 +- packages/mobile/src/firebase/saga.ts | 7 ++++++- .../mobile/src/qrcode/__snapshots__/QRCode.test.tsx.snap | 2 +- packages/mobile/src/web3/reducer.ts | 2 +- packages/mobile/src/web3/saga.test.ts | 2 +- packages/mobile/src/web3/selectors.ts | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/mobile/src/app/__snapshots__/Debug.test.tsx.snap b/packages/mobile/src/app/__snapshots__/Debug.test.tsx.snap index ea5bfbfaef2..9192020d510 100644 --- a/packages/mobile/src/app/__snapshots__/Debug.test.tsx.snap +++ b/packages/mobile/src/app/__snapshots__/Debug.test.tsx.snap @@ -53,7 +53,7 @@ exports[`Debug renders correctly 1`] = ` } } > - Address: 0x0000000000000000000000000000000000007E57 + Address: 0x0000000000000000000000000000000000007e57 + firebase + .database() + .ref(`${REQUEST_DB}/${id}`) + .update({ status }) + ) Logger.debug(TAG, 'Payment request status updated', id) } catch (error) { Logger.error(TAG, `Error while updating payment request ${id} status`, error) diff --git a/packages/mobile/src/qrcode/__snapshots__/QRCode.test.tsx.snap b/packages/mobile/src/qrcode/__snapshots__/QRCode.test.tsx.snap index c0bedbb255b..d805c7c0965 100644 --- a/packages/mobile/src/qrcode/__snapshots__/QRCode.test.tsx.snap +++ b/packages/mobile/src/qrcode/__snapshots__/QRCode.test.tsx.snap @@ -113,7 +113,7 @@ exports[`QRCode renders correctly 1`] = ` width={375} /> diff --git a/packages/mobile/src/web3/reducer.ts b/packages/mobile/src/web3/reducer.ts index 1ec445cfbfe..a8339d651be 100644 --- a/packages/mobile/src/web3/reducer.ts +++ b/packages/mobile/src/web3/reducer.ts @@ -49,7 +49,7 @@ export const reducer = ( case Actions.SET_ACCOUNT: return { ...state, - account: action.address, + account: action.address.toLowerCase(), } case Actions.SET_ACCOUNT_IN_WEB3_KEYSTORE: return { diff --git a/packages/mobile/src/web3/saga.test.ts b/packages/mobile/src/web3/saga.test.ts index 0d1e240e959..bee6ac8009f 100644 --- a/packages/mobile/src/web3/saga.test.ts +++ b/packages/mobile/src/web3/saga.test.ts @@ -59,7 +59,7 @@ describe(getOrCreateAccount, () => { .withState(state) .provide([[select(currentAccountSelector), null]]) .provide([[select(pincodeTypeSelector), '123']]) - .returns('0x0000000000000000000000000000000000007E57') + .returns('0x0000000000000000000000000000000000007e57') .run() }) }) diff --git a/packages/mobile/src/web3/selectors.ts b/packages/mobile/src/web3/selectors.ts index 4e2b7b4524d..9312f303862 100644 --- a/packages/mobile/src/web3/selectors.ts +++ b/packages/mobile/src/web3/selectors.ts @@ -1,6 +1,7 @@ import { RootState } from 'src/redux/reducers' -export const currentAccountSelector = (state: RootState) => state.web3.account +export const currentAccountSelector = (state: RootState) => + (state.web3.account && state.web3.account.toLowerCase()) || null export const currentAccountInWeb3KeystoreSelector = (state: RootState) => state.web3.accountInWeb3Keystore export const zeroSyncSelector = (state: RootState) => state.web3.zeroSyncMode