Skip to content

Commit

Permalink
Add client_domain to SEP-6 transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
philipliu committed Nov 23, 2023
1 parent 9ccff3f commit 6bf0327
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public class PlatformTransactionData {
@SerializedName("withdraw_anchor_account")
String withdrawAnchorAccount;

@SerializedName("client_domain")
String clientDomain;

Customers customers;
StellarId creator;

Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/org/stellar/anchor/sep6/Sep6Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public StartDepositResponse deposit(Sep10Jwt token, StartDepositRequest request)
.startedAt(Instant.now())
.sep10Account(token.getAccount())
.sep10AccountMemo(token.getAccountMemo())
.toAccount(request.getAccount());
.toAccount(request.getAccount())
.clientDomain(token.getClientDomain());

if (memo != null) {
builder.memo(memo.toString());
Expand Down Expand Up @@ -185,6 +186,7 @@ public StartDepositResponse depositExchange(Sep10Jwt token, StartDepositExchange
.sep10Account(token.getAccount())
.sep10AccountMemo(token.getAccountMemo())
.toAccount(request.getAccount())
.clientDomain(token.getClientDomain())
.quoteId(request.getQuoteId());

if (memo != null) {
Expand Down Expand Up @@ -253,6 +255,7 @@ public StartWithdrawResponse withdraw(Sep10Jwt token, StartWithdrawRequest reque
.sep10Account(token.getAccount())
.sep10AccountMemo(token.getAccountMemo())
.fromAccount(sourceAccount)
.clientDomain(token.getClientDomain())
.refundMemo(request.getRefundMemo())
.refundMemoType(request.getRefundMemoType());

Expand Down Expand Up @@ -339,6 +342,7 @@ public StartWithdrawResponse withdrawExchange(
.sep10Account(token.getAccount())
.sep10AccountMemo(token.getAccountMemo())
.fromAccount(sourceAccount)
.clientDomain(token.getClientDomain())
.refundMemo(request.getRefundMemo())
.refundMemoType(request.getRefundMemoType())
.quoteId(request.getQuoteId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ public interface Sep6Transaction extends SepTransaction {

void setMemoType(String memoType);

/**
* The client domain of the wallet that initiated the transaction.
*
* @return the client domain.
*/
String getClientDomain();

void setClientDomain(String clientDomain);

/**
* The ID returned from a SEP-38 quote response. IF this is set, the user must deliver the deposit
* funds to the anchor before the quote expires, otherwise the anchor may not honor the quote.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ public Sep6TransactionBuilder memoType(String memoType) {
return this;
}

public Sep6TransactionBuilder clientDomain(String clientDomain) {
txn.setClientDomain(clientDomain);
return this;
}

public Sep6TransactionBuilder quoteId(String quoteId) {
txn.setQuoteId(quoteId);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static GetTransactionResponse toGetTransactionResponse(Sep31Transaction t
.refunds(refunds)
.stellarTransactions(txn.getStellarTransactions())
.externalTransactionId(txn.getExternalTransactionId())
.clientDomain(txn.getClientDomain())
.customers(txn.getCustomers())
.creator(txn.getCreator())
.build();
Expand Down Expand Up @@ -145,6 +146,7 @@ public static GetTransactionResponse toGetTransactionResponse(
.externalTransactionId(txn.getExternalTransactionId())
.memo(txn.getMemo())
.memoType(txn.getMemoType())
.clientDomain(txn.getClientDomain())
.refundMemo(txn.getRefundMemo())
.refundMemoType(txn.getRefundMemoType())
.requiredInfoMessage(txn.getRequiredInfoMessage())
Expand Down Expand Up @@ -190,6 +192,7 @@ public static GetTransactionResponse toGetTransactionResponse(
.externalTransactionId(txn.getExternalTransactionId())
.memo(txn.getMemo())
.memoType(txn.getMemoType())
.clientDomain(txn.getClientDomain())
.refundMemo(txn.getRefundMemo())
.refundMemoType(txn.getRefundMemoType())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class PojoSep6Transaction implements Sep6Transaction {
String toAccount;
String memo;
String memoType;
String clientDomain;
String quoteId;
String message;
Refunds refunds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ class Sep6ServiceTestData {
"amountExpected": "100",
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO"
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org"
}
"""
.trimIndent()
Expand All @@ -188,6 +189,7 @@ class Sep6ServiceTestData {
"asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
},
"destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand All @@ -212,7 +214,8 @@ class Sep6ServiceTestData {
"requestAssetIssuer": "GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO"
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org"
}
"""
Expand All @@ -231,6 +234,7 @@ class Sep6ServiceTestData {
"asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
},
"destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand Down Expand Up @@ -264,6 +268,7 @@ class Sep6ServiceTestData {
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org",
"quoteId": "test-quote-id"
}
"""
Expand Down Expand Up @@ -293,6 +298,7 @@ class Sep6ServiceTestData {
},
"quote_id": "test-quote-id",
"destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand Down Expand Up @@ -325,7 +331,8 @@ class Sep6ServiceTestData {
"amountExpected": "100",
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO"
"toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org"
}
"""
.trimIndent()
Expand All @@ -351,6 +358,7 @@ class Sep6ServiceTestData {
},
"amount_fee": { "amount": "0", "asset": "iso4217:USD" },
"destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand Down Expand Up @@ -387,6 +395,7 @@ class Sep6ServiceTestData {
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org",
"refundMemo": "some text",
"refundMemoType": "text"
}
Expand All @@ -413,6 +422,7 @@ class Sep6ServiceTestData {
"source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"refund_memo": "some text",
"refund_memo_type": "text",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand All @@ -439,6 +449,7 @@ class Sep6ServiceTestData {
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org",
"refundMemo": "some text",
"refundMemoType": "text"
}
Expand All @@ -460,6 +471,7 @@ class Sep6ServiceTestData {
"source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"refund_memo": "some text",
"refund_memo_type": "text",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand Down Expand Up @@ -493,6 +505,7 @@ class Sep6ServiceTestData {
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org",
"quoteId": "test-quote-id",
"refundMemo": "some text",
"refundMemoType": "text"
Expand Down Expand Up @@ -523,6 +536,7 @@ class Sep6ServiceTestData {
"source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"refund_memo": "some text",
"refund_memo_type": "text",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand Down Expand Up @@ -556,6 +570,7 @@ class Sep6ServiceTestData {
"sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"sep10AccountMemo": "123",
"fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"clientDomain": "vibrant.stellar.org",
"refundMemo": "some text",
"refundMemoType": "text"
}
Expand Down Expand Up @@ -588,6 +603,7 @@ class Sep6ServiceTestData {
"source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
"refund_memo": "some text",
"refund_memo_type": "text",
"client_domain": "vibrant.stellar.org",
"customers": {
"sender": {
"account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public String getProtocol() {
@Column(name = "memo_type")
String memoType;

@SerializedName("client_domain")
@Column(name = "client_domain")
String clientDomain;

@SerializedName("quote_id")
@Column(name = "quote_id")
String quoteId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE sep6_transaction ADD client_domain VARCHAR(255);

0 comments on commit 6bf0327

Please sign in to comment.