@audius/sdk 3.0.8-beta.11 → 3.0.8-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@audius/sdk",
3
- "version": "3.0.8-beta.11",
3
+ "version": "3.0.8-beta.13",
4
4
  "audius": {
5
- "releaseSHA": "94503e85377fab74d3b3f490b927c5a3bc12fd1f"
5
+ "releaseSHA": "473c515045520b748c27a58060a426eba8a3fc19"
6
6
  },
7
7
  "description": "Audius SDK",
8
8
  "keywords": [
@@ -72,8 +72,8 @@
72
72
  "@noble/secp256k1": "1.7.0",
73
73
  "@project-serum/anchor": "0.24.1",
74
74
  "@scure/base": "1.1.1",
75
- "@solana/spl-token": "0.1.8",
76
- "@solana/web3.js": "1.37.1",
75
+ "@solana/spl-token": "0.3.8",
76
+ "@solana/web3.js": "1.78.4",
77
77
  "abi-decoder": "2.4.0",
78
78
  "ajv": "6.12.2",
79
79
  "assert": "2.0.0",
package/src/api/Track.ts CHANGED
@@ -505,7 +505,7 @@ export class Track extends Base {
505
505
  let updatedMetadata = { ...metadata }
506
506
 
507
507
  if (transcodePreview) {
508
- if (!metadata.preview_start_seconds) {
508
+ if (metadata.preview_start_seconds == null) {
509
509
  throw new Error('No track preview start time specified')
510
510
  }
511
511
  if (!metadata.audio_upload_id) {
@@ -150,7 +150,7 @@ export class CreatorNode {
150
150
  }
151
151
 
152
152
  async transcodeTrackPreview(metadata: TrackMetadata): Promise<TrackMetadata> {
153
- if (!metadata.preview_start_seconds) {
153
+ if (metadata.preview_start_seconds == null) {
154
154
  throw new Error('No track preview start time specified')
155
155
  }
156
156
  if (!metadata.audio_upload_id) {
@@ -182,7 +182,7 @@ export class CreatorNode {
182
182
  ): Promise<TrackMetadata> {
183
183
  const updatedMetadata = { ...metadata }
184
184
  const audioUploadOpts: { [key: string]: string } = {}
185
- if (updatedMetadata.preview_start_seconds) {
185
+ if (updatedMetadata.preview_start_seconds != null) {
186
186
  audioUploadOpts['previewStartSeconds'] =
187
187
  updatedMetadata.preview_start_seconds.toString()
188
188
  }
@@ -214,7 +214,7 @@ export class CreatorNode {
214
214
  updatedMetadata.track_segments = []
215
215
  updatedMetadata.duration = parseInt(audioResp.probe.format.duration, 10)
216
216
  updatedMetadata.track_cid = audioResp.results['320']
217
- if (updatedMetadata.preview_start_seconds) {
217
+ if (updatedMetadata.preview_start_seconds != null) {
218
218
  const previewKey = `320_preview|${updatedMetadata.preview_start_seconds}`
219
219
  updatedMetadata.preview_cid = audioResp.results[previewKey]
220
220
  }
@@ -239,10 +239,7 @@ export class SolanaWeb3Manager {
239
239
  mint?: MintName
240
240
  } = {}) {
241
241
  const userbank = await this.deriveUserBank({ ethAddress, mint })
242
- const tokenAccount = await this.getTokenAccountInfo(
243
- userbank.toString(),
244
- mint
245
- )
242
+ const tokenAccount = await this.getTokenAccountInfo(userbank.toString())
246
243
  return !!tokenAccount
247
244
  }
248
245
 
@@ -292,7 +289,7 @@ export class SolanaWeb3Manager {
292
289
  | { error: string; errorCode: string | number | null }
293
290
  | {
294
291
  didExist: boolean
295
- userbank: solanaWeb3.PublicKey
292
+ userbank: PublicKey
296
293
  }
297
294
  > {
298
295
  const didExist = await this.doesUserbankExist({ ethAddress, mint })
@@ -378,15 +375,10 @@ export class SolanaWeb3Manager {
378
375
  * Gets the info for a user bank/wAudio token account given a spl-token address.
379
376
  * If the address is not a valid token account, returns `null`
380
377
  */
381
- async getTokenAccountInfo(
382
- solanaAddress: string,
383
- mint: MintName = DEFAULT_MINT
384
- ) {
378
+ async getTokenAccountInfo(solanaAddress: string) {
385
379
  try {
386
380
  const res = await getTokenAccountInfo({
387
381
  tokenAccountAddressKey: new PublicKey(solanaAddress),
388
- mintKey: this.mints[mint],
389
- solanaTokenProgramKey: this.solanaTokenKey,
390
382
  connection: this.connection
391
383
  })
392
384
  return res
@@ -418,7 +410,7 @@ export class SolanaWeb3Manager {
418
410
 
419
411
  // Multiply by 10^10 to maintain same decimals as eth $AUDIO
420
412
  const decimals = AUDIO_DECMIALS - WAUDIO_DECMIALS
421
- return tokenAccount.amount.mul(Utils.toBN('1'.padEnd(decimals + 1, '0')))
413
+ return tokenAccount.amount * BigInt('1'.padEnd(decimals + 1, '0'))
422
414
  } catch (e) {
423
415
  return null
424
416
  }
@@ -1,11 +1,11 @@
1
- import { ASSOCIATED_TOKEN_PROGRAM_ID, Token } from '@solana/spl-token'
1
+ import { ASSOCIATED_TOKEN_PROGRAM_ID, getAccount } from '@solana/spl-token'
2
2
  import {
3
3
  PublicKey,
4
4
  SystemProgram,
5
5
  SYSVAR_RENT_PUBKEY,
6
6
  Connection
7
7
  } from '@solana/web3.js'
8
- import { Nullable, randomKeyPair } from '../../utils'
8
+ import type { Nullable } from '../../utils'
9
9
  import type { IdentityService } from '../identity'
10
10
 
11
11
  type FindAssociatedTokenAddressConfig = {
@@ -35,8 +35,6 @@ export async function findAssociatedTokenAddress({
35
35
 
36
36
  type GetTokenAccountInfoConfig = {
37
37
  tokenAccountAddressKey: PublicKey
38
- mintKey: PublicKey
39
- solanaTokenProgramKey: PublicKey
40
38
  connection: Connection
41
39
  }
42
40
 
@@ -45,23 +43,10 @@ type GetTokenAccountInfoConfig = {
45
43
  */
46
44
  export async function getTokenAccountInfo({
47
45
  tokenAccountAddressKey,
48
- mintKey,
49
- solanaTokenProgramKey,
50
46
  connection
51
47
  }: GetTokenAccountInfoConfig) {
52
- const token = new Token(
53
- connection,
54
- mintKey,
55
- solanaTokenProgramKey,
56
- randomKeyPair
57
- )
58
-
59
48
  // Fetch token info with 'processed commitment to get any recently changed amounts.
60
- // NOTE: Our version of spl-token omits the second argument
61
- // in the type definitions even though it's actually available,
62
- // so we suppress error until we can upgrade.
63
- // @ts-expect-error
64
- const info = await token.getAccountInfo(tokenAccountAddressKey, 'processed')
49
+ const info = await getAccount(connection, tokenAccountAddressKey, 'processed')
65
50
  return info
66
51
  }
67
52