planetmint-go/x/machine/client/cli/tx_attest_machine.go
Julian Strobl d4eed021c8
[go.mod] Switch module to github.com (#86)
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>
2023-09-21 17:37:57 +02:00

48 lines
1.0 KiB
Go

package cli
import (
"strconv"
"encoding/json"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/planetmint/planetmint-go/x/machine/types"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdAttestMachine() *cobra.Command {
cmd := &cobra.Command{
Use: "attest-machine [machine]",
Short: "Broadcast message attest-machine",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argMachine := new(types.Machine)
err = json.Unmarshal([]byte(args[0]), argMachine)
if err != nil {
return err
}
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
msg := types.NewMsgAttestMachine(
clientCtx.GetFromAddress().String(),
argMachine,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}