From 6bf03273867353cc4aad2ef06d9c52a6d903a276 Mon Sep 17 00:00:00 2001 From: philipliu Date: Thu, 23 Nov 2023 16:32:32 -0500 Subject: [PATCH 1/5] Add client_domain to SEP-6 transaction --- .../api/platform/PlatformTransactionData.java | 3 +++ .../org/stellar/anchor/sep6/Sep6Service.java | 6 ++++- .../stellar/anchor/sep6/Sep6Transaction.java | 9 ++++++++ .../anchor/sep6/Sep6TransactionBuilder.java | 5 +++++ .../anchor/util/TransactionHelper.java | 3 +++ .../anchor/sep6/PojoSep6Transaction.java | 1 + .../anchor/sep6/Sep6ServiceTestData.kt | 22 ++++++++++++++++--- .../platform/data/JdbcSep6Transaction.java | 4 ++++ .../db/migration/V11__sep6_client_domain.sql | 1 + 9 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 platform/src/main/resources/db/migration/V11__sep6_client_domain.sql diff --git a/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java b/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java index 831161534b..cd3ebbc629 100644 --- a/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java +++ b/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java @@ -89,6 +89,9 @@ public class PlatformTransactionData { @SerializedName("withdraw_anchor_account") String withdrawAnchorAccount; + @SerializedName("client_domain") + String clientDomain; + Customers customers; StellarId creator; diff --git a/core/src/main/java/org/stellar/anchor/sep6/Sep6Service.java b/core/src/main/java/org/stellar/anchor/sep6/Sep6Service.java index 60a5cb26ea..9b7bfc61d7 100644 --- a/core/src/main/java/org/stellar/anchor/sep6/Sep6Service.java +++ b/core/src/main/java/org/stellar/anchor/sep6/Sep6Service.java @@ -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()); @@ -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) { @@ -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()); @@ -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()); diff --git a/core/src/main/java/org/stellar/anchor/sep6/Sep6Transaction.java b/core/src/main/java/org/stellar/anchor/sep6/Sep6Transaction.java index 0d5d97091e..05f0c65b77 100644 --- a/core/src/main/java/org/stellar/anchor/sep6/Sep6Transaction.java +++ b/core/src/main/java/org/stellar/anchor/sep6/Sep6Transaction.java @@ -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. diff --git a/core/src/main/java/org/stellar/anchor/sep6/Sep6TransactionBuilder.java b/core/src/main/java/org/stellar/anchor/sep6/Sep6TransactionBuilder.java index 2a06129b65..0b79ad1290 100644 --- a/core/src/main/java/org/stellar/anchor/sep6/Sep6TransactionBuilder.java +++ b/core/src/main/java/org/stellar/anchor/sep6/Sep6TransactionBuilder.java @@ -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; diff --git a/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java b/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java index 4ae9e63399..baf0475195 100644 --- a/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java +++ b/core/src/main/java/org/stellar/anchor/util/TransactionHelper.java @@ -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(); @@ -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()) @@ -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(); diff --git a/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java b/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java index 191dd09a1c..063656b6c4 100644 --- a/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java +++ b/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java @@ -40,6 +40,7 @@ public class PojoSep6Transaction implements Sep6Transaction { String toAccount; String memo; String memoType; + String clientDomain; String quoteId; String message; Refunds refunds; diff --git a/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt b/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt index 4fbdb95c2e..a49f7dced5 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt @@ -169,7 +169,8 @@ class Sep6ServiceTestData { "amountExpected": "100", "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", - "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO" + "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org" } """ .trimIndent() @@ -188,6 +189,7 @@ class Sep6ServiceTestData { "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -212,7 +214,8 @@ class Sep6ServiceTestData { "requestAssetIssuer": "GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", - "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO" + "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org" } """ @@ -231,6 +234,7 @@ class Sep6ServiceTestData { "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -264,6 +268,7 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", "quoteId": "test-quote-id" } """ @@ -293,6 +298,7 @@ class Sep6ServiceTestData { }, "quote_id": "test-quote-id", "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -325,7 +331,8 @@ class Sep6ServiceTestData { "amountExpected": "100", "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", - "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO" + "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org" } """ .trimIndent() @@ -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", @@ -387,6 +395,7 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", "refundMemo": "some text", "refundMemoType": "text" } @@ -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", @@ -439,6 +449,7 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", "refundMemo": "some text", "refundMemoType": "text" } @@ -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", @@ -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" @@ -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", @@ -556,6 +570,7 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", "refundMemo": "some text", "refundMemoType": "text" } @@ -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", diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java index 6823677ccd..afd9ee347a 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java @@ -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; diff --git a/platform/src/main/resources/db/migration/V11__sep6_client_domain.sql b/platform/src/main/resources/db/migration/V11__sep6_client_domain.sql new file mode 100644 index 0000000000..80def739b1 --- /dev/null +++ b/platform/src/main/resources/db/migration/V11__sep6_client_domain.sql @@ -0,0 +1 @@ +ALTER TABLE sep6_transaction ADD client_domain VARCHAR(255); \ No newline at end of file From 4cfee86f558e8ac6e109548ab7a66a0caedd5138 Mon Sep 17 00:00:00 2001 From: philipliu Date: Wed, 29 Nov 2023 16:09:04 -0500 Subject: [PATCH 2/5] Add client name --- .../api/platform/PlatformTransactionData.java | 3 +++ .../stellar/anchor/client/ClientFinder.java | 6 ++--- .../stellar/anchor/sep24/Sep24Service.java | 8 ++++++- .../anchor/sep24/Sep24Transaction.java | 9 ++++++++ .../anchor/sep24/Sep24TransactionBuilder.java | 5 +++++ .../stellar/anchor/sep31/Sep31Service.java | 1 + .../anchor/sep31/Sep31Transaction.java | 4 ++++ .../anchor/sep31/Sep31TransactionBuilder.java | 5 +++++ .../org/stellar/anchor/sep6/Sep6Service.java | 11 +++++++++- .../stellar/anchor/sep6/Sep6Transaction.java | 9 ++++++++ .../anchor/sep6/Sep6TransactionBuilder.java | 5 +++++ .../anchor/util/TransactionHelper.java | 3 +++ .../anchor/sep24/PojoSep24Transaction.java | 1 + .../anchor/sep31/PojoSep31Transaction.java | 1 + .../anchor/sep6/PojoSep6Transaction.java | 1 + .../stellar/anchor/sep24/Sep24ServiceTest.kt | 10 +++++++++ .../stellar/anchor/sep31/Sep31ServiceTest.kt | 9 ++++++++ .../stellar/anchor/sep6/Sep6ServiceTest.kt | 4 ++++ .../anchor/sep6/Sep6ServiceTestData.kt | 22 ++++++++++++++++--- .../stellar/anchor/util/ClientFinderTest.kt | 20 ++++++++--------- .../integrationtest/PlatformApiTests.kt | 9 +++++--- .../platform/component/sep/SepBeans.java | 4 ++++ .../platform/data/JdbcSep24Transaction.java | 4 ++++ .../platform/data/JdbcSep31Transaction.java | 4 ++++ .../platform/data/JdbcSep6Transaction.java | 4 ++++ .../db/migration/V11__client_domain_name.sql | 5 +++++ .../db/migration/V11__sep6_client_domain.sql | 1 - 27 files changed, 146 insertions(+), 22 deletions(-) create mode 100644 platform/src/main/resources/db/migration/V11__client_domain_name.sql delete mode 100644 platform/src/main/resources/db/migration/V11__sep6_client_domain.sql diff --git a/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java b/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java index cd3ebbc629..40a26b7ff3 100644 --- a/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java +++ b/api-schema/src/main/java/org/stellar/anchor/api/platform/PlatformTransactionData.java @@ -92,6 +92,9 @@ public class PlatformTransactionData { @SerializedName("client_domain") String clientDomain; + @SerializedName("client_name") + String clientName; + Customers customers; StellarId creator; diff --git a/core/src/main/java/org/stellar/anchor/client/ClientFinder.java b/core/src/main/java/org/stellar/anchor/client/ClientFinder.java index 8ade86f931..c1a2baf445 100644 --- a/core/src/main/java/org/stellar/anchor/client/ClientFinder.java +++ b/core/src/main/java/org/stellar/anchor/client/ClientFinder.java @@ -9,14 +9,14 @@ import org.stellar.anchor.config.ClientsConfig.ClientConfig; import org.stellar.anchor.config.Sep10Config; -/** Finds the client ID for a SEP-10 JWT. */ +/** Finds the client name for a SEP-10 JWT. */ @RequiredArgsConstructor public class ClientFinder { @NonNull private final Sep10Config sep10Config; @NonNull private final ClientsConfig clientsConfig; /** - * Returns the client ID for a SEP-10 JWT. If the client attribution is not required, the client + * Returns the client name for a SEP-10 JWT. If the client attribution is not required, the client * ID is returned if the client is found. If the client attribution is required, the client ID is * returned if the client is found and the client domain and name are allowed. * @@ -25,7 +25,7 @@ public class ClientFinder { * @throws BadRequestException if the client is not found or the client domain or name is not */ @Nullable - public String getClientId(Sep10Jwt token) throws BadRequestException { + public String getClientName(Sep10Jwt token) throws BadRequestException { ClientsConfig.ClientConfig client = getClient(token); // If client attribution is not required, return the client name diff --git a/core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java b/core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java index dff3ca5766..05e1593348 100644 --- a/core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java +++ b/core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java @@ -50,6 +50,7 @@ import org.stellar.anchor.asset.AssetService; import org.stellar.anchor.auth.JwtService; import org.stellar.anchor.auth.Sep10Jwt; +import org.stellar.anchor.client.ClientFinder; import org.stellar.anchor.config.AppConfig; import org.stellar.anchor.config.ClientsConfig; import org.stellar.anchor.config.CustodyConfig; @@ -69,6 +70,7 @@ public class Sep24Service { final ClientsConfig clientsConfig; final AssetService assetService; final JwtService jwtService; + final ClientFinder clientFinder; final Sep24TransactionStore txnStore; final EventService.Session eventSession; final InteractiveUrlConstructor interactiveUrlConstructor; @@ -99,6 +101,7 @@ public Sep24Service( ClientsConfig clientsConfig, AssetService assetService, JwtService jwtService, + ClientFinder clientFinder, Sep24TransactionStore txnStore, EventService eventService, InteractiveUrlConstructor interactiveUrlConstructor, @@ -111,6 +114,7 @@ public Sep24Service( this.clientsConfig = clientsConfig; this.assetService = assetService; this.jwtService = jwtService; + this.clientFinder = clientFinder; this.txnStore = txnStore; this.eventSession = eventService.createSession(this.getClass().getName(), TRANSACTION); this.interactiveUrlConstructor = interactiveUrlConstructor; @@ -215,7 +219,8 @@ public InteractiveTransactionResponse withdraw( // TODO - jamie to add unique address generator .withdrawAnchorAccount(asset.getDistributionAccount()) .toAccount(asset.getDistributionAccount()) - .clientDomain(token.getClientDomain()); + .clientDomain(token.getClientDomain()) + .clientName(clientFinder.getClientName(token)); // TODO - jamie to look into memo vs withdrawal_memo if (memo != null) { @@ -391,6 +396,7 @@ public InteractiveTransactionResponse deposit(Sep10Jwt token, Map fields; Boolean refunded; diff --git a/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java b/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java index 063656b6c4..91fbb5b468 100644 --- a/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java +++ b/core/src/test/java/org/stellar/anchor/sep6/PojoSep6Transaction.java @@ -41,6 +41,7 @@ public class PojoSep6Transaction implements Sep6Transaction { String memo; String memoType; String clientDomain; + String clientName; String quoteId; String message; Refunds refunds; diff --git a/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt index a5c4ccb83a..42e1b3af64 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt @@ -38,6 +38,7 @@ import org.stellar.anchor.auth.JwtService import org.stellar.anchor.auth.JwtService.CLIENT_DOMAIN import org.stellar.anchor.auth.Sep10Jwt import org.stellar.anchor.auth.Sep24InteractiveUrlJwt +import org.stellar.anchor.client.ClientFinder import org.stellar.anchor.config.* import org.stellar.anchor.event.EventService import org.stellar.anchor.util.GsonUtils @@ -66,6 +67,8 @@ internal class Sep24ServiceTest { @MockK(relaxed = true) lateinit var feeIntegration: FeeIntegration + @MockK(relaxed = true) lateinit var clientFinder: ClientFinder + @MockK(relaxed = true) lateinit var txnStore: Sep24TransactionStore @MockK(relaxed = true) lateinit var interactiveUrlConstructor: InteractiveUrlConstructor @@ -103,6 +106,7 @@ internal class Sep24ServiceTest { every { moreInfoUrlConstructor.construct(any()) } returns "${TEST_SEP24_MORE_INFO_URL}?lang=en&token=$strToken" every { clientsConfig.getClientConfigByDomain(any()) } returns clientConfig + every { clientFinder.getClientName(any()) } returns TEST_CLIENT_NAME sep24Service = Sep24Service( @@ -111,6 +115,7 @@ internal class Sep24ServiceTest { clientsConfig, assetService, jwtService, + clientFinder, txnStore, eventService, interactiveUrlConstructor, @@ -146,6 +151,7 @@ internal class Sep24ServiceTest { ) assertEquals(TEST_ACCOUNT, slotTxn.captured.fromAccount) assertEquals(TEST_CLIENT_DOMAIN, slotTxn.captured.clientDomain) + assertEquals(TEST_CLIENT_NAME, slotTxn.captured.clientName) val params = URLEncodedUtils.parse(URI(response.url), Charset.forName("UTF-8")) val tokenStrings = params.filter { pair -> pair.name.equals("token") } @@ -195,6 +201,7 @@ internal class Sep24ServiceTest { assertEquals(TEST_MEMO, slotTxn.captured.sep10AccountMemo) assertEquals(TEST_ACCOUNT, slotTxn.captured.fromAccount) assertEquals(TEST_CLIENT_DOMAIN, slotTxn.captured.clientDomain) + assertEquals(TEST_CLIENT_NAME, slotTxn.captured.clientName) } @Test @@ -274,6 +281,7 @@ internal class Sep24ServiceTest { assertEquals(TEST_ASSET_ISSUER_ACCOUNT_ID, slotTxn.captured.requestAssetIssuer) assertEquals(TEST_ACCOUNT, slotTxn.captured.toAccount) assertEquals(TEST_CLIENT_DOMAIN, slotTxn.captured.clientDomain) + assertEquals(TEST_CLIENT_NAME, slotTxn.captured.clientName) } @Test @@ -308,6 +316,7 @@ internal class Sep24ServiceTest { assertEquals(TEST_MEMO, slotTxn.captured.sep10AccountMemo) assertEquals(TEST_ACCOUNT, slotTxn.captured.fromAccount) assertEquals(TEST_CLIENT_DOMAIN, slotTxn.captured.clientDomain) + assertEquals(TEST_CLIENT_NAME, slotTxn.captured.clientName) } @Test @@ -360,6 +369,7 @@ internal class Sep24ServiceTest { assertEquals(TEST_ASSET_ISSUER_ACCOUNT_ID, slotTxn.captured.requestAssetIssuer) assertEquals(whitelistedAccount, slotTxn.captured.toAccount) assertEquals(TEST_CLIENT_DOMAIN, slotTxn.captured.clientDomain) + assertEquals(TEST_CLIENT_NAME, slotTxn.captured.clientName) } @Test diff --git a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt index b8656e2385..33cf9418f0 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt @@ -784,6 +784,14 @@ class Sep31ServiceTest { SepDepositInfo(tx.stellarAccountId, memo, "hash") } + // mock client config + every { sep10Config.allowedClientDomains } returns listOf("vibrant.stellar.org") + every { clientsConfig.getClientConfigBySigningKey(any()) } returns + ClientsConfig.ClientConfig().apply { + domain = "vibrant.stellar.org" + name = "vibrant" + } + // mock transaction save val slotTxn = slot() every { txnStore.save(capture(slotTxn)) } answers @@ -824,6 +832,7 @@ class Sep31ServiceTest { "updatedAt": "$txStartedAt", "quoteId": "my_quote_id", "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "fields": { "receiver_account_number": "1", "type": "1", diff --git a/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTest.kt index 4eec4f174d..dae20c04fe 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTest.kt @@ -28,6 +28,7 @@ import org.stellar.anchor.api.shared.RefundPayment import org.stellar.anchor.api.shared.Refunds import org.stellar.anchor.asset.AssetService import org.stellar.anchor.asset.DefaultAssetService +import org.stellar.anchor.client.ClientFinder import org.stellar.anchor.config.Sep6Config import org.stellar.anchor.event.EventService import org.stellar.anchor.sep6.ExchangeAmountsCalculator.Amounts @@ -43,6 +44,7 @@ class Sep6ServiceTest { @MockK(relaxed = true) lateinit var sep6Config: Sep6Config @MockK(relaxed = true) lateinit var requestValidator: RequestValidator + @MockK(relaxed = true) lateinit var clientFinder: ClientFinder @MockK(relaxed = true) lateinit var txnStore: Sep6TransactionStore @MockK(relaxed = true) lateinit var exchangeAmountsCalculator: ExchangeAmountsCalculator @MockK(relaxed = true) lateinit var eventService: EventService @@ -55,6 +57,7 @@ class Sep6ServiceTest { MockKAnnotations.init(this, relaxUnitFun = true) every { sep6Config.features.isAccountCreation } returns false every { sep6Config.features.isClaimableBalances } returns false + every { clientFinder.getClientName(token) } returns "vibrant" every { txnStore.newInstance() } returns PojoSep6Transaction() every { eventService.createSession(any(), any()) } returns eventSession every { requestValidator.getDepositAsset(TEST_ASSET) } returns asset @@ -64,6 +67,7 @@ class Sep6ServiceTest { sep6Config, assetService, requestValidator, + clientFinder, txnStore, exchangeAmountsCalculator, eventService diff --git a/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt b/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt index a49f7dced5..20561c45f3 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep6/Sep6ServiceTestData.kt @@ -170,7 +170,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", - "clientDomain": "vibrant.stellar.org" + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant" } """ .trimIndent() @@ -190,6 +191,7 @@ class Sep6ServiceTestData { }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -215,7 +217,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", - "clientDomain": "vibrant.stellar.org" + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant" } """ @@ -235,6 +238,7 @@ class Sep6ServiceTestData { }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -269,6 +273,7 @@ class Sep6ServiceTestData { "sep10AccountMemo": "123", "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "quoteId": "test-quote-id" } """ @@ -299,6 +304,7 @@ class Sep6ServiceTestData { "quote_id": "test-quote-id", "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -332,7 +338,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", - "clientDomain": "vibrant.stellar.org" + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant" } """ .trimIndent() @@ -359,6 +366,7 @@ class Sep6ServiceTestData { "amount_fee": { "amount": "0", "asset": "iso4217:USD" }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -396,6 +404,7 @@ class Sep6ServiceTestData { "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "refundMemo": "some text", "refundMemoType": "text" } @@ -423,6 +432,7 @@ class Sep6ServiceTestData { "refund_memo": "some text", "refund_memo_type": "text", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -450,6 +460,7 @@ class Sep6ServiceTestData { "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "refundMemo": "some text", "refundMemoType": "text" } @@ -472,6 +483,7 @@ class Sep6ServiceTestData { "refund_memo": "some text", "refund_memo_type": "text", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -506,6 +518,7 @@ class Sep6ServiceTestData { "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "quoteId": "test-quote-id", "refundMemo": "some text", "refundMemoType": "text" @@ -537,6 +550,7 @@ class Sep6ServiceTestData { "refund_memo": "some text", "refund_memo_type": "text", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -571,6 +585,7 @@ class Sep6ServiceTestData { "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "refundMemo": "some text", "refundMemoType": "text" } @@ -604,6 +619,7 @@ class Sep6ServiceTestData { "refund_memo": "some text", "refund_memo_type": "text", "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", diff --git a/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt b/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt index d97161d6f9..ec6ecaeaed 100644 --- a/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt @@ -56,7 +56,7 @@ class ClientFinderTest { @Test fun `test getClientId with client found by domain`() { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns clientConfig - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @@ -64,7 +64,7 @@ class ClientFinderTest { @Test fun `test getClientId with client found by signing key`() { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @@ -74,27 +74,27 @@ class ClientFinderTest { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null every { clientsConfig.getClientConfigBySigningKey(token.account) } returns null - assertThrows { clientFinder.getClientId(token) } + assertThrows { clientFinder.getClientName(token) } } @Test fun `test getClientId with client not found by domain`() { every { sep10Config.allowedClientDomains } returns listOf("nothing") - assertThrows { clientFinder.getClientId(token) } + assertThrows { clientFinder.getClientName(token) } } @Test fun `test getClientId with client not found by name`() { every { sep10Config.allowedClientNames } returns listOf("nothing") - assertThrows { clientFinder.getClientId(token) } + assertThrows { clientFinder.getClientName(token) } } @Test fun `test getClientId with all domains allowed`() { every { sep10Config.allowedClientDomains } returns emptyList() - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @@ -102,7 +102,7 @@ class ClientFinderTest { @Test fun `test getClientId with all names allowed`() { every { sep10Config.allowedClientNames } returns emptyList() - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @@ -113,7 +113,7 @@ class ClientFinderTest { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null every { clientsConfig.getClientConfigBySigningKey(token.account) } returns null - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertNull(clientId) } @@ -123,7 +123,7 @@ class ClientFinderTest { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null every { clientsConfig.getClientConfigBySigningKey(token.account) } returns clientConfig - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @@ -133,7 +133,7 @@ class ClientFinderTest { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns clientConfig every { clientsConfig.getClientConfigBySigningKey(token.account) } returns null - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } } diff --git a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt index 9f5b3fdfba..4b859600d3 100644 --- a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt +++ b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/PlatformApiTests.kt @@ -6565,7 +6565,8 @@ class PlatformApiTests : AbstractIntegrationTests(TestConfig()) { "started_at":"2023-07-20T08:57:05.380736Z", "updated_at":"2023-07-20T08:57:16.672110400Z", "message":"test message", - "destination_account":"GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG" + "destination_account":"GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", + "client_name": "referenceCustodial" }, "id":1 } @@ -6601,7 +6602,8 @@ class PlatformApiTests : AbstractIntegrationTests(TestConfig()) { "started_at":"2023-07-20T09:07:51.007629Z", "updated_at":"2023-07-20T09:07:59.425534900Z", "message":"test message", - "destination_account":"GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG" + "destination_account":"GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", + "client_name": "referenceCustodial" }, "id":1 }, @@ -6632,7 +6634,8 @@ class PlatformApiTests : AbstractIntegrationTests(TestConfig()) { "updated_at":"2023-07-20T09:07:59.448888600Z", "message":"test message", "external_transaction_id": "1", - "destination_account":"GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG" + "destination_account":"GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", + "client_name": "referenceCustodial" }, "id":2 } diff --git a/platform/src/main/java/org/stellar/anchor/platform/component/sep/SepBeans.java b/platform/src/main/java/org/stellar/anchor/platform/component/sep/SepBeans.java index 9a1ea1ba9d..06062c1124 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/component/sep/SepBeans.java +++ b/platform/src/main/java/org/stellar/anchor/platform/component/sep/SepBeans.java @@ -133,6 +133,7 @@ ClientFinder clientFinder(Sep10Config sep10Config, ClientsConfig clientsConfig) Sep6Service sep6Service( Sep6Config sep6Config, AssetService assetService, + ClientFinder clientFinder, Sep6TransactionStore txnStore, EventService eventService, Sep38QuoteStore sep38QuoteStore) { @@ -143,6 +144,7 @@ Sep6Service sep6Service( sep6Config, assetService, requestValidator, + clientFinder, txnStore, exchangeAmountsCalculator, eventService); @@ -176,6 +178,7 @@ Sep24Service sep24Service( ClientsConfig clientsConfig, AssetService assetService, JwtService jwtService, + ClientFinder clientFinder, Sep24TransactionStore sep24TransactionStore, EventService eventService, InteractiveUrlConstructor interactiveUrlConstructor, @@ -187,6 +190,7 @@ Sep24Service sep24Service( clientsConfig, assetService, jwtService, + clientFinder, sep24TransactionStore, eventService, interactiveUrlConstructor, diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Transaction.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Transaction.java index 3f74f80e70..68e9f24b95 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Transaction.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep24Transaction.java @@ -120,6 +120,10 @@ public void setRefunds(Sep24Refunds refunds) { @Column(name = "client_domain") String clientDomain; + @SerializedName("client_name") + @Column(name = "client_name") + String clientName; + @SerializedName("claimable_balance_supported") @Column(name = "claimable_balance_supported") Boolean claimableBalanceSupported; diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31Transaction.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31Transaction.java index c355359d06..21104bbd9d 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31Transaction.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep31Transaction.java @@ -54,6 +54,10 @@ public String getProtocol() { @Column(name = "client_domain") String clientDomain; + @SerializedName("client_name") + @Column(name = "client_name") + String clientName; + @SerializedName("sender_id") @Column(name = "sender_id") String senderId; diff --git a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java index afd9ee347a..7a4f58178e 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java +++ b/platform/src/main/java/org/stellar/anchor/platform/data/JdbcSep6Transaction.java @@ -91,6 +91,10 @@ public String getProtocol() { @Column(name = "client_domain") String clientDomain; + @SerializedName("client_name") + @Column(name = "client_name") + String clientName; + @SerializedName("quote_id") @Column(name = "quote_id") String quoteId; diff --git a/platform/src/main/resources/db/migration/V11__client_domain_name.sql b/platform/src/main/resources/db/migration/V11__client_domain_name.sql new file mode 100644 index 0000000000..6ef076bd97 --- /dev/null +++ b/platform/src/main/resources/db/migration/V11__client_domain_name.sql @@ -0,0 +1,5 @@ +ALTER TABLE sep6_transaction ADD client_domain VARCHAR(255); +ALTER TABLE sep6_transaction ADD client_name VARCHAR(255); + +ALTER TABLE sep24_transaction ADD client_name VARCHAR(255); +ALTER TABLE sep31_transaction ADD client_name VARCHAR(255); diff --git a/platform/src/main/resources/db/migration/V11__sep6_client_domain.sql b/platform/src/main/resources/db/migration/V11__sep6_client_domain.sql deleted file mode 100644 index 80def739b1..0000000000 --- a/platform/src/main/resources/db/migration/V11__sep6_client_domain.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE sep6_transaction ADD client_domain VARCHAR(255); \ No newline at end of file From 4a61d6466691c3abdadc9c33bb2eb6cae9859983 Mon Sep 17 00:00:00 2001 From: philipliu Date: Wed, 29 Nov 2023 16:29:02 -0500 Subject: [PATCH 3/5] Fix migration file name --- .../{V11__client_domain_name.sql => V12__client_domain_name.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/src/main/resources/db/migration/{V11__client_domain_name.sql => V12__client_domain_name.sql} (100%) diff --git a/platform/src/main/resources/db/migration/V11__client_domain_name.sql b/platform/src/main/resources/db/migration/V12__client_domain_name.sql similarity index 100% rename from platform/src/main/resources/db/migration/V11__client_domain_name.sql rename to platform/src/main/resources/db/migration/V12__client_domain_name.sql From 88b68bf5f69cf280b1c3c47eff408ba3638e4aed Mon Sep 17 00:00:00 2001 From: philipliu Date: Wed, 29 Nov 2023 16:43:50 -0500 Subject: [PATCH 4/5] Rename method in test --- .../stellar/anchor/util/ClientFinderTest.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt b/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt index ec6ecaeaed..7760ca526b 100644 --- a/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/util/ClientFinderTest.kt @@ -54,7 +54,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with client found by domain`() { + fun `test getClientName with client found by domain`() { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns clientConfig val clientId = clientFinder.getClientName(token) @@ -62,7 +62,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with client found by signing key`() { + fun `test getClientName with client found by signing key`() { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null val clientId = clientFinder.getClientName(token) @@ -70,7 +70,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with client not found`() { + fun `test getClientName with client not found`() { every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null every { clientsConfig.getClientConfigBySigningKey(token.account) } returns null @@ -78,21 +78,21 @@ class ClientFinderTest { } @Test - fun `test getClientId with client not found by domain`() { + fun `test getClientName with client not found by domain`() { every { sep10Config.allowedClientDomains } returns listOf("nothing") assertThrows { clientFinder.getClientName(token) } } @Test - fun `test getClientId with client not found by name`() { + fun `test getClientName with client not found by name`() { every { sep10Config.allowedClientNames } returns listOf("nothing") assertThrows { clientFinder.getClientName(token) } } @Test - fun `test getClientId with all domains allowed`() { + fun `test getClientName with all domains allowed`() { every { sep10Config.allowedClientDomains } returns emptyList() val clientId = clientFinder.getClientName(token) @@ -100,7 +100,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with all names allowed`() { + fun `test getClientName with all names allowed`() { every { sep10Config.allowedClientNames } returns emptyList() val clientId = clientFinder.getClientName(token) @@ -108,7 +108,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with client attribution disabled and missing client`() { + fun `test getClientName with client attribution disabled and missing client`() { every { sep10Config.isClientAttributionRequired } returns false every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null every { clientsConfig.getClientConfigBySigningKey(token.account) } returns null @@ -118,7 +118,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with client attribution disabled and client found by signing key`() { + fun `test getClientName with client attribution disabled and client found by signing key`() { every { sep10Config.isClientAttributionRequired } returns false every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns null every { clientsConfig.getClientConfigBySigningKey(token.account) } returns clientConfig @@ -128,7 +128,7 @@ class ClientFinderTest { } @Test - fun `test getClientId with client attribution disabled and client found by domain`() { + fun `test getClientName with client attribution disabled and client found by domain`() { every { sep10Config.isClientAttributionRequired } returns false every { clientsConfig.getClientConfigByDomain(token.clientDomain) } returns clientConfig every { clientsConfig.getClientConfigBySigningKey(token.account) } returns null From c3217a13528d7d900c2fdf6e8ffd6f76950d118e Mon Sep 17 00:00:00 2001 From: philipliu Date: Wed, 29 Nov 2023 17:24:34 -0500 Subject: [PATCH 5/5] Fix extended tests --- .../anchor/platform/test/CustodyApiTests.kt | 6 +++-- .../platform/test/PlatformApiCustodyTests.kt | 27 ++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/CustodyApiTests.kt b/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/CustodyApiTests.kt index 50ccf8bf0c..527aac9619 100644 --- a/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/CustodyApiTests.kt +++ b/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/CustodyApiTests.kt @@ -523,7 +523,8 @@ private const val EXPECTED_TRANSACTION_RESPONSE = ] } ], - "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG" + "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", + "client_name": "referenceCustodial" } """ @@ -602,7 +603,8 @@ private const val EXPECTED_TXN_REFUND_RESPONSE = "memo": "testTag", "memo_type": "id", "refund_memo": "12345", - "refund_memo_type": "id" + "refund_memo_type": "id", + "client_name": "referenceCustodial" } """ diff --git a/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/PlatformApiCustodyTests.kt b/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/PlatformApiCustodyTests.kt index 66d8e3ca96..784ce3264a 100644 --- a/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/PlatformApiCustodyTests.kt +++ b/extended-tests/src/test/kotlin/org/stellar/anchor/platform/test/PlatformApiCustodyTests.kt @@ -279,7 +279,8 @@ private const val SEP_24_DEPOSIT_COMPLETE_FULL_FLOW_ACTION_RESPONSES = "started_at": "2023-08-07T12:52:01.663006Z", "updated_at": "2023-08-07T12:52:03.100242Z", "message": "test message 1", - "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG" + "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", + "client_name": "referenceCustodial" }, "id": "1" }, @@ -309,7 +310,8 @@ private const val SEP_24_DEPOSIT_COMPLETE_FULL_FLOW_ACTION_RESPONSES = "started_at": "2023-08-07T12:52:01.663006Z", "updated_at": "2023-08-07T12:52:04.165625Z", "message": "test message 2", - "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG" + "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", + "client_name": "referenceCustodial" }, "id": "2" }, @@ -340,7 +342,8 @@ private const val SEP_24_DEPOSIT_COMPLETE_FULL_FLOW_ACTION_RESPONSES = "updated_at": "2023-08-07T12:52:05.241766Z", "message": "test message 3", "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", - "external_transaction_id": "ext-123456" + "external_transaction_id": "ext-123456", + "client_name": "referenceCustodial" }, "id": "3" }, @@ -371,7 +374,8 @@ private const val SEP_24_DEPOSIT_COMPLETE_FULL_FLOW_ACTION_RESPONSES = "updated_at": "2023-08-07T12:52:07.016199Z", "message": "test message 4", "destination_account": "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG", - "external_transaction_id": "ext-123456" + "external_transaction_id": "ext-123456", + "client_name": "referenceCustodial" }, "id": "4" } @@ -515,7 +519,8 @@ private const val SEP_24_WITHDRAW_FULL_REFUND_FLOW_ACTION_RESPONSES = "updated_at": "2023-08-07T10:35:39.973638Z", "message": "test message 1", "source_account": "GAIUIZPHLIHQEMNJGSZKCEUWHAZVGUZDBDMO2JXNAJZZZVNSVHQCEWJ4", - "destination_account": "GBN4NNCDGJO4XW4KQU3CBIESUJWFVBUZPOKUZHT7W7WRB7CWOA7BXVQF" + "destination_account": "GBN4NNCDGJO4XW4KQU3CBIESUJWFVBUZPOKUZHT7W7WRB7CWOA7BXVQF", + "client_name": "referenceCustodial" }, "id": "1" }, @@ -548,7 +553,8 @@ private const val SEP_24_WITHDRAW_FULL_REFUND_FLOW_ACTION_RESPONSES = "source_account": "GAIUIZPHLIHQEMNJGSZKCEUWHAZVGUZDBDMO2JXNAJZZZVNSVHQCEWJ4", "destination_account": "GBA3CI3MMCHWNKQYGYQNXGXSQEZZHTZCYY5JZ7MIVLJ74DBUGIOAGNV6", "memo": "testMemo", - "memo_type": "id" + "memo_type": "id", + "client_name": "referenceCustodial" }, "id": "2" }, @@ -602,7 +608,8 @@ private const val SEP_24_WITHDRAW_FULL_REFUND_FLOW_ACTION_RESPONSES = "source_account": "GAIUIZPHLIHQEMNJGSZKCEUWHAZVGUZDBDMO2JXNAJZZZVNSVHQCEWJ4", "destination_account": "GBA3CI3MMCHWNKQYGYQNXGXSQEZZHTZCYY5JZ7MIVLJ74DBUGIOAGNV6", "memo": "testMemo", - "memo_type": "id" + "memo_type": "id", + "client_name": "referenceCustodial" }, "id": "3" }, @@ -656,7 +663,8 @@ private const val SEP_24_WITHDRAW_FULL_REFUND_FLOW_ACTION_RESPONSES = "source_account": "GAIUIZPHLIHQEMNJGSZKCEUWHAZVGUZDBDMO2JXNAJZZZVNSVHQCEWJ4", "destination_account": "GBA3CI3MMCHWNKQYGYQNXGXSQEZZHTZCYY5JZ7MIVLJ74DBUGIOAGNV6", "memo": "testMemo", - "memo_type": "id" + "memo_type": "id", + "client_name": "referenceCustodial" }, "id": "4" }, @@ -735,7 +743,8 @@ private const val SEP_24_WITHDRAW_FULL_REFUND_FLOW_ACTION_RESPONSES = "source_account": "GAIUIZPHLIHQEMNJGSZKCEUWHAZVGUZDBDMO2JXNAJZZZVNSVHQCEWJ4", "destination_account": "GBA3CI3MMCHWNKQYGYQNXGXSQEZZHTZCYY5JZ7MIVLJ74DBUGIOAGNV6", "memo": "testMemo", - "memo_type": "id" + "memo_type": "id", + "client_name": "referenceCustodial" }, "id": "5" }