on master help sign in
useRoller, IssueChild: fix typescript errors
736316bpkova
src/lib/useRoller.ts+10−10
@@ -44,7 +44,7 @@ import { useRollerOptions } from './useRollerOptions';
44import { useTimerStore } from 'store/timerStore';
44import { useTimerStore } from 'store/timerStore';
45
45
46interface UpdateParams {
46interface UpdateParams {
47− point: number;
47+ point?: Point | number;
48 message?: string;
48 message?: string;
49 notify?: boolean;
49 notify?: boolean;
50 field?: PointField;
50 field?: PointField;
@@ -140,7 +140,7 @@ export default function useRoller() {
140 }, [nextQuotaTime, point, setModalText]);
140 }, [nextQuotaTime, point, setModalText]);
141
141
142 const initPoint = useCallback(
142 const initPoint = useCallback(
143− async (point: string | number) => {
143+ async (point: string | number): Promise<Point> => {
144 const _wallet = wallet.getOrElse(null);
144 const _wallet = wallet.getOrElse(null);
145 const _contracts = contracts.getOrElse(null);
145 const _contracts = contracts.getOrElse(null);
146
146
@@ -210,25 +210,25 @@ export default function useRoller() {
210 field,
210 field,
211 l1Txn,
211 l1Txn,
212 intervalTime = TEN_SECONDS,
212 intervalTime = TEN_SECONDS,
213− pointValue,
214 }: UpdateParams) => {
213 }: UpdateParams) => {
215
214
215+
216− point = point === undefined ? await initPoint(pointValue) : point;
216+ const p = (typeof point === 'number' ? await initPoint(point) : point) as Point
217
217
218 if (l1Txn) storePendingL1Txn(l1Txn);
218 if (l1Txn) storePendingL1Txn(l1Txn);
219
219
220 let interval: any;
220 let interval: any;
221 const check = async () => {
221 const check = async () => {
222− const changedField = !points[point]
222+ const changedField = !points[p.value]
223 ? 'newPoint'
223 ? 'newPoint'
224− : point.getChangedField(points[point], field);
224+ : p.getChangedField(points[p.value], field);
225
225
226 if (isDevelopment) {
226 if (isDevelopment) {
227− console.log(`CHECKING FOR ${changedField} UPDATES:`, point.patp);
227+ console.log(`CHECKING FOR ${changedField} UPDATES:`, p.patp);
228 }
228 }
229
229
230− if (!point.isPlaceholder && changedField) {
230+ if (!p.isPlaceholder && changedField) {
231− updatePoint(point);
231+ updatePoint(p);
232 if (interval) {
232 if (interval) {
233 clearInterval(interval);
233 clearInterval(interval);
234 }
234 }
@@ -236,7 +236,7 @@ export default function useRoller() {
236 if (l1Txn) deletePendingL1Txn(l1Txn);
236 if (l1Txn) deletePendingL1Txn(l1Txn);
237 if (notify) {
237 if (notify) {
238 showNotification(
238 showNotification(
239− `${message || getUpdatedPointMessage(point, changedField)}`
239+ `${message || getUpdatedPointMessage(p, changedField)}`
240 );
240 );
241 }
241 }
242 }
242 }
src/views/Point/IssueChild.tsx+2−2
@@ -119,7 +119,7 @@ export default function IssueChild() {
119 if (pointToSpawn && destinationAddress) {
119 if (pointToSpawn && destinationAddress) {
120 setLoading(true);
120 setLoading(true);
121 await spawnPoint(pointToSpawn, destinationAddress);
121 await spawnPoint(pointToSpawn, destinationAddress);
122− checkForUpdates({ pointValue: pointToSpawn });
122+ checkForUpdates({ point: pointToSpawn });
123 setPointToSpawn(null);
123 setPointToSpawn(null);
124 setDestinationAddress(null);
124 setDestinationAddress(null);
125 setL2SpawnSent(true);
125 setL2SpawnSent(true);
@@ -140,7 +140,7 @@ export default function IssueChild() {
140 useEffect(() => {
140 useEffect(() => {
141 if (completed && pointToSpawn) {
141 if (completed && pointToSpawn) {
142 checkForUpdates({
142 checkForUpdates({
143− pointValue: pointToSpawn,
143+ point: pointToSpawn,
144 l1Txn: {
144 l1Txn: {
145 id: `${pointToSpawn}`,
145 id: `${pointToSpawn}`,
146 point: point.value,
146 point: point.value,