AlphaWallet / alpha-wallet-android

An advanced Ethereum mobile wallet
https://www.alphawallet.com
MIT License
585 stars 529 forks source link

Integrate Unstoppable Domains #2929

Closed hboon closed 1 year ago

hboon commented 1 year ago

@oa-s would you help write up details including how to test it, test data? For some reason, we never integrated it.

oa-s commented 1 year ago

Integration Unstoppable Domain requires to implement the next api call:

Api calls require Authorization header, its static, ping me, or Boon for sharing.

hboon commented 1 year ago

@oa-s do you have sample/test data to test against?

oa-s commented 1 year ago

@hboon do you mean example of json and curl of request?

oa-s commented 1 year ago

here is wallet address for testing: 0xac1dE5BbdC2C8D0B3E4324c87599Dc66D3221c13 and curl request example: ` curl request forresolveDomain(address` curl -XGET -H 'Authorization: Bearer <API_KEY>' 'https://resolve.unstoppabledomains.com/domains/?owners=0xac1dE5BbdC2C8D0B3E4324c87599Dc66D3221c13&perPage=50&sortBy=id&sortDirection=DESC'

with its reponse: "{\"data\":[{\"id\":\"vladylav.wallet\",\"attributes\":{\"records\":{\"crypto.ETH.address\":\"0xac1de5bbdc2c8d0b3e4324c87599dc66d3221c13\",\"crypto.MATIC.version.ERC20.address\":\"0xac1de5bbdc2c8d0b3e4324c87599dc66d3221c13\",\"crypto.MATIC.version.MATIC.address\":\"0xac1de5bbdc2c8d0b3e4324c87599dc66d3221c13\"},\"meta\":{\"domain\":\"vladylav.wallet\",\"blockchain\":\"MATIC\",\"networkId\":137,\"owner\":\"0xac1de5bbdc2c8d0b3e4324c87599dc66d3221c13\",\"resolver\":\"0xa9a6a3626993d487d2dbda3173cf58ca1a9d9e9f\",\"registry\":\"0xa9a6a3626993d487d2dbda3173cf58ca1a9d9e9f\",\"reverse\":false}}}],\"meta\":{\"perPage\":50,\"nextStartingAfter\":\"994754\",\"sortBy\":\"id\",\"sortDirection\":\"DESC\",\"hasMore\":false}}"

hboon commented 1 year ago

Yeah. Or how to test in app. But curl is good too

hboon commented 1 year ago

Thanks

Imdavyking commented 1 year ago

Future unstoppableDomainENS({ String cryptoDomainName, String currency, }) async { try { cryptoDomainName = cryptoDomainName.toLowerCase(); final udResolvers = { "0x049aba7510f45BA5b64ea9E658E342F904DB358D": "Ethereum", "0x1BDc0fD4fbABeed3E611fd6195fCd5d41dcEF393": "Ethereum", "0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f": "Polygon Matic", }; for (String contractAddr in udResolvers.keys) { final web3.EthereumAddress proxyReader = web3.EthereumAddress.fromHex(contractAddr);

  web3.DeployedContract contract = web3.DeployedContract(
    web3.ContractAbi.fromJson(unstoppableDomainAbi, ''),
    proxyReader,
  );
  final rpcUrl = getEVMBlockchains()[udResolvers[contractAddr]]['rpc'];

  final client = web3.Web3Client(rpcUrl, Client());
  String udCryptoAddress = (await client.call(
    contract: contract,
    function: contract.function('get'),
    params: [
      "crypto.${currency ?? 'ETH'}.address",
      BigInt.parse(nameHash(cryptoDomainName))
    ],
  ))
      .first;

  if (udCryptoAddress.isNotEmpty) {
    return {'success': true, 'msg': udCryptoAddress};
  }
}
return {'success': false, 'msg': 'Error resolving unstoppable domain ens'};

} catch (e) { return {'success': false, 'msg': 'Error resolving unstoppable domain ens'}; } }