@t2000/sdk 9.3.0 → 9.3.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/browser.cjs CHANGED
@@ -531,11 +531,18 @@ function preflightPay(input) {
531
531
  return PREFLIGHT_OK;
532
532
  }
533
533
  async function payWithMpp(args) {
534
- const { signer, client, options } = args;
534
+ const { signer, client } = args;
535
+ let options = args.options;
535
536
  const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
536
537
  if (!pf.valid) throw new exports.T2000Error(pf.code, pf.error);
537
538
  const method = (options.method ?? "GET").toUpperCase();
538
539
  const canHaveBody = method !== "GET" && method !== "HEAD";
540
+ if (canHaveBody && typeof options.body === "string" && isJsonText(options.body) && !hasContentType(options.headers)) {
541
+ options = {
542
+ ...options,
543
+ headers: { ...options.headers ?? {}, "content-type": "application/json" }
544
+ };
545
+ }
539
546
  const reqInit = {
540
547
  method,
541
548
  headers: options.headers,
@@ -722,6 +729,18 @@ async function ensureAddressBalanceCovers(args) {
722
729
  const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
723
730
  return migration.gasCostSui;
724
731
  }
732
+ function isJsonText(text) {
733
+ try {
734
+ JSON.parse(text);
735
+ return true;
736
+ } catch {
737
+ return false;
738
+ }
739
+ }
740
+ function hasContentType(headers) {
741
+ if (!headers) return false;
742
+ return Object.keys(headers).some((k) => k.toLowerCase() === "content-type");
743
+ }
725
744
  async function finalize(response, opts) {
726
745
  const contentType = response.headers.get("content-type") ?? "";
727
746
  let body;