fix stack and storage

This commit is contained in:
Sina Mahmoodi 2025-02-28 15:14:34 +01:00
parent c111269745
commit ed90dfb61a
1 changed files with 3 additions and 3 deletions

View File

@ -167,7 +167,7 @@ func (s *StructLog) toLegacyJSON() json.RawMessage {
Error: s.ErrorString(),
RefundCounter: s.RefundCounter,
}
if s.Stack != nil {
if len(s.Stack) > 0 {
stack := make([]string, len(s.Stack))
for i, stackValue := range s.Stack {
stack[i] = stackValue.Hex()
@ -177,14 +177,14 @@ func (s *StructLog) toLegacyJSON() json.RawMessage {
if len(s.ReturnData) > 0 {
msg.ReturnData = hexutil.Bytes(s.ReturnData).String()
}
if s.Memory != nil && len(s.Memory) > 0 {
if len(s.Memory) > 0 {
memory := make([]string, 0, (len(s.Memory)+31)/32)
for i := 0; i+32 <= len(s.Memory); i += 32 {
memory = append(memory, fmt.Sprintf("%x", s.Memory[i:i+32]))
}
msg.Memory = &memory
}
if s.Storage != nil {
if len(s.Storage) > 0 {
storage := make(map[string]string)
for i, storageValue := range s.Storage {
storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)