on master help sign in
quota: swaps generic quota for actual allowance, fixes quota reset time
commit6d5246ae9b6cd42ff667192a9ba68e502793095b authorHunter Miller <hunter@thisdot.co> dateMon 14 Feb 2022, 11:51 (5 years ago) parent162912b
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
@@ -164,7 +164,7 @@ export default function useRoller() {
164164 );
165165
166166 const fetchConfig = useCallback(async () => {
167− getNextQuotaTime(1);
167+ getNextQuotaTime(Date.now() + 1000);
168168 api
169169 .getRollerConfig()
170170 .then(config => {
@@ -184,12 +184,12 @@ export default function useRoller() {
184184 if (point.l2Quota <= 0) {
185185 setModalText(
186186 `You have reached your weekly L2 transaction limit. You will get another
187− ${config?.rollerQuota} transactions on ${ddmmmYYYY(nextQuotaTime)}.`
187+ ${point.l2Allowance} transactions on ${ddmmmYYYY(nextQuotaTime)}.`
188188 );
189189 }
190190
191191 return point.l2Quota <= 0;
192− }, [config, nextQuotaTime, point, setModalText]);
192+ }, [nextQuotaTime, point, setModalText]);
193193
194194 const initPoint = useCallback(
195195 async (point: string | number) => {
@@ -203,9 +203,9 @@ export default function useRoller() {
203203 const pointNum = Number(point);
204204 try {
205205 const rawDetails = await api.getPoint(pointNum);
206− const l2Quota = isL2Spawn(rawDetails?.dominion)
207− ? await api.getRemainingQuota(pointNum)
208− : 0;
206+ const isL2 = isL2Spawn(rawDetails?.dominion);
207+ const l2Quota = isL2 ? await api.getRemainingQuota(pointNum) : 0;
208+ const l2Allowance = isL2 ? await api.getAllowance(pointNum) : 0;
209209
210210 const details = isL2Spawn(rawDetails?.dominion)
211211 ? toL1Details(rawDetails)
@@ -216,6 +216,7 @@ export default function useRoller() {
216216 details,
217217 address: _wallet.address,
218218 l2Quota,
219+ l2Allowance,
219220 });
220221 } catch (e) {
221222 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}