Skip to content

Commit

Permalink
[chore] Fix empty checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed May 12, 2022
1 parent 1b83346 commit 3c6864e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 47 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ android {
applicationId "com.emurgo"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 342
versionName "4.7.13"
versionCode 344
versionName "4.7.14"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
Expand Down
48 changes: 24 additions & 24 deletions ios/emurgo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@
BUNDLE_ID_SUFFIX = "";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -1369,7 +1369,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1395,7 +1395,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1418,7 +1418,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1441,7 +1441,7 @@
BUNDLE_DISPLAY_NAME = Yoroi;
BUNDLE_ID_SUFFIX = "";
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1469,7 +1469,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1492,7 +1492,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1520,7 +1520,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1545,7 +1545,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1572,7 +1572,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -1595,7 +1595,7 @@
BUNDLE_DISPLAY_NAME = "Yoroi Staging";
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -1622,7 +1622,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1831,7 +1831,7 @@
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -1855,7 +1855,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1979,7 +1979,7 @@
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -2002,7 +2002,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -2064,7 +2064,7 @@
BUNDLE_ID_SUFFIX = "";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -2088,7 +2088,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -2113,7 +2113,7 @@
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
Expand All @@ -2137,7 +2137,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -2163,7 +2163,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -2186,7 +2186,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand All @@ -2210,7 +2210,7 @@
BUNDLE_ID_SUFFIX = .staging;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 394;
DEVELOPMENT_TEAM = F8NVT2G2L4;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
Expand All @@ -2233,7 +2233,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 4.7.13;
MARKETING_VERSION = 4.7.14;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
2 changes: 1 addition & 1 deletion legacy/components/Common/WalletAccountIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Props = {|
|}

const WalletAccountIcon = ({iconSeed, scalePx = 5, saturationFactor = 0, style}: Props) => {
const colorIdx = Buffer.from(iconSeed, 'hex')[0] % COLORS.length
const colorIdx = !iconSeed || iconSeed.length < 2 ? 0 : Buffer.from(iconSeed, 'hex')[0] % COLORS.length
const color = COLORS[colorIdx]
return (
<View style={[styles.defaultStyle, style]}>
Expand Down
10 changes: 8 additions & 2 deletions src/appStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const mockedWalletData = Object.freeze({
id: 'wallet-id',
externalChain: {
addressGenerator: {
account: {
derivation_scheme: 'V2',
root_cached_key:
'7f53efa3c08093db3824235769079e96ef96b6680fc254f6c021ec420e4d1555' +
'b5bafb0b1fc6c8040cc8f69f7c1948dfb4dcadec4acd09730c0efb39c6159362',
},
accountPubKeyHex:
'8e4e2f11b6ac2a269913286e26339779ab8767579d18d173cdd324929d94e2c43e3ec212cc8a36ed9860579dfe1e3ef4d6de778c5dbdd981623b48727cd96247',
},
Expand Down Expand Up @@ -197,9 +203,9 @@ describe('migrateWalletMetas()', () => {
...mockedWalletMeta,
walletImplementationId: WALLETS.JORMUNGANDR_ITN.WALLET_IMPLEMENTATION_ID,
checksum: {
TextPart: 'ATPE-6458',
TextPart: 'SKBE-5478',
ImagePart:
'1dda96f3e8a39341da9549bef4be416c173eeb940f092cfc98d5c63a06c6007d326c77a599b1fd36ddf57507b8ea52537f129dac7bceb18c674bc3baab90411f',
'61942e0a01bd7eccff636a468e4d04bd05fe2169c2d26f83236ade661860d93e22c07ff007117555c6a15a92ac43f88e453d31c3b7a240dcd11ca3a7eba29321',
},
}

Expand Down
37 changes: 21 additions & 16 deletions src/appStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {Logger} from '../legacy/utils/logging'
import storage from '../legacy/utils/storage'

async function toShelleyWalletMeta(currentWalletMeta: Partial<WalletMeta>): Promise<WalletMeta> {
if (!currentWalletMeta?.id) throw new Error(`Wallet meta stored is corrupted. ${JSON.stringify(currentWalletMeta)}`)

if (!currentWalletMeta.id) throw new Error(`Wallet meta stored is corrupted. ${JSON.stringify(currentWalletMeta)}`)
const walletData = await storage.read(`/wallet/${currentWalletMeta.id}/data`)
const walletMetaUpdate: Partial<WalletMeta> = {...currentWalletMeta}

Expand Down Expand Up @@ -40,16 +39,22 @@ async function toShelleyWalletMeta(currentWalletMeta: Partial<WalletMeta>): Prom
}

// migrate checksum
if (!currentWalletMeta?.checksum) {
if (!currentWalletMeta.checksum || !currentWalletMeta.checksum?.ImagePart) {
if (walletData != null && walletData?.externalChain?.addressGenerator != null) {
const {accountPubKeyHex} = walletData.externalChain.addressGenerator
const {accountPubKeyHex, account} = walletData.externalChain.addressGenerator
switch (walletImplementationId) {
case WALLETS.HASKELL_BYRON.WALLET_IMPLEMENTATION_ID:
checksum = legacyWalletChecksum(accountPubKeyHex || account.root_cached_key)
break
case WALLETS.HASKELL_SHELLEY_24.WALLET_IMPLEMENTATION_ID:
case WALLETS.HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID:
checksum = walletChecksum(accountPubKeyHex)
break
case WALLETS.JORMUNGANDR_ITN.WALLET_IMPLEMENTATION_ID:
checksum = legacyWalletChecksum(accountPubKeyHex)
checksum = legacyWalletChecksum(account?.root_cached_key || '')
break
default:
checksum = walletChecksum(accountPubKeyHex)
checksum = {ImagePart: '', TextPart: ''}
}
} else {
checksum = {ImagePart: '', TextPart: ''}
Expand Down Expand Up @@ -104,25 +109,25 @@ function isWalletMeta(walletMeta: WalletMeta | object | undefined): walletMeta i
return (
// prettier-ignore
!!walletMeta &&
'id' in walletMeta
'id' in walletMeta
&& typeof walletMeta.id === 'string' &&
'name' in walletMeta
'name' in walletMeta
&& typeof walletMeta.name === 'string' &&
'networkId' in walletMeta
'networkId' in walletMeta
&& typeof walletMeta.networkId === 'number' &&
'isHW' in walletMeta
'isHW' in walletMeta
&& typeof walletMeta.isHW === 'boolean' &&
'isEasyConfirmationEnabled' in walletMeta
'isEasyConfirmationEnabled' in walletMeta
&& typeof walletMeta.isEasyConfirmationEnabled === 'boolean' &&
'checksum' in walletMeta
'checksum' in walletMeta
&& typeof walletMeta.checksum === 'object' &&
('provider' in walletMeta
('provider' in walletMeta
&& typeof walletMeta.provider === 'string'
|| !('provider' in walletMeta)) &&
'walletImplementationId' in walletMeta
&& typeof walletMeta.walletImplementationId === 'string'
'walletImplementationId' in walletMeta
&& typeof walletMeta.walletImplementationId === 'string'
&& Object.values(WALLET_IMPLEMENTATION_REGISTRY).includes(walletMeta?.walletImplementationId) &&
('isShelley' in walletMeta
('isShelley' in walletMeta
&& typeof walletMeta.isShelley === 'boolean'
|| !('isShelley' in walletMeta))
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ storiesOf('Icon', module).add('Gallery', () => {
<Item icon={<Icon.Magnify size={40} />} title="Magnify" />
<Item icon={<Icon.Received />} title="Received" />
<Item icon={<Icon.Sent />} title="Sent" />
<Item icon={<Icon.WalletAccount iconSeed="asdasd" />} title="WalletAccount" />
<Item icon={<Icon.WalletAccount iconSeed="" />} title="WalletAccount" />
<Item icon={<Icon.Emurgo width={40} height={40} />} title="Emurgo" />
<Item icon={<Icon.Check height={40} width={40} />} title="Check" />
<Item mode="dark" icon={<Icon.YoroiWallet height={40} width={40} />} title="YoroiWallet" />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Icon/WalletAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Props = {
}

export const WalletAccount = ({iconSeed, scalePx = 5, saturationFactor = 0, style}: Props) => {
const colorIdx = Buffer.from(iconSeed, 'hex')[0] % COLORS.length
const colorIdx = !iconSeed || iconSeed.length < 2 ? 0 : Buffer.from(iconSeed, 'hex')[0] % COLORS.length
const color = COLORS[colorIdx]
return (
<View style={[styles.defaultStyle, style]}>
Expand Down

0 comments on commit 3c6864e

Please sign in to comment.