@medialane/sdk 0.34.0 → 0.35.1

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,73 @@ 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 = null;
6323
+ function factoryContract() {
6324
+ if (!_factoryContract) {
6325
+ _factoryContract = new starknet.Contract(
6326
+ CreatorCoinFactoryABI,
6327
+ CREATOR_COIN_FACTORY_CONTRACT_MAINNET
6328
+ );
6329
+ }
6330
+ return _factoryContract;
6331
+ }
6332
+ function buildCreateCreatorCoinCall(params) {
6333
+ const salt = params.salt ?? BigInt("0x" + Date.now().toString(16));
6334
+ return factoryContract().populate("create_creator_coin", [
6335
+ params.owner,
6336
+ params.name,
6337
+ params.symbol,
6338
+ BigInt(params.initialSupply),
6339
+ BigInt(salt)
6340
+ ]);
6341
+ }
6342
+ function buildLaunchOnEkuboCalls(params) {
6343
+ const ek = params.ekubo ?? VALIDATED_EKUBO_PARAMS;
6344
+ const launchParameters = {
6345
+ creator_coin_address: params.creatorCoin,
6346
+ transfer_restriction_delay: params.transferRestrictionDelay ?? 0,
6347
+ max_percentage_buy_launch: params.maxPercentageBuyLaunch ?? 200,
6348
+ quote_address: params.quoteToken,
6349
+ initial_holders: params.initialHolders,
6350
+ initial_holders_amounts: params.initialHoldersAmounts.map((a) => BigInt(a))
6351
+ };
6352
+ const ekuboParameters = {
6353
+ fee: BigInt(ek.fee),
6354
+ tick_spacing: BigInt(ek.tickSpacing),
6355
+ starting_price: { mag: BigInt(ek.startingPrice.mag), sign: ek.startingPrice.sign },
6356
+ bound: BigInt(ek.bound)
6357
+ };
6358
+ const calls = [];
6359
+ if (params.quoteFundAmount !== void 0) {
6360
+ const amt = starknet.uint256.bnToUint256(BigInt(params.quoteFundAmount));
6361
+ calls.push({
6362
+ contractAddress: params.quoteToken,
6363
+ entrypoint: "transfer",
6364
+ calldata: [CREATOR_COIN_FACTORY_CONTRACT_MAINNET, amt.low, amt.high]
6365
+ });
6366
+ }
6367
+ calls.push(factoryContract().populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
6368
+ return calls;
6369
+ }
6370
+ var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
6371
+ function parseCreatorCoinCreated(receipt) {
6372
+ const factory = normalizeAddress(CREATOR_COIN_FACTORY_CONTRACT_MAINNET);
6373
+ for (const ev of receipt?.events ?? []) {
6374
+ let from;
6375
+ try {
6376
+ from = normalizeAddress(ev.from_address ?? "");
6377
+ } catch {
6378
+ continue;
6379
+ }
6380
+ if (from !== factory) continue;
6381
+ const k0 = ev.keys?.[0];
6382
+ if (!k0 || normalizeAddress(k0) !== normalizeAddress(CREATOR_COIN_CREATED_SELECTOR)) continue;
6383
+ const data = ev.data ?? [];
6384
+ if (data.length < 1) continue;
6385
+ return normalizeAddress(data[data.length - 1]);
6386
+ }
6387
+ throw new Error("Coin deployed but the coin address could not be read from the receipt");
6388
+ }
6324
6389
  var CreatorCoinService = class {
6325
6390
  constructor(config) {
6326
6391
  this.factoryAddress = CREATOR_COIN_FACTORY_CONTRACT_MAINNET;
@@ -6331,15 +6396,7 @@ var CreatorCoinService = class {
6331
6396
  }
6332
6397
  /** Deploy a fixed-supply CreatorCoin (full supply minted to the Factory). */
6333
6398
  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]);
6399
+ const res = await account.execute([buildCreateCreatorCoinCall(params)]);
6343
6400
  return { txHash: res.transaction_hash };
6344
6401
  }
6345
6402
  /**
@@ -6348,33 +6405,7 @@ var CreatorCoinService = class {
6348
6405
  * locked in the EkuboLauncher.
6349
6406
  */
6350
6407
  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);
6408
+ const res = await account.execute(buildLaunchOnEkuboCalls(params));
6378
6409
  return { txHash: res.transaction_hash };
6379
6410
  }
6380
6411
  /** View: is this address a Factory-deployed Creator Coin? */
@@ -6632,10 +6663,8 @@ function getServicesByCapability(cap) {
6632
6663
 
6633
6664
  exports.ApiClient = ApiClient;
6634
6665
  exports.COLLECTION_1155_CLASS_HASH_MAINNET = COLLECTION_1155_CLASS_HASH_MAINNET;
6635
- exports.COLLECTION_1155_CONTRACT_LEGACY_MAINNET = COLLECTION_1155_CONTRACT_LEGACY_MAINNET;
6636
6666
  exports.COLLECTION_1155_CONTRACT_MAINNET = COLLECTION_1155_CONTRACT_MAINNET;
6637
6667
  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
6668
  exports.COLLECTION_1155_START_BLOCK_MAINNET = COLLECTION_1155_START_BLOCK_MAINNET;
6640
6669
  exports.COLLECTION_721_CONTRACT_MAINNET = COLLECTION_721_CONTRACT_MAINNET;
6641
6670
  exports.COLLECTION_721_START_BLOCK_MAINNET = COLLECTION_721_START_BLOCK_MAINNET;
@@ -6689,7 +6718,9 @@ exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
6689
6718
  exports.build1155CancellationTypedData = build1155CancellationTypedData;
6690
6719
  exports.build1155OrderTypedData = build1155OrderTypedData;
6691
6720
  exports.buildCancellationTypedData = buildCancellationTypedData;
6721
+ exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
6692
6722
  exports.buildFeeCall = buildFeeCall;
6723
+ exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
6693
6724
  exports.buildOrderTypedData = buildOrderTypedData;
6694
6725
  exports.createFailoverFetch = createFailoverFetch;
6695
6726
  exports.encodeByteArray = encodeByteArray;
@@ -6706,6 +6737,7 @@ exports.listServices = listServices;
6706
6737
  exports.normalizeAddress = normalizeAddress;
6707
6738
  exports.normalizeHash = normalizeHash;
6708
6739
  exports.parseAmount = parseAmount;
6740
+ exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
6709
6741
  exports.resolveConfig = resolveConfig;
6710
6742
  exports.resolveFeeConfig = resolveFeeConfig;
6711
6743
  exports.shortenAddress = shortenAddress;