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

[Discovery] Enable user to user grants ("delegated writes") aka manager mode [PAY-2544] #7890

Merged
merged 6 commits into from
Mar 20, 2024

Conversation

nicoback2
Copy link
Contributor

@nicoback2 nicoback2 commented Mar 20, 2024

Description

  • Enable manager mode access. A manger-to-artist relationship is represented by an entry in the existing Grants table where instead of the grantee_address being a developer app address, it is the manager's wallet address. I.e. a user to user grant.
  • User to user grants must be approved in order to grant access. The grantor (artist) creates the Grant, then the manager approves or rejects the grant (corresponds to is_approved column = True or False; None if it has neither been approved or rejected yet).
  • Enable developer apps/managers to perform Developer App and Grant entity actions on behalf of their grantors.

How Has This Been Tested?

  • Integration tests. Planning to add more in subsequent PR.

Follow-ons

https://linear.app/audius/issue/C-4041/manager-mode-grants-follow-ons

Copy link
Contributor

@schottra schottra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few minor things. One larger question:
I think we want to allow the flow to be initiated from either side (manager asking artist or artist asking manager). Is this easily modifiable to allow that?

Also wondering if this design would easily support notifications for one or the other user that a grant request has been created? (Seems like yes since we generally use triggers for that)

@@ -674,6 +799,20 @@ def test_index_invalid_tracks(app, mocker):
)
},
],
"CreateTrackInvalidUserGrantNotApproved": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

# plugins = sqlmypy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no!! thanks for catching

@@ -90,40 +106,70 @@ def validate_grant_tx(params: ManageEntityParameters, metadata):
raise IndexingValidationError(
f"Invalid Grant transaction, developer app address {metadata['grantee_address']} is invalid"
)
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we could stand to refactor this later to split up the developer app and user cases into separate functions just to make this a little less complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet = params.existing_records["User"][user_id].wallet
if wallet and wallet.lower() != params.signer.lower():
validate_signer(params)
elif (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion here, would be nice to handle each action individually.

)

is_valid_user_grantee = (
not not user_grantee and not user_grantee.is_deactivated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not not? Is this checking that the user_grantee isn't None? If so, can we do a more explicit check here? This is a bit hard to read :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yeah it is. I originally checked != None but for some reason mypy then could not deduce that user_grantee wouldn't be empty in the next condition. honestly mypy is trash. let me double check that this is the case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok confirmed that making this sensical results inexplicably results in a mypy error. i added parens to make the not not more clear.

@nicoback2
Copy link
Contributor Author

nicoback2 commented Mar 20, 2024

Looks good, just a few minor things. One larger question: I think we want to allow the flow to be initiated from either side (manager asking artist or artist asking manager). Is this easily modifiable to allow that?

Also wondering if this design would easily support notifications for one or the other user that a grant request has been created? (Seems like yes since we generally use triggers for that)

  1. Yes it is easily modifiable to allow that! But in the meeting yesterday I think we were instructed that only the artist can initiate the flow (notes)
  2. Yeah I think so. I haven't haven't built any notifications before but seems like we can trigger a notification upon grant creation / approval / reject / revoke

@nicoback2 nicoback2 merged commit 184c576 into main Mar 20, 2024
10 of 11 checks passed
@nicoback2 nicoback2 deleted the nkang--user-user-grants branch March 20, 2024 17:28
audius-infra pushed a commit that referenced this pull request Mar 25, 2024
[d09c970] Change internal sdk deps back to wildcard version (#7928) Sebastian Klingler
[7271dbc] [C-4026, C-4059] Update profile page to render basic info and pictures on the server side (#7915) Kyle Shanks
[bfde29f] Log error when retry on new node fails (#7924) Marcus Pasell
[a5a0d96] [C-3961] Fix sign up modal toast triggers (#7916) JD Francis
[0183bf8] [PROTO-1693] Fix tag search triggering autocomplete (#7913) Isaac Solo
[eeb6e19] [C-4028] Harmony QA (#7919) Dylan Jeffers
[fc94c44] [PROTO-1718] Parse DDEX subgenre and handle multiple genre elements (#7921) Theo Ilie
[bf34d35] Bump version to 0.6.66 audius-infra
[8c98f63] [C-4063] Add Sign on routes and aliases to static routes (#7918) Kyle Shanks
[92ced07] [PROTO-1700] Make DDEX publisher support batched and local S3 (#7902) Theo Ilie
[1f61df3] ⚠️ [C-4064] Fix empty feed/trending pages (#7920) Reed
[6ea4bd7] boost relay retries and address in logging (#7914) alecsavvy
[0c8911a] Misc accessibility improvements + mobile drawer fix (#7912) JD Francis
[d62d210] [C-3962] Fix sign up referrals (#7880) JD Francis
[61adb86] Bump version to 0.6.65 audius-infra
[9d270a5] Fix remix uploads and AI attributed uploads (#7911) Marcus Pasell
[4bc9f03] [C-4055] Improve modal and popover performance (#7909) Dylan Jeffers
[befe0a5] [C-4027] Harmony migration fixes (#7907) Dylan Jeffers
[5b3e9fa] Fix search autocomplete race condition (#7908) Isaac Solo
[8f9d022] Fix ddex indexing (#7904) Michelle Brier
[f1472a7] Re-add download to track api response for old clients (#7906) Reed
[e2c7024] Improve search quality: genre, mood, tag, fuzziness, exact matches (#7883) Isaac Solo
[efcb74e] [C-4024] Update SSR to dynamically import Root based on HYDRATE_CLIENT (#7892) Kyle Shanks
[daf7c1e] Log retryTxId in TransactionHandler (#7895) Reed
[38442bd] Bump version to 0.6.64 audius-infra
[e0a0606] Pin docker to older version to fix regression (#7905) Danny
[5f8aecc] [PAY-2577] Fix nft issues (#7884) Saliou Diallo
[f27c8e1] ⚠️  Upload Saga Typed and Parallel Stems v2 (#7723) Marcus Pasell
[4b4fd9b] fix nullable new fields in collection schema (#7903) Michelle Brier
[d71ec07] [PAY-2568] Add access field to playlists (#7894) Andrew Mendelsohn
[63ca5d4] Fix EM parsing of ddex fields (#7900) Michelle Brier
[921a19e] Add undefined check to sentry navigator and remove profile page route (#7898) Kyle Shanks
[73994e0] Add markdown-to-jsx to web (#7899) Dylan Jeffers
[474a902] Remove is_downloadable from trending query (#7896) Reed
[3fb1624] Fix collection search ranking in common (#7855) Isaac Solo
[2a0a663] [C-3561] Remove playback delay on native (#7893) Dylan Jeffers
[28f1150] Fix DDEX e2e tests (#7871) Michelle Brier
[78add43] [Mediorum] [Discovery] Change `/services` protodash routes to `/nodes` (#7864) nicoback2
[8fb1fd9] [SDK] Enable User to User Grants [PAY-2544] (#7889) nicoback2
[184c576] [Discovery] Enable user to user grants ("delegated writes") aka manager mode [PAY-2544] (#7890) nicoback2
[a9b4c5e] Add missing containers for DDEX Docker build (#7891) Theo Ilie
[e7b08ab] [C-4040, C-4032] Fix play cls, Fix pause on track screen (#7888) Dylan Jeffers
[c876ae7] [C-4031, C-4039] Fix add to collection, Add fuzzy search (#7887) Dylan Jeffers
[05a0bb3] Bump version to 0.6.63 audius-infra
[93fed47] Fix discovery ddex fields (#7885) Michelle Brier
[2f5f717] [C-4009] Remove stems styles and package (#7876) Dylan Jeffers
[38e3a87] [C-4034] Fix feed tip tile (#7886) Dylan Jeffers
[e4982a3] Bump mobile version for full-app-release (#7879) Dylan Jeffers
[050a1b3] [C-4014] Fix red chat icons (#7882) Dylan Jeffers
[f1edefd] [INF-672] Improve create-audius-app speed (#7866) Sebastian Klingler
[c4ca5ca] [C-4025] Update profile page for ssr (#7881) Kyle Shanks
[fdbcafc] fix solana relay build (#7872) alecsavvy
[f84715f] Ignore sentry errors for probers (#7870) Marcus Pasell
[2f17f53] Change loglevel to error in TransactionHandler _locallyConfirmTransaction (#7878) Reed
[aeed7a3] [PROTO-1700] Update DDEX UI for batches and improved schema (#7877) Theo Ilie
[062814a] [C-3958] Add StaticImage component and update track artwork rendering on web and mobile-web track pages for ssr (#7847) Kyle Shanks
[a7e4c14] [C-4003] Fix sign up overflow issues on small devices (#7868) JD Francis
[cb27af1] Misc Sign Up QA fixes (#7869) JD Francis
[c259739] Bump version to 0.6.62 audius-infra
[1d4f278] [C-4006] Remove all stems components (#7861) Dylan Jeffers
[efb2b44] Fix audius-cmd test (#7874) Saliou Diallo
[e32d515] Revert "Persist unused DDEX fields in discovery (#7862)" (#7873) Marcus Pasell
[bd822ac] Add fixed-decimal to web deps and update version in libs (#7867) Reed
[02b67d9] Document local audius-compose DDEX steps (#7865) Theo Ilie
[f6bc750] Persist unused DDEX fields in discovery (#7862) Michelle Brier
[e892314] [Protocol Dashboard] Requested changes to new Protocol Dashboard [C-4013] (#7863) nicoback2
[ed08d93] Related artists in sql (#7857) Steve Perkins
[6cad61d] [C-3953] Perma-dismiss purple select artists banner on mobile (#7790) JD Francis
[4cafd23] Bump version to 0.6.61 audius-infra
[075f483] [PAY-2348][PAY-2317] Remove download json field from track metadata (#7784) Saliou Diallo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants