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..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 @@ -89,6 +89,12 @@ public class PlatformTransactionData { @SerializedName("withdraw_anchor_account") String withdrawAnchorAccount; + @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 1592e23a3c..62366dbc14 100644 --- a/core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java +++ b/core/src/main/java/org/stellar/anchor/sep24/Sep24Service.java @@ -41,6 +41,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; @@ -62,6 +63,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; @@ -93,6 +95,7 @@ public Sep24Service( ClientsConfig clientsConfig, AssetService assetService, JwtService jwtService, + ClientFinder clientFinder, Sep24TransactionStore txnStore, EventService eventService, InteractiveUrlConstructor interactiveUrlConstructor, @@ -106,6 +109,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; @@ -209,7 +213,8 @@ public InteractiveTransactionResponse withdraw( .sep10AccountMemo(token.getAccountMemo()) .fromAccount(sourceAccount) .toAccount(asset.getDistributionAccount()) - .clientDomain(token.getClientDomain()); + .clientDomain(token.getClientDomain()) + .clientName(clientFinder.getClientName(token)); if (!isEmpty(asset.getDistributionAccount())) { builder.withdrawAnchorAccount(asset.getDistributionAccount()); @@ -397,6 +402,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 191dd09a1c..91fbb5b468 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,8 @@ public class PojoSep6Transaction implements Sep6Transaction { String toAccount; 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 466899d435..a864a5941c 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt @@ -39,6 +39,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.sep38.PojoSep38Quote @@ -106,6 +107,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 @@ -148,6 +151,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 calculator = ExchangeAmountsCalculator(sep38QuoteStore) sep24Service = @@ -157,6 +161,7 @@ internal class Sep24ServiceTest { clientsConfig, assetService, jwtService, + clientFinder, txnStore, eventService, interactiveUrlConstructor, @@ -195,6 +200,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") } @@ -244,6 +250,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 @@ -343,6 +350,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 @@ -377,6 +385,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 @@ -442,6 +451,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 4fbdb95c2e..20561c45f3 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,9 @@ class Sep6ServiceTestData { "amountExpected": "100", "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", - "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO" + "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant" } """ .trimIndent() @@ -188,6 +190,8 @@ class Sep6ServiceTestData { "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -212,7 +216,9 @@ class Sep6ServiceTestData { "requestAssetIssuer": "GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", - "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO" + "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant" } """ @@ -231,6 +237,8 @@ class Sep6ServiceTestData { "asset": "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -264,6 +272,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "quoteId": "test-quote-id" } """ @@ -293,6 +303,8 @@ class Sep6ServiceTestData { }, "quote_id": "test-quote-id", "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -325,7 +337,9 @@ class Sep6ServiceTestData { "amountExpected": "100", "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", - "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO" + "toAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant" } """ .trimIndent() @@ -351,6 +365,8 @@ class Sep6ServiceTestData { }, "amount_fee": { "amount": "0", "asset": "iso4217:USD" }, "destination_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -387,6 +403,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "refundMemo": "some text", "refundMemoType": "text" } @@ -413,6 +431,8 @@ class Sep6ServiceTestData { "source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "refund_memo": "some text", "refund_memo_type": "text", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -439,6 +459,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "refundMemo": "some text", "refundMemoType": "text" } @@ -460,6 +482,8 @@ class Sep6ServiceTestData { "source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "refund_memo": "some text", "refund_memo_type": "text", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -493,6 +517,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "quoteId": "test-quote-id", "refundMemo": "some text", "refundMemoType": "text" @@ -523,6 +549,8 @@ class Sep6ServiceTestData { "source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "refund_memo": "some text", "refund_memo_type": "text", + "client_domain": "vibrant.stellar.org", + "client_name": "vibrant", "customers": { "sender": { "account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", @@ -556,6 +584,8 @@ class Sep6ServiceTestData { "sep10Account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "sep10AccountMemo": "123", "fromAccount": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", + "clientDomain": "vibrant.stellar.org", + "clientName": "vibrant", "refundMemo": "some text", "refundMemoType": "text" } @@ -588,6 +618,8 @@ class Sep6ServiceTestData { "source_account": "GBLGJA4TUN5XOGTV6WO2BWYUI2OZR5GYQ5PDPCRMQ5XEPJOYWB2X4CJO", "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..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,86 +54,86 @@ 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.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @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.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @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 - assertThrows { clientFinder.getClientId(token) } + assertThrows { clientFinder.getClientName(token) } } @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.getClientId(token) } + 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.getClientId(token) } + 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.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @Test - fun `test getClientId with all names allowed`() { + fun `test getClientName with all names allowed`() { every { sep10Config.allowedClientNames } returns emptyList() - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @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 - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertNull(clientId) } @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 - val clientId = clientFinder.getClientId(token) + val clientId = clientFinder.getClientName(token) assertEquals(clientConfig.name, clientId) } @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 - 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/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" } 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 6b93be61ac..43f5d0b932 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, @@ -190,6 +193,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 1699279120..7d046d4885 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 6823677ccd..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 @@ -87,6 +87,14 @@ public String getProtocol() { @Column(name = "memo_type") String memoType; + @SerializedName("client_domain") + @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/V12__client_domain_name.sql b/platform/src/main/resources/db/migration/V12__client_domain_name.sql new file mode 100644 index 0000000000..6ef076bd97 --- /dev/null +++ b/platform/src/main/resources/db/migration/V12__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);