@audius/sdk 2.0.3-beta.6 → 2.0.3-beta.7

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.
Files changed (39) hide show
  1. package/dist/api/Account.d.ts +26 -0
  2. package/dist/api/Users.d.ts +20 -0
  3. package/dist/core.js +5 -0
  4. package/dist/core.js.map +1 -1
  5. package/dist/index.cjs.js +2658 -932
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.esm.js +2646 -920
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/legacy.js +2656 -929
  10. package/dist/legacy.js.map +1 -1
  11. package/dist/native-libs.js +2647 -921
  12. package/dist/native-libs.js.map +1 -1
  13. package/dist/services/creatorNode/CreatorNode.d.ts +3 -7
  14. package/dist/services/dataContracts/IPLDBlacklistFactoryClient.d.ts +17 -0
  15. package/dist/services/dataContracts/PlaylistFactoryClient.d.ts +22 -0
  16. package/dist/services/dataContracts/RegistryClient.d.ts +15 -0
  17. package/dist/services/dataContracts/SocialFeatureFactoryClient.d.ts +11 -0
  18. package/dist/services/dataContracts/TrackFactoryClient.d.ts +23 -0
  19. package/dist/services/dataContracts/UserFactoryClient.d.ts +64 -0
  20. package/dist/services/dataContracts/UserLibraryFactoryClient.d.ts +9 -0
  21. package/dist/services/dataContracts/UserReplicaSetManagerClient.d.ts +82 -0
  22. package/dist/services/discoveryProvider/DiscoveryProvider.d.ts +1 -1
  23. package/dist/services/discoveryProvider/requests.d.ts +2 -1
  24. package/dist/services/solanaAudiusData/SolanaAudiusData.d.ts +408 -0
  25. package/dist/services/solanaAudiusData/errors.d.ts +7 -0
  26. package/dist/services/solanaAudiusData/index.d.ts +2 -0
  27. package/dist/utils/fileHasher.d.ts +9 -2
  28. package/dist/utils/types.d.ts +1 -0
  29. package/dist/utils/utils.d.ts +1 -0
  30. package/package.json +2 -1
  31. package/src/api/Account.ts +77 -0
  32. package/src/api/Users.ts +181 -3
  33. package/src/eth-contracts/ABIs/Wormhole.json +121 -11
  34. package/src/services/creatorNode/CreatorNode.ts +9 -0
  35. package/src/services/discoveryProvider/DiscoveryProvider.ts +4 -2
  36. package/src/services/discoveryProvider/requests.ts +6 -1
  37. package/src/services/solana/rewardsAttester.ts +47 -21
  38. package/src/utils/fileHasher.ts +18 -3
  39. package/src/utils/types.ts +1 -0
@@ -0,0 +1,408 @@
1
+ /// <reference types="bn.js" />
2
+ /// <reference types="node" />
3
+ import * as AudiusData from '@audius/anchor-audius-data';
4
+ import type { AudiusDataProgram } from '@audius/anchor-audius-data';
5
+ import anchor, { BN } from '@project-serum/anchor';
6
+ import type { SolanaWeb3Manager } from '../solana';
7
+ import type { Web3Manager } from '../web3Manager';
8
+ import { PublicKey, Transaction } from '@solana/web3.js';
9
+ import { Nullable } from '../../utils';
10
+ export declare type AnchorAudiusDataConfig = {
11
+ programId: string;
12
+ adminAccount: string;
13
+ };
14
+ declare type SeedAddress = {
15
+ bumpSeed: number;
16
+ derivedAddress: anchor.web3.PublicKey;
17
+ };
18
+ declare type OmitAndRequire<T, K extends keyof T, L extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, L>>;
19
+ /**
20
+ * SolanaAudiusData acts as the interface to solana audius data programs from a client.
21
+ * It wraps methods to create transactions.
22
+ */
23
+ export declare class SolanaAudiusData {
24
+ anchorAudiusDataConfig: AnchorAudiusDataConfig;
25
+ solanaWeb3Manager: SolanaWeb3Manager;
26
+ program: AudiusDataProgram;
27
+ programId: PublicKey;
28
+ adminAccount: PublicKey;
29
+ provider: anchor.Provider;
30
+ web3Manager: Nullable<Web3Manager>;
31
+ AudiusData: any;
32
+ constructor(anchorAudiusDataConfig: AnchorAudiusDataConfig, solanaWeb3Manager: SolanaWeb3Manager, web3Manager: Nullable<Web3Manager>);
33
+ init(): Promise<void>;
34
+ setAdminAccount(AdminAccount: PublicKey): void;
35
+ /**
36
+ * Validate that the program, provider and base variables were initted
37
+ * @returns {boolean} True if the class was initted
38
+ */
39
+ didInit(): boolean;
40
+ /**
41
+ * Encodes and derives the user account, bump seed, and base authority
42
+ */
43
+ getUserIdSeed(userId: BN): Promise<{
44
+ userId: anchor.BN;
45
+ userIdSeed: Buffer & any[];
46
+ userAccount: anchor.web3.PublicKey;
47
+ bumpSeed: number;
48
+ baseAuthorityAccount: anchor.web3.PublicKey;
49
+ }>;
50
+ /**
51
+ * Derives the user solana keypair using the user's eth private key
52
+ */
53
+ getUserKeyPair(): anchor.web3.Keypair;
54
+ /**
55
+ * Encodes and derives the content node account and bump seed
56
+ */
57
+ getContentNodeSeedAddress(spId: number): Promise<SeedAddress>;
58
+ /**
59
+ * Signs a transaction using the user's key pair
60
+ * NOTE: The blockhash and feepayer must be set when signing and passed along
61
+ * with the transaction for further signatures for consitency or the signature
62
+ * will be invalide
63
+ */
64
+ signTransaction(tx: anchor.web3.Transaction, userKeyPair: anchor.web3.Keypair): Promise<anchor.web3.Transaction>;
65
+ /**
66
+ * Submits a transaction via the solanaWeb3Manager transactionHandler passing along
67
+ * the signtures.
68
+ * This base method is used to send all transactions in this class
69
+ */
70
+ sendTx(tx: Transaction): Promise<{
71
+ res: string | null;
72
+ errorCode: string | number | null;
73
+ error: string | null;
74
+ }>;
75
+ /**
76
+ * Creates an admin account
77
+ * @memberof SolanaWeb3Manager
78
+ */
79
+ initAdmin(params: Omit<AudiusData.InitAdminParams, 'payer' | 'program'>): Promise<{
80
+ res: string | null;
81
+ errorCode: string | number | null;
82
+ error: string | null;
83
+ } | undefined>;
84
+ /**
85
+ * Creates a user account to be claimed.
86
+ * NOTE: This transaction needs to be signed by the admin account
87
+ * @memberof SolanaWeb3Manager
88
+ */
89
+ initUser(params: OmitAndRequire<AudiusData.InitUserParams, 'program' | 'payer', 'userId' | 'metadata' | 'ethAddress' | 'bumpSeed' | 'userAccount' | 'baseAuthorityAccount' | 'cn1' | 'cn2' | 'cn3' | 'replicaSet' | 'replicaSetBumps' | 'adminAuthorityPublicKey'>): Promise<{
90
+ res: string | null;
91
+ errorCode: string | number | null;
92
+ error: string | null;
93
+ } | undefined>;
94
+ /**
95
+ * Claims a user account that is created via init user using secp
96
+ * @memberof SolanaWeb3Manager
97
+ */
98
+ initUserSolPubkey(params: Omit<AudiusData.InitUserSolPubkeyParams, 'program' | 'ethPrivateKey' | 'message'> & {
99
+ userId: BN;
100
+ }): Promise<{
101
+ res: string | null;
102
+ errorCode: string | number | null;
103
+ error: string | null;
104
+ } | undefined>;
105
+ /**
106
+ * Creates a content node account
107
+ * NOTE: This transaction must be signed by the admin account
108
+ * @memberof SolanaWeb3Manager
109
+ */
110
+ createContentNode(params: OmitAndRequire<AudiusData.CreateContentNodeParams, 'program', 'spID' | 'payer' | 'adminAccount' | 'adminAuthorityPublicKey' | 'baseAuthorityAccount' | 'spID' | 'contentNodeAuthority' | 'contentNodeAccount' | 'ownerEthAddress'>): Promise<{
111
+ res: string | null;
112
+ errorCode: string | number | null;
113
+ error: string | null;
114
+ } | undefined>;
115
+ /**
116
+ * Updates the user replica set in the user account
117
+ * NOTE: This transaction must be signed by a replica or the user's authority
118
+ * @memberof SolanaWeb3Manager
119
+ */
120
+ updateUserReplicaSet(params: Omit<AudiusData.UpdateUserReplicaSetParams, 'program' | 'payer'>): Promise<{
121
+ res: string | null;
122
+ errorCode: string | number | null;
123
+ error: string | null;
124
+ } | undefined>;
125
+ /**
126
+ * Create or update a content node using attestations from multiple content nodes
127
+ * @memberof SolanaWeb3Manager
128
+ */
129
+ publicCreateOrUpdateContentNode(params: Omit<AudiusData.PublicCreateOrUpdateContentNodeParams, 'program' | 'payer'>): Promise<{
130
+ res: string | null;
131
+ errorCode: string | number | null;
132
+ error: string | null;
133
+ }>;
134
+ /**
135
+ * Deletes a content node using attestations from multiple content nodes
136
+ * @memberof SolanaWeb3Manager
137
+ */
138
+ publicDeleteContentNode(params: Omit<AudiusData.PublicDeleteContentNodeParams, 'program' | 'payer'>): Promise<{
139
+ res: string | null;
140
+ errorCode: string | number | null;
141
+ error: string | null;
142
+ }>;
143
+ /**
144
+ * Creates a user account
145
+ * NOTE: This method can only we called after the admin account is write enabled false
146
+ * @memberof SolanaWeb3Manager
147
+ */
148
+ createUser(params: OmitAndRequire<AudiusData.CreateUserParams, 'program' | 'payer', 'userId' | 'metadata'> & {
149
+ cn1SpId: number;
150
+ cn2SpId: number;
151
+ cn3SpId: number;
152
+ }): Promise<{
153
+ res: string | null;
154
+ errorCode: string | number | null;
155
+ error: string | null;
156
+ } | undefined>;
157
+ /**
158
+ * Updates a user account
159
+ * @memberof SolanaWeb3Manager
160
+ */
161
+ updateUser(params: OmitAndRequire<AudiusData.UpdateUserParams, 'program', 'metadata'> & {
162
+ userId: anchor.BN;
163
+ }): Promise<{
164
+ res: string | null;
165
+ errorCode: string | number | null;
166
+ error: string | null;
167
+ } | undefined>;
168
+ /**
169
+ * Updates the admin account, used for write enabled
170
+ * @memberof SolanaWeb3Manager
171
+ */
172
+ updateAdmin(params: Omit<AudiusData.UpdateAdminParams, 'program'>): Promise<{
173
+ res: string | null;
174
+ errorCode: string | number | null;
175
+ error: string | null;
176
+ } | undefined>;
177
+ initAuthorityDelegationStatus(params: Omit<AudiusData.InitAuthorityDelegationStatusParams, 'program' | 'payer'>): Promise<{
178
+ res: string | null;
179
+ errorCode: string | number | null;
180
+ error: string | null;
181
+ }>;
182
+ revokeAuthorityDelegation(params: Omit<AudiusData.RevokeAuthorityDelegationParams, 'program' | 'payer'>): Promise<{
183
+ res: string | null;
184
+ errorCode: string | number | null;
185
+ error: string | null;
186
+ }>;
187
+ addUserAuthorityDelegate(params: Omit<AudiusData.AddUserAuthorityDelegateParams, 'program' | 'payer'>): Promise<{
188
+ res: string | null;
189
+ errorCode: string | number | null;
190
+ error: string | null;
191
+ }>;
192
+ removeUserAuthorityDelegate(params: Omit<AudiusData.RemoveUserAuthorityDelegateParams, 'program' | 'payer'>): Promise<{
193
+ res: string | null;
194
+ errorCode: string | number | null;
195
+ error: string | null;
196
+ }>;
197
+ /**
198
+ * Updates a user to be verified
199
+ * NOTE: This tx must be signed by the admin verifier
200
+ * @memberof SolanaWeb3Manager
201
+ */
202
+ updateIsVerified(params: OmitAndRequire<AudiusData.UpdateIsVerifiedParams, 'program' | 'verifierPublicKey', 'userId'> & {
203
+ verifierKeyPair: anchor.web3.Keypair;
204
+ }): Promise<{
205
+ res: string | null;
206
+ errorCode: string | number | null;
207
+ error: string | null;
208
+ } | undefined>;
209
+ /**
210
+ * Creates a track
211
+ *
212
+ * @return {Promise<any>}
213
+ * @memberof SolanaWeb3Manager
214
+ */
215
+ createTrack(params: OmitAndRequire<AudiusData.CreateEntityParams, 'program', 'id' | 'userId' | 'metadata'>): Promise<{
216
+ res: string | null;
217
+ errorCode: string | number | null;
218
+ error: string | null;
219
+ } | undefined>;
220
+ /**
221
+ * Updates a track
222
+ *
223
+ * @return {Promise<any>}
224
+ * @memberof SolanaWeb3Manager
225
+ */
226
+ updateTrack(params: OmitAndRequire<AudiusData.UpdateEntityParams, 'program', 'id' | 'userId' | 'metadata'>): Promise<{
227
+ res: string | null;
228
+ errorCode: string | number | null;
229
+ error: string | null;
230
+ } | undefined>;
231
+ /**
232
+ * Deletes a track
233
+ *
234
+ * @return {Promise<any>}
235
+ * @memberof SolanaWeb3Manager
236
+ */
237
+ deleteTrack(params: OmitAndRequire<AudiusData.DeleteEntityParams, 'program', 'id' | 'userId'>): Promise<{
238
+ res: string | null;
239
+ errorCode: string | number | null;
240
+ error: string | null;
241
+ } | undefined>;
242
+ /**
243
+ * Creates a solana transaction for createPlaylist
244
+ *
245
+ * @return {Promise<any>}
246
+ * @memberof SolanaWeb3Manager
247
+ */
248
+ createPlaylist(params: OmitAndRequire<AudiusData.CreateEntityParams, 'program', 'id' | 'userId' | 'metadata'>): Promise<{
249
+ res: string | null;
250
+ errorCode: string | number | null;
251
+ error: string | null;
252
+ } | undefined>;
253
+ /**
254
+ * Creates a solana transaction for updatePlaylist
255
+ *
256
+ * @return {Promise<any>}
257
+ * @memberof SolanaWeb3Manager
258
+ */
259
+ updatePlaylist(params: OmitAndRequire<AudiusData.UpdateEntityParams, 'program', 'id' | 'userId' | 'metadata'>): Promise<{
260
+ res: string | null;
261
+ errorCode: string | number | null;
262
+ error: string | null;
263
+ } | undefined>;
264
+ /**
265
+ * Creates a solana transaction for deletePlaylist
266
+ *
267
+ * @return {Promise<any>}
268
+ * @memberof SolanaWeb3Manager
269
+ */
270
+ deletePlaylist(params: OmitAndRequire<AudiusData.DeleteEntityParams, 'program', 'id' | 'userId'>): Promise<{
271
+ res: string | null;
272
+ errorCode: string | number | null;
273
+ error: string | null;
274
+ } | undefined>;
275
+ /**
276
+ * Creates a solana transaction for addTrackRepost
277
+ *
278
+ * @return {Promise<any>}
279
+ * @memberof SolanaWeb3Manager
280
+ */
281
+ addTrackSave(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
282
+ res: string | null;
283
+ errorCode: string | number | null;
284
+ error: string | null;
285
+ } | undefined>;
286
+ /**
287
+ * Creates a solana transaction for deleteTrackSave
288
+ *
289
+ * @return {Promise<any>}
290
+ * @memberof SolanaWeb3Manager
291
+ */
292
+ deleteTrackSave(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
293
+ res: string | null;
294
+ errorCode: string | number | null;
295
+ error: string | null;
296
+ } | undefined>;
297
+ /**
298
+ * Creates a solana transaction for addTrackRepost
299
+ *
300
+ * @return {Promise<any>}
301
+ * @memberof SolanaWeb3Manager
302
+ */
303
+ addTrackRepost(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
304
+ res: string | null;
305
+ errorCode: string | number | null;
306
+ error: string | null;
307
+ } | undefined>;
308
+ /**
309
+ * Creates a solana transaction for deleteTrackRepost
310
+ *
311
+ * @return {Promise<any>}
312
+ * @memberof SolanaWeb3Manager
313
+ */
314
+ deleteTrackRepost(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
315
+ res: string | null;
316
+ errorCode: string | number | null;
317
+ error: string | null;
318
+ } | undefined>;
319
+ /**
320
+ * Creates a solana transaction for addPlaylistSave
321
+ *
322
+ * @return {Promise<any>}
323
+ * @memberof SolanaWeb3Manager
324
+ */
325
+ addPlaylistSave(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
326
+ res: string | null;
327
+ errorCode: string | number | null;
328
+ error: string | null;
329
+ } | undefined>;
330
+ /**
331
+ * Creates a solana transaction for deletePlaylistSave
332
+ *
333
+ * @return {Promise<any>}
334
+ * @memberof SolanaWeb3Manager
335
+ */
336
+ deletePlaylistSave(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
337
+ res: string | null;
338
+ errorCode: string | number | null;
339
+ error: string | null;
340
+ } | undefined>;
341
+ /**
342
+ * Creates a solana transaction for addPlaylistRepost
343
+ *
344
+ * @return {Promise<any>}
345
+ * @memberof SolanaWeb3Manager
346
+ */
347
+ addPlaylistRepost(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
348
+ res: string | null;
349
+ errorCode: string | number | null;
350
+ error: string | null;
351
+ } | undefined>;
352
+ /**
353
+ * Creates a solana transaction for deletePlaylistRepost
354
+ *
355
+ * @return {Promise<any>}
356
+ * @memberof SolanaWeb3Manager
357
+ */
358
+ deletePlaylistRepost(params: OmitAndRequire<AudiusData.EntitySocialActionParams, 'program', 'id' | 'userId'>): Promise<{
359
+ res: string | null;
360
+ errorCode: string | number | null;
361
+ error: string | null;
362
+ } | undefined>;
363
+ /**
364
+ * Creates a solana transaction for followUser
365
+ *
366
+ * @return {Promise<any>}
367
+ * @memberof SolanaWeb3Manager
368
+ */
369
+ followUser(params: OmitAndRequire<AudiusData.UserSocialActionParams, 'program', 'sourceUserId' | 'targetUserId'>): Promise<{
370
+ res: string | null;
371
+ errorCode: string | number | null;
372
+ error: string | null;
373
+ } | undefined>;
374
+ /**
375
+ * Creates a solana transaction for unfollowUser
376
+ *
377
+ * @return {Promise<any>}
378
+ * @memberof SolanaWeb3Manager
379
+ */
380
+ unfollowUser(params: OmitAndRequire<AudiusData.UserSocialActionParams, 'program', 'sourceUserId' | 'targetUserId'>): Promise<{
381
+ res: string | null;
382
+ errorCode: string | number | null;
383
+ error: string | null;
384
+ } | undefined>;
385
+ /**
386
+ * Creates a solana transaction for subscribeUser
387
+ *
388
+ * @return {Promise<any>}
389
+ * @memberof SolanaWeb3Manager
390
+ */
391
+ subscribeUser(params: OmitAndRequire<AudiusData.UserSocialActionParams, 'program', 'sourceUserId' | 'targetUserId'>): Promise<{
392
+ res: string | null;
393
+ errorCode: string | number | null;
394
+ error: string | null;
395
+ } | undefined>;
396
+ /**
397
+ * Creates a solana transaction for unsubscribeUser
398
+ *
399
+ * @return {Promise<any>}
400
+ * @memberof SolanaWeb3Manager
401
+ */
402
+ unsubscribeUser(params: OmitAndRequire<AudiusData.UserSocialActionParams, 'program', 'sourceUserId' | 'targetUserId'>): Promise<{
403
+ res: string | null;
404
+ errorCode: string | number | null;
405
+ error: string | null;
406
+ } | undefined>;
407
+ }
408
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * All errors returned by Anchor Audius Data
3
+ */
4
+ export declare const CustomAudiusDataErrors: Map<number, string>;
5
+ export declare const audiusDataErrorMapping: {
6
+ fromErrorCode: (errorCode: number) => string;
7
+ };
@@ -0,0 +1,2 @@
1
+ export * from './SolanaAudiusData';
2
+ export * from './errors';
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { ImportCandidate, UserImporterOptions } from 'ipfs-unixfs-importer';
3
+ import { CID } from 'multiformats/cid';
3
4
  export declare type Content = ReadableStream | Buffer | string;
4
5
  export interface ImageHasher {
5
6
  options: UserImporterOptions;
@@ -35,7 +36,7 @@ export declare const fileHasher: {
35
36
  * Custom fn to generate the content-hashing logic
36
37
  * @param content a buffer of the content
37
38
  * @param options options for importer
38
- * @returns the CID from content addressing logic
39
+ * @returns the V0 CID from content addressing logic
39
40
  */
40
41
  hashNonImages(content: Uint8Array, options?: UserImporterOptions): Promise<string>;
41
42
  /**
@@ -75,12 +76,18 @@ export declare const fileHasher: {
75
76
  */
76
77
  hashImages(content: ImportCandidate, options?: UserImporterOptions): Promise<HashedImage[]>;
77
78
  /**
78
- * Generates CID for a non-image file (track segment, track transcode, metadata)
79
+ * Generates CID V0 (46-char string starting with "Qm") for a non-image file (track segment, track transcode, metadata)
79
80
  * @param {Buffer|ReadStream|string} content a single Buffer, a ReadStream, or path to an existing file
80
81
  * @param {Object?} logger
81
82
  * @returns {string} only hash response cid
82
83
  */
83
84
  generateNonImageCid(content: Content, logger?: any): Promise<string>;
85
+ /**
86
+ * Generates CID V1 for a JSON metadata object (NOT the string of the metadata - must be an object).
87
+ * CID<T, 512, SHA_256, 1> represents CID with json codec (512) and sha256 hash using CID V1.
88
+ * Call toString() on the result to get the CID V1 string.
89
+ */
90
+ generateMetadataCidV1(metadata: {}): Promise<CID>;
84
91
  /**
85
92
  * Wrapper that generates multihashes for image files
86
93
  * @param {Object[]} content an Object[] with the structure [{ path: string, content: buffer }, ...]
@@ -38,6 +38,7 @@ export declare type UserMetadata = {
38
38
  handle_lc: string;
39
39
  is_deactivated: boolean;
40
40
  is_verified: boolean;
41
+ is_storage_v2: boolean;
41
42
  location: Nullable<string>;
42
43
  is_creator: boolean;
43
44
  name: string;
@@ -61,6 +61,7 @@ export declare class Utils {
61
61
  hashNonImages(content: Uint8Array, options?: import("ipfs-unixfs-importer/types/src/types").UserImporterOptions): Promise<string>;
62
62
  hashImages(content: import("ipfs-unixfs-importer/types/src/types").ImportCandidate, options?: import("ipfs-unixfs-importer/types/src/types").UserImporterOptions): Promise<HashedImage[]>;
63
63
  generateNonImageCid(content: import("./fileHasher").Content, logger?: any): Promise<string>;
64
+ generateMetadataCidV1(metadata: {}): Promise<import("multiformats").CID>;
64
65
  generateImageCids(content: import("ipfs-unixfs-importer/types/src/types").ImportCandidate, _?: any): Promise<HashedImage[]>;
65
66
  };
66
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audius/sdk",
3
- "version": "2.0.3-beta.6",
3
+ "version": "2.0.3-beta.7",
4
4
  "audius": {
5
5
  "releaseSHA": "0a1b8fee5de228d48f2aab265720fbaf45bda661"
6
6
  },
@@ -90,6 +90,7 @@
90
90
  "keccak256": "1.0.2",
91
91
  "lodash": "4.17.21",
92
92
  "micro-aes-gcm": "0.3.3",
93
+ "multiformats": "9.9.0",
93
94
  "node-abort-controller": "3.1.1",
94
95
  "node-localstorage": "1.3.1",
95
96
  "proper-url-join": "1.2.0",
@@ -36,6 +36,7 @@ export class Account extends Base {
36
36
  this.sendTokensFromEthToSol = this.sendTokensFromEthToSol.bind(this)
37
37
  this.sendTokensFromSolToEth = this.sendTokensFromSolToEth.bind(this)
38
38
  this.userHasClaimedSolAccount = this.userHasClaimedSolAccount.bind(this)
39
+ this.signUpV2 = this.signUpV2.bind(this)
39
40
  }
40
41
 
41
42
  /**
@@ -151,10 +152,12 @@ export class Account extends Base {
151
152
  }
152
153
 
153
154
  // Add user to chain
155
+ phase = phases.ADD_USER
154
156
  const { newMetadata, blockHash, blockNumber } =
155
157
  await this.User.createEntityManagerUser({
156
158
  metadata
157
159
  })
160
+ phase = phases.UPLOAD_PROFILE_IMAGES
158
161
  await this.User.uploadProfileImages(
159
162
  profilePictureFile!,
160
163
  coverPhotoFile!,
@@ -170,6 +173,80 @@ export class Account extends Base {
170
173
  }
171
174
  }
172
175
 
176
+ /**
177
+ * Signs a user up for Audius
178
+ * @param email
179
+ * @param password
180
+ * @param metadata
181
+ * @param profilePictureFile an optional file to upload as the profile picture
182
+ * @param coverPhotoFile an optional file to upload as the cover phtoo
183
+ * @param hasWallet
184
+ * @param host The host url used for the recovery email
185
+ * @param generateRecoveryLink an optional flag to skip generating recovery link for testing purposes
186
+ */
187
+ async signUpV2(
188
+ email: string,
189
+ password: string,
190
+ metadata: UserMetadata,
191
+ profilePictureFile: Nullable<File> = null,
192
+ coverPhotoFile: Nullable<File> = null,
193
+ hasWallet = false,
194
+ host = (typeof window !== 'undefined' && window.location.origin) || null,
195
+ generateRecoveryLink = true
196
+ ) {
197
+ const phases = {
198
+ CREATE_USER_RECORD: 'CREATE_USER_RECORD',
199
+ HEDGEHOG_SIGNUP: 'HEDGEHOG_SIGNUP',
200
+ ADD_USER: 'ADD_USER',
201
+ UPLOAD_PROFILE_IMAGES: 'UPLOAD_PROFILE_IMAGES'
202
+ }
203
+ let phase = ''
204
+ try {
205
+ this.REQUIRES(Services.CREATOR_NODE, Services.IDENTITY_SERVICE)
206
+
207
+ if (this.web3Manager.web3IsExternal()) {
208
+ phase = phases.CREATE_USER_RECORD
209
+ await this.identityService.createUserRecord(
210
+ email,
211
+ this.web3Manager.getWalletAddress()
212
+ )
213
+ } else {
214
+ this.REQUIRES(Services.HEDGEHOG)
215
+ // If an owner wallet already exists, don't try to recreate it
216
+ if (!hasWallet) {
217
+ phase = phases.HEDGEHOG_SIGNUP
218
+ const ownerWallet = await this.hedgehog.signUp(email, password)
219
+ this.web3Manager.setOwnerWallet(ownerWallet)
220
+ if (generateRecoveryLink) {
221
+ await this.generateRecoveryLink({ handle: metadata.handle, host })
222
+ }
223
+ }
224
+ }
225
+
226
+ // Add user to chain
227
+ phase = phases.ADD_USER
228
+ const { newMetadata, blockHash, blockNumber } =
229
+ await this.User.createEntityManagerUserV2({
230
+ metadata
231
+ })
232
+
233
+ // Upload user's profile images, if any
234
+ phase = phases.UPLOAD_PROFILE_IMAGES
235
+ await this.User.uploadProfileImagesV2(
236
+ profilePictureFile!,
237
+ coverPhotoFile!,
238
+ newMetadata
239
+ )
240
+ return { blockHash, blockNumber, userId: newMetadata.user_id }
241
+ } catch (e: any) {
242
+ return {
243
+ error: e.message,
244
+ phase,
245
+ errorStatus: e.response ? e.response.status : null
246
+ }
247
+ }
248
+ }
249
+
173
250
  /**
174
251
  * Generates and sends a recovery email for a user
175
252
  */