mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-01-21 00:00:47 +00:00
add enable token permissions to mobile registration screen
This commit is contained in:
parent
b267cdeb63
commit
7f1540d387
@ -11,6 +11,7 @@ import { zeroAddress, zeroBytes32, formatPrice } from './utils';
|
||||
import { getStatusContactCode, getSNTAllowance } from '../../reducers/accounts';
|
||||
import FieldGroup from '../standard/FieldGroup';
|
||||
import LinearProgress from '@material-ui/core/LinearProgress';
|
||||
import TokenPermissions from '../standard/TokenPermissionConnect';
|
||||
import { generateXY } from '../../utils/ecdsa';
|
||||
|
||||
const { soliditySha3, fromWei } = web3.utils;
|
||||
@ -18,7 +19,6 @@ const { soliditySha3, fromWei } = web3.utils;
|
||||
const InnerForm = ({
|
||||
values,
|
||||
errors,
|
||||
touched,
|
||||
handleChange,
|
||||
handleBlur,
|
||||
handleSubmit,
|
||||
@ -27,102 +27,108 @@ const InnerForm = ({
|
||||
subDomain,
|
||||
domainName,
|
||||
domainPrice,
|
||||
statusContactCode,
|
||||
SNTAllowance,
|
||||
}) => (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div style={{ margin: '10px' }}>
|
||||
{!subDomain &&
|
||||
<FieldGroup
|
||||
id="subDomain"
|
||||
name="subDomain"
|
||||
type="text"
|
||||
label="Sub Domain"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.subDomain}
|
||||
error={errors.subDomain}
|
||||
/>}
|
||||
{!domainName &&
|
||||
<FieldGroup
|
||||
id="domainName"
|
||||
name="domainName"
|
||||
type="text"
|
||||
label="Domain Name"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.domainName}
|
||||
button={
|
||||
<Button
|
||||
mode="strong"
|
||||
style={{ marginTop: '5px' }}
|
||||
{!subDomain &&
|
||||
<FieldGroup
|
||||
id="subDomain"
|
||||
name="subDomain"
|
||||
type="text"
|
||||
label="Sub Domain"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.subDomain}
|
||||
error={errors.subDomain}
|
||||
/>}
|
||||
{!domainName &&
|
||||
<FieldGroup
|
||||
id="domainName"
|
||||
name="domainName"
|
||||
type="text"
|
||||
label="Domain Name"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.domainName}
|
||||
button={
|
||||
<Button
|
||||
mode="strong"
|
||||
style={{ marginTop: '5px' }}
|
||||
onClick={() => {
|
||||
ENSSubdomainRegistry.methods.getPrice(hash(values.domainName))
|
||||
.call()
|
||||
.then((res) => { setFieldValue('price', fromWei(res)); });
|
||||
}}
|
||||
>
|
||||
Get Price
|
||||
</Button>
|
||||
}
|
||||
/>}
|
||||
{!domainPrice &&
|
||||
<FieldGroup
|
||||
id="price"
|
||||
name="price"
|
||||
label="Domain Price"
|
||||
disabled
|
||||
value={values.price ? `${formatPrice(values.price)} SNT` : ''} />}
|
||||
<Hidden mdDown>
|
||||
<FieldGroup
|
||||
id="statusAddress"
|
||||
name="statusAddress"
|
||||
type="text"
|
||||
label="Status messenger address domain resolves to"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.statusAddress}
|
||||
error={errors.statusAddress}
|
||||
wide="true"
|
||||
/>
|
||||
<FieldGroup
|
||||
id="address"
|
||||
name="address"
|
||||
type="text"
|
||||
label="Ethereum address domain resolves to"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.address}
|
||||
error={errors.address}
|
||||
button={<Button mode="strong" style={{ padding: '5px 15px 5px 15px', marginTop: '5px' }} onClick={() => setFieldValue('address', web3.eth.defaultAccount)}>Use My Primary Address</Button>}
|
||||
/>
|
||||
{!isSubmitting ? <Button wide mode="strong" type="submit" disabled={isSubmitting || !!Object.keys(errors).length}>{!isSubmitting ? 'Submit' : 'Submitting to the Blockchain - (this may take awhile)'}</Button> : <LinearProgress />}
|
||||
</Hidden>
|
||||
<Hidden mdUp>
|
||||
<Field label="Your Contact Code">
|
||||
<MobileSearch
|
||||
>
|
||||
Get Price
|
||||
</Button>
|
||||
}
|
||||
/>}
|
||||
{!domainPrice &&
|
||||
<FieldGroup
|
||||
id="price"
|
||||
name="price"
|
||||
label="Domain Price"
|
||||
disabled
|
||||
value={values.price ? `${formatPrice(values.price)} SNT` : ''} />}
|
||||
<Hidden mdDown>
|
||||
<FieldGroup
|
||||
id="statusAddress"
|
||||
name="statusAddress"
|
||||
style={{ marginTop: '10px' }}
|
||||
placeholder="Status Messenger Address"
|
||||
type="text"
|
||||
label="Status messenger address domain resolves to"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.statusAddress}
|
||||
onChange={handleChange}
|
||||
onClick={() => setFieldValue('statusAddress', '')}
|
||||
wide />
|
||||
</Field>
|
||||
<Field label="Your Wallet Address">
|
||||
<MobileSearch
|
||||
error={errors.statusAddress}
|
||||
wide="true"
|
||||
/>
|
||||
<FieldGroup
|
||||
id="address"
|
||||
name="address"
|
||||
style={{ marginTop: '10px' }}
|
||||
placeholder="Ethereum Address"
|
||||
value={values.address}
|
||||
type="text"
|
||||
label="Ethereum address domain resolves to"
|
||||
onChange={handleChange}
|
||||
onClick={() => setFieldValue('address', '')}
|
||||
required
|
||||
wide />
|
||||
</Field>
|
||||
<div style={{ position: 'relative', left: 0, right: 0, bottom: 0 }}>
|
||||
<MobileButton type="submit" text="Register with transaction" style={{ width: '100%' }}/>
|
||||
</div>
|
||||
</Hidden>
|
||||
onBlur={handleBlur}
|
||||
value={values.address}
|
||||
error={errors.address}
|
||||
button={<Button mode="strong" style={{ padding: '5px 15px 5px 15px', marginTop: '5px' }} onClick={() => setFieldValue('address', web3.eth.defaultAccount)}>Use My Primary Address</Button>}
|
||||
/>
|
||||
{!isSubmitting ? <Button wide mode="strong" type="submit" disabled={isSubmitting || !!Object.keys(errors).length}>{!isSubmitting ? 'Submit' : 'Submitting to the Blockchain - (this may take awhile)'}</Button> : <LinearProgress />}
|
||||
</Hidden>
|
||||
<Hidden mdUp>
|
||||
<Field label="Your Contact Code">
|
||||
<MobileSearch
|
||||
name="statusAddress"
|
||||
style={{ marginTop: '10px' }}
|
||||
placeholder="Status Messenger Address"
|
||||
value={values.statusAddress}
|
||||
onChange={handleChange}
|
||||
onClick={() => setFieldValue('statusAddress', '')}
|
||||
wide />
|
||||
</Field>
|
||||
<Field label="Your Wallet Address">
|
||||
<MobileSearch
|
||||
name="address"
|
||||
style={{ marginTop: '10px' }}
|
||||
placeholder="Ethereum Address"
|
||||
value={values.address}
|
||||
onChange={handleChange}
|
||||
onClick={() => setFieldValue('address', '')}
|
||||
required
|
||||
wide />
|
||||
</Field>
|
||||
<div style={{ position: 'relative', left: 0, right: 0, bottom: 0 }}>
|
||||
{!Number(SNTAllowance) ? <TokenPermissions
|
||||
symbol="SNT"
|
||||
spender={ENSSubdomainRegistry.address}
|
||||
methods={TestToken.methods}
|
||||
mobile
|
||||
/>
|
||||
: <MobileButton type="submit" text="Register with transaction" style={{ width: '100%' }}/>}
|
||||
</div>
|
||||
</Hidden>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user