Skip to content

Commit

Permalink
Fix RequestOnchainFunds incorrect hash memo (#1447)
Browse files Browse the repository at this point in the history
### Description

This sets the `memo` value to the request `memo` value.

### Context

`memo.toString()` returns the hex value of the memo but the `memo` in
the Payment object is in Base64 format, so the observer will never find
the transaction in the database.

### Testing

- `./gradlew test`

### Documentation

N/A

### Known limitations

N/A
  • Loading branch information
philipliu authored Aug 6, 2024
1 parent 6d0f746 commit 3b35f29
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ protected void updateTransactionWithRpcRequest(
if (sep6DepositInfoGenerator instanceof Sep6DepositInfoNoneGenerator) {
Memo memo = makeMemo(request.getMemo(), request.getMemoType());
if (memo != null) {
txn6.setMemo(memo.toString());
txn6.setMemo(request.getMemo());
txn6.setMemoType(memoTypeString(memoType(memo)));
}
txn6.setWithdrawAnchorAccount(request.getDestinationAccount());
Expand Down Expand Up @@ -286,7 +286,7 @@ protected void updateTransactionWithRpcRequest(
if (sep24DepositInfoGenerator instanceof Sep24DepositInfoNoneGenerator) {
Memo memo = makeMemo(request.getMemo(), request.getMemoType());
if (memo != null) {
txn24.setMemo(memo.toString());
txn24.setMemo(request.getMemo());
txn24.setMemoType(memoTypeString(memoType(memo)));
}
txn24.setWithdrawAnchorAccount(request.getDestinationAccount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class RequestOnchainFundsHandlerTest {
private const val STELLAR_USDC_ISSUER =
"GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"
private const val TEXT_MEMO = "testMemo"
private const val TEXT_MEMO_2 = "testMemo2"
private const val HASH_MEMO = "YWYwOTk2M2QtNzU3Mi00NGQ4LWE5MDktMmY2YzMzNTY="
private const val TEXT_MEMO_TYPE = "text"
private const val HASH_MEMO_TYPE = "hash"
Expand Down Expand Up @@ -558,8 +557,8 @@ class RequestOnchainFundsHandlerTest {
.amountOut(AmountAssetRequest("0.9", FIAT_USD))
.feeDetails(Amount("0.1", STELLAR_USDC).toRate())
.amountExpected(AmountRequest("1"))
.memo(TEXT_MEMO)
.memoType(TEXT_MEMO_TYPE)
.memo(HASH_MEMO)
.memoType(HASH_MEMO_TYPE)
.destinationAccount(DESTINATION_ACCOUNT)
.build()
val txn24 = JdbcSep24Transaction()
Expand Down Expand Up @@ -603,8 +602,8 @@ class RequestOnchainFundsHandlerTest {
expectedSep24Txn.amountFee = "0.1"
expectedSep24Txn.amountFeeAsset = STELLAR_USDC
expectedSep24Txn.amountExpected = "1"
expectedSep24Txn.memo = TEXT_MEMO
expectedSep24Txn.memoType = TEXT_MEMO_TYPE
expectedSep24Txn.memo = HASH_MEMO
expectedSep24Txn.memoType = HASH_MEMO_TYPE
expectedSep24Txn.toAccount = DESTINATION_ACCOUNT
expectedSep24Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT

Expand All @@ -624,8 +623,8 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep24TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.memo = HASH_MEMO
expectedResponse.memoType = HASH_MEMO_TYPE
expectedResponse.destinationAccount = DESTINATION_ACCOUNT

JSONAssert.assertEquals(
Expand Down Expand Up @@ -685,7 +684,7 @@ class RequestOnchainFundsHandlerTest {
txn24.requestAssetIssuer = STELLAR_USDC_ISSUER
val sep24TxnCapture = slot<JdbcSep24Transaction>()
val anchorEventCapture = slot<AnchorEvent>()
val depositInfo = SepDepositInfo(DESTINATION_ACCOUNT_2, TEXT_MEMO_2, TEXT_MEMO_TYPE)
val depositInfo = SepDepositInfo(DESTINATION_ACCOUNT_2, TEXT_MEMO, TEXT_MEMO_TYPE)

every { txn6Store.findByTransactionId(any()) } returns null
every { txn24Store.findByTransactionId(TX_ID) } returns txn24
Expand Down Expand Up @@ -721,7 +720,7 @@ class RequestOnchainFundsHandlerTest {
expectedSep24Txn.amountFee = "0.1"
expectedSep24Txn.amountFeeAsset = STELLAR_USDC
expectedSep24Txn.amountExpected = "1"
expectedSep24Txn.memo = TEXT_MEMO_2
expectedSep24Txn.memo = TEXT_MEMO
expectedSep24Txn.memoType = TEXT_MEMO_TYPE
expectedSep24Txn.toAccount = DESTINATION_ACCOUNT_2
expectedSep24Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT_2
Expand All @@ -742,7 +741,7 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep24TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO_2
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.destinationAccount = DESTINATION_ACCOUNT_2

Expand Down Expand Up @@ -888,8 +887,8 @@ class RequestOnchainFundsHandlerTest {
.amountIn(AmountAssetRequest("1", STELLAR_USDC))
.amountOut(AmountAssetRequest("0.9", FIAT_USD))
.amountFee(AmountAssetRequest("0.1", STELLAR_USDC))
.memo(TEXT_MEMO)
.memoType(TEXT_MEMO_TYPE)
.memo(HASH_MEMO)
.memoType(HASH_MEMO_TYPE)
.destinationAccount(DESTINATION_ACCOUNT)
.userActionRequiredBy(actionRequiredBy)
.build()
Expand Down Expand Up @@ -933,8 +932,8 @@ class RequestOnchainFundsHandlerTest {
expectedSep24Txn.amountFee = "0.1"
expectedSep24Txn.amountFeeAsset = STELLAR_USDC
expectedSep24Txn.amountExpected = "1"
expectedSep24Txn.memo = TEXT_MEMO
expectedSep24Txn.memoType = TEXT_MEMO_TYPE
expectedSep24Txn.memo = HASH_MEMO
expectedSep24Txn.memoType = HASH_MEMO_TYPE
expectedSep24Txn.toAccount = DESTINATION_ACCOUNT
expectedSep24Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT
expectedSep24Txn.userActionRequiredBy = actionRequiredBy
Expand All @@ -955,8 +954,8 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep24TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.memo = HASH_MEMO
expectedResponse.memoType = HASH_MEMO_TYPE
expectedResponse.destinationAccount = DESTINATION_ACCOUNT
expectedResponse.userActionRequiredBy = actionRequiredBy

Expand Down Expand Up @@ -989,8 +988,8 @@ class RequestOnchainFundsHandlerTest {
val request =
RequestOnchainFundsRequest.builder()
.transactionId(TX_ID)
.memo(TEXT_MEMO)
.memoType(TEXT_MEMO_TYPE)
.memo(HASH_MEMO)
.memoType(HASH_MEMO_TYPE)
.destinationAccount(DESTINATION_ACCOUNT)
.build()
val txn24 = JdbcSep24Transaction()
Expand Down Expand Up @@ -1040,8 +1039,8 @@ class RequestOnchainFundsHandlerTest {
expectedSep24Txn.amountFee = "0.1"
expectedSep24Txn.amountFeeAsset = STELLAR_USDC
expectedSep24Txn.amountExpected = "1"
expectedSep24Txn.memo = TEXT_MEMO
expectedSep24Txn.memoType = TEXT_MEMO_TYPE
expectedSep24Txn.memo = HASH_MEMO
expectedSep24Txn.memoType = HASH_MEMO_TYPE
expectedSep24Txn.toAccount = DESTINATION_ACCOUNT
expectedSep24Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT

Expand All @@ -1061,8 +1060,8 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep24TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.memo = HASH_MEMO
expectedResponse.memoType = HASH_MEMO_TYPE
expectedResponse.destinationAccount = DESTINATION_ACCOUNT

JSONAssert.assertEquals(
Expand Down Expand Up @@ -1223,8 +1222,8 @@ class RequestOnchainFundsHandlerTest {
.amountOut(AmountAssetRequest("0.9", FIAT_USD))
.feeDetails(Amount("0.1", STELLAR_USDC).toRate())
.amountExpected(AmountRequest("1"))
.memo(TEXT_MEMO)
.memoType(TEXT_MEMO_TYPE)
.memo(HASH_MEMO)
.memoType(HASH_MEMO_TYPE)
.destinationAccount(DESTINATION_ACCOUNT)
.build()
val txn6 = JdbcSep6Transaction()
Expand Down Expand Up @@ -1269,8 +1268,8 @@ class RequestOnchainFundsHandlerTest {
expectedSep6Txn.amountFee = "0.1"
expectedSep6Txn.amountFeeAsset = STELLAR_USDC
expectedSep6Txn.amountExpected = "1"
expectedSep6Txn.memo = TEXT_MEMO
expectedSep6Txn.memoType = TEXT_MEMO_TYPE
expectedSep6Txn.memo = HASH_MEMO
expectedSep6Txn.memoType = HASH_MEMO_TYPE
expectedSep6Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT

JSONAssert.assertEquals(
Expand All @@ -1295,8 +1294,8 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep6TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.memo = HASH_MEMO
expectedResponse.memoType = HASH_MEMO_TYPE
expectedResponse.customers = Customers(StellarId(null, null, null), StellarId(null, null, null))

JSONAssert.assertEquals(
Expand Down Expand Up @@ -1357,7 +1356,7 @@ class RequestOnchainFundsHandlerTest {
txn6.requestAssetIssuer = STELLAR_USDC_ISSUER
val sep6TxnCapture = slot<JdbcSep6Transaction>()
val anchorEventCapture = slot<AnchorEvent>()
val depositInfo = SepDepositInfo(DESTINATION_ACCOUNT_2, TEXT_MEMO_2, TEXT_MEMO_TYPE)
val depositInfo = SepDepositInfo(DESTINATION_ACCOUNT_2, TEXT_MEMO, TEXT_MEMO_TYPE)

every { txn6Store.findByTransactionId(TX_ID) } returns txn6
every { txn24Store.findByTransactionId(any()) } returns null
Expand Down Expand Up @@ -1392,7 +1391,7 @@ class RequestOnchainFundsHandlerTest {
expectedSep6Txn.amountFee = "0.1"
expectedSep6Txn.amountFeeAsset = STELLAR_USDC
expectedSep6Txn.amountExpected = "1"
expectedSep6Txn.memo = TEXT_MEMO_2
expectedSep6Txn.memo = TEXT_MEMO
expectedSep6Txn.memoType = TEXT_MEMO_TYPE
expectedSep6Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT_2

Expand All @@ -1412,7 +1411,7 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep6TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO_2
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.customers = Customers(StellarId(null, null, null), StellarId(null, null, null))

Expand Down Expand Up @@ -1449,8 +1448,8 @@ class RequestOnchainFundsHandlerTest {
.amountIn(AmountAssetRequest("1", STELLAR_USDC))
.amountOut(AmountAssetRequest("0.9", FIAT_USD))
.amountFee(AmountAssetRequest("0.1", STELLAR_USDC))
.memo(TEXT_MEMO)
.memoType(TEXT_MEMO_TYPE)
.memo(HASH_MEMO)
.memoType(HASH_MEMO_TYPE)
.destinationAccount(DESTINATION_ACCOUNT)
.build()
val txn6 = JdbcSep6Transaction()
Expand Down Expand Up @@ -1490,8 +1489,8 @@ class RequestOnchainFundsHandlerTest {
expectedSep6Txn.amountFee = "0.1"
expectedSep6Txn.amountFeeAsset = STELLAR_USDC
expectedSep6Txn.amountExpected = "1"
expectedSep6Txn.memo = TEXT_MEMO
expectedSep6Txn.memoType = TEXT_MEMO_TYPE
expectedSep6Txn.memo = HASH_MEMO
expectedSep6Txn.memoType = HASH_MEMO_TYPE
expectedSep6Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT

JSONAssert.assertEquals(
Expand All @@ -1510,8 +1509,8 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = Amount("0.1", STELLAR_USDC).toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep6TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.memo = HASH_MEMO
expectedResponse.memoType = HASH_MEMO_TYPE
expectedResponse.customers = Customers(StellarId(null, null, null), StellarId(null, null, null))

JSONAssert.assertEquals(
Expand Down Expand Up @@ -1544,8 +1543,8 @@ class RequestOnchainFundsHandlerTest {
val request =
RequestOnchainFundsRequest.builder()
.transactionId(TX_ID)
.memo(TEXT_MEMO)
.memoType(TEXT_MEMO_TYPE)
.memo(HASH_MEMO)
.memoType(HASH_MEMO_TYPE)
.destinationAccount(DESTINATION_ACCOUNT)
.build()
val txn6 = JdbcSep6Transaction()
Expand Down Expand Up @@ -1593,8 +1592,8 @@ class RequestOnchainFundsHandlerTest {
expectedSep6Txn.amountFee = "0.1"
expectedSep6Txn.amountFeeAsset = STELLAR_USDC
expectedSep6Txn.amountExpected = "1"
expectedSep6Txn.memo = TEXT_MEMO
expectedSep6Txn.memoType = TEXT_MEMO_TYPE
expectedSep6Txn.memo = HASH_MEMO
expectedSep6Txn.memoType = HASH_MEMO_TYPE
expectedSep6Txn.withdrawAnchorAccount = DESTINATION_ACCOUNT

JSONAssert.assertEquals(
Expand All @@ -1613,8 +1612,8 @@ class RequestOnchainFundsHandlerTest {
expectedResponse.feeDetails = expectedResponse.amountFee.toRate()
expectedResponse.amountExpected = Amount("1", STELLAR_USDC)
expectedResponse.updatedAt = sep6TxnCapture.captured.updatedAt
expectedResponse.memo = TEXT_MEMO
expectedResponse.memoType = TEXT_MEMO_TYPE
expectedResponse.memo = HASH_MEMO
expectedResponse.memoType = HASH_MEMO_TYPE
expectedResponse.customers = Customers(StellarId(null, null, null), StellarId(null, null, null))

JSONAssert.assertEquals(
Expand Down

0 comments on commit 3b35f29

Please sign in to comment.