diff --git a/core/src/main/java/org/stellar/anchor/asset/AssetServiceValidator.java b/core/src/main/java/org/stellar/anchor/asset/AssetServiceValidator.java index 84e074af30..67fff5b5b3 100644 --- a/core/src/main/java/org/stellar/anchor/asset/AssetServiceValidator.java +++ b/core/src/main/java/org/stellar/anchor/asset/AssetServiceValidator.java @@ -17,12 +17,6 @@ public static void validate(AssetService assetService) throws InvalidConfigExcep throw new InvalidConfigException("0 assets defined in configuration"); } - // TODO: remove this check once we support SEP-31 and SEP-38 for native asset - AssetInfo nativeAsset = assetService.getAsset("native"); - if (nativeAsset != null && (nativeAsset.getSep31Enabled() || nativeAsset.getSep38Enabled())) { - throw new InvalidConfigException("Native asset does not support SEP-31 or SEP-38"); - } - // Check for duplicate assets Set existingAssetNames = new HashSet<>(); for (AssetInfo asset : assetService.listAllAssets()) { diff --git a/core/src/test/kotlin/org/stellar/anchor/asset/DefaultAssetServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/asset/DefaultAssetServiceTest.kt index 0954f789b4..df1230498a 100644 --- a/core/src/test/kotlin/org/stellar/anchor/asset/DefaultAssetServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/asset/DefaultAssetServiceTest.kt @@ -53,16 +53,6 @@ internal class DefaultAssetServiceTest { } } - @Test - fun `test native asset with SEP-31 or SEP-38 enabled`() { - assertThrows { - DefaultAssetService.fromJsonResource("test_native_asset_sep31.json.bad") - } - assertThrows { - DefaultAssetService.fromJsonResource("test_native_asset_sep38.json.bad") - } - } - @Test fun `test invalid config with duplicate assets`() { assertThrows { @@ -389,8 +379,8 @@ internal class DefaultAssetServiceTest { }, "sep6_enabled": false, "sep24_enabled": true, - "sep31_enabled": false, - "sep38_enabled": false + "sep31_enabled": true, + "sep38_enabled": true } ] } diff --git a/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt b/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt index f6c0aa797d..922515f21f 100644 --- a/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt @@ -21,11 +21,11 @@ class InfoResponseTest { @Test fun `test the InfoResponse construction`() { val infoResponse = InfoResponse(assets) - assertEquals(3, infoResponse.assets.size) + assertEquals(4, infoResponse.assets.size) val assetMap = HashMap() infoResponse.assets.forEach { assetMap[it.asset] = it } - assertEquals(3, assetMap.size) + assertEquals(4, assetMap.size) val stellarUSDC = assetMap["stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"] @@ -65,5 +65,14 @@ class InfoResponseTest { ) assertTrue(fiatUSD.exchangeableAssetNames.containsAll(wantAssets)) assertTrue(wantAssets.containsAll(fiatUSD.exchangeableAssetNames)) + + val stellarNative = assetMap["stellar:native"] + assertNotNull(stellarNative) + assertNull(stellarNative!!.countryCodes) + assertNull(stellarNative.sellDeliveryMethods) + assertNull(stellarNative.buyDeliveryMethods) + wantAssets = listOf("stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP") + assertTrue(stellarNative.exchangeableAssetNames.containsAll(wantAssets)) + assertTrue(wantAssets.containsAll(stellarNative.exchangeableAssetNames)) } } diff --git a/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt index e209dcdf50..6983a6b885 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt @@ -88,11 +88,11 @@ class Sep38ServiceTest { @Test fun `test GET info`() { val infoResponse = sep38Service.info - assertEquals(3, infoResponse.assets.size) + assertEquals(4, infoResponse.assets.size) val assetMap = HashMap() infoResponse.assets.forEach { assetMap[it.asset] = it } - assertEquals(3, assetMap.size) + assertEquals(4, assetMap.size) val usdcAsset = assetMap[stellarUSDC] assertNotNull(usdcAsset) @@ -128,6 +128,15 @@ class Sep38ServiceTest { listOf("stellar:JPYC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", stellarUSDC) assertTrue(fiatUSD.exchangeableAssetNames.containsAll(wantAssets)) assertTrue(wantAssets.containsAll(fiatUSD.exchangeableAssetNames)) + + val stellarNative = assetMap["stellar:native"] + assertNotNull(stellarNative) + assertNull(stellarNative!!.countryCodes) + assertNull(stellarNative.sellDeliveryMethods) + assertNull(stellarNative.buyDeliveryMethods) + wantAssets = listOf("stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP") + assertTrue(stellarNative.exchangeableAssetNames.containsAll(wantAssets)) + assertTrue(wantAssets.containsAll(stellarNative.exchangeableAssetNames)) } @Test diff --git a/core/src/test/resources/test_assets.json b/core/src/test/resources/test_assets.json index e636e5d929..c3dc0f1dc9 100644 --- a/core/src/test/resources/test_assets.json +++ b/core/src/test/resources/test_assets.json @@ -286,8 +286,8 @@ }, "sep6_enabled": false, "sep24_enabled": true, - "sep31_enabled": false, - "sep38_enabled": false + "sep31_enabled": true, + "sep38_enabled": true } ] } \ No newline at end of file diff --git a/core/src/test/resources/test_assets.yaml b/core/src/test/resources/test_assets.yaml index cd718a4c00..4fe2633e4d 100644 --- a/core/src/test/resources/test_assets.yaml +++ b/core/src/test/resources/test_assets.yaml @@ -205,5 +205,5 @@ assets: decimals: 7 sep6_enabled: false sep24_enabled: true - sep31_enabled: false - sep38_enabled: false \ No newline at end of file + sep31_enabled: true + sep38_enabled: true \ No newline at end of file diff --git a/core/src/test/resources/test_native_asset_sep31.json.bad b/core/src/test/resources/test_native_asset_sep31.json.bad deleted file mode 100644 index 4f5f98ba99..0000000000 --- a/core/src/test/resources/test_native_asset_sep31.json.bad +++ /dev/null @@ -1,79 +0,0 @@ -{ - "assets": [ - { - "schema": "stellar", - "code": "native", - "significant_decimals": 7, - "deposit": { - "enabled": true, - "min_amount": 1, - "max_amount": 1000000 - }, - "withdraw": { - "enabled": true, - "min_amount": 1, - "max_amount": 1000000 - }, - "send": { - "fee_fixed": 0, - "fee_percent": 0, - "min_amount": 1, - "max_amount": 1000000 - }, - "sep31": { - "quotes_supported": true, - "quotes_required": true, - "sep12": { - "sender": { - "types": { - "sep31-sender": { - "description": "U.S. citizens limited to sending payments of less than $10,000 in value" - }, - "sep31-large-sender": { - "description": "U.S. citizens that do not have sending limits" - }, - "sep31-foreign-sender": { - "description": "non-U.S. citizens sending payments of less than $10,000 in value" - } - } - }, - "receiver": { - "types": { - "sep31-receiver": { - "description": "U.S. citizens receiving USD" - }, - "sep31-foreign-receiver": { - "description": "non-U.S. citizens receiving USD" - } - } - } - }, - "fields": { - "transaction": { - "receiver_routing_number": { - "description": "routing number of the destination bank account" - }, - "receiver_account_number": { - "description": "bank account number of the destination" - }, - "type": { - "description": "type of deposit to make", - "choices": [ - "SEPA", - "SWIFT" - ] - } - } - } - }, - "sep38": { - "exchangeable_assets": [ - "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" - ], - "decimals": 7 - }, - "sep31_enabled": true, - "sep38_enabled": false - } - ] -} diff --git a/core/src/test/resources/test_native_asset_sep38.json.bad b/core/src/test/resources/test_native_asset_sep38.json.bad deleted file mode 100644 index b723b4d688..0000000000 --- a/core/src/test/resources/test_native_asset_sep38.json.bad +++ /dev/null @@ -1,79 +0,0 @@ -{ - "assets": [ - { - "schema": "stellar", - "code": "native", - "significant_decimals": 7, - "deposit": { - "enabled": true, - "min_amount": 1, - "max_amount": 1000000 - }, - "withdraw": { - "enabled": true, - "min_amount": 1, - "max_amount": 1000000 - }, - "send": { - "fee_fixed": 0, - "fee_percent": 0, - "min_amount": 1, - "max_amount": 1000000 - }, - "sep31": { - "quotes_supported": true, - "quotes_required": true, - "sep12": { - "sender": { - "types": { - "sep31-sender": { - "description": "U.S. citizens limited to sending payments of less than $10,000 in value" - }, - "sep31-large-sender": { - "description": "U.S. citizens that do not have sending limits" - }, - "sep31-foreign-sender": { - "description": "non-U.S. citizens sending payments of less than $10,000 in value" - } - } - }, - "receiver": { - "types": { - "sep31-receiver": { - "description": "U.S. citizens receiving USD" - }, - "sep31-foreign-receiver": { - "description": "non-U.S. citizens receiving USD" - } - } - } - }, - "fields": { - "transaction": { - "receiver_routing_number": { - "description": "routing number of the destination bank account" - }, - "receiver_account_number": { - "description": "bank account number of the destination" - }, - "type": { - "description": "type of deposit to make", - "choices": [ - "SEPA", - "SWIFT" - ] - } - } - } - }, - "sep38": { - "exchangeable_assets": [ - "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" - ], - "decimals": 7 - }, - "sep31_enabled": false, - "sep38_enabled": true - } - ] -} diff --git a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/Sep31Tests.kt b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/Sep31Tests.kt index 2decc13c1a..b8950b1c2e 100644 --- a/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/Sep31Tests.kt +++ b/essential-tests/src/testFixtures/kotlin/org/stellar/anchor/platform/integrationtest/Sep31Tests.kt @@ -498,6 +498,59 @@ private const val expectedSep31Info = } } } + }, + "native": { + "enabled": true, + "quotes_supported": true, + "quotes_required": true, + "fee_fixed": 0, + "fee_percent": 0, + "max_amount": 1000000, + "sep12": { + "sender": { + "types": { + "sep31-sender": { + "description": "U.S. citizens limited to sending payments of less than ${'$'}10,000 in value" + }, + "sep31-large-sender": { + "description": "U.S. citizens that do not have sending limits" + }, + "sep31-foreign-sender": { + "description": "non-U.S. citizens sending payments of less than ${'$'}10,000 in value" + } + } + }, + "receiver": { + "types": { + "sep31-receiver": { + "description": "U.S. citizens receiving USD" + }, + "sep31-foreign-receiver": { + "description": "non-U.S. citizens receiving USD" + } + } + } + }, + "fields": { + "transaction": { + "receiver_routing_number": { + "description": "routing number of the destination bank account", + "optional": false + }, + "receiver_account_number": { + "description": "bank account number of the destination", + "optional": false + }, + "type": { + "description": "type of deposit to make", + "choices": [ + "SEPA", + "SWIFT" + ], + "optional": false + } + } + } } } } diff --git a/service-runner/src/main/resources/config/assets.yaml b/service-runner/src/main/resources/config/assets.yaml index 090a4feafc..7320cbf433 100644 --- a/service-runner/src/main/resources/config/assets.yaml +++ b/service-runner/src/main/resources/config/assets.yaml @@ -247,6 +247,6 @@ assets: - stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP decimals: 7 sep6_enabled: false - sep31_enabled: false - sep38_enabled: false + sep31_enabled: true + sep38_enabled: true sep24_enabled: true \ No newline at end of file