@paraspell/sdk-dedot 12.9.7 → 13.0.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _paraspell_sdk_core from '@paraspell/sdk-core';
2
- import { TApiOrUrl, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, GeneralBuilder as GeneralBuilder$1, TSendBaseOptions } from '@paraspell/sdk-core';
2
+ import { TApiOrUrl, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, TSubstrateChain, TBuilderOptions, GeneralBuilder as GeneralBuilder$1, TTransferBaseOptions } from '@paraspell/sdk-core';
3
3
  export * from '@paraspell/sdk-core';
4
4
  import { DedotClient as DedotClient$1 } from 'dedot';
5
5
  import { GenericSubstrateApi as GenericSubstrateApi$1, ChainSubmittableExtrinsic as ChainSubmittableExtrinsic$1, IKeyringPair as IKeyringPair$1 } from 'dedot/types';
@@ -19,20 +19,11 @@ declare const getBalance: (options: _paraspell_sdk_core.TGetBalanceCommonOptions
19
19
  } & {
20
20
  api?: TDedotApiOrUrl;
21
21
  }) => Promise<bigint>;
22
- /**
23
- * Claims assets from a parachain.
24
- *
25
- * @returns An extrinsic representing the claim transaction.
26
- */
27
- declare const claimAssets: (options: _paraspell_sdk_core.TAssetClaimOptionsBase & {
28
- api?: TDedotApiOrUrl;
29
- }) => Promise<ChainSubmittableExtrinsic>;
30
22
 
31
23
  declare const assets_Foreign: typeof Foreign;
32
24
  declare const assets_ForeignAbstract: typeof ForeignAbstract;
33
25
  declare const assets_Native: typeof Native;
34
26
  declare const assets_Override: typeof Override;
35
- declare const assets_claimAssets: typeof claimAssets;
36
27
  declare const assets_findAssetInfo: typeof findAssetInfo;
37
28
  declare const assets_getAllAssetsSymbols: typeof getAllAssetsSymbols;
38
29
  declare const assets_getAssetDecimals: typeof getAssetDecimals;
@@ -55,7 +46,6 @@ declare namespace assets {
55
46
  assets_ForeignAbstract as ForeignAbstract,
56
47
  assets_Native as Native,
57
48
  assets_Override as Override,
58
- assets_claimAssets as claimAssets,
59
49
  assets_findAssetInfo as findAssetInfo,
60
50
  assets_getAllAssetsSymbols as getAllAssetsSymbols,
61
51
  assets_getAssetDecimals as getAssetDecimals,
@@ -84,7 +74,7 @@ declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
84
74
  * @returns A new Builder instance.
85
75
  */
86
76
  declare const Builder: (api?: TBuilderOptions<TDedotApiOrUrl>) => GeneralBuilder$1<DedotClient<GenericSubstrateApi>, ChainSubmittableExtrinsic, IKeyringPair, object>;
87
- type GeneralBuilder<T extends Partial<TSendBaseOptions<TDedotApi, TDedotExtrinsic, TDedotSigner>> = object> = GeneralBuilder$1<TDedotApi, TDedotExtrinsic, TDedotSigner, T>;
77
+ type GeneralBuilder<T extends Partial<TTransferBaseOptions<TDedotApi, TDedotExtrinsic, TDedotSigner>> = object> = GeneralBuilder$1<TDedotApi, TDedotExtrinsic, TDedotSigner, T>;
88
78
 
89
79
  declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<ChainSubmittableExtrinsic> & {
90
80
  api?: TDedotApiOrUrl;
@@ -113,5 +103,5 @@ declare namespace transfer {
113
103
 
114
104
  declare const createChainClient: (chain: TSubstrateChain, builderOptions?: TBuilderOptions<TDedotApiOrUrl>) => Promise<DedotClient<GenericSubstrateApi>>;
115
105
 
116
- export { Builder, assets, claimAssets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
106
+ export { Builder, assets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
117
107
  export type { GeneralBuilder, TDedotApi, TDedotApiOrUrl, TDedotExtrinsic, TDedotSigner };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, DEFAULT_TTL_MS, resolveChainApi, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, replaceBigInt, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$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';
1
+ import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, DEFAULT_TTL_MS, resolveChainApi, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, replaceBigInt, 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, 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 { stringPascalCase, isEvmAddress, decodeAddress, isHex, u8aToHex, hexToU8a, stringToU8a, blake2AsHex } from 'dedot/utils';
4
4
  import { Keyring } from '@polkadot/keyring';
@@ -607,7 +607,7 @@ var _transform = function transform(obj) {
607
607
  return {
608
608
  type: key,
609
609
  value: {
610
- jit_withdraw: (_value$jit_withdraw = value.jit_withdraw) !== null && _value$jit_withdraw !== void 0 ? _value$jit_withdraw : false
610
+ jitWithdraw: (_value$jit_withdraw = value.jit_withdraw) !== null && _value$jit_withdraw !== void 0 ? _value$jit_withdraw : false
611
611
  }
612
612
  };
613
613
  } else if (key === "PayFees") {
@@ -883,7 +883,7 @@ var DedotApi = /*#__PURE__*/function () {
883
883
  case 0:
884
884
  params = serialized.params;
885
885
  _this$convertToDedotC2 = this.convertToDedotCall(serialized), module = _this$convertToDedotC2.module, method = _this$convertToDedotC2.method;
886
- return _context4.a(2, this.api.query[module][method](params.length > 1 ? params : params[0]));
886
+ return _context4.a(2, this.api.query[module][method](params.length > 1 ? params.map(_transform) : params[0]));
887
887
  }
888
888
  }, _callee4, this);
889
889
  }));
@@ -1056,13 +1056,13 @@ var DedotApi = /*#__PURE__*/function () {
1056
1056
  return _regenerator().w(function (_context8) {
1057
1057
  while (1) switch (_context8.n) {
1058
1058
  case 0:
1059
- api = new DedotApi();
1059
+ api = new DedotApi(isConfig(this._config) ? this._config : undefined);
1060
1060
  _context8.n = 1;
1061
1061
  return api.init(chain);
1062
1062
  case 1:
1063
1063
  return _context8.a(2, api);
1064
1064
  }
1065
- }, _callee8);
1065
+ }, _callee8, this);
1066
1066
  }));
1067
1067
  function createApiForChain(_x11) {
1068
1068
  return _createApiForChain.apply(this, arguments);
@@ -1111,7 +1111,7 @@ var DedotApi = /*#__PURE__*/function () {
1111
1111
  isCustomAsset: true,
1112
1112
  asset: findAssetInfoOrThrow(chain, {
1113
1113
  id: assetId
1114
- }, null)
1114
+ })
1115
1115
  });
1116
1116
  }
1117
1117
  }, _callee9, this);
@@ -1129,7 +1129,7 @@ var DedotApi = /*#__PURE__*/function () {
1129
1129
  _result,
1130
1130
  _resValue$executionRe,
1131
1131
  _execRes$actualWeight;
1132
- var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, resValue, execRes, forwardedXcms, actualWeight, weight, destParaId, localXcm, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
1132
+ var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, _getAssetsObject, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, resValue, execRes, forwardedXcms, actualWeight, weight, destParaId, localXcm, USE_XCM_PAYMENT_API_CHAINS, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
1133
1133
  return _regenerator().w(function (_context1) {
1134
1134
  while (1) switch (_context1.p = _context1.n) {
1135
1135
  case 0:
@@ -1186,14 +1186,22 @@ var DedotApi = /*#__PURE__*/function () {
1186
1186
  return _ref1.apply(this, arguments);
1187
1187
  };
1188
1188
  }();
1189
+ findFailingEventInResult = function findFailingEventInResult(res) {
1190
+ var _res$value;
1191
+ return res === null || res === void 0 || (_res$value = res.value) === null || _res$value === void 0 || (_res$value = _res$value.emittedEvents) === null || _res$value === void 0 ? void 0 : _res$value.find(function (event) {
1192
+ var _event$palletEvent, _event$palletEvent2;
1193
+ return event.pallet === "Utility" && ((_event$palletEvent = event.palletEvent) === null || _event$palletEvent === void 0 ? void 0 : _event$palletEvent.name) === "DispatchedAs" && ((_event$palletEvent2 = event.palletEvent) === null || _event$palletEvent2 === void 0 || (_event$palletEvent2 = _event$palletEvent2.data) === null || _event$palletEvent2 === void 0 || (_event$palletEvent2 = _event$palletEvent2.result) === null || _event$palletEvent2 === void 0 ? void 0 : _event$palletEvent2.isErr) === true;
1194
+ });
1195
+ };
1189
1196
  getExecutionSuccessFromResult = function getExecutionSuccessFromResult(result) {
1190
1197
  var _result$value$executi;
1198
+ var errorInEvents = findFailingEventInResult(result);
1191
1199
  if (result !== null && result !== void 0 && result.isOk) {
1192
1200
  var _result$value3;
1193
1201
  var execResult = result === null || result === void 0 || (_result$value3 = result.value) === null || _result$value3 === void 0 ? void 0 : _result$value3.executionResult;
1194
- if (execResult !== null && execResult !== void 0 && execResult.isOk) return true;
1202
+ if (execResult !== null && execResult !== void 0 && execResult.isOk) return !errorInEvents;
1195
1203
  }
1196
- return Boolean((result === null || result === void 0 ? void 0 : result.isOk) && ((_result$value$executi = result.value.executionResult) === null || _result$value$executi === void 0 ? void 0 : _result$value$executi.isOk));
1204
+ return Boolean((result === null || result === void 0 ? void 0 : result.isOk) && ((_result$value$executi = result.value.executionResult) === null || _result$value$executi === void 0 ? void 0 : _result$value$executi.isOk)) && !errorInEvents;
1197
1205
  };
1198
1206
  extractFailureReasonFromResult = function extractFailureReasonFromResult(result) {
1199
1207
  var _result$value4, _execResult$value;
@@ -1220,6 +1228,21 @@ var DedotApi = /*#__PURE__*/function () {
1220
1228
  failureReason: JSON.stringify(execErr.error)
1221
1229
  };
1222
1230
  }
1231
+ var erroredEvent = findFailingEventInResult(result);
1232
+ if (erroredEvent) {
1233
+ var _eventResult$err;
1234
+ var eventResult = erroredEvent.palletEvent.data.result;
1235
+ var err = (_eventResult$err = eventResult === null || eventResult === void 0 ? void 0 : eventResult.err) !== null && _eventResult$err !== void 0 ? _eventResult$err : eventResult === null || eventResult === void 0 ? void 0 : eventResult.value;
1236
+ if (err !== null && err !== void 0 && err.type) {
1237
+ var subErr = err.value;
1238
+ if (subErr) {
1239
+ return resolveModuleError(chain, subErr);
1240
+ }
1241
+ return {
1242
+ failureReason: err.type
1243
+ };
1244
+ }
1245
+ }
1223
1246
  return {
1224
1247
  failureReason: JSON.stringify(result !== null && result !== void 0 ? result : "Unknown error")
1225
1248
  };
@@ -1580,19 +1603,19 @@ var DedotApi = /*#__PURE__*/function () {
1580
1603
  key: "getXcmWeight",
1581
1604
  value: function () {
1582
1605
  var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(xcm) {
1583
- var _ref11, _okValue$refTime, _ref12, _okValue$proofSize;
1606
+ var _okValue$refTime, _okValue$proofSize;
1584
1607
  var result, okValue;
1585
1608
  return _regenerator().w(function (_context14) {
1586
1609
  while (1) switch (_context14.n) {
1587
1610
  case 0:
1588
1611
  _context14.n = 1;
1589
- return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
1612
+ return this.api.call.xcmPaymentApi.queryXcmWeight(!xcm.type ? _transform(xcm) : xcm);
1590
1613
  case 1:
1591
1614
  result = _context14.v;
1592
1615
  okValue = result === null || result === void 0 ? void 0 : result.value;
1593
1616
  return _context14.a(2, {
1594
- refTime: BigInt((_ref11 = (_okValue$refTime = okValue === null || okValue === void 0 ? void 0 : okValue.refTime) !== null && _okValue$refTime !== void 0 ? _okValue$refTime : okValue === null || okValue === void 0 ? void 0 : okValue.ref_time) !== null && _ref11 !== void 0 ? _ref11 : 0),
1595
- proofSize: BigInt((_ref12 = (_okValue$proofSize = okValue === null || okValue === void 0 ? void 0 : okValue.proofSize) !== null && _okValue$proofSize !== void 0 ? _okValue$proofSize : okValue === null || okValue === void 0 ? void 0 : okValue.proof_size) !== null && _ref12 !== void 0 ? _ref12 : 0)
1617
+ refTime: BigInt((_okValue$refTime = okValue === null || okValue === void 0 ? void 0 : okValue.refTime) !== null && _okValue$refTime !== void 0 ? _okValue$refTime : 0),
1618
+ proofSize: BigInt((_okValue$proofSize = okValue === null || okValue === void 0 ? void 0 : okValue.proofSize) !== null && _okValue$proofSize !== void 0 ? _okValue$proofSize : 0)
1596
1619
  });
1597
1620
  }
1598
1621
  }, _callee14, this);
@@ -1605,13 +1628,13 @@ var DedotApi = /*#__PURE__*/function () {
1605
1628
  }, {
1606
1629
  key: "getDryRunXcm",
1607
1630
  value: function () {
1608
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref13) {
1631
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref11) {
1609
1632
  var _result$value5;
1610
1633
  var originLocation, xcm, asset, chain, version, _getAssetsObject2, supportsDryRunApi, transformedOriginLocation, result, executionResult, isSuccess, actualWeight, weight, forwardedXcms, destParaId, fee;
1611
1634
  return _regenerator().w(function (_context15) {
1612
1635
  while (1) switch (_context15.n) {
1613
1636
  case 0:
1614
- originLocation = _ref13.originLocation, xcm = _ref13.xcm, asset = _ref13.asset, chain = _ref13.chain, version = _ref13.version;
1637
+ originLocation = _ref11.originLocation, xcm = _ref11.xcm, asset = _ref11.asset, chain = _ref11.chain, version = _ref11.version;
1615
1638
  _getAssetsObject2 = getAssetsObject(chain), supportsDryRunApi = _getAssetsObject2.supportsDryRunApi;
1616
1639
  if (supportsDryRunApi) {
1617
1640
  _context15.n = 1;
@@ -1773,6 +1796,28 @@ var DedotApi = /*#__PURE__*/function () {
1773
1796
  }
1774
1797
  return signAndSubmit;
1775
1798
  }()
1799
+ }, {
1800
+ key: "signAndSubmitFinalized",
1801
+ value: function () {
1802
+ var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(tx, sender) {
1803
+ var account, result;
1804
+ return _regenerator().w(function (_context18) {
1805
+ while (1) switch (_context18.n) {
1806
+ case 0:
1807
+ account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
1808
+ _context18.n = 1;
1809
+ return tx.signAndSend(account).untilFinalized();
1810
+ case 1:
1811
+ result = _context18.v;
1812
+ return _context18.a(2, result.txHash);
1813
+ }
1814
+ }, _callee18);
1815
+ }));
1816
+ function signAndSubmitFinalized(_x33, _x34) {
1817
+ return _signAndSubmitFinalized.apply(this, arguments);
1818
+ }
1819
+ return signAndSubmitFinalized;
1820
+ }()
1776
1821
  }]);
1777
1822
  }();
1778
1823
 
@@ -1807,12 +1852,6 @@ var createDedotApiCall = function createDedotApiCall(apiCall) {
1807
1852
  * @returns The asset balance as a bigint.
1808
1853
  */
1809
1854
  var getBalance = createDedotApiCall(getBalance$1);
1810
- /**
1811
- * Claims assets from a parachain.
1812
- *
1813
- * @returns An extrinsic representing the claim transaction.
1814
- */
1815
- var claimAssets = createDedotApiCall(claimAssets$1);
1816
1855
 
1817
1856
  var assets = /*#__PURE__*/Object.freeze({
1818
1857
  __proto__: null,
@@ -1820,7 +1859,6 @@ var assets = /*#__PURE__*/Object.freeze({
1820
1859
  ForeignAbstract: ForeignAbstract,
1821
1860
  Native: Native,
1822
1861
  Override: Override,
1823
- claimAssets: claimAssets,
1824
1862
  findAssetInfo: findAssetInfo,
1825
1863
  getAllAssetsSymbols: getAllAssetsSymbols,
1826
1864
  getAssetDecimals: getAssetDecimals,
@@ -1902,4 +1940,4 @@ var transfer = /*#__PURE__*/Object.freeze({
1902
1940
  getParaEthTransferFees: getParaEthTransferFees
1903
1941
  });
1904
1942
 
1905
- export { Builder, assets, claimAssets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
1943
+ export { Builder, assets, convertSs58, createChainClient, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, transfer as xcmPallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-dedot",
3
- "version": "12.9.7",
3
+ "version": "13.0.0-rc.1",
4
4
  "description": "Dedot-based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@paraspell/sdk-core": "12.9.7"
26
+ "@paraspell/sdk-core": "13.0.0-rc.1"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "dedot": ">= 1.2.0",