-
Notifications
You must be signed in to change notification settings - Fork 89
refactor(billing): require wallet address in public wallet API responses #3521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
baktun14
wants to merge
14
commits into
main
Choose a base branch
from
refactor/billing-require-wallet-address-in-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
294228f
refactor(billing): require wallet address in public wallet API responses
baktun14 824bfea
refactor(managed-wallet): drop null-address wallet handling from web …
baktun14 0be7d86
refactor(managed-wallet): tidy wallet-address refactor diff
baktun14 0a55580
refactor(billing): scope wallet address mutation and harden readiness…
baktun14 9e439e5
fix(billing): stop publishing a stale endDate default in the usage Op…
baktun14 0252d67
fix(billing): derive usage startDate with UTC date arithmetic
baktun14 4cbb393
Merge origin/main into refactor/billing-require-wallet-address-in-api
baktun14 6c12ce5
refactor(billing): address review feedback on wallet initialization
baktun14 6924eaa
fix(config): restore production server URL in openapi spec
baktun14 6ca8e9e
fix(billing): treat empty-string address as uninitialized wallet
baktun14 88939d9
Merge remote-tracking branch 'origin/main' into refactor/billing-requ…
baktun14 7ba0481
refactor(deployment): use type-only import for wallet types in deploy…
baktun14 d9f8537
refactor(billing): mark type-only wallet imports in wallet reader
baktun14 3a3f940
refactor(billing): reuse isWalletInitialized guard in getWalletByUserId
baktun14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { GetUsageHistoryQuerySchema } from "./usage.schema"; | ||
|
|
||
| describe("Usage Schema", () => { | ||
| describe("GetUsageHistoryQuerySchema", () => { | ||
| const address = "akash18andxgtd6r08zzfpcdqg9pdr6smks7gv76tyt6"; | ||
|
|
||
| it("derives startDate as 30 days before the provided endDate", () => { | ||
| const result = GetUsageHistoryQuerySchema.parse({ address, endDate: "2024-01-31" }); | ||
|
|
||
| expect(result.startDate).toBe("2024-01-01"); | ||
| expect(result.endDate).toBe("2024-01-31"); | ||
| }); | ||
|
|
||
| it("derives startDate across month and year boundaries", () => { | ||
| const result = GetUsageHistoryQuerySchema.parse({ address, endDate: "2024-01-15" }); | ||
|
|
||
| expect(result.startDate).toBe("2023-12-16"); | ||
| expect(result.endDate).toBe("2024-01-15"); | ||
| }); | ||
|
|
||
| it("computes startDate in UTC regardless of the process timezone", () => { | ||
| const originalTimezone = process.env.TZ; | ||
| process.env.TZ = "America/New_York"; | ||
|
|
||
| try { | ||
| const result = GetUsageHistoryQuerySchema.parse({ address, endDate: "2024-11-15" }); | ||
|
|
||
| expect(result.startDate).toBe("2024-10-16"); | ||
| expect(result.endDate).toBe("2024-11-15"); | ||
| } finally { | ||
| process.env.TZ = originalTimezone; | ||
| } | ||
| }); | ||
|
|
||
| it("keeps the provided startDate untouched", () => { | ||
| const result = GetUsageHistoryQuerySchema.parse({ address, startDate: "2024-01-01", endDate: "2024-01-31" }); | ||
|
|
||
| expect(result.startDate).toBe("2024-01-01"); | ||
| expect(result.endDate).toBe("2024-01-31"); | ||
| }); | ||
|
|
||
| it("defaults endDate to today and spans a 30-day window when both dates are omitted", () => { | ||
| const result = GetUsageHistoryQuerySchema.parse({ address }); | ||
|
|
||
| expect(result.endDate).toMatch(/^\d{4}-\d{2}-\d{2}$/); | ||
| const spanInDays = (Date.parse(result.endDate) - Date.parse(result.startDate)) / (24 * 60 * 60 * 1000); | ||
| expect(spanInDays).toBe(30); | ||
| }); | ||
|
|
||
| it("rejects a range wider than 366 days", () => { | ||
| expect(() => GetUsageHistoryQuerySchema.parse({ address, startDate: "2023-01-01", endDate: "2024-12-31" })).toThrow( | ||
| "Date range cannot exceed 366 days and startDate must be before endDate" | ||
| ); | ||
| }); | ||
|
|
||
| it("rejects a startDate after the endDate", () => { | ||
| expect(() => GetUsageHistoryQuerySchema.parse({ address, startDate: "2024-02-01", endDate: "2024-01-01" })).toThrow( | ||
| "Date range cannot exceed 366 days and startDate must be before endDate" | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.