@medialane/sdk 0.119.0 → 0.119.2
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/starknet/index.cjs
CHANGED
|
@@ -12029,10 +12029,14 @@ function mintedTokenIdFromReceipt(receipt, contract) {
|
|
|
12029
12029
|
// src/starknet/services/sponsoredExecutor.ts
|
|
12030
12030
|
var SponsoredCallRejectedError = class extends Error {
|
|
12031
12031
|
};
|
|
12032
|
-
var
|
|
12033
|
-
|
|
12032
|
+
var USER_MAY_PAY = /* @__PURE__ */ new Set(["sponsor_unavailable", "credits_exhausted"]);
|
|
12033
|
+
function userMayPayInstead(code, status, stage) {
|
|
12034
|
+
if (code) return USER_MAY_PAY.has(code);
|
|
12035
|
+
return stage === "build" ? status >= 500 : status === 503;
|
|
12036
|
+
}
|
|
12037
|
+
async function failureOf(res, fallback) {
|
|
12034
12038
|
const body = await res.json().catch(() => null);
|
|
12035
|
-
return body?.error || fallback;
|
|
12039
|
+
return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
|
|
12036
12040
|
}
|
|
12037
12041
|
async function executeSponsored(config, signer, calls) {
|
|
12038
12042
|
const doFetch = config.fetchImpl ?? fetch;
|
|
@@ -12043,7 +12047,9 @@ async function executeSponsored(config, signer, calls) {
|
|
|
12043
12047
|
body: JSON.stringify({ userAddress: signer.address, calls })
|
|
12044
12048
|
});
|
|
12045
12049
|
if (!buildRes.ok) {
|
|
12046
|
-
|
|
12050
|
+
const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
|
|
12051
|
+
if (userMayPayInstead(code, buildRes.status, "build")) return { status: "unavailable", reason };
|
|
12052
|
+
throw new SponsoredCallRejectedError(reason);
|
|
12047
12053
|
}
|
|
12048
12054
|
const { typedData } = await buildRes.json();
|
|
12049
12055
|
const signature = await signer.signTypedData(typedData);
|
|
@@ -12053,8 +12059,8 @@ async function executeSponsored(config, signer, calls) {
|
|
|
12053
12059
|
body: JSON.stringify({ userAddress: signer.address, typedData, signature, calls })
|
|
12054
12060
|
});
|
|
12055
12061
|
if (!executeRes.ok) {
|
|
12056
|
-
const reason = await
|
|
12057
|
-
if (
|
|
12062
|
+
const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
|
|
12063
|
+
if (userMayPayInstead(code, executeRes.status, "execute")) {
|
|
12058
12064
|
return { status: "unavailable", reason };
|
|
12059
12065
|
}
|
|
12060
12066
|
throw new SponsoredCallRejectedError(reason);
|
|
@@ -12428,6 +12434,7 @@ exports.syncTransactionBestEffort = syncTransactionBestEffort;
|
|
|
12428
12434
|
exports.teamCoinsRaw = teamCoinsRaw;
|
|
12429
12435
|
exports.toDropContractConditions = toContractConditions;
|
|
12430
12436
|
exports.unsealPrivateKey = unsealPrivateKey;
|
|
12437
|
+
exports.userMayPayInstead = userMayPayInstead;
|
|
12431
12438
|
exports.validateCoinName = validateName;
|
|
12432
12439
|
exports.validateCoinSupply = validateSupply;
|
|
12433
12440
|
exports.validateCoinSymbol = validateSymbol;
|