@medialane/sdk 0.144.0 → 0.146.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.
@@ -352,7 +352,6 @@ var ApiClient = class {
352
352
  getActiveOrdersForToken(contract, tokenId) {
353
353
  return this.get(`/v1/orders/token/${this.addr(contract)}/${tokenId}`);
354
354
  }
355
- /** Offers others made on the address's assets. */
356
355
  getReceivedOffers(address, opts = {}) {
357
356
  const params = new URLSearchParams({ page: String(opts.page ?? 1), limit: String(opts.limit ?? 50) });
358
357
  return this.get(`/v1/orders/received/${this.addr(address)}?${params}`);
@@ -511,7 +510,6 @@ var ApiClient = class {
511
510
  uploadMetadata(metadata) {
512
511
  return this.post("/v1/metadata/upload", metadata);
513
512
  }
514
- /** Pins several JSON files as one IPFS directory, e.g. a drop's token metadata. */
515
513
  async uploadMetadataDirectory(files) {
516
514
  const res = await this.post("/v1/metadata/upload-directory", { files });
517
515
  return res.data;
@@ -565,7 +563,6 @@ var ApiClient = class {
565
563
  headers: this.asSubject(siwsToken)
566
564
  });
567
565
  }
568
- /** @deprecated Use the funding methods (`createFunding`, or `fundWithChainTransfer` from `@medialane/sdk/starknet`). This call only nudges a legacy scanner and never credits anything itself. */
569
566
  checkDeposit(txHash, siwsToken) {
570
567
  return this.request("/v1/portal/credits/check", {
571
568
  method: "POST",
@@ -757,14 +754,9 @@ var ApiClient = class {
757
754
  async verifyEmailCode(email, code) {
758
755
  await this.post("/v1/auth/email/verify-code", { email, code });
759
756
  }
760
- /**
761
- * Makes the passkey the only owner of the session account's wallet. `signature` is the passkey's owner-alive
762
- * proof for the wallet. Answers 409 when the wallet is already set up.
763
- */
764
757
  setupWalletKey(params) {
765
758
  return this.post("/v1/users/me/wallet/key", params);
766
759
  }
767
- /** The session account's wallet, and whether its passkey still has to be set up (`setupWalletKey`). */
768
760
  async getSessionWallet() {
769
761
  const body = await this.post("/v1/users/me/wallet", {});
770
762
  return body.walletAddress ? { walletAddress: body.walletAddress, needsKeySetup: body.needsKeySetup === true } : null;
@@ -12074,6 +12066,25 @@ var SERVICES = {
12074
12066
  ],
12075
12067
  metadataSchema: { licenseDefault: "CC BY-SA" }
12076
12068
  },
12069
+ "certificate-emission": {
12070
+ id: "certificate-emission",
12071
+ displayName: "Certificate Emission",
12072
+ description: "Issue a soulbound credential to a list of recipients in one run \u2014 everyone gets a wallet and their certificate.",
12073
+ standard: "ERC721",
12074
+ provenance: "MEDIALANE",
12075
+ onchain: {
12076
+ STARKNET: {
12077
+ factoryAddress: SN2.popFactory,
12078
+ classHash: SN2.popCollectionClassHash
12079
+ }
12080
+ },
12081
+ uiVariant: "pop",
12082
+ capabilities: ["mint", "airdrop"],
12083
+ events: [
12084
+ { name: "CollectionCreated", emittedBy: "factory" }
12085
+ ],
12086
+ metadataSchema: { licenseDefault: "CC BY-SA" }
12087
+ },
12077
12088
  "drop-collection": {
12078
12089
  id: "drop-collection",
12079
12090
  displayName: "Collection Drop",
@@ -12412,12 +12423,11 @@ function computeAccountAddress(ownerPubkey, salt = 0) {
12412
12423
  }
12413
12424
  var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
12414
12425
  var OPTION_NONE = "0x1";
12415
- var OPTION_SOME = "0x0";
12416
12426
  var SIGNER_STARKNET = "0x0";
12417
12427
  function computeOwnerGuid(ownerPubkey) {
12418
12428
  return starknet.hash.computePoseidonHash(STARKNET_SIGNER_TYPE, starknet.num.toHex(ownerPubkey));
12419
12429
  }
12420
- function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd, ownerAlive) {
12430
+ function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd) {
12421
12431
  return {
12422
12432
  contractAddress: accountAddress,
12423
12433
  entrypoint: "change_owners",
@@ -12426,55 +12436,10 @@ function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd, ownerAlive) {
12426
12436
  ...guidsToRemove,
12427
12437
  starknet.num.toHex(pubkeysToAdd.length),
12428
12438
  ...pubkeysToAdd.flatMap((p) => [SIGNER_STARKNET, starknet.num.toHex(p)]),
12429
- ...ownerAlive ? ownerAliveCalldata(ownerAlive) : [OPTION_NONE]
12439
+ OPTION_NONE
12430
12440
  ]
12431
12441
  };
12432
12442
  }
12433
- function ownerAliveTypedData(newOwnerGuid, expiration, chainId) {
12434
- return {
12435
- types: {
12436
- StarknetDomain: [
12437
- { name: "name", type: "shortstring" },
12438
- { name: "version", type: "shortstring" },
12439
- { name: "chainId", type: "shortstring" },
12440
- { name: "revision", type: "shortstring" }
12441
- ],
12442
- "Owner Alive": [
12443
- { name: "Owner GUID", type: "felt" },
12444
- { name: "Signature expiration", type: "timestamp" }
12445
- ]
12446
- },
12447
- primaryType: "Owner Alive",
12448
- domain: { name: "Owner Alive", version: "1", chainId, revision: "1" },
12449
- message: { "Owner GUID": newOwnerGuid, "Signature expiration": expiration }
12450
- };
12451
- }
12452
- function ownerAliveCalldata(proof) {
12453
- if (proof.signature.length !== 2) {
12454
- throw new Error("owner-alive proof needs an r and s from the incoming owner");
12455
- }
12456
- return [
12457
- OPTION_SOME,
12458
- SIGNER_STARKNET,
12459
- starknet.num.toHex(proof.newOwnerPubkey),
12460
- starknet.num.toHex(proof.signature[0]),
12461
- starknet.num.toHex(proof.signature[1]),
12462
- starknet.num.toHex(proof.expiration)
12463
- ];
12464
- }
12465
- function buildChangeOwnersCall(accountAddress, removeOwnerPubkey, addOwnerPubkey, ownerAlive) {
12466
- if (!ownerAlive) {
12467
- throw new Error(
12468
- "Replacing the signing owner requires an owner-alive proof from the new owner. Sign ownerAliveTypedData with the new owner key and pass it here."
12469
- );
12470
- }
12471
- return changeOwners(
12472
- accountAddress,
12473
- [computeOwnerGuid(removeOwnerPubkey)],
12474
- [addOwnerPubkey],
12475
- ownerAlive
12476
- );
12477
- }
12478
12443
  function buildAddOwnerCall(accountAddress, addOwnerPubkey) {
12479
12444
  return changeOwners(accountAddress, [], [addOwnerPubkey]);
12480
12445
  }
@@ -13227,20 +13192,20 @@ function createMediaWallet(config) {
13227
13192
  }
13228
13193
  };
13229
13194
  }
13195
+
13196
+ // src/session/session-wallet.ts
13230
13197
  async function adoptSessionWallet(api, saveAddress) {
13231
13198
  const wallet = await api.getSessionWallet();
13232
13199
  if (wallet) saveAddress(wallet.walletAddress);
13233
13200
  return wallet;
13234
13201
  }
13235
- var PROOF_TTL_SECONDS = 600;
13236
- async function setupSessionWalletKey(api, walletAddress, deps) {
13237
- const { sealed, privateKeyHex } = await deps.createOwnerKey();
13238
- const now = deps.now?.() ?? Math.floor(Date.now() / 1e3);
13239
- const expiration = now + PROOF_TTL_SECONDS;
13240
- const message = ownerAliveTypedData(computeOwnerGuid(sealed.ownerPubKey), expiration, "SN_MAIN");
13241
- const signature = signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(message, walletAddress));
13242
- const result = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey, signature, expiration });
13243
- deps.saveOwner({ ...sealed, address: result.walletAddress });
13202
+ async function claimSessionWallet(api, walletAddress, deps) {
13203
+ const saved = deps.loadOwner();
13204
+ const resuming = saved !== null && normalizeWalletAddress(saved.address) === normalizeWalletAddress(walletAddress);
13205
+ const sealed = resuming ? saved : { ...(await deps.createOwnerKey()).sealed, address: walletAddress };
13206
+ if (!resuming) deps.saveOwner(sealed);
13207
+ const { removeOwnerGuid } = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey });
13208
+ if (removeOwnerGuid) await deps.removeOwner(sealed, removeOwnerGuid);
13244
13209
  }
13245
13210
 
13246
13211
  exports.ADMIN_HEADERS = ADMIN_HEADERS;
@@ -13296,7 +13261,6 @@ exports.buildAddOwnerCall = buildAddOwnerCall;
13296
13261
  exports.buildAdminSessionTypedData = buildAdminSessionTypedData;
13297
13262
  exports.buildCancelEscapeCall = buildCancelEscapeCall;
13298
13263
  exports.buildCancellationTypedData = buildCancellationTypedData;
13299
- exports.buildChangeOwnersCall = buildChangeOwnersCall;
13300
13264
  exports.buildCompleteEscapeOwnerCall = buildCompleteEscapeOwnerCall;
13301
13265
  exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
13302
13266
  exports.buildDeployAccountParams = buildDeployAccountParams;
@@ -13310,6 +13274,7 @@ exports.buildSetFirstGuardianCall = buildSetFirstGuardianCall;
13310
13274
  exports.buildTriggerEscapeOwnerCall = buildTriggerEscapeOwnerCall;
13311
13275
  exports.buybackQuoteRaw = buybackQuoteRaw;
13312
13276
  exports.canRemoveDevice = canRemoveDevice;
13277
+ exports.claimSessionWallet = claimSessionWallet;
13313
13278
  exports.coinToRaw = toRaw;
13314
13279
  exports.completeDeployment = completeDeployment;
13315
13280
  exports.computeAccountAddress = computeAccountAddress;
@@ -13359,7 +13324,6 @@ exports.isValidStarknetAddress = isValidStarknetAddress;
13359
13324
  exports.mintedTokenIdFromReceipt = mintedTokenIdFromReceipt;
13360
13325
  exports.normalizeSiwsSignature = normalizeSiwsSignature;
13361
13326
  exports.normalizeWalletAddress = normalizeWalletAddress;
13362
- exports.ownerAliveTypedData = ownerAliveTypedData;
13363
13327
  exports.ownerConstructorCalldata = ownerConstructorCalldata;
13364
13328
  exports.parseAccountAddress = parseAccountAddress;
13365
13329
  exports.parseAdminHeaders = parseAdminHeaders;
@@ -13372,7 +13336,6 @@ exports.requestSiwsToken = requestSiwsToken;
13372
13336
  exports.sealPrivateKey = sealPrivateKey;
13373
13337
  exports.selfFundedExecutor = selfFundedExecutor;
13374
13338
  exports.sessionKeyHashOf = sessionKeyHashOf;
13375
- exports.setupSessionWalletKey = setupSessionWalletKey;
13376
13339
  exports.signAdminRequest = signAdminRequest;
13377
13340
  exports.signWithPrivateKey = signWithPrivateKey;
13378
13341
  exports.sponsoredExecutor = sponsoredExecutor;