-
Notifications
You must be signed in to change notification settings - Fork 40
/
seturi_mini.go
43 lines (37 loc) · 1.11 KB
/
seturi_mini.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
package commands
import (
"github.com/bnb-chain/node/common/client"
"github.com/bnb-chain/node/common/types"
"github.com/bnb-chain/node/plugins/tokens/seturi"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func setTokenURICmd(cmdr Commander) *cobra.Command {
cmd := &cobra.Command{
Use: "set-uri-mini --symbol {symbol} --uri {token uri} --from {token issuer address}",
Short: "set token URI of mini-token",
RunE: cmdr.setTokenURI,
}
cmd.Flags().StringP(flagSymbol, "s", "", "symbol of the mini-token")
cmd.Flags().String(flagTokenUri, "", "uri of the token information")
return cmd
}
func (c Commander) setTokenURI(cmd *cobra.Command, args []string) error {
cliCtx, txBldr := client.PrepareCtx(c.Cdc)
from, err := cliCtx.GetFromAddress()
if err != nil {
return err
}
symbol := viper.GetString(flagSymbol)
err = types.ValidateMiniTokenSymbol(symbol)
if err != nil {
return err
}
tokenURI := viper.GetString(flagTokenUri)
err = validateTokenURI(tokenURI)
if err != nil {
return err
}
msg := seturi.NewSetUriMsg(from, symbol, tokenURI)
return client.SendOrPrintTx(cliCtx, txBldr, msg)
}