-
Notifications
You must be signed in to change notification settings - Fork 1
/
fabric.go
66 lines (55 loc) · 1.4 KB
/
fabric.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package cmd
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/datachainlab/fabric-besu-cross-demo/cmds/erc20/config"
"github.com/datachainlab/fabric-besu-cross-demo/contracts/erc20/erc20mgr/types"
"github.com/spf13/cobra"
)
func fabricCmd(ctx *config.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "fabric",
Short: "Fabric subcommands",
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(
clientIDFabricCmd(ctx),
idFabricCmd(ctx),
)
return cmd
}
func clientIDFabricCmd(ctx *config.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "clientId",
Short: "Get client id",
RunE: func(cmd *cobra.Command, args []string) error {
clientID, err := clientIDFromWallet(homePath, ctx.Config.WalletLabel)
if err != nil {
return err
}
fmt.Println(clientID)
return nil
},
}
return cmd
}
func idFabricCmd(ctx *config.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "id",
Short: "Get id in contract module",
RunE: func(cmd *cobra.Command, args []string) error {
clientID, err := clientIDFromWallet(homePath, ctx.Config.WalletLabel)
if err != nil {
return err
}
id, err := types.NewID(types.MSPID(ctx.Config.WalletLabel), types.ClientID(clientID))
if err != nil {
return err
}
fmt.Println(id)
return nil
},
}
return cmd
}