@medialane/sdk 0.34.0 → 0.35.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.cjs CHANGED
@@ -58,11 +58,9 @@ var DEFAULT_RPC_URL = "https://rpc.starknet.lava.build";
58
58
  var POP_COLLECTION_CLASS_HASH_MAINNET = "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f";
59
59
  var DROP_COLLECTION_CLASS_HASH_MAINNET = "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282";
60
60
  var COLLECTION_1155_CONTRACT_MAINNET = "0x0083543c3ee15040a419fc539fa6889f5b956e7d071bcfa97842cb0ae42ad6cc";
61
- var COLLECTION_1155_CONTRACT_LEGACY_MAINNET = "0x067064adcaaed61e17bf50ea802ea6482336126aec5b4d032b4ff8fbb5009131";
62
61
  var COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = "0x331a69da8655a882ba1fbcb55188b8fa09116521db901bbbaafc9fead0689f8";
63
62
  var COLLECTION_1155_CLASS_HASH_MAINNET = "0x4e110b59af240ae6c7742999964c4eae13fb2ed935c47fe97653ec017ebea34";
64
63
  var COLLECTION_1155_START_BLOCK_MAINNET = 10665319;
65
- var COLLECTION_1155_START_BLOCK_LEGACY_MAINNET = 10045611;
66
64
  var CREATOR_COIN_FACTORY_CONTRACT_MAINNET = "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c";
67
65
  var CREATOR_COIN_EKUBO_LAUNCHER_MAINNET = "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4";
68
66
  var CREATOR_COIN_CLASS_HASH_MAINNET = "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6";
@@ -5399,12 +5397,12 @@ function normalizeAddress(address) {
5399
5397
  throw new Error(`Invalid Starknet address: "${address}"`);
5400
5398
  }
5401
5399
  }
5402
- function normalizeHash(hash) {
5400
+ function normalizeHash(hash2) {
5403
5401
  try {
5404
- const hex = starknet.num.toHex(BigInt(hash));
5402
+ const hex = starknet.num.toHex(BigInt(hash2));
5405
5403
  return "0x" + hex.slice(2).padStart(64, "0").toLowerCase();
5406
5404
  } catch {
5407
- throw new Error(`Invalid Starknet hash: "${hash}"`);
5405
+ throw new Error(`Invalid Starknet hash: "${hash2}"`);
5408
5406
  }
5409
5407
  }
5410
5408
  function shortenAddress(address, chars = 4) {
@@ -6321,6 +6319,67 @@ async function getCreatorCoinPrice(coinAddress, provider) {
6321
6319
  const quotePerCoin = (quoteIsToken0 ? 1 / priceT1perT0 : priceT1perT0) * decAdj;
6322
6320
  return { quotePerCoin, quoteToken, quoteSymbol: token?.symbol ?? null, quoteDecimals };
6323
6321
  }
6322
+ var factoryContract = new starknet.Contract(
6323
+ CreatorCoinFactoryABI,
6324
+ CREATOR_COIN_FACTORY_CONTRACT_MAINNET
6325
+ );
6326
+ function buildCreateCreatorCoinCall(params) {
6327
+ const salt = params.salt ?? BigInt("0x" + Date.now().toString(16));
6328
+ return factoryContract.populate("create_creator_coin", [
6329
+ params.owner,
6330
+ params.name,
6331
+ params.symbol,
6332
+ BigInt(params.initialSupply),
6333
+ BigInt(salt)
6334
+ ]);
6335
+ }
6336
+ function buildLaunchOnEkuboCalls(params) {
6337
+ const ek = params.ekubo ?? VALIDATED_EKUBO_PARAMS;
6338
+ const launchParameters = {
6339
+ creator_coin_address: params.creatorCoin,
6340
+ transfer_restriction_delay: params.transferRestrictionDelay ?? 0,
6341
+ max_percentage_buy_launch: params.maxPercentageBuyLaunch ?? 200,
6342
+ quote_address: params.quoteToken,
6343
+ initial_holders: params.initialHolders,
6344
+ initial_holders_amounts: params.initialHoldersAmounts.map((a) => BigInt(a))
6345
+ };
6346
+ const ekuboParameters = {
6347
+ fee: BigInt(ek.fee),
6348
+ tick_spacing: BigInt(ek.tickSpacing),
6349
+ starting_price: { mag: BigInt(ek.startingPrice.mag), sign: ek.startingPrice.sign },
6350
+ bound: BigInt(ek.bound)
6351
+ };
6352
+ const calls = [];
6353
+ if (params.quoteFundAmount !== void 0) {
6354
+ const amt = starknet.uint256.bnToUint256(BigInt(params.quoteFundAmount));
6355
+ calls.push({
6356
+ contractAddress: params.quoteToken,
6357
+ entrypoint: "transfer",
6358
+ calldata: [CREATOR_COIN_FACTORY_CONTRACT_MAINNET, amt.low, amt.high]
6359
+ });
6360
+ }
6361
+ calls.push(factoryContract.populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
6362
+ return calls;
6363
+ }
6364
+ var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
6365
+ function parseCreatorCoinCreated(receipt) {
6366
+ const factory = normalizeAddress(CREATOR_COIN_FACTORY_CONTRACT_MAINNET);
6367
+ for (const ev of receipt?.events ?? []) {
6368
+ let from;
6369
+ try {
6370
+ from = normalizeAddress(ev.from_address ?? "");
6371
+ } catch {
6372
+ continue;
6373
+ }
6374
+ if (from !== factory) continue;
6375
+ const k0 = ev.keys?.[0];
6376
+ if (!k0 || normalizeAddress(k0) !== normalizeAddress(CREATOR_COIN_CREATED_SELECTOR)) continue;
6377
+ const data = ev.data ?? [];
6378
+ if (data.length < 1) continue;
6379
+ return normalizeAddress(data[data.length - 1]);
6380
+ }
6381
+ throw new Error("Coin deployed but the coin address could not be read from the receipt");
6382
+ }
6324
6383
  var CreatorCoinService = class {
6325
6384
  constructor(config) {
6326
6385
  this.factoryAddress = CREATOR_COIN_FACTORY_CONTRACT_MAINNET;
@@ -6331,15 +6390,7 @@ var CreatorCoinService = class {
6331
6390
  }
6332
6391
  /** Deploy a fixed-supply CreatorCoin (full supply minted to the Factory). */
6333
6392
  async createCreatorCoin(account, params) {
6334
- const salt = params.salt ?? BigInt("0x" + Date.now().toString(16));
6335
- const call = this._factory(account).populate("create_creator_coin", [
6336
- params.owner,
6337
- params.name,
6338
- params.symbol,
6339
- BigInt(params.initialSupply),
6340
- BigInt(salt)
6341
- ]);
6342
- const res = await account.execute([call]);
6393
+ const res = await account.execute([buildCreateCreatorCoinCall(params)]);
6343
6394
  return { txHash: res.transaction_hash };
6344
6395
  }
6345
6396
  /**
@@ -6348,33 +6399,7 @@ var CreatorCoinService = class {
6348
6399
  * locked in the EkuboLauncher.
6349
6400
  */
6350
6401
  async launchOnEkubo(account, params) {
6351
- const ek = params.ekubo ?? VALIDATED_EKUBO_PARAMS;
6352
- const factory = this._factory(account);
6353
- const launchParameters = {
6354
- creator_coin_address: params.creatorCoin,
6355
- transfer_restriction_delay: params.transferRestrictionDelay ?? 0,
6356
- max_percentage_buy_launch: params.maxPercentageBuyLaunch ?? 200,
6357
- quote_address: params.quoteToken,
6358
- initial_holders: params.initialHolders,
6359
- initial_holders_amounts: params.initialHoldersAmounts.map((a) => BigInt(a))
6360
- };
6361
- const ekuboParameters = {
6362
- fee: BigInt(ek.fee),
6363
- tick_spacing: BigInt(ek.tickSpacing),
6364
- starting_price: { mag: BigInt(ek.startingPrice.mag), sign: ek.startingPrice.sign },
6365
- bound: BigInt(ek.bound)
6366
- };
6367
- const calls = [];
6368
- if (params.quoteFundAmount !== void 0) {
6369
- const amt = starknet.uint256.bnToUint256(BigInt(params.quoteFundAmount));
6370
- calls.push({
6371
- contractAddress: params.quoteToken,
6372
- entrypoint: "transfer",
6373
- calldata: [this.factoryAddress, amt.low, amt.high]
6374
- });
6375
- }
6376
- calls.push(factory.populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
6377
- const res = await account.execute(calls);
6402
+ const res = await account.execute(buildLaunchOnEkuboCalls(params));
6378
6403
  return { txHash: res.transaction_hash };
6379
6404
  }
6380
6405
  /** View: is this address a Factory-deployed Creator Coin? */
@@ -6632,10 +6657,8 @@ function getServicesByCapability(cap) {
6632
6657
 
6633
6658
  exports.ApiClient = ApiClient;
6634
6659
  exports.COLLECTION_1155_CLASS_HASH_MAINNET = COLLECTION_1155_CLASS_HASH_MAINNET;
6635
- exports.COLLECTION_1155_CONTRACT_LEGACY_MAINNET = COLLECTION_1155_CONTRACT_LEGACY_MAINNET;
6636
6660
  exports.COLLECTION_1155_CONTRACT_MAINNET = COLLECTION_1155_CONTRACT_MAINNET;
6637
6661
  exports.COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET = COLLECTION_1155_FACTORY_CLASS_HASH_MAINNET;
6638
- exports.COLLECTION_1155_START_BLOCK_LEGACY_MAINNET = COLLECTION_1155_START_BLOCK_LEGACY_MAINNET;
6639
6662
  exports.COLLECTION_1155_START_BLOCK_MAINNET = COLLECTION_1155_START_BLOCK_MAINNET;
6640
6663
  exports.COLLECTION_721_CONTRACT_MAINNET = COLLECTION_721_CONTRACT_MAINNET;
6641
6664
  exports.COLLECTION_721_START_BLOCK_MAINNET = COLLECTION_721_START_BLOCK_MAINNET;
@@ -6689,7 +6712,9 @@ exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
6689
6712
  exports.build1155CancellationTypedData = build1155CancellationTypedData;
6690
6713
  exports.build1155OrderTypedData = build1155OrderTypedData;
6691
6714
  exports.buildCancellationTypedData = buildCancellationTypedData;
6715
+ exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
6692
6716
  exports.buildFeeCall = buildFeeCall;
6717
+ exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
6693
6718
  exports.buildOrderTypedData = buildOrderTypedData;
6694
6719
  exports.createFailoverFetch = createFailoverFetch;
6695
6720
  exports.encodeByteArray = encodeByteArray;
@@ -6706,6 +6731,7 @@ exports.listServices = listServices;
6706
6731
  exports.normalizeAddress = normalizeAddress;
6707
6732
  exports.normalizeHash = normalizeHash;
6708
6733
  exports.parseAmount = parseAmount;
6734
+ exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
6709
6735
  exports.resolveConfig = resolveConfig;
6710
6736
  exports.resolveFeeConfig = resolveFeeConfig;
6711
6737
  exports.shortenAddress = shortenAddress;