on master help sign in
fix: style disabled checkbox input and cleanup admin networking logic
ee32cc5Matt Condon (shrugs)
src/indigo-react/components/CheckboxInput.js+8−4
@@ -33,9 +33,12 @@ export default function CheckboxInput({
33}) {
33}) {
34 return (
34 return (
35 <Flex
35 <Flex
36− className={cn(className, 'mv2')}
37 row
36 row
38 align="center"
37 align="center"
38+ className={cn(className, 'mv2', {
39+ black: !disabled,
40+ gray4: disabled,
41+ })}
39 style={{
42 style={{
40 ...(disabled && {
43 ...(disabled && {
41 pointerEvents: 'none',
44 pointerEvents: 'none',
@@ -60,9 +63,10 @@ export default function CheckboxInput({
60 <Flex
63 <Flex
61 justify="center"
64 justify="center"
62 align="center"
65 align="center"
63− className={cn('b-black b1 p1 mr3', {
66+ className={cn('b1 p1 mr3', {
67+ 'bg-gray1': disabled,
64− 'bg-black white': data,
68+ 'bg-black white b-black': !disabled && data,
65− 'bg-white black': !data,
69+ 'bg-white black b-black': !disabled && !data,
66 })}
70 })}
67 style={{
71 style={{
68 height: '14px',
72 height: '14px',
src/views/Admin/AdminNetworkingKeys.js+32−25
@@ -66,6 +66,7 @@ function useSetKeys() {
66 construct: _construct,
66 construct: _construct,
67 broadcasting,
67 broadcasting,
68 confirmed,
68 confirmed,
69+ inputsLocked,
69 bind,
70 bind,
70 } = useEthereumTransaction(GAS_LIMITS.CONFIGURE_KEYS);
71 } = useEthereumTransaction(GAS_LIMITS.CONFIGURE_KEYS);
71
72
@@ -76,13 +77,15 @@ function useSetKeys() {
76 }
77 }
77 }, [_point, confirmed, syncOwnedPoint]);
78 }, [_point, confirmed, syncOwnedPoint]);
78
79
79− const construct = useCallback(
80+ const getSeed = useCallback(
80− async (manualSeed, isDiscontinuity) => {
81+ async manualSeed => {
81 const details = need.details(getDetails(_point));
82 const details = need.details(getDetails(_point));
82 const networkRevision = parseInt(details.keyRevisionNumber, 10);
83 const networkRevision = parseInt(details.keyRevisionNumber, 10);
83
84
84− let _seed = manualSeed;
85+ if (manualSeed !== undefined) {
85− if (!_seed) {
86+ setNdNetworkSeed(manualSeed);
87+ return manualSeed;
88+ } else {
86 const networkSeed = await attemptNetworkSeedDerivation({
89 const networkSeed = await attemptNetworkSeedDerivation({
87 urbitWallet,
90 urbitWallet,
88 wallet,
91 wallet,
@@ -91,7 +94,7 @@ function useSetKeys() {
91 revision: networkRevision + 1,
94 revision: networkRevision + 1,
92 });
95 });
93
96
94− _seed = networkSeed.matchWith({
97+ return networkSeed.matchWith({
95 Nothing: () => {
98 Nothing: () => {
96 const ndSeed = randomHex(64);
99 const ndSeed = randomHex(64);
97 setNdNetworkSeed(ndSeed);
100 setNdNetworkSeed(ndSeed);
@@ -100,7 +103,14 @@ function useSetKeys() {
100 Just: p => p.value,
103 Just: p => p.value,
101 });
104 });
102 }
105 }
106+ },
107+ [_point, authMnemonic, getDetails, urbitWallet, wallet]
108+ );
109+
110+ const construct = useCallback(
111+ async (manualSeed, isDiscontinuity) => {
112+ const seed = await getSeed(manualSeed);
103− const pair = deriveNetworkKeys(_seed);
113+ const pair = deriveNetworkKeys(seed);
104
114
105 const txn = azimuth.ecliptic.configureKeys(
115 const txn = azimuth.ecliptic.configureKeys(
106 _contracts,
116 _contracts,
@@ -113,15 +123,7 @@ function useSetKeys() {
113
123
114 _construct(txn);
124 _construct(txn);
115 },
125 },
116− [
117− _construct,
126+ [_construct, _contracts, _point, getSeed]
118− _contracts,
119− _point,
120− authMnemonic,
121− getDetails,
122− urbitWallet,
123− wallet,
124− ]
125 );
127 );
126
128
127 return {
129 return {
@@ -130,6 +132,7 @@ function useSetKeys() {
130 broadcasting,
132 broadcasting,
131 confirmed,
133 confirmed,
132 ndNetworkSeed,
134 ndNetworkSeed,
135+ inputsLocked,
133 bind,
136 bind,
134 };
137 };
135}
138}
@@ -147,12 +150,24 @@ export default function AdminNetworkingKeys() {
147 Just: ({ value: details }) => parseInt(details.keyRevisionNumber, 10) > 0,
150 Just: ({ value: details }) => parseInt(details.keyRevisionNumber, 10) > 0,
148 });
151 });
149
152
153+ const {
154+ isDefaultState,
155+ construct,
156+ broadcasting,
157+ confirmed,
158+ inputsLocked,
159+ ndNetworkSeed,
160+ bind,
161+ } = useSetKeys();
162+
150 const [showNetworkSeedInput, { data: showNetworkSeed }] = useCheckboxInput({
163 const [showNetworkSeedInput, { data: showNetworkSeed }] = useCheckboxInput({
151 name: 'shownetworkseed',
164 name: 'shownetworkseed',
152 label: 'Use Custom Network Seed',
165 label: 'Use Custom Network Seed',
153 inverseLabel: 'Back to Derived Network Seed',
166 inverseLabel: 'Back to Derived Network Seed',
154 initialValue: false,
167 initialValue: false,
168+ disabled: inputsLocked,
155 });
169 });
170+
156 const [
171 const [
157 networkSeedInput,
172 networkSeedInput,
158 { pass: validNetworkSeed, data: networkSeed },
173 { pass: validNetworkSeed, data: networkSeed },
@@ -161,6 +176,7 @@ export default function AdminNetworkingKeys() {
161 name: 'networkseed',
176 name: 'networkseed',
162 label: 'Network Seed (64 bytes)',
177 label: 'Network Seed (64 bytes)',
163 length: 32, // 64 bytes
178 length: 32, // 64 bytes
179+ disabled: inputsLocked,
164 });
180 });
165
181
166 const [
182 const [
@@ -169,19 +185,10 @@ export default function AdminNetworkingKeys() {
169 ] = useCheckboxInput({
185 ] = useCheckboxInput({
170 name: 'discontinuity',
186 name: 'discontinuity',
171 label: 'Trigger New Continuity Era',
187 label: 'Trigger New Continuity Era',
172− length: 64,
173 initialValue: false,
188 initialValue: false,
189+ disabled: inputsLocked,
174 });
190 });
175
191
176− const {
177− isDefaultState,
178− construct,
179− broadcasting,
180− confirmed,
181− ndNetworkSeed,
182− bind,
183− } = useSetKeys();
184−
185 useEffect(() => {
192 useEffect(() => {
186 if (
193 if (
187 (!showNetworkSeed || (showNetworkSeed && validNetworkSeed)) &&
194 (!showNetworkSeed || (showNetworkSeed && validNetworkSeed)) &&