All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.unstoppabledomains.resolution.contracts.cns.Registry Maven / Gradle / Ivy

package com.unstoppabledomains.resolution.contracts.cns;

import com.unstoppabledomains.exceptions.NSExceptionCode;
import com.unstoppabledomains.exceptions.NSExceptionParams;
import com.unstoppabledomains.exceptions.NamingServiceException;
import com.unstoppabledomains.resolution.contracts.Contract;
import java.math.BigInteger;

public class Registry extends Contract {

  public Registry(String url, String address) {
    super(url, address, "registry", "abi/cns");
  }

  public String getResolver(BigInteger tokenID) throws Exception {
    Object[] args = new Object[1];
    args[0] = tokenID;
    String ans = this.fetchAddress("resolverOf", args);
    if (ans == null) 
      throw new NamingServiceException(NSExceptionCode.UnspecifiedResolver);
    return ans;
  }

  public String getOwner(BigInteger tokenID) throws Exception {
    try {
      Object[] args = new Object[1];
      args[0] = tokenID;
      return this.fetchAddress("ownerOf", args);
    } catch (IllegalArgumentException e) {
      // params will be added on level above;
      throw new NamingServiceException(NSExceptionCode.UnregisteredDomain, new NSExceptionParams("", ""), e);
    } catch (Exception e) {
      return null;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy