fix: the confirmation screen reads its balance on the network it is drawn for (closes #558)
ConfirmTx showed and checked the balance Send handed it, so a screen the popup reopened onto stated the balance as Send knew it, not as it is on the network the screen is drawn for. Each time it is shown, ConfirmTx now reads the From address's ETH balance, and for a token send its token balance, from the node reviewedNetworkProvider() picks for the network the transaction was reviewed for, the node the fee estimate and recipient checks ask. The fee estimate starts once the read returns. Until then the balance line says "Loading..." and Sign & Send stays disabled; a failed read is stated as unknown. Each message the read can bring has a box reserved from the first paint, so nothing moves when it returns. Model: opus-5-5
This commit was merged in pull request #569.
This commit is contained in:
@@ -1743,37 +1743,46 @@ view would leave a wallet one click from deletion.
|
||||
arrives, as the balance minus the reserve, and the transaction is signed
|
||||
with that estimate's fee fields, so a fee fetched again at signing cannot
|
||||
exceed what the amount leaves behind. The address keeps whatever part of
|
||||
the reserve the transaction does not use. If the balance no longer covers
|
||||
the fee, the amount is left as it was and the amount-plus-fee error below
|
||||
blocks the send
|
||||
- Your balance: value + symbol (USD in parentheses), or `unknown (SYMBOL)`
|
||||
for a token whose scale is unknown
|
||||
the reserve the transaction does not use. If the balance could not be read
|
||||
or no longer covers the fee, the amount is left as it was and one of the
|
||||
errors below blocks the send
|
||||
- Your balance: the From address's balance on the network its transaction
|
||||
was reviewed on, read from that network's RPC endpoint each time the
|
||||
screen is shown, so a screen the popup reopens onto states and checks that
|
||||
network's balance as it is then, whichever network is active. "Loading..."
|
||||
until the read returns, then value + symbol (USD in parentheses), or
|
||||
`unknown (SYMBOL)` for a token whose scale is unknown or when the read
|
||||
failed. The amount check uses the same balances: the ETH balance, and for
|
||||
a token transfer the token balance as well
|
||||
- Network fee: "Estimating..." then two lines, or "Unable to estimate",
|
||||
fetched async. The first line is what the transfer is expected to cost,
|
||||
`gasLimit * gasPrice` (USD in parentheses); the second is the
|
||||
`gasLimit * maxFeePerGas` reserve the node requires, which is what the
|
||||
balance check gates on. The second line is omitted on a network with no
|
||||
type-2 pricing, where the two are the same number, but its space is
|
||||
reserved either way
|
||||
fetched async once the balance is read. The first line is what the
|
||||
transfer is expected to cost, `gasLimit * gasPrice` (USD in parentheses);
|
||||
the second is the `gasLimit * maxFeePerGas` reserve the node requires,
|
||||
which is what the balance check gates on. The second line is omitted on a
|
||||
network with no type-2 pricing, where the two are the same number, but its
|
||||
space is reserved either way
|
||||
- Warnings: inline warnings from the local checks (scam address, self-send)
|
||||
plus four reserved warning boxes made visible by the async checks —
|
||||
recipient that has never sent a transaction and holds no ETH, recipient is
|
||||
a contract, burn address, and an Etherscan phishing/scam label. An address
|
||||
that has received ETH but never sent a transaction still holds that ETH,
|
||||
so it gets no warning
|
||||
- Errors (insufficient balance), plus three reserved error boxes — the
|
||||
amount plus the fee exceeds the balance (ETH transfers), not enough ETH to
|
||||
pay the fee for the transfer (ERC-20 transfers), and the fee could not be
|
||||
estimated. The first two are mutually exclusive per transfer type, so only
|
||||
the applicable one holds space. The last names its cause: for a token
|
||||
whose scale is unknown the fee can never be estimated, and it says the
|
||||
wallet does not know how many decimal places the token uses and that the
|
||||
transaction cannot be sent; for any other failure it asks the user to go
|
||||
back and try again
|
||||
- Errors (an invalid amount), plus five reserved error boxes, so the balance
|
||||
and the fee arriving later move nothing — the amount exceeds the balance
|
||||
(for a token whose scale is unknown it says the token's balance is
|
||||
unknown), the balance could not be read (it asks the user to go back and
|
||||
try again), the amount plus the fee exceeds the balance (ETH transfers),
|
||||
not enough ETH to pay the fee for the transfer (ERC-20 transfers), and the
|
||||
fee could not be estimated. The third and fourth are mutually exclusive
|
||||
per transfer type, so only the applicable one holds space. The last names
|
||||
its cause: for a token whose scale is unknown the fee can never be
|
||||
estimated, and it says the wallet does not know how many decimal places
|
||||
the token uses and that the transaction cannot be sent; for any other
|
||||
failure it asks the user to go back and try again
|
||||
- Password: an inline field on this screen, not a modal, with its own error
|
||||
line
|
||||
- "Sign & Send" button (disabled if errors, and while the network fee
|
||||
estimate is pending or unavailable)
|
||||
- "Sign & Send" button (disabled if errors, while the balance is being read,
|
||||
and while the network fee estimate is pending or unavailable)
|
||||
- **Transitions**:
|
||||
- "Sign & Send" (correct password) → broadcast tx → **WaitTx**
|
||||
- "Sign & Send" (correct password) → broadcast fails → **ErrorTx**
|
||||
@@ -1795,9 +1804,9 @@ view would leave a wallet one click from deletion.
|
||||
whichever network is active: its amounts are in that network's native
|
||||
currency, its USD values are that network's, so a testnet transaction
|
||||
shows none, its From, To and token contract links open that network's
|
||||
explorer, the fee estimate and the contract and never-sent recipient
|
||||
checks ask that network's RPC endpoint, and the Etherscan label check asks
|
||||
that network's explorer
|
||||
explorer, the balance read, the fee estimate and the contract and
|
||||
never-sent recipient checks ask that network's RPC endpoint, and the
|
||||
Etherscan label check asks that network's explorer
|
||||
- "Sign & Send" (wrong password) → "Wrong password." on the password error
|
||||
line, no screen change
|
||||
- "Sign & Send" signs as the From address above, not as whichever address is
|
||||
|
||||
Reference in New Issue
Block a user