From 17663a0f267618475b921e0e2c92b772001fe05a Mon Sep 17 00:00:00 2001 From: Vladyslav Budichenko Date: Mon, 4 Nov 2024 17:57:56 -0500 Subject: [PATCH] wip: update e2e test for debugging --- ethereum/eip712/eip712.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ethereum/eip712/eip712.go b/ethereum/eip712/eip712.go index b210639860..25a8d7c403 100644 --- a/ethereum/eip712/eip712.go +++ b/ethereum/eip712/eip712.go @@ -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") @@ -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) } @@ -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 } @@ -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 }