Skip to content

Commit

Permalink
Merge branch 'dev' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidHaji-zada committed Nov 3, 2023
2 parents f29fbab + 7f8b1aa commit 86ac997
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/components/modular/Passcode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { View, TextInput } from 'react-native';
import { styles } from '@components/modular/Passcode/styles';
import { Button } from '@components/base';
import { useForwardedRef } from '@hooks';
import { StringUtils } from '@utils/string';

interface PasscodeProps {
onPasscodeChange: (passcode: string[]) => void;
Expand All @@ -15,11 +16,12 @@ export const Passcode = forwardRef<TextInput, PasscodeProps>(
const localRef = useForwardedRef<TextInput>(ref);

const handleCodeChange = (text: string) => {
setCode(text);
const passcodeArray = text.split('');
const numericText = StringUtils.removeNonNumericCharacters(text, false);
setCode(numericText);
const passcodeArray = numericText.split('');
onPasscodeChange(passcodeArray);
if (type === 'change') {
if (text.length === 4) {
if (numericText.length === 4) {
setTimeout(() => setCode(''), 50);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ const pluralize = (count: number, str: string, pluralForm?: string): string => {
return count + ' ' + finalForm;
};

const removeNonNumericCharacters = (str: string): string => {
const removeNonNumericCharacters = (str: string, allowDot = true): string => {
if (!str) return '';
return str.replace(/[^.\d]+/g, '');
if (allowDot) return str.replace(/[^.\d]+/g, '');
return str.replace(/[^\d]+/g, '');
};

const removeNonAlphabeticCharacters = (str: string): string => {
Expand Down
7 changes: 3 additions & 4 deletions src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ const processWallet = async (mnemonic: string) => {
mnemonic: mnemonic
});
const currencyCode = AirDAODictTypes.Code.AMB; // TODO this needs to be changed if we support multiple currencies
// create wallet in db
walletInDb = await WalletDB.createWallet(fullWallet);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [walletInDbResult, _, accountInDbResult] = await Promise.all([
// create wallet in db
WalletDB.createWallet(fullWallet),
const [_, accountInDbResult] = await Promise.all([
// securely store private key
Cache.setItem(
`${CacheKey.WalletPrivateKey}-${fullWallet.hash}`,
Expand All @@ -90,7 +90,6 @@ const processWallet = async (mnemonic: string) => {
currencyCode
)
]);
walletInDb = walletInDbResult;
accountInDb = accountInDbResult;
// subscribe to notifications
API.watcherService.watchAddresses([_account.address]);
Expand Down

0 comments on commit 86ac997

Please sign in to comment.