Fixed AnkrProvider for REPLACEMENT_TRANSACTION.

This commit is contained in:
Richard Moore 2022-12-30 16:25:44 -05:00
parent 67675dfcbf
commit a5e906f51d

@ -9,6 +9,7 @@ import { JsonRpcProvider } from "./provider-jsonrpc.js";
import type { CommunityResourcable } from "./community.js";
import type { Networkish } from "./network.js";
import type { JsonRpcError, JsonRpcPayload } from "./provider-jsonrpc.js";
const defaultApiKey = "9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";
@ -74,6 +75,16 @@ export class AnkrProvider extends JsonRpcProvider implements CommunityResourcabl
return request;
}
getRpcError(payload: JsonRpcPayload, error: JsonRpcError): Error {
if (payload.method === "eth_sendRawTransaction") {
if (error && error.error && error.error.message === "INTERNAL_ERROR: could not replace existing tx") {
error.error.message = "replacement transaction underpriced";
}
}
return super.getRpcError(payload, error);
}
isCommunityResource(): boolean {
return (this.apiKey === defaultApiKey);
}