Skip to content

Commit

Permalink
Merge pull request #3 from virtualeconomy/code-compatible
Browse files Browse the repository at this point in the history
modify code compatible with lower version C# compiler
  • Loading branch information
SheldonYS authored Dec 25, 2019
2 parents f513715 + e5b7ed9 commit 2cc7e0c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
10 changes: 6 additions & 4 deletions VsysSDK/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ public class Blockchain
{
public const long V_UNITY = 100000000L;
public const int DEFAULT_TX_LIMIT = 100;
private readonly NetworkType network;
private readonly string nodeUrl;

public Blockchain(NetworkType network, string nodeUrl)
{
this.Network = network;
this.NodeUrl = nodeUrl;
this.network = network;
this.nodeUrl = nodeUrl;
}

public long? GetBalance(string address)
Expand Down Expand Up @@ -180,8 +182,8 @@ private T ParseResponse<T>(string json)
}
}

public NetworkType Network { get; }
public NetworkType Network { get { return this.network; } }

public string NodeUrl { get; }
public string NodeUrl { get { return this.nodeUrl; } }
}
}
9 changes: 8 additions & 1 deletion VsysSDK/entity/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ public class Block
public string TransactionMerkleRoot { get; set; }


public IList<ITransaction> Transactions { get; set; } = new List<ITransaction>();
private IList<ITransaction> transactions = new List<ITransaction>();


public IList<ITransaction> Transactions
{
get { return transactions; }
set { transactions = value; }
}


public string Generator { get; set; }
Expand Down
34 changes: 15 additions & 19 deletions VsysSDK/transaction/ProvenTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ public abstract class ProvenTransaction : BytesSerializableTransaction, JsonSeri

public virtual JObject ToAPIRequestJson(string publicKey, string signature)
{
JObject json = new JObject
{
["timestamp"] = this.timestamp,
["fee"] = this.fee,
["feeScale"] = this.feeScale,
["senderPublicKey"] = publicKey,
["signature"] = signature
};
JObject json = new JObject();
json["timestamp"] = this.timestamp;
json["fee"] = this.fee;
json["feeScale"] = this.feeScale;
json["senderPublicKey"] = publicKey;
json["signature"] = signature;
return json;
}

Expand All @@ -33,17 +31,15 @@ public virtual JObject ToColdSignJson(string publicKey)

public virtual JObject ToColdSignJson(string publicKey, int ApiVersion)
{
JObject json = new JObject
{
["protocol"] = "v.systems",
["api"] = ApiVersion,
["opc"] = "transaction",
["transactionType"] = this.type,
["senderPublicKey"] = publicKey,
["fee"] = this.fee,
["feeScale"] = this.feeScale,
["timestamp"] = this.timestamp
};
JObject json = new JObject();
json["protocol"] = "v.systems";
json["api"] = ApiVersion;
json["opc"] = "transaction";
json["transactionType"] = this.type;
json["senderPublicKey"] = publicKey;
json["fee"] = this.fee;
json["feeScale"] = this.feeScale;
json["timestamp"] = this.timestamp;
return json;
}

Expand Down
15 changes: 10 additions & 5 deletions VsysTest/BlockchainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,39 @@ public void GetTransactionHistoryTest()
Assert.IsNotNull(tx.Id, "Failed to get Tx Id");
Assert.IsNotNull(tx.Height, "Failed to get Tx Height (Id: " + tx.Id + ")");
Assert.IsNotNull(tx.Status, "Failed to get Tx Status (Id: " + tx.Id + ")");
if (tx is ProvenTransaction pvtx)
if (tx is ProvenTransaction)
{
ProvenTransaction pvtx = tx as ProvenTransaction;
Assert.IsNotNull(pvtx.Proofs, "Failed to get Tx Proofs (Id: " + tx.Id + ")");
Assert.IsTrue(pvtx.Proofs.Count > 0, "Tx Proofs should more than one (Id: " + tx.Id + ")");
Assert.IsNotNull(pvtx.Proofs[0].PublicKey, "Failed to get Tx PublicKey (Id: " + tx.Id + ")");
Assert.IsNotNull(pvtx.Proofs[0].Signature, "Failed to get Tx Signature (Id: " + tx.Id + ")");
}
if (tx is PaymentTransaction ptx)
if (tx is PaymentTransaction)
{
PaymentTransaction ptx = tx as PaymentTransaction;
Assert.IsNotNull(ptx.Recipient, "Failed to get Recipient for Payment Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(ptx.Amount, "Failed to get Amount for Payment Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(ptx.Attachment, "Failed to get Attachment for Payment Tx (Id: " + tx.Id + ")");
}
if (tx is LeaseTransaction ltx)
if (tx is LeaseTransaction)
{
LeaseTransaction ltx = tx as LeaseTransaction;
Assert.IsNotNull(ltx.Recipient, "Failed to get Recipient for Lease Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(ltx.Amount, "Failed to get Amount for Lease Tx (Id: " + tx.Id + ")");
}
if (tx is LeaseCancelTransaction lctx)
if (tx is LeaseCancelTransaction)
{
LeaseCancelTransaction lctx = tx as LeaseCancelTransaction;
Assert.IsNotNull(lctx.LeaseId, "Failed to get LeaseId for LeaseCancel Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(lctx.Lease, "Failed to get Lease Info for LeaseCancel Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(lctx.Lease.Id, "Failed to get Id of Lease Info for LeaseCancel Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(lctx.Lease.Recipient, "Failed to get Recipient of Lease Info for LeaseCancel Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(lctx.Lease.Amount, "Failed to get Amount of Lease Info for LeaseCancel Tx (Id: " + tx.Id + ")");
}
if (tx is MintingTransaction mtx)
if (tx is MintingTransaction)
{
MintingTransaction mtx = tx as MintingTransaction;
Assert.IsNotNull(mtx.Recipient, "Failed to get Recipient for Minting Tx (Id: " + tx.Id + ")");
Assert.IsNotNull(mtx.Amount, "Failed to get Amount for Minting Tx (Id: " + tx.Id + ")");
}
Expand Down

0 comments on commit 2cc7e0c

Please sign in to comment.