Added some provider-specific adjustments to deal with eip-1559 (#1610).

This commit is contained in:
Richard Moore 2021-06-25 22:58:55 -04:00
parent e95708eedc
commit 0364dd9368
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
2 changed files with 14 additions and 1 deletions

@ -86,6 +86,17 @@ export class AlchemyProvider extends UrlJsonRpcProvider {
};
}
async perform(method: string, params: any): Promise<any> {
if ((method === "estimateGas" && params.transaction.type === 2) || (method === "sendTransaction" && params.signedTransaction.substring(0, 4) === "0x02")) {
logger.throwError("AlchemyProvider does not currently support EIP-1559", Logger.errors.UNSUPPORTED_OPERATION, {
operation: method,
transaction: params.transaction
});
}
return super.perform(method, params);
}
isCommunityResource(): boolean {
return (this.apiKey === defaultApiKey);
}

@ -22,8 +22,10 @@ function getTransactionPostData(transaction: TransactionRequest): Record<string,
for (let key in transaction) {
if ((<any>transaction)[key] == null) { continue; }
let value = (<any>transaction)[key];
if (key === "type" && value === 0) { continue; }
// Quantity-types require no leading zero, unless 0
if ((<any>{ type: true, gasLimit: true, gasPrice: true, nonce: true, value: true })[key]) {
if ((<any>{ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true })[key]) {
value = hexValue(hexlify(value));
} else if (key === "accessList") {
value = "[" + accessListify(value).map((set) => {