Skip to content

Commit

Permalink
Refactor XCM SDK pages
Browse files Browse the repository at this point in the history
  • Loading branch information
dudo50 committed Mar 8, 2024
1 parent ed017dc commit 400270d
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 207 deletions.
40 changes: 20 additions & 20 deletions docs/.vitepress/cache/deps/@theme_index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/.vitepress/cache/deps/_metadata.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"hash": "fd4e14ff",
"browserHash": "da24b300",
"hash": "35f0d3e0",
"browserHash": "25c38c39",
"optimized": {
"vue": {
"src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
"file": "vue.js",
"fileHash": "485c8bf5",
"fileHash": "4c03b848",
"needsInterop": false
},
"@theme/index": {
"src": "../../../../node_modules/vitepress/dist/client/theme-default/index.js",
"file": "@theme_index.js",
"fileHash": "afd2ace0",
"fileHash": "b8519eb0",
"needsInterop": false
}
},
Expand Down
19 changes: 10 additions & 9 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export default {
{ text: 'Welcome to ParaSpell✨', link: '/' },
]
},
{
text: 'ParaSpell✨ XCM SDK',
items: [
{ text: 'Getting started', link: '/sdk/getting-started' },
{ text: 'Send XCM', link: '/sdk/xcmPallet' },
{ text: 'Asset query', link: '/sdk/AssetPallet' },
{ text: 'Create HRMP channels', link: '/sdk/HRMP' },
{ text: 'Query XCM pallets', link: '/sdk/NodePallets' },
]
},
{
text: 'LightSpell⚡️ XCM API',
items: [
Expand All @@ -46,15 +56,6 @@ export default {
{ text: 'Router playground', link: '/router/playground' },
]
},
{
text: 'ParaSpell✨ XCM SDK',
items: [
{ text: 'Getting started', link: '/sdk/getting-started' },
{ text: 'Asset pallet', link: '/sdk/AssetPallet' },
{ text: 'HRMP pallet', link: '/sdk/HRMP' },
{ text: 'Node pallets', link: '/sdk/NodePallets' },
{ text: 'XCM pallet', link: '/sdk/xcmPallet' }, ]
},
{
text: 'Might interest you 🔭',
items: [
Expand Down
28 changes: 14 additions & 14 deletions docs/sdk/AssetPallet.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
# Asset pallet
This pallet serves to retrieve asset data from compatible Parachains. Users can retrieve details like `asset decimals`, `registered assets on particular Parachain`, `check if the asset is registered on Parachain` and more.
# Asset 💰 query operations for your front-end
This functionality serves to retrieve asset data from compatible Parachains. Users can retrieve details like `asset decimals`, `registered assets on particular Parachain`, `check if the asset is registered on Parachain` and more.

## New video guide for this section:
### Video guide for this section:
[
![assetPallet](https://user-images.githubusercontent.com/55763425/238154687-c506cd39-887d-4135-8144-eca64f17e6ed.png)
](https://youtu.be/jjGbXXqtElk)

## Retrieve assets object for a specific Parachain
## Query assets object
This function returns `assets object` from `assets.json` for `particular Parachain` including information about `native` and `foreign` assets.
```js
paraspell.assets.getAssetsObject('Acala')
```

## Retrieve asset ID for particular Parachain and asset
## Query asset ID
This function returns `assetId` for `particular Parachain` and `asset symbol`
```js
paraspell.assets.getAssetId('Acala', 'tDOT')
```
## Retrieve the Relay chain asset Symbol for a particular Parachain
## Query Relay chain asset symbol
This function returns the `symbol` of the Relay chain for a particular Parachain. Either "DOT" or "KSM"
```js
paraspell.assets.getRelayChainSymbol('Basilisk')
```
## Retrieve native assets for a particular Parachain
## Query native assets
This function returns a string array of `native` assets symbols for a particular Parachain
```js
paraspell.assets.getNativeAssets('Acala')
```
## Retrieve foreign assets for a particular Parachain
## Query foreign assets
This function returns an object array of foreign assets for a particular Parachain. Each object has a symbol and assetId property
```js
paraspell.assets.getOtherAssets('Acala')
```
## Retrieve all asset symbols for particular Parachain
## Query all asset symbols
Function returns string array of all asset symbols for a specific Parachain. (native and foreign assets are merged into a single array)
```js
paraspell.assets.getAllAssetsSymbols('Acala')
```
## Retrieve support for a particular asset on a particular Parachain
## Query asset support
The function checks if Parachain supports a particular asset. (Both native and foreign assets are searched). Returns boolean
```js
paraspell.assets.hasSupportForAsset(node: TNode, symbol: string)
```
## Retrieve decimals of a particular asset for a particular Parachain
## Query asset decimals
The function returns decimals for a specific asset
```js
paraspell.assets.getAssetDecimals('Basilisk', 'KSM')
```
## Retrieve Parachain ID for a particular Parachain
## Query Parachain ID
The function returns specific Parachain id
```js
paraspell.assets.getParaId('Basilisk')
```

## Retrieve Parachain name from Parachain ID
## Query Parachain name
Function to get specific TNode from Parachain id
```js
paraspell.assets.getTNode(nodeID: number)
```

## Import SDK compatible Parachains as constant
## Import Parachains as constant
Import all compatible Parachains as constant
```js
paraspell.NODE_NAMES
Expand Down
73 changes: 38 additions & 35 deletions docs/sdk/HRMP.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
# HRMP pallet, every possible call variation explained
### There are two scenarios we use in our SDK. These are:
- Opening HRMP channels between Parachains
- Closing HRMP channels between Parachains
# Create channels between Parachains 🌐
### SDK allows you to:
- Open HRMP channels between Parachains
- Close HRMP channels between Parachains

## New video guide for this section:
*(This pallet only works on Locally launched network. These functions require sudo access)*


### Video guide for this section:
[
![hrmpPallets](https://user-images.githubusercontent.com/55763425/238154733-cef698ac-f00f-4e74-8c4f-1e0d7cfe4059.png)
](https://youtu.be/8iXQZhyNrPM)

### There are also two possible ways that our SDK allows you to construct your HRMP calls:
- Construct your calls via Builder pattern (recommended, easy to use)
- Construct them in classic function-like way

Both of these ways will be explained.

*(This pallet only works on Locally launched network. These functions require sudo access)*

## Builder pattern HRMP call to open channels
## Open HRMP channel
When opening a new channel the operation has to be specified by providing `origin` & `destination` Parachains, calling the `openChannel()` method and then providing `maxSize` and `maxMessageSize` parameters.

### Builder pattern

```js
Builder(api)
.from('Karura') // Origin Parachain
Expand All @@ -29,8 +26,25 @@ When opening a new channel the operation has to be specified by providing `origi
.build()
```

## Builder pattern HRMP call to close channels
### Function pattern

```js
paraspell.openChannels.openChannel(
{
api,
origin, // Origin Parachain
destination, // Destination Parachain
maxSize, // Max size
maxMessageSize // Max message size
}
)
```

## Close HRMP channel
When closing channels the operation has to be specified by providing the `origin` Parachain, calling the `closeChannel()` method and then providing `inbound` and `outbound` parameters.

### Builder pattern

```js
Builder(api)
.from('Karura') //Origin Parachain
Expand All @@ -40,31 +54,20 @@ When closing channels the operation has to be specified by providing the `origin
.build()
```

## Function pattern HRMP call to open channel
Same as the Builder pattern, this pattern requires the same details to construct. When opening a new channel the operation has to be specified by providing `origin` & `destination` Parachains, calling the `openChannel()` method and then providing `maxSize` and `maxMessageSize` parameters.

```js
paraspell.openChannels.openChannel(
api,
origin, // Origin Parachain
destination, // Destination Parachain
maxSize, // Max size
maxMessageSize // Max message size
)
### Function pattern

```
## Function pattern HRMP call to close the channel
Same as the Builder pattern, this pattern requires the same details to construct. When closing channels the operation has to be specified by providing the `origin` Parachain, calling the `closeChannel()` method and then providing `inbound` and `outbound` parameters.
```js
paraspell.closeChannels.closeChannel(
api,
origin, // Origin Parachain
inbound, // Inbound
outbound // Outbound
)

{
api,
origin, // Origin Parachain
inbound, // Inbound
outbound // Outbound
}
)
```


## Developer experience

### Builder pattern experience
Expand Down
12 changes: 6 additions & 6 deletions docs/sdk/NodePallets.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# Parachain pallets
# Query which XCM pallet Parachain uses 📦

This functionality allows developers to query the `XCM pallets` that Parachains currently support.

## New video guide for this section:
### Video guide for this section:
[
![xcmPallets](https://user-images.githubusercontent.com/55763425/238154722-aedb5798-0cfe-4f0d-875c-dea5c60373eb.png)
](https://youtu.be/oE1JttYN1zY)

## Importing functionality
## Import functionality

To use this functionality you first have to import it in the following way.
```js
import { getDefaultPallet, getSupportedPallets, SUPPORTED_PALLETS } from '@paraspell/sdk'
```

## Return default pallet for specific Parachain
## Get default XCM pallet

The function returns the default XCM pallet for selected compatible Parachain.
```js
getDefaultPallet(node: TNode)
```

## Return an array of supported pallets for specific Parachain
## Get all supported XCM pallets

The function returns all supported XCM pallets for selected compatible Parachain.
```js
getSupportedPallets(node: TNode)
```

## Print all pallets that are currently supported
## Print all supported XCM pallets

This returns all supported XCM pallets supported by compatible Parachains as constant.
```js
Expand Down
47 changes: 15 additions & 32 deletions docs/sdk/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,34 @@
# Getting started
# Getting started with your journey accross Paraverse 👨‍🚀

#### Since version 1.0.0
Our SDK introduced all Polkadot libraries as peer dependencies. The reason for this is, that most of the projects use these libraries in some way already and it fixes issues with unmet dependency warnings. Make sure your project has them. You can install them by the following command:
This guide guides you through implementation of XCM SDK that allows you to do various exciting actions on Polkadot and Kusama chains. To start proceed with steps mentioned below. Good luck adventurer!

##### Install dependencies
## Install dependencies
Choose your package provider and proceed to install dependencies to your project.
```sh
# npm
npm install @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config @polkadot/util
```
```sh
# yarn
yarn add @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config @polkadot/util
```
```sh
# pnpm
pnpm install @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config @polkadot/util
pnpm | npm | yarn install @polkadot/api @polkadot/types @polkadot/api-base @polkadot/apps-config @polkadot/util
```

**To get started install the following package (depending on your package manager of choice):**
```sh
# npm
npm install @paraspell/sdk
```
## Install XCM SDK package
Choose your package provider and proceed to install XCM SDK to your project.
```sh
# yarn
yarn add @paraspell/sdk
```
```sh
# pnpm
pnpm install @paraspell/sdk
pnpm | npm | yarn install @paraspell/sdk
```

## Importing package
After installing the package there are two ways of importing it:
## Import package
There are two ways to import package to your project. Importing builder or classic import.

### 1. Builder pattern - in case you plan to use XCM & XCMP functionality only
This way allows you to enhance builder patterns and construct your calls in a simple way.
### Builder import
Builder import is restricted for sending XCM messages and opening HRMP channels.
```js
import { Builder } from '@paraspell/sdk'
```

### 2. Classic pattern and Asset pallet functionality
### Classic import
Classic import allows you to use every functionality XCM SDK offers.
```js
// ESM
import * as paraspell from '@paraspell/sdk'
```
```js

// CommonJS
const { } = require('@paraspell/sdk')
```
Expand Down
Loading

0 comments on commit 400270d

Please sign in to comment.