-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
The API client library needs methods to call Web4/DHT domain resolution endpoints once they are implemented on the ZHTP node.
Required Library Methods
Add these methods to src/core/zhtp-api-methods.ts:
1. Resolve Web4 Domain via DHT
/**
* Resolve Web4 domain via DHT network
* @param domain - Domain name (e.g., "example.zhtp")
*/
async resolveWeb4ViaDht(domain: string): Promise<DApp> {
return this.request<DApp>(`/api/v1/dht/web4/resolve/${domain}`);
}2. Get Contract from DHT
/**
* Get contract from DHT distributed storage
* @param contractId - Contract identifier
*/
async getContractFromDht(contractId: string): Promise<SmartContract> {
return this.request<SmartContract>(`/api/v1/dht/contract/${contractId}`);
}3. Get Contract by Blockchain Hash
/**
* Lookup contract by blockchain transaction hash
* @param transactionHash - Deployment transaction hash
*/
async getContractByHash(transactionHash: string): Promise<SmartContract> {
return this.request<SmartContract>(`/api/v1/blockchain/contract/${transactionHash}`);
}Existing Methods (Already Working)
These methods already exist and work with the node:
loadWeb4Resource(url: string)- CallsPOST /api/v1/web4/load✅resolveWeb4Domain(domain: string)- CallsGET /api/v1/web4/resolve/{domain}✅
Implementation
File: src/core/zhtp-api-methods.ts
Add the 3 new methods in the Web4/Contract section of the class.
Type Definitions
Ensure these types are defined in src/core/types.ts:
export interface DApp {
domain: string;
contract_id: string;
resolved_via?: string;
// ... other fields
}
export interface SmartContract {
contract_id: string;
bytecode: string;
metadata?: any;
transaction_hash?: string;
deployed_at?: number;
source?: string;
}Acceptance Criteria
-
resolveWeb4ViaDht()method added -
getContractFromDht()method added -
getContractByHash()method added - Proper TypeScript types defined
- JSDoc comments added
- Library builds successfully
- Methods will work once node implements endpoints
Dependencies
Blocked by: Node Issue #113 - Missing Web4/DHT resolution endpoints
The node must implement these endpoints first:
GET /api/v1/dht/web4/resolve/{domain}GET /api/v1/dht/contract/{id}GET /api/v1/blockchain/contract/{hash}
Priority
P1 - HIGH - Required for complete Web4/dApp functionality
Related
- Node Issue #113: Implementation of missing endpoints
- These methods complete the Web4 domain resolution feature set
Metadata
Metadata
Assignees
Labels
No labels