Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANCHOR-729]Include buy/sell delivery method in SEP-38 GET /quote response #1520

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public class GetQuoteResponse {
@SerializedName("sell_asset")
String sellAsset;

@JsonProperty("sell_delivery_method")
@SerializedName("sell_delivery_method")
String sellDeliveryMethod;

@JsonProperty("buy_amount")
@SerializedName("buy_amount")
String buyAmount;
Expand All @@ -31,6 +35,10 @@ public class GetQuoteResponse {
@SerializedName("buy_asset")
String buyAsset;

@JsonProperty("buy_delivery_method")
@SerializedName("buy_delivery_method")
String buyDeliveryMethod;

@JsonProperty("expires_at")
@SerializedName("expires_at")
Instant expiresAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ public class Sep38QuoteResponse {
@SerializedName("sell_amount")
String sellAmount;

@SerializedName("sell_delivery_method")
String sellDeliveryMethod;

@SerializedName("buy_asset")
String buyAsset;

@SerializedName("buy_amount")
String buyAmount;

@SerializedName("buy_delivery_method")
String buyDeliveryMethod;

FeeDetails fee;
}
6 changes: 6 additions & 0 deletions core/src/main/java/org/stellar/anchor/sep38/Sep38Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ public Sep38QuoteResponse postQuote(Sep10Jwt token, Sep38PostQuoteRequest reques
.expiresAt(rate.getExpiresAt())
.price(rate.getPrice())
.sellAsset(request.getSellAssetName())
.sellDeliveryMethod(request.getSellDeliveryMethod())
.buyAsset(request.getBuyAssetName())
.buyDeliveryMethod(request.getBuyDeliveryMethod())
.fee(rate.getFee());

String sellAmount = formatAmount(decimal(rate.getSellAmount()), sellAsset.getDecimals());
Expand Down Expand Up @@ -412,8 +414,10 @@ public Sep38QuoteResponse postQuote(Sep10Jwt token, Sep38PostQuoteRequest reques
updateField(newQuote, "id", event, "quote.id");
updateField(newQuote, "sellAsset", event, "quote.sellAsset");
updateField(newQuote, "sellAmount", event, "quote.sellAmount");
updateField(newQuote, "sellDeliveryMethod", event, "quote.sellDeliveryMethod");
updateField(newQuote, "buyAsset", event, "quote.buyAsset");
updateField(newQuote, "buyAmount", event, "quote.buyAmount");
updateField(newQuote, "buyDeliveryMethod", event, "quote.buyDeliveryMethod");
updateField(newQuote, "expiresAt", event, "quote.expiresAt");
updateField(newQuote, "createdAt", event, "quote.createdAt");
updateField(newQuote, "price", event, "quote.price");
Expand Down Expand Up @@ -473,8 +477,10 @@ public Sep38QuoteResponse getQuote(Sep10Jwt token, String quoteId) throws Anchor
.price(quote.getPrice())
.sellAsset(quote.getSellAsset())
.sellAmount(quote.getSellAmount())
.sellDeliveryMethod(quote.getSellDeliveryMethod())
.buyAsset(quote.getBuyAsset())
.buyAmount(quote.getBuyAmount())
.buyDeliveryMethod(quote.getBuyDeliveryMethod())
.fee(quote.getFee())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ class Sep38ServiceTest {
.totalPrice("1.0300000004")
.sellAsset(fiatUSD)
.sellAmount("100")
.sellDeliveryMethod("WIRE")
.buyAsset(stellarUSDC)
.buyAmount("97.09")
.fee(mockFee)
Expand Down Expand Up @@ -1113,6 +1114,7 @@ class Sep38ServiceTest {
wantEvent.quote.id = "123"
wantEvent.quote.sellAsset = fiatUSD
wantEvent.quote.sellAmount = "100"
wantEvent.quote.sellDeliveryMethod = "WIRE"
wantEvent.quote.buyAsset = stellarUSDC
wantEvent.quote.buyAmount = "97.09"
wantEvent.quote.expiresAt = tomorrow
Expand Down Expand Up @@ -1183,6 +1185,7 @@ class Sep38ServiceTest {
.totalPrice("1.03")
.sellAsset(fiatUSD)
.sellAmount("103")
.sellDeliveryMethod("WIRE")
.buyAsset(stellarUSDC)
.buyAmount("100")
.fee(mockFee)
Expand Down Expand Up @@ -1215,6 +1218,7 @@ class Sep38ServiceTest {
wantEvent.quote.id = "456"
wantEvent.quote.sellAsset = fiatUSD
wantEvent.quote.sellAmount = "103"
wantEvent.quote.sellDeliveryMethod = "WIRE"
wantEvent.quote.buyAsset = stellarUSDC
wantEvent.quote.buyAmount = "100"
wantEvent.quote.expiresAt = tomorrow
Expand Down Expand Up @@ -1293,6 +1297,7 @@ class Sep38ServiceTest {
.totalPrice(anchorCalculatedPrice)
.sellAsset(fiatUSD)
.sellAmount(anchorCalculatedSellAmount)
.sellDeliveryMethod("WIRE")
.buyAsset(stellarUSDC)
.buyAmount(anchorCalculatedBuyAmount)
.fee(mockFee)
Expand Down Expand Up @@ -1325,6 +1330,7 @@ class Sep38ServiceTest {
wantEvent.quote.id = "456"
wantEvent.quote.sellAsset = fiatUSD
wantEvent.quote.sellAmount = anchorCalculatedSellAmount
wantEvent.quote.sellDeliveryMethod = "WIRE"
wantEvent.quote.buyAsset = stellarUSDC
wantEvent.quote.buyAmount = anchorCalculatedBuyAmount
wantEvent.quote.expiresAt = tomorrow
Expand Down Expand Up @@ -1473,6 +1479,7 @@ class Sep38ServiceTest {
.totalPrice("1.03")
.sellAsset(fiatUSD)
.sellAmount("100")
.sellDeliveryMethod("WIRE")
.buyAsset(stellarUSDC)
.buyAmount("97.0873786")
.fee(mockFee)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.gson.reflect.TypeToken
import org.apache.hc.core5.http.HttpStatus.SC_OK
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.skyscreamer.jsonassert.Customization
import org.skyscreamer.jsonassert.JSONAssert
Expand Down Expand Up @@ -32,6 +33,7 @@ import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.util.GsonUtils

// TODO add refund flow test for withdrawal: https://stellarorg.atlassian.net/browse/ANCHOR-694
@Disabled
class PlatformApiTests : AbstractIntegrationTests(TestConfig()) {
private val gson = GsonUtils.getInstance()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.gson
import org.stellar.anchor.util.RSAUtil

@Disabled
class CustodyApiTests : AbstractIntegrationTests(TestConfig("custody")) {
private val custodyApiClient =
CustodyApiClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.RecordedRequest
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.skyscreamer.jsonassert.Customization
import org.skyscreamer.jsonassert.JSONAssert
Expand All @@ -23,6 +24,7 @@ import org.stellar.anchor.platform.AbstractIntegrationTests
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.util.GsonUtils

@Disabled
class PlatformApiCustodyTests : AbstractIntegrationTests(TestConfig("custody")) {
companion object {
private const val TX_ID_KEY = "TX_ID"
Expand Down
Loading