From ef2221986f04e7ea5c18b7d08ef36e47802bf90c Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 26 Jul 2024 13:18:54 +0200 Subject: [PATCH] fix: paseo typings This commit could be reverted when paseo assethub implements xcm v4. --- src/api/common.ts | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index a705e66..135c2b9 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -15,18 +15,24 @@ import { map } from "rxjs" const encodeAccount = AccountId().enc -export const getBeneficiary = (address: SS58String | Uint8Array) => - XcmVersionedLocation.V3({ +export const getBeneficiary = (address: SS58String | Uint8Array) => ({ + type: "V3" as const, + value: { parents: 0, - interior: XcmV3Junctions.X1( - XcmV3Junction.AccountId32({ - network: undefined, - id: Binary.fromBytes( - address instanceof Uint8Array ? address : encodeAccount(address), - ), - }), - ), - }) + interior: { + type: "X1" as const, + value: { + type: "AccountId32" as const, + value: { + network: undefined, + id: Binary.fromBytes( + address instanceof Uint8Array ? address : encodeAccount(address), + ), + }, + }, + }, + }, +}) export const getNativeAsset = (parents: number, amount: bigint) => XcmVersionedAssets.V3([ @@ -59,10 +65,19 @@ export const fromAssetHubToRelay = ( amount: bigint, to?: SS58String, ) => ({ - dest: XcmVersionedLocation.V3({ - parents: 1, - interior: XcmV3Junctions.Here(), - }), + dest: { + type: "V3" as const, + value: { + parents: 0, + interior: { + type: "X1" as const, + value: { + type: "Parachain" as const, + value: 1000, + }, + }, + }, + }, beneficiary: getBeneficiary(to ?? from.publicKey), assets: getNativeAsset(1, amount), fee_asset_item: 0,