@hyperbridge/sdk 1.4.5 → 1.4.7-rc0000000001

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.
@@ -717,8 +717,8 @@ declare class EvmChain implements IChain {
717
717
  * @param request - The post request to calculate the fee for
718
718
  * @returns The total fee in wei required to send the post request
719
719
  */
720
- quote(request: IPostRequest): Promise<bigint>;
721
- quoteNative(request: IPostRequest, fee: bigint): Promise<bigint>;
720
+ quote(request: IPostRequest | IGetRequest): Promise<bigint>;
721
+ quoteNative(request: IPostRequest | IGetRequest, fee: bigint): Promise<bigint>;
722
722
  private getAmountsIn;
723
723
  /**
724
724
  * Estimates the gas required for a post request execution on this chain.
@@ -2994,6 +2994,11 @@ declare class IntentGateway {
2994
2994
  */
2995
2995
  isOrderFilled(order: Order): Promise<boolean>;
2996
2996
  private submitAndConfirmReceipt;
2997
+ /**
2998
+ * Returns the native token amount required to dispatch a cancellation GET request for the given order.
2999
+ * Internally constructs the IGetRequest and calls quoteNative.
3000
+ */
3001
+ quoteCancelNative(order: Order): Promise<bigint>;
2997
3002
  /**
2998
3003
  * Cancels an order through the cross-chain protocol by generating and submitting proofs.
2999
3004
  * This is an async generator function that yields status updates throughout the cancellation process.
@@ -3123,7 +3128,7 @@ type HyperbridgeTxEvents = {
3123
3128
  error: unknown;
3124
3129
  };
3125
3130
  /**
3126
- * Parameters for teleporting DOT from Polkadot relay chain to EVM-based destination
3131
+ * Parameters for teleporting DOT from AssetHub to EVM-based destination
3127
3132
  */
3128
3133
  type XcmGatewayParams = {
3129
3134
  /**
@@ -3152,33 +3157,32 @@ type XcmGatewayParams = {
3152
3157
  paraId: number;
3153
3158
  };
3154
3159
  /**
3155
- * Teleports DOT tokens from Polkadot relay chain to an EVM-based destination chain
3156
- * using XCM (Cross-Consensus Message Format) and uses the indexer client to track
3157
- * the transaction instead of polling hyperbridge blocks.
3160
+ * Teleports DOT tokens from AssetHub to Hyperbridge parachain
3161
+ * using XCM V3 with transferAssetsUsingTypeAndThen.
3162
+ *
3163
+ * This function uses transferAssetsUsingTypeAndThen to construct XCM V3 transfers with a custom
3164
+ * beneficiary structure that embeds Hyperbridge-specific parameters (sender account, recipient EVM address,
3165
+ * timeout, and nonce) within an X4 junction. The beneficiary is wrapped in a DepositAsset XCM V3 instruction
3166
+ * that deposits all transferred assets. The assets are transferred using LocalReserve transfer type.
3158
3167
  *
3159
- * This function initiates a teleport transaction, monitors its status through the indexer,
3160
- * and yields events about the transaction's progress through a ReadableStream.
3161
3168
  * It handles the complete lifecycle of a teleport operation:
3162
- * 1. Transaction preparation and signing
3163
- * 2. Broadcasting to the relay chain
3164
- * 3. Tracking the transaction via the indexer client
3165
- * 4. Yielding events about transaction status
3169
+ * 1. Encoding Hyperbridge parameters into the beneficiary X4 junction
3170
+ * 2. Wrapping the beneficiary in a DepositAsset XCM V3 instruction using sourceApi.createType
3171
+ * 3. Constructing the XCM V3 transfer transaction using polkadotXcm.transferAssetsUsingTypeAndThen
3172
+ * 4. Transaction signing and broadcasting
3173
+ * 5. Yielding events about transaction status through a ReadableStream
3166
3174
  *
3167
3175
  * Note: There is no guarantee that both Dispatched and Finalized events will be yielded.
3168
3176
  * Consumers should listen for either one of these events instead of expecting both.
3169
3177
  *
3170
- * @param sourceApi - Polkadot API instance connected to the relay chain or asset hub
3171
- * @param sourceIsAssetHub - If `true` uses AssetHub Network for teleport
3178
+ * @param sourceApi - Polkadot API instance connected to AssetHub
3172
3179
  * @param who - Sender's SS58Address address
3173
3180
  * @param options - Transaction signing options
3174
- * @param params - Teleport parameters including destination, recipient, and amount
3175
- * @param indexerClient - The indexer client to track the transaction
3176
- * @param pollInterval - Optional polling interval in milliseconds (default: 2000)
3181
+ * @param params - Teleport parameters including destination, recipient, amount, timeout, and paraId
3177
3182
  * @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
3178
3183
  */
3179
3184
  declare function teleportDot(param_: {
3180
3185
  sourceApi: ApiPromise;
3181
- sourceIsAssetHub: boolean;
3182
3186
  who: string;
3183
3187
  xcmGatewayParams: XcmGatewayParams;
3184
3188
  options: Partial<SignerOptions>;
@@ -13,12 +13,10 @@ import { WsProvider, ApiPromise } from '@polkadot/api';
13
13
  import { keccakAsU8a, decodeAddress, keccakAsHex, xxhashAsU8a } from '@polkadot/util-crypto';
14
14
  import { GraphQLClient } from 'graphql-request';
15
15
  import { Decimal } from 'decimal.js';
16
- import { createStorage } from 'unstorage';
17
16
  import stringify from 'safe-stable-stringify';
17
+ import { createStorage } from 'unstorage';
18
+ import inMemoryDriver from 'unstorage/drivers/memory';
18
19
  import fsDriver from 'unstorage/drivers/fs';
19
- import indexedDBDriver from 'unstorage/drivers/indexedb';
20
- import localStorageDriver from 'unstorage/drivers/localstorage';
21
- import memoryDriver from 'unstorage/drivers/memory';
22
20
  import { hexToU8a, u8aToHex } from '@polkadot/util';
23
21
 
24
22
  var __defProp = Object.defineProperty;
@@ -6032,13 +6030,14 @@ var EvmChain = class {
6032
6030
  * @returns The total fee in wei required to send the post request
6033
6031
  */
6034
6032
  async quote(request) {
6033
+ const bodyByteLength = "body" in request ? Math.floor((request.body.length - 2) / 2) : Math.floor((request.context.length - 2) / 2);
6034
+ const args = "body" in request ? [toHex(request.dest)] : [toHex(request.source)];
6035
6035
  const perByteFee = await this.publicClient.readContract({
6036
6036
  address: this.params.host,
6037
6037
  abi: evmHost_default.ABI,
6038
6038
  functionName: "perByteFee",
6039
- args: [toHex(request.dest)]
6039
+ args
6040
6040
  });
6041
- const bodyByteLength = Math.floor((request.body.length - 2) / 2);
6042
6041
  const length = bodyByteLength < 32 ? 32 : bodyByteLength;
6043
6042
  return perByteFee * BigInt(length);
6044
6043
  }
@@ -6874,7 +6873,7 @@ query GetResponseByRequestId($requestId: String!) {
6874
6873
  `;
6875
6874
  var ORDER_STATUS = `
6876
6875
  query OrderStatus($commitment: String!) {
6877
- orderPlaceds(
6876
+ orders(
6878
6877
  filter: { commitment: { equalTo: $commitment } }
6879
6878
  ) {
6880
6879
  nodes {
@@ -6895,6 +6894,7 @@ query OrderStatus($commitment: String!) {
6895
6894
  outputBeneficiaries
6896
6895
  calldata
6897
6896
  status
6897
+ referrer
6898
6898
  createdAt
6899
6899
  blockNumber
6900
6900
  blockTimestamp
@@ -10002,6 +10002,77 @@ var ABI4 = [
10002
10002
  }
10003
10003
  ];
10004
10004
  var IntentGateway_default = { ABI: ABI4 };
10005
+ var loadDriver = ({ options }) => {
10006
+ return fsDriver({ base: options?.basePath ?? "./.hyperbridge-cache" });
10007
+ };
10008
+
10009
+ // src/storage/index.ts
10010
+ var convertBigIntsToSerializable = (value) => {
10011
+ if (value === null || value === void 0) return value;
10012
+ if (typeof value === "bigint") return { __type: "bigint", value: value.toString() };
10013
+ if (Array.isArray(value)) return value.map(convertBigIntsToSerializable);
10014
+ if (typeof value === "object") {
10015
+ return Object.entries(value).reduce((acc, [k, v]) => {
10016
+ acc[k] = convertBigIntsToSerializable(v);
10017
+ return acc;
10018
+ }, {});
10019
+ }
10020
+ return value;
10021
+ };
10022
+ var convertSerializableToBigInts = (value) => {
10023
+ if (value === null || value === void 0) return value;
10024
+ if (Array.isArray(value)) return value.map(convertSerializableToBigInts);
10025
+ if (typeof value === "object" && value !== null) {
10026
+ const obj = value;
10027
+ if (obj.__type === "bigint" && typeof obj.value === "string") {
10028
+ return BigInt(obj.value);
10029
+ }
10030
+ return Object.entries(obj).reduce((acc, [k, v]) => {
10031
+ acc[k] = convertSerializableToBigInts(v);
10032
+ return acc;
10033
+ }, {});
10034
+ }
10035
+ return value;
10036
+ };
10037
+ var detectEnvironment = () => {
10038
+ if (typeof process !== "undefined" && !!process.versions?.node) return "node";
10039
+ if (typeof globalThis !== "undefined" && "localStorage" in globalThis) return "localstorage";
10040
+ if (typeof globalThis !== "undefined" && "indexedDB" in globalThis) return "indexeddb";
10041
+ return "memory";
10042
+ };
10043
+ function createCancellationStorage(options = {}) {
10044
+ options.env ?? detectEnvironment();
10045
+ const driver = loadDriver({ options }) ?? inMemoryDriver;
10046
+ const baseStorage = createStorage({ driver });
10047
+ const getItem = async (key2) => {
10048
+ const value = await baseStorage.getItem(key2);
10049
+ if (!value) return null;
10050
+ try {
10051
+ return convertSerializableToBigInts(JSON.parse(value));
10052
+ } catch {
10053
+ return value;
10054
+ }
10055
+ };
10056
+ const setItem = async (key2, value) => {
10057
+ const serializable = convertBigIntsToSerializable(value);
10058
+ const stringified = stringify(serializable) ?? "null";
10059
+ await baseStorage.setItem(key2, stringified);
10060
+ };
10061
+ const removeItem = async (key2) => {
10062
+ baseStorage.removeItem(key2);
10063
+ };
10064
+ return Object.freeze({
10065
+ ...baseStorage,
10066
+ getItem,
10067
+ setItem,
10068
+ removeItem
10069
+ });
10070
+ }
10071
+ var STORAGE_KEYS = Object.freeze({
10072
+ destProof: (orderId) => `cancel-order:${orderId}:destProof`,
10073
+ getRequest: (orderId) => `cancel-order:${orderId}:getRequest`,
10074
+ sourceProof: (orderId) => `cancel-order:${orderId}:sourceProof`
10075
+ });
10005
10076
 
10006
10077
  // src/abis/uniswapV3Quoter.ts
10007
10078
  var ABI5 = [
@@ -12322,81 +12393,6 @@ var Swap = class {
12322
12393
  }
12323
12394
  }
12324
12395
  };
12325
- var convertBigIntsToSerializable = (value) => {
12326
- if (value === null || value === void 0) return value;
12327
- if (typeof value === "bigint") return { __type: "bigint", value: value.toString() };
12328
- if (Array.isArray(value)) return value.map(convertBigIntsToSerializable);
12329
- if (typeof value === "object") {
12330
- return Object.entries(value).reduce((acc, [k, v]) => {
12331
- acc[k] = convertBigIntsToSerializable(v);
12332
- return acc;
12333
- }, {});
12334
- }
12335
- return value;
12336
- };
12337
- var convertSerializableToBigInts = (value) => {
12338
- if (value === null || value === void 0) return value;
12339
- if (Array.isArray(value)) return value.map(convertSerializableToBigInts);
12340
- if (typeof value === "object" && value !== null) {
12341
- const obj = value;
12342
- if (obj.__type === "bigint" && typeof obj.value === "string") {
12343
- return BigInt(obj.value);
12344
- }
12345
- return Object.entries(obj).reduce((acc, [k, v]) => {
12346
- acc[k] = convertSerializableToBigInts(v);
12347
- return acc;
12348
- }, {});
12349
- }
12350
- return value;
12351
- };
12352
- var detectEnvironment = () => {
12353
- if (typeof process !== "undefined" && !!process.versions?.node) return "node";
12354
- if (typeof globalThis !== "undefined" && "localStorage" in globalThis) return "localstorage";
12355
- if (typeof globalThis !== "undefined" && "indexedDB" in globalThis) return "indexeddb";
12356
- return "memory";
12357
- };
12358
- function createCancellationStorage(options = {}) {
12359
- const environment = options.env ?? detectEnvironment();
12360
- const driver = (() => {
12361
- switch (environment) {
12362
- case "node":
12363
- return fsDriver({ base: options.basePath ?? "./.hyperbridge-cache" });
12364
- case "localstorage":
12365
- return localStorageDriver({ base: "hyperbridge" });
12366
- case "indexeddb":
12367
- return indexedDBDriver({ base: "hyperbridge" });
12368
- default:
12369
- return memoryDriver();
12370
- }
12371
- })();
12372
- const baseStorage = createStorage({ driver });
12373
- const getItem = async (key) => {
12374
- const value = await baseStorage.getItem(key);
12375
- if (!value) return null;
12376
- try {
12377
- return convertSerializableToBigInts(JSON.parse(value));
12378
- } catch {
12379
- return value;
12380
- }
12381
- };
12382
- const setItem = async (key, value) => {
12383
- const serializable = convertBigIntsToSerializable(value);
12384
- const stringified = stringify(serializable) ?? "null";
12385
- await baseStorage.setItem(key, stringified);
12386
- };
12387
- const removeItem = (key) => baseStorage.removeItem(key);
12388
- return Object.freeze({
12389
- ...baseStorage,
12390
- getItem,
12391
- setItem,
12392
- removeItem
12393
- });
12394
- }
12395
- var STORAGE_KEYS = Object.freeze({
12396
- destProof: (orderId) => `cancel-order:${orderId}:destProof`,
12397
- getRequest: (orderId) => `cancel-order:${orderId}:getRequest`,
12398
- sourceProof: (orderId) => `cancel-order:${orderId}:sourceProof`
12399
- });
12400
12396
 
12401
12397
  // src/protocols/intents.ts
12402
12398
  var IntentGateway = class {
@@ -12470,7 +12466,10 @@ var IntentGateway = class {
12470
12466
  tokenAddress,
12471
12467
  allowanceData
12472
12468
  );
12473
- stateDiffs.push({ slot: allowanceSlot, value: testValue });
12469
+ stateDiffs.push({
12470
+ slot: allowanceSlot,
12471
+ value: testValue
12472
+ });
12474
12473
  } catch (e) {
12475
12474
  console.warn(`Could not find allowance slot for token ${tokenAddress}:`, e);
12476
12475
  }
@@ -12733,6 +12732,60 @@ var IntentGateway = class {
12733
12732
  }
12734
12733
  console.log("Hyperbridge Receipt confirmed.");
12735
12734
  }
12735
+ /**
12736
+ * Returns the native token amount required to dispatch a cancellation GET request for the given order.
12737
+ * Internally constructs the IGetRequest and calls quoteNative.
12738
+ */
12739
+ async quoteCancelNative(order) {
12740
+ const orderWithCommitment = transformOrder(order);
12741
+ const height = orderWithCommitment.deadline + 1n;
12742
+ const destIntentGateway = this.dest.configService.getIntentGatewayAddress(orderWithCommitment.destChain);
12743
+ const slotHash = await this.dest.client.readContract({
12744
+ abi: IntentGateway_default.ABI,
12745
+ address: destIntentGateway,
12746
+ functionName: "calculateCommitmentSlotHash",
12747
+ args: [orderWithCommitment.id]
12748
+ });
12749
+ const key = concatHex([destIntentGateway, slotHash]);
12750
+ const context = encodeAbiParameters(
12751
+ [
12752
+ {
12753
+ name: "requestBody",
12754
+ type: "tuple",
12755
+ components: [
12756
+ { name: "commitment", type: "bytes32" },
12757
+ { name: "beneficiary", type: "bytes32" },
12758
+ {
12759
+ name: "tokens",
12760
+ type: "tuple[]",
12761
+ components: [
12762
+ { name: "token", type: "bytes32" },
12763
+ { name: "amount", type: "uint256" }
12764
+ ]
12765
+ }
12766
+ ]
12767
+ }
12768
+ ],
12769
+ [
12770
+ {
12771
+ commitment: orderWithCommitment.id,
12772
+ beneficiary: orderWithCommitment.user,
12773
+ tokens: orderWithCommitment.inputs
12774
+ }
12775
+ ]
12776
+ );
12777
+ const getRequest = {
12778
+ source: orderWithCommitment.sourceChain,
12779
+ dest: orderWithCommitment.destChain,
12780
+ from: this.source.configService.getIntentGatewayAddress(orderWithCommitment.destChain),
12781
+ nonce: await this.source.getHostNonce(),
12782
+ height,
12783
+ keys: [key],
12784
+ timeoutTimestamp: 0n,
12785
+ context
12786
+ };
12787
+ return await this.source.quoteNative(getRequest, 0n);
12788
+ }
12736
12789
  /**
12737
12790
  * Cancels an order through the cross-chain protocol by generating and submitting proofs.
12738
12791
  * This is an async generator function that yields status updates throughout the cancellation process.
@@ -12776,7 +12829,7 @@ var IntentGateway = class {
12776
12829
  */
12777
12830
  async *cancelOrder(order, indexerClient) {
12778
12831
  const orderId = orderCommitment(order);
12779
- let hyperbridge = indexerClient.hyperbridge;
12832
+ const hyperbridge = indexerClient.hyperbridge;
12780
12833
  const sourceStateMachine = hexToString$1(order.sourceChain);
12781
12834
  const sourceConsensusStateId = this.source.configService.getConsensusStateId(sourceStateMachine);
12782
12835
  let destIProof = await this.storage.getItem(STORAGE_KEYS.destProof(orderId));
@@ -12786,19 +12839,30 @@ var IntentGateway = class {
12786
12839
  }
12787
12840
  let getRequest = await this.storage.getItem(STORAGE_KEYS.getRequest(orderId));
12788
12841
  if (!getRequest) {
12789
- const transactionHash = yield { status: "AWAITING_GET_REQUEST", data: void 0 };
12790
- const receipt = await this.source.client.getTransactionReceipt({ hash: transactionHash });
12842
+ const transactionHash = yield {
12843
+ status: "AWAITING_GET_REQUEST",
12844
+ data: void 0
12845
+ };
12846
+ const receipt = await this.source.client.getTransactionReceipt({
12847
+ hash: transactionHash
12848
+ });
12791
12849
  const events = parseEventLogs({ abi: evmHost_default.ABI, logs: receipt.logs });
12792
12850
  const request = events.find((e) => e.eventName === "GetRequestEvent");
12793
12851
  if (!request) throw new Error("GetRequest missing");
12794
12852
  getRequest = request.args;
12795
12853
  await this.storage.setItem(STORAGE_KEYS.getRequest(orderId), getRequest);
12796
12854
  }
12797
- const commitment = getRequestCommitment({ ...getRequest, keys: [...getRequest.keys] });
12855
+ const commitment = getRequestCommitment({
12856
+ ...getRequest,
12857
+ keys: [...getRequest.keys]
12858
+ });
12798
12859
  const sourceStatusStream = indexerClient.getRequestStatusStream(commitment);
12799
12860
  for await (const statusUpdate of sourceStatusStream) {
12800
12861
  if (statusUpdate.status === RequestStatus.SOURCE_FINALIZED) {
12801
- yield { status: "SOURCE_FINALIZED", data: { metadata: statusUpdate.metadata } };
12862
+ yield {
12863
+ status: "SOURCE_FINALIZED",
12864
+ data: { metadata: statusUpdate.metadata }
12865
+ };
12802
12866
  const sourceHeight = BigInt(statusUpdate.metadata.blockNumber);
12803
12867
  let sourceIProof = await this.storage.getItem(STORAGE_KEYS.sourceProof(orderId));
12804
12868
  if (!sourceIProof) {
@@ -12829,11 +12893,17 @@ var IntentGateway = class {
12829
12893
  continue;
12830
12894
  }
12831
12895
  if (statusUpdate.status === RequestStatus.HYPERBRIDGE_DELIVERED) {
12832
- yield { status: "HYPERBRIDGE_DELIVERED", data: statusUpdate };
12896
+ yield {
12897
+ status: "HYPERBRIDGE_DELIVERED",
12898
+ data: statusUpdate
12899
+ };
12833
12900
  continue;
12834
12901
  }
12835
12902
  if (statusUpdate.status === RequestStatus.HYPERBRIDGE_FINALIZED) {
12836
- yield { status: "HYPERBRIDGE_FINALIZED", data: statusUpdate };
12903
+ yield {
12904
+ status: "HYPERBRIDGE_FINALIZED",
12905
+ data: statusUpdate
12906
+ };
12837
12907
  await this.storage.removeItem(STORAGE_KEYS.destProof(orderId));
12838
12908
  await this.storage.removeItem(STORAGE_KEYS.getRequest(orderId));
12839
12909
  await this.storage.removeItem(STORAGE_KEYS.sourceProof(orderId));
@@ -13067,7 +13137,7 @@ var MultiAccount = Struct({
13067
13137
  });
13068
13138
  var DECIMALS = 10;
13069
13139
  async function teleportDot(param_) {
13070
- const { sourceApi, sourceIsAssetHub, who, options, xcmGatewayParams: params } = param_;
13140
+ const { sourceApi, who, options, xcmGatewayParams: params } = param_;
13071
13141
  const { nonce: accountNonce } = await sourceApi.query.system.account(who);
13072
13142
  const encoded_message = MultiAccount.enc({
13073
13143
  substrate_account: decodeAddress(who),
@@ -13078,7 +13148,7 @@ async function teleportDot(param_) {
13078
13148
  });
13079
13149
  const message_id = keccakAsHex(encoded_message);
13080
13150
  const beneficiary = {
13081
- V3: {
13151
+ V4: {
13082
13152
  parents: 0,
13083
13153
  interior: {
13084
13154
  X4: [
@@ -13108,81 +13178,58 @@ async function teleportDot(param_) {
13108
13178
  }
13109
13179
  }
13110
13180
  };
13111
- let assets2;
13112
- let destination;
13113
- if (sourceIsAssetHub) {
13114
- destination = {
13115
- V3: {
13116
- parents: 1,
13117
- interior: {
13118
- X1: {
13119
- Parachain: params.paraId
13120
- }
13121
- }
13181
+ const destination = {
13182
+ V4: {
13183
+ parents: 1,
13184
+ interior: {
13185
+ X1: [{ Parachain: params.paraId }]
13122
13186
  }
13123
- };
13124
- assets2 = {
13125
- V3: [
13126
- {
13127
- id: {
13128
- Concrete: {
13129
- parents: 1,
13130
- interior: "Here"
13131
- }
13132
- },
13133
- fun: {
13134
- Fungible: parseUnits(params.amount.toString(), DECIMALS)
13135
- }
13136
- }
13137
- ]
13138
- };
13139
- } else {
13140
- destination = {
13141
- V3: {
13142
- parents: 0,
13143
- interior: {
13144
- X1: {
13145
- Parachain: params.paraId
13146
- }
13187
+ }
13188
+ };
13189
+ const assets2 = {
13190
+ V4: [
13191
+ {
13192
+ id: {
13193
+ parents: 1,
13194
+ interior: "Here"
13195
+ },
13196
+ fun: {
13197
+ Fungible: parseUnits(params.amount.toString(), DECIMALS)
13147
13198
  }
13148
13199
  }
13149
- };
13150
- assets2 = {
13151
- V3: [
13152
- {
13153
- id: {
13154
- Concrete: {
13155
- parents: 0,
13156
- interior: "Here"
13200
+ ]
13201
+ };
13202
+ const weightLimit = "Unlimited";
13203
+ const feeAssetId = {
13204
+ V4: assets2.V4[0].id
13205
+ };
13206
+ const customXcmOnDest = {
13207
+ V4: [
13208
+ {
13209
+ DepositAsset: {
13210
+ assets: {
13211
+ Wild: {
13212
+ AllCounted: 1
13157
13213
  }
13158
13214
  },
13159
- fun: {
13160
- Fungible: parseUnits(params.amount.toString(), DECIMALS)
13161
- }
13215
+ beneficiary: beneficiary.V4
13162
13216
  }
13163
- ]
13164
- };
13165
- }
13166
- const feeAssetItem = 0;
13167
- const weightLimit = "Unlimited";
13168
- let tx;
13169
- if (sourceIsAssetHub) {
13170
- tx = sourceApi.tx.polkadotXcm.limitedReserveTransferAssets(
13171
- destination,
13172
- beneficiary,
13173
- assets2,
13174
- feeAssetItem,
13175
- weightLimit
13176
- );
13177
- } else {
13178
- tx = sourceApi.tx.xcmPallet.limitedReserveTransferAssets(
13179
- destination,
13180
- beneficiary,
13181
- assets2,
13182
- feeAssetItem,
13183
- weightLimit
13184
- );
13185
- }
13217
+ }
13218
+ ]
13219
+ };
13220
+ const tx = sourceApi.tx.polkadotXcm.transferAssetsUsingTypeAndThen(
13221
+ destination,
13222
+ assets2,
13223
+ { LocalReserve: null },
13224
+ // Assets transfer type
13225
+ feeAssetId,
13226
+ // Fee asset ID wrapped as VersionedAssetId
13227
+ { LocalReserve: null },
13228
+ // Remote fee transfer type
13229
+ customXcmOnDest,
13230
+ // XCM instruction with DepositAsset containing custom beneficiary
13231
+ weightLimit
13232
+ );
13186
13233
  let closed = false;
13187
13234
  let unsubscribe;
13188
13235
  const stream = new ReadableStream(