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