@@ -26,20 +26,20 @@ ethereumWithNode.addProvider(new providers.ethereum.EthereumRPCProvider(config.e
2626ethereumWithNode . addProvider ( new providers . ethereum . EthereumSwapProvider ( ) )
2727
2828const chains = {
29- bitcoinWithLedger,
30- bitcoinWithNode,
31- ethereumWithMetaMask,
32- ethereumWithNode
29+ bitcoinWithLedger : { id : 'Bitcoin Ledger' , name : 'bitcoin' , client : bitcoinWithLedger } ,
30+ bitcoinWithNode : { id : 'Bitcoin Node' , name : 'bitcoin' , client : bitcoinWithNode } ,
31+ ethereumWithMetaMask : { id : 'Ethereum MetaMask' , name : 'ethereum' , client : ethereumWithMetaMask } ,
32+ ethereumWithNode : { id : 'Ethereum Node' , name : 'ethereum' , client : ethereumWithNode }
3333}
3434
35- async function getSwapParams ( id , chain ) {
36- const unusedAddress = await chain . getUnusedAddress ( )
35+ async function getSwapParams ( chain ) {
36+ const unusedAddress = await chain . client . getUnusedAddress ( )
3737 const recipientAddress = unusedAddress . address
3838 const refundAddress = unusedAddress . address
3939 const expiration = parseInt ( Date . now ( ) / 1000 ) + parseInt ( Math . random ( ) * 1000000 )
40- const value = 10000
40+ const value = config [ chain . name ] . value
4141
42- console . log ( '\x1b[2m' , `Swap Params for ${ id } ` , '\x1b[0m' )
42+ console . log ( '\x1b[2m' , `Swap Params for ${ chain . id } ` , '\x1b[0m' )
4343 console . log ( '\x1b[2m' , 'Recipient Address:' , recipientAddress , '\x1b[0m' )
4444 console . log ( '\x1b[2m' , 'Refund Address:' , refundAddress , '\x1b[0m' )
4545 console . log ( '\x1b[2m' , 'Expiry:' , expiration , '\x1b[0m' )
@@ -53,29 +53,29 @@ async function getSwapParams (id, chain) {
5353 }
5454}
5555
56- async function initiateAndVerify ( chain , chainId , secretHash , swapParams ) {
57- console . log ( '\x1b[33m' , `Initiating ${ chainId } : Watch prompt on wallet` , '\x1b[0m' )
56+ async function initiateAndVerify ( chain , secretHash , swapParams ) {
57+ console . log ( '\x1b[33m' , `Initiating ${ chain . id } : Watch prompt on wallet` , '\x1b[0m' )
5858 const initiationParams = [ swapParams . value , swapParams . recipientAddress , swapParams . refundAddress , secretHash , swapParams . expiration ]
5959 const [ initiationTx , initiationTxId ] = await Promise . all ( [
60- chain . findInitiateSwapTransaction ( ...initiationParams ) ,
61- chain . initiateSwap ( ...initiationParams )
60+ chain . client . findInitiateSwapTransaction ( ...initiationParams ) ,
61+ chain . client . initiateSwap ( ...initiationParams )
6262 ] )
6363 expect ( initiationTx . hash ) . to . equal ( initiationTxId )
64- const isVerified = await chain . verifyInitiateSwapTransaction ( initiationTxId , ...initiationParams )
64+ const isVerified = await chain . client . verifyInitiateSwapTransaction ( initiationTxId , ...initiationParams )
6565 expect ( isVerified ) . to . equal ( true )
66- console . log ( `${ chainId } Initiated ${ initiationTxId } ` )
66+ console . log ( `${ chain . id } Initiated ${ initiationTxId } ` )
6767 return initiationTxId
6868}
6969
70- async function claimAndVerify ( chain , chainId , initiationTxId , secret , swapParams ) {
71- console . log ( '\x1b[33m' , `Claiming ${ chainId } : Watch prompt on wallet` , '\x1b[0m' )
70+ async function claimAndVerify ( chain , initiationTxId , secret , swapParams ) {
71+ console . log ( '\x1b[33m' , `Claiming ${ chain . id } : Watch prompt on wallet` , '\x1b[0m' )
7272 const secretHash = crypto . sha256 ( secret )
7373 const [ claimTx , claimTxId ] = await Promise . all ( [
74- chain . findClaimSwapTransaction ( initiationTxId , swapParams . recipientAddress , swapParams . refundAddress , secretHash , swapParams . expiration ) ,
75- chain . claimSwap ( initiationTxId , swapParams . recipientAddress , swapParams . refundAddress , secret , swapParams . expiration )
74+ chain . client . findClaimSwapTransaction ( initiationTxId , swapParams . recipientAddress , swapParams . refundAddress , secretHash , swapParams . expiration ) ,
75+ chain . client . claimSwap ( initiationTxId , swapParams . recipientAddress , swapParams . refundAddress , secret , swapParams . expiration )
7676 ] )
7777 expect ( claimTx . hash ) . to . equal ( claimTxId )
78- console . log ( `${ chainId } Claimed ${ claimTxId } ` )
78+ console . log ( `${ chain . id } Claimed ${ claimTxId } ` )
7979 return claimTx . secret
8080}
8181
0 commit comments