@paraspell/sdk-pjs 12.1.1 → 12.2.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 +5 -2
- package/dist/index.mjs +71 -34
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -298,7 +298,7 @@ const result = await Builder(/*chain api/builder_config/ws_url_string/ws_url_arr
|
|
|
298
298
|
```ts
|
|
299
299
|
const builder = await Builder({
|
|
300
300
|
development: true, // Optional: Enforces overrides for all chains used
|
|
301
|
-
decimalAbstraction: true //Abstracts decimals, so 1 as input amount equals 10_000_000_000 if selected asset is DOT.
|
|
301
|
+
decimalAbstraction: true // Abstracts decimals, so 1 as input amount equals 10_000_000_000 if selected asset is DOT.
|
|
302
302
|
apiOverrides: {
|
|
303
303
|
Hydration: // "wsEndpointString" | papiClient
|
|
304
304
|
BridgeHubPolkadot: // "wsEndpointString" | papiClient
|
|
@@ -308,9 +308,12 @@ const builder = await Builder({
|
|
|
308
308
|
.from(TSubstrateChain)
|
|
309
309
|
.to(TChain)
|
|
310
310
|
.currency({id: currencyID, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: currencySymbol, amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Native('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: Foreign('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {symbol: ForeignAbstract('currencySymbol'), amount: amount /*Use "ALL" to transfer everything*/} | {location: AssetLocationString, amount: amount /*Use "ALL" to transfer everything*/ | AssetLocationJson, amount: amount /*Use "ALL" to transfer everything*/} | {location: Override('Custom Location'), amount: amount /*Use "ALL" to transfer everything*/} | [{currencySelection, isFeeAsset?: true /* for example symbol: symbol or id: id, or Location: Location*/, amount: amount /*Use "ALL" to transfer everything*/}])
|
|
311
|
-
.address(address)
|
|
311
|
+
.address(address) //You can also use prederived accounts - //Alice, //Bob... //Alith, //Balthathar...
|
|
312
|
+
.senderAddress(address) //You can also use prederived accounts //Alice, //Bob... //Alith, //Balthathar...
|
|
312
313
|
|
|
313
314
|
const tx = await builder.build()
|
|
315
|
+
//Or if you use prederived account as senderAddress:
|
|
316
|
+
//await builder.signAndSubmit()
|
|
314
317
|
|
|
315
318
|
//Disconnect API after TX
|
|
316
319
|
await builder.disconnect()
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { isConfig, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, getChainProviders, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, RELAY_LOCATION, getRelayChainOf, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
1
|
+
import { getEvmPrivateKeyHex, isConfig, BatchMode, findNativeAssetInfoOrThrow, MissingChainApiError, getChainProviders, UnsupportedOperationError, findAssetInfoOrThrow, computeFeeFromDryRunPjs, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, assertHasLocation, localizeLocation, isAssetXcEqual, addXcmVersionHeader, Version, RELAY_LOCATION, getRelayChainOf, createChainClient as createChainClient$1, getBalance as getBalance$1, claimAssets as claimAssets$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, getParaId, ETH_CHAIN_ID, RoutingResolutionError, abstractDecimals, assertHasId, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, getBridgeStatus as getBridgeStatus$1, send as send$1, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
|
-
import { WsProvider, ApiPromise } from '@polkadot/api';
|
|
3
|
+
import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
|
|
4
4
|
import { isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
|
|
5
5
|
import { decodeAddress, blake2AsHex, validateAddress } from '@polkadot/util-crypto';
|
|
6
6
|
import { environment, Context, toPolkadotV2, assetsV2 } from '@snowbridge/api';
|
|
7
7
|
import { WETH9__factory } from '@snowbridge/contract-types';
|
|
8
8
|
|
|
9
|
+
var createKeyringPair = function createKeyringPair(path) {
|
|
10
|
+
var evmPrivateKey = getEvmPrivateKeyHex(path);
|
|
11
|
+
var keyring = evmPrivateKey ? new Keyring() : new Keyring({
|
|
12
|
+
type: 'sr25519'
|
|
13
|
+
});
|
|
14
|
+
return evmPrivateKey ? keyring.createFromUri(evmPrivateKey, undefined, 'ethereum') : keyring.addFromUri(path);
|
|
15
|
+
};
|
|
16
|
+
|
|
9
17
|
function _arrayLikeToArray(r, a) {
|
|
10
18
|
(null == a || a > r.length) && (a = r.length);
|
|
11
19
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -1265,6 +1273,35 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1265
1273
|
return false;
|
|
1266
1274
|
}
|
|
1267
1275
|
}
|
|
1276
|
+
}, {
|
|
1277
|
+
key: "deriveAddress",
|
|
1278
|
+
value: function deriveAddress(path) {
|
|
1279
|
+
var _createKeyringPair = createKeyringPair(path),
|
|
1280
|
+
address = _createKeyringPair.address;
|
|
1281
|
+
return address;
|
|
1282
|
+
}
|
|
1283
|
+
}, {
|
|
1284
|
+
key: "signAndSubmit",
|
|
1285
|
+
value: function () {
|
|
1286
|
+
var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, path) {
|
|
1287
|
+
var pair, hash;
|
|
1288
|
+
return _regenerator().w(function (_context17) {
|
|
1289
|
+
while (1) switch (_context17.n) {
|
|
1290
|
+
case 0:
|
|
1291
|
+
pair = createKeyringPair(path);
|
|
1292
|
+
_context17.n = 1;
|
|
1293
|
+
return tx.signAndSend(pair);
|
|
1294
|
+
case 1:
|
|
1295
|
+
hash = _context17.v;
|
|
1296
|
+
return _context17.a(2, hash.toHex());
|
|
1297
|
+
}
|
|
1298
|
+
}, _callee17);
|
|
1299
|
+
}));
|
|
1300
|
+
function signAndSubmit(_x27, _x28) {
|
|
1301
|
+
return _signAndSubmit.apply(this, arguments);
|
|
1302
|
+
}
|
|
1303
|
+
return signAndSubmit;
|
|
1304
|
+
}()
|
|
1268
1305
|
}]);
|
|
1269
1306
|
}();
|
|
1270
1307
|
|
|
@@ -1310,28 +1347,28 @@ var getBalance = createPolkadotJsApiCall(getBalance$1);
|
|
|
1310
1347
|
var claimAssets = createPolkadotJsApiCall(claimAssets$1);
|
|
1311
1348
|
|
|
1312
1349
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1350
|
+
__proto__: null,
|
|
1351
|
+
Foreign: Foreign,
|
|
1352
|
+
ForeignAbstract: ForeignAbstract,
|
|
1353
|
+
Native: Native,
|
|
1354
|
+
Override: Override,
|
|
1355
|
+
claimAssets: claimAssets,
|
|
1356
|
+
findAssetInfo: findAssetInfo,
|
|
1357
|
+
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
1358
|
+
getAssetDecimals: getAssetDecimals,
|
|
1359
|
+
getAssetId: getAssetId,
|
|
1360
|
+
getAssets: getAssets,
|
|
1361
|
+
getAssetsObject: getAssetsObject,
|
|
1362
|
+
getBalance: getBalance,
|
|
1363
|
+
getExistentialDeposit: getExistentialDeposit,
|
|
1364
|
+
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
1365
|
+
getNativeAssets: getNativeAssets,
|
|
1366
|
+
getOtherAssets: getOtherAssets,
|
|
1367
|
+
getRelayChainSymbol: getRelayChainSymbol,
|
|
1368
|
+
getSupportedAssets: getSupportedAssets,
|
|
1369
|
+
getTChain: getTChain,
|
|
1370
|
+
hasSupportForAsset: hasSupportForAsset,
|
|
1371
|
+
isChainEvm: isChainEvm
|
|
1335
1372
|
});
|
|
1336
1373
|
|
|
1337
1374
|
var convertSs58 = function convertSs58(address, chain) {
|
|
@@ -1871,16 +1908,16 @@ var getBridgeStatus = /*#__PURE__*/function () {
|
|
|
1871
1908
|
}();
|
|
1872
1909
|
|
|
1873
1910
|
var transfer = /*#__PURE__*/Object.freeze({
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1911
|
+
__proto__: null,
|
|
1912
|
+
approveToken: approveToken,
|
|
1913
|
+
depositToken: depositToken,
|
|
1914
|
+
dryRun: dryRun,
|
|
1915
|
+
dryRunOrigin: dryRunOrigin,
|
|
1916
|
+
getBridgeStatus: getBridgeStatus,
|
|
1917
|
+
getParaEthTransferFees: getParaEthTransferFees,
|
|
1918
|
+
getTokenBalance: getTokenBalance,
|
|
1919
|
+
send: send,
|
|
1920
|
+
transferEthToPolkadot: transferEthToPolkadot
|
|
1884
1921
|
});
|
|
1885
1922
|
|
|
1886
1923
|
export { Builder, EvmBuilder, approveToken, assets, claimAssets, convertSs58, createChainClient, depositToken, dryRun, dryRunOrigin, getBalance, getBridgeStatus, getParaEthTransferFees, getTokenBalance, send, transferEthToPolkadot, transfer as xcmPallet };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-pjs",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"description": "Polkadot.js based SDK for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@snowbridge/contract-types": "0.2.20",
|
|
28
28
|
"ethers": "6.15.0",
|
|
29
29
|
"viem": "2.40.3",
|
|
30
|
-
"@paraspell/sdk-core": "12.
|
|
30
|
+
"@paraspell/sdk-core": "12.2.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@polkadot/api": ">= 16.0 < 17",
|