@t2000/sdk 9.7.0 → 9.8.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/dist/browser.cjs CHANGED
@@ -556,6 +556,19 @@ async function payWithMpp(args) {
556
556
  }
557
557
  const requirements = await pickSuiExactRequirements(probe, client.network);
558
558
  if (requirements) {
559
+ const { isX402EscrowRequirements } = await import('@suimpp/mpp/x402');
560
+ if (isX402EscrowRequirements(requirements)) {
561
+ const escrow = requirements.extra.escrow;
562
+ const price = atomicToHuman(
563
+ BigInt(requirements.maxAmountRequired),
564
+ await assetDecimals(requirements.asset)
565
+ );
566
+ throw new exports.T2000Error(
567
+ "ESCROW_REQUIRED",
568
+ `This endpoint sells deliverable work through on-chain escrow, not an instant call. Create a job instead: t2 job create ${price} ${requirements.payTo} --spec <your-brief> \u2014 funds lock in a Job object and release on delivery. No payment was made.`,
569
+ { payTo: requirements.payTo, priceUsdc: price, escrow }
570
+ );
571
+ }
559
572
  const result = await payViaX402({ signer, client, options, reqInit, requirements });
560
573
  await reportDirectPayment(result, options.url);
561
574
  return result;
@@ -1344,8 +1357,9 @@ function hexToBytes(hex) {
1344
1357
  return out;
1345
1358
  }
1346
1359
  function bytesToHex(bytes) {
1360
+ const arr = typeof bytes === "string" ? Array.from(atob(bytes), (c) => c.charCodeAt(0)) : bytes;
1347
1361
  let s = "0x";
1348
- for (const b of bytes) s += b.toString(16).padStart(2, "0");
1362
+ for (const b of arr) s += b.toString(16).padStart(2, "0");
1349
1363
  return s;
1350
1364
  }
1351
1365
  function preflightCreateJob(terms) {