Skip to content

Commit

Permalink
fix: estimate_gas interface with drip unit gas price. Resolves #36
Browse files Browse the repository at this point in the history
  • Loading branch information
darwintree committed Aug 27, 2024
1 parent 9ecb791 commit a3da4a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions conflux_web3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def estimate_gas_and_collateral_munger(
) -> Tuple[TxParam, Optional[EpochNumberParam]]:
if "from" not in transaction and self.default_account:
transaction = assoc(transaction, "from", self.default_account)
if 'value' in transaction:
transaction['value'] = to_int_if_drip_units(transaction['value'])
if 'gasPrice' in transaction:
transaction['gasPrice'] = to_int_if_drip_units(transaction['gasPrice'])

if block_identifier is None:
params = (transaction, self._default_block)
Expand Down
3 changes: 2 additions & 1 deletion tests/transaction/test_base_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def test_basetx_estimate(w3: Web3, address: Base32Address):
tx = {
"from": address,
"to": w3.account.create().address,
"value": 100
"value": 100,
"gasPrice": w3.cfx.gas_price
}

estimate = w3.cfx.estimate_gas_and_collateral(tx, w3.cfx.epoch_number-5)
Expand Down

0 comments on commit a3da4a3

Please sign in to comment.