@t2000/sdk 10.16.0 → 10.17.0
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 +1 -1
- package/dist/browser.cjs +0 -17
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +0 -17
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +5 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +4 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ const agent = T2000.fromPrivateKey('suiprivkey1…'); // in-memory load (no fi
|
|
|
26
26
|
|
|
27
27
|
await agent.send({ to: 'alice.sui', amount: 5, asset: 'USDC' }); // gasless
|
|
28
28
|
await agent.swap({ from: 'USDC', to: 'SUI', amount: 100 }); // Cetus, needs SUI
|
|
29
|
-
await agent.pay({ url: 'https://
|
|
29
|
+
await agent.pay({ url: 'https://api.seller.example/v1/chat', method: 'POST', body, maxPrice: 0.10 });
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
USDC + USDsui sends and x402 USDC payments are gasless (Sui foundation's `0x2::balance::send_funds` sponsor). SUI sends and Cetus swaps need gas — keep ~0.05 SUI on hand.
|
package/dist/browser.cjs
CHANGED
|
@@ -572,7 +572,6 @@ async function payWithMpp(args) {
|
|
|
572
572
|
}
|
|
573
573
|
assertNotSelfPayment(signer.getAddress(), requirements.payTo);
|
|
574
574
|
const result = await payViaX402({ signer, client, options, reqInit, requirements });
|
|
575
|
-
await reportDirectPayment(result, options.url);
|
|
576
575
|
return result;
|
|
577
576
|
}
|
|
578
577
|
const headerChallenge = await parseMppSuiChallenge(probe);
|
|
@@ -586,7 +585,6 @@ async function payWithMpp(args) {
|
|
|
586
585
|
}
|
|
587
586
|
assertNotSelfPayment(signer.getAddress(), headerChallenge.recipient);
|
|
588
587
|
const result = await payViaMppHeader({ signer, client, options });
|
|
589
|
-
await reportDirectPayment(result, options.url);
|
|
590
588
|
return result;
|
|
591
589
|
}
|
|
592
590
|
if (pick.kind === "incomplete") {
|
|
@@ -601,21 +599,6 @@ async function payWithMpp(args) {
|
|
|
601
599
|
`Endpoint returned 402 without an x402 'exact' / sui:${client.network} requirement in the body or an MPP 'sui' challenge in WWW-Authenticate. Nothing this SDK can pay.`
|
|
602
600
|
);
|
|
603
601
|
}
|
|
604
|
-
var MPP_REPORT_URL = "https://mpp.t2000.ai/api/mpp/report";
|
|
605
|
-
var REPORT_TIMEOUT_MS = 2e3;
|
|
606
|
-
async function reportDirectPayment(result, url) {
|
|
607
|
-
if (!result.paid || !result.receipt?.reference) return;
|
|
608
|
-
try {
|
|
609
|
-
if (new URL(url).origin === new URL(MPP_REPORT_URL).origin) return;
|
|
610
|
-
await fetch(MPP_REPORT_URL, {
|
|
611
|
-
method: "POST",
|
|
612
|
-
headers: { "content-type": "application/json" },
|
|
613
|
-
body: JSON.stringify({ digest: result.receipt.reference, url }),
|
|
614
|
-
signal: AbortSignal.timeout(REPORT_TIMEOUT_MS)
|
|
615
|
-
});
|
|
616
|
-
} catch {
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
602
|
async function parseMppSuiChallenge(response) {
|
|
620
603
|
try {
|
|
621
604
|
const { Challenge } = await import('mppx');
|