Skip to content

Commit

Permalink
Merge pull request #511 from onflow/510-feature-remove-unnecessary-da…
Browse files Browse the repository at this point in the history
…ta-from-getpubkey

fixed: remove unnecessary data in pubkey return, add type check for pubk
  • Loading branch information
zzggo authored Feb 13, 2025
2 parents 5051add + f65529a commit b7134bb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import {
import eventBus from '@/eventBus';
import { type FeatureFlagKey, type FeatureFlags } from '@/shared/types/feature-types';
import { type TrackingEvents } from '@/shared/types/tracking-types';
import { type ActiveChildType, type LoggedInAccount } from '@/shared/types/wallet-types';
import {
type ActiveChildType,
type LoggedInAccount,
type PublicKeyTuple,
} from '@/shared/types/wallet-types';
import { ensureEvmAddressPrefix, isValidEthereumAddress, withPrefix } from '@/shared/utils/address';
import { getHashAlgo, getSignAlgo } from '@/shared/utils/algo';
import { retryOperation } from '@/shared/utils/retryOperation';
Expand Down Expand Up @@ -531,7 +535,7 @@ export class WalletController extends BaseController {
return privateKey;
};

getPubKey = async () => {
getPubKey = async (): Promise<PublicKeyTuple> => {
let privateKey;
let pubKTuple;
const keyrings = await keyringService.getKeyring();
Expand Down Expand Up @@ -565,7 +569,14 @@ export class WalletController extends BaseController {
const error = new Error('No mnemonic or private key found in any of the keyrings.');
throw error;
}
return pubKTuple;
return {
P256: {
pubK: pubKTuple.P256.pubK,
},
SECP256K1: {
pubK: pubKTuple.SECP256K1.pubK,
},
};
};

importPrivateKey = async (data) => {
Expand Down
3 changes: 2 additions & 1 deletion src/background/service/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
type LoggedInAccount,
type FlowAddress,
type ActiveChildType,
type PublicKeyTuple,
} from '@/shared/types/wallet-types';
import { isValidFlowAddress, isValidEthereumAddress } from '@/shared/utils/address';
import { getStringFromHashAlgo, getStringFromSignAlgo } from '@/shared/utils/algo';
Expand Down Expand Up @@ -2349,7 +2350,7 @@ class OpenApiService {
freshUserInfo = async (
currentWallet: BlockchainResponse,
keys: FclAccount,
pubKTuple,
pubKTuple: PublicKeyTuple,
wallet,
isChild: ActiveChildType
) => {
Expand Down
9 changes: 9 additions & 0 deletions src/shared/types/wallet-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@ export type LoggedInAccount = {
export type LoggedInAccountWithIndex = LoggedInAccount & {
indexInLoggedInAccounts: number;
};

export type PublicKeyTuple = {
P256: {
pubK: string;
};
SECP256K1: {
pubK: string;
};
};

0 comments on commit b7134bb

Please sign in to comment.