@@ -8,12 +8,12 @@ import {
88 EthereumStakeOptions ,
99 EthereumTx ,
1010 EthNetworkStats ,
11- EthStakes ,
11+ EthStakes , EthTxStatus ,
1212 InternalEthereumConfig ,
1313 ValidationKeyDepositData ,
1414} from '../types/eth' ;
1515import {
16- BroadcastError ,
16+ BroadcastError , GetTxStatusError ,
1717 InvalidIntegration ,
1818 InvalidSignature ,
1919} from "../errors/integrations" ;
@@ -95,19 +95,16 @@ export class EthService extends Service {
9595 ) ;
9696
9797 const data = batchDepositFunction . encodeABI ( ) ;
98- const gasPrice = await batchDepositFunction . estimateGas ( {
99- from : walletAddress ,
100- value : this . web3 . utils . toWei ( amountEth . toString ( ) , 'ether' ) ,
101- } ) ;
98+ const gasWei = 100000 + nbKeysNeeded * 80000 ;
10299 const common = new Common ( { chain : this . testnet ? Chain . Goerli : Chain . Mainnet } ) ;
103100 const nonce = await this . web3 . eth . getTransactionCount ( walletAddress ) ;
104101 return Transaction . fromTxData ( {
105102 nonce : nonce ,
106103 data : data ,
107- to : this . testnet ? ADDRESSES . eth . testnet . depositContract : ADDRESSES . eth . mainnet . depositContract ,
108- value : this . web3 . utils . numberToHex ( this . web3 . utils . toWei ( amountEth . toString ( ) , 'ether' ) ) ,
109- gasPrice : this . web3 . utils . numberToHex ( gasPrice ) ,
110- gasLimit : this . web3 . utils . numberToHex ( 100000 ) ,
104+ to : walletAddress ,
105+ value : this . web3 . utils . numberToHex ( 0 ) ,
106+ gasPrice : this . web3 . utils . numberToHex ( gasWei ) ,
107+ gasLimit : this . web3 . utils . numberToHex ( gasWei ) ,
111108 } , { common } ) ;
112109 } catch ( err : any ) {
113110 throw new Error ( err ) ;
@@ -174,6 +171,23 @@ export class EthService extends Service {
174171 }
175172 }
176173
174+ /**
175+ * Get transaction status
176+ * @param transactionHash: transaction hash
177+ */
178+ async getTxStatus ( transactionHash : string ) : Promise < EthTxStatus > {
179+ try {
180+ const receipt = await this . web3 . eth . getTransactionReceipt ( transactionHash ) ;
181+ const status = receipt ? receipt . status ? 'success' : 'error' : 'pending_confirmation' ;
182+ return {
183+ status : status ,
184+ txReceipt : receipt ,
185+ } ;
186+ } catch ( e : any ) {
187+ throw new GetTxStatusError ( e ) ;
188+ }
189+ }
190+
177191 /**
178192 * Retrieve stakes of given kiln accounts
179193 * @param accountIds: account ids of which you wish to retrieve rewards
0 commit comments