fix: [PRODUCT-604] build --start param of equivalent buy command correctly#223
Merged
Conversation
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Fixed the equivalent sf buy command shown by the deprecated sf extend command to include the --start parameter set to the contract's end time, making it truly equivalent to extending a contract.
Key changes:
- Fetches contract details via API to retrieve the contract end time
- Extracts
endsAtfrom contract shape usinggetContractRangeutility - Builds equivalent buy command with
-s <contract_end_time>parameter - Falls back to placeholder
<contract_end_time>if API fetch fails - Updates help text to reflect the corrected command format
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The change correctly addresses the reported issue by fetching contract details and extracting the end time to build an accurate equivalent command. The implementation follows existing patterns in the codebase (using
apiClient,getContractRange), includes proper error handling with fallback to a placeholder value, and maintains backward compatibility. The change is isolated to a deprecated command with clear migration messaging. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/lib/extend/index.tsx | 5/5 | Added API call to fetch contract details and correctly build the equivalent buy command with --start parameter set to the contract's end time |
Sequence Diagram
sequenceDiagram
participant User
participant extendAction
participant apiClient
participant API as /v0/contracts/{id}
participant getContractRange
participant Console
User->>extendAction: Run sf extend command
extendAction->>apiClient: Initialize API client
extendAction->>API: GET /v0/contracts/{id}
alt Fetch successful
API-->>extendAction: Return contract data
extendAction->>getContractRange: Extract contract.shape
getContractRange-->>extendAction: Return {startsAt, endsAt}
extendAction->>extendAction: Build command with endsAt.toISOString()
extendAction->>Console: Display equivalent buy command with -s flag
extendAction->>User: Exit with code 0
else Fetch failed
API-->>extendAction: Return error
extendAction->>Console: Display error and equivalent command with placeholder
extendAction->>User: Exit with code 1
end
1 file reviewed, no comments
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@coffinsfcompute pointed out that we don't include
--start <contractToExtend.End>in the equivalent buy colocate command, making it not actually equivalent.