File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
packages/providers/src.ts Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -526,6 +526,24 @@ export class JsonRpcProvider extends BaseProvider {
526526 }
527527
528528 async perform ( method : string , params : any ) : Promise < any > {
529+ // Legacy networks do not like the type field being passed along (which
530+ // is fair), so we delete type if it is 0 and a non-EIP-1559 network
531+ if ( method === "call" || method === "estimateGas" ) {
532+ const tx = params . transaction ;
533+ if ( tx && tx . type != null && BigNumber . from ( tx . type ) . isZero ( ) ) {
534+ // If there are no EIP-1559 properties, it might be non-EIP-a559
535+ if ( tx . maxFeePerGas == null && tx . maxPriorityFeePerGas == null ) {
536+ const feeData = await this . getFeeData ( ) ;
537+ if ( feeData . maxFeePerGas == null && feeData . maxPriorityFeePerGas == null ) {
538+ // Network doesn't know about EIP-1559 (and hence type)
539+ params = shallowCopy ( params ) ;
540+ params . transaction = shallowCopy ( tx ) ;
541+ delete params . transaction . type ;
542+ }
543+ }
544+ }
545+ }
546+
529547 const args = this . prepareRequest ( method , params ) ;
530548
531549 if ( args == null ) {
You can’t perform that action at this time.
0 commit comments