Skip to content

Commit

Permalink
Merge pull request #147 from UniqueNetwork/basic-docs
Browse files Browse the repository at this point in the history
SDK: remove outdated documentation
  • Loading branch information
Maksandre authored Apr 24, 2024
2 parents 0723882 + 0695431 commit 3307a2f
Show file tree
Hide file tree
Showing 39 changed files with 957 additions and 1,457 deletions.
1 change: 0 additions & 1 deletion docs/.vuepress/components/HomePageSections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<div v-for="item in menu" :class="$style.item">
<RouterLink :to="item.path">
<img :src="withBase(`/images/icons/${item.iconName}.svg`)" :class="$style.icon"/>
<div :class="$style.icon" v-html="item.icon"/>
<div :class="$style.title" v-html="item.title"/>
<div :class="$style.subtitle" v-html="item.subtitle"/>
</RouterLink>
Expand Down
102 changes: 102 additions & 0 deletions docs/.vuepress/components/WalletTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<template>
<div :class="$style.root">
<div v-for="item in wallets" :class="$style.item">
<a :href="item.path" target="_blank" rel="noopener noreferrer">
<img :src="withBase(`/images/wallets/${item.iconName}.svg`)" :class="$style.icon"/>
<h2 :class="$style.title" v-html="item.title"></h2>
</a>
</div>
</div>
</template>

<script setup lang="ts">
import {withBase} from '@vuepress/client';
interface WalletItem {
title: string
path: string
iconName: string
}
const wallets: WalletItem[] = [
{
title: 'Polkadot.js',
path: 'https://polkadot.js.org/extension/',
iconName: 'polkadotjs',
},
{
title: 'Metamask',
path: 'https://metamask.io/download/',
iconName: 'metamask',
},
{
title: 'Talisman',
path: 'https://www.talisman.xyz/',
iconName: 'talisman',
},
{
title: 'SubWallet',
path: 'https://www.subwallet.app/download.html',
iconName: 'subwallet'
},
{
title: 'Enkrypt',
path: 'https://www.enkrypt.com/',
iconName: 'enkrypt',
},
{
title: 'Nova Wallet',
path: 'https://novawallet.io/',
iconName: 'nova'
}
];
</script>

<style lang="scss" module>
.root {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.item {
width: 250px;
display: flex;
flex-direction: column;
align-items: center;
background-color: var(--c-bg-light);
border-radius: 12px;
overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
cursor: pointer;
}
.item:hover {
transform: translateY(-5px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.icon {
width: 120px;
height: 120px;
object-fit: contain;
padding: 20px;
}
.title {
font-size: 20px;
color: var(--c-text-hover);
width: 100%;
padding: 20px;
text-align: center;
font-weight: 600;
margin: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
text-decoration: none;
}
</style>
54 changes: 32 additions & 22 deletions docs/.vuepress/configs/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,11 @@ 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/getting-started.md',
'/build/sdk/accounts.md',
'/build/sdk/collections.md',
'/build/sdk/tokens.md',
'/build/sdk/examples-nesting.md',
]
},
{
Expand All @@ -96,10 +89,7 @@ export const sidebar: Record<string, SidebarConfig> = {
{
text: 'SDK guides',
children: [
'/tutorials/how-to-accounts.md',
'/tutorials/work-with-accounts.md',
'/tutorials/how-to-collections.md',
'/tutorials/how-to-tokens.md',
// '/tutorials/accounts/create-account.md', - how-to-accounts.md
// '/tutorials/getAccountAndBalance.md', - how-to-accounts.md
// '/tutorials/create-collection-token.md', - exists in how-to-collections.md + how-to-tokens.md
Expand Down Expand Up @@ -161,9 +151,21 @@ export const sidebar: Record<string, SidebarConfig> = {
'/tutorials/getNFTsAndTokens.md',
'/tutorials/easy-market.md',
// '/tutorials/how-to-use-nesting-and-bundling.md', -> moved to SDK nesting
'/tutorials/ledger-connect.md',
]
},
{
text: 'User guides',
children: [
{
text: 'Choose your wallet',
link: '/tutorials/user-guides/wallets.md',
children: [
'/tutorials/user-guides/polkadotjs.md',
'/tutorials/user-guides/ledger-connect.md'
]
},
]
}
],
'/reference': [
{
Expand All @@ -172,6 +174,13 @@ export const sidebar: Record<string, SidebarConfig> = {
'/reference',
]
},
{
text: "SDK",
children: [
'/reference/sdk-endpoints.md',
'/reference/sdk-methods.md'
]
},
{
text: 'EVM',
children: [
Expand All @@ -181,12 +190,13 @@ export const sidebar: Record<string, SidebarConfig> = {
{
text: 'Blockchain API',
children: [
'/reference/rpc.md',
'/reference/extrinsics.md',
'/reference/events.md',
'/reference/nesting.md',
'/reference/owner-admin-roles.md',
],
'/reference/blockchain/collections.md',
'/reference/blockchain/properties.md',
'/reference/blockchain/nesting.md',
'/reference/blockchain/owner-admin-roles.md',
'/reference/blockchain/rpc.md',
'/reference/blockchain/extrinsics.md',
'/reference/blockchain/events.md', ],
},
],
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 0 additions & 37 deletions docs/_todo/collection-limits.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/build/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Unique Network provides various tools for application development.

- [SDK](./sdk/) for the most friendly developer experience and advanced capabilities.
- [SDK](./sdk/getting-started.md) for the most friendly developer experience and advanced capabilities.
- [EVM tools](./evm/) if you want to use smart contracts in your application.
43 changes: 13 additions & 30 deletions docs/tutorials/how-to-accounts.md → docs/build/sdk/accounts.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
# How to work with accounts

# Working with accounts
<!-- TODO review this doc -->
[[toc]]

## Creating a Substrate address via the browser extension

Unique Network, like most blockchains, is based on [accounts or addresses](/concepts/addresses/index.md). An address can own some QTZ or UNQ tokens, NFTs or some ERC-20 tokens. It can sign transactions to transfer these valuable assets to other addresses or to make some actions in Decentralized Apps (dApps). For example, an address can buy and sell NFTs on the NFT Marketplace.

A typical Quartz address looks like this: `yGHuU9CWnrHMUz8GJRmpA9MowmtMKZvnq2tLc5mk3zMFizW5X`

So, to purchase and sell tokens on the Market, you need to have a Unique Network account. To create a new account, you should get an address that can own NFTs and allow you to manage KSM. The best way to get an address is to install the **Polkadot{.js} browser extension** [for Chrome](https://chrome.google.com/webstore/detail/polkadot%7Bjs%7D-extension/mopnmbcafieddcagagdcbnhejhlodfdd) or [for Firefox](https://addons.mozilla.org/en-US/firefox/addon/polkadot-js-extension/). This browser extension manages accounts and allows you to sign transactions with these accounts.

To create a Unique Network account:
1. Download the [Polkadot{.js} extension](https://polkadot.js.org/extension/) and add it to your browser.
2. Click on the Polkadot{.js} extension in your browser.
3. In the **Authorize** window, read the disclaimer and click **Yes, allow this application access**.
4. Click the **Add Account** icon (**+**) and then click **Create new account**. This will generate your wallet address and the 12-word mnemonic seed – the series of words that can be used to restore your wallet. :warning: Copy this seed and keep it a safe place. :warning:
![Seed](./images/seed.png)
5. Select "I have saved my mnemonic seed safely" and click **Next step**.
6. On the next screen, in the _NETWORK_ drop-down menu, select **Allow use on any chain**. Add a name for your account and create a new password by entering the password twice.
![AccountName](./images/acc-name.png)
7. Click **Add the account with the generated seed**. Your newly created account is now displayed in the Accounts window.
![AccountList](./images/acc-list.png)

Each account has an icon displayed next to the account name. Clicking this icon, you copy the account address to the clipboard.
## Creating a Substrate address with wallets

- [Choose from supported wallets](../../tutorials/user-guides/wallets.md)
- [Create account via Polkadot.js browser extension](../../tutorials/user-guides/polkadotjs.md)
- [Learn how to connect Ledger](../../tutorials/user-guides/ledger-connect.md)

## Create an account via code
## Create an account via SDK

In this tutorial, we will go through the entire process of creating an account using the Unique Network SDK.

Consider using how you can create or get an account using the [Accounts](https://www.npmjs.com/package/@unique-nft/accounts) package.
Consider how you can create or get an account using the [Accounts](https://www.npmjs.com/package/@unique-nft/accounts) package.

You will need to come up with or generate a mnemonic phrase (this is a set of words that can be used to create and restore your wallet).
You will need to create or generate a mnemonic phrase (a set of words that can be used to create and restore your wallet).

:warning: Never share your mnemonic phrase with anyone. If someone gets access to your mnemonic phrase, they can steal your funds.

Expand Down Expand Up @@ -74,7 +57,7 @@ console.log(account);

### Get an account from mnemonic

If you already have a mnemonic phrase, you can use it to get an account. Here is how the phrase looks like:
If you already have a mnemonic phrase, you can use it to get an account. Here is what the phrase looks like:

``
affair spoon other impact target solve extra range cute myself float panda
Expand Down Expand Up @@ -126,7 +109,7 @@ const account = await getAccountFromMnemonic({

### Providers

If you need to get an account from one specific provider, then it is not necessary to create an Accounts object, you can contact the provider directly:
If you need to get an account from one specific provider, then it is not necessary to create an Accounts object. You can contact the provider directly:

```typescript:no-line-numbers
import { Account } from '@unique-nft/accounts';
Expand Down Expand Up @@ -224,7 +207,7 @@ const signer = await provider.first();

### Get accounts

You can use the [Accounts](https://www.npmjs.com/package/@unique-nft/accounts) package to work with accounts easily.
You can use the [Accounts](https://www.npmjs.com/package/@unique-nft/accounts) package to easily manage accounts.

The package allows connecting with different accounts. To get an accounts list, you need to create an instance of the `Accounts` class and connect the necessary providers to it:

Expand Down Expand Up @@ -285,7 +268,7 @@ import { KeyringLocalProvider } from '@unique-nft/accounts/keyring-local';
const options: KeyringLocalOptions = {
type: 'sr25519', //
passwordCallback: async (keyring: KeyringPair) => {
... // here you need to ask the user to enter a password to sign the transaction and return it from this callback
... // here you need to ask the user to enter a password to sign the transaction and return it from this callback
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# How to work with collections

# Working with collections
<!-- TODO review this page -->
[[toc]]

## Intro
Expand All @@ -21,11 +21,11 @@ In Unique Network, the collection has the following entities:

## Prerequisites

We'll need a Substrate address to use in this example. If you do not have it yet, please check [Create an account](../tutorials/how-to-accounts.md#create-an-account-via-code).
We'll need a Substrate address to use in this example. If you do not have it yet, please check [working with account](./accounts.md#create-an-account-via-sdk).

And, since some Opal tokens are required to pay for the transaction fees as well (around 2 to 2.5 OPL), please make sure that your balance has some tokens. These can be obtained via the [Telegram faucet bot](https://t.me/unique2faucet_opal_bot).

We will use SDK and some other packages in this section. To learn how to install SDK, please refer to [SDK Installation](../sdk/installation.md).
We will use SDK and some other packages in this section. To learn how to install SDK, please refer to [getting started](./getting-started.md).

## Collection creation

Expand All @@ -34,7 +34,7 @@ We will use SDK and some other packages in this section. To learn how to install
Please find below a full sample code that creates an account from a mnemonic phrase, initializes SDK, and then creates a collection on the Opal testnet.

:warning: Please note that you need to use your mnemonic phrase, or even use another way to initialize your account
(see [Create an account](../tutorials/how-to-accounts.md#create-an-account-via-code)).
(see [Create an account](./accounts.md#create-an-account-via-sdk)).

<CodeGroup>
<CodeGroupItem title = "SDK">
Expand Down Expand Up @@ -294,7 +294,7 @@ curl -X 'GET' \

Your NFT collection have a bunch of various properties such as limits, permissions, token attributes and some others. Some of them you can set only while collection creation, but others you can set up later, when your collection is already created.

You can find the list of SDK methods, that you can use to adjust your collection [here](../sdk/methods.md#collection).
You can find the list of SDK methods, that you can use to adjust your collection [here](../../reference/sdk-methods.md).

For example, let's update the collection limits using `sdk.collections.setLimits` method. The method sets some collection limits and starts enforcing them immediately. By the way, only the collection owner has the permission to call this method.

Expand Down
Loading

0 comments on commit 3307a2f

Please sign in to comment.