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

This is the quasi-standard and fixes the error below: ``` $ go get -u github.com/planetmint/planetmint-go@v0.1.0 go: github.com/planetmint/planetmint-go@v0.1.0: parsing go.mod: module declares its path as: planetmint-go but was required as: github.com/planetmint/planetmint-go ``` Signed-off-by: Julian Strobl <jmastr@mailbox.org>
40 lines
929 B
Go
40 lines
929 B
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/planetmint/planetmint-go/util"
|
|
"github.com/planetmint/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
|
|
}
|