@paraspell/sdk-pjs 13.0.0-rc.1 → 13.0.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 +197 -71
- package/dist/index.d.ts +11 -12
- package/dist/index.mjs +61 -44
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -44,7 +44,33 @@ npm install | pnpm add | yarn add @polkadot/api @polkadot/types @polkadot/api-ba
|
|
|
44
44
|
npm install | pnpm add | yarn add @paraspell/sdk-pjs
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
###
|
|
47
|
+
### Install Swap extension
|
|
48
|
+
|
|
49
|
+
If you plan to [do Swap XCMs](https://paraspell.github.io/docs/sdk/xcmPallet.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.
|
|
50
|
+
|
|
51
|
+
> [!IMPORTANT]
|
|
52
|
+
> - ⚠️ **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.
|
|
53
|
+
>
|
|
54
|
+
> - ⚠️ Additionally, Hydration requires the use of the **augment package** (see: https://github.com/galacticcouncil/sdk/issues/114).
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install | pnpm add | yarn add @paraspell/swap @galacticcouncil/api-augment
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Setup Swap extension
|
|
61
|
+
|
|
62
|
+
Add the `@paraspell/swap` import to your application's root component (Usually `App.tsx`). This ensures the extension is registered before using Builder.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// Import swap extension here
|
|
66
|
+
import '@paraspell/swap';
|
|
67
|
+
|
|
68
|
+
export default function App() {
|
|
69
|
+
return {/* Your app here */};
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Importing SDK functionality
|
|
48
74
|
|
|
49
75
|
Named import:
|
|
50
76
|
```ts
|
|
@@ -61,13 +87,14 @@ import * as paraspell from '@paraspell/sdk-pjs'
|
|
|
61
87
|
## Implementation
|
|
62
88
|
|
|
63
89
|
> [!NOTE]
|
|
64
|
-
> -
|
|
65
|
-
> - V11 > V12 Migration guide https://paraspell.github.io/docs/migration/v11-to-v12.html
|
|
66
|
-
>
|
|
67
|
-
> **Latest news:**
|
|
68
|
-
> - You can now pass signer directly into senderAddress parameter
|
|
90
|
+
> - You can now pass signer directly into sender parameter
|
|
69
91
|
> - The local transfers now have additional builder parameter called keepAlive
|
|
70
92
|
> - Transact is here! Find out more: https://paraspell.github.io/docs/sdk/xcmPallet.html#transact
|
|
93
|
+
>
|
|
94
|
+
> **Latest news:**
|
|
95
|
+
> - V12 > V13 Migration guide: https://paraspell.github.io/docs/migration/v12-to-v13.html
|
|
96
|
+
> - Swap package is now available on every XCM SDK version: https://paraspell.github.io/docs/sdk/getting-started.html#install-swap-extension
|
|
97
|
+
> - abstractDecimals is now turned on by default!
|
|
71
98
|
|
|
72
99
|
|
|
73
100
|
### Sending XCM
|
|
@@ -80,15 +107,15 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
80
107
|
.from(TSubstrateChain)
|
|
81
108
|
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/)
|
|
82
109
|
.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*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..])
|
|
83
|
-
.
|
|
84
|
-
.
|
|
110
|
+
.recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address Location in one object (x2)*/)
|
|
111
|
+
.sender(address | {address, PJS_Signer}) // - OPTIONAL but strongly recommended as it is automatically ignored when not needed - Used when origin is AssetHub with feeAsset or when sending to AssetHub to prevent asset traps by auto-swapping to DOT to have DOT ED.
|
|
85
112
|
/*.ahAddress(ahAddress) - OPTIONAL - used when origin is EVM chain and XCM goes through AssetHub (Multihop transfer where we are unable to convert Key20 to ID32 address eg. origin: Moonbeam & destination: Ethereum (Multihop goes from Moonbeam > AssetHub > BridgeHub > Ethereum)
|
|
86
113
|
.feeAsset({symbol: 'symbol'} || {id: 'id'} || {location: 'location'}) // Optional parameter used when multiasset is provided or when origin is AssetHub - so user can pay in fees different than DOT
|
|
87
114
|
.xcmVersion(Version.V3/V4/V5) //Optional parameter for manual override of XCM Version used in call
|
|
88
115
|
.customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some chain but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
|
|
89
116
|
|
|
90
117
|
const tx = await builder.build()
|
|
91
|
-
// Or if you use signers in
|
|
118
|
+
// Or if you use signers in sender:
|
|
92
119
|
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
93
120
|
|
|
94
121
|
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
@@ -101,9 +128,9 @@ const builder = Builder()
|
|
|
101
128
|
.to('Polkadot')
|
|
102
129
|
.currency({
|
|
103
130
|
symbol: 'DOT',
|
|
104
|
-
amount: '
|
|
131
|
+
amount: '1'
|
|
105
132
|
})
|
|
106
|
-
.
|
|
133
|
+
.recipient(address)
|
|
107
134
|
|
|
108
135
|
const tx = await builder.build()
|
|
109
136
|
|
|
@@ -119,7 +146,7 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
119
146
|
.from(TSubstrateChain)
|
|
120
147
|
.to(TChain) //Has to be the same as the origin (from)
|
|
121
148
|
.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*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..])
|
|
122
|
-
.
|
|
149
|
+
.recipient(address)
|
|
123
150
|
/* .keepAlive(bool) - Optional: Allows draining the account below the existential deposit. */
|
|
124
151
|
|
|
125
152
|
|
|
@@ -135,9 +162,9 @@ const builder = Builder()
|
|
|
135
162
|
.to('Hydration')
|
|
136
163
|
.currency({
|
|
137
164
|
symbol: 'DOT',
|
|
138
|
-
amount: '
|
|
165
|
+
amount: '1'
|
|
139
166
|
})
|
|
140
|
-
.
|
|
167
|
+
.recipient(address)
|
|
141
168
|
|
|
142
169
|
const tx = await builder.build()
|
|
143
170
|
|
|
@@ -153,18 +180,45 @@ const builder = Builder(/*client | builder_config | ws_url | [ws_url, ws_url,..]
|
|
|
153
180
|
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
154
181
|
.to(TChain) // Has to be same as origin (from)
|
|
155
182
|
.currency(CURRENCY_SPEC) // Refer to currency spec options below
|
|
156
|
-
.
|
|
157
|
-
.
|
|
183
|
+
.sender(sender | PAPI SIGNER)
|
|
184
|
+
.recipient(address)
|
|
158
185
|
.transact(hex, /* originType, TWeight - Optional */)
|
|
159
186
|
|
|
160
187
|
const tx = await builder.build()
|
|
161
|
-
// Or if you use signers in
|
|
188
|
+
// Or if you use signers in sender:
|
|
162
189
|
// await builder.signAndSubmit() - Signs and submits the transaction; returns TX hash for tracking
|
|
163
190
|
|
|
164
191
|
//Disconnect API after TX
|
|
165
192
|
await builder.disconnect()
|
|
166
193
|
```
|
|
167
194
|
|
|
195
|
+
#### Swap
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const builder = Builder(/*client | builder_config |ws_url | [ws_url, ws_url,..] - Optional*/)
|
|
199
|
+
.from(TSubstrateChain) // 'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
200
|
+
.to(TChain /*,customParaId - optional*/ | Location object /*Only works for PolkadotXCM pallet*/) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
201
|
+
.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*/})
|
|
202
|
+
.recipient(address | Location object /*If you are sending through xTokens, you need to pass the destination and address location in one object (x2)*/)
|
|
203
|
+
.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.
|
|
204
|
+
.swap({
|
|
205
|
+
currencyTo: {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*/}
|
|
206
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
207
|
+
// slippage: 1, - Optional - 1 by default
|
|
208
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
209
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
210
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
const tx = await builder.buildAll()
|
|
214
|
+
// Or if you use signers in sender:
|
|
215
|
+
// await builder.signAndSubmit() - Signs and submits the transaction (only working in 1click scenarios); returns TX hash for tracking
|
|
216
|
+
// await builder.signAndSubmitAll() - Signs and submits transactions (required in 2click scenarios); returns array of TX hashes for tracking
|
|
217
|
+
|
|
218
|
+
// Make sure to disconnect API after it is no longer used (eg. after transaction)
|
|
219
|
+
await builder.disconnect()
|
|
220
|
+
```
|
|
221
|
+
|
|
168
222
|
#### Dry run your XCM Calls:
|
|
169
223
|
```ts
|
|
170
224
|
//Builder pattern
|
|
@@ -172,9 +226,17 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
172
226
|
.from(TSubstrateChain)
|
|
173
227
|
.to(TChain)
|
|
174
228
|
.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*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
175
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency
|
|
176
|
-
|
|
177
|
-
|
|
229
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.
|
|
230
|
+
.swap({
|
|
231
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
232
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
233
|
+
// slippage: 1, - Optional - 1 by default
|
|
234
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
235
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
236
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
237
|
+
})*/
|
|
238
|
+
.recipient(ADDRESS)
|
|
239
|
+
.sender(address | {address, PJS_Signer})
|
|
178
240
|
.dryRun()
|
|
179
241
|
|
|
180
242
|
//Check Parachain for DryRun support - returns true/false
|
|
@@ -191,8 +253,8 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
191
253
|
.to(TChain)
|
|
192
254
|
.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*/} | {[{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}]})
|
|
193
255
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
194
|
-
.
|
|
195
|
-
.
|
|
256
|
+
.recipient(ADDRESS)
|
|
257
|
+
.sender(address | {address, PJS_Signer})
|
|
196
258
|
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
197
259
|
```
|
|
198
260
|
|
|
@@ -203,13 +265,13 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
203
265
|
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
204
266
|
.to(TChain2) //Any compatible Parachain
|
|
205
267
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
206
|
-
.
|
|
268
|
+
.recipient(address | Location object)
|
|
207
269
|
.addToBatch()
|
|
208
270
|
|
|
209
271
|
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
210
272
|
.to(TChain3) //Any compatible Parachain
|
|
211
273
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
212
|
-
.
|
|
274
|
+
.recipient(address | Location object)
|
|
213
275
|
.addToBatch()
|
|
214
276
|
|
|
215
277
|
const tx = await builder.buildBatch({
|
|
@@ -221,23 +283,6 @@ const tx = await builder.buildBatch({
|
|
|
221
283
|
await builder.disconnect()
|
|
222
284
|
```
|
|
223
285
|
|
|
224
|
-
#### Asset claim:
|
|
225
|
-
|
|
226
|
-
```ts
|
|
227
|
-
//Claim XCM trapped assets from the selected chain
|
|
228
|
-
const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
229
|
-
.claimfrom(TSubstrateChain)
|
|
230
|
-
.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*/} | [{currencySelection /*for example symbol: symbol or id: id, or location: location*/, amount: amount /*Use "ALL" to transfer everything*/}, {currencySelection}, ..]
|
|
231
|
-
)
|
|
232
|
-
.address(address | Location object)
|
|
233
|
-
/*.xcmVersion(Version.V3) Optional parameter, by default chain specific version. XCM Version ENUM if a different XCM version is needed (Supported V3 & V4 & V5). Requires importing Version enum.*/
|
|
234
|
-
|
|
235
|
-
const tx = await builder.build()
|
|
236
|
-
|
|
237
|
-
//Make sure to disconnect the API after it is no longer used (eg, after a transaction)
|
|
238
|
-
await builder.disconnect()
|
|
239
|
-
```
|
|
240
|
-
|
|
241
286
|
### Localhost test setup
|
|
242
287
|
|
|
243
288
|
```ts
|
|
@@ -253,11 +298,11 @@ const builder = await Builder({
|
|
|
253
298
|
.from(TSubstrateChain)
|
|
254
299
|
.to(TChain)
|
|
255
300
|
.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*/} | [{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}])
|
|
256
|
-
.
|
|
257
|
-
.
|
|
301
|
+
.recipient(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
|
|
302
|
+
.sender(address | {address, PJS_Signer}) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
258
303
|
|
|
259
304
|
const tx = await builder.build()
|
|
260
|
-
//Or if you use prederived account as
|
|
305
|
+
//Or if you use prederived account as sender:
|
|
261
306
|
//await builder.signAndSubmit()
|
|
262
307
|
|
|
263
308
|
//Disconnect API after TX
|
|
@@ -275,9 +320,17 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
275
320
|
.from(TSubstrateChain)
|
|
276
321
|
.to(TChain)
|
|
277
322
|
.currency(CURRENCY_SPEC)
|
|
278
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
279
|
-
|
|
280
|
-
|
|
323
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
324
|
+
.swap({
|
|
325
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
326
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
327
|
+
// slippage: 1, - Optional - 1 by default
|
|
328
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
329
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
330
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
331
|
+
})*/
|
|
332
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
333
|
+
.sender(address | {address, PJS_Signer})
|
|
281
334
|
.getXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of a DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin or Destination chain do not support DryRun out of the box.
|
|
282
335
|
```
|
|
283
336
|
|
|
@@ -289,8 +342,8 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
289
342
|
.to(TChain)
|
|
290
343
|
.currency(CURRENCY_SPEC)
|
|
291
344
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
292
|
-
.
|
|
293
|
-
.
|
|
345
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
346
|
+
.sender(address | {address, PJS_Signer})
|
|
294
347
|
.getOriginXcmFee(/*{disableFallback: true / false}*/) //Fallback is optional. When fallback is disabled, you only get notified of a DryRun error, but no Payment info query fallback is performed. Payment info is still performed if Origin do not support DryRun out of the box.
|
|
295
348
|
```
|
|
296
349
|
|
|
@@ -301,8 +354,8 @@ const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
301
354
|
.to(TChain)
|
|
302
355
|
.currency(CURRENCY_SPEC)
|
|
303
356
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
304
|
-
.
|
|
305
|
-
.
|
|
357
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
358
|
+
.sender(address | {address, PJS_Signer})
|
|
306
359
|
.getTransferInfo()
|
|
307
360
|
```
|
|
308
361
|
|
|
@@ -312,9 +365,17 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
312
365
|
.from(TSubstrateChain)
|
|
313
366
|
.to(TChain)
|
|
314
367
|
.currency(CURRENCY_SPEC)
|
|
315
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
316
|
-
|
|
317
|
-
|
|
368
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
369
|
+
.swap({
|
|
370
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
371
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
372
|
+
// slippage: 1, - Optional - 1 by default
|
|
373
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
374
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
375
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
376
|
+
})*/
|
|
377
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
378
|
+
.sender(address | {address, PJS_Signer})
|
|
318
379
|
.getTransferableAmount()
|
|
319
380
|
```
|
|
320
381
|
|
|
@@ -324,9 +385,17 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
324
385
|
.from(TSubstrateChain)
|
|
325
386
|
.to(TChain)
|
|
326
387
|
.currency(CURRENCY_SPEC)
|
|
327
|
-
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency
|
|
328
|
-
|
|
329
|
-
|
|
388
|
+
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.
|
|
389
|
+
.swap({
|
|
390
|
+
currencyTo: CURRENCY_SPEC, //Reffer to currency spec options above
|
|
391
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
392
|
+
// slippage: 1, - Optional - 1 by default
|
|
393
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
394
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
395
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
396
|
+
})*/
|
|
397
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
398
|
+
.sender(address | {address, PJS_Signer})
|
|
330
399
|
.getMinTransferableAmount()
|
|
331
400
|
```
|
|
332
401
|
|
|
@@ -337,8 +406,8 @@ const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url
|
|
|
337
406
|
.to(TChain)
|
|
338
407
|
.currency(CURRENCY_SPEC)
|
|
339
408
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
340
|
-
.
|
|
341
|
-
.
|
|
409
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
410
|
+
.sender(address | {address, PJS_Signer})
|
|
342
411
|
.getReceivableAmount()
|
|
343
412
|
```
|
|
344
413
|
|
|
@@ -349,11 +418,31 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
349
418
|
.to(TChain)
|
|
350
419
|
.currency(CURRENCY_SPEC)
|
|
351
420
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
352
|
-
.
|
|
353
|
-
.
|
|
421
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
422
|
+
.sender(address | {address, PJS_Signer})
|
|
354
423
|
.verifyEdOnDestination()
|
|
355
424
|
```
|
|
356
425
|
|
|
426
|
+
#### Get best amount out
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array - optional*/)
|
|
430
|
+
.from(TSubstrateChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
431
|
+
.to(TChain) //'AssetHubPolkadot' | 'Hydration' | 'Moonbeam' | 'Polkadot' | ... https://paraspell.github.io/docs/sdk/AssetPallet.html#import-chains-as-types
|
|
432
|
+
.currency(CURRENCY_SPEC)
|
|
433
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
434
|
+
.sender(SENDER_ADDRESS)
|
|
435
|
+
.swap({
|
|
436
|
+
currencyTo: CURRENCY_SPEC,
|
|
437
|
+
// exchange: ['AssetHubPolkadot'], - Optional parameter - 'Hydration' | 'Acala' | 'AssetHubPolkadot' | ...
|
|
438
|
+
// slippage: 1, - Optional - 1 by default
|
|
439
|
+
// evmSenderAddress: '0x000', - Optional parameter when origin CHAIN is EVM based (Required with evmSigner)
|
|
440
|
+
// evmSigner: Signer, - Optional parameter when origin CHAIN is EVM based (Required with evmInjectorAddress)
|
|
441
|
+
// onStatusChange: (event) => void - Optional parameter for callback events when sender address is supplied as signer
|
|
442
|
+
})
|
|
443
|
+
.getBestAmountOut();
|
|
444
|
+
```
|
|
445
|
+
|
|
357
446
|
#### Asset balance
|
|
358
447
|
```ts
|
|
359
448
|
import { getBalance } from "@paraspell/sdk-pjs";
|
|
@@ -390,7 +479,7 @@ let result = convertSs58(ADDRESS, TChain) // returns converted address in string
|
|
|
390
479
|
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
|
|
391
480
|
|
|
392
481
|
```ts
|
|
393
|
-
import { getSupportedDestinations, getFeeAssets, getAssetsObject,
|
|
482
|
+
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk-pjs'
|
|
394
483
|
|
|
395
484
|
//Get chains that support the specific asset related to origin
|
|
396
485
|
getSupportedDestinations(TChain, CURRENCY)
|
|
@@ -413,9 +502,6 @@ getAssetLocation(TChain, { symbol: symbol } | { id: assetId })
|
|
|
413
502
|
// Retrieve assets object from assets.json for a particular chain, including information about native and foreign assets
|
|
414
503
|
getAssetsObject(TChain)
|
|
415
504
|
|
|
416
|
-
// Retrieve foreign assetId for a particular chain and asset symbol
|
|
417
|
-
getAssetId(TChain, ASSET_SYMBOL)
|
|
418
|
-
|
|
419
505
|
// Retrieve the symbol of the relay chain for a particular chain. Either "DOT" or "KSM"
|
|
420
506
|
getRelayChainSymbol(TChain)
|
|
421
507
|
|
|
@@ -428,12 +514,6 @@ getOtherAssets(TChain)
|
|
|
428
514
|
// Retrieve string array of all asset symbols. (native and foreign assets are merged into a single array)
|
|
429
515
|
getAllAssetsSymbols(TChain)
|
|
430
516
|
|
|
431
|
-
// Check if a chain supports a particular asset. (Both native and foreign assets are searched). Returns boolean
|
|
432
|
-
hasSupportForAsset(TChain, ASSET_SYMBOL)
|
|
433
|
-
|
|
434
|
-
// Get decimals for specific asset
|
|
435
|
-
getAssetDecimals(TChain, ASSET_SYMBOL)
|
|
436
|
-
|
|
437
517
|
// Get specific chain id
|
|
438
518
|
getParaId(TChain)
|
|
439
519
|
|
|
@@ -470,6 +550,52 @@ getOtherAssetsPallets(chain: TChain)
|
|
|
470
550
|
console.log(SUPPORTED_PALLETS)
|
|
471
551
|
```
|
|
472
552
|
|
|
553
|
+
### Import chains as types
|
|
554
|
+
There are 6 options for types you can choose based on your prefference
|
|
555
|
+
|
|
556
|
+
```ts
|
|
557
|
+
// Import all exchange chains (Swap)
|
|
558
|
+
import type { TExchangeChain } from "@paraspell/sdk-pjs"
|
|
559
|
+
|
|
560
|
+
// Import all Parachains
|
|
561
|
+
import type { TParachain } from "@paraspell/sdk-pjs"
|
|
562
|
+
|
|
563
|
+
// Import all Relay chains
|
|
564
|
+
import type { TRelaychain } from "@paraspell/sdk-pjs"
|
|
565
|
+
|
|
566
|
+
// Import all Substrate chains (Parachains + Relays)
|
|
567
|
+
import type { TSubstrateChain } from "@paraspell/sdk-pjs"
|
|
568
|
+
|
|
569
|
+
// Import chains outside Polkadot ecosystem (Ethereum)
|
|
570
|
+
import type { TExternalChain } from "@paraspell/sdk-pjs"
|
|
571
|
+
|
|
572
|
+
// Import all chains implemented in ParaSpell
|
|
573
|
+
import type { TChain } from "@paraspell/sdk-pjs"
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Import chains as constant
|
|
577
|
+
There are 6 options for constants you can choose based on your prefference
|
|
578
|
+
|
|
579
|
+
```ts
|
|
580
|
+
// Print all exchange chains (Swap)
|
|
581
|
+
console.log(EXCHANGE_CHAINS)
|
|
582
|
+
|
|
583
|
+
// Print all Parachains
|
|
584
|
+
console.log(PARACHAINS)
|
|
585
|
+
|
|
586
|
+
// Print all Relay chains
|
|
587
|
+
console.log(RELAYCHAINS)
|
|
588
|
+
|
|
589
|
+
// Print all Substrate chains (Parachains + Relays)
|
|
590
|
+
console.log(SUBSTRATE_CHAINS)
|
|
591
|
+
|
|
592
|
+
// Print chains outside Polkadot ecosystem (Ethereum)
|
|
593
|
+
console.log(EXTERNAL_CHAINS)
|
|
594
|
+
|
|
595
|
+
// Print all chains implemented in ParaSpell
|
|
596
|
+
console.log(CHAINS)
|
|
597
|
+
```
|
|
598
|
+
|
|
473
599
|
## 💻 Tests
|
|
474
600
|
- Run compilation using `pnpm compile`
|
|
475
601
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import {
|
|
2
|
+
import { WithApi, TEvmChainFrom, 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';
|
|
@@ -10,7 +10,6 @@ import { WalletClient } from 'viem';
|
|
|
10
10
|
import { toPolkadotV2 } from '@snowbridge/api';
|
|
11
11
|
|
|
12
12
|
type TPjsApi = ApiPromise;
|
|
13
|
-
type TPjsApiOrUrl = TApiOrUrl<TPjsApi>;
|
|
14
13
|
type Extrinsic = SubmittableExtrinsic<'promise'>;
|
|
15
14
|
type TPjsSigner = {
|
|
16
15
|
signer: Signer;
|
|
@@ -54,7 +53,7 @@ type TPjsEvmBuilderOptions<TApi, TRes, TSigner> = WithApi<TEvmBuilderOptionsBase
|
|
|
54
53
|
declare const getBalance: (options: _paraspell_sdk_core.TGetBalanceCommonOptions & {
|
|
55
54
|
currency?: _paraspell_sdk_core.TCurrencyCore;
|
|
56
55
|
} & {
|
|
57
|
-
api?:
|
|
56
|
+
api?: _paraspell_sdk_core.TApiOrUrl<TPjsApi>;
|
|
58
57
|
}) => Promise<bigint>;
|
|
59
58
|
|
|
60
59
|
declare const assets_Foreign: typeof Foreign;
|
|
@@ -172,10 +171,10 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuild
|
|
|
172
171
|
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
173
172
|
* @returns A new Builder instance.
|
|
174
173
|
*/
|
|
175
|
-
declare const Builder: (api?: TBuilderOptions<
|
|
174
|
+
declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object>;
|
|
176
175
|
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPjsApi, Extrinsic, TPjsSigner>> = object> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T>;
|
|
177
|
-
declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<
|
|
178
|
-
api: _paraspell_sdk_core.
|
|
176
|
+
declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => EvmBuilderCore<unknown, unknown, unknown, {
|
|
177
|
+
api: _paraspell_sdk_core.PolkadotApi<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner>;
|
|
179
178
|
provider: AbstractProvider | undefined;
|
|
180
179
|
}>;
|
|
181
180
|
|
|
@@ -207,17 +206,17 @@ declare const transferEthToPolkadot$1: <TApi, TRes, TSigner>({ api, provider, si
|
|
|
207
206
|
declare const getTokenBalance: (signer: Signer$1, symbol: string) => Promise<bigint>;
|
|
208
207
|
|
|
209
208
|
declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<Extrinsic> & {
|
|
210
|
-
api?:
|
|
209
|
+
api?: TApiOrUrl<TPjsApi>;
|
|
211
210
|
}) => Promise<_paraspell_sdk_core.TDryRunResult>;
|
|
212
211
|
declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<Extrinsic> & {
|
|
213
|
-
api?:
|
|
212
|
+
api?: TApiOrUrl<TPjsApi>;
|
|
214
213
|
}) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
|
|
215
214
|
declare const transferEthToPolkadot: (options: Omit<TPjsEvmBuilderOptions<TPjsApi, Extrinsic, TPjsSigner>, "api">) => ReturnType<typeof transferEthToPolkadot$1>;
|
|
216
|
-
declare const getParaEthTransferFees: (api?:
|
|
215
|
+
declare const getParaEthTransferFees: (api?: TApiOrUrl<TPjsApi>) => Promise<[bigint, bigint]>;
|
|
217
216
|
/**
|
|
218
217
|
* Gets the Ethereum bridge status.
|
|
219
218
|
*/
|
|
220
|
-
declare const getBridgeStatus: (api?:
|
|
219
|
+
declare const getBridgeStatus: (api?: TApiOrUrl<TPjsApi>) => Promise<_paraspell_sdk_core.TBridgeStatus>;
|
|
221
220
|
|
|
222
221
|
declare const transfer_approveToken: typeof approveToken;
|
|
223
222
|
declare const transfer_depositToken: typeof depositToken;
|
|
@@ -240,7 +239,7 @@ declare namespace transfer {
|
|
|
240
239
|
};
|
|
241
240
|
}
|
|
242
241
|
|
|
243
|
-
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<
|
|
242
|
+
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => Promise<_polkadot_api.ApiPromise>;
|
|
244
243
|
|
|
245
244
|
export { Builder, EvmBuilder, approveToken, assets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, transferEthToPolkadot, transfer as xcmPallet };
|
|
246
|
-
export type { Extrinsic, GeneralBuilder, TPjsApi,
|
|
245
|
+
export type { Extrinsic, GeneralBuilder, TPjsApi, TPjsEvmBuilderOptions, TPjsSigner };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner,
|
|
1
|
+
import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
|
|
4
4
|
import { u8aConcat, compactToU8a, u8aEq, isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
@@ -15,6 +15,10 @@ function _arrayLikeToArray(r, a) {
|
|
|
15
15
|
function _arrayWithoutHoles(r) {
|
|
16
16
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
17
17
|
}
|
|
18
|
+
function _assertThisInitialized(e) {
|
|
19
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
18
22
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
19
23
|
try {
|
|
20
24
|
var i = n[a](c),
|
|
@@ -40,6 +44,9 @@ function _asyncToGenerator(n) {
|
|
|
40
44
|
});
|
|
41
45
|
};
|
|
42
46
|
}
|
|
47
|
+
function _callSuper(t, o, e) {
|
|
48
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
49
|
+
}
|
|
43
50
|
function _classCallCheck(a, n) {
|
|
44
51
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
45
52
|
}
|
|
@@ -110,6 +117,31 @@ function _defineProperty(e, r, t) {
|
|
|
110
117
|
writable: true
|
|
111
118
|
}) : e[r] = t, e;
|
|
112
119
|
}
|
|
120
|
+
function _getPrototypeOf(t) {
|
|
121
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
122
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
123
|
+
}, _getPrototypeOf(t);
|
|
124
|
+
}
|
|
125
|
+
function _inherits(t, e) {
|
|
126
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
127
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
128
|
+
constructor: {
|
|
129
|
+
value: t,
|
|
130
|
+
writable: true,
|
|
131
|
+
configurable: true
|
|
132
|
+
}
|
|
133
|
+
}), Object.defineProperty(t, "prototype", {
|
|
134
|
+
writable: false
|
|
135
|
+
}), e && _setPrototypeOf(t, e);
|
|
136
|
+
}
|
|
137
|
+
function _isNativeReflectConstruct() {
|
|
138
|
+
try {
|
|
139
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
140
|
+
} catch (t) {}
|
|
141
|
+
return (_isNativeReflectConstruct = function () {
|
|
142
|
+
return !!t;
|
|
143
|
+
})();
|
|
144
|
+
}
|
|
113
145
|
function _iterableToArray(r) {
|
|
114
146
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
115
147
|
}
|
|
@@ -137,6 +169,11 @@ function _objectSpread2(e) {
|
|
|
137
169
|
}
|
|
138
170
|
return e;
|
|
139
171
|
}
|
|
172
|
+
function _possibleConstructorReturn(t, e) {
|
|
173
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
174
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
175
|
+
return _assertThisInitialized(t);
|
|
176
|
+
}
|
|
140
177
|
function _regenerator() {
|
|
141
178
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
142
179
|
var e,
|
|
@@ -245,6 +282,11 @@ function _regeneratorDefine(e, r, n, t) {
|
|
|
245
282
|
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
246
283
|
}, _regeneratorDefine(e, r, n, t);
|
|
247
284
|
}
|
|
285
|
+
function _setPrototypeOf(t, e) {
|
|
286
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
287
|
+
return t.__proto__ = e, t;
|
|
288
|
+
}, _setPrototypeOf(t, e);
|
|
289
|
+
}
|
|
248
290
|
function _toConsumableArray(r) {
|
|
249
291
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
250
292
|
}
|
|
@@ -445,41 +487,27 @@ var createPolkadotJsClient = /*#__PURE__*/function () {
|
|
|
445
487
|
var _createClientPoolHelp = createClientPoolHelpers(clientPool, createPolkadotJsClient),
|
|
446
488
|
leaseClient = _createClientPoolHelp.leaseClient,
|
|
447
489
|
releaseClient = _createClientPoolHelp.releaseClient;
|
|
448
|
-
var PolkadotJsApi = /*#__PURE__*/function () {
|
|
449
|
-
function PolkadotJsApi(
|
|
490
|
+
var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
491
|
+
function PolkadotJsApi() {
|
|
492
|
+
var _this;
|
|
450
493
|
_classCallCheck(this, PolkadotJsApi);
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this._config = config;
|
|
494
|
+
_this = _callSuper(this, PolkadotJsApi, arguments);
|
|
495
|
+
_this.type = 'PJS';
|
|
496
|
+
return _this;
|
|
455
497
|
}
|
|
498
|
+
_inherits(PolkadotJsApi, _PolkadotApi);
|
|
456
499
|
return _createClass(PolkadotJsApi, [{
|
|
457
|
-
key: "getType",
|
|
458
|
-
value: function getType() {
|
|
459
|
-
return 'PJS';
|
|
460
|
-
}
|
|
461
|
-
}, {
|
|
462
|
-
key: "getConfig",
|
|
463
|
-
value: function getConfig() {
|
|
464
|
-
return this._config;
|
|
465
|
-
}
|
|
466
|
-
}, {
|
|
467
|
-
key: "getApi",
|
|
468
|
-
value: function getApi() {
|
|
469
|
-
return this.api;
|
|
470
|
-
}
|
|
471
|
-
}, {
|
|
472
500
|
key: "init",
|
|
473
501
|
value: function () {
|
|
474
502
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
|
|
475
|
-
var
|
|
503
|
+
var _this2 = this;
|
|
476
504
|
var clientTtlMs,
|
|
477
505
|
_args = arguments;
|
|
478
506
|
return _regenerator().w(function (_context3) {
|
|
479
507
|
while (1) switch (_context3.n) {
|
|
480
508
|
case 0:
|
|
481
509
|
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
482
|
-
if (!(this.
|
|
510
|
+
if (!(this._chain !== undefined || isExternalChain(chain))) {
|
|
483
511
|
_context3.n = 1;
|
|
484
512
|
break;
|
|
485
513
|
}
|
|
@@ -489,11 +517,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
489
517
|
this._chain = chain;
|
|
490
518
|
_context3.n = 2;
|
|
491
519
|
return resolveChainApi(this._config, chain, function (wsUrl, c) {
|
|
492
|
-
return
|
|
520
|
+
return _this2.createApiInstance(wsUrl, c);
|
|
493
521
|
});
|
|
494
522
|
case 2:
|
|
495
|
-
this.
|
|
496
|
-
this.initialized = true;
|
|
523
|
+
this._api = _context3.v;
|
|
497
524
|
case 3:
|
|
498
525
|
return _context3.a(2);
|
|
499
526
|
}
|
|
@@ -809,7 +836,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
809
836
|
key: "getDryRunCall",
|
|
810
837
|
value: function () {
|
|
811
838
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
|
|
812
|
-
var
|
|
839
|
+
var _this3 = this;
|
|
813
840
|
var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
|
|
814
841
|
return _regenerator().w(function (_context1) {
|
|
815
842
|
while (1) switch (_context1.p = _context1.n) {
|
|
@@ -853,13 +880,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
853
880
|
resolvedFeeAsset = _context1.v;
|
|
854
881
|
performDryRunCall = /*#__PURE__*/function () {
|
|
855
882
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
|
|
856
|
-
var
|
|
883
|
+
var _this3$api$call$dryRu;
|
|
857
884
|
var versionNum;
|
|
858
885
|
return _regenerator().w(function (_context0) {
|
|
859
886
|
while (1) switch (_context0.n) {
|
|
860
887
|
case 0:
|
|
861
888
|
versionNum = Number(version.charAt(1));
|
|
862
|
-
return _context0.a(2, (
|
|
889
|
+
return _context0.a(2, (_this3$api$call$dryRu = _this3.api.call.dryRunApi).dryRunCall.apply(_this3$api$call$dryRu, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
|
|
863
890
|
}
|
|
864
891
|
}, _callee0);
|
|
865
892
|
}));
|
|
@@ -1408,22 +1435,12 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1408
1435
|
}
|
|
1409
1436
|
return getBridgeStatus;
|
|
1410
1437
|
}()
|
|
1411
|
-
}, {
|
|
1412
|
-
key: "setDisconnectAllowed",
|
|
1413
|
-
value: function setDisconnectAllowed(allowed) {
|
|
1414
|
-
this.disconnectAllowed = allowed;
|
|
1415
|
-
}
|
|
1416
|
-
}, {
|
|
1417
|
-
key: "getDisconnectAllowed",
|
|
1418
|
-
value: function getDisconnectAllowed() {
|
|
1419
|
-
return this.disconnectAllowed;
|
|
1420
|
-
}
|
|
1421
1438
|
}, {
|
|
1422
1439
|
key: "disconnect",
|
|
1423
1440
|
value: function disconnect() {
|
|
1424
1441
|
var _this$_config$apiOver;
|
|
1425
1442
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1426
|
-
if (!this.
|
|
1443
|
+
if (!this._chain) return Promise.resolve();
|
|
1427
1444
|
if (!force && !this.disconnectAllowed) return Promise.resolve();
|
|
1428
1445
|
var api = isConfig(this._config) ? (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[this._chain] : this._config;
|
|
1429
1446
|
// Own client provided, destroy only if force true
|
|
@@ -1499,7 +1516,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1499
1516
|
key: "signAndSubmitFinalized",
|
|
1500
1517
|
value: function () {
|
|
1501
1518
|
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, sender) {
|
|
1502
|
-
var
|
|
1519
|
+
var _this4 = this;
|
|
1503
1520
|
return _regenerator().w(function (_context17) {
|
|
1504
1521
|
while (1) switch (_context17.n) {
|
|
1505
1522
|
case 0:
|
|
@@ -1526,7 +1543,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1526
1543
|
if (status.isFinalized) {
|
|
1527
1544
|
if (dispatchError !== undefined) {
|
|
1528
1545
|
if (dispatchError.isModule) {
|
|
1529
|
-
var decoded =
|
|
1546
|
+
var decoded = _this4.api.registry.findMetaError(dispatchError.asModule);
|
|
1530
1547
|
var docs = decoded.docs,
|
|
1531
1548
|
name = decoded.name,
|
|
1532
1549
|
section = decoded.section;
|
|
@@ -1551,7 +1568,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1551
1568
|
return signAndSubmitFinalized;
|
|
1552
1569
|
}()
|
|
1553
1570
|
}]);
|
|
1554
|
-
}();
|
|
1571
|
+
}(PolkadotApi);
|
|
1555
1572
|
|
|
1556
1573
|
var createChainClient = function createChainClient(chain, builderOptions) {
|
|
1557
1574
|
var pjsApi = new PolkadotJsApi(builderOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "13.0.0
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@snowbridge/contract-types": "^0.4.4",
|
|
29
29
|
"@snowbridge/registry": "^0.4.4",
|
|
30
30
|
"ethers": "^6.16.0",
|
|
31
|
-
"viem": "2.47.
|
|
32
|
-
"@paraspell/sdk-core": "13.0.0
|
|
31
|
+
"viem": "^2.47.6",
|
|
32
|
+
"@paraspell/sdk-core": "13.0.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@polkadot/api": ">= 16.0 < 17",
|