mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
native: change contract names, move them to separate package
Follow neo-project/neo#2138 and make RPC client's GetNativeContractHash case-sensitive.
This commit is contained in:
parent
aff1469482
commit
cf8cf93e7a
20 changed files with 66 additions and 52 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"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/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
@ -28,7 +29,7 @@ func TestNEP17Balance(t *testing.T) {
|
||||||
b, index := e.Chain.GetGoverningTokenBalance(validatorHash)
|
b, index := e.Chain.GetGoverningTokenBalance(validatorHash)
|
||||||
checkResult := func(t *testing.T) {
|
checkResult := func(t *testing.T) {
|
||||||
e.checkNextLine(t, "^\\s*Account\\s+"+validatorAddr)
|
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*Amount\\s*:\\s*"+b.String())
|
||||||
e.checkNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10))
|
e.checkNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10))
|
||||||
e.checkEOF(t)
|
e.checkEOF(t)
|
||||||
|
@ -45,7 +46,7 @@ func TestNEP17Balance(t *testing.T) {
|
||||||
t.Run("GAS", func(t *testing.T) {
|
t.Run("GAS", func(t *testing.T) {
|
||||||
e.Run(t, append(cmd, "--token", "GAS")...)
|
e.Run(t, append(cmd, "--token", "GAS")...)
|
||||||
e.checkNextLine(t, "^\\s*Account\\s+"+validatorAddr)
|
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)
|
b := e.Chain.GetUtilityTokenBalance(validatorHash)
|
||||||
e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(b.Int64()).String())
|
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")
|
addr1, err := address.StringToUint160("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
e.checkNextLine(t, "^Account "+address.Uint160ToString(addr1))
|
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)
|
balance := e.Chain.GetUtilityTokenBalance(addr1)
|
||||||
e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String())
|
e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String())
|
||||||
e.checkNextLine(t, "^\\s*Updated:")
|
e.checkNextLine(t, "^\\s*Updated:")
|
||||||
|
@ -72,13 +73,13 @@ func TestNEP17Balance(t *testing.T) {
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
line := e.getNextLine(t)
|
line := e.getNextLine(t)
|
||||||
if strings.Contains(line, "GAS") {
|
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)
|
balance = e.Chain.GetUtilityTokenBalance(addr3)
|
||||||
e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String())
|
e.checkNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String())
|
||||||
e.checkNextLine(t, "^\\s*Updated:")
|
e.checkNextLine(t, "^\\s*Updated:")
|
||||||
} else {
|
} else {
|
||||||
balance, index := e.Chain.GetGoverningTokenBalance(validatorHash)
|
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*Amount\\s*:\\s*"+balance.String())
|
||||||
e.checkNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10))
|
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)
|
e := newExecutor(t, true)
|
||||||
defer e.Close(t)
|
defer e.Close(t)
|
||||||
neoContractHash, err := e.Chain.GetNativeContractScriptHash("neo")
|
neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
args := []string{
|
args := []string{
|
||||||
"neo-go", "wallet", "nep17", "multitransfer",
|
"neo-go", "wallet", "nep17", "multitransfer",
|
||||||
|
@ -169,9 +170,9 @@ func TestNEP17ImportToken(t *testing.T) {
|
||||||
walletPath := path.Join(tmpDir, "walletForImport.json")
|
walletPath := path.Join(tmpDir, "walletForImport.json")
|
||||||
defer os.Remove(walletPath)
|
defer os.Remove(walletPath)
|
||||||
|
|
||||||
neoContractHash, err := e.Chain.GetNativeContractScriptHash("neo")
|
neoContractHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Neo)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
gasContractHash, err := e.Chain.GetNativeContractScriptHash("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)
|
||||||
e.Run(t, "neo-go", "wallet", "nep17", "import",
|
e.Run(t, "neo-go", "wallet", "nep17", "import",
|
||||||
|
@ -185,7 +186,7 @@ func TestNEP17ImportToken(t *testing.T) {
|
||||||
|
|
||||||
t.Run("Info", func(t *testing.T) {
|
t.Run("Info", func(t *testing.T) {
|
||||||
checkGASInfo := 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, "^Symbol:\\s*GAS")
|
||||||
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")
|
||||||
|
@ -202,7 +203,7 @@ func TestNEP17ImportToken(t *testing.T) {
|
||||||
checkGASInfo(t)
|
checkGASInfo(t)
|
||||||
_, err := e.Out.ReadString('\n')
|
_, err := e.Out.ReadString('\n')
|
||||||
require.NoError(t, err)
|
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, "^Symbol:\\s*NEO")
|
||||||
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")
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/cli/options"
|
"github.com/nspcc-dev/neo-go/cli/options"
|
||||||
"github.com/nspcc-dev/neo-go/cli/paramcontext"
|
"github.com/nspcc-dev/neo-go/cli/paramcontext"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/compiler"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
@ -771,7 +772,7 @@ func contractDeploy(ctx *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmtHash, err := c.GetNativeContractHash("Neo Contract Management")
|
mgmtHash, err := c.GetNativeContractHash(nativenames.Management)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to get management contract's hash: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to get management contract's hash: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
|
BIN
cli/testdata/chain50x2.acc
vendored
BIN
cli/testdata/chain50x2.acc
vendored
Binary file not shown.
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||||
"github.com/nspcc-dev/neo-go/cli/input"
|
"github.com/nspcc-dev/neo-go/cli/input"
|
||||||
"github.com/nspcc-dev/neo-go/cli/options"
|
"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/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"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/encoding/address"
|
||||||
|
@ -99,7 +100,7 @@ func handleCandidate(ctx *cli.Context, method string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
gas := flags.Fixed8FromContext(ctx, "gas")
|
gas := flags.Fixed8FromContext(ctx, "gas")
|
||||||
neoContractHash, err := c.GetNativeContractHash("neo")
|
neoContractHash, err := c.GetNativeContractHash(nativenames.Neo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -161,7 +162,7 @@ func handleVote(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
gas := flags.Fixed8FromContext(ctx, "gas")
|
gas := flags.Fixed8FromContext(ctx, "gas")
|
||||||
neoContractHash, err := c.GetNativeContractHash("neo")
|
neoContractHash, err := c.GetNativeContractHash(nativenames.Neo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/cli/flags"
|
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||||
"github.com/nspcc-dev/neo-go/cli/input"
|
"github.com/nspcc-dev/neo-go/cli/input"
|
||||||
"github.com/nspcc-dev/neo-go/cli/options"
|
"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/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
|
@ -233,7 +234,7 @@ func claimGas(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
neoContractHash, err := c.GetNativeContractHash("neo")
|
neoContractHash, err := c.GetNativeContractHash(nativenames.Neo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -40,7 +41,6 @@ type oraclesData struct {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
designateContractID = -5
|
designateContractID = -5
|
||||||
designateName = "Designation"
|
|
||||||
|
|
||||||
// maxNodeCount is the maximum number of nodes to set the role for.
|
// maxNodeCount is the maximum number of nodes to set the role for.
|
||||||
maxNodeCount = 32
|
maxNodeCount = 32
|
||||||
|
@ -71,7 +71,7 @@ func (s *Designate) isValidRole(r Role) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDesignate(p2pSigExtensionsEnabled bool) *Designate {
|
func newDesignate(p2pSigExtensionsEnabled bool) *Designate {
|
||||||
s := &Designate{ContractMD: *interop.NewContractMD(designateName)}
|
s := &Designate{ContractMD: *interop.NewContractMD(nativenames.Designation)}
|
||||||
s.ContractID = designateContractID
|
s.ContractID = designateContractID
|
||||||
s.p2pSigExtensionsEnabled = p2pSigExtensionsEnabled
|
s.p2pSigExtensionsEnabled = p2pSigExtensionsEnabled
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/contract"
|
"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/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/bigint"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
|
@ -29,7 +30,6 @@ type Management struct {
|
||||||
const StoragePrice = 100000
|
const StoragePrice = 100000
|
||||||
|
|
||||||
const (
|
const (
|
||||||
managementName = "Neo Contract Management"
|
|
||||||
prefixContract = 8
|
prefixContract = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ func makeContractKey(h util.Uint160) []byte {
|
||||||
|
|
||||||
// newManagement creates new Management native contract.
|
// newManagement creates new Management native contract.
|
||||||
func newManagement() *Management {
|
func newManagement() *Management {
|
||||||
var m = &Management{ContractMD: *interop.NewContractMD(managementName)}
|
var m = &Management{ContractMD: *interop.NewContractMD(nativenames.Management)}
|
||||||
|
|
||||||
desc := newDescriptor("getContract", smartcontract.ArrayType,
|
desc := newDescriptor("getContract", smartcontract.ArrayType,
|
||||||
manifest.NewParameter("hash", smartcontract.Hash160Type))
|
manifest.NewParameter("hash", smartcontract.Hash160Type))
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
|
@ -17,7 +18,6 @@ type GAS struct {
|
||||||
NEO *NEO
|
NEO *NEO
|
||||||
}
|
}
|
||||||
|
|
||||||
const gasName = "GAS"
|
|
||||||
const gasContractID = -2
|
const gasContractID = -2
|
||||||
|
|
||||||
// GASFactor is a divisor for finding GAS integral value.
|
// GASFactor is a divisor for finding GAS integral value.
|
||||||
|
@ -27,7 +27,7 @@ const initialGAS = 30000000
|
||||||
// newGAS returns GAS native contract.
|
// newGAS returns GAS native contract.
|
||||||
func newGAS() *GAS {
|
func newGAS() *GAS {
|
||||||
g := &GAS{}
|
g := &GAS{}
|
||||||
nep17 := newNEP17Native(gasName)
|
nep17 := newNEP17Native(nativenames.Gas)
|
||||||
nep17.symbol = "GAS"
|
nep17.symbol = "GAS"
|
||||||
nep17.decimals = 8
|
nep17.decimals = 8
|
||||||
nep17.factor = GASFactor
|
nep17.factor = GASFactor
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
|
@ -49,7 +50,6 @@ type NEO struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
neoName = "NEO"
|
|
||||||
neoContractID = -1
|
neoContractID = -1
|
||||||
// NEOTotalSupply is the total amount of NEO in the system.
|
// NEOTotalSupply is the total amount of NEO in the system.
|
||||||
NEOTotalSupply = 100000000
|
NEOTotalSupply = 100000000
|
||||||
|
@ -93,7 +93,7 @@ func makeValidatorKey(key *keys.PublicKey) []byte {
|
||||||
// newNEO returns NEO native contract.
|
// newNEO returns NEO native contract.
|
||||||
func newNEO() *NEO {
|
func newNEO() *NEO {
|
||||||
n := &NEO{}
|
n := &NEO{}
|
||||||
nep17 := newNEP17Native(neoName)
|
nep17 := newNEP17Native(nativenames.Neo)
|
||||||
nep17.symbol = "NEO"
|
nep17.symbol = "NEO"
|
||||||
nep17.decimals = 0
|
nep17.decimals = 0
|
||||||
nep17.factor = 1
|
nep17.factor = 1
|
||||||
|
|
12
pkg/core/native/nativenames/names.go
Normal file
12
pkg/core/native/nativenames/names.go
Normal file
|
@ -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"
|
||||||
|
)
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"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/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
@ -37,7 +38,6 @@ type Notary struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
notaryName = "Notary"
|
|
||||||
notaryContractID = reservedContractID - 1
|
notaryContractID = reservedContractID - 1
|
||||||
// NotaryVerificationPrice is the price of `verify` Notary method.
|
// NotaryVerificationPrice is the price of `verify` Notary method.
|
||||||
NotaryVerificationPrice = 100_0000
|
NotaryVerificationPrice = 100_0000
|
||||||
|
@ -52,7 +52,7 @@ var maxNotValidBeforeDeltaKey = []byte{10}
|
||||||
|
|
||||||
// newNotary returns Notary native contract.
|
// newNotary returns Notary native contract.
|
||||||
func newNotary() *Notary {
|
func newNotary() *Notary {
|
||||||
n := &Notary{ContractMD: *interop.NewContractMD(notaryName)}
|
n := &Notary{ContractMD: *interop.NewContractMD(nativenames.Notary)}
|
||||||
n.ContractID = notaryContractID
|
n.ContractID = notaryContractID
|
||||||
|
|
||||||
desc := newDescriptor("onPayment", smartcontract.VoidType,
|
desc := newDescriptor("onPayment", smartcontract.VoidType,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"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/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop/interopnames"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
@ -36,11 +37,7 @@ type Oracle struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
oracleContractID = -4
|
oracleContractID = -4
|
||||||
oracleName = "Oracle"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
maxURLLength = 256
|
maxURLLength = 256
|
||||||
maxFilterLength = 128
|
maxFilterLength = 128
|
||||||
maxCallbackLength = 32
|
maxCallbackLength = 32
|
||||||
|
@ -58,7 +55,7 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
emit.String(w.BinWriter, oracleName)
|
emit.String(w.BinWriter, nativenames.Oracle)
|
||||||
emit.Syscall(w.BinWriter, interopnames.SystemContractCallNative)
|
emit.Syscall(w.BinWriter, interopnames.SystemContractCallNative)
|
||||||
oracleInvokeScript = w.Bytes()
|
oracleInvokeScript = w.Bytes()
|
||||||
h := hash.Hash160(oracleInvokeScript)
|
h := hash.Hash160(oracleInvokeScript)
|
||||||
|
@ -102,7 +99,7 @@ func GetOracleResponseScript() []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newOracle() *Oracle {
|
func newOracle() *Oracle {
|
||||||
o := &Oracle{ContractMD: *interop.NewContractMD(oracleName)}
|
o := &Oracle{ContractMD: *interop.NewContractMD(nativenames.Oracle)}
|
||||||
o.ContractID = oracleContractID
|
o.ContractID = oracleContractID
|
||||||
|
|
||||||
desc := newDescriptor("request", smartcontract.VoidType,
|
desc := newDescriptor("request", smartcontract.VoidType,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
"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/dao"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"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/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
|
@ -19,7 +20,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
policyName = "Policy"
|
|
||||||
policyContractID = -3
|
policyContractID = -3
|
||||||
|
|
||||||
defaultMaxBlockSize = 1024 * 256
|
defaultMaxBlockSize = 1024 * 256
|
||||||
|
@ -69,7 +69,7 @@ var _ interop.Contract = (*Policy)(nil)
|
||||||
|
|
||||||
// newPolicy returns Policy native contract.
|
// newPolicy returns Policy native contract.
|
||||||
func newPolicy() *Policy {
|
func newPolicy() *Policy {
|
||||||
p := &Policy{ContractMD: *interop.NewContractMD(policyName)}
|
p := &Policy{ContractMD: *interop.NewContractMD(nativenames.Policy)}
|
||||||
|
|
||||||
p.ContractID = policyContractID
|
p.ContractID = policyContractID
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"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/request"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -117,21 +118,21 @@ func (c *Client) Init() error {
|
||||||
}
|
}
|
||||||
c.network = version.Magic
|
c.network = version.Magic
|
||||||
c.stateRootInHeader = version.StateRootInHeader
|
c.stateRootInHeader = version.StateRootInHeader
|
||||||
neoContractHash, err := c.GetContractStateByAddressOrName("neo")
|
neoContractHash, err := c.GetContractStateByAddressOrName(nativenames.Neo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get NEO contract scripthash: %w", err)
|
return fmt.Errorf("failed to get NEO contract scripthash: %w", err)
|
||||||
}
|
}
|
||||||
c.cache.nativeHashes["neo"] = neoContractHash.Hash
|
c.cache.nativeHashes[nativenames.Neo] = neoContractHash.Hash
|
||||||
gasContractHash, err := c.GetContractStateByAddressOrName("gas")
|
gasContractHash, err := c.GetContractStateByAddressOrName(nativenames.Gas)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get GAS contract scripthash: %w", err)
|
return fmt.Errorf("failed to get GAS contract scripthash: %w", err)
|
||||||
}
|
}
|
||||||
c.cache.nativeHashes["gas"] = gasContractHash.Hash
|
c.cache.nativeHashes[nativenames.Gas] = gasContractHash.Hash
|
||||||
policyContractHash, err := c.GetContractStateByAddressOrName("policy")
|
policyContractHash, err := c.GetContractStateByAddressOrName(nativenames.Policy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get Policy contract scripthash: %w", err)
|
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
|
c.initDone = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package client
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"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/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
|
@ -28,7 +29,7 @@ func (c *Client) invokeNativePolicyMethod(operation string) (int64, error) {
|
||||||
if !c.initDone {
|
if !c.initDone {
|
||||||
return 0, errNetworkNotInitialized
|
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 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,7 @@ func (c *Client) IsBlocked(hash util.Uint160) (bool, error) {
|
||||||
if !c.initDone {
|
if !c.initDone {
|
||||||
return false, errNetworkNotInitialized
|
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,
|
Type: smartcontract.Hash160Type,
|
||||||
Value: hash,
|
Value: hash,
|
||||||
}}, nil)
|
}}, nil)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||||
|
@ -612,10 +611,9 @@ func (c *Client) StateRootInHeader() bool {
|
||||||
return c.stateRootInHeader
|
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) {
|
func (c *Client) GetNativeContractHash(name string) (util.Uint160, error) {
|
||||||
lowercasedName := strings.ToLower(name)
|
hash, ok := c.cache.nativeHashes[name]
|
||||||
hash, ok := c.cache.nativeHashes[lowercasedName]
|
|
||||||
if ok {
|
if ok {
|
||||||
return hash, nil
|
return hash, nil
|
||||||
}
|
}
|
||||||
|
@ -623,6 +621,6 @@ func (c *Client) GetNativeContractHash(name string) (util.Uint160, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, err
|
return util.Uint160{}, err
|
||||||
}
|
}
|
||||||
c.cache.nativeHashes[lowercasedName] = cs.Hash
|
c.cache.nativeHashes[name] = cs.Hash
|
||||||
return cs.Hash, nil
|
return cs.Hash, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1463,11 +1463,11 @@ func wrapInitResponse(r *request.In, resp string) string {
|
||||||
response = resp
|
response = resp
|
||||||
}
|
}
|
||||||
switch name {
|
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"}}`
|
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"}}`
|
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}}}`
|
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:
|
default:
|
||||||
response = resp
|
response = resp
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/testchain"
|
"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/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/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -266,7 +267,7 @@ func TestCreateNEP17TransferTx(t *testing.T) {
|
||||||
priv := testchain.PrivateKeyByID(0)
|
priv := testchain.PrivateKeyByID(0)
|
||||||
acc := wallet.NewAccountFromPrivateKey(priv)
|
acc := wallet.NewAccountFromPrivateKey(priv)
|
||||||
|
|
||||||
gasContractHash, err := c.GetNativeContractHash("gas")
|
gasContractHash, err := c.GetNativeContractHash(nativenames.Gas)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
tx, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0)
|
tx, err := c.CreateNEP17TransferTx(acc, util.Uint160{}, gasContractHash, 1000, 0)
|
||||||
|
|
|
@ -57,7 +57,7 @@ type rpcTestCase struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testContractHash = "743ed26f78e29ecd595535b74a943b1f9ccbc444"
|
const testContractHash = "743ed26f78e29ecd595535b74a943b1f9ccbc444"
|
||||||
const deploymentTxHash = "7e60be17078d05135c359805beece3ea4c5140f55adec8170179713f2124eb14"
|
const deploymentTxHash = "37644146394ad76ddb9431d10b724a3cad5f8b249abdaed0b086fcd761756951"
|
||||||
const genesisBlockHash = "0542f4350c6e236d0509bcd98188b0034bfbecc1a0c7fcdb8e4295310d468b70"
|
const genesisBlockHash = "0542f4350c6e236d0509bcd98188b0034bfbecc1a0c7fcdb8e4295310d468b70"
|
||||||
|
|
||||||
const verifyContractHash = "a2eb22340979804cb10cc1add0b8822c201f4d8a"
|
const verifyContractHash = "a2eb22340979804cb10cc1add0b8822c201f4d8a"
|
||||||
|
@ -170,7 +170,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "positive, native by name",
|
name: "positive, native by name",
|
||||||
params: `["Policy"]`,
|
params: `["PolicyContract"]`,
|
||||||
result: func(e *executor) interface{} { return &state.Contract{} },
|
result: func(e *executor) interface{} { return &state.Contract{} },
|
||||||
check: func(t *testing.T, e *executor, cs interface{}) {
|
check: func(t *testing.T, e *executor, cs interface{}) {
|
||||||
res, ok := cs.(*state.Contract)
|
res, ok := cs.(*state.Contract)
|
||||||
|
|
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
Loading…
Reference in a new issue