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

Added the Kleros Curate Service to obtain address tags #2608

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jaybuidl
Copy link

@jaybuidl jaybuidl commented May 14, 2022

Resolves #2607 for Android only.

Overview

The implementation provides a new KlerosCurateService with a request function returning an AddressInformation entity.

The current service provides tags for addresses on Ethereum mainnet only (chainid 1). It should not be queried for non-Ethereum mainnet addresses at this stage.

Under the hood, the dataset of Ethereum mainnet tags is spread out across 2 registries deployed on Ethereum mainnet and Gnosis chain. If the address is not found the first registry, then it is looked up in the second one.

Looking up an address in a registry consists in making a call to the subgraph API, parsing the IPFS content identifier and retrieving the corresponding JSON file from IPFS.

If the address is not present in the registry, the service returns a static NULL_ADDRESS_INFORMATION object (null object pattern).

Testing

The service can be tested as follow:

@Test
public void klerosCurateService() {
    // Not a mock: this is testing against a live service.
    OkHttpClient httpClient = new OkHttpClient.Builder()
            .connectTimeout(7, TimeUnit.SECONDS)
            .readTimeout(7, TimeUnit.SECONDS)
            .writeTimeout(7, TimeUnit.SECONDS)
            .retryOnConnectionFailure(false)
            .build();

    KlerosCurateService curate = new KlerosCurateService(httpClient);

    try {
        AddressInformation info = curate.request("0xdAC17F958D2ee523a2206206994597C13D831ec7");
        assertEquals("Tether: USDT Stablecoin", info.publicNameTag);
        assertEquals("0xdAC17F958D2ee523a2206206994597C13D831ec7", info.contractAddress);
        assertEquals("https://tether.to/", info.uiWebsiteLink);
        assertEquals("The contract of Tether (USDT) stablecoin.", info.publicNote);

        info = curate.request("0xe592427a0aece92de3edee1f18e0157c05861564");
        assertEquals("Uniswap V3: Router 1", info.publicNameTag);
        assertEquals("0xe592427a0aece92de3edee1f18e0157c05861564", info.contractAddress);
        assertEquals("https://app.uniswap.org/#/swap", info.uiWebsiteLink);
        assertEquals("Version 1 of the Uniswap V3 Router.", info.publicNote);

        info = curate.request("0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72");
        assertEquals(KlerosCurateService.NULL_ADDRESS_INFORMATION, info);
    } catch (IOException e) {
        fail();
    }
}

@gmkung @alcercu @AndreiMVP

@JamesSmartCell
Copy link
Member

@jaybuidl this is awesome; it's complementary to our TokenScript approach in some respects. I can certainly wire it into mainnet requests.

@gmkung
Copy link

gmkung commented Jul 9, 2022

@hboon @JamesSmartCell , wondering how you guys are progressing with the UI parts of this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New feature: address tags from Kleros Curate
3 participants