Skip to content

Fix/implement migration service methods#205

Merged
Mosas2000 merged 23 commits into
mainfrom
fix/implement-migration-service-methods
May 30, 2026
Merged

Fix/implement migration service methods#205
Mosas2000 merged 23 commits into
mainfrom
fix/implement-migration-service-methods

Conversation

@Mosas2000
Copy link
Copy Markdown
Owner

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

Mosas2000 and others added 23 commits May 30, 2026 16:10
- 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>
@Mosas2000 Mosas2000 merged commit 8abbd34 into main May 30, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement placeholder methods in MigrationService

1 participant