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

[PAY-2337] Purchase Tracks via SDK: sdk.tracks.purchase() #8278

Merged
merged 33 commits into from
May 8, 2024

Conversation

rickyrombo
Copy link
Contributor

@rickyrombo rickyrombo commented Apr 30, 2024

Description

Adds support for purchasing stream access to tracks using the SDK.

Currently defaults to using the user's userbank (if exists) unless a wallet adapter is passed to the method.

How Has This Been Tested?

Tested locally with new audius-cmd purchase-track

Copy link

changeset-bot bot commented Apr 30, 2024

🦋 Changeset detected

Latest commit: f6769b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@audius/sdk Minor
@audius/spl Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/mjp-sdk-purchase-access

Base automatically changed from mjp-swagger-to-openapi to main May 2, 2024 01:20
Copy link

gitguardian bot commented May 2, 2024

⚠️ GitGuardian has uncovered 10 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
4714545 Triggered Generic High Entropy Secret bb5d992 packages/libs/src/sdk/config/development.ts View secret
10622417 Triggered Generic High Entropy Secret bb5d992 packages/libs/src/sdk/config/development.ts View secret
1606950 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/production.ts View secret
2416685 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/staging.ts View secret
2460750 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/production.ts View secret
4714545 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/development.ts View secret
7150224 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/staging.ts View secret
10622416 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/staging.ts View secret
10622416 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/production.ts View secret
10622417 Triggered Generic High Entropy Secret 679a5b9 packages/libs/src/sdk/config/development.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@rickyrombo rickyrombo changed the title First iteration of sdk.full.tracks.purchaseStreamAccess() [PAY-2337] Purchase Tracks via SDK: sdk.tracks.purchase() May 6, 2024
@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/mjp-sdk-purchase-access

@rickyrombo rickyrombo marked this pull request as ready for review May 6, 2024 23:05
@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/mjp-sdk-purchase-access

Copy link
Member

@raymondjacobson raymondjacobson left a comment

Choose a reason for hiding this comment

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

huge if true

@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/mjp-sdk-purchase-access

@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/mjp-sdk-purchase-access

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.

Big lift!
No major complaints, just a lot of musings.

middleware: [
{
pre: async (context) => {
const endpoint = 'http://audius-protocol-discovery-provider-1'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we use any kind of env var or programmatic generation of this we could leverage? Feels like an easy way to get frustrated if something happens to change or you're running multiple DNs locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

open to ideas - ideally this is temporary until we use relays broadly across nodes

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't have any good recommendations at the moment, just wanted to call it out in case you did! 😄

@@ -150,7 +150,7 @@ class Track(Resource):
@cache(ttl_sec=5)
def get(self, track_id):
decoded_id = decode_with_abort(track_id, ns)
return get_single_track(decoded_id, None, ns)
return get_single_track(decoded_id, None, ns, exclude_gated=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a small change that could have a big impact to any client flows that are using it and not expecting gated tracks to come back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is definitely true, and the only part of this change that makes me somewhat nervous - I need to double check where (if anywhere) we hit this endpoint in our client. I suspect it's nowhere but good to be sure.

}

let extraAmount = USDC(extraAmountNumber).value
const total = USDC(centPrice / 100.0).value + extraAmount
Copy link
Contributor

Choose a reason for hiding this comment

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

Every time we write one of these I get a slight bit more anxious that we'll mess one up 😅

'crateTransferInstruction',
CreateTransferInstructionSchema
)(params)
const mint = this.mints[args.mint]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's interesting that some of our utilities/program clients default to a mint and others don't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

none of the clients should? where are you seeing that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me rephrase 😅
It looks like this client expects you to pass a mint and doesn't default to something. But I may have missed where it's default-initialized (and I would assume it defaults to usdc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's desirable for the clients to default to a mint, personally. The apis should be explicit imo

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay. I had thought I saw in other clients we defined here that they did default (Maybe claimable tokens defaulting to waudio?). But I agree with you that they shouldn't, and if I'm imagining things then great!

@rickyrombo rickyrombo merged commit 75169cf into main May 8, 2024
14 of 27 checks passed
@rickyrombo rickyrombo deleted the mjp-sdk-purchase-access branch May 8, 2024 04:27
audius-infra pushed a commit that referenced this pull request May 8, 2024
[75169cf] [PAY-2337] Purchase Tracks via SDK: sdk.tracks.purchase() (#8278) Marcus Pasell
[1cef77a] Add image url to response for developer app request (#8387) Raymond Jacobson
[72c8171] misc ddex cleanup (#8368) Michelle Brier
audius-infra pushed a commit that referenced this pull request May 11, 2024
[42e9679] [PAY-2995] Fix stream_conditions in saved and library fetch (#8442) Andrew Mendelsohn
[ea3beb9] Fix coinflow default (#8443) Raymond Jacobson
[64fc7fa] [PAY-2975] Fix mobile-web premium album overflow options (#8441) Reed
[ebb531b] [C-4384][C-4383] Small web mobile UI fixes (#8440) Isaac Solo
[692df26] [PAY-2966] Add purchase track to mobile collection tracklist overflow (#8429) Reed
[0371ee2] re-do placement_hosts field (#8438) Steve Perkins
[c6ae1a3] [QA-1268] Fix sentry upload (#8432) Dylan Jeffers
[682bfea] [QA-1253] Improve details tile layout (#8433) Dylan Jeffers
[1561eba] [QA-1251] Fix short lineup playback issues. (#8402) Dylan Jeffers
[8351cba] fix ddex playlists UI (#8435) Michelle Brier
[cc2da2c] [PAY-2965, PAY-2968, PAY-2963] Album upload copy fixes; remove 'hidden' option (#8428) Andrew Mendelsohn
[7e25f1d] [PAY-2786] Clean up skeletons for collection page (#8427) Andrew Mendelsohn
[abc2def] Fix dog ear pt 3 (#8420) JD Francis
[0b01e5a] QA-1260: change content title to not say track (#8436) alecsavvy
[51733b8] [Web] Implement Remove Manager flows [Manager Mode ] [PAY-2827] (#8413) nicoback2
[c0d1d99] [Web] [Common] Accounts You Manage flows; hook up Accounts Managing You to API (#8301) nicoback2
[92a7937] [QA-1267] Fix blank android tip screen (#8430) Dylan Jeffers
[e9a66b1] [QA-1259] Restrict OTP spam (#8426) Dylan Jeffers
[102197f] [PAY-2985] Fix squished art in purchase modal (#8423) Reed
[9103d7c] [PAY-2960] Change library filter title to Premium (#8422) Reed
[7acb56c] Fix web-test by resolving circular import (#8418) Sebastian Klingler
[79ffcf4] Revert "Fix dog ear on track page" (#8416) JD Francis
[2983a34] Misc $album fixes (#8393) JD Francis
[71e5257] Fix dog ear on track page (#8406) JD Francis
[212a691] [PAY-2892] Omit albumTrackPrice from data going to backend (#8410) JD Francis
[70be1d7] [PAY-2869] Fix play button on mobile collections default state (#8369) Reed
[96816ad] [INF-694] Run playwright against local stack (#8407) Sebastian Klingler
[51f8462] [PAY-2878] Fix tracks tables right icons (#8412) Reed
[c7e9b46] [PAY-2890] Fix hover state on CollectionCard title (#8405) Reed
[d45b535] Cleanup user auth config (#8411) Marcus Pasell
[a3d41af] [QA-844] Fix misaligned bio links (#8399) Dylan Jeffers
[8d2fe53] [PAY-2895] Add native collection card (#8367) Dylan Jeffers
[1e1d569] Run SDK gen script as user to allow deletes (#8316) Marcus Pasell
[55f127a] [C-4344][C-4352] Fix empty rewards mobile crashing (#8403) Isaac Solo
[0b82d23] [PAY-2867] Fix native DMs allowing purchase button to show after purchase (#8392) JD Francis
[bcaac19] [PAY-2883] Disable links in purchase modal during purchase (#8388) Reed
[535d5d3] [PAY-2865] Mobile web collection page fixes (#8398) Andrew Mendelsohn
[11a3837] [QA-1248] Fix search header width (#8381) Dylan Jeffers
[359bb4e] [PAY-2902][PAY-2903][PAY-2901] Fix miscellaneous rewards issues (#8395) Saliou Diallo
[75169cf] [PAY-2337] Purchase Tracks via SDK: sdk.tracks.purchase() (#8278) Marcus Pasell
[c44d02c] Play with RNTP buffer settings (#8328) Raymond Jacobson
[9cca4d5] [PAY-2868] Hide count stats if all zeros (#8396) Andrew Mendelsohn
[cb43f96] [PAY-2871] Track table link to track even when it's gated (#8394) Andrew Mendelsohn
[c7648c9] Disable failing audius-sdk test (#8386) Marcus Pasell
[1254030] [PAY-2773] Remove embed option for premium albums (#8391) Andrew Mendelsohn
[ef7c0d0] [PAY-2900] Fix collection upload/edit layout (#8390) Andrew Mendelsohn
[f8bfef3] [PAY-2637] Update audio balance on successful rewards claim (#8377) Saliou Diallo
[36f1367] [PAY-2893] Fix FilterButton dark mode selection text color (#8389) Reed
[a80792e] [PAY-2889] Fix edit collection unlisted value (#8358) Andrew Mendelsohn
[415f65b] [PAY-2896][PAY-2908][PAY-2907] Update claim all button text logic (#8376) Saliou Diallo
[1ed7651] [PAY-2899] Fix collection header title becoming centered (#8385) Reed
[1f7abd7] [PAY-2824] Make Collection play button large (#8384) Reed
[270ceaa] [PAY-2886] Fix artist dashboard border radii (#8383) Reed
[e2f7dfe] [QA-955] Dismiss keyboard when clicking external link (#8375) Dylan Jeffers
[4c86327] [QA-1214] Fix slider border radius (#8379) Dylan Jeffers
[ff98977] [QA-1242] Fix play correct track (#8373) Dylan Jeffers
[15dee1f] [QA-1239] Fix collection loading state (#8371) Dylan Jeffers
[c23549c] [PAY-2722] Add account switcher (#8269) Randy Schott
[672a1b1] Bump versions (#8372) Raymond Jacobson
[12f0efe] [PAY-2885] Remove require statements on encoded params (#8366) Raymond Jacobson
[39dbbb3] Fix mobile lint on main (#8365) Reed
[2062cfb] [PAY-2887] Fix purchase notification twitter share copy (#8364) Andrew Mendelsohn
[d88f0ab] [PAY-2809] Mobile premium album tracklist UI updates (#8351) Reed
[7e3e25b] [PAY-2879] Add purchased pill to mobile albums library (#8363) Andrew Mendelsohn
[435c15f] [PAY-2806] Fix offline downloads legacy content node selection (#8362) Andrew Mendelsohn
[6485633] QA-1093: fix upload button dark mode (#8359) alecsavvy
[009c0e8] [C-4338] Fix $AUDIO available to claim (#8350) Isaac Solo
[f411ae5] [PAY-2763] Remove dividers on mobile collection screens (#8353) Reed
[7108530] Fix wallet matches check (#8360) Raymond Jacobson
[757055a] [PAY-2881] Fix access & sale showing hidden by default (#8352) JD Francis
[e5ba7a9] [C-4077] Migrate HelpCallout to Hint (#8349) Dylan Jeffers
[50bd5c2] [PAY-2814] Omit favorite and repost buttons for unowned albums (#8357) Andrew Mendelsohn
[f8db460] [C-4339] Fix rewards progress label formatting (#8354) Isaac Solo
[a057115] [PAY-2888] Fix dog ear positioning (#8356) JD Francis
[fdd027c] [PAY-2866] Fix duration showing 0m 0s (#8355) JD Francis
[a3797cf] [PAY-2864] Fix progress label for reward on native (#8348) Saliou Diallo
[a141f70] [QA-1240] Fix hover state on upload completion (#8341) Raymond Jacobson
[deaface] [PAY-2784] Fix premium album upload with download toggle disabled (#8339) JD Francis
[8447d73] Fix profile page artist vs user (#8347) Dylan Jeffers
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.

None yet

5 participants