Overview
User accounts will allow users to
- Claim ownership of contracts and code bundles they uploaded
- Favorite contracts/code bundles
- Integrate with ink! playground authored elements (tbd)
The user account doubles as a Textile identity allowing interactions with ThreadDB's remote features (pushing to and pulling from the IPFS database). In case an account is not connected, a generic randomly generated identity will be used strictly to allow fetching remote data.
Sign in process
(adapted from https://docs.textile.io/tutorials/hub/pki-identities/#metamask)
- From the sidebar, user clicks Connect Account to open a dialog
- User selects one of their Polkadot accounts from a dropdown and enters a secret (password) to generate their identity
- The app then creates a unique string that contains a hashed version of the secret, the app name (canvas-ui), and some additional text. The app can regenerate this string at any time in the future if the user supplies their secret. example
- The unique string is then signed with the user's Polkadot address via the extension. (example)
- The resulting signature is used to generate an ed25519 key that can be used as an identity with all Textile APIs. User can then edit their displayed name, add optional fields like email address, etc. to be stored in User collection
This approach allows the user to retain access to their identity and saved contracts etc. as long as they still have access to the Polkadot account and the secret they used. The last used identity can be saved in localStorage to prevent the need to connect on every page load. The account dropdown can be used to switch between previously used identities.
Once signed in, all contracts the user uploads will be associated with their identity and displayed under "My Contracts" on the sidebar and elsewhere. They will be able to favorite/"star" code bundles and contracts uploaded by others.
Claiming on-chain items
Even if a user was not signed in, the database will record the Polkadot account that was used to instantiate or upload each item on the chain. Once they are signed in, users can claim unclaimed contracts or code bundles by signing a unique message with the Polkadot account that was used, and the contract/code bundle will then be associated with their identity.