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