Skip to content

Commit 7f1bcf3

Browse files
authored
Update sdk with new v1 endpoints and types (#13721)
Adds updated v1 endpoints to sdk, and updates various type issues
1 parent 1c96306 commit 7f1bcf3

299 files changed

Lines changed: 28250 additions & 1988 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/common/src/adapters/coin.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ export const coinFromSdk = (input: CoinSDK | undefined): Coin | undefined => {
5555
// Birdeye data may not be available right after launch.
5656
// Fall back to dynamic bonding curve data if so.
5757
const defaultSupply = 1e9
58+
const dbc = input.dynamicBondingCurve
59+
if (!dbc) {
60+
return undefined
61+
}
5862

59-
const { isMigrated, priceUSD, address } = input.dynamicBondingCurve
63+
const { isMigrated, priceUSD, address } = dbc
6064
const hasBirdeyeSupply =
6165
input.totalSupply !== undefined && input.totalSupply > 0
6266
const hasBirdeyePrice = input.price !== undefined && input.price > 0
@@ -67,14 +71,15 @@ export const coinFromSdk = (input: CoinSDK | undefined): Coin | undefined => {
6771
// For price, use the bonding curve price if the input hasn't graduated or we have no birdeye data
6872
const displayPrice =
6973
(!isMigrated && hasBondingCurveData) || !hasBirdeyePrice
70-
? priceUSD
71-
: input.price
74+
? (priceUSD ?? 0)
75+
: (input.price ?? 0)
7276

7377
// For market cap, use the bonding curve market cap if the input hasn't graduated or we have no birdeye data
7478
const displayMarketCap =
7579
(!isMigrated && hasBondingCurveData) || !hasBirdeyeSupply
76-
? displayPrice * (hasBirdeyeSupply ? input.totalSupply : defaultSupply)
77-
: input.marketCap
80+
? displayPrice *
81+
(hasBirdeyeSupply ? (input.totalSupply ?? 0) : defaultSupply)
82+
: (input.marketCap ?? 0)
7883

7984
const { ownerId: _ignored, ...rest } = input
8085
return {

packages/common/src/adapters/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export const playlistMetadataForUpdateWithSDK = (
206206
? input.playlist_contents.track_ids.map((t) => ({
207207
timestamp: t.time,
208208
trackId: Id.parse(t.track),
209-
metadataTimestamp: t.metadata_time
209+
metadataTimestamp: t.metadata_time ?? 0
210210
}))
211211
: undefined,
212212
playlistName: input.playlist_name ?? '',

packages/common/src/adapters/track.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Genre,
55
Mood,
66
type NativeFile,
7-
type TrackMetadata,
7+
type UpdateTrackRequestBody,
88
HashId,
99
Id,
1010
OptionalHashId,
@@ -260,7 +260,7 @@ const DEFAULT_GENRE = Genre.Electronic
260260

261261
export const trackMetadataForUploadToSdk = (
262262
input: TrackMetadataForUpload
263-
): TrackMetadata => {
263+
): UpdateTrackRequestBody => {
264264
const sdkGenre = toSdkGenre(input.genre)
265265
const genre = sdkGenre ?? DEFAULT_GENRE
266266
return {
@@ -348,7 +348,7 @@ export const trackMetadataForUploadToSdk = (
348348
camelcaseKeys(contributor)
349349
)
350350
: undefined
351-
} as TrackMetadata
351+
} as UpdateTrackRequestBody
352352
}
353353

354354
export const fileToSdk = (

packages/common/src/api/tan-query/coins/useUpdateArtistCoin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const useUpdateArtistCoin = () => {
7171
const response = await sdk.coins.updateCoin({
7272
mint,
7373
userId: Id.parse(currentUserId),
74-
metadata: {
74+
updateCoinRequest: {
7575
description: updateCoinRequest.description,
7676
link1: updateCoinRequest.links?.[0] ?? '',
7777
link2: updateCoinRequest.links?.[1] ?? '',

packages/common/src/api/tan-query/tracks/useFavoritedTracks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const useFavoritedTracks = (
2424
queryKey: getFavoritedTracksQueryKey(userId),
2525
queryFn: async () => {
2626
const sdk = await audiusSdk()
27-
const { data } = await sdk.users.getFavorites({
27+
const { data } = await sdk.users.getUserFavorites({
2828
id: Id.parse(userId)
2929
})
3030

packages/common/src/api/tan-query/upload/usePublishCollection.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
109109
params.collectionMetadata
110110
)
111111
metadata.playlistContents = publishedTracks.map((t) => ({
112-
timestamp: Date.now() / 1000,
113-
trackId: Id.parse(t.trackId)
112+
timestamp: Math.round(Date.now() / 1000),
113+
trackId: Id.parse(t.trackId),
114+
metadataTimestamp: Math.round(Date.now() / 1000)
114115
}))
115116
return await sdk.albums.createAlbum({
116117
userId: Id.parse(userId),
@@ -122,8 +123,9 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
122123
params.collectionMetadata
123124
)
124125
metadata.playlistContents = publishedTracks.map((t) => ({
125-
timestamp: Date.now() / 1000,
126-
trackId: Id.parse(t.trackId)
126+
timestamp: Math.round(Date.now() / 1000),
127+
trackId: Id.parse(t.trackId),
128+
metadataTimestamp: Math.round(Date.now() / 1000)
127129
}))
128130
return await sdk.playlists.createPlaylist({
129131
userId: Id.parse(userId),

packages/common/src/hooks/chats/useAudiusLinkResolver.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ export const useAudiusLinkResolver = ({
140140
data: res.data[0]
141141
}
142142
} else if (instanceOfUserResponse(res)) {
143-
const human = formatUserName({ user: res.data })
144-
linkToHuman[match] = human
145-
humanToData[human] = {
146-
link: match,
147-
type: 'user',
148-
data: res.data
143+
const user = Array.isArray(res.data) ? res.data[0] : res.data
144+
if (user) {
145+
const human = formatUserName({ user })
146+
linkToHuman[match] = human
147+
humanToData[human] = {
148+
link: match,
149+
type: 'user',
150+
data: user
151+
}
149152
}
150153
}
151154
}

packages/common/src/utils/coinMetrics.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,21 @@ export const createCoinMetrics = (coin: Coin): MetricData[] => {
6969
createMetric({
7070
value: formatCurrencyWithSubscript(coin.displayPrice),
7171
label: messages.pricePerCoin,
72-
changePercent: coin.priceChange24hPercent,
72+
changePercent:
73+
(coin as Coin & { priceChange24hPercent?: number })
74+
.priceChange24hPercent ?? undefined,
7375
rawValue: formatCurrency(coin.displayPrice)
7476
}),
7577
createMetric({
76-
value: `$${formatCount(coin.displayMarketCap, 2)}`,
78+
value: `$${formatCount(coin.displayMarketCap ?? 0, 2)}`,
7779
label: messages.marketCap
7880
}),
7981
createMetric({
80-
value: `$${formatCount(coin.totalVolumeUSD, 2)}`,
82+
value: `$${formatCount(coin.totalVolumeUSD ?? 0, 2)}`,
8183
label: messages.totalVolume
8284
}),
8385
createMetric({
84-
value: formatCount(coin.holder),
86+
value: formatCount(coin.holder ?? 0),
8587
label: messages.uniqueHolders
8688
}),
8789
createMetric({

packages/mobile/src/components/core/UserGeneratedText.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ const Link = ({
9999
params: { id: HashId.parse(res.data[0].id) }
100100
})
101101
} else if (instanceOfUserResponse(res)) {
102-
setUnfurledContent(formatUserName({ user: res.data }))
103-
setTo({
104-
screen: 'Profile',
105-
params: { id: HashId.parse(res.data.id) }
106-
})
102+
const user = Array.isArray(res.data) ? res.data[0] : res.data
103+
if (user) {
104+
setUnfurledContent(formatUserName({ user }))
105+
setTo({
106+
screen: 'Profile',
107+
params: { id: HashId.parse(user.id) }
108+
})
109+
}
107110
}
108111
}
109112
}

packages/mobile/src/screens/buy-sell-screen/components/BuyScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export const BuyScreen = ({
148148
onAmountChange={handleOutputAmountChange}
149149
availableBalance={0}
150150
exchangeRate={currentExchangeRate}
151-
tokenPrice={tokenPriceData?.price.toString() ?? null}
151+
tokenPrice={tokenPriceData?.price?.toString() ?? null}
152152
isTokenPriceLoading={isTokenPriceLoading}
153153
tokenPriceDecimalPlaces={decimalPlaces}
154154
availableTokens={availableOutputTokens ?? artistCoins}

0 commit comments

Comments
 (0)