Skip to content

Commit 2b9eded

Browse files
authored
Update API paths to use /api/v1 prefix (#13)
- 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
1 parent f98bb20 commit 2b9eded

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/core/zhtp-api-methods.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
372372
// ==================== Network Operations ====================
373373

374374
async getNetworkInfo(): Promise<NetworkStatus> {
375-
return this.request<NetworkStatus>('/mesh/peers');
375+
return this.request<NetworkStatus>('/api/v1/blockchain/network/peers');
376376
}
377377

378378
// ==================== Wallet & Transaction Operations ====================
@@ -409,7 +409,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
409409
amount: number,
410410
metadata?: Record<string, any>
411411
): Promise<Transaction> {
412-
return this.request<Transaction>('/wallet/send', {
412+
return this.request<Transaction>('/api/v1/wallet/send', {
413413
method: 'POST',
414414
headers: { 'Content-Type': 'application/json' },
415415
body: JSON.stringify({ from, to, amount, metadata }),
@@ -419,7 +419,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
419419
// ==================== DAO Operations ====================
420420

421421
async getDaoProposals(): Promise<DaoProposal[]> {
422-
return this.request<DaoProposal[]>('/dao/proposals');
422+
return this.request<DaoProposal[]>('/api/v1/dao/proposals/list');
423423
}
424424

425425
async getDaoStats(): Promise<DaoStats> {
@@ -447,7 +447,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
447447
}
448448

449449
async createProposal(proposal: any): Promise<DaoProposal> {
450-
return this.request<DaoProposal>('/dao/proposals', {
450+
return this.request<DaoProposal>('/api/v1/dao/proposals', {
451451
method: 'POST',
452452
headers: { 'Content-Type': 'application/json' },
453453
body: JSON.stringify(proposal),
@@ -459,15 +459,15 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
459459
vote: boolean,
460460
voterDid: string
461461
): Promise<void> {
462-
await this.request<void>('/dao/vote', {
462+
await this.request<void>('/api/v1/dao/vote/cast', {
463463
method: 'POST',
464464
headers: { 'Content-Type': 'application/json' },
465465
body: JSON.stringify({ proposalId, vote, voterDid }),
466466
});
467467
}
468468

469469
async getDaoTreasury(): Promise<number> {
470-
const response = await this.request<any>('/dao/treasury');
470+
const response = await this.request<any>('/api/v1/dao/treasury/balance');
471471
return response?.balance || 0;
472472
}
473473

@@ -476,39 +476,39 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
476476
}
477477

478478
async getDaoData(): Promise<Record<string, any>> {
479-
return this.request<Record<string, any>>('/dao/data');
479+
return this.request<Record<string, any>>('/api/v1/dao/data');
480480
}
481481

482482
async getDaoDelegates(): Promise<Delegate[]> {
483-
return this.request<Delegate[]>('/dao/delegates');
483+
return this.request<Delegate[]>('/api/v1/dao/delegates');
484484
}
485485

486486
async getDelegateProfile(delegateId: string): Promise<Delegate> {
487487
return this.request<Delegate>(`/dao/delegates/${delegateId}`);
488488
}
489489

490490
async registerDelegate(userDid: string, delegateInfo: Record<string, any>): Promise<Delegate> {
491-
return this.request<Delegate>('/dao/delegates/register', {
491+
return this.request<Delegate>('/api/v1/dao/delegates/register', {
492492
method: 'POST',
493493
headers: { 'Content-Type': 'application/json' },
494494
body: JSON.stringify({ userDid, delegateInfo }),
495495
});
496496
}
497497

498498
async revokeDelegation(userDid: string): Promise<void> {
499-
await this.request<void>('/dao/delegates/revoke', {
499+
await this.request<void>('/api/v1/dao/delegates/revoke', {
500500
method: 'POST',
501501
headers: { 'Content-Type': 'application/json' },
502502
body: JSON.stringify({ userDid }),
503503
});
504504
}
505505

506506
async getTreasuryHistory(): Promise<TreasuryRecord[]> {
507-
return this.request<TreasuryRecord[]>('/dao/treasury/history');
507+
return this.request<TreasuryRecord[]>('/api/v1/dao/treasury/history');
508508
}
509509

510510
async createSpendingProposal(proposalData: Record<string, any>): Promise<DaoProposal> {
511-
return this.request<DaoProposal>('/dao/proposals/spending', {
511+
return this.request<DaoProposal>('/api/v1/dao/proposals/spending', {
512512
method: 'POST',
513513
headers: { 'Content-Type': 'application/json' },
514514
body: JSON.stringify(proposalData),
@@ -572,19 +572,19 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
572572
// ==================== Blockchain Operations ====================
573573

574574
async getBlockchainInfo(): Promise<any> {
575-
return this.request<any>('/blockchain/info');
575+
return this.request<any>('/api/v1/blockchain/status');
576576
}
577577

578578
async getGasInfo(): Promise<any> {
579-
return this.request<any>('/network/gas');
579+
return this.request<any>('/api/v1/network/gas');
580580
}
581581

582582
async getNodeStatus(): Promise<NodeStatus> {
583-
return this.request<NodeStatus>('/node/status');
583+
return this.request<NodeStatus>('/api/v1/protocol/info');
584584
}
585585

586586
async getMeshPeers(): Promise<{ peers: string[]; count: number }> {
587-
return this.request<{ peers: string[]; count: number }>('/mesh/peers');
587+
return this.request<{ peers: string[]; count: number }>('/api/v1/blockchain/network/peers');
588588
}
589589

590590
async getNetworkStats(): Promise<{
@@ -709,7 +709,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
709709

710710
async getProtocolInfo() {
711711
try {
712-
const response = await this.request<any>('/node/status');
712+
const response = await this.request<any>('/api/v1/protocol/info');
713713

714714
return {
715715
success: true,

0 commit comments

Comments
 (0)