Added contract id to the instance create message (#19)

This commit is contained in:
Chalith Desaman
2021-06-28 10:41:08 +05:30
committed by GitHub
parent 7dd0ea97b5
commit c8df2e75ac
9 changed files with 56 additions and 15 deletions

View File

@@ -109,6 +109,7 @@ namespace msg::json
* {
* "type": "create",
* "owner_pubkey": "<pubkey of the owner>"
* "contract_id": "<contract id>"
* }
* @return 0 on successful extraction. -1 for failure.
*/
@@ -116,6 +117,20 @@ namespace msg::json
{
if (extract_commons(msg.type, msg.id, msg.pubkey, d) == -1)
return -1;
if (!d.contains(msg::FLD_CONTRACT_ID))
{
LOG_ERROR << "Field contract_id is missing.";
return -1;
}
if (!d[msg::FLD_CONTRACT_ID].is<std::string>())
{
LOG_ERROR << "Invalid contract_id value.";
return -1;
}
msg.contract_id = d[msg::FLD_CONTRACT_ID].as<std::string>();
return 0;
}

View File

@@ -10,6 +10,7 @@ namespace msg
std::string id;
std::string type;
std::string pubkey;
std::string contract_id;
};
struct destroy_msg
@@ -42,6 +43,7 @@ namespace msg
constexpr const char *FLD_CONTENT = "content";
constexpr const char *FLD_PUBKEY = "owner_pubkey";
constexpr const char *FLD_CONTAINER_NAME = "container_name";
constexpr const char *FLD_CONTRACT_ID = "contract_id";
constexpr const char *FLD_ID = "id";
// Message types