Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change json fields to all lower case for consistency #1736

Merged
merged 4 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/neo/Network/P2P/Payloads/BlockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public virtual JObject ToJson()
json["hash"] = Hash.ToString();
json["size"] = Size;
json["version"] = Version;
json["previousblockhash"] = PrevHash.ToString();
json["merkleroot"] = MerkleRoot.ToString();
json["previous_block_hash"] = PrevHash.ToString();
json["merkle_root"] = MerkleRoot.ToString();
json["time"] = Timestamp;
json["index"] = Index;
json["nextconsensus"] = NextConsensus.ToAddress();
json["next_consensus"] = NextConsensus.ToAddress();
json["witnesses"] = new JArray(Witness.ToJson());
return json;
}
Expand Down
4 changes: 2 additions & 2 deletions src/neo/Network/P2P/Payloads/Cosigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public override JObject ToJson()
json["account"] = Account.ToString();
json["scopes"] = Scopes;
if (Scopes.HasFlag(WitnessScope.CustomContracts))
json["allowedContracts"] = AllowedContracts.Select(p => (JObject)p.ToString()).ToArray();
json["allowed_contracts"] = AllowedContracts.Select(p => (JObject)p.ToString()).ToArray();
if (Scopes.HasFlag(WitnessScope.CustomGroups))
json["allowedGroups"] = AllowedGroups.Select(p => (JObject)p.ToString()).ToArray();
json["allowed_groups"] = AllowedGroups.Select(p => (JObject)p.ToString()).ToArray();
return json;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/neo/SmartContract/Manifest/ContractGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static ContractGroup FromJson(JObject json)
{
return new ContractGroup
{
PubKey = ECPoint.Parse(json["pubKey"].AsString(), ECCurve.Secp256r1),
PubKey = ECPoint.Parse(json["pub_key"].AsString(), ECCurve.Secp256r1),
Signature = Convert.FromBase64String(json["signature"].AsString()),
};
}
Expand All @@ -58,7 +58,7 @@ public bool IsValid(UInt160 hash)
public virtual JObject ToJson()
{
var json = new JObject();
json["pubKey"] = PubKey.ToString();
json["pub_key"] = PubKey.ToString();
json["signature"] = Convert.ToBase64String(Signature);
return json;
}
Expand Down
4 changes: 2 additions & 2 deletions src/neo/SmartContract/Manifest/ContractManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public JObject ToJson()
json["abi"] = Abi.ToJson();
json["permissions"] = Permissions.Select(p => p.ToJson()).ToArray();
json["trusts"] = Trusts.ToJson();
json["safeMethods"] = SafeMethods.ToJson();
json["safe_methods"] = SafeMethods.ToJson();
json["extra"] = Extra;

return json;
Expand Down Expand Up @@ -158,7 +158,7 @@ private void DeserializeFromJson(JObject json)
Features = ContractFeatures.NoProperty;
Permissions = ((JArray)json["permissions"]).Select(u => ContractPermission.FromJson(u)).ToArray();
Trusts = WildcardContainer<UInt160>.FromJson(json["trusts"], u => UInt160.Parse(u.AsString()));
SafeMethods = WildcardContainer<string>.FromJson(json["safeMethods"], u => u.AsString());
SafeMethods = WildcardContainer<string>.FromJson(json["safe_methods"], u => u.AsString());
Extra = json["extra"];
if (json["features"]["storage"].AsBoolean()) Features |= ContractFeatures.HasStorage;
if (json["features"]["payable"].AsBoolean()) Features |= ContractFeatures.Payable;
Expand Down
4 changes: 2 additions & 2 deletions src/neo/SmartContract/Manifest/ContractMethodDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public int Offset
Name = json["name"].AsString(),
Parameters = ((JArray)json["parameters"]).Select(u => ContractParameterDefinition.FromJson(u)).ToArray(),
Offset = (int)json["offset"].AsNumber(),
ReturnType = (ContractParameterType)Enum.Parse(typeof(ContractParameterType), json["returnType"].AsString()),
ReturnType = (ContractParameterType)Enum.Parse(typeof(ContractParameterType), json["return_type"].AsString()),
};
}

public override JObject ToJson()
{
var json = base.ToJson();
json["offset"] = Offset;
json["returnType"] = ReturnType.ToString();
json["return_type"] = ReturnType.ToString();
return json;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/neo/Wallets/NEP6/NEP6Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static NEP6Account FromJson(JObject json, NEP6Wallet wallet)
return new NEP6Account(wallet, json["address"].AsString().ToScriptHash(), json["key"]?.AsString())
{
Label = json["label"]?.AsString(),
IsDefault = json["isDefault"].AsBoolean(),
IsDefault = json["is_default"].AsBoolean(),
Lock = json["lock"].AsBoolean(),
Contract = NEP6Contract.FromJson(json["contract"]),
Extra = json["extra"]
Expand Down Expand Up @@ -65,7 +65,7 @@ public JObject ToJson()
JObject account = new JObject();
account["address"] = ScriptHash.ToAddress();
account["label"] = Label;
account["isDefault"] = IsDefault;
account["is_default"] = IsDefault;
account["lock"] = Lock;
account["key"] = nep2key;
account["contract"] = ((NEP6Contract)Contract)?.ToJson();
Expand Down
6 changes: 3 additions & 3 deletions tests/neo.UnitTests/Network/P2P/Payloads/UT_Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ public void ToJson()
jObj["hash"].AsString().Should().Be("0xac84cebc5825cbe78941b301789bc43e8906bb9d86edd80cc94591088a26d9cc");
jObj["size"].AsNumber().Should().Be(165);
jObj["version"].AsNumber().Should().Be(0);
jObj["previousblockhash"].AsString().Should().Be("0x0000000000000000000000000000000000000000000000000000000000000000");
jObj["merkleroot"].AsString().Should().Be("0xf616d65d5844a65476c8976a0849b9e171fa2fc4791b8327ddfcf1b44e0172bc");
jObj["previous_block_hash"].AsString().Should().Be("0x0000000000000000000000000000000000000000000000000000000000000000");
jObj["merkle_root"].AsString().Should().Be("0xf616d65d5844a65476c8976a0849b9e171fa2fc4791b8327ddfcf1b44e0172bc");
jObj["time"].AsNumber().Should().Be(328665601001);
jObj["index"].AsNumber().Should().Be(0);
jObj["nextconsensus"].AsString().Should().Be("NKuyBkoGdZZSLyPbJEetheRhMjeznFZszf");
jObj["next_consensus"].AsString().Should().Be("NKuyBkoGdZZSLyPbJEetheRhMjeznFZszf");

JObject scObj = ((JArray)jObj["witnesses"])[0];
scObj["invocation"].AsString().Should().Be("");
Expand Down
2 changes: 1 addition & 1 deletion tests/neo.UnitTests/Wallets/NEP6/UT_NEP6Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void TestToJson()
JObject json = _account.ToJson();
json["address"].Should().Equals("AZk5bAanTtD6AvpeesmYgL8CLRYUt5JQsX");
json["label"].Should().BeNull();
json["isDefault"].ToString().Should().Be("false");
json["is_default"].ToString().Should().Be("false");
json["lock"].ToString().Should().Be("false");
json["key"].Should().BeNull();
json["contract"]["script"].ToString().Should().Be(@"""IQNgPziA63rqCtRQCJOSXkpC/qSKRO5viYoQs8fOBdKiZ6w=""");
Expand Down