import EmbarkJS from 'Embark/EmbarkJS'; import React from 'react'; import {Alert, Form, FormGroup, FormControl, Button} from 'react-bootstrap'; window.EmbarkJS = EmbarkJS; class ENS extends React.Component { constructor(props) { super(props); this.state = { valueResolve: 'ethereumfoundation.eth', responseResolve: null, isResolveError: false, valueLookup: '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359', responseLookup: null, isLookupError: false, embarkLogs: [] }; } handleChange(stateName, e) { this.setState({[stateName]: e.target.value}); } resolveName(e) { e.preventDefault(); const embarkLogs = this.state.embarkLogs; embarkLogs.push(`EmbarkJS.Names.resolve('${this.state.valueResolve}', console.log)`); this.setState({ embarkLogs: embarkLogs }); EmbarkJS.Names.resolve(this.state.valueResolve, (err, result) => { if (err) { return this.setState({ responseResolve: err, isResolveError: true }); } this.setState({ responseResolve: result, isResolveError: false }); }); } lookupAddress(e) { e.preventDefault(); const embarkLogs = this.state.embarkLogs; embarkLogs.push(`EmbarkJS.Names.resolve('${this.state.valueLookup}', console.log)`); this.setState({ embarkLogs: embarkLogs }); EmbarkJS.Names.lookup(this.state.valueLookup, (err, result) => { if (err) { return this.setState({ responseLookup: err, isLookupError: true }); } this.setState({ responseLookup: result, isLookupError: false }); }); } render() { return ( { !this.props.enabled ? ENS provider might not be set : '' }

Resolve a name

{this.state.responseResolve && Resolved address: {this.state.responseResolve} } this.handleChange('valueResolve', e)}/>

Lookup an address

{this.state.responseLookup && Looked up domain: {this.state.responseLookup} } this.handleChange('valueLookup', e)}/>

Embark Calls

Javascript calls being made:

{ this.state.embarkLogs.map((item, i) =>

{item}

) }
); } } export default ENS;