Skip to content

Commit

Permalink
fix: paseo typings
Browse files Browse the repository at this point in the history
This commit could be reverted when paseo assethub implements xcm v4.
  • Loading branch information
carlosala committed Jul 26, 2024
1 parent f6609cd commit ef22219
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions src/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ef22219

Please sign in to comment.