Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Token dependent on single wallet address #107
Following a discussion with @octavioamu, it occurred to me that
Originally, we discussed introducing a
If we introduce something like an
class Wallet(SuperModel): """Define the Wallet data schema for profiles.""" address = models.CharField(max_length=255, db_index=True) is_default = models.BooleanField(default=False) profile = models.ForeignKey('dashboard.Profile', on_delete=models.CASCADE, related_name='wallets') wallet_users = models.ManyToManyField('dashboard.Profile')
We could then update the
@property def preferred_payout_address(self): """Return the preferred payout address for this Profile.""" try: return self.wallets.get(is_default=True).address except Wallet.DoesNotExist: return ''
This should greatly reduce the initial lift throughout the codebase from
This allows us to perform prefetch/select_relates on the appropriate models and limit our queries while also ensuring we can always display historic kudos and transactions for a
Additionally, this allows a dev to simply query the profile and access
If you'd like, I can raise this issue on
Consideration during implementation:
Possible "attack vector" with the current implementation... If a user wants to display another user's kudos on their profile, they could simply:
Any thoughts on this?
I like the idea. If you want to make that change in the master branch, that would be great. I can pull it in then and add the FK for the Kudos Token.
As far as the attack vector: We don't allow users to add an arbitrary address from the Profile. They can only add an address that's in their MetaMask account.
However, regarding the "Indirect Tips" receive, if the user uses someone else's address and then sets it as their
@jasonrhaas Pushing out the PR today. I'll
Regarding the attack vector, if you browse to https://gitcoin.co/settings/account - you can update your
I'm totally good with not using the
I think this change will solve it for Kudos and the Gitcoin app as a whole so that a user can have multiple wallets associated with their profile.