Skip to content

Commit

Permalink
remove unused exports from apiClient and audiusBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra committed May 9, 2024
1 parent bc34a2c commit afc2644
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 224 deletions.
47 changes: 0 additions & 47 deletions packages/common/src/services/audius-api-client/AudiusAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ const FULL_ENDPOINT_MAP = {
userTracksByHandle: (handle: OpaqueID) => `/users/handle/${handle}/tracks`,
userAiTracksByHandle: (handle: OpaqueID) =>
`/users/handle/${handle}/tracks/ai_attributed`,
userFavoritedTracks: (userId: OpaqueID) =>
`/users/${userId}/favorites/tracks`,
userRepostsByHandle: (handle: OpaqueID) => `/users/handle/${handle}/reposts`,
getRelatedArtists: (userId: OpaqueID) => `/users/${userId}/related`,
getPlaylist: (playlistId: OpaqueID) => `/playlists/${playlistId}`,
Expand Down Expand Up @@ -279,16 +277,6 @@ type GetFavoritesArgs = {
limit?: number
}

type GetProfileListArgs = {
profileUserId: ID
currentUserId: Nullable<ID>
limit?: number
offset?: number
query?: string
sortMethod?: string
sortDirection?: string
}

type GetTopArtistGenresArgs = {
genres?: string[]
limit?: number
Expand Down Expand Up @@ -1184,41 +1172,6 @@ export class AudiusAPIClient {
return data.map(adapter.makeFavorite).filter(removeNullable)
}

async getFavoritedTracks({
profileUserId,
currentUserId,
limit,
offset,
query,
sortMethod,
sortDirection
}: GetProfileListArgs) {
this._assertInitialized()
const encodedUserId = encodeHashId(currentUserId)
const encodedProfileUserId = this._encodeOrThrow(profileUserId)
const params = {
user_id: encodedUserId || undefined,
limit,
offset,
...(query && { query }),
...(sortMethod && { sort_method: sortMethod }),
...(sortDirection && { sort_direction: sortDirection })
}

const response = await this._getResponse<APIResponse<APIActivity[]>>(
FULL_ENDPOINT_MAP.userFavoritedTracks(encodedProfileUserId),
params
)

if (!response) return null

const adapted = response.data.map(({ item, ...props }) => ({
timestamp: props.timestamp,
track: adapter.makeTrack(item as APITrack)
}))
return adapted
}

async getUserRepostsByHandle({
handle,
currentUserId,
Expand Down
177 changes: 0 additions & 177 deletions packages/common/src/services/audius-backend/AudiusBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,10 +824,6 @@ export const audiusBackend = ({
return audiusLibs.creatorNode.setEndpoint(endpoint)
}

async function listCreatorNodes() {
return audiusLibs.ServiceProvider.listCreatorNodes()
}

async function getAccount() {
await waitForLibsInit()
try {
Expand Down Expand Up @@ -1004,89 +1000,12 @@ export const audiusBackend = ({
}
}

// Uploads a single track
// Returns { trackId, error, phase }
async function uploadTrack(
trackFile: File,
coverArtFile: File,
metadata: TrackMetadata,
onProgress: (loaded: number, total: number) => void,
trackId?: number
) {
try {
const {
trackId: updatedTrackId,
updatedMetadata,
txReceipt
} = await audiusLibs.Track.uploadTrackV2AndWriteToChain(
trackFile,
coverArtFile,
metadata,
onProgress,
trackId
)
// Return with properties that confirmer expects
return {
blockHash: txReceipt.blockHash,
blockNumber: txReceipt.blockNumber,
trackId: updatedTrackId,
transcodedTrackCID: updatedMetadata.track_cid,
error: false
}
} catch (e: any) {
return { error: e }
}
}

// Used to upload multiple tracks as part of an album/playlist.
// V2: Returns { metadataMultihash, updatedMetadata }
// LEGACY: Returns { metadataMultihash, metadataFileUUID, transcodedTrackCID, transcodedTrackUUID, metadata }
async function uploadTrackToCreatorNode(
trackFile: File,
coverArtFile: File,
metadata: TrackMetadata,
onProgress: (loaded: number, total: number) => void
) {
const updatedMetadata = await audiusLibs.Track.uploadTrackV2(
trackFile,
coverArtFile,
metadata,
onProgress
)
return {
metadata: updatedMetadata,

// We don't need these properties, but the confirmer expects them.
// TODO (theo): Remove after v2 is fully rolled out and v1 is removed
transcodedTrackCID: updatedMetadata.track_cid,
metadataMultihash: '',
metadataFileUUID: '',
transcodedTrackUUID: ''
}
}

async function getUserEmail(): Promise<string> {
await waitForLibsInit()
const { email } = await audiusLibs.Account.getUserEmail()
return email
}

/**
* Adds tracks to chain for this user.
* Associates tracks with user on creatorNode if in legacy flow (non storage v2).
*/
async function registerUploadedTracks(
uploadedTracks: {
metadataMultihash: string
metadataFileUUID: string
metadata: TrackMetadata
}[]
) {
return await audiusLibs.Track.addTracksToChainV2(
uploadedTracks.map((t) => t.metadata)
)
}

async function uploadImage(file: File) {
return await audiusLibs.creatorNode.uploadTrackCoverArtV2(file, () => {})
}
Expand Down Expand Up @@ -1262,16 +1181,6 @@ export const audiusBackend = ({
}
}

async function updateIsVerified(userId: ID, verified: boolean) {
try {
await audiusLibs.User.updateIsVerified(userId, verified)
return true
} catch (err) {
console.error(getErrorMessage(err))
return false
}
}

async function followUser(followeeUserId: ID) {
try {
return await audiusLibs.EntityManager.followUser(followeeUserId)
Expand Down Expand Up @@ -1474,23 +1383,6 @@ export const audiusBackend = ({
}
}

// TODO(C-2719)
async function getSavedTracks(limit = 100, offset = 0) {
try {
return withEagerOption(
{
normal: (libs) => libs.Track.getSavedTracks,
eager: DiscoveryAPI.getSavedTracks
},
limit,
offset
)
} catch (err) {
console.error(getErrorMessage(err))
return []
}
}

// Favoriting a track
async function saveTrack(
trackId: ID,
Expand Down Expand Up @@ -1663,16 +1555,6 @@ export const audiusBackend = ({
}
}

async function handleInUse(handle: string) {
await waitForLibsInit()
try {
const handleIsValid = await audiusLibs.Account.handleIsValid(handle)
return !handleIsValid
} catch (error) {
return true
}
}

async function twitterHandle(handle: string) {
await waitForLibsInit()
try {
Expand Down Expand Up @@ -2875,24 +2757,6 @@ export const audiusBackend = ({
}
}

/**
* Retrieves the claim distribution amount
* @returns {BN} amount The claim amount
*/
async function getClaimDistributionAmount() {
await waitForLibsInit()
const wallet = audiusLibs.web3Manager.getWalletAddress()
if (!wallet) return

try {
const amount = await audiusLibs.Account.getClaimDistributionAmount()
return amount
} catch (e) {
console.error(e)
return null
}
}

/**
* Make a request to fetch the eth AUDIO balance of the the user
* @params {bool} bustCache
Expand Down Expand Up @@ -3067,17 +2931,6 @@ export const audiusBackend = ({
return audiusLibs.web3Manager.sign(data)
}

/**
* Get latest transaction receipt based on block number
* Used by confirmer
*/
function getLatestTxReceipt(receipts: TransactionReceipt[]) {
if (!receipts.length) return {} as TransactionReceipt
return receipts.sort((receipt1, receipt2) =>
receipt1.blockNumber < receipt2.blockNumber ? 1 : -1
)[0]
}

/**
* Transfers the user's ERC20 AUDIO into SPL WAUDIO to their solana user bank account
* @param {BN} balance The amount of AUDIO to be transferred
Expand Down Expand Up @@ -3118,26 +2971,6 @@ export const audiusBackend = ({
return new BN(waudioBalance.toString())
}

async function getAudioTransactionsCount() {
try {
const { data, signature } = await signDiscoveryNodeRequest()
const res = await fetch(
`${currentDiscoveryProvider}/v1/full/transactions`,
{
headers: {
encodedDataMessage: data,
encodedDataSignature: signature
}
}
)
const json = await res.json()
return json
} catch (e) {
console.error(e)
return 0
}
}

/**
* Aggregate, submit, and evaluate attestations for a given challenge for a user
*/
Expand Down Expand Up @@ -3274,29 +3107,25 @@ export const audiusBackend = ({
getAccount,
getAddressTotalStakedBalance,
getAddressWAudioBalance,
getAudioTransactionsCount,
getAddressSolBalance,
getAssociatedTokenAccountInfo,
getAudiusLibs,
getAudiusLibsTyped,
getBalance,
getBrowserPushNotificationSettings,
getBrowserPushSubscription,
getClaimDistributionAmount,
getCollectionImages,
getCreators,
getSocialHandles,
getEmailNotificationSettings,
getFolloweeFollows,
getImageUrl,
getLatestTxReceipt,
getNotifications,
getDiscoveryNotifications,
getPlaylists,
getPushNotificationSettings,
getRandomFeePayer,
getSafariBrowserPushEnabled,
getSavedTracks,
getSignature,
getTrackImages,
getUserEmail,
Expand All @@ -3305,15 +3134,12 @@ export const audiusBackend = ({
getUserSubscribed,
getWAudioBalance,
getWeb3,
handleInUse,
identityServiceUrl,
listCreatorNodes,
markAllNotificationAsViewed,
orderPlaylist,
publishPlaylist,
recordTrackListen,
registerDeviceToken,
registerUploadedTracks,
repostCollection,
repostTrack,
resetPassword,
Expand Down Expand Up @@ -3347,7 +3173,6 @@ export const audiusBackend = ({
updateCreator,
updateEmailNotificationSettings,
updateHCaptchaScore,
updateIsVerified,
updateNotificationSettings,
updatePlaylist,
updatePlaylistLastViewedAt,
Expand All @@ -3358,8 +3183,6 @@ export const audiusBackend = ({
subscribeToUser,
unsubscribeFromUser,
uploadImage,
uploadTrack,
uploadTrackToCreatorNode,
userNodeUrl,
validateTracksInPlaylist,
waitForLibsInit,
Expand Down

0 comments on commit afc2644

Please sign in to comment.