Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[PAY-1727] USDC Withdrawals saga pt. 1 #3932

Merged
merged 10 commits into from
Aug 25, 2023
Merged

[PAY-1727] USDC Withdrawals saga pt. 1 #3932

merged 10 commits into from
Aug 25, 2023

Conversation

dharit-tan
Copy link
Contributor

@dharit-tan dharit-tan commented Aug 23, 2023

Description

Part 1 takes us through swapping USDC for sol on the sender's side, in the case of a fresh account with no USDC ATA.

Also updates Jupiter service to handle ExactOut swapmode.

Scope creep: added a libs and solana web service and updated BuyAudio and WithdrawUSDC services to use those.

There are a few TODOs

  • Handling existing sol balances
  • Handling funding of root solana account

Dragons

How Has This Been Tested?

Manually inspected instructions/logs to verify behavior against the POC script.
Did not test against relay bc relay won't accept it yet.

How will this change be monitored?

For features that are critical or could fail silently please describe the monitoring/alerting being added.

Feature Flags

This flow will only be launchable from USDC UI which should all be feature-flagged.

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.

Overall looks good. Might want another pair of eyes since I'm only moderately familiar with how all of this works.

import { getRootSolanaAccount, getSolanaConnection } from './BuyAudio'

// @ts-ignore
const libs = (): AudiusLibs => window.audiusLibs
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the ignore for?

Copy link
Contributor

Choose a reason for hiding this comment

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

Second thought:

I'm wondering if we should discuss a plan for what our direction is for libs/backend stuff. I only mention it because this file differs from the pattern in solana.ts where a backend instance is passed in, each function that needs lib is written in dependency injection style, and functions wait on libs directly. In this file, we're reading it directly off the window instead of dependency-injecting the backend instance.
I can see pros and cons to both ways. And I think ultimately we're trying to get to a place where we can have most code use a well-typed libs instance that doesn't require using overrides (!) and ignores in various places to get around the fact that we can't be sure the instance is correctly initialized 😞 .

One additional argument for the DI route, though it's a bit tedious, is that we aren't directly bound to reading something off the window. Which would make things slightly more testable if/when we get to that point.

Anyway, a lot of text to say that maybe if we aren't going to actually use a backend instance here, we should move it out of the audius-backend subfolder and up to its own folder in services.

Thoughts?
cc @rickyrombo

Copy link
Contributor

Choose a reason for hiding this comment

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

good call, I think most of these should probably live under a solana folder instead

packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/rt-usdc-saga

packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
)

// Destination is a sol address - check for ATA
if (isDestinationSolAddress) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if has no else - intentional? TODO?

packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
import { getRootSolanaAccount, getSolanaConnection } from './BuyAudio'

// @ts-ignore
const libs = (): AudiusLibs => window.audiusLibs
Copy link
Contributor

Choose a reason for hiding this comment

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

good call, I think most of these should probably live under a solana folder instead

packages/web/src/services/audius-backend/WithdrawUSDC.ts Outdated Show resolved Hide resolved
@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/rt-usdc-saga

@audius-infra
Copy link
Collaborator

It looks like there may be some changes to native mobile code, which requires triggering a full app release. Please follow the instructions here: https://www.notion.so/audiusproject/When-to-bump-app-version-2644a8f772364a4d91f44abcba44ce0b?pvs=4. cc @nicoback2 @sliptype

@socket-security
Copy link

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: @audius/sdk@3.0.3, eth-sig-util@2.5.4, web3@1.7.1, web3-utils@1.7.1

@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/rt-usdc-saga

@@ -10,8 +10,8 @@ import { AudiusBackend } from './AudiusBackend'
const DEFAULT_RETRY_DELAY = 1000
const DEFAULT_MAX_RETRY_COUNT = 120

type MintName = 'audio' | 'usdc'
const DEFAULT_MINT: MintName = 'audio'
export type MintName = 'audio' | 'usdc'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Let's pull this from libs if possible?

/**
* Gets the current user's root solana account.
*/
export const getRootSolanaAccount = async () => {
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 need to change, but https://github.com/AudiusProject/audius-client/pull/3932/files#diff-c4178e3bf5f830edcb482f8b60bb9b6ad94318d3ea2ff009db38fd717e924269R26

Seems like a lot of these are dupes of what's in common/audius-backend actually

@audius-infra
Copy link
Collaborator

It looks like there may be some changes to native mobile code, which requires triggering a full app release. Please follow the instructions here: https://www.notion.so/audiusproject/When-to-bump-app-version-2644a8f772364a4d91f44abcba44ce0b?pvs=4. cc @nicoback2 @sliptype

@audius-infra
Copy link
Collaborator

Preview this change https://demo.audius.co/rt-usdc-saga

@dharit-tan dharit-tan merged commit 337f80f into main Aug 25, 2023
2 checks passed
@dharit-tan dharit-tan deleted the rt-usdc-saga branch August 25, 2023 19:27
audius-infra pushed a commit that referenced this pull request Aug 26, 2023
[b39cb5d] [PAY-1733] Remove Gated Prompt Modal (#3948) Marcus Pasell
[a522294] [PAY-1748][PAY-1731][PAY-1729][PAY-1730] DMs link fixes (#3946) Marcus Pasell
[adea357] quick linting fix (#3945) Kyle Shanks
[a0ff27c] Add embed cloudflare deployment and CI (#3940) Raymond Jacobson
[337f80f] [PAY-1727] USDC Withdrawals saga pt. 1 (#3932) Reed
[5bf820c] [C-2956] Add new Access & Sale modal to legacy upload form (#3900) Andrew Mendelsohn
[5258675] [C-2986] Upload flow qa round 1 (#3941) Kyle Shanks
[dd30c09] Use does_current_user_subscribe API field (#3943) Michelle Brier
[778a518] [C-2987] Add UserGeneratedText (#3942) Dylan Jeffers
[bb9e0cf] Update pull_request_template.md (#3939) Raymond Jacobson
[930dd1a] [C-2977] Fix collection page seo (#3936) Dylan Jeffers
[1e50b85] Update README.md (#3911) sabrina-kiam
[687fd28] Add lint check for console.log and remove some bad ones (#3930) Raymond Jacobson
[9f67e7b] [C-2968] Fix private collection action buttons (#3937) Dylan Jeffers
[7ab7a38] Fix canonical url consistency (#3938) Dylan Jeffers
[b1fbef8] [C-2689] Add upload confirmation modal (#3934) Kyle Shanks
[eb41fd3] [C-2966] Make sure that collection description limits are set to 1000 (#3935) Kyle Shanks
[6258484] Move sitemap hostname back to audius.co (#3931) Raymond Jacobson
[1e0c335] Client uses cids in requests to CN for images (#3882) Michelle Brier
[7974acc] Add library albums and playlists audius-query hook + migrate collection reformat util; bump SDK PAY-1679 (#3864) nicoback2
[7cba35b] [C-2982] Fix seo based on ahref recommendations (#3929) Dylan Jeffers
[05744b3] Migrate withdraw USDC saga to web common (#3928) Reed
[5d01710] USDC Withdrawal saga scaffolding (#3926) Reed
[4e0c480] Fix useAllPaginated query C-2980 (#3924) nicoback2
[21eb35c] Fix infinite scrolling cards C-2979 (#3923) nicoback2
[0025261] [PAY-1632] Clean up and improve performance of music confetti (#3921) Raymond Jacobson
[7ed2248] Revert "Update twitter icon on mobile (#3880)" (#3925) Reed
[1091934] [PAY-1742] Remove useMetaMask on invalid account (#3920) Raymond Jacobson
[6e303b1] [PAY-1741] Add routes for transactional pages (#3916) Randy Schott
[74cdb3c] Remove ontouchstart from index.html (#3919) Raymond Jacobson
[1a0332c] Improve lighthouse score (#3918) Raymond Jacobson
[a63896f] [PAY-1706] Merge modalsWithState with modals in common store (#3908) Marcus Pasell
[6a08944] [C-2976] Fix profile-page seo (#3912) Dylan Jeffers
[2381d46] Fix account details css (#3917) Raymond Jacobson
[8c24bdd] Fix mobile share of playlist permalink (#3913) sabrina-kiam
[1e376fe] [C-2911] Update new select page of the upload flow (#3910) Kyle Shanks
[bc0226f] Fix stripe modal opening behavior (#3914) Raymond Jacobson
[a3219c3] [C-2975] Fix stale local data (#3915) Dylan Jeffers
[748fdfd] PAY-1724 Add color specialGreen on mobile (#3909) Reed
[5c59fe5] [PAY-1628] Navigate to track after purchase (#3904) Randy Schott
schottra added a commit that referenced this pull request Aug 28, 2023
* origin/main:
  Fix Share to IG/T/S sticker consistency [C-3009] (#3949)
  v1.5.39
  [PAY-1733] Remove Gated Prompt Modal (#3948)
  [PAY-1748][PAY-1731][PAY-1729][PAY-1730] DMs link fixes (#3946)
  quick linting fix (#3945)
  Add embed cloudflare deployment and CI (#3940)
  [PAY-1727] USDC Withdrawals saga pt. 1 (#3932)
  [C-2956] Add new Access & Sale modal to legacy upload form (#3900)
  [C-2986] Upload flow qa round 1 (#3941)
  Use does_current_user_subscribe API field (#3943)
  [C-2987] Add UserGeneratedText (#3942)
  Update pull_request_template.md (#3939)
  [C-2977] Fix collection page seo (#3936)
  Update README.md (#3911)
@AudiusProject AudiusProject deleted a comment from linear bot Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants