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: add useExportAccount hook #567

Merged
merged 9 commits into from
Apr 18, 2024
Merged

Conversation

avasisht23
Copy link
Contributor

@avasisht23 avasisht23 commented Apr 11, 2024

Pull Request Checklist


PR-Codex overview

This PR introduces a new useExportAccount hook for exporting account recovery details in Alchemy.

Detailed summary

  • Added useExportAccount hook with related types and components
  • Updated multiple files to implement and use the new hook
  • Added documentation for useExportAccount hook in Markdown format

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

@avasisht23 avasisht23 changed the base branch from main to ajv/add_disconnect_signer_hook April 11, 2024 06:45
Copy link
Collaborator

@moldy530 moldy530 left a comment

Choose a reason for hiding this comment

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

same comment here as in the other ones -- docs :)

packages/alchemy/src/react/hooks/useExportWallet.ts Outdated Show resolved Hide resolved
packages/alchemy/src/react/hooks/useExportWallet.ts Outdated Show resolved Hide resolved
@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from e5ad797 to 7144c68 Compare April 12, 2024 16:55
@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from 7144c68 to 00c9eb0 Compare April 12, 2024 18:18
@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch from 36923ee to 13b8ceb Compare April 12, 2024 18:18
@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from 00c9eb0 to 58597f8 Compare April 12, 2024 18:58
@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch from 0327d40 to f1c986b Compare April 12, 2024 18:58
@avasisht23 avasisht23 changed the title feat: add useExportWallet hook feat: add useExportAccount hook Apr 12, 2024
@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from 58597f8 to 4ab6722 Compare April 15, 2024 02:31
@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch from f1c986b to b7a9bc0 Compare April 15, 2024 02:31
@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from 4ab6722 to 7cb782b Compare April 15, 2024 16:08
@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch from b7a9bc0 to e3de338 Compare April 15, 2024 18:18
@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from 33413f4 to 57dacd7 Compare April 16, 2024 05:39
@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch from e3de338 to c14022c Compare April 16, 2024 05:39
site/snippets/react/useExportAccount.tsx Outdated Show resolved Hide resolved
packages/alchemy/src/react/hooks/useExportAccount.ts Outdated Show resolved Hide resolved
params?: ExportAccountParams;
} & BaseHookMutationArgs<UseExportAccountData, UseExportAccountParams>;

export type ExportAccountComponentProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

How or why this should be used is not clear, we should document this and put some comments around it.

Copy link
Contributor Author

@avasisht23 avasisht23 Apr 17, 2024

Choose a reason for hiding this comment

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

this is documented on the account kit docs and in the example snippet, but agree, also put js docs on this

style: { display: !isExported ? "none" : "block" },
id: iframeContainerId,
},
createElement("style", {}, iframeCss)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we want to create a <style> element inside of the iframe container div?

What is the expected escape hatch you are trying to do here? I'm a little confused by that. Can we add what this does in documentation somewhere? (Hence the push for jsdocs)

Also if you are trying to add style to the iframe itself, why not just add it in line 68?

Side note you can always make iframeCss be a React.CSSProperties and then just merge object that with whatever existing styles you want? It'll probably make downstream code more type safe.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The why is mainly because this is what turnkey's docs show for styling the iframe. Maybe it should be just css props and the style component always is like

iframe { ${iframeCSS} }

Or h/e that works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a little different even doing iframe { ${iframeCSS} } because if iframeCSS is React.CSSProperties then it's still not a css string: it's an object which we can't just stringify (keys need to go from camel case to kebab case, and we need to separate key-vals with ";")

b/c it's more typesafe, i've added a parser to continue doing the iframe styling as turnkey recommends @moldy530 @rthomare. lmk what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just commenting to flag

isExported: boolean;
};

export type UseExportAccountResult = {
Copy link
Contributor

Choose a reason for hiding this comment

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

the code here in this hook assumes web environment.
Can we make it generic so that the client can also be non-web react environment but also react native? (i.e. webview)

The API between webview <> iframe should be similar/compatible, but haven't looked deeply myself yet if having a shared react hook for this hook between web vs native env would work/be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably something we'd fast follow with, separating this as a devex improvement vs. net-new functionality for react native.

@avasisht23 avasisht23 force-pushed the ajv/add_disconnect_signer_hook branch from 57dacd7 to fb55de7 Compare April 17, 2024 15:05
@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch 2 times, most recently from 85f5b5b to a2f5510 Compare April 18, 2024 07:02
rthomare
rthomare previously approved these changes Apr 18, 2024
Base automatically changed from ajv/add_disconnect_signer_hook to main April 18, 2024 17:52
@avasisht23 avasisht23 dismissed rthomare’s stale review April 18, 2024 17:52

The base branch was changed.

@avasisht23 avasisht23 force-pushed the ajv/add_export_wallet_hook branch from 2437cc0 to 4b54aee Compare April 18, 2024 17:53
@avasisht23 avasisht23 merged commit 50770d8 into main Apr 18, 2024
2 checks passed
@avasisht23 avasisht23 deleted the ajv/add_export_wallet_hook branch April 18, 2024 17:58
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.

4 participants