register and retrieve contact code using pubkey
This commit is contained in:
parent
6d48a33509
commit
b392f4e47c
|
@ -7,6 +7,7 @@ import Typography from '@material-ui/core/Typography';
|
|||
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
|
||||
import { Button, Field, TextInput, MobileSearch, Card, Info, Text } from '../../ui/components'
|
||||
import { IconCheck } from '../../ui/icons'
|
||||
import { keyFromXY } from '../../utils/ecdsa';
|
||||
import theme from '../../ui/theme'
|
||||
import { withFormik } from 'formik';
|
||||
import PublicResolver from 'Embark/contracts/PublicResolver';
|
||||
|
@ -286,10 +287,11 @@ const NameLookup = withFormik({
|
|||
mapPropsToValues: props => ({ domainName: '' }),
|
||||
async handleSubmit(values, { status, setSubmitting, setStatus }) {
|
||||
const { domainName } = values;
|
||||
const { addr, text } = PublicResolver.methods;
|
||||
const { addr, pubkey } = PublicResolver.methods;
|
||||
const lookupHash = hash(formatName(domainName));
|
||||
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();
|
||||
setStatus({ address, statusAccount, expirationTime });
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { zeroAddress, zeroBytes32, formatPrice } from './utils';
|
|||
import { getStatusContactCode } from '../../reducers/accounts';
|
||||
import FieldGroup from '../standard/FieldGroup';
|
||||
import LinearProgress from '@material-ui/core/LinearProgress';
|
||||
import { generateXY } from '../../utils/ecdsa';
|
||||
|
||||
const { soliditySha3, fromWei } = web3.utils;
|
||||
|
||||
|
@ -142,15 +143,14 @@ const RegisterSubDomain = withFormik({
|
|||
const subdomainHash = soliditySha3(subDomain);
|
||||
const domainNameHash = hash(domainName);
|
||||
const resolveToAddr = address || zeroAddress;
|
||||
const resolveToStatusAddr = statusAddress || zeroBytes32;
|
||||
const points = statusAddress ? generateXY(statusAddress) : null;
|
||||
|
||||
const toSend = register(
|
||||
subdomainHash,
|
||||
domainNameHash,
|
||||
resolveToAddr,
|
||||
zeroBytes32,
|
||||
zeroBytes32,
|
||||
resolveToStatusAddr,
|
||||
points ? points.x : zeroBytes32,
|
||||
points ? points.y : zeroBytes32
|
||||
);
|
||||
toSend.estimateGas().then(gasEstimated => {
|
||||
console.log("Register would work. :D Gas estimated: "+gasEstimated)
|
||||
|
@ -167,7 +167,7 @@ const RegisterSubDomain = withFormik({
|
|||
console.dir(err)
|
||||
}).finally(() => {
|
||||
// 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);
|
||||
});
|
||||
}).catch(err => {
|
||||
|
|
Loading…
Reference in New Issue