@@ -10,6 +10,7 @@ import (
1010 "github.com/ethereum/go-ethereum/core/types"
1111 "github.com/ethereum/go-ethereum/crypto"
1212 "github.com/ethereum/go-ethereum/ethclient"
13+ er "github.com/pkg/errors"
1314 "github.com/smartcontractkit/chainlink-testing-framework/framework"
1415 "github.com/smartcontractkit/chainlink-testing-framework/framework/clclient"
1516 "math/big"
@@ -18,7 +19,7 @@ import (
1819func SendETH (client * ethclient.Client , privateKeyHex string , toAddress string , amount * big.Float ) error {
1920 privateKey , err := crypto .HexToECDSA (privateKeyHex )
2021 if err != nil {
21- return fmt . Errorf ( "failed to parse private key: %v" , err )
22+ return er . Wrap ( err , "failed to parse private key" )
2223 }
2324 wei := new (big.Int )
2425 amountWei := new (big.Float ).Mul (amount , big .NewFloat (1e18 ))
@@ -33,29 +34,29 @@ func SendETH(client *ethclient.Client, privateKeyHex string, toAddress string, a
3334
3435 nonce , err := client .PendingNonceAt (context .Background (), fromAddress )
3536 if err != nil {
36- return fmt . Errorf ( "failed to fetch nonce: %v" , err )
37+ return er . Wrap ( err , "failed to fetch nonce" )
3738 }
3839
3940 gasPrice , err := client .SuggestGasPrice (context .Background ())
4041 if err != nil {
41- return fmt . Errorf ( "failed to fetch gas price: %v" , err )
42+ return er . Wrap ( err , "failed to fetch gas price" )
4243 }
4344 gasLimit := uint64 (21000 ) // Standard gas limit for ETH transfer
4445
4546 tx := types .NewTransaction (nonce , common .HexToAddress (toAddress ), wei , gasLimit , gasPrice , nil )
4647
4748 chainID , err := client .NetworkID (context .Background ())
4849 if err != nil {
49- return fmt . Errorf ( "failed to fetch chain ID: %v" , err )
50+ return er . Wrap ( err , "failed to fetch chain ID" )
5051 }
5152 signedTx , err := types .SignTx (tx , types .NewEIP155Signer (chainID ), privateKey )
5253 if err != nil {
53- return fmt . Errorf ( "failed to sign transaction: %v" , err )
54+ return er . Wrap ( err , "failed to sign transaction" )
5455 }
5556
5657 err = client .SendTransaction (context .Background (), signedTx )
5758 if err != nil {
58- return fmt . Errorf ( "failed to send transaction: %v" , err )
59+ return er . Wrap ( err , "failed to send transaction" )
5960 }
6061 framework .L .Info ().Msgf ("Transaction sent: %s" , signedTx .Hash ().Hex ())
6162 _ , err = bind .WaitMined (context .Background (), client , signedTx )
@@ -67,13 +68,17 @@ func FundNodes(c *ethclient.Client, nodes []*clclient.ChainlinkClient, pkey stri
6768 if ethAmount == 0 {
6869 return errors .New ("funds_eth is 0, set some value in config, ex.: funds_eth = 30.0" )
6970 }
71+ chainID , err := c .ChainID (context .Background ())
72+ if err != nil {
73+ return er .Wrap (err , "failed to fetch chain ID" )
74+ }
7075 for _ , cl := range nodes {
71- ek , err := cl .ReadPrimaryETHKey ()
76+ ek , err := cl .ReadPrimaryETHKey (chainID . String () )
7277 if err != nil {
7378 return err
7479 }
7580 if err := SendETH (c , pkey , ek .Attributes .Address , big .NewFloat (ethAmount )); err != nil {
76- return fmt . Errorf ( "failed to fund CL node %s: %w " , ek .Attributes .Address , err )
81+ return er . Wrapf ( err , "failed to fund CL node %s" , ek .Attributes .Address )
7782 }
7883 }
7984 return nil
0 commit comments