Use case-insensitive matching for JSON-RPC error strings.

This commit is contained in:
Richard Moore 2022-12-30 16:27:46 -05:00
parent 426c1e1b05
commit 65c7df1ee8

@ -890,26 +890,25 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
}); });
} }
if (method === "eth_sendRawTransaction" || method === "eth_sendTransaction") { if (method === "eth_sendRawTransaction" || method === "eth_sendTransaction") {
const transaction = <TransactionLike<string>>((<any>payload).params[0]); const transaction = <TransactionLike<string>>((<any>payload).params[0]);
if (message.match(/insufficient funds|base fee exceeds gas limit/)) { if (message.match(/insufficient funds|base fee exceeds gas limit/i)) {
return makeError("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", { return makeError("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", {
transaction transaction
}); });
} }
if (message.match(/nonce/) && message.match(/too low/)) { if (message.match(/nonce/i) && message.match(/too low/i)) {
return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction }); return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction });
} }
// "replacement transaction underpriced" // "replacement transaction underpriced"
if (message.match(/replacement transaction/) && message.match(/underpriced/)) { if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) {
return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction }); return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction });
} }
if (message.match(/only replay-protected/)) { if (message.match(/only replay-protected/i)) {
return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", { return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", {
operation: method, info: { transaction } operation: method, info: { transaction }
}); });