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

add sessions to wallet stamper demo #338

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrewkmin
Copy link
Collaborator

@andrewkmin andrewkmin commented Aug 21, 2024

Summary & Motivation

Add session support to the wallet stamper demo. See recording below:

Screen.Recording.2024-08-21.at.5.06.36.PM.mov

How I Tested These Changes

Did you add a changeset?

If updating one of our packages, you'll likely need to add a changeset to your PR. To do so, run pnpm changeset. pnpm changeset will generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).

These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.

@andrewkmin andrewkmin force-pushed the andrew/wallet-stamper-sessions branch from d0e4c70 to 8008627 Compare August 21, 2024 20:58
Copy link

codesandbox-ci bot commented Aug 21, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@andrewkmin andrewkmin changed the title Andrew/wallet stamper sessions add sessions to wallet stamper demo Aug 21, 2024

// Need to save resulting bundle and information.
// This is required by the authIframeClient abstraction.
localStorage.setItem("CREDENTIAL_BUNDLE", result?.credentialBundle!);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is soon to be abstracted away once we have proper support in our higher level SDK packages.


const handleCreateWallet = (walletName: string) => {
createWallet(walletName, () => {
getWallets().then((wallets) => setWallets(wallets));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Passing a callback here. A bit of an antipattern, but just a quick solution until proper resource fetching is in place

return whoami;
}

async function createWallet(walletName: string) {
async function createWallet(walletName: string, callback: any) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: bit of an antipattern. See caller in examples/with-wallet-stamper/src/components/user.tsx

<body className={inter.className}>
<Providers>{children}</Providers>
</body>
<TurnkeyReactProvider config={turnkeyConfig}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We essentially have two wrappers here: TurnkeyReactProvider from @turnkey/sdk-react, and another one that's created within this project. I included TurnkeyReactProvider in this demo because it abstracts away some iframe-related logic, so if it's confusing as to why where are two separate providers, I hope that offers some clarity.

@andrewkmin andrewkmin force-pushed the andrew/wallet-stamper-sessions branch from 5766067 to b0e927b Compare October 7, 2024 03:01
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