Skip to content

Commit

Permalink
[ANCHOR-936] Country code validation and bump version (#1615)
Browse files Browse the repository at this point in the history
### Description

This is a re-submit of
#1609 as the original PR
was reverted as part of 3.0.1 release revertion

### Next Step
Cut release/3.0.1 from develop HEAD and merge it to main
Regenerate release note
  • Loading branch information
JiahuiWho authored Jan 9, 2025
2 parents a9f6f06 + 3b5adc8 commit 182f9b4
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ subprojects {

allprojects {
group = "org.stellar.anchor-sdk"
version = "3.0.0"
version = "3.0.1"

tasks.jar {
manifest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,15 @@ static void validateSep38(AssetService assetService, Sep38Info sep38Info, String
}
}

// TODO: Enable validate country codes in version 3.x because 2.x does not conform to the ISO
// country code
/*
// Validate country codes
if (sep38Info.getCountryCodes() != null) {
for (String country : sep38Info.getCountryCodes()) {
if (!isCountryCodeValid(country))
throw new InvalidConfigException(
String.format("Invalid country code %s defined for asset %s.", country, assetId));
}
}
*/

if (sep38Info.getBuyDeliveryMethods() != null) {
// Validate methods
for (DeliveryMethod method : sep38Info.getBuyDeliveryMethods()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ items:
# - stellar:USDC:GBN4NNCDGJO4XW4KQU3CBIESUJWFVBUZPOKUZHT7W7WRB7CWOA7BXVQF
exchangeable_assets:

# The list of the country codes that the asset is available in.
# The list of the ISO 3166-1 alpha-2 country codes that the asset is available in.
# Example:
# - USA
# - CAN
# - US
# - CA
country_codes:

# An array of objects describing the methods a client can use to sell/deliver funds to the anchor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ internal class DefaultAssetServiceTest {
"stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
],
"country_codes": [
"USA"
"US"
],
"sell_delivery_methods": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class InfoResponseTest {

val fiatUSD = assetMap["iso4217:USD"]
assertNotNull(fiatUSD)
assertEquals(listOf("USA"), fiatUSD!!.countryCodes)
assertEquals(listOf("US"), fiatUSD!!.countryCodes)
val wantSellDeliveryMethod =
Sep38Info.DeliveryMethod("WIRE", "Send USD directly to the Anchor's bank account.")
assertEquals(listOf(wantSellDeliveryMethod), fiatUSD.sellDeliveryMethods)
Expand Down
30 changes: 15 additions & 15 deletions core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Sep38ServiceTest {

val fiatUSD = assetMap[fiatUSD]
assertNotNull(fiatUSD)
assertEquals(listOf("USA"), fiatUSD!!.countryCodes)
assertEquals(listOf("US"), fiatUSD!!.countryCodes)
val wantSellDeliveryMethod =
Sep38Info.DeliveryMethod("WIRE", "Send USD directly to the Anchor's bank account.")
assertEquals(listOf(wantSellDeliveryMethod), fiatUSD.sellDeliveryMethods)
Expand Down Expand Up @@ -236,7 +236,7 @@ class Sep38ServiceTest {
.sellAsset(fiatUSD)
.buyAsset("stellar:JPYC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5")
.sellAmount("100")
.countryCode("USA")
.countryCode("US")
.sellDeliveryMethod("WIRE")
.build()
every { mockRateIntegration.getRate(getRateReq1) } returns
Expand All @@ -248,7 +248,7 @@ class Sep38ServiceTest {
.sellAsset(fiatUSD)
.buyAsset(stellarUSDC)
.sellAmount("100")
.countryCode("USA")
.countryCode("US")
.sellDeliveryMethod("WIRE")
.build()
every { mockRateIntegration.getRate(getRateReq2) } returns
Expand All @@ -258,7 +258,7 @@ class Sep38ServiceTest {

// test happy path with all the parameters
var gotResponse: GetPricesResponse? = null
assertDoesNotThrow { gotResponse = sep38Service.getPrices(fiatUSD, "100", "WIRE", null, "USA") }
assertDoesNotThrow { gotResponse = sep38Service.getPrices(fiatUSD, "100", "WIRE", null, "US") }
val wantResponse = GetPricesResponse()
wantResponse.addAsset(stellarJPYC, 2, "1.1")
wantResponse.addAsset(stellarUSDC, 2, "2.1")
Expand Down Expand Up @@ -393,13 +393,13 @@ class Sep38ServiceTest {

// unsupported country_code
getPriceRequestBuilder = getPriceRequestBuilder.buyDeliveryMethod(null)
getPriceRequestBuilder = getPriceRequestBuilder.countryCode("BRA")
getPriceRequestBuilder = getPriceRequestBuilder.countryCode("BR")
ex = assertThrows { sep38Service.getPrice(null, getPriceRequestBuilder.build()) }
assertInstanceOf(BadRequestException::class.java, ex)
assertEquals("Unsupported country code", ex.message)

// unsupported (null) context
getPriceRequestBuilder = getPriceRequestBuilder.countryCode("USA")
getPriceRequestBuilder = getPriceRequestBuilder.countryCode("US")
ex = assertThrows { sep38Service.getPrice(null, getPriceRequestBuilder.build()) }
assertInstanceOf(BadRequestException::class.java, ex)
assertEquals("Unsupported context. Should be one of [sep6, sep31].", ex.message)
Expand Down Expand Up @@ -497,7 +497,7 @@ class Sep38ServiceTest {
.sellAsset(fiatUSD)
.buyAsset(stellarUSDC)
.sellAmount("100")
.countryCode("USA")
.countryCode("US")
.sellDeliveryMethod("WIRE")
.build()
every { mockRateIntegration.getRate(getRateReq) } returns
Expand All @@ -512,7 +512,7 @@ class Sep38ServiceTest {
.sellAmount("100")
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.countryCode("USA")
.countryCode("US")
.context(SEP6)
.build()
var gotResponse: GetPriceResponse? = null
Expand All @@ -537,7 +537,7 @@ class Sep38ServiceTest {
.sellAsset(fiatUSD)
.buyAsset(stellarUSDC)
.buyAmount("100")
.countryCode("USA")
.countryCode("US")
.sellDeliveryMethod("WIRE")
.build()

Expand All @@ -553,7 +553,7 @@ class Sep38ServiceTest {
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.buyAmount("100")
.countryCode("USA")
.countryCode("US")
.context(SEP31)
.build()
var gotResponse: GetPriceResponse? = null
Expand Down Expand Up @@ -788,7 +788,7 @@ class Sep38ServiceTest {
.sellAmount("1.23")
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.countryCode("BRA")
.countryCode("BR")
.build()
)
}
Expand All @@ -804,7 +804,7 @@ class Sep38ServiceTest {
.sellAmount("1.23")
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.countryCode("USA")
.countryCode("US")
.expireAfter("2022-04-18T23:33:24.629719Z")
.build()
)
Expand Down Expand Up @@ -1063,7 +1063,7 @@ class Sep38ServiceTest {
.sellAmount("100")
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.countryCode("USA")
.countryCode("US")
.expireAfter(now.toString())
.build()
)
Expand Down Expand Up @@ -1167,7 +1167,7 @@ class Sep38ServiceTest {
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.buyAmount("100")
.countryCode("USA")
.countryCode("US")
.expireAfter(now.toString())
.build()
)
Expand Down Expand Up @@ -1279,7 +1279,7 @@ class Sep38ServiceTest {
.sellDeliveryMethod("WIRE")
.buyAssetName(stellarUSDC)
.buyAmount(requestBuyAmount)
.countryCode("USA")
.countryCode("US")
.expireAfter(now.toString())
.build()
)
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/resources/test_assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
],
"country_codes": [
"USA"
"US"
],
"decimals": 4,
"sell_delivery_methods": [
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/resources/test_assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ items:
- stellar:JPYC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5
- stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP
country_codes:
- USA
- US
sell_delivery_methods:
- name: WIRE
description: Send USD directly to the Anchor's bank account.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![License](https://badgen.net/badge/license/Apache%202/blue?icon=github&label=License)](https://github.com/stellar/java-stellar-anchor-sdk/blob/develop/LICENSE)
[![GitHub Version](https://badgen.net/github/release/stellar/java-stellar-anchor-sdk?icon=github&label=Latest%20release)](https://github.com/stellar/java-stellar-anchor-sdk/releases)
[![Docker](https://badgen.net/badge/Latest%20Release/v3.0.0/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=3.0.0)
[![Docker](https://badgen.net/badge/Latest%20Release/v3.0.1/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=3.0.1)
![Develop Branch](https://github.com/stellar/java-stellar-anchor-sdk/actions/workflows/on_push_to_develop.yml/badge.svg?branch=develop)

<div style="text-align: center">
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/sep-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ assets_config: |
exchangeable_assets:
- stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP
country_codes:
- USA
- US
sell_delivery_methods:
- name: WIRE
description: Send USD directly to the Anchor's bank account.
Expand All @@ -293,7 +293,7 @@ assets_config: |
exchangeable_assets:
- stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP
country_codes:
- CAN
- CA
sell_delivery_methods:
- name: WIRE
description: Send CAD directly to the Anchor's bank account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.stellar.anchor.filter.PlatformAuthJwtFilter;
import org.stellar.anchor.horizon.Horizon;
import org.stellar.anchor.platform.apiclient.CustodyApiClient;
import org.stellar.anchor.platform.condition.OnAnySepsEnabled;
import org.stellar.anchor.platform.config.PlatformApiConfig;
import org.stellar.anchor.platform.config.PlatformServerConfig;
import org.stellar.anchor.platform.config.PropertyCustodyConfig;
Expand Down
2 changes: 1 addition & 1 deletion platform/src/main/resources/example.anchor-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ assets:
"stellar:JPYC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
],
"country_codes": [
"USA"
"US"
],
"decimals": 4,
"sell_delivery_methods": [
Expand Down
2 changes: 1 addition & 1 deletion platform/src/test/resources/test_assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"exchangeable_assets": [
"stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"
],
"country_codes": ["USA"],
"country_codes": ["US"],
"decimals": 4,
"sell_delivery_methods": [
{
Expand Down
2 changes: 1 addition & 1 deletion platform/src/test/resources/test_assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ items:
exchangeable_assets:
- stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN
country_codes:
- USA
- US
decimals: 4
sell_delivery_methods:
- name: WIRE
Expand Down
2 changes: 1 addition & 1 deletion platform/src/test/resources/test_sep38_get_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"asset": "iso4217:USD",
"country_codes": ["USA"],
"country_codes": ["US"],
"decimals": 4,
"sell_delivery_methods": [
{
Expand Down
4 changes: 2 additions & 2 deletions service-runner/src/main/resources/config/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ items:
- stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP
- stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5
country_codes:
- USA
- US
sell_delivery_methods:
- name: WIRE
description: Send USD directly to the Anchor's bank account.
Expand All @@ -204,7 +204,7 @@ items:
- stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP
- stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5
country_codes:
- CAN
- CA
sell_delivery_methods:
- name: WIRE
description: Send CAD directly to the Anchor's bank account.
Expand Down

0 comments on commit 182f9b4

Please sign in to comment.