Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
askolesov committed Mar 18, 2022
1 parent dfa4807 commit 7a0a398
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions x/cheqd/keeper/msg_server_update_did.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func (k msgServer) UpdateDid(goCtx context.Context, msg *types.MsgUpdateDid) (*t
updatedDid := msg.Payload.ToDid()
updatedDid.ReplaceIds(updatedDid.Id, updatedDid.Id+UpdatedPostfix)

updatedMetadata := existingStateValue.Metadata
updatedMetadata := *existingStateValue.Metadata
updatedMetadata.Update(ctx)

updatedStateValue, err := types.NewStateValue(&updatedDid, updatedMetadata)
updatedStateValue, err := types.NewStateValue(&updatedDid, &updatedMetadata)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -98,7 +98,7 @@ func (k msgServer) UpdateDid(goCtx context.Context, msg *types.MsgUpdateDid) (*t

// Apply changes: return original id and modify state
updatedDid.ReplaceIds(updatedDid.Id, existingDid.Id)
err = k.SetDid(&ctx, &updatedDid, updatedMetadata)
err = k.SetDid(&ctx, &updatedDid, &updatedMetadata)
if err != nil {
return nil, types.ErrInternal.Wrapf(err.Error())
}
Expand Down
6 changes: 0 additions & 6 deletions x/cheqd/utils/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

multibase "github.com/multiformats/go-multibase"
"github.com/tendermint/tendermint/types"
)

func ValidateMultibase(data string) error {
Expand All @@ -29,8 +28,3 @@ func ValidateMultibaseEncoding(data string, expectedEncoding multibase.Encoding)
func ValidateBase58(data string) error {
return ValidateMultibaseEncoding(string(multibase.Base58BTC)+data, multibase.Base58BTC)
}

func GetTxHash(txBytes []byte) string {
//return base64.StdEncoding.EncodeToString(tmhash.Sum(txBytes))
return fmt.Sprintf("%X", types.Tx(txBytes).Hash())
}
11 changes: 11 additions & 0 deletions x/cheqd/utils/tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package utils

import (
"fmt"
"github.com/tendermint/tendermint/types"
)

func GetTxHash(txBytes []byte) string {
//return base64.StdEncoding.EncodeToString(tmhash.Sum(txBytes))
return fmt.Sprintf("%X", types.Tx(txBytes).Hash())
}

0 comments on commit 7a0a398

Please sign in to comment.