@paraspell/sdk-pjs 13.2.2 → 13.4.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/README.md +57 -20
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +305 -371
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<img alt="build" src="https://github.com/paraspell/xcm-tools/actions/workflows/ci.yml/badge.svg" />
|
|
15
15
|
</a>
|
|
16
16
|
</p>
|
|
17
|
-
<p>Supporting every XCM Active Parachain <a href = "https://paraspell.github.io/docs/supported.html"\>[list]</p>
|
|
17
|
+
<p>Supporting every XCM Active Parachain <a href = "https://paraspell.github.io/docs/supported-chains.html"\>[list]</p>
|
|
18
18
|
<p>SDK documentation <a href = "https://paraspell.github.io/docs/" \>[here]</p>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
@@ -41,9 +41,9 @@ npm install | pnpm add | yarn add @polkadot/api @polkadot/types @polkadot/api-ba
|
|
|
41
41
|
npm install | pnpm add | yarn add @paraspell/sdk-pjs
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
### Install Swap extension
|
|
44
|
+
### (OPTIONAL) Install Swap extension
|
|
45
45
|
|
|
46
|
-
If you plan to [do Swap XCMs](https://paraspell.github.io/docs/sdk/
|
|
46
|
+
If you plan to [do Swap XCMs](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#swap) you can install Swap package which allows you to do cross-chain swaps on popular Polkadot, Kusama, Paseo, Westend exchanges. Now available in all JS client versions of SDK.
|
|
47
47
|
|
|
48
48
|
> [!IMPORTANT]
|
|
49
49
|
> - ⚠️ **WebAssembly (Wasm) must be enabled in your project** because of the Hydration SDK (One of the exchanges implemented in XCM Router). Wasm can be enabled either through the web application configuration or through the appropriate plugin.
|
|
@@ -54,7 +54,7 @@ If you plan to [do Swap XCMs](https://paraspell.github.io/docs/sdk/xcmPallet.htm
|
|
|
54
54
|
npm install | pnpm add | yarn add @paraspell/swap @galacticcouncil/api-augment
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
#### Setup Swap extension
|
|
58
58
|
|
|
59
59
|
Add the `@paraspell/swap` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
60
60
|
|
|
@@ -67,6 +67,46 @@ export default function App() {
|
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
### (OPTIONAL) Install EVM extension
|
|
71
|
+
If you plan to [do EVM contract transfers](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#moonbeam-xtokens-smart-contract) you can install EVM package which allows you to interact with EVM contract based XCMs on Moonbeam, Moonriver and Darwinia. Available in **ALL** versions of SDK.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install | pnpm add | yarn add @paraspell/evm
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Setup EVM extension
|
|
78
|
+
|
|
79
|
+
Add the `@paraspell/evm` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// Import EVM extension here
|
|
83
|
+
import '@paraspell/evm';
|
|
84
|
+
|
|
85
|
+
export default function App() {
|
|
86
|
+
return {/* Your app here */};
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### (OPTIONAL) Install Snowbridge extension
|
|
91
|
+
If you plan to [do Snowbridge transfers from Ethereum](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#ethereum-polkadot-transfer) you can install Snowbridge package which allows you to input "Ethereum" as from chain parameter. Available in **ALL** versions of SDK.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install | pnpm add | yarn add @paraspell/evm-snowbridge
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Setup Snowbridge extension
|
|
98
|
+
|
|
99
|
+
Add the `@paraspell/evm-snowbridge` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// Import Snowbridge extension here
|
|
103
|
+
import '@paraspell/evm-snowbridge';
|
|
104
|
+
|
|
105
|
+
export default function App() {
|
|
106
|
+
return {/* Your app here */};
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
70
110
|
### Importing SDK functionality
|
|
71
111
|
|
|
72
112
|
Named import:
|
|
@@ -84,18 +124,15 @@ import * as paraspell from '@paraspell/sdk-pjs'
|
|
|
84
124
|
## Implementation
|
|
85
125
|
|
|
86
126
|
> [!NOTE]
|
|
87
|
-
> - You can now pass signer directly into sender parameter
|
|
88
|
-
> - The local transfers now have additional builder parameter called keepAlive
|
|
89
|
-
> - Transact is here! Find out more: https://paraspell.github.io/docs/sdk/xcmPallet.html#transact
|
|
90
|
-
>
|
|
91
127
|
> **Latest news:**
|
|
92
128
|
> - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
|
|
93
|
-
> - Swap
|
|
94
|
-
> -
|
|
129
|
+
> - Swap extension is now available on every XCM SDK version: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-swap-extension
|
|
130
|
+
> - EVM extension is now available: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-evm-extension
|
|
131
|
+
> - Snowbridge extension is now available: https://paraspell.github.io/docs/xcm-sdk/getting-started.html#install-snowbridge-extension
|
|
95
132
|
|
|
96
133
|
|
|
97
134
|
### Sending XCM
|
|
98
|
-
For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
135
|
+
For full documentation on XCM Transfers head over to [official documentation](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html).
|
|
99
136
|
|
|
100
137
|
#### Transfer assets from Substrate to Substrate
|
|
101
138
|
|
|
@@ -174,7 +211,7 @@ await builder.disconnect()
|
|
|
174
211
|
|
|
175
212
|
```ts
|
|
176
213
|
const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
177
|
-
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
214
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
178
215
|
.to(TChain) // Has to be same as origin (from)
|
|
179
216
|
.currency(CURRENCY_SPEC) // Refer to currency spec options below
|
|
180
217
|
.sender(sender | PAPI SIGNER)
|
|
@@ -193,8 +230,8 @@ await builder.disconnect()
|
|
|
193
230
|
|
|
194
231
|
```ts
|
|
195
232
|
const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
196
|
-
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
197
|
-
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
233
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
234
|
+
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
198
235
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/})
|
|
199
236
|
.recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address location in one object (x2)*/)
|
|
200
237
|
.sender(address | PAPI_SIGNER /*Only in PAPI SDK*/ | {address, PJS_SIGNER} /*Only in PJS SDK*/) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub/Hydration with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
@@ -308,7 +345,7 @@ await builder.disconnect()
|
|
|
308
345
|
|
|
309
346
|
### XCM Fee queries
|
|
310
347
|
|
|
311
|
-
For full documentation with output examples of XCM Fee queries, head to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
348
|
+
For full documentation with output examples of XCM Fee queries, head to [official documentation](https://paraspell.github.io/docs/xcm-sdk/xcm-utils.html).
|
|
312
349
|
|
|
313
350
|
#### XCM Fee (Origin and Dest.)
|
|
314
351
|
|
|
@@ -424,8 +461,8 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
424
461
|
|
|
425
462
|
```ts
|
|
426
463
|
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
427
|
-
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
428
|
-
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/
|
|
464
|
+
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
465
|
+
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/xcm-sdk/asset-package.html#import-chains-as-types
|
|
429
466
|
.currency(CURRENCY_SPEC)
|
|
430
467
|
.recipient(RECIPIENT_ADDRESS)
|
|
431
468
|
.sender(SENDER_ADDRESS)
|
|
@@ -473,7 +510,7 @@ let result = convertSs58(ADDRESS, TChain) // returns converted address in string
|
|
|
473
510
|
|
|
474
511
|
### Asset queries:
|
|
475
512
|
|
|
476
|
-
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
513
|
+
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/xcm-sdk/asset-package.html).
|
|
477
514
|
|
|
478
515
|
```ts
|
|
479
516
|
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk-pjs'
|
|
@@ -523,7 +560,7 @@ CHAINS
|
|
|
523
560
|
|
|
524
561
|
### Parachain XCM Pallet queries
|
|
525
562
|
|
|
526
|
-
For full documentation with output examples of pallet queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/
|
|
563
|
+
For full documentation with output examples of pallet queries, head over to [official documentation](https://paraspell.github.io/docs/xcm-sdk/pallet-package.html).
|
|
527
564
|
|
|
528
565
|
```ts
|
|
529
566
|
import { getDefaultPallet, getSupportedPallets, getPalletIndex, getNativeAssetsPallet, getOtherAssetsPallets, SUPPORTED_PALLETS } from '@paraspell/sdk-pjs';
|
|
@@ -609,7 +646,7 @@ console.log(CHAINS)
|
|
|
609
646
|
|
|
610
647
|
## Contribute to XCM Tools and earn rewards 💰
|
|
611
648
|
|
|
612
|
-
We run an open Bug Bounty Program that rewards contributors for reporting and fixing bugs in the project. More information on bug bounty can be found in the [official documentation](https://paraspell.github.io/docs/contribution.html).
|
|
649
|
+
We run an open Bug Bounty Program that rewards contributors for reporting and fixing bugs in the project. More information on bug bounty can be found in the [official documentation](https://paraspell.github.io/docs/contribution-guidelines.html).
|
|
613
650
|
|
|
614
651
|
## Get Support 🚑
|
|
615
652
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import { WithApi,
|
|
2
|
+
import { WithApi, TChain, TCurrencyInputWithAmount, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, TApiOrUrl, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions } from '@paraspell/sdk-core';
|
|
3
3
|
export * from '@paraspell/sdk-core';
|
|
4
4
|
import * as _polkadot_api from '@polkadot/api';
|
|
5
5
|
import { ApiPromise } from '@polkadot/api';
|
|
@@ -7,7 +7,7 @@ import { SubmittableExtrinsic, Signer } from '@polkadot/api/types';
|
|
|
7
7
|
import * as ethers from 'ethers';
|
|
8
8
|
import { Signer as Signer$1, AbstractProvider } from 'ethers';
|
|
9
9
|
import { WalletClient } from 'viem';
|
|
10
|
-
import
|
|
10
|
+
import * as _snowbridge_api_dist_transfers_toPolkadot_transferInterface from '@snowbridge/api/dist/transfers/toPolkadot/transferInterface';
|
|
11
11
|
|
|
12
12
|
type TPjsApi = ApiPromise;
|
|
13
13
|
type Extrinsic = SubmittableExtrinsic<'promise'>;
|
|
@@ -15,6 +15,7 @@ type TPjsSigner = {
|
|
|
15
15
|
signer: Signer;
|
|
16
16
|
address: string;
|
|
17
17
|
};
|
|
18
|
+
type TEvmChainFrom = Extract<TChain, 'Ethereum' | 'Moonbeam' | 'Moonriver' | 'Darwinia'>;
|
|
18
19
|
type TEvmBuilderOptionsBase = {
|
|
19
20
|
/**
|
|
20
21
|
* The source chain. Can be either 'Ethereum', 'Moonbeam', 'Moonriver', or 'Darwinia'.
|
|
@@ -105,6 +106,8 @@ declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
108
|
* Builder class for constructing transfers from Ethereum to Polkadot.
|
|
109
|
+
*
|
|
110
|
+
* @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
|
|
108
111
|
*/
|
|
109
112
|
declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuilderOptions<TApi, TRes, TSigner>> = object> {
|
|
110
113
|
protected readonly _options: T;
|
|
@@ -173,6 +176,7 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuild
|
|
|
173
176
|
*/
|
|
174
177
|
declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object>;
|
|
175
178
|
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPjsApi, Extrinsic, TPjsSigner>> = object> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T>;
|
|
179
|
+
/** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
|
|
176
180
|
declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
177
181
|
api: _paraspell_sdk_core.PolkadotApi<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner>;
|
|
178
182
|
provider: AbstractProvider | undefined;
|
|
@@ -200,7 +204,7 @@ declare const depositToken: (signer: Signer$1, amount: bigint, symbol: string) =
|
|
|
200
204
|
*/
|
|
201
205
|
declare const transferEthToPolkadot$1: <TApi, TRes, TSigner>({ api, provider, signer, recipient, to, currency }: TPjsEvmBuilderOptions<TApi, TRes, TSigner>) => Promise<{
|
|
202
206
|
response: ethers.TransactionResponse;
|
|
203
|
-
messageReceipt:
|
|
207
|
+
messageReceipt: _snowbridge_api_dist_transfers_toPolkadot_transferInterface.MessageReceipt;
|
|
204
208
|
}>;
|
|
205
209
|
|
|
206
210
|
declare const getTokenBalance: (signer: Signer$1, symbol: string) => Promise<bigint>;
|
|
@@ -242,4 +246,4 @@ declare namespace transfer {
|
|
|
242
246
|
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => Promise<_polkadot_api.ApiPromise>;
|
|
243
247
|
|
|
244
248
|
export { Builder, EvmBuilder, approveToken, assets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, transferEthToPolkadot, transfer as xcmPallet };
|
|
245
|
-
export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsEvmBuilderOptions, TPjsSigner };
|
|
249
|
+
export type { Extrinsic, GeneralBuilder, TEvmChainFrom, TPjsApi, TPjsEvmBuilderOptions, TPjsSigner };
|