Skip to content

Commit

Permalink
feat: update stored value for indicating modified-zip32 derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Feb 12, 2025
1 parent 3a982b7 commit 75b2cbc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
11 changes: 10 additions & 1 deletion apps/extension/src/App/Accounts/ParentAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ export const ParentAccounts = (): JSX.Element => {
(account) => account.parentId || account.type === AccountType.Ledger
)
.map((account) => {
const outdated =
let outdated =
account.type !== AccountType.Ledger &&
typeof account.pseudoExtendedKey === "undefined";

// The only account without a parent is the ledger account
const parent =
parentAccounts.find((pa) => pa.id === account.parentId) || account;

if (parent?.type === AccountType.Mnemonic) {
if (
account.type === AccountType.ShieldedKeys &&
!account.modifiedZip32Path
) {
outdated = true;
}
}

return { ...parent, outdated };
});

Expand Down
27 changes: 26 additions & 1 deletion apps/extension/src/background/keyring/keyring.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { DEFAULT_ZIP32_PATH, PhraseSize, ShieldedKeys } from "@namada/sdk/web";
import { chains } from "@namada/chains";
import {
DEFAULT_ZIP32_PATH,
makeBip44Path,
MODIFIED_ZIP32_PATH,
PhraseSize,
ShieldedKeys,
} from "@namada/sdk/web";
import { KVStore } from "@namada/storage";
import {
AccountType,
Expand Down Expand Up @@ -368,13 +375,31 @@ export class KeyRing {
timestamp: number
): Promise<DerivedAccount> {
const { address, id, text, owner, pseudoExtendedKey } = derivedAccountInfo;

let modifiedZip32Path: string | undefined;

const parent = parentId ? await this.queryAccountById(parentId) : null;

if (parent) {
if (
type === AccountType.ShieldedKeys &&
parent.type === AccountType.Mnemonic
) {
modifiedZip32Path = makeBip44Path(
chains.namada.bip44.coinType,
MODIFIED_ZIP32_PATH
);
}
}

const account: AccountStore = {
id,
address,
alias,
parentId,
path,
type,
modifiedZip32Path,
owner,
pseudoExtendedKey,
source,
Expand Down
1 change: 1 addition & 0 deletions apps/extension/src/background/keyring/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AccountType, DerivedAccount, Path } from "@namada/types";
export interface AccountStore extends StoredRecord {
alias: string;
address: string;
modifiedZip32Path?: string;
owner: string;
publicKey?: string;
path: Path;
Expand Down

0 comments on commit 75b2cbc

Please sign in to comment.