Skip to content

Commit

Permalink
Merge pull request #18 from LIT-Protocol/fix/not-topping-up-when-needed
Browse files Browse the repository at this point in the history
Multiply seconds timestamp from chain by 1000 to convert to milliseconds
  • Loading branch information
glitch003 authored Nov 2, 2024
2 parents 495c909 + 3ceb3e0 commit 7a64756
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"test": "pnpm -r run test",
"dev": "pnpm build && pnpm dotenvx run -- node ./dist/worker/worker_test_run_now.js",
"start": "pnpm build && node ./dist/worker/worker.js",
"runNow": "node ./dist/worker/worker_test_run_now.js",
"prepare": "husky",
"ci_validate": "node ./dist/bin/validateJSONRecipients.js",
"validate": "pnpm build && node ./dist/bin/validateJSONRecipients.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-task-auto-top-up/src/Classes/TaskHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class TaskHandler {
if (isExpired) {
return true;
}
const tokenExpiresDate = new TZDate(timestamp, 'UTC');
const tokenExpiresDate = new TZDate(timestamp * 1000, 'UTC');
return isSameDay(tokenExpiresDate, tomorrow) || isSameDay(tokenExpiresDate, today);
});
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: DAY_BEFORE_YESTERDAY.toISOString(),
timestamp: DAY_BEFORE_YESTERDAY.getTime(),
timestamp: DAY_BEFORE_YESTERDAY.getTime() / 1000, // the real data from the contract is in seconds
},
requestsPerMillisecond: 50,
},
Expand All @@ -73,7 +73,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: YESTERDAY.toISOString(),
timestamp: YESTERDAY.getTime(),
timestamp: YESTERDAY.getTime() / 1000, // the real data from the contract is in seconds
},
requestsPerMillisecond: 50,
},
Expand All @@ -91,7 +91,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: DAY_AFTER_TOMORROW.toISOString(),
timestamp: DAY_AFTER_TOMORROW.getTime(),
timestamp: DAY_AFTER_TOMORROW.getTime() / 1000, // the real data from the contract is in seconds
},
requestsPerMillisecond: 50,
},
Expand All @@ -107,7 +107,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: NEXT_WEEK.toISOString(),
timestamp: NEXT_WEEK.getTime(),
timestamp: NEXT_WEEK.getTime() / 1000, // the real data from the contract is in seconds,
},
requestsPerMillisecond: 50,
},
Expand All @@ -123,7 +123,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: TWO_WEEKS_FROM_NOW.toISOString(),
timestamp: TWO_WEEKS_FROM_NOW.getTime(),
timestamp: TWO_WEEKS_FROM_NOW.getTime() / 1000, // the real data from the contract is in seconds,
},
requestsPerMillisecond: 50,
},
Expand All @@ -141,7 +141,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: LATER_TODAY.toISOString(),
timestamp: LATER_TODAY.getTime(),
timestamp: LATER_TODAY.getTime() / 1000, // the real data from the contract is in seconds,
},
requestsPerMillisecond: 50,
},
Expand All @@ -157,7 +157,7 @@ export const tokenFixtures: TokenFixtures = {
capacity: {
expiresAt: {
formatted: TOMORROW.toISOString(),
timestamp: TOMORROW.getTime(),
timestamp: TOMORROW.getTime() / 1000, // the real data from the contract is in seconds,
},
requestsPerMillisecond: 50,
},
Expand Down

0 comments on commit 7a64756

Please sign in to comment.