Skip to content

Commit 0c0b970

Browse files
committed
fix: resolve type safety issues #678 #679 #680 #681
1 parent 0041b03 commit 0c0b970

4 files changed

Lines changed: 43 additions & 14 deletions

File tree

.gitignore

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ contracts/**/test_snapshots/
2626
coverage/
2727

2828
# TypeScript build info cache
29-
tsconfig.tsbuildinfo
29+
*.tsbuildinfo
3030

3131
# Playwright test results and reports
3232
test-results/
@@ -47,3 +47,22 @@ pnpm-lock.yaml
4747
.vscode/
4848
.DS_Store
4949
Thumbs.db
50+
51+
# Build output
52+
dist/
53+
54+
# Monorepo / Turborepo cache
55+
.turbo/
56+
57+
# Broader env file catch
58+
*.local
59+
.env
60+
61+
# Storybook static output
62+
storybook-static/
63+
64+
# Istanbul / NYC coverage output
65+
.nyc_output/
66+
67+
# CI test reports
68+
junit.xml

hooks/use-contract.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ function showErrorToast(err: unknown, toastId?: string | number) {
3838
duration: 7000,
3939
...(toastId ? { id: toastId } : {}),
4040
action: mapped.details
41-
? {
42-
label: "Details",
43-
onClick: () => {
44-
const short =
45-
mapped.details!.length > 200
46-
? mapped.details!.slice(0, 200) + "…"
47-
: mapped.details!;
48-
toast.info(short, { duration: 10000 });
49-
},
50-
}
41+
? (() => {
42+
const details = mapped.details;
43+
return {
44+
label: "Details",
45+
onClick: () => {
46+
const short =
47+
details.length > 200
48+
? details.slice(0, 200) + "…"
49+
: details;
50+
toast.info(short, { duration: 10000 });
51+
},
52+
};
53+
})()
5154
: undefined,
5255
};
5356
toast.error(mapped.message, opts);

hooks/use-webhooks.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ const STORAGE_KEY = 'flowstar_webhooks'
3030
const HISTORY_KEY = 'flowstar_webhook_history'
3131
const MAX_HISTORY = 50
3232

33+
export interface WebhookPayload {
34+
event: WebhookEventType | string
35+
timestamp: string
36+
data: Record<string, unknown>
37+
}
38+
3339
function loadWebhooks(): WebhookConfig[] {
3440
if (typeof window === 'undefined') return []
3541
try {
@@ -58,7 +64,7 @@ function saveHistory(history: WebhookDelivery[]) {
5864

5965
async function deliverWithRetry(
6066
url: string,
61-
payload: object,
67+
payload: WebhookPayload,
6268
retries = 3
6369
): Promise<{ statusCode: number | null; success: boolean }> {
6470
for (let attempt = 0; attempt < retries; attempt++) {
@@ -120,7 +126,7 @@ export function useWebhooks() {
120126
}, [])
121127

122128
const fireEvent = useCallback(
123-
async (eventType: WebhookEventType, data: object) => {
129+
async (eventType: WebhookEventType, data: WebhookPayload) => {
124130
const active = webhooks.filter((h) => h.enabled && h.events.includes(eventType))
125131
for (const hook of active) {
126132
const payload = { event: eventType, timestamp: new Date().toISOString(), data }

lib/contract.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ async function invoke(
181181
error?: { message: string }
182182
}
183183
if (pollJson.error) throw new Error(`Poll failed: ${pollJson.error.message}`)
184-
pollStatus = pollJson.result!.status
184+
if (!pollJson.result) continue
185+
pollStatus = pollJson.result.status
185186
}
186187

187188
if (pollStatus === 'FAILED') throw new Error('Transaction failed on-chain')

0 commit comments

Comments
 (0)