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

Commit

Permalink
[PAY-1727] USDC Withdrawals saga pt. 1 (#3932)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Aug 25, 2023
1 parent 5bf820c commit 337f80f
Show file tree
Hide file tree
Showing 18 changed files with 507 additions and 412 deletions.
88 changes: 44 additions & 44 deletions packages/common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"url": "https://github.com/AudiusProject/audius-client/issues"
},
"dependencies": {
"@audius/sdk": "3.0.7-beta.0",
"@audius/sdk": "3.0.7-beta.3",
"@fingerprintjs/fingerprintjs-pro": "3.5.6",
"@metaplex-foundation/mpl-token-metadata": "2.5.2",
"@optimizely/optimizely-sdk": "4.0.0",
Expand Down
44 changes: 3 additions & 41 deletions packages/common/src/services/audius-backend/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { AudiusBackend } from './AudiusBackend'
const DEFAULT_RETRY_DELAY = 1000
const DEFAULT_MAX_RETRY_COUNT = 120

type MintName = 'audio' | 'usdc'
const DEFAULT_MINT: MintName = 'audio'
// TODO: Import from libs https://linear.app/audius/issue/PAY-1750/export-mintname-and-default-mint-from-libs
export type MintName = 'audio' | 'usdc'
export const DEFAULT_MINT: MintName = 'audio'

type UserBankConfig = {
ethAddress?: string
Expand All @@ -23,45 +24,6 @@ const delay = (ms: number) =>
setTimeout(resolve, ms)
})

export const isValidSolDestinationAddress = async (
audiusBackendInstance: AudiusBackend,
destinationWallet: SolanaWalletAddress
) => {
const audiusLibs: AudiusLibs = await audiusBackendInstance.getAudiusLibs()
const solanaweb3 = audiusLibs.solanaWeb3Manager?.solanaWeb3
if (!solanaweb3) {
console.error('No solana web3 found')
return false
}
try {
// @ts-ignore - need an unused variable to check if the destinationWallet is valid
const ignored = new solanaweb3.PublicKey(destinationWallet)
return true
} catch (err) {
console.debug(err)
return false
}
}

export const isSolWallet = async (
audiusBackendInstance: AudiusBackend,
destinationWallet: SolanaWalletAddress
) => {
const audiusLibs: AudiusLibs = await audiusBackendInstance.getAudiusLibs()
const solanaweb3 = audiusLibs.solanaWeb3Manager?.solanaWeb3
if (!solanaweb3) {
console.error('No solana web3 found')
return false
}
try {
const destination = new solanaweb3.PublicKey(destinationWallet)
return solanaweb3.PublicKey.isOnCurve(destination.toBytes())
} catch (err) {
console.debug(err)
return false
}
}

export const getRootSolanaAccount = async (
audiusBackendInstance: AudiusBackend
) => {
Expand Down
Loading

0 comments on commit 337f80f

Please sign in to comment.