Skip to content

Commit

Permalink
fixed: finding address with weight
Browse files Browse the repository at this point in the history
  • Loading branch information
zzggo committed Dec 3, 2024
1 parent 4aa79af commit b8f408f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/ui/utils/modules/findAddressWithPK.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) => {
Expand Down

0 comments on commit b8f408f

Please sign in to comment.