@paraspell/sdk-pjs 12.9.7 → 12.10.0-rc.1
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 +96 -51
- package/dist/index.d.ts +17 -28
- package/dist/index.mjs +208 -74
- package/package.json +2 -2
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: ['AssetHubPolkadotDex'], - Optional parameter - 'HydrationDex' | 'AcalaDex' | 'AssetHubPolkadotDex' | ...
|
|
207
|
+
// slippage: 1, - Optional - 1 by default
|
|
208
|
+
// evmsender: '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
|
|
@@ -173,8 +227,8 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
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
229
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
176
|
-
.
|
|
177
|
-
.
|
|
230
|
+
.recipient(ADDRESS)
|
|
231
|
+
.sender(address | {address, PJS_Signer})
|
|
178
232
|
.dryRun()
|
|
179
233
|
|
|
180
234
|
//Check Parachain for DryRun support - returns true/false
|
|
@@ -191,8 +245,8 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
191
245
|
.to(TChain)
|
|
192
246
|
.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
247
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in same fee asset as selected currency.*/
|
|
194
|
-
.
|
|
195
|
-
.
|
|
248
|
+
.recipient(ADDRESS)
|
|
249
|
+
.sender(address | {address, PJS_Signer})
|
|
196
250
|
.dryRunPreview(/*{ mintFeeAssets: true } - false by default - Mints fee assets also, if user does not have enough to cover fees on origin.*/)
|
|
197
251
|
```
|
|
198
252
|
|
|
@@ -203,13 +257,13 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
203
257
|
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
204
258
|
.to(TChain2) //Any compatible Parachain
|
|
205
259
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
206
|
-
.
|
|
260
|
+
.recipient(address | Location object)
|
|
207
261
|
.addToBatch()
|
|
208
262
|
|
|
209
263
|
.from(TSubstrateChain) //Ensure, that origin chain is the same in all batched XCM Calls.
|
|
210
264
|
.to(TChain3) //Any compatible Parachain
|
|
211
265
|
.currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
|
|
212
|
-
.
|
|
266
|
+
.recipient(address | Location object)
|
|
213
267
|
.addToBatch()
|
|
214
268
|
|
|
215
269
|
const tx = await builder.buildBatch({
|
|
@@ -229,7 +283,7 @@ const builder = Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
229
283
|
.claimfrom(TSubstrateChain)
|
|
230
284
|
.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
285
|
)
|
|
232
|
-
.
|
|
286
|
+
.recipient(address | Location object)
|
|
233
287
|
/*.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
288
|
|
|
235
289
|
const tx = await builder.build()
|
|
@@ -253,11 +307,11 @@ const builder = await Builder({
|
|
|
253
307
|
.from(TSubstrateChain)
|
|
254
308
|
.to(TChain)
|
|
255
309
|
.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
|
-
.
|
|
310
|
+
.recipient(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
|
|
311
|
+
.sender(address | {address, PJS_Signer}) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
258
312
|
|
|
259
313
|
const tx = await builder.build()
|
|
260
|
-
//Or if you use prederived account as
|
|
314
|
+
//Or if you use prederived account as sender:
|
|
261
315
|
//await builder.signAndSubmit()
|
|
262
316
|
|
|
263
317
|
//Disconnect API after TX
|
|
@@ -276,8 +330,8 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
276
330
|
.to(TChain)
|
|
277
331
|
.currency(CURRENCY_SPEC)
|
|
278
332
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
279
|
-
.
|
|
280
|
-
.
|
|
333
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
334
|
+
.sender(address | {address, PJS_Signer})
|
|
281
335
|
.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
336
|
```
|
|
283
337
|
|
|
@@ -289,8 +343,8 @@ const fee = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
289
343
|
.to(TChain)
|
|
290
344
|
.currency(CURRENCY_SPEC)
|
|
291
345
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
292
|
-
.
|
|
293
|
-
.
|
|
346
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
347
|
+
.sender(address | {address, PJS_Signer})
|
|
294
348
|
.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
349
|
```
|
|
296
350
|
|
|
@@ -301,8 +355,8 @@ const info = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array
|
|
|
301
355
|
.to(TChain)
|
|
302
356
|
.currency(CURRENCY_SPEC)
|
|
303
357
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
304
|
-
.
|
|
305
|
-
.
|
|
358
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
359
|
+
.sender(address | {address, PJS_Signer})
|
|
306
360
|
.getTransferInfo()
|
|
307
361
|
```
|
|
308
362
|
|
|
@@ -313,8 +367,8 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
313
367
|
.to(TChain)
|
|
314
368
|
.currency(CURRENCY_SPEC)
|
|
315
369
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
316
|
-
.
|
|
317
|
-
.
|
|
370
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
371
|
+
.sender(address | {address, PJS_Signer})
|
|
318
372
|
.getTransferableAmount()
|
|
319
373
|
```
|
|
320
374
|
|
|
@@ -325,8 +379,8 @@ const transferable = await Builder(/*chain api/builder_config/ws_url_string/ws_u
|
|
|
325
379
|
.to(TChain)
|
|
326
380
|
.currency(CURRENCY_SPEC)
|
|
327
381
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
328
|
-
.
|
|
329
|
-
.
|
|
382
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
383
|
+
.sender(address | {address, PJS_Signer})
|
|
330
384
|
.getMinTransferableAmount()
|
|
331
385
|
```
|
|
332
386
|
|
|
@@ -337,8 +391,8 @@ const receivable = await Builder(/*chain api/builder_config/ws_url_string/ws_url
|
|
|
337
391
|
.to(TChain)
|
|
338
392
|
.currency(CURRENCY_SPEC)
|
|
339
393
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
340
|
-
.
|
|
341
|
-
.
|
|
394
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
395
|
+
.sender(address | {address, PJS_Signer})
|
|
342
396
|
.getReceivableAmount()
|
|
343
397
|
```
|
|
344
398
|
|
|
@@ -349,8 +403,8 @@ const ed = await Builder(/*chain api/builder_config/ws_url_string/ws_url_array -
|
|
|
349
403
|
.to(TChain)
|
|
350
404
|
.currency(CURRENCY_SPEC)
|
|
351
405
|
/*.feeAsset(CURRENCY) - Optional parameter when origin === AssetHubPolkadot and TX is supposed to be paid in the same fee asset as selected currency.*/
|
|
352
|
-
.
|
|
353
|
-
.
|
|
406
|
+
.recipient(RECIPIENT_ADDRESS)
|
|
407
|
+
.sender(address | {address, PJS_Signer})
|
|
354
408
|
.verifyEdOnDestination()
|
|
355
409
|
```
|
|
356
410
|
|
|
@@ -390,7 +444,7 @@ let result = convertSs58(ADDRESS, TChain) // returns converted address in string
|
|
|
390
444
|
For full documentation with output examples of asset queries, head over to [official documentation](https://paraspell.github.io/docs/sdk/AssetPallet.html).
|
|
391
445
|
|
|
392
446
|
```ts
|
|
393
|
-
import { getSupportedDestinations, getFeeAssets, getAssetsObject,
|
|
447
|
+
import { getSupportedDestinations, getFeeAssets, getAssetsObject, getRelayChainSymbol, getNativeAssets, getNativeAssets, getOtherAssets, getAllAssetsSymbols, getParaId, getTChain, getAssetLocation, CHAINS, findAssetInfo, findAssetInfoOrThrow } from '@paraspell/sdk-pjs'
|
|
394
448
|
|
|
395
449
|
//Get chains that support the specific asset related to origin
|
|
396
450
|
getSupportedDestinations(TChain, CURRENCY)
|
|
@@ -413,9 +467,6 @@ getAssetLocation(TChain, { symbol: symbol } | { id: assetId })
|
|
|
413
467
|
// Retrieve assets object from assets.json for a particular chain, including information about native and foreign assets
|
|
414
468
|
getAssetsObject(TChain)
|
|
415
469
|
|
|
416
|
-
// Retrieve foreign assetId for a particular chain and asset symbol
|
|
417
|
-
getAssetId(TChain, ASSET_SYMBOL)
|
|
418
|
-
|
|
419
470
|
// Retrieve the symbol of the relay chain for a particular chain. Either "DOT" or "KSM"
|
|
420
471
|
getRelayChainSymbol(TChain)
|
|
421
472
|
|
|
@@ -428,12 +479,6 @@ getOtherAssets(TChain)
|
|
|
428
479
|
// Retrieve string array of all asset symbols. (native and foreign assets are merged into a single array)
|
|
429
480
|
getAllAssetsSymbols(TChain)
|
|
430
481
|
|
|
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
482
|
// Get specific chain id
|
|
438
483
|
getParaId(TChain)
|
|
439
484
|
|
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;
|
|
@@ -32,7 +31,7 @@ type TEvmBuilderOptionsBase = {
|
|
|
32
31
|
/**
|
|
33
32
|
* The Polkadot destination address.
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
recipient: string;
|
|
36
35
|
/**
|
|
37
36
|
* The AssetHub address
|
|
38
37
|
*/
|
|
@@ -54,22 +53,13 @@ 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
|
-
/**
|
|
60
|
-
* Claims assets from a parachain.
|
|
61
|
-
*
|
|
62
|
-
* @returns An extrinsic representing the claim transaction.
|
|
63
|
-
*/
|
|
64
|
-
declare const claimAssets: (options: _paraspell_sdk_core.TAssetClaimOptionsBase & {
|
|
65
|
-
api?: TPjsApiOrUrl;
|
|
66
|
-
}) => Promise<Extrinsic>;
|
|
67
58
|
|
|
68
59
|
declare const assets_Foreign: typeof Foreign;
|
|
69
60
|
declare const assets_ForeignAbstract: typeof ForeignAbstract;
|
|
70
61
|
declare const assets_Native: typeof Native;
|
|
71
62
|
declare const assets_Override: typeof Override;
|
|
72
|
-
declare const assets_claimAssets: typeof claimAssets;
|
|
73
63
|
declare const assets_findAssetInfo: typeof findAssetInfo;
|
|
74
64
|
declare const assets_getAllAssetsSymbols: typeof getAllAssetsSymbols;
|
|
75
65
|
declare const assets_getAssetDecimals: typeof getAssetDecimals;
|
|
@@ -92,7 +82,6 @@ declare namespace assets {
|
|
|
92
82
|
assets_ForeignAbstract as ForeignAbstract,
|
|
93
83
|
assets_Native as Native,
|
|
94
84
|
assets_Override as Override,
|
|
95
|
-
assets_claimAssets as claimAssets,
|
|
96
85
|
assets_findAssetInfo as findAssetInfo,
|
|
97
86
|
assets_getAllAssetsSymbols as getAllAssetsSymbols,
|
|
98
87
|
assets_getAssetDecimals as getAssetDecimals,
|
|
@@ -147,8 +136,8 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuild
|
|
|
147
136
|
* @param address - The Polkadot address to receive the transfer.
|
|
148
137
|
* @returns An instance of EvmBuilder
|
|
149
138
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
139
|
+
recipient(address: string): EvmBuilderCore<TApi, TRes, TSigner, T & {
|
|
140
|
+
recipient: string;
|
|
152
141
|
}>;
|
|
153
142
|
/**
|
|
154
143
|
* Sets the asset hub address. This is used for transfers that go through the Asset Hub.
|
|
@@ -182,10 +171,10 @@ declare class EvmBuilderCore<TApi, TRes, TSigner, T extends Partial<TPjsEvmBuild
|
|
|
182
171
|
* @param api - The API instance to use for building transactions. If not provided, a new instance will be created.
|
|
183
172
|
* @returns A new Builder instance.
|
|
184
173
|
*/
|
|
185
|
-
declare const Builder: (api?: TBuilderOptions<
|
|
186
|
-
type GeneralBuilder<T extends Partial<
|
|
187
|
-
declare const EvmBuilder: (provider?: AbstractProvider, api?: TBuilderOptions<
|
|
188
|
-
api: _paraspell_sdk_core.
|
|
174
|
+
declare const Builder: (api?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => GeneralBuilder$1<_polkadot_api.ApiPromise, Extrinsic, TPjsSigner, object>;
|
|
175
|
+
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TPjsApi, Extrinsic, TPjsSigner>> = object> = GeneralBuilder$1<TPjsApi, Extrinsic, TPjsSigner, T>;
|
|
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>;
|
|
189
178
|
provider: AbstractProvider | undefined;
|
|
190
179
|
}>;
|
|
191
180
|
|
|
@@ -209,7 +198,7 @@ declare const depositToken: (signer: Signer$1, amount: bigint, symbol: string) =
|
|
|
209
198
|
*
|
|
210
199
|
* @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
|
|
211
200
|
*/
|
|
212
|
-
declare const transferEthToPolkadot$1: <TApi, TRes, TSigner>({ api, provider, signer,
|
|
201
|
+
declare const transferEthToPolkadot$1: <TApi, TRes, TSigner>({ api, provider, signer, recipient, to, currency }: TPjsEvmBuilderOptions<TApi, TRes, TSigner>) => Promise<{
|
|
213
202
|
response: ethers.TransactionResponse;
|
|
214
203
|
messageReceipt: toPolkadotV2.MessageReceipt;
|
|
215
204
|
}>;
|
|
@@ -217,17 +206,17 @@ declare const transferEthToPolkadot$1: <TApi, TRes, TSigner>({ api, provider, si
|
|
|
217
206
|
declare const getTokenBalance: (signer: Signer$1, symbol: string) => Promise<bigint>;
|
|
218
207
|
|
|
219
208
|
declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<Extrinsic> & {
|
|
220
|
-
api?:
|
|
209
|
+
api?: TApiOrUrl<TPjsApi>;
|
|
221
210
|
}) => Promise<_paraspell_sdk_core.TDryRunResult>;
|
|
222
211
|
declare const dryRunOrigin: (options: _paraspell_sdk_core.TDryRunCallBaseOptions<Extrinsic> & {
|
|
223
|
-
api?:
|
|
212
|
+
api?: TApiOrUrl<TPjsApi>;
|
|
224
213
|
}) => Promise<_paraspell_sdk_core.TDryRunChainResult>;
|
|
225
214
|
declare const transferEthToPolkadot: (options: Omit<TPjsEvmBuilderOptions<TPjsApi, Extrinsic, TPjsSigner>, "api">) => ReturnType<typeof transferEthToPolkadot$1>;
|
|
226
|
-
declare const getParaEthTransferFees: (api?:
|
|
215
|
+
declare const getParaEthTransferFees: (api?: TApiOrUrl<TPjsApi>) => Promise<[bigint, bigint]>;
|
|
227
216
|
/**
|
|
228
217
|
* Gets the Ethereum bridge status.
|
|
229
218
|
*/
|
|
230
|
-
declare const getBridgeStatus: (api?:
|
|
219
|
+
declare const getBridgeStatus: (api?: TApiOrUrl<TPjsApi>) => Promise<_paraspell_sdk_core.TBridgeStatus>;
|
|
231
220
|
|
|
232
221
|
declare const transfer_approveToken: typeof approveToken;
|
|
233
222
|
declare const transfer_depositToken: typeof depositToken;
|
|
@@ -250,7 +239,7 @@ declare namespace transfer {
|
|
|
250
239
|
};
|
|
251
240
|
}
|
|
252
241
|
|
|
253
|
-
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<
|
|
242
|
+
declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TApiOrUrl<TPjsApi>>) => Promise<_polkadot_api.ApiPromise>;
|
|
254
243
|
|
|
255
|
-
export { Builder, EvmBuilder, approveToken, assets,
|
|
256
|
-
export type { Extrinsic, GeneralBuilder, TPjsApi,
|
|
244
|
+
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, 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
|
-
import { isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
4
|
+
import { u8aConcat, compactToU8a, u8aEq, isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
5
5
|
import { decodeAddress, blake2AsHex, validateAddress } from '@polkadot/util-crypto';
|
|
6
6
|
import { WETH9__factory } from '@snowbridge/contract-types';
|
|
7
7
|
import { bridgeInfoFor } from '@snowbridge/registry';
|
|
@@ -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
|
}
|
|
@@ -359,6 +401,54 @@ var snakeToCamel = function snakeToCamel(str) {
|
|
|
359
401
|
});
|
|
360
402
|
};
|
|
361
403
|
|
|
404
|
+
var txFromHex = function txFromHex(api, hex) {
|
|
405
|
+
var _api$tx$section;
|
|
406
|
+
// Try as full extrinsic
|
|
407
|
+
try {
|
|
408
|
+
var tx = api.tx(hex);
|
|
409
|
+
if (tx.toHex() === hex) return tx;
|
|
410
|
+
} catch (_unused) {
|
|
411
|
+
// Not a valid extrinsic, try other formats
|
|
412
|
+
}
|
|
413
|
+
// Try as Call
|
|
414
|
+
try {
|
|
415
|
+
var _call = api.createType('Call', hex);
|
|
416
|
+
var callHex = _call.toHex();
|
|
417
|
+
if (callHex === hex) {
|
|
418
|
+
var _api$tx$_section;
|
|
419
|
+
var _api$registry$findMet = api.registry.findMetaCall(_call.callIndex),
|
|
420
|
+
_method = _api$registry$findMet.method,
|
|
421
|
+
_section = _api$registry$findMet.section;
|
|
422
|
+
return (_api$tx$_section = api.tx[_section])[_method].apply(_api$tx$_section, _toConsumableArray(_call.args));
|
|
423
|
+
}
|
|
424
|
+
if (hex.startsWith(callHex)) {
|
|
425
|
+
// Try as un-prefixed ExtrinsicPayload
|
|
426
|
+
var prefixed = u8aConcat(compactToU8a(_call.encodedLength), hex);
|
|
427
|
+
var _payload = api.createType('ExtrinsicPayload', prefixed);
|
|
428
|
+
if (u8aEq(_payload.toU8a(), prefixed)) {
|
|
429
|
+
var _api$tx$_section2;
|
|
430
|
+
var payloadCall = api.createType('Call', _payload.method.toHex());
|
|
431
|
+
var _api$registry$findMet2 = api.registry.findMetaCall(payloadCall.callIndex),
|
|
432
|
+
_method2 = _api$registry$findMet2.method,
|
|
433
|
+
_section2 = _api$registry$findMet2.section;
|
|
434
|
+
return (_api$tx$_section2 = api.tx[_section2])[_method2].apply(_api$tx$_section2, _toConsumableArray(payloadCall.args));
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
} catch (_unused2) {
|
|
438
|
+
// Not a valid call, try as payload
|
|
439
|
+
}
|
|
440
|
+
// Final attempt: try as prefixed ExtrinsicPayload
|
|
441
|
+
var payload = api.createType('ExtrinsicPayload', hex);
|
|
442
|
+
if (payload.toHex() !== hex) {
|
|
443
|
+
throw new UnsupportedOperationError('Unable to decode hex as Extrinsic, Call, or ExtrinsicPayload');
|
|
444
|
+
}
|
|
445
|
+
var call = api.createType('Call', payload.method.toHex());
|
|
446
|
+
var _api$registry$findMet3 = api.registry.findMetaCall(call.callIndex),
|
|
447
|
+
method = _api$registry$findMet3.method,
|
|
448
|
+
section = _api$registry$findMet3.section;
|
|
449
|
+
return (_api$tx$section = api.tx[section])[method].apply(_api$tx$section, _toConsumableArray(call.args));
|
|
450
|
+
};
|
|
451
|
+
|
|
362
452
|
var clientPool = createClientCache(MAX_CLIENTS, /*#__PURE__*/function () {
|
|
363
453
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(client) {
|
|
364
454
|
return _regenerator().w(function (_context) {
|
|
@@ -397,41 +487,27 @@ var createPolkadotJsClient = /*#__PURE__*/function () {
|
|
|
397
487
|
var _createClientPoolHelp = createClientPoolHelpers(clientPool, createPolkadotJsClient),
|
|
398
488
|
leaseClient = _createClientPoolHelp.leaseClient,
|
|
399
489
|
releaseClient = _createClientPoolHelp.releaseClient;
|
|
400
|
-
var PolkadotJsApi = /*#__PURE__*/function () {
|
|
401
|
-
function PolkadotJsApi(
|
|
490
|
+
var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
491
|
+
function PolkadotJsApi() {
|
|
492
|
+
var _this;
|
|
402
493
|
_classCallCheck(this, PolkadotJsApi);
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
this._config = config;
|
|
494
|
+
_this = _callSuper(this, PolkadotJsApi, arguments);
|
|
495
|
+
_this.type = 'PJS';
|
|
496
|
+
return _this;
|
|
407
497
|
}
|
|
498
|
+
_inherits(PolkadotJsApi, _PolkadotApi);
|
|
408
499
|
return _createClass(PolkadotJsApi, [{
|
|
409
|
-
key: "getType",
|
|
410
|
-
value: function getType() {
|
|
411
|
-
return 'PJS';
|
|
412
|
-
}
|
|
413
|
-
}, {
|
|
414
|
-
key: "getConfig",
|
|
415
|
-
value: function getConfig() {
|
|
416
|
-
return this._config;
|
|
417
|
-
}
|
|
418
|
-
}, {
|
|
419
|
-
key: "getApi",
|
|
420
|
-
value: function getApi() {
|
|
421
|
-
return this.api;
|
|
422
|
-
}
|
|
423
|
-
}, {
|
|
424
500
|
key: "init",
|
|
425
501
|
value: function () {
|
|
426
502
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
|
|
427
|
-
var
|
|
503
|
+
var _this2 = this;
|
|
428
504
|
var clientTtlMs,
|
|
429
505
|
_args = arguments;
|
|
430
506
|
return _regenerator().w(function (_context3) {
|
|
431
507
|
while (1) switch (_context3.n) {
|
|
432
508
|
case 0:
|
|
433
509
|
clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
|
|
434
|
-
if (!(this.
|
|
510
|
+
if (!(this._chain !== undefined || isExternalChain(chain))) {
|
|
435
511
|
_context3.n = 1;
|
|
436
512
|
break;
|
|
437
513
|
}
|
|
@@ -441,11 +517,10 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
441
517
|
this._chain = chain;
|
|
442
518
|
_context3.n = 2;
|
|
443
519
|
return resolveChainApi(this._config, chain, function (wsUrl, c) {
|
|
444
|
-
return
|
|
520
|
+
return _this2.createApiInstance(wsUrl, c);
|
|
445
521
|
});
|
|
446
522
|
case 2:
|
|
447
|
-
this.
|
|
448
|
-
this.initialized = true;
|
|
523
|
+
this._api = _context3.v;
|
|
449
524
|
case 3:
|
|
450
525
|
return _context3.a(2);
|
|
451
526
|
}
|
|
@@ -497,8 +572,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
497
572
|
}
|
|
498
573
|
}, {
|
|
499
574
|
key: "txFromHex",
|
|
500
|
-
value: function txFromHex(hex) {
|
|
501
|
-
return Promise.resolve(this.api
|
|
575
|
+
value: function txFromHex$1(hex) {
|
|
576
|
+
return Promise.resolve(txFromHex(this.api, hex));
|
|
502
577
|
}
|
|
503
578
|
}, {
|
|
504
579
|
key: "queryState",
|
|
@@ -691,13 +766,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
691
766
|
return _regenerator().w(function (_context8) {
|
|
692
767
|
while (1) switch (_context8.n) {
|
|
693
768
|
case 0:
|
|
694
|
-
api = new PolkadotJsApi();
|
|
769
|
+
api = new PolkadotJsApi(isConfig(this._config) ? this._config : undefined);
|
|
695
770
|
_context8.n = 1;
|
|
696
771
|
return api.init(chain);
|
|
697
772
|
case 1:
|
|
698
773
|
return _context8.a(2, api);
|
|
699
774
|
}
|
|
700
|
-
}, _callee8);
|
|
775
|
+
}, _callee8, this);
|
|
701
776
|
}));
|
|
702
777
|
function createApiForChain(_x11) {
|
|
703
778
|
return _createApiForChain.apply(this, arguments);
|
|
@@ -747,7 +822,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
747
822
|
isCustomAsset: true,
|
|
748
823
|
asset: findAssetInfoOrThrow(chain, {
|
|
749
824
|
id: assetId
|
|
750
|
-
}
|
|
825
|
+
})
|
|
751
826
|
});
|
|
752
827
|
}
|
|
753
828
|
}, _callee9, this);
|
|
@@ -761,8 +836,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
761
836
|
key: "getDryRunCall",
|
|
762
837
|
value: function () {
|
|
763
838
|
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
|
|
764
|
-
var
|
|
765
|
-
var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, 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;
|
|
839
|
+
var _this3 = this;
|
|
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;
|
|
766
841
|
return _regenerator().w(function (_context1) {
|
|
767
842
|
while (1) switch (_context1.p = _context1.n) {
|
|
768
843
|
case 0:
|
|
@@ -805,13 +880,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
805
880
|
resolvedFeeAsset = _context1.v;
|
|
806
881
|
performDryRunCall = /*#__PURE__*/function () {
|
|
807
882
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(includeVersion) {
|
|
808
|
-
var
|
|
883
|
+
var _this3$api$call$dryRu;
|
|
809
884
|
var versionNum;
|
|
810
885
|
return _regenerator().w(function (_context0) {
|
|
811
886
|
while (1) switch (_context0.n) {
|
|
812
887
|
case 0:
|
|
813
888
|
versionNum = Number(version.charAt(1));
|
|
814
|
-
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] : []))));
|
|
815
890
|
}
|
|
816
891
|
}, _callee0);
|
|
817
892
|
}));
|
|
@@ -819,23 +894,31 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
819
894
|
return _ref5.apply(this, arguments);
|
|
820
895
|
};
|
|
821
896
|
}();
|
|
897
|
+
findFailingEventInResult = function findFailingEventInResult(resultHuman) {
|
|
898
|
+
var _resultHuman$Ok;
|
|
899
|
+
return resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok = resultHuman.Ok) === null || _resultHuman$Ok === void 0 || (_resultHuman$Ok = _resultHuman$Ok.emittedEvents) === null || _resultHuman$Ok === void 0 ? void 0 : _resultHuman$Ok.find(function (event) {
|
|
900
|
+
var _event$data;
|
|
901
|
+
return (event.section === 'utility' || event.section === 'Utility') && event.method === 'DispatchedAs' && ((_event$data = event.data) === null || _event$data === void 0 || (_event$data = _event$data.result) === null || _event$data === void 0 ? void 0 : _event$data.Err);
|
|
902
|
+
});
|
|
903
|
+
};
|
|
822
904
|
getExecutionSuccessFromResult = function getExecutionSuccessFromResult(resultHuman) {
|
|
823
905
|
var _resultHuman$Ok$execu;
|
|
824
|
-
|
|
906
|
+
var errorInEvents = findFailingEventInResult(resultHuman);
|
|
907
|
+
return Boolean((resultHuman === null || resultHuman === void 0 ? void 0 : resultHuman.Ok) && ((_resultHuman$Ok$execu = resultHuman.Ok.executionResult) === null || _resultHuman$Ok$execu === void 0 ? void 0 : _resultHuman$Ok$execu.Ok) && !errorInEvents);
|
|
825
908
|
};
|
|
826
909
|
extractFailureReasonFromResult = function extractFailureReasonFromResult(resultHuman, resultJson) {
|
|
827
|
-
var _resultHuman$
|
|
828
|
-
var modErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$
|
|
910
|
+
var _resultHuman$Ok2, _resultHuman$Ok3, _resultHuman$Ok4, _resultJson$ok, _ref6;
|
|
911
|
+
var modErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok2 = resultHuman.Ok) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.executionResult) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.Err) === null || _resultHuman$Ok2 === void 0 || (_resultHuman$Ok2 = _resultHuman$Ok2.error) === null || _resultHuman$Ok2 === void 0 ? void 0 : _resultHuman$Ok2.Module;
|
|
829
912
|
if (modErrHuman) {
|
|
830
913
|
return resolveModuleError(chain, modErrHuman);
|
|
831
914
|
}
|
|
832
|
-
var otherErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$
|
|
915
|
+
var otherErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok3 = resultHuman.Ok) === null || _resultHuman$Ok3 === void 0 || (_resultHuman$Ok3 = _resultHuman$Ok3.executionResult) === null || _resultHuman$Ok3 === void 0 || (_resultHuman$Ok3 = _resultHuman$Ok3.Err) === null || _resultHuman$Ok3 === void 0 || (_resultHuman$Ok3 = _resultHuman$Ok3.error) === null || _resultHuman$Ok3 === void 0 ? void 0 : _resultHuman$Ok3.Other;
|
|
833
916
|
if (otherErrHuman) {
|
|
834
917
|
return {
|
|
835
918
|
failureReason: String(otherErrHuman)
|
|
836
919
|
};
|
|
837
920
|
}
|
|
838
|
-
var secondErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$
|
|
921
|
+
var secondErrHuman = resultHuman === null || resultHuman === void 0 || (_resultHuman$Ok4 = resultHuman.Ok) === null || _resultHuman$Ok4 === void 0 || (_resultHuman$Ok4 = _resultHuman$Ok4.executionResult) === null || _resultHuman$Ok4 === void 0 || (_resultHuman$Ok4 = _resultHuman$Ok4.Err) === null || _resultHuman$Ok4 === void 0 ? void 0 : _resultHuman$Ok4.error;
|
|
839
922
|
if (secondErrHuman) {
|
|
840
923
|
return {
|
|
841
924
|
failureReason: String(secondErrHuman)
|
|
@@ -850,6 +933,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
850
933
|
failureReason: String(execErrJson.other)
|
|
851
934
|
};
|
|
852
935
|
}
|
|
936
|
+
var erroredEvent = findFailingEventInResult(resultHuman);
|
|
937
|
+
if (erroredEvent) {
|
|
938
|
+
var _erroredEvent$data;
|
|
939
|
+
var err = (_erroredEvent$data = erroredEvent.data) === null || _erroredEvent$data === void 0 || (_erroredEvent$data = _erroredEvent$data.result) === null || _erroredEvent$data === void 0 ? void 0 : _erroredEvent$data.Err;
|
|
940
|
+
if (err !== null && err !== void 0 && err.Module) {
|
|
941
|
+
return resolveModuleError(chain, err.Module);
|
|
942
|
+
}
|
|
943
|
+
if (err) {
|
|
944
|
+
return {
|
|
945
|
+
failureReason: typeof err === 'string' ? err : JSON.stringify(err)
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
}
|
|
853
949
|
return {
|
|
854
950
|
failureReason: JSON.stringify((_ref6 = resultJson !== null && resultJson !== void 0 ? resultJson : resultHuman) !== null && _ref6 !== void 0 ? _ref6 : 'Unknown error')
|
|
855
951
|
};
|
|
@@ -1339,22 +1435,12 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1339
1435
|
}
|
|
1340
1436
|
return getBridgeStatus;
|
|
1341
1437
|
}()
|
|
1342
|
-
}, {
|
|
1343
|
-
key: "setDisconnectAllowed",
|
|
1344
|
-
value: function setDisconnectAllowed(allowed) {
|
|
1345
|
-
this.disconnectAllowed = allowed;
|
|
1346
|
-
}
|
|
1347
|
-
}, {
|
|
1348
|
-
key: "getDisconnectAllowed",
|
|
1349
|
-
value: function getDisconnectAllowed() {
|
|
1350
|
-
return this.disconnectAllowed;
|
|
1351
|
-
}
|
|
1352
1438
|
}, {
|
|
1353
1439
|
key: "disconnect",
|
|
1354
1440
|
value: function disconnect() {
|
|
1355
1441
|
var _this$_config$apiOver;
|
|
1356
1442
|
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1357
|
-
if (!this.
|
|
1443
|
+
if (!this._chain) return Promise.resolve();
|
|
1358
1444
|
if (!force && !this.disconnectAllowed) return Promise.resolve();
|
|
1359
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;
|
|
1360
1446
|
// Own client provided, destroy only if force true
|
|
@@ -1426,8 +1512,63 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1426
1512
|
}
|
|
1427
1513
|
return signAndSubmit;
|
|
1428
1514
|
}()
|
|
1515
|
+
}, {
|
|
1516
|
+
key: "signAndSubmitFinalized",
|
|
1517
|
+
value: function () {
|
|
1518
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, sender) {
|
|
1519
|
+
var _this4 = this;
|
|
1520
|
+
return _regenerator().w(function (_context17) {
|
|
1521
|
+
while (1) switch (_context17.n) {
|
|
1522
|
+
case 0:
|
|
1523
|
+
if (!isSenderSigner(sender)) {
|
|
1524
|
+
_context17.n = 2;
|
|
1525
|
+
break;
|
|
1526
|
+
}
|
|
1527
|
+
_context17.n = 1;
|
|
1528
|
+
return tx.signAsync(sender.address, {
|
|
1529
|
+
signer: sender.signer
|
|
1530
|
+
});
|
|
1531
|
+
case 1:
|
|
1532
|
+
_context17.n = 3;
|
|
1533
|
+
break;
|
|
1534
|
+
case 2:
|
|
1535
|
+
_context17.n = 3;
|
|
1536
|
+
return tx.signAsync(createKeyringPair(sender));
|
|
1537
|
+
case 3:
|
|
1538
|
+
return _context17.a(2, new Promise(function (resolve, reject) {
|
|
1539
|
+
tx.send(function (_ref13) {
|
|
1540
|
+
var status = _ref13.status,
|
|
1541
|
+
dispatchError = _ref13.dispatchError,
|
|
1542
|
+
txHash = _ref13.txHash;
|
|
1543
|
+
if (status.isFinalized) {
|
|
1544
|
+
if (dispatchError !== undefined) {
|
|
1545
|
+
if (dispatchError.isModule) {
|
|
1546
|
+
var decoded = _this4.api.registry.findMetaError(dispatchError.asModule);
|
|
1547
|
+
var docs = decoded.docs,
|
|
1548
|
+
name = decoded.name,
|
|
1549
|
+
section = decoded.section;
|
|
1550
|
+
reject(new SubmitTransactionError("".concat(section, ".").concat(name, ": ").concat(docs.join(' '))));
|
|
1551
|
+
} else {
|
|
1552
|
+
reject(new SubmitTransactionError(dispatchError.toString()));
|
|
1553
|
+
}
|
|
1554
|
+
} else {
|
|
1555
|
+
resolve(txHash.toString());
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
})["catch"](function (error) {
|
|
1559
|
+
reject(error instanceof Error ? error : new SubmitTransactionError(String(error)));
|
|
1560
|
+
});
|
|
1561
|
+
}));
|
|
1562
|
+
}
|
|
1563
|
+
}, _callee17);
|
|
1564
|
+
}));
|
|
1565
|
+
function signAndSubmitFinalized(_x33, _x34) {
|
|
1566
|
+
return _signAndSubmitFinalized.apply(this, arguments);
|
|
1567
|
+
}
|
|
1568
|
+
return signAndSubmitFinalized;
|
|
1569
|
+
}()
|
|
1429
1570
|
}]);
|
|
1430
|
-
}();
|
|
1571
|
+
}(PolkadotApi);
|
|
1431
1572
|
|
|
1432
1573
|
var createChainClient = function createChainClient(chain, builderOptions) {
|
|
1433
1574
|
var pjsApi = new PolkadotJsApi(builderOptions);
|
|
@@ -1463,12 +1604,6 @@ var isEthersSigner = function isEthersSigner(signer) {
|
|
|
1463
1604
|
* @returns The asset balance as a bigint.
|
|
1464
1605
|
*/
|
|
1465
1606
|
var getBalance = createPolkadotJsApiCall(getBalance$1);
|
|
1466
|
-
/**
|
|
1467
|
-
* Claims assets from a parachain.
|
|
1468
|
-
*
|
|
1469
|
-
* @returns An extrinsic representing the claim transaction.
|
|
1470
|
-
*/
|
|
1471
|
-
var claimAssets = createPolkadotJsApiCall(claimAssets$1);
|
|
1472
1607
|
|
|
1473
1608
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1474
1609
|
__proto__: null,
|
|
@@ -1476,7 +1611,6 @@ var assets = /*#__PURE__*/Object.freeze({
|
|
|
1476
1611
|
ForeignAbstract: ForeignAbstract,
|
|
1477
1612
|
Native: Native,
|
|
1478
1613
|
Override: Override,
|
|
1479
|
-
claimAssets: claimAssets,
|
|
1480
1614
|
findAssetInfo: findAssetInfo,
|
|
1481
1615
|
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
1482
1616
|
getAssetDecimals: getAssetDecimals,
|
|
@@ -1509,7 +1643,7 @@ var approveToken = /*#__PURE__*/function () {
|
|
|
1509
1643
|
_bridgeInfoFor = bridgeInfoFor('polkadot_mainnet'), gatewayContract = _bridgeInfoFor.environment.gatewayContract;
|
|
1510
1644
|
asset = findAssetInfoOrThrow('Ethereum', {
|
|
1511
1645
|
symbol: symbol
|
|
1512
|
-
}
|
|
1646
|
+
});
|
|
1513
1647
|
assertHasId(asset);
|
|
1514
1648
|
weth9 = WETH9__factory.connect(asset.assetId, signer);
|
|
1515
1649
|
_context.n = 1;
|
|
@@ -1540,7 +1674,7 @@ var depositToken = /*#__PURE__*/function () {
|
|
|
1540
1674
|
case 0:
|
|
1541
1675
|
asset = findAssetInfoOrThrow('Ethereum', {
|
|
1542
1676
|
symbol: symbol
|
|
1543
|
-
}
|
|
1677
|
+
});
|
|
1544
1678
|
assertHasId(asset);
|
|
1545
1679
|
weth9 = WETH9__factory.connect(asset.assetId, signer);
|
|
1546
1680
|
_context.n = 1;
|
|
@@ -1599,11 +1733,11 @@ var createContext = function createContext(executionUrl, env) {
|
|
|
1599
1733
|
*/
|
|
1600
1734
|
var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
1601
1735
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
1602
|
-
var api, provider, signer,
|
|
1736
|
+
var api, provider, signer, recipient, to, currency, ethAsset, amount, _bridgeInfoFor, environment, registry, context, destParaId, fee, sourceAddress, transfer, validation, tx, response, receipt, messageReceipt, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1;
|
|
1603
1737
|
return _regenerator().w(function (_context) {
|
|
1604
1738
|
while (1) switch (_context.n) {
|
|
1605
1739
|
case 0:
|
|
1606
|
-
api = _ref.api, provider = _ref.provider, signer = _ref.signer,
|
|
1740
|
+
api = _ref.api, provider = _ref.provider, signer = _ref.signer, recipient = _ref.recipient, to = _ref.to, currency = _ref.currency;
|
|
1607
1741
|
if (!Array.isArray(currency)) {
|
|
1608
1742
|
_context.n = 1;
|
|
1609
1743
|
break;
|
|
@@ -1657,7 +1791,7 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
|
1657
1791
|
case 8:
|
|
1658
1792
|
sourceAddress = _context.v;
|
|
1659
1793
|
_context.n = 9;
|
|
1660
|
-
return toPolkadotV2.createTransfer(registry, sourceAddress,
|
|
1794
|
+
return toPolkadotV2.createTransfer(registry, sourceAddress, recipient, ethAsset.assetId, destParaId, amount, fee);
|
|
1661
1795
|
case 9:
|
|
1662
1796
|
transfer = _context.v;
|
|
1663
1797
|
_t5 = toPolkadotV2;
|
|
@@ -1752,7 +1886,7 @@ var getTokenBalance = /*#__PURE__*/function () {
|
|
|
1752
1886
|
case 0:
|
|
1753
1887
|
asset = findAssetInfoOrThrow('Ethereum', {
|
|
1754
1888
|
symbol: symbol
|
|
1755
|
-
}
|
|
1889
|
+
});
|
|
1756
1890
|
assertHasId(asset);
|
|
1757
1891
|
weth9 = WETH9__factory.connect(asset.assetId, signer);
|
|
1758
1892
|
_context.n = 1;
|
|
@@ -1816,10 +1950,10 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
1816
1950
|
* @returns An instance of EvmBuilder
|
|
1817
1951
|
*/
|
|
1818
1952
|
}, {
|
|
1819
|
-
key: "
|
|
1820
|
-
value: function address
|
|
1953
|
+
key: "recipient",
|
|
1954
|
+
value: function recipient(address) {
|
|
1821
1955
|
return new EvmBuilderCore(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1822
|
-
|
|
1956
|
+
recipient: address
|
|
1823
1957
|
}));
|
|
1824
1958
|
}
|
|
1825
1959
|
/**
|
|
@@ -1857,12 +1991,12 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
1857
1991
|
key: "build",
|
|
1858
1992
|
value: (function () {
|
|
1859
1993
|
var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1860
|
-
var _this$_options, from, to,
|
|
1994
|
+
var _this$_options, from, to, recipient, signer, api, _yield$transferEthToP, response;
|
|
1861
1995
|
return _regenerator().w(function (_context) {
|
|
1862
1996
|
while (1) switch (_context.n) {
|
|
1863
1997
|
case 0:
|
|
1864
|
-
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to,
|
|
1865
|
-
validateAddress$1(api,
|
|
1998
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, recipient = _this$_options.recipient, signer = _this$_options.signer, api = _this$_options.api;
|
|
1999
|
+
validateAddress$1(api, recipient, to);
|
|
1866
2000
|
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
1867
2001
|
_context.n = 2;
|
|
1868
2002
|
break;
|
|
@@ -1993,4 +2127,4 @@ var transfer = /*#__PURE__*/Object.freeze({
|
|
|
1993
2127
|
transferEthToPolkadot: transferEthToPolkadot
|
|
1994
2128
|
});
|
|
1995
2129
|
|
|
1996
|
-
export { Builder, EvmBuilder, approveToken, assets,
|
|
2130
|
+
export { Builder, EvmBuilder, approveToken, assets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, transferEthToPolkadot, transfer as xcmPallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.10.0-rc.1",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@snowbridge/registry": "^0.4.4",
|
|
30
30
|
"ethers": "^6.16.0",
|
|
31
31
|
"viem": "2.47.1",
|
|
32
|
-
"@paraspell/sdk-core": "12.
|
|
32
|
+
"@paraspell/sdk-core": "12.10.0-rc.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@polkadot/api": ">= 16.0 < 17",
|