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

Commit

Permalink
Merge pull request #264 from elucidsoft/memo-text-fix
Browse files Browse the repository at this point in the history
Added missing Memo Text from TransactionResponse.cs
  • Loading branch information
fracek authored Jun 4, 2020
2 parents 5a7e1f8 + 8685a20 commit f5f875e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
15 changes: 15 additions & 0 deletions stellar-dotnet-sdk-test/responses/TransactionDeserializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ public void TestDeserializeWithoutMemo()
Assert.IsTrue(transaction.Memo is MemoNone);
}

[TestMethod]
public void TestDeserializeWithMemoText()
{
var json = File.ReadAllText(Path.Combine("testdata", "transactionTransactionWithMemo.json"));
var transaction = JsonSingleton.GetInstance<TransactionResponse>(json);
TransactionResponse copyTransaction = new TransactionResponse(transaction.Hash, transaction.Ledger, transaction.CreatedAt, transaction.SourceAccount,
transaction.FeeAccount, transaction.Successful, transaction.PagingToken, transaction.SourceAccountSequence,
transaction.MaxFee, transaction.FeeCharged, transaction.OperationCount, transaction.EnvelopeXdr,
transaction.ResultXdr, transaction.ResultMetaXdr, transaction.Memo, transaction.Signatures,
transaction.FeeBumpTx, transaction.InnerTx, transaction.Links);

Assert.AreEqual(transaction.MemoValue, copyTransaction.MemoValue);
Assert.IsFalse(transaction.Successful);
}

[TestMethod]
public void TestDeserializeTransactionPreProtocol13()
{
Expand Down
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 @@ -254,6 +254,9 @@
<None Update="testdata\transactionTransaction.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\transactionTransactionWithMemo.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\transactionTransactionWithoutMemo.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"_links": {
"account": {
"href": "/accounts/GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK"
},
"effects": {
"href": "/transactions/5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b/effects{?cursor,limit,order}",
"templated": true
},
"ledger": {
"href": "/ledgers/915744"
},
"operations": {
"href": "/transactions/5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b/operations{?cursor,limit,order}",
"templated": true
},
"precedes": {
"href": "/transactions?cursor=3933090531512320\\u0026order=asc"
},
"self": {
"href": "/transactions/5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b"
},
"succeeds": {
"href": "/transactions?cursor=3933090531512320\\u0026order=desc"
}
},
"id": "5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b",
"paging_token": "3933090531512320",
"hash": "5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b",
"ledger": 915744,
"created_at": "2015-11-20T17:01:28Z",
"source_account": "GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK",
"source_account_sequence": 2373051035426646,
"fee_paid": 100,
"fee_charged": 100,
"max_fee": 1050,
"operation_count": 1,
"envelope_xdr": "AAAAAKgfpXwD1fWpPmZL+GkzWcBmhRQH7ouPsoTN3RoaGCfrAAAAZAAIbkcAAB9WAAAAAAAAAANRBBZE6D1qyGjISUGLY5Ldvp31PwAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAP1qe44j+i4uIT+arbD4QDQBt8ryEeJd7a0jskQ3nwDeAAAAAAAAAADA7RnarSzCwj3OT+M2btCMFpVBdqxJS+Sr00qBjtFv7gAAAABLCs/QAAAAAAAAAAEaGCfrAAAAQG/56Cj2J8W/KCZr+oC4sWND1CTGWfaccHNtuibQH8kZIb+qBSDY94g7hiaAXrlIeg9b7oz/XuP3x9MWYw2jtwM=",
"result_xdr": "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=",
"result_meta_xdr": "AAAAAAAAAAEAAAACAAAAAAAN+SAAAAAAAAAAAMDtGdqtLMLCPc5P4zZu0IwWlUF2rElL5KvTSoGO0W/uAAAAAEsKz9AADfkgAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQAN+SAAAAAAAAAAAP1qe44j+i4uIT+arbD4QDQBt8ryEeJd7a0jskQ3nwDeAAHp6WMr55YACD1BAAAAHgAAAAoAAAAAAAAAAAAAAAABAAAAAAAACgAAAAARC07BokpLTOF+/vVKBwiAlop7hHGJTNeGGlY4MoPykwAAAAEAAAAAK+Lzfd3yDD+Ov0GbYu1g7SaIBrKZeBUxoCunkLuI7aoAAAABAAAAAERmsKL73CyLV/HvjyQCERDXXpWE70Xhyb6MR5qPO3yQAAAAAQAAAABSORGwAdyuanN3sNOHqNSpACyYdkUM3L8VafUu69EvEgAAAAEAAAAAeCzqJNkMM/jLvyuMIfyFHljBlLCtDyj17RMycPuNtRMAAAABAAAAAIEi4R7juq15ymL00DNlAddunyFT4FyUD4muC4t3bobdAAAAAQAAAACaNpLL5YMfjOTdXVEqrAh99LM12sN6He6pHgCRAa1f1QAAAAEAAAAAqB+lfAPV9ak+Zkv4aTNZwGaFFAfui4+yhM3dGhoYJ+sAAAABAAAAAMNJrEvdMg6M+M+n4BDIdzsVSj/ZI9SvAp7mOOsvAD/WAAAAAQAAAADbHA6xiKB1+G79mVqpsHMOleOqKa5mxDpP5KEp/Xdz9wAAAAEAAAAAAAAAAA==",
"memo_type": "text",
"memo": "Some sample text",
"successful": false,
"signatures": [
"b/noKPYnxb8oJmv6gLixY0PUJMZZ9pxwc226JtAfyRkhv6oFINj3iDuGJoBeuUh6D1vujP9e4/fH0xZjDaO3Aw=="
]
}
8 changes: 7 additions & 1 deletion stellar-dotnet-sdk/responses/TransactionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public Memo Memo
switch (MemoType)
{
case "none":
return Memo.None();
return Memo.None();
case "text":
return Memo.Text(MemoValue);
case "id":
return Memo.Id(ulong.Parse(MemoValue));
case "hash":
Expand All @@ -96,6 +98,10 @@ private set
case MemoNone _:
MemoType = "none";
MemoValue = null;
return;
case MemoText text:
MemoType = "text";
MemoValue = text.MemoTextValue;
return;
case MemoId id:
MemoType = "id";
Expand Down

0 comments on commit f5f875e

Please sign in to comment.