Skip to content

Commit

Permalink
Merge pull request #79 from unstoppabledomains/mike/dt-638-update-con…
Browse files Browse the repository at this point in the history
…figs-in-resolution-java

chore: Update default provider configs
  • Loading branch information
sammyluo authored Aug 29, 2022
2 parents 8367b2a + 9ee01bb commit 128cea9
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
name: Build & test

env:
TESTING_PROVIDER_URL: ${{ secrets.TESTING_PROVIDER_URL }}
TESTING_INFURA_PROJECT_ID: ${{ secrets.TESTING_INFURA_PROJECT_ID }}
nexusUsername: ${{ secrets.NEXUS_USERNAME }}
nexusPassword: ${{ secrets.NEXUS_PASSWORD }}

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.0
### Changes
* Updated default providers to use [Alchemy](http://alchemy.com/)

## 6.0.0

### New methods and features
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ Java 8+ version is required to use this library.

### Default Ethereum Providers

resolution-java library provides zero-configuration experience by using built-in production-ready Infura endpoint by default.
Default Ethereum provider is free to use without restrictions and rate-limits for UNS resolution.
resolution-java library provides zero-configuration experience by using built-in production-ready [Alchemy](http://alchemy.com/) endpoint by default.
Default Ethereum provider is free to use without restrictions and rate-limits for `UNS` resolution.

### Custom Ethereum provider configuration

You may want to specify a custom provider:
- if you want to use a dedicated blockchain node
- if you want to monitor app usage
- if you already have a provider in your app to re-use it for domain resolution

Default provider can be changed by using the builder class `ResolutionBuilder`.

```java
// Default config:

Expand All @@ -55,13 +62,13 @@ DomainResolution resolution = new Resolution();
// Note: if a custom configuration is provided for one UNS layer,
// it should be provided for the other layer too

String infuraApiKey = INFURA_PROJECT_ID;
String ethProviderURL = "https://mainnet.infura.io/v3/" + infuraApiKey
String polygonProviderURL = "https://polygon-mainnet.infura.io/v3/" + infuraApiKey
String ethProviderURL = ALCHEMY_ETHEREUM_API;
String polygonProviderURL = ALCHEMY_POLYGON_API;


DomainResolution resolution = Resolution.builder()
.unsProviderUrl(UNSLocation.Layer1, ethProviderURL)
.unsProviderUrl(UNSLocation.Layer1, polygonProviderURL)
.unsProviderUrl(UNSLocation.Layer2, polygonProviderURL)
.build();

// Custom provider config:
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,8 @@ task pullResolverKeys(type: Download) {
src 'https://raw.githubusercontent.com/unstoppabledomains/uns/main/resolver-keys.json'
dest 'src/main/resources/com/unstoppabledomains/config/knownRecords.json'
}

build {
dependsOn pullNetworkConfig
dependsOn pullResolverKeys
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static ResolutionBuilder builder() {

/**
* Create resolution object with default config:
* <a href="https://infura.io">infura</a> blockchain provider for UNS
* <a href="https://alchemy.com">alchemy</a> blockchain provider for UNS
* <a href="https://zilliqa.com">zilliqa</a> for ZNS
*/
public Resolution() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import com.unstoppabledomains.util.BuilderNSConfig;

public class ResolutionBuilder {
static final String UNS_DEFAULT_URL = "https://mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6";
static final String UNS_L2_DEFAULT_URL = "https://polygon-mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6";
static final String UNS_DEFAULT_URL = "https://eth-mainnet.g.alchemy.com/v2/0f3HESE2kvMWVLZJboiFHtHAlTtdbE_F";
static final String UNS_L2_DEFAULT_URL = "https://polygon-mainnet.g.alchemy.com/v2/PX1vXP3OgwLSsbRrk4NetZF7oqi6vcLE";
static final String ZILLIQA_DEFAULT_URL = "https://api.zilliqa.com";

static final String ZNS_DEFAULT_REGISTRY_ADDRESS = "0x9611c53BE6d1b32058b2747bdeCECed7e1216793";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "6.0.0"
"version": "6.1.0"
}
28 changes: 24 additions & 4 deletions src/main/resources/com/unstoppabledomains/config/knownRecords.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "2.1.1",
"version": "2.1.4",
"information": {
"description": "This file desribes all resolver keys with a defined meaning and related metadata used by Unstoppable Domains UNS Registry",
"documentation": "https://docs.unstoppabledomains.com/domain-registry-essentials/records-reference",
"description": "This file describes all resolver keys with a defined meaning and related metadata used by Unstoppable Domains UNS Registry",
"documentation": "https://docs.unstoppabledomains.com/developer-toolkit/records-reference/",
"contribution": "https://github.com/unstoppabledomains/uns/blob/main/resolver-keys.json"
},
"keys": {
Expand Down Expand Up @@ -436,6 +436,16 @@
"validationRegex": "^(G|P)[a-zA-HJ-NP-Z0-9]{25,39}$",
"deprecated": false
},
"crypto.YLD.address": {
"deprecatedKeyName": "YLD",
"deprecated": false,
"validationRegex": "^0x[a-fA-F0-9]{40}$"
},
"crypto.OKT.address": {
"deprecatedKeyName": "OKT",
"validationRegex": "^0x[a-fA-F0-9]{40}$|^ex[a-zA-HJ-NP-Z0-9]{6,90}$",
"deprecated": false
},
"crypto.ELA.version.ELA.address": {
"deprecatedKeyName": "ELA_ELA",
"validationRegex": "E[a-zA-HJ-NP-Z0-9]{33}",
Expand Down Expand Up @@ -466,6 +476,11 @@
"validationRegex": "^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$",
"deprecated": false
},
"crypto.USDT.version.OKC.address": {
"deprecatedKeyName": "USDT_OKC",
"validationRegex": "^0x[a-fA-F0-9]{40}$|^ex[a-zA-HJ-NP-Z0-9]{6,90}$",
"deprecated": false
},
"crypto.FTM.version.ERC20.address": {
"deprecatedKeyName": "FTM_ERC20",
"validationRegex": "^0x[a-fA-F0-9]{40}$",
Expand Down Expand Up @@ -1181,6 +1196,11 @@
"validationRegex": "^0x[a-fA-F0-9]{40}$",
"deprecated": false
},
"crypto.BLOCKS.address": {
"deprecatedKeyName": "BLOCKS",
"validationRegex": "^0x[a-fA-F0-9]{40}$",
"deprecated": false
},
"crypto.SHIB.version.ERC20.address": {
"deprecatedKeyName": "SHIB_ERC20",
"validationRegex": "^0x[a-fA-F0-9]{40}$",
Expand Down Expand Up @@ -2412,4 +2432,4 @@
"deprecated": false
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.0",
"version": "0.5.1",
"networks": {
"1": {
"contracts": {
Expand Down Expand Up @@ -106,7 +106,7 @@
"contracts": {
"UNSRegistry": {
"address": "0x070e83FCed225184E67c86302493ffFCDB953f71",
"implementation": "0x4473e84898E3F58feEFb7529dfF9E83Ff26CCae9",
"implementation": "0xe42Cae86552020ABb3C4D9d212B43f0e33C381D7",
"legacyAddresses": [],
"deploymentBlock": "0x5b57ea",
"forwarder": "0x070e83FCed225184E67c86302493ffFCDB953f71"
Expand Down Expand Up @@ -384,7 +384,7 @@
"address": "0x2a93C52E7B6E7054870758e15A1446E769EdfB93",
"legacyAddresses": [],
"deploymentBlock": "0x0189f713",
"implementation": "0xAc1a1F2136BfDe3a353a95C0676Cd0d55f311ee3",
"implementation": "0x267f251B85B2003B98645195D085021C5B6e928c",
"forwarder": "0x2a93C52E7B6E7054870758e15A1446E769EdfB93"
},
"CNSRegistry": {
Expand Down Expand Up @@ -472,4 +472,4 @@
}
}
}
}
}
6 changes: 2 additions & 4 deletions src/test/java/com/unstoppabledomains/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

public class TestUtils {

public static final String TESTING_INFURA_UNS_PROJECT_ID = "e0c0cb9d12c440a29379df066de587e6";
public static final String TESTING_INFURA_UNS_L2_PROJECT_ID = "e0c0cb9d12c440a29379df066de587e6";
public static final String TESTING_UNS_PROVIDER_URL = "https://eth-goerli.alchemyapi.io/v2/J-ff_OlmWzw41ocqwpkRccHdfqSZML4q";
public static final String TESTING_UNS_PROVIDER_URL = "https://eth-goerli.alchemyapi.io/v2/GBZTbTp1SUFwvUtVxVkKryzr3xbBq6k8";
public static final String TESTING_ZNS_PROVIDER_URL = "https://dev-api.zilliqa.com";
public static final String TESTING_UNS_L2_PROVIDER_URL = "https://polygon-mumbai.g.alchemy.com/v2/ymbY17ik_HyGfXnPWxBAGhuZE7MwtErX";
public static final String TESTING_UNS_L2_PROVIDER_URL = "https://polygon-mumbai.g.alchemy.com/v2/zvXnIKUcg-AuN67mMstCN_5ZsFZMf_j5";

public static <T> void expectError(Callable<T> f, NSExceptionCode code) throws Exception {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void shouldNotThrowExceptionsWhenLoadingRecords() {
void shouldLoadCorrectRecords() {
String versionFromCode = KnownRecords.getVersion();
// we want to keep this hardcoded and manually updated to test if the Client.getVersion correctly reads the .json file;
String versionFromFile = "2.1.1";
String versionFromFile = "2.1.4";
assertEquals(versionFromFile, versionFromCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void shouldNotThrowExceptionsWhenLoadingNetworkConfig() {
void shouldLoadCorrectNetworkConfig() {
String versionFromClient = Client.getVersion();
// we want to keep this hardcoded and manually updated to test if the Client.getVersion correctly reads the .json file;
String versionFromFile = "6.0.0";
String versionFromFile = "6.1.0";
assertEquals(versionFromFile, versionFromClient);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ private void checkUnsConfigurations(NSConfig expected, UNS service, UNSLocation

@Test
public void buildsWithDefaultParams() throws Exception {
NSConfig expectedUNSL1Config = new NSConfig(Network.MAINNET, "https://mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x3E67b8c702a1292d1CEb025494C84367fcb12b45");
NSConfig expectedUNSL1Config = new NSConfig(Network.MAINNET, "https://eth-mainnet.g.alchemy.com/v2/0f3HESE2kvMWVLZJboiFHtHAlTtdbE_F", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.g.alchemy.com/v2/PX1vXP3OgwLSsbRrk4NetZF7oqi6vcLE", "0x3E67b8c702a1292d1CEb025494C84367fcb12b45");
NSConfig expectedZNSConfig = new NSConfig(Network.MAINNET, "https://api.zilliqa.com", "0x9611c53BE6d1b32058b2747bdeCECed7e1216793");

ResolutionBuilder builder = new ResolutionBuilder(mockConnector);
Expand All @@ -61,8 +61,8 @@ public void buildsWithDefaultParams() throws Exception {

@Test
public void buildsWithCustomParams() throws Exception {
NSConfig expectedUNSL1Config = new NSConfig(Network.RINKEBY, "https://rinkeby.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x00000000000000000000000000000000000000001");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x00000000000000000000000000000000000000002");
NSConfig expectedUNSL1Config = new NSConfig(Network.GOERLI, "https://eth-goerli.alchemyapi.io/v2/GBZTbTp1SUFwvUtVxVkKryzr3xbBq6k8", "0x00000000000000000000000000000000000000001");
NSConfig expectedUNSL2Config = new NSConfig(Network.MUMBAI_TESTNET, "https://polygon-mumbai.g.alchemy.com/v2/zvXnIKUcg-AuN67mMstCN_5ZsFZMf_j5", "0x00000000000000000000000000000000000000002");
NSConfig expectedZNSConfig = new NSConfig(Network.ZIL_TESTNET, "https://dev-api.zilliqa.com", "0x00000000000000000000000000000000000000004");

ResolutionBuilder builder = new ResolutionBuilder(mockConnector);
Expand All @@ -89,8 +89,8 @@ public void buildsWithCustomParams() throws Exception {

@Test
public void allowsToCustomizeOneService() throws Exception {
NSConfig expectedUNSL1Config = new NSConfig(Network.MAINNET, "https://mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x3E67b8c702a1292d1CEb025494C84367fcb12b45");
NSConfig expectedUNSL1Config = new NSConfig(Network.MAINNET, "https://eth-mainnet.g.alchemy.com/v2/0f3HESE2kvMWVLZJboiFHtHAlTtdbE_F", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.g.alchemy.com/v2/PX1vXP3OgwLSsbRrk4NetZF7oqi6vcLE", "0x3E67b8c702a1292d1CEb025494C84367fcb12b45");
NSConfig expectedZNSConfig = new NSConfig(Network.ZIL_TESTNET, "https://dev-api.zilliqa.com", "0x00000000000000000000000000000000000000004");

ResolutionBuilder builder = new ResolutionBuilder(mockConnector);
Expand Down Expand Up @@ -132,8 +132,8 @@ public void checksIfAllConfigsAreSetForOneService() throws Exception {

@Test
public void pullsContractAddressFromConfig() throws Exception {
NSConfig expectedUNSL1Config = new NSConfig(Network.MAINNET, "https://mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.infura.io/v3/e0c0cb9d12c440a29379df066de587e6", "0x3E67b8c702a1292d1CEb025494C84367fcb12b45");
NSConfig expectedUNSL1Config = new NSConfig(Network.MAINNET, "https://eth-mainnet.g.alchemy.com/v2/0f3HESE2kvMWVLZJboiFHtHAlTtdbE_F", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393");
NSConfig expectedUNSL2Config = new NSConfig(Network.MATIC_MAINNET, "https://polygon-mainnet.g.alchemy.com/v2/PX1vXP3OgwLSsbRrk4NetZF7oqi6vcLE", "0x3E67b8c702a1292d1CEb025494C84367fcb12b45");

ResolutionBuilder builder = new ResolutionBuilder(mockConnector);
builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,15 @@ public void testLocationsUNS() throws Exception {
Network.GOERLI,
"ETH",
"0xe586d5bf4d7779498648df67b73c88a712e4359d",
"https://eth-goerli.alchemyapi.io/v2/J-ff_OlmWzw41ocqwpkRccHdfqSZML4q");
TestUtils.TESTING_UNS_PROVIDER_URL);

Location l2 = new Location(
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
Network.MUMBAI_TESTNET,
"MATIC",
"0x499dd6d875787869670900a2130223d85d4f6aa7",
"https://polygon-mumbai.g.alchemy.com/v2/ymbY17ik_HyGfXnPWxBAGhuZE7MwtErX");
TestUtils.TESTING_UNS_L2_PROVIDER_URL);

Map<String, Location> locations = resolution.getLocations("reseller-test-udtesting-459239285.crypto", "udtestdev-my-new-tls.wallet", "not-registered-12345abc.crypto", "udtestdev-test-l2-domain-784391.wallet");
assertEquals(uns, locations.get("reseller-test-udtesting-459239285.crypto"));
Expand All @@ -644,15 +644,15 @@ public void testLocationsZNS() throws Exception {
Network.ZIL_TESTNET,
"ZIL",
"0x003e3cdfeceae96efe007f8196a1b1b1df547eee",
"https://dev-api.zilliqa.com");
TestUtils.TESTING_ZNS_PROVIDER_URL);

Location uns = new Location(
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
Network.MUMBAI_TESTNET,
"MATIC",
"0x499dd6d875787869670900a2130223d85d4f6aa7",
"https://polygon-mumbai.g.alchemy.com/v2/ymbY17ik_HyGfXnPWxBAGhuZE7MwtErX");
TestUtils.TESTING_UNS_L2_PROVIDER_URL);

Map<String, Location> locations = resolution.getLocations(
"uns-devtest-testdomain303030.zil",
Expand All @@ -670,31 +670,31 @@ public void testLocationsMixed() throws Exception {
Network.GOERLI,
"ETH",
"0xe586d5bf4d7779498648df67b73c88a712e4359d",
"https://eth-goerli.alchemyapi.io/v2/J-ff_OlmWzw41ocqwpkRccHdfqSZML4q");
TestUtils.TESTING_UNS_PROVIDER_URL);

Location l2 = new Location(
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
Network.MUMBAI_TESTNET,
"MATIC",
"0x499dd6d875787869670900a2130223d85d4f6aa7",
"https://polygon-mumbai.g.alchemy.com/v2/ymbY17ik_HyGfXnPWxBAGhuZE7MwtErX");
TestUtils.TESTING_UNS_L2_PROVIDER_URL);

Location l2zil = new Location(
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
"0x2a93c52e7b6e7054870758e15a1446e769edfb93",
Network.MUMBAI_TESTNET,
"MATIC",
"0x499dd6d875787869670900a2130223d85d4f6aa7",
"https://polygon-mumbai.g.alchemy.com/v2/ymbY17ik_HyGfXnPWxBAGhuZE7MwtErX");
TestUtils.TESTING_UNS_L2_PROVIDER_URL);

Location zil = new Location(
null,
null,
Network.ZIL_TESTNET,
"ZIL",
"0x003e3cdfeceae96efe007f8196a1b1b1df547eee",
"https://dev-api.zilliqa.com");
TestUtils.TESTING_ZNS_PROVIDER_URL);

Map<String, Location> locations = resolution.getLocations(
"reseller-test-udtesting-459239285.crypto",
Expand Down

0 comments on commit 128cea9

Please sign in to comment.