浏览代码

fix: 复制失败

zhangchunrui 1 周之前
父节点
当前提交
c22f842169
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/copy/index.ts

+ 5 - 1
src/copy/index.ts

@@ -49,7 +49,11 @@ export async function copyPosition(positionDetails: OpenPositionEvent['positionD
 			positionAddress,
 			maxUsdValue,
 		}),
-	}).then(res => res.json()).then(() => {
+	}).then(res => res.json()).then((response: unknown) => {
+		const data = response as { ok?: boolean, error?: string }
+		if (!data.ok) {
+			throw new Error(data.error ?? 'Failed to copy position')
+		}
 		console.log(`[${Date.now()}] 复制仓位成功`)
 		// 发送Discord通知,使用embeds
 		const solscanBaseUrl = 'https://solscan.io'