on master help sign in
Add isZeroAddress helper function
46dbb79Fang
src/lib/wallet.js+3
@@ -71,6 +71,8 @@ const keccak256 = str =>
71
71
72const isValidAddress = a => '0x0' === a || isAddress(a);
72const isValidAddress = a => '0x0' === a || isAddress(a);
73
73
74+const isZeroAddress = a => ETH_ZERO_ADDR === a;
75+
74const toChecksumAddress = address => {
76const toChecksumAddress = address => {
75 const addr = stripHexPrefix(address).toLowerCase();
77 const addr = stripHexPrefix(address).toLowerCase();
76 const hash = keccak256(addr).toString('hex');
78 const hash = keccak256(addr).toString('hex');
@@ -140,6 +142,7 @@ export {
140 CURVE_ZERO_ADDR,
142 CURVE_ZERO_ADDR,
141 renderWalletType,
143 renderWalletType,
142 isValidAddress,
144 isValidAddress,
145+ isZeroAddress,
143 toChecksumAddress,
146 toChecksumAddress,
144 addressFromSecp256k1Public,
147 addressFromSecp256k1Public,
145 eqAddr,
148 eqAddr,
src/views/CreateGalaxy.js+2−2
@@ -18,7 +18,7 @@ import StatelessTransaction from '../components/old/StatelessTransaction';
18import { NETWORK_TYPES } from '../lib/network';
18import { NETWORK_TYPES } from '../lib/network';
19import { canDecodePatp } from '../lib/txn';
19import { canDecodePatp } from '../lib/txn';
20
20
21−import { ETH_ZERO_ADDR, isValidAddress, eqAddr } from '../lib/wallet';
21+import { isValidAddress, isZeroAddress } from '../lib/wallet';
22
22
23import { isValidGalaxy, compose } from '../lib/lib';
23import { isValidGalaxy, compose } from '../lib/lib';
24import { withNetwork } from '../store/network';
24import { withNetwork } from '../store/network';
@@ -103,7 +103,7 @@ class CreateGalaxy extends React.Component {
103 galaxyDec
103 galaxyDec
104 );
104 );
105
105
106− const available = eqAddr(currentOwner, ETH_ZERO_ADDR);
106+ const available = isZeroAddress(currentOwner);
107
107
108 this.setState({ isAvailable: available });
108 this.setState({ isAvailable: available });
109 };
109 };
src/views/Point/Actions.js+2−2
@@ -2,7 +2,7 @@ import React from 'react';
2import { azimuth } from 'azimuth-js';
2import { azimuth } from 'azimuth-js';
3import * as need from '../../lib/need';
3import * as need from '../../lib/need';
4
4
5−import { ETH_ZERO_ADDR, CURVE_ZERO_ADDR, eqAddr } from '../../lib/wallet';
5+import { CURVE_ZERO_ADDR, isZeroAddress, eqAddr } from '../../lib/wallet';
6import { H2, P } from '../../components/old/Base';
6import { H2, P } from '../../components/old/Base';
7import { Button } from '../../components/old/Base';
7import { Button } from '../../components/old/Base';
8import { ROUTE_NAMES } from '../../lib/routeNames';
8import { ROUTE_NAMES } from '../../lib/routeNames';
@@ -89,7 +89,7 @@ function Actions() {
89 Nothing: () => false,
89 Nothing: () => false,
90 Just: deets =>
90 Just: deets =>
91 eqAddr(deets.value.owner, addr) &&
91 eqAddr(deets.value.owner, addr) &&
92− !eqAddr(deets.value.transferProxy, ETH_ZERO_ADDR),
92+ !isZeroAddress(deets.value.transferProxy),
93 });
93 });
94
94
95 const displayReminder = pointDetails.matchWith({
95 const displayReminder = pointDetails.matchWith({
src/views/Point/KeysAndMetadata.js+3−6
@@ -1,14 +1,11 @@
1import React from 'react';
1import React from 'react';
2import { H2, H4 } from '../../components/old/Base';
2import { H2, H4 } from '../../components/old/Base';
3
3
4−import { ETH_ZERO_ADDR, eqAddr } from '../../lib/wallet';
4+import { CURVE_ZERO_ADDR, isZeroAddress } from '../../lib/wallet';
5import { Grid } from 'indigo-react';
5import { Grid } from 'indigo-react';
6
6
7−const NULL_KEY =
8− '0x0000000000000000000000000000000000000000000000000000000000000000';
9−
10const renderAddress = addr =>
7const renderAddress = addr =>
11− eqAddr(addr, ETH_ZERO_ADDR) ? (
8+ isZeroAddress(addr) ? (
12 <div>{'(not set)'}</div>
9 <div>{'(not set)'}</div>
13 ) : (
10 ) : (
14 <div>
11 <div>
@@ -27,7 +24,7 @@ const renderAddress = addr =>
27const renderNetworkKey = hex => {
24const renderNetworkKey = hex => {
28 const sl = i => hex.slice(i, i + 4);
25 const sl = i => hex.slice(i, i + 4);
29 const rowFrom = i => `${sl(i)}.${sl(i + 4)}.${sl(i + 8)}.${sl(i + 12)}`;
26 const rowFrom = i => `${sl(i)}.${sl(i + 4)}.${sl(i + 8)}.${sl(i + 12)}`;
30− return hex === NULL_KEY ? (
27+ return hex === CURVE_ZERO_ADDR ? (
31 <div>{'(not set)'}</div>
28 <div>{'(not set)'}</div>
32 ) : (
29 ) : (
33 <div>
30 <div>
src/views/Points.js+2−2
@@ -3,7 +3,7 @@ import Maybe from 'folktale/maybe';
3import { H1, H2, P, Grid } from 'indigo-react';
3import { H1, H2, P, Grid } from 'indigo-react';
4
4
5import { ROUTE_NAMES } from 'lib/routeNames';
5import { ROUTE_NAMES } from 'lib/routeNames';
6−import { ETH_ZERO_ADDR, eqAddr } from 'lib/wallet';
6+import { isZeroAddress } from 'lib/wallet';
7import useIsEclipticOwner from 'lib/useIsEclipticOwner';
7import useIsEclipticOwner from 'lib/useIsEclipticOwner';
8import { useSyncKnownPoints } from 'lib/useSyncPoints';
8import { useSyncKnownPoints } from 'lib/useSyncPoints';
9
9
@@ -20,7 +20,7 @@ const matchArray = obj =>
20 obj.matchWith({ Nothing: () => [], Just: p => p.value });
20 obj.matchWith({ Nothing: () => [], Just: p => p.value });
21
21
22const hasTransferProxy = (details, point) =>
22const hasTransferProxy = (details, point) =>
23− !eqAddr(details.transferProxy, ETH_ZERO_ADDR);
23+ !isZeroAddress(details.transferProxy);
24
24
25export default function Points() {
25export default function Points() {
26 const { wallet } = useWallet();
26 const { wallet } = useWallet();