forked from TrueCloudLab/neoneo-go
cli: use AddressFlag for nep17 import
This commit is contained in:
parent
92c6708fa0
commit
ced90e0510
2 changed files with 13 additions and 6 deletions
cli
|
@ -200,6 +200,12 @@ func TestNEP17ImportToken(t *testing.T) {
|
|||
gasContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas)
|
||||
require.NoError(t, err)
|
||||
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
|
||||
|
||||
// missing token hash
|
||||
e.RunWithError(t, "neo-go", "wallet", "nep17", "import",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath)
|
||||
|
||||
e.Run(t, "neo-go", "wallet", "nep17", "import",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath,
|
||||
|
@ -207,7 +213,7 @@ func TestNEP17ImportToken(t *testing.T) {
|
|||
e.Run(t, "neo-go", "wallet", "nep17", "import",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--wallet", walletPath,
|
||||
"--token", neoContractHash.StringLE())
|
||||
"--token", address.Uint160ToString(neoContractHash)) // try address instead of sh
|
||||
|
||||
t.Run("Info", func(t *testing.T) {
|
||||
checkGASInfo := func(t *testing.T) {
|
||||
|
|
|
@ -40,9 +40,9 @@ func newNEP17Commands() []cli.Command {
|
|||
balanceFlags = append(balanceFlags, options.RPC...)
|
||||
importFlags := []cli.Flag{
|
||||
walletPathFlag,
|
||||
cli.StringFlag{
|
||||
flags.AddressFlag{
|
||||
Name: "token",
|
||||
Usage: "Token contract hash in LE",
|
||||
Usage: "Token contract address or hash in LE",
|
||||
},
|
||||
}
|
||||
importFlags = append(importFlags, options.RPC...)
|
||||
|
@ -257,10 +257,11 @@ func importNEP17Token(ctx *cli.Context) error {
|
|||
}
|
||||
defer wall.Close()
|
||||
|
||||
tokenHash, err := flags.ParseAddress(ctx.String("token"))
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("invalid token contract hash: %w", err), 1)
|
||||
tokenHashFlag := ctx.Generic("token").(*flags.Address)
|
||||
if !tokenHashFlag.IsSet {
|
||||
return cli.NewExitError("token contract hash was not set", 1)
|
||||
}
|
||||
tokenHash := tokenHashFlag.Uint160()
|
||||
|
||||
for _, t := range wall.Extra.Tokens {
|
||||
if t.Hash.Equals(tokenHash) {
|
||||
|
|
Loading…
Reference in a new issue