forked from TrueCloudLab/neoneo-go
rpc: check token standard in nepTokenInfo
This commit is contained in:
parent
40ae78cb88
commit
c3264c065d
2 changed files with 14 additions and 2 deletions
|
@ -280,7 +280,7 @@ func TestNEP17ImportToken(t *testing.T) {
|
||||||
e.checkNextLine(t, "^Hash:\\s*"+gasContractHash.StringLE())
|
e.checkNextLine(t, "^Hash:\\s*"+gasContractHash.StringLE())
|
||||||
e.checkNextLine(t, "^Decimals:\\s*8")
|
e.checkNextLine(t, "^Decimals:\\s*8")
|
||||||
e.checkNextLine(t, "^Address:\\s*"+address.Uint160ToString(gasContractHash))
|
e.checkNextLine(t, "^Address:\\s*"+address.Uint160ToString(gasContractHash))
|
||||||
e.checkNextLine(t, "^Standard:\\s*"+manifest.NEP17StandardName)
|
e.checkNextLine(t, "^Standard:\\s*"+string(manifest.NEP17StandardName))
|
||||||
}
|
}
|
||||||
t.Run("WithToken", func(t *testing.T) {
|
t.Run("WithToken", func(t *testing.T) {
|
||||||
e.Run(t, "neo-go", "wallet", "nep17", "info",
|
e.Run(t, "neo-go", "wallet", "nep17", "info",
|
||||||
|
@ -298,7 +298,7 @@ func TestNEP17ImportToken(t *testing.T) {
|
||||||
e.checkNextLine(t, "^Hash:\\s*"+neoContractHash.StringLE())
|
e.checkNextLine(t, "^Hash:\\s*"+neoContractHash.StringLE())
|
||||||
e.checkNextLine(t, "^Decimals:\\s*0")
|
e.checkNextLine(t, "^Decimals:\\s*0")
|
||||||
e.checkNextLine(t, "^Address:\\s*"+address.Uint160ToString(neoContractHash))
|
e.checkNextLine(t, "^Address:\\s*"+address.Uint160ToString(neoContractHash))
|
||||||
e.checkNextLine(t, "^Standard:\\s*"+manifest.NEP17StandardName)
|
e.checkNextLine(t, "^Standard:\\s*"+string(manifest.NEP17StandardName))
|
||||||
})
|
})
|
||||||
t.Run("Remove", func(t *testing.T) {
|
t.Run("Remove", func(t *testing.T) {
|
||||||
e.In.WriteString("y\r")
|
e.In.WriteString("y\r")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
@ -78,6 +80,16 @@ func (c *Client) nepTokenInfo(tokenHash util.Uint160, standard string) (*wallet.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var isStandardOK bool
|
||||||
|
for _, st := range cs.Manifest.SupportedStandards {
|
||||||
|
if st == standard {
|
||||||
|
isStandardOK = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !isStandardOK {
|
||||||
|
return nil, fmt.Errorf("token %s does not support %s standard", tokenHash.StringLE(), standard)
|
||||||
|
}
|
||||||
symbol, err := c.nepSymbol(tokenHash)
|
symbol, err := c.nepSymbol(tokenHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue