core: rename call flags
Also new States flag is added and ReadOnly flag is adjusted.
This commit is contained in:
parent
3bbf7642ea
commit
fadbae8997
16 changed files with 95 additions and 91 deletions
|
@ -13,10 +13,11 @@ import (
|
||||||
|
|
||||||
// Checks that changes in `smartcontract` are reflected in compiler interop package.
|
// Checks that changes in `smartcontract` are reflected in compiler interop package.
|
||||||
func TestCallFlags(t *testing.T) {
|
func TestCallFlags(t *testing.T) {
|
||||||
require.EqualValues(t, contract.AllowStates, smartcontract.AllowStates)
|
require.EqualValues(t, contract.ReadStates, smartcontract.ReadStates)
|
||||||
require.EqualValues(t, contract.AllowModifyStates, smartcontract.AllowModifyStates)
|
require.EqualValues(t, contract.WriteStates, smartcontract.WriteStates)
|
||||||
require.EqualValues(t, contract.AllowCall, smartcontract.AllowCall)
|
require.EqualValues(t, contract.AllowCall, smartcontract.AllowCall)
|
||||||
require.EqualValues(t, contract.AllowNotify, smartcontract.AllowNotify)
|
require.EqualValues(t, contract.AllowNotify, smartcontract.AllowNotify)
|
||||||
|
require.EqualValues(t, contract.States, smartcontract.States)
|
||||||
require.EqualValues(t, contract.ReadOnly, smartcontract.ReadOnly)
|
require.EqualValues(t, contract.ReadOnly, smartcontract.ReadOnly)
|
||||||
require.EqualValues(t, contract.All, smartcontract.All)
|
require.EqualValues(t, contract.All, smartcontract.All)
|
||||||
require.EqualValues(t, contract.NoneFlag, smartcontract.NoneFlag)
|
require.EqualValues(t, contract.NoneFlag, smartcontract.NoneFlag)
|
||||||
|
|
|
@ -769,7 +769,7 @@ func (bc *Blockchain) storeBlock(block *block.Block, txpool *mempool.Pool) error
|
||||||
func (bc *Blockchain) runPersist(script []byte, block *block.Block, cache *dao.Cached, trig trigger.Type) (*state.AppExecResult, error) {
|
func (bc *Blockchain) runPersist(script []byte, block *block.Block, cache *dao.Cached, trig trigger.Type) (*state.AppExecResult, error) {
|
||||||
systemInterop := bc.newInteropContext(trig, cache, block, nil)
|
systemInterop := bc.newInteropContext(trig, cache, block, nil)
|
||||||
v := systemInterop.SpawnVM()
|
v := systemInterop.SpawnVM()
|
||||||
v.LoadScriptWithFlags(script, smartcontract.AllowModifyStates|smartcontract.AllowCall)
|
v.LoadScriptWithFlags(script, smartcontract.WriteStates|smartcontract.AllowCall)
|
||||||
v.SetPriceGetter(getPrice)
|
v.SetPriceGetter(getPrice)
|
||||||
if err := v.Run(); err != nil {
|
if err := v.Run(); err != nil {
|
||||||
return nil, fmt.Errorf("VM has failed: %w", err)
|
return nil, fmt.Errorf("VM has failed: %w", err)
|
||||||
|
@ -1674,7 +1674,7 @@ func (bc *Blockchain) initVerificationVM(ic *interop.Context, hash util.Uint160,
|
||||||
return ErrInvalidVerificationContract
|
return ErrInvalidVerificationContract
|
||||||
}
|
}
|
||||||
initMD := cs.Manifest.ABI.GetMethod(manifest.MethodInit)
|
initMD := cs.Manifest.ABI.GetMethod(manifest.MethodInit)
|
||||||
v.LoadScriptWithHash(cs.Script, hash, smartcontract.AllowStates)
|
v.LoadScriptWithHash(cs.Script, hash, smartcontract.ReadStates)
|
||||||
v.Jump(v.Context(), md.Offset)
|
v.Jump(v.Context(), md.Offset)
|
||||||
|
|
||||||
if cs.ID < 0 {
|
if cs.ID < 0 {
|
||||||
|
|
|
@ -123,7 +123,7 @@ func NewContractMD(name string) *ContractMD {
|
||||||
func (c *ContractMD) AddMethod(md *MethodAndPrice, desc *manifest.Method) {
|
func (c *ContractMD) AddMethod(md *MethodAndPrice, desc *manifest.Method) {
|
||||||
c.Manifest.ABI.Methods = append(c.Manifest.ABI.Methods, *desc)
|
c.Manifest.ABI.Methods = append(c.Manifest.ABI.Methods, *desc)
|
||||||
md.MD = desc
|
md.MD = desc
|
||||||
desc.Safe = (md.RequiredFlags & smartcontract.AllowModifyStates) == 0
|
desc.Safe = (md.RequiredFlags & smartcontract.WriteStates) == 0
|
||||||
c.Methods[desc.Name] = *md
|
c.Methods[desc.Name] = *md
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ func callExInternal(ic *interop.Context, h []byte, name string, args []stackitem
|
||||||
return errors.New("method not found")
|
return errors.New("method not found")
|
||||||
}
|
}
|
||||||
if md.Safe {
|
if md.Safe {
|
||||||
f &^= smartcontract.AllowModifyStates
|
f &^= smartcontract.WriteStates
|
||||||
} else if ctx := ic.VM.Context(); ctx != nil && ctx.IsDeployed() {
|
} else if ctx := ic.VM.Context(); ctx != nil && ctx.IsDeployed() {
|
||||||
curr, err := ic.DAO.GetContractState(ic.VM.GetCurrentScriptHash())
|
curr, err := ic.DAO.GetContractState(ic.VM.GetCurrentScriptHash())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -54,8 +54,8 @@ func checkScope(d dao.DAO, tx *transaction.Transaction, v *vm.VM, hash util.Uint
|
||||||
if callingScriptHash.Equals(util.Uint160{}) {
|
if callingScriptHash.Equals(util.Uint160{}) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if !v.Context().GetCallFlags().Has(smartcontract.AllowStates) {
|
if !v.Context().GetCallFlags().Has(smartcontract.ReadStates) {
|
||||||
return false, errors.New("missing AllowStates call flag")
|
return false, errors.New("missing ReadStates call flag")
|
||||||
}
|
}
|
||||||
cs, err := d.GetContractState(callingScriptHash)
|
cs, err := d.GetContractState(callingScriptHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1178,11 +1178,11 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
check(t, ic, []byte{1, 2, 3}, true)
|
check(t, ic, []byte{1, 2, 3}, true)
|
||||||
})
|
})
|
||||||
t.Run("script container is not a transaction", func(t *testing.T) {
|
t.Run("script container is not a transaction", func(t *testing.T) {
|
||||||
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.AllowStates)
|
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.ReadStates)
|
||||||
check(t, ic, random.Uint160().BytesBE(), true)
|
check(t, ic, random.Uint160().BytesBE(), true)
|
||||||
})
|
})
|
||||||
t.Run("check scope", func(t *testing.T) {
|
t.Run("check scope", func(t *testing.T) {
|
||||||
t.Run("CustomGroups, missing AllowStates flag", func(t *testing.T) {
|
t.Run("CustomGroups, missing ReadStates flag", func(t *testing.T) {
|
||||||
hash := random.Uint160()
|
hash := random.Uint160()
|
||||||
tx := &transaction.Transaction{
|
tx := &transaction.Transaction{
|
||||||
Signers: []transaction.Signer{
|
Signers: []transaction.Signer{
|
||||||
|
@ -1213,7 +1213,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
callingScriptHash := scriptHash
|
callingScriptHash := scriptHash
|
||||||
loadScriptWithHashAndFlags(ic, script, callingScriptHash, smartcontract.All)
|
loadScriptWithHashAndFlags(ic, script, callingScriptHash, smartcontract.All)
|
||||||
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), smartcontract.AllowStates)
|
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), smartcontract.ReadStates)
|
||||||
check(t, ic, hash.BytesBE(), true)
|
check(t, ic, hash.BytesBE(), true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1246,7 +1246,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.AllowStates)
|
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.ReadStates)
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
check(t, ic, hash.BytesBE(), false, true)
|
check(t, ic, hash.BytesBE(), false, true)
|
||||||
})
|
})
|
||||||
|
@ -1260,7 +1260,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.AllowStates)
|
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.ReadStates)
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
check(t, ic, hash.BytesBE(), false, true)
|
check(t, ic, hash.BytesBE(), false, true)
|
||||||
})
|
})
|
||||||
|
@ -1275,7 +1275,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.AllowStates)
|
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.ReadStates)
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
check(t, ic, hash.BytesBE(), false, true)
|
check(t, ic, hash.BytesBE(), false, true)
|
||||||
})
|
})
|
||||||
|
@ -1291,7 +1291,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.AllowStates)
|
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.ReadStates)
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
check(t, ic, hash.BytesBE(), false, false)
|
check(t, ic, hash.BytesBE(), false, false)
|
||||||
})
|
})
|
||||||
|
@ -1320,7 +1320,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
}
|
}
|
||||||
require.NoError(t, ic.DAO.PutContractState(contractState))
|
require.NoError(t, ic.DAO.PutContractState(contractState))
|
||||||
loadScriptWithHashAndFlags(ic, contractScript, contractScriptHash, smartcontract.All)
|
loadScriptWithHashAndFlags(ic, contractScript, contractScriptHash, smartcontract.All)
|
||||||
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), smartcontract.AllowStates)
|
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), smartcontract.ReadStates)
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
check(t, ic, targetHash.BytesBE(), false, true)
|
check(t, ic, targetHash.BytesBE(), false, true)
|
||||||
})
|
})
|
||||||
|
@ -1335,7 +1335,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.AllowStates)
|
loadScriptWithHashAndFlags(ic, script, scriptHash, smartcontract.ReadStates)
|
||||||
ic.Container = tx
|
ic.Container = tx
|
||||||
check(t, ic, hash.BytesBE(), false, false)
|
check(t, ic, hash.BytesBE(), false, false)
|
||||||
})
|
})
|
||||||
|
|
|
@ -42,17 +42,17 @@ var systemInterops = []interop.Function{
|
||||||
{Name: interopnames.SystemBinaryItoa, Func: binary.Itoa, Price: 100000, ParamCount: 2},
|
{Name: interopnames.SystemBinaryItoa, Func: binary.Itoa, Price: 100000, ParamCount: 2},
|
||||||
{Name: interopnames.SystemBinarySerialize, Func: binary.Serialize, Price: 100000, ParamCount: 1},
|
{Name: interopnames.SystemBinarySerialize, Func: binary.Serialize, Price: 100000, ParamCount: 1},
|
||||||
{Name: interopnames.SystemBlockchainGetBlock, Func: bcGetBlock, Price: 2500000,
|
{Name: interopnames.SystemBlockchainGetBlock, Func: bcGetBlock, Price: 2500000,
|
||||||
RequiredFlags: smartcontract.AllowStates, ParamCount: 1},
|
RequiredFlags: smartcontract.ReadStates, ParamCount: 1},
|
||||||
{Name: interopnames.SystemBlockchainGetContract, Func: bcGetContract, Price: 1000000,
|
{Name: interopnames.SystemBlockchainGetContract, Func: bcGetContract, Price: 1000000,
|
||||||
RequiredFlags: smartcontract.AllowStates, ParamCount: 1},
|
RequiredFlags: smartcontract.ReadStates, ParamCount: 1},
|
||||||
{Name: interopnames.SystemBlockchainGetHeight, Func: bcGetHeight, Price: 400,
|
{Name: interopnames.SystemBlockchainGetHeight, Func: bcGetHeight, Price: 400,
|
||||||
RequiredFlags: smartcontract.AllowStates},
|
RequiredFlags: smartcontract.ReadStates},
|
||||||
{Name: interopnames.SystemBlockchainGetTransaction, Func: bcGetTransaction, Price: 1000000,
|
{Name: interopnames.SystemBlockchainGetTransaction, Func: bcGetTransaction, Price: 1000000,
|
||||||
RequiredFlags: smartcontract.AllowStates, ParamCount: 1},
|
RequiredFlags: smartcontract.ReadStates, ParamCount: 1},
|
||||||
{Name: interopnames.SystemBlockchainGetTransactionFromBlock, Func: bcGetTransactionFromBlock, Price: 1000000,
|
{Name: interopnames.SystemBlockchainGetTransactionFromBlock, Func: bcGetTransactionFromBlock, Price: 1000000,
|
||||||
RequiredFlags: smartcontract.AllowStates, ParamCount: 2},
|
RequiredFlags: smartcontract.ReadStates, ParamCount: 2},
|
||||||
{Name: interopnames.SystemBlockchainGetTransactionHeight, Func: bcGetTransactionHeight, Price: 1000000,
|
{Name: interopnames.SystemBlockchainGetTransactionHeight, Func: bcGetTransactionHeight, Price: 1000000,
|
||||||
RequiredFlags: smartcontract.AllowStates, ParamCount: 1},
|
RequiredFlags: smartcontract.ReadStates, ParamCount: 1},
|
||||||
{Name: interopnames.SystemCallbackCreate, Func: callback.Create, Price: 400, ParamCount: 3, DisallowCallback: true},
|
{Name: interopnames.SystemCallbackCreate, Func: callback.Create, Price: 400, ParamCount: 3, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemCallbackCreateFromMethod, Func: callback.CreateFromMethod, Price: 1000000, ParamCount: 2, DisallowCallback: true},
|
{Name: interopnames.SystemCallbackCreateFromMethod, Func: callback.CreateFromMethod, Price: 1000000, ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemCallbackCreateFromSyscall, Func: callback.CreateFromSyscall, Price: 400, ParamCount: 1, DisallowCallback: true},
|
{Name: interopnames.SystemCallbackCreateFromSyscall, Func: callback.CreateFromSyscall, Price: 400, ParamCount: 1, DisallowCallback: true},
|
||||||
|
@ -62,13 +62,13 @@ var systemInterops = []interop.Function{
|
||||||
{Name: interopnames.SystemContractCallEx, Func: contract.CallEx, Price: 1000000,
|
{Name: interopnames.SystemContractCallEx, Func: contract.CallEx, Price: 1000000,
|
||||||
RequiredFlags: smartcontract.AllowCall, ParamCount: 4, DisallowCallback: true},
|
RequiredFlags: smartcontract.AllowCall, ParamCount: 4, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemContractCreate, Func: contractCreate, Price: 0,
|
{Name: interopnames.SystemContractCreate, Func: contractCreate, Price: 0,
|
||||||
RequiredFlags: smartcontract.AllowModifyStates, ParamCount: 2, DisallowCallback: true},
|
RequiredFlags: smartcontract.WriteStates, ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemContractCreateStandardAccount, Func: contractCreateStandardAccount, Price: 10000, ParamCount: 1, DisallowCallback: true},
|
{Name: interopnames.SystemContractCreateStandardAccount, Func: contractCreateStandardAccount, Price: 10000, ParamCount: 1, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemContractDestroy, Func: contractDestroy, Price: 1000000, RequiredFlags: smartcontract.AllowModifyStates, DisallowCallback: true},
|
{Name: interopnames.SystemContractDestroy, Func: contractDestroy, Price: 1000000, RequiredFlags: smartcontract.WriteStates, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemContractIsStandard, Func: contractIsStandard, Price: 30000, RequiredFlags: smartcontract.AllowStates, ParamCount: 1},
|
{Name: interopnames.SystemContractIsStandard, Func: contractIsStandard, Price: 30000, RequiredFlags: smartcontract.ReadStates, ParamCount: 1},
|
||||||
{Name: interopnames.SystemContractGetCallFlags, Func: contractGetCallFlags, Price: 30000, DisallowCallback: true},
|
{Name: interopnames.SystemContractGetCallFlags, Func: contractGetCallFlags, Price: 30000, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemContractUpdate, Func: contractUpdate, Price: 0,
|
{Name: interopnames.SystemContractUpdate, Func: contractUpdate, Price: 0,
|
||||||
RequiredFlags: smartcontract.AllowModifyStates, ParamCount: 2, DisallowCallback: true},
|
RequiredFlags: smartcontract.WriteStates, ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemEnumeratorConcat, Func: enumerator.Concat, Price: 400, ParamCount: 2, DisallowCallback: true},
|
{Name: interopnames.SystemEnumeratorConcat, Func: enumerator.Concat, Price: 400, ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemEnumeratorCreate, Func: enumerator.Create, Price: 400, ParamCount: 1, DisallowCallback: true},
|
{Name: interopnames.SystemEnumeratorCreate, Func: enumerator.Create, Price: 400, ParamCount: 1, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemEnumeratorNext, Func: enumerator.Next, Price: 1000000, ParamCount: 1, DisallowCallback: true},
|
{Name: interopnames.SystemEnumeratorNext, Func: enumerator.Next, Price: 1000000, ParamCount: 1, DisallowCallback: true},
|
||||||
|
@ -89,7 +89,7 @@ var systemInterops = []interop.Function{
|
||||||
{Name: interopnames.SystemRuntimeGetInvocationCounter, Func: runtime.GetInvocationCounter, Price: 400},
|
{Name: interopnames.SystemRuntimeGetInvocationCounter, Func: runtime.GetInvocationCounter, Price: 400},
|
||||||
{Name: interopnames.SystemRuntimeGetNotifications, Func: runtime.GetNotifications, Price: 10000, ParamCount: 1},
|
{Name: interopnames.SystemRuntimeGetNotifications, Func: runtime.GetNotifications, Price: 10000, ParamCount: 1},
|
||||||
{Name: interopnames.SystemRuntimeGetScriptContainer, Func: engineGetScriptContainer, Price: 250},
|
{Name: interopnames.SystemRuntimeGetScriptContainer, Func: engineGetScriptContainer, Price: 250},
|
||||||
{Name: interopnames.SystemRuntimeGetTime, Func: runtime.GetTime, Price: 250, RequiredFlags: smartcontract.AllowStates},
|
{Name: interopnames.SystemRuntimeGetTime, Func: runtime.GetTime, Price: 250, RequiredFlags: smartcontract.ReadStates},
|
||||||
{Name: interopnames.SystemRuntimeGetTrigger, Func: runtime.GetTrigger, Price: 250},
|
{Name: interopnames.SystemRuntimeGetTrigger, Func: runtime.GetTrigger, Price: 250},
|
||||||
{Name: interopnames.SystemRuntimeLog, Func: runtime.Log, Price: 1000000, RequiredFlags: smartcontract.AllowNotify,
|
{Name: interopnames.SystemRuntimeLog, Func: runtime.Log, Price: 1000000, RequiredFlags: smartcontract.AllowNotify,
|
||||||
ParamCount: 1, DisallowCallback: true},
|
ParamCount: 1, DisallowCallback: true},
|
||||||
|
@ -97,21 +97,21 @@ var systemInterops = []interop.Function{
|
||||||
ParamCount: 2, DisallowCallback: true},
|
ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemRuntimePlatform, Func: runtime.Platform, Price: 250},
|
{Name: interopnames.SystemRuntimePlatform, Func: runtime.Platform, Price: 250},
|
||||||
{Name: interopnames.SystemStorageDelete, Func: storageDelete, Price: StoragePrice,
|
{Name: interopnames.SystemStorageDelete, Func: storageDelete, Price: StoragePrice,
|
||||||
RequiredFlags: smartcontract.AllowModifyStates, ParamCount: 2, DisallowCallback: true},
|
RequiredFlags: smartcontract.WriteStates, ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemStorageFind, Func: storageFind, Price: 1000000, RequiredFlags: smartcontract.AllowStates,
|
{Name: interopnames.SystemStorageFind, Func: storageFind, Price: 1000000, RequiredFlags: smartcontract.ReadStates,
|
||||||
ParamCount: 2, DisallowCallback: true},
|
ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemStorageGet, Func: storageGet, Price: 1000000, RequiredFlags: smartcontract.AllowStates,
|
{Name: interopnames.SystemStorageGet, Func: storageGet, Price: 1000000, RequiredFlags: smartcontract.ReadStates,
|
||||||
ParamCount: 2, DisallowCallback: true},
|
ParamCount: 2, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemStorageGetContext, Func: storageGetContext, Price: 400,
|
{Name: interopnames.SystemStorageGetContext, Func: storageGetContext, Price: 400,
|
||||||
RequiredFlags: smartcontract.AllowStates, DisallowCallback: true},
|
RequiredFlags: smartcontract.ReadStates, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemStorageGetReadOnlyContext, Func: storageGetReadOnlyContext, Price: 400,
|
{Name: interopnames.SystemStorageGetReadOnlyContext, Func: storageGetReadOnlyContext, Price: 400,
|
||||||
RequiredFlags: smartcontract.AllowStates, DisallowCallback: true},
|
RequiredFlags: smartcontract.ReadStates, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemStoragePut, Func: storagePut, Price: 0, RequiredFlags: smartcontract.AllowModifyStates,
|
{Name: interopnames.SystemStoragePut, Func: storagePut, Price: 0, RequiredFlags: smartcontract.WriteStates,
|
||||||
ParamCount: 3, DisallowCallback: true}, // These don't have static price in C# code.
|
ParamCount: 3, DisallowCallback: true}, // These don't have static price in C# code.
|
||||||
{Name: interopnames.SystemStoragePutEx, Func: storagePutEx, Price: 0, RequiredFlags: smartcontract.AllowModifyStates,
|
{Name: interopnames.SystemStoragePutEx, Func: storagePutEx, Price: 0, RequiredFlags: smartcontract.WriteStates,
|
||||||
ParamCount: 4, DisallowCallback: true},
|
ParamCount: 4, DisallowCallback: true},
|
||||||
{Name: interopnames.SystemStorageAsReadOnly, Func: storageContextAsReadOnly, Price: 400,
|
{Name: interopnames.SystemStorageAsReadOnly, Func: storageContextAsReadOnly, Price: 400,
|
||||||
RequiredFlags: smartcontract.AllowStates, ParamCount: 1, DisallowCallback: true},
|
RequiredFlags: smartcontract.ReadStates, ParamCount: 1, DisallowCallback: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
var neoInterops = []interop.Function{
|
var neoInterops = []interop.Function{
|
||||||
|
@ -124,7 +124,7 @@ var neoInterops = []interop.Function{
|
||||||
{Name: interopnames.NeoCryptoSHA256, Func: crypto.Sha256, Price: 1000000, ParamCount: 1},
|
{Name: interopnames.NeoCryptoSHA256, Func: crypto.Sha256, Price: 1000000, ParamCount: 1},
|
||||||
{Name: interopnames.NeoCryptoRIPEMD160, Func: crypto.RipeMD160, Price: 1000000, ParamCount: 1},
|
{Name: interopnames.NeoCryptoRIPEMD160, Func: crypto.RipeMD160, Price: 1000000, ParamCount: 1},
|
||||||
{Name: interopnames.NeoNativeCall, Func: native.Call, Price: 0, ParamCount: 1, DisallowCallback: true},
|
{Name: interopnames.NeoNativeCall, Func: native.Call, Price: 0, ParamCount: 1, DisallowCallback: true},
|
||||||
{Name: interopnames.NeoNativeDeploy, Func: native.Deploy, Price: 0, RequiredFlags: smartcontract.AllowModifyStates, DisallowCallback: true},
|
{Name: interopnames.NeoNativeDeploy, Func: native.Deploy, Price: 0, RequiredFlags: smartcontract.WriteStates, DisallowCallback: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
// initIDinInteropsSlice initializes IDs from names in one given
|
// initIDinInteropsSlice initializes IDs from names in one given
|
||||||
|
|
|
@ -78,21 +78,21 @@ func newDesignate(p2pSigExtensionsEnabled bool) *Designate {
|
||||||
desc := newDescriptor("getDesignatedByRole", smartcontract.ArrayType,
|
desc := newDescriptor("getDesignatedByRole", smartcontract.ArrayType,
|
||||||
manifest.NewParameter("role", smartcontract.IntegerType),
|
manifest.NewParameter("role", smartcontract.IntegerType),
|
||||||
manifest.NewParameter("index", smartcontract.IntegerType))
|
manifest.NewParameter("index", smartcontract.IntegerType))
|
||||||
md := newMethodAndPrice(s.getDesignatedByRole, 1000000, smartcontract.AllowStates)
|
md := newMethodAndPrice(s.getDesignatedByRole, 1000000, smartcontract.ReadStates)
|
||||||
s.AddMethod(md, desc)
|
s.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("designateAsRole", smartcontract.VoidType,
|
desc = newDescriptor("designateAsRole", smartcontract.VoidType,
|
||||||
manifest.NewParameter("role", smartcontract.IntegerType),
|
manifest.NewParameter("role", smartcontract.IntegerType),
|
||||||
manifest.NewParameter("nodes", smartcontract.ArrayType))
|
manifest.NewParameter("nodes", smartcontract.ArrayType))
|
||||||
md = newMethodAndPrice(s.designateAsRole, 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(s.designateAsRole, 0, smartcontract.WriteStates)
|
||||||
s.AddMethod(md, desc)
|
s.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.WriteStates)
|
||||||
s.AddMethod(md, desc)
|
s.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.WriteStates)
|
||||||
s.AddMethod(md, desc)
|
s.AddMethod(md, desc)
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -120,44 +120,44 @@ func newNEO() *NEO {
|
||||||
desc := newDescriptor("unclaimedGas", smartcontract.IntegerType,
|
desc := newDescriptor("unclaimedGas", smartcontract.IntegerType,
|
||||||
manifest.NewParameter("account", smartcontract.Hash160Type),
|
manifest.NewParameter("account", smartcontract.Hash160Type),
|
||||||
manifest.NewParameter("end", smartcontract.IntegerType))
|
manifest.NewParameter("end", smartcontract.IntegerType))
|
||||||
md := newMethodAndPrice(n.unclaimedGas, 3000000, smartcontract.AllowStates)
|
md := newMethodAndPrice(n.unclaimedGas, 3000000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("registerCandidate", smartcontract.BoolType,
|
desc = newDescriptor("registerCandidate", smartcontract.BoolType,
|
||||||
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
|
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
|
||||||
md = newMethodAndPrice(n.registerCandidate, 5000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.registerCandidate, 5000000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("unregisterCandidate", smartcontract.BoolType,
|
desc = newDescriptor("unregisterCandidate", smartcontract.BoolType,
|
||||||
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
|
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
|
||||||
md = newMethodAndPrice(n.unregisterCandidate, 5000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.unregisterCandidate, 5000000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("vote", smartcontract.BoolType,
|
desc = newDescriptor("vote", smartcontract.BoolType,
|
||||||
manifest.NewParameter("account", smartcontract.Hash160Type),
|
manifest.NewParameter("account", smartcontract.Hash160Type),
|
||||||
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
|
manifest.NewParameter("pubkey", smartcontract.PublicKeyType))
|
||||||
md = newMethodAndPrice(n.vote, 5000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.vote, 5000000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getCandidates", smartcontract.ArrayType)
|
desc = newDescriptor("getCandidates", smartcontract.ArrayType)
|
||||||
md = newMethodAndPrice(n.getCandidatesCall, 100000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.getCandidatesCall, 100000000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getСommittee", smartcontract.ArrayType)
|
desc = newDescriptor("getСommittee", smartcontract.ArrayType)
|
||||||
md = newMethodAndPrice(n.getCommittee, 100000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.getCommittee, 100000000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getNextBlockValidators", smartcontract.ArrayType)
|
desc = newDescriptor("getNextBlockValidators", smartcontract.ArrayType)
|
||||||
md = newMethodAndPrice(n.getNextBlockValidators, 100000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.getNextBlockValidators, 100000000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getGasPerBlock", smartcontract.IntegerType)
|
desc = newDescriptor("getGasPerBlock", smartcontract.IntegerType)
|
||||||
md = newMethodAndPrice(n.getGASPerBlock, 100_0000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.getGASPerBlock, 100_0000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("setGasPerBlock", smartcontract.BoolType,
|
desc = newDescriptor("setGasPerBlock", smartcontract.BoolType,
|
||||||
manifest.NewParameter("gasPerBlock", smartcontract.IntegerType))
|
manifest.NewParameter("gasPerBlock", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(n.setGASPerBlock, 500_0000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.setGASPerBlock, 500_0000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
return n
|
return n
|
||||||
|
|
|
@ -63,12 +63,12 @@ func newNEP17Native(name string) *nep17TokenNative {
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("totalSupply", smartcontract.IntegerType)
|
desc = newDescriptor("totalSupply", smartcontract.IntegerType)
|
||||||
md = newMethodAndPrice(n.TotalSupply, 1000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.TotalSupply, 1000000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("balanceOf", smartcontract.IntegerType,
|
desc = newDescriptor("balanceOf", smartcontract.IntegerType,
|
||||||
manifest.NewParameter("account", smartcontract.Hash160Type))
|
manifest.NewParameter("account", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(n.balanceOf, 1000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.balanceOf, 1000000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
transferParams := []manifest.Parameter{
|
transferParams := []manifest.Parameter{
|
||||||
|
@ -79,15 +79,15 @@ func newNEP17Native(name string) *nep17TokenNative {
|
||||||
desc = newDescriptor("transfer", smartcontract.BoolType,
|
desc = newDescriptor("transfer", smartcontract.BoolType,
|
||||||
append(transferParams, manifest.NewParameter("data", smartcontract.AnyType))...,
|
append(transferParams, manifest.NewParameter("data", smartcontract.AnyType))...,
|
||||||
)
|
)
|
||||||
md = newMethodAndPrice(n.Transfer, 8000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.Transfer, 8000000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
n.AddEvent("Transfer", transferParams...)
|
n.AddEvent("Transfer", transferParams...)
|
||||||
|
|
|
@ -59,51 +59,51 @@ func newNotary() *Notary {
|
||||||
manifest.NewParameter("from", smartcontract.Hash160Type),
|
manifest.NewParameter("from", smartcontract.Hash160Type),
|
||||||
manifest.NewParameter("amount", smartcontract.IntegerType),
|
manifest.NewParameter("amount", smartcontract.IntegerType),
|
||||||
manifest.NewParameter("data", smartcontract.AnyType))
|
manifest.NewParameter("data", smartcontract.AnyType))
|
||||||
md := newMethodAndPrice(n.onPayment, 100_0000, smartcontract.AllowModifyStates)
|
md := newMethodAndPrice(n.onPayment, 100_0000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("lockDepositUntil", smartcontract.BoolType,
|
desc = newDescriptor("lockDepositUntil", smartcontract.BoolType,
|
||||||
manifest.NewParameter("address", smartcontract.Hash160Type),
|
manifest.NewParameter("address", smartcontract.Hash160Type),
|
||||||
manifest.NewParameter("till", smartcontract.IntegerType))
|
manifest.NewParameter("till", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(n.lockDepositUntil, 100_0000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.lockDepositUntil, 100_0000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("withdraw", smartcontract.BoolType,
|
desc = newDescriptor("withdraw", smartcontract.BoolType,
|
||||||
manifest.NewParameter("from", smartcontract.Hash160Type),
|
manifest.NewParameter("from", smartcontract.Hash160Type),
|
||||||
manifest.NewParameter("to", smartcontract.Hash160Type))
|
manifest.NewParameter("to", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(n.withdraw, 100_0000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.withdraw, 100_0000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("balanceOf", smartcontract.IntegerType,
|
desc = newDescriptor("balanceOf", smartcontract.IntegerType,
|
||||||
manifest.NewParameter("addr", smartcontract.Hash160Type))
|
manifest.NewParameter("addr", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(n.balanceOf, 100_0000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.balanceOf, 100_0000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("expirationOf", smartcontract.IntegerType,
|
desc = newDescriptor("expirationOf", smartcontract.IntegerType,
|
||||||
manifest.NewParameter("addr", smartcontract.Hash160Type))
|
manifest.NewParameter("addr", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(n.expirationOf, 100_0000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.expirationOf, 100_0000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("verify", smartcontract.BoolType,
|
desc = newDescriptor("verify", smartcontract.BoolType,
|
||||||
manifest.NewParameter("signature", smartcontract.SignatureType))
|
manifest.NewParameter("signature", smartcontract.SignatureType))
|
||||||
md = newMethodAndPrice(n.verify, 100_0000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.verify, 100_0000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getMaxNotValidBeforeDelta", smartcontract.IntegerType)
|
desc = newDescriptor("getMaxNotValidBeforeDelta", smartcontract.IntegerType)
|
||||||
md = newMethodAndPrice(n.getMaxNotValidBeforeDelta, 100_0000, smartcontract.AllowStates)
|
md = newMethodAndPrice(n.getMaxNotValidBeforeDelta, 100_0000, smartcontract.ReadStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("setMaxNotValidBeforeDelta", smartcontract.BoolType,
|
desc = newDescriptor("setMaxNotValidBeforeDelta", smartcontract.BoolType,
|
||||||
manifest.NewParameter("value", smartcontract.IntegerType))
|
manifest.NewParameter("value", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(n.setMaxNotValidBeforeDelta, 300_0000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(n.setMaxNotValidBeforeDelta, 300_0000, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(n.OnPersist), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(n.OnPersist), 0, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.WriteStates)
|
||||||
n.AddMethod(md, desc)
|
n.AddMethod(md, desc)
|
||||||
|
|
||||||
return n
|
return n
|
||||||
|
|
|
@ -111,11 +111,11 @@ func newOracle() *Oracle {
|
||||||
manifest.NewParameter("callback", smartcontract.StringType),
|
manifest.NewParameter("callback", smartcontract.StringType),
|
||||||
manifest.NewParameter("userData", smartcontract.AnyType),
|
manifest.NewParameter("userData", smartcontract.AnyType),
|
||||||
manifest.NewParameter("gasForResponse", smartcontract.IntegerType))
|
manifest.NewParameter("gasForResponse", smartcontract.IntegerType))
|
||||||
md := newMethodAndPrice(o.request, oracleRequestPrice, smartcontract.AllowModifyStates)
|
md := newMethodAndPrice(o.request, oracleRequestPrice, smartcontract.WriteStates)
|
||||||
o.AddMethod(md, desc)
|
o.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("finish", smartcontract.VoidType)
|
desc = newDescriptor("finish", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(o.finish, 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(o.finish, 0, smartcontract.WriteStates)
|
||||||
o.AddMethod(md, desc)
|
o.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("verify", smartcontract.BoolType)
|
desc = newDescriptor("verify", smartcontract.BoolType)
|
||||||
|
@ -124,11 +124,11 @@ func newOracle() *Oracle {
|
||||||
|
|
||||||
pp := chainOnPersist(postPersistBase, o.PostPersist)
|
pp := chainOnPersist(postPersistBase, o.PostPersist)
|
||||||
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(pp), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(pp), 0, smartcontract.WriteStates)
|
||||||
o.AddMethod(md, desc)
|
o.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(onPersistBase), 0, smartcontract.WriteStates)
|
||||||
o.AddMethod(md, desc)
|
o.AddMethod(md, desc)
|
||||||
|
|
||||||
o.AddEvent("OracleRequest", manifest.NewParameter("Id", smartcontract.IntegerType),
|
o.AddEvent("OracleRequest", manifest.NewParameter("Id", smartcontract.IntegerType),
|
||||||
|
|
|
@ -74,62 +74,62 @@ func newPolicy() *Policy {
|
||||||
p.ContractID = policyContractID
|
p.ContractID = policyContractID
|
||||||
|
|
||||||
desc := newDescriptor("getMaxTransactionsPerBlock", smartcontract.IntegerType)
|
desc := newDescriptor("getMaxTransactionsPerBlock", smartcontract.IntegerType)
|
||||||
md := newMethodAndPrice(p.getMaxTransactionsPerBlock, 1000000, smartcontract.AllowStates)
|
md := newMethodAndPrice(p.getMaxTransactionsPerBlock, 1000000, smartcontract.ReadStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getMaxBlockSize", smartcontract.IntegerType)
|
desc = newDescriptor("getMaxBlockSize", smartcontract.IntegerType)
|
||||||
md = newMethodAndPrice(p.getMaxBlockSize, 1000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(p.getMaxBlockSize, 1000000, smartcontract.ReadStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getFeePerByte", smartcontract.IntegerType)
|
desc = newDescriptor("getFeePerByte", smartcontract.IntegerType)
|
||||||
md = newMethodAndPrice(p.getFeePerByte, 1000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(p.getFeePerByte, 1000000, smartcontract.ReadStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("isBlocked", smartcontract.BoolType,
|
desc = newDescriptor("isBlocked", smartcontract.BoolType,
|
||||||
manifest.NewParameter("account", smartcontract.Hash160Type))
|
manifest.NewParameter("account", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(p.isBlocked, 1000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(p.isBlocked, 1000000, smartcontract.ReadStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("getMaxBlockSystemFee", smartcontract.IntegerType)
|
desc = newDescriptor("getMaxBlockSystemFee", smartcontract.IntegerType)
|
||||||
md = newMethodAndPrice(p.getMaxBlockSystemFee, 1000000, smartcontract.AllowStates)
|
md = newMethodAndPrice(p.getMaxBlockSystemFee, 1000000, smartcontract.ReadStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("setMaxBlockSize", smartcontract.BoolType,
|
desc = newDescriptor("setMaxBlockSize", smartcontract.BoolType,
|
||||||
manifest.NewParameter("value", smartcontract.IntegerType))
|
manifest.NewParameter("value", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(p.setMaxBlockSize, 3000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(p.setMaxBlockSize, 3000000, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("setMaxTransactionsPerBlock", smartcontract.BoolType,
|
desc = newDescriptor("setMaxTransactionsPerBlock", smartcontract.BoolType,
|
||||||
manifest.NewParameter("value", smartcontract.IntegerType))
|
manifest.NewParameter("value", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(p.setMaxTransactionsPerBlock, 3000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(p.setMaxTransactionsPerBlock, 3000000, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("setFeePerByte", smartcontract.BoolType,
|
desc = newDescriptor("setFeePerByte", smartcontract.BoolType,
|
||||||
manifest.NewParameter("value", smartcontract.IntegerType))
|
manifest.NewParameter("value", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(p.setFeePerByte, 3000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(p.setFeePerByte, 3000000, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("setMaxBlockSystemFee", smartcontract.BoolType,
|
desc = newDescriptor("setMaxBlockSystemFee", smartcontract.BoolType,
|
||||||
manifest.NewParameter("value", smartcontract.IntegerType))
|
manifest.NewParameter("value", smartcontract.IntegerType))
|
||||||
md = newMethodAndPrice(p.setMaxBlockSystemFee, 3000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(p.setMaxBlockSystemFee, 3000000, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("blockAccount", smartcontract.BoolType,
|
desc = newDescriptor("blockAccount", smartcontract.BoolType,
|
||||||
manifest.NewParameter("account", smartcontract.Hash160Type))
|
manifest.NewParameter("account", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(p.blockAccount, 3000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(p.blockAccount, 3000000, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("unblockAccount", smartcontract.BoolType,
|
desc = newDescriptor("unblockAccount", smartcontract.BoolType,
|
||||||
manifest.NewParameter("account", smartcontract.Hash160Type))
|
manifest.NewParameter("account", smartcontract.Hash160Type))
|
||||||
md = newMethodAndPrice(p.unblockAccount, 3000000, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(p.unblockAccount, 3000000, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
desc = newDescriptor("onPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(p.OnPersist), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(p.OnPersist), 0, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
desc = newDescriptor("postPersist", smartcontract.VoidType)
|
||||||
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.AllowModifyStates)
|
md = newMethodAndPrice(getOnPersistWrapper(postPersistBase), 0, smartcontract.WriteStates)
|
||||||
p.AddMethod(md, desc)
|
p.AddMethod(md, desc)
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ func newTestNative() *testNative {
|
||||||
tn.meta.AddMethod(md, desc)
|
tn.meta.AddMethod(md, desc)
|
||||||
|
|
||||||
desc = &manifest.Method{Name: "onPersist", ReturnType: smartcontract.BoolType}
|
desc = &manifest.Method{Name: "onPersist", ReturnType: smartcontract.BoolType}
|
||||||
md = &interop.MethodAndPrice{Func: tn.OnPersist, RequiredFlags: smartcontract.AllowModifyStates}
|
md = &interop.MethodAndPrice{Func: tn.OnPersist, RequiredFlags: smartcontract.WriteStates}
|
||||||
tn.meta.AddMethod(md, desc)
|
tn.meta.AddMethod(md, desc)
|
||||||
|
|
||||||
return tn
|
return tn
|
||||||
|
|
|
@ -20,12 +20,13 @@ type CallFlag byte
|
||||||
// Using `smartcontract` package from compiled contract requires moderate
|
// Using `smartcontract` package from compiled contract requires moderate
|
||||||
// compiler refactoring, thus all flags are mirrored here.
|
// compiler refactoring, thus all flags are mirrored here.
|
||||||
const (
|
const (
|
||||||
AllowStates CallFlag = 1 << iota
|
ReadStates CallFlag = 1 << iota
|
||||||
AllowModifyStates
|
WriteStates
|
||||||
AllowCall
|
AllowCall
|
||||||
AllowNotify
|
AllowNotify
|
||||||
ReadOnly = AllowStates | AllowCall | AllowNotify
|
States = ReadStates | WriteStates
|
||||||
All = ReadOnly | AllowModifyStates
|
ReadOnly = ReadStates | AllowCall
|
||||||
|
All = States | AllowCall | AllowNotify
|
||||||
NoneFlag CallFlag = 0
|
NoneFlag CallFlag = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,14 @@ type CallFlag byte
|
||||||
|
|
||||||
// Default flags.
|
// Default flags.
|
||||||
const (
|
const (
|
||||||
AllowStates CallFlag = 1 << iota
|
ReadStates CallFlag = 1 << iota
|
||||||
AllowModifyStates
|
WriteStates
|
||||||
AllowCall
|
AllowCall
|
||||||
AllowNotify
|
AllowNotify
|
||||||
ReadOnly = AllowStates | AllowCall | AllowNotify
|
|
||||||
All = ReadOnly | AllowModifyStates
|
States = ReadStates | WriteStates
|
||||||
|
ReadOnly = ReadStates | AllowCall
|
||||||
|
All = States | AllowCall | AllowNotify
|
||||||
NoneFlag CallFlag = 0
|
NoneFlag CallFlag = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue