on master help sign in
Merge branch 'hm/quota-communication'
9875f17Hunter 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
@@ -157,7 +157,7 @@ export default function useRoller() {
157 );
157 );
158
158
159 const fetchConfig = useCallback(async () => {
159 const fetchConfig = useCallback(async () => {
160− getNextQuotaTime(1);
160+ getNextQuotaTime(Date.now() + 1000);
161 api
161 api
162 .getRollerConfig()
162 .getRollerConfig()
163 .then(config => {
163 .then(config => {
@@ -177,12 +177,12 @@ export default function useRoller() {
177 if (point.l2Quota <= 0) {
177 if (point.l2Quota <= 0) {
178 setModalText(
178 setModalText(
179 `You have reached your weekly L2 transaction limit. You will get another
179 `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)}.`
181 );
181 );
182 }
182 }
183
183
184 return point.l2Quota <= 0;
184 return point.l2Quota <= 0;
185− }, [config, nextQuotaTime, point, setModalText]);
185+ }, [nextQuotaTime, point, setModalText]);
186
186
187 const initPoint = useCallback(
187 const initPoint = useCallback(
188 async (point: string | number) => {
188 async (point: string | number) => {
@@ -196,9 +196,9 @@ export default function useRoller() {
196 const pointNum = Number(point);
196 const pointNum = Number(point);
197 try {
197 try {
198 const rawDetails = await api.getPoint(pointNum);
198 const rawDetails = await api.getPoint(pointNum);
199− const l2Quota = isL2Spawn(rawDetails?.dominion)
199+ const isL2 = isL2Spawn(rawDetails?.dominion);
200− ? await api.getRemainingQuota(pointNum)
200+ const l2Quota = isL2 ? await api.getRemainingQuota(pointNum) : 0;
201− : 0;
201+ const l2Allowance = isL2 ? await api.getAllowance(pointNum) : 0;
202
202
203 const details = isL2Spawn(rawDetails?.dominion)
203 const details = isL2Spawn(rawDetails?.dominion)
204 ? toL1Details(rawDetails)
204 ? toL1Details(rawDetails)
@@ -209,6 +209,7 @@ export default function useRoller() {
209 details,
209 details,
210 address: _wallet.address,
210 address: _wallet.address,
211 l2Quota,
211 l2Quota,
212+ l2Allowance,
212 });
213 });
213 } catch (e) {
214 } catch (e) {
214 console.warn(e);
215 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}