diff --git a/cli/nep17_test.go b/cli/nep17_test.go index fbabec187..35c60e253 100644 --- a/cli/nep17_test.go +++ b/cli/nep17_test.go @@ -9,6 +9,7 @@ import ( "strings" "testing" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/wallet" @@ -28,7 +29,7 @@ func TestNEP17Balance(t *testing.T) { b, index := e.Chain.GetGoverningTokenBalance(validatorHash) checkResult := func(t *testing.T) { e.checkNextLine(t, "^\\s*Account\\s+"+validatorAddr) - e.checkNextLine(t, "^\\s*NEO:\\s+NEO \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") + e.checkNextLine(t, "^\\s*NEO:\\s+NeoToken \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+b.String()) e.checkNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10)) e.checkEOF(t) @@ -45,7 +46,7 @@ func TestNEP17Balance(t *testing.T) { t.Run("GAS", func(t *testing.T) { e.Run(t, append(cmd, "--token", "GAS")...) e.checkNextLine(t, "^\\s*Account\\s+"+validatorAddr) - e.checkNextLine(t, "^\\s*GAS:\\s+GAS \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") + e.checkNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") b := e.Chain.GetUtilityTokenBalance(validatorHash) e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(b.Int64()).String()) }) @@ -54,7 +55,7 @@ func TestNEP17Balance(t *testing.T) { addr1, err := address.StringToUint160("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc") require.NoError(t, err) e.checkNextLine(t, "^Account "+address.Uint160ToString(addr1)) - e.checkNextLine(t, "^\\s*GAS:\\s+GAS \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") + e.checkNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") balance := e.Chain.GetUtilityTokenBalance(addr1) e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()) e.checkNextLine(t, "^\\s*Updated:") @@ -72,13 +73,13 @@ func TestNEP17Balance(t *testing.T) { for i := 0; i < 2; i++ { line := e.getNextLine(t) if strings.Contains(line, "GAS") { - e.checkLine(t, line, "^\\s*GAS:\\s+GAS \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") + e.checkLine(t, line, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") balance = e.Chain.GetUtilityTokenBalance(addr3) e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()) e.checkNextLine(t, "^\\s*Updated:") } else { balance, index := e.Chain.GetGoverningTokenBalance(validatorHash) - e.checkLine(t, line, "^\\s*NEO:\\s+NEO \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") + e.checkLine(t, line, "^\\s*NEO:\\s+NeoToken \\("+e.Chain.GoverningTokenHash().StringLE()+"\\)") e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+balance.String()) e.checkNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10)) } @@ -137,7 +138,7 @@ func TestNEP17MultiTransfer(t *testing.T) { e := newExecutor(t, true) defer e.Close(t) - neoContractHash, err := e.Chain.GetNativeContractScriptHash("neo") + neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo) require.NoError(t, err) args := []string{ "neo-go", "wallet", "nep17", "multitransfer", @@ -169,9 +170,9 @@ func TestNEP17ImportToken(t *testing.T) { walletPath := path.Join(tmpDir, "walletForImport.json") defer os.Remove(walletPath) - neoContractHash, err := e.Chain.GetNativeContractScriptHash("neo") + neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo) require.NoError(t, err) - gasContractHash, err := e.Chain.GetNativeContractScriptHash("gas") + gasContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas) require.NoError(t, err) e.Run(t, "neo-go", "wallet", "init", "--wallet", walletPath) e.Run(t, "neo-go", "wallet", "nep17", "import", @@ -185,7 +186,7 @@ func TestNEP17ImportToken(t *testing.T) { t.Run("Info", func(t *testing.T) { checkGASInfo := func(t *testing.T) { - e.checkNextLine(t, "^Name:\\s*GAS") + e.checkNextLine(t, "^Name:\\s*GasToken") e.checkNextLine(t, "^Symbol:\\s*GAS") e.checkNextLine(t, "^Hash:\\s*"+gasContractHash.StringLE()) e.checkNextLine(t, "^Decimals:\\s*8") @@ -202,7 +203,7 @@ func TestNEP17ImportToken(t *testing.T) { checkGASInfo(t) _, err := e.Out.ReadString('\n') require.NoError(t, err) - e.checkNextLine(t, "^Name:\\s*NEO") + e.checkNextLine(t, "^Name:\\s*NeoToken") e.checkNextLine(t, "^Symbol:\\s*NEO") e.checkNextLine(t, "^Hash:\\s*"+neoContractHash.StringLE()) e.checkNextLine(t, "^Decimals:\\s*0") diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index b9ccc3032..bb130466c 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -16,6 +16,7 @@ import ( "github.com/nspcc-dev/neo-go/cli/options" "github.com/nspcc-dev/neo-go/cli/paramcontext" "github.com/nspcc-dev/neo-go/pkg/compiler" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/encoding/address" @@ -771,7 +772,7 @@ func contractDeploy(ctx *cli.Context) error { return err } - mgmtHash, err := c.GetNativeContractHash("Neo Contract Management") + mgmtHash, err := c.GetNativeContractHash(nativenames.Management) if err != nil { return cli.NewExitError(fmt.Errorf("failed to get management contract's hash: %w", err), 1) } diff --git a/cli/testdata/chain50x2.acc b/cli/testdata/chain50x2.acc index a9e5a8104..c8f6d3982 100644 Binary files a/cli/testdata/chain50x2.acc and b/cli/testdata/chain50x2.acc differ diff --git a/cli/wallet/validator.go b/cli/wallet/validator.go index 3efd6c4ec..3d8a337a0 100644 --- a/cli/wallet/validator.go +++ b/cli/wallet/validator.go @@ -6,6 +6,7 @@ import ( "github.com/nspcc-dev/neo-go/cli/flags" "github.com/nspcc-dev/neo-go/cli/input" "github.com/nspcc-dev/neo-go/cli/options" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" @@ -99,7 +100,7 @@ func handleCandidate(ctx *cli.Context, method string) error { } gas := flags.Fixed8FromContext(ctx, "gas") - neoContractHash, err := c.GetNativeContractHash("neo") + neoContractHash, err := c.GetNativeContractHash(nativenames.Neo) if err != nil { return err } @@ -161,7 +162,7 @@ func handleVote(ctx *cli.Context) error { } gas := flags.Fixed8FromContext(ctx, "gas") - neoContractHash, err := c.GetNativeContractHash("neo") + neoContractHash, err := c.GetNativeContractHash(nativenames.Neo) if err != nil { return cli.NewExitError(err, 1) } diff --git a/cli/wallet/wallet.go b/cli/wallet/wallet.go index 31ce122d4..5b593f678 100644 --- a/cli/wallet/wallet.go +++ b/cli/wallet/wallet.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neo-go/cli/flags" "github.com/nspcc-dev/neo-go/cli/input" "github.com/nspcc-dev/neo-go/cli/options" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" @@ -233,7 +234,7 @@ func claimGas(ctx *cli.Context) error { return cli.NewExitError(err, 1) } - neoContractHash, err := c.GetNativeContractHash("neo") + neoContractHash, err := c.GetNativeContractHash(nativenames.Neo) if err != nil { return cli.NewExitError(err, 1) } diff --git a/pkg/core/native/designate.go b/pkg/core/native/designate.go index d57864266..57c726cfa 100644 --- a/pkg/core/native/designate.go +++ b/pkg/core/native/designate.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop/runtime" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" @@ -40,7 +41,6 @@ type oraclesData struct { const ( designateContractID = -5 - designateName = "Designation" // maxNodeCount is the maximum number of nodes to set the role for. maxNodeCount = 32 @@ -71,7 +71,7 @@ func (s *Designate) isValidRole(r Role) bool { } func newDesignate(p2pSigExtensionsEnabled bool) *Designate { - s := &Designate{ContractMD: *interop.NewContractMD(designateName)} + s := &Designate{ContractMD: *interop.NewContractMD(nativenames.Designation)} s.ContractID = designateContractID s.p2pSigExtensionsEnabled = p2pSigExtensionsEnabled diff --git a/pkg/core/native/management.go b/pkg/core/native/management.go index e4afa20f4..04631c5e8 100644 --- a/pkg/core/native/management.go +++ b/pkg/core/native/management.go @@ -10,6 +10,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop/contract" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/encoding/bigint" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -29,7 +30,6 @@ type Management struct { const StoragePrice = 100000 const ( - managementName = "Neo Contract Management" prefixContract = 8 ) @@ -43,7 +43,7 @@ func makeContractKey(h util.Uint160) []byte { // newManagement creates new Management native contract. func newManagement() *Management { - var m = &Management{ContractMD: *interop.NewContractMD(managementName)} + var m = &Management{ContractMD: *interop.NewContractMD(nativenames.Management)} desc := newDescriptor("getContract", smartcontract.ArrayType, manifest.NewParameter("hash", smartcontract.Hash160Type)) diff --git a/pkg/core/native/native_gas.go b/pkg/core/native/native_gas.go index 28714bf62..8883f3ada 100644 --- a/pkg/core/native/native_gas.go +++ b/pkg/core/native/native_gas.go @@ -5,6 +5,7 @@ import ( "math/big" "github.com/nspcc-dev/neo-go/pkg/core/interop" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -17,7 +18,6 @@ type GAS struct { NEO *NEO } -const gasName = "GAS" const gasContractID = -2 // GASFactor is a divisor for finding GAS integral value. @@ -27,7 +27,7 @@ const initialGAS = 30000000 // newGAS returns GAS native contract. func newGAS() *GAS { g := &GAS{} - nep17 := newNEP17Native(gasName) + nep17 := newNEP17Native(nativenames.Gas) nep17.symbol = "GAS" nep17.decimals = 8 nep17.factor = GASFactor diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index 77d31f225..ed5ce11da 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -14,6 +14,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop/runtime" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" @@ -49,7 +50,6 @@ type NEO struct { } const ( - neoName = "NEO" neoContractID = -1 // NEOTotalSupply is the total amount of NEO in the system. NEOTotalSupply = 100000000 @@ -93,7 +93,7 @@ func makeValidatorKey(key *keys.PublicKey) []byte { // newNEO returns NEO native contract. func newNEO() *NEO { n := &NEO{} - nep17 := newNEP17Native(neoName) + nep17 := newNEP17Native(nativenames.Neo) nep17.symbol = "NEO" nep17.decimals = 0 nep17.factor = 1 diff --git a/pkg/core/native/nativenames/names.go b/pkg/core/native/nativenames/names.go new file mode 100644 index 000000000..301f5e17d --- /dev/null +++ b/pkg/core/native/nativenames/names.go @@ -0,0 +1,12 @@ +package nativenames + +// Names of all native contracts. +const ( + Management = "ManagementContract" + Neo = "NeoToken" + Gas = "GasToken" + Policy = "PolicyContract" + Oracle = "OracleContract" + Designation = "DesignationContract" + Notary = "Notary" +) diff --git a/pkg/core/native/notary.go b/pkg/core/native/notary.go index 3fecfe7ef..5ac5a393f 100644 --- a/pkg/core/native/notary.go +++ b/pkg/core/native/notary.go @@ -11,6 +11,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop/contract" "github.com/nspcc-dev/neo-go/pkg/core/interop/runtime" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/core/transaction" @@ -37,7 +38,6 @@ type Notary struct { } const ( - notaryName = "Notary" notaryContractID = reservedContractID - 1 // NotaryVerificationPrice is the price of `verify` Notary method. NotaryVerificationPrice = 100_0000 @@ -52,7 +52,7 @@ var maxNotValidBeforeDeltaKey = []byte{10} // newNotary returns Notary native contract. func newNotary() *Notary { - n := &Notary{ContractMD: *interop.NewContractMD(notaryName)} + n := &Notary{ContractMD: *interop.NewContractMD(nativenames.Notary)} n.ContractID = notaryContractID desc := newDescriptor("onPayment", smartcontract.VoidType, diff --git a/pkg/core/native/oracle.go b/pkg/core/native/oracle.go index 162fa9ca9..49b23ada7 100644 --- a/pkg/core/native/oracle.go +++ b/pkg/core/native/oracle.go @@ -11,6 +11,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop/contract" "github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/core/transaction" @@ -36,11 +37,7 @@ type Oracle struct { } const ( - oracleContractID = -4 - oracleName = "Oracle" -) - -const ( + oracleContractID = -4 maxURLLength = 256 maxFilterLength = 128 maxCallbackLength = 32 @@ -58,7 +55,7 @@ var ( func init() { w := io.NewBufBinWriter() - emit.String(w.BinWriter, oracleName) + emit.String(w.BinWriter, nativenames.Oracle) emit.Syscall(w.BinWriter, interopnames.SystemContractCallNative) oracleInvokeScript = w.Bytes() h := hash.Hash160(oracleInvokeScript) @@ -102,7 +99,7 @@ func GetOracleResponseScript() []byte { } func newOracle() *Oracle { - o := &Oracle{ContractMD: *interop.NewContractMD(oracleName)} + o := &Oracle{ContractMD: *interop.NewContractMD(nativenames.Oracle)} o.ContractID = oracleContractID desc := newDescriptor("request", smartcontract.VoidType, diff --git a/pkg/core/native/policy.go b/pkg/core/native/policy.go index 2dc80b5fb..33d5f14a9 100644 --- a/pkg/core/native/policy.go +++ b/pkg/core/native/policy.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/interop" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/network/payload" @@ -19,7 +20,6 @@ import ( ) const ( - policyName = "Policy" policyContractID = -3 defaultMaxBlockSize = 1024 * 256 @@ -69,7 +69,7 @@ var _ interop.Contract = (*Policy)(nil) // newPolicy returns Policy native contract. func newPolicy() *Policy { - p := &Policy{ContractMD: *interop.NewContractMD(policyName)} + p := &Policy{ContractMD: *interop.NewContractMD(nativenames.Policy)} p.ContractID = policyContractID diff --git a/pkg/rpc/client/client.go b/pkg/rpc/client/client.go index 904b0dff4..bccd0d4a5 100644 --- a/pkg/rpc/client/client.go +++ b/pkg/rpc/client/client.go @@ -12,6 +12,7 @@ import ( "time" "github.com/nspcc-dev/neo-go/pkg/config/netmode" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/util" @@ -117,21 +118,21 @@ func (c *Client) Init() error { } c.network = version.Magic c.stateRootInHeader = version.StateRootInHeader - neoContractHash, err := c.GetContractStateByAddressOrName("neo") + neoContractHash, err := c.GetContractStateByAddressOrName(nativenames.Neo) if err != nil { return fmt.Errorf("failed to get NEO contract scripthash: %w", err) } - c.cache.nativeHashes["neo"] = neoContractHash.Hash - gasContractHash, err := c.GetContractStateByAddressOrName("gas") + c.cache.nativeHashes[nativenames.Neo] = neoContractHash.Hash + gasContractHash, err := c.GetContractStateByAddressOrName(nativenames.Gas) if err != nil { return fmt.Errorf("failed to get GAS contract scripthash: %w", err) } - c.cache.nativeHashes["gas"] = gasContractHash.Hash - policyContractHash, err := c.GetContractStateByAddressOrName("policy") + c.cache.nativeHashes[nativenames.Gas] = gasContractHash.Hash + policyContractHash, err := c.GetContractStateByAddressOrName(nativenames.Policy) if err != nil { return fmt.Errorf("failed to get Policy contract scripthash: %w", err) } - c.cache.nativeHashes["policy"] = policyContractHash.Hash + c.cache.nativeHashes[nativenames.Policy] = policyContractHash.Hash c.initDone = true return nil } diff --git a/pkg/rpc/client/policy.go b/pkg/rpc/client/policy.go index 38fafd97b..6c89baf68 100644 --- a/pkg/rpc/client/policy.go +++ b/pkg/rpc/client/policy.go @@ -3,6 +3,7 @@ package client import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" @@ -28,7 +29,7 @@ func (c *Client) invokeNativePolicyMethod(operation string) (int64, error) { if !c.initDone { return 0, errNetworkNotInitialized } - result, err := c.InvokeFunction(c.cache.nativeHashes["policy"], operation, []smartcontract.Parameter{}, nil) + result, err := c.InvokeFunction(c.cache.nativeHashes[nativenames.Policy], operation, []smartcontract.Parameter{}, nil) if err != nil { return 0, err } @@ -45,7 +46,7 @@ func (c *Client) IsBlocked(hash util.Uint160) (bool, error) { if !c.initDone { return false, errNetworkNotInitialized } - result, err := c.InvokeFunction(c.cache.nativeHashes["policy"], "isBlocked", []smartcontract.Parameter{{ + result, err := c.InvokeFunction(c.cache.nativeHashes[nativenames.Policy], "isBlocked", []smartcontract.Parameter{{ Type: smartcontract.Hash160Type, Value: hash, }}, nil) diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index 65da7f66f..3f4b59c6d 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -4,7 +4,6 @@ import ( "encoding/hex" "errors" "fmt" - "strings" "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/core" @@ -612,10 +611,9 @@ func (c *Client) StateRootInHeader() bool { return c.stateRootInHeader } -// GetNativeContractHash returns native contract hash by its name. It is not case-sensitive. +// GetNativeContractHash returns native contract hash by its name. func (c *Client) GetNativeContractHash(name string) (util.Uint160, error) { - lowercasedName := strings.ToLower(name) - hash, ok := c.cache.nativeHashes[lowercasedName] + hash, ok := c.cache.nativeHashes[name] if ok { return hash, nil } @@ -623,6 +621,6 @@ func (c *Client) GetNativeContractHash(name string) (util.Uint160, error) { if err != nil { return util.Uint160{}, err } - c.cache.nativeHashes[lowercasedName] = cs.Hash + c.cache.nativeHashes[name] = cs.Hash return cs.Hash, nil } diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index a73e1db72..589dfec16 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -1463,11 +1463,11 @@ func wrapInitResponse(r *request.In, resp string) string { response = resp } switch name { - case "neo": + case "NeoToken": response = `{"id":1,"jsonrpc":"2.0","result":{"id":-1,"script":"DANORU9Ba2d4Cw==","manifest":{"name":"NEO","abi":{"hash":"0xde5f57d430d3dece511cf975a8d37848cb9e0525","methods":[{"name":"name","offset":0,"parameters":null,"returntype":"String"},{"name":"symbol","offset":0,"parameters":null,"returntype":"String"},{"name":"decimals","offset":0,"parameters":null,"returntype":"Integer"},{"name":"totalSupply","offset":0,"parameters":null,"returntype":"Integer"},{"name":"balanceOf","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Integer"},{"name":"transfer","offset":0,"parameters":[{"name":"from","type":"Hash160"},{"name":"to","type":"Hash160"},{"name":"amount","type":"Integer"}],"returntype":"Boolean"},{"name":"onPersist","offset":0,"parameters":null,"returntype":"Void"},{"name":"postPersist","offset":0,"parameters":null,"returntype":"Void"},{"name":"unclaimedGas","offset":0,"parameters":[{"name":"account","type":"Hash160"},{"name":"end","type":"Integer"}],"returntype":"Integer"},{"name":"registerCandidate","offset":0,"parameters":[{"name":"pubkey","type":"PublicKey"}],"returntype":"Boolean"},{"name":"unregisterCandidate","offset":0,"parameters":[{"name":"pubkey","type":"PublicKey"}],"returntype":"Boolean"},{"name":"vote","offset":0,"parameters":[{"name":"account","type":"Hash160"},{"name":"pubkey","type":"PublicKey"}],"returntype":"Boolean"},{"name":"getCandidates","offset":0,"parameters":null,"returntype":"Array"},{"name":"getŠ”ommittee","offset":0,"parameters":null,"returntype":"Array"},{"name":"getNextBlockValidators","offset":0,"parameters":null,"returntype":"Array"},{"name":"getGasPerBlock","offset":0,"parameters":null,"returntype":"Integer"},{"name":"setGasPerBlock","offset":0,"parameters":[{"name":"gasPerBlock","type":"Integer"}],"returntype":"Boolean"}],"events":[{"name":"Transfer","parameters":null}]},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":["NEP-5"],"trusts":[],"safemethods":["name","symbol","decimals","totalSupply","balanceOf","unclaimedGas","getCandidates","getŠ”ommittee","getNextBlockValidators"],"extra":null},"hash":"0xde5f57d430d3dece511cf975a8d37848cb9e0525"}}` - case "gas": + case "GasToken": response = `{"id":1,"jsonrpc":"2.0","result":{"id":-2,"script":"DANHQVNBa2d4Cw==","manifest":{"name":"GAS","abi":{"hash":"0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","methods":[{"name":"name","offset":0,"parameters":null,"returntype":"String"},{"name":"symbol","offset":0,"parameters":null,"returntype":"String"},{"name":"decimals","offset":0,"parameters":null,"returntype":"Integer"},{"name":"totalSupply","offset":0,"parameters":null,"returntype":"Integer"},{"name":"balanceOf","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Integer"},{"name":"transfer","offset":0,"parameters":[{"name":"from","type":"Hash160"},{"name":"to","type":"Hash160"},{"name":"amount","type":"Integer"}],"returntype":"Boolean"},{"name":"onPersist","offset":0,"parameters":null,"returntype":"Void"},{"name":"postPersist","offset":0,"parameters":null,"returntype":"Void"}],"events":[{"name":"Transfer","parameters":null}]},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":["NEP-5"],"trusts":[],"safemethods":["name","symbol","decimals","totalSupply","balanceOf"],"extra":null},"hash":"0x668e0c1f9d7b70a99dd9e06eadd4c784d641afbc"}}` - case "policy": + case "PolicyContract": response = `{"id":1,"jsonrpc":"2.0","result":{"id":-3,"updatecounter":0,"hash":"0xac593e6183643940a9193f87c64ccf55ef19c529","script":"DAZQb2xpY3lBGvd7Zw==","manifest":{"name":"Policy","abi":{"methods":[{"name":"getMaxTransactionsPerBlock","offset":0,"parameters":null,"returntype":"Integer"},{"name":"getMaxBlockSize","offset":0,"parameters":null,"returntype":"Integer"},{"name":"getFeePerByte","offset":0,"parameters":null,"returntype":"Integer"},{"name":"isBlocked","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Boolean"},{"name":"getMaxBlockSystemFee","offset":0,"parameters":null,"returntype":"Integer"},{"name":"setMaxBlockSize","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"setMaxTransactionsPerBlock","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"setFeePerByte","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"setMaxBlockSystemFee","offset":0,"parameters":[{"name":"value","type":"Integer"}],"returntype":"Boolean"},{"name":"blockAccount","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Boolean"},{"name":"unblockAccount","offset":0,"parameters":[{"name":"account","type":"Hash160"}],"returntype":"Boolean"}],"events":[]},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"safemethods":["getMaxTransactionsPerBlock","getMaxBlockSize","getFeePerByte","isBlocked","getMaxBlockSystemFee"],"extra":null}}}` default: response = resp diff --git a/pkg/rpc/server/client_test.go b/pkg/rpc/server/client_test.go index 086fc4a98..500f2c3e6 100644 --- a/pkg/rpc/server/client_test.go +++ b/pkg/rpc/server/client_test.go @@ -7,6 +7,7 @@ import ( "github.com/nspcc-dev/neo-go/internal/testchain" "github.com/nspcc-dev/neo-go/pkg/core/fee" + "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" @@ -266,7 +267,7 @@ func TestCreateNEP17TransferTx(t *testing.T) { priv := testchain.PrivateKeyByID(0) acc := wallet.NewAccountFromPrivateKey(priv) - gasContractHash, err := c.GetNativeContractHash("gas") + gasContractHash, err := c.GetNativeContractHash(nativenames.Gas) require.NoError(t, err) tx, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0) diff --git a/pkg/rpc/server/server_test.go b/pkg/rpc/server/server_test.go index 3d812813f..030a96e22 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/rpc/server/server_test.go @@ -57,7 +57,7 @@ type rpcTestCase struct { } const testContractHash = "743ed26f78e29ecd595535b74a943b1f9ccbc444" -const deploymentTxHash = "7e60be17078d05135c359805beece3ea4c5140f55adec8170179713f2124eb14" +const deploymentTxHash = "37644146394ad76ddb9431d10b724a3cad5f8b249abdaed0b086fcd761756951" const genesisBlockHash = "0542f4350c6e236d0509bcd98188b0034bfbecc1a0c7fcdb8e4295310d468b70" const verifyContractHash = "a2eb22340979804cb10cc1add0b8822c201f4d8a" @@ -170,7 +170,7 @@ var rpcTestCases = map[string][]rpcTestCase{ }, { name: "positive, native by name", - params: `["Policy"]`, + params: `["PolicyContract"]`, result: func(e *executor) interface{} { return &state.Contract{} }, check: func(t *testing.T, e *executor, cs interface{}) { res, ok := cs.(*state.Contract) diff --git a/pkg/rpc/server/testdata/testblocks.acc b/pkg/rpc/server/testdata/testblocks.acc index f7b74765d..3cbc31749 100644 Binary files a/pkg/rpc/server/testdata/testblocks.acc and b/pkg/rpc/server/testdata/testblocks.acc differ