mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00

* added upper and lower case TA resolution testing * added more detailed error reporting to the ValidateSignature method. * extended test cases to test and verify these errs and their differences * fixed CID attestation issue. CIDs are send in web compatible encoding that is not hex encoded and can be utilized without any further decoding on the server side. * added checks and error handling for the Ta store object storage/loading Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
40 lines
885 B
Go
40 lines
885 B
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"planetmint-go/util"
|
|
"planetmint-go/x/asset/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
func (k msgServer) NotarizeAsset(goCtx context.Context, msg *types.MsgNotarizeAsset) (*types.MsgNotarizeAssetResponse, error) {
|
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
|
|
_, found := k.machineKeeper.GetMachineIndex(ctx, msg.PubKey)
|
|
|
|
if !found {
|
|
return nil, errors.New("machine not found")
|
|
}
|
|
hex_pub_key, err := util.GetHexPubKey(msg.PubKey)
|
|
if err != nil {
|
|
return nil, errors.New("could not convert xpub key to hex pub key")
|
|
}
|
|
valid, err := util.ValidateSignatureByteMsg([]byte(msg.Hash), msg.Signature, hex_pub_key)
|
|
if !valid {
|
|
return nil, err
|
|
}
|
|
|
|
var asset = types.Asset{
|
|
Hash: msg.Hash,
|
|
Signature: msg.Signature,
|
|
Pubkey: msg.PubKey,
|
|
}
|
|
|
|
k.StoreAsset(ctx, asset)
|
|
|
|
return &types.MsgNotarizeAssetResponse{}, nil
|
|
}
|