From 8c2452f9e6973bdefbc2e531a9ed88de76969c95 Mon Sep 17 00:00:00 2001 From: chalith Date: Mon, 17 Oct 2022 18:53:55 +0530 Subject: [PATCH] Changed hp environment variable format --- dependencies/hp.cfg | 2 +- evernode-bootstrap-contract | 2 +- src/msg/json/msg_json.cpp | 19 ++++++++++++++++++- src/msg/msg_common.hpp | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dependencies/hp.cfg b/dependencies/hp.cfg index b7899b3..fc67c5a 100644 --- a/dependencies/hp.cfg +++ b/dependencies/hp.cfg @@ -23,7 +23,7 @@ "unl": [], "bin_path": "", "bin_args": "", - "environment": "", + "environment": {}, "max_input_ledger_offset": 10, "consensus": { "mode": "public", diff --git a/evernode-bootstrap-contract b/evernode-bootstrap-contract index cabc4cf..2364117 160000 --- a/evernode-bootstrap-contract +++ b/evernode-bootstrap-contract @@ -1 +1 @@ -Subproject commit cabc4cfdb68de13b84e4088e9b1c2d54b017265b +Subproject commit 2364117f38cae1441da4a1d7be7a9f4a34ff3c24 diff --git a/src/msg/json/msg_json.cpp b/src/msg/json/msg_json.cpp index 85cfb46..74dd925 100644 --- a/src/msg/json/msg_json.cpp +++ b/src/msg/json/msg_json.cpp @@ -297,7 +297,24 @@ namespace msg::json msg.config.contract.execute = contract[msg::FLD_EXECUTE].as(); if (contract.contains(msg::FLD_ENVIRONMENT)) - msg.config.contract.environment = contract[msg::FLD_ENVIRONMENT].as(); + { + if (!contract[msg::FLD_ENVIRONMENT].is_object()) + { + LOG_ERROR << "Invalid environment variable value."; + return -1; + } + for (const auto &obj : contract[msg::FLD_ENVIRONMENT].object_range()) + { + // Environment variable values should be strings. + if (!obj.value().is_string()) + { + LOG_ERROR << obj.key() << " environment variable should be a string."; + return -1; + } + + msg.config.contract.environment.emplace(obj.key(), obj.value().as()); + } + } if (contract.contains(msg::FLD_MAX_INP_LEDGER_OFFSET)) msg.config.contract.max_input_ledger_offset = contract[msg::FLD_MAX_INP_LEDGER_OFFSET].as(); diff --git a/src/msg/msg_common.hpp b/src/msg/msg_common.hpp index c56222d..7b4a911 100644 --- a/src/msg/msg_common.hpp +++ b/src/msg/msg_common.hpp @@ -63,7 +63,7 @@ namespace msg std::optional roundtime; std::set unl; std::optional execute; - std::optional environment; + std::optional> environment; std::optional max_input_ledger_offset; c_log_config log; consensus_config consensus;