@@ -303,12 +303,9 @@ func verifySignature(pubKey *ecdsa.PublicKey, hash, sig []byte) bool {
303303}
304304
305305// SignerFn returns a `bind.SignerFn` compatible function for use with go-ethereum contract bindings.
306- // It captures the chain ID to produce EIP-155 compatible signatures.
306+ // It captures the chain ID to produce EIP-155 and EIP-1559 compatible signatures.
307307func (s * KMSSigner ) SignerFn (chainID * big.Int ) bind.SignerFn {
308308 if chainID == nil || chainID .Sign () <= 0 {
309- // Use a default or handle error? EIP-155 requires a positive chainID.
310- // For now, let's return an error or panic, as non-EIP155 is insecure.
311- // Panic might be better to catch configuration errors early.
312309 panic ("SignerFn requires a valid positive chainID for EIP-155" )
313310 }
314311
@@ -317,12 +314,20 @@ func (s *KMSSigner) SignerFn(chainID *big.Int) bind.SignerFn {
317314 return nil , fmt .Errorf ("attempted to sign transaction with incorrect address: expected %s, got %s" , s .Address ().Hex (), addr .Hex ())
318315 }
319316
320- // EIP-155 signer requires the chain ID
321- eip155Signer := types .NewEIP155Signer (chainID )
322- txHash := eip155Signer .Hash (tx )
317+ // Use the appropriate signer based on transaction type
318+ var signer types.Signer
319+ switch tx .Type () {
320+ case types .DynamicFeeTxType :
321+ signer = types .NewLondonSigner (chainID )
322+ case types .AccessListTxType :
323+ signer = types .NewEIP2930Signer (chainID )
324+ default :
325+ signer = types .NewEIP155Signer (chainID )
326+ }
327+
328+ txHash := signer .Hash (tx )
323329
324330 // Sign the hash using KMS
325- // Use context.Background or pass one down if needed for cancellation/deadlines
326331 signature , err := s .Sign (context .Background (), txHash [:])
327332 if err != nil {
328333 return nil , fmt .Errorf ("failed to sign transaction hash with KMS: %w" , err )
@@ -348,7 +353,7 @@ func (s *KMSSigner) SignerFn(chainID *big.Int) bind.SignerFn {
348353 }
349354
350355 // Add the signature to the transaction
351- signedTx , err := tx .WithSignature (eip155Signer , signature )
356+ signedTx , err := tx .WithSignature (signer , signature )
352357 if err != nil {
353358 return nil , fmt .Errorf ("failed to add KMS signature to transaction: %w" , err )
354359 }
0 commit comments