Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanphan committed Mar 13, 2024
1 parent 28365ff commit 5e262db
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
23 changes: 20 additions & 3 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ A Umi-compatible JavaScript library for the project.
// Create an asset
const assetAddress = generateSigner(umi);
const owner = generateSigner(umi);

await create(umi, {
name: 'Test Asset',
uri: 'https://example.com/asset.json',
Expand All @@ -67,8 +67,22 @@ A Umi-compatible JavaScript library for the project.
authority: collectionUpdateAuthority, // optional, defaults to payer
}).sendAndConfirm(umi);

// Transfer an asset
const recipient = generateSigner(umi);
await transfer(umi, {
asset: assetAddress.publicKey,
newOwner: recipient.publicKey,
}).sendAndConfirm(umi);

// Transfer an asset belonging to a collection
await transfer(umi, {
asset: assetAddress.publicKey,
newOwner: recipient.publicKey,
collection: collectionAddress.publicKey,
}).sendAndConfirm(umi);

// Fetch an asset
const asset = await fetchAsset(umi, assetAddress.publicKey)
const asset = await fetchAsset(umi, assetAddress.publicKey);

// GPA fetch assets by owner
const assetsByOwner = await getAssetGpaBuilder(umi)
Expand All @@ -77,7 +91,10 @@ A Umi-compatible JavaScript library for the project.

// GPA fetch assets by collection
const assetsByCollection = await getAssetGpaBuilder(umi)
.whereField('updateAuthority', updateAuthority('Collection', [collectionAddress.publicKey]))
.whereField(
'updateAuthority',
updateAuthority('Collection', [collectionAddress.publicKey])
)
.getDeserialized();

// DAS API (RPC based indexing) fetch assets by owner/collection
Expand Down
15 changes: 15 additions & 0 deletions clients/js/src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
pluginAuthorityPair,
revokePluginAuthority,
ruleSet,
transfer,
updateAuthority,
} from './index';

Expand Down Expand Up @@ -48,6 +49,20 @@ const example = async () => {
authority: collectionUpdateAuthority, // optional, defaults to payer
}).sendAndConfirm(umi);

// Transfer an asset
const recipient = generateSigner(umi);
await transfer(umi, {
asset: assetAddress.publicKey,
newOwner: recipient.publicKey,
}).sendAndConfirm(umi);

// Transfer an asset in a collection
await transfer(umi, {
asset: assetAddress.publicKey,
newOwner: recipient.publicKey,
collection: collectionAddress.publicKey,
}).sendAndConfirm(umi);

// Fetch an asset
const asset = await fetchAsset(umi, assetAddress.publicKey);

Expand Down

0 comments on commit 5e262db

Please sign in to comment.