diff --git a/pkg/core/interop_neo.go b/pkg/core/interop_neo.go index e8dfda15d..0507764dc 100644 --- a/pkg/core/interop_neo.go +++ b/pkg/core/interop_neo.go @@ -540,7 +540,7 @@ func contractMigrate(ic *interop.Context, v *vm.VM) error { return err } if contract.HasStorage() { - hash := v.GetContextScriptHash(0) + hash := v.GetCurrentScriptHash() siMap, err := ic.DAO.GetStorageItems(hash) if err != nil { return err diff --git a/pkg/core/interop_system.go b/pkg/core/interop_system.go index 396534c8a..30f085f7c 100644 --- a/pkg/core/interop_system.go +++ b/pkg/core/interop_system.go @@ -292,7 +292,7 @@ func runtimeNotify(ic *interop.Context, v *vm.VM) error { if err != nil { item = vm.NewByteArrayItem([]byte(fmt.Sprintf("bad notification: %v", err))) } - ne := state.NotificationEvent{ScriptHash: v.GetContextScriptHash(0), Item: item} + ne := state.NotificationEvent{ScriptHash: v.GetCurrentScriptHash(), Item: item} ic.Notifications = append(ic.Notifications, ne) return nil } @@ -301,7 +301,7 @@ func runtimeNotify(ic *interop.Context, v *vm.VM) error { func runtimeLog(ic *interop.Context, v *vm.VM) error { msg := fmt.Sprintf("%q", v.Estack().Pop().Bytes()) ic.Log.Info("runtime log", - zap.Stringer("script", v.GetContextScriptHash(0)), + zap.Stringer("script", v.GetCurrentScriptHash()), zap.String("logs", msg)) return nil } @@ -383,7 +383,7 @@ func storageGet(ic *interop.Context, v *vm.VM) error { // storageGetContext returns storage context (scripthash). func storageGetContext(ic *interop.Context, v *vm.VM) error { sc := &StorageContext{ - ScriptHash: v.GetContextScriptHash(0), + ScriptHash: v.GetCurrentScriptHash(), ReadOnly: false, } v.Estack().PushVal(vm.NewInteropItem(sc)) @@ -393,7 +393,7 @@ func storageGetContext(ic *interop.Context, v *vm.VM) error { // storageGetReadOnlyContext returns read-only context (scripthash). func storageGetReadOnlyContext(ic *interop.Context, v *vm.VM) error { sc := &StorageContext{ - ScriptHash: v.GetContextScriptHash(0), + ScriptHash: v.GetCurrentScriptHash(), ReadOnly: true, } v.Estack().PushVal(vm.NewInteropItem(sc)) @@ -475,7 +475,7 @@ func contractDestroy(ic *interop.Context, v *vm.VM) error { if ic.Trigger != trigger.Application { return errors.New("can't destroy contract when not triggered by application") } - hash := v.GetContextScriptHash(0) + hash := v.GetCurrentScriptHash() cs, err := ic.DAO.GetContractState(hash) if err != nil { return nil diff --git a/pkg/core/native/contract.go b/pkg/core/native/contract.go index a4b83e751..a16df5af8 100644 --- a/pkg/core/native/contract.go +++ b/pkg/core/native/contract.go @@ -69,7 +69,7 @@ func (cs *Contracts) GetNativeInterop(ic *interop.Context) func(uint32) *vm.Inte // getNativeInterop returns native contract interop. func getNativeInterop(ic *interop.Context, c interop.Contract) func(v *vm.VM) error { return func(v *vm.VM) error { - h := v.GetContextScriptHash(0) + h := v.GetCurrentScriptHash() if !h.Equals(c.Metadata().Hash) { return errors.New("invalid hash") } diff --git a/pkg/vm/context.go b/pkg/vm/context.go index 14b039dfd..3a799b13c 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -223,9 +223,9 @@ func (c *Context) String() string { return "execution context" } -// GetContextScriptHash returns script hash of the invocation stack element +// getContextScriptHash returns script hash of the invocation stack element // number n. -func (v *VM) GetContextScriptHash(n int) util.Uint160 { +func (v *VM) getContextScriptHash(n int) util.Uint160 { element := v.Istack().Peek(n) if element == nil { return util.Uint160{} @@ -238,7 +238,7 @@ func (v *VM) GetContextScriptHash(n int) util.Uint160 { // PushContextScriptHash pushes to evaluation stack the script hash of the // invocation stack element number n. func (v *VM) PushContextScriptHash(n int) error { - h := v.GetContextScriptHash(n) + h := v.getContextScriptHash(n) v.Estack().PushVal(h.BytesBE()) return nil } diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 6daeae0cc..573d28159 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -1537,15 +1537,15 @@ func (v *VM) bytesToPublicKey(b []byte) *keys.PublicKey { // GetCallingScriptHash implements ScriptHashGetter interface func (v *VM) GetCallingScriptHash() util.Uint160 { - return v.GetContextScriptHash(1) + return v.getContextScriptHash(1) } // GetEntryScriptHash implements ScriptHashGetter interface func (v *VM) GetEntryScriptHash() util.Uint160 { - return v.GetContextScriptHash(v.Istack().Len() - 1) + return v.getContextScriptHash(v.Istack().Len() - 1) } // GetCurrentScriptHash implements ScriptHashGetter interface func (v *VM) GetCurrentScriptHash() util.Uint160 { - return v.GetContextScriptHash(0) + return v.getContextScriptHash(0) }