@medialane/sdk 0.139.0 → 0.141.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.
@@ -12325,9 +12325,9 @@ function mintedTokenIdFromReceipt(receipt, contract) {
12325
12325
  // src/starknet/services/sponsoredExecutor.ts
12326
12326
  var SponsoredCallRejectedError = class extends Error {
12327
12327
  };
12328
- var USER_MAY_PAY = /* @__PURE__ */ new Set(["sponsor_unavailable", "credits_exhausted"]);
12329
- function userMayPayInstead(code, status, stage) {
12330
- if (code) return USER_MAY_PAY.has(code);
12328
+ var FALLBACK_FUNDING_FAILURES = /* @__PURE__ */ new Set(["sponsor_unavailable", "credits_exhausted"]);
12329
+ function allowsFallbackFunding(code, status, stage) {
12330
+ if (code) return FALLBACK_FUNDING_FAILURES.has(code);
12331
12331
  return stage === "build" ? status >= 500 : status === 503;
12332
12332
  }
12333
12333
  async function failureOf(res, fallback) {
@@ -12345,7 +12345,7 @@ async function executeSponsored(config, signer, calls) {
12345
12345
  });
12346
12346
  if (!buildRes.ok) {
12347
12347
  const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
12348
- if (userMayPayInstead(code, buildRes.status, "build")) return { status: "unavailable", reason };
12348
+ if (allowsFallbackFunding(code, buildRes.status, "build")) return { status: "unavailable", reason };
12349
12349
  throw new SponsoredCallRejectedError(reason);
12350
12350
  }
12351
12351
  const { typedData } = await buildRes.json();
@@ -12357,7 +12357,7 @@ async function executeSponsored(config, signer, calls) {
12357
12357
  });
12358
12358
  if (!executeRes.ok) {
12359
12359
  const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
12360
- if (userMayPayInstead(code, executeRes.status, "execute")) {
12360
+ if (allowsFallbackFunding(code, executeRes.status, "execute")) {
12361
12361
  return { status: "unavailable", reason };
12362
12362
  }
12363
12363
  throw new SponsoredCallRejectedError(reason);
@@ -13182,6 +13182,21 @@ function createMediaWallet(config) {
13182
13182
  }
13183
13183
  };
13184
13184
  }
13185
+ async function adoptSessionWallet(api, saveAddress) {
13186
+ const wallet = await api.getSessionWallet();
13187
+ if (wallet) saveAddress(wallet.walletAddress);
13188
+ return wallet;
13189
+ }
13190
+ var PROOF_TTL_SECONDS = 600;
13191
+ async function setupSessionWalletKey(api, walletAddress, deps) {
13192
+ const { sealed, privateKeyHex } = await deps.createOwnerKey();
13193
+ const now = deps.now?.() ?? Math.floor(Date.now() / 1e3);
13194
+ const expiration = now + PROOF_TTL_SECONDS;
13195
+ const message = ownerAliveTypedData(computeOwnerGuid(sealed.ownerPubKey), expiration, "SN_MAIN");
13196
+ const signature = signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(message, walletAddress));
13197
+ const result = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey, signature, expiration });
13198
+ deps.saveOwner({ ...sealed, address: result.walletAddress });
13199
+ }
13185
13200
 
13186
13201
  exports.ADMIN_HEADERS = ADMIN_HEADERS;
13187
13202
  exports.ADMIN_SCOPE = ADMIN_SCOPE;
@@ -13226,6 +13241,8 @@ exports.UserFacingError = UserFacingError;
13226
13241
  exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
13227
13242
  exports.accountFor = accountFor;
13228
13243
  exports.adminRequestDigest = adminRequestDigest;
13244
+ exports.adoptSessionWallet = adoptSessionWallet;
13245
+ exports.allowsFallbackFunding = allowsFallbackFunding;
13229
13246
  exports.assertTransactionSucceeded = assertTransactionSucceeded;
13230
13247
  exports.build1155CancellationTypedData = build1155CancellationTypedData;
13231
13248
  exports.build1155OrderTypedData = build1155OrderTypedData;
@@ -13308,6 +13325,7 @@ exports.requestSiwsToken = requestSiwsToken;
13308
13325
  exports.sealPrivateKey = sealPrivateKey;
13309
13326
  exports.selfFundedExecutor = selfFundedExecutor;
13310
13327
  exports.sessionKeyHashOf = sessionKeyHashOf;
13328
+ exports.setupSessionWalletKey = setupSessionWalletKey;
13311
13329
  exports.signAdminRequest = signAdminRequest;
13312
13330
  exports.signWithPrivateKey = signWithPrivateKey;
13313
13331
  exports.sponsoredExecutor = sponsoredExecutor;
@@ -13317,7 +13335,6 @@ exports.syncTransactionBestEffort = syncTransactionBestEffort;
13317
13335
  exports.teamCoinsRaw = teamCoinsRaw;
13318
13336
  exports.toDropContractConditions = toContractConditions;
13319
13337
  exports.unsealPrivateKey = unsealPrivateKey;
13320
- exports.userMayPayInstead = userMayPayInstead;
13321
13338
  exports.validateCoinName = validateName;
13322
13339
  exports.validateCoinSupply = validateSupply;
13323
13340
  exports.validateCoinSymbol = validateSymbol;