go-livepeer
go-livepeer copied to clipboard
feat: show estimated tx cost in confirmation step
Summary
Implements #1815 - Add estimated transaction cost display and confirmation step before submitting on-chain transactions.
Changes
Server-side
- New
/estimateTxCostendpoint (server/handlers.go): AcceptstxTypequery param, returns estimated gas cost in ETH based on current gas price and typical gas limits per tx type - Registered route in
server/webserver.go
CLI-side
- New
confirmTx()helper (cmd/livepeer_cli/wizard.go): Queries/estimateTxCost, displays estimated cost, prompts user for y/N confirmation - Added confirmation to all transaction wizards:
bond,rebond,unbond,withdrawStake,withdrawFees(wizard_bond.go)initializeRound(wizard_rounds.go)activateOrchestrator(wizard_transcoder.go)fundDepositAndReserve,unlock,withdraw(wizard_ticketbroker.go)
ETH Client
- Added
EstimateTransferGasmethod toeth/client.gointerface
User Experience
⚠️ Transaction: Bond 100 tokens to 0x123...
💰 Estimated cost: 0.0015 ETH (gas limit: 150000, gas price: 10000000000 wei)
Do you want to proceed? [y/N]:
Closes #1815 Relates to #1783