@audius/sdk 3.0.3-beta.54 → 3.0.3-beta.55

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.3-beta.54",
3
+ "version": "3.0.3-beta.55",
4
4
  "audius": {
5
- "releaseSHA": "e75a4127b283f5686787f8998f1fd582c01836a0"
5
+ "releaseSHA": "0adb382c5750ea1da6b25a35bb857503ee32420a"
6
6
  },
7
7
  "description": "Audius SDK",
8
8
  "main": "dist/index.cjs.js",
@@ -249,11 +249,16 @@ export class Account extends Base {
249
249
  phase = phases.ADD_USER
250
250
  const { newMetadata, blockHash, blockNumber } =
251
251
  await this.User.createEntityManagerUserV2({
252
- metadata,
253
- profilePictureFile,
254
- coverPhotoFile
252
+ metadata
255
253
  })
256
254
 
255
+ // Upload user's profile images, if any
256
+ phase = phases.UPLOAD_PROFILE_IMAGES
257
+ await this.User.uploadProfileImagesV2(
258
+ profilePictureFile!,
259
+ coverPhotoFile!,
260
+ newMetadata
261
+ )
257
262
  return { blockHash, blockNumber, userId: newMetadata.user_id }
258
263
  } catch (e: any) {
259
264
  return {
package/src/api/Users.ts CHANGED
@@ -591,20 +591,25 @@ export class Users extends Base {
591
591
  }
592
592
  }
593
593
 
594
- async createEntityManagerUserV2({
595
- metadata,
596
- profilePictureFile,
597
- coverPhotoFile
598
- }: {
599
- metadata: UserMetadata
600
- profilePictureFile: Nullable<File>
601
- coverPhotoFile: Nullable<File>
602
- }) {
594
+ async createEntityManagerUserV2({ metadata }: { metadata: UserMetadata }) {
603
595
  this.REQUIRES(Services.DISCOVERY_PROVIDER)
604
596
 
605
597
  try {
606
598
  // Create the user with EntityMananer
607
599
  const userId = await this._generateUserId()
600
+ const manageEntityResponse =
601
+ await this.contracts.EntityManagerClient!.manageEntity(
602
+ userId,
603
+ EntityManagerClient.EntityType.USER,
604
+ userId,
605
+ EntityManagerClient.Action.CREATE,
606
+ 'v2'
607
+ )
608
+ await this._waitForDiscoveryToIndexUser(
609
+ userId,
610
+ manageEntityResponse.txReceipt.blockNumber
611
+ )
612
+
608
613
  // Ensure metadata has expected properties
609
614
  const newMetadata = this.cleanUserMetadata({ ...metadata })
610
615
  this._validateUserMetadata(newMetadata)
@@ -622,42 +627,13 @@ export class Users extends Base {
622
627
  repost_count: 0
623
628
  })
624
629
 
625
- // Upload images
626
- if (profilePictureFile) {
627
- const resp = await this.creatorNode.uploadProfilePictureV2(
628
- profilePictureFile
629
- )
630
- newMetadata.profile_picture_sizes = resp.id
631
- }
632
- if (coverPhotoFile) {
633
- const resp = await this.creatorNode.uploadCoverPhotoV2(coverPhotoFile)
634
- newMetadata.cover_photo_sizes = resp.id
635
- }
636
-
637
- const cid = await Utils.fileHasher.generateMetadataCidV1(newMetadata)
638
- const manageEntityResponse =
639
- await this.contracts.EntityManagerClient!.manageEntity(
640
- userId,
641
- EntityManagerClient.EntityType.USER,
642
- userId,
643
- EntityManagerClient.Action.CREATE,
644
- JSON.stringify({
645
- cid: cid.toString(),
646
- data: newMetadata
647
- })
648
- )
649
- await this._waitForDiscoveryToIndexUser(
650
- userId,
651
- manageEntityResponse.txReceipt.blockNumber
652
- )
653
- // Update libs instance with new user metadata object
654
- this.userStateManager.setCurrentUser({ ...newMetadata })
655
-
656
- return {
630
+ // Update metadata on chain to include wallet
631
+ const { blockHash, blockNumber } = await this.updateMetadataV2({
657
632
  newMetadata,
658
- blockHash: manageEntityResponse.txReceipt.blockHash,
659
- blockNumber: manageEntityResponse.txReceipt.blockNumber
660
- }
633
+ userId
634
+ })
635
+
636
+ return { newMetadata, blockHash, blockNumber }
661
637
  } catch (e) {
662
638
  const errorMsg = `createEntityManagerUserV2() error: ${e}`
663
639
  if (e instanceof Error) {
@@ -76,9 +76,9 @@ const isApiSolanaIndexerHealthy = ({
76
76
  data.latest_chain_slot_plays - data.latest_indexed_slot_plays <=
77
77
  maxSlotDiffPlays
78
78
 
79
- const isApiCommsHealthy = ({ data }: { data: CommsResponse }) => {
80
- return data.health?.is_healthy
81
- }
79
+ // const isApiCommsHealthy = ({ data }: { data: CommsResponse }) => {
80
+ // return data.health?.is_healthy
81
+ // }
82
82
 
83
83
  export const parseApiHealthStatusReason = ({
84
84
  data,
@@ -110,9 +110,10 @@ export const parseApiHealthStatusReason = ({
110
110
  return { health: HealthCheckStatus.BEHIND, reason: 'slot diff' }
111
111
  }
112
112
  } else if (isCommsResponse(data)) {
113
- if (!isApiCommsHealthy({ data })) {
114
- return { health: HealthCheckStatus.UNHEALTHY, reason: 'comms' }
115
- }
113
+ // TODO: Re-enable once is_healthy is correctly reporting
114
+ // if (!isApiCommsHealthy({ data })) {
115
+ // return { health: HealthCheckStatus.UNHEALTHY, reason: 'comms' }
116
+ // }
116
117
  }
117
118
 
118
119
  return { health: HealthCheckStatus.HEALTHY }