Skip to content

Latest commit

 

History

History
152 lines (109 loc) · 4.68 KB

File metadata and controls

152 lines (109 loc) · 4.68 KB

API Path Update Summary - Issue #18

Overview

Updated all API methods in src/core/zhtp-api-methods.ts to use the standardized /api/v1 path prefix, ensuring compatibility with the ZHTP node's current API structure.

Changes Made

Wallet Operations

All wallet methods now use /api/v1/wallet prefix:

  1. getWallets() (line 381)

    • ❌ Old: /wallet/balance?address=...
    • ✅ New: /api/v1/wallet/balance?address=...
  2. getTransactionHistory() (line 395)

    • ❌ Old: /wallet/transactions?address=...
    • ✅ New: /api/v1/wallet/transactions?address=...
  3. getAssets() (line 403)

    • ❌ Old: /wallet/assets?address=...
    • ✅ New: /api/v1/wallet/assets?address=...

DAO Operations

All DAO methods now use /api/v1/dao prefix:

  1. getProposalDetails() (line 475)

    • ❌ Old: /dao/proposals/${proposalId}
    • ✅ New: /api/v1/dao/proposals/${proposalId}
  2. getDelegateProfile() (line 487)

    • ❌ Old: /dao/delegates/${delegateId}
    • ✅ New: /api/v1/dao/delegates/${delegateId}
  3. getVotingPower() (line 521)

    • ❌ Old: /dao/voting-power/${userDid}
    • ✅ New: /api/v1/dao/voting-power/${userDid}
  4. getUserVotes() (line 532)

    • ❌ Old: /dao/user-votes/${userDid}
    • ✅ New: /api/v1/dao/user-votes/${userDid}

Already Correct Paths

The following sections were already using /api/v1 paths correctly:

Identity Operations (lines 44-370)

  • All /api/v1/identity/* endpoints

Backup Operations (lines 198-219)

  • All /api/v1/identity/backup/* endpoints

Guardian Management (lines 238-305)

  • All /api/v1/guardian/* and /api/v1/identity/guardians/* endpoints

Network Operations (lines 375, 607)

  • /api/v1/blockchain/network/peers

Blockchain Operations (lines 595-642)

  • All /api/v1/blockchain/* endpoints

Smart Contract Operations (lines 641-684)

  • All /api/v1/blockchain/contracts/* endpoints
  • All /api/v1/contract/* endpoints

Zero-Knowledge Proof Operations (lines 689-708)

  • /api/v1/zkp/generate
  • /api/v1/zkp/verify

Protocol Operations (lines 599, 603, 726)

  • /api/v1/protocol/info
  • /api/v1/network/gas

Web4/DHT Operations (lines 539-590)

  • All /api/v1/dht/* and /api/v1/web4/* endpoints

Backward Compatibility

The ZHTP node supports backward compatibility through path aliases (see zhtp/src/server/http/router.rs:187-256):

Legacy Path Mappings:

  • /wallet/*/api/v1/wallet/*
  • /dao/*/api/v1/dao/*
  • /mesh/peers/api/v1/blockchain/network/peers
  • /node/status/api/v1/protocol/info
  • /blockchain/info/api/v1/blockchain/status
  • /contract/*/api/v1/blockchain/contracts/*

Result: Even though we updated the client to use /api/v1 paths, the old paths would have still worked due to node-side aliasing. However, using the standard paths directly is cleaner and more future-proof.

Verification

Total API methods checked: 70+ methods

Path Distribution:

  • Methods using /api/v1: 70 methods
  • Methods using /health: 1 method ✅ (health check endpoint)
  • Methods using legacy paths: 0 methods

All paths now conform to the /api/v1 standard!

Testing Recommendations

  1. Wallet Methods Test:

    await client.getWallets(testDid);
    await client.getTransactionHistory(testAddress);
    await client.getAssets(testAddress);
  2. DAO Methods Test:

    await client.getProposalDetails(testProposalId);
    await client.getDelegateProfile(testDelegateId);
    await client.getVotingPower(testDid);
    await client.getUserVotes(testDid);
  3. End-to-End Test:

    • Run full API client test suite against ZHTP node
    • Verify all methods return expected responses
    • Check error handling for invalid paths

Impact Assessment

Breaking Changes: ❌ None

  • All changes are path updates only
  • No method signatures changed
  • No request/response formats changed
  • Backward compatible with existing code

Benefits:

  • ✅ Consistent API path structure
  • ✅ Future-proof against potential removal of legacy aliases
  • ✅ Clearer API documentation
  • ✅ Easier to maintain and understand

Files Modified

  1. src/core/zhtp-api-methods.ts - 7 path updates

Related Issues

  • Issue #18: [P1] Verify and update API paths to /api/v1 standard
  • Parent Issue #17: Implementation Guide - Complete ZHTP Node API Endpoint Reference
  • Node Issue SOVEREIGN-NET/The-Sovereign-Network#112 (closed - all endpoints implemented)

Next Steps

  1. Run TypeScript compilation check
  2. Run test suite
  3. Update issue #18 with completion status
  4. Move to Priority 2: Backup & Recovery methods (Issue #19)