@@ -15,6 +15,8 @@ import {
1515 WalletConnectProvider ,
1616 WalletConnectInterface ,
1717 SwitchableChain ,
18+ EvmTransactionParams ,
19+ EthereumTxParams ,
1820} from "../../__types__" ;
1921import type { WalletConnectClient } from "./client" ;
2022import type { SessionTypes } from "@walletconnect/types" ;
@@ -320,20 +322,52 @@ export class WalletConnectWallet implements WalletConnectInterface {
320322 address ,
321323 ] ) ) as string ;
322324 case SignIntent . SignAndSendTransaction :
323- const account = provider . connectedAddresses [ 0 ] ;
325+ const account = provider . connectedAddresses [ 0 ] as Hex ;
326+ if ( ! account ) throw new Error ( "no connected address" ) ;
324327 const tx = Transaction . from ( payload ) ;
325- const txParams = {
328+
329+ const base : EvmTransactionParams = {
326330 from : account ,
327331 to : tx . to ?. toString ( ) as Hex ,
328332 value : toHex ( tx . value ) ,
329333 gas : toHex ( tx . gasLimit ) ,
330- maxFeePerGas : toHex ( tx . maxFeePerGas ?? 0n ) ,
331- maxPriorityFeePerGas : toHex ( tx . maxPriorityFeePerGas ?? 0n ) ,
332334 nonce : toHex ( tx . nonce ) ,
333335 chainId : toHex ( tx . chainId ) ,
334336 data : ( tx . data ?. toString ( ) as Hex ) ?? "0x" ,
335337 } ;
336338
339+ // Some libs use undefined for legacy, so normalize
340+ const txType = ( tx as any ) . type ?? 0 ;
341+
342+ let txParams : EthereumTxParams ;
343+
344+ if ( txType === undefined || txType === 0 || txType === 1 ) {
345+ // legacy or EIP-2930 (gasPrice-based)
346+ if ( tx . gasPrice == null ) {
347+ throw new Error (
348+ "Legacy or EIP-2930 transaction missing gasPrice" ,
349+ ) ;
350+ }
351+
352+ txParams = {
353+ ...base ,
354+ gasPrice : toHex ( tx . gasPrice ) ,
355+ } ;
356+ } else {
357+ // EIP-1559 or future fee-market types
358+ if ( tx . maxFeePerGas == null || tx . maxPriorityFeePerGas == null ) {
359+ throw new Error (
360+ "EIP-1559-style transaction missing maxFeePerGas or maxPriorityFeePerGas" ,
361+ ) ;
362+ }
363+
364+ txParams = {
365+ ...base ,
366+ maxFeePerGas : toHex ( tx . maxFeePerGas ) ,
367+ maxPriorityFeePerGas : toHex ( tx . maxPriorityFeePerGas ) ,
368+ } ;
369+ }
370+
337371 return ( await this . client . request (
338372 this . ethChain ,
339373 "eth_sendTransaction" ,
0 commit comments