AmbireTech / adex-platform

AdEx Platform UI
https://platform.adex.network
GNU General Public License v3.0
58 stars 19 forks source link

Ability to set an ENS username #197

Closed Ivshti closed 4 years ago

Ivshti commented 5 years ago

Is your feature request related to a problem? Please describe. Working with crypto addresses is bad UX; It'd be much better if you can see ENS usernames We have adex.eth, so allowing accounts to set usernames, e.g. "stremio.adex.eth" would be nice

Describe the solution you'd like The Account tab should have an option to set a username.

This should be a text field that:

And once you confirm it, the app should ask you whether you want to pay the username fee (tx fee to set the username)

WARNING: We should warn users that this is public information posted on the blockchain

Additional context This feature isn't trivial, especially with counterfactual accounts. It requires work in the relayer too, because the transaction to set the username has to be sent normally if the account is created, and it has to be sent through deployAndExecute if the account hasn't been created yet. - this will be covered by the counterfactual implementation in the relayer /execute anyway

to do this, you must perform 4 transactions which are basically the steps here: https://github.com/UniversalLogin/UniversalLoginSDK/blob/master/universal-login-contracts/contracts/utils/ENSUtils.sol

  1. call the registrar to register the label; the registrar addr for adex.eth is: https://etherscan.io/address/0xa3f69f48d4a45419d48b56b1cfbf4af2d4586728#code ; use registerAndSetup with the default publicresolver (0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8): this will register the subdomain as well as call ENS to set a resolver and call the resolver to set the address it resolves to; example: registerAndSetup(0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8, keccak256('username'), identityAddr)
  2. set the reverse lookup: ReverseRegistrar reverseRegistrar = ReverseRegistrar(ens.owner(0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2)); reverseRegistrar.setName(name); (the hash is a namehash("addr.reverse"))

All of those can be done as a single /execute with 2 transactions

rori4 commented 4 years ago

Why isn't this below added to the AdExENSManager contract itself as it is done in the ENSUtils contract? ReverseRegistrar reverseRegistrar = ReverseRegistrar(ens.owner(0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2)); reverseRegistrar.setName(name);

Ivshti commented 4 years ago

good catch!

first of all, ens terminology: label is the first part of the subdomain (e.g. label "xxx" in xxx.tentacion.ens)

The reason is, calling the reverseRegistrar is done with the label as a string (plain text), while calling everything else takes a keccak256 hash of the label

You cannot know the label just by looking at the hash

But if you reveal the label on-chain, someone who likes the label may just frontrun you. When they see the on-chain tx, they will frontrun it, and buy the label instead. So someone who simply wants a certain number of labels may just sit and watch when someone tries to buy them, and then get them before you.

in summary, we either skip the reverse registrar, or set them in separate secondary transactions

rori4 commented 4 years ago

So for the second step I must deploy this ReverseRegistrar with ens.owner(namehash("adex.eth")) in the constructor from this sol file -> https://github.com/ensdomains/ens/blob/master/contracts/ReverseRegistrar.sol and then call the setName with the plain text of the label Those are two more transactions or am I missing something here?

Also what is the ENS address set in the https://etherscan.io/address/0xa3f69f48d4a45419d48b56b1cfbf4af2d4586728#code I can't seem to find it and I will need it in order to call ens.owner(namehash("adex.eth"))

Ivshti commented 4 years ago

Don't implement this for now, wait until we discuss it in person.

But:

Otherwise the ENS address is the same as the one the AdExENSRegistrar is deployed with (apparently it's not public but it's 0x314159265dd8dbb310642f98f50c066173c1259b

re namehash, you need to import a npm module

but i'm pretty sure the owner will be the Identity contract, so you might not need this call entirely