Skip to content

Commit

Permalink
SDK: remove outdated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksandre committed Apr 1, 2024
1 parent 0723882 commit fb22cf5
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 815 deletions.
19 changes: 8 additions & 11 deletions docs/.vuepress/configs/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ export const sidebar: Record<string, SidebarConfig> = {
text: 'SDK',
children: [
'/build/sdk',
'/build/sdk/examplesSubstrateREST.md',
'/build/sdk/examplesSDK.md',
'/build/sdk/examplesLifeNFT.md',
'/build/sdk/examplesNesting.md',
// '/build/sdk/installation.md', -> moved to other pages
'/build/sdk/architecture.md',
'/build/sdk/methods.md',
'/build/sdk/ios.md',
'/build/sdk/android.md',
'/build/sdk/C_sharp.md',
// '/build/sdk/tools.md', -> this info exists in Tutorials section
'/build/sdk/examples-nesting.md',
]
},
{
Expand Down Expand Up @@ -170,6 +160,13 @@ export const sidebar: Record<string, SidebarConfig> = {
text: 'Blockchains',
children: [
'/reference',
'/reference/sdk-endpoints.md'
]
},
{
text: "SDK",
children: [
'/reference/sdk-methods.md'
]
},
{
Expand Down
82 changes: 82 additions & 0 deletions docs/build/sdk/examples-nesting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Nesting

The **nesting** feature allows you to create **nested tokens**. Thus, the topmost token will have a wallet address as its owner, while the owner of tokens nested in it will be the token above it.
The entire chain of nested tokens will be called a **bundle**. If you transfer a top-level token to another owner, all tokens in the bundle will go with it.

> If you don't know how to create collections and tokens, start from [the beginning](./index.md)
## Nesting permission

Nesting is not allowed by default. You need to set special permissions at the collection level during creation.

<!-- TODO create a reference article about permissions -->

```typescript
const creationResult = await sdk.collection.create.submitWaitResult({
name: "Test collection",
description: "My test collection",
tokenPrefix: "TST",
// Token owners and collection admins are allowed to nest tokens:
permissions: {
nesting: {
tokenOwner: true,
collectionAdmin: true,
// You can set collection ids allowed for nesting:
// restricted: [1]
},
},
});
```

## Creating bundles

```typescript
async function main() {
// ... Create collection and NFTs
// and get their IDs (collectionId, firstTokenId, secondTokenId)


await sdk.token.nest({
parent: { collectionId, tokenId: firstTokenId },
nested: { collectionId, tokenId: secondTokenId },
});
}

main();
```

## Check if the token is bundle

- To check if the token is part of a bundle, use `isBundle`
- To get the hole bundle tree, use `getBundle`

```typescript
const { isBundle } = await sdk.token.isBundle({
collectionId,
tokenId: token1Id,
});

console.log('token 1 isBundle?', isBundle);

const getBundleResult = await sdk.token.getBundle({
collectionId,
tokenId: token1Id,
});

console.log('getBundleResult:', getBundleResult);
```


## Unnest

The reverse process is called unnesting, when a token no longer belongs to any token and its owner becomes the wallet address.

```typescript
const { parsed, error } = await sdk.token.unnest.submitWaitResult({
nested: { collectionId, tokenId: token2Id },
});
```

After unnesting the token with tokenId=2 is no longer part of the bundle. Neither is the token with tokenId=1 - because it no longer has any attached tokens.

Read more about nesting functions in the [reference](../../reference/sdk-methods.md)
206 changes: 0 additions & 206 deletions docs/build/sdk/examplesNesting.md

This file was deleted.

Loading

0 comments on commit fb22cf5

Please sign in to comment.