Skip to content

Commit 5e33c29

Browse files
authored
Update smart contract endpoints to canonical paths (#14)
- Deploy: /api/v1/contract/deploy → /api/v1/blockchain/contracts/deploy - Execute: /api/v1/contract/execute → /api/v1/blockchain/contracts/{id}/call - Move contractId from request body to URL path - Query: POST /api/v1/contract/query/{id} → GET /api/v1/blockchain/contracts/{id}/state - Change from POST to GET method - Simplify to retrieve contract state directly Uses canonical /blockchain/contracts/* paths for consistency with ZHTP node implementation. Fixes #8
1 parent 2b9eded commit 5e33c29

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/core/zhtp-api-methods.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
618618
contractData: SmartContract,
619619
options?: Record<string, any>
620620
): Promise<ContractDeploymentResult> {
621-
return this.request<ContractDeploymentResult>('/api/v1/contract/deploy', {
621+
return this.request<ContractDeploymentResult>('/api/v1/blockchain/contracts/deploy', {
622622
method: 'POST',
623623
headers: { 'Content-Type': 'application/json' },
624624
body: JSON.stringify({ ...contractData, ...options }),
@@ -630,10 +630,10 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
630630
functionName: string,
631631
args?: any[]
632632
): Promise<ContractExecutionResult> {
633-
return this.request<ContractExecutionResult>('/api/v1/contract/execute', {
633+
return this.request<ContractExecutionResult>(`/api/v1/blockchain/contracts/${contractId}/call`, {
634634
method: 'POST',
635635
headers: { 'Content-Type': 'application/json' },
636-
body: JSON.stringify({ contractId, functionName, args }),
636+
body: JSON.stringify({ functionName, args }),
637637
});
638638
}
639639

@@ -642,14 +642,8 @@ export abstract class ZhtpApiMethods extends ZhtpApiCore {
642642
functionName?: string,
643643
args?: any[]
644644
): Promise<Record<string, any>> {
645-
let endpoint = `/api/v1/contract/query/${contractId}`;
646-
if (functionName) {
647-
endpoint += `/${functionName}`;
648-
}
649-
return this.request<Record<string, any>>(endpoint, {
650-
method: 'POST',
651-
headers: { 'Content-Type': 'application/json' },
652-
body: JSON.stringify({ args }),
645+
return this.request<Record<string, any>>(`/api/v1/blockchain/contracts/${contractId}/state`, {
646+
method: 'GET',
653647
});
654648
}
655649

0 commit comments

Comments
 (0)