mud icon indicating copy to clipboard operation
mud copied to clipboard

Wallets and user onboarding (v1)

Open frolic opened this issue 1 year ago • 1 comments

We've been prototyping a complete wallet integration and user onboarding flow in https://github.com/latticexyz/mud/pull/2623

This issue will capture what we have left for a v1 and replaces some previous issues.

This new library/package will be wired up in the same way you might wire up RainbowKit or ConnectKit, where it sits within a Wagmi provider and leans on the Wagmi config for defaults. It will expose an appAccountClient that is populated once a user has fully onboarded (wallet connected, app account funded and registered into the world).

  • [ ] Get Unstable_CallWithSignatureModule audited
  • [ ] Rip out smart account and gas tank stuff for now
  • [ ] Finalize designs
    • [ ] Implement designs
  • [ ] Clarify "gas tank balance" analogy
  • [ ] Properly calculate gas required for "withdraw all funds"
  • [ ] Solidify assumptions: for MUD apps on OP Stack chains
  • [ ] Onboarded = all requirements fulfilled and balance > 0
  • [ ] Consistent error+pending states and async operations (e.g. deposits)
  • [ ] Revisit button pending states
  • [ ] UI page in sandbox to show various states for easier design iteration
  • [ ] Add tests for critical paths
  • [ ] Explore remote iframes for isolation and automatic upgrades
    • wallet connection lives in parent window, app account lives in iframe
    • account kit package mounts the remote iframe, sets up message bus(es)
    • some message bus for account kit iframe to trigger wallet actions (e.g. signing messages and txs, switching network, etc.)
    • some message bus for app account client in parent window to trigger actions on app account
      • or, more simply, just pass the app signer PK up to the parent window?
  • [ ] Explore what is required to move away from RainbowKit to our own UI (not a v1 blocker)
  • [ ] Explore mobile support (not a v1 blocker)
  • [ ] Add to templates

frolic avatar May 22 '24 12:05 frolic

Some additional reminders for myself:

  • [ ] rename config.appInfo to config.app for alignment with upcoming app metadata
  • [ ] remove config.gasPerAction and config.calldataPerAction in favor of gas tank gauge analogy
  • [ ] add "url" suffix to config options that are URLs?
  • [ ] add "learn more" config option to align with RainbowKit? also check for ConnectKit app metadata alignment
  • [ ] move rainbowkit usage into core (and into iframe portal) in prep for replacing it with something else
  • [ ] use wagmi config subset rather than the full thing excluding client?
  • [ ] use "wallet" abstraction instead of "connector" in config so we can get extra metadata like wallet name, icon, etc? (see RainbowKit for example)
  • [ ] add wagmi/viem/react peer deps for using account kit import as a wrapper around global
  • [ ] chains should use our own type to include icon URL, bundler URL, etc.
  • [ ] figure out how to include foundry chain by default without causing errors related to talking to a node that may not be listening/running (can't do this conditionally at build time since it'll be a remote script)
  • [ ] expose some notion of external store on global/instance (need to factor in app account client vs prepared app account client)
  • [x] figure out how to expose things like usePreparedAppAccountClient exported from core
  • [ ] upgrade to zustand v5?
  • [ ] internal stores in core (e.g. useAccountModal) should be constructed as part of initializing account kit, not during import time
  • [ ] see if we can tap directly into these internal core stores rather than SyncStore to avoid undefined sprinkled everywhere
  • [ ] revisit resolveJsonModule and strong types when importing ABI from .json.d.ts files

frolic avatar Jun 04 '24 10:06 frolic