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

refactor: switch alchemy client configs to use alchemy transport #987

Open
wants to merge 1 commit into
base: moldy/alchemy-transport-0
Choose a base branch
from

Conversation

moldy530
Copy link
Collaborator

@moldy530 moldy530 commented Sep 26, 2024

Pull Request Checklist


PR-Codex overview

This PR introduces significant updates to the account-kit library, primarily focusing on the integration of alchemy transport for smart account clients, enhancing the functionality and configuration of various client creation methods, and refining type definitions for better clarity.

Detailed summary

  • Removed createAlchemySmartAccountClientFromExisting function.
  • Added alchemy transport integration in client creation methods.
  • Updated type definitions to simplify transport usage.
  • Enhanced getSmartAccountClient to utilize new transport methods.
  • Improved test cases for various account client functionalities.
  • Cleared local storage before each test in watchSmartAccountClient.
  • Updated configuration files to reflect the new jsdom environment.
  • Modified documentation to align with transport changes.

The following files were skipped due to too many changes: yarn.lock

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

Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 9:25pm
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 9:25pm

@moldy530
Copy link
Collaborator Author

moldy530 commented Sep 26, 2024

TODO:

  • confirm docs all still render without error
  • make sure tests pass
  • add to the migration guide to highlight the changes
  • update guides for thirdparty which used some of these methods

@moldy530 moldy530 force-pushed the moldy/alchemy-transport branch 2 times, most recently from 357b010 to 64a6405 Compare September 26, 2024 23:24
Comment on lines 120 to 121
fetchOptions.headers = new Headers(fetchOptions.headers);
fetchOptions.headers.set("Alchemy-AA-Sdk-Version", VERSION);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dphilipson finally fixed the issues in the previous PR doing this: #563 (comment)

@moldy530 moldy530 force-pushed the moldy/alchemy-transport branch 2 times, most recently from 579cacf to fd7bca0 Compare September 27, 2024 17:22
Comment on lines +82 to +85
const pConn = persistedConnection as Record<string, any>;
if (key === "chain") return value.id === pConn.chain.id;

return pConn[key] === value;
Copy link
Collaborator Author

@moldy530 moldy530 Sep 27, 2024

Choose a reason for hiding this comment

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

yaayyy testing, we need to get better at our coverage here. it's really bad (I take a lot of the blame for that) and this core logic does a lot of complex state mgmt that needs to be tested

// this is the default merge behavior
return { ...current, ...persistedState };
const { chain, ...connection } = persistedConnections.find(
(x) => x.chain.id === persistedState.bundlerClient.chain.id
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's fine to use the persisted state here because we've already established the persisted client uses the same connections as the core state. this way if a user has switched chains that switch persists (see tests above)

@moldy530
Copy link
Collaborator Author

Gonna do the docs in a separate PR to keep this one from getting any bigger than it already is

@moldy530 moldy530 marked this pull request as ready for review September 30, 2024 15:52
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.

1 participant