Skip to content

Commit

Permalink
*: replace all NEP5 occurences to NEP17
Browse files Browse the repository at this point in the history
  • Loading branch information
fyrchik committed Nov 24, 2020
1 parent b97dfae commit 31eca34
Show file tree
Hide file tree
Showing 33 changed files with 335 additions and 335 deletions.
2 changes: 1 addition & 1 deletion cli/candidate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestRegisterCandidate(t *testing.T) {
defer e.Close(t)

e.In.WriteString("one\r")
e.Run(t, "neo-go", "wallet", "nep5", "multitransfer",
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", validatorWallet,
"--from", validatorAddr,
Expand Down
4 changes: 2 additions & 2 deletions cli/multisig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestSignMultisigTx(t *testing.T) {

// Transfer funds to the multisig.
e.In.WriteString("one\r")
e.Run(t, "neo-go", "wallet", "nep5", "multitransfer",
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", validatorWallet,
"--from", validatorAddr,
Expand All @@ -66,7 +66,7 @@ func TestSignMultisigTx(t *testing.T) {
txPath := path.Join(tmpDir, "multisigtx.json")
defer os.Remove(txPath)
e.In.WriteString("pass\r")
e.Run(t, "neo-go", "wallet", "nep5", "transfer",
e.Run(t, "neo-go", "wallet", "nep17", "transfer",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", wallet1Path, "--from", multisigAddr,
"--to", priv.Address(), "--token", "neo", "--amount", "1",
Expand Down
26 changes: 13 additions & 13 deletions cli/nep5_test.go → cli/nep17_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"github.com/stretchr/testify/require"
)

func TestNEP5Balance(t *testing.T) {
func TestNEP17Balance(t *testing.T) {
e := newExecutor(t, true)
defer e.Close(t)
cmdbalance := []string{"neo-go", "wallet", "nep5", "balance"}
cmdbalance := []string{"neo-go", "wallet", "nep17", "balance"}
cmdbase := append(cmdbalance,
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", validatorWallet,
Expand Down Expand Up @@ -99,15 +99,15 @@ func TestNEP5Balance(t *testing.T) {
return
}

func TestNEP5Transfer(t *testing.T) {
func TestNEP17Transfer(t *testing.T) {
w, err := wallet.NewWalletFromFile("testdata/testwallet.json")
require.NoError(t, err)
defer w.Close()

e := newExecutor(t, true)
defer e.Close(t)
args := []string{
"neo-go", "wallet", "nep5", "transfer",
"neo-go", "wallet", "nep17", "transfer",
"--rpc-endpoint", "http://" + e.RPC.Addr,
"--wallet", validatorWallet,
"--from", validatorAddr,
Expand All @@ -132,15 +132,15 @@ func TestNEP5Transfer(t *testing.T) {
require.Equal(t, big.NewInt(1), b)
}

func TestNEP5MultiTransfer(t *testing.T) {
func TestNEP17MultiTransfer(t *testing.T) {
privs, _ := generateKeys(t, 3)

e := newExecutor(t, true)
defer e.Close(t)
neoContractHash, err := e.Chain.GetNativeContractScriptHash("neo")
require.NoError(t, err)
args := []string{
"neo-go", "wallet", "nep5", "multitransfer",
"neo-go", "wallet", "nep17", "multitransfer",
"--rpc-endpoint", "http://" + e.RPC.Addr,
"--wallet", validatorWallet,
"--from", validatorAddr,
Expand All @@ -161,7 +161,7 @@ func TestNEP5MultiTransfer(t *testing.T) {
require.Equal(t, big.NewInt(13), b)
}

func TestNEP5ImportToken(t *testing.T) {
func TestNEP17ImportToken(t *testing.T) {
e := newExecutor(t, true)
defer e.Close(t)

Expand All @@ -174,11 +174,11 @@ func TestNEP5ImportToken(t *testing.T) {
gasContractHash, err := e.Chain.GetNativeContractScriptHash("gas")
require.NoError(t, err)
e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath)
e.Run(t, "neo-go", "wallet", "nep5", "import",
e.Run(t, "neo-go", "wallet", "nep17", "import",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", walletPath,
"--token", gasContractHash.StringLE())
e.Run(t, "neo-go", "wallet", "nep5", "import",
e.Run(t, "neo-go", "wallet", "nep17", "import",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", walletPath,
"--token", neoContractHash.StringLE())
Expand All @@ -192,12 +192,12 @@ func TestNEP5ImportToken(t *testing.T) {
e.checkNextLine(t, "^Address:\\s*"+address.Uint160ToString(gasContractHash))
}
t.Run("WithToken", func(t *testing.T) {
e.Run(t, "neo-go", "wallet", "nep5", "info",
e.Run(t, "neo-go", "wallet", "nep17", "info",
"--wallet", walletPath, "--token", gasContractHash.StringLE())
checkGASInfo(t)
})
t.Run("NoToken", func(t *testing.T) {
e.Run(t, "neo-go", "wallet", "nep5", "info",
e.Run(t, "neo-go", "wallet", "nep17", "info",
"--wallet", walletPath)
checkGASInfo(t)
_, err := e.Out.ReadString('\n')
Expand All @@ -210,9 +210,9 @@ func TestNEP5ImportToken(t *testing.T) {
})
t.Run("Remove", func(t *testing.T) {
e.In.WriteString("y\r")
e.Run(t, "neo-go", "wallet", "nep5", "remove",
e.Run(t, "neo-go", "wallet", "nep17", "remove",
"--wallet", walletPath, "--token", neoContractHash.StringLE())
e.Run(t, "neo-go", "wallet", "nep5", "info",
e.Run(t, "neo-go", "wallet", "nep17", "info",
"--wallet", walletPath)
checkGASInfo(t)
_, err := e.Out.ReadString('\n')
Expand Down
48 changes: 24 additions & 24 deletions cli/wallet/nep5.go → cli/wallet/nep17.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
}
)

func newNEP5Commands() []cli.Command {
func newNEP17Commands() []cli.Command {
balanceFlags := []cli.Flag{
walletPathFlag,
tokenFlag,
Expand Down Expand Up @@ -69,21 +69,21 @@ func newNEP5Commands() []cli.Command {
Name: "balance",
Usage: "get address balance",
UsageText: "balance --wallet <path> --rpc-endpoint <node> [--timeout <time>] [--address <address>] [--token <hash-or-name>]",
Action: getNEP5Balance,
Action: getNEP17Balance,
Flags: balanceFlags,
},
{
Name: "import",
Usage: "import NEP5 token to a wallet",
Usage: "import NEP17 token to a wallet",
UsageText: "import --wallet <path> --rpc-endpoint <node> --timeout <time> --token <hash>",
Action: importNEP5Token,
Action: importNEP17Token,
Flags: importFlags,
},
{
Name: "info",
Usage: "print imported NEP5 token info",
Usage: "print imported NEP17 token info",
UsageText: "print --wallet <path> [--token <hash-or-name>]",
Action: printNEP5Info,
Action: printNEP17Info,
Flags: []cli.Flag{
walletPathFlag,
cli.StringFlag{
Expand All @@ -94,9 +94,9 @@ func newNEP5Commands() []cli.Command {
},
{
Name: "remove",
Usage: "remove NEP5 token from the wallet",
Usage: "remove NEP17 token from the wallet",
UsageText: "remove --wallet <path> --token <hash-or-name>",
Action: removeNEP5Token,
Action: removeNEP17Token,
Flags: []cli.Flag{
walletPathFlag,
cli.StringFlag{
Expand All @@ -108,23 +108,23 @@ func newNEP5Commands() []cli.Command {
},
{
Name: "transfer",
Usage: "transfer NEP5 tokens",
Usage: "transfer NEP17 tokens",
UsageText: "transfer --wallet <path> --rpc-endpoint <node> --timeout <time> --from <addr> --to <addr> --token <hash> --amount string",
Action: transferNEP5,
Action: transferNEP17,
Flags: transferFlags,
},
{
Name: "multitransfer",
Usage: "transfer NEP5 tokens to multiple recipients",
Usage: "transfer NEP17 tokens to multiple recipients",
UsageText: `multitransfer --wallet <path> --rpc-endpoint <node> --timeout <time> --from <addr>` +
` <token1>:<addr1>:<amount1> [<token2>:<addr2>:<amount2> [...]]`,
Action: multiTransferNEP5,
Action: multiTransferNEP17,
Flags: multiTransferFlags,
},
}
}

func getNEP5Balance(ctx *cli.Context) error {
func getNEP17Balance(ctx *cli.Context) error {
var accounts []*wallet.Account

wall, err := openWallet(ctx.String("wallet"))
Expand Down Expand Up @@ -170,7 +170,7 @@ func getNEP5Balance(ctx *cli.Context) error {
if err != nil {
return cli.NewExitError(fmt.Errorf("invalid account address: %w", err), 1)
}
balances, err := c.GetNEP5Balances(addrHash)
balances, err := c.GetNEP17Balances(addrHash)
if err != nil {
return cli.NewExitError(err, 1)
}
Expand All @@ -186,7 +186,7 @@ func getNEP5Balance(ctx *cli.Context) error {
asset := balances.Balances[i].Asset
token, err := getMatchingToken(ctx, wall, asset.StringLE())
if err != nil {
token, err = c.NEP5TokenInfo(asset)
token, err = c.NEP17TokenInfo(asset)
}
if err == nil {
if name != "" && !(token.Name == name || token.Symbol == name || token.Address() == name || token.Hash.StringLE() == name) {
Expand Down Expand Up @@ -215,12 +215,12 @@ func getMatchingToken(ctx *cli.Context, w *wallet.Wallet, name string) (*wallet.
}

func getMatchingTokenRPC(ctx *cli.Context, c *client.Client, addr util.Uint160, name string) (*wallet.Token, error) {
bs, err := c.GetNEP5Balances(addr)
bs, err := c.GetNEP17Balances(addr)
if err != nil {
return nil, err
}
get := func(i int) *wallet.Token {
t, _ := c.NEP5TokenInfo(bs.Balances[i].Asset)
t, _ := c.NEP17TokenInfo(bs.Balances[i].Asset)
return t
}
return getMatchingTokenAux(ctx, get, len(bs.Balances), name)
Expand All @@ -247,7 +247,7 @@ func getMatchingTokenAux(ctx *cli.Context, get func(i int) *wallet.Token, n int,
return token, nil
}

func importNEP5Token(ctx *cli.Context) error {
func importNEP17Token(ctx *cli.Context) error {
wall, err := openWallet(ctx.String("wallet"))
if err != nil {
return cli.NewExitError(err, 1)
Expand All @@ -274,7 +274,7 @@ func importNEP5Token(ctx *cli.Context) error {
return cli.NewExitError(err, 1)
}

tok, err := c.NEP5TokenInfo(tokenHash)
tok, err := c.NEP17TokenInfo(tokenHash)
if err != nil {
return cli.NewExitError(fmt.Errorf("can't receive token info: %w", err), 1)
}
Expand All @@ -296,7 +296,7 @@ func printTokenInfo(ctx *cli.Context, tok *wallet.Token) {
fmt.Fprintf(w, "Address: %s\n", tok.Address())
}

func printNEP5Info(ctx *cli.Context) error {
func printNEP17Info(ctx *cli.Context) error {
wall, err := openWallet(ctx.String("wallet"))
if err != nil {
return cli.NewExitError(err, 1)
Expand All @@ -321,7 +321,7 @@ func printNEP5Info(ctx *cli.Context) error {
return nil
}

func removeNEP5Token(ctx *cli.Context) error {
func removeNEP17Token(ctx *cli.Context) error {
wall, err := openWallet(ctx.String("wallet"))
if err != nil {
return cli.NewExitError(err, 1)
Expand All @@ -345,7 +345,7 @@ func removeNEP5Token(ctx *cli.Context) error {
return nil
}

func multiTransferNEP5(ctx *cli.Context) error {
func multiTransferNEP17(ctx *cli.Context) error {
wall, err := openWallet(ctx.String("wallet"))
if err != nil {
return cli.NewExitError(err, 1)
Expand Down Expand Up @@ -412,7 +412,7 @@ func multiTransferNEP5(ctx *cli.Context) error {
return signAndSendTransfer(ctx, c, acc, recipients)
}

func transferNEP5(ctx *cli.Context) error {
func transferNEP17(ctx *cli.Context) error {
wall, err := openWallet(ctx.String("wallet"))
if err != nil {
return cli.NewExitError(err, 1)
Expand Down Expand Up @@ -464,7 +464,7 @@ func transferNEP5(ctx *cli.Context) error {
func signAndSendTransfer(ctx *cli.Context, c *client.Client, acc *wallet.Account, recipients []client.TransferTarget) error {
gas := flags.Fixed8FromContext(ctx, "gas")

tx, err := c.CreateNEP5MultiTransferTx(acc, int64(gas), recipients...)
tx, err := c.CreateNEP17MultiTransferTx(acc, int64(gas), recipients...)
if err != nil {
return cli.NewExitError(err, 1)
}
Expand Down
8 changes: 4 additions & 4 deletions cli/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func NewCommands() []cli.Command {
Subcommands: newMultisigCommands(),
},
{
Name: "nep5",
Usage: "work with NEP5 contracts",
Subcommands: newNEP5Commands(),
Name: "nep17",
Usage: "work with NEP17 contracts",
Subcommands: newNEP17Commands(),
},
{
Name: "candidate",
Expand Down Expand Up @@ -237,7 +237,7 @@ func claimGas(ctx *cli.Context) error {
if err != nil {
return cli.NewExitError(err, 1)
}
hash, err := c.TransferNEP5(acc, scriptHash, neoContractHash, 0, 0)
hash, err := c.TransferNEP17(acc, scriptHash, neoContractHash, 0, 0)
if err != nil {
return cli.NewExitError(err, 1)
}
Expand Down
6 changes: 3 additions & 3 deletions cli/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func TestClaimGas(t *testing.T) {
defer w.Close()

args := []string{
"neo-go", "wallet", "nep5", "multitransfer",
"neo-go", "wallet", "nep17", "multitransfer",
"--rpc-endpoint", "http://" + e.RPC.Addr,
"--wallet", validatorWallet,
"--from", validatorAddr,
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestImportDeployed(t *testing.T) {

t.Run("Sign", func(t *testing.T) {
e.In.WriteString("one\r")
e.Run(t, "neo-go", "wallet", "nep5", "multitransfer",
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", validatorWallet, "--from", validatorAddr,
"neo:"+contractAddr+":10",
Expand All @@ -269,7 +269,7 @@ func TestImportDeployed(t *testing.T) {
require.NoError(t, err)

e.In.WriteString("pass\r")
e.Run(t, "neo-go", "wallet", "nep5", "transfer",
e.Run(t, "neo-go", "wallet", "nep17", "transfer",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--wallet", walletPath, "--from", contractAddr,
"--to", privTo.Address(), "--token", "neo", "--amount", "1")
Expand Down
12 changes: 6 additions & 6 deletions docs/rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ which would yield the response:
| `getblocksysfee` |
| `getconnectioncount` |
| `getcontractstate` |
| `getnep5balances` |
| `getnep5transfers` |
| `getnep17balances` |
| `getnep17transfers` |
| `getpeers` |
| `getrawmempool` |
| `getrawtransaction` |
Expand Down Expand Up @@ -108,9 +108,9 @@ and we're not accepting issues related to them.

Some additional extensions are implemented as a part of this RPC server.

#### Limits and paging for getnep5transfers
#### Limits and paging for getnep17transfers

`getnep5transfers` RPC call never returns more than 1000 results for one
`getnep17transfers` RPC call never returns more than 1000 results for one
request (within specified time frame). You can pass your own limit via an
additional parameter and then use paging to request the next batch of
transfers.
Expand All @@ -119,14 +119,14 @@ Example requesting 10 events for address NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc
within 0-1600094189 timestamps:

```json
{ "jsonrpc": "2.0", "id": 5, "method": "getnep5transfers", "params":
{ "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params":
["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189, 10] }
```

Get the next 10 transfers for the same account within the same time frame:

```json
{ "jsonrpc": "2.0", "id": 5, "method": "getnep5transfers", "params":
{ "jsonrpc": "2.0", "id": 5, "method": "getnep17transfers", "params":
["NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", 0, 1600094189, 10, 1] }
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nep5
package nep17

import (
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
Expand Down
Loading

0 comments on commit 31eca34

Please sign in to comment.