@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/index.js
CHANGED
|
@@ -1122,11 +1122,18 @@ function preflightPay(input) {
|
|
|
1122
1122
|
return PREFLIGHT_OK;
|
|
1123
1123
|
}
|
|
1124
1124
|
async function payWithMpp(args) {
|
|
1125
|
-
const { signer, client
|
|
1125
|
+
const { signer, client } = args;
|
|
1126
|
+
let options = args.options;
|
|
1126
1127
|
const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
|
|
1127
1128
|
if (!pf.valid) throw new T2000Error(pf.code, pf.error);
|
|
1128
1129
|
const method = (options.method ?? "GET").toUpperCase();
|
|
1129
1130
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
1131
|
+
if (canHaveBody && typeof options.body === "string" && isJsonText(options.body) && !hasContentType(options.headers)) {
|
|
1132
|
+
options = {
|
|
1133
|
+
...options,
|
|
1134
|
+
headers: { ...options.headers ?? {}, "content-type": "application/json" }
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1130
1137
|
const reqInit = {
|
|
1131
1138
|
method,
|
|
1132
1139
|
headers: options.headers,
|
|
@@ -1313,6 +1320,18 @@ async function ensureAddressBalanceCovers(args) {
|
|
|
1313
1320
|
const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
|
|
1314
1321
|
return migration.gasCostSui;
|
|
1315
1322
|
}
|
|
1323
|
+
function isJsonText(text) {
|
|
1324
|
+
try {
|
|
1325
|
+
JSON.parse(text);
|
|
1326
|
+
return true;
|
|
1327
|
+
} catch {
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
function hasContentType(headers) {
|
|
1332
|
+
if (!headers) return false;
|
|
1333
|
+
return Object.keys(headers).some((k) => k.toLowerCase() === "content-type");
|
|
1334
|
+
}
|
|
1316
1335
|
async function finalize(response, opts) {
|
|
1317
1336
|
const contentType = response.headers.get("content-type") ?? "";
|
|
1318
1337
|
let body2;
|