on master help sign in
quota: swaps generic quota for actual allowance, fixes quota reset time
6d5246aHunter Miller
src/lib/types/Point.ts+4
@@ -69,6 +69,7 @@ interface PointConstructorParams {
69 details: L1Point;
69 details: L1Point;
70 address: string;
70 address: string;
71 l2Quota?: number;
71 l2Quota?: number;
72+ l2Allowance?: number;
72 isPlaceholder?: boolean;
73 isPlaceholder?: boolean;
73}
74}
74
75
@@ -77,6 +78,7 @@ export default class Point {
77 patp: string;
78 patp: string;
78 layer: 1 | 2;
79 layer: 1 | 2;
79 l2Quota: number;
80 l2Quota: number;
81+ l2Allowance: number;
80 active: boolean;
82 active: boolean;
81 authenticationKey: string;
83 authenticationKey: string;
82 continuityNumber: string;
84 continuityNumber: string;
@@ -132,6 +134,7 @@ export default class Point {
132 details,
134 details,
133 address,
135 address,
134 l2Quota = 0,
136 l2Quota = 0,
137+ l2Allowance = 0,
135 isPlaceholder = false,
138 isPlaceholder = false,
136 }: PointConstructorParams) {
139 }: PointConstructorParams) {
137 this.value = value;
140 this.value = value;
@@ -139,6 +142,7 @@ export default class Point {
139
142
140 this.layer = details.layer || 1;
143 this.layer = details.layer || 1;
141 this.l2Quota = l2Quota;
144 this.l2Quota = l2Quota;
145+ this.l2Allowance = l2Allowance;
142 this.isL2Spawn = Boolean(details.isL2Spawn);
146 this.isL2Spawn = Boolean(details.isL2Spawn);
143 this.active = details.active;
147 this.active = details.active;
144 this.authenticationKey = details.authenticationKey;
148 this.authenticationKey = details.authenticationKey;
src/lib/useRoller.ts+7−6
@@ -164,7 +164,7 @@ export default function useRoller() {
164 );
164 );
165
165
166 const fetchConfig = useCallback(async () => {
166 const fetchConfig = useCallback(async () => {
167− getNextQuotaTime(1);
167+ getNextQuotaTime(Date.now() + 1000);
168 api
168 api
169 .getRollerConfig()
169 .getRollerConfig()
170 .then(config => {
170 .then(config => {
@@ -184,12 +184,12 @@ export default function useRoller() {
184 if (point.l2Quota <= 0) {
184 if (point.l2Quota <= 0) {
185 setModalText(
185 setModalText(
186 `You have reached your weekly L2 transaction limit. You will get another
186 `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)}.`
188 );
188 );
189 }
189 }
190
190
191 return point.l2Quota <= 0;
191 return point.l2Quota <= 0;
192− }, [config, nextQuotaTime, point, setModalText]);
192+ }, [nextQuotaTime, point, setModalText]);
193
193
194 const initPoint = useCallback(
194 const initPoint = useCallback(
195 async (point: string | number) => {
195 async (point: string | number) => {
@@ -203,9 +203,9 @@ export default function useRoller() {
203 const pointNum = Number(point);
203 const pointNum = Number(point);
204 try {
204 try {
205 const rawDetails = await api.getPoint(pointNum);
205 const rawDetails = await api.getPoint(pointNum);
206− const l2Quota = isL2Spawn(rawDetails?.dominion)
206+ const isL2 = isL2Spawn(rawDetails?.dominion);
207− ? await api.getRemainingQuota(pointNum)
207+ const l2Quota = isL2 ? await api.getRemainingQuota(pointNum) : 0;
208− : 0;
208+ const l2Allowance = isL2 ? await api.getAllowance(pointNum) : 0;
209
209
210 const details = isL2Spawn(rawDetails?.dominion)
210 const details = isL2Spawn(rawDetails?.dominion)
211 ? toL1Details(rawDetails)
211 ? toL1Details(rawDetails)
@@ -216,6 +216,7 @@ export default function useRoller() {
216 details,
216 details,
217 address: _wallet.address,
217 address: _wallet.address,
218 l2Quota,
218 l2Quota,
219+ l2Allowance,
219 });
220 });
220 } catch (e) {
221 } catch (e) {
221 console.warn(e);
222 console.warn(e);
src/views/Invite/Cohort.tsx+2−3
@@ -72,7 +72,6 @@ export default function InviteCohort() {
72 const { nextRoll } = useTimerStore();
72 const { nextRoll } = useTimerStore();
73
73
74 const {
74 const {
75− config,
76 ls,
75 ls,
77 generateInviteCodes,
76 generateInviteCodes,
78 getPendingTransactions,
77 getPendingTransactions,
@@ -382,7 +381,7 @@ export default function InviteCohort() {
382 You can generate up to
381 You can generate up to
383 <strong>{` ${point.l2Quota} `}</strong>
382 <strong>{` ${point.l2Quota} `}</strong>
384 invites. You will be able to generate another
383 invites. You will be able to generate another
385− <strong>{` ${config?.rollerQuota}`}</strong> invites on
384+ <strong>{` ${point.l2Allowance}`}</strong> invites on
386 <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
385 <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
387 </Box>
386 </Box>
388 )}
387 )}
@@ -501,7 +500,7 @@ export default function InviteCohort() {
501 <Box className="invite-limit-message">
500 <Box className="invite-limit-message">
502 You have hit your weekly invite limit. You will be able to generate
501 You have hit your weekly invite limit. You will be able to generate
503 another
502 another
504− <strong>{` ${config?.rollerQuota}`}</strong> invites on
503+ <strong>{` ${point.l2Allowance}`}</strong> invites on
505 <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
504 <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
506 </Box>
505 </Box>
507 ) : null}
506 ) : null}