11import { AccountId , PolkadotSigner , TypedApi } from "polkadot-api"
22import {
3- XcmV3Junction ,
4- XcmV3JunctionNetworkId ,
5- XcmV3Junctions ,
63 XcmV3MultiassetFungibility ,
74 XcmV3WeightLimit ,
5+ XcmV5Junction ,
6+ XcmV5Junctions ,
7+ XcmV5NetworkId ,
88 XcmVersionedAssets ,
99 XcmVersionedLocation ,
1010 dotAh ,
@@ -15,10 +15,10 @@ import { combineLatest, from, map } from "rxjs"
1515const encodeAccount = AccountId ( ) . enc
1616
1717export const getBeneficiary = ( address : SS58String | Uint8Array ) =>
18- XcmVersionedLocation . V4 ( {
18+ XcmVersionedLocation . V5 ( {
1919 parents : 0 ,
20- interior : XcmV3Junctions . X1 (
21- XcmV3Junction . AccountId32 ( {
20+ interior : XcmV5Junctions . X1 (
21+ XcmV5Junction . AccountId32 ( {
2222 network : undefined ,
2323 id : Binary . fromBytes (
2424 address instanceof Uint8Array ? address : encodeAccount ( address ) ,
@@ -28,11 +28,11 @@ export const getBeneficiary = (address: SS58String | Uint8Array) =>
2828 } )
2929
3030export const getNativeAsset = ( parents : number , amount : bigint ) =>
31- XcmVersionedAssets . V4 ( [
31+ XcmVersionedAssets . V5 ( [
3232 {
3333 id : {
3434 parents,
35- interior : XcmV3Junctions . Here ( ) ,
35+ interior : XcmV5Junctions . Here ( ) ,
3636 } ,
3737 fun : XcmV3MultiassetFungibility . Fungible ( amount ) ,
3838 } ,
@@ -50,9 +50,9 @@ export const fromRelayToParachain = (
5050 amount : bigint ,
5151 to ?: SS58String ,
5252) => ( {
53- dest : XcmVersionedLocation . V4 ( {
53+ dest : XcmVersionedLocation . V5 ( {
5454 parents : 0 ,
55- interior : XcmV3Junctions . X1 ( XcmV3Junction . Parachain ( paraId ) ) ,
55+ interior : XcmV5Junctions . X1 ( XcmV5Junction . Parachain ( paraId ) ) ,
5656 } ) ,
5757 beneficiary : getBeneficiary ( to ?? from . publicKey ) ,
5858 assets : getNativeAsset ( 0 , amount ) ,
@@ -65,9 +65,9 @@ export const fromAssetHubToRelay = (
6565 amount : bigint ,
6666 to ?: SS58String ,
6767) => ( {
68- dest : XcmVersionedLocation . V4 ( {
68+ dest : XcmVersionedLocation . V5 ( {
6969 parents : 1 ,
70- interior : XcmV3Junctions . Here ( ) ,
70+ interior : XcmV5Junctions . Here ( ) ,
7171 } ) ,
7272 beneficiary : getBeneficiary ( to ?? from . publicKey ) ,
7373 assets : getNativeAsset ( 1 , amount ) ,
@@ -76,17 +76,17 @@ export const fromAssetHubToRelay = (
7676} )
7777
7878export const fromAssetHubToForeign = (
79- network : XcmV3JunctionNetworkId ,
79+ network : XcmV5NetworkId ,
8080 parachainId : number ,
8181 assets : XcmVersionedAssets ,
8282 from : PolkadotSigner ,
8383 to ?: SS58String ,
8484) => ( {
85- dest : XcmVersionedLocation . V4 ( {
85+ dest : XcmVersionedLocation . V5 ( {
8686 parents : 2 ,
87- interior : XcmV3Junctions . X2 ( [
88- XcmV3Junction . GlobalConsensus ( network ) ,
89- XcmV3Junction . Parachain ( parachainId ) ,
87+ interior : XcmV5Junctions . X2 ( [
88+ XcmV5Junction . GlobalConsensus ( network ) ,
89+ XcmV5Junction . Parachain ( parachainId ) ,
9090 ] ) ,
9191 } ) ,
9292 beneficiary : getBeneficiary ( to ?? from . publicKey ) ,
@@ -137,7 +137,7 @@ export const watchForeingAssetAccoutFreeBalance =
137137 }
138138 }
139139 } ,
140- asset : { parents : number ; interior : XcmV3Junctions } ,
140+ asset : { parents : number ; interior : XcmV5Junctions } ,
141141 ) =>
142142 ( account : SS58String ) =>
143143 api . query . ForeignAssets . Account . watchValue ( asset , account , "best" ) . pipe (
0 commit comments