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

ENS Subdomain Feature #509

Merged
merged 63 commits into from May 21, 2018

Conversation

Projects
None yet
5 participants
@scottydelta
Copy link
Contributor

commented Feb 27, 2018

Description

Implements subdomain registration

Checklist
  • subdomain registration/deletion form
  • message signing for registration and deletion
  • subdomain registration and deletion
Refers/Fixes

Fixes #450

@scottydelta scottydelta changed the title Fixes: https://github.com/gitcoinco/web/issues/450 ENS Subdomain Feature Feb 27, 2018

@mbeacom mbeacom changed the title ENS Subdomain Feature WIP: ENS Subdomain Feature Mar 2, 2018

@mbeacom

This comment has been minimized.

Copy link
Contributor

commented Mar 2, 2018

@scottydelta Thanks for jumping on this! Feel free to let me know if you have any questions or need assistance.

@scottydelta scottydelta closed this Mar 3, 2018

@scottydelta scottydelta reopened this Mar 3, 2018

@owocki

This comment has been minimized.

Copy link
Member

commented Mar 6, 2018

how goes it @scottydelta -- let us know if you are blocked on anything!?

@scottydelta

This comment has been minimized.

Copy link
Contributor Author

commented Mar 6, 2018

Just got my ens domain 2 days ago, will start playing with it on a test network and will have something soon.

@owocki

This comment has been minimized.

Copy link
Member

commented Mar 7, 2018

great :)

@scottydelta scottydelta referenced this pull request Mar 8, 2018

Closed

gitcoin ENS subdomains #450

recovered_signer = w3.eth.account.recoverMessage(text="Github Username : {}".format(github_handle), signature=signedMsg).lower()
print(recovered_signer,signer)
if recovered_signer == signer:
ns.setup_address("{}.{}".format(github_handle, settings.ENS_TLD), recovered_signer)

This comment has been minimized.

Copy link
@scottydelta

scottydelta Mar 13, 2018

Author Contributor

@owocki what would happen here while the transaction is being mined? Right now nothing is being stored. We could store the transaction hash for the user and show him a message while the transaction is being mined.

This comment has been minimized.

Copy link
@owocki

owocki Mar 13, 2018

Member

@owocki what would happen here while the transaction is being mined?

i didnt write this code... so im not totally sure.. but what you said makes sense to me

This comment has been minimized.

Copy link
@scottydelta

scottydelta Mar 13, 2018

Author Contributor

Oh sorry, that's my code, I didn't know if we wanted to store that kind of data or if we could get away without storing it, so I was asking for your suggestion 🤣

This comment has been minimized.

Copy link
@owocki

owocki Mar 13, 2018

Member

makes sense to me

'gas': 100000,
'gasPrice': recommend_min_gas_price_to_confirm_in_time(1) * 10**9
}
#w3.middleware_stack.add(construct_sign_and_send_raw_middleware(settings.ENS_PRIVATE_KEY))

This comment has been minimized.

Copy link
@voith

voith May 18, 2018

the middleware should ideally be plugged immediately after creating a web3 instance on line 42 in the same file.

w3 = Web3(HTTPProvider(settings.WEB3_HTTP_PROVIDER))
w3.middleware_stack.add(construct_sign_and_send_raw_middleware(settings.ENS_PRIVATE_KEY))
ns._assert_control = lambda *_: True

plugging it inside this view is redundant.


ns = ENS.fromWeb3(w3)
w3 = Web3(HTTPProvider(settings.WEB3_HTTP_PROVIDER))
ENS_MAINNET_ADDR = '0x314159265dD8dbb310642f98f50C066173C1259b'

This comment has been minimized.

Copy link
@voith

voith May 18, 2018

wondering why you need this. The ens implementation in web3 already has this hardcoded.

This comment has been minimized.

Copy link
@owocki

owocki May 18, 2018

Member

good call.. removing it now




@csrf_exempt

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E303 too many blank lines (3)

txn_hash = None
gasPrice = recommend_min_gas_price_to_confirm_in_time(1) * 10**9 if not settings.DEBUG else 15 * 10**9
transaction = {
# 'to': ENS_MAINNET_ADDR,

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E122 continuation line missing indentation or outdented

use_high_level_code = False
if use_high_level_code:
w3.middleware_stack.add(construct_sign_and_send_raw_middleware(settings.ENS_PRIVATE_KEY))
ns._assert_control = lambda *_: True # monkey patch https://github.com/ethereum/web3.py/issues/852#issuecomment-390054210

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E261 at least two spaces before inline comment
E501 line too long (141 > 120 characters)

signer,
).buildTransaction(transaction)
signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

W291 trailing whitespace

).buildTransaction(transaction)
signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E231 missing whitespace after ','
W291 trailing whitespace

if use_high_level_code:
# from enssubdomain.web3.middleware.signing import construct_sign_and_send_raw_middleware
# w3.middleware_stack.add(construct_sign_and_send_raw_middleware(settings.ENS_PRIVATE_KEY))
ns._assert_control = lambda *_: True # monkey patch https://github.com/ethereum/web3.py/issues/852#issuecomment-390054210

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E261 at least two spaces before inline comment
E501 line too long (141 > 120 characters)

'es': es,
'profile': profile,
'msg': response['output'],
}
return TemplateResponse(request, 'settings/slack.html', context)

def ens_settings(request):

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E302 expected 2 blank lines, found 1

ens_subdomain = ens_subdomains.first() if ens_subdomains.exists() else None
if request.POST:

if test and token and channel:

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F821 undefined name 'test'
F821 undefined name 'token'
F821 undefined name 'channel'

if request.POST:

if test and token and channel:
response = validate_slack_integration(token, channel)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F821 undefined name 'token'
F821 undefined name 'channel'

if test and token and channel:
response = validate_slack_integration(token, channel)

if submit or (response and response.get('success')):

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F821 undefined name 'submit'

response = validate_slack_integration(token, channel)

if submit or (response and response.get('success')):
profile.update_slack_integration(token, channel, repos)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F821 undefined name 'token'
F821 undefined name 'channel'
F821 undefined name 'repos'

profile.update_slack_integration(token, channel, repos)
if not response.get('output'):
response['output'] = _('Updated your preferences.')
ua_type = 'added_slack_integration' if token and channel and repos else 'removed_slack_integration'

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F821 undefined name 'token'
F821 undefined name 'channel'
F821 undefined name 'repos'

if not response.get('output'):
response['output'] = _('Updated your preferences.')
ua_type = 'added_slack_integration' if token and channel and repos else 'removed_slack_integration'
create_user_action(user, ua_type, request, {'channel': channel, 'repos': repos})

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F821 undefined name 'channel'
F821 undefined name 'repos'

owocki added some commits May 18, 2018

'gas': 100000,
'gasPrice': gasPrice
}
# TODO -- refactor to use_high_level_code once construct_sign_and_send_raw_middleware is merged

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

W291 trailing whitespace

if use_high_level_code:
# from enssubdomain.web3.middleware.signing import construct_sign_and_send_raw_middleware
# w3.middleware_stack.add(construct_sign_and_send_raw_middleware(settings.ENS_PRIVATE_KEY))
ns._assert_control = lambda *_: True # monkey patch https://github.com/ethereum/web3.py/issues/852#issuecomment-390054210

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E261 at least two spaces before inline comment
E501 line too long (137 > 120 characters)

signer,
).buildTransaction(transaction)
signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

W291 trailing whitespace

).buildTransaction(transaction)
signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

E231 missing whitespace after ','
W291 trailing whitespace

@owocki

This comment has been minimized.

Copy link
Member

commented May 18, 2018

@scottydelta @mbeacom this is working now! id love to take a pass at code review so we can deploy early next week

owocki added some commits May 18, 2018

from ens.utils import dot_eth_namehash, label_to_hash
from eth_account.messages import defunct_hash_message
from gas.utils import recommend_min_gas_price_to_confirm_in_time
from web3 import HTTPProvider, Web3

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 18, 2018

F401 'web3.HTTPProvider' imported but unused

resolver_addr,
).buildTransaction(transaction)
signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

W291 trailing whitespace

signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E231 missing whitespace after ','
W291 trailing whitespace

dot_eth_namehash(owned),
label_to_hash(label),
Web3.toChecksumAddress(settings.ENS_OWNER_ACCOUNT),
).buildTransaction(transaction)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

W291 trailing whitespace

Web3.toChecksumAddress(settings.ENS_OWNER_ACCOUNT),
).buildTransaction(transaction)
signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

W291 trailing whitespace

signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E231 missing whitespace after ','
W291 trailing whitespace

signed_msg=signedMsg,
)
return JsonResponse(
{'success': _('false'), 'msg': _('Your request has been submitted. Please wait for the transaction to mine!')})

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E501 line too long (123 > 120 characters)

@csrf_exempt
def ens_subdomain(request):
"""Register ENS Subdomain."""
github_handle = request.user.profile.handle if request.user.is_authenticated and hasattr(request.user, 'profile') else None

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E501 line too long (127 > 120 characters)

"""Register ENS Subdomain."""
github_handle = request.user.profile.handle if request.user.is_authenticated and hasattr(request.user, 'profile') else None

#TODO: this should really be a login_required decordator

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E265 block comment should start with '# '

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E231 missing whitespace after ','
W291 trailing whitespace

signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E231 missing whitespace after ','
W291 trailing whitespace

end_nonce=nonce,
)
return JsonResponse(
{'success': _('false'), 'msg': _('Your request has been submitted. Please wait for the transaction to mine!')})

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 19, 2018

E501 line too long (123 > 120 characters)

This comment has been minimized.

Copy link
@scottydelta

scottydelta May 20, 2018

Author Contributor

@owocki The success needs to be True in this case and it need to be handled accordingly in the front-end. I can fix this if it can wait till Tuesday. thanks

This comment has been minimized.

Copy link
@owocki

owocki May 21, 2018

Member

ill update now

@owocki owocki changed the title WIP: ENS Subdomain Feature ENS Subdomain Feature May 19, 2018

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 20, 2018

E231 missing whitespace after ','
W291 trailing whitespace

signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 20, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 20, 2018

E231 missing whitespace after ','
W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 21, 2018

E231 missing whitespace after ','
W291 trailing whitespace

signed_txn = w3.eth.account.signTransaction(txn, private_key=settings.ENS_PRIVATE_KEY)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)

# hack to convert

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 21, 2018

W291 trailing whitespace

# hack to convert
# "b'7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39'"
# to "0x7bce7e4bcd2fea4d26f3d254bb8cf52b9ee8dd7353b19bfbc86803c27d9bbf39"
txn_hash = str(binascii.b2a_hex(txn_hash)).replace("b'","0x").replace("'","")

This comment has been minimized.

Copy link
@stickler-ci

stickler-ci May 21, 2018

E231 missing whitespace after ','
W291 trailing whitespace

@owocki owocki merged commit d251301 into gitcoinco:master May 21, 2018

3 of 5 checks passed

stickler-ci Lint errors found, see pull request comments.
codebeat analysis in progress
Details
codecov/patch 35.26% of diff hit (target 31.67%)
Details
codecov/project 31.71% (+0.03%) compared to 34a3d06
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mbeacom

This comment has been minimized.

Copy link
Contributor

commented on app/marketing/views.py in 37d1487 May 24, 2018

Should any of this be in here? Looks like it's from our slack settings view. test, token, channel, and submit here are all undefined. @owocki

This comment has been minimized.

Copy link
Member Author

replied May 24, 2018

i removed these variables in a commit that was after this one when i was devving.. they are not in master aymore

This comment has been minimized.

Copy link
Contributor

replied May 24, 2018

This comment has been minimized.

Copy link
Member Author

replied May 24, 2018

ah shoot you are right.. i must have been looking at the wrong views.py.

fixed in 49f4089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.