@paraspell/sdk 7.2.0 → 7.2.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/dist/index.cjs CHANGED
@@ -15976,8 +15976,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
15976
15976
  case 3:
15977
15977
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
15978
15978
  case 4:
15979
+ if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
15980
+ _context.next = 6;
15981
+ break;
15982
+ }
15983
+ return _context.abrupt("return", api.getBalanceForeignBifrost(address, asset));
15984
+ case 6:
15979
15985
  return _context.abrupt("return", api.getBalanceForeignXTokens(address, asset));
15980
- case 5:
15986
+ case 7:
15981
15987
  case "end":
15982
15988
  return _context.stop();
15983
15989
  }
@@ -18183,17 +18189,39 @@ var PolkadotJsApi = /*#__PURE__*/function () {
18183
18189
  }));
18184
18190
  }
18185
18191
  }, {
18186
- key: "getBalanceForeignXTokens",
18187
- value: function getBalanceForeignXTokens(address, asset) {
18192
+ key: "getBalanceForeignBifrost",
18193
+ value: function getBalanceForeignBifrost(address, asset) {
18188
18194
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
18189
- var response, entry, accountData;
18195
+ var currencySelection, response, accountData;
18190
18196
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
18191
18197
  while (1) switch (_context9.prev = _context9.next) {
18192
18198
  case 0:
18193
- _context9.next = 2;
18199
+ currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
18200
+ _context9.next = 3;
18201
+ return this.api.query.tokens.accounts(address, currencySelection);
18202
+ case 3:
18203
+ response = _context9.sent;
18204
+ accountData = response ? response : null;
18205
+ return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18206
+ case 6:
18207
+ case "end":
18208
+ return _context9.stop();
18209
+ }
18210
+ }, _callee9, this);
18211
+ }));
18212
+ }
18213
+ }, {
18214
+ key: "getBalanceForeignXTokens",
18215
+ value: function getBalanceForeignXTokens(address, asset) {
18216
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18217
+ var response, entry, accountData;
18218
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18219
+ while (1) switch (_context10.prev = _context10.next) {
18220
+ case 0:
18221
+ _context10.next = 2;
18194
18222
  return this.api.query.tokens.accounts.entries(address);
18195
18223
  case 2:
18196
- response = _context9.sent;
18224
+ response = _context10.sent;
18197
18225
  entry = response.find(function (_ref2) {
18198
18226
  var _ref3 = _slicedToArray(_ref2, 2),
18199
18227
  _ref3$0$args = _slicedToArray(_ref3[0].args, 2);
@@ -18205,53 +18233,53 @@ var PolkadotJsApi = /*#__PURE__*/function () {
18205
18233
  return assetSymbol === ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || isForeignAsset(asset) && assetSymbol === ((_b = asset.assetId) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || Object.values((_c = assetItem.toHuman()) !== null && _c !== void 0 ? _c : {}).toString().toLowerCase() === ((_d = asset.symbol) === null || _d === void 0 ? void 0 : _d.toLowerCase()) || isForeignAsset(asset) && Object.values((_e = assetItem.toHuman()) !== null && _e !== void 0 ? _e : {}).toString().toLowerCase() === ((_f = asset.assetId) === null || _f === void 0 ? void 0 : _f.toLowerCase());
18206
18234
  });
18207
18235
  accountData = entry ? entry[1] : null;
18208
- return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18236
+ return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18209
18237
  case 6:
18210
18238
  case "end":
18211
- return _context9.stop();
18239
+ return _context10.stop();
18212
18240
  }
18213
- }, _callee9, this);
18241
+ }, _callee10, this);
18214
18242
  }));
18215
18243
  }
18216
18244
  }, {
18217
18245
  key: "getBalanceForeignAssetsAccount",
18218
18246
  value: function getBalanceForeignAssetsAccount(address, assetId) {
18219
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18247
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18220
18248
  var response, obj;
18221
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18222
- while (1) switch (_context10.prev = _context10.next) {
18249
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18250
+ while (1) switch (_context11.prev = _context11.next) {
18223
18251
  case 0:
18224
- _context10.next = 2;
18252
+ _context11.next = 2;
18225
18253
  return this.api.query.assets.account(assetId, address);
18226
18254
  case 2:
18227
- response = _context10.sent;
18255
+ response = _context11.sent;
18228
18256
  obj = response.toJSON();
18229
- return _context10.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
18257
+ return _context11.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
18230
18258
  case 5:
18231
18259
  case "end":
18232
- return _context10.stop();
18260
+ return _context11.stop();
18233
18261
  }
18234
- }, _callee10, this);
18262
+ }, _callee11, this);
18235
18263
  }));
18236
18264
  }
18237
18265
  }, {
18238
18266
  key: "getFromStorage",
18239
18267
  value: function getFromStorage(key) {
18240
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18268
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18241
18269
  var response;
18242
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18243
- while (1) switch (_context11.prev = _context11.next) {
18270
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18271
+ while (1) switch (_context12.prev = _context12.next) {
18244
18272
  case 0:
18245
- _context11.next = 2;
18273
+ _context12.next = 2;
18246
18274
  return this.api.rpc.state.getStorage(key);
18247
18275
  case 2:
18248
- response = _context11.sent;
18249
- return _context11.abrupt("return", response.toHex());
18276
+ response = _context12.sent;
18277
+ return _context12.abrupt("return", response.toHex());
18250
18278
  case 4:
18251
18279
  case "end":
18252
- return _context11.stop();
18280
+ return _context12.stop();
18253
18281
  }
18254
- }, _callee11, this);
18282
+ }, _callee12, this);
18255
18283
  }));
18256
18284
  }
18257
18285
  }, {
@@ -18262,21 +18290,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
18262
18290
  }, {
18263
18291
  key: "createApiForNode",
18264
18292
  value: function createApiForNode(node) {
18265
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18293
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
18266
18294
  var api;
18267
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18268
- while (1) switch (_context12.prev = _context12.next) {
18295
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
18296
+ while (1) switch (_context13.prev = _context13.next) {
18269
18297
  case 0:
18270
18298
  api = new PolkadotJsApi();
18271
- _context12.next = 3;
18299
+ _context13.next = 3;
18272
18300
  return api.init(node);
18273
18301
  case 3:
18274
- return _context12.abrupt("return", api);
18302
+ return _context13.abrupt("return", api);
18275
18303
  case 4:
18276
18304
  case "end":
18277
- return _context12.stop();
18305
+ return _context13.stop();
18278
18306
  }
18279
- }, _callee12);
18307
+ }, _callee13);
18280
18308
  }));
18281
18309
  }
18282
18310
  }]);
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ interface IPolkadotApi<TApi, TRes> {
22
22
  getAssetHubForeignBalance(address: string, multiLocation: TMultiLocation): Promise<bigint>;
23
23
  getForeignAssetsByIdBalance(address: string, assetId: string): Promise<bigint>;
24
24
  getBalanceForeignXTokens(address: string, asset: TAsset): Promise<bigint>;
25
+ getBalanceForeignBifrost(address: string, asset: TAsset): Promise<bigint>;
25
26
  getBalanceForeignAssetsAccount(address: string, assetId: bigint | number): Promise<bigint>;
26
27
  getFromStorage(key: string): Promise<string>;
27
28
  clone(): IPolkadotApi<TApi, TRes>;
@@ -69,7 +70,49 @@ declare class Crust<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXT
69
70
 
70
71
  declare class BifrostPolkadot<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXTokensTransfer, IPolkadotXCMTransfer {
71
72
  constructor();
72
- private getCurrencySelection;
73
+ getCurrencySelection(asset: TAsset): {
74
+ Native: string;
75
+ VToken?: undefined;
76
+ Token?: undefined;
77
+ VSToken2?: undefined;
78
+ VToken2?: undefined;
79
+ Token2?: undefined;
80
+ } | {
81
+ VToken: string;
82
+ Native?: undefined;
83
+ Token?: undefined;
84
+ VSToken2?: undefined;
85
+ VToken2?: undefined;
86
+ Token2?: undefined;
87
+ } | {
88
+ Token: string;
89
+ Native?: undefined;
90
+ VToken?: undefined;
91
+ VSToken2?: undefined;
92
+ VToken2?: undefined;
93
+ Token2?: undefined;
94
+ } | {
95
+ VSToken2: number;
96
+ Native?: undefined;
97
+ VToken?: undefined;
98
+ Token?: undefined;
99
+ VToken2?: undefined;
100
+ Token2?: undefined;
101
+ } | {
102
+ VToken2: number;
103
+ Native?: undefined;
104
+ VToken?: undefined;
105
+ Token?: undefined;
106
+ VSToken2?: undefined;
107
+ Token2?: undefined;
108
+ } | {
109
+ Token2: number;
110
+ Native?: undefined;
111
+ VToken?: undefined;
112
+ Token?: undefined;
113
+ VSToken2?: undefined;
114
+ VToken2?: undefined;
115
+ };
73
116
  transferXTokens<TApi, TRes>(input: XTokensTransferInput<TApi, TRes>): TTransferReturn<TRes>;
74
117
  transferPolkadotXCM<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>): Promise<TTransferReturn<TRes>>;
75
118
  protected canUseXTokens({ asset, destination }: TSendInternalOptions<TApi, TRes>): boolean;
package/dist/index.mjs CHANGED
@@ -15974,8 +15974,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
15974
15974
  case 3:
15975
15975
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
15976
15976
  case 4:
15977
+ if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
15978
+ _context.next = 6;
15979
+ break;
15980
+ }
15981
+ return _context.abrupt("return", api.getBalanceForeignBifrost(address, asset));
15982
+ case 6:
15977
15983
  return _context.abrupt("return", api.getBalanceForeignXTokens(address, asset));
15978
- case 5:
15984
+ case 7:
15979
15985
  case "end":
15980
15986
  return _context.stop();
15981
15987
  }
@@ -18181,17 +18187,39 @@ var PolkadotJsApi = /*#__PURE__*/function () {
18181
18187
  }));
18182
18188
  }
18183
18189
  }, {
18184
- key: "getBalanceForeignXTokens",
18185
- value: function getBalanceForeignXTokens(address, asset) {
18190
+ key: "getBalanceForeignBifrost",
18191
+ value: function getBalanceForeignBifrost(address, asset) {
18186
18192
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
18187
- var response, entry, accountData;
18193
+ var currencySelection, response, accountData;
18188
18194
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
18189
18195
  while (1) switch (_context9.prev = _context9.next) {
18190
18196
  case 0:
18191
- _context9.next = 2;
18197
+ currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
18198
+ _context9.next = 3;
18199
+ return this.api.query.tokens.accounts(address, currencySelection);
18200
+ case 3:
18201
+ response = _context9.sent;
18202
+ accountData = response ? response : null;
18203
+ return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18204
+ case 6:
18205
+ case "end":
18206
+ return _context9.stop();
18207
+ }
18208
+ }, _callee9, this);
18209
+ }));
18210
+ }
18211
+ }, {
18212
+ key: "getBalanceForeignXTokens",
18213
+ value: function getBalanceForeignXTokens(address, asset) {
18214
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18215
+ var response, entry, accountData;
18216
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18217
+ while (1) switch (_context10.prev = _context10.next) {
18218
+ case 0:
18219
+ _context10.next = 2;
18192
18220
  return this.api.query.tokens.accounts.entries(address);
18193
18221
  case 2:
18194
- response = _context9.sent;
18222
+ response = _context10.sent;
18195
18223
  entry = response.find(function (_ref2) {
18196
18224
  var _ref3 = _slicedToArray(_ref2, 2),
18197
18225
  _ref3$0$args = _slicedToArray(_ref3[0].args, 2);
@@ -18203,53 +18231,53 @@ var PolkadotJsApi = /*#__PURE__*/function () {
18203
18231
  return assetSymbol === ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || isForeignAsset(asset) && assetSymbol === ((_b = asset.assetId) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || Object.values((_c = assetItem.toHuman()) !== null && _c !== void 0 ? _c : {}).toString().toLowerCase() === ((_d = asset.symbol) === null || _d === void 0 ? void 0 : _d.toLowerCase()) || isForeignAsset(asset) && Object.values((_e = assetItem.toHuman()) !== null && _e !== void 0 ? _e : {}).toString().toLowerCase() === ((_f = asset.assetId) === null || _f === void 0 ? void 0 : _f.toLowerCase());
18204
18232
  });
18205
18233
  accountData = entry ? entry[1] : null;
18206
- return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18234
+ return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18207
18235
  case 6:
18208
18236
  case "end":
18209
- return _context9.stop();
18237
+ return _context10.stop();
18210
18238
  }
18211
- }, _callee9, this);
18239
+ }, _callee10, this);
18212
18240
  }));
18213
18241
  }
18214
18242
  }, {
18215
18243
  key: "getBalanceForeignAssetsAccount",
18216
18244
  value: function getBalanceForeignAssetsAccount(address, assetId) {
18217
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18245
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18218
18246
  var response, obj;
18219
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18220
- while (1) switch (_context10.prev = _context10.next) {
18247
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18248
+ while (1) switch (_context11.prev = _context11.next) {
18221
18249
  case 0:
18222
- _context10.next = 2;
18250
+ _context11.next = 2;
18223
18251
  return this.api.query.assets.account(assetId, address);
18224
18252
  case 2:
18225
- response = _context10.sent;
18253
+ response = _context11.sent;
18226
18254
  obj = response.toJSON();
18227
- return _context10.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
18255
+ return _context11.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
18228
18256
  case 5:
18229
18257
  case "end":
18230
- return _context10.stop();
18258
+ return _context11.stop();
18231
18259
  }
18232
- }, _callee10, this);
18260
+ }, _callee11, this);
18233
18261
  }));
18234
18262
  }
18235
18263
  }, {
18236
18264
  key: "getFromStorage",
18237
18265
  value: function getFromStorage(key) {
18238
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18266
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18239
18267
  var response;
18240
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18241
- while (1) switch (_context11.prev = _context11.next) {
18268
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18269
+ while (1) switch (_context12.prev = _context12.next) {
18242
18270
  case 0:
18243
- _context11.next = 2;
18271
+ _context12.next = 2;
18244
18272
  return this.api.rpc.state.getStorage(key);
18245
18273
  case 2:
18246
- response = _context11.sent;
18247
- return _context11.abrupt("return", response.toHex());
18274
+ response = _context12.sent;
18275
+ return _context12.abrupt("return", response.toHex());
18248
18276
  case 4:
18249
18277
  case "end":
18250
- return _context11.stop();
18278
+ return _context12.stop();
18251
18279
  }
18252
- }, _callee11, this);
18280
+ }, _callee12, this);
18253
18281
  }));
18254
18282
  }
18255
18283
  }, {
@@ -18260,21 +18288,21 @@ var PolkadotJsApi = /*#__PURE__*/function () {
18260
18288
  }, {
18261
18289
  key: "createApiForNode",
18262
18290
  value: function createApiForNode(node) {
18263
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18291
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
18264
18292
  var api;
18265
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18266
- while (1) switch (_context12.prev = _context12.next) {
18293
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
18294
+ while (1) switch (_context13.prev = _context13.next) {
18267
18295
  case 0:
18268
18296
  api = new PolkadotJsApi();
18269
- _context12.next = 3;
18297
+ _context13.next = 3;
18270
18298
  return api.init(node);
18271
18299
  case 3:
18272
- return _context12.abrupt("return", api);
18300
+ return _context13.abrupt("return", api);
18273
18301
  case 4:
18274
18302
  case "end":
18275
- return _context12.stop();
18303
+ return _context13.stop();
18276
18304
  }
18277
- }, _callee12);
18305
+ }, _callee13);
18278
18306
  }));
18279
18307
  }
18280
18308
  }]);
@@ -15976,8 +15976,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
15976
15976
  case 3:
15977
15977
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
15978
15978
  case 4:
15979
+ if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
15980
+ _context.next = 6;
15981
+ break;
15982
+ }
15983
+ return _context.abrupt("return", api.getBalanceForeignBifrost(address, asset));
15984
+ case 6:
15979
15985
  return _context.abrupt("return", api.getBalanceForeignXTokens(address, asset));
15980
- case 5:
15986
+ case 7:
15981
15987
  case "end":
15982
15988
  return _context.stop();
15983
15989
  }
@@ -18259,9 +18265,7 @@ var PapiApi = /*#__PURE__*/function () {
18259
18265
  var module = _ref.module,
18260
18266
  section = _ref.section,
18261
18267
  parameters = _ref.parameters;
18262
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18263
18268
  var transformedParameters = _transform(parameters);
18264
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
18265
18269
  return this.api.getUnsafeApi().tx[module][section](transformedParameters);
18266
18270
  }
18267
18271
  }, {
@@ -18347,8 +18351,7 @@ var PapiApi = /*#__PURE__*/function () {
18347
18351
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
18348
18352
  while (1) switch (_context7.prev = _context7.next) {
18349
18353
  case 0:
18350
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18351
- transformedMultiLocation = _transform(multiLocation); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18354
+ transformedMultiLocation = _transform(multiLocation);
18352
18355
  _context7.next = 3;
18353
18356
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
18354
18357
  case 3:
@@ -18382,70 +18385,92 @@ var PapiApi = /*#__PURE__*/function () {
18382
18385
  }));
18383
18386
  }
18384
18387
  }, {
18385
- key: "getBalanceForeignXTokens",
18386
- value: function getBalanceForeignXTokens(address, asset) {
18388
+ key: "getBalanceForeignBifrost",
18389
+ value: function getBalanceForeignBifrost(address, asset) {
18387
18390
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
18388
- var response, entry;
18391
+ var currencySelection, transformedParameters, response, accountData;
18389
18392
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
18390
18393
  while (1) switch (_context9.prev = _context9.next) {
18391
18394
  case 0:
18392
- _context9.next = 2;
18395
+ currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
18396
+ transformedParameters = _transform(currencySelection);
18397
+ _context9.next = 4;
18398
+ return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
18399
+ case 4:
18400
+ response = _context9.sent;
18401
+ accountData = response ? response : null;
18402
+ return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18403
+ case 7:
18404
+ case "end":
18405
+ return _context9.stop();
18406
+ }
18407
+ }, _callee9, this);
18408
+ }));
18409
+ }
18410
+ }, {
18411
+ key: "getBalanceForeignXTokens",
18412
+ value: function getBalanceForeignXTokens(address, asset) {
18413
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18414
+ var response, entry;
18415
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18416
+ while (1) switch (_context10.prev = _context10.next) {
18417
+ case 0:
18418
+ _context10.next = 2;
18393
18419
  return this.api.getUnsafeApi().query.Tokens.Accounts.getEntries(address);
18394
18420
  case 2:
18395
- response = _context9.sent;
18421
+ response = _context10.sent;
18396
18422
  entry = response.find(function (_ref2) {
18397
18423
  var keyArgs = _ref2.keyArgs;
18398
18424
  var _a, _b, _c, _d;
18399
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18400
18425
  var _keyArgs = _slicedToArray(keyArgs, 2);
18401
18426
  _keyArgs[0];
18402
18427
  var assetItem = _keyArgs[1];
18403
18428
  return assetItem.toString().toLowerCase() === ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_b = asset.assetId) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_c = asset.symbol) === null || _c === void 0 ? void 0 : _c.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_d = asset.assetId) === null || _d === void 0 ? void 0 : _d.toLowerCase());
18404
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
18405
- return _context9.abrupt("return", (entry === null || entry === void 0 ? void 0 : entry.value) ? BigInt(entry.value.free.toString()) : BigInt(0));
18429
+ });
18430
+ return _context10.abrupt("return", (entry === null || entry === void 0 ? void 0 : entry.value) ? BigInt(entry.value.free.toString()) : BigInt(0));
18406
18431
  case 5:
18407
18432
  case "end":
18408
- return _context9.stop();
18433
+ return _context10.stop();
18409
18434
  }
18410
- }, _callee9, this);
18435
+ }, _callee10, this);
18411
18436
  }));
18412
18437
  }
18413
18438
  }, {
18414
18439
  key: "getBalanceForeignAssetsAccount",
18415
18440
  value: function getBalanceForeignAssetsAccount(address, assetId) {
18416
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18441
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18417
18442
  var response;
18418
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18419
- while (1) switch (_context10.prev = _context10.next) {
18443
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18444
+ while (1) switch (_context11.prev = _context11.next) {
18420
18445
  case 0:
18421
- _context10.next = 2;
18446
+ _context11.next = 2;
18422
18447
  return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
18423
18448
  case 2:
18424
- response = _context10.sent;
18425
- return _context10.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
18449
+ response = _context11.sent;
18450
+ return _context11.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
18426
18451
  case 4:
18427
18452
  case "end":
18428
- return _context10.stop();
18453
+ return _context11.stop();
18429
18454
  }
18430
- }, _callee10, this);
18455
+ }, _callee11, this);
18431
18456
  }));
18432
18457
  }
18433
18458
  }, {
18434
18459
  key: "getFromStorage",
18435
18460
  value: function getFromStorage(key) {
18436
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18437
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18438
- while (1) switch (_context11.prev = _context11.next) {
18461
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18462
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18463
+ while (1) switch (_context12.prev = _context12.next) {
18439
18464
  case 0:
18440
- _context11.next = 2;
18465
+ _context12.next = 2;
18441
18466
  return this.api._request('state_getStorage', [key]);
18442
18467
  case 2:
18443
- return _context11.abrupt("return", _context11.sent);
18468
+ return _context12.abrupt("return", _context12.sent);
18444
18469
  case 3:
18445
18470
  case "end":
18446
- return _context11.stop();
18471
+ return _context12.stop();
18447
18472
  }
18448
- }, _callee11, this);
18473
+ }, _callee12, this);
18449
18474
  }));
18450
18475
  }
18451
18476
  }, {
@@ -18456,21 +18481,21 @@ var PapiApi = /*#__PURE__*/function () {
18456
18481
  }, {
18457
18482
  key: "createApiForNode",
18458
18483
  value: function createApiForNode(node) {
18459
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18484
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
18460
18485
  var api;
18461
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18462
- while (1) switch (_context12.prev = _context12.next) {
18486
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
18487
+ while (1) switch (_context13.prev = _context13.next) {
18463
18488
  case 0:
18464
18489
  api = new PapiApi();
18465
- _context12.next = 3;
18490
+ _context13.next = 3;
18466
18491
  return api.init(node);
18467
18492
  case 3:
18468
- return _context12.abrupt("return", api);
18493
+ return _context13.abrupt("return", api);
18469
18494
  case 4:
18470
18495
  case "end":
18471
- return _context12.stop();
18496
+ return _context13.stop();
18472
18497
  }
18473
- }, _callee12);
18498
+ }, _callee13);
18474
18499
  }));
18475
18500
  }
18476
18501
  }]);
@@ -21,6 +21,7 @@ interface IPolkadotApi<TApi, TRes> {
21
21
  getAssetHubForeignBalance(address: string, multiLocation: TMultiLocation): Promise<bigint>;
22
22
  getForeignAssetsByIdBalance(address: string, assetId: string): Promise<bigint>;
23
23
  getBalanceForeignXTokens(address: string, asset: TAsset): Promise<bigint>;
24
+ getBalanceForeignBifrost(address: string, asset: TAsset): Promise<bigint>;
24
25
  getBalanceForeignAssetsAccount(address: string, assetId: bigint | number): Promise<bigint>;
25
26
  getFromStorage(key: string): Promise<string>;
26
27
  clone(): IPolkadotApi<TApi, TRes>;
@@ -68,7 +69,49 @@ declare class Crust<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXT
68
69
 
69
70
  declare class BifrostPolkadot<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXTokensTransfer, IPolkadotXCMTransfer {
70
71
  constructor();
71
- private getCurrencySelection;
72
+ getCurrencySelection(asset: TAsset): {
73
+ Native: string;
74
+ VToken?: undefined;
75
+ Token?: undefined;
76
+ VSToken2?: undefined;
77
+ VToken2?: undefined;
78
+ Token2?: undefined;
79
+ } | {
80
+ VToken: string;
81
+ Native?: undefined;
82
+ Token?: undefined;
83
+ VSToken2?: undefined;
84
+ VToken2?: undefined;
85
+ Token2?: undefined;
86
+ } | {
87
+ Token: string;
88
+ Native?: undefined;
89
+ VToken?: undefined;
90
+ VSToken2?: undefined;
91
+ VToken2?: undefined;
92
+ Token2?: undefined;
93
+ } | {
94
+ VSToken2: number;
95
+ Native?: undefined;
96
+ VToken?: undefined;
97
+ Token?: undefined;
98
+ VToken2?: undefined;
99
+ Token2?: undefined;
100
+ } | {
101
+ VToken2: number;
102
+ Native?: undefined;
103
+ VToken?: undefined;
104
+ Token?: undefined;
105
+ VSToken2?: undefined;
106
+ Token2?: undefined;
107
+ } | {
108
+ Token2: number;
109
+ Native?: undefined;
110
+ VToken?: undefined;
111
+ Token?: undefined;
112
+ VSToken2?: undefined;
113
+ VToken2?: undefined;
114
+ };
72
115
  transferXTokens<TApi, TRes>(input: XTokensTransferInput<TApi, TRes>): TTransferReturn<TRes>;
73
116
  transferPolkadotXCM<TApi, TRes>(input: PolkadotXCMTransferInput<TApi, TRes>): Promise<TTransferReturn<TRes>>;
74
117
  protected canUseXTokens({ asset, destination }: TSendInternalOptions<TApi, TRes>): boolean;
@@ -15974,8 +15974,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
15974
15974
  case 3:
15975
15975
  return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
15976
15976
  case 4:
15977
+ if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
15978
+ _context.next = 6;
15979
+ break;
15980
+ }
15981
+ return _context.abrupt("return", api.getBalanceForeignBifrost(address, asset));
15982
+ case 6:
15977
15983
  return _context.abrupt("return", api.getBalanceForeignXTokens(address, asset));
15978
- case 5:
15984
+ case 7:
15979
15985
  case "end":
15980
15986
  return _context.stop();
15981
15987
  }
@@ -18257,9 +18263,7 @@ var PapiApi = /*#__PURE__*/function () {
18257
18263
  var module = _ref.module,
18258
18264
  section = _ref.section,
18259
18265
  parameters = _ref.parameters;
18260
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18261
18266
  var transformedParameters = _transform(parameters);
18262
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
18263
18267
  return this.api.getUnsafeApi().tx[module][section](transformedParameters);
18264
18268
  }
18265
18269
  }, {
@@ -18345,8 +18349,7 @@ var PapiApi = /*#__PURE__*/function () {
18345
18349
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
18346
18350
  while (1) switch (_context7.prev = _context7.next) {
18347
18351
  case 0:
18348
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18349
- transformedMultiLocation = _transform(multiLocation); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18352
+ transformedMultiLocation = _transform(multiLocation);
18350
18353
  _context7.next = 3;
18351
18354
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
18352
18355
  case 3:
@@ -18380,70 +18383,92 @@ var PapiApi = /*#__PURE__*/function () {
18380
18383
  }));
18381
18384
  }
18382
18385
  }, {
18383
- key: "getBalanceForeignXTokens",
18384
- value: function getBalanceForeignXTokens(address, asset) {
18386
+ key: "getBalanceForeignBifrost",
18387
+ value: function getBalanceForeignBifrost(address, asset) {
18385
18388
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
18386
- var response, entry;
18389
+ var currencySelection, transformedParameters, response, accountData;
18387
18390
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
18388
18391
  while (1) switch (_context9.prev = _context9.next) {
18389
18392
  case 0:
18390
- _context9.next = 2;
18393
+ currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
18394
+ transformedParameters = _transform(currencySelection);
18395
+ _context9.next = 4;
18396
+ return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
18397
+ case 4:
18398
+ response = _context9.sent;
18399
+ accountData = response ? response : null;
18400
+ return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
18401
+ case 7:
18402
+ case "end":
18403
+ return _context9.stop();
18404
+ }
18405
+ }, _callee9, this);
18406
+ }));
18407
+ }
18408
+ }, {
18409
+ key: "getBalanceForeignXTokens",
18410
+ value: function getBalanceForeignXTokens(address, asset) {
18411
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18412
+ var response, entry;
18413
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18414
+ while (1) switch (_context10.prev = _context10.next) {
18415
+ case 0:
18416
+ _context10.next = 2;
18391
18417
  return this.api.getUnsafeApi().query.Tokens.Accounts.getEntries(address);
18392
18418
  case 2:
18393
- response = _context9.sent;
18419
+ response = _context10.sent;
18394
18420
  entry = response.find(function (_ref2) {
18395
18421
  var keyArgs = _ref2.keyArgs;
18396
18422
  var _a, _b, _c, _d;
18397
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18398
18423
  var _keyArgs = _slicedToArray(keyArgs, 2);
18399
18424
  _keyArgs[0];
18400
18425
  var assetItem = _keyArgs[1];
18401
18426
  return assetItem.toString().toLowerCase() === ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_b = asset.assetId) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_c = asset.symbol) === null || _c === void 0 ? void 0 : _c.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_d = asset.assetId) === null || _d === void 0 ? void 0 : _d.toLowerCase());
18402
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
18403
- return _context9.abrupt("return", (entry === null || entry === void 0 ? void 0 : entry.value) ? BigInt(entry.value.free.toString()) : BigInt(0));
18427
+ });
18428
+ return _context10.abrupt("return", (entry === null || entry === void 0 ? void 0 : entry.value) ? BigInt(entry.value.free.toString()) : BigInt(0));
18404
18429
  case 5:
18405
18430
  case "end":
18406
- return _context9.stop();
18431
+ return _context10.stop();
18407
18432
  }
18408
- }, _callee9, this);
18433
+ }, _callee10, this);
18409
18434
  }));
18410
18435
  }
18411
18436
  }, {
18412
18437
  key: "getBalanceForeignAssetsAccount",
18413
18438
  value: function getBalanceForeignAssetsAccount(address, assetId) {
18414
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
18439
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18415
18440
  var response;
18416
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
18417
- while (1) switch (_context10.prev = _context10.next) {
18441
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18442
+ while (1) switch (_context11.prev = _context11.next) {
18418
18443
  case 0:
18419
- _context10.next = 2;
18444
+ _context11.next = 2;
18420
18445
  return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
18421
18446
  case 2:
18422
- response = _context10.sent;
18423
- return _context10.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
18447
+ response = _context11.sent;
18448
+ return _context11.abrupt("return", BigInt(response === undefined ? 0 : response.balance));
18424
18449
  case 4:
18425
18450
  case "end":
18426
- return _context10.stop();
18451
+ return _context11.stop();
18427
18452
  }
18428
- }, _callee10, this);
18453
+ }, _callee11, this);
18429
18454
  }));
18430
18455
  }
18431
18456
  }, {
18432
18457
  key: "getFromStorage",
18433
18458
  value: function getFromStorage(key) {
18434
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
18435
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
18436
- while (1) switch (_context11.prev = _context11.next) {
18459
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18460
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18461
+ while (1) switch (_context12.prev = _context12.next) {
18437
18462
  case 0:
18438
- _context11.next = 2;
18463
+ _context12.next = 2;
18439
18464
  return this.api._request('state_getStorage', [key]);
18440
18465
  case 2:
18441
- return _context11.abrupt("return", _context11.sent);
18466
+ return _context12.abrupt("return", _context12.sent);
18442
18467
  case 3:
18443
18468
  case "end":
18444
- return _context11.stop();
18469
+ return _context12.stop();
18445
18470
  }
18446
- }, _callee11, this);
18471
+ }, _callee12, this);
18447
18472
  }));
18448
18473
  }
18449
18474
  }, {
@@ -18454,21 +18479,21 @@ var PapiApi = /*#__PURE__*/function () {
18454
18479
  }, {
18455
18480
  key: "createApiForNode",
18456
18481
  value: function createApiForNode(node) {
18457
- return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
18482
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
18458
18483
  var api;
18459
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
18460
- while (1) switch (_context12.prev = _context12.next) {
18484
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
18485
+ while (1) switch (_context13.prev = _context13.next) {
18461
18486
  case 0:
18462
18487
  api = new PapiApi();
18463
- _context12.next = 3;
18488
+ _context13.next = 3;
18464
18489
  return api.init(node);
18465
18490
  case 3:
18466
- return _context12.abrupt("return", api);
18491
+ return _context13.abrupt("return", api);
18467
18492
  case 4:
18468
18493
  case "end":
18469
- return _context12.stop();
18494
+ return _context13.stop();
18470
18495
  }
18471
- }, _callee12);
18496
+ }, _callee13);
18472
18497
  }));
18473
18498
  }
18474
18499
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "7.2.0",
3
+ "version": "7.2.1",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",