11/* eslint @typescript-eslint/no-var-requires: "off" */
22import { createSubstrateAPI } from "../src/factory" ;
33import { ApiPromise , Keyring } from "@polkadot/api" ;
4- import {
5- DefaultTransactionAPI ,
6- } from "../src/parachain" ;
4+ import { DefaultTransactionAPI } from "../src/parachain" ;
75import { cryptoWaitReady } from "@polkadot/util-crypto" ;
86import { XcmVersionedMultiLocation } from "@polkadot/types/lookup" ;
9- import { XcmV1MultiLocation } from "@polkadot/types/lookup" ;
10-
117
128// const PARACHAIN_ENDPOINT = "wss://api-dev-moonbeam.interlay.io/parachain";
139const PARACHAIN_ENDPOINT = "ws://127.0.0.1:9988" ;
@@ -19,28 +15,36 @@ main().catch((err) => {
1915} ) ;
2016
2117function construct_kint_transfer ( api : ApiPromise , dest : XcmVersionedMultiLocation ) {
22- const kint = api . createType ( "InterbtcPrimitivesCurrencyId" , {
18+ const kint = api . createType ( "InterbtcPrimitivesCurrencyId" , {
2319 token : api . createType ( "InterbtcPrimitivesTokenSymbol" , {
2420 kint : true ,
25- } )
21+ } ) ,
2622 } ) ;
2723
28- return api . tx . xTokens . transfer ( kint , 100000000000 , dest , 400000000000 )
24+ return api . tx . xTokens . transfer ( kint , 100000000000 , dest , "Unlimited" ) ;
2925}
3026
3127function construct_kbtc_transfer ( api : ApiPromise , dest : XcmVersionedMultiLocation ) {
32- const kint = api . createType ( "InterbtcPrimitivesCurrencyId" , {
28+ const kint = api . createType ( "InterbtcPrimitivesCurrencyId" , {
3329 token : api . createType ( "InterbtcPrimitivesTokenSymbol" , {
3430 kint : true ,
35- } )
31+ } ) ,
3632 } ) ;
37- const kbtc = api . createType ( "InterbtcPrimitivesCurrencyId" , {
33+ const kbtc = api . createType ( "InterbtcPrimitivesCurrencyId" , {
3834 token : api . createType ( "InterbtcPrimitivesTokenSymbol" , {
3935 kbtc : true ,
40- } )
36+ } ) ,
4137 } ) ;
42-
43- return api . tx . xTokens . transferMulticurrencies ( [ [ kint , 100000000000 ] , [ kbtc , 100000 ] ] , 1 , dest , 400000000000 )
38+
39+ return api . tx . xTokens . transferMulticurrencies (
40+ [
41+ [ kint , 100000000000 ] ,
42+ [ kbtc , 100000 ] ,
43+ ] ,
44+ 1 ,
45+ dest ,
46+ "Unlimited"
47+ ) ;
4448}
4549
4650function construct_dest_rococo ( api : ApiPromise ) {
@@ -49,16 +53,18 @@ function construct_dest_rococo(api: ApiPromise) {
4953 parents : 1 ,
5054 interior : api . createType ( "XcmV1MultilocationJunctions" , {
5155 x2 : [
52- api . createType ( "XcmV1Junction" , {
53- parachain : 3000
54- } ) , api . createType ( "XcmV1Junction" , {
56+ api . createType ( "XcmV1Junction" , {
57+ parachain : 3000 ,
58+ } ) ,
59+ api . createType ( "XcmV1Junction" , {
5560 accountId32 : {
5661 network : api . createType ( "XcmV0JunctionNetworkId" , { any : true } ) ,
57- id : "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" // alice
58- }
59- } ) ]
60- } )
61- } )
62+ id : "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" , // alice
63+ } ,
64+ } ) ,
65+ ] ,
66+ } ) ,
67+ } ) ,
6268 } ) ;
6369}
6470
@@ -68,16 +74,18 @@ function construct_dest_moonbase_alpha(api: ApiPromise) {
6874 parents : 1 ,
6975 interior : api . createType ( "XcmV1MultilocationJunctions" , {
7076 x2 : [
71- api . createType ( "XcmV1Junction" , {
72- parachain : 1000
73- } ) , api . createType ( "XcmV1Junction" , {
77+ api . createType ( "XcmV1Junction" , {
78+ parachain : 1000 ,
79+ } ) ,
80+ api . createType ( "XcmV1Junction" , {
7481 accountKey20 : {
7582 network : api . createType ( "XcmV0JunctionNetworkId" , { any : true } ) ,
76- key : "0x09Af4E864b84706fbCFE8679BF696e8c0B472201"
77- }
78- } ) ]
79- } )
80- } )
83+ key : "0x09Af4E864b84706fbCFE8679BF696e8c0B472201" ,
84+ } ,
85+ } ) ,
86+ ] ,
87+ } ) ,
88+ } ) ,
8189 } ) ;
8290}
8391
@@ -96,7 +104,6 @@ async function main(): Promise<void> {
96104 // send kbtc but use kint to pay for xcm fee on target chain
97105 const xcmKbtcTransferTx = construct_kbtc_transfer ( api , dest_rococo ) ;
98106
99-
100107 const transactionAPI = new DefaultTransactionAPI ( api , userKeyring ) ;
101108 console . log ( "broadcasting..." ) ;
102109 await transactionAPI . sendLogged ( xcmKintTransferTx , undefined ) ;
0 commit comments