@moonbeam-network/xcm-builder 1.0.0-dev.209 → 1.0.0-dev.210

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/build/index.d.ts CHANGED
@@ -384,6 +384,15 @@ declare function polkadotXcm$1(): {
384
384
  };
385
385
  };
386
386
 
387
+ declare function xcmPallet(): {
388
+ limitedReserveTransferAssets: (parents?: Parents) => {
389
+ here: () => ExtrinsicConfigBuilder;
390
+ };
391
+ transferAssetsUsingTypeAndThen: () => {
392
+ here: () => ExtrinsicConfigBuilder;
393
+ };
394
+ };
395
+
387
396
  declare function xTokens(): {
388
397
  transfer: () => ExtrinsicConfigBuilder;
389
398
  transferMultiAsset: (originParachainId: number) => {
@@ -401,15 +410,6 @@ declare function xTransfer(): {
401
410
  };
402
411
  };
403
412
 
404
- declare function xcmPallet(): {
405
- limitedReserveTransferAssets: (parents?: Parents) => {
406
- here: () => ExtrinsicConfigBuilder;
407
- };
408
- transferAssetsUsingTypeAndThen: () => {
409
- here: () => ExtrinsicConfigBuilder;
410
- };
411
- };
412
-
413
413
  declare function ExtrinsicBuilder(): {
414
414
  eqBalances: typeof eqBalances;
415
415
  xTokens: typeof xTokens;
@@ -469,10 +469,6 @@ declare function FeeBuilder(): {
469
469
  xcmPaymentApi: typeof xcmPaymentApi;
470
470
  };
471
471
 
472
- declare function wormhole$1(): {
473
- tokenTransfer: () => MrlConfigBuilder;
474
- };
475
-
476
472
  type WormholeTransferFunctions = 'tokenTransfer';
477
473
  type WormholeFunctionArgs = Parameters<Wormhole<Network>[WormholeTransferFunctions]>;
478
474
  interface WormholeConfigConstructorParams {
@@ -486,6 +482,10 @@ declare class WormholeConfig {
486
482
  constructor({ args, func }: WormholeConfigConstructorParams);
487
483
  }
488
484
 
485
+ declare function wormhole$1(): {
486
+ tokenTransfer: () => MrlConfigBuilder;
487
+ };
488
+
489
489
  declare function wormholeFactory(chain: AnyChain): Wormhole<"Mainnet" | "Testnet">;
490
490
 
491
491
  type MrlConfigBuilder = ConfigBuilder<ContractConfig | ExtrinsicConfig | WormholeConfig, MrlBuilderParams>;
package/build/index.mjs CHANGED
@@ -2161,6 +2161,112 @@ function polkadotXcm() {
2161
2161
  };
2162
2162
  }
2163
2163
 
2164
+ // src/extrinsic/pallets/xcmPallet/xcmPallet.ts
2165
+ var pallet3 = "xcmPallet";
2166
+ function xcmPallet() {
2167
+ return {
2168
+ limitedReserveTransferAssets: (parents = 1) => {
2169
+ const func = "limitedReserveTransferAssets";
2170
+ return {
2171
+ here: () => ({
2172
+ build: (params) => new ExtrinsicConfig({
2173
+ module: pallet3,
2174
+ func,
2175
+ getArgs: (extrinsicFunction) => {
2176
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
2177
+ return getPolkadotXcmExtrinsicArgs({
2178
+ ...params,
2179
+ parents,
2180
+ func: extrinsicFunction,
2181
+ asset: [
2182
+ {
2183
+ id: normalizeConcrete(version, {
2184
+ parents: 0,
2185
+ interior: "Here"
2186
+ }),
2187
+ fun: {
2188
+ Fungible: params.asset.amount
2189
+ }
2190
+ }
2191
+ ]
2192
+ });
2193
+ }
2194
+ })
2195
+ })
2196
+ };
2197
+ },
2198
+ transferAssetsUsingTypeAndThen: () => {
2199
+ const func = "transferAssetsUsingTypeAndThen";
2200
+ return {
2201
+ here: () => ({
2202
+ build: (params) => new ExtrinsicConfig({
2203
+ module: pallet3,
2204
+ func,
2205
+ getArgs: () => {
2206
+ const version = "V4" /* v4 */;
2207
+ return [
2208
+ {
2209
+ [version]: {
2210
+ parents: 0,
2211
+ interior: {
2212
+ X1: [
2213
+ {
2214
+ Parachain: params.destination.parachainId
2215
+ }
2216
+ ]
2217
+ }
2218
+ }
2219
+ },
2220
+ {
2221
+ [version]: [
2222
+ {
2223
+ id: {
2224
+ parents: 0,
2225
+ interior: "Here"
2226
+ },
2227
+ fun: {
2228
+ Fungible: params.asset.amount
2229
+ }
2230
+ }
2231
+ ]
2232
+ },
2233
+ "LocalReserve",
2234
+ {
2235
+ [version]: {
2236
+ parents: 0,
2237
+ interior: "Here"
2238
+ }
2239
+ },
2240
+ "LocalReserve",
2241
+ {
2242
+ [version]: [
2243
+ {
2244
+ DepositAsset: {
2245
+ assets: {
2246
+ Wild: { AllCounted: 1 }
2247
+ },
2248
+ beneficiary: {
2249
+ parents: 0,
2250
+ interior: {
2251
+ X1: [
2252
+ getExtrinsicAccount(params.destinationAddress)
2253
+ ]
2254
+ }
2255
+ }
2256
+ }
2257
+ }
2258
+ ]
2259
+ },
2260
+ "Unlimited"
2261
+ ];
2262
+ }
2263
+ })
2264
+ })
2265
+ };
2266
+ }
2267
+ };
2268
+ }
2269
+
2164
2270
  // src/extrinsic/pallets/xTokens/xTokens.utils.ts
2165
2271
  function getWeight() {
2166
2272
  return "Unlimited";
@@ -2182,12 +2288,12 @@ function getDestination(version, address, destination) {
2182
2288
  }
2183
2289
 
2184
2290
  // src/extrinsic/pallets/xTokens/xTokens.ts
2185
- var pallet3 = "xTokens";
2291
+ var pallet4 = "xTokens";
2186
2292
  function xTokens() {
2187
2293
  return {
2188
2294
  transfer: () => ({
2189
2295
  build: ({ destinationAddress, asset, destination }) => new ExtrinsicConfig({
2190
- module: pallet3,
2296
+ module: pallet4,
2191
2297
  func: "transfer",
2192
2298
  getArgs: (func) => {
2193
2299
  const destIndex = 2;
@@ -2207,7 +2313,7 @@ function xTokens() {
2207
2313
  return {
2208
2314
  here: () => ({
2209
2315
  build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
2210
- module: pallet3,
2316
+ module: pallet4,
2211
2317
  func: funcName,
2212
2318
  getArgs: (func) => {
2213
2319
  const version = getExtrinsicArgumentVersion(func, destIndex);
@@ -2231,7 +2337,7 @@ function xTokens() {
2231
2337
  }),
2232
2338
  X1: () => ({
2233
2339
  build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
2234
- module: pallet3,
2340
+ module: pallet4,
2235
2341
  func: funcName,
2236
2342
  getArgs: (func) => {
2237
2343
  const version = getExtrinsicArgumentVersion(func, destIndex);
@@ -2262,7 +2368,7 @@ function xTokens() {
2262
2368
  }),
2263
2369
  X2: () => ({
2264
2370
  build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
2265
- module: pallet3,
2371
+ module: pallet4,
2266
2372
  func: funcName,
2267
2373
  getArgs: (func) => {
2268
2374
  const version = getExtrinsicArgumentVersion(func, destIndex);
@@ -2297,7 +2403,7 @@ function xTokens() {
2297
2403
  },
2298
2404
  transferMultiCurrencies: () => ({
2299
2405
  build: ({ destinationAddress: address, asset, destination, fee }) => new ExtrinsicConfig({
2300
- module: pallet3,
2406
+ module: pallet4,
2301
2407
  func: "transferMulticurrencies",
2302
2408
  getArgs: () => [
2303
2409
  [
@@ -2314,7 +2420,7 @@ function xTokens() {
2314
2420
  }
2315
2421
 
2316
2422
  // src/extrinsic/pallets/xTransfer/xTransfer.ts
2317
- var pallet4 = "xTransfer";
2423
+ var pallet5 = "xTransfer";
2318
2424
  function xTransfer() {
2319
2425
  return {
2320
2426
  transfer: () => {
@@ -2322,7 +2428,7 @@ function xTransfer() {
2322
2428
  return {
2323
2429
  here: () => ({
2324
2430
  build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
2325
- module: pallet4,
2431
+ module: pallet5,
2326
2432
  func: method,
2327
2433
  getArgs: () => [
2328
2434
  {
@@ -2356,7 +2462,7 @@ function xTransfer() {
2356
2462
  }),
2357
2463
  X2: () => ({
2358
2464
  build: ({ destinationAddress, asset, destination }) => new ExtrinsicConfig({
2359
- module: pallet4,
2465
+ module: pallet5,
2360
2466
  func: method,
2361
2467
  getArgs: () => [
2362
2468
  {
@@ -2402,112 +2508,6 @@ function xTransfer() {
2402
2508
  };
2403
2509
  }
2404
2510
 
2405
- // src/extrinsic/pallets/xcmPallet/xcmPallet.ts
2406
- var pallet5 = "xcmPallet";
2407
- function xcmPallet() {
2408
- return {
2409
- limitedReserveTransferAssets: (parents = 1) => {
2410
- const func = "limitedReserveTransferAssets";
2411
- return {
2412
- here: () => ({
2413
- build: (params) => new ExtrinsicConfig({
2414
- module: pallet5,
2415
- func,
2416
- getArgs: (extrinsicFunction) => {
2417
- const version = getExtrinsicArgumentVersion(extrinsicFunction);
2418
- return getPolkadotXcmExtrinsicArgs({
2419
- ...params,
2420
- parents,
2421
- func: extrinsicFunction,
2422
- asset: [
2423
- {
2424
- id: normalizeConcrete(version, {
2425
- parents: 0,
2426
- interior: "Here"
2427
- }),
2428
- fun: {
2429
- Fungible: params.asset.amount
2430
- }
2431
- }
2432
- ]
2433
- });
2434
- }
2435
- })
2436
- })
2437
- };
2438
- },
2439
- transferAssetsUsingTypeAndThen: () => {
2440
- const func = "transferAssetsUsingTypeAndThen";
2441
- return {
2442
- here: () => ({
2443
- build: (params) => new ExtrinsicConfig({
2444
- module: pallet5,
2445
- func,
2446
- getArgs: () => {
2447
- const version = "V4" /* v4 */;
2448
- return [
2449
- {
2450
- [version]: {
2451
- parents: 0,
2452
- interior: {
2453
- X1: [
2454
- {
2455
- Parachain: params.destination.parachainId
2456
- }
2457
- ]
2458
- }
2459
- }
2460
- },
2461
- {
2462
- [version]: [
2463
- {
2464
- id: {
2465
- parents: 0,
2466
- interior: "Here"
2467
- },
2468
- fun: {
2469
- Fungible: params.asset.amount
2470
- }
2471
- }
2472
- ]
2473
- },
2474
- "LocalReserve",
2475
- {
2476
- [version]: {
2477
- parents: 0,
2478
- interior: "Here"
2479
- }
2480
- },
2481
- "LocalReserve",
2482
- {
2483
- [version]: [
2484
- {
2485
- DepositAsset: {
2486
- assets: {
2487
- Wild: { AllCounted: 1 }
2488
- },
2489
- beneficiary: {
2490
- parents: 0,
2491
- interior: {
2492
- X1: [
2493
- getExtrinsicAccount(params.destinationAddress)
2494
- ]
2495
- }
2496
- }
2497
- }
2498
- }
2499
- ]
2500
- },
2501
- "Unlimited"
2502
- ];
2503
- }
2504
- })
2505
- })
2506
- };
2507
- }
2508
- };
2509
- }
2510
-
2511
2511
  // src/extrinsic/ExtrinsicBuilder.ts
2512
2512
  function ExtrinsicBuilder() {
2513
2513
  return {
@@ -3033,29 +3033,32 @@ function buildSendExtrinsic({
3033
3033
  if (!transact) {
3034
3034
  throw new Error("Transact params are required");
3035
3035
  }
3036
+ const version = getExtrinsicArgumentVersion(sourceApi.tx.polkadotXcm.send);
3036
3037
  return sourceApi.tx.polkadotXcm.send(
3037
3038
  {
3038
- // TODO apply XCM versioning
3039
- V3: {
3039
+ [version]: normalizeX1(version, {
3040
3040
  parents: 1,
3041
- interior: { X1: { Parachain: moonChain.parachainId } }
3042
- }
3041
+ interior: {
3042
+ X1: { Parachain: moonChain.parachainId }
3043
+ }
3044
+ })
3043
3045
  },
3044
3046
  {
3045
- V3: [
3047
+ [version]: [
3046
3048
  {
3047
3049
  WithdrawAsset: [
3048
3050
  {
3049
- id: {
3050
- Concrete: {
3051
+ id: normalizeConcrete(
3052
+ version,
3053
+ normalizeX1(version, {
3051
3054
  parents: 0,
3052
3055
  interior: {
3053
3056
  X1: {
3054
3057
  PalletInstance: moonAsset.getAssetPalletInstance()
3055
3058
  }
3056
3059
  }
3057
- }
3058
- },
3060
+ })
3061
+ ),
3059
3062
  fun: { Fungible: BUY_EXECUTION_FEE }
3060
3063
  }
3061
3064
  ]
@@ -3063,16 +3066,17 @@ function buildSendExtrinsic({
3063
3066
  {
3064
3067
  BuyExecution: {
3065
3068
  fees: {
3066
- id: {
3067
- Concrete: {
3069
+ id: normalizeConcrete(
3070
+ version,
3071
+ normalizeX1(version, {
3068
3072
  parents: 0,
3069
3073
  interior: {
3070
3074
  X1: {
3071
3075
  PalletInstance: moonAsset.getAssetPalletInstance()
3072
3076
  }
3073
3077
  }
3074
- }
3075
- },
3078
+ })
3079
+ ),
3076
3080
  fun: { Fungible: BUY_EXECUTION_FEE }
3077
3081
  },
3078
3082
  weightLimit: "Unlimited"
@@ -3096,12 +3100,14 @@ function buildSendExtrinsic({
3096
3100
  {
3097
3101
  DepositAsset: {
3098
3102
  assets: { Wild: { AllCounted: 1 } },
3099
- beneficiary: {
3103
+ beneficiary: normalizeX1(version, {
3100
3104
  parents: 0,
3101
3105
  interior: {
3102
- X1: { AccountKey20: { key: computedOriginAccount } }
3106
+ X1: {
3107
+ AccountKey20: { key: computedOriginAccount }
3108
+ }
3103
3109
  }
3104
- }
3110
+ })
3105
3111
  }
3106
3112
  }
3107
3113
  ]
@@ -3705,7 +3711,7 @@ var PEAQ_XTOKENS_ABI = [
3705
3711
  ];
3706
3712
 
3707
3713
  // src/mrl/providers/wormhole/contract/Batch/abi/abi.helpers.ts
3708
- function getAbisForChain(chain) {
3714
+ function getAbisForChain(_) {
3709
3715
  return {
3710
3716
  BatchAbi: PEAQ_BATCH_ABI,
3711
3717
  XcmUtilsAbi: PEAQ_XCM_UTILS_ABI,
@@ -3874,12 +3880,6 @@ function Gmp() {
3874
3880
  // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridge.ts
3875
3881
  import { convertAddressTo32Bytes } from "@moonbeam-network/xcm-utils";
3876
3882
 
3877
- // src/mrl/providers/wormhole/wormhole/wormhole.ts
3878
- import { EvmChain, EvmParachain as EvmParachain4, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
3879
- import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
3880
- import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
3881
- import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
3882
-
3883
3883
  // src/mrl/providers/wormhole/wormhole/WormholeConfig.ts
3884
3884
  var WormholeConfig = class _WormholeConfig {
3885
3885
  args;
@@ -3893,6 +3893,12 @@ var WormholeConfig = class _WormholeConfig {
3893
3893
  }
3894
3894
  };
3895
3895
 
3896
+ // src/mrl/providers/wormhole/wormhole/wormhole.ts
3897
+ import { EvmChain, EvmParachain as EvmParachain4, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
3898
+ import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
3899
+ import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
3900
+ import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
3901
+
3896
3902
  // src/mrl/providers/wormhole/wormhole/wormholeFactory.ts
3897
3903
  import { EvmParachain as EvmParachain3 } from "@moonbeam-network/xcm-types";
3898
3904
  import { Wormhole } from "@wormhole-foundation/sdk-connect";
@@ -3977,9 +3983,10 @@ function getPayload({
3977
3983
  `Destination ${destination.name} is not a Parachain or EvmParachain`
3978
3984
  );
3979
3985
  }
3980
- const isPeaqEvm = destination.key === "peaq-evm-Alphanet" || destination.key === "peaq-evm";
3986
+ const isEvmDestination = EvmParachain4.is(destination);
3987
+ const version = getExtrinsicArgumentVersion(moonApi.tx.polkadotXcm.send);
3981
3988
  const multilocation = moonApi.createType("XcmVersionedLocation", {
3982
- V3: {
3989
+ [version]: {
3983
3990
  parents: 1,
3984
3991
  interior: {
3985
3992
  X2: [
@@ -3987,7 +3994,7 @@ function getPayload({
3987
3994
  Parachain: destination.parachainId
3988
3995
  },
3989
3996
  getExtrinsicAccount(
3990
- isPeaqEvm ? evmToAddress4(destinationAddress) : destinationAddress
3997
+ isEvmDestination ? evmToAddress4(destinationAddress) : destinationAddress
3991
3998
  )
3992
3999
  ]
3993
4000
  }