@@ -4,39 +4,36 @@ async function main() {
44 const accounts = await hre . ethers . getSigners ( ) ;
55 const alice = accounts [ 0 ] . address ;
66 const bob = accounts [ 1 ] . address ;
7-
8- const channel = "channel-0" ;
9- const timeoutHeight = [
10- [ BigInt ( 1 ) , BigInt ( 10000000 ) ] ,
11- BigInt ( 0 )
12- ] ;
13- const sendingAmount = 20
14-
7+ const timeoutHeight = [ [ 1 , 10000000 ] , 0 ] ;
158 try {
169 const token = await util . readContract ( "ERC20Token" ) ;
10+ const transfer = await util . readContract ( "ICS20Transfer" ) ;
11+
1712 const before = await token . balanceOf ( alice )
1813 console . log ( "before = " , before . toString ( ) )
19- const transfer = await util . readContract ( "ICS20Transfer" ) ;
14+
15+ const escrowBefore = await token . balanceOf ( transfer . target )
16+ console . log ( "escrow before = " , escrowBefore . toString ( ) )
2017
2118 // Deposit and SendTransfer
22- await token . approve ( transfer . target , sendingAmount , { from : alice } ) . then ( tx => tx . wait ( ) ) ;
23- const depositResult = await transfer . depositSendTransfer ( channel , token . target , sendingAmount , bob , timeoutHeight , {
19+ await token . approve ( transfer . target , util . config . amount , { from : alice } ) . then ( tx => tx . wait ( ) ) ;
20+ const depositResult = await transfer . depositSendTransfer ( util . config . channel , token . target , util . config . amount , bob , timeoutHeight , {
2421 from : alice
2522 } )
2623 const depositReceipt = await depositResult . wait ( )
27- console . log ( "deposit success" , depositReceipt . hash ) ;
24+ console . log ( "depositSendTransfer success" , depositReceipt . hash ) ;
2825
2926 // Check reduced amount
3027 const after = await token . balanceOf ( alice )
3128 console . log ( "after = " , after . toString ( ) )
32- if ( parseInt ( after . toString ( ) , 10 ) !== Number ( before ) - sendingAmount ) {
29+ if ( parseInt ( after . toString ( ) , 10 ) !== Number ( before ) - util . config . amount ) {
3330 throw new Error ( "alice amount error" ) ;
3431 }
3532
3633 // Check escrow balance
37- const escrowAmount = await token . balanceOf ( transfer . target )
38- console . log ( "escrow = " , escrowAmount . toString ( ) )
39- if ( parseInt ( escrowAmount . toString ( ) , 10 ) !== sendingAmount ) {
34+ const escrowAfter = await token . balanceOf ( transfer . target )
35+ console . log ( "escrow after = " , escrowAfter . toString ( ) )
36+ if ( parseInt ( escrowAfter . toString ( ) , 10 ) !== Number ( escrowBefore ) + util . config . amount ) {
4037 throw new Error ( "escrow amount error" ) ;
4138 }
4239
0 commit comments