@t2000/cli 10.21.0 → 10.21.1
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/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -28578,6 +28578,23 @@ async function executeTx(client, signer, buildTx, options = {}) {
|
|
|
28578
28578
|
return { digest: txn.digest, gasCostSui, effects };
|
|
28579
28579
|
}
|
|
28580
28580
|
init_errors();
|
|
28581
|
+
var DEFAULT_ACTIVITY_REPORT_URL = "https://t2000.ai/api/activity/x402";
|
|
28582
|
+
function resolveActivityReportUrl(override) {
|
|
28583
|
+
if (override) return override;
|
|
28584
|
+
const env = typeof process !== "undefined" && process.env ? process.env.T2000_ACTIVITY_REPORT_URL?.trim() : void 0;
|
|
28585
|
+
return env && env.length > 0 ? env : DEFAULT_ACTIVITY_REPORT_URL;
|
|
28586
|
+
}
|
|
28587
|
+
function reportX402Activity(payload, url) {
|
|
28588
|
+
try {
|
|
28589
|
+
void fetch(resolveActivityReportUrl(url), {
|
|
28590
|
+
method: "POST",
|
|
28591
|
+
headers: { "content-type": "application/json" },
|
|
28592
|
+
body: JSON.stringify(payload),
|
|
28593
|
+
signal: AbortSignal.timeout(1500)
|
|
28594
|
+
}).catch(() => void 0);
|
|
28595
|
+
} catch {
|
|
28596
|
+
}
|
|
28597
|
+
}
|
|
28581
28598
|
init_preflight();
|
|
28582
28599
|
function preflightPay(input) {
|
|
28583
28600
|
if (typeof input.url !== "string" || input.url.trim() === "") {
|
|
@@ -28720,6 +28737,21 @@ async function payViaX402(args) {
|
|
|
28720
28737
|
}
|
|
28721
28738
|
const result = await finalize(res, { paid });
|
|
28722
28739
|
if (!paid) return { ...result, dialect: "x402" };
|
|
28740
|
+
if (digest && options.activityReport !== false) {
|
|
28741
|
+
const report = options.activityReport || {};
|
|
28742
|
+
reportX402Activity(
|
|
28743
|
+
{
|
|
28744
|
+
digest,
|
|
28745
|
+
payTo: requirements.payTo,
|
|
28746
|
+
payer: signer.getAddress(),
|
|
28747
|
+
amountMicroUsdc: Number(amountRaw),
|
|
28748
|
+
network: requirements.network,
|
|
28749
|
+
route: options.url,
|
|
28750
|
+
source: report.source ?? "pay"
|
|
28751
|
+
},
|
|
28752
|
+
report.url
|
|
28753
|
+
);
|
|
28754
|
+
}
|
|
28723
28755
|
return {
|
|
28724
28756
|
...result,
|
|
28725
28757
|
dialect: "x402",
|