on master help sign in
Merge branch 'hm/quota-communication'
commit9875f17cc47b5cd01c6d7422d52d4ea1e10cc107 authorHunter Miller <hunter@thisdot.co> dateTue 15 Feb 2022, 15:20 (5 years ago) parent4452e336d5246a
3 files changed+13−9
src/lib/types/Point.ts+4 src/lib/useRoller.ts+7−6 src/views/Invite/Cohort.tsx+2−3
src/lib/types/Point.ts+4
@@ -69,6 +69,7 @@ interface PointConstructorParams {
6969 details: L1Point;
7070 address: string;
7171 l2Quota?: number;
72+ l2Allowance?: number;
7273 isPlaceholder?: boolean;
7374}
7475
@@ -77,6 +78,7 @@ export default class Point {
7778 patp: string;
7879 layer: 1 | 2;
7980 l2Quota: number;
81+ l2Allowance: number;
8082 active: boolean;
8183 authenticationKey: string;
8284 continuityNumber: string;
@@ -132,6 +134,7 @@ export default class Point {
132134 details,
133135 address,
134136 l2Quota = 0,
137+ l2Allowance = 0,
135138 isPlaceholder = false,
136139 }: PointConstructorParams) {
137140 this.value = value;
@@ -139,6 +142,7 @@ export default class Point {
139142
140143 this.layer = details.layer || 1;
141144 this.l2Quota = l2Quota;
145+ this.l2Allowance = l2Allowance;
142146 this.isL2Spawn = Boolean(details.isL2Spawn);
143147 this.active = details.active;
144148 this.authenticationKey = details.authenticationKey;
src/lib/useRoller.ts+7−6
@@ -157,7 +157,7 @@ export default function useRoller() {
157157 );
158158
159159 const fetchConfig = useCallback(async () => {
160− getNextQuotaTime(1);
160+ getNextQuotaTime(Date.now() + 1000);
161161 api
162162 .getRollerConfig()
163163 .then(config => {
@@ -177,12 +177,12 @@ export default function useRoller() {
177177 if (point.l2Quota <= 0) {
178178 setModalText(
179179 `You have reached your weekly L2 transaction limit. You will get another
180− ${config?.rollerQuota} transactions on ${ddmmmYYYY(nextQuotaTime)}.`
180+ ${point.l2Allowance} transactions on ${ddmmmYYYY(nextQuotaTime)}.`
181181 );
182182 }
183183
184184 return point.l2Quota <= 0;
185− }, [config, nextQuotaTime, point, setModalText]);
185+ }, [nextQuotaTime, point, setModalText]);
186186
187187 const initPoint = useCallback(
188188 async (point: string | number) => {
@@ -196,9 +196,9 @@ export default function useRoller() {
196196 const pointNum = Number(point);
197197 try {
198198 const rawDetails = await api.getPoint(pointNum);
199− const l2Quota = isL2Spawn(rawDetails?.dominion)
200− ? await api.getRemainingQuota(pointNum)
201− : 0;
199+ const isL2 = isL2Spawn(rawDetails?.dominion);
200+ const l2Quota = isL2 ? await api.getRemainingQuota(pointNum) : 0;
201+ const l2Allowance = isL2 ? await api.getAllowance(pointNum) : 0;
202202
203203 const details = isL2Spawn(rawDetails?.dominion)
204204 ? toL1Details(rawDetails)
@@ -209,6 +209,7 @@ export default function useRoller() {
209209 details,
210210 address: _wallet.address,
211211 l2Quota,
212+ l2Allowance,
212213 });
213214 } catch (e) {
214215 console.warn(e);
src/views/Invite/Cohort.tsx+2−3
@@ -72,7 +72,6 @@ export default function InviteCohort() {
7272 const { nextRoll } = useTimerStore();
7373
7474 const {
75− config,
7675 ls,
7776 generateInviteCodes,
7877 getPendingTransactions,
@@ -382,7 +381,7 @@ export default function InviteCohort() {
382381 You can generate up to
383382 <strong>{` ${point.l2Quota} `}</strong>
384383 invites. You will be able to generate another
385− <strong>{` ${config?.rollerQuota}`}</strong> invites on
384+ <strong>{` ${point.l2Allowance}`}</strong> invites on
386385 <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
387386 </Box>
388387 )}
@@ -501,7 +500,7 @@ export default function InviteCohort() {
501500 <Box className="invite-limit-message">
502501 You have hit your weekly invite limit. You will be able to generate
503502 another
504− <strong>{` ${config?.rollerQuota}`}</strong> invites on
503+ <strong>{` ${point.l2Allowance}`}</strong> invites on
505504 <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
506505 </Box>
507506 ) : null}