From 9946e5b9e24ba30621fc3181c1098afb9fe877bb Mon Sep 17 00:00:00 2001 From: biwasbhandari Date: Fri, 29 Aug 2025 19:58:31 +0545 Subject: [PATCH 1/2] use preview url --- src/hooks/useAgentPermissions.ts | 3 ++- src/hooks/useContractApproval.ts | 3 ++- src/lib/vote-utils.ts | 11 ++++++----- src/services/vote.service.ts | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/hooks/useAgentPermissions.ts b/src/hooks/useAgentPermissions.ts index a0f59272..1b914ef5 100644 --- a/src/hooks/useAgentPermissions.ts +++ b/src/hooks/useAgentPermissions.ts @@ -13,7 +13,8 @@ export function useAgentPermissions(agentAddress: string | null) { const [contractAddress, contractName] = agentAddress.split("."); const res = await fetch( - `${process.env.NEXT_PUBLIC_CACHE_URL}/contract-calls/read-only/${contractAddress}/${contractName}/get-agent-permissions`, + // `${process.env.NEXT_PUBLIC_CACHE_URL}/contract-calls/read-only/${contractAddress}/${contractName}/get-agent-permissions`, + `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${contractAddress}/${contractName}/get-agent-permissions`, { method: "POST", headers: { diff --git a/src/hooks/useContractApproval.ts b/src/hooks/useContractApproval.ts index 9a902cb8..ec7a9efe 100644 --- a/src/hooks/useContractApproval.ts +++ b/src/hooks/useContractApproval.ts @@ -13,7 +13,8 @@ async function fetchApprovals( const results = await Promise.all( contractIds.map(async (targetContractId) => { const res = await fetch( - `${process.env.NEXT_PUBLIC_CACHE_URL}/contract-calls/read-only/${agentAddr}/${agentName}/is-approved-contract`, + // `${process.env.NEXT_PUBLIC_CACHE_URL}/contract-calls/read-only/${agentAddr}/${agentName}/is-approved-contract`, + `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${agentAddr}/${agentName}/get-agent-permissions`, { method: "POST", headers: { "Content-Type": "application/json" }, diff --git a/src/lib/vote-utils.ts b/src/lib/vote-utils.ts index 7f34e16e..73906afc 100644 --- a/src/lib/vote-utils.ts +++ b/src/lib/vote-utils.ts @@ -7,10 +7,10 @@ export function formatVotes(votes: number): string { return (votes / 1e8).toString(); } -const url = - process.env.NEXT_PUBLIC_STACKS_NETWORK === "testnet" - ? process.env.NEXT_PUBLIC_CACHE_URL_TESTNET - : process.env.NEXT_PUBLIC_CACHE_URL; +// const url = +// process.env.NEXT_PUBLIC_STACKS_NETWORK === "testnet" +// ? process.env.NEXT_PUBLIC_CACHE_URL_TESTNET +// : process.env.NEXT_PUBLIC_CACHE_URL; export async function getProposalVotes( contractPrincipal: string, @@ -26,7 +26,8 @@ export async function getProposalVotes( // Call the endpoint with POST method and the correct request body format const response = await fetch( - `${url}/contract-calls/read-only/${contractAddress}/${contractName}/get-proposal`, + // `${url}/contract-calls/read-only/${contractAddress}/${contractName}/get-proposal`, + `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${contractAddress}/${contractName}/get-agent-permissions`, { method: "POST", headers: { diff --git a/src/services/vote.service.ts b/src/services/vote.service.ts index 540195a5..4e8124a3 100644 --- a/src/services/vote.service.ts +++ b/src/services/vote.service.ts @@ -279,13 +279,14 @@ export async function getProposalVotes( const proposalIdString = proposalId.toString(); try { - const apiUrl = `${url}/contract-calls/read-only/${contractAddress}/${contractName}/get-proposal`; + // const apiUrl = `${url}/contract-calls/read-only/${contractAddress}/${contractName}/get-proposal`; + const apiUrl = `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${contractAddress}/${contractName}/get-agent-permissions`; const response = await fetch(apiUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ functionArgs: [{ type: "uint", value: proposalIdString }], - // Optional: Add cache control if the endpoint supports it + network: process.env.NEXT_PUBLIC_STACKS_NETWORK, cacheControl: bustCache ? { bustCache: true, ttl: 3600 } : undefined, }), }); From 48e99a656ba62510ff83f88a65cda651c8dd6bcf Mon Sep 17 00:00:00 2001 From: biwasbhandari Date: Fri, 29 Aug 2025 20:12:23 +0545 Subject: [PATCH 2/2] update --- src/hooks/useAgentPermissions.ts | 2 +- src/hooks/useContractApproval.ts | 2 +- src/lib/vote-utils.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/useAgentPermissions.ts b/src/hooks/useAgentPermissions.ts index 1b914ef5..416354bc 100644 --- a/src/hooks/useAgentPermissions.ts +++ b/src/hooks/useAgentPermissions.ts @@ -14,7 +14,7 @@ export function useAgentPermissions(agentAddress: string | null) { const [contractAddress, contractName] = agentAddress.split("."); const res = await fetch( // `${process.env.NEXT_PUBLIC_CACHE_URL}/contract-calls/read-only/${contractAddress}/${contractName}/get-agent-permissions`, - `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${contractAddress}/${contractName}/get-agent-permissions`, + `https://aibtcdev-cache-preview.hosting-962.workers.dev/contract-calls/read-only/${contractAddress}/${contractName}/get-agent-permissions`, { method: "POST", headers: { diff --git a/src/hooks/useContractApproval.ts b/src/hooks/useContractApproval.ts index ec7a9efe..ad66e174 100644 --- a/src/hooks/useContractApproval.ts +++ b/src/hooks/useContractApproval.ts @@ -14,7 +14,7 @@ async function fetchApprovals( contractIds.map(async (targetContractId) => { const res = await fetch( // `${process.env.NEXT_PUBLIC_CACHE_URL}/contract-calls/read-only/${agentAddr}/${agentName}/is-approved-contract`, - `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${agentAddr}/${agentName}/get-agent-permissions`, + `https://aibtcdev-cache-preview.hosting-962.workers.dev/contract-calls/read-only/${agentAddr}/${agentName}/get-agent-permissions`, { method: "POST", headers: { "Content-Type": "application/json" }, diff --git a/src/lib/vote-utils.ts b/src/lib/vote-utils.ts index 73906afc..97cd1630 100644 --- a/src/lib/vote-utils.ts +++ b/src/lib/vote-utils.ts @@ -27,7 +27,7 @@ export async function getProposalVotes( // Call the endpoint with POST method and the correct request body format const response = await fetch( // `${url}/contract-calls/read-only/${contractAddress}/${contractName}/get-proposal`, - `https://aibtcdev-cache-preview.hosting-962.workers.dev/read-only/${contractAddress}/${contractName}/get-agent-permissions`, + `https://aibtcdev-cache-preview.hosting-962.workers.dev/contract-calls/read-only/${contractAddress}/${contractName}/get-agent-permissions`, { method: "POST", headers: {