Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed: remove unnecessary data in pubkey return, add type check for pubk #511

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2348,7 +2349,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;
};
};
Loading