@paraspell/sdk-dedot 13.5.0 → 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 +68 -19
- 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';
|
|
@@ -941,6 +941,30 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
941
941
|
var methodFormatted = snakeToCamel(method);
|
|
942
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);
|
|
943
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
|
+
}
|
|
944
968
|
}, {
|
|
945
969
|
key: "getFromRpc",
|
|
946
970
|
value: function () {
|
|
@@ -1661,6 +1685,31 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1661
1685
|
}
|
|
1662
1686
|
return getBridgeStatus;
|
|
1663
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
|
+
}()
|
|
1664
1713
|
}, {
|
|
1665
1714
|
key: "disconnect",
|
|
1666
1715
|
value: function disconnect() {
|
|
@@ -1678,7 +1727,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1678
1727
|
if (force) {
|
|
1679
1728
|
void this.api.disconnect();
|
|
1680
1729
|
} else {
|
|
1681
|
-
var key = api === undefined ?
|
|
1730
|
+
var key = api === undefined ? getChainProvidersImpl(this._chain, this._customCtx) : api;
|
|
1682
1731
|
releaseClient(key);
|
|
1683
1732
|
}
|
|
1684
1733
|
}
|
|
@@ -1705,18 +1754,18 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1705
1754
|
}, {
|
|
1706
1755
|
key: "signAndSubmit",
|
|
1707
1756
|
value: function () {
|
|
1708
|
-
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1757
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(tx, sender) {
|
|
1709
1758
|
var account;
|
|
1710
|
-
return _regenerator().w(function (
|
|
1711
|
-
while (1) switch (
|
|
1759
|
+
return _regenerator().w(function (_context14) {
|
|
1760
|
+
while (1) switch (_context14.n) {
|
|
1712
1761
|
case 0:
|
|
1713
1762
|
account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
|
|
1714
|
-
|
|
1763
|
+
_context14.n = 1;
|
|
1715
1764
|
return tx.signAndSend(account);
|
|
1716
1765
|
case 1:
|
|
1717
|
-
return
|
|
1766
|
+
return _context14.a(2, _context14.v);
|
|
1718
1767
|
}
|
|
1719
|
-
},
|
|
1768
|
+
}, _callee14);
|
|
1720
1769
|
}));
|
|
1721
1770
|
function signAndSubmit(_x25, _x26) {
|
|
1722
1771
|
return _signAndSubmit.apply(this, arguments);
|
|
@@ -1726,19 +1775,19 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
|
|
|
1726
1775
|
}, {
|
|
1727
1776
|
key: "signAndSubmitFinalized",
|
|
1728
1777
|
value: function () {
|
|
1729
|
-
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1778
|
+
var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(tx, sender) {
|
|
1730
1779
|
var account, result;
|
|
1731
|
-
return _regenerator().w(function (
|
|
1732
|
-
while (1) switch (
|
|
1780
|
+
return _regenerator().w(function (_context15) {
|
|
1781
|
+
while (1) switch (_context15.n) {
|
|
1733
1782
|
case 0:
|
|
1734
1783
|
account = isSenderSigner(sender) ? sender : createKeyringPair(sender);
|
|
1735
|
-
|
|
1784
|
+
_context15.n = 1;
|
|
1736
1785
|
return tx.signAndSend(account).untilFinalized();
|
|
1737
1786
|
case 1:
|
|
1738
|
-
result =
|
|
1739
|
-
return
|
|
1787
|
+
result = _context15.v;
|
|
1788
|
+
return _context15.a(2, result.txHash);
|
|
1740
1789
|
}
|
|
1741
|
-
},
|
|
1790
|
+
}, _callee15);
|
|
1742
1791
|
}));
|
|
1743
1792
|
function signAndSubmitFinalized(_x27, _x28) {
|
|
1744
1793
|
return _signAndSubmitFinalized.apply(this, arguments);
|
|
@@ -1810,13 +1859,13 @@ var convertSs58 = function convertSs58(address, chain) {
|
|
|
1810
1859
|
};
|
|
1811
1860
|
|
|
1812
1861
|
/**
|
|
1813
|
-
* Creates a new Builder instance
|
|
1862
|
+
* Creates a new Builder instance.
|
|
1814
1863
|
*
|
|
1815
|
-
* @param
|
|
1864
|
+
* @param options - Either an existing API instance, a WS URL, or a config object.
|
|
1816
1865
|
* @returns A new Builder instance.
|
|
1817
1866
|
*/
|
|
1818
|
-
var Builder = function Builder(
|
|
1819
|
-
var dedotApi = new DedotApi(
|
|
1867
|
+
var Builder = function Builder(options) {
|
|
1868
|
+
var dedotApi = new DedotApi(options);
|
|
1820
1869
|
return Builder$1(dedotApi);
|
|
1821
1870
|
};
|
|
1822
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
|
},
|