core: add GetTransactionVMState to native Ledger contract

Close #2343.
This commit is contained in:
Anna Shaleva 2022-04-04 13:22:20 +03:00
parent 4254407a9b
commit b431e47d2a
3 changed files with 68 additions and 2 deletions

View file

@ -13,6 +13,21 @@ import (
// Hash represents Ledger contract hash.
const Hash = "\xbe\xf2\x04\x31\x40\x36\x2a\x77\xc1\x50\x99\xc7\xe6\x4c\x12\xf7\x00\xb6\x65\xda"
// VMState represents VM execution state.
type VMState uint8
// Various VM execution states.
const (
// NoneState represents NONE VM state.
NoneState VMState = 0
// HaltState represents HALT VM state.
HaltState VMState = 1
// FaultState represents FAULT VM state.
FaultState VMState = 2
// BreakState represents BREAK VM state.
BreakState VMState = 4
)
// CurrentHash represents `currentHash` method of Ledger native contract.
func CurrentHash() interop.Hash256 {
return neogointernal.CallWithToken(Hash, "currentHash", int(contract.ReadStates)).(interop.Hash256)
@ -43,3 +58,8 @@ func GetTransactionFromBlock(indexOrHash interface{}, txIndex int) *Transaction
return neogointernal.CallWithToken(Hash, "getTransactionFromBlock", int(contract.ReadStates),
indexOrHash, txIndex).(*Transaction)
}
// GetTransactionVMState represents `getTransactionVMState` method of Ledger native contract.
func GetTransactionVMState(hash interop.Hash256) VMState {
return neogointernal.CallWithToken(Hash, "getTransactionVMState", int(contract.ReadStates), hash).(VMState)
}