register and retrieve contact code using pubkey

This commit is contained in:
Barry Gitarts 2018-08-10 14:29:15 -04:00 committed by Barry G
parent 6d48a33509
commit b392f4e47c
2 changed files with 9 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import Typography from '@material-ui/core/Typography';
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry'; import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
import { Button, Field, TextInput, MobileSearch, Card, Info, Text } from '../../ui/components' import { Button, Field, TextInput, MobileSearch, Card, Info, Text } from '../../ui/components'
import { IconCheck } from '../../ui/icons' import { IconCheck } from '../../ui/icons'
import { keyFromXY } from '../../utils/ecdsa';
import theme from '../../ui/theme' import theme from '../../ui/theme'
import { withFormik } from 'formik'; import { withFormik } from 'formik';
import PublicResolver from 'Embark/contracts/PublicResolver'; import PublicResolver from 'Embark/contracts/PublicResolver';
@ -286,10 +287,11 @@ const NameLookup = withFormik({
mapPropsToValues: props => ({ domainName: '' }), mapPropsToValues: props => ({ domainName: '' }),
async handleSubmit(values, { status, setSubmitting, setStatus }) { async handleSubmit(values, { status, setSubmitting, setStatus }) {
const { domainName } = values; const { domainName } = values;
const { addr, text } = PublicResolver.methods; const { addr, pubkey } = PublicResolver.methods;
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 keys = await pubkey(lookupHash).call();
const statusAccount = keyFromXY(keys[0], keys[1]);
const expirationTime = await getExpirationTime(lookupHash).call(); const expirationTime = await getExpirationTime(lookupHash).call();
setStatus({ address, statusAccount, expirationTime }); setStatus({ address, statusAccount, expirationTime });
} }

View File

@ -10,6 +10,7 @@ import { zeroAddress, zeroBytes32, formatPrice } from './utils';
import { getStatusContactCode } from '../../reducers/accounts'; import { getStatusContactCode } from '../../reducers/accounts';
import FieldGroup from '../standard/FieldGroup'; import FieldGroup from '../standard/FieldGroup';
import LinearProgress from '@material-ui/core/LinearProgress'; import LinearProgress from '@material-ui/core/LinearProgress';
import { generateXY } from '../../utils/ecdsa';
const { soliditySha3, fromWei } = web3.utils; const { soliditySha3, fromWei } = web3.utils;
@ -142,15 +143,14 @@ const RegisterSubDomain = withFormik({
const subdomainHash = soliditySha3(subDomain); const subdomainHash = soliditySha3(subDomain);
const domainNameHash = hash(domainName); const domainNameHash = hash(domainName);
const resolveToAddr = address || zeroAddress; const resolveToAddr = address || zeroAddress;
const resolveToStatusAddr = statusAddress || zeroBytes32; const points = statusAddress ? generateXY(statusAddress) : null;
const toSend = register( const toSend = register(
subdomainHash, subdomainHash,
domainNameHash, domainNameHash,
resolveToAddr, resolveToAddr,
zeroBytes32, points ? points.x : zeroBytes32,
zeroBytes32, points ? points.y : zeroBytes32
resolveToStatusAddr,
); );
toSend.estimateGas().then(gasEstimated => { toSend.estimateGas().then(gasEstimated => {
console.log("Register would work. :D Gas estimated: "+gasEstimated) console.log("Register would work. :D Gas estimated: "+gasEstimated)
@ -167,7 +167,7 @@ const RegisterSubDomain = withFormik({
console.dir(err) console.dir(err)
}).finally(() => { }).finally(() => {
// REQUIRED UNTIL THIS ISSUES IS RESOLVED: https://github.com/jaredpalmer/formik/issues/597 // REQUIRED UNTIL THIS ISSUES IS RESOLVED: https://github.com/jaredpalmer/formik/issues/597
setTimeout(() => { registeredCallbackFn(resolveToAddr, resolveToStatusAddr); }, 200); setTimeout(() => { registeredCallbackFn(resolveToAddr, statusAddress || zeroBytes32); }, 200);
setSubmitting(false); setSubmitting(false);
}); });
}).catch(err => { }).catch(err => {