@paraspell/sdk-dedot 13.4.1 → 13.6.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 +68 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +78 -23
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -317,6 +317,74 @@ const tx = await builder.buildBatch({
|
|
|
317
317
|
await builder.disconnect()
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
+
#### Adding chain and/or assets
|
|
321
|
+
SDK features ability to add custom chain and/or custom assets simply by adding its config to the Builder.
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
const tx = await Builder({
|
|
325
|
+
// Adding custom chain
|
|
326
|
+
customChains: {
|
|
327
|
+
MyChain: {
|
|
328
|
+
paraId: 4242,
|
|
329
|
+
ecosystem: 'Polkadot',
|
|
330
|
+
xcmVersion: Version.V5,
|
|
331
|
+
providers: [{ name: 'Primary', endpoint: 'wss://rpc.mychain.example/ws' }],
|
|
332
|
+
// Everything below is optional — auto-fetched from runtime `system.properties` when omitted
|
|
333
|
+
nativeAssetSymbol: 'MYC',
|
|
334
|
+
nativeAssetDecimals: 12,
|
|
335
|
+
ss58Prefix: 42,
|
|
336
|
+
pallets: {
|
|
337
|
+
nativeAssets: "Balances”,
|
|
338
|
+
otherAssets: "Assets",
|
|
339
|
+
}
|
|
340
|
+
assets: [
|
|
341
|
+
{
|
|
342
|
+
symbol: 'USDC',
|
|
343
|
+
decimals: 6,
|
|
344
|
+
location: {
|
|
345
|
+
parents: 1,
|
|
346
|
+
interior: { X3: [{ Parachain: 1000 }, { PalletInstance: 50 }, {
|
|
347
|
+
GeneralIndex: 1337 }] }
|
|
348
|
+
},
|
|
349
|
+
assetId: '1337'
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
// Adding assets to existing chains
|
|
356
|
+
customAssets: {
|
|
357
|
+
AssetHubPolkadot: [
|
|
358
|
+
{
|
|
359
|
+
symbol: 'MYNEWUSD',
|
|
360
|
+
decimals: 6,
|
|
361
|
+
assetId: '9999',
|
|
362
|
+
location: {
|
|
363
|
+
parents: 0,
|
|
364
|
+
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 9999 }] }
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
// Replace an existing registry asset that shares the same location
|
|
369
|
+
symbol: 'USDT',
|
|
370
|
+
decimals: 6,
|
|
371
|
+
assetId: '1984',
|
|
372
|
+
location: {
|
|
373
|
+
parents: 0,
|
|
374
|
+
interior: { X2: [{ PalletInstance: 50 }, { GeneralIndex: 1984 }] }
|
|
375
|
+
},
|
|
376
|
+
forceOverride: true
|
|
377
|
+
}
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
})
|
|
381
|
+
.from('MyChain') // custom chain name — TS-autocompletes
|
|
382
|
+
.to('AssetHubPolkadot') // could be any of the existing or also the new ones added
|
|
383
|
+
.currency({ symbol: 'USDC', amount: amount })
|
|
384
|
+
.recipient(address)
|
|
385
|
+
.build()
|
|
386
|
+
```
|
|
387
|
+
|
|
320
388
|
### Localhost test setup
|
|
321
389
|
|
|
322
390
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _paraspell_sdk_core from '@paraspell/sdk-core';
|
|
2
|
-
import { 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';
|
|
2
|
+
import { 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, TCustomChainFrom, 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';
|
|
@@ -67,13 +67,13 @@ declare namespace assets {
|
|
|
67
67
|
declare const convertSs58: (address: string, chain: TSubstrateChain) => string;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Creates a new Builder instance
|
|
70
|
+
* Creates a new Builder instance.
|
|
71
71
|
*
|
|
72
|
-
* @param
|
|
72
|
+
* @param options - Either an existing API instance, a WS URL, or a config object.
|
|
73
73
|
* @returns A new Builder instance.
|
|
74
74
|
*/
|
|
75
|
-
declare const Builder:
|
|
76
|
-
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TDedotApi, TDedotExtrinsic, TDedotSigner>> = object> = GeneralBuilder$1<TDedotApi, TDedotExtrinsic, TDedotSigner, T>;
|
|
75
|
+
declare const Builder: <const TOpts extends TBuilderOptions<TApiOrUrl<TDedotApi>>>(options?: TOpts) => GeneralBuilder$1<DedotClient<GenericSubstrateApi>, ChainSubmittableExtrinsic, IKeyringPair, object, TCustomChainFrom<TOpts>>;
|
|
76
|
+
type GeneralBuilder<T extends Partial<TTransferBaseOptions<TDedotApi, TDedotExtrinsic, TDedotSigner>> = object, TCustomChain extends string = never> = GeneralBuilder$1<TDedotApi, TDedotExtrinsic, TDedotSigner, T, TCustomChain>;
|
|
77
77
|
|
|
78
78
|
declare const dryRun: (options: _paraspell_sdk_core.TDryRunBaseOptions<ChainSubmittableExtrinsic> & {
|
|
79
79
|
api?: TApiOrUrl<TDedotApi>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow,
|
|
1
|
+
import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProvidersImpl, isSenderSigner, PolkadotApi, UnsupportedOperationError, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, 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';
|
|
@@ -829,8 +829,12 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
829
829
|
}, {
|
|
830
830
|
key: "encodeTx",
|
|
831
831
|
value: function encodeTx(hex) {
|
|
832
|
+
// Pad odd-length hex to match PAPI behavior (0x0 -> 0x00)
|
|
833
|
+
var prefix = hex.startsWith("0x") ? "0x" : "";
|
|
834
|
+
var body = prefix ? hex.slice(2) : hex;
|
|
835
|
+
var padded = body.length % 2 === 1 ? "0".concat(body) : body;
|
|
832
836
|
return {
|
|
833
|
-
encoded:
|
|
837
|
+
encoded: "".concat(prefix).concat(padded)
|
|
834
838
|
};
|
|
835
839
|
}
|
|
836
840
|
}, {
|
|
@@ -937,6 +941,30 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
937
941
|
var methodFormatted = snakeToCamel(method);
|
|
938
942
|
return Promise.resolve(((_this$api$tx$palletFo = this.api.tx[palletFormatted]) === null || _this$api$tx$palletFo === void 0 ? void 0 : _this$api$tx$palletFo[methodFormatted]) !== undefined);
|
|
939
943
|
}
|
|
944
|
+
}, {
|
|
945
|
+
key: "hasRuntimeApi",
|
|
946
|
+
value: function hasRuntimeApi(runtimeApi) {
|
|
947
|
+
return Promise.resolve(this.api.call[lowercaseFirstLetter(runtimeApi)] !== undefined);
|
|
948
|
+
}
|
|
949
|
+
}, {
|
|
950
|
+
key: "fetchPalletList",
|
|
951
|
+
value: function fetchPalletList() {
|
|
952
|
+
var entries = this.api.metadata.latest.pallets.map(function (p) {
|
|
953
|
+
return {
|
|
954
|
+
name: p.name,
|
|
955
|
+
index: p.index,
|
|
956
|
+
hasExtrinsics: p.calls !== undefined
|
|
957
|
+
};
|
|
958
|
+
});
|
|
959
|
+
return Promise.resolve(entries);
|
|
960
|
+
}
|
|
961
|
+
}, {
|
|
962
|
+
key: "isEvmChain",
|
|
963
|
+
value: function isEvmChain() {
|
|
964
|
+
var _this$api$metadata$la, _path$includes;
|
|
965
|
+
var path = (_this$api$metadata$la = this.api.metadata.latest.types[0]) === null || _this$api$metadata$la === void 0 ? void 0 : _this$api$metadata$la.path;
|
|
966
|
+
return Promise.resolve((_path$includes = path === null || path === void 0 ? void 0 : path.includes("AccountId20")) !== null && _path$includes !== void 0 ? _path$includes : false);
|
|
967
|
+
}
|
|
940
968
|
}, {
|
|
941
969
|
key: "getFromRpc",
|
|
942
970
|
value: function () {
|
|
@@ -1218,9 +1246,11 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1218
1246
|
_context7.p = 13;
|
|
1219
1247
|
_t3 = _context7.v;
|
|
1220
1248
|
_msg = _t3 instanceof Error ? _t3.message : String(_t3);
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1249
|
+
if (!failureErr.failureReason) {
|
|
1250
|
+
failureErr = {
|
|
1251
|
+
failureReason: _msg
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1224
1254
|
return _context7.a(2, {
|
|
1225
1255
|
success: false,
|
|
1226
1256
|
failureReason: failureErr.failureReason,
|
|
@@ -1655,6 +1685,31 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1655
1685
|
}
|
|
1656
1686
|
return getBridgeStatus;
|
|
1657
1687
|
}()
|
|
1688
|
+
}, {
|
|
1689
|
+
key: "getSystemProperties",
|
|
1690
|
+
value: function () {
|
|
1691
|
+
var _getSystemProperties = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
1692
|
+
var props;
|
|
1693
|
+
return _regenerator().w(function (_context13) {
|
|
1694
|
+
while (1) switch (_context13.n) {
|
|
1695
|
+
case 0:
|
|
1696
|
+
_context13.n = 1;
|
|
1697
|
+
return this.api.rpc.system_properties();
|
|
1698
|
+
case 1:
|
|
1699
|
+
props = _context13.v;
|
|
1700
|
+
return _context13.a(2, {
|
|
1701
|
+
ss58Format: typeof (props === null || props === void 0 ? void 0 : props.ss58Format) === "number" ? props.ss58Format : undefined,
|
|
1702
|
+
tokenSymbol: [props === null || props === void 0 ? void 0 : props.tokenSymbol].flat()[0],
|
|
1703
|
+
tokenDecimals: [props === null || props === void 0 ? void 0 : props.tokenDecimals].flat()[0]
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
}, _callee13, this);
|
|
1707
|
+
}));
|
|
1708
|
+
function getSystemProperties() {
|
|
1709
|
+
return _getSystemProperties.apply(this, arguments);
|
|
1710
|
+
}
|
|
1711
|
+
return getSystemProperties;
|
|
1712
|
+
}()
|
|
1658
1713
|
}, {
|
|
1659
1714
|
key: "disconnect",
|
|
1660
1715
|
value: function disconnect() {
|
|
@@ -1672,7 +1727,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1672
1727
|
if (force) {
|
|
1673
1728
|
void this.api.disconnect();
|
|
1674
1729
|
} else {
|
|
1675
|
-
var key = api === undefined ?
|
|
1730
|
+
var key = api === undefined ? getChainProvidersImpl(this._chain, this._customCtx) : api;
|
|
1676
1731
|
releaseClient(key);
|
|
1677
1732
|
}
|
|
1678
1733
|
}
|
|
@@ -1699,18 +1754,18 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1699
1754
|
}, {
|
|
1700
1755
|
key: "signAndSubmit",
|
|
1701
1756
|
value: function () {
|
|
1702
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1757
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(tx, sender) {
|
|
1703
1758
|
var account;
|
|
1704
|
-
return _regenerator().w(function (
|
|
1705
|
-
while (1) switch (
|
|
1759
|
+
return _regenerator().w(function (_context14) {
|
|
1760
|
+
while (1) switch (_context14.n) {
|
|
1706
1761
|
case 0:
|
|
1707
1762
|
account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
|
|
1708
|
-
|
|
1763
|
+
_context14.n = 1;
|
|
1709
1764
|
return tx.signAndSend(account);
|
|
1710
1765
|
case 1:
|
|
1711
|
-
return
|
|
1766
|
+
return _context14.a(2, _context14.v);
|
|
1712
1767
|
}
|
|
1713
|
-
},
|
|
1768
|
+
}, _callee14);
|
|
1714
1769
|
}));
|
|
1715
1770
|
function signAndSubmit(_x25, _x26) {
|
|
1716
1771
|
return _signAndSubmit.apply(this, arguments);
|
|
@@ -1720,19 +1775,19 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1720
1775
|
}, {
|
|
1721
1776
|
key: "signAndSubmitFinalized",
|
|
1722
1777
|
value: function () {
|
|
1723
|
-
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1778
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(tx, sender) {
|
|
1724
1779
|
var account, result;
|
|
1725
|
-
return _regenerator().w(function (
|
|
1726
|
-
while (1) switch (
|
|
1780
|
+
return _regenerator().w(function (_context15) {
|
|
1781
|
+
while (1) switch (_context15.n) {
|
|
1727
1782
|
case 0:
|
|
1728
1783
|
account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
|
|
1729
|
-
|
|
1784
|
+
_context15.n = 1;
|
|
1730
1785
|
return tx.signAndSend(account).untilFinalized();
|
|
1731
1786
|
case 1:
|
|
1732
|
-
result =
|
|
1733
|
-
return
|
|
1787
|
+
result = _context15.v;
|
|
1788
|
+
return _context15.a(2, result.txHash);
|
|
1734
1789
|
}
|
|
1735
|
-
},
|
|
1790
|
+
}, _callee15);
|
|
1736
1791
|
}));
|
|
1737
1792
|
function signAndSubmitFinalized(_x27, _x28) {
|
|
1738
1793
|
return _signAndSubmitFinalized.apply(this, arguments);
|
|
@@ -1804,13 +1859,13 @@ var convertSs58 = function convertSs58(address, chain) {
|
|
|
1804
1859
|
};
|
|
1805
1860
|
|
|
1806
1861
|
/**
|
|
1807
|
-
* Creates a new Builder instance
|
|
1862
|
+
* Creates a new Builder instance.
|
|
1808
1863
|
*
|
|
1809
|
-
* @param
|
|
1864
|
+
* @param options - Either an existing API instance, a WS URL, or a config object.
|
|
1810
1865
|
* @returns A new Builder instance.
|
|
1811
1866
|
*/
|
|
1812
|
-
var Builder = function Builder(
|
|
1813
|
-
var dedotApi = new DedotApi(
|
|
1867
|
+
var Builder = function Builder(options) {
|
|
1868
|
+
var dedotApi = new DedotApi(options);
|
|
1814
1869
|
return Builder$1(dedotApi);
|
|
1815
1870
|
};
|
|
1816
1871
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-dedot",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.6.0",
|
|
4
4
|
"description": "Dedot-based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@paraspell/sdk-core": "13.
|
|
25
|
+
"@paraspell/sdk-core": "13.6.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"dedot": ">= 1.3.0",
|
|
29
29
|
"@polkadot/keyring": ">= 14"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/plugin-syntax-import-attributes": "^7.
|
|
33
|
-
"@babel/preset-env": "^7.29.
|
|
32
|
+
"@babel/plugin-syntax-import-attributes": "^7.29.7",
|
|
33
|
+
"@babel/preset-env": "^7.29.7",
|
|
34
34
|
"@codecov/rollup-plugin": "^2.0.1",
|
|
35
35
|
"@rollup/plugin-babel": "^7.0.0",
|
|
36
36
|
"@rollup/plugin-json": "^6.1.0",
|
|
37
37
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
38
|
-
"@vitest/coverage-v8": "^4.1.
|
|
38
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
39
39
|
"dotenv": "^17.4.2",
|
|
40
|
-
"rollup": "^4.60.
|
|
40
|
+
"rollup": "^4.60.4",
|
|
41
41
|
"rollup-plugin-dts": "^6.4.1",
|
|
42
42
|
"tslib": "^2.8.1"
|
|
43
43
|
},
|