@medialane/sdk 0.99.1 → 0.100.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/starknet/index.cjs
CHANGED
|
@@ -11544,6 +11544,43 @@ async function requestSiwsToken({
|
|
|
11544
11544
|
storeSiwsToken(walletAddress, token);
|
|
11545
11545
|
return token;
|
|
11546
11546
|
}
|
|
11547
|
+
|
|
11548
|
+
// src/starknet/services/sponsoredExecutor.ts
|
|
11549
|
+
var SponsoredCallRejectedError = class extends Error {
|
|
11550
|
+
};
|
|
11551
|
+
var PRE_BROADCAST_EXECUTE_STATUSES = /* @__PURE__ */ new Set([400, 429, 503]);
|
|
11552
|
+
async function errorReason(res, fallback) {
|
|
11553
|
+
const body = await res.json().catch(() => null);
|
|
11554
|
+
return body?.error || fallback;
|
|
11555
|
+
}
|
|
11556
|
+
async function executeSponsored(config, signer, calls) {
|
|
11557
|
+
const doFetch = config.fetchImpl ?? fetch;
|
|
11558
|
+
const base = config.proxyUrl.replace(/\/$/, "");
|
|
11559
|
+
const buildRes = await doFetch(`${base}/build`, {
|
|
11560
|
+
method: "POST",
|
|
11561
|
+
headers: { "Content-Type": "application/json" },
|
|
11562
|
+
body: JSON.stringify({ userAddress: signer.address, calls })
|
|
11563
|
+
});
|
|
11564
|
+
if (!buildRes.ok) {
|
|
11565
|
+
return { status: "unavailable", reason: await errorReason(buildRes, "We couldn't prepare this transaction.") };
|
|
11566
|
+
}
|
|
11567
|
+
const { typedData } = await buildRes.json();
|
|
11568
|
+
const signature = await signer.signTypedData(typedData);
|
|
11569
|
+
const executeRes = await doFetch(`${base}/execute`, {
|
|
11570
|
+
method: "POST",
|
|
11571
|
+
headers: { "Content-Type": "application/json" },
|
|
11572
|
+
body: JSON.stringify({ userAddress: signer.address, typedData, signature, calls })
|
|
11573
|
+
});
|
|
11574
|
+
if (!executeRes.ok) {
|
|
11575
|
+
const reason = await errorReason(executeRes, "We couldn't submit this transaction.");
|
|
11576
|
+
if (PRE_BROADCAST_EXECUTE_STATUSES.has(executeRes.status)) {
|
|
11577
|
+
return { status: "unavailable", reason };
|
|
11578
|
+
}
|
|
11579
|
+
throw new SponsoredCallRejectedError(reason);
|
|
11580
|
+
}
|
|
11581
|
+
const { transactionHash } = await executeRes.json();
|
|
11582
|
+
return { status: "sponsored", transactionHash };
|
|
11583
|
+
}
|
|
11547
11584
|
function encodeByteArray(str) {
|
|
11548
11585
|
const bytes = new TextEncoder().encode(str);
|
|
11549
11586
|
const fullChunks = [];
|
|
@@ -11748,6 +11785,7 @@ exports.POPCollectionABI = POPCollectionABI;
|
|
|
11748
11785
|
exports.POPFactoryABI = POPFactoryABI;
|
|
11749
11786
|
exports.PopService = PopService;
|
|
11750
11787
|
exports.SUGGESTED_DEFAULT_PRICE = SUGGESTED_DEFAULT_PRICE;
|
|
11788
|
+
exports.SponsoredCallRejectedError = SponsoredCallRejectedError;
|
|
11751
11789
|
exports.SponsorshipService = SponsorshipService;
|
|
11752
11790
|
exports.StarknetVenue = StarknetVenue;
|
|
11753
11791
|
exports.TicketService = TicketService;
|
|
@@ -11778,6 +11816,7 @@ exports.deriveAesKey = deriveAesKey;
|
|
|
11778
11816
|
exports.deriveOwnerKeyPair = deriveOwnerKeyPair;
|
|
11779
11817
|
exports.encodeAdminHeaders = encodeAdminHeaders;
|
|
11780
11818
|
exports.encodeByteArray = encodeByteArray;
|
|
11819
|
+
exports.executeSponsored = executeSponsored;
|
|
11781
11820
|
exports.fdvHuman = fdvHuman;
|
|
11782
11821
|
exports.generateStarkKeyPair = generateStarkKeyPair;
|
|
11783
11822
|
exports.getCounter = getCounter;
|