core: adjust parameters of native methods

This commit is mostly about Hash160 -> ByteArray for native contracts'
methods. Manifest is included into states, so we need to be compatible.
This commit is contained in:
Anna Shaleva 2020-12-22 17:30:45 +03:00
parent e40f3610ed
commit 33386065bc
4 changed files with 18 additions and 17 deletions

View file

@ -64,7 +64,7 @@ func newManagement() *Management {
}
desc := newDescriptor("getContract", smartcontract.ArrayType,
manifest.NewParameter("hash", smartcontract.Hash160Type))
manifest.NewParameter("hash", smartcontract.ByteArrayType))
md := newMethodAndPrice(m.getContract, 1000000, smartcontract.ReadStates)
m.AddMethod(md, desc)

View file

@ -108,24 +108,24 @@ func newNEO() *NEO {
n.committeeHash.Store(util.Uint160{})
desc := newDescriptor("unclaimedGas", smartcontract.IntegerType,
manifest.NewParameter("account", smartcontract.Hash160Type),
manifest.NewParameter("account", smartcontract.ByteArrayType),
manifest.NewParameter("end", smartcontract.IntegerType))
md := newMethodAndPrice(n.unclaimedGas, 3000000, smartcontract.ReadStates)
n.AddMethod(md, desc)
desc = newDescriptor("registerCandidate", smartcontract.BoolType,
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
manifest.NewParameter("pubkey", smartcontract.ByteArrayType))
md = newMethodAndPrice(n.registerCandidate, 5000000, smartcontract.WriteStates)
n.AddMethod(md, desc)
desc = newDescriptor("unregisterCandidate", smartcontract.BoolType,
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
manifest.NewParameter("pubkey", smartcontract.ByteArrayType))
md = newMethodAndPrice(n.unregisterCandidate, 5000000, smartcontract.WriteStates)
n.AddMethod(md, desc)
desc = newDescriptor("vote", smartcontract.BoolType,
manifest.NewParameter("account", smartcontract.Hash160Type),
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
manifest.NewParameter("account", smartcontract.ByteArrayType),
manifest.NewParameter("pubkey", smartcontract.ByteArrayType))
md = newMethodAndPrice(n.vote, 5000000, smartcontract.WriteStates)
n.AddMethod(md, desc)

View file

@ -59,22 +59,23 @@ func newNEP17Native(name string) *nep17TokenNative {
n.AddMethod(md, desc)
desc = newDescriptor("balanceOf", smartcontract.IntegerType,
manifest.NewParameter("account", smartcontract.Hash160Type))
manifest.NewParameter("account", smartcontract.ByteArrayType))
md = newMethodAndPrice(n.balanceOf, 1000000, smartcontract.ReadStates)
n.AddMethod(md, desc)
transferParams := []manifest.Parameter{
manifest.NewParameter("from", smartcontract.Hash160Type),
manifest.NewParameter("to", smartcontract.Hash160Type),
manifest.NewParameter("amount", smartcontract.IntegerType),
}
desc = newDescriptor("transfer", smartcontract.BoolType,
append(transferParams, manifest.NewParameter("data", smartcontract.AnyType))...,
manifest.NewParameter("from", smartcontract.ByteArrayType),
manifest.NewParameter("to", smartcontract.ByteArrayType),
manifest.NewParameter("amount", smartcontract.IntegerType),
manifest.NewParameter("data", smartcontract.AnyType),
)
md = newMethodAndPrice(n.Transfer, 9000000, smartcontract.WriteStates|smartcontract.AllowCall|smartcontract.AllowNotify)
n.AddMethod(md, desc)
n.AddEvent("Transfer", transferParams...)
n.AddEvent("Transfer",
manifest.NewParameter("from", smartcontract.Hash160Type),
manifest.NewParameter("to", smartcontract.Hash160Type),
manifest.NewParameter("amount", smartcontract.IntegerType))
return n
}

View file

@ -97,7 +97,7 @@ func newPolicy() *Policy {
p.AddMethod(md, desc)
desc = newDescriptor("isBlocked", smartcontract.BoolType,
manifest.NewParameter("account", smartcontract.Hash160Type))
manifest.NewParameter("account", smartcontract.ByteArrayType))
md = newMethodAndPrice(p.isBlocked, 1000000, smartcontract.ReadStates)
p.AddMethod(md, desc)
@ -144,12 +144,12 @@ func newPolicy() *Policy {
p.AddMethod(md, desc)
desc = newDescriptor("blockAccount", smartcontract.BoolType,
manifest.NewParameter("account", smartcontract.Hash160Type))
manifest.NewParameter("account", smartcontract.ByteArrayType))
md = newMethodAndPrice(p.blockAccount, 3000000, smartcontract.WriteStates)
p.AddMethod(md, desc)
desc = newDescriptor("unblockAccount", smartcontract.BoolType,
manifest.NewParameter("account", smartcontract.Hash160Type))
manifest.NewParameter("account", smartcontract.ByteArrayType))
md = newMethodAndPrice(p.unblockAccount, 3000000, smartcontract.WriteStates)
p.AddMethod(md, desc)