Skip to content

Commit

Permalink
feat: new dropdown menu for multiple account
Browse files Browse the repository at this point in the history
  • Loading branch information
zzggo committed Dec 3, 2024
1 parent f3481f8 commit 183d0d1
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 195 deletions.
10 changes: 4 additions & 6 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,9 @@ export class WalletController extends BaseController {
const pubKey = await this.getPubKey();
const address = await findAddressWithNetwork(pubKey, network);
const emoji = await this.getEmoji();

if (!address) {
throw new Error("Can't find address in chain");
}
let transformedArray: any[];

// Check if the addresses array is empty
Expand Down Expand Up @@ -3351,11 +3353,7 @@ export class WalletController extends BaseController {

getEvmEnabled = async (): Promise<boolean> => {
const address = await this.getEvmAddress();
if (isValidEthereumAddress(address)) {
return true;
} else {
return false;
}
return !!address && isValidEthereumAddress(address);
};

refreshEvmWallets = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/utils/modules/findAddressWithPK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const findAddressWithNetwork = async (pubKTuple, network) => {
}

const account = accounts.find((account) => account.weight >= 1000);
return account ? [account] : null;
return account ? accounts : null;
};

export const findAddressWithPK = async (pk, address) => {
Expand Down
22 changes: 11 additions & 11 deletions src/ui/utils/modules/passkey.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck

import { initWasm } from '@trustwallet/wallet-core';

import { getStringFromHashAlgo, getStringFromSignAlgo } from '@/shared/utils/algo';
import { storage } from 'background/webapi';

import { decodeArray, encodeArray } from './base64';
import { FLOW_BIP44_PATH, HASH_ALGO, KEY_TYPE, SIGN_ALGO } from './constants';
import { addCredential, readSettings } from './settings';
import {
decodeAuthenticatorData,
decodeClientDataJSON,
decodeAttestationObject,
} from './WebAuthnDecoder';
import { decodeArray, encodeArray } from './base64';
import { initWasm } from '@trustwallet/wallet-core';
import { addCredential, readSettings } from './settings';
import { FLOW_BIP44_PATH, HASH_ALGO, KEY_TYPE, SIGN_ALGO } from './constants';
import { getStringFromHashAlgo, getStringFromSignAlgo } from 'ui/utils';
import { storage } from 'background/webapi';

const jsonToKey = async (json, password) => {
try {
Expand Down Expand Up @@ -73,10 +76,7 @@ const seed2PubKey = async (seed) => {
(await storage.get(pathKeyId)) ?? (await storage.get(pathKeyIndex)) ?? FLOW_BIP44_PATH;

const passphrase = (await storage.get(phraseKeyId)) ?? (await storage.get(phraseKeyIndex)) ?? '';
// console.log('pathpathpath ', path)
// console.log('pathKey ', pathKey)
// console.log('phraseKey ', phraseKey)
// console.log('passphrase ', passphrase)

const wallet = HDWallet.createWithMnemonic(seed, passphrase);
const p256PK = wallet.getKeyByCurve(Curve.nist256p1, path);
const p256PubK = Buffer.from(p256PK.getPublicKeyNist256p1().uncompressed().data())
Expand Down Expand Up @@ -127,7 +127,7 @@ const seed2PubKeyTemp = async (seed) => {
};

function getRandomBytes(length) {
var array = new Uint8Array(length ?? 32);
const array = new Uint8Array(length ?? 32);
crypto.getRandomValues(array);
return array;
}
Expand Down
Loading

0 comments on commit 183d0d1

Please sign in to comment.