Skip to content

Commit

Permalink
wip: update e2e test for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Nov 4, 2024
1 parent bb02c25 commit 17663a0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ethereum/eip712/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func ConstructUntypedEIP712Data(

fmt.Println("ConstructUntypedEIP712Data inInterface", inInterface)

for _, msg := range msgs {
bz := legacytx.RegressionTestingAminoCodec.MustMarshalJSON(msg)
fmt.Println("ConstructUntypedEIP712Data bz for msg: ", msg)
fmt.Println("ConstructUntypedEIP712Data bz for msg: ", bz)
}

// remove msgs from the sign doc since we will be adding them as separate fields
delete(inInterface, "msgs")

Expand Down Expand Up @@ -116,11 +122,12 @@ func EncodeData(typedData apitypes.TypedData, primaryType string, data map[strin

// Add field contents. Structs and arrays have special handlers.
for _, field := range typedData.Types[primaryType] {
fmt.Println("field", field)
encType := field.Type
encValue := data[field.Name]
if encType[len(encType)-1:] == "]" {
arrayValue, ok := encValue.([]interface{})
fmt.Println("arrayValue", arrayValue, ok)
fmt.Println("arrayValue 1", arrayValue, ok)
if !ok {
return nil, dataMismatchError(encType, encValue)
}
Expand All @@ -130,18 +137,19 @@ func EncodeData(typedData apitypes.TypedData, primaryType string, data map[strin
for _, item := range arrayValue {
if typedData.Types[parsedType] != nil {
mapValue, ok := item.(map[string]interface{})
fmt.Println("mapValue", mapValue, ok)
fmt.Println("mapValue 1", mapValue, ok)
if !ok {
return nil, dataMismatchError(parsedType, item)
}
encodedData, err := typedData.EncodeData(parsedType, mapValue, depth+1)
fmt.Println("encodedData", encodedData, err)
fmt.Println("encodedData 1", encodedData, err)
if err != nil {
return nil, err
}
arrayBuffer.Write(crypto.Keccak256(encodedData))
} else {
bytesValue, err := typedData.EncodePrimitiveValue(parsedType, item, depth)
fmt.Println("bytesValue 1", bytesValue, err)
if err != nil {
return nil, err
}
Expand All @@ -152,16 +160,19 @@ func EncodeData(typedData apitypes.TypedData, primaryType string, data map[strin
buffer.Write(crypto.Keccak256(arrayBuffer.Bytes()))
} else if typedData.Types[field.Type] != nil {
mapValue, ok := encValue.(map[string]interface{})
fmt.Println("mapValue 2", mapValue, ok)
if !ok {
return nil, dataMismatchError(encType, encValue)
}
encodedData, err := typedData.EncodeData(field.Type, mapValue, depth+1)
fmt.Println("encodedData 2", encodedData, err)
if err != nil {
return nil, err
}
buffer.Write(crypto.Keccak256(encodedData))
} else {
byteValue, err := typedData.EncodePrimitiveValue(encType, encValue, depth)
fmt.Println("byteValue 2", byteValue, err)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 17663a0

Please sign in to comment.