leather-io / mono

Leather monorepo
https://leather.io
MIT License
11 stars 5 forks source link

feat: shared stacks signing logic #430

Closed kyranjamie closed 1 month ago

kyranjamie commented 1 month ago

This PR adds code for the Stacks signer. This gets initialised in part of the keychain selector.

Next, I aim to figure out the best way to consume these signers in the app. I am very reluctant to continue using the pattern from the extension where we do something like

const signer = useCurrentAccountStacksSigner(); // `signer | undefined`

Instead I want a pattern where we pass signers around dynamically, which might look something like:

function Assets () {
  return signers.map(signer => {
    switch (signer.type) {
      case 'stacks': return <StacksSigner signer={signer} />
      case 'bitcoin': return <BitcoinSigner signer={signer} />
    }
  });
}

This way, we can consume the signer well in the knowledge it exists

or


<SignerLoader requiredKeys={[keyOrigin1, keyOrigin2]} fallback={<AddMoreKeysOrWarningComponent />}>
  {signers => <SendForm signers={signers} />}
</SignerLoader>
kyranjamie commented 1 month ago

Merging this, and will push a follow up with proposal to above concerns