Skip to content

Commit

Permalink
fix: unknown network accounts do not listed (#646)
Browse files Browse the repository at this point in the history
* fix showing account with unknown network path id

* rephrase errors

* bump version to 4.4.0

* update ios bundle

* fix unit test
  • Loading branch information
hanwencheng authored Jun 24, 2020
1 parent 5f65055 commit 7284d15
Show file tree
Hide file tree
Showing 12 changed files with 2,259 additions and 1,765 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ android {
minSdkVersion 18
missingDimensionStrategy 'react-native-camera', 'general'
targetSdkVersion 28
versionCode 4302
versionName "4.3.2"
versionCode 4400
versionName "4.4.0"
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
Expand Down
4 changes: 2 additions & 2 deletions ios/NativeSigner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.3.2</string>
<string>4.4.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>4302</string>
<string>4400</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
Binary file modified ios/assets/res/img/card_shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/assets/res/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/assets/res/img/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,994 changes: 2,241 additions & 1,753 deletions ios/main.jsbundle

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NativeSigner",
"version": "4.3.2-beta",
"version": "4.4.0-beta",
"private": true,
"license": "GPL-3.0",
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions src/components/AccountIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export default function AccountIcon(props: {

const styles = StyleSheet.create({
logo: {
alignItems: 'center',
height: 36,
justifyContent: 'center',
marginHorizontal: 2,
opacity: 0.7,
width: 36
Expand Down
7 changes: 5 additions & 2 deletions src/modules/main/components/NetworkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import React, { ReactElement, useState } from 'react';
import React, { ReactElement, useMemo, useState } from 'react';
import { BackHandler, FlatList, FlatListProps } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';

Expand Down Expand Up @@ -231,7 +231,10 @@ export default function NetworkSelector({
}
};

const availableNetworks = getExistedNetworkKeys(currentIdentity);
const availableNetworks = useMemo(
() => getExistedNetworkKeys(currentIdentity),
[currentIdentity]
);
const networkList = Object.entries(NETWORK_LIST).filter(filterNetworkKeys);
networkList.sort(sortNetworkKeys);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const accountExistedError = 'account already existed';
export const accountExistedError = 'the path of the account already existed';
export const addressGenerateError =
'substrate address cannot be generated, please check suri and prefix';
export const identityUpdateError = 'current identity cannot be updated';
Expand Down
5 changes: 3 additions & 2 deletions src/utils/identitiesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ export const getPathsWithSubstrateNetworkKey = (
networkKey: string
): string[] => {
const pathEntries = Array.from(identity.meta.entries());
const targetPathId = SUBSTRATE_NETWORK_LIST[networkKey]?.pathId;
const targetPathId =
SUBSTRATE_NETWORK_LIST[networkKey]?.pathId || unknownNetworkPathId;
const pathReducer = (
groupedPaths: string[],
[path, pathMeta]: [string, AccountMeta]
): string[] => {
let pathId;
if (!isSubstratePath(path)) return groupedPaths;
if (pathMeta.hasOwnProperty('networkPathId')) {
if (pathMeta.networkPathId !== undefined) {
pathId = pathMeta.networkPathId;
} else {
pathId = extractPathId(path);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/util/identitiesUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe('IdentitiesUtils', () => {
it('group path under their network correctly, has no missing accounts', () => {
const mockIdentity = testIdentities[0];
const existedNetworks = getExistedNetworkKeys(mockIdentity);
const existedAccounts = mockIdentity.meta.size;
const existedAccountsSize = mockIdentity.meta.size;

const allListedAccounts = existedNetworks.reduce(
(acc: string[], networkKey: string) => {
Expand All @@ -284,7 +284,7 @@ describe('IdentitiesUtils', () => {
},
[]
);
expect(existedAccounts).toEqual(allListedAccounts.length);
expect(existedAccountsSize).toEqual(allListedAccounts.length);
});

it('decides account is only with hard derivation', () => {
Expand Down

0 comments on commit 7284d15

Please sign in to comment.