Fix/implement migration service methods#205
Merged
Merged
Conversation
- Import callReadOnlyFunction for querying contract state - Import cvToValue for parsing Clarity values - Support read-only operations on migration contract Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Support optional network configuration for contract operations - Enable flexibility in test and production environments - Store network for use in read-only function calls Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Extract base address from contract name format (address.contract-name) - Handle both qualified and unqualified contract addresses - Support flexibility in contract address specification Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Query get-current-version read-only function from migration contract - Parse returned Clarity value and convert to number - Fallback to version 1 on error or invalid response - Add comprehensive error handling and logging Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Call get-migration read-only function with migration ID parameter - Parse response and map contract fields to Migration interface - Handle optional fields (executedAt, executedBy) - Support snake_case contract field names - Return null if migration not found or on error Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Query get-migration-data read-only function with migration ID - Extract data hash and size from contract response - Map contract response fields to MigrationData interface - Return empty Uint8Array and 0 for missing values - Return null if data not found or on error Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Query is-migration-executed read-only function - Check migration execution status on contract - Return boolean indicating if migration has been executed - Fallback to false on error or invalid response - Add error handling and logging for execution status checks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Query get-migration-count read-only function - Return total number of migrations registered in contract - Parse Clarity integer response and convert to JavaScript number - Fallback to 0 on error or invalid response - Add error handling and logging Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Key Changes:
Added imports: callReadOnlyFunction, cvToValue from @stacks/transactions
Enhanced constructor: Added optional network parameter for contract calls
Added helper method: extractAddress() to parse contract addresses
Implemented contract calls: Each method now calls the corresponding Clarity read-only function
Error handling: Comprehensive try-catch blocks with appropriate fallbacks
Response parsing: Proper conversion of Clarity values to JavaScript types
Closes #157