Forráskód Böngészése

Merge pull request #117 from metaplex-foundation/tony/missing-helper-examples

added missing helpers
Michael Danenberg 1 éve
szülő
commit
2fb436be7f
3 módosított fájl, 71 hozzáadás és 59 törlés
  1. 29 7
      src/pages/core/burn.md
  2. 32 42
      src/pages/core/collections.md
  3. 10 10
      src/pages/core/update.md

+ 29 - 7
src/pages/core/burn.md

@@ -33,11 +33,17 @@ Here is how you can use our SDKs to burn a Core asset. The snippet assumes that
 
 ```ts
 import { publicKey } from '@metaplex-foundation/umi'
-import { burnV1 } from '@metaplex-foundation/mpl-core'
+import {
+  burn,
+  fetchAsset,
+  collectionAddress,
+  fetchCollection,
+} from '@metaplex-foundation/mpl-core'
 
-const asset = publicKey('11111111111111111111111111111111')
+const assetId = publicKey('11111111111111111111111111111111')
+const asset = await fetchAsset(umi, assetId)
 
-await burnV1(umi, {
+await burn(umi, {
   asset: asset,
 }).sendAndConfirm(umi)
 ```
@@ -96,12 +102,28 @@ Here is how you can use our SDKs to burn a Core asset that is part of a collecti
 import { publicKey } from '@metaplex-foundation/umi'
 import { burnV1, fetchAsset } from '@metaplex-foundation/mpl-core'
 
+import { publicKey } from '@metaplex-foundation/umi'
+import {
+  burn,
+  fetchAsset,
+  collectionAddress,
+  fetchCollection,
+} from '@metaplex-foundation/mpl-core'
+
 const assetId = publicKey('11111111111111111111111111111111')
-const asset = await fetchAssetV1(umi, assetId)
+const asset = await fetchAsset(umi, assetId)
+
+const collectionId = collectionAddress(asset)
 
-await burnV1(umi, {
-  asset: asset.publicKey,
-  collection: collectionAddress(asset),
+let collection = undefined
+
+if (collectionId) {
+  collection = await fetchCollection(umi, collection)
+}
+
+await burn(umi, {
+  asset: asset,
+  collection: collection,
 }).sendAndConfirm(umi)
 ```
 

+ 32 - 42
src/pages/core/collections.md

@@ -58,11 +58,11 @@ The following snippet creates a simple collection without Plugins or anything sp
 
 ```ts
 import { generateSigner } from '@metaplex-foundation/umi'
-import { createCollectionV1 } from '@metaplex-foundation/mpl-core'
+import { createCollection } from '@metaplex-foundation/mpl-core'
 
 const collectionSigner = generateSigner(umi)
 
-await createCollectionV1(umi, {
+await createCollection(umi, {
   collection: collectionSigner,
   name: 'My Collection',
   uri: 'https://example.com/my-collection.json',
@@ -123,39 +123,33 @@ The following snippet creates a collection with the [Royalties Plugin](/core/plu
 
 ```ts
 import { generateSigner, publicKey } from '@metaplex-foundation/umi'
-import {
-  createCollectionV1,
-  pluginAuthorityPair,
-  ruleSet,
-} from '@metaplex-foundation/core'
+import { createCollection, ruleSet } from '@metaplex-foundation/core'
 
 const collectionSigner = generateSigner(umi)
 
 const creator1 = publicKey('11111111111111111111111111111111')
 const creator2 = publicKey('22222222222222222222222222222222')
 
-await createCollectionV1(umi, {
+await createCollection(umi, {
   collection: collectionSigner,
   name: 'My NFT',
   uri: 'https://example.com/my-nft.json',
   plugins: [
-    pluginAuthorityPair({
+    {
       type: 'Royalties',
-      data: {
-        basisPoints: 500,
-        creators: [
-          {
-            address: creator1,
-            percentage: 20,
-          },
-          {
-            address: creator2,
-            percentage: 80,
-          },
-        ],
-        ruleSet: ruleSet('None'), // Compatibility rule set
-      },
-    }),
+      basisPoints: 500,
+      creators: [
+        {
+          address: creator1,
+          percentage: 20,
+        },
+        {
+          address: creator2,
+          percentage: 80,
+        },
+      ],
+      ruleSet: ruleSet('None'), // Compatibility rule set
+    },
   ],
 }).sendAndConfirm(umi)
 ```
@@ -233,7 +227,9 @@ To fetch a collection the following function can be used:
 import { fetchCollectionV1 } from '@metaplex-foundation/mpl-core'
 import { publicKey } from '@metaplex-foundation/umi'
 
-const collection = await fetchCollectionV1(umi, publicKey("11111111111111111111111111111111"))
+const collectionId = publicKey('11111111111111111111111111111111')
+
+const collection = await fetchCollection(umi, collectionId)
 
 console.log(collection)
 ```
@@ -302,14 +298,14 @@ A full detailed look at the on chain instruction it can be viewed on [Github](ht
 
 ```ts
 import { publicKey } from '@metaplex-foundation/umi'
-import { updateCollectionV1 } from '@metaplex-foundation/mpl-core'
+import { updateCollection } from '@metaplex-foundation/mpl-core'
 
 const collectionAddress = publicKey('1111111111111111111111111111111')
 
-await updateCollectionV1(umi, {
+await updateCollection(umi, {
   collection: collectionAddress,
-  newName: 'my-nft',
-  newUri: 'https://exmaple.com/new-uri',
+  name: 'my-nft',
+  uri: 'https://exmaple.com/new-uri',
 }).sendAndConfirm(umi)
 ```
 
@@ -396,26 +392,20 @@ A full detailed look at the on chain instruction it can be viewed on [Github](ht
 
 ```ts
 import { publicKey } from '@metaplex-foundation/umi'
-import {
-  updateCollectionPluginV1,
-  createPlugin,
-  ruleSet,
-} from '@metaplex-foundation/mpl-core'
+import { updateCollectionPlugin, ruleSet } from '@metaplex-foundation/mpl-core'
 
 const collectionAddress = publicKey('1111111111111111111111111111111')
 
 const newCreator = publicKey('5555555555555555555555555555555')
 
-await updateCollectionPluginV1(umi, {
+await updateCollectionPlugin(umi, {
   collection: collectionAddress,
-  plugin: createPlugin({
+  plugin: {
     type: 'Royalties',
-    data: {
-      basisPoints: 400,
-      creators: [{ address: newCreator, percentage: 100 }],
-      ruleSet: ruleSet('None'),
-    },
-  }),
+    basisPoints: 400,
+    creators: [{ address: newCreator, percentage: 100 }],
+    ruleSet: ruleSet('None'),
+  },
 }).sendAndConfirm(umi)
 ```
 

+ 10 - 10
src/pages/core/update.md

@@ -43,14 +43,15 @@ Here is how you can use our SDKs to update an MPL Core Asset.
 
 ```ts
 import { publicKey } from '@metaplex-foundation/umi'
-import { updateV1 } from '@metaplex-foundation/mpl-core'
+import { update, fetchAsset } from '@metaplex-foundation/mpl-core'
 
-const asset = publicKey('11111111111111111111111111111111')
+const assetId = publicKey('11111111111111111111111111111111')
+const asset = await fetchAsset(umi, assetId)
 
-await updateV1(umi, {
+await update(umi, {
   asset: asset,
-  newName: 'New Nft Name',
-  newUri: 'https://example.com/new-uri',
+  name: 'New Nft Name',
+  uri: 'https://example.com/new-uri',
 }).sendAndConfirm(umi)
 ```
 
@@ -108,15 +109,14 @@ Here is how you can use our SDKs to update an MPL Core Asset.
 
 ```ts
 import { publicKey } from '@metaplex-foundation/umi'
-import { updateV1 } from '@metaplex-foundation/mpl-core'
+import { update, fetchAsset } from '@metaplex-foundation/mpl-core'
 
-const asset = publicKey('11111111111111111111111111111111')
+const assetId = publicKey('11111111111111111111111111111111')
+const asset = await fetchAsset(umi, asset)
 
-await updateV1(umi, {
+await update(umi, {
   asset: asset,
   newUpdateAuthority: updateAuthority('None'),
-  newName: null,
-  newUri: null,
 }).sendAndConfirm(umi)
 ```