implementation of eth_estimateGas
This commit is contained in:
parent
fef8237701
commit
7c6f0e472d
@ -418,6 +418,26 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn estimate_gas(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
from_params::<(TransactionRequest, BlockNumber)>(params)
|
||||||
|
.and_then(|(transaction_request, _block_number)| {
|
||||||
|
let accounts = take_weak!(self.accounts);
|
||||||
|
match accounts.account_secret(&transaction_request.from) {
|
||||||
|
Ok(secret) => {
|
||||||
|
let client = take_weak!(self.client);
|
||||||
|
|
||||||
|
let transaction: EthTransaction = transaction_request.into();
|
||||||
|
let signed_transaction = transaction.sign(&secret);
|
||||||
|
|
||||||
|
to_value(&client.call(&signed_transaction)
|
||||||
|
.map(|e| e.gas_used)
|
||||||
|
.unwrap_or(U256::zero()))
|
||||||
|
},
|
||||||
|
Err(_) => { to_value(&U256::zero()) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Eth filter rpc implementation.
|
/// Eth filter rpc implementation.
|
||||||
|
Loading…
Reference in New Issue
Block a user