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

feat: vks birthdays #1415

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions apps/extension/src/background/keyring/keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class KeyRing {
path: bip44Path,
type: AccountType.Ledger,
source: "imported",
timestamp: new Date().getTime(),
timestamp: 0,
};

const sensitive = await this.vaultService.encryptSensitiveData({
Expand Down Expand Up @@ -162,8 +162,8 @@ export class KeyRing {
await this.vaultService.assertIsUnlocked();

const keys = this.sdkService.getSdk().getKeys();
const timestamp = new Date().getTime();
const source = flow === "create" ? "generated" : "imported";
const timestamp = source === "generated" ? new Date().getTime() : 0;

const { sk, text, passphrase, accountType } = ((): {
sk: string;
Expand Down Expand Up @@ -449,7 +449,7 @@ export class KeyRing {
);
}

const timestamp = new Date().getTime();
const timestamp = source === "generated" ? new Date().getTime() : 0;
const derivedAccount = await this.persistAccount(
type === AccountType.ShieldedKeys ? zip32Path : derivationPath,
parentId,
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/src/storage/schemas/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const v1toV2 = (data: VaultV1Type): VaultV2Type => {
data: {
"key-store": data.data["key-store"].map((ks) => ({
...ks,
public: { ...ks.public, source: "generated", timestamp: 0 },
// we set source to "imported" because "generated" with timestamp 0 does not make sense
public: { ...ks.public, source: "imported", timestamp: 0 },
})),
},
};
Expand Down
5 changes: 3 additions & 2 deletions apps/extension/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ export const toPublicAccount = (derivedAccount: DerivedAccount): Account => {
alias,
address,
type,
pseudoExtendedKey,
source,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last comment - if we don't need source on transparent, I would maybe omit it here. It gets appended below for shielded which makes sense!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I forgot to remove the line :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

timestamp,
};
if (isShielded) {
account.viewingKey = owner;
Copy link
Collaborator

@jurevans jurevans Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once thought: Move pseudoExtendedKey (and maybe timestamp if it's only used for shielded accounts) down here, so we don't return undefined values in transparent accounts. If we don't need source in Namadillo, I would vote to drop it from here. Maybe timestamp can be a shielded-only thing too?

account.pseudoExtendedKey = pseudoExtendedKey;
account.source = source;
account.timestamp = timestamp;
} else {
account.publicKey = publicKey;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/namadillo/src/atoms/balance/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ const toDatedKeypair = async (
api: DefaultApi,
{ viewingKey, source, timestamp }: Account
): Promise<DatedViewingKey> => {
if (!viewingKey) {
if (typeof viewingKey === "undefined") {
throw new Error("Viewing key not found");
}
if (!timestamp) {
if (typeof timestamp === "undefined") {
throw new Error("Timestamp not found");
}
let height = 0;
Expand Down
Loading