@paraspell/sdk-pjs 8.0.2 → 8.1.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 CHANGED
@@ -77,31 +77,37 @@ NOTES:
77
77
  - ParaSpell now offers advanced asset symbol selection {symbol: "symbol"} for non duplicate assets, {symbol: Native("symbol")} or {symbol: Foreign("symbol")} if the duplicates are between native and foreign assets and {symbol: ForeignAbstract("symbol")} if the duplicates are in foreign assets only. You will get an error that will guide you further if you simply start with {symbol: "symbol"}.
78
78
  - You can now select assets by multilocation by simply using { multilocation: string | JSON }. The custom multilocation selection remains supported, but in order to use it you now have to use override - {multilocation: Override('Custom Multilocation')}.
79
79
  - The balance queries also support multilocation asset selection
80
+ - You can now query foreign asset minimal deposits also.
80
81
  ```
81
82
 
82
83
  ```
83
84
  Latest news:
84
- - You can now query foreign asset minimal deposits also.
85
85
  - Since v8, amount moved closer to currency selection and specifying from and to parameters is no longer optional to save code.
86
86
  - More information on v8 major breaking change: https://github.com/paraspell/xcm-tools/pull/554
87
87
  - XCM SDK Now supports API Failsafe - If one endpoint doesn't work it automatically switches to the next one.
88
+ - Builder now allows you to directly disconnect API.
88
89
  ```
89
90
 
90
91
  ### Builder pattern:
91
92
 
92
93
  ##### Transfer assets from Parachain to Parachain
93
94
  ```ts
94
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
95
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
95
96
  .from(NODE)
96
97
  .to(NODE /*,customParaId - optional*/ | Multilocation object /*Only works for PolkadotXCM pallet*/)
97
98
  .currency({id: currencyID, amount: amount} | {symbol: currencySymbol, amount: amount} | {symbol: Native('currencySymbol'), amount: amount} | {symbol: Foreign('currencySymbol'), amount: amount} | {symbol: ForeignAbstract('currencySymbol'), amount: amount} | {multilocation: AssetMultilocationString, amount: amount | AssetMultilocationJson, amount: amount} | {multilocation: Override('Custom Multilocation'), amount: amount} | {multiasset: {currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or multilocation: multilocation*/, amount: amount}})
98
99
  .address(address | Multilocation object /*If you are sending through xTokens, you need to pass the destination and address multilocation in one object (x2)*/)
99
100
  /*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
100
101
  .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
101
- .build()
102
+
103
+ const tx = await builder.build()
104
+
105
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
106
+ await builder.disconnect()
107
+
102
108
  /*
103
109
  EXAMPLE:
104
- const tx = await Builder()
110
+ const builder = Builder()
105
111
  .from('Acala')
106
112
  .to('Astar')
107
113
  .currency({
@@ -109,22 +115,31 @@ const tx = await Builder()
109
115
  amount: '1000000000'
110
116
  })
111
117
  .address(address)
112
- .build();
118
+
119
+ const tx = await builder.build()
120
+
121
+ //Disconnect API after TX
122
+ await builder.disconnect()
113
123
  */
114
124
  ```
115
125
  ##### Transfer assets from the Relay chain to Parachain
116
126
  ```ts
117
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
127
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
118
128
  .from(RELAY_NODE) //Kusama or Polkadot
119
129
  .to(NODE/*,customParaId - optional*/ | Multilocation object)
120
130
  .currency({symbol: 'DOT', amount: amount})
121
131
  .address(address | Multilocation object)
122
132
  /*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
123
133
  .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
124
- .build()
134
+
135
+ const tx = await builder.build()
136
+
137
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
138
+ await builder.disconnect()
139
+
125
140
  /*
126
141
  EXAMPLE:
127
- const tx = await Builder()
142
+ const builder = await Builder()
128
143
  .from('Polkadot')
129
144
  .to('Astar')
130
145
  .currency({
@@ -132,22 +147,31 @@ const tx = await Builder()
132
147
  amount: '1000000000'
133
148
  })
134
149
  .address(address)
135
- .build();
150
+
151
+ const tx = await builder.build()
152
+
153
+ //Disconnect API after TX
154
+ await builder.disconnect()
136
155
  */
137
156
  ```
138
157
  ##### Transfer assets from Parachain to Relay chain
139
158
  ```ts
140
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
159
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
141
160
  .from(NODE)
142
161
  .to(RELAY_NODE) //Kusama or Polkadot
143
162
  .currency({symbol: 'DOT', amount: amount})
144
163
  .address(address | Multilocation object)
145
164
  /*.xcmVersion(Version.V1/V2/V3/V4) //Optional parameter for manual override of XCM Version used in call
146
165
  .customPallet('Pallet','pallet_function') //Optional parameter for manual override of XCM Pallet and function used in call (If they are named differently on some node but syntax stays the same). Both pallet name and function required. Pallet name must be CamelCase, function name snake_case.*/
147
- .build()
166
+
167
+ const tx = await builder.build()
168
+
169
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
170
+ await builder.disconnect()
171
+
148
172
  /*
149
173
  EXAMPLE:
150
- const tx = await Builder()
174
+ const builder = await Builder()
151
175
  .from('Astar')
152
176
  .to('Polkadot')
153
177
  .currency({
@@ -155,14 +179,18 @@ const tx = await Builder()
155
179
  amount: '1000000000'
156
180
  })
157
181
  .address(address)
158
- .build();
182
+
183
+ const tx = await builder.build()
184
+
185
+ //Disconnect API after TX
186
+ await builder.disconnect()
159
187
  */
160
188
  ```
161
189
 
162
190
  ##### Batch calls
163
191
  You can batch XCM calls and execute multiple XCM calls within one call. All three scenarios (Para->Para, Para->Relay, Relay->Para) can be used and combined.
164
192
  ```js
165
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
193
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
166
194
  .from(NODE) //Ensure, that origin node is the same in all batched XCM Calls.
167
195
  .to(NODE_2) //Any compatible Parachain
168
196
  .currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
@@ -174,10 +202,14 @@ await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
174
202
  .currency({currencySelection, amount}) //Currency to transfer - options as in scenarios above
175
203
  .address(address | Multilocation object)
176
204
  .addToBatch()
177
- .buildBatch({
205
+
206
+ const tx = await builder.buildBatch({
178
207
  // This settings object is optional and batch all is the default option
179
208
  mode: BatchMode.BATCH_ALL //or BatchMode.BATCH
180
209
  })
210
+
211
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
212
+ await builder.disconnect()
181
213
  ```
182
214
 
183
215
  ### Dry run your XCM Calls:
@@ -197,12 +229,16 @@ getDryRun({api /*optional*/, node, address, tx /* Extrinsic object */})
197
229
  ### Asset claim:
198
230
  ```ts
199
231
  //Claim XCM trapped assets from the selected chain
200
- await Builder(/*node api/ws_url_string/ws_url_array - optional*/)
232
+ const builder = Builder(/*node api/ws_url_string/ws_url_array - optional*/)
201
233
  .claimFrom(NODE)
202
234
  .fungible(MultilocationArray (Only one multilocation allowed) [{Multilocation}])
203
235
  .account(address | Multilocation object)
204
236
  /*.xcmVersion(Version.V3) Optional parameter, by default V3. XCM Version ENUM if a different XCM version is needed (Supported V2 & V3). Requires importing Version enum.*/
205
- .build()
237
+
238
+ const tx = await builder.build()
239
+
240
+ //Make sure to disconnect API after it is no longer used (eg. after transaction)
241
+ await builder.disconnect()
206
242
  ```
207
243
 
208
244
  ### Asset queries:
package/dist/index.cjs CHANGED
@@ -1182,22 +1182,31 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1182
1182
  key: "disconnect",
1183
1183
  value: function () {
1184
1184
  var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1185
+ var force,
1186
+ _args16 = arguments;
1185
1187
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1186
1188
  while (1) switch (_context16.prev = _context16.next) {
1187
1189
  case 0:
1188
- if (this.disconnectAllowed) {
1189
- _context16.next = 2;
1190
+ force = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : false;
1191
+ if (this.initialized) {
1192
+ _context16.next = 3;
1190
1193
  break;
1191
1194
  }
1192
- return _context16.abrupt("return");
1193
- case 2:
1194
- if (!(typeof this._api === 'string' || this._api === undefined)) {
1195
+ return _context16.abrupt("return", Promise.resolve());
1196
+ case 3:
1197
+ if (!(!force && !this.disconnectAllowed)) {
1195
1198
  _context16.next = 5;
1196
1199
  break;
1197
1200
  }
1198
- _context16.next = 5;
1199
- return this.api.disconnect();
1201
+ return _context16.abrupt("return");
1200
1202
  case 5:
1203
+ if (!(force || typeof this._api === 'string' || this._api === undefined)) {
1204
+ _context16.next = 8;
1205
+ break;
1206
+ }
1207
+ _context16.next = 8;
1208
+ return this.api.disconnect();
1209
+ case 8:
1201
1210
  case "end":
1202
1211
  return _context16.stop();
1203
1212
  }
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { SubmittableExtrinsic } from '@polkadot/api/types';
6
6
  import * as _polkadot_api from '@polkadot/api';
7
7
  import { ApiPromise } from '@polkadot/api';
8
8
  import { AbstractProvider, Signer } from 'ethers';
9
+ import { WalletClient } from 'viem';
9
10
 
10
11
  type TPjsApi = ApiPromise;
11
12
  type TPjsApiOrUrl = TApiOrUrl<TPjsApi>;
@@ -164,7 +165,7 @@ declare class EvmBuilderClass<TApi, TRes> {
164
165
  * @param signer - The Ethereum signer to authorize the transfer.
165
166
  * @returns An instance of EvmBuilder
166
167
  */
167
- signer(signer: Signer): this;
168
+ signer(signer: Signer | WalletClient): this;
168
169
  /**
169
170
  * Builds and executes the transfer from Ethereum to Polkadot.
170
171
  *
package/dist/index.mjs CHANGED
@@ -1181,22 +1181,31 @@ var PolkadotJsApi = /*#__PURE__*/function () {
1181
1181
  key: "disconnect",
1182
1182
  value: function () {
1183
1183
  var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1184
+ var force,
1185
+ _args16 = arguments;
1184
1186
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1185
1187
  while (1) switch (_context16.prev = _context16.next) {
1186
1188
  case 0:
1187
- if (this.disconnectAllowed) {
1188
- _context16.next = 2;
1189
+ force = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : false;
1190
+ if (this.initialized) {
1191
+ _context16.next = 3;
1189
1192
  break;
1190
1193
  }
1191
- return _context16.abrupt("return");
1192
- case 2:
1193
- if (!(typeof this._api === 'string' || this._api === undefined)) {
1194
+ return _context16.abrupt("return", Promise.resolve());
1195
+ case 3:
1196
+ if (!(!force && !this.disconnectAllowed)) {
1194
1197
  _context16.next = 5;
1195
1198
  break;
1196
1199
  }
1197
- _context16.next = 5;
1198
- return this.api.disconnect();
1200
+ return _context16.abrupt("return");
1199
1201
  case 5:
1202
+ if (!(force || typeof this._api === 'string' || this._api === undefined)) {
1203
+ _context16.next = 8;
1204
+ break;
1205
+ }
1206
+ _context16.next = 8;
1207
+ return this.api.disconnect();
1208
+ case 8:
1200
1209
  case "end":
1201
1210
  return _context16.stop();
1202
1211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-pjs",
3
- "version": "8.0.2",
3
+ "version": "8.1.0",
4
4
  "description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,9 +11,9 @@
11
11
  "type": "module",
12
12
  "exports": {
13
13
  ".": {
14
+ "types": "./dist/index.d.ts",
14
15
  "import": "./dist/index.mjs",
15
- "require": "./dist/index.cjs",
16
- "types": "./dist/index.d.ts"
16
+ "require": "./dist/index.cjs"
17
17
  }
18
18
  },
19
19
  "main": "dist/index.cjs",
@@ -26,7 +26,7 @@
26
26
  "@snowbridge/api": "^0.1.25",
27
27
  "ethers": "^6.13.4",
28
28
  "viem": "^2.21.58",
29
- "@paraspell/sdk-core": "8.0.2"
29
+ "@paraspell/sdk-core": "8.1.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@polkadot/api": ">= 15.0 < 16",