@paraspell/assets 8.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +137 -0
- package/dist/index.cjs +12648 -0
- package/dist/index.d.ts +262 -0
- package/dist/index.mjs +12611 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 ParaSpell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<br /><br />
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<h1 align="center">@paraspell/assets</h1>
|
|
5
|
+
<h4 align="center"> Pallet queries for Polkadot and Kusama Parachains. </h4>
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://npmjs.com/package/@paraspell/assets">
|
|
8
|
+
<img alt="version" src="https://img.shields.io/npm/v/@paraspell/assets?style=flat-square" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://npmjs.com/package/@paraspell/assets">
|
|
11
|
+
<img alt="downloads" src="https://img.shields.io/npm/dm/@paraspell/assets?style=flat-square" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://github.com/paraspell/xcm-sdk/actions">
|
|
14
|
+
<img alt="build" src="https://github.com/paraspell/xcm-sdk/actions/workflows/release.yml/badge.svg" />
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://snyk.io/test/github/paraspell/sdk">
|
|
17
|
+
<img alt="snyk" src="https://snyk.io/test/github/paraspell/sdk/badge.svg" />
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<br /><br />
|
|
23
|
+
<br /><br />
|
|
24
|
+
|
|
25
|
+
## Information
|
|
26
|
+
|
|
27
|
+
This package serves as a `core` component for both `@paraspell/sdk` and `@paraspell/sdk-pjs` and is `automatically` installed as a `dependency`. The package on its own offers functionality that can be imported separately and be used in front-end applications. It allows 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.
|
|
28
|
+
|
|
29
|
+
## Implementation
|
|
30
|
+
|
|
31
|
+
### Install package
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm | npm install || yarn add @paraspell/assets
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Import functionality
|
|
38
|
+
|
|
39
|
+
To use this functionality you first have to import it in the following way.
|
|
40
|
+
```ts
|
|
41
|
+
import { getAssetsObject, getAssetId, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, hasSupportForAsset, getAssetDecimals, getParaId, getTNode, getAssetMultiLocation, NODE_NAMES } from '@paraspell/assets'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Query assets object
|
|
46
|
+
This function returns `assets object` from `assets.json` for `particular Parachain` including information about `native` and `foreign` assets.
|
|
47
|
+
```ts
|
|
48
|
+
getAssetsObject('Acala')
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Query asset ID
|
|
52
|
+
This function returns `assetId` for `particular Parachain` and `asset symbol`
|
|
53
|
+
```ts
|
|
54
|
+
getAssetId('Acala', 'DOT')
|
|
55
|
+
```
|
|
56
|
+
### Query Relay chain asset symbol
|
|
57
|
+
This function returns the `symbol` of the Relay chain for a particular Parachain. Either "DOT" or "KSM"
|
|
58
|
+
```ts
|
|
59
|
+
getRelayChainSymbol('Basilisk')
|
|
60
|
+
```
|
|
61
|
+
### Query native assets
|
|
62
|
+
This function returns a string array of `native` assets symbols for a particular Parachain
|
|
63
|
+
```ts
|
|
64
|
+
getNativeAssets('Acala')
|
|
65
|
+
```
|
|
66
|
+
### Query foreign assets
|
|
67
|
+
This function returns an object array of foreign assets for a particular Parachain. Each object has a symbol and assetId property
|
|
68
|
+
```ts
|
|
69
|
+
getOtherAssets('Acala')
|
|
70
|
+
```
|
|
71
|
+
### Query all asset symbols
|
|
72
|
+
Function returns string array of all asset symbols for a specific Parachain. (native and foreign assets are merged into a single array)
|
|
73
|
+
```ts
|
|
74
|
+
getAllAssetsSymbols('Acala')
|
|
75
|
+
```
|
|
76
|
+
### Query asset support
|
|
77
|
+
The function checks if Parachain supports a particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
78
|
+
```ts
|
|
79
|
+
hasSupportForAsset(node: TNode, symbol: string)
|
|
80
|
+
```
|
|
81
|
+
### Query asset decimals
|
|
82
|
+
The function returns decimals for a specific asset
|
|
83
|
+
```ts
|
|
84
|
+
getAssetDecimals('Basilisk', 'KSM')
|
|
85
|
+
```
|
|
86
|
+
### Query Parachain ID
|
|
87
|
+
The function returns specific Parachain id
|
|
88
|
+
```ts
|
|
89
|
+
getParaId('Basilisk')
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Query Parachain name
|
|
93
|
+
Function to get specific TNode from Parachain id
|
|
94
|
+
```ts
|
|
95
|
+
getTNode(nodeID: number, ecosystem: 'polkadot' || 'kusama' || 'ethereum') //When Ethereum ecosystem is selected please fill nodeID as 1 to select Ethereum.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Import Parachains as constant
|
|
99
|
+
Import all compatible Parachains as constant
|
|
100
|
+
```ts
|
|
101
|
+
console.log(NODE_NAMES)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Convert id or symbol to multilocation
|
|
105
|
+
Get multilocation for asset id or symbol.
|
|
106
|
+
```ts
|
|
107
|
+
getAssetMultiLocation(chainFrom, { symbol: symbol } | { id: assetId })
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 💻 Tests
|
|
111
|
+
|
|
112
|
+
- Run compilation using `pnpm compile`
|
|
113
|
+
|
|
114
|
+
- Run linter using `pnpm lint`
|
|
115
|
+
|
|
116
|
+
- Run unit tests using `pnpm test`
|
|
117
|
+
|
|
118
|
+
- Update Parachain registered assets in the map using script - `pnpm updateAssets`
|
|
119
|
+
|
|
120
|
+
- Update existential deposits in the map using script - `pnpm updateEds`
|
|
121
|
+
|
|
122
|
+
Assets can be tested in [Playground](https://playground.paraspell.xyz/xcm-sdk/assets).
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
Made with 💛 by [ParaSpell✨](https://paraspell.xyz/)
|
|
127
|
+
|
|
128
|
+
Published under [MIT License](https://github.com/paraspell/xcm-tools/blob/main/packages/assets/LICENSE).
|
|
129
|
+
|
|
130
|
+
## Support
|
|
131
|
+
|
|
132
|
+
<div align="center">
|
|
133
|
+
<p align="center">
|
|
134
|
+
<img width="200" alt="version" src="https://user-images.githubusercontent.com/55763425/211145923-f7ee2a57-3e63-4b7d-9674-2da9db46b2ee.png" />
|
|
135
|
+
<img width="200" alt="version" src="https://github.com/paraspell/xcm-sdk/assets/55763425/9ed74ebe-9b29-4efd-8e3e-7467ac4caed6" />
|
|
136
|
+
</p>
|
|
137
|
+
</div>
|