@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.
- package/dist/index.cjs.js +3399 -187
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +3399 -187
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.js +3399 -187
- package/dist/legacy.js.map +1 -1
- package/dist/native-libs.js +3399 -187
- package/dist/native-libs.js.map +1 -1
- package/dist/sdk/api/generated/full/models/PremiumConditions.d.ts +6 -0
- package/dist/services/creatorNode/CreatorNode.d.ts +1 -1
- package/dist/utils/types.d.ts +5 -0
- package/package.json +2 -2
- package/src/sanityChecks/rolloverNodes.ts +26 -10
- package/src/sdk/api/generated/full/models/PremiumConditions.ts +6 -0
- package/src/services/creatorNode/CreatorNode.ts +1 -1
- package/src/services/schemaValidator/schemas/trackSchema.json +19 -2
- package/src/utils/types.ts +5 -0
|
@@ -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
|
|
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
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -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,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 (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
}
|
|
@@ -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": {
|
package/src/utils/types.ts
CHANGED
|
@@ -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 = {
|