forked from TrueCloudLab/neoneo-go
core: remove native contracts' name
method
We have `name` in contract manifest.
This commit is contained in:
parent
0f68528095
commit
c013522296
6 changed files with 2 additions and 51 deletions
|
@ -87,10 +87,6 @@ func newDesignate(p2pSigExtensionsEnabled bool) *Designate {
|
|||
md = newMethodAndPrice(s.designateAsRole, 0, smartcontract.AllowModifyStates)
|
||||
s.AddMethod(md, desc, false)
|
||||
|
||||
desc = newDescriptor("name", smartcontract.StringType)
|
||||
md = newMethodAndPrice(nameMethod(designateName), 0, smartcontract.NoneFlag)
|
||||
s.AddMethod(md, desc, true)
|
||||
|
||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.AllowModifyStates)
|
||||
s.AddMethod(md, desc, false)
|
||||
|
|
|
@ -53,12 +53,8 @@ func newNEP17Native(name string) *nep17TokenNative {
|
|||
n := &nep17TokenNative{ContractMD: *interop.NewContractMD(name)}
|
||||
n.Manifest.SupportedStandards = []string{manifest.NEP17StandardName}
|
||||
|
||||
desc := newDescriptor("name", smartcontract.StringType)
|
||||
md := newMethodAndPrice(nameMethod(name), 0, smartcontract.NoneFlag)
|
||||
n.AddMethod(md, desc, true)
|
||||
|
||||
desc = newDescriptor("symbol", smartcontract.StringType)
|
||||
md = newMethodAndPrice(n.Symbol, 0, smartcontract.NoneFlag)
|
||||
desc := newDescriptor("symbol", smartcontract.StringType)
|
||||
md := newMethodAndPrice(n.Symbol, 0, smartcontract.NoneFlag)
|
||||
n.AddMethod(md, desc, true)
|
||||
|
||||
desc = newDescriptor("decimals", smartcontract.IntegerType)
|
||||
|
|
|
@ -113,10 +113,6 @@ func newOracle() *Oracle {
|
|||
md := newMethodAndPrice(o.request, oracleRequestPrice, smartcontract.AllowModifyStates)
|
||||
o.AddMethod(md, desc, false)
|
||||
|
||||
desc = newDescriptor("name", smartcontract.StringType)
|
||||
md = newMethodAndPrice(nameMethod(oracleName), 0, smartcontract.NoneFlag)
|
||||
o.AddMethod(md, desc, true)
|
||||
|
||||
desc = newDescriptor("finish", smartcontract.VoidType)
|
||||
md = newMethodAndPrice(o.finish, 0, smartcontract.AllowModifyStates)
|
||||
o.AddMethod(md, desc, false)
|
||||
|
|
|
@ -126,10 +126,6 @@ func newPolicy() *Policy {
|
|||
md = newMethodAndPrice(p.unblockAccount, 3000000, smartcontract.AllowModifyStates)
|
||||
p.AddMethod(md, desc, false)
|
||||
|
||||
desc = newDescriptor("name", smartcontract.StringType)
|
||||
md = newMethodAndPrice(nameMethod(policyName), 0, smartcontract.NoneFlag)
|
||||
p.AddMethod(md, desc, true)
|
||||
|
||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||
md = newMethodAndPrice(getOnPersistWrapper(p.OnPersist), 0, smartcontract.AllowModifyStates)
|
||||
p.AddMethod(md, desc, false)
|
||||
|
|
|
@ -2,10 +2,8 @@ package native
|
|||
|
||||
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/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
)
|
||||
|
||||
func getSerializableFromDAO(id int32, d dao.DAO, key []byte, item io.Serializable) error {
|
||||
|
@ -17,9 +15,3 @@ func getSerializableFromDAO(id int32, d dao.DAO, key []byte, item io.Serializabl
|
|||
item.DecodeBinary(r)
|
||||
return r.Err
|
||||
}
|
||||
|
||||
func nameMethod(name string) interop.Method {
|
||||
return func(_ *interop.Context, _ []stackitem.Item) stackitem.Item {
|
||||
return stackitem.NewByteArray([]byte(name))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,28 +276,3 @@ func TestNativeContract_InvokeOtherContract(t *testing.T) {
|
|||
require.Equal(t, stackitem.Null{}, res[0].Stack[0]) // simple call is done with EnsureNotEmpty
|
||||
})
|
||||
}
|
||||
|
||||
func TestAllContractsHaveName(t *testing.T) {
|
||||
bc := newTestChain(t)
|
||||
defer bc.Close()
|
||||
for _, c := range bc.contracts.Contracts {
|
||||
name := c.Metadata().Name
|
||||
t.Run(name, func(t *testing.T) {
|
||||
w := io.NewBufBinWriter()
|
||||
emit.AppCallWithOperationAndArgs(w.BinWriter, c.Metadata().Hash, "name")
|
||||
require.NoError(t, w.Err)
|
||||
|
||||
tx := transaction.New(netmode.UnitTestNet, w.Bytes(), 1015570)
|
||||
tx.ValidUntilBlock = bc.blockHeight + 1
|
||||
addSigners(tx)
|
||||
require.NoError(t, testchain.SignTx(bc, tx))
|
||||
require.NoError(t, bc.AddBlock(bc.newBlock(tx)))
|
||||
|
||||
aers, err := bc.GetAppExecResults(tx.Hash(), trigger.Application)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(aers))
|
||||
require.Len(t, aers[0].Stack, 1)
|
||||
require.Equal(t, []byte(name), aers[0].Stack[0].Value())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue