fix: TxApproval prices a site's ETH send from its exact amount on its own network (closes #614)
TxApproval worked out the USD value of a site's ETH send from the
four-decimal figure it shows, at the price on the active network, so the
same value read a few cents different than on ConfirmTx, and a
transaction on another network was priced at the active one's rate, its
network fee too. It now prices the exact value with getPrice("ETH",
chainId) for the transaction's chain id, as ConfirmTx does, and passes
that chain id to formatFee() for the fee.
getPrice() now returns null for a chain id that names no network instead
of throwing, so such a transaction is still shown, with no USD value.
Model: opus-5-5
This commit was merged in pull request #635.
This commit is contained in:
@@ -38,11 +38,12 @@ function clearPrices() {
|
||||
}
|
||||
|
||||
// Return the USD price for a symbol on the network with `chainId`, or on the
|
||||
// active network when no chain id is given; null on testnet / unknown.
|
||||
// active network when no chain id is given; null on testnet, on a chain id
|
||||
// that names no network, or for a symbol with no price.
|
||||
function getPrice(symbol, chainId) {
|
||||
const { currentNetwork } = require("./state");
|
||||
const network = chainId ? networkByChainId(chainId) : currentNetwork();
|
||||
if (network.isTestnet) return null;
|
||||
if (!network || network.isTestnet) return null;
|
||||
return prices[symbol] || null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user