Skip to content

fix: cleanup chain-sdk migration (addresses PR #14 review)#16

Merged
zJuuu merged 11 commits into
akash-network:mainfrom
jobordu:fix/chain-sdk-migration-cleanup
Mar 30, 2026
Merged

fix: cleanup chain-sdk migration (addresses PR #14 review)#16
zJuuu merged 11 commits into
akash-network:mainfrom
jobordu:fix/chain-sdk-migration-cleanup

Conversation

@jobordu

@jobordu jobordu commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR builds on top of PR #14 (rebased on latest main) and addresses all 7 cleanup items identified by maintainer @zJuuu in the review:

  1. Remove org-specific code — Deleted check-provider-safety.ts (hardcoded AlternateFutures provider addresses), AUDIT_REPORT.md, SECRETS.md, IMPROVEMENTS.md, and all 10 fork-specific debug scripts in scripts/
  2. Remove unused client parameter — Removed from loadCertificate() signature and all call sites
  3. Fix certificate fallback — Now throws when chainSDK is unavailable instead of silently saving locally (providers reject unbroadcast certificates)
  4. Move @types/ws to devDependencies — Type packages are build-time only
  5. Deduplicate pemToUint8Array — Extracted to shared util in load-certificate.ts, imported in regenerate-certificate.ts
  6. Replace any typesCertificatePem for certificate params, local interfaces for chain SDK responses, error: unknown with instanceof guards across all catch blocks
  7. Reorganize tests — Moved from src/ to tests/ directory mirroring src/ structure, updated import paths and vitest config

Also fixed: unused ResourceDefinition import in get-sdl.ts, unused extra parameter in all tool registrations, explicit WebSocket event handler types.

Relationship to PR #14

This PR includes all commits from PR #14 (by @wonderwomancode), rebased on latest main to resolve merge conflicts, plus the cleanup commit. If merged, PR #14 can be closed.

Test plan

  • npm run build — passes (zero TypeScript errors)
  • npm test — 65/65 tests pass
  • No remaining any types in src/ (verified with grep)
  • Manual testing of deployment operations on mainnet/testnet

🤖 Generated with Claude Code

wonderwomancode and others added 11 commits March 20, 2026 09:55
BREAKING CHANGE: Migrates from deprecated @akashnetwork/akashjs and @akashnetwork/akash-api packages to the new @akashnetwork/chain-sdk package.

Key changes:
- Update dependencies to use @akashnetwork/chain-sdk@1.0.0-alpha.18
- Require Node.js >= 22.0.0
- Update all tools to use new chain SDK API:
  - deployment v1beta4 (was v1beta3)
  - market v1beta5 (was v1beta4)
  - escrow v1
  - provider v1beta4 (was v1beta3)
  - cert v1
- Update type definitions for new SDK interfaces
- Use createChainNodeSDK for queries and transactions
- Use createStargateClient for signing operations
- Update field names: version -> hash for deployments
- Add bseq field to BidID and LeaseID
- Update Lease.id (was Lease.leaseId) and Bid.id (was Bid.bidId)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Set up vitest testing framework with coverage support
- Add unit tests for create-output utility function
- Add tests for tool handlers:
  - get-account-addr: metadata and handler tests
  - get-bids: parameter validation and handler tests
  - get-balances: parameter validation and handler tests
  - create-deployment: parameter validation and error handling tests
  - create-lease: parameter validation and handler tests
  - close-deployment: parameter validation and handler tests
- All 65 tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add exec-command tool for running shell commands in containers
- Add get-logs tool for retrieving container logs via WebSocket
- Add certificate management tools (revoke, revoke-all, regenerate)
- Add deployment audit scripts and documentation
- Improve send-manifest with better mTLS handling
- Add reloadCertificate method for dynamic cert refresh

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- New MCP tool to check if a provider is safe for a deployment
- Prevents NAT hairpin issues by blocking proxy's provider for backend services
- Parameters: provider (address), serviceType (proxy|backend|standalone)
- Returns safety status with detailed reason

Usage:
  mcp__akash__check-provider-safety with provider and serviceType

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Increased gasMultiplier from default 1.3 to 2.0
- Resolves transaction code 11 (out of gas) errors when updating deployments
- The default multiplier was insufficient for deployment update transactions

Fixes alternatefutures/infrastructure-proxy proxy update issue

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- get-deployment now includes:
  - Resource totals (CPU, memory, storage, GPU) calculated from groups
  - Lease information with provider details (hostUri, attributes, info)
  - Lease pricing information
  - Created height for timeline tracking

- get-bids now includes:
  - Provider information (hostUri, attributes, info) for each bid
  - Helps users make better decisions when selecting bids

These changes align with the context displayed in the Akash Console,
providing more visibility into deployments and provider capabilities.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added comprehensive documentation of the context field enhancements
made to get-deployment and get-bids tools. This includes resource
totals, lease information, provider details, and timeline tracking.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Addresses all 7 cleanup items from maintainer (zJuuu) review on PR akash-network#14:

1. Remove org-specific code: delete check-provider-safety.ts (hardcoded
   provider addresses), AUDIT_REPORT.md, SECRETS.md, IMPROVEMENTS.md,
   and 10 fork-specific debug scripts in scripts/

2. Remove unused client parameter from loadCertificate() signature
   and all call sites

3. Fix certificate fallback: throw error when chainSDK is unavailable
   instead of silently saving cert locally (providers won't recognize
   unbroadcast certificates)

4. Move @types/ws from dependencies to devDependencies

5. Deduplicate pemToUint8Array: extract to shared util in
   load-certificate.ts, import in regenerate-certificate.ts

6. Replace all `any` types with proper types: CertificatePem for
   certificate params, local interfaces for chain SDK responses,
   `error: unknown` with instanceof guards for catch blocks

7. Move tests from src/ to tests/ directory mirroring src/ structure,
   update import paths and vitest config

Build passes, all 65 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add validateMnemonic() that fails fast with a clear error if
  AKASH_MNEMONIC is missing or not 12/24 words
- Validation runs at wallet creation (not module import) so tests
  that mock the wallet aren't broken
- Add null guard in getToolContext(): throw explicit error if no
  certificate is available (disk or memory) instead of passing
  stale/null cert that causes silent 401s from providers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zJuuu zJuuu merged commit 41a7e4e into akash-network:main Mar 30, 2026
1 check failed
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.

4 participants