Skip to content

Commit 1bbcbdc

Browse files
committed
#623 [Frontend] StreamCreationWizard.startPolling hits wrong URL and wrong shape
1 parent cb53cc6 commit 1bbcbdc

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

frontend/src/components/stream-creation/StreamCreationWizard.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { fetchTokenBalanceDisplay } from "@/lib/soroban";
1414
import { isValidStellarPublicKey } from "@/lib/stellar";
1515
import toast from "react-hot-toast";
1616
import { useRouter } from "next/navigation";
17+
import { getApiBaseUrl } from "@/lib/api/_shared";
1718

1819
export interface StreamFormData {
1920
recipient: string;
@@ -349,18 +350,20 @@ export const StreamCreationWizard: React.FC<StreamCreationWizardProps> = ({
349350
const startTime = Date.now();
350351
const TIMEOUT_MS = 30000; // 30 seconds
351352
const POLL_INTERVAL = 2000; // 2 seconds
353+
const baseUrl = getApiBaseUrl();
352354

353355
while (Date.now() - startTime < TIMEOUT_MS) {
354356
try {
355-
const response = await fetch(`/v1/streams?sender=${senderAddress}`);
356-
const streams = await response.json();
357+
const response = await fetch(`${baseUrl}/v1/streams?sender=${senderAddress}`);
358+
const payload = await response.json();
359+
const streams = Array.isArray(payload) ? payload : (payload.data ?? []);
357360

358361
// Assuming the latest stream is what we want
359362
if (streams && streams.length > 0) {
360363
// Found!
361364
const newStream = streams[0]; // Simplification
362365
toast.success("Stream indexed and confirmed!");
363-
router.push(`/app/streams/${newStream.streamId}`); // Updated path to match new structure
366+
router.push(`/streams/${newStream.streamId}`); // Updated path to match new structure
364367
return;
365368
}
366369
} catch (e) {
@@ -384,7 +387,7 @@ export const StreamCreationWizard: React.FC<StreamCreationWizardProps> = ({
384387

385388
// Step 2: Start Polling for Indexer
386389
setIsPolling(true);
387-
await startPolling(formData.recipient);
390+
await startPolling(walletPublicKey || "");
388391

389392
} catch (error) {
390393
logger.error("Failed to create stream:", error);

0 commit comments

Comments
 (0)