@medialane/sdk 0.171.0 → 0.172.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
|
@@ -12120,14 +12120,14 @@ async function failureOf(res, fallback) {
|
|
|
12120
12120
|
const body = await res.json().catch(() => null);
|
|
12121
12121
|
return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
|
|
12122
12122
|
}
|
|
12123
|
-
async function executeSponsored(config, signer,
|
|
12123
|
+
async function executeSponsored(config, signer, request) {
|
|
12124
12124
|
const doFetch = config.fetchImpl ?? fetch;
|
|
12125
12125
|
const base = config.proxyUrl.replace(/\/$/, "");
|
|
12126
12126
|
const headers = { "Content-Type": "application/json", ...config.headers };
|
|
12127
12127
|
const buildRes = await doFetch(`${base}/build`, {
|
|
12128
12128
|
method: "POST",
|
|
12129
12129
|
headers,
|
|
12130
|
-
body: JSON.stringify(
|
|
12130
|
+
body: JSON.stringify(request)
|
|
12131
12131
|
});
|
|
12132
12132
|
if (!buildRes.ok) {
|
|
12133
12133
|
const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
|
|
@@ -12139,7 +12139,7 @@ async function executeSponsored(config, signer, calls, intentIds) {
|
|
|
12139
12139
|
const executeRes = await doFetch(`${base}/execute`, {
|
|
12140
12140
|
method: "POST",
|
|
12141
12141
|
headers,
|
|
12142
|
-
body: JSON.stringify(
|
|
12142
|
+
body: JSON.stringify({ ...request, typedData, signature })
|
|
12143
12143
|
});
|
|
12144
12144
|
if (!executeRes.ok) {
|
|
12145
12145
|
const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
|
|
@@ -12521,14 +12521,18 @@ function sponsoredExecutor(deps) {
|
|
|
12521
12521
|
return {
|
|
12522
12522
|
async execute(input) {
|
|
12523
12523
|
const { userAddress, privateKeyHex, calls, intentIds } = input;
|
|
12524
|
+
if (!intentIds?.length) {
|
|
12525
|
+
const consented2 = await deps.consent.request({ address: userAddress, calls });
|
|
12526
|
+
if (!consented2) throw new SponsoredCallRejectedError("This action can't be sponsored");
|
|
12527
|
+
return fallback.execute(input);
|
|
12528
|
+
}
|
|
12524
12529
|
const result = await executeSponsored(
|
|
12525
12530
|
{ proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
|
|
12526
12531
|
{
|
|
12527
12532
|
address: userAddress,
|
|
12528
12533
|
signTypedData: async (data) => chunkBC2L2H6A_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
|
|
12529
12534
|
},
|
|
12530
|
-
|
|
12531
|
-
intentIds
|
|
12535
|
+
{ intentIds }
|
|
12532
12536
|
);
|
|
12533
12537
|
if (result.status === "sponsored") return { transactionHash: result.transactionHash };
|
|
12534
12538
|
const consented = await deps.consent.request({ address: userAddress, calls });
|