Skip to content

Commit

Permalink
Adding website and description
Browse files Browse the repository at this point in the history
  • Loading branch information
lock9 committed Nov 18, 2019
1 parent 18ac8fe commit 54538c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion neo.UnitTests/SmartContract/Manifest/UT_ContractManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ public void ParseFromJson_Groups()
[TestMethod]
public void ParseFromJson_Contacts()
{
var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[],""contact"":{""author"":""author"",""email"":""email""}}";
var json = @"{""groups"":[],""features"":{""storage"":false,""payable"":false},""abi"":{""hash"":""0x0000000000000000000000000000000000000000"",""entryPoint"":{""name"":""Main"",""parameters"":[{""name"":""operation"",""type"":""String""},{""name"":""args"",""type"":""Array""}],""returnType"":""Any""},""methods"":[],""events"":[]},""permissions"":[{""contract"":""*"",""methods"":""*""}],""trusts"":[],""safeMethods"":[],""contact"":{""author"":""author"",""email"":""email"",""description"":""description"",""website"":""website""}}";
var manifest = ContractManifest.Parse(json);
var manifestString = manifest.ToString();

Assert.AreEqual(manifestString, json);
Assert.AreEqual("author", manifest.Contact.Author);
Assert.AreEqual("email", manifest.Contact.Email);
Assert.AreEqual("description", manifest.Contact.Description);
Assert.AreEqual("website", manifest.Contact.Website);
}

[TestMethod]
Expand Down
8 changes: 8 additions & 0 deletions neo/SmartContract/Manifest/ContractContactInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ public class ContractContactInformation

public string Email { get; set; } = "";

public string Description { get; set; } = "";

public string Website { get; set; } = "";

public static ContractContactInformation FromJson(JObject jsonObject)
{
return jsonObject != null ? new ContractContactInformation
{
Author = jsonObject["author"]?.AsString(),
Email = jsonObject["email"]?.AsString(),
Description = jsonObject["description"]?.AsString(),
Website = jsonObject["website"]?.AsString(),
} : new ContractContactInformation();
}

Expand All @@ -25,6 +31,8 @@ public JObject ToJson()
var json = new JObject();
json["author"] = Author;
json["email"] = Email;
json["description"] = Description;
json["website"] = Website;
return json;
}
}
Expand Down

0 comments on commit 54538c0

Please sign in to comment.