anza-xyz / wallet-standard

Solana extensions to the Wallet Standard.
Apache License 2.0
79 stars 42 forks source link

A wallet registry that vends ‘handles’ #51

Closed steveluscher closed 2 months ago

steveluscher commented 3 months ago

In this PR we introduce types to represent Wallet Standard wallets and accounts that are specifically designed for use in UI applications. UI developers can treat these like immutable data structures:

  1. Apps can memoize renders across time because two UiWallet or UiWalletAccount objects that are referentially equal can be understood not to have changed over time (ie. all of the accounts, chains, and features are the same)
  2. Any time referential equality is not found, the subtree therein can be understood to have changed.

At the same time, we maintain weak references between every instance of UiWallet and the underlying Wallet, and UiWalletAccount and the underlying UiWalletAccount such that the underlying wallet can be accessed by any (internal) method that needs it.

In subsequent PRs in this stack you will find hooks that materialize the concrete implementation of a feature belonging to a UiWallet (eg. standard:connect) by following the weak reference between a UiWallet and its underlying Wallet, then binding a callback to the relevant feature.

To understand more about how this registry is used, see https://app.graphite.dev/github/pr/anza-xyz/wallet-standard/53, https://app.graphite.dev/github/pr/anza-xyz/wallet-standard/54, and https://app.graphite.dev/github/pr/anza-xyz/wallet-standard/55.

steveluscher commented 3 months ago

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @steveluscher and the rest of your teammates on Graphite Graphite

steveluscher commented 2 months ago

Would it make sense to separate the WalletHandle concept from wallet-standard/react

Oh, yes. That's the idea. I guess I need to evict this stuff into some other package and then either drop the INTERNAL_ONLY suffixes, or add DO_NOT_USE_OR_YOU_WILL_BE_FIRED to every one.

Oh boy.

steveluscher commented 2 months ago

Merge activity