Skip to content

Conversation

@tremarkley
Copy link
Contributor

@tremarkley tremarkley commented Sep 17, 2025

Closes #86

Demo

Description

Adds support for frontend wallets hosted by Dynamic. If you want to check out a fully working demo with dynamic wallets build and run this PR and also reach out to me for the Dynamic environment variables.

Changes

  • Adds a DynamicWallet class
  • Creates a new export path that can be imported by frontends that want to use verbs. This is important in order to separate Node specific dependencies and React / Browser dependencies
  • Adds a new entrypoint for creating Verbs instances that leverages the hosted wallet registry in order to register the correct wallet infra depending on whether Verbs is being used in Node or React
  • Establishes a framework so that Verbs can be flexible and support either frontend wallets or server wallets

@netlify
Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for verbs-ui ready!

Name Link
🔨 Latest commit 584b9fd
🔍 Latest deploy log https://app.netlify.com/projects/verbs-ui/deploys/68d2e8665ddf7d00088de32b
😎 Deploy Preview https://deploy-preview-120--verbs-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tremarkley
Copy link
Contributor Author

tremarkley commented Sep 17, 2025

@tremarkley tremarkley force-pushed the harry/frontend_dynamic branch from 38fe047 to 8cb2301 Compare September 18, 2025 22:15
@tremarkley tremarkley force-pushed the harry/frontend_dynamic branch from 8cb2301 to 7c29958 Compare September 18, 2025 23:08
@tremarkley tremarkley force-pushed the harry/frontend_dynamic branch 15 times, most recently from 0c775ca to af5850d Compare September 19, 2025 19:44
@tremarkley tremarkley changed the title spike: add dynamic fe wallet support feat: add dynamic frontend wallet support Sep 19, 2025
@tremarkley tremarkley marked this pull request as ready for review September 19, 2025 19:50
@tremarkley tremarkley requested a review from a team as a code owner September 19, 2025 19:50
signTypedData: walletClient.signTypedData,
})
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 With lend, I have all the Morpho related files together in: sdk/src/lend/providers/morpho/

I wonder if it makes sense to do something similar with wallet providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah right now everything is under sdk/src/wallet/ and sdk/src/wallet/providers. Maybe it makes sense to do sdk/src/wallet/dynamic and sdk/src/wallet/providers/dynamic?

? fallback(rpcUrls.map((rpcUrl) => http(rpcUrl)))
: http(),
})
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 It looks like this function doesn't have anything specific to Dynamic, can it be pulled into the parent Wallet and called from there?

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 specifically for Wallet that are non smart wallets. I dont think we would want this for a smart wallet so I am hesitant to pull it into the Wallet class. We could consider having a non-smart wallet parent class in the future though. if we did that, we could probably pull this into it and maybe even the performInitialization implementation. But currently, it's such a small amount of code, I don't think it's worth creating that abstraction just yet

dynamicWallet: DynamicHostedWalletToVerbsWalletOptions['wallet'],
) {
super(chainManager)
this.dynamicWallet = dynamicWallet
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 If we renamed this something general like this.hostedWallet, can it be abstracted into the parent? If so, would it reduce the amount of boilerplate for this and and PrivyWallet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the issue is that the type this has is going to be different for each hosted wallet, so if we were to abstract it to the parent we would have to give it a generic type and ultimately, it wouldn't really end up saving us any code except maybe this one line. We would still need to add code to every implementation class to specify how to convert the wallet to a LocalAccount

protected async performInitialization() {
this.signer = await this.createAccount()
this.address = this.signer.address
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question

chainManager: ChainManager
}): Promise<DynamicWallet> {
const wallet = new DynamicWallet(params.chainManager, params.dynamicWallet)
await wallet.initialize()
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 I don't know what the fix is, but It's a little confusing that this class (and I assume PrivyWallet) have:

  • constructor()
  • create()
  • createAccount()
  • performInitialization()
  • initialize() from the parent Wallet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can try to think of better ways to share code. Things just get a little gnarly when you have async calls that need to occur in order to fully initialize a class.

*/
export class WalletNamespace<
H extends HostedWalletProvider = HostedWalletProvider,
H extends HostedWalletProvider<any> = HostedWalletProvider<any>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ Can this be more strict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

*/
export class WalletProvider<
H extends HostedWalletProvider,
H extends HostedWalletProvider<any>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Collaborator

@its-everdred its-everdred left a comment

Choose a reason for hiding this comment

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

What is the thought with the mapping?

ReactHostedWalletProviderRegistry == Dynamic
NodeHostedWalletProviderRegistry == Privy

@tremarkley tremarkley force-pushed the harry/frontend_dynamic branch 3 times, most recently from d9d9ad3 to e57d44b Compare September 23, 2025 18:28
@tremarkley tremarkley force-pushed the harry/frontend_dynamic branch from e57d44b to 584b9fd Compare September 23, 2025 18:35
@tremarkley tremarkley merged commit e876a00 into main Sep 23, 2025
10 checks passed
@tremarkley tremarkley deleted the harry/frontend_dynamic branch September 23, 2025 18:42
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.

Wallet adapter for Dynamic

3 participants