mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 23:55:11 +00:00
native: add refuel
method to GAS contract
This commit is contained in:
parent
0114f9a912
commit
ac601601c1
5 changed files with 128 additions and 2 deletions
|
@ -347,6 +347,10 @@ func getTestContractState(bc *Blockchain) (*state.Contract, *state.Contract) {
|
|||
emit.Opcodes(w.BinWriter, opcode.CALLT, 1, 0, opcode.RET)
|
||||
callT2Off := w.Len()
|
||||
emit.Opcodes(w.BinWriter, opcode.CALLT, 0, 0, opcode.RET)
|
||||
refuelOff := w.Len()
|
||||
emit.Opcodes(w.BinWriter, opcode.PUSH2, opcode.PACK)
|
||||
emit.AppCallNoArgs(w.BinWriter, bc.contracts.GAS.Hash, "refuel", callflag.States|callflag.AllowNotify)
|
||||
emit.Opcodes(w.BinWriter, opcode.DROP)
|
||||
burnGasOff := w.Len()
|
||||
emit.Syscall(w.BinWriter, interopnames.SystemRuntimeBurnGas)
|
||||
emit.Opcodes(w.BinWriter, opcode.RET)
|
||||
|
@ -518,8 +522,18 @@ func getTestContractState(bc *Blockchain) (*state.Contract, *state.Contract) {
|
|||
},
|
||||
ReturnType: smartcontract.VoidType,
|
||||
},
|
||||
{
|
||||
Name: "refuelGas",
|
||||
Offset: refuelOff,
|
||||
Parameters: []manifest.Parameter{
|
||||
manifest.NewParameter("account", smartcontract.Hash160Type),
|
||||
manifest.NewParameter("gasRefuel", smartcontract.IntegerType),
|
||||
manifest.NewParameter("gasBurn", smartcontract.IntegerType),
|
||||
},
|
||||
ReturnType: smartcontract.VoidType,
|
||||
},
|
||||
}
|
||||
m.Permissions = make([]manifest.Permission, 2)
|
||||
m.Permissions = make([]manifest.Permission, 3)
|
||||
m.Permissions[0].Contract.Type = manifest.PermissionHash
|
||||
m.Permissions[0].Contract.Value = bc.contracts.NEO.Hash
|
||||
m.Permissions[0].Methods.Add("balanceOf")
|
||||
|
@ -528,6 +542,10 @@ func getTestContractState(bc *Blockchain) (*state.Contract, *state.Contract) {
|
|||
m.Permissions[1].Contract.Value = util.Uint160{}
|
||||
m.Permissions[1].Methods.Add("method")
|
||||
|
||||
m.Permissions[2].Contract.Type = manifest.PermissionHash
|
||||
m.Permissions[2].Contract.Value = bc.contracts.GAS.Hash
|
||||
m.Permissions[2].Methods.Add("refuel")
|
||||
|
||||
cs := &state.Contract{
|
||||
ContractBase: state.ContractBase{
|
||||
Hash: h,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue