Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions packages/common/src/adapters/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,6 @@ function normalizeActivityItem(
)
}

export const activityFromSDK = (input: Activity) => {
const { timestamp, itemType: item_type, item } = input
if (item_type === ActivityItemTypeEnum.Track) {
const normalized = normalizeActivityItem(item as object, item_type)
return {
timestamp,
item_type,
item: userTrackMetadataFromSDK(normalized as Track)
}
} else if (item_type === ActivityItemTypeEnum.Playlist) {
const normalized = normalizeActivityItem(item as object, item_type)
return {
timestamp,
item_type,
item: userCollectionMetadataFromSDK(normalized as Playlist)
}
}
return undefined
}

export const trackActivityFromSDK = (input: Activity) => {
const { timestamp, itemType: item_type, item } = input
if (item_type === ActivityItemTypeEnum.Track) {
Expand Down
43 changes: 0 additions & 43 deletions packages/common/src/adapters/coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ export const coinFromSdk = (input: CoinSDK | undefined): Coin | undefined => {
}
}

/**
* Converts a list of SDK `Coin` responses to CoinMetadata list
*/
export const coinMetadataListFromSDK = (input?: CoinSDK[]): CoinMetadata[] =>
input ? input.map(coinMetadataFromCoin).filter(removeNullable) : []

/**
* Converts a SDK `UserCoin` response to UserCoin, parsing ownerId from HashId string to number
*/
Expand Down Expand Up @@ -123,40 +117,3 @@ export const coinListFromSDK = (input?: CoinSDK[]): Coin[] =>
*/
export const userCoinListFromSDK = (input?: UserCoinSdk[]): UserCoin[] =>
input ? input.map(userCoinFromSdk).filter(removeNullable) : []

/**
* Creates a map of coins keyed by ticker symbol
*/
export const coinMapFromSDK = (
input?: CoinSDK[]
): Record<string, CoinMetadata> => {
const coinMap: Record<string, CoinMetadata> = {}

if (input) {
input.forEach((coin) => {
const coinMetadata = coinMetadataFromCoin(coin)
if (coinMetadata.ticker) {
coinMap[coinMetadata.ticker] = coinMetadata
}
})
}

return coinMap
}

/**
* Gets all token symbols from a list of coins
*/
export const getTokenSymbolsFromCoins = (coins: CoinMetadata[]): string[] =>
coins.map((coin) => coin.ticker || '').filter(Boolean)

/**
* Gets token mints by symbol from a list of coins
*/
export const getTokenMintsBySymbolsFromCoins = (
coins: CoinMetadata[],
symbols: string[]
): string[] =>
coins
.filter((coin) => coin.ticker && symbols.includes(coin.ticker))
.map((coin) => coin.mint)
12 changes: 4 additions & 8 deletions packages/common/src/adapters/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ export const notificationFromSDK = (
const data = action.data
entityId = HashId.parse(data.entityId)
commentId = OptionalHashId.parse(data.commentId)
// @ts-ignore
entityType = data.type
entityType = data.type as Entity
return HashId.parse(data.commentUserId)
})
.filter(removeNullable)
Expand Down Expand Up @@ -523,8 +522,7 @@ export const notificationFromSDK = (
entityId = HashId.parse(data.entityId)
entityUserId = HashId.parse(data.entityUserId)
commentId = OptionalHashId.parse(data.commentId)
// @ts-ignore
entityType = data.type
entityType = data.type as Entity
return HashId.parse(data.commentUserId)
})
.filter(removeNullable)
Expand All @@ -551,8 +549,7 @@ export const notificationFromSDK = (
entityId = HashId.parse(data.entityId)
entityUserId = HashId.parse(data.entityUserId)
commentId = OptionalHashId.parse(data.commentId)
// @ts-ignore
entityType = data.type
entityType = data.type as Entity
return HashId.parse(data.commentUserId)
})
.filter(removeNullable)
Expand All @@ -577,8 +574,7 @@ export const notificationFromSDK = (
entityId = HashId.parse(data.entityId)
entityUserId = HashId.parse(data.entityUserId)
commentId = OptionalHashId.parse(data.commentId)
// @ts-ignore
entityType = data.type
entityType = data.type as Entity
return HashId.parse(data.reacterUserId)
})
.filter(removeNullable)
Expand Down
12 changes: 0 additions & 12 deletions packages/common/src/adapters/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,3 @@ export const searchResultsFromSDK = (
saved_albums
}
}

export const AUTOCOMPLETE_TOTAL_RESULTS = 3

export const limitAutocompleteResults = (
results: SearchResults,
maxResults: number = AUTOCOMPLETE_TOTAL_RESULTS
): SearchResults => {
return Object.keys(results).reduce((acc, key) => {
acc[key] = results[key].slice(0, Math.min(maxResults, results[key].length))
return acc
}, {} as SearchResults)
}
1 change: 0 additions & 1 deletion packages/common/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export * from './tan-query/purchases/useSalesAggregate'

// Reactions
export * from './tan-query/reactions/types'
export * from './tan-query/reactions/utils'

// Remixes
export * from './tan-query/remixes/useRemixesLineup'
Expand Down
7 changes: 0 additions & 7 deletions packages/common/src/api/tan-query/coins/useCoinPair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,3 @@ export const useCoinPair = (
data: queryResult.data || createFallbackPair()
}
}

// Hook for getting default AUDIO/USDC pair
export const useDefaultTokenPair = (
options?: Partial<ReturnType<typeof getTokenPairOptions>>
) => {
return useCoinPair({ baseSymbol: 'AUDIO', quoteSymbol: 'USDC' }, options)
}
174 changes: 0 additions & 174 deletions packages/common/src/api/tan-query/collection/useUpdateCollection.ts

This file was deleted.

6 changes: 1 addition & 5 deletions packages/common/src/api/tan-query/comments/useComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ import { keyBy } from 'lodash'

import { ID } from '~/models/Identifiers'

import { QueryKey, QueryOptions } from '../types'
import { QueryOptions } from '../types'
import { combineQueryResults } from '../utils/combineQueryResults'
import { useQueries } from '../utils/useQueries'

import { CommentOrReply } from './types'
import { getCommentQueryKey } from './utils'

export const getCommentsQueryKey = (commentIds: ID[] | null | undefined) => {
return ['comments', commentIds] as unknown as QueryKey<CommentOrReply[]>
}

export const useComments = (
commentIds: ID[] | null | undefined,
options?: QueryOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getAllRemixContestsQueryKey = ({

/**
* Hook to fetch all remix contest events with infinite query support.
* Calls the dedicated discovery endpoint `GET /v1/events/remix-contests`
* Calls the dedicated validator node endpoint `GET /v1/events/remix-contests`
* (SDK: `events.getRemixContests`), which returns events ordered with
* currently-active contests first (by soonest-ending end_date) followed by
* ended contests.
Expand Down Expand Up @@ -85,7 +85,7 @@ export const useAllRemixContests = (
})

// Prime related tracks + users (full objects, delivered alongside the
// event list on the discovery endpoint). This turns ContestCard's
// event list on the validator node endpoint). This turns ContestCard's
// useTrack / useUser into cache hits so the grid can paint with one
// network round-trip instead of N+1.
primeRelatedData({ related, queryClient })
Expand Down
Loading
Loading