add expiration time for given domain

This commit is contained in:
Barry Gitarts 2018-06-19 10:12:49 -04:00
parent f4ed8f7c4b
commit 10500ac171
2 changed files with 17 additions and 5 deletions

View File

@ -12,7 +12,7 @@ import { CopyToClipboard } from 'react-copy-to-clipboard';
import RegisterSubDomain from '../ens/registerSubDomain'; import RegisterSubDomain from '../ens/registerSubDomain';
import StatusLogo from '../../ui/icons/components/StatusLogo' import StatusLogo from '../../ui/icons/components/StatusLogo'
import EnsLogo from '../../ui/icons/logos/ens.png'; import EnsLogo from '../../ui/icons/logos/ens.png';
const { getPrice } = ENSSubdomainRegistry.methods; const { getPrice, getExpirationTime } = ENSSubdomainRegistry.methods;
const invalidSuffix = '0000000000000000000000000000000000000000' const invalidSuffix = '0000000000000000000000000000000000000000'
const nullAddress = '0x0000000000000000000000000000000000000000' const nullAddress = '0x0000000000000000000000000000000000000000'
@ -41,18 +41,20 @@ const backButton = {
cursor: 'pointer' cursor: 'pointer'
} }
const generatePrettyDate = (timestamp) => new Date(timestamp * 1000).toDateString();
class RenderAddresses extends PureComponent { class RenderAddresses extends PureComponent {
state = { copied: false } state = { copied: false }
render() { render() {
const { domainName, address, statusAccount } = this.props const { domainName, address, statusAccount, expirationTime } = this.props
const { copied } = this.state const { copied } = this.state
const markCopied = (v) => { this.setState({ copied: v }) } const markCopied = (v) => { this.setState({ copied: v }) }
const isCopied = address => address == copied; const isCopied = address => address == copied;
const renderCopied = address => isCopied(address) && <span style={{ color: theme.positive }}><IconCheck/>Copied!</span>; const renderCopied = address => isCopied(address) && <span style={{ color: theme.positive }}><IconCheck/>Copied!</span>;
return ( return (
<div style={{ display: 'flex', flexDirection: 'column' }}> <div style={{ display: 'flex', flexDirection: 'column' }}>
<Info.Action title="Click to copy"><b>{formatName(domainName).toUpperCase()}</b> Resolves To:</Info.Action> <Info.Action title="Click to copy"><b>{formatName(domainName).toUpperCase()}</b>{expirationTime && <i> (Expires {generatePrettyDate(expirationTime)})</i>} Resolves To:</Info.Action>
{address && <Text style={{ marginTop: '1em' }}>Ethereum Address {renderCopied(address)}</Text>} {address && <Text style={{ marginTop: '1em' }}>Ethereum Address {renderCopied(address)}</Text>}
<CopyToClipboard text={address} onCopy={markCopied}> <CopyToClipboard text={address} onCopy={markCopied}>
<div style={addressStyle}>{address}</div> <div style={addressStyle}>{address}</div>
@ -163,6 +165,7 @@ const InnerForm = ({
domainName={values.domainName} domainName={values.domainName}
address={status.address} address={status.address}
statusAccount={status.statusAccount} statusAccount={status.statusAccount}
expirationTime={status.expirationTime}
setStatus={setStatus} /> : setStatus={setStatus} /> :
<ConnectedRegister <ConnectedRegister
setStatus={setStatus} setStatus={setStatus}
@ -179,7 +182,8 @@ const NameLookup = withFormik({
const lookupHash = hash(formatName(domainName)); const lookupHash = hash(formatName(domainName));
const address = await addr(lookupHash).call(); const address = await addr(lookupHash).call();
const statusAccount = await text(lookupHash, 'statusAccount').call(); const statusAccount = await text(lookupHash, 'statusAccount').call();
setStatus({ address, statusAccount }); const expirationTime = await getExpirationTime(lookupHash).call();
setStatus({ address, statusAccount, expirationTime });
} }
})(InnerForm) })(InnerForm)

View File

@ -336,4 +336,12 @@ contract ENSSubdomainRegistry is Controlled {
creationTime = accounts[_subdomainHash].creationTime; creationTime = accounts[_subdomainHash].creationTime;
} }
function getExpirationTime(bytes32 _subdomainHash)
external
view
returns(uint256 expirationTime)
{
expirationTime = accounts[_subdomainHash].creationTime + releaseDelay;
}
} }