Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve user alias for asset methods (balances, transfer etc.) #247

Open
dzikowski opened this issue Jun 4, 2024 · 0 comments
Open

Resolve user alias for asset methods (balances, transfer etc.) #247

dzikowski opened this issue Jun 4, 2024 · 0 comments

Comments

@dzikowski
Copy link
Collaborator

dzikowski commented Jun 4, 2024

Currently UserProfile is saved on GCUP/<eth-addr> key and contains the alias field. When you authorize with signature-based auth ctx.callingUser is set to alias. Also all balances and other user-related key parts use alias. But when you do some operations, like fetching balances or tranferring tokens, we don't search for aliases. If you provide eth|<ath-addr> for user that has an alias, it won't find the alias, which leads to potentially inconsistent state.

Implementation proposal:

  1. For all DTO parameters which point to user, use a custom class UserId (like owner?: UserId in FetchBalances)
  2. UserId should be serialized to string and deserialized from string to something like { "userId": string }
  3. For all ChainObject parameters which point to user, use a custom class - UserAlias.
  4. UserAlias should be serialized to string containing user alias to keep backward compatibility (we use alias-first approach), and deserialized to something like { "alias": string }.
  5. Each time you want to use UserAlias type, you need to get it with some custom method like getUserAlias(id: UserId): UserAlias. This way we keep type-safety and enforce resolving user aliases.

Additionally we should support lower-cased eth addresses (not only checksumed ones)

To be considered:

  1. Maybe we should implement it once we drop the legacy auth: Drop support for legacy auth #176 There is a risk that making it backward compatible with the legacy auth may be problematic. But there is also a benefit of making it backward compatible - no need to wait till the 2.0 release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants