Skip to content

Commit

Permalink
fix data race issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Mar 16, 2023
1 parent 2af4458 commit 6b68e49
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions x/auth/tx/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ import (
"github.com/gogo/protobuf/jsonpb"
)

var MsgCodec = jsonpb.Marshaler{
EmitDefaults: true,
OrigName: true,
}

var domain = apitypes.TypedDataDomain{
Name: "Greenfield Tx",
Version: "1.0.0",
Expand Down Expand Up @@ -164,8 +159,13 @@ func WrapTxToTypedData(
signDoc *types.SignDocEip712,
msgTypes apitypes.Types,
) (apitypes.TypedData, error) {
msgCodec := jsonpb.Marshaler{
EmitDefaults: true,
OrigName: true,
}
bz, err := msgCodec.MarshalToString(signDoc)

var txData map[string]interface{}
bz, err := MsgCodec.MarshalToString(signDoc)
if err != nil {
return apitypes.TypedData{}, errors.Wrap(err, "failed to JSON marshal data")
}
Expand All @@ -180,11 +180,13 @@ func WrapTxToTypedData(
// filling nil value
cleanTypesAndMsgValue(msgTypes, "Msg", txData["msg"].(map[string]interface{}))

domain.ChainId = math.NewHexOrDecimal256(int64(chainID))
var domainTemp apitypes.TypedDataDomain
domainTemp = domain
domainTemp.ChainId = math.NewHexOrDecimal256(int64(chainID))
typedData := apitypes.TypedData{
Types: msgTypes,
PrimaryType: "Tx",
Domain: domain,
Domain: domainTemp,
Message: txData,
}

Expand Down

0 comments on commit 6b68e49

Please sign in to comment.