1- async function readContract ( contractName ) {
2- const fs = require ( "fs" ) ;
3- const path = require ( "path" ) ;
4-
5- const filepath = path . join ( "addresses" , contractName ) ;
6- const address = fs . readFileSync ( filepath , "utf-8" ) ;
7- return await hre . ethers . getContractAt ( contractName , address ) ;
8- }
1+ const util = require ( "./util" ) ;
92
103async function main ( ) {
114 const accounts = await hre . ethers . getSigners ( ) ;
@@ -20,21 +13,20 @@ async function main() {
2013
2114 try {
2215 // Mint
23- const bank = await readContract ( "ICS20Bank" ) ;
16+ const bank = await util . readContract ( "ICS20Bank" ) ;
2417 const mintResult = await bank . mint ( alice , "simple_erc_20_token_for_test" , mintAmount , {
2518 from : alice
2619 } ) ;
2720 const mintReceipt = await mintResult . wait ( )
28- console . log ( "mint success block= " , mintReceipt ) ;
21+ console . log ( "mint success" , mintReceipt . hash ) ;
2922
3023 // Send to counterparty chain
31- const transfer = await readContract ( "ICS20TransferBank" ) ;
32- console . log ( transfer . interface )
24+ const transfer = await util . readContract ( "ICS20TransferBank" ) ;
3325 const transferResult = await transfer . sendTransfer ( "simple_erc_20_token_for_test" , sendingAmount , bob , port , channel , timeoutHeight , {
3426 from : alice ,
3527 } ) ;
3628 const transferReceipt = await transferResult . wait ( )
37- console . log ( "send success block= " , transferReceipt ) ;
29+ console . log ( "send success" , transferReceipt . hash ) ;
3830
3931 // Check reduced amount
4032 const aliceAmount = await bank . balanceOf ( alice , "simple_erc_20_token_for_test" )
@@ -44,7 +36,7 @@ async function main() {
4436 }
4537
4638 // Check escrow balance
47- const escrowAmount = await bank . balanceOf ( transfer . address , "simple_erc_20_token_for_test" )
39+ const escrowAmount = await bank . balanceOf ( transfer . target , "simple_erc_20_token_for_test" )
4840 console . log ( "escrow = " , escrowAmount . toString ( ) )
4941 if ( parseInt ( escrowAmount . toString ( ) , 10 ) !== sendingAmount ) {
5042 throw new Error ( "escrow amount error" ) ;
0 commit comments