Skip to content

Commit

Permalink
Fixed JsonRpcProvider for pre-EIP-2930 chains (#1766).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 30, 2021
1 parent be3854e commit 7274cd0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/providers/src.ts/json-rpc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,24 @@ export class JsonRpcProvider extends BaseProvider {
}

async perform(method: string, params: any): Promise<any> {
// Legacy networks do not like the type field being passed along (which
// is fair), so we delete type if it is 0 and a non-EIP-1559 network
if (method === "call" || method === "estimateGas") {
const tx = params.transaction;
if (tx && tx.type != null && BigNumber.from(tx.type).isZero()) {
// If there are no EIP-1559 properties, it might be non-EIP-a559
if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) {
const feeData = await this.getFeeData();
if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) {
// Network doesn't know about EIP-1559 (and hence type)
params = shallowCopy(params);
params.transaction = shallowCopy(tx);
delete params.transaction.type;
}
}
}
}

const args = this.prepareRequest(method, params);

if (args == null) {
Expand Down

0 comments on commit 7274cd0

Please sign in to comment.