@medialane/sdk 0.198.0 → 0.200.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.
Files changed (92) hide show
  1. package/README.md +86 -41
  2. package/dist/chains-CmwjZVU7.d.cts +85 -0
  3. package/dist/chains-CmwjZVU7.d.ts +85 -0
  4. package/dist/chunk-3HPMEDYH.cjs +967 -0
  5. package/dist/chunk-3HPMEDYH.cjs.map +1 -0
  6. package/dist/{chunk-3ME5YKTW.js → chunk-5KY6P434.js} +2 -2
  7. package/dist/chunk-5KY6P434.js.map +1 -0
  8. package/dist/chunk-F7W6IWTL.js +660 -0
  9. package/dist/chunk-F7W6IWTL.js.map +1 -0
  10. package/dist/chunk-GIBIHGSV.js +916 -0
  11. package/dist/chunk-GIBIHGSV.js.map +1 -0
  12. package/dist/chunk-GV4A2WNO.js +444 -0
  13. package/dist/chunk-GV4A2WNO.js.map +1 -0
  14. package/dist/{chunk-7EYJC5CB.cjs → chunk-H2NJB3AK.cjs} +2 -2
  15. package/dist/chunk-H2NJB3AK.cjs.map +1 -0
  16. package/dist/chunk-KGAGWULG.js +932 -0
  17. package/dist/chunk-KGAGWULG.js.map +1 -0
  18. package/dist/chunk-MEJ47LC3.cjs +463 -0
  19. package/dist/chunk-MEJ47LC3.cjs.map +1 -0
  20. package/dist/chunk-W76AZ5WC.cjs +376 -0
  21. package/dist/chunk-W76AZ5WC.cjs.map +1 -0
  22. package/dist/chunk-WRBXQPRL.js +323 -0
  23. package/dist/chunk-WRBXQPRL.js.map +1 -0
  24. package/dist/chunk-ZLMIHQWM.cjs +975 -0
  25. package/dist/chunk-ZLMIHQWM.cjs.map +1 -0
  26. package/dist/chunk-ZVANOWIB.cjs +688 -0
  27. package/dist/chunk-ZVANOWIB.cjs.map +1 -0
  28. package/dist/contract/index.cjs +88 -261
  29. package/dist/contract/index.cjs.map +1 -1
  30. package/dist/contract/index.d.cts +139 -4
  31. package/dist/contract/index.d.ts +139 -4
  32. package/dist/contract/index.js +4 -220
  33. package/dist/contract/index.js.map +1 -1
  34. package/dist/evm/index.cjs +3 -3
  35. package/dist/evm/index.d.cts +2 -1
  36. package/dist/evm/index.d.ts +2 -1
  37. package/dist/evm/index.js +1 -1
  38. package/dist/fetch-Cx9Pr7-B.d.cts +3 -0
  39. package/dist/fetch-Cx9Pr7-B.d.ts +3 -0
  40. package/dist/index.cjs +177 -833
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +54 -132
  43. package/dist/index.d.ts +54 -132
  44. package/dist/index.js +6 -659
  45. package/dist/index.js.map +1 -1
  46. package/dist/passkey-errors-B0HGcjPc.d.ts +981 -0
  47. package/dist/passkey-errors-yndCFeHv.d.cts +981 -0
  48. package/dist/provisioning-CwRkCN8D.d.cts +14 -0
  49. package/dist/provisioning-CwRkCN8D.d.ts +14 -0
  50. package/dist/{provisioning-BUYiU8Tr.d.ts → responses-D3nBY71f.d.cts} +40 -48
  51. package/dist/{provisioning-BUYiU8Tr.d.cts → responses-D3nBY71f.d.ts} +40 -48
  52. package/dist/server/index.cjs +117 -0
  53. package/dist/server/index.cjs.map +1 -0
  54. package/dist/server/index.d.cts +98 -0
  55. package/dist/server/index.d.ts +98 -0
  56. package/dist/server/index.js +4 -0
  57. package/dist/server/index.js.map +1 -0
  58. package/dist/services-B15RJBSW.d.cts +728 -0
  59. package/dist/services-BAnTJhwt.d.ts +728 -0
  60. package/dist/solana/index.cjs +2 -2
  61. package/dist/solana/index.d.cts +2 -1
  62. package/dist/solana/index.d.ts +2 -1
  63. package/dist/solana/index.js +1 -1
  64. package/dist/starknet/index.cjs +898 -1729
  65. package/dist/starknet/index.cjs.map +1 -1
  66. package/dist/starknet/index.d.cts +98 -467
  67. package/dist/starknet/index.d.ts +98 -467
  68. package/dist/starknet/index.js +704 -1680
  69. package/dist/starknet/index.js.map +1 -1
  70. package/dist/stellar/index.cjs +2 -2
  71. package/dist/stellar/index.d.cts +2 -1
  72. package/dist/stellar/index.d.ts +2 -1
  73. package/dist/stellar/index.js +1 -1
  74. package/dist/types-BW6ktwcT.d.ts +71 -0
  75. package/dist/types-BftPOVEJ.d.cts +71 -0
  76. package/dist/wallet/index.cjs +240 -0
  77. package/dist/wallet/index.cjs.map +1 -0
  78. package/dist/wallet/index.d.cts +319 -0
  79. package/dist/wallet/index.d.ts +319 -0
  80. package/dist/wallet/index.js +7 -0
  81. package/dist/wallet/index.js.map +1 -0
  82. package/package.json +13 -2
  83. package/dist/chunk-2R7XBA34.cjs +0 -1938
  84. package/dist/chunk-2R7XBA34.cjs.map +0 -1
  85. package/dist/chunk-3ME5YKTW.js.map +0 -1
  86. package/dist/chunk-6WVUUBFI.js +0 -1853
  87. package/dist/chunk-6WVUUBFI.js.map +0 -1
  88. package/dist/chunk-7EYJC5CB.cjs.map +0 -1
  89. package/dist/errors-CZm-NZK0.d.cts +0 -1754
  90. package/dist/errors-h6H6cj3Q.d.ts +0 -1754
  91. package/dist/types-DC4jNPAF.d.cts +0 -153
  92. package/dist/types-DC4jNPAF.d.ts +0 -153
@@ -1,45 +1,45 @@
1
1
  'use strict';
2
2
 
3
- var chunk2R7XBA34_cjs = require('../chunk-2R7XBA34.cjs');
4
- var chunk7EYJC5CB_cjs = require('../chunk-7EYJC5CB.cjs');
3
+ var chunkMEJ47LC3_cjs = require('../chunk-MEJ47LC3.cjs');
4
+ var chunkZLMIHQWM_cjs = require('../chunk-ZLMIHQWM.cjs');
5
+ var chunk3HPMEDYH_cjs = require('../chunk-3HPMEDYH.cjs');
6
+ var chunkH2NJB3AK_cjs = require('../chunk-H2NJB3AK.cjs');
7
+ require('../chunk-W76AZ5WC.cjs');
5
8
  require('../chunk-Q7SFCCGT.cjs');
6
9
  var starknet = require('starknet');
7
- var hkdf_js = require('@noble/hashes/hkdf.js');
8
- var sha2_js = require('@noble/hashes/sha2.js');
9
10
 
10
- // src/starknet/marketplace/errors.ts
11
- var MedialaneError = class extends Error {
12
- constructor(message, code = "UNKNOWN", cause) {
13
- super(message);
14
- this.code = code;
15
- this.cause = cause;
16
- this.name = "MedialaneError";
17
- }
18
- };
19
-
20
- // src/starknet/marketplace/utils.ts
21
- var START_TIME_BUFFER_SECS = 30;
22
- function newContract(abi, address, providerOrAccount) {
23
- const C = starknet.Contract;
24
- return C.length === 1 ? new starknet.Contract({ abi, address, providerOrAccount }) : new starknet.Contract(
25
- abi,
26
- address,
27
- providerOrAccount
28
- );
11
+ function createChainProvider(backendUrl, apiKey) {
12
+ return new starknet.RpcProvider({
13
+ nodeUrl: `${backendUrl.replace(/\/$/, "")}/v1/rpc`,
14
+ headers: apiKey ? { "x-api-key": apiKey } : {},
15
+ blockIdentifier: "latest"
16
+ });
29
17
  }
30
- function getChainId(config) {
31
- if (config.chain !== "STARKNET") {
32
- throw new Error(`SNIP-12 signing is Starknet-only; got chain "${config.chain}"`);
18
+
19
+ // src/starknet/client.ts
20
+ var NO_BACKEND = "backendUrl not configured. Pass backendUrl to MedialaneClient to use";
21
+ var MedialaneClient = class {
22
+ constructor(rawConfig = {}) {
23
+ this.config = chunkMEJ47LC3_cjs.resolveConfig(rawConfig);
24
+ const config = this.config;
25
+ this.api = config.backendUrl ? new chunk3HPMEDYH_cjs.ApiClient({ baseUrl: config.backendUrl, apiKey: config.apiKey, retry: config.retryOptions, chain: config.chain }) : new chunk3HPMEDYH_cjs.ApiClient({
26
+ baseUrl: "https://medialane-sdk-no-backend.invalid",
27
+ apiKey: config.apiKey,
28
+ fetch: () => {
29
+ throw new Error(`${NO_BACKEND} .api`);
30
+ }
31
+ });
33
32
  }
34
- return starknet.constants.StarknetChainId.SN_MAIN;
35
- }
36
- function resolveToken(currency) {
37
- const token = chunk2R7XBA34_cjs.SUPPORTED_TOKENS.find(
38
- (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
39
- );
40
- if (!token) throw new MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
41
- return token;
42
- }
33
+ get chain() {
34
+ return this.config.chain;
35
+ }
36
+ get provider() {
37
+ if (!this.config.backendUrl) {
38
+ throw new Error(`${NO_BACKEND} .provider`);
39
+ }
40
+ return this._provider ?? (this._provider = createChainProvider(this.config.backendUrl, this.config.apiKey));
41
+ }
42
+ };
43
43
 
44
44
  // src/starknet/abis/ipMarketplace.ts
45
45
  var IPMarketplaceABI = [
@@ -10377,148 +10377,121 @@ var IPGenesisABI = [
10377
10377
  ]
10378
10378
  }
10379
10379
  ];
10380
- var FRAGMENT_KEY = "pop-proof";
10381
- var toHex = (x) => "0x" + x.toString(16).padStart(64, "0");
10382
- var poseidon = (xs) => BigInt(starknet.hash.computePoseidonHashOnElements(xs.map((x) => "0x" + x.toString(16))));
10383
- var nodeHash = (a, b) => a < b ? poseidon([a, b]) : poseidon([b, a]);
10384
- function popLeafHash(address) {
10385
- return poseidon([poseidon([BigInt(address)])]);
10380
+ var START_TIME_BUFFER_SECS = 30;
10381
+ function newContract(abi, address, providerOrAccount) {
10382
+ const C = starknet.Contract;
10383
+ return C.length === 1 ? new starknet.Contract({ abi, address, providerOrAccount }) : new starknet.Contract(
10384
+ abi,
10385
+ address,
10386
+ providerOrAccount
10387
+ );
10386
10388
  }
10387
- function merkleTree(leafHashes) {
10388
- const leaves = [...leafHashes].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
10389
- const tree = new Array(2 * leaves.length - 1);
10390
- leaves.forEach((leaf, i) => tree[tree.length - 1 - i] = leaf);
10391
- for (let i = tree.length - 1 - leaves.length; i >= 0; i--) {
10392
- tree[i] = nodeHash(tree[2 * i + 1], tree[2 * i + 2]);
10389
+ function getChainId(config) {
10390
+ if (config.chain !== "STARKNET") {
10391
+ throw new Error(`SNIP-12 signing is Starknet-only; got chain "${config.chain}"`);
10393
10392
  }
10394
- return {
10395
- root: tree[0],
10396
- proof(leaf) {
10397
- let i = tree.lastIndexOf(leaf);
10398
- if (i < tree.length - leaves.length) throw new Error("Not a leaf of this tree");
10399
- const proof = [];
10400
- while (i > 0) {
10401
- proof.push(tree[i % 2 === 1 ? i + 1 : i - 1]);
10402
- i = Math.floor((i - 1) / 2);
10403
- }
10404
- return proof;
10405
- }
10406
- };
10407
- }
10408
- function buildPopAllowlist(addresses) {
10409
- const unique = [...new Set(addresses.map((a) => chunk2R7XBA34_cjs.normalizeAddress("STARKNET", a)))];
10410
- if (unique.length === 0) throw new Error("An allowlist needs at least one address");
10411
- const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
10412
- const tree = merkleTree(leaves.map((l) => l.leaf));
10413
- const proofs = {};
10414
- for (const { address, leaf } of leaves) proofs[address] = tree.proof(leaf).map(toHex);
10415
- return { root: toHex(tree.root), proofs };
10416
- }
10417
- function verifyPopProof(root, address, proof) {
10418
- let computed = popLeafHash(address);
10419
- for (const sibling of proof) computed = nodeHash(computed, BigInt(sibling));
10420
- return computed === BigInt(root);
10421
- }
10422
- function encodePopClaimFragment(proof) {
10423
- return `#${FRAGMENT_KEY}=${proof.join(",")}`;
10393
+ return starknet.constants.StarknetChainId.SN_MAIN;
10424
10394
  }
10425
- function decodePopClaimFragment(fragment) {
10426
- const raw = new URLSearchParams(fragment.replace(/^#/, "")).get(FRAGMENT_KEY);
10427
- if (raw === null) return null;
10428
- if (raw === "") return [];
10429
- const parts = raw.split(",");
10430
- return parts.every((p) => /^0x[0-9a-fA-F]{1,64}$/.test(p)) ? parts : null;
10395
+ function resolveToken(currency) {
10396
+ const token = chunk3HPMEDYH_cjs.SUPPORTED_TOKENS.find(
10397
+ (t) => t.symbol === currency.toUpperCase() || t.address.toLowerCase() === currency.toLowerCase()
10398
+ );
10399
+ if (!token) throw new chunk3HPMEDYH_cjs.MedialaneError(`Unsupported currency: ${currency}`, "INVALID_PARAMS");
10400
+ return token;
10431
10401
  }
10432
-
10433
- // src/starknet/pop-claim.ts
10434
- function popClaimLinks(origin, collection, list) {
10435
- const base = `${origin}${chunk2R7XBA34_cjs.collectionHref("STARKNET", collection)}`;
10436
- return Object.entries(list.proofs).map(([address, proof]) => ({
10437
- address,
10438
- url: `${base}${encodePopClaimFragment(proof)}`
10439
- }));
10402
+ var STARKNET_DOMAIN = [
10403
+ { name: "name", type: "shortstring" },
10404
+ { name: "version", type: "shortstring" },
10405
+ { name: "chainId", type: "shortstring" },
10406
+ { name: "revision", type: "shortstring" }
10407
+ ];
10408
+ var OFFER_ITEM = [
10409
+ { name: "item_type", type: "shortstring" },
10410
+ { name: "token", type: "ContractAddress" },
10411
+ { name: "identifier_or_criteria", type: "felt" },
10412
+ { name: "amount", type: "felt" }
10413
+ ];
10414
+ var CONSIDERATION_ITEM = [
10415
+ { name: "item_type", type: "shortstring" },
10416
+ { name: "token", type: "ContractAddress" },
10417
+ { name: "identifier_or_criteria", type: "felt" },
10418
+ { name: "amount", type: "felt" },
10419
+ { name: "recipient", type: "ContractAddress" }
10420
+ ];
10421
+ var ORDER_PARAMETERS = [
10422
+ { name: "offerer", type: "ContractAddress" },
10423
+ { name: "marketplace", type: "ContractAddress" },
10424
+ { name: "offer", type: "OfferItem" },
10425
+ { name: "consideration", type: "ConsiderationItem" },
10426
+ { name: "royalty_max_bps", type: "felt" },
10427
+ { name: "start_time", type: "felt" },
10428
+ { name: "end_time", type: "felt" },
10429
+ { name: "salt", type: "felt" },
10430
+ { name: "counter", type: "felt" }
10431
+ ];
10432
+ var ORDER_CANCELLATION = [
10433
+ { name: "order_hash", type: "felt" },
10434
+ { name: "offerer", type: "ContractAddress" }
10435
+ ];
10436
+ var DOMAIN_VERSION = {
10437
+ erc721: "5",
10438
+ erc1155: "4"
10439
+ };
10440
+ function buildDomain(standard, chainId) {
10441
+ return {
10442
+ name: "Medialane",
10443
+ version: DOMAIN_VERSION[standard],
10444
+ chainId,
10445
+ revision: starknet.TypedDataRevision.ACTIVE
10446
+ };
10440
10447
  }
10441
- function popClaimLinksCsv(links) {
10442
- return ["address,claim_link", ...links.map((l) => `${l.address},${l.url}`)].join("\n");
10448
+ function buildOrderTypedData(message, chainId) {
10449
+ return {
10450
+ domain: buildDomain("erc721", chainId),
10451
+ primaryType: "OrderParameters",
10452
+ types: {
10453
+ StarknetDomain: STARKNET_DOMAIN,
10454
+ OrderParameters: ORDER_PARAMETERS,
10455
+ OfferItem: OFFER_ITEM,
10456
+ ConsiderationItem: CONSIDERATION_ITEM
10457
+ },
10458
+ message
10459
+ };
10443
10460
  }
10444
- async function popClaimInfo(provider, collection) {
10445
- const contractAddress = chunk2R7XBA34_cjs.normalizeAddress("STARKNET", collection);
10446
- const [root, end] = await Promise.all([
10447
- provider.callContract({ contractAddress, entrypoint: "allowlist_root", calldata: [] }),
10448
- provider.callContract({ contractAddress, entrypoint: "claim_end_time", calldata: [] })
10449
- ]);
10450
- return { root: root[0] ?? "0x0", claimEndTime: Number(BigInt(end[0] ?? "0x0")) };
10461
+ function build1155OrderTypedData(message, chainId) {
10462
+ return {
10463
+ domain: buildDomain("erc1155", chainId),
10464
+ primaryType: "OrderParameters",
10465
+ types: {
10466
+ StarknetDomain: STARKNET_DOMAIN,
10467
+ OrderParameters: ORDER_PARAMETERS,
10468
+ OfferItem: OFFER_ITEM,
10469
+ ConsiderationItem: CONSIDERATION_ITEM
10470
+ },
10471
+ message
10472
+ };
10451
10473
  }
10452
- function popClaimState(input) {
10453
- const { hasClaimed, proof, wallet, info } = input;
10454
- if (hasClaimed === true) return "claimed";
10455
- if (hasClaimed === null || info === null) return "loading";
10456
- if (BigInt(info.root) === 0n) return "closed";
10457
- if (info.claimEndTime !== 0 && info.now > info.claimEndTime) return "ended";
10458
- if (proof === null) return "no-link";
10459
- if (!wallet || !verifyPopProof(info.root, wallet, proof)) return "wrong-wallet";
10460
- return "ready";
10474
+ function buildCancellationTypedData(message, chainId) {
10475
+ return {
10476
+ domain: buildDomain("erc721", chainId),
10477
+ primaryType: "OrderCancellation",
10478
+ types: {
10479
+ StarknetDomain: STARKNET_DOMAIN,
10480
+ OrderCancellation: ORDER_CANCELLATION
10481
+ },
10482
+ message
10483
+ };
10461
10484
  }
10462
- var addr = (a) => chunk2R7XBA34_cjs.normalizeAddress("STARKNET", a);
10463
- var byteArrayFelts = (s) => starknet.CallData.compile([starknet.byteArray.byteArrayFromString(s)]);
10464
- var popCalls = {
10465
- claim(collection, proof) {
10466
- return { contractAddress: addr(collection), entrypoint: "claim", calldata: [String(proof.length), ...proof] };
10467
- },
10468
- /** An empty `tokenUri` uses the collection's URI. */
10469
- issue(collection, recipient, tokenUri = "") {
10470
- return { contractAddress: addr(collection), entrypoint: "issue", calldata: [addr(recipient), ...byteArrayFelts(tokenUri)] };
10471
- },
10472
- /** Only the token's holder can burn it. */
10473
- burn(collection, tokenId) {
10474
- const id = starknet.cairo.uint256(BigInt(tokenId));
10475
- return { contractAddress: addr(collection), entrypoint: "burn", calldata: [String(id.low), String(id.high)] };
10476
- },
10477
- setAllowlistRoot(collection, root) {
10478
- return { contractAddress: addr(collection), entrypoint: "set_allowlist_root", calldata: [root] };
10479
- }
10480
- };
10481
-
10482
- // src/starknet/services/pop.ts
10483
- var PopService = class {
10484
- constructor(config) {
10485
- this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).popFactory;
10486
- }
10487
- async createCollection(account, params) {
10488
- const factory = newContract(POPFactoryABI, this.factoryAddress, account);
10489
- const call = factory.populate("create_collection", [params.name, params.symbol, params.baseUri, params.claimEndTime]);
10490
- const res = await account.execute([call]);
10491
- return { txHash: res.transaction_hash };
10492
- }
10493
- async setAllowlistRoot(account, params) {
10494
- const call = popCalls.setAllowlistRoot(params.collection, params.root);
10495
- const res = await account.execute([call]);
10496
- return { txHash: res.transaction_hash };
10497
- }
10498
- async claim(account, params) {
10499
- const call = popCalls.claim(params.collection, params.proof);
10500
- const res = await account.execute([call]);
10501
- return { txHash: res.transaction_hash };
10502
- }
10503
- async issue(account, params) {
10504
- const call = popCalls.issue(params.collection, params.recipient, params.tokenUri);
10505
- const res = await account.execute([call]);
10506
- return { txHash: res.transaction_hash };
10507
- }
10508
- /** Destroys the caller's own credential; the address cannot receive another from this collection. */
10509
- async burn(account, params) {
10510
- const call = popCalls.burn(params.collection, params.tokenId);
10511
- const res = await account.execute([call]);
10512
- return { txHash: res.transaction_hash };
10513
- }
10514
- };
10515
- async function popHasClaimed(provider, collection, address) {
10516
- const res = await provider.callContract({
10517
- contractAddress: chunk2R7XBA34_cjs.normalizeAddress("STARKNET", collection),
10518
- entrypoint: "has_claimed",
10519
- calldata: [chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address)]
10520
- });
10521
- return BigInt(res[0] ?? "0x0") !== 0n;
10485
+ function build1155CancellationTypedData(message, chainId) {
10486
+ return {
10487
+ domain: buildDomain("erc1155", chainId),
10488
+ primaryType: "OrderCancellation",
10489
+ types: {
10490
+ StarknetDomain: STARKNET_DOMAIN,
10491
+ OrderCancellation: ORDER_CANCELLATION
10492
+ },
10493
+ message
10494
+ };
10522
10495
  }
10523
10496
  function feeBps(surface, cfg) {
10524
10497
  if (!cfg.enabled || !cfg.fundAddress) return 0;
@@ -10537,815 +10510,15 @@ function buildFeeCall(p, cfg) {
10537
10510
  calldata: [cfg.fundAddress, u.low.toString(), u.high.toString()]
10538
10511
  };
10539
10512
  }
10540
- var DROP_MAX_CLAIM_QUANTITY = 50n;
10541
- var addr2 = (a) => chunk2R7XBA34_cjs.normalizeAddress("STARKNET", a);
10542
- var factoryData = new starknet.CallData(DropFactoryABI);
10543
- var collectionData = new starknet.CallData(DropCollectionABI);
10544
- function toContractTerms(t) {
10545
- const price = BigInt(t.price);
10546
- return {
10547
- start_time: t.startTime,
10548
- end_time: t.endTime,
10549
- price: starknet.cairo.uint256(price),
10550
- payment_token: price === 0n ? "0x0" : addr2(t.paymentToken),
10551
- max_per_wallet: starknet.cairo.uint256(BigInt(t.maxPerWallet))
10552
- };
10553
- }
10554
- var dropCalls = {
10555
- create(factory, p) {
10556
- return {
10557
- contractAddress: addr2(factory),
10558
- entrypoint: "create_drop",
10559
- calldata: factoryData.compile("create_drop", {
10560
- name: p.name,
10561
- symbol: p.symbol,
10562
- base_uri: p.baseUri,
10563
- max_supply: starknet.cairo.uint256(BigInt(p.maxSupply)),
10564
- terms: toContractTerms(p.terms),
10565
- allowlist_root: p.allowlistRoot ?? "0x0"
10566
- })
10567
- };
10568
- },
10569
- /** Approve (paid drops) and claim. The platform fee call is added by the caller. */
10570
- claim(collection, p) {
10571
- const quantity = BigInt(p.quantity);
10572
- if (quantity < 1n || quantity > DROP_MAX_CLAIM_QUANTITY) throw new RangeError(`quantity must be 1 to ${DROP_MAX_CLAIM_QUANTITY}`);
10573
- const total = BigInt(p.price) * quantity;
10574
- const calls = [];
10575
- if (total > 0n) {
10576
- calls.push({
10577
- contractAddress: addr2(p.paymentToken),
10578
- entrypoint: "approve",
10579
- calldata: starknet.CallData.compile([addr2(collection), starknet.cairo.uint256(total)])
10580
- });
10581
- }
10582
- calls.push({
10583
- contractAddress: addr2(collection),
10584
- entrypoint: "claim",
10585
- calldata: collectionData.compile("claim", { quantity: starknet.cairo.uint256(quantity), proof: p.proof ?? [] })
10586
- });
10587
- return calls;
10588
- },
10589
- /** Organizer only: free mint within the supply cap. */
10590
- issue(collection, recipient, quantity) {
10591
- const q = BigInt(quantity);
10592
- if (q < 1n) throw new RangeError("quantity must be at least 1");
10593
- return {
10594
- contractAddress: addr2(collection),
10595
- entrypoint: "issue",
10596
- calldata: collectionData.compile("issue", { recipient: addr2(recipient), quantity: starknet.cairo.uint256(q) })
10597
- };
10598
- },
10599
- /** Organizer only. 0 opens the drop to everyone. */
10600
- setAllowlistRoot(collection, root) {
10601
- return { contractAddress: addr2(collection), entrypoint: "set_allowlist_root", calldata: collectionData.compile("set_allowlist_root", { root }) };
10602
- }
10603
- };
10604
- function dropMintCost(price, quantity, feeBps2) {
10605
- const subtotal = BigInt(price) * BigInt(quantity);
10606
- const fee = feeAmount(subtotal, feeBps2);
10607
- return { subtotal, fee, total: subtotal + fee };
10608
- }
10609
-
10610
- // src/starknet/drop-state.ts
10611
- var hex = (v) => chunk2R7XBA34_cjs.normalizeAddress("STARKNET", v ?? "0x0");
10612
- var u256 = (low, high) => BigInt(low ?? "0x0") + (BigInt(high ?? "0x0") << 128n);
10613
- async function readDrop(provider, collection) {
10614
- const contractAddress = hex(collection);
10615
- const read = (entrypoint) => provider.callContract({ contractAddress, entrypoint, calldata: [] });
10616
- const [organizer, terms, root, max, minted] = await Promise.all([
10617
- read("organizer"),
10618
- read("terms"),
10619
- read("allowlist_root"),
10620
- read("max_supply"),
10621
- read("total_minted")
10622
- ]);
10623
- return {
10624
- organizer: hex(organizer[0]),
10625
- startTime: Number(BigInt(terms[0] ?? "0x0")),
10626
- endTime: Number(BigInt(terms[1] ?? "0x0")),
10627
- price: u256(terms[2], terms[3]),
10628
- paymentToken: hex(terms[4]),
10629
- maxPerWallet: u256(terms[5], terms[6]),
10630
- allowlistRoot: root[0] ?? "0x0",
10631
- maxSupply: u256(max[0], max[1]),
10632
- totalMinted: u256(minted[0], minted[1])
10633
- };
10634
- }
10635
- async function dropClaimedBy(provider, collection, wallet) {
10636
- const res = await provider.callContract({ contractAddress: hex(collection), entrypoint: "claimed_by", calldata: [hex(wallet)] });
10637
- return u256(res[0], res[1]);
10638
- }
10639
- function dropMintState(input) {
10640
- const none = (state) => ({ state, maxQuantity: 0n });
10641
- const { drop, wallet, claimed, proof, balance, now } = input;
10642
- if (!drop) return none("loading");
10643
- if (drop.startTime !== 0 && now < drop.startTime) return none("upcoming");
10644
- if (drop.endTime !== 0 && now > drop.endTime) return none("ended");
10645
- const supplyLeft = drop.maxSupply === 0n ? null : drop.maxSupply - drop.totalMinted;
10646
- if (supplyLeft !== null && supplyLeft <= 0n) return none("sold-out");
10647
- if (!wallet) return none("no-wallet");
10648
- if (BigInt(drop.allowlistRoot) !== 0n) {
10649
- if (proof === null) return none("no-link");
10650
- if (!verifyPopProof(drop.allowlistRoot, wallet, proof)) return none("not-on-list");
10651
- }
10652
- if (claimed === null) return none("loading");
10653
- const walletLeft = drop.maxPerWallet === 0n ? null : drop.maxPerWallet - claimed;
10654
- if (walletLeft !== null && walletLeft <= 0n) return none("limit-reached");
10655
- let max = DROP_MAX_CLAIM_QUANTITY;
10656
- if (supplyLeft !== null && supplyLeft < max) max = supplyLeft;
10657
- if (walletLeft !== null && walletLeft < max) max = walletLeft;
10658
- if (drop.price > 0n) {
10659
- if (balance === null) return none("loading");
10660
- while (max > 0n && dropMintCost(drop.price, max, input.feeBps).total > balance) max--;
10661
- if (max === 0n) return none("insufficient-balance");
10662
- }
10663
- return { state: "ready", maxQuantity: max };
10664
- }
10665
- function dropClaimLinks(origin, collection, list) {
10666
- const base = `${origin}${chunk2R7XBA34_cjs.dropHref(collection)}`;
10667
- return Object.entries(list.proofs).map(([address, proof]) => ({
10668
- address,
10669
- url: `${base}${encodePopClaimFragment(proof)}`
10670
- }));
10671
- }
10672
-
10673
- // src/starknet/services/drop.ts
10674
- var DropService = class {
10675
- constructor(config) {
10676
- this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).dropFactory;
10677
- this.config = config;
10678
- }
10679
- async createDrop(account, params) {
10680
- const res = await account.execute([dropCalls.create(this.factoryAddress, params)]);
10681
- return { txHash: res.transaction_hash };
10682
- }
10683
- /** Mints `quantity` to the account, paying the drop's price and the platform fee. */
10684
- async claim(account, params) {
10685
- const drop = await readDrop(account.provider, params.collection);
10686
- const calls = dropCalls.claim(params.collection, {
10687
- quantity: params.quantity,
10688
- proof: params.proof,
10689
- price: drop.price,
10690
- paymentToken: drop.paymentToken
10691
- });
10692
- const fee = drop.price > 0n ? buildFeeCall(
10693
- { surface: "launchpad", token: drop.paymentToken, grossAmount: drop.price * BigInt(params.quantity) },
10694
- this.config.feeConfig
10695
- ) : null;
10696
- const res = await account.execute(fee ? [...calls, fee] : calls);
10697
- return { txHash: res.transaction_hash };
10698
- }
10699
- async issue(account, params) {
10700
- const res = await account.execute([dropCalls.issue(params.collection, params.recipient, params.quantity)]);
10701
- return { txHash: res.transaction_hash };
10702
- }
10703
- async setAllowlistRoot(account, params) {
10704
- const res = await account.execute([dropCalls.setAllowlistRoot(params.collection, params.root)]);
10705
- return { txHash: res.transaction_hash };
10706
- }
10707
- };
10708
-
10709
- // src/starknet/services/erc1155collection.ts
10710
- var ERC1155CollectionService = class {
10711
- constructor(config) {
10712
- this.factoryAddress = config.collection1155Contract ?? chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).collection1155;
10713
- }
10714
- _factory(account) {
10715
- return newContract(
10716
- IPCollection1155FactoryABI,
10717
- chunk2R7XBA34_cjs.normalizeAddress("STARKNET", this.factoryAddress),
10718
- account
10719
- );
10720
- }
10721
- _collection(address, account) {
10722
- return newContract(
10723
- IPCollection1155ABI,
10724
- chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address),
10725
- account
10726
- );
10727
- }
10728
- async deployCollection(account, params) {
10729
- const factory = this._factory(account);
10730
- const call = factory.populate("deploy_collection", [params.name, params.symbol, params.baseUri]);
10731
- const res = await account.execute([call]);
10732
- return { txHash: res.transaction_hash };
10733
- }
10734
- async mintEdition(account, params) {
10735
- const collection = this._collection(params.collection, account);
10736
- const call = collection.populate("mint_edition", [
10737
- params.to,
10738
- BigInt(params.value),
10739
- params.tokenUri
10740
- ]);
10741
- const res = await account.execute([call]);
10742
- return { txHash: res.transaction_hash };
10743
- }
10744
- async batchMintEdition(account, params) {
10745
- const collection = this._collection(params.collection, account);
10746
- const values = params.items.map((i) => BigInt(i.value));
10747
- const tokenUris = params.items.map((i) => i.tokenUri);
10748
- const call = collection.populate("batch_mint_edition", [
10749
- params.to,
10750
- values,
10751
- tokenUris
10752
- ]);
10753
- const res = await account.execute([call]);
10754
- return { txHash: res.transaction_hash };
10755
- }
10756
- async addSupply(account, params) {
10757
- const collection = this._collection(params.collection, account);
10758
- const call = collection.populate("add_supply", [
10759
- params.to,
10760
- BigInt(params.tokenId),
10761
- BigInt(params.value)
10762
- ]);
10763
- const res = await account.execute([call]);
10764
- return { txHash: res.transaction_hash };
10765
- }
10766
- async setDefaultRoyalty(account, params) {
10767
- const collection = this._collection(params.collection, account);
10768
- const call = collection.populate("set_default_royalty", [
10769
- params.receiver,
10770
- BigInt(params.feeNumerator)
10771
- ]);
10772
- const res = await account.execute([call]);
10773
- return { txHash: res.transaction_hash };
10774
- }
10775
- async setTokenRoyalty(account, params) {
10776
- const collection = this._collection(params.collection, account);
10777
- const call = collection.populate("set_token_royalty", [
10778
- BigInt(params.tokenId),
10779
- params.receiver,
10780
- BigInt(params.feeNumerator)
10781
- ]);
10782
- const res = await account.execute([call]);
10783
- return { txHash: res.transaction_hash };
10784
- }
10785
- async setApprovalForAll(account, params) {
10786
- const collection = this._collection(params.collection, account);
10787
- const call = collection.populate("set_approval_for_all", [
10788
- params.operator,
10789
- params.approved
10790
- ]);
10791
- const res = await account.execute([call]);
10792
- return { txHash: res.transaction_hash };
10793
- }
10794
- };
10795
-
10796
- // src/starknet/services/coinLaunchMath.ts
10797
- var COIN_DECIMALS = 18;
10798
- var SUGGESTED_DEFAULT_PRICE = 0.01;
10799
- var MIN_SUPPLY = 1000n;
10800
- var MAX_SUPPLY = 1000000000000n;
10801
- var MAX_FELT_BYTES = 31;
10802
- function byteLen(s) {
10803
- return new TextEncoder().encode(s).length;
10804
- }
10805
- function validateName(s) {
10806
- if (!s.trim()) return "Name is required";
10807
- if (byteLen(s) > MAX_FELT_BYTES) return `Name must be at most ${MAX_FELT_BYTES} bytes`;
10808
- return null;
10809
- }
10810
- function validateSymbol(s) {
10811
- if (!s.trim()) return "Symbol is required";
10812
- if (byteLen(s) > MAX_FELT_BYTES) return `Symbol must be at most ${MAX_FELT_BYTES} bytes`;
10813
- return null;
10814
- }
10815
- function validateSupply(human) {
10816
- if (!/^\d+$/.test(human.trim())) return "Supply must be a whole number";
10817
- const v = BigInt(human.trim());
10818
- if (v < MIN_SUPPLY) return `Supply must be at least ${MIN_SUPPLY.toString()}`;
10819
- if (v > MAX_SUPPLY) return `Supply must be at most ${MAX_SUPPLY.toString()}`;
10820
- return null;
10821
- }
10822
- function toRaw(human, decimals = COIN_DECIMALS) {
10823
- return human * 10n ** BigInt(decimals);
10824
- }
10825
- function teamCoinsRaw(supplyRaw, pct) {
10826
- const bps = BigInt(Math.round(pct * 100));
10827
- return supplyRaw * bps / 10000n;
10828
- }
10829
- var PRICE_SCALE = 1000000000000n;
10830
- function buybackQuoteRaw(teamCoinsRawValue, price, quoteDecimals) {
10831
- const priceScaled = BigInt(Math.round(price * Number(PRICE_SCALE)));
10832
- return teamCoinsRawValue * priceScaled * 10n ** BigInt(quoteDecimals) / (PRICE_SCALE * 10n ** BigInt(COIN_DECIMALS));
10833
- }
10834
- function fdvHuman(supplyHuman, price) {
10835
- return supplyHuman * price;
10836
- }
10837
-
10838
- // src/starknet/services/creatorCoin.ts
10839
- var VALIDATED_EKUBO_PARAMS = {
10840
- fee: "0xc49ba5e353f7d00000000000000000",
10841
- tickSpacing: 5982n,
10842
- startingPrice: { mag: 4600158n, sign: true },
10843
- bound: 88719042n
10844
- };
10845
- var TICK_BASE = 1.000001;
10846
- function priceToEkuboParams(quoteDecimals, price = SUGGESTED_DEFAULT_PRICE) {
10847
- const decAdj = 10 ** (COIN_DECIMALS - quoteDecimals);
10848
- const rawRatio = price / decAdj;
10849
- const tickSpacing = Number(VALIDATED_EKUBO_PARAMS.tickSpacing);
10850
- const rawTick = Math.log(rawRatio) / Math.log(TICK_BASE);
10851
- const roundedTick = Math.trunc(rawTick / tickSpacing) * tickSpacing;
10852
- return {
10853
- fee: VALIDATED_EKUBO_PARAMS.fee,
10854
- tickSpacing: VALIDATED_EKUBO_PARAMS.tickSpacing,
10855
- startingPrice: { mag: BigInt(Math.abs(roundedTick)), sign: roundedTick < 0 },
10856
- bound: VALIDATED_EKUBO_PARAMS.bound
10857
- };
10858
- }
10859
- function validatePrice(quoteDecimals, price) {
10860
- if (!isFinite(price) || price <= 0) return "Price must be a positive number";
10861
- const decAdj = 10 ** (COIN_DECIMALS - quoteDecimals);
10862
- const rawRatio = price / decAdj;
10863
- if (!isFinite(rawRatio) || rawRatio <= 0) return "Price must be a positive number";
10864
- const rawTick = Math.log(rawRatio) / Math.log(TICK_BASE);
10865
- if (!isFinite(rawTick)) return "Price is outside the supported range";
10866
- const bound = Number(VALIDATED_EKUBO_PARAMS.bound);
10867
- if (Math.abs(rawTick) >= bound) return "Price is outside the supported range";
10868
- return null;
10869
- }
10870
- var MAX_TEAM_ALLOCATION_PERCENT = 10;
10871
- var MAX_HOLDERS_AT_LAUNCH = 10;
10872
- function u2562(parts, offset = 0) {
10873
- return BigInt(parts[offset] ?? "0x0") + (BigInt(parts[offset + 1] ?? "0x0") << 128n);
10874
- }
10875
- async function getCreatorCoinGuarantees(coinAddress, provider) {
10876
- const call = (entrypoint) => provider.callContract({ contractAddress: coinAddress, entrypoint, calldata: [] });
10877
- const [launchedRes, allocRes] = await Promise.all([
10878
- call("is_launched").catch(() => null),
10879
- call("get_team_allocation").catch(() => null)
10880
- ]);
10881
- if (!launchedRes || !allocRes) return null;
10882
- const [supplyRes, blockRes, liquidityRes] = await Promise.all([
10883
- call("total_supply"),
10884
- call("launched_at_block_number").catch(() => null),
10885
- call("liquidity_type").catch(() => null)
10886
- ]);
10887
- const isLaunched = BigInt(launchedRes[0] ?? "0x0") !== 0n;
10888
- const totalSupply = u2562(supplyRes);
10889
- const teamAllocation = u2562(allocRes);
10890
- const teamAllocationPercent = totalSupply > 0n ? Number(teamAllocation * 10000n / totalSupply) / 100 : null;
10891
- const launchedAtBlock = isLaunched && blockRes?.[0] != null ? Number(BigInt(blockRes[0])) : null;
10892
- const liquidityPositionId = liquidityRes && BigInt(liquidityRes[0] ?? "0x1") === 0n && liquidityRes[2] != null ? BigInt(liquidityRes[2]).toString() : null;
10893
- return {
10894
- isLaunched,
10895
- launchedAtBlock,
10896
- totalSupplyRaw: totalSupply.toString(),
10897
- teamAllocationRaw: teamAllocation.toString(),
10898
- teamAllocationPercent,
10899
- liquidityPositionId
10900
- };
10901
- }
10902
- var _factoryContract = null;
10903
- function factoryContract() {
10904
- if (!_factoryContract) {
10905
- _factoryContract = newContract(
10906
- CreatorCoinFactoryABI,
10907
- chunk7EYJC5CB_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory
10908
- );
10909
- }
10910
- return _factoryContract;
10911
- }
10912
- function buildCreateCreatorCoinCall(params) {
10913
- const salt = params.salt ?? BigInt("0x" + Date.now().toString(16));
10914
- return factoryContract().populate("create_creator_coin", [
10915
- params.owner,
10916
- params.name,
10917
- params.symbol,
10918
- BigInt(params.initialSupply),
10919
- BigInt(salt)
10920
- ]);
10921
- }
10922
- function buildLaunchOnEkuboCalls(params) {
10923
- const ek = params.ekubo;
10924
- const launchParameters = {
10925
- creator_coin_address: params.creatorCoin,
10926
- transfer_restriction_delay: params.transferRestrictionDelay ?? 0,
10927
- max_percentage_buy_launch: params.maxPercentageBuyLaunch ?? 200,
10928
- quote_address: params.quoteToken,
10929
- initial_holders: params.initialHolders,
10930
- initial_holders_amounts: params.initialHoldersAmounts.map((a) => BigInt(a))
10931
- };
10932
- const ekuboParameters = {
10933
- fee: BigInt(ek.fee),
10934
- tick_spacing: BigInt(ek.tickSpacing),
10935
- starting_price: { mag: BigInt(ek.startingPrice.mag), sign: ek.startingPrice.sign },
10936
- bound: BigInt(ek.bound)
10937
- };
10938
- const calls = [];
10939
- if (params.quoteFundAmount !== void 0) {
10940
- const amt = starknet.uint256.bnToUint256(BigInt(params.quoteFundAmount));
10941
- calls.push({
10942
- contractAddress: params.quoteToken,
10943
- entrypoint: "transfer",
10944
- calldata: [chunk7EYJC5CB_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory, amt.low, amt.high]
10945
- });
10946
- }
10947
- calls.push(factoryContract().populate("launch_on_ekubo", [launchParameters, ekuboParameters]));
10948
- return calls;
10949
- }
10950
- var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
10951
- function parseCreatorCoinCreated(receipt) {
10952
- const factory = chunk2R7XBA34_cjs.normalizeAddress("STARKNET", chunk7EYJC5CB_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
10953
- for (const ev of receipt?.events ?? []) {
10954
- let from;
10955
- try {
10956
- from = chunk2R7XBA34_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
10957
- } catch {
10958
- continue;
10959
- }
10960
- if (from !== factory) continue;
10961
- const k0 = ev.keys?.[0];
10962
- if (!k0 || chunk2R7XBA34_cjs.normalizeAddress("STARKNET", k0) !== chunk2R7XBA34_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
10963
- const data = ev.data ?? [];
10964
- if (data.length < 1) continue;
10965
- return chunk2R7XBA34_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
10966
- }
10967
- throw new Error("Coin deployed but the coin address could not be read from the receipt");
10968
- }
10969
- var CreatorCoinService = class {
10970
- constructor(config) {
10971
- this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).creatorCoinFactory;
10972
- }
10973
- _factory(account) {
10974
- return newContract(CreatorCoinFactoryABI, this.factoryAddress, account);
10975
- }
10976
- async createCreatorCoin(account, params) {
10977
- const res = await account.execute([buildCreateCreatorCoinCall(params)]);
10978
- return { txHash: res.transaction_hash };
10979
- }
10980
- async launchOnEkubo(account, params) {
10981
- const res = await account.execute(buildLaunchOnEkuboCalls(params));
10982
- return { txHash: res.transaction_hash };
10983
- }
10984
- async isCreatorCoin(address, account) {
10985
- const r = await this._factory(account).is_creator_coin(address);
10986
- return BigInt(r) === 1n;
10987
- }
10988
- };
10989
- var TicketService = class {
10990
- constructor(config) {
10991
- this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).ipTicketsFactory;
10992
- }
10993
- _factory(account, factoryAddress) {
10994
- const address = factoryAddress ?? this.factoryAddress;
10995
- if (!address) throw new Error("IP-Tickets factory address not configured for this chain");
10996
- return newContract(IPTicketCollectionFactoryABI, chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address), account);
10997
- }
10998
- _collection(address, account) {
10999
- return newContract(IPTicketCollectionABI, chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address), account);
11000
- }
11001
- async deployCollection(account, params) {
11002
- const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
11003
- params.name,
11004
- params.symbol,
11005
- params.baseUri
11006
- ]);
11007
- const res = await account.execute([call]);
11008
- return { txHash: res.transaction_hash };
11009
- }
11010
- async createTicket(account, params) {
11011
- const startTime = params.startTime != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.startTime) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
11012
- const endTime = params.endTime != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.endTime) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
11013
- const call = this._collection(params.collection, account).populate("create_ticket", [
11014
- starknet.cairo.uint256(params.maxSupply),
11015
- startTime,
11016
- endTime,
11017
- params.royaltyBps,
11018
- params.metadataUri
11019
- ]);
11020
- const res = await account.execute([call]);
11021
- return { txHash: res.transaction_hash };
11022
- }
11023
- async mint(account, params) {
11024
- const call = this._collection(params.collection, account).populate("mint", [
11025
- params.to,
11026
- starknet.cairo.uint256(params.tokenId),
11027
- starknet.cairo.uint256(params.amount)
11028
- ]);
11029
- const res = await account.execute([call]);
11030
- return { txHash: res.transaction_hash };
11031
- }
11032
- };
11033
- var ClubService = class {
11034
- constructor(config) {
11035
- this.factoryAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).ipClubFactory;
11036
- }
11037
- _factory(account, factoryAddress) {
11038
- const address = factoryAddress ?? this.factoryAddress;
11039
- if (!address) throw new Error("IP-Club factory address not configured for this chain");
11040
- return newContract(IPClubFactoryABI, chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address), account);
11041
- }
11042
- _collection(address, account) {
11043
- return newContract(IPClubCollectionABI, chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address), account);
11044
- }
11045
- async deployCollection(account, params) {
11046
- const call = this._factory(account, params.factoryAddress).populate("deploy_collection", [
11047
- params.name,
11048
- params.symbol,
11049
- params.baseUri
11050
- ]);
11051
- const res = await account.execute([call]);
11052
- return { txHash: res.transaction_hash };
11053
- }
11054
- async createMembership(account, params) {
11055
- const startTime = params.startTime != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.startTime) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
11056
- const endTime = params.endTime != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.endTime) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
11057
- const call = this._collection(params.collection, account).populate("create_membership", [
11058
- starknet.cairo.uint256(params.maxSupply),
11059
- startTime,
11060
- endTime,
11061
- params.royaltyBps,
11062
- params.metadataUri
11063
- ]);
11064
- const res = await account.execute([call]);
11065
- return { txHash: res.transaction_hash };
11066
- }
11067
- async mint(account, params) {
11068
- const call = this._collection(params.collection, account).populate("mint", [
11069
- params.to,
11070
- starknet.cairo.uint256(params.tokenId),
11071
- starknet.cairo.uint256(params.amount)
11072
- ]);
11073
- const res = await account.execute([call]);
11074
- return { txHash: res.transaction_hash };
11075
- }
11076
- };
11077
- var SponsorshipService = class {
11078
- constructor(config) {
11079
- this.sponsorshipAddress = chunk7EYJC5CB_cjs.getStarknetCoordinates(config.chain).ipSponsorship;
11080
- }
11081
- _contract(account, address) {
11082
- const resolved = address ?? this.sponsorshipAddress;
11083
- if (!resolved) {
11084
- throw new Error("IP-Sponsorship address not configured for this chain");
11085
- }
11086
- return newContract(IPSponsorshipABI, chunk2R7XBA34_cjs.normalizeAddress("STARKNET", resolved), account);
11087
- }
11088
- async createOffer(account, params) {
11089
- const specificSponsor = params.specificSponsor ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, params.specificSponsor) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
11090
- const call = this._contract(account, params.sponsorshipAddress).populate("create_offer", [
11091
- params.nftContract,
11092
- starknet.cairo.uint256(params.tokenId),
11093
- starknet.cairo.uint256(params.minAmount),
11094
- params.duration,
11095
- params.paymentToken,
11096
- params.licenseTermsUri,
11097
- params.transferable,
11098
- starknet.cairo.uint256(params.royaltyBps),
11099
- specificSponsor
11100
- ]);
11101
- const res = await account.execute([call]);
11102
- return { txHash: res.transaction_hash };
11103
- }
11104
- async setOfferOpen(account, params) {
11105
- const call = this._contract(account, params.sponsorshipAddress).populate("set_offer_open", [
11106
- starknet.cairo.uint256(params.offerId),
11107
- params.open
11108
- ]);
11109
- const res = await account.execute([call]);
11110
- return { txHash: res.transaction_hash };
11111
- }
11112
- async placeBid(account, params) {
11113
- const sponsorshipAddress = params.sponsorshipAddress ?? this.sponsorshipAddress;
11114
- if (!sponsorshipAddress) {
11115
- throw new Error("IP-Sponsorship address not configured for this chain");
11116
- }
11117
- const amount = starknet.cairo.uint256(params.amount);
11118
- const approveCall = {
11119
- contractAddress: params.paymentToken,
11120
- entrypoint: "approve",
11121
- calldata: [chunk2R7XBA34_cjs.normalizeAddress("STARKNET", sponsorshipAddress), amount.low.toString(), amount.high.toString()]
11122
- };
11123
- const bidCall = this._contract(account, sponsorshipAddress).populate("place_bid", [
11124
- starknet.cairo.uint256(params.offerId),
11125
- amount
11126
- ]);
11127
- const res = await account.execute([approveCall, bidCall]);
11128
- return { txHash: res.transaction_hash };
11129
- }
11130
- async retractBid(account, params) {
11131
- const call = this._contract(account, params.sponsorshipAddress).populate("retract_bid", [
11132
- starknet.cairo.uint256(params.offerId)
11133
- ]);
11134
- const res = await account.execute([call]);
11135
- return { txHash: res.transaction_hash };
11136
- }
11137
- async acceptBid(account, params) {
11138
- const call = this._contract(account, params.sponsorshipAddress).populate("accept_bid", [
11139
- starknet.cairo.uint256(params.offerId),
11140
- params.sponsor
11141
- ]);
11142
- const res = await account.execute([call]);
11143
- return { txHash: res.transaction_hash };
11144
- }
11145
- async proposeSponsorship(account, params) {
11146
- const call = this._contract(account, params.sponsorshipAddress).populate("propose_sponsorship", [
11147
- params.nftContract,
11148
- starknet.cairo.uint256(params.tokenId),
11149
- starknet.cairo.uint256(params.amount),
11150
- params.duration,
11151
- params.validUntil ?? 0,
11152
- params.paymentToken,
11153
- params.licenseTermsUri,
11154
- params.transferable,
11155
- starknet.cairo.uint256(params.royaltyBps)
11156
- ]);
11157
- const res = await account.execute([call]);
11158
- return { txHash: res.transaction_hash };
11159
- }
11160
- async withdrawProposal(account, params) {
11161
- const call = this._contract(account, params.sponsorshipAddress).populate("withdraw_proposal", [
11162
- starknet.cairo.uint256(params.proposalId)
11163
- ]);
11164
- const res = await account.execute([call]);
11165
- return { txHash: res.transaction_hash };
11166
- }
11167
- async acceptProposal(account, params) {
11168
- const call = this._contract(account, params.sponsorshipAddress).populate("accept_proposal", [
11169
- starknet.cairo.uint256(params.proposalId)
11170
- ]);
11171
- const res = await account.execute([call]);
11172
- return { txHash: res.transaction_hash };
11173
- }
11174
- async rejectProposal(account, params) {
11175
- const call = this._contract(account, params.sponsorshipAddress).populate("reject_proposal", [
11176
- starknet.cairo.uint256(params.proposalId)
11177
- ]);
11178
- const res = await account.execute([call]);
11179
- return { txHash: res.transaction_hash };
11180
- }
11181
- };
11182
- function createChainProvider(backendUrl, apiKey) {
11183
- return new starknet.RpcProvider({
11184
- nodeUrl: `${backendUrl.replace(/\/$/, "")}/v1/rpc`,
11185
- headers: apiKey ? { "x-api-key": apiKey } : {},
11186
- blockIdentifier: "latest"
11187
- });
11188
- }
11189
-
11190
- // src/starknet/client.ts
11191
- var MedialaneClient = class {
11192
- constructor(rawConfig = {}) {
11193
- this.config = chunk2R7XBA34_cjs.resolveConfig(rawConfig);
11194
- this.services = {
11195
- pop: new PopService(this.config),
11196
- drop: new DropService(this.config),
11197
- erc1155Collection: new ERC1155CollectionService(this.config),
11198
- creatorCoin: new CreatorCoinService(this.config),
11199
- ticket: new TicketService(this.config),
11200
- club: new ClubService(this.config),
11201
- sponsorship: new SponsorshipService(this.config)
11202
- };
11203
- if (!this.config.backendUrl) {
11204
- const sentinel = new chunk2R7XBA34_cjs.ApiClient("https://medialane-sdk-no-backend.invalid", this.config.apiKey);
11205
- const apiMethodNames = new Set(
11206
- Object.getOwnPropertyNames(chunk2R7XBA34_cjs.ApiClient.prototype).filter(
11207
- (k) => k !== "constructor" && typeof sentinel[k] === "function"
11208
- )
11209
- );
11210
- this.api = new Proxy(sentinel, {
11211
- get(target, prop, receiver) {
11212
- if (typeof prop === "symbol" || !apiMethodNames.has(prop)) {
11213
- return Reflect.get(target, prop, receiver);
11214
- }
11215
- return () => {
11216
- throw new Error(
11217
- `backendUrl not configured. Pass backendUrl to MedialaneClient to use .api.${String(prop)}()`
11218
- );
11219
- };
11220
- }
11221
- });
11222
- } else {
11223
- this.api = new chunk2R7XBA34_cjs.ApiClient(this.config.backendUrl, this.config.apiKey, this.config.retryOptions, this.config.chain);
11224
- }
11225
- }
11226
- get chain() {
11227
- return this.config.chain;
11228
- }
11229
- get provider() {
11230
- if (!this.config.backendUrl) {
11231
- throw new Error("backendUrl not configured. Pass backendUrl to MedialaneClient to use .provider");
11232
- }
11233
- return this._provider ?? (this._provider = createChainProvider(this.config.backendUrl, this.config.apiKey));
11234
- }
11235
- get marketplaceContract() {
11236
- return this.config.marketplaceContract;
11237
- }
11238
- };
11239
-
11240
- // src/starknet/erc20.ts
11241
- async function erc20Balance(provider, token, holder) {
11242
- const read = (entrypoint) => provider.callContract({ contractAddress: token, entrypoint, calldata: [holder] }, "latest");
11243
- const [low = "0x0", high = "0x0"] = await read("balanceOf").catch(() => read("balance_of"));
11244
- return BigInt(low) + (BigInt(high) << 128n);
11245
- }
11246
- var STARKNET_DOMAIN = [
11247
- { name: "name", type: "shortstring" },
11248
- { name: "version", type: "shortstring" },
11249
- { name: "chainId", type: "shortstring" },
11250
- { name: "revision", type: "shortstring" }
11251
- ];
11252
- var OFFER_ITEM = [
11253
- { name: "item_type", type: "shortstring" },
11254
- { name: "token", type: "ContractAddress" },
11255
- { name: "identifier_or_criteria", type: "felt" },
11256
- { name: "amount", type: "felt" }
11257
- ];
11258
- var CONSIDERATION_ITEM = [
11259
- { name: "item_type", type: "shortstring" },
11260
- { name: "token", type: "ContractAddress" },
11261
- { name: "identifier_or_criteria", type: "felt" },
11262
- { name: "amount", type: "felt" },
11263
- { name: "recipient", type: "ContractAddress" }
11264
- ];
11265
- var ORDER_PARAMETERS = [
11266
- { name: "offerer", type: "ContractAddress" },
11267
- { name: "marketplace", type: "ContractAddress" },
11268
- { name: "offer", type: "OfferItem" },
11269
- { name: "consideration", type: "ConsiderationItem" },
11270
- { name: "royalty_max_bps", type: "felt" },
11271
- { name: "start_time", type: "felt" },
11272
- { name: "end_time", type: "felt" },
11273
- { name: "salt", type: "felt" },
11274
- { name: "counter", type: "felt" }
11275
- ];
11276
- var ORDER_CANCELLATION = [
11277
- { name: "order_hash", type: "felt" },
11278
- { name: "offerer", type: "ContractAddress" }
11279
- ];
11280
- var DOMAIN_VERSION = {
11281
- erc721: "5",
11282
- erc1155: "4"
11283
- };
11284
- function buildDomain(standard, chainId) {
11285
- return {
11286
- name: "Medialane",
11287
- version: DOMAIN_VERSION[standard],
11288
- chainId,
11289
- revision: starknet.TypedDataRevision.ACTIVE
11290
- };
11291
- }
11292
- function buildOrderTypedData(message, chainId) {
11293
- return {
11294
- domain: buildDomain("erc721", chainId),
11295
- primaryType: "OrderParameters",
11296
- types: {
11297
- StarknetDomain: STARKNET_DOMAIN,
11298
- OrderParameters: ORDER_PARAMETERS,
11299
- OfferItem: OFFER_ITEM,
11300
- ConsiderationItem: CONSIDERATION_ITEM
11301
- },
11302
- message
11303
- };
11304
- }
11305
- function build1155OrderTypedData(message, chainId) {
11306
- return {
11307
- domain: buildDomain("erc1155", chainId),
11308
- primaryType: "OrderParameters",
11309
- types: {
11310
- StarknetDomain: STARKNET_DOMAIN,
11311
- OrderParameters: ORDER_PARAMETERS,
11312
- OfferItem: OFFER_ITEM,
11313
- ConsiderationItem: CONSIDERATION_ITEM
11314
- },
11315
- message
11316
- };
11317
- }
11318
- function buildCancellationTypedData(message, chainId) {
11319
- return {
11320
- domain: buildDomain("erc721", chainId),
11321
- primaryType: "OrderCancellation",
11322
- types: {
11323
- StarknetDomain: STARKNET_DOMAIN,
11324
- OrderCancellation: ORDER_CANCELLATION
11325
- },
11326
- message
11327
- };
11328
- }
11329
- function build1155CancellationTypedData(message, chainId) {
11330
- return {
11331
- domain: buildDomain("erc1155", chainId),
11332
- primaryType: "OrderCancellation",
11333
- types: {
11334
- StarknetDomain: STARKNET_DOMAIN,
11335
- OrderCancellation: ORDER_CANCELLATION
11336
- },
11337
- message
11338
- };
11339
- }
11340
10513
 
11341
10514
  // src/starknet/marketplace/build.ts
11342
10515
  function contractFor(cfg) {
11343
- return newContract(IPMarketplaceABI, cfg.marketplaceContract);
10516
+ return newContract(IPMarketplaceABI, cfg.marketplace721Contract);
11344
10517
  }
11345
10518
  function buildListingOrder(i, cfg) {
11346
10519
  const orderParams = {
11347
10520
  offerer: i.offerer,
11348
- marketplace: cfg.marketplaceContract,
10521
+ marketplace: cfg.marketplace721Contract,
11349
10522
  offer: { item_type: "ERC721", token: i.nftContract, identifier_or_criteria: i.tokenId, amount: "1" },
11350
10523
  consideration: {
11351
10524
  item_type: "ERC20",
@@ -11360,13 +10533,13 @@ function buildListingOrder(i, cfg) {
11360
10533
  salt: i.salt,
11361
10534
  counter: i.counter
11362
10535
  };
11363
- const typedData = chunk2R7XBA34_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10536
+ const typedData = chunkMEJ47LC3_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
11364
10537
  return { orderParams, typedData };
11365
10538
  }
11366
10539
  function buildOfferOrder(i, cfg) {
11367
10540
  const orderParams = {
11368
10541
  offerer: i.offerer,
11369
- marketplace: cfg.marketplaceContract,
10542
+ marketplace: cfg.marketplace721Contract,
11370
10543
  offer: { item_type: "ERC20", token: i.paymentTokenAddress, identifier_or_criteria: "0", amount: i.priceWei },
11371
10544
  consideration: {
11372
10545
  item_type: "ERC721",
@@ -11381,11 +10554,11 @@ function buildOfferOrder(i, cfg) {
11381
10554
  salt: i.salt,
11382
10555
  counter: i.counter
11383
10556
  };
11384
- const typedData = chunk2R7XBA34_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
10557
+ const typedData = chunkMEJ47LC3_cjs.stringifyBigInts(buildOrderTypedData(orderParams, getChainId(cfg)));
11385
10558
  return { orderParams, typedData };
11386
10559
  }
11387
10560
  function registerPayload(orderParams, signature) {
11388
- return chunk2R7XBA34_cjs.stringifyBigInts({
10561
+ return chunkMEJ47LC3_cjs.stringifyBigInts({
11389
10562
  parameters: {
11390
10563
  ...orderParams,
11391
10564
  offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
@@ -11406,7 +10579,7 @@ function buildFulfillCalls(a, cfg) {
11406
10579
  const approve = {
11407
10580
  contractAddress: a.paymentToken,
11408
10581
  entrypoint: "approve",
11409
- calldata: [cfg.marketplaceContract, u.low.toString(), u.high.toString()]
10582
+ calldata: [cfg.marketplace721Contract, u.low.toString(), u.high.toString()]
11410
10583
  };
11411
10584
  const fulfill = contractFor(cfg).populate("fulfill_order", [a.orderHash]);
11412
10585
  const fee = buildFeeCall(
@@ -11416,14 +10589,14 @@ function buildFulfillCalls(a, cfg) {
11416
10589
  return fee ? [approve, fulfill, fee] : [approve, fulfill];
11417
10590
  }
11418
10591
  function buildCancelCalls(a, cfg) {
11419
- const cancelRequest = chunk2R7XBA34_cjs.stringifyBigInts({
10592
+ const cancelRequest = chunkMEJ47LC3_cjs.stringifyBigInts({
11420
10593
  cancelation: { order_hash: a.orderHash, offerer: a.offerer },
11421
10594
  signature: a.signature
11422
10595
  });
11423
10596
  return [contractFor(cfg).populate("cancel_order", [cancelRequest])];
11424
10597
  }
11425
10598
  function buildCancelTypedData(orderHash, offerer, cfg) {
11426
- return chunk2R7XBA34_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
10599
+ return chunkMEJ47LC3_cjs.stringifyBigInts(buildCancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg)));
11427
10600
  }
11428
10601
  function contractFor2(cfg) {
11429
10602
  return newContract(Medialane1155ABI, cfg.marketplace1155Contract);
@@ -11446,7 +10619,7 @@ function buildListing1155Order(i, cfg) {
11446
10619
  salt: i.salt,
11447
10620
  counter: i.counter
11448
10621
  };
11449
- const typedData = chunk2R7XBA34_cjs.stringifyBigInts(
10622
+ const typedData = chunkMEJ47LC3_cjs.stringifyBigInts(
11450
10623
  build1155OrderTypedData(orderParams, getChainId(cfg))
11451
10624
  );
11452
10625
  return { orderParams, typedData };
@@ -11469,13 +10642,13 @@ function buildOffer1155Order(i, cfg) {
11469
10642
  salt: i.salt,
11470
10643
  counter: i.counter
11471
10644
  };
11472
- const typedData = chunk2R7XBA34_cjs.stringifyBigInts(
10645
+ const typedData = chunkMEJ47LC3_cjs.stringifyBigInts(
11473
10646
  build1155OrderTypedData(orderParams, getChainId(cfg))
11474
10647
  );
11475
10648
  return { orderParams, typedData };
11476
10649
  }
11477
10650
  function registerPayload2(orderParams, signature) {
11478
- return chunk2R7XBA34_cjs.stringifyBigInts({
10651
+ return chunkMEJ47LC3_cjs.stringifyBigInts({
11479
10652
  parameters: {
11480
10653
  ...orderParams,
11481
10654
  offer: { ...orderParams.offer, item_type: starknet.shortString.encodeShortString(orderParams.offer.item_type) },
@@ -11506,14 +10679,14 @@ function buildFulfill1155Calls(a, cfg) {
11506
10679
  return fee ? [approve, fulfill, fee] : [approve, fulfill];
11507
10680
  }
11508
10681
  function buildCancel1155Calls(a, cfg) {
11509
- const cancelPayload = chunk2R7XBA34_cjs.stringifyBigInts({
10682
+ const cancelPayload = chunkMEJ47LC3_cjs.stringifyBigInts({
11510
10683
  cancelation: { order_hash: a.orderHash, offerer: a.offerer },
11511
10684
  signature: a.signature
11512
10685
  });
11513
10686
  return [contractFor2(cfg).populate("cancel_order", [cancelPayload])];
11514
10687
  }
11515
10688
  function buildCancel1155TypedData(orderHash, offerer, cfg) {
11516
- return chunk2R7XBA34_cjs.stringifyBigInts(
10689
+ return chunkMEJ47LC3_cjs.stringifyBigInts(
11517
10690
  build1155CancellationTypedData({ order_hash: orderHash, offerer }, getChainId(cfg))
11518
10691
  );
11519
10692
  }
@@ -11527,15 +10700,15 @@ var StarknetVenue = class {
11527
10700
  }
11528
10701
  async incrementCounter(signer) {
11529
10702
  return signer.execute([
11530
- { contractAddress: this.deps.config.marketplaceContract, entrypoint: "increment_counter", calldata: [] }
10703
+ { contractAddress: this.deps.config.marketplace721Contract, entrypoint: "increment_counter", calldata: [] }
11531
10704
  ]);
11532
10705
  }
11533
10706
  getOrderDetails(orderRef) {
11534
- const marketplace = newContract(IPMarketplaceABI, this.deps.config.marketplaceContract, this.deps.provider);
10707
+ const marketplace = newContract(IPMarketplaceABI, this.deps.config.marketplace721Contract, this.deps.provider);
11535
10708
  return marketplace.get_order_details(orderRef);
11536
10709
  }
11537
10710
  async getCounter(address) {
11538
- return this.readCounter(this.deps.config.marketplaceContract, address);
10711
+ return this.readCounter(this.deps.config.marketplace721Contract, address);
11539
10712
  }
11540
10713
  async fulfillOrder(signer, orderRef, opts) {
11541
10714
  const o = await this.deps.resolveOrder(orderRef);
@@ -11558,7 +10731,7 @@ var StarknetVenue = class {
11558
10731
  const startTime = Math.floor(Date.now() / 1e3) + START_TIME_BUFFER_SECS;
11559
10732
  const endTime = p.endTime && p.endTime > 0 ? p.endTime : startTime + NO_EXPIRY_SECONDS;
11560
10733
  const quantity = p.quantity ?? "1";
11561
- const marketplace = standard === "ERC1155" ? this.deps.config.marketplace1155Contract : this.deps.config.marketplaceContract;
10734
+ const marketplace = standard === "ERC1155" ? this.deps.config.marketplace1155Contract : this.deps.config.marketplace721Contract;
11562
10735
  const counter = String(await this.readCounter(marketplace, signer.address));
11563
10736
  let typedData;
11564
10737
  let buildCalls;
@@ -11620,7 +10793,7 @@ var StarknetVenue = class {
11620
10793
  const approve = {
11621
10794
  contractAddress: nftContract,
11622
10795
  entrypoint: "approve",
11623
- calldata: [this.deps.config.marketplaceContract, id.low.toString(), id.high.toString()]
10796
+ calldata: [this.deps.config.marketplace721Contract, id.low.toString(), id.high.toString()]
11624
10797
  };
11625
10798
  let approved = false;
11626
10799
  try {
@@ -11629,7 +10802,7 @@ var StarknetVenue = class {
11629
10802
  entrypoint: "get_approved",
11630
10803
  calldata: [id.low.toString(), id.high.toString()]
11631
10804
  });
11632
- approved = BigInt(res[0]).toString() === BigInt(this.deps.config.marketplaceContract).toString();
10805
+ approved = BigInt(res[0]).toString() === BigInt(this.deps.config.marketplace721Contract).toString();
11633
10806
  } catch {
11634
10807
  }
11635
10808
  return { approvalNeeded: !approved, approve };
@@ -11818,13 +10991,7 @@ var FundingTransferNotSentError = class extends Error {
11818
10991
  }
11819
10992
  };
11820
10993
  function fundingApiFor(client) {
11821
- return {
11822
- createFunding: (input) => client.createFunding(input),
11823
- getFundingChallenge: (id, payer) => client.getFundingChallenge(id, payer),
11824
- authorizeFunding: (id, input) => client.authorizeFunding(id, input),
11825
- submitFunding: (id, txHash) => client.submitFunding(id, txHash),
11826
- cancelFunding: (id) => client.cancelFunding(id)
11827
- };
10994
+ return client.portal.funding;
11828
10995
  }
11829
10996
  function buildFundingTransferCall(instructions) {
11830
10997
  const amount = BigInt(instructions.amountAtomic);
@@ -11843,32 +11010,32 @@ async function fundWithChainTransfer(api, wallet, options) {
11843
11010
  const maxPolls = options.maxPolls ?? 20;
11844
11011
  step("creating");
11845
11012
  const params = options.amount !== void 0 ? { amount: options.amount } : { amountUsdc: options.amountUsdc };
11846
- const { data: intent } = await api.createFunding({ method: "chain-transfer", params });
11013
+ const intent = await api.create({ method: "chain-transfer", params });
11847
11014
  let txHash;
11848
11015
  let transferStarted = false;
11849
11016
  try {
11850
11017
  step("signing");
11851
- const challenge = await api.getFundingChallenge(intent.id, wallet.address);
11852
- const signature = await wallet.signTypedData(challenge.data.typedData);
11018
+ const challenge = await api.challenge(intent.id, wallet.address);
11019
+ const signature = await wallet.signTypedData(challenge.typedData);
11853
11020
  step("authorizing");
11854
- const authorized = await api.authorizeFunding(intent.id, { payer: wallet.address, signature });
11021
+ const authorized = await api.authorize(intent.id, { payer: wallet.address, signature });
11855
11022
  step("paying");
11856
11023
  transferStarted = true;
11857
- ({ txHash } = await wallet.sendTransfer(buildFundingTransferCall(authorized.data.instructions)));
11024
+ ({ txHash } = await wallet.sendTransfer(buildFundingTransferCall(authorized.instructions)));
11858
11025
  } catch (err) {
11859
11026
  if (!transferStarted || err instanceof FundingTransferNotSentError) {
11860
- await api.cancelFunding(intent.id).catch(() => void 0);
11027
+ await api.cancel(intent.id).catch(() => void 0);
11861
11028
  }
11862
11029
  throw err;
11863
11030
  }
11864
11031
  step("confirming");
11865
11032
  let reason = "waiting for the transfer to confirm";
11866
11033
  for (let attempt = 0; attempt < maxPolls; attempt++) {
11867
- const res = await api.submitFunding(intent.id, txHash);
11868
- if (res.data.status === "SETTLED") {
11869
- return { status: "SETTLED", intentId: intent.id, credited: res.data.credited };
11034
+ const res = await api.submit(intent.id, txHash);
11035
+ if (res.status === "SETTLED") {
11036
+ return { status: "SETTLED", intentId: intent.id, credited: res.credited };
11870
11037
  }
11871
- reason = res.data.reason;
11038
+ reason = res.reason;
11872
11039
  await sleep(pollMs);
11873
11040
  }
11874
11041
  return { status: "PENDING", intentId: intent.id, reason };
@@ -11876,13 +11043,13 @@ async function fundWithChainTransfer(api, wallet, options) {
11876
11043
 
11877
11044
  // src/starknet/services/executeIntent.ts
11878
11045
  async function confirmIntentBestEffort(client, intentId, txHash) {
11879
- await client.api.confirmIntent(intentId, txHash).catch(() => {
11046
+ await client.api.intents.confirm(intentId, txHash).catch(() => {
11880
11047
  });
11881
11048
  }
11882
11049
  var SYNC_TIMEOUT_MS = 2e4;
11883
11050
  var SYNC_RETRY_MS = 2e3;
11884
11051
  function readableLater(err) {
11885
- return err instanceof chunk2R7XBA34_cjs.MedialaneApiError && err.status === 404;
11052
+ return err instanceof chunk3HPMEDYH_cjs.MedialaneApiError && err.status === 404;
11886
11053
  }
11887
11054
  async function syncTransactionBestEffort(client, txHash, timeoutMs = SYNC_TIMEOUT_MS, retryMs = SYNC_RETRY_MS) {
11888
11055
  const deadline = Date.now() + timeoutMs;
@@ -11893,8 +11060,8 @@ async function syncTransactionBestEffort(client, txHash, timeoutMs = SYNC_TIMEOU
11893
11060
  });
11894
11061
  const sync = (async () => {
11895
11062
  while (!stopped) {
11896
- const again = await client.api.syncTransaction(txHash).then(
11897
- (res) => res.data?.pending === true,
11063
+ const again = await client.api.intents.syncTransaction(txHash).then(
11064
+ (res) => res?.pending === true,
11898
11065
  readableLater
11899
11066
  );
11900
11067
  if (!again || Date.now() + retryMs >= deadline) return;
@@ -11917,21 +11084,21 @@ async function assertTransactionSucceeded(provider, txHash, retryDelaysMs = RECE
11917
11084
  const receipt = await provider.getTransactionReceipt(txHash);
11918
11085
  const status = receipt.execution_status ?? receipt.status;
11919
11086
  if (status === "REVERTED" || status === "REJECTED") {
11920
- throw new chunk2R7XBA34_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
11087
+ throw new chunk3HPMEDYH_cjs.UserFacingError("Transaction was submitted but reverted onchain. Please check your balance and try again.");
11921
11088
  }
11922
11089
  if (status) return receipt;
11923
11090
  } catch (err) {
11924
11091
  if (err instanceof Error && err.message.includes("reverted onchain")) throw err;
11925
11092
  }
11926
11093
  }
11927
- throw new chunk2R7XBA34_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
11094
+ throw new chunk3HPMEDYH_cjs.UserFacingError("Verification timed out. Check your account for the transaction status.");
11928
11095
  }
11929
11096
  async function executeIntent(signer, client, intent, opts = {}) {
11930
11097
  let calls;
11931
11098
  if (intent.requiresSignature) {
11932
11099
  const signature = await signer.signTypedData(intent.typedData);
11933
- const signed = await client.api.submitIntentSignature(intent.id, signature);
11934
- calls = signed.data.calls;
11100
+ const signed = await client.api.intents.submitSignature(intent.id, signature);
11101
+ calls = signed.calls;
11935
11102
  } else {
11936
11103
  calls = intent.calls;
11937
11104
  }
@@ -11973,18 +11140,18 @@ function sameFelt(a, b) {
11973
11140
  return false;
11974
11141
  }
11975
11142
  }
11976
- function u2563(low, high) {
11143
+ function u256(low, high) {
11977
11144
  return (BigInt(low ?? 0) + (BigInt(high ?? 0) << 128n)).toString();
11978
11145
  }
11979
11146
  function deployedCollectionFromReceipt(receipt, service) {
11980
- const factory = chunk2R7XBA34_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
11147
+ const factory = chunkMEJ47LC3_cjs.getService(service)?.onchain?.STARKNET?.factoryAddress;
11981
11148
  const { event, address } = DEPLOY_EVENTS[service];
11982
11149
  const selector = BigInt(starknet.hash.getSelectorFromName(event));
11983
11150
  for (const e of receipt.events ?? []) {
11984
11151
  if (factory && !sameFelt(e.from_address, factory)) continue;
11985
11152
  if (!sameFelt(e.keys?.[0], selector)) continue;
11986
11153
  const value = address(e);
11987
- if (value) return chunk2R7XBA34_cjs.normalizeAddress("STARKNET", value);
11154
+ if (value) return chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", value);
11988
11155
  }
11989
11156
  return null;
11990
11157
  }
@@ -11992,771 +11159,816 @@ function mintedTokenIdFromReceipt(receipt, contract) {
11992
11159
  for (const e of receipt.events ?? []) {
11993
11160
  if (!sameFelt(e.from_address, contract)) continue;
11994
11161
  const keys = e.keys ?? [];
11995
- if (sameFelt(keys[0], IP_MINTED_SELECTOR) && keys.length >= 3) return u2563(keys[1], keys[2]);
11996
- if (sameFelt(keys[0], TRANSFER_SELECTOR) && keys.length === 5 && sameFelt(keys[1], 0n)) return u2563(keys[3], keys[4]);
11162
+ if (sameFelt(keys[0], IP_MINTED_SELECTOR) && keys.length >= 3) return u256(keys[1], keys[2]);
11163
+ if (sameFelt(keys[0], TRANSFER_SELECTOR) && keys.length === 5 && sameFelt(keys[1], 0n)) return u256(keys[3], keys[4]);
11997
11164
  }
11998
11165
  return null;
11999
11166
  }
12000
-
12001
- // src/starknet/services/sponsoredExecutor.ts
12002
- var SponsoredCallRejectedError = class extends Error {
12003
- };
12004
- var FALLBACK_FUNDING_FAILURES = /* @__PURE__ */ new Set(["sponsor_unavailable", "credits_exhausted"]);
12005
- function allowsFallbackFunding(code, status, stage) {
12006
- if (code) return FALLBACK_FUNDING_FAILURES.has(code);
12007
- return stage === "build" ? status >= 500 : status === 503;
12008
- }
12009
- async function failureOf(res, fallback) {
12010
- const body = await res.json().catch(() => null);
12011
- return { reason: body?.error || fallback, code: typeof body?.code === "string" ? body.code : void 0 };
12012
- }
12013
- async function executeSponsored(config, signer, request) {
12014
- const doFetch = config.fetchImpl ?? fetch;
12015
- const base = config.proxyUrl.replace(/\/$/, "");
12016
- const headers = { "Content-Type": "application/json", ...config.headers };
12017
- const buildRes = await doFetch(`${base}/build`, {
12018
- method: "POST",
12019
- headers,
12020
- body: JSON.stringify(request)
12021
- });
12022
- if (!buildRes.ok) {
12023
- const { reason, code } = await failureOf(buildRes, "We couldn't prepare this transaction.");
12024
- if (allowsFallbackFunding(code, buildRes.status, "build")) return { status: "unavailable", reason };
12025
- throw new SponsoredCallRejectedError(reason);
12026
- }
12027
- const { typedData } = await buildRes.json();
12028
- const signature = await signer.signTypedData(typedData);
12029
- const executeRes = await doFetch(`${base}/execute`, {
12030
- method: "POST",
12031
- headers,
12032
- body: JSON.stringify({ ...request, typedData, signature })
12033
- });
12034
- if (!executeRes.ok) {
12035
- const { reason, code } = await failureOf(executeRes, "We couldn't submit this transaction.");
12036
- if (allowsFallbackFunding(code, executeRes.status, "execute")) {
12037
- return { status: "unavailable", reason };
12038
- }
12039
- throw new SponsoredCallRejectedError(reason);
12040
- }
12041
- const { transactionHash } = await executeRes.json();
12042
- return { status: "sponsored", transactionHash };
11167
+ var FRAGMENT_KEY = "pop-proof";
11168
+ var toHex = (x) => "0x" + x.toString(16).padStart(64, "0");
11169
+ var poseidon = (xs) => BigInt(starknet.hash.computePoseidonHashOnElements(xs.map((x) => "0x" + x.toString(16))));
11170
+ var nodeHash = (a, b) => a < b ? poseidon([a, b]) : poseidon([b, a]);
11171
+ function popLeafHash(address) {
11172
+ return poseidon([poseidon([BigInt(address)])]);
12043
11173
  }
12044
- function encodeByteArray(str) {
12045
- const bytes = new TextEncoder().encode(str);
12046
- const fullChunks = [];
12047
- let i = 0;
12048
- while (i + 31 <= bytes.length) {
12049
- let val = 0n;
12050
- for (const b of bytes.slice(i, i + 31)) {
12051
- val = val << 8n | BigInt(b);
12052
- }
12053
- fullChunks.push(starknet.num.toHex(val));
12054
- i += 31;
12055
- }
12056
- const remaining = bytes.slice(i);
12057
- let pendingVal = 0n;
12058
- for (const b of remaining) {
12059
- pendingVal = pendingVal << 8n | BigInt(b);
11174
+ function merkleTree(leafHashes) {
11175
+ const leaves = [...leafHashes].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
11176
+ const tree = new Array(2 * leaves.length - 1);
11177
+ leaves.forEach((leaf, i) => tree[tree.length - 1 - i] = leaf);
11178
+ for (let i = tree.length - 1 - leaves.length; i >= 0; i--) {
11179
+ tree[i] = nodeHash(tree[2 * i + 1], tree[2 * i + 2]);
12060
11180
  }
12061
- return [
12062
- fullChunks.length.toString(),
12063
- ...fullChunks,
12064
- starknet.num.toHex(pendingVal),
12065
- remaining.length.toString()
12066
- ];
12067
- }
12068
- var STARK_ORDER = 3618502788666131213697322783095070105526743751716087489154079457884512865583n;
12069
- function deriveOwnerKeyPair(secret, recipientId) {
12070
- const prk = hkdf_js.extract(sha2_js.sha256, secret);
12071
- const okm = hkdf_js.expand(sha2_js.sha256, prk, new TextEncoder().encode(recipientId), 32);
12072
- let scalar = BigInt("0x" + Buffer.from(okm).toString("hex")) % STARK_ORDER;
12073
- if (scalar === 0n) scalar = 1n;
12074
- const privateKey = starknet.num.toHex(scalar);
12075
- const publicKey = starknet.ec.starkCurve.getStarkKey(privateKey);
12076
- return { privateKey, publicKey };
12077
- }
12078
- var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
12079
- var OPTION_NONE = "0x1";
12080
- var SIGNER_STARKNET = "0x0";
12081
- function computeOwnerGuid(ownerPubkey) {
12082
- return starknet.hash.computePoseidonHash(STARKNET_SIGNER_TYPE, starknet.num.toHex(ownerPubkey));
12083
- }
12084
- function changeOwners(accountAddress, guidsToRemove, pubkeysToAdd) {
12085
- return {
12086
- contractAddress: accountAddress,
12087
- entrypoint: "change_owners",
12088
- calldata: [
12089
- starknet.num.toHex(guidsToRemove.length),
12090
- ...guidsToRemove,
12091
- starknet.num.toHex(pubkeysToAdd.length),
12092
- ...pubkeysToAdd.flatMap((p) => [SIGNER_STARKNET, starknet.num.toHex(p)]),
12093
- OPTION_NONE
12094
- ]
12095
- };
12096
- }
12097
- function buildAddOwnerCall(accountAddress, addOwnerPubkey) {
12098
- return changeOwners(accountAddress, [], [addOwnerPubkey]);
12099
- }
12100
- function buildRemoveOwnerCall(accountAddress, removeOwnerPubkey) {
12101
- return changeOwners(accountAddress, [computeOwnerGuid(removeOwnerPubkey)], []);
12102
- }
12103
- function buildRemoveOwnerByGuidCall(accountAddress, ownerGuid) {
12104
- return changeOwners(accountAddress, [starknet.num.toHex(ownerGuid)], []);
12105
- }
12106
- function buildDeployAccountParams(ownerPubkey, salt = 0) {
12107
- return {
12108
- classHash: chunk2R7XBA34_cjs.STARKNET_MEDIAWALLET_CLASS_HASH,
12109
- constructorCalldata: chunk2R7XBA34_cjs.ownerConstructorCalldata(ownerPubkey),
12110
- addressSalt: starknet.num.toHex(salt),
12111
- contractAddress: chunk2R7XBA34_cjs.computeAccountAddress(ownerPubkey, salt)
12112
- };
12113
- }
12114
- var norm = (address) => chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address);
12115
- var SIGNER_TYPE_NAMES = ["Starknet", "Secp256k1", "Secp256r1"];
12116
- function encodeFeltArray(items) {
12117
- return [starknet.num.toHex(items.length), ...items];
12118
- }
12119
- function encodeStarknetSigner(pubkey) {
12120
- return ["0x0", starknet.num.toHex(pubkey)];
12121
- }
12122
- function encodeStarknetSignerArray(pubkeys) {
12123
- return [starknet.num.toHex(pubkeys.length), ...pubkeys.flatMap(encodeStarknetSigner)];
12124
- }
12125
- function buildSetFirstGuardianCall(address, guardianPubkey) {
12126
11181
  return {
12127
- contractAddress: norm(address),
12128
- entrypoint: "change_guardians",
12129
- calldata: [...encodeFeltArray([]), ...encodeStarknetSignerArray([guardianPubkey])]
11182
+ root: tree[0],
11183
+ proof(leaf) {
11184
+ let i = tree.lastIndexOf(leaf);
11185
+ if (i < tree.length - leaves.length) throw new Error("Not a leaf of this tree");
11186
+ const proof = [];
11187
+ while (i > 0) {
11188
+ proof.push(tree[i % 2 === 1 ? i + 1 : i - 1]);
11189
+ i = Math.floor((i - 1) / 2);
11190
+ }
11191
+ return proof;
11192
+ }
12130
11193
  };
12131
11194
  }
12132
- function buildTriggerEscapeOwnerCall(targetAddress, newOwnerPubkey) {
12133
- return {
12134
- contractAddress: norm(targetAddress),
12135
- entrypoint: "trigger_escape_owner",
12136
- calldata: encodeStarknetSigner(newOwnerPubkey)
12137
- };
11195
+ function buildPopAllowlist(addresses) {
11196
+ const unique = [...new Set(addresses.map((a) => chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", a)))];
11197
+ if (unique.length === 0) throw new Error("An allowlist needs at least one address");
11198
+ const leaves = unique.map((address) => ({ address, leaf: popLeafHash(address) }));
11199
+ const tree = merkleTree(leaves.map((l) => l.leaf));
11200
+ const proofs = {};
11201
+ for (const { address, leaf } of leaves) proofs[address] = tree.proof(leaf).map(toHex);
11202
+ return { root: toHex(tree.root), proofs };
12138
11203
  }
12139
- function buildCompleteEscapeOwnerCall(targetAddress) {
12140
- return { contractAddress: norm(targetAddress), entrypoint: "escape_owner", calldata: [] };
11204
+ function verifyPopProof(root, address, proof) {
11205
+ let computed = popLeafHash(address);
11206
+ for (const sibling of proof) computed = nodeHash(computed, BigInt(sibling));
11207
+ return computed === BigInt(root);
12141
11208
  }
12142
- function buildCancelEscapeCall(address) {
12143
- return { contractAddress: norm(address), entrypoint: "cancel_escape", calldata: [] };
11209
+ function encodePopClaimFragment(proof) {
11210
+ return `#${FRAGMENT_KEY}=${proof.join(",")}`;
12144
11211
  }
12145
- function decodeGuardiansInfo(res) {
12146
- const len = Number(res[0]);
12147
- const out = [];
12148
- for (let i = 0; i < len; i++) {
12149
- const base = 1 + i * 3;
12150
- out.push({
12151
- type: SIGNER_TYPE_NAMES[Number(res[base])] ?? "Starknet",
12152
- guid: res[base + 1],
12153
- storedValue: res[base + 2]
12154
- });
12155
- }
12156
- return out;
11212
+ function decodePopClaimFragment(fragment) {
11213
+ const raw = new URLSearchParams(fragment.replace(/^#/, "")).get(FRAGMENT_KEY);
11214
+ if (raw === null) return null;
11215
+ if (raw === "") return [];
11216
+ const parts = raw.split(",");
11217
+ return parts.every((p) => /^0x[0-9a-fA-F]{1,64}$/.test(p)) ? parts : null;
12157
11218
  }
12158
- var ESCAPE_TYPE_NAMES = ["None", "Guardian", "Owner"];
12159
- var ESCAPE_STATUS_NAMES = ["None", "NotReady", "Ready", "Expired"];
12160
- function decodeEscapeAndStatus(res) {
12161
- const readyAt = Number(res[0]);
12162
- const escapeType = ESCAPE_TYPE_NAMES[Number(res[1])] ?? "None";
12163
- const optionTag = Number(res[2]);
12164
- const statusIndex = optionTag === 0 ? 5 : 3;
12165
- const status = ESCAPE_STATUS_NAMES[Number(res[statusIndex])] ?? "None";
12166
- return { readyAt, escapeType, status };
11219
+ function popClaimLinks(origin, collection, list) {
11220
+ const base = `${origin}${chunkMEJ47LC3_cjs.collectionHref("STARKNET", collection)}`;
11221
+ return Object.entries(list.proofs).map(([address, proof]) => ({
11222
+ address,
11223
+ url: `${base}${encodePopClaimFragment(proof)}`
11224
+ }));
12167
11225
  }
12168
- async function getGuardians(provider, address) {
12169
- const res = await provider.callContract({
12170
- contractAddress: norm(address),
12171
- entrypoint: "get_guardians_info",
12172
- calldata: []
12173
- });
12174
- return decodeGuardiansInfo(res);
11226
+ function popClaimLinksCsv(links) {
11227
+ return ["address,claim_link", ...links.map((l) => `${l.address},${l.url}`)].join("\n");
12175
11228
  }
12176
- async function getOwners(provider, address) {
12177
- const res = await provider.callContract({
12178
- contractAddress: norm(address),
12179
- entrypoint: "get_owners_info",
12180
- calldata: []
12181
- });
12182
- return decodeGuardiansInfo(res);
11229
+ async function popClaimInfo(provider, collection) {
11230
+ const contractAddress = chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", collection);
11231
+ const [root, end] = await Promise.all([
11232
+ provider.callContract({ contractAddress, entrypoint: "allowlist_root", calldata: [] }),
11233
+ provider.callContract({ contractAddress, entrypoint: "claim_end_time", calldata: [] })
11234
+ ]);
11235
+ return { root: root[0] ?? "0x0", claimEndTime: Number(BigInt(end[0] ?? "0x0")) };
12183
11236
  }
12184
- async function getEscape(provider, address) {
12185
- const res = await provider.callContract({
12186
- contractAddress: norm(address),
12187
- entrypoint: "get_escape_and_status",
12188
- calldata: []
12189
- });
12190
- return decodeEscapeAndStatus(res);
11237
+ function popClaimState(input) {
11238
+ const { hasClaimed, proof, wallet, info } = input;
11239
+ if (hasClaimed === true) return "claimed";
11240
+ if (hasClaimed === null || info === null) return "loading";
11241
+ if (BigInt(info.root) === 0n) return "closed";
11242
+ if (info.claimEndTime !== 0 && info.now > info.claimEndTime) return "ended";
11243
+ if (proof === null) return "no-link";
11244
+ if (!wallet || !verifyPopProof(info.root, wallet, proof)) return "wrong-wallet";
11245
+ return "ready";
12191
11246
  }
12192
- async function getEscapeSecurityPeriod(provider, address) {
11247
+ var addr = (a) => chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", a);
11248
+ var byteArrayFelts = (s) => starknet.CallData.compile([starknet.byteArray.byteArrayFromString(s)]);
11249
+ var popCalls = {
11250
+ claim(collection, proof) {
11251
+ return { contractAddress: addr(collection), entrypoint: "claim", calldata: [String(proof.length), ...proof] };
11252
+ },
11253
+ /** An empty `tokenUri` uses the collection's URI. */
11254
+ issue(collection, recipient, tokenUri = "") {
11255
+ return { contractAddress: addr(collection), entrypoint: "issue", calldata: [addr(recipient), ...byteArrayFelts(tokenUri)] };
11256
+ },
11257
+ /** Only the token's holder can burn it. */
11258
+ burn(collection, tokenId) {
11259
+ const id = starknet.cairo.uint256(BigInt(tokenId));
11260
+ return { contractAddress: addr(collection), entrypoint: "burn", calldata: [String(id.low), String(id.high)] };
11261
+ },
11262
+ setAllowlistRoot(collection, root) {
11263
+ return { contractAddress: addr(collection), entrypoint: "set_allowlist_root", calldata: [root] };
11264
+ }
11265
+ };
11266
+ async function popHasClaimed(provider, collection, address) {
12193
11267
  const res = await provider.callContract({
12194
- contractAddress: norm(address),
12195
- entrypoint: "get_escape_security_period",
12196
- calldata: []
11268
+ contractAddress: chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", collection),
11269
+ entrypoint: "has_claimed",
11270
+ calldata: [chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", address)]
12197
11271
  });
12198
- return Number(res[0]);
11272
+ return BigInt(res[0] ?? "0x0") !== 0n;
12199
11273
  }
12200
-
12201
- // src/wallet/store.ts
12202
- function createOwnerStore(config) {
12203
- const { storeKey, changeEvent } = config;
12204
- const announce = () => {
12205
- if (typeof window === "undefined") return;
12206
- window.dispatchEvent(new Event(changeEvent));
12207
- };
11274
+ var DROP_MAX_CLAIM_QUANTITY = 50n;
11275
+ var addr2 = (a) => chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", a);
11276
+ var factoryData = new starknet.CallData(DropFactoryABI);
11277
+ var collectionData = new starknet.CallData(DropCollectionABI);
11278
+ function toContractTerms(t) {
11279
+ const price = BigInt(t.price);
12208
11280
  return {
12209
- load() {
12210
- if (typeof window === "undefined") return null;
12211
- try {
12212
- const raw = localStorage.getItem(storeKey);
12213
- return raw ? JSON.parse(raw) : null;
12214
- } catch {
12215
- return null;
12216
- }
12217
- },
12218
- loadAddress() {
12219
- return this.load()?.address ?? null;
12220
- },
12221
- save(sealed) {
12222
- const previous = this.load();
12223
- if (previous && previous.address !== sealed.address) {
12224
- localStorage.setItem(`${storeKey}:${previous.address}`, JSON.stringify(previous));
12225
- }
12226
- localStorage.setItem(storeKey, JSON.stringify(sealed));
12227
- announce();
12228
- },
12229
- clear() {
12230
- localStorage.removeItem(storeKey);
12231
- announce();
12232
- },
12233
- notifyChange: announce,
12234
- onChange(listener) {
12235
- window.addEventListener(changeEvent, listener);
12236
- return () => window.removeEventListener(changeEvent, listener);
12237
- }
11281
+ start_time: t.startTime,
11282
+ end_time: t.endTime,
11283
+ price: starknet.cairo.uint256(price),
11284
+ payment_token: price === 0n ? "0x0" : addr2(t.paymentToken),
11285
+ max_per_wallet: starknet.cairo.uint256(BigInt(t.maxPerWallet))
12238
11286
  };
12239
11287
  }
12240
-
12241
- // src/wallet/pairing.ts
12242
- var SCHEME = "medialane-device";
12243
- var VERSION = 1;
12244
- var LABEL_MAX = 32;
12245
- var STARK_PRIME = (1n << 251n) + 17n * (1n << 192n) + 1n;
12246
- var InvalidPairingPayloadError = class extends Error {
12247
- constructor(message = "This code is not a Medialane device request.") {
12248
- super(message);
12249
- this.name = "InvalidPairingPayloadError";
11288
+ var dropCalls = {
11289
+ create(factory, p) {
11290
+ return {
11291
+ contractAddress: addr2(factory),
11292
+ entrypoint: "create_drop",
11293
+ calldata: factoryData.compile("create_drop", {
11294
+ name: p.name,
11295
+ symbol: p.symbol,
11296
+ base_uri: p.baseUri,
11297
+ max_supply: starknet.cairo.uint256(BigInt(p.maxSupply)),
11298
+ terms: toContractTerms(p.terms),
11299
+ allowlist_root: p.allowlistRoot ?? "0x0"
11300
+ })
11301
+ };
11302
+ },
11303
+ /** Approve (paid drops) and claim. The platform fee call is added by the caller. */
11304
+ claim(collection, p) {
11305
+ const quantity = BigInt(p.quantity);
11306
+ if (quantity < 1n || quantity > DROP_MAX_CLAIM_QUANTITY) throw new RangeError(`quantity must be 1 to ${DROP_MAX_CLAIM_QUANTITY}`);
11307
+ const total = BigInt(p.price) * quantity;
11308
+ const calls = [];
11309
+ if (total > 0n) {
11310
+ calls.push({
11311
+ contractAddress: addr2(p.paymentToken),
11312
+ entrypoint: "approve",
11313
+ calldata: starknet.CallData.compile([addr2(collection), starknet.cairo.uint256(total)])
11314
+ });
11315
+ }
11316
+ calls.push({
11317
+ contractAddress: addr2(collection),
11318
+ entrypoint: "claim",
11319
+ calldata: collectionData.compile("claim", { quantity: starknet.cairo.uint256(quantity), proof: p.proof ?? [] })
11320
+ });
11321
+ return calls;
11322
+ },
11323
+ /** Organizer only: free mint within the supply cap. */
11324
+ issue(collection, recipient, quantity) {
11325
+ const q = BigInt(quantity);
11326
+ if (q < 1n) throw new RangeError("quantity must be at least 1");
11327
+ return {
11328
+ contractAddress: addr2(collection),
11329
+ entrypoint: "issue",
11330
+ calldata: collectionData.compile("issue", { recipient: addr2(recipient), quantity: starknet.cairo.uint256(q) })
11331
+ };
11332
+ },
11333
+ /** Organizer only. 0 opens the drop to everyone. */
11334
+ setAllowlistRoot(collection, root) {
11335
+ return { contractAddress: addr2(collection), entrypoint: "set_allowlist_root", calldata: collectionData.compile("set_allowlist_root", { root }) };
12250
11336
  }
12251
11337
  };
12252
- function normalisePublicKey(input) {
12253
- if (typeof input !== "string" || !/^0x[0-9a-fA-F]+$/.test(input)) {
12254
- throw new InvalidPairingPayloadError("That device key is not valid.");
12255
- }
12256
- const value = BigInt(input);
12257
- if (value === 0n || value >= STARK_PRIME) {
12258
- throw new InvalidPairingPayloadError("That device key is not valid.");
12259
- }
12260
- return `0x${value.toString(16)}`;
11338
+ function dropMintCost(price, quantity, feeBps2) {
11339
+ const subtotal = BigInt(price) * BigInt(quantity);
11340
+ const fee = feeAmount(subtotal, feeBps2);
11341
+ return { subtotal, fee, total: subtotal + fee };
12261
11342
  }
12262
- function sanitiseLabel(input) {
12263
- const raw = typeof input === "string" ? input : "";
12264
- return raw.replace(/\s+/g, " ").trim().slice(0, LABEL_MAX);
11343
+
11344
+ // src/starknet/drop-state.ts
11345
+ var hex = (v) => chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", v ?? "0x0");
11346
+ var u2562 = (low, high) => BigInt(low ?? "0x0") + (BigInt(high ?? "0x0") << 128n);
11347
+ async function readDrop(provider, collection) {
11348
+ const contractAddress = hex(collection);
11349
+ const read = (entrypoint) => provider.callContract({ contractAddress, entrypoint, calldata: [] });
11350
+ const [organizer, terms, root, max, minted] = await Promise.all([
11351
+ read("organizer"),
11352
+ read("terms"),
11353
+ read("allowlist_root"),
11354
+ read("max_supply"),
11355
+ read("total_minted")
11356
+ ]);
11357
+ return {
11358
+ organizer: hex(organizer[0]),
11359
+ startTime: Number(BigInt(terms[0] ?? "0x0")),
11360
+ endTime: Number(BigInt(terms[1] ?? "0x0")),
11361
+ price: u2562(terms[2], terms[3]),
11362
+ paymentToken: hex(terms[4]),
11363
+ maxPerWallet: u2562(terms[5], terms[6]),
11364
+ allowlistRoot: root[0] ?? "0x0",
11365
+ maxSupply: u2562(max[0], max[1]),
11366
+ totalMinted: u2562(minted[0], minted[1])
11367
+ };
12265
11368
  }
12266
- function encodePairingPayload(payload) {
12267
- return JSON.stringify({
12268
- scheme: SCHEME,
12269
- version: VERSION,
12270
- publicKey: normalisePublicKey(payload.publicKey),
12271
- label: sanitiseLabel(payload.label)
11369
+ async function buildDropClaimCalls(provider, collection, input, feeConfig) {
11370
+ const drop = await readDrop(provider, collection);
11371
+ const calls = dropCalls.claim(collection, {
11372
+ quantity: input.quantity,
11373
+ proof: input.proof,
11374
+ price: drop.price,
11375
+ paymentToken: drop.paymentToken
12272
11376
  });
11377
+ if (drop.price === 0n) return calls;
11378
+ const fee = buildFeeCall(
11379
+ { surface: "launchpad", token: drop.paymentToken, grossAmount: drop.price * BigInt(input.quantity) },
11380
+ feeConfig
11381
+ );
11382
+ return fee ? [...calls, fee] : calls;
12273
11383
  }
12274
- function parsePairingPayload(encoded) {
12275
- let data;
12276
- try {
12277
- data = JSON.parse(encoded);
12278
- } catch {
12279
- throw new InvalidPairingPayloadError();
12280
- }
12281
- if (data === null || typeof data !== "object") throw new InvalidPairingPayloadError();
12282
- if (data.scheme !== SCHEME || data.version !== VERSION) throw new InvalidPairingPayloadError();
12283
- return {
12284
- publicKey: normalisePublicKey(data.publicKey),
12285
- label: sanitiseLabel(data.label)
12286
- };
11384
+ async function dropClaimedBy(provider, collection, wallet) {
11385
+ const res = await provider.callContract({ contractAddress: hex(collection), entrypoint: "claimed_by", calldata: [hex(wallet)] });
11386
+ return u2562(res[0], res[1]);
12287
11387
  }
12288
- function parseAccountAddress(input) {
12289
- const trimmed = typeof input === "string" ? input.trim() : "";
12290
- if (!/^0x[0-9a-fA-F]{50,64}$/.test(trimmed)) {
12291
- throw new InvalidPairingPayloadError("That does not look like an account address.");
11388
+ function dropMintState(input) {
11389
+ const none = (state) => ({ state, maxQuantity: 0n });
11390
+ const { drop, wallet, claimed, proof, balance, now } = input;
11391
+ if (!drop) return none("loading");
11392
+ if (drop.startTime !== 0 && now < drop.startTime) return none("upcoming");
11393
+ if (drop.endTime !== 0 && now > drop.endTime) return none("ended");
11394
+ const supplyLeft = drop.maxSupply === 0n ? null : drop.maxSupply - drop.totalMinted;
11395
+ if (supplyLeft !== null && supplyLeft <= 0n) return none("sold-out");
11396
+ if (!wallet) return none("no-wallet");
11397
+ if (BigInt(drop.allowlistRoot) !== 0n) {
11398
+ if (proof === null) return none("no-link");
11399
+ if (!verifyPopProof(drop.allowlistRoot, wallet, proof)) return none("not-on-list");
12292
11400
  }
12293
- if (BigInt(trimmed) === 0n) {
12294
- throw new InvalidPairingPayloadError("That does not look like an account address.");
11401
+ if (claimed === null) return none("loading");
11402
+ const walletLeft = drop.maxPerWallet === 0n ? null : drop.maxPerWallet - claimed;
11403
+ if (walletLeft !== null && walletLeft <= 0n) return none("limit-reached");
11404
+ let max = DROP_MAX_CLAIM_QUANTITY;
11405
+ if (supplyLeft !== null && supplyLeft < max) max = supplyLeft;
11406
+ if (walletLeft !== null && walletLeft < max) max = walletLeft;
11407
+ if (drop.price > 0n) {
11408
+ if (balance === null) return none("loading");
11409
+ while (max > 0n && dropMintCost(drop.price, max, input.feeBps).total > balance) max--;
11410
+ if (max === 0n) return none("insufficient-balance");
12295
11411
  }
12296
- return trimmed;
11412
+ return { state: "ready", maxQuantity: max };
12297
11413
  }
12298
-
12299
- // src/wallet/recovery-key.ts
12300
- var PREFIX = "medialane-recovery:v1:";
12301
- var ADDRESS = /^0x[0-9a-fA-F]{1,64}$/;
12302
- var InvalidRecoveryKeyError = class extends Error {
12303
- constructor(message = "This is not a valid recovery key.") {
12304
- super(message);
12305
- this.name = "InvalidRecoveryKeyError";
12306
- }
11414
+ function dropClaimLinks(origin, collection, list) {
11415
+ const base = `${origin}${chunkMEJ47LC3_cjs.dropHref(collection)}`;
11416
+ return Object.entries(list.proofs).map(([address, proof]) => ({
11417
+ address,
11418
+ url: `${base}${encodePopClaimFragment(proof)}`
11419
+ }));
11420
+ }
11421
+ function populateCall(abi, contractAddress, entrypoint, args) {
11422
+ return { contractAddress, entrypoint, calldata: new starknet.CallData(abi).compile(entrypoint, args) };
11423
+ }
11424
+ var addr3 = (address) => chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", address);
11425
+ var optionOf = (value) => value != null ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, value) : new starknet.CairoOption(starknet.CairoOptionVariant.None);
11426
+ var deployCollectionCall = (abi, factory, p) => populateCall(abi, addr3(factory), "deploy_collection", [p.name, p.symbol, p.baseUri]);
11427
+ var popFactoryCalls = {
11428
+ createCollection: (factory, p) => populateCall(POPFactoryABI, factory, "create_collection", [p.name, p.symbol, p.baseUri, p.claimEndTime])
12307
11429
  };
12308
- var canonicalAddress = (address) => `0x${BigInt(address).toString(16).padStart(64, "0")}`;
12309
- function keyPair(privateKey) {
12310
- try {
12311
- return chunk2R7XBA34_cjs.starkKeyPairFromPrivateKey(privateKey);
12312
- } catch {
12313
- throw new InvalidRecoveryKeyError();
12314
- }
11430
+ var ticketCalls = {
11431
+ deployCollection: (factory, p) => deployCollectionCall(IPTicketCollectionFactoryABI, factory, p),
11432
+ createTicket: (p) => populateCall(IPTicketCollectionABI, addr3(p.collection), "create_ticket", [
11433
+ starknet.cairo.uint256(p.maxSupply),
11434
+ optionOf(p.startTime),
11435
+ optionOf(p.endTime),
11436
+ p.royaltyBps,
11437
+ p.metadataUri
11438
+ ]),
11439
+ mint: (p) => populateCall(IPTicketCollectionABI, addr3(p.collection), "mint", [
11440
+ p.to,
11441
+ starknet.cairo.uint256(p.tokenId),
11442
+ starknet.cairo.uint256(p.amount)
11443
+ ])
11444
+ };
11445
+ var clubCalls = {
11446
+ deployCollection: (factory, p) => deployCollectionCall(IPClubFactoryABI, factory, p),
11447
+ createMembership: (p) => populateCall(IPClubCollectionABI, addr3(p.collection), "create_membership", [
11448
+ starknet.cairo.uint256(p.maxSupply),
11449
+ optionOf(p.startTime),
11450
+ optionOf(p.endTime),
11451
+ p.royaltyBps,
11452
+ p.metadataUri
11453
+ ]),
11454
+ mint: (p) => populateCall(IPClubCollectionABI, addr3(p.collection), "mint", [
11455
+ p.to,
11456
+ starknet.cairo.uint256(p.tokenId),
11457
+ starknet.cairo.uint256(p.amount)
11458
+ ])
11459
+ };
11460
+ var sponsorship = (contract, entrypoint, args) => populateCall(IPSponsorshipABI, addr3(contract), entrypoint, args);
11461
+ var sponsorshipCalls = {
11462
+ createOffer: (contract, p) => sponsorship(contract, "create_offer", [
11463
+ p.nftContract,
11464
+ starknet.cairo.uint256(p.tokenId),
11465
+ starknet.cairo.uint256(p.minAmount),
11466
+ p.duration,
11467
+ p.paymentToken,
11468
+ p.licenseTermsUri,
11469
+ p.transferable,
11470
+ starknet.cairo.uint256(p.royaltyBps),
11471
+ p.specificSponsor ? new starknet.CairoOption(starknet.CairoOptionVariant.Some, p.specificSponsor) : new starknet.CairoOption(starknet.CairoOptionVariant.None)
11472
+ ]),
11473
+ setOfferOpen: (contract, p) => sponsorship(contract, "set_offer_open", [starknet.cairo.uint256(p.offerId), p.open]),
11474
+ placeBid: (contract, p) => {
11475
+ const amount = starknet.cairo.uint256(p.amount);
11476
+ return [
11477
+ {
11478
+ contractAddress: p.paymentToken,
11479
+ entrypoint: "approve",
11480
+ calldata: [addr3(contract), amount.low.toString(), amount.high.toString()]
11481
+ },
11482
+ sponsorship(contract, "place_bid", [starknet.cairo.uint256(p.offerId), amount])
11483
+ ];
11484
+ },
11485
+ retractBid: (contract, p) => sponsorship(contract, "retract_bid", [starknet.cairo.uint256(p.offerId)]),
11486
+ acceptBid: (contract, p) => sponsorship(contract, "accept_bid", [starknet.cairo.uint256(p.offerId), p.sponsor]),
11487
+ propose: (contract, p) => sponsorship(contract, "propose_sponsorship", [
11488
+ p.nftContract,
11489
+ starknet.cairo.uint256(p.tokenId),
11490
+ starknet.cairo.uint256(p.amount),
11491
+ p.duration,
11492
+ p.validUntil ?? 0,
11493
+ p.paymentToken,
11494
+ p.licenseTermsUri,
11495
+ p.transferable,
11496
+ starknet.cairo.uint256(p.royaltyBps)
11497
+ ]),
11498
+ withdrawProposal: (contract, p) => sponsorship(contract, "withdraw_proposal", [starknet.cairo.uint256(p.proposalId)]),
11499
+ acceptProposal: (contract, p) => sponsorship(contract, "accept_proposal", [starknet.cairo.uint256(p.proposalId)]),
11500
+ rejectProposal: (contract, p) => sponsorship(contract, "reject_proposal", [starknet.cairo.uint256(p.proposalId)])
11501
+ };
11502
+ var edition = (collection, entrypoint, args) => populateCall(IPCollection1155ABI, addr3(collection), entrypoint, args);
11503
+ var editionCalls = {
11504
+ deployCollection: (factory, p) => deployCollectionCall(IPCollection1155FactoryABI, factory, p),
11505
+ mintEdition: (p) => edition(p.collection, "mint_edition", [p.to, BigInt(p.value), p.tokenUri]),
11506
+ batchMintEdition: (p) => edition(p.collection, "batch_mint_edition", [
11507
+ p.to,
11508
+ p.items.map((i) => BigInt(i.value)),
11509
+ p.items.map((i) => i.tokenUri)
11510
+ ]),
11511
+ addSupply: (p) => edition(p.collection, "add_supply", [p.to, BigInt(p.tokenId), BigInt(p.value)]),
11512
+ setDefaultRoyalty: (p) => edition(p.collection, "set_default_royalty", [p.receiver, BigInt(p.feeNumerator)]),
11513
+ setTokenRoyalty: (p) => edition(p.collection, "set_token_royalty", [BigInt(p.tokenId), p.receiver, BigInt(p.feeNumerator)]),
11514
+ setApprovalForAll: (p) => edition(p.collection, "set_approval_for_all", [p.operator, p.approved])
11515
+ };
11516
+
11517
+ // src/starknet/services/coinLaunchMath.ts
11518
+ var COIN_DECIMALS = 18;
11519
+ var SUGGESTED_DEFAULT_PRICE = 0.01;
11520
+ var MIN_SUPPLY = 1000n;
11521
+ var MAX_SUPPLY = 1000000000000n;
11522
+ var MAX_FELT_BYTES = 31;
11523
+ function byteLen(s) {
11524
+ return new TextEncoder().encode(s).length;
12315
11525
  }
12316
- function encodeRecoveryKey(key) {
12317
- if (!ADDRESS.test(key.walletAddress) || BigInt(key.walletAddress) === 0n) throw new InvalidRecoveryKeyError();
12318
- return `${PREFIX}${canonicalAddress(key.walletAddress)}:${keyPair(key.privateKey).privateKeyHex}`;
11526
+ function validateName(s) {
11527
+ if (!s.trim()) return "Name is required";
11528
+ if (byteLen(s) > MAX_FELT_BYTES) return `Name must be at most ${MAX_FELT_BYTES} bytes`;
11529
+ return null;
12319
11530
  }
12320
- function parseRecoveryKey(input) {
12321
- const trimmed = input.trim();
12322
- if (!trimmed.startsWith(PREFIX)) {
12323
- const { privateKeyHex, publicKeyHex } = keyPair(trimmed);
12324
- return { walletAddress: chunk2R7XBA34_cjs.computeAccountAddress(publicKeyHex, 0), privateKey: privateKeyHex };
12325
- }
12326
- const parts = trimmed.slice(PREFIX.length).split(":");
12327
- const [walletAddress, privateKey] = parts;
12328
- if (parts.length !== 2 || !walletAddress || !privateKey || !ADDRESS.test(walletAddress) || BigInt(walletAddress) === 0n) {
12329
- throw new InvalidRecoveryKeyError();
12330
- }
12331
- return { walletAddress: canonicalAddress(walletAddress), privateKey: keyPair(privateKey).privateKeyHex };
11531
+ function validateSymbol(s) {
11532
+ if (!s.trim()) return "Symbol is required";
11533
+ if (byteLen(s) > MAX_FELT_BYTES) return `Symbol must be at most ${MAX_FELT_BYTES} bytes`;
11534
+ return null;
12332
11535
  }
12333
-
12334
- // src/wallet/guardian-status.ts
12335
- function describeGuardianStatus(guardians) {
12336
- if (guardians.length === 0) return { kind: "none" };
12337
- return { kind: "active", guardian: guardians[0] };
11536
+ function validateSupply(human) {
11537
+ if (!/^\d+$/.test(human.trim())) return "Supply must be a whole number";
11538
+ const v = BigInt(human.trim());
11539
+ if (v < MIN_SUPPLY) return `Supply must be at least ${MIN_SUPPLY.toString()}`;
11540
+ if (v > MAX_SUPPLY) return `Supply must be at most ${MAX_SUPPLY.toString()}`;
11541
+ return null;
12338
11542
  }
12339
- function describeRecoveryAction(escape) {
12340
- if (escape.escapeType !== "Owner") return "none";
12341
- if (escape.status === "Ready") return "complete";
12342
- if (escape.status === "Expired") return "start";
12343
- return "none";
11543
+ function toRaw(human, decimals = COIN_DECIMALS) {
11544
+ return human * 10n ** BigInt(decimals);
11545
+ }
11546
+ function teamCoinsRaw(supplyRaw, pct) {
11547
+ const bps = BigInt(Math.round(pct * 100));
11548
+ return supplyRaw * bps / 10000n;
12344
11549
  }
12345
- function normalizeWalletAddress(address) {
12346
- return chunk2R7XBA34_cjs.normalizeAddress("STARKNET", address);
11550
+ var PRICE_SCALE = 1000000000000n;
11551
+ function buybackQuoteRaw(teamCoinsRawValue, price, quoteDecimals) {
11552
+ const priceScaled = BigInt(Math.round(price * Number(PRICE_SCALE)));
11553
+ return teamCoinsRawValue * priceScaled * 10n ** BigInt(quoteDecimals) / (PRICE_SCALE * 10n ** BigInt(COIN_DECIMALS));
12347
11554
  }
12348
- function isValidStarknetAddress(address) {
12349
- try {
12350
- starknet.validateAndParseAddress(address.trim());
12351
- return true;
12352
- } catch {
12353
- return false;
12354
- }
11555
+ function fdvHuman(supplyHuman, price) {
11556
+ return supplyHuman * price;
12355
11557
  }
12356
- var CONTRACT_NOT_FOUND = 20;
12357
- async function isDeployed(provider, address) {
12358
- try {
12359
- await provider.getClassHashAt(normalizeWalletAddress(address));
12360
- return true;
12361
- } catch (err) {
12362
- if (err?.code === CONTRACT_NOT_FOUND) return false;
12363
- throw err;
12364
- }
11558
+
11559
+ // src/starknet/services/creatorCoin.ts
11560
+ var VALIDATED_EKUBO_PARAMS = {
11561
+ fee: "0xc49ba5e353f7d00000000000000000",
11562
+ tickSpacing: 5982n,
11563
+ startingPrice: { mag: 4600158n, sign: true },
11564
+ bound: 88719042n
11565
+ };
11566
+ var TICK_BASE = 1.000001;
11567
+ function priceToEkuboParams(quoteDecimals, price = SUGGESTED_DEFAULT_PRICE) {
11568
+ const decAdj = 10 ** (COIN_DECIMALS - quoteDecimals);
11569
+ const rawRatio = price / decAdj;
11570
+ const tickSpacing = Number(VALIDATED_EKUBO_PARAMS.tickSpacing);
11571
+ const rawTick = Math.log(rawRatio) / Math.log(TICK_BASE);
11572
+ const roundedTick = Math.trunc(rawTick / tickSpacing) * tickSpacing;
11573
+ return {
11574
+ fee: VALIDATED_EKUBO_PARAMS.fee,
11575
+ tickSpacing: VALIDATED_EKUBO_PARAMS.tickSpacing,
11576
+ startingPrice: { mag: BigInt(Math.abs(roundedTick)), sign: roundedTick < 0 },
11577
+ bound: VALIDATED_EKUBO_PARAMS.bound
11578
+ };
11579
+ }
11580
+ function validatePrice(quoteDecimals, price) {
11581
+ if (!isFinite(price) || price <= 0) return "Price must be a positive number";
11582
+ const decAdj = 10 ** (COIN_DECIMALS - quoteDecimals);
11583
+ const rawRatio = price / decAdj;
11584
+ if (!isFinite(rawRatio) || rawRatio <= 0) return "Price must be a positive number";
11585
+ const rawTick = Math.log(rawRatio) / Math.log(TICK_BASE);
11586
+ if (!isFinite(rawTick)) return "Price is outside the supported range";
11587
+ const bound = Number(VALIDATED_EKUBO_PARAMS.bound);
11588
+ if (Math.abs(rawTick) >= bound) return "Price is outside the supported range";
11589
+ return null;
12365
11590
  }
12366
-
12367
- // src/wallet/self-fund-consent.ts
12368
- function createSelfFundConsent(estimateFee) {
12369
- let handler = null;
11591
+ var MAX_TEAM_ALLOCATION_PERCENT = 10;
11592
+ var MAX_HOLDERS_AT_LAUNCH = 10;
11593
+ function u2563(parts, offset = 0) {
11594
+ return BigInt(parts[offset] ?? "0x0") + (BigInt(parts[offset + 1] ?? "0x0") << 128n);
11595
+ }
11596
+ async function getCreatorCoinGuarantees(coinAddress, provider) {
11597
+ const call = (entrypoint) => provider.callContract({ contractAddress: coinAddress, entrypoint, calldata: [] });
11598
+ const [launchedRes, allocRes] = await Promise.all([
11599
+ call("is_launched").catch(() => null),
11600
+ call("get_team_allocation").catch(() => null)
11601
+ ]);
11602
+ if (!launchedRes || !allocRes) return null;
11603
+ const [supplyRes, blockRes, liquidityRes] = await Promise.all([
11604
+ call("total_supply"),
11605
+ call("launched_at_block_number").catch(() => null),
11606
+ call("liquidity_type").catch(() => null)
11607
+ ]);
11608
+ const isLaunched = BigInt(launchedRes[0] ?? "0x0") !== 0n;
11609
+ const totalSupply = u2563(supplyRes);
11610
+ const teamAllocation = u2563(allocRes);
11611
+ const teamAllocationPercent = totalSupply > 0n ? Number(teamAllocation * 10000n / totalSupply) / 100 : null;
11612
+ const launchedAtBlock = isLaunched && blockRes?.[0] != null ? Number(BigInt(blockRes[0])) : null;
11613
+ const liquidityPositionId = liquidityRes && BigInt(liquidityRes[0] ?? "0x1") === 0n && liquidityRes[2] != null ? BigInt(liquidityRes[2]).toString() : null;
12370
11614
  return {
12371
- registerHandler(next) {
12372
- handler = next;
12373
- },
12374
- async request({ address, calls }) {
12375
- if (!handler) return false;
12376
- const feeEstimate = address && calls ? estimateFee(address, calls).catch(() => null) : Promise.resolve(null);
12377
- return handler(feeEstimate);
12378
- }
11615
+ isLaunched,
11616
+ launchedAtBlock,
11617
+ totalSupplyRaw: totalSupply.toString(),
11618
+ teamAllocationRaw: teamAllocation.toString(),
11619
+ teamAllocationPercent,
11620
+ liquidityPositionId
12379
11621
  };
12380
11622
  }
12381
- function accountFor(provider, address, privateKeyHex) {
12382
- return new starknet.Account({ provider, address, signer: privateKeyHex, cairoVersion: "1" });
12383
- }
12384
- async function estimateSelfFundedFee(provider, address, calls) {
12385
- const account = new starknet.Account({ provider, address, signer: "0x1", cairoVersion: "1" });
12386
- const estimate = await account.estimateInvokeFee(calls);
12387
- const balanceRaw = await feeTokenBalance(provider, address, estimate.unit).catch(() => null);
12388
- return { feeRaw: estimate.overall_fee, unit: estimate.unit, balanceRaw };
12389
- }
12390
- async function feeTokenBalance(provider, address, unit) {
12391
- const token = chunk2R7XBA34_cjs.getTokenBySymbol(unit === "FRI" ? "STRK" : "ETH");
12392
- if (!token) throw new Error(`No fee token for unit ${unit}`);
12393
- return erc20Balance(provider, token.address, address);
11623
+ var factoryAddress = () => chunkH2NJB3AK_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory;
11624
+ function buildCreateCreatorCoinCall(params) {
11625
+ const salt = params.salt ?? BigInt("0x" + Date.now().toString(16));
11626
+ return populateCall(CreatorCoinFactoryABI, factoryAddress(), "create_creator_coin", [
11627
+ params.owner,
11628
+ params.name,
11629
+ params.symbol,
11630
+ BigInt(params.initialSupply),
11631
+ BigInt(salt)
11632
+ ]);
12394
11633
  }
12395
- function selfFundedExecutor(deps) {
12396
- return {
12397
- async execute({ userAddress, privateKeyHex, calls }) {
12398
- const account = accountFor(deps.provider(), userAddress, privateKeyHex);
12399
- const { transaction_hash } = await account.execute(calls);
12400
- return { transactionHash: transaction_hash };
12401
- }
11634
+ function buildLaunchOnEkuboCalls(params) {
11635
+ const ek = params.ekubo;
11636
+ const launchParameters = {
11637
+ creator_coin_address: params.creatorCoin,
11638
+ transfer_restriction_delay: params.transferRestrictionDelay ?? 0,
11639
+ max_percentage_buy_launch: params.maxPercentageBuyLaunch ?? 200,
11640
+ quote_address: params.quoteToken,
11641
+ initial_holders: params.initialHolders,
11642
+ initial_holders_amounts: params.initialHoldersAmounts.map((a) => BigInt(a))
12402
11643
  };
12403
- }
12404
- function sponsoredExecutor(deps) {
12405
- const fallback = deps.fallback ?? selfFundedExecutor(deps);
12406
- return {
12407
- async execute(input) {
12408
- const { userAddress, privateKeyHex, calls, intentIds } = input;
12409
- if (!intentIds?.length) {
12410
- const consented2 = await deps.consent.request({ address: userAddress, calls });
12411
- if (!consented2) throw new SponsoredCallRejectedError("This action can't be sponsored");
12412
- return fallback.execute(input);
12413
- }
12414
- const result = await executeSponsored(
12415
- { proxyUrl: deps.proxyUrl, fetchImpl: deps.fetchImpl },
12416
- {
12417
- address: userAddress,
12418
- signTypedData: async (data) => chunk2R7XBA34_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, userAddress))
12419
- },
12420
- { intentIds }
12421
- );
12422
- if (result.status === "sponsored") return { transactionHash: result.transactionHash };
12423
- const consented = await deps.consent.request({ address: userAddress, calls });
12424
- if (!consented) throw new SponsoredCallRejectedError(result.reason);
12425
- return fallback.execute(input);
12426
- }
11644
+ const ekuboParameters = {
11645
+ fee: BigInt(ek.fee),
11646
+ tick_spacing: BigInt(ek.tickSpacing),
11647
+ starting_price: { mag: BigInt(ek.startingPrice.mag), sign: ek.startingPrice.sign },
11648
+ bound: BigInt(ek.bound)
12427
11649
  };
12428
- }
12429
- async function describeFailure(res, fallback) {
12430
- const body = await res.json().catch(() => null);
12431
- throw new Error(body?.error || fallback);
12432
- }
12433
- async function deploySponsored(input) {
12434
- const doFetch = input.fetchImpl ?? fetch;
12435
- const base = input.proxyUrl.replace(/\/$/, "");
12436
- const buildRes = await doFetch(`${base}/build`, {
12437
- method: "POST",
12438
- headers: { "Content-Type": "application/json" },
12439
- body: JSON.stringify({
12440
- ownerPubkey: input.ownerPubKey,
12441
- ownerAddress: input.ownerAddress,
12442
- salt: input.salt ?? "0x0"
12443
- })
12444
- });
12445
- if (!buildRes.ok) {
12446
- await describeFailure(buildRes, "We couldn't prepare your wallet deployment. Please try again.");
12447
- }
12448
- const { typedData, deployment, calls } = await buildRes.json();
12449
- const account = new starknet.Account({
12450
- provider: input.provider,
12451
- address: input.ownerAddress,
12452
- signer: input.privateKeyHex,
12453
- cairoVersion: "1"
12454
- });
12455
- const signature = starknet.stark.signatureToHexArray(await account.signMessage(typedData));
12456
- const executeRes = await doFetch(`${base}/execute`, {
12457
- method: "POST",
12458
- headers: { "Content-Type": "application/json" },
12459
- body: JSON.stringify({ ownerAddress: input.ownerAddress, typedData, signature, deployment, calls })
12460
- });
12461
- if (!executeRes.ok) {
12462
- await describeFailure(executeRes, "We couldn't complete your wallet deployment. Please try again.");
12463
- }
12464
- const { transactionHash } = await executeRes.json();
12465
- return { transactionHash };
12466
- }
12467
- async function deploySelfFunded(input) {
12468
- const classHash = chunk7EYJC5CB_cjs.getCoordinates("STARKNET").mediaWalletClassHash;
12469
- if (!classHash) throw new Error("Media Wallet class hash is not configured");
12470
- const account = new starknet.Account({
12471
- provider: input.provider,
12472
- address: input.ownerAddress,
12473
- signer: input.privateKeyHex,
12474
- cairoVersion: "1"
12475
- });
12476
- const { transaction_hash } = await account.deployAccount({
12477
- classHash,
12478
- constructorCalldata: chunk2R7XBA34_cjs.ownerConstructorCalldata(input.ownerPubKey),
12479
- addressSalt: 0,
12480
- contractAddress: input.ownerAddress
12481
- });
12482
- return { transactionHash: transaction_hash };
12483
- }
12484
- async function waitUntilDeployed(provider, address, timeoutMs = 9e4, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) {
12485
- const deadline = Date.now() + timeoutMs;
12486
- let wait = 1e3;
12487
- for (; ; ) {
12488
- if (await isDeployed(provider, address).catch(() => false)) return;
12489
- if (Date.now() >= deadline) {
12490
- throw new Error(
12491
- "Your wallet was submitted but has not appeared on Starknet yet. Please try again in a moment."
12492
- );
12493
- }
12494
- await sleep(wait);
12495
- wait = Math.min(Math.round(wait * 1.5), 5e3);
11650
+ const calls = [];
11651
+ if (params.quoteFundAmount !== void 0) {
11652
+ const amt = starknet.uint256.bnToUint256(BigInt(params.quoteFundAmount));
11653
+ calls.push({
11654
+ contractAddress: params.quoteToken,
11655
+ entrypoint: "transfer",
11656
+ calldata: [factoryAddress(), amt.low, amt.high]
11657
+ });
12496
11658
  }
11659
+ calls.push(populateCall(CreatorCoinFactoryABI, factoryAddress(), "launch_on_ekubo", [launchParameters, ekuboParameters]));
11660
+ return calls;
12497
11661
  }
12498
- async function deployWallet(deps, wallet) {
12499
- const sponsored = deps.deploySponsoredImpl ?? deploySponsored;
12500
- const selfFunded = deps.deploySelfFundedImpl ?? deploySelfFunded;
12501
- if (deps.deployProxyUrl) {
11662
+ var CREATOR_COIN_CREATED_SELECTOR = starknet.hash.getSelectorFromName("CreatorCoinCreated");
11663
+ function parseCreatorCoinCreated(receipt) {
11664
+ const factory = chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", chunkH2NJB3AK_cjs.getStarknetCoordinates("STARKNET").creatorCoinFactory);
11665
+ for (const ev of receipt?.events ?? []) {
11666
+ let from;
12502
11667
  try {
12503
- await sponsored({
12504
- proxyUrl: deps.deployProxyUrl,
12505
- provider: deps.provider(),
12506
- fetchImpl: deps.fetchImpl,
12507
- ...wallet
12508
- });
12509
- } catch (sponsoredErr) {
12510
- try {
12511
- await selfFunded({ provider: deps.provider(), ...wallet });
12512
- } catch (selfFundedErr) {
12513
- const sponsored2 = sponsoredErr instanceof Error ? sponsoredErr.message : String(sponsoredErr);
12514
- const selfFunded2 = selfFundedErr instanceof Error ? selfFundedErr.message : String(selfFundedErr);
12515
- throw new Error(`Sponsored deploy failed: ${sponsored2}. Self-funded fallback failed: ${selfFunded2}`);
12516
- }
11668
+ from = chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", ev.from_address ?? "");
11669
+ } catch {
11670
+ continue;
12517
11671
  }
12518
- } else {
12519
- await selfFunded({ provider: deps.provider(), ...wallet });
12520
- }
12521
- await (deps.waitUntilDeployedImpl ?? waitUntilDeployed)(deps.provider(), wallet.ownerAddress);
12522
- }
12523
- async function completeDeployment(deps, onStep, options = {}) {
12524
- let sealed = options.forceNew ? null : deps.store.load();
12525
- if (sealed && await (deps.isDeployedImpl ?? isDeployed)(deps.provider(), sealed.address).catch(() => false)) {
12526
- sealed = null;
12527
- }
12528
- let privateKeyHex;
12529
- if (!sealed) {
12530
- onStep("creating-passkey");
12531
- const created = await deps.passkey.createOwnerKey();
12532
- sealed = created.sealed;
12533
- privateKeyHex = created.privateKeyHex;
12534
- deps.store.save(sealed);
12535
- } else {
12536
- privateKeyHex = await deps.passkey.unlockOwnerKey(sealed);
11672
+ if (from !== factory) continue;
11673
+ const k0 = ev.keys?.[0];
11674
+ if (!k0 || chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", k0) !== chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", CREATOR_COIN_CREATED_SELECTOR)) continue;
11675
+ const data = ev.data ?? [];
11676
+ if (data.length < 1) continue;
11677
+ return chunk3HPMEDYH_cjs.normalizeAddress("STARKNET", data[data.length - 1]);
12537
11678
  }
12538
- onStep("deploying");
12539
- await deployWallet(deps, { ownerAddress: sealed.address, ownerPubKey: sealed.ownerPubKey, privateKeyHex });
12540
- deps.store.notifyChange();
12541
- return { sealed };
12542
- }
12543
- function createDeploymentCoordinator(execute) {
12544
- let inFlight = null;
12545
- let currentStep = null;
12546
- const listeners = /* @__PURE__ */ new Set();
12547
- return {
12548
- run(onStep, options = {}) {
12549
- if (inFlight) {
12550
- if (options.forceNew) {
12551
- return Promise.reject(new Error("A wallet setup is already in progress."));
12552
- }
12553
- if (currentStep) onStep(currentStep);
12554
- listeners.add(onStep);
12555
- return inFlight.finally(() => listeners.delete(onStep));
12556
- }
12557
- listeners.add(onStep);
12558
- let started;
12559
- try {
12560
- started = execute((step) => {
12561
- currentStep = step;
12562
- for (const listener of listeners) listener(step);
12563
- }, options);
12564
- } catch (err) {
12565
- listeners.clear();
12566
- return Promise.reject(err);
12567
- }
12568
- const run = started.finally(() => {
12569
- inFlight = null;
12570
- currentStep = null;
12571
- listeners.clear();
12572
- });
12573
- inFlight = run;
12574
- return run;
12575
- },
12576
- isDeploying: () => inFlight !== null
12577
- };
12578
- }
12579
-
12580
- // src/wallet/client.ts
12581
- function describeDevices(owners, thisDevicePubkey) {
12582
- const mine = computeOwnerGuid(thisDevicePubkey);
12583
- return owners.map((owner) => ({
12584
- guid: owner.guid,
12585
- type: owner.type,
12586
- isThisDevice: BigInt(owner.guid) === BigInt(mine)
12587
- }));
12588
- }
12589
- function canRemoveDevice(devices, guid) {
12590
- if (devices.length <= 1) return false;
12591
- return devices.some((device) => BigInt(device.guid) === BigInt(guid));
11679
+ throw new Error("Coin deployed but the coin address could not be read from the receipt");
12592
11680
  }
12593
- function createMediaWallet(config) {
12594
- const ttl = config.unlockTtlMs ?? 2e4;
12595
- const deployments = createDeploymentCoordinator((onStep, options) => {
12596
- const deps = {
12597
- store: config.store,
12598
- passkey: config.passkey,
12599
- provider: config.provider,
12600
- deployProxyUrl: config.deployProxyUrl,
12601
- fetchImpl: config.fetchImpl
12602
- };
12603
- return completeDeployment(deps, onStep, options);
12604
- });
12605
- const unlockCache = /* @__PURE__ */ new Map();
12606
- const lock = (address) => {
12607
- const entry = unlockCache.get(address);
12608
- if (!entry) return;
12609
- clearTimeout(entry.timer);
12610
- unlockCache.delete(address);
12611
- };
12612
- const unlockOnce = (sealed) => {
12613
- const existing = unlockCache.get(sealed.address);
12614
- if (existing) return existing.promise;
12615
- const promise = config.passkey.unlockOwnerKey(sealed).catch((err) => {
12616
- lock(sealed.address);
12617
- throw err;
12618
- });
12619
- const timer = setTimeout(() => lock(sealed.address), ttl);
12620
- unlockCache.set(sealed.address, { promise, timer });
12621
- return promise;
12622
- };
12623
- const run = async (sealed, calls, userAddress, intentIds) => {
12624
- const privateKeyHex = await unlockOnce(sealed);
12625
- return config.executor.execute({
12626
- userAddress: userAddress ?? sealed.address,
12627
- privateKeyHex,
12628
- calls,
12629
- intentIds
12630
- });
12631
- };
12632
- const walletIntents = config.walletIntents ?? (async (params) => {
12633
- if (!config.backendUrl) throw new Error("This wallet has no backend url configured");
12634
- const created = await new chunk2R7XBA34_cjs.ApiClient(config.backendUrl).createWalletManageIntent(params);
12635
- return created.data;
11681
+ async function isCreatorCoin(provider, address) {
11682
+ const res = await provider.callContract({
11683
+ contractAddress: factoryAddress(),
11684
+ entrypoint: "is_creator_coin",
11685
+ calldata: [address]
12636
11686
  });
12637
- const manage = async (sealed, params) => {
12638
- const intent = await walletIntents(params);
12639
- const { transactionHash } = await run(sealed, intent.calls, params.owner, [intent.id]);
12640
- return transactionHash;
12641
- };
12642
- return {
12643
- store: config.store,
12644
- passkey: config.passkey,
12645
- lock,
12646
- signerFor(sealed) {
12647
- return {
12648
- address: sealed.address,
12649
- signTypedData: async (data) => {
12650
- const privateKeyHex = await unlockOnce(sealed);
12651
- return chunk2R7XBA34_cjs.signWithPrivateKey(privateKeyHex, starknet.typedData.getMessageHash(data, sealed.address));
12652
- },
12653
- execute: async (calls, opts) => {
12654
- const { transactionHash } = await run(sealed, calls, void 0, opts?.intentIds);
12655
- return { txHash: transactionHash };
12656
- }
12657
- };
12658
- },
12659
- run,
12660
- getGuardians: (address) => getGuardians(config.provider(), address),
12661
- getEscape: (address) => getEscape(config.provider(), address),
12662
- getEscapeSecurityPeriod: (address) => getEscapeSecurityPeriod(config.provider(), address),
12663
- getOwners: (address) => getOwners(config.provider(), address),
12664
- async isOwnerOf(accountAddress, devicePubkey) {
12665
- const owners = await getOwners(config.provider(), accountAddress);
12666
- const guid = BigInt(computeOwnerGuid(devicePubkey));
12667
- return owners.some((owner) => BigInt(owner.guid) === guid);
12668
- },
12669
- setFirstGuardian: (sealed, guardianPubkey) => manage(sealed, { owner: sealed.address, action: "set_first_guardian", pubkey: guardianPubkey }),
12670
- triggerEscapeOwner: (guardianSealed, targetAddress, newOwnerPubkey) => manage(guardianSealed, { owner: normalizeWalletAddress(targetAddress), action: "trigger_escape", newOwnerPubkey }),
12671
- completeEscapeOwner: (guardianSealed, targetAddress) => manage(guardianSealed, { owner: normalizeWalletAddress(targetAddress), action: "complete_escape" }),
12672
- cancelEscape: (sealed) => manage(sealed, { owner: sealed.address, action: "cancel_escape" }),
12673
- addDevice: (sealed, devicePubkey) => manage(sealed, { owner: sealed.address, action: "add_owner", pubkey: devicePubkey }),
12674
- removeDevice: (sealed, ownerGuid) => manage(sealed, { owner: sealed.address, action: "remove_owner", ownerGuid }),
12675
- completeDeployment: (onStep, options) => deployments.run(onStep, options),
12676
- isDeploying: () => deployments.isDeploying()
12677
- };
11687
+ return BigInt(res[0] ?? "0x0") === 1n;
12678
11688
  }
12679
-
12680
- // src/session/session-wallet.ts
12681
- async function claimSessionWallet(api, walletAddress, deps) {
12682
- const saved = deps.loadOwner();
12683
- const resuming = saved !== null && normalizeWalletAddress(saved.address) === normalizeWalletAddress(walletAddress);
12684
- const sealed = resuming ? saved : { ...(await deps.createOwnerKey()).sealed, address: walletAddress };
12685
- if (!resuming) deps.saveOwner(sealed);
12686
- const { removeOwnerGuid } = await api.setupWalletKey({ newOwnerPubkey: sealed.ownerPubKey });
12687
- if (removeOwnerGuid) await deps.removeOwner(sealed, removeOwnerGuid);
11689
+ function encodeByteArray(str) {
11690
+ const bytes = new TextEncoder().encode(str);
11691
+ const fullChunks = [];
11692
+ let i = 0;
11693
+ while (i + 31 <= bytes.length) {
11694
+ let val = 0n;
11695
+ for (const b of bytes.slice(i, i + 31)) {
11696
+ val = val << 8n | BigInt(b);
11697
+ }
11698
+ fullChunks.push(starknet.num.toHex(val));
11699
+ i += 31;
11700
+ }
11701
+ const remaining = bytes.slice(i);
11702
+ let pendingVal = 0n;
11703
+ for (const b of remaining) {
11704
+ pendingVal = pendingVal << 8n | BigInt(b);
11705
+ }
11706
+ return [
11707
+ fullChunks.length.toString(),
11708
+ ...fullChunks,
11709
+ starknet.num.toHex(pendingVal),
11710
+ remaining.length.toString()
11711
+ ];
12688
11712
  }
12689
11713
 
12690
- Object.defineProperty(exports, "DeviceKeyMissingError", {
11714
+ Object.defineProperty(exports, "InvalidPairingPayloadError", {
11715
+ enumerable: true,
11716
+ get: function () { return chunkZLMIHQWM_cjs.InvalidPairingPayloadError; }
11717
+ });
11718
+ Object.defineProperty(exports, "InvalidRecoveryKeyError", {
12691
11719
  enumerable: true,
12692
- get: function () { return chunk2R7XBA34_cjs.DeviceKeyMissingError; }
11720
+ get: function () { return chunkZLMIHQWM_cjs.InvalidRecoveryKeyError; }
12693
11721
  });
12694
11722
  Object.defineProperty(exports, "InvalidStarkPrivateKeyError", {
12695
11723
  enumerable: true,
12696
- get: function () { return chunk2R7XBA34_cjs.InvalidStarkPrivateKeyError; }
11724
+ get: function () { return chunkZLMIHQWM_cjs.InvalidStarkPrivateKeyError; }
12697
11725
  });
12698
- Object.defineProperty(exports, "PasskeyCancelledError", {
11726
+ Object.defineProperty(exports, "SponsoredCallRejectedError", {
12699
11727
  enumerable: true,
12700
- get: function () { return chunk2R7XBA34_cjs.PasskeyCancelledError; }
11728
+ get: function () { return chunkZLMIHQWM_cjs.SponsoredCallRejectedError; }
12701
11729
  });
12702
- Object.defineProperty(exports, "PasskeyUnsupportedError", {
11730
+ Object.defineProperty(exports, "accountFor", {
12703
11731
  enumerable: true,
12704
- get: function () { return chunk2R7XBA34_cjs.PasskeyUnsupportedError; }
11732
+ get: function () { return chunkZLMIHQWM_cjs.accountFor; }
12705
11733
  });
12706
- Object.defineProperty(exports, "UserFacingError", {
11734
+ Object.defineProperty(exports, "allowsFallbackFunding", {
11735
+ enumerable: true,
11736
+ get: function () { return chunkZLMIHQWM_cjs.allowsFallbackFunding; }
11737
+ });
11738
+ Object.defineProperty(exports, "buildAddOwnerCall", {
12707
11739
  enumerable: true,
12708
- get: function () { return chunk2R7XBA34_cjs.UserFacingError; }
11740
+ get: function () { return chunkZLMIHQWM_cjs.buildAddOwnerCall; }
11741
+ });
11742
+ Object.defineProperty(exports, "buildCancelEscapeCall", {
11743
+ enumerable: true,
11744
+ get: function () { return chunkZLMIHQWM_cjs.buildCancelEscapeCall; }
11745
+ });
11746
+ Object.defineProperty(exports, "buildCompleteEscapeOwnerCall", {
11747
+ enumerable: true,
11748
+ get: function () { return chunkZLMIHQWM_cjs.buildCompleteEscapeOwnerCall; }
11749
+ });
11750
+ Object.defineProperty(exports, "buildDeployAccountParams", {
11751
+ enumerable: true,
11752
+ get: function () { return chunkZLMIHQWM_cjs.buildDeployAccountParams; }
11753
+ });
11754
+ Object.defineProperty(exports, "buildRemoveOwnerByGuidCall", {
11755
+ enumerable: true,
11756
+ get: function () { return chunkZLMIHQWM_cjs.buildRemoveOwnerByGuidCall; }
11757
+ });
11758
+ Object.defineProperty(exports, "buildRemoveOwnerCall", {
11759
+ enumerable: true,
11760
+ get: function () { return chunkZLMIHQWM_cjs.buildRemoveOwnerCall; }
11761
+ });
11762
+ Object.defineProperty(exports, "buildSetFirstGuardianCall", {
11763
+ enumerable: true,
11764
+ get: function () { return chunkZLMIHQWM_cjs.buildSetFirstGuardianCall; }
11765
+ });
11766
+ Object.defineProperty(exports, "buildTriggerEscapeOwnerCall", {
11767
+ enumerable: true,
11768
+ get: function () { return chunkZLMIHQWM_cjs.buildTriggerEscapeOwnerCall; }
11769
+ });
11770
+ Object.defineProperty(exports, "canRemoveDevice", {
11771
+ enumerable: true,
11772
+ get: function () { return chunkZLMIHQWM_cjs.canRemoveDevice; }
11773
+ });
11774
+ Object.defineProperty(exports, "claimSessionWallet", {
11775
+ enumerable: true,
11776
+ get: function () { return chunkZLMIHQWM_cjs.claimSessionWallet; }
11777
+ });
11778
+ Object.defineProperty(exports, "completeDeployment", {
11779
+ enumerable: true,
11780
+ get: function () { return chunkZLMIHQWM_cjs.completeDeployment; }
12709
11781
  });
12710
11782
  Object.defineProperty(exports, "computeAccountAddress", {
12711
11783
  enumerable: true,
12712
- get: function () { return chunk2R7XBA34_cjs.computeAccountAddress; }
11784
+ get: function () { return chunkZLMIHQWM_cjs.computeAccountAddress; }
11785
+ });
11786
+ Object.defineProperty(exports, "computeOwnerGuid", {
11787
+ enumerable: true,
11788
+ get: function () { return chunkZLMIHQWM_cjs.computeOwnerGuid; }
11789
+ });
11790
+ Object.defineProperty(exports, "createDeploymentCoordinator", {
11791
+ enumerable: true,
11792
+ get: function () { return chunkZLMIHQWM_cjs.createDeploymentCoordinator; }
11793
+ });
11794
+ Object.defineProperty(exports, "createMediaWallet", {
11795
+ enumerable: true,
11796
+ get: function () { return chunkZLMIHQWM_cjs.createMediaWallet; }
11797
+ });
11798
+ Object.defineProperty(exports, "createOwnerStore", {
11799
+ enumerable: true,
11800
+ get: function () { return chunkZLMIHQWM_cjs.createOwnerStore; }
12713
11801
  });
12714
11802
  Object.defineProperty(exports, "createPasskeyOwner", {
12715
11803
  enumerable: true,
12716
- get: function () { return chunk2R7XBA34_cjs.createPasskeyOwner; }
11804
+ get: function () { return chunkZLMIHQWM_cjs.createPasskeyOwner; }
11805
+ });
11806
+ Object.defineProperty(exports, "createSelfFundConsent", {
11807
+ enumerable: true,
11808
+ get: function () { return chunkZLMIHQWM_cjs.createSelfFundConsent; }
11809
+ });
11810
+ Object.defineProperty(exports, "decodeEscapeAndStatus", {
11811
+ enumerable: true,
11812
+ get: function () { return chunkZLMIHQWM_cjs.decodeEscapeAndStatus; }
11813
+ });
11814
+ Object.defineProperty(exports, "decodeGuardiansInfo", {
11815
+ enumerable: true,
11816
+ get: function () { return chunkZLMIHQWM_cjs.decodeGuardiansInfo; }
11817
+ });
11818
+ Object.defineProperty(exports, "deploySelfFunded", {
11819
+ enumerable: true,
11820
+ get: function () { return chunkZLMIHQWM_cjs.deploySelfFunded; }
11821
+ });
11822
+ Object.defineProperty(exports, "deploySponsored", {
11823
+ enumerable: true,
11824
+ get: function () { return chunkZLMIHQWM_cjs.deploySponsored; }
12717
11825
  });
12718
11826
  Object.defineProperty(exports, "deriveAesKey", {
12719
11827
  enumerable: true,
12720
- get: function () { return chunk2R7XBA34_cjs.deriveAesKey; }
11828
+ get: function () { return chunkZLMIHQWM_cjs.deriveAesKey; }
11829
+ });
11830
+ Object.defineProperty(exports, "deriveOwnerKeyPair", {
11831
+ enumerable: true,
11832
+ get: function () { return chunkZLMIHQWM_cjs.deriveOwnerKeyPair; }
11833
+ });
11834
+ Object.defineProperty(exports, "describeDevices", {
11835
+ enumerable: true,
11836
+ get: function () { return chunkZLMIHQWM_cjs.describeDevices; }
11837
+ });
11838
+ Object.defineProperty(exports, "describeGuardianStatus", {
11839
+ enumerable: true,
11840
+ get: function () { return chunkZLMIHQWM_cjs.describeGuardianStatus; }
11841
+ });
11842
+ Object.defineProperty(exports, "describeRecoveryAction", {
11843
+ enumerable: true,
11844
+ get: function () { return chunkZLMIHQWM_cjs.describeRecoveryAction; }
11845
+ });
11846
+ Object.defineProperty(exports, "encodePairingPayload", {
11847
+ enumerable: true,
11848
+ get: function () { return chunkZLMIHQWM_cjs.encodePairingPayload; }
11849
+ });
11850
+ Object.defineProperty(exports, "encodeRecoveryKey", {
11851
+ enumerable: true,
11852
+ get: function () { return chunkZLMIHQWM_cjs.encodeRecoveryKey; }
11853
+ });
11854
+ Object.defineProperty(exports, "erc20Balance", {
11855
+ enumerable: true,
11856
+ get: function () { return chunkZLMIHQWM_cjs.erc20Balance; }
11857
+ });
11858
+ Object.defineProperty(exports, "estimateSelfFundedFee", {
11859
+ enumerable: true,
11860
+ get: function () { return chunkZLMIHQWM_cjs.estimateSelfFundedFee; }
11861
+ });
11862
+ Object.defineProperty(exports, "executeSponsored", {
11863
+ enumerable: true,
11864
+ get: function () { return chunkZLMIHQWM_cjs.executeSponsored; }
12721
11865
  });
12722
11866
  Object.defineProperty(exports, "generateStarkKeyPair", {
12723
11867
  enumerable: true,
12724
- get: function () { return chunk2R7XBA34_cjs.generateStarkKeyPair; }
11868
+ get: function () { return chunkZLMIHQWM_cjs.generateStarkKeyPair; }
11869
+ });
11870
+ Object.defineProperty(exports, "getEscape", {
11871
+ enumerable: true,
11872
+ get: function () { return chunkZLMIHQWM_cjs.getEscape; }
11873
+ });
11874
+ Object.defineProperty(exports, "getEscapeSecurityPeriod", {
11875
+ enumerable: true,
11876
+ get: function () { return chunkZLMIHQWM_cjs.getEscapeSecurityPeriod; }
11877
+ });
11878
+ Object.defineProperty(exports, "getGuardians", {
11879
+ enumerable: true,
11880
+ get: function () { return chunkZLMIHQWM_cjs.getGuardians; }
11881
+ });
11882
+ Object.defineProperty(exports, "getOwners", {
11883
+ enumerable: true,
11884
+ get: function () { return chunkZLMIHQWM_cjs.getOwners; }
12725
11885
  });
12726
11886
  Object.defineProperty(exports, "indexedDbDeviceKeys", {
12727
11887
  enumerable: true,
12728
- get: function () { return chunk2R7XBA34_cjs.indexedDbDeviceKeys; }
11888
+ get: function () { return chunkZLMIHQWM_cjs.indexedDbDeviceKeys; }
11889
+ });
11890
+ Object.defineProperty(exports, "isDeployed", {
11891
+ enumerable: true,
11892
+ get: function () { return chunkZLMIHQWM_cjs.isDeployed; }
11893
+ });
11894
+ Object.defineProperty(exports, "isValidStarknetAddress", {
11895
+ enumerable: true,
11896
+ get: function () { return chunkZLMIHQWM_cjs.isValidStarknetAddress; }
11897
+ });
11898
+ Object.defineProperty(exports, "normalizeWalletAddress", {
11899
+ enumerable: true,
11900
+ get: function () { return chunkZLMIHQWM_cjs.normalizeWalletAddress; }
12729
11901
  });
12730
11902
  Object.defineProperty(exports, "ownerConstructorCalldata", {
12731
11903
  enumerable: true,
12732
- get: function () { return chunk2R7XBA34_cjs.ownerConstructorCalldata; }
11904
+ get: function () { return chunkZLMIHQWM_cjs.ownerConstructorCalldata; }
11905
+ });
11906
+ Object.defineProperty(exports, "parseAccountAddress", {
11907
+ enumerable: true,
11908
+ get: function () { return chunkZLMIHQWM_cjs.parseAccountAddress; }
11909
+ });
11910
+ Object.defineProperty(exports, "parsePairingPayload", {
11911
+ enumerable: true,
11912
+ get: function () { return chunkZLMIHQWM_cjs.parsePairingPayload; }
11913
+ });
11914
+ Object.defineProperty(exports, "parseRecoveryKey", {
11915
+ enumerable: true,
11916
+ get: function () { return chunkZLMIHQWM_cjs.parseRecoveryKey; }
12733
11917
  });
12734
11918
  Object.defineProperty(exports, "sealPrivateKey", {
12735
11919
  enumerable: true,
12736
- get: function () { return chunk2R7XBA34_cjs.sealPrivateKey; }
11920
+ get: function () { return chunkZLMIHQWM_cjs.sealPrivateKey; }
11921
+ });
11922
+ Object.defineProperty(exports, "selfFundedExecutor", {
11923
+ enumerable: true,
11924
+ get: function () { return chunkZLMIHQWM_cjs.selfFundedExecutor; }
12737
11925
  });
12738
11926
  Object.defineProperty(exports, "signWithPrivateKey", {
12739
11927
  enumerable: true,
12740
- get: function () { return chunk2R7XBA34_cjs.signWithPrivateKey; }
11928
+ get: function () { return chunkZLMIHQWM_cjs.signWithPrivateKey; }
11929
+ });
11930
+ Object.defineProperty(exports, "sponsoredExecutor", {
11931
+ enumerable: true,
11932
+ get: function () { return chunkZLMIHQWM_cjs.sponsoredExecutor; }
12741
11933
  });
12742
11934
  Object.defineProperty(exports, "starkKeyPairFromPrivateKey", {
12743
11935
  enumerable: true,
12744
- get: function () { return chunk2R7XBA34_cjs.starkKeyPairFromPrivateKey; }
11936
+ get: function () { return chunkZLMIHQWM_cjs.starkKeyPairFromPrivateKey; }
12745
11937
  });
12746
11938
  Object.defineProperty(exports, "unsealPrivateKey", {
12747
11939
  enumerable: true,
12748
- get: function () { return chunk2R7XBA34_cjs.unsealPrivateKey; }
11940
+ get: function () { return chunkZLMIHQWM_cjs.unsealPrivateKey; }
11941
+ });
11942
+ Object.defineProperty(exports, "waitUntilDeployed", {
11943
+ enumerable: true,
11944
+ get: function () { return chunkZLMIHQWM_cjs.waitUntilDeployed; }
11945
+ });
11946
+ Object.defineProperty(exports, "DeviceKeyMissingError", {
11947
+ enumerable: true,
11948
+ get: function () { return chunk3HPMEDYH_cjs.DeviceKeyMissingError; }
11949
+ });
11950
+ Object.defineProperty(exports, "MedialaneError", {
11951
+ enumerable: true,
11952
+ get: function () { return chunk3HPMEDYH_cjs.MedialaneError; }
11953
+ });
11954
+ Object.defineProperty(exports, "PasskeyCancelledError", {
11955
+ enumerable: true,
11956
+ get: function () { return chunk3HPMEDYH_cjs.PasskeyCancelledError; }
11957
+ });
11958
+ Object.defineProperty(exports, "PasskeyUnsupportedError", {
11959
+ enumerable: true,
11960
+ get: function () { return chunk3HPMEDYH_cjs.PasskeyUnsupportedError; }
11961
+ });
11962
+ Object.defineProperty(exports, "UserFacingError", {
11963
+ enumerable: true,
11964
+ get: function () { return chunk3HPMEDYH_cjs.UserFacingError; }
12749
11965
  });
12750
11966
  exports.COIN_MAX_SUPPLY = MAX_SUPPLY;
12751
11967
  exports.COIN_MIN_SUPPLY = MIN_SUPPLY;
12752
- exports.ClubService = ClubService;
12753
11968
  exports.CreatorCoinFactoryABI = CreatorCoinFactoryABI;
12754
- exports.CreatorCoinService = CreatorCoinService;
12755
11969
  exports.DROP_MAX_CLAIM_QUANTITY = DROP_MAX_CLAIM_QUANTITY;
12756
11970
  exports.DropCollectionABI = DropCollectionABI;
12757
11971
  exports.DropFactoryABI = DropFactoryABI;
12758
- exports.DropService = DropService;
12759
- exports.ERC1155CollectionService = ERC1155CollectionService;
12760
11972
  exports.FundingTransferNotSentError = FundingTransferNotSentError;
12761
11973
  exports.IPClubCollectionABI = IPClubCollectionABI;
12762
11974
  exports.IPClubFactoryABI = IPClubFactoryABI;
@@ -12769,122 +11981,79 @@ exports.IPNftABI = IPNftABI;
12769
11981
  exports.IPSponsorshipABI = IPSponsorshipABI;
12770
11982
  exports.IPTicketCollectionABI = IPTicketCollectionABI;
12771
11983
  exports.IPTicketCollectionFactoryABI = IPTicketCollectionFactoryABI;
12772
- exports.InvalidPairingPayloadError = InvalidPairingPayloadError;
12773
- exports.InvalidRecoveryKeyError = InvalidRecoveryKeyError;
12774
11984
  exports.MAX_HOLDERS_AT_LAUNCH = MAX_HOLDERS_AT_LAUNCH;
12775
11985
  exports.MAX_TEAM_ALLOCATION_PERCENT = MAX_TEAM_ALLOCATION_PERCENT;
12776
11986
  exports.Medialane1155ABI = Medialane1155ABI;
12777
11987
  exports.MedialaneClient = MedialaneClient;
12778
- exports.MedialaneError = MedialaneError;
12779
11988
  exports.POPCollectionABI = POPCollectionABI;
12780
11989
  exports.POPFactoryABI = POPFactoryABI;
12781
- exports.PopService = PopService;
12782
11990
  exports.SUGGESTED_DEFAULT_PRICE = SUGGESTED_DEFAULT_PRICE;
12783
- exports.SponsoredCallRejectedError = SponsoredCallRejectedError;
12784
- exports.SponsorshipService = SponsorshipService;
12785
11991
  exports.StarknetVenue = StarknetVenue;
12786
- exports.TicketService = TicketService;
12787
11992
  exports.VALIDATED_EKUBO_PARAMS = VALIDATED_EKUBO_PARAMS;
12788
- exports.accountFor = accountFor;
12789
- exports.allowsFallbackFunding = allowsFallbackFunding;
12790
11993
  exports.apiKeyConfirmationTypedData = apiKeyConfirmationTypedData;
12791
11994
  exports.assertTransactionSucceeded = assertTransactionSucceeded;
12792
11995
  exports.build1155CancellationTypedData = build1155CancellationTypedData;
12793
11996
  exports.build1155OrderTypedData = build1155OrderTypedData;
12794
- exports.buildAddOwnerCall = buildAddOwnerCall;
12795
- exports.buildCancelEscapeCall = buildCancelEscapeCall;
12796
11997
  exports.buildCancellationTypedData = buildCancellationTypedData;
12797
- exports.buildCompleteEscapeOwnerCall = buildCompleteEscapeOwnerCall;
12798
11998
  exports.buildCreateCreatorCoinCall = buildCreateCreatorCoinCall;
12799
- exports.buildDeployAccountParams = buildDeployAccountParams;
11999
+ exports.buildDropClaimCalls = buildDropClaimCalls;
12800
12000
  exports.buildFeeCall = buildFeeCall;
12801
12001
  exports.buildFundingTransferCall = buildFundingTransferCall;
12802
12002
  exports.buildLaunchOnEkuboCalls = buildLaunchOnEkuboCalls;
12803
12003
  exports.buildOrderTypedData = buildOrderTypedData;
12804
12004
  exports.buildPopAllowlist = buildPopAllowlist;
12805
- exports.buildRemoveOwnerByGuidCall = buildRemoveOwnerByGuidCall;
12806
- exports.buildRemoveOwnerCall = buildRemoveOwnerCall;
12807
- exports.buildSetFirstGuardianCall = buildSetFirstGuardianCall;
12808
- exports.buildTriggerEscapeOwnerCall = buildTriggerEscapeOwnerCall;
12809
12005
  exports.buybackQuoteRaw = buybackQuoteRaw;
12810
- exports.canRemoveDevice = canRemoveDevice;
12811
- exports.claimSessionWallet = claimSessionWallet;
12006
+ exports.clubCalls = clubCalls;
12812
12007
  exports.coinToRaw = toRaw;
12813
- exports.completeDeployment = completeDeployment;
12814
- exports.computeOwnerGuid = computeOwnerGuid;
12815
12008
  exports.confirmIntentBestEffort = confirmIntentBestEffort;
12816
12009
  exports.createChainProvider = createChainProvider;
12817
- exports.createDeploymentCoordinator = createDeploymentCoordinator;
12818
- exports.createMediaWallet = createMediaWallet;
12819
- exports.createOwnerStore = createOwnerStore;
12820
- exports.createSelfFundConsent = createSelfFundConsent;
12821
- exports.decodeEscapeAndStatus = decodeEscapeAndStatus;
12822
- exports.decodeGuardiansInfo = decodeGuardiansInfo;
12823
12010
  exports.decodePopClaimFragment = decodePopClaimFragment;
12824
- exports.deploySelfFunded = deploySelfFunded;
12825
- exports.deploySponsored = deploySponsored;
12826
12011
  exports.deployedCollectionFromReceipt = deployedCollectionFromReceipt;
12827
- exports.deriveOwnerKeyPair = deriveOwnerKeyPair;
12828
- exports.describeDevices = describeDevices;
12829
- exports.describeGuardianStatus = describeGuardianStatus;
12830
- exports.describeRecoveryAction = describeRecoveryAction;
12831
12012
  exports.dropCalls = dropCalls;
12832
12013
  exports.dropClaimLinks = dropClaimLinks;
12833
12014
  exports.dropClaimedBy = dropClaimedBy;
12834
12015
  exports.dropMintCost = dropMintCost;
12835
12016
  exports.dropMintState = dropMintState;
12017
+ exports.editionCalls = editionCalls;
12836
12018
  exports.encodeByteArray = encodeByteArray;
12837
- exports.encodePairingPayload = encodePairingPayload;
12838
12019
  exports.encodePopClaimFragment = encodePopClaimFragment;
12839
- exports.encodeRecoveryKey = encodeRecoveryKey;
12840
- exports.erc20Balance = erc20Balance;
12841
- exports.estimateSelfFundedFee = estimateSelfFundedFee;
12842
12020
  exports.executeIntent = executeIntent;
12843
12021
  exports.executeIntents = executeIntents;
12844
- exports.executeSponsored = executeSponsored;
12845
12022
  exports.fdvHuman = fdvHuman;
12846
12023
  exports.feeAmount = feeAmount;
12847
12024
  exports.feeBps = feeBps;
12848
12025
  exports.fundWithChainTransfer = fundWithChainTransfer;
12849
12026
  exports.fundingApiFor = fundingApiFor;
12850
12027
  exports.getCreatorCoinGuarantees = getCreatorCoinGuarantees;
12851
- exports.getEscape = getEscape;
12852
- exports.getEscapeSecurityPeriod = getEscapeSecurityPeriod;
12853
- exports.getGuardians = getGuardians;
12854
- exports.getOwners = getOwners;
12855
12028
  exports.getSiwsStorageKey = getSiwsStorageKey;
12856
12029
  exports.getStoredSiwsToken = getStoredSiwsToken;
12857
- exports.isDeployed = isDeployed;
12030
+ exports.isCreatorCoin = isCreatorCoin;
12858
12031
  exports.isSiwsTokenValid = isSiwsTokenValid;
12859
- exports.isValidStarknetAddress = isValidStarknetAddress;
12860
12032
  exports.mintedTokenIdFromReceipt = mintedTokenIdFromReceipt;
12861
12033
  exports.normalizeSiwsSignature = normalizeSiwsSignature;
12862
- exports.normalizeWalletAddress = normalizeWalletAddress;
12863
- exports.parseAccountAddress = parseAccountAddress;
12864
12034
  exports.parseCreatorCoinCreated = parseCreatorCoinCreated;
12865
- exports.parsePairingPayload = parsePairingPayload;
12866
- exports.parseRecoveryKey = parseRecoveryKey;
12867
12035
  exports.popCalls = popCalls;
12868
12036
  exports.popClaimInfo = popClaimInfo;
12869
12037
  exports.popClaimLinks = popClaimLinks;
12870
12038
  exports.popClaimLinksCsv = popClaimLinksCsv;
12871
12039
  exports.popClaimState = popClaimState;
12040
+ exports.popFactoryCalls = popFactoryCalls;
12872
12041
  exports.popHasClaimed = popHasClaimed;
12042
+ exports.populateCall = populateCall;
12873
12043
  exports.priceToEkuboParams = priceToEkuboParams;
12874
12044
  exports.readDrop = readDrop;
12875
12045
  exports.requestSiwsToken = requestSiwsToken;
12876
- exports.selfFundedExecutor = selfFundedExecutor;
12877
12046
  exports.signInWithWallet = signInWithWallet;
12878
- exports.sponsoredExecutor = sponsoredExecutor;
12047
+ exports.sponsorshipCalls = sponsorshipCalls;
12879
12048
  exports.storeSiwsToken = storeSiwsToken;
12880
12049
  exports.syncTransactionBestEffort = syncTransactionBestEffort;
12881
12050
  exports.teamCoinsRaw = teamCoinsRaw;
12051
+ exports.ticketCalls = ticketCalls;
12882
12052
  exports.toDropContractTerms = toContractTerms;
12883
12053
  exports.validateCoinName = validateName;
12884
12054
  exports.validateCoinSupply = validateSupply;
12885
12055
  exports.validateCoinSymbol = validateSymbol;
12886
12056
  exports.validatePrice = validatePrice;
12887
12057
  exports.verifyPopProof = verifyPopProof;
12888
- exports.waitUntilDeployed = waitUntilDeployed;
12889
12058
  //# sourceMappingURL=index.cjs.map
12890
12059
  //# sourceMappingURL=index.cjs.map