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

chore: track walletType usage #774

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Nov 18, 2024

PR-Codex overview

This PR primarily focuses on renaming the parameter address to walletAddress in various functions and files related to wallet details, enhancing clarity and consistency across the codebase. Additionally, it introduces caching for wallet details to improve performance.

Detailed summary

  • Renamed address to walletAddress in multiple files:
    • src/utils/cache/getWallet.ts
    • src/server/routes/backend-wallet/signMessage.ts
    • src/utils/account.ts
    • src/utils/cache/clearCache.ts
    • src/utils/usage.ts
    • src/db/wallets/getWalletDetails.ts
    • src/utils/transaction/insertTransaction.ts
  • Introduced walletDetailsCache in src/db/wallets/getWalletDetails.ts for caching wallet details.
  • Updated error messages to reflect the new walletAddress parameter.
  • Added walletType to QueuedTransaction in src/utils/transaction/types.ts.
  • Modified insertTransaction logic to handle wallet details more effectively.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@arcoraven arcoraven requested a review from d4mr November 18, 2024 04:41
@@ -130,6 +131,8 @@ export type SmartBackendWalletType = (typeof SmartBackendWalletTypes)[number];
export type BackendWalletType = (typeof BackendWalletTypes)[number];
export type ParsedWalletDetails = z.infer<typeof walletDetailsSchema>;

export const walletDetailsCache = new LRUMap<string, ParsedWalletDetails>(2048);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add caching here because this is called on every write request.

Only caches if wallet details are found. Does not cache DB misses.

// Get wallet details. For EOA and SBW (v5 endpoints), `from` should return a valid backend wallet.
// For SBW (v4 endpoints), `accountAddress` should return a valid backend wallet.
// Else the provided details are incorrect (user error).
let walletDetails: ParsedWalletDetails | undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the big change @d4mr. To track walletType we need to query walletDetails for all transactions (not just SBW).

Copy link

This PR is stale because it has been open for 7 days with no activity. Remove stale label or comment or this PR will be closed in 3 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants