@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/index.cjs CHANGED
@@ -1152,6 +1152,19 @@ async function payWithMpp(args) {
1152
1152
  }
1153
1153
  const requirements = await pickSuiExactRequirements(probe, client.network);
1154
1154
  if (requirements) {
1155
+ const { isX402EscrowRequirements } = await import('@suimpp/mpp/x402');
1156
+ if (isX402EscrowRequirements(requirements)) {
1157
+ const escrow = requirements.extra.escrow;
1158
+ const price = atomicToHuman(
1159
+ BigInt(requirements.maxAmountRequired),
1160
+ await assetDecimals(requirements.asset)
1161
+ );
1162
+ throw new exports.T2000Error(
1163
+ "ESCROW_REQUIRED",
1164
+ `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.`,
1165
+ { payTo: requirements.payTo, priceUsdc: price, escrow }
1166
+ );
1167
+ }
1155
1168
  const result = await payViaX402({ signer, client, options, reqInit, requirements });
1156
1169
  await reportDirectPayment(result, options.url);
1157
1170
  return result;
@@ -3163,8 +3176,9 @@ function hexToBytes2(hex) {
3163
3176
  return out;
3164
3177
  }
3165
3178
  function bytesToHex2(bytes) {
3179
+ const arr = typeof bytes === "string" ? Array.from(atob(bytes), (c) => c.charCodeAt(0)) : bytes;
3166
3180
  let s = "0x";
3167
- for (const b of bytes) s += b.toString(16).padStart(2, "0");
3181
+ for (const b of arr) s += b.toString(16).padStart(2, "0");
3168
3182
  return s;
3169
3183
  }
3170
3184
  function preflightCreateJob(terms) {