Skip to content

Commit 63f6574

Browse files
dylanjeffersclaude
andcommitted
Update archiver/relay/solana-relay/staking to @audius/sdk ^15.3.1
Brings the four remaining pedalboard plugins still on the old SDK onto ^15.3.1, matching the version anti-abuse-oracle already runs in prod. Plugin bumps: - archiver: 10.0.0 -> ^15.3.1 - relay: 10.0.0 -> ^15.3.1 - solana-relay: 15.1.0 -> ^15.3.1 - staking: 10.0.0 -> ^15.3.1 Source migrations the new SDK requires: - archiver: bare sdk() now exposes only the *generated* TracksApi, which doesn't include getTrackDownloadUrl. Switch the archiver's SDK helper to createSdkWithServices so the extended TracksApi (with getTrackDownloadUrl) is wired up. - relay: bump 10.0.0 -> ^15.3.1, migrate sdk() -> createSdkWithServices so audiusSdk.services.entityManager (decodeManageEntity / recoverSigner) keeps working; switch the AudiusSdk type alias to AudiusSdkWithServices; drop the 'staging' environment value (no longer accepted by the SDK) by routing stage to 'production'. services.entityManager is now typed as optional on AudiusSdkWithServices but is always populated in practice by the SDK's default services, so add ! assertions at the call sites to keep tsc happy. Update the sandbox script to use apiEndpoint for the staging discovery node, and switch users.updateProfile (gone in 15.3.1) to the equivalent users.updateUser({ id, userId, metadata }) shape. - solana-relay, staking: package.json bump only; no source changes (the SDK types they use - FirstBuyQuoteResponse, RelayRequestBody - are still exported, and staking has no @audius/sdk imports in src). Intentionally NOT included: - trending-challenge-rewards: stays at 14.1.0. The bump to 15.3.1 with createSdkWithServices was tried in 044f0e2 and explicitly reverted in 2d9f65d; the revert reason isn't documented but predates this PR, so honoring it. - anti-abuse-oracle: already at ^15.3.1 on main (PR #34); the original PR #20 AAO changes targeted the pre-migration source that no longer exists. Pre-existing main-branch issues not addressed by this PR: - apps/relay/src/middleware/logging.ts(21,5) has a pino Logger<never> type incompatibility introduced by the node 24 upgrade / pino pin commits. Unrelated to the SDK and present without this change. - viem / abitype .d.ts syntax errors under node_modules are flagged by relay's TS 5.0.4 - same as on main, not introduced here. Test plan: - [x] npm install resolves all four plugins to @audius/sdk 15.3.1 - [x] tsc --noEmit on archiver, solana-relay, staking source is clean - [x] relay tsc errors are reduced from ~10 to 1 (the pre-existing pino issue); all 'services does not exist on UsersApi' errors that existed on main are gone - [ ] Smoke test the relay against a stage discovery node to confirm decodeManageEntity / recoverSigner paths still work end-to-end Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 66f6cae commit 63f6574

13 files changed

Lines changed: 511 additions & 686 deletions

File tree

apps/archiver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"test:watch": "vitest"
1515
},
1616
"dependencies": {
17-
"@audius/sdk": "10.0.0",
17+
"@audius/sdk": "^15.3.1",
1818
"@pedalboard/basekit": "*",
1919
"@pedalboard/logger": "*",
2020
"@pedalboard/storage": "*",

apps/archiver/src/sdk.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { sdk } from '@audius/sdk'
1+
import { createSdkWithServices } from '@audius/sdk'
22
import { readConfig, Environment } from './config'
33

44
const environmentToSdkEnvironment: Record<
@@ -9,7 +9,7 @@ const environmentToSdkEnvironment: Record<
99
prod: 'production'
1010
}
1111

12-
let audiusSdk: ReturnType<typeof sdk> | undefined = undefined
12+
let audiusSdk: ReturnType<typeof createSdkWithServices> | undefined = undefined
1313

1414
export const getAudiusSdk = () => {
1515
if (audiusSdk === undefined) {
@@ -19,7 +19,9 @@ export const getAudiusSdk = () => {
1919
// inspectTrack land in the configured app's rps/rpm bucket on the server's
2020
// rate-limit middleware. The raw downloadFile fetch (which bypasses the
2121
// SDK entirely) attaches api_key itself — see downloadFile in utils.ts.
22-
audiusSdk = sdk({
22+
// Use createSdkWithServices (not sdk()) so tracks.getTrackDownloadUrl is
23+
// available — the bare sdk() factory exposes only the generated TracksApi.
24+
audiusSdk = createSdkWithServices({
2325
appName: 'audius-archiver',
2426
environment: environmentToSdkEnvironment[config.environment],
2527
apiKey: config.apiKey

apps/relay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"preset": "jest-presets/jest/node"
1818
},
1919
"dependencies": {
20-
"@audius/sdk": "10.0.0",
20+
"@audius/sdk": "^15.3.1",
2121
"@bufbuild/protobuf": "2.2.3",
2222
"@connectrpc/connect": "2.0.1",
2323
"@connectrpc/connect-node": "2.0.1",

apps/relay/src/coreRelay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const coreRelay = async (
114114
metadata,
115115
subjectSig,
116116
nonce: nonceBytes
117-
} = audiusSdk.services.entityManager.decodeManageEntity(
117+
} = audiusSdk.services.entityManager!.decodeManageEntity(
118118
encodedABI as `0x${string}`
119119
)
120120

apps/relay/src/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { logger } from './logger'
66
import { initializeDiscoveryDb } from '@pedalboard/basekit'
77
import { connectWeb3 } from './web3'
88
import { app } from './server'
9-
import { AudiusSdk, sdk } from '@audius/sdk'
9+
import { AudiusSdkWithServices, createSdkWithServices } from '@audius/sdk'
1010

1111
export type SharedData = {
1212
config: Config
1313
web3: ethers.providers.JsonRpcProvider
14-
sdk: AudiusSdk
14+
sdk: AudiusSdkWithServices
1515
wallets: WalletManager
16-
audiusSdk: AudiusSdk
16+
audiusSdk: AudiusSdkWithServices
1717
}
1818

1919
export const config = readConfig()
@@ -28,17 +28,13 @@ export const discoveryDb = initializeDiscoveryDb(
2828

2929
export let web3: providers.JsonRpcProvider
3030
export let wallets: WalletManager
31-
export let audiusSdk: AudiusSdk
31+
export let audiusSdk: AudiusSdkWithServices
3232

3333
const main = async () => {
34-
audiusSdk = sdk({
34+
audiusSdk = createSdkWithServices({
3535
appName: 'relay',
3636
environment:
37-
config.environment === 'dev'
38-
? 'development'
39-
: config.environment === 'stage'
40-
? 'staging'
41-
: 'production'
37+
config.environment === 'dev' ? 'development' : 'production'
4238
})
4339
try {
4440
// async config

apps/relay/src/middleware/rateLimiter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const rateLimiterMiddleware = async (
9292
}
9393

9494
export const getEntityManagerActionKey = (encodedABI: string): string => {
95-
const decodedABI = audiusSdk.services.entityManager.decodeManageEntity(
95+
const decodedABI = audiusSdk.services.entityManager!.decodeManageEntity(
9696
encodedABI as `0x${string}`
9797
)
9898
const { action, entityType } = decodedABI

apps/relay/src/middleware/validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export const retrieveUser = async (
195195
// if entitymanager transaction, recover signer
196196
if (contractRegistryKey === 'EntityManager') {
197197
const recoveredAddress =
198-
await audiusSdk.services.entityManager.recoverSigner(
198+
await audiusSdk.services.entityManager!.recoverSigner(
199199
encodedABI as `0x${string}`
200200
)
201201

@@ -232,7 +232,7 @@ export const retrieveDeveloperApp = async (params: {
232232
contractAddress: string
233233
}): Promise<DeveloperApps | undefined> => {
234234
const { encodedABI } = params
235-
const recoveredAddress = await audiusSdk.services.entityManager.recoverSigner(
235+
const recoveredAddress = await audiusSdk.services.entityManager!.recoverSigner(
236236
encodedABI as `0x${string}`
237237
)
238238
return await discoveryDb<DeveloperApps>(Table.DeveloperApps)

apps/relay/src/scripts/sandbox.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ export const main = async () => {
1919

2020
const audiusSdk = sdk({
2121
appName: 'experimentalDiscoveryRelay',
22-
apiKey,
23-
apiSecret,
24-
environment: 'staging'
22+
apiKey: apiKey!,
23+
apiSecret: apiSecret!,
24+
environment: 'production',
25+
apiEndpoint: 'https://discoveryprovider.staging.audius.co'
2526
})
2627
const { data } = await audiusSdk.users.getUserByHandle({
2728
handle: 'totallynotalec'
2829
})
2930
const userId = data?.id!
30-
const res = await audiusSdk.users.updateProfile({
31+
const res = await audiusSdk.users.updateUser({
32+
id: userId,
3133
userId,
3234
metadata: {
3335
bio: `identity has no reigns on me ${new Date().getTime()}`

apps/relay/src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { audiusSdk } from '.'
22

33
export const isUserCreate = (encodedABI: string): boolean => {
4-
const decodedAbi = audiusSdk.services.entityManager.decodeManageEntity(
4+
const decodedAbi = audiusSdk.services.entityManager!.decodeManageEntity(
55
encodedABI as `0x${string}`
66
)
77
return decodedAbi.action === 'Create' && decodedAbi.entityType === 'User'
@@ -11,7 +11,7 @@ export const isUserDeactivate = (
1111
isDeactivated: boolean,
1212
encodedABI: string
1313
): boolean => {
14-
const decodedAbi = audiusSdk.services.entityManager.decodeManageEntity(
14+
const decodedAbi = audiusSdk.services.entityManager!.decodeManageEntity(
1515
encodedABI as `0x${string}`
1616
)
1717
return (
@@ -23,14 +23,14 @@ export const isUserDeactivate = (
2323
}
2424

2525
export const isTrackDownload = (encodedABI: string) => {
26-
const decodedAbi = audiusSdk.services.entityManager.decodeManageEntity(
26+
const decodedAbi = audiusSdk.services.entityManager!.decodeManageEntity(
2727
encodedABI as `0x${string}`
2828
)
2929
return decodedAbi.action === 'Download' && decodedAbi.entityType === 'Track'
3030
}
3131

3232
export const isViewNotification = (encodedABI: string): boolean => {
33-
const decodedAbi = audiusSdk.services.entityManager.decodeManageEntity(
33+
const decodedAbi = audiusSdk.services.entityManager!.decodeManageEntity(
3434
encodedABI as `0x${string}`
3535
)
3636
return (
@@ -39,7 +39,7 @@ export const isViewNotification = (encodedABI: string): boolean => {
3939
}
4040

4141
export const isViewPlaylistNotification = (encodedABI: string): boolean => {
42-
const decodedAbi = audiusSdk.services.entityManager.decodeManageEntity(
42+
const decodedAbi = audiusSdk.services.entityManager!.decodeManageEntity(
4343
encodedABI as `0x${string}`
4444
)
4545
return (

apps/relay/src/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { audiusSdk } from '.'
22

33
/// async in case we need to make a db call
44
export const validateTransactionData = async (encodedABI: string) => {
5-
const decoded = audiusSdk.services.entityManager.decodeManageEntity(
5+
const decoded = audiusSdk.services.entityManager!.decodeManageEntity(
66
encodedABI as `0x${string}`
77
)
88
// TODO: validate decoded tx with zod

0 commit comments

Comments
 (0)