@@ -192,22 +192,19 @@ func ConvertCallMsgFromProto(protoMsg *CallMsg) (*evmtypes.CallMsg, error) {
192192 if protoMsg == nil {
193193 return nil , errEmptyMsg
194194 }
195- var from evmtypes.Address
196- if len (protoMsg .From ) != 0 {
197- if len (protoMsg .From ) != evmtypes .AddressLength {
198- return nil , fmt .Errorf ("invalid from address length: expected %d, got %d" , evmtypes .AddressLength , len (protoMsg .From ))
199- }
200-
201- from = evmtypes .Address (protoMsg .From )
195+ from , err := ConvertOptionalAddressFromProto (protoMsg .From )
196+ if err != nil {
197+ return nil , fmt .Errorf ("from address is invalid: %w" , err )
202198 }
203199
204- if len (protoMsg .To ) != evmtypes .AddressLength {
205- return nil , fmt .Errorf ("invalid to address length: expected %d, got %d" , evmtypes .AddressLength , len (protoMsg .To ))
200+ to , err := ConvertAddressFromProto (protoMsg .GetTo ())
201+ if err != nil {
202+ return nil , fmt .Errorf ("to address is invalid: %w" , err )
206203 }
207204 return & evmtypes.CallMsg {
208205 From : from ,
209206 Data : protoMsg .GetData (),
210- To : evmtypes . Address ( protoMsg . GetTo ()) ,
207+ To : to ,
211208 }, nil
212209}
213210
@@ -573,6 +570,14 @@ func ConvertAddressFromProto(b []byte) (evmtypes.Address, error) {
573570 return evmtypes .Address (b ), nil
574571}
575572
573+ func ConvertOptionalAddressFromProto (b []byte ) (evmtypes.Address , error ) {
574+ if len (b ) == 0 {
575+ return evmtypes.Address {}, nil // Return zero address if empty
576+ }
577+
578+ return ConvertAddressFromProto (b )
579+ }
580+
576581func ConvertHashFromProto (b []byte ) (evmtypes.Hash , error ) {
577582 if len (b ) != evmtypes .HashLength {
578583 return evmtypes.Hash {}, fmt .Errorf ("invalid hash length: expected %d, got %d" , evmtypes .HashLength , len (b ))
0 commit comments