From 68f502b32710a54c224ef0fd043c46316c4c0082 Mon Sep 17 00:00:00 2001 From: supertramp Date: Tue, 2 Dec 2025 22:56:19 +0000 Subject: [PATCH] Update API paths to use /api/v1 prefix - Update all endpoint paths to use /api/v1 versioned API - DAO endpoints: proposals, voting, treasury, delegates - Blockchain endpoints: status, network peers - Protocol endpoints: node status/info - Network endpoints: gas info - Wallet endpoints: send transactions Fixes #7 --- src/core/zhtp-api-methods.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/core/zhtp-api-methods.ts b/src/core/zhtp-api-methods.ts index 2a7da67..14742d6 100644 --- a/src/core/zhtp-api-methods.ts +++ b/src/core/zhtp-api-methods.ts @@ -372,7 +372,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { // ==================== Network Operations ==================== async getNetworkInfo(): Promise { - return this.request('/mesh/peers'); + return this.request('/api/v1/blockchain/network/peers'); } // ==================== Wallet & Transaction Operations ==================== @@ -409,7 +409,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { amount: number, metadata?: Record ): Promise { - return this.request('/wallet/send', { + return this.request('/api/v1/wallet/send', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ from, to, amount, metadata }), @@ -419,7 +419,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { // ==================== DAO Operations ==================== async getDaoProposals(): Promise { - return this.request('/dao/proposals'); + return this.request('/api/v1/dao/proposals/list'); } async getDaoStats(): Promise { @@ -447,7 +447,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { } async createProposal(proposal: any): Promise { - return this.request('/dao/proposals', { + return this.request('/api/v1/dao/proposals', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(proposal), @@ -459,7 +459,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { vote: boolean, voterDid: string ): Promise { - await this.request('/dao/vote', { + await this.request('/api/v1/dao/vote/cast', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ proposalId, vote, voterDid }), @@ -467,7 +467,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { } async getDaoTreasury(): Promise { - const response = await this.request('/dao/treasury'); + const response = await this.request('/api/v1/dao/treasury/balance'); return response?.balance || 0; } @@ -476,11 +476,11 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { } async getDaoData(): Promise> { - return this.request>('/dao/data'); + return this.request>('/api/v1/dao/data'); } async getDaoDelegates(): Promise { - return this.request('/dao/delegates'); + return this.request('/api/v1/dao/delegates'); } async getDelegateProfile(delegateId: string): Promise { @@ -488,7 +488,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { } async registerDelegate(userDid: string, delegateInfo: Record): Promise { - return this.request('/dao/delegates/register', { + return this.request('/api/v1/dao/delegates/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ userDid, delegateInfo }), @@ -496,7 +496,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { } async revokeDelegation(userDid: string): Promise { - await this.request('/dao/delegates/revoke', { + await this.request('/api/v1/dao/delegates/revoke', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ userDid }), @@ -504,11 +504,11 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { } async getTreasuryHistory(): Promise { - return this.request('/dao/treasury/history'); + return this.request('/api/v1/dao/treasury/history'); } async createSpendingProposal(proposalData: Record): Promise { - return this.request('/dao/proposals/spending', { + return this.request('/api/v1/dao/proposals/spending', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(proposalData), @@ -572,19 +572,19 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { // ==================== Blockchain Operations ==================== async getBlockchainInfo(): Promise { - return this.request('/blockchain/info'); + return this.request('/api/v1/blockchain/status'); } async getGasInfo(): Promise { - return this.request('/network/gas'); + return this.request('/api/v1/network/gas'); } async getNodeStatus(): Promise { - return this.request('/node/status'); + return this.request('/api/v1/protocol/info'); } async getMeshPeers(): Promise<{ peers: string[]; count: number }> { - return this.request<{ peers: string[]; count: number }>('/mesh/peers'); + return this.request<{ peers: string[]; count: number }>('/api/v1/blockchain/network/peers'); } async getNetworkStats(): Promise<{ @@ -709,7 +709,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore { async getProtocolInfo() { try { - const response = await this.request('/node/status'); + const response = await this.request('/api/v1/protocol/info'); return { success: true,