瀏覽代碼

fix asset collection update

Tony Boyle 3 月之前
父節點
當前提交
9f7a5345de
共有 1 個文件被更改,包括 11 次插入7 次删除
  1. 11 7
      src/pages/core/update.md

+ 11 - 7
src/pages/core/update.md

@@ -124,22 +124,26 @@ import {
   update,
   fetchAsset,
   fetchCollection,
-  updateAuthority,
 } from "@metaplex-foundation/mpl-core";
 
 const assetId = publicKey("11111111111111111111111111111111");
+
 const asset = await fetchAsset(umi, assetId);
-const oldCollectionId = publicKey("22222222222222222222222222222222");
-const collection = await fetchCollection(umi, oldCollectionId);
-const newCollectionId = publicKey("33333333333333333333333333333333");
+
+const collectionId = collectionAddress(asset)
+
+if (!collectionId) {
+  console.log("Collection not found");
+  return;
+}
+
+const collection = await fetchCollection(umi, collectionId);
 
 const updateTx = await update(umi, {
   asset,
-  name: "Updated Asset",
   collection,
-  newUpdateAuthority: updateAuthority("Collection", [newCollectionId]),
+  newCollection: publicKey("22222222222222222222222222222222"),
 }).sendAndConfirm(umi);
-
 ```
 
 {% /dialect %}