Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Merge 304ff43 into 5667ca5
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirbyrawr committed Apr 28, 2020
2 parents 5667ca5 + 304ff43 commit 8db5d49
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 55 deletions.
32 changes: 30 additions & 2 deletions stellar-dotnet-sdk-test/responses/TransactionDeserializerTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using stellar_dotnet_sdk;
Expand Down Expand Up @@ -62,7 +63,7 @@ public static void AssertTestData(TransactionResponse transaction)
transaction.ResultMetaXdr);

Assert.IsTrue(transaction.Memo is MemoHash);
var memo = (MemoHash) transaction.Memo;
var memo = (MemoHash)transaction.Memo;
Assert.AreEqual("51041644e83d6ac868c849418b6392ddbe9df53f000000000000000000000000", memo.GetHexValue());

Assert.AreEqual("/accounts/GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK",
Expand All @@ -89,5 +90,32 @@ public void TestDeserializeWithoutMemo()
Assert.IsFalse(transaction.Successful);
Assert.IsTrue(transaction.Memo is MemoNone);
}

[TestMethod]
public void TestDeserializeFeeBump()
{
var json = File.ReadAllText(Path.Combine("testdata", "transactionFeeBump.json"));
var transaction = JsonSingleton.GetInstance<TransactionResponse>(json);

Assert.AreEqual(transaction.Hash, "3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352");
Assert.AreEqual(transaction.Ledger, 123L);
Assert.AreEqual(transaction.Successful, true);
Assert.AreEqual(transaction.SourceAccount, "GABQGAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB2MX");
Assert.AreEqual(transaction.FeeAccount, "GABAEAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGKJ");
Assert.AreEqual(transaction.SourceAccountSequence, 97L);
Assert.AreEqual(transaction.MaxFee, 776L);
Assert.AreEqual(transaction.FeeCharged, 123L);
Assert.AreEqual(transaction.OperationCount, 1);
CollectionAssert.AreEqual(transaction.Signatures, new List<string>() { "Hh4e" });

TransactionResponse.FeeBumpTransaction feeBumpTransaction = transaction.FeeBumpTx;
Assert.AreEqual(feeBumpTransaction.Hash, "3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352");
CollectionAssert.AreEqual(feeBumpTransaction.Signatures, new List<string>() { "Hh4e" });

TransactionResponse.InnerTransaction innerTransaction = transaction.InnerTx;
Assert.AreEqual(innerTransaction.Hash, "e98869bba8bce08c10b78406202127f3888c25454cd37b02600862452751f526");
Assert.AreEqual(innerTransaction.MaxFee, 99L);
CollectionAssert.AreEqual(innerTransaction.Signatures, new List<string> { "FBQU" });
}
}
}
3 changes: 3 additions & 0 deletions stellar-dotnet-sdk-test/stellar-dotnet-sdk-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
<None Update="testdata\transactionPage.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\transactionFeeBump.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\transactionTransaction.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
65 changes: 65 additions & 0 deletions stellar-dotnet-sdk-test/testdata/transactionFeeBump.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"_links": {
"self": {
"href": "transactions/3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352"
},
"account": {
"href": "/accounts/GABQGAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB2MX"
},
"ledger": {
"href": "ledgers/123"
},
"operations": {
"href": "transactions/3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352/operations{?cursor,limit,order}",
"templated": true
},
"effects": {
"href": "transactions/3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352/effects{?cursor,limit,order}",
"templated": true
},
"precedes": {
"href": "transactions?order=asc&cursor=528280981504"
},
"succeeds": {
"href": "transactions?order=desc&cursor=528280981504"
},
"transaction": {
"href": "transactions/3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352"
}
},
"id": "3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352",
"paging_token": "528280981504",
"successful": true,
"hash": "3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352",
"ledger": 123,
"created_at": "2020-04-21T10:21:26Z",
"source_account": "GABQGAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB2MX",
"source_account_sequence": "97",
"fee_account": "GABAEAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGKJ",
"fee_charged": 123,
"max_fee": 776,
"operation_count": 1,
"envelope_xdr": "AAAABQAAAAACAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMIAAAAAgAAAAADAwMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGMAAAAAAAAAYQAAAAEAAAAAAAAAAgAAAAAAAAAEAAAAAAAAAAEAAAAAAAAACwAAAAAAAABiAAAAAAAAAAECAgICAAAAAxQUFAAAAAAAAAAAAQMDAwMAAAADHh4eAA==",
"result_xdr": "AAAAAAAAAHsAAAAB6Yhpu6i84IwQt4QGICEn84iMJUVM03sCYAhiRSdR9SYAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAsAAAAAAAAAAAAAAAA=",
"result_meta_xdr": "AAAAAQAAAAAAAAAA",
"fee_meta_xdr": "AAAAAA==",
"memo_type": "none",
"signatures": [
"Hh4e"
],
"valid_after": "1970-01-01T00:00:02Z",
"valid_before": "1970-01-01T00:00:04Z",
"fee_bump_transaction": {
"hash": "3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352",
"signatures": [
"Hh4e"
]
},
"inner_transaction": {
"hash": "e98869bba8bce08c10b78406202127f3888c25454cd37b02600862452751f526",
"signatures": [
"FBQU"
],
"max_fee": "99"
}
}
151 changes: 98 additions & 53 deletions stellar-dotnet-sdk/responses/TransactionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using stellar_dotnet_sdk.responses.effects;
using stellar_dotnet_sdk.responses.operations;
using stellar_dotnet_sdk.responses.page;

using System.Collections.Generic;

namespace stellar_dotnet_sdk.responses
{
public class TransactionResponse : Response, IPagingToken
Expand All @@ -19,7 +20,10 @@ public class TransactionResponse : Response, IPagingToken
public string CreatedAt { get; private set; }

[JsonProperty(PropertyName = "source_account")]
public string SourceAccount { get; private set; }
public string SourceAccount { get; private set; }

[JsonProperty(PropertyName = "fee_account")]
public string FeeAccount { get; set; }

[DefaultValue(true)]
[JsonProperty(PropertyName = "successful", DefaultValueHandling = DefaultValueHandling.Populate)]
Expand All @@ -31,9 +35,6 @@ public class TransactionResponse : Response, IPagingToken
[JsonProperty(PropertyName = "source_account_sequence")]
public long SourceAccountSequence { get; private set; }

[JsonProperty(PropertyName = "fee_account")]
public long FeeAccount { get; set; }

[JsonProperty(PropertyName = "fee_charged")]
public long FeeCharged { get; set; }

Expand All @@ -50,7 +51,16 @@ public class TransactionResponse : Response, IPagingToken
public string ResultXdr { get; private set; }

[JsonProperty(PropertyName = "result_meta_xdr")]
public string ResultMetaXdr { get; private set; }
public string ResultMetaXdr { get; private set; }

[JsonProperty(PropertyName = "signatures")]
public List<string> Signatures { get; private set; }

[JsonProperty(PropertyName = "fee_bump_transaction")]
public FeeBumpTransaction FeeBumpTx { get; set; }

[JsonProperty(PropertyName = "inner_transaction")]
public InnerTransaction InnerTx { get; private set; }

[JsonProperty(PropertyName = "_links")]
public TransactionResponseLinks Links { get; private set; }
Expand All @@ -61,9 +71,6 @@ public class TransactionResponse : Response, IPagingToken
[JsonProperty(PropertyName = "memo")]
public string MemoValue { get; private set; }

[JsonProperty(PropertyName = "fee_bump_transaction")]
public FeeBumpTransaction FeeBumpTransaction { get; set; }

public Memo Memo
{
get
Expand Down Expand Up @@ -115,9 +122,10 @@ public TransactionResponse()
// Used by deserializer
}

public TransactionResponse(string hash, uint ledger, string createdAt, string sourceAccount, bool successful,
public TransactionResponse(string hash, uint ledger, string createdAt, string sourceAccount, string feeAccount, bool successful,
string pagingToken, long sourceAccountSequence, long feePaid, int operationCount, string envelopeXdr,
string resultXdr, string resultMetaXdr, Memo memo, TransactionResponseLinks links)
string resultXdr, string resultMetaXdr, Memo memo, List<String> signatures,
FeeBumpTransaction feeBumpTransaction, InnerTransaction innerTransaction, TransactionResponseLinks links)
{
Hash = hash;
Ledger = ledger;
Expand All @@ -130,48 +138,85 @@ public TransactionResponse()
EnvelopeXdr = envelopeXdr;
ResultXdr = resultXdr;
ResultMetaXdr = resultMetaXdr;
Memo = memo;
Memo = memo;
Signatures = signatures;
FeeBumpTx = feeBumpTransaction;
InnerTx = innerTransaction;
Links = links;
}

///
/// Links connected to transaction.
///
public class TransactionResponseLinks
{
[JsonProperty(PropertyName = "account")]
public Link<AccountResponse> Account { get; private set; }

[JsonProperty(PropertyName = "effects")]
public Link<Page<EffectResponse>> Effects { get; private set; }

[JsonProperty(PropertyName = "ledger")]
public Link<LedgerResponse> Ledger { get; private set; }

[JsonProperty(PropertyName = "operations")]
public Link<Page<OperationResponse>> Operations { get; private set; }

[JsonProperty(PropertyName = "precedes")]
public Link<TransactionResponse> Precedes { get; private set; }

[JsonProperty(PropertyName = "self")]
public Link<TransactionResponse> Self { get; private set; }

[JsonProperty(PropertyName = "succeeds")]
public Link<TransactionResponse> Succeeds { get; private set; }

public TransactionResponseLinks(Link<AccountResponse> account, Link<Page<EffectResponse>> effects,
Link<LedgerResponse> ledger, Link<Page<OperationResponse>> operations, Link<TransactionResponse> self,
Link<TransactionResponse> precedes, Link<TransactionResponse> succeeds)
{
Account = account;
Effects = effects;
Ledger = ledger;
Operations = operations;
Self = self;
Precedes = precedes;
Succeeds = succeeds;
}
}
}

public class FeeBumpTransaction
{
[JsonProperty(PropertyName = "hash")]
public string Hash { get; private set; }

[JsonProperty(PropertyName = "signatures")]
public List<string> Signatures { get; private set; }

public FeeBumpTransaction(string hash, List<string> signatures)
{
Hash = hash;
Signatures = signatures;
}
}

public class InnerTransaction
{
[JsonProperty(PropertyName = "hash")]
public string Hash { get; private set; }

[JsonProperty(PropertyName = "signatures")]
public List<string> Signatures { get; private set; }

[JsonProperty(PropertyName = "max_fee")]
public long MaxFee { get; private set; }

public InnerTransaction(String hash, List<String> signatures, long maxFee)
{
Hash = hash;
Signatures = signatures;
MaxFee = maxFee;
}
}
}

///
/// Links connected to transaction.
///
public class TransactionResponseLinks
{
[JsonProperty(PropertyName = "account")]
public Link<AccountResponse> Account { get; private set; }

[JsonProperty(PropertyName = "effects")]
public Link<Page<EffectResponse>> Effects { get; private set; }

[JsonProperty(PropertyName = "ledger")]
public Link<LedgerResponse> Ledger { get; private set; }

[JsonProperty(PropertyName = "operations")]
public Link<Page<OperationResponse>> Operations { get; private set; }

[JsonProperty(PropertyName = "precedes")]
public Link<TransactionResponse> Precedes { get; private set; }

[JsonProperty(PropertyName = "self")]
public Link<TransactionResponse> Self { get; private set; }

[JsonProperty(PropertyName = "succeeds")]
public Link<TransactionResponse> Succeeds { get; private set; }

public TransactionResponseLinks(Link<AccountResponse> account, Link<Page<EffectResponse>> effects,
Link<LedgerResponse> ledger, Link<Page<OperationResponse>> operations, Link<TransactionResponse> self,
Link<TransactionResponse> precedes, Link<TransactionResponse> succeeds)
{
Account = account;
Effects = effects;
Ledger = ledger;
Operations = operations;
Self = self;
Precedes = precedes;
Succeeds = succeeds;
}
}
}

0 comments on commit 8db5d49

Please sign in to comment.