From b8f408f52fff01dd0552cfd4d1d0b762b104e4fb Mon Sep 17 00:00:00 2001 From: zzggo Date: Tue, 3 Dec 2024 16:07:34 +1100 Subject: [PATCH] fixed: finding address with weight --- src/ui/utils/modules/findAddressWithPK.tsx | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/ui/utils/modules/findAddressWithPK.tsx b/src/ui/utils/modules/findAddressWithPK.tsx index 120ba664..ca604235 100644 --- a/src/ui/utils/modules/findAddressWithPK.tsx +++ b/src/ui/utils/modules/findAddressWithPK.tsx @@ -1,5 +1,5 @@ -import { pk2PubKey, seed2PubKey, seed2PubKeyTemp } from './passkey'; import { findAddressWithKey } from './findAddressWithPubKey'; +import { pk2PubKey, seed2PubKey, seed2PubKeyTemp } from './passkey'; const findAddress = async (pubKTuple, address) => { const { P256, SECP256K1 } = pubKTuple; @@ -9,18 +9,20 @@ const findAddress = async (pubKTuple, address) => { const pS = sepc256k1Accounts.map((s) => ({ ...s, pk: SECP256K1.pk })); const accounts = pA.concat(pS); - // console.log('accounts 222 ==>', accounts); - if (accounts[0].weight < 1000) { - return null; - } if (!accounts || accounts.length === 0) { - SECP256K1['weight'] = 1000; - SECP256K1['hashAlgo'] = 'SHA2_256'; - SECP256K1['signAlgo'] = 'ECDSA_secp256k1'; - SECP256K1['keyIndex'] = 0; - return [SECP256K1]; + return [ + { + ...SECP256K1, + weight: 1000, + hashAlgo: 'SHA2_256', + signAlgo: 'ECDSA_secp256k1', + keyIndex: 0, + }, + ]; } - return accounts; + + const account = accounts.find((account) => account.weight >= 1000); + return account ? [account] : null; }; export const findAddressWithPK = async (pk, address) => {