@rozoai/checkout 0.1.1 → 0.1.3
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/README.md +137 -12
- package/docs/QUICKSTART.es.md +128 -11
- package/docs/QUICKSTART.ja.md +110 -11
- package/docs/QUICKSTART.md +126 -12
- package/docs/QUICKSTART.zh.md +99 -11
- package/docs/README.es.md +114 -9
- package/docs/README.ja.md +98 -9
- package/docs/README.zh.md +90 -10
- package/docs/safety.md +7 -3
- package/llms.txt +45 -3
- package/package.json +1 -1
- package/scripts/dist/cli.js +803 -295
- package/scripts/dist/create-order.js +53 -2
- package/scripts/dist/quote.js +4 -0
- package/scripts/dist/send-evm.js +6699 -6237
- package/scripts/dist/send-sol.js +1731 -634
- package/scripts/dist/status.js +39 -1
package/scripts/dist/status.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __rozoCreateRequire } from 'node:module';
|
|
3
|
+
import { fileURLToPath as __rozoFileURLToPath } from 'node:url';
|
|
4
|
+
import { dirname as __rozoDirname } from 'node:path';
|
|
3
5
|
const require = __rozoCreateRequire(import.meta.url);
|
|
6
|
+
const __filename = __rozoFileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __rozoDirname(__filename);
|
|
4
8
|
|
|
5
9
|
// scripts/src/lib/output.mjs
|
|
6
10
|
var EXIT_OK = 0;
|
|
@@ -428,6 +432,30 @@ function classifyStatus({ payment, routerState, coinbase, now = Date.now(), view
|
|
|
428
432
|
);
|
|
429
433
|
}
|
|
430
434
|
|
|
435
|
+
// scripts/src/lib/expiry.mjs
|
|
436
|
+
var MINUTE = 6e4;
|
|
437
|
+
var MARGINS_MS = {
|
|
438
|
+
1: 10 * MINUTE,
|
|
439
|
+
56: 10 * MINUTE,
|
|
440
|
+
137: 10 * MINUTE,
|
|
441
|
+
8453: 10 * MINUTE,
|
|
442
|
+
900: 5 * MINUTE,
|
|
443
|
+
1500: 10 * MINUTE,
|
|
444
|
+
lightning: 10 * MINUTE
|
|
445
|
+
};
|
|
446
|
+
var BOLT11_MIN_VALIDITY_MS = 10 * MINUTE;
|
|
447
|
+
var DEFAULT_MARGIN_MS = 10 * MINUTE;
|
|
448
|
+
function formatRemaining(ms) {
|
|
449
|
+
if (!Number.isFinite(ms)) return "unknown";
|
|
450
|
+
if (ms <= 0) return "expired";
|
|
451
|
+
const totalMinutes = Math.floor(ms / 6e4);
|
|
452
|
+
if (totalMinutes < 1) return `${Math.floor(ms / 1e3)}s`;
|
|
453
|
+
if (totalMinutes < 60) return `${totalMinutes}m`;
|
|
454
|
+
const h = Math.floor(totalMinutes / 60);
|
|
455
|
+
const m = totalMinutes % 60;
|
|
456
|
+
return m ? `${h}h ${m}m` : `${h}h`;
|
|
457
|
+
}
|
|
458
|
+
|
|
431
459
|
// scripts/src/lib/state.mjs
|
|
432
460
|
import fs from "node:fs";
|
|
433
461
|
import path from "node:path";
|
|
@@ -519,6 +547,16 @@ async function snapshot({ rozoPaymentId, linkId }) {
|
|
|
519
547
|
senderAddressMasked: source.senderAddress ? maskAddress(source.senderAddress) : null,
|
|
520
548
|
chain: source.chainId ? chainName(source.chainId) : null
|
|
521
549
|
},
|
|
550
|
+
expiry: (() => {
|
|
551
|
+
const iso = payment?.expiresAt ?? status?.rozoPayment?.expiresAt ?? null;
|
|
552
|
+
if (!iso) return { expiresAt: null, expiresIn: null, msRemaining: null };
|
|
553
|
+
const ms = Date.parse(iso) - Date.now();
|
|
554
|
+
return {
|
|
555
|
+
expiresAt: iso,
|
|
556
|
+
expiresIn: formatRemaining(ms),
|
|
557
|
+
msRemaining: Number.isFinite(ms) ? ms : null
|
|
558
|
+
};
|
|
559
|
+
})(),
|
|
522
560
|
payout: {
|
|
523
561
|
txHash: payment?.destination?.txHash ?? status?.rozoPayment?.destination?.txHash ?? null,
|
|
524
562
|
confirmedAt: payment?.destination?.confirmedAt ?? status?.rozoPayment?.destination?.confirmedAt ?? null
|
|
@@ -544,7 +582,7 @@ async function main(argv) {
|
|
|
544
582
|
if (next.state !== result.state) history.push({ at: (/* @__PURE__ */ new Date()).toISOString(), state: next.state });
|
|
545
583
|
result = next;
|
|
546
584
|
}
|
|
547
|
-
const guidance = result.escalate ? "MONEY DETECTED and the order is not on a healthy path. Do NOT pay again and do NOT create a new order for this link. Preserve linkId, rozoPaymentId and every tx hash, then escalate to the operator for manual reconciliation." : result.unknown ? "The order state could not be established. This is NOT evidence that nothing was paid \u2014 do not create a new order and do not send again on the strength of it. Retry, or pass --rozo-payment-id so the authoritative pay-in view can be read." : !result.authoritativeView ? "Only the fulfilment view was readable; the pay-in view is unavailable, so the money-detected rule cannot be enforced. Pass --rozo-payment-id for a complete answer." : result.state === "expired_unfunded" ? "Nothing was funded.
|
|
585
|
+
const guidance = result.escalate ? "MONEY DETECTED and the order is not on a healthy path. Do NOT pay again and do NOT create a new order for this link. Preserve linkId, rozoPaymentId and every tx hash, then escalate to the operator for manual reconciliation." : result.unknown ? "The order state could not be established. This is NOT evidence that nothing was paid \u2014 do not create a new order and do not send again on the strength of it. Retry, or pass --rozo-payment-id so the authoritative pay-in view can be read." : !result.authoritativeView ? "Only the fulfilment view was readable; the pay-in view is unavailable, so the money-detected rule cannot be enforced. Pass --rozo-payment-id for a complete answer." : result.state === "expired_unfunded" ? "Nothing was funded, so nothing was lost. Start a fresh order with: rozo-checkout pay <coinbase-link> --with <coin> (or create-order.js --url <link> --chain <id> --token <SYMBOL>)" : result.terminal ? "Done." : "Still in flight. Poll again in ~10s.";
|
|
548
586
|
const unresolved = watch && !result.terminal && !result.escalate && !result.unknown;
|
|
549
587
|
const failed = result.escalate || result.unknown || !result.authoritativeView;
|
|
550
588
|
emit(
|