From 709c7ec738ba9d694b8ae2478d895d5fc2e03ccc Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 3 Mar 2025 18:13:10 +0800 Subject: [PATCH] Add optional options handling in objectCall.run method - Modify options unmarshaling to handle undefined JavaScript options - Add null check to prevent unmarshaling errors when no options are provided - Improve robustness of method call argument processing --- neo/assistant/call.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/neo/assistant/call.go b/neo/assistant/call.go index 532e8a7e..cc17194e 100644 --- a/neo/assistant/call.go +++ b/neo/assistant/call.go @@ -202,9 +202,12 @@ func (obj *objectCall) run(info *v8go.FunctionCallbackInfo) *v8go.Value { return bridge.JsException(info.Context(), fmt.Sprintf("Failed to get the options: %s", err.Error())) } - err = bridge.Unmarshal(jsOptions, &options) - if err != nil { - return bridge.JsException(info.Context(), fmt.Sprintf("Failed to unmarshal the options: %s", err.Error())) + // Check if the options is undefined + if !jsOptions.IsUndefined() { + err = bridge.Unmarshal(jsOptions, &options) + if err != nil { + return bridge.JsException(info.Context(), fmt.Sprintf("Failed to unmarshal the options: %s", err.Error())) + } } }