@medialane/sdk 0.8.3 → 0.9.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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { TypedDataRevision, Contract, shortString, cairo, constants, RpcProvider, byteArray, num } from 'starknet';
2
+ import { TypedDataRevision, num, Contract, shortString, cairo, constants, RpcProvider } from 'starknet';
3
3
 
4
4
  // src/config.ts
5
5
 
@@ -192,6 +192,30 @@ function buildCancellationTypedData(message, chainId) {
192
192
  message
193
193
  };
194
194
  }
195
+ function encodeByteArray(str) {
196
+ const bytes = new TextEncoder().encode(str);
197
+ const fullChunks = [];
198
+ let i = 0;
199
+ while (i + 31 <= bytes.length) {
200
+ let val = 0n;
201
+ for (const b of bytes.slice(i, i + 31)) {
202
+ val = val << 8n | BigInt(b);
203
+ }
204
+ fullChunks.push(num.toHex(val));
205
+ i += 31;
206
+ }
207
+ const remaining = bytes.slice(i);
208
+ let pendingVal = 0n;
209
+ for (const b of remaining) {
210
+ pendingVal = pendingVal << 8n | BigInt(b);
211
+ }
212
+ return [
213
+ fullChunks.length.toString(),
214
+ ...fullChunks,
215
+ num.toHex(pendingVal),
216
+ remaining.length.toString()
217
+ ];
218
+ }
195
219
 
196
220
  // src/abis.ts
197
221
  var IPMarketplaceABI = [
@@ -1677,7 +1701,7 @@ function getListableTokens() {
1677
1701
  return SUPPORTED_TOKENS.filter((t) => t.listable);
1678
1702
  }
1679
1703
 
1680
- // src/marketplace/orders.ts
1704
+ // src/marketplace/errors.ts
1681
1705
  var MedialaneError = class extends Error {
1682
1706
  constructor(message, code = "UNKNOWN", cause) {
1683
1707
  super(message);
@@ -1686,6 +1710,7 @@ var MedialaneError = class extends Error {
1686
1710
  this.name = "MedialaneError";
1687
1711
  }
1688
1712
  };
1713
+ var START_TIME_BUFFER_SECS = 30;
1689
1714
  function toSignatureArray(sig) {
1690
1715
  if (Array.isArray(sig)) return sig;
1691
1716
  const s = sig;
@@ -1694,35 +1719,36 @@ function toSignatureArray(sig) {
1694
1719
  function getChainId(_config) {
1695
1720
  return constants.StarknetChainId.SN_MAIN;
1696
1721
  }
1697
- var _contractCache = /* @__PURE__ */ new WeakMap();
1722
+ function resolveToken(currency) {
1723
+ const token = SUPPORTED_TOKENS.find(
1724
+ (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
1725
+ );
1726
+ if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
1727
+ return token;
1728
+ }
1698
1729
  var _providerCache = /* @__PURE__ */ new WeakMap();
1699
1730
  function getProvider(config) {
1700
- let provider = _providerCache.get(config);
1701
- if (!provider) {
1702
- provider = new RpcProvider({ nodeUrl: config.rpcUrl });
1703
- _providerCache.set(config, provider);
1731
+ let p = _providerCache.get(config);
1732
+ if (!p) {
1733
+ p = new RpcProvider({ nodeUrl: config.rpcUrl });
1734
+ _providerCache.set(config, p);
1704
1735
  }
1705
- return provider;
1736
+ return p;
1706
1737
  }
1738
+
1739
+ // src/marketplace/orders.ts
1740
+ var _contractCache = /* @__PURE__ */ new WeakMap();
1707
1741
  function makeContract(config) {
1708
1742
  const cached = _contractCache.get(config);
1709
- if (cached) return cached;
1710
1743
  const provider = getProvider(config);
1744
+ if (cached) return { ...cached, provider };
1711
1745
  const contract = new Contract(
1712
1746
  IPMarketplaceABI,
1713
1747
  config.marketplaceContract,
1714
1748
  provider
1715
1749
  );
1716
- const result = { contract, provider };
1717
- _contractCache.set(config, result);
1718
- return result;
1719
- }
1720
- function resolveToken(currency) {
1721
- const token = SUPPORTED_TOKENS.find(
1722
- (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
1723
- );
1724
- if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
1725
- return token;
1750
+ _contractCache.set(config, { contract });
1751
+ return { contract, provider };
1726
1752
  }
1727
1753
  async function createListing(account, params, config) {
1728
1754
  const { nftContract, tokenId, price, currency = DEFAULT_CURRENCY, durationSeconds } = params;
@@ -1730,7 +1756,7 @@ async function createListing(account, params, config) {
1730
1756
  const token = resolveToken(currency);
1731
1757
  const priceWei = parseAmount(price, token.decimals);
1732
1758
  const now = Math.floor(Date.now() / 1e3);
1733
- const startTime = now + 300;
1759
+ const startTime = now + START_TIME_BUFFER_SECS;
1734
1760
  const endTime = now + durationSeconds;
1735
1761
  const saltBytes = new Uint8Array(4);
1736
1762
  crypto.getRandomValues(saltBytes);
@@ -1814,7 +1840,7 @@ async function makeOffer(account, params, config) {
1814
1840
  const token = resolveToken(currency);
1815
1841
  const priceWei = parseAmount(price, token.decimals);
1816
1842
  const now = Math.floor(Date.now() / 1e3);
1817
- const startTime = now + 300;
1843
+ const startTime = now + START_TIME_BUFFER_SECS;
1818
1844
  const endTime = now + durationSeconds;
1819
1845
  const saltBytes = new Uint8Array(4);
1820
1846
  crypto.getRandomValues(saltBytes);
@@ -1880,7 +1906,7 @@ async function makeOffer(account, params, config) {
1880
1906
  }
1881
1907
  }
1882
1908
  async function fulfillOrder(account, params, config) {
1883
- const { orderHash } = params;
1909
+ const { orderHash, paymentToken, totalPrice } = params;
1884
1910
  const { contract, provider } = makeContract(config);
1885
1911
  const currentNonce = await contract.nonces(account.address);
1886
1912
  const chainId = getChainId();
@@ -1898,9 +1924,19 @@ async function fulfillOrder(account, params, config) {
1898
1924
  fulfillment: fulfillmentParams,
1899
1925
  signature: signatureArray
1900
1926
  });
1901
- const call = contract.populate("fulfill_order", [fulfillPayload]);
1927
+ const totalPriceU256 = cairo.uint256(totalPrice);
1928
+ const approveCall = {
1929
+ contractAddress: paymentToken,
1930
+ entrypoint: "approve",
1931
+ calldata: [
1932
+ config.marketplaceContract,
1933
+ totalPriceU256.low.toString(),
1934
+ totalPriceU256.high.toString()
1935
+ ]
1936
+ };
1937
+ const fulfillCall = contract.populate("fulfill_order", [fulfillPayload]);
1902
1938
  try {
1903
- const tx = await account.execute(call);
1939
+ const tx = await account.execute([approveCall, fulfillCall]);
1904
1940
  await provider.waitForTransaction(tx.transaction_hash);
1905
1941
  return { txHash: tx.transaction_hash };
1906
1942
  } catch (err) {
@@ -1935,15 +1971,6 @@ async function cancelOrder(account, params, config) {
1935
1971
  throw new MedialaneError("Failed to cancel order", "TRANSACTION_FAILED", err);
1936
1972
  }
1937
1973
  }
1938
- function encodeByteArray(str) {
1939
- const ba = byteArray.byteArrayFromString(str);
1940
- return [
1941
- ba.data.length.toString(),
1942
- ...ba.data.map((d) => num.toHex(d)),
1943
- num.toHex(ba.pending_word),
1944
- ba.pending_word_len.toString()
1945
- ];
1946
- }
1947
1974
  async function mint(account, params, config) {
1948
1975
  const { collectionId, recipient, tokenUri, collectionContract } = params;
1949
1976
  const provider = getProvider(config);
@@ -2026,6 +2053,14 @@ async function checkoutCart(account, items, config) {
2026
2053
  throw new MedialaneError("Cart checkout failed", "TRANSACTION_FAILED", err);
2027
2054
  }
2028
2055
  }
2056
+ async function getOrderDetails(orderHash, config) {
2057
+ const { contract } = makeContract(config);
2058
+ return contract.get_order_details(orderHash);
2059
+ }
2060
+ async function getNonce(address, config) {
2061
+ const { contract } = makeContract(config);
2062
+ return BigInt((await contract.nonces(address)).toString());
2063
+ }
2029
2064
 
2030
2065
  // src/marketplace/index.ts
2031
2066
  var MarketplaceModule = class {
@@ -2054,6 +2089,13 @@ var MarketplaceModule = class {
2054
2089
  createCollection(account, params) {
2055
2090
  return createCollection(account, params, this.config);
2056
2091
  }
2092
+ // ─── View calls ───────────────────────────────────────────────────────────
2093
+ getOrderDetails(orderHash) {
2094
+ return getOrderDetails(orderHash, this.config);
2095
+ }
2096
+ getNonce(address) {
2097
+ return getNonce(address, this.config);
2098
+ }
2057
2099
  // ─── Typed data builders (for ChipiPay / custom signing flows) ───────────
2058
2100
  buildListingTypedData(params, chainId) {
2059
2101
  return buildOrderTypedData(params, chainId);
@@ -2144,28 +2186,11 @@ function build1155CancellationTypedData(message, chainId) {
2144
2186
  message
2145
2187
  };
2146
2188
  }
2147
- function toSignatureArray2(sig) {
2148
- if (Array.isArray(sig)) return sig;
2149
- const s = sig;
2150
- return [s.r.toString(), s.s.toString()];
2151
- }
2152
- function getChainId2(_config) {
2153
- return constants.StarknetChainId.SN_MAIN;
2154
- }
2155
- var _providerCache2 = /* @__PURE__ */ new WeakMap();
2156
2189
  var _contractCache2 = /* @__PURE__ */ new WeakMap();
2157
- function getProvider2(config) {
2158
- let p = _providerCache2.get(config);
2159
- if (!p) {
2160
- p = new RpcProvider({ nodeUrl: config.rpcUrl });
2161
- _providerCache2.set(config, p);
2162
- }
2163
- return p;
2164
- }
2165
2190
  function getContract(config) {
2166
2191
  let c = _contractCache2.get(config);
2167
2192
  if (!c) {
2168
- const provider = getProvider2(config);
2193
+ const provider = getProvider(config);
2169
2194
  c = new Contract(
2170
2195
  Medialane1155ABI,
2171
2196
  config.marketplace1155Contract,
@@ -2175,13 +2200,6 @@ function getContract(config) {
2175
2200
  }
2176
2201
  return c;
2177
2202
  }
2178
- function resolveToken2(currency) {
2179
- const token = SUPPORTED_TOKENS.find(
2180
- (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
2181
- );
2182
- if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
2183
- return token;
2184
- }
2185
2203
  async function createListing1155(account, params, config) {
2186
2204
  const {
2187
2205
  nftContract,
@@ -2192,8 +2210,8 @@ async function createListing1155(account, params, config) {
2192
2210
  durationSeconds
2193
2211
  } = params;
2194
2212
  const contract = getContract(config);
2195
- const provider = getProvider2(config);
2196
- const token = resolveToken2(currency);
2213
+ const provider = getProvider(config);
2214
+ const token = resolveToken(currency);
2197
2215
  const priceWei = parseAmount(pricePerUnit, token.decimals);
2198
2216
  const now = Math.floor(Date.now() / 1e3);
2199
2217
  const endTime = now + durationSeconds;
@@ -2201,7 +2219,7 @@ async function createListing1155(account, params, config) {
2201
2219
  crypto.getRandomValues(saltBytes);
2202
2220
  const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
2203
2221
  const currentNonce = await contract.nonces(account.address);
2204
- const chainId = getChainId2();
2222
+ const chainId = getChainId();
2205
2223
  const orderParams = {
2206
2224
  offerer: account.address,
2207
2225
  offer: {
@@ -2219,7 +2237,7 @@ async function createListing1155(account, params, config) {
2219
2237
  end_amount: priceWei,
2220
2238
  recipient: account.address
2221
2239
  },
2222
- start_time: now.toString(),
2240
+ start_time: (now + START_TIME_BUFFER_SECS).toString(),
2223
2241
  end_time: endTime.toString(),
2224
2242
  salt,
2225
2243
  nonce: currentNonce.toString()
@@ -2228,9 +2246,19 @@ async function createListing1155(account, params, config) {
2228
2246
  build1155OrderTypedData(orderParams, chainId)
2229
2247
  );
2230
2248
  const signature = await account.signMessage(typedData);
2231
- const signatureArray = toSignatureArray2(signature);
2249
+ const signatureArray = toSignatureArray(signature);
2232
2250
  const orderPayload = stringifyBigInts({
2233
- parameters: orderParams,
2251
+ parameters: {
2252
+ ...orderParams,
2253
+ offer: {
2254
+ ...orderParams.offer,
2255
+ item_type: shortString.encodeShortString(orderParams.offer.item_type)
2256
+ },
2257
+ consideration: {
2258
+ ...orderParams.consideration,
2259
+ item_type: shortString.encodeShortString(orderParams.consideration.item_type)
2260
+ }
2261
+ },
2234
2262
  signature: signatureArray
2235
2263
  });
2236
2264
  let isApproved = false;
@@ -2263,8 +2291,8 @@ async function createListing1155(account, params, config) {
2263
2291
  async function fulfillOrder1155(account, params, config) {
2264
2292
  const { orderHash, paymentToken, totalPrice, quantity = "1" } = params;
2265
2293
  const contract = getContract(config);
2266
- const provider = getProvider2(config);
2267
- const chainId = getChainId2();
2294
+ const provider = getProvider(config);
2295
+ const chainId = getChainId();
2268
2296
  const currentNonce = await contract.nonces(account.address);
2269
2297
  const fulfillmentParams = {
2270
2298
  order_hash: orderHash,
@@ -2276,7 +2304,7 @@ async function fulfillOrder1155(account, params, config) {
2276
2304
  build1155FulfillmentTypedData(fulfillmentParams, chainId)
2277
2305
  );
2278
2306
  const signature = await account.signMessage(typedData);
2279
- const signatureArray = toSignatureArray2(signature);
2307
+ const signatureArray = toSignatureArray(signature);
2280
2308
  const fulfillPayload = stringifyBigInts({
2281
2309
  fulfillment: fulfillmentParams,
2282
2310
  signature: signatureArray
@@ -2303,8 +2331,8 @@ async function fulfillOrder1155(account, params, config) {
2303
2331
  async function cancelOrder1155(account, params, config) {
2304
2332
  const { orderHash } = params;
2305
2333
  const contract = getContract(config);
2306
- const provider = getProvider2(config);
2307
- const chainId = getChainId2();
2334
+ const provider = getProvider(config);
2335
+ const chainId = getChainId();
2308
2336
  const currentNonce = await contract.nonces(account.address);
2309
2337
  const cancelParams = {
2310
2338
  order_hash: orderHash,
@@ -2315,7 +2343,7 @@ async function cancelOrder1155(account, params, config) {
2315
2343
  build1155CancellationTypedData(cancelParams, chainId)
2316
2344
  );
2317
2345
  const signature = await account.signMessage(typedData);
2318
- const signatureArray = toSignatureArray2(signature);
2346
+ const signatureArray = toSignatureArray(signature);
2319
2347
  const cancelPayload = stringifyBigInts({
2320
2348
  cancelation: cancelParams,
2321
2349
  signature: signatureArray
@@ -2329,6 +2357,148 @@ async function cancelOrder1155(account, params, config) {
2329
2357
  throw new MedialaneError("Failed to cancel ERC-1155 order", "TRANSACTION_FAILED", err);
2330
2358
  }
2331
2359
  }
2360
+ async function makeOffer1155(account, params, config) {
2361
+ const {
2362
+ nftContract,
2363
+ tokenId,
2364
+ amount,
2365
+ price,
2366
+ currency = DEFAULT_CURRENCY,
2367
+ durationSeconds
2368
+ } = params;
2369
+ const contract = getContract(config);
2370
+ const provider = getProvider(config);
2371
+ const chainId = getChainId();
2372
+ const token = resolveToken(currency);
2373
+ const priceWei = parseAmount(price, token.decimals);
2374
+ const now = Math.floor(Date.now() / 1e3);
2375
+ const endTime = now + durationSeconds;
2376
+ const saltBytes = new Uint8Array(4);
2377
+ crypto.getRandomValues(saltBytes);
2378
+ const salt = new DataView(saltBytes.buffer).getUint32(0).toString();
2379
+ const currentNonce = await contract.nonces(account.address);
2380
+ const orderParams = {
2381
+ offerer: account.address,
2382
+ offer: {
2383
+ item_type: "ERC20",
2384
+ token: token.address,
2385
+ identifier_or_criteria: "0",
2386
+ start_amount: priceWei,
2387
+ end_amount: priceWei
2388
+ },
2389
+ consideration: {
2390
+ item_type: "ERC1155",
2391
+ token: nftContract,
2392
+ identifier_or_criteria: tokenId,
2393
+ start_amount: amount,
2394
+ end_amount: amount,
2395
+ recipient: account.address
2396
+ },
2397
+ start_time: (now + START_TIME_BUFFER_SECS).toString(),
2398
+ end_time: endTime.toString(),
2399
+ salt,
2400
+ nonce: currentNonce.toString()
2401
+ };
2402
+ const typedData = stringifyBigInts(
2403
+ build1155OrderTypedData(orderParams, chainId)
2404
+ );
2405
+ const signature = await account.signMessage(typedData);
2406
+ const signatureArray = toSignatureArray(signature);
2407
+ const registerPayload = stringifyBigInts({
2408
+ parameters: {
2409
+ ...orderParams,
2410
+ offer: {
2411
+ ...orderParams.offer,
2412
+ item_type: shortString.encodeShortString(orderParams.offer.item_type)
2413
+ },
2414
+ consideration: {
2415
+ ...orderParams.consideration,
2416
+ item_type: shortString.encodeShortString(orderParams.consideration.item_type)
2417
+ }
2418
+ },
2419
+ signature: signatureArray
2420
+ });
2421
+ const amountU256 = cairo.uint256(priceWei);
2422
+ const approveCall = {
2423
+ contractAddress: token.address,
2424
+ entrypoint: "approve",
2425
+ calldata: [
2426
+ config.marketplace1155Contract,
2427
+ amountU256.low.toString(),
2428
+ amountU256.high.toString()
2429
+ ]
2430
+ };
2431
+ const registerCall = contract.populate("register_order", [registerPayload]);
2432
+ try {
2433
+ const tx = await account.execute([approveCall, registerCall]);
2434
+ await provider.waitForTransaction(tx.transaction_hash);
2435
+ return { txHash: tx.transaction_hash };
2436
+ } catch (err) {
2437
+ throw new MedialaneError("Failed to make ERC-1155 offer", "TRANSACTION_FAILED", err);
2438
+ }
2439
+ }
2440
+ async function checkoutCart1155(account, items, config) {
2441
+ if (items.length === 0) throw new MedialaneError("Cart is empty", "INVALID_PARAMS");
2442
+ const contract = getContract(config);
2443
+ const provider = getProvider(config);
2444
+ const tokenTotals = /* @__PURE__ */ new Map();
2445
+ for (const item of items) {
2446
+ const prev = tokenTotals.get(item.considerationToken) ?? 0n;
2447
+ tokenTotals.set(item.considerationToken, prev + BigInt(item.considerationAmount));
2448
+ }
2449
+ const approveCalls = Array.from(tokenTotals.entries()).map(([tokenAddr, totalWei]) => {
2450
+ const amount = cairo.uint256(totalWei.toString());
2451
+ return {
2452
+ contractAddress: tokenAddr,
2453
+ entrypoint: "approve",
2454
+ calldata: [
2455
+ config.marketplace1155Contract,
2456
+ amount.low.toString(),
2457
+ amount.high.toString()
2458
+ ]
2459
+ };
2460
+ });
2461
+ const currentNonce = await contract.nonces(account.address);
2462
+ const baseNonce = BigInt(currentNonce.toString());
2463
+ const chainId = getChainId();
2464
+ const fulfillCalls = [];
2465
+ for (let i = 0; i < items.length; i++) {
2466
+ const item = items[i];
2467
+ const nonce = (baseNonce + BigInt(i)).toString();
2468
+ const quantity = item.quantity ?? "1";
2469
+ const fulfillmentParams = {
2470
+ order_hash: item.orderHash,
2471
+ fulfiller: account.address,
2472
+ quantity,
2473
+ nonce
2474
+ };
2475
+ const typedData = stringifyBigInts(
2476
+ build1155FulfillmentTypedData(fulfillmentParams, chainId)
2477
+ );
2478
+ const signature = await account.signMessage(typedData);
2479
+ const signatureArray = toSignatureArray(signature);
2480
+ const fulfillPayload = stringifyBigInts({
2481
+ fulfillment: fulfillmentParams,
2482
+ signature: signatureArray
2483
+ });
2484
+ fulfillCalls.push(contract.populate("fulfill_order", [fulfillPayload]));
2485
+ }
2486
+ try {
2487
+ const tx = await account.execute([...approveCalls, ...fulfillCalls]);
2488
+ await provider.waitForTransaction(tx.transaction_hash);
2489
+ return { txHash: tx.transaction_hash };
2490
+ } catch (err) {
2491
+ throw new MedialaneError("ERC-1155 cart checkout failed", "TRANSACTION_FAILED", err);
2492
+ }
2493
+ }
2494
+ async function getOrderDetails1155(orderHash, config) {
2495
+ const contract = getContract(config);
2496
+ return contract.get_order_details(orderHash);
2497
+ }
2498
+ async function getNonce1155(address, config) {
2499
+ const contract = getContract(config);
2500
+ return BigInt((await contract.nonces(address)).toString());
2501
+ }
2332
2502
 
2333
2503
  // src/marketplace1155/index.ts
2334
2504
  var Medialane1155Module = class {
@@ -2343,6 +2513,13 @@ var Medialane1155Module = class {
2343
2513
  createListing(account, params) {
2344
2514
  return createListing1155(account, params, this.config);
2345
2515
  }
2516
+ /**
2517
+ * Make an offer (bid) on an ERC-1155 token.
2518
+ * Approves the ERC-20 spend then calls `register_order` atomically.
2519
+ */
2520
+ makeOffer(account, params) {
2521
+ return makeOffer1155(account, params, this.config);
2522
+ }
2346
2523
  /**
2347
2524
  * Fulfill (buy) an ERC-1155 listing.
2348
2525
  * Approves the payment token then calls `fulfill_order` atomically.
@@ -2356,6 +2533,20 @@ var Medialane1155Module = class {
2356
2533
  cancelOrder(account, params) {
2357
2534
  return cancelOrder1155(account, params, this.config);
2358
2535
  }
2536
+ /**
2537
+ * Checkout a cart of ERC-1155 orders atomically.
2538
+ * Signs one fulfillment per item (with quantity), sums ERC-20 approvals by token.
2539
+ */
2540
+ checkoutCart(account, items) {
2541
+ return checkoutCart1155(account, items, this.config);
2542
+ }
2543
+ // ─── View calls ───────────────────────────────────────────────────────────
2544
+ getOrderDetails(orderHash) {
2545
+ return getOrderDetails1155(orderHash, this.config);
2546
+ }
2547
+ getNonce(address) {
2548
+ return getNonce1155(address, this.config);
2549
+ }
2359
2550
  // ─── Typed data builders (for ChipiPay / custom signing flows) ───────────
2360
2551
  buildListingTypedData(params, chainId) {
2361
2552
  return build1155OrderTypedData(params, chainId);
@@ -3063,44 +3254,6 @@ var DropService = class {
3063
3254
  return { txHash: res.transaction_hash };
3064
3255
  }
3065
3256
  };
3066
-
3067
- // src/client.ts
3068
- var MedialaneClient = class {
3069
- constructor(rawConfig = {}) {
3070
- this.config = resolveConfig(rawConfig);
3071
- this.marketplace = new MarketplaceModule(this.config);
3072
- this.marketplace1155 = new Medialane1155Module(this.config);
3073
- this.services = {
3074
- pop: new PopService(this.config),
3075
- drop: new DropService(this.config)
3076
- };
3077
- if (!this.config.backendUrl) {
3078
- this.api = new Proxy({}, {
3079
- get(_target, prop) {
3080
- return () => {
3081
- throw new Error(
3082
- `backendUrl not configured. Pass backendUrl to MedialaneClient to use .api.${String(prop)}()`
3083
- );
3084
- };
3085
- }
3086
- });
3087
- } else {
3088
- this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions);
3089
- }
3090
- }
3091
- get network() {
3092
- return this.config.network;
3093
- }
3094
- get rpcUrl() {
3095
- return this.config.rpcUrl;
3096
- }
3097
- get marketplaceContract() {
3098
- return this.config.marketplaceContract;
3099
- }
3100
- };
3101
-
3102
- // src/types/api.ts
3103
- var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
3104
3257
  var ERC1155CollectionService = class {
3105
3258
  constructor(config) {
3106
3259
  this.factoryAddress = config.collection1155Contract ?? COLLECTION_1155_CONTRACT_MAINNET;
@@ -3209,6 +3362,45 @@ var ERC1155CollectionService = class {
3209
3362
  }
3210
3363
  };
3211
3364
 
3212
- export { ApiClient, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_CONTRACT_MAINNET, CollectionRegistryABI, DEFAULT_RPC_URL, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, ERC1155CollectionService, ERC1155_COLLECTION_CLASS_HASH_MAINNET, ERC1155_FACTORY_CONTRACT_MAINNET, INDEXER_START_BLOCK_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPMarketplaceABI, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MARKETPLACE_CLASS_HASH_MAINNET, MARKETPLACE_CONTRACT_MAINNET, MARKETPLACE_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PopService, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, build1155CancellationTypedData, build1155FulfillmentTypedData, build1155OrderTypedData, buildCancellationTypedData, buildFulfillmentTypedData, buildOrderTypedData, formatAmount, getListableTokens, getTokenByAddress, getTokenBySymbol, normalizeAddress, parseAmount, resolveConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
3365
+ // src/client.ts
3366
+ var MedialaneClient = class {
3367
+ constructor(rawConfig = {}) {
3368
+ this.config = resolveConfig(rawConfig);
3369
+ this.marketplace = new MarketplaceModule(this.config);
3370
+ this.marketplace1155 = new Medialane1155Module(this.config);
3371
+ this.services = {
3372
+ pop: new PopService(this.config),
3373
+ drop: new DropService(this.config),
3374
+ erc1155Collection: new ERC1155CollectionService(this.config)
3375
+ };
3376
+ if (!this.config.backendUrl) {
3377
+ this.api = new Proxy({}, {
3378
+ get(_target, prop) {
3379
+ return () => {
3380
+ throw new Error(
3381
+ `backendUrl not configured. Pass backendUrl to MedialaneClient to use .api.${String(prop)}()`
3382
+ );
3383
+ };
3384
+ }
3385
+ });
3386
+ } else {
3387
+ this.api = new ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions);
3388
+ }
3389
+ }
3390
+ get network() {
3391
+ return this.config.network;
3392
+ }
3393
+ get rpcUrl() {
3394
+ return this.config.rpcUrl;
3395
+ }
3396
+ get marketplaceContract() {
3397
+ return this.config.marketplaceContract;
3398
+ }
3399
+ };
3400
+
3401
+ // src/types/api.ts
3402
+ var OPEN_LICENSES = ["CC0", "CC BY", "CC BY-SA", "CC BY-NC"];
3403
+
3404
+ export { ApiClient, COLLECTION_1155_CLASS_HASH_MAINNET, COLLECTION_1155_CONTRACT_MAINNET, COLLECTION_721_CONTRACT_MAINNET, COLLECTION_CONTRACT_MAINNET, CollectionRegistryABI, DEFAULT_RPC_URL, DROP_COLLECTION_CLASS_HASH_MAINNET, DROP_FACTORY_CONTRACT_MAINNET, DropCollectionABI, DropFactoryABI, DropService, ERC1155CollectionService, ERC1155_COLLECTION_CLASS_HASH_MAINNET, ERC1155_FACTORY_CONTRACT_MAINNET, INDEXER_START_BLOCK_MAINNET, IPCollection1155ABI, IPCollection1155FactoryABI, IPMarketplaceABI, MARKETPLACE_1155_CLASS_HASH_MAINNET, MARKETPLACE_1155_CONTRACT_MAINNET, MARKETPLACE_1155_START_BLOCK_MAINNET, MARKETPLACE_721_CLASS_HASH_MAINNET, MARKETPLACE_721_CONTRACT_MAINNET, MARKETPLACE_721_START_BLOCK_MAINNET, MARKETPLACE_CLASS_HASH_MAINNET, MARKETPLACE_CONTRACT_MAINNET, MARKETPLACE_START_BLOCK_MAINNET, MarketplaceModule, Medialane1155ABI, Medialane1155Module, MedialaneApiError, MedialaneClient, MedialaneError, NFTCOMMENTS_CONTRACT_MAINNET, OPEN_LICENSES, POPCollectionABI, POPFactoryABI, POP_COLLECTION_CLASS_HASH_MAINNET, POP_FACTORY_CONTRACT_MAINNET, PopService, SUPPORTED_NETWORKS, SUPPORTED_TOKENS, build1155CancellationTypedData, build1155FulfillmentTypedData, build1155OrderTypedData, buildCancellationTypedData, buildFulfillmentTypedData, buildOrderTypedData, encodeByteArray, formatAmount, getListableTokens, getTokenByAddress, getTokenBySymbol, normalizeAddress, parseAmount, resolveConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
3213
3405
  //# sourceMappingURL=index.js.map
3214
3406
  //# sourceMappingURL=index.js.map