opentool 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -587,16 +587,30 @@ async function verifyX402Payment(attempt, definition, options = {}) {
587
587
  paymentRequirements: requirement
588
588
  })
589
589
  });
590
- if (settleResponse.ok) {
591
- const settlePayload = await settleResponse.json();
592
- if (settlePayload.txHash) {
593
- responseHeaders[HEADER_PAYMENT_RESPONSE] = JSON.stringify({
594
- settled: true,
595
- txHash: settlePayload.txHash
596
- });
597
- }
590
+ if (!settleResponse.ok) {
591
+ return {
592
+ success: false,
593
+ failure: {
594
+ reason: `Facilitator settlement failed: ${settleResponse.status}`,
595
+ code: "settlement_failed"
596
+ }
597
+ };
598
+ }
599
+ const settlePayload = await settleResponse.json();
600
+ if (settlePayload.txHash) {
601
+ responseHeaders[HEADER_PAYMENT_RESPONSE] = JSON.stringify({
602
+ settled: true,
603
+ txHash: settlePayload.txHash
604
+ });
598
605
  }
599
- } catch {
606
+ } catch (error) {
607
+ return {
608
+ success: false,
609
+ failure: {
610
+ reason: error instanceof Error ? error.message : "Settlement failed",
611
+ code: "settlement_failed"
612
+ }
613
+ };
600
614
  }
601
615
  }
602
616
  const result = {