From 9f3c9be96a66739fac3da5d74ede2bccb3436e51 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Tue, 10 Sep 2024 18:31:38 +0200 Subject: [PATCH 1/2] added support for empty return data --- .../snippets/src/interactor_scenario/interactor_vm_query.rs | 6 +++++- sdk/core/src/data/vm.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/framework/snippets/src/interactor_scenario/interactor_vm_query.rs b/framework/snippets/src/interactor_scenario/interactor_vm_query.rs index aa9f87efb7..ad1704a5fd 100644 --- a/framework/snippets/src/interactor_scenario/interactor_vm_query.rs +++ b/framework/snippets/src/interactor_scenario/interactor_vm_query.rs @@ -41,7 +41,11 @@ impl Interactor { info!("{:#?}", result); - let raw_results: Vec> = result.data.return_data.iter().map(base64_decode).collect(); + let raw_results: Vec> = if let Some(data) = result.data.return_data { + data.iter().map(base64_decode).collect() + } else { + Vec::new() + }; step.save_response(TxResponse::from_raw_results(raw_results)); diff --git a/sdk/core/src/data/vm.rs b/sdk/core/src/data/vm.rs index 4b6e15539d..37fc60c7fd 100644 --- a/sdk/core/src/data/vm.rs +++ b/sdk/core/src/data/vm.rs @@ -85,7 +85,7 @@ pub struct StorageUpdateApi { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct VMOutputApi { - pub return_data: Vec, + pub return_data: Option>, pub return_code: String, pub return_message: String, pub gas_remaining: u64, From d3e3666f06fc7115998c3ef023950b84958453f1 Mon Sep 17 00:00:00 2001 From: Mihai Calin Luca Date: Tue, 1 Oct 2024 12:05:15 +0200 Subject: [PATCH 2/2] fix after review --- .../snippets/src/interactor_scenario/interactor_vm_query.rs | 6 +----- sdk/core/src/data/vm.rs | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/framework/snippets/src/interactor_scenario/interactor_vm_query.rs b/framework/snippets/src/interactor_scenario/interactor_vm_query.rs index ad1704a5fd..aa9f87efb7 100644 --- a/framework/snippets/src/interactor_scenario/interactor_vm_query.rs +++ b/framework/snippets/src/interactor_scenario/interactor_vm_query.rs @@ -41,11 +41,7 @@ impl Interactor { info!("{:#?}", result); - let raw_results: Vec> = if let Some(data) = result.data.return_data { - data.iter().map(base64_decode).collect() - } else { - Vec::new() - }; + let raw_results: Vec> = result.data.return_data.iter().map(base64_decode).collect(); step.save_response(TxResponse::from_raw_results(raw_results)); diff --git a/sdk/core/src/data/vm.rs b/sdk/core/src/data/vm.rs index 37fc60c7fd..f1af94b10a 100644 --- a/sdk/core/src/data/vm.rs +++ b/sdk/core/src/data/vm.rs @@ -85,7 +85,8 @@ pub struct StorageUpdateApi { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct VMOutputApi { - pub return_data: Option>, + #[serde(default)] + pub return_data: Vec, pub return_code: String, pub return_message: String, pub gas_remaining: u64,