@medialane/sdk 0.159.0 → 0.160.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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkK5MWWVX5_cjs = require('../chunk-K5MWWVX5.cjs');
3
+ var chunkLXPVVK7R_cjs = require('../chunk-LXPVVK7R.cjs');
4
4
  var chunkH7I6TEOA_cjs = require('../chunk-H7I6TEOA.cjs');
5
5
  var starknet = require('starknet');
6
6
  var hkdf_js = require('@noble/hashes/hkdf.js');
@@ -33,7 +33,7 @@ function getChainId(config) {
33
33
  return starknet.constants.StarknetChainId.SN_MAIN;
34
34
  }
35
35
  function resolveToken(currency) {
36
- const token = chunkK5MWWVX5_cjs.SUPPORTED_TOKENS.find(
36
+ const token = chunkLXPVVK7R_cjs.SUPPORTED_TOKENS.find(
37
37
  (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
38
38
  );
39
39
  if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
@@ -44,7 +44,7 @@ function getProvider(config) {
44
44
  let p = _providerCache.get(config);
45
45
  if (!p) {
46
46
  const urls = [config.rpcUrl];
47
- p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: chunkK5MWWVX5_cjs.createFailoverFetch(urls) });
47
+ p = new starknet.RpcProvider({ nodeUrl: urls[0], baseFetch: chunkLXPVVK7R_cjs.createFailoverFetch(urls) });
48
48
  _providerCache.set(config, p);
49
49
  }
50
50
  return p;
@@ -9739,15 +9739,113 @@ var IPGenesisABI = [
9739
9739
  ]
9740
9740
  }
9741
9741
  ];
9742
+ var FRAGMENT_KEY = "pop-proof";
9743
+ var toHex = (x) => "0x" + x.toString(16).padStart(64, "0");
9744
+ var poseidon = (xs) => BigInt(starknet.hash.computePoseidonHashOnElements(xs.map((x) => "0x" + x.toString(16))));
9745
+ var nodeHash = (a, b) => a < b ? poseidon([a, b]) : poseidon([b, a]);
9746
+ function popLeafHash(address) {
9747
+ return poseidon([poseidon([BigInt(address)])]);
9748
+ }
9749
+ function merkleTree(leafHashes) {
9750
+ const leaves = [...leafHashes].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
9751
+ const tree = new Array(2 * leaves.length - 1);
9752
+ leaves.forEach((leaf, i) => tree[tree.length - 1 - i] = leaf);
9753
+ for (let i = tree.length - 1 - leaves.length; i >= 0; i--) {
9754
+ tree[i] = nodeHash(tree[2 * i + 1], tree[2 * i + 2]);
9755
+ }
9756
+ return {
9757
+ root: tree[0],
9758
+ proof(leaf) {
9759
+ let i = tree.lastIndexOf(leaf);
9760
+ if (i < tree.length - leaves.length) throw new Error("Not a leaf of this tree");
9761
+ const proof = [];
9762
+ while (i > 0) {
9763
+ proof.push(tree[i % 2 === 1 ? i + 1 : i - 1]);
9764
+ i = Math.floor((i - 1) / 2);
9765
+ }
9766
+ return proof;
9767
+ }
9768
+ };
9769
+ }
9770
+ function buildPopAllowlist(addresses) {
9771
+ const unique = [...new Set(addresses.map((a) => chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", a)))];
9772
+ if (unique.length === 0) throw new Error("An allowlist needs at least one address");
9773
+ const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
9774
+ const tree = merkleTree(leaves.map((l) => l.leaf));
9775
+ const proofs = {};
9776
+ for (const { address, leaf } of leaves) proofs[address] = tree.proof(leaf).map(toHex);
9777
+ return { root: toHex(tree.root), proofs };
9778
+ }
9779
+ function verifyPopProof(root, address, proof) {
9780
+ let computed = popLeafHash(address);
9781
+ for (const sibling of proof) computed = nodeHash(computed, BigInt(sibling));
9782
+ return computed === BigInt(root);
9783
+ }
9784
+ function encodePopClaimFragment(proof) {
9785
+ return `#${FRAGMENT_KEY}=${proof.join(",")}`;
9786
+ }
9787
+ function decodePopClaimFragment(fragment) {
9788
+ const raw = new URLSearchParams(fragment.replace(/^#/, "")).get(FRAGMENT_KEY);
9789
+ if (raw === null) return null;
9790
+ if (raw === "") return [];
9791
+ const parts = raw.split(",");
9792
+ return parts.every((p) => /^0x[0-9a-fA-F]{1,64}$/.test(p)) ? parts : null;
9793
+ }
9794
+
9795
+ // src/starknet/pop-claim.ts
9796
+ function popClaimLinks(origin, collection, list) {
9797
+ const base = `${origin}${chunkLXPVVK7R_cjs.collectionHref("STARKNET", collection)}`;
9798
+ return Object.entries(list.proofs).map(([address, proof]) => ({
9799
+ address,
9800
+ url: `${base}${encodePopClaimFragment(proof)}`
9801
+ }));
9802
+ }
9803
+ function popClaimLinksCsv(links) {
9804
+ return ["address,claim_link", ...links.map((l) => `${l.address},${l.url}`)].join("\n");
9805
+ }
9806
+ async function popClaimInfo(provider, collection) {
9807
+ const contractAddress = chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", collection);
9808
+ const [root, end] = await Promise.all([
9809
+ provider.callContract({ contractAddress, entrypoint: "allowlist_root", calldata: [] }),
9810
+ provider.callContract({ contractAddress, entrypoint: "claim_end_time", calldata: [] })
9811
+ ]);
9812
+ return { root: root[0] ?? "0x0", claimEndTime: Number(BigInt(end[0] ?? "0x0")) };
9813
+ }
9814
+ function popClaimState(input) {
9815
+ const { hasClaimed, proof, wallet, info } = input;
9816
+ if (hasClaimed === true) return "claimed";
9817
+ if (hasClaimed === null || info === null) return "loading";
9818
+ if (BigInt(info.root) === 0n) return "closed";
9819
+ if (info.claimEndTime !== 0 && info.now > info.claimEndTime) return "ended";
9820
+ if (proof === null) return "no-link";
9821
+ if (!wallet || !verifyPopProof(info.root, wallet, proof)) return "wrong-wallet";
9822
+ return "ready";
9823
+ }
9824
+ var addr = (a) => chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", a);
9825
+ var byteArrayFelts = (s) => starknet.CallData.compile([starknet.byteArray.byteArrayFromString(s)]);
9826
+ var popCalls = {
9827
+ claim(collection, proof) {
9828
+ return { contractAddress: addr(collection), entrypoint: "claim", calldata: [String(proof.length), ...proof] };
9829
+ },
9830
+ /** An empty `tokenUri` uses the collection's URI. */
9831
+ issue(collection, recipient, tokenUri = "") {
9832
+ return { contractAddress: addr(collection), entrypoint: "issue", calldata: [addr(recipient), ...byteArrayFelts(tokenUri)] };
9833
+ },
9834
+ /** Only the token's holder can burn it. */
9835
+ burn(collection, tokenId) {
9836
+ const id = starknet.cairo.uint256(BigInt(tokenId));
9837
+ return { contractAddress: addr(collection), entrypoint: "burn", calldata: [String(id.low), String(id.high)] };
9838
+ },
9839
+ setAllowlistRoot(collection, root) {
9840
+ return { contractAddress: addr(collection), entrypoint: "set_allowlist_root", calldata: [root] };
9841
+ }
9842
+ };
9742
9843
 
9743
9844
  // src/starknet/services/pop.ts
9744
9845
  var PopService = class {
9745
9846
  constructor(config) {
9746
9847
  this.factoryAddress = chunkH7I6TEOA_cjs.getStarknetCoordinates(config.chain).popFactory;
9747
9848
  }
9748
- _collection(address, account) {
9749
- return newContract(POPCollectionABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), account);
9750
- }
9751
9849
  async createCollection(account, params) {
9752
9850
  const factory = newContract(POPFactoryABI, this.factoryAddress, account);
9753
9851
  const call = factory.populate("create_collection", [params.name, params.symbol, params.baseUri, params.claimEndTime]);
@@ -9755,32 +9853,32 @@ var PopService = class {
9755
9853
  return { txHash: res.transaction_hash };
9756
9854
  }
9757
9855
  async setAllowlistRoot(account, params) {
9758
- const call = this._collection(params.collection, account).populate("set_allowlist_root", [params.root]);
9856
+ const call = popCalls.setAllowlistRoot(params.collection, params.root);
9759
9857
  const res = await account.execute([call]);
9760
9858
  return { txHash: res.transaction_hash };
9761
9859
  }
9762
9860
  async claim(account, params) {
9763
- const call = this._collection(params.collection, account).populate("claim", [params.proof]);
9861
+ const call = popCalls.claim(params.collection, params.proof);
9764
9862
  const res = await account.execute([call]);
9765
9863
  return { txHash: res.transaction_hash };
9766
9864
  }
9767
9865
  async issue(account, params) {
9768
- const call = this._collection(params.collection, account).populate("issue", [params.recipient, params.tokenUri ?? ""]);
9866
+ const call = popCalls.issue(params.collection, params.recipient, params.tokenUri);
9769
9867
  const res = await account.execute([call]);
9770
9868
  return { txHash: res.transaction_hash };
9771
9869
  }
9772
9870
  /** Destroys the caller's own credential; the address cannot receive another from this collection. */
9773
9871
  async burn(account, params) {
9774
- const call = this._collection(params.collection, account).populate("burn", [BigInt(params.tokenId)]);
9872
+ const call = popCalls.burn(params.collection, params.tokenId);
9775
9873
  const res = await account.execute([call]);
9776
9874
  return { txHash: res.transaction_hash };
9777
9875
  }
9778
9876
  };
9779
9877
  async function popHasClaimed(provider, collection, address) {
9780
9878
  const res = await provider.callContract({
9781
- contractAddress: chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", collection),
9879
+ contractAddress: chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", collection),
9782
9880
  entrypoint: "has_claimed",
9783
- calldata: [chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address)]
9881
+ calldata: [chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address)]
9784
9882
  });
9785
9883
  return BigInt(res[0] ?? "0x0") !== 0n;
9786
9884
  }
@@ -9814,7 +9912,7 @@ var DropService = class {
9814
9912
  this.config = config;
9815
9913
  }
9816
9914
  _collection(address, account) {
9817
- return newContract(DropCollectionABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), account);
9915
+ return newContract(DropCollectionABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), account);
9818
9916
  }
9819
9917
  async claim(account, collectionAddress, quantity = 1) {
9820
9918
  const collection = this._collection(collectionAddress, account);
@@ -9899,14 +9997,14 @@ var ERC1155CollectionService = class {
9899
9997
  _factory(account) {
9900
9998
  return newContract(
9901
9999
  IPCollection1155FactoryABI,
9902
- chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", this.factoryAddress),
10000
+ chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", this.factoryAddress),
9903
10001
  account
9904
10002
  );
9905
10003
  }
9906
10004
  _collection(address, account) {
9907
10005
  return newContract(
9908
10006
  IPCollection1155ABI,
9909
- chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address),
10007
+ chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address),
9910
10008
  account
9911
10009
  );
9912
10010
  }
@@ -10134,20 +10232,20 @@ function buildLaunchOnEkuboCalls(params) {
10134
10232
  }
10135
10233
  var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
10136
10234
  function parseCreatorCoinCreated(receipt) {
10137
- const factory = chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", chunkH7I6TEOA_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
10235
+ const factory = chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", chunkH7I6TEOA_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
10138
10236
  for (const ev of receipt?.events ?? []) {
10139
10237
  let from;
10140
10238
  try {
10141
- from = chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
10239
+ from = chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
10142
10240
  } catch {
10143
10241
  continue;
10144
10242
  }
10145
10243
  if (from !== factory) continue;
10146
10244
  const k0 = ev.keys?.[0];
10147
- if (!k0 || chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", k0) !== chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
10245
+ if (!k0 || chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", k0) !== chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
10148
10246
  const data = ev.data ?? [];
10149
10247
  if (data.length < 1) continue;
10150
- return chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
10248
+ return chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
10151
10249
  }
10152
10250
  throw new Error("Coin deployed but the coin address could not be read from the receipt");
10153
10251
  }
@@ -10183,14 +10281,14 @@ var TicketService = class {
10183
10281
  _factory(account, factoryAddress) {
10184
10282
  const address = factoryAddress ?? this.factoryAddress;
10185
10283
  if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
10186
- return newContract(IPTicketCollectionFactoryABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), account);
10284
+ return newContract(IPTicketCollectionFactoryABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), account);
10187
10285
  }
10188
10286
  _collection(address, account) {
10189
- return newContract(IPTicketCollectionABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), account);
10287
+ return newContract(IPTicketCollectionABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), account);
10190
10288
  }
10191
10289
  _collectionRead(address) {
10192
10290
  const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
10193
- return newContract(IPTicketCollectionABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), provider);
10291
+ return newContract(IPTicketCollectionABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), provider);
10194
10292
  }
10195
10293
  async deployCollection(account, params) {
10196
10294
  const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
@@ -10256,14 +10354,14 @@ var ClubService = class {
10256
10354
  _factory(account, factoryAddress) {
10257
10355
  const address = factoryAddress ?? this.factoryAddress;
10258
10356
  if (!address) throw new Error("IP-Club factory address not configured for this chain");
10259
- return newContract(IPClubFactoryABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), account);
10357
+ return newContract(IPClubFactoryABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), account);
10260
10358
  }
10261
10359
  _collection(address, account) {
10262
- return newContract(IPClubCollectionABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), account);
10360
+ return newContract(IPClubCollectionABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), account);
10263
10361
  }
10264
10362
  _collectionRead(address) {
10265
10363
  const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
10266
- return newContract(IPClubCollectionABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address), provider);
10364
+ return newContract(IPClubCollectionABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address), provider);
10267
10365
  }
10268
10366
  async deployCollection(account, params) {
10269
10367
  const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
@@ -10333,7 +10431,7 @@ var SponsorshipService = class {
10333
10431
  if (!resolved) {
10334
10432
  throw new Error("IP-Sponsorship address not configured for this chain");
10335
10433
  }
10336
- return newContract(IPSponsorshipABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", resolved), account);
10434
+ return newContract(IPSponsorshipABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", resolved), account);
10337
10435
  }
10338
10436
  _contractRead(address) {
10339
10437
  const resolved = address ?? this.sponsorshipAddress;
@@ -10341,7 +10439,7 @@ var SponsorshipService = class {
10341
10439
  throw new Error("IP-Sponsorship address not configured for this chain");
10342
10440
  }
10343
10441
  const provider = new starknet.RpcProvider({ nodeUrl: this.config.rpcUrl });
10344
- return newContract(IPSponsorshipABI, chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", resolved), provider);
10442
+ return newContract(IPSponsorshipABI, chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", resolved), provider);
10345
10443
  }
10346
10444
  async createOffer(account, params) {
10347
10445
  const specificSponsor = params.specificSponsor ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.specificSponsor) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
@@ -10376,7 +10474,7 @@ var SponsorshipService = class {
10376
10474
  const approveCall = {
10377
10475
  contractAddress: params.paymentToken,
10378
10476
  entrypoint: "approve",
10379
- calldata: [chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", sponsorshipAddress), amount.low.toString(), amount.high.toString()]
10477
+ calldata: [chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", sponsorshipAddress), amount.low.toString(), amount.high.toString()]
10380
10478
  };
10381
10479
  const bidCall = this._contract(account, sponsorshipAddress).populate("place_bid", [
10382
10480
  starknet.cairo.uint256(params.offerId),
@@ -10503,7 +10601,7 @@ var SponsorshipService = class {
10503
10601
  // src/starknet/client.ts
10504
10602
  var MedialaneClient = class {
10505
10603
  constructor(rawConfig = {}) {
10506
- this.config = chunkK5MWWVX5_cjs.resolveConfig(rawConfig);
10604
+ this.config = chunkLXPVVK7R_cjs.resolveConfig(rawConfig);
10507
10605
  this.services = {
10508
10606
  pop: new PopService(this.config),
10509
10607
  drop: new DropService(this.config),
@@ -10514,9 +10612,9 @@ var MedialaneClient = class {
10514
10612
  sponsorship: new SponsorshipService(this.config)
10515
10613
  };
10516
10614
  if (!this.config.backendUrl) {
10517
- const sentinel = new chunkK5MWWVX5_cjs.ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
10615
+ const sentinel = new chunkLXPVVK7R_cjs.ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
10518
10616
  const apiMethodNames = new Set(
10519
- Object.getOwnPropertyNames(chunkK5MWWVX5_cjs.ApiClient.prototype).filter(
10617
+ Object.getOwnPropertyNames(chunkLXPVVK7R_cjs.ApiClient.prototype).filter(
10520
10618
  (k) => k !== "constructor" && typeof sentinel[k] === "function"
10521
10619
  )
10522
10620
  );
@@ -10533,7 +10631,7 @@ var MedialaneClient = class {
10533
10631
  }
10534
10632
  });
10535
10633
  } else {
10536
- this.api = new chunkK5MWWVX5_cjs.ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
10634
+ this.api = new chunkLXPVVK7R_cjs.ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
10537
10635
  }
10538
10636
  }
10539
10637
  get chain() {
@@ -10705,7 +10803,7 @@ function buildListingOrder(i, cfg) {
10705
10803
  salt: i.salt,
10706
10804
  counter: i.counter
10707
10805
  };
10708
- const typedData = chunkK5MWWVX5_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10806
+ const typedData = chunkLXPVVK7R_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10709
10807
  return { orderParams, typedData };
10710
10808
  }
10711
10809
  function buildOfferOrder(i, cfg) {
@@ -10726,11 +10824,11 @@ function buildOfferOrder(i, cfg) {
10726
10824
  salt: i.salt,
10727
10825
  counter: i.counter
10728
10826
  };
10729
- const typedData = chunkK5MWWVX5_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10827
+ const typedData = chunkLXPVVK7R_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10730
10828
  return { orderParams, typedData };
10731
10829
  }
10732
10830
  function registerPayload(orderParams, signature) {
10733
- return chunkK5MWWVX5_cjs.stringifyBigInts({
10831
+ return chunkLXPVVK7R_cjs.stringifyBigInts({
10734
10832
  parameters: {
10735
10833
  ...orderParams,
10736
10834
  offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
@@ -10761,14 +10859,14 @@ function buildFulfillCalls(a, cfg) {
10761
10859
  return fee ? [approve, fulfill, fee] : [approve, fulfill];
10762
10860
  }
10763
10861
  function buildCancelCalls(a, cfg) {
10764
- const cancelRequest = chunkK5MWWVX5_cjs.stringifyBigInts({
10862
+ const cancelRequest = chunkLXPVVK7R_cjs.stringifyBigInts({
10765
10863
  cancelation: { order_hash: a.orderHash, offerer: a.offerer },
10766
10864
  signature: a.signature
10767
10865
  });
10768
10866
  return [contractFor(cfg).populate("cancel_order", [cancelRequest])];
10769
10867
  }
10770
10868
  function buildCancelTypedData(orderHash, offerer, cfg) {
10771
- return chunkK5MWWVX5_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
10869
+ return chunkLXPVVK7R_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
10772
10870
  }
10773
10871
  function contractFor2(cfg) {
10774
10872
  return newContract(Medialane1155ABI, cfg.marketplace1155Contract, getProvider(cfg));
@@ -10791,7 +10889,7 @@ function buildListing1155Order(i, cfg) {
10791
10889
  salt: i.salt,
10792
10890
  counter: i.counter
10793
10891
  };
10794
- const typedData = chunkK5MWWVX5_cjs.stringifyBigInts(
10892
+ const typedData = chunkLXPVVK7R_cjs.stringifyBigInts(
10795
10893
  build1155OrderTypedData(orderParams, getChainId(cfg))
10796
10894
  );
10797
10895
  return { orderParams, typedData };
@@ -10814,13 +10912,13 @@ function buildOffer1155Order(i, cfg) {
10814
10912
  salt: i.salt,
10815
10913
  counter: i.counter
10816
10914
  };
10817
- const typedData = chunkK5MWWVX5_cjs.stringifyBigInts(
10915
+ const typedData = chunkLXPVVK7R_cjs.stringifyBigInts(
10818
10916
  build1155OrderTypedData(orderParams, getChainId(cfg))
10819
10917
  );
10820
10918
  return { orderParams, typedData };
10821
10919
  }
10822
10920
  function registerPayload2(orderParams, signature) {
10823
- return chunkK5MWWVX5_cjs.stringifyBigInts({
10921
+ return chunkLXPVVK7R_cjs.stringifyBigInts({
10824
10922
  parameters: {
10825
10923
  ...orderParams,
10826
10924
  offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
@@ -10851,14 +10949,14 @@ function buildFulfill1155Calls(a, cfg) {
10851
10949
  return fee ? [approve, fulfill, fee] : [approve, fulfill];
10852
10950
  }
10853
10951
  function buildCancel1155Calls(a, cfg) {
10854
- const cancelPayload = chunkK5MWWVX5_cjs.stringifyBigInts({
10952
+ const cancelPayload = chunkLXPVVK7R_cjs.stringifyBigInts({
10855
10953
  cancelation: { order_hash: a.orderHash, offerer: a.offerer },
10856
10954
  signature: a.signature
10857
10955
  });
10858
10956
  return [contractFor2(cfg).populate("cancel_order", [cancelPayload])];
10859
10957
  }
10860
10958
  function buildCancel1155TypedData(orderHash, offerer, cfg) {
10861
- return chunkK5MWWVX5_cjs.stringifyBigInts(
10959
+ return chunkLXPVVK7R_cjs.stringifyBigInts(
10862
10960
  build1155CancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg))
10863
10961
  );
10864
10962
  }
@@ -11201,14 +11299,14 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
11201
11299
  const receipt = await provider.getTransactionReceipt(txHash);
11202
11300
  const status = receipt.execution_status ?? receipt.status;
11203
11301
  if (status === "REVERTED" || status === "REJECTED") {
11204
- throw new chunkK5MWWVX5_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
11302
+ throw new chunkLXPVVK7R_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
11205
11303
  }
11206
11304
  if (status) return receipt;
11207
11305
  } catch (err) {
11208
11306
  if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
11209
11307
  }
11210
11308
  }
11211
- throw new chunkK5MWWVX5_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
11309
+ throw new chunkLXPVVK7R_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
11212
11310
  }
11213
11311
  async function executeIntent(provider, signer, client, intent, opts = {}) {
11214
11312
  let calls;
@@ -11261,14 +11359,14 @@ function u2562(low, high) {
11261
11359
  return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
11262
11360
  }
11263
11361
  function deployedCollectionFromReceipt(receipt, service) {
11264
- const factory = chunkK5MWWVX5_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
11362
+ const factory = chunkLXPVVK7R_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
11265
11363
  const { event, address } = DEPLOY_EVENTS[service];
11266
11364
  const selector = BigInt(starknet.hash.getSelectorFromName(event));
11267
11365
  for (const e of receipt.events ?? []) {
11268
11366
  if (factory && !sameFelt(e.from_address, factory)) continue;
11269
11367
  if (!sameFelt(e.keys?.[0], selector)) continue;
11270
11368
  const value = address(e);
11271
- if (value) return chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", value);
11369
+ if (value) return chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", value);
11272
11370
  }
11273
11371
  return null;
11274
11372
  }
@@ -11281,58 +11379,6 @@ function mintedTokenIdFromReceipt(receipt, contract) {
11281
11379
  }
11282
11380
  return null;
11283
11381
  }
11284
- var FRAGMENT_KEY = "pop-proof";
11285
- var toHex = (x) => "0x" + x.toString(16).padStart(64, "0");
11286
- var poseidon = (xs) => BigInt(starknet.hash.computePoseidonHashOnElements(xs.map((x) => "0x" + x.toString(16))));
11287
- var nodeHash = (a, b) => a < b ? poseidon([a, b]) : poseidon([b, a]);
11288
- function popLeafHash(address) {
11289
- return poseidon([poseidon([BigInt(address)])]);
11290
- }
11291
- function merkleTree(leafHashes) {
11292
- const leaves = [...leafHashes].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
11293
- const tree = new Array(2 * leaves.length - 1);
11294
- leaves.forEach((leaf, i) => tree[tree.length - 1 - i] = leaf);
11295
- for (let i = tree.length - 1 - leaves.length; i >= 0; i--) {
11296
- tree[i] = nodeHash(tree[2 * i + 1], tree[2 * i + 2]);
11297
- }
11298
- return {
11299
- root: tree[0],
11300
- proof(leaf) {
11301
- let i = tree.lastIndexOf(leaf);
11302
- if (i < tree.length - leaves.length) throw new Error("Not a leaf of this tree");
11303
- const proof = [];
11304
- while (i > 0) {
11305
- proof.push(tree[i % 2 === 1 ? i + 1 : i - 1]);
11306
- i = Math.floor((i - 1) / 2);
11307
- }
11308
- return proof;
11309
- }
11310
- };
11311
- }
11312
- function buildPopAllowlist(addresses) {
11313
- const unique = [...new Set(addresses.map((a) => chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", a)))];
11314
- if (unique.length === 0) throw new Error("An allowlist needs at least one address");
11315
- const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
11316
- const tree = merkleTree(leaves.map((l) => l.leaf));
11317
- const proofs = {};
11318
- for (const { address, leaf } of leaves) proofs[address] = tree.proof(leaf).map(toHex);
11319
- return { root: toHex(tree.root), proofs };
11320
- }
11321
- function verifyPopProof(root, address, proof) {
11322
- let computed = popLeafHash(address);
11323
- for (const sibling of proof) computed = nodeHash(computed, BigInt(sibling));
11324
- return computed === BigInt(root);
11325
- }
11326
- function encodePopClaimFragment(proof) {
11327
- return `#${FRAGMENT_KEY}=${proof.join(",")}`;
11328
- }
11329
- function decodePopClaimFragment(fragment) {
11330
- const raw = new URLSearchParams(fragment.replace(/^#/, "")).get(FRAGMENT_KEY);
11331
- if (raw === null) return null;
11332
- if (raw === "") return [];
11333
- const parts = raw.split(",");
11334
- return parts.every((p) => /^0x[0-9a-fA-F]{1,64}$/.test(p)) ? parts : null;
11335
- }
11336
11382
 
11337
11383
  // src/starknet/services/sponsoredExecutor.ts
11338
11384
  var SponsoredCallRejectedError = class extends Error {
@@ -11441,13 +11487,13 @@ function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
11441
11487
  }
11442
11488
  function buildDeployAccountParams(ownerPubkey, salt = 0) {
11443
11489
  return {
11444
- classHash: chunkK5MWWVX5_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
11445
- constructorCalldata: chunkK5MWWVX5_cjs.ownerConstructorCalldata(ownerPubkey),
11490
+ classHash: chunkLXPVVK7R_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
11491
+ constructorCalldata: chunkLXPVVK7R_cjs.ownerConstructorCalldata(ownerPubkey),
11446
11492
  addressSalt: starknet.num.toHex(salt),
11447
- contractAddress: chunkK5MWWVX5_cjs.computeAccountAddress(ownerPubkey, salt)
11493
+ contractAddress: chunkLXPVVK7R_cjs.computeAccountAddress(ownerPubkey, salt)
11448
11494
  };
11449
11495
  }
11450
- var norm = (address) => chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address);
11496
+ var norm = (address) => chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address);
11451
11497
  var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
11452
11498
  function encodeFeltArray(items) {
11453
11499
  return [starknet.num.toHex(items.length), ...items];
@@ -11640,7 +11686,7 @@ var InvalidRecoveryKeyError = class extends Error {
11640
11686
  var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
11641
11687
  function keyPair(privateKey) {
11642
11688
  try {
11643
- return chunkK5MWWVX5_cjs.starkKeyPairFromPrivateKey(privateKey);
11689
+ return chunkLXPVVK7R_cjs.starkKeyPairFromPrivateKey(privateKey);
11644
11690
  } catch {
11645
11691
  throw new InvalidRecoveryKeyError();
11646
11692
  }
@@ -11653,7 +11699,7 @@ function parseRecoveryKey(input) {
11653
11699
  const trimmed = input.trim();
11654
11700
  if (!trimmed.startsWith(PREFIX)) {
11655
11701
  const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
11656
- return { walletAddress: chunkK5MWWVX5_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
11702
+ return { walletAddress: chunkLXPVVK7R_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
11657
11703
  }
11658
11704
  const parts = trimmed.slice(PREFIX.length).split(":");
11659
11705
  const [walletAddress, privateKey] = parts;
@@ -11675,7 +11721,7 @@ function describeRecoveryAction(escape) {
11675
11721
  return "none";
11676
11722
  }
11677
11723
  function normalizeWalletAddress(address) {
11678
- return chunkK5MWWVX5_cjs.normalizeAddress("STARKNET", address);
11724
+ return chunkLXPVVK7R_cjs.normalizeAddress("STARKNET", address);
11679
11725
  }
11680
11726
  function isValidStarknetAddress(address) {
11681
11727
  try {
@@ -11720,7 +11766,7 @@ async function estimateSelfFundedFee(provider, address, calls) {
11720
11766
  return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
11721
11767
  }
11722
11768
  async function feeTokenBalance(provider, address, unit) {
11723
- const token = chunkK5MWWVX5_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
11769
+ const token = chunkLXPVVK7R_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
11724
11770
  if (!token) throw new Error(`No fee token for unit ${unit}`);
11725
11771
  const [low = "0x0", high = "0x0"] = await provider.callContract({
11726
11772
  contractAddress: token.address,
@@ -11747,7 +11793,7 @@ function sponsoredExecutor(deps) {
11747
11793
  { proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
11748
11794
  {
11749
11795
  address: userAddress,
11750
- signTypedData: async (data) => chunkK5MWWVX5_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
11796
+ signTypedData: async (data) => chunkLXPVVK7R_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
11751
11797
  },
11752
11798
  calls
11753
11799
  );
@@ -11807,7 +11853,7 @@ async function deploySelfFunded(input) {
11807
11853
  });
11808
11854
  const { transaction_hash } = await account.deployAccount({
11809
11855
  classHash,
11810
- constructorCalldata: chunkK5MWWVX5_cjs.ownerConstructorCalldata(input.ownerPubKey),
11856
+ constructorCalldata: chunkLXPVVK7R_cjs.ownerConstructorCalldata(input.ownerPubKey),
11811
11857
  addressSalt: 0,
11812
11858
  contractAddress: input.ownerAddress
11813
11859
  });
@@ -11870,7 +11916,7 @@ async function completeDeployment(deps, onStep, options = {}) {
11870
11916
  backendUrl: deps.backendUrl,
11871
11917
  walletAddress: address,
11872
11918
  signer: {
11873
- signMessage: async (td) => chunkK5MWWVX5_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(td, address))
11919
+ signMessage: async (td) => chunkLXPVVK7R_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(td, address))
11874
11920
  }
11875
11921
  });
11876
11922
  deps.store.notifyChange();
@@ -11975,7 +12021,7 @@ function createMediaWallet(config) {
11975
12021
  address: sealed.address,
11976
12022
  signTypedData: async (data) => {
11977
12023
  const privateKeyHex = await unlockOnce(sealed);
11978
- return chunkK5MWWVX5_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
12024
+ return chunkLXPVVK7R_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
11979
12025
  },
11980
12026
  execute: async (calls) => {
11981
12027
  const { transactionHash } = await run(sealed, calls);
@@ -12047,51 +12093,51 @@ async function claimSessionWallet(api, walletAddress, deps) {
12047
12093
 
12048
12094
  Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
12049
12095
  enumerable: true,
12050
- get: function () { return chunkK5MWWVX5_cjs.InvalidStarkPrivateKeyError; }
12096
+ get: function () { return chunkLXPVVK7R_cjs.InvalidStarkPrivateKeyError; }
12051
12097
  });
12052
12098
  Object.defineProperty(exports, "PasskeyCancelledError", {
12053
12099
  enumerable: true,
12054
- get: function () { return chunkK5MWWVX5_cjs.PasskeyCancelledError; }
12100
+ get: function () { return chunkLXPVVK7R_cjs.PasskeyCancelledError; }
12055
12101
  });
12056
12102
  Object.defineProperty(exports, "UserFacingError", {
12057
12103
  enumerable: true,
12058
- get: function () { return chunkK5MWWVX5_cjs.UserFacingError; }
12104
+ get: function () { return chunkLXPVVK7R_cjs.UserFacingError; }
12059
12105
  });
12060
12106
  Object.defineProperty(exports, "computeAccountAddress", {
12061
12107
  enumerable: true,
12062
- get: function () { return chunkK5MWWVX5_cjs.computeAccountAddress; }
12108
+ get: function () { return chunkLXPVVK7R_cjs.computeAccountAddress; }
12063
12109
  });
12064
12110
  Object.defineProperty(exports, "createPasskeyOwner", {
12065
12111
  enumerable: true,
12066
- get: function () { return chunkK5MWWVX5_cjs.createPasskeyOwner; }
12112
+ get: function () { return chunkLXPVVK7R_cjs.createPasskeyOwner; }
12067
12113
  });
12068
12114
  Object.defineProperty(exports, "deriveAesKey", {
12069
12115
  enumerable: true,
12070
- get: function () { return chunkK5MWWVX5_cjs.deriveAesKey; }
12116
+ get: function () { return chunkLXPVVK7R_cjs.deriveAesKey; }
12071
12117
  });
12072
12118
  Object.defineProperty(exports, "generateStarkKeyPair", {
12073
12119
  enumerable: true,
12074
- get: function () { return chunkK5MWWVX5_cjs.generateStarkKeyPair; }
12120
+ get: function () { return chunkLXPVVK7R_cjs.generateStarkKeyPair; }
12075
12121
  });
12076
12122
  Object.defineProperty(exports, "ownerConstructorCalldata", {
12077
12123
  enumerable: true,
12078
- get: function () { return chunkK5MWWVX5_cjs.ownerConstructorCalldata; }
12124
+ get: function () { return chunkLXPVVK7R_cjs.ownerConstructorCalldata; }
12079
12125
  });
12080
12126
  Object.defineProperty(exports, "sealPrivateKey", {
12081
12127
  enumerable: true,
12082
- get: function () { return chunkK5MWWVX5_cjs.sealPrivateKey; }
12128
+ get: function () { return chunkLXPVVK7R_cjs.sealPrivateKey; }
12083
12129
  });
12084
12130
  Object.defineProperty(exports, "signWithPrivateKey", {
12085
12131
  enumerable: true,
12086
- get: function () { return chunkK5MWWVX5_cjs.signWithPrivateKey; }
12132
+ get: function () { return chunkLXPVVK7R_cjs.signWithPrivateKey; }
12087
12133
  });
12088
12134
  Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
12089
12135
  enumerable: true,
12090
- get: function () { return chunkK5MWWVX5_cjs.starkKeyPairFromPrivateKey; }
12136
+ get: function () { return chunkLXPVVK7R_cjs.starkKeyPairFromPrivateKey; }
12091
12137
  });
12092
12138
  Object.defineProperty(exports, "unsealPrivateKey", {
12093
12139
  enumerable: true,
12094
- get: function () { return chunkK5MWWVX5_cjs.unsealPrivateKey; }
12140
+ get: function () { return chunkLXPVVK7R_cjs.unsealPrivateKey; }
12095
12141
  });
12096
12142
  exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
12097
12143
  exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
@@ -12204,6 +12250,11 @@ exports.parseAccountAddress = parseAccountAddress;
12204
12250
  exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
12205
12251
  exports.parsePairingPayload = parsePairingPayload;
12206
12252
  exports.parseRecoveryKey = parseRecoveryKey;
12253
+ exports.popCalls = popCalls;
12254
+ exports.popClaimInfo = popClaimInfo;
12255
+ exports.popClaimLinks = popClaimLinks;
12256
+ exports.popClaimLinksCsv = popClaimLinksCsv;
12257
+ exports.popClaimState = popClaimState;
12207
12258
  exports.popHasClaimed = popHasClaimed;
12208
12259
  exports.priceToEkuboParams = priceToEkuboParams;
12209
12260
  exports.requestSiwsToken = requestSiwsToken;