@audius/sdk 1.0.34 → 1.0.36

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.
@@ -27,4 +27,10 @@ export interface PremiumConditions {
27
27
  * @memberof PremiumConditions
28
28
  */
29
29
  follow_user_id?: number;
30
+ /**
31
+ *
32
+ * @type {number}
33
+ * @memberof PremiumConditions
34
+ */
35
+ tip_user_id?: number;
30
36
  }
@@ -76,7 +76,7 @@ export declare class CreatorNode {
76
76
  * @param timeout max time alloted for clock request
77
77
  * @param params optional query string params
78
78
  */
79
- static getClockValue(endpoint: string, wallet: string, timeout: number, params?: Record<string, string>): Promise<any>;
79
+ static getClockValue(endpoint: string, wallet: string, timeout?: number, params?: Record<string, string>): Promise<any>;
80
80
  /**
81
81
  * Checks if a download is available from provided creator node endpoints
82
82
  * @param endpoints creator node endpoints
@@ -79,10 +79,15 @@ export declare type PremiumConditionsEthNFTCollection = {
79
79
  chain: 'eth';
80
80
  standard: TokenStandard;
81
81
  address: string;
82
+ name: string;
83
+ slug: string;
84
+ externalLink: Nullable<string>;
82
85
  };
83
86
  export declare type PremiumConditionsSolNFTCollection = {
84
87
  chain: 'sol';
85
88
  address: string;
89
+ name: string;
90
+ externalLink: Nullable<string>;
86
91
  };
87
92
  export declare type PremiumConditions = {
88
93
  nft_collection?: PremiumConditionsEthNFTCollection | PremiumConditionsSolNFTCollection;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@audius/sdk",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "audius": {
5
- "releaseSHA": "8f0ae0d181bf1ee2dcf5ccc26987aaf1d0861903"
5
+ "releaseSHA": "f5d39ff9c22d1fe9b5ca9c14261a1690575af34d"
6
6
  },
7
7
  "description": "",
8
8
  "main": "dist/index.cjs.js",
@@ -1,6 +1,7 @@
1
1
  import { Nullable, Utils } from '../utils'
2
2
  import { CreatorNode } from '../services/creatorNode'
3
3
  import type { AudiusLibs } from '../AudiusLibs'
4
+ import maxBy from 'lodash/maxBy'
4
5
 
5
6
  const THREE_SECONDS = 3000
6
7
  const MAX_TRIES = 3
@@ -23,15 +24,26 @@ const checkPrimaryHealthy = async (
23
24
  }
24
25
 
25
26
  /** Gets new endpoints from a user's secondaries */
26
- const getNewPrimary = async (libs: AudiusLibs, secondaries: string[]) => {
27
- for (const secondary of secondaries) {
28
- const syncStatus = await libs.creatorNode?.getSyncStatus(secondary)
29
- if (!syncStatus) continue
30
- if (!syncStatus.isBehind) {
31
- return secondary
32
- }
27
+ const getNewPrimary = async (secondaries: string[], wallet: string) => {
28
+ const secondaryStatuses = (
29
+ await Promise.all(
30
+ secondaries.map(async (secondary) => {
31
+ try {
32
+ const clockValue = await CreatorNode.getClockValue(secondary, wallet)
33
+ if (clockValue) return { secondary, clockValue }
34
+ return undefined
35
+ } catch (e) {
36
+ console.warn(e)
37
+ return undefined
38
+ }
39
+ })
40
+ )
41
+ ).filter(Boolean)
42
+ const max = maxBy(secondaryStatuses, (s) => s?.clockValue)?.secondary
43
+ if (!max) {
44
+ throw new Error(`Could not find valid secondaries for user ${secondaries}`)
33
45
  }
34
- throw new Error(`Could not find valid secondaries for user ${secondaries}`)
46
+ return max
35
47
  }
36
48
 
37
49
  export const rolloverNodes = async (
@@ -54,7 +66,7 @@ export const rolloverNodes = async (
54
66
 
55
67
  try {
56
68
  // Get a new primary
57
- const newPrimary = await getNewPrimary(libs, secondaries)
69
+ const newPrimary = await getNewPrimary(secondaries, user.wallet!)
58
70
  const index = secondaries.indexOf(newPrimary)
59
71
  // Get new secondaries and backfill up to 2
60
72
  let newSecondaries = [...secondaries]
@@ -85,7 +97,11 @@ export const rolloverNodes = async (
85
97
  console.debug(
86
98
  `Sanity Check - rolloverNodes - new nodes ${newMetadata.creator_node_endpoint}`
87
99
  )
88
- await libs.User?.updateCreator(user.user_id, newMetadata)
100
+ await libs.User?.updateCreator(
101
+ user.user_id,
102
+ newMetadata,
103
+ true /* useEntityManager */
104
+ )
89
105
  } catch (e) {
90
106
  console.error(e)
91
107
  }
@@ -32,6 +32,12 @@ export interface PremiumConditions
32
32
  * @memberof PremiumConditions
33
33
  */
34
34
  follow_user_id?: number;
35
+ /**
36
+ *
37
+ * @type {number}
38
+ * @memberof PremiumConditions
39
+ */
40
+ tip_user_id?: number;
35
41
  }
36
42
 
37
43
 
@@ -115,7 +115,7 @@ export class CreatorNode {
115
115
  static async getClockValue(
116
116
  endpoint: string,
117
117
  wallet: string,
118
- timeout: number,
118
+ timeout?: number,
119
119
  params: Record<string, string> = {}
120
120
  ) {
121
121
  const baseReq: AxiosRequestConfig = {
@@ -312,9 +312,19 @@
312
312
  },
313
313
  "standard": {
314
314
  "enum": ["ERC721", "ERC1155"]
315
+ },
316
+ "name": {
317
+ "type": "string"
318
+ },
319
+ "slug": {
320
+ "type": "string"
321
+ },
322
+ "externalLink": {
323
+ "type": ["string", "null"],
324
+ "default": null
315
325
  }
316
326
  },
317
- "required": ["chain", "address", "standard"],
327
+ "required": ["chain", "address", "standard", "name", "slug"],
318
328
  "title": "PremiumConditionsEthNFTCollection"
319
329
  },
320
330
  "PremiumConditionsSolNFTCollection": {
@@ -327,9 +337,16 @@
327
337
  },
328
338
  "address": {
329
339
  "type": "string"
340
+ },
341
+ "name": {
342
+ "type": "string"
343
+ },
344
+ "externalLink": {
345
+ "type": ["string", "null"],
346
+ "default": null
330
347
  }
331
348
  },
332
- "required": ["chain", "address"],
349
+ "required": ["chain", "address", "name"],
333
350
  "title": "PremiumConditionsSolNFTCollection"
334
351
  },
335
352
  "PremiumConditionsFollowUserId": {
@@ -92,11 +92,16 @@ export type PremiumConditionsEthNFTCollection = {
92
92
  chain: 'eth'
93
93
  standard: TokenStandard
94
94
  address: string
95
+ name: string
96
+ slug: string
97
+ externalLink: Nullable<string>
95
98
  }
96
99
 
97
100
  export type PremiumConditionsSolNFTCollection = {
98
101
  chain: 'sol'
99
102
  address: string
103
+ name: string
104
+ externalLink: Nullable<string>
100
105
  }
101
106
 
102
107
  export type PremiumConditions = {