Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Add ownership checks the Registry dApp #4001

Merged
merged 10 commits into from
Jan 4, 2017
Merged

Add ownership checks the Registry dApp #4001

merged 10 commits into from
Jan 4, 2017

Conversation

ngotchac
Copy link
Contributor

This PR closes #3037

Add proper methods to get the owner of a name in the Registry.

Use it in name lookups, reserving, resolving, etc...
Add a new lookup query: get the owner of a name.

@ngotchac ngotchac added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Dec 30, 2016
@@ -44,8 +44,8 @@ export default class Application extends Component {

static propTypes = {
accounts: PropTypes.object.isRequired,
contract: nullableProptype(PropTypes.object).isRequired,
fee: nullableProptype(PropTypes.object).isRequired
contract: nullableProptype(PropTypes.object.isRequired),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we swapping the isRequired here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below.

@@ -94,6 +69,7 @@ class Lookup extends Component {
<MenuItem value='IMG' primaryText='IMG – hash of a picture in the blockchain' />
<MenuItem value='CONTENT' primaryText='CONTENT – hash of a data in the blockchain' />
<MenuItem value='reverse' primaryText='reverse – find a name for an address' />
<MenuItem value='owner' primaryText='owner – find a the owner' />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just double-check with @gavofyork on this - there was obviously reasons why we didn't want transfers (squatting), just want to make doubly-sure on the ability to actually display the owner of anything to anybody. (Do we want it sem-opaque o fully transparent)

const values = [
sha3(name)
];
return getOwner(contract, name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this part. i.e. warn up-front if an action is possible or not.

@@ -78,35 +79,21 @@ const renderQueue = (queue) => {
class Names extends Component {

static propTypes = {
error: nullableProptype(PropTypes.object.isRequired),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per comment above, believe that nullableProptype(type).isRequired is probably more in line with intent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to write it that IMO, however it doesn't work. It's done like this everywhere else in the app.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing:

dapps/registry/Application/application.js:47
dapps/registry/Application/application.js:48
views/Wallet/wallet.js:74


const allAccounts = Object.assign({}, accounts.all, contacts);

// Add lower case addresses to map
Copy link
Contributor

@jacogr jacogr Dec 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this lowerCase and not checksum-case? (bear in mind this has an impact anywhere where the address is used in icons, checksumIcon !== lowercaseIcon)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just because sometimes the returned data from a contract method isn't formatted as an address. This does not change the displayed address, it only adds to the Address Map the key for the lower case addresses.


return api
.eth
.getStorageAt(address, position)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would rather do lowerCase here, instead of global to app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per above

}

onKeyDown = (event) => {
if (event.which !== 13) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to use import keycode from 'keycode', which you used in the address selector.

}
};
}

const mapStateToProps = (state) => ({ ...state.names, fee: state.fee });
const mapDispatchToProps = (dispatch) => bindActionCreators({ reserve, drop }, dispatch);
const mapDispatchToProps = (dispatch) => bindActionCreators({ clearError, reserve, drop }, dispatch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would actually prefer multiple lines now. :)

import postTx from '../util/post-tx';

export const clearError = () => ({
Copy link
Contributor

@derhuerst derhuerst Jan 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If clearError is getting handled app-wide (in dapps/registry/reducers), why not declare it in dapps/registry/actions to DRY the code?

Object
.keys(allAccounts)
.forEach((address) => {
allAccounts[address.toLowerCase()] = allAccounts[address];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[tiniest grumble] This could be Object.values(…).reduce.

@derhuerst
Copy link
Contributor

Looks mostly good to me!

@jacogr jacogr added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 4, 2017
@jacogr jacogr merged commit 6301726 into master Jan 4, 2017
@jacogr jacogr deleted the ng-registry-owner branch January 4, 2017 14:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

registry dapp: should check if name is owned when changed records
3 participants