diff --git a/package-lock.json b/package-lock.json
index 0ca46471..55a8d87c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "neon3",
- "version": "3.2.1",
+ "version": "3.2.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "neon3",
- "version": "3.2.1",
+ "version": "3.2.2",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -17,8 +17,8 @@
"@cityofzion/bs-neo-legacy": "1.6.7",
"@cityofzion/bs-neo3": "1.8.9",
"@cityofzion/bs-swap": "0.3.2",
- "@cityofzion/neon-core": "5.5.1",
- "@cityofzion/neon-js": "5.5.1",
+ "@cityofzion/neon-core": "5.6.0",
+ "@cityofzion/neon-js": "5.6.0",
"@cityofzion/wallet-connect-sdk-wallet-core": "4.4.0",
"@cityofzion/wallet-connect-sdk-wallet-react": "4.0.18",
"@electron-toolkit/preload": "^2.0.0",
@@ -812,6 +812,35 @@
"query-string": "7.1.3"
}
},
+ "node_modules/@cityofzion/bs-neo3/node_modules/@cityofzion/neon-core": {
+ "version": "5.5.1",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-core/-/neon-core-5.5.1.tgz",
+ "integrity": "sha512-cqJ+RYTdUVoUl2e3I5bqgAvYFuqGd2M8lmgUgH/+kf0zS0b8EuKwliauJ2EA56fudwaXtCmmHZTfRBFs+RJ2vw==",
+ "dependencies": {
+ "bn.js": "5.2.1",
+ "bs58": "5.0.0",
+ "buffer": "6.0.3",
+ "cross-fetch": "^3.1.5",
+ "crypto-js": "4.1.1",
+ "elliptic": "6.5.4",
+ "ethereum-cryptography": "2.0.0",
+ "lodash": "4.17.21",
+ "loglevel": "1.8.1",
+ "loglevel-plugin-prefix": "0.8.4"
+ },
+ "engines": {
+ "node": ">=16.19.0"
+ }
+ },
+ "node_modules/@cityofzion/bs-neo3/node_modules/@cityofzion/neon-js": {
+ "version": "5.5.1",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-js/-/neon-js-5.5.1.tgz",
+ "integrity": "sha512-iCoE5PGKy3Kj36dR3aevkVOKK4yB1Mq/0WEUQzrzMkGOGBNJXa2+cTtmSi39tDkgxSHibvS77S5oZ6QGIXMCdg==",
+ "dependencies": {
+ "@cityofzion/neon-api": "^5.4.0",
+ "@cityofzion/neon-core": "^5.5.1"
+ }
+ },
"node_modules/@cityofzion/bs-neo3/node_modules/@ledgerhq/hw-transport": {
"version": "6.30.6",
"resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.30.6.tgz",
@@ -863,16 +892,15 @@
}
},
"node_modules/@cityofzion/neon-core": {
- "version": "5.5.1",
- "resolved": "https://registry.npmjs.org/@cityofzion/neon-core/-/neon-core-5.5.1.tgz",
- "integrity": "sha512-cqJ+RYTdUVoUl2e3I5bqgAvYFuqGd2M8lmgUgH/+kf0zS0b8EuKwliauJ2EA56fudwaXtCmmHZTfRBFs+RJ2vw==",
- "license": "MIT",
+ "version": "5.6.0",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-core/-/neon-core-5.6.0.tgz",
+ "integrity": "sha512-46Y8A/SgKNXIMFbyNUSX63aUA9tWfe3eKmXaX97AGNNR62tPw45yBVxkfAGLECS9MVy/Y4jgi9/TacGQMEaNsQ==",
"dependencies": {
"bn.js": "5.2.1",
"bs58": "5.0.0",
"buffer": "6.0.3",
"cross-fetch": "^3.1.5",
- "crypto-js": "4.1.1",
+ "crypto-js": "4.2.0",
"elliptic": "6.5.4",
"ethereum-cryptography": "2.0.0",
"lodash": "4.17.21",
@@ -883,6 +911,11 @@
"node": ">=16.19.0"
}
},
+ "node_modules/@cityofzion/neon-core/node_modules/crypto-js": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+ },
"node_modules/@cityofzion/neon-dappkit": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/@cityofzion/neon-dappkit/-/neon-dappkit-0.4.1.tgz",
@@ -906,16 +939,24 @@
"integrity": "sha512-bQA/EBQUU6ZPmDARXB0w6I2iJqdo4S2s3xERPN91wCHd9WMkCIrtec269X1Yjd9qGoVibLMyA3xjqrOTyUBpxw==",
"license": "MIT"
},
- "node_modules/@cityofzion/neon-js": {
+ "node_modules/@cityofzion/neon-dappkit/node_modules/@cityofzion/neon-js": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/@cityofzion/neon-js/-/neon-js-5.5.1.tgz",
"integrity": "sha512-iCoE5PGKy3Kj36dR3aevkVOKK4yB1Mq/0WEUQzrzMkGOGBNJXa2+cTtmSi39tDkgxSHibvS77S5oZ6QGIXMCdg==",
- "license": "MIT",
"dependencies": {
"@cityofzion/neon-api": "^5.4.0",
"@cityofzion/neon-core": "^5.5.1"
}
},
+ "node_modules/@cityofzion/neon-js": {
+ "version": "5.6.0",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-js/-/neon-js-5.6.0.tgz",
+ "integrity": "sha512-0QDgGtDjqu5JlshCJdlFSkFVygHHE8Tfdj/gmdqlFcXf37Naqg7QHQ/JjTf74AGqPVykejRP6c4qr35jRgM0/w==",
+ "dependencies": {
+ "@cityofzion/neon-api": "^5.4.0",
+ "@cityofzion/neon-core": "^5.6.0"
+ }
+ },
"node_modules/@cityofzion/neon-nep5": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/@cityofzion/neon-nep5/-/neon-nep5-4.9.0.tgz",
@@ -1026,6 +1067,26 @@
"typed-emitter": "^2.1.0"
}
},
+ "node_modules/@cityofzion/wallet-connect-sdk-core/node_modules/@cityofzion/neon-core": {
+ "version": "5.5.1",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-core/-/neon-core-5.5.1.tgz",
+ "integrity": "sha512-cqJ+RYTdUVoUl2e3I5bqgAvYFuqGd2M8lmgUgH/+kf0zS0b8EuKwliauJ2EA56fudwaXtCmmHZTfRBFs+RJ2vw==",
+ "dependencies": {
+ "bn.js": "5.2.1",
+ "bs58": "5.0.0",
+ "buffer": "6.0.3",
+ "cross-fetch": "^3.1.5",
+ "crypto-js": "4.1.1",
+ "elliptic": "6.5.4",
+ "ethereum-cryptography": "2.0.0",
+ "lodash": "4.17.21",
+ "loglevel": "1.8.1",
+ "loglevel-plugin-prefix": "0.8.4"
+ },
+ "engines": {
+ "node": ">=16.19.0"
+ }
+ },
"node_modules/@cityofzion/wallet-connect-sdk-core/node_modules/@cityofzion/neon-dappkit-types": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/@cityofzion/neon-dappkit-types/-/neon-dappkit-types-0.4.0.tgz",
@@ -1051,6 +1112,26 @@
"moment": "^2.29.4"
}
},
+ "node_modules/@cityofzion/wallet-connect-sdk-wallet-core/node_modules/@cityofzion/neon-core": {
+ "version": "5.5.1",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-core/-/neon-core-5.5.1.tgz",
+ "integrity": "sha512-cqJ+RYTdUVoUl2e3I5bqgAvYFuqGd2M8lmgUgH/+kf0zS0b8EuKwliauJ2EA56fudwaXtCmmHZTfRBFs+RJ2vw==",
+ "dependencies": {
+ "bn.js": "5.2.1",
+ "bs58": "5.0.0",
+ "buffer": "6.0.3",
+ "cross-fetch": "^3.1.5",
+ "crypto-js": "4.1.1",
+ "elliptic": "6.5.4",
+ "ethereum-cryptography": "2.0.0",
+ "lodash": "4.17.21",
+ "loglevel": "1.8.1",
+ "loglevel-plugin-prefix": "0.8.4"
+ },
+ "engines": {
+ "node": ">=16.19.0"
+ }
+ },
"node_modules/@cityofzion/wallet-connect-sdk-wallet-core/node_modules/@cityofzion/neon-dappkit": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/@cityofzion/neon-dappkit/-/neon-dappkit-0.5.1.tgz",
@@ -1074,6 +1155,15 @@
"integrity": "sha512-UjveRGBuj/OlwlX39IutXFPBalosc+dZClC32+wm5JLOsAy12vFeI+dNFe6nnV8HIrFRZSLcHyfq08ILA68LVQ==",
"license": "MIT"
},
+ "node_modules/@cityofzion/wallet-connect-sdk-wallet-core/node_modules/@cityofzion/neon-js": {
+ "version": "5.5.1",
+ "resolved": "https://registry.npmjs.org/@cityofzion/neon-js/-/neon-js-5.5.1.tgz",
+ "integrity": "sha512-iCoE5PGKy3Kj36dR3aevkVOKK4yB1Mq/0WEUQzrzMkGOGBNJXa2+cTtmSi39tDkgxSHibvS77S5oZ6QGIXMCdg==",
+ "dependencies": {
+ "@cityofzion/neon-api": "^5.4.0",
+ "@cityofzion/neon-core": "^5.5.1"
+ }
+ },
"node_modules/@cityofzion/wallet-connect-sdk-wallet-core/node_modules/@ethersproject/providers": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz",
diff --git a/package.json b/package.json
index 92181f99..be64f8e8 100644
--- a/package.json
+++ b/package.json
@@ -36,8 +36,8 @@
"@cityofzion/bs-neo-legacy": "1.6.7",
"@cityofzion/bs-neo3": "1.8.9",
"@cityofzion/bs-swap": "0.3.2",
- "@cityofzion/neon-core": "5.5.1",
- "@cityofzion/neon-js": "5.5.1",
+ "@cityofzion/neon-core": "5.6.0",
+ "@cityofzion/neon-js": "5.6.0",
"@cityofzion/wallet-connect-sdk-wallet-core": "4.4.0",
"@cityofzion/wallet-connect-sdk-wallet-react": "4.0.18",
"@electron-toolkit/preload": "^2.0.0",
@@ -125,4 +125,4 @@
"vite-plugin-node-polyfills": "^0.17.0",
"vite-plugin-svgr": "^3.2.0"
}
-}
\ No newline at end of file
+}
diff --git a/src/renderer/src/assets/skins/coz-face-december-2024.png b/src/renderer/src/assets/skins/coz-face-december-2024.png
new file mode 100644
index 00000000..84074510
Binary files /dev/null and b/src/renderer/src/assets/skins/coz-face-december-2024.png differ
diff --git a/src/renderer/src/components/AccountIcon.tsx b/src/renderer/src/components/AccountIcon.tsx
index 62e40e78..1685aa82 100644
--- a/src/renderer/src/components/AccountIcon.tsx
+++ b/src/renderer/src/components/AccountIcon.tsx
@@ -1,5 +1,6 @@
import { cloneElement } from 'react'
import { ACCOUNT_COLOR_SKINS, ACCOUNT_LOCAL_SKINS } from '@renderer/constants/skins'
+import { TBlockchainServiceKey } from '@shared/@types/blockchain'
import { IAccountState, TNftSkin } from '@shared/@types/store'
import { BlockchainIcon } from './BlockchainIcon'
@@ -7,43 +8,70 @@ type TProps = {
account: IAccountState
}
+type TAccountBlockchainCircleProps = {
+ blockchain: TBlockchainServiceKey
+}
+
+const AccountBlockchainCircle = ({ blockchain }: TAccountBlockchainCircleProps) => (
+
+)
+
const AccountIconColor = ({ account }: TProps) => {
- const bgColor = ACCOUNT_COLOR_SKINS.find(({ id }) => id === account.skin.id)?.color ?? ACCOUNT_COLOR_SKINS[0].color
+ const color = ACCOUNT_COLOR_SKINS.find(({ id }) => id === account.skin.id)?.color
+
+ if (!color) return null
return (
-
-
+
)
}
const AccountIconNFT = ({ account }: TProps) => {
- const skin = account.skin as TNftSkin
+ const imgUrl = (account.skin as TNftSkin)?.imgUrl
+
+ if (!imgUrl) return null
+
return (
-
-
+
+
+
+
)
}
const AccountIconLocal = ({ account }: TProps) => {
- const component = ACCOUNT_LOCAL_SKINS.find(it => it.id === account.skin.id)!.component
+ const component = ACCOUNT_LOCAL_SKINS.find(({ id }) => id === account.skin.id)?.component
+
+ if (!component) return null
- return
{cloneElement(component, { className: 'w-full h-full' })}
+ return (
+
+ {cloneElement(component, {
+ 'aria-hidden': true,
+ className: 'w-full h-full object-cover absolute inset-0 m-auto',
+ })}
+
+
+
+ )
}
export const AccountIcon = ({ account }: TProps) => {
return (
-
- {account.skin.type === 'color' ? (
-
- ) : account.skin.type === 'nft' ? (
+
+ {account.skin.type === 'nft' ? (
- ) : (
+ ) : account.skin.type === 'local' ? (
+ ) : (
+
)}
)
diff --git a/src/renderer/src/components/SkinCard.tsx b/src/renderer/src/components/SkinCard.tsx
index e671c9a0..0c06e3d1 100644
--- a/src/renderer/src/components/SkinCard.tsx
+++ b/src/renderer/src/components/SkinCard.tsx
@@ -1,6 +1,7 @@
import { cloneElement } from 'react'
import { MdCheckCircle } from 'react-icons/md'
import { StyleHelper } from '@renderer/helpers/StyleHelper'
+import { match, P } from 'ts-pattern'
type TProps = {
showCheck: boolean
@@ -14,17 +15,24 @@ export const SkinCard = ({ showCheck, image, color, className, component }: TPro
return (
- {image ? (
-
- ) : color ? (
-
- ) : component ? (
- cloneElement(component, { className: 'w-full h-full' })
- ) : null}
+ {match({ image, component, color })
+ .with({ image: P.when(value => !!value) }, () => (
+
+ ))
+ .with({ component: P.when(value => !!value) }, () =>
+ cloneElement(component, {
+ 'aria-hidden': true,
+ className: 'w-full h-full object-cover absolute inset-0 m-auto',
+ })
+ )
+ .with({ color: P.when(value => !!value) }, () => (
+
+ ))
+ .otherwise(() => null)}
,
+ unlockedContractHash: '0x76a8f8a7a901b29a33013b469949f4b08db15756',
+ },
+]
export const LOCAL_SKINS: TLocalSkin[] = [...ACCOUNT_LOCAL_SKINS]
diff --git a/src/renderer/src/helpers/UtilsHelper.ts b/src/renderer/src/helpers/UtilsHelper.ts
index ca289907..9faa799e 100644
--- a/src/renderer/src/helpers/UtilsHelper.ts
+++ b/src/renderer/src/helpers/UtilsHelper.ts
@@ -1,5 +1,6 @@
import { getI18n } from 'react-i18next'
import { AVAILABLE_RANDOM_COLORS, MANDATORY_TOKEN_COLORS } from '@renderer/constants/colors'
+import { ACCOUNT_COLOR_SKINS } from '@renderer/constants/skins'
import _ from 'lodash'
import * as uuid from 'uuid'
@@ -222,4 +223,10 @@ export class UtilsHelper {
static isHexadecimal(hexadecimal: string) {
return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hexadecimal)
}
+
+ static getSkinColor(index?: number) {
+ const newIndex = index ?? UtilsHelper.getRandomNumber(7)
+
+ return ACCOUNT_COLOR_SKINS[newIndex]?.id ?? ACCOUNT_COLOR_SKINS[0].id
+ }
}
diff --git a/src/renderer/src/hooks/useAccountSelector.ts b/src/renderer/src/hooks/useAccountSelector.ts
index e63c5686..ed8d1bc8 100644
--- a/src/renderer/src/hooks/useAccountSelector.ts
+++ b/src/renderer/src/hooks/useAccountSelector.ts
@@ -14,6 +14,10 @@ const selectAccounts = createAppSelector(
}
)
+const selectOwnAccounts = createAppSelector(selectAccounts, accounts =>
+ accounts.filter(account => account.type !== 'watch')
+)
+
const selectHasHardwareAccount = createAppSelector(
[state => state.auth.data.applicationDataByLoginType, state => state.auth.currentLoginSession],
(applicationDataByLoginType, currentLoginSession) => {
@@ -53,6 +57,15 @@ export const useAccountsSelector = () => {
}
}
+export const useOwnAccountsSelector = () => {
+ const { value: ownAccounts, ref: ownAccountsRef } = useAppSelector(selectOwnAccounts)
+
+ return {
+ ownAccounts,
+ ownAccountsRef,
+ }
+}
+
export const useAccountsByWalletIdSelector = (walletId: string) => {
const { ref, value } = useAppSelector(selectAccountsByWalletId(walletId))
diff --git a/src/renderer/src/hooks/useAfterLogin.ts b/src/renderer/src/hooks/useAfterLogin.ts
index be663fda..7204dd36 100644
--- a/src/renderer/src/hooks/useAfterLogin.ts
+++ b/src/renderer/src/hooks/useAfterLogin.ts
@@ -5,15 +5,15 @@ import { hasNft } from '@cityofzion/blockchain-service'
import { useWalletConnectWallet } from '@cityofzion/wallet-connect-sdk-wallet-react'
import { LOCAL_SKINS } from '@renderer/constants/skins'
import { AccountHelper } from '@renderer/helpers/AccountHelper'
-import { NetworkHelper } from '@renderer/helpers/NetworkHelper'
import { ToastHelper } from '@renderer/helpers/ToastHelper'
import { UtilsHelper } from '@renderer/helpers/UtilsHelper'
import { WalletConnectHelper } from '@renderer/helpers/WalletConnectHelper'
import { bsAggregator } from '@renderer/libs/blockchainService'
+import { authReducerActions } from '@renderer/store/reducers/AuthReducer'
import { settingsReducerActions } from '@renderer/store/reducers/SettingsReducer'
import { IAccountState } from '@shared/@types/store'
-import { useAccountsSelector } from './useAccountSelector'
+import { useAccountsSelector, useOwnAccountsSelector } from './useAccountSelector'
import { useCurrentLoginSessionSelector } from './useAuthSelector'
import { useBlockchainActions } from './useBlockchainActions'
import { useLogin } from './useLogin'
@@ -193,50 +193,55 @@ const useRegisterDeeplinkListeners = () => {
}, [commonWc, modalNavigate, navigate])
}
-const useUnlockedSkins = () => {
- const { unlockedSkinIdsRef } = useUnlockedSkinIdsSelector()
- const { accounts } = useAccountsSelector()
- const { networkByBlockchainRef } = useSelectedNetworkByBlockchainSelector()
+const useUnlockSkins = () => {
const dispatch = useAppDispatch()
+ const { unlockedSkinIds } = useUnlockedSkinIdsSelector()
+ const { ownAccounts } = useOwnAccountsSelector()
+
+ const unlockSkins = async () => {
+ const skinIds = new Set
([])
- const unlockSkins = useCallback(async () => {
await Promise.allSettled(
LOCAL_SKINS.map(async skin => {
- if (
- unlockedSkinIdsRef.current.includes(skin.id) ||
- !NetworkHelper.isMainnet(skin.blockchain, networkByBlockchainRef.current[skin.blockchain])
- )
- return
-
- await Promise.allSettled(
- accounts.map(async account => {
- if (account.type === 'watch') return
-
+ for (const account of ownAccounts) {
+ try {
const service = bsAggregator.blockchainServicesByName[account.blockchain]
- if (!hasNft(service)) return
+
+ if (account.blockchain !== skin.blockchain || !hasNft(service)) continue
const hasToken = await service.nftDataService.hasToken({
- contractHash: skin.unlockedContractHash,
address: account.address,
+ contractHash: skin.unlockedContractHash,
})
- if (hasToken) {
- dispatch(settingsReducerActions.unlockSkin(skin.id))
- }
- })
- )
+ if (!hasToken) continue
+
+ skinIds.add(skin.id)
+
+ break
+ } catch {
+ /* empty */
+ }
+ }
})
)
- }, [accounts, dispatch, networkByBlockchainRef, unlockedSkinIdsRef])
+
+ const invalidSkinIds = unlockedSkinIds.filter(skinId => !skinIds.has(skinId))
+
+ dispatch(settingsReducerActions.setUnlockedSkinIds([...skinIds]))
+ dispatch(authReducerActions.removeAccountSkins(invalidSkinIds))
+ }
useEffect(() => {
unlockSkins()
- }, [unlockSkins])
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [])
}
export const useAfterLogin = () => {
useRegisterWalletConnectListeners()
useRegisterHardwareWalletListeners()
useRegisterDeeplinkListeners()
- useUnlockedSkins()
+ useUnlockSkins()
}
diff --git a/src/renderer/src/hooks/useBlockchainActions.ts b/src/renderer/src/hooks/useBlockchainActions.ts
index d04d1342..1a587431 100644
--- a/src/renderer/src/hooks/useBlockchainActions.ts
+++ b/src/renderer/src/hooks/useBlockchainActions.ts
@@ -1,7 +1,6 @@
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { useWalletConnectWallet } from '@cityofzion/wallet-connect-sdk-wallet-react'
-import { ACCOUNT_COLOR_SKINS } from '@renderer/constants/skins'
import { AccountHelper } from '@renderer/helpers/AccountHelper'
import { UtilsHelper } from '@renderer/helpers/UtilsHelper'
import { WalletConnectHelper } from '@renderer/helpers/WalletConnectHelper'
@@ -88,8 +87,7 @@ export function useBlockchainActions() {
idWallet: wallet.id,
name,
blockchain,
- skin: skin ?? { type: 'color', id: ACCOUNT_COLOR_SKINS[UtilsHelper.getRandomNumber(7)].id },
- lastNftSkin: skin?.type === 'nft' ? skin : undefined,
+ skin: skin ?? { type: 'color', id: UtilsHelper.getSkinColor() },
address: generatedAccount.address,
type: 'standard',
encryptedKey,
@@ -126,8 +124,7 @@ export function useBlockchainActions() {
idWallet: wallet.id,
name: name ?? t('defaultName', { accountNumber: accountOrder + 1 }),
blockchain,
- skin: skin ?? { type: 'color', id: ACCOUNT_COLOR_SKINS[UtilsHelper.getRandomNumber(7)].id },
- lastNftSkin: skin?.type === 'nft' ? skin : undefined,
+ skin: skin ?? { type: 'color', id: UtilsHelper.getSkinColor() },
address,
type,
encryptedKey,
diff --git a/src/renderer/src/hooks/useNeonBackup.ts b/src/renderer/src/hooks/useNeonBackup.ts
index 6e1d8886..36676a1b 100644
--- a/src/renderer/src/hooks/useNeonBackup.ts
+++ b/src/renderer/src/hooks/useNeonBackup.ts
@@ -1,6 +1,5 @@
import { useTranslation } from 'react-i18next'
import { BACKUP_FILE_EXTENSION, BACKUP_VERSION, DEPRECATED_BACKUP_FILE_EXTENSION } from '@renderer/constants/backup'
-import { ACCOUNT_COLOR_SKINS } from '@renderer/constants/skins'
import { DateHelper } from '@renderer/helpers/DateHelper'
import { UtilsHelper } from '@renderer/helpers/UtilsHelper'
import { doesBlockchainSupported } from '@renderer/libs/blockchainService'
@@ -13,7 +12,6 @@ import {
IWalletState,
TAccountType,
TContactAddress,
- TNftSkin,
TSkin,
TSwapRecord,
} from '@shared/@types/store'
@@ -55,7 +53,6 @@ export const backupAccountSchema = zod.object({
key: zod.string().optional(),
order: zod.number(),
skin: backupAccountSkinSchema,
- lastNftSkin: backupAccountSkinSchema.optional(),
})
export const backupWalletSchema = zod.object({
@@ -112,7 +109,7 @@ const fixAccountProperties = (
backupAccount.type === 'ledger' || backupAccount.type === 'hardware' ? 'watch' : backupAccount.type
if (!backupAccount.skin || UtilsHelper.isHexadecimal(backupAccount.skin.id))
- backupAccount.skin = { id: ACCOUNT_COLOR_SKINS[UtilsHelper.getRandomNumber(7)].id, type: 'color' }
+ backupAccount.skin = { id: UtilsHelper.getSkinColor(), type: 'color' }
return {
address: backupAccount.address,
@@ -122,7 +119,6 @@ const fixAccountProperties = (
name: backupAccount.name,
order: backupAccount.order,
skin: backupAccount.skin as TSkin,
- lastNftSkin: backupAccount.lastNftSkin as TNftSkin,
type,
}
}
diff --git a/src/renderer/src/hooks/useSettingsSelector.ts b/src/renderer/src/hooks/useSettingsSelector.ts
index 17290a14..b8b5bc34 100644
--- a/src/renderer/src/hooks/useSettingsSelector.ts
+++ b/src/renderer/src/hooks/useSettingsSelector.ts
@@ -61,6 +61,7 @@ export const useCurrencySelector = () => {
export const useUnlockedSkinIdsSelector = () => {
const { ref, value } = useAppSelector(state => state.settings.data.unlockedSkinIds)
+
return {
unlockedSkinIds: value,
unlockedSkinIdsRef: ref,
diff --git a/src/renderer/src/locales/en/modals.json b/src/renderer/src/locales/en/modals.json
index c6eb1358..f37d62b2 100644
--- a/src/renderer/src/locales/en/modals.json
+++ b/src/renderer/src/locales/en/modals.json
@@ -50,7 +50,7 @@
"inputPlaceholder": "Enter your account name...",
"inputSubtitle": "It could be helpful to name your account with a label related to what you want to use the account for (such as ‘Investments’ or ‘Trading’).",
"selectBlockchainDescription": "Please select which chain you would like to use for this account.",
- "colorSelectorLabel": "Select an account colour",
+ "skinSelectorLabel": "Select an account skin",
"saveButtonLabel": "Save",
"nextButtonLabel": "Next",
"cancelButtonLabel": "Cancel",
diff --git a/src/renderer/src/routes/modals/PersistAccount/SkinSelector.tsx b/src/renderer/src/routes/modals/PersistAccount/SkinSelector.tsx
index ca1f68c2..08bc302f 100644
--- a/src/renderer/src/routes/modals/PersistAccount/SkinSelector.tsx
+++ b/src/renderer/src/routes/modals/PersistAccount/SkinSelector.tsx
@@ -1,20 +1,19 @@
-import { MdAdd } from 'react-icons/md'
import { SkinCard } from '@renderer/components/SkinCard'
import { ACCOUNT_COLOR_SKINS, ACCOUNT_LOCAL_SKINS } from '@renderer/constants/skins'
import { useUnlockedSkinIdsSelector } from '@renderer/hooks/useSettingsSelector'
-import { TNftSkin, TSkin } from '@shared/@types/store'
+import { IAccountState, TSkin } from '@shared/@types/store'
type TProps = {
label: string
selectedSkin: TSkin
- lastNftSkin?: TNftSkin
onSelectSkin: (skin: TSkin) => void
+ account?: IAccountState
}
-export const SkinSelector = ({ label, selectedSkin, onSelectSkin, lastNftSkin }: TProps) => {
+export const SkinSelector = ({ label, selectedSkin, account, onSelectSkin }: TProps) => {
const { unlockedSkinIds } = useUnlockedSkinIdsSelector()
-
- const unlokedLocalSkins = ACCOUNT_LOCAL_SKINS.filter(skin => unlockedSkinIds.includes(skin.id))
+ const unlockedLocalSkins =
+ account?.type === 'watch' ? [] : ACCOUNT_LOCAL_SKINS.filter(skin => unlockedSkinIds.includes(skin.id))
return (
@@ -22,25 +21,16 @@ export const SkinSelector = ({ label, selectedSkin, onSelectSkin, lastNftSkin }:
{ACCOUNT_COLOR_SKINS.map(skin => (
))}
-
-
-
-
- {lastNftSkin && (
-
- )}
+ {/* TODO: create color picker here */}
+ {/*
*/}
+ {/* */}
+ {/*
*/}
- {unlokedLocalSkins.map(skin => (
+ {unlockedLocalSkins.map(skin => (
diff --git a/src/renderer/src/routes/modals/PersistAccount/index.tsx b/src/renderer/src/routes/modals/PersistAccount/index.tsx
index 3b001d10..ce85eeb6 100644
--- a/src/renderer/src/routes/modals/PersistAccount/index.tsx
+++ b/src/renderer/src/routes/modals/PersistAccount/index.tsx
@@ -4,7 +4,7 @@ import { TbPencil, TbPlus } from 'react-icons/tb'
import { Button } from '@renderer/components/Button'
import { Input } from '@renderer/components/Input'
import { Separator } from '@renderer/components/Separator'
-import { ACCOUNT_COLOR_SKINS } from '@renderer/constants/skins'
+import { UtilsHelper } from '@renderer/helpers/UtilsHelper'
import { useActions } from '@renderer/hooks/useActions'
import { useBlockchainActions } from '@renderer/hooks/useBlockchainActions'
import { useHardwareWalletActions } from '@renderer/hooks/useHardwareWallet'
@@ -13,14 +13,13 @@ import { useAppDispatch } from '@renderer/hooks/useRedux'
import { SideModalLayout } from '@renderer/layouts/SideModal'
import { authReducerActions } from '@renderer/store/reducers/AuthReducer'
import { TBlockchainServiceKey } from '@shared/@types/blockchain'
-import { IAccountState, IWalletState, TNftSkin, TSkin } from '@shared/@types/store'
+import { IAccountState, IWalletState, TSkin } from '@shared/@types/store'
import { SkinSelector } from './SkinSelector'
type TFormData = {
name: string
skin: TSkin
- lastNftSkin?: TNftSkin
}
type TLocationState = {
@@ -39,15 +38,14 @@ export const PersistAccountModal = () => {
const { actionData, actionState, handleAct, setDataFromEventWrapper, setData, setError } = useActions
({
name: account ? account.name : '',
- skin: account ? account.skin : { id: ACCOUNT_COLOR_SKINS[0].id, type: 'color' },
- lastNftSkin: account ? account.lastNftSkin : undefined,
+ skin: account ? account.skin : { id: UtilsHelper.getSkinColor(0), type: 'color' },
})
const handleSelectColorSkin = (skin: TSkin) => {
setData({ skin })
}
- const handleSubmit = async ({ name, skin, lastNftSkin }: TFormData) => {
+ const handleSubmit = async ({ name, skin }: TFormData) => {
const nameTrimmed = name.trim()
if (nameTrimmed.length === 0) {
setError('name', t('nameLengthError'))
@@ -55,7 +53,7 @@ export const PersistAccountModal = () => {
}
if (account) {
- dispatch(authReducerActions.saveAccount({ ...account, name: nameTrimmed, skin, lastNftSkin }))
+ dispatch(authReducerActions.saveAccount({ ...account, name: nameTrimmed, skin }))
modalNavigate(-1)
return
@@ -116,14 +114,15 @@ export const PersistAccountModal = () => {