@manifoldxyz/dropkit 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -151,11 +151,15 @@ export function mintedLine(result: MintResult): string {
151
151
  | `quantity` | Initial quantity, or controlled quantity with `onQuantityChange`. Defaults to 1. |
152
152
  | `onQuantityChange` | Receives the clamped requested quantity. The parent must update `quantity`. |
153
153
  | `connect` | Optional `{ walletConnectProjectId }` forwarded to the shared connect widget. Defaults to Manifold's project id. |
154
- | `onEvent` | Optional event callback. No telemetry is sent by the package. |
154
+ | `onEvent` | Optional event callback. The package sends no analytics. It does send Manifold's mint record for Manifold claim mints (see [Manifold mint record](#manifold-mint-record)). |
155
155
  | `crossChain` | Manifold claims only. Default on. `false` turns cross-chain minting off; `{ chains: [8453] }` narrows the pay chains. |
156
156
  | `payChainId` | Forces the pay chain. The drop chain means a direct mint. Must be a pay chain. |
157
157
 
158
158
  `MintButton` additionally accepts `className`, `labels`, and `children`.
159
+
160
+ ### Manifold mint record
161
+
162
+ Every Manifold claim mint sends the same mint record the Manifold claim widget sends: once the mint transaction is sent, `POST https://apps.api.manifoldxyz.dev/public/instance/tx?appId=…&instanceId=…&hash=…`. For a Relay mint it records the drop-chain fill hash; for the cart, each line's hash. It carries no wallet address. It is fire and forget: it never delays or fails a mint. `contract` and `tl-stacks` mints send nothing; only Manifold claims are recorded, as in the widget. Sites can't turn it off.
159
163
  A function child receives the full `MintState` and replaces the default button.
160
164
 
161
165
  ```tsx
package/dist/cart.cjs CHANGED
@@ -18,7 +18,8 @@
18
18
 
19
19
 
20
20
 
21
- var _chunkGO4TR3HBcjs = require('./chunk-GO4TR3HB.cjs');
21
+
22
+ var _chunkX4P6BUV4cjs = require('./chunk-X4P6BUV4.cjs');
22
23
 
23
24
  // src/cart/react.ts
24
25
  var _react = require('react');
@@ -34,13 +35,13 @@ var CartError = class extends Error {
34
35
  };
35
36
  function cartReason(e) {
36
37
  if (e instanceof CartError) return { reason: e.reason, message: e.message };
37
- if (_chunkGO4TR3HBcjs.isMintError.call(void 0, e)) return _chunkGO4TR3HBcjs.toReason.call(void 0, e);
38
- return _chunkGO4TR3HBcjs.toReason.call(void 0, e);
38
+ if (_chunkX4P6BUV4cjs.isMintError.call(void 0, e)) return _chunkX4P6BUV4cjs.toReason.call(void 0, e);
39
+ return _chunkX4P6BUV4cjs.toReason.call(void 0, e);
39
40
  }
40
41
 
41
42
  // src/cart/line.ts
42
43
  var _viem = require('viem');
43
- var isUnsupportedReason = (r) => _chunkGO4TR3HBcjs.UNSUPPORTED_REASONS.includes(r);
44
+ var isUnsupportedReason = (r) => _chunkX4P6BUV4cjs.UNSUPPORTED_REASONS.includes(r);
44
45
  function deriveLine(args) {
45
46
  const { drop, walletRead, readError, now, pending, walletConnected } = args;
46
47
  const out = (state, reason = null, message = null) => ({ state, reason, message });
@@ -63,7 +64,7 @@ function lineMaxQuantity(drop, walletRead) {
63
64
  let max = null;
64
65
  if (drop.maxSupply !== null && drop.maxSupply > 0n) {
65
66
  const left = drop.maxSupply - drop.totalMinted;
66
- max = left > 0n ? left < BigInt(_chunkGO4TR3HBcjs.MAX_QUANTITY) ? Number(left) : _chunkGO4TR3HBcjs.MAX_QUANTITY : 0;
67
+ max = left > 0n ? left < BigInt(_chunkX4P6BUV4cjs.MAX_QUANTITY) ? Number(left) : _chunkX4P6BUV4cjs.MAX_QUANTITY : 0;
67
68
  }
68
69
  if (walletRead !== null && walletRead.maxQuantity !== null) {
69
70
  const cap = Math.max(0, Math.floor(walletRead.maxQuantity));
@@ -100,7 +101,7 @@ function sharedReadClient(raw) {
100
101
  const overrides = {
101
102
  getCode: (args) => {
102
103
  const address = args.address.toLowerCase();
103
- if (_chunkGO4TR3HBcjs.findExtension.call(void 0, chainId(), address)) return memo(forever, `code:${address}`, () => raw.getCode(args));
104
+ if (_chunkX4P6BUV4cjs.findExtension.call(void 0, chainId(), address)) return memo(forever, `code:${address}`, () => raw.getCode(args));
104
105
  return raw.getCode(args);
105
106
  },
106
107
  readContract: (args) => {
@@ -185,19 +186,19 @@ function itemKey(config) {
185
186
  function canonicalConfig(config, chainId) {
186
187
  const c = _nullishCoalesce(config, () => ( {}));
187
188
  if (c.type !== "manifold-claim") {
188
- throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", 'The cart takes only Manifold claims (type: "manifold-claim").', { field: "type" });
189
+ throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", 'The cart takes only Manifold claims (type: "manifold-claim").', { field: "type" });
189
190
  }
190
191
  if (c.chainId !== chainId) {
191
- throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", `This cart is on chain ${String(chainId)}; the config is on chain ${String(c.chainId)}.`, { field: "chainId" });
192
+ throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", `This cart is on chain ${String(chainId)}; the config is on chain ${String(c.chainId)}.`, { field: "chainId" });
192
193
  }
193
194
  if (typeof c.creatorContract !== "string" || !_viem.isAddress.call(void 0, c.creatorContract, { strict: false })) {
194
- throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", "creatorContract is not a valid address.", { field: "creatorContract" });
195
+ throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", "creatorContract is not a valid address.", { field: "creatorContract" });
195
196
  }
196
197
  if (typeof c.extension !== "string" || !_viem.isAddress.call(void 0, c.extension, { strict: false })) {
197
- throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", "Cart configs must set extension (the claim extension address).", { field: "extension" });
198
+ throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", "Cart configs must set extension (the claim extension address).", { field: "extension" });
198
199
  }
199
200
  if (typeof c.instanceId !== "string" || !/^\d+$/.test(c.instanceId)) {
200
- throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", "instanceId must be a non-negative integer string.", { field: "instanceId" });
201
+ throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", "instanceId must be a non-negative integer string.", { field: "instanceId" });
201
202
  }
202
203
  return {
203
204
  type: "manifold-claim",
@@ -207,13 +208,13 @@ function canonicalConfig(config, chainId) {
207
208
  extension: _viem.getAddress.call(void 0, c.extension)
208
209
  };
209
210
  }
210
- var clampQuantity = (q) => Math.max(1, Math.min(Math.floor(Number.isFinite(q) ? q : 1), _chunkGO4TR3HBcjs.MAX_QUANTITY));
211
+ var clampQuantity = (q) => Math.max(1, Math.min(Math.floor(Number.isFinite(q) ? q : 1), _chunkX4P6BUV4cjs.MAX_QUANTITY));
211
212
  var EMPTY_VALUE = (chainId) => ({ v: CART_VALUE_VERSION, chainId, items: [], pending: [], results: [] });
212
213
  var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
213
214
  var isHash = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{64}$/.test(v);
214
215
  var isAddr = (v) => typeof v === "string" && _viem.isAddress.call(void 0, v, { strict: false });
215
216
  var isIntStr = (v) => typeof v === "string" && /^\d+$/.test(v);
216
- var isQuantity = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= _chunkGO4TR3HBcjs.MAX_QUANTITY;
217
+ var isQuantity = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= _chunkX4P6BUV4cjs.MAX_QUANTITY;
217
218
  function restoreConfig(v, chainId) {
218
219
  try {
219
220
  return canonicalConfig(v, chainId);
@@ -552,7 +553,7 @@ var CART_TIMING = {
552
553
  merklePerMinute: 10
553
554
  };
554
555
  var nowSec = () => Math.floor(Date.now() / 1e3);
555
- var adapter = _chunkGO4TR3HBcjs.manifoldClaimAdapter;
556
+ var adapter = _chunkX4P6BUV4cjs.manifoldClaimAdapter;
556
557
  var LineSkipped = class extends Error {
557
558
 
558
559
 
@@ -603,11 +604,11 @@ async function prepareLine(env, line, payer) {
603
604
  try {
604
605
  await adapter.simulate(a.ctx, a.attempt, a.plan);
605
606
  } catch (e) {
606
- if (e instanceof _chunkGO4TR3HBcjs.MintError && e.reason === "SIMULATION_REVERTED") throw new LineSkipped("ineligible", "SIMULATION_REVERTED", _chunkGO4TR3HBcjs.friendlyErrorMessage.call(void 0, e));
607
+ if (e instanceof _chunkX4P6BUV4cjs.MintError && e.reason === "SIMULATION_REVERTED") throw new LineSkipped("ineligible", "SIMULATION_REVERTED", _chunkX4P6BUV4cjs.friendlyErrorMessage.call(void 0, e));
607
608
  throw e;
608
609
  }
609
610
  const query = _nullishCoalesce(_optionalChain([adapter, 'access', _27 => _27.holdingsQuery, 'optionalCall', _28 => _28(a.drop)]), () => ( null));
610
- if (!query || !adapter.readHoldings) throw new (0, _chunkGO4TR3HBcjs.MintError)("RPC_ERROR", "The cart cannot count holdings for this item.");
611
+ if (!query || !adapter.readHoldings) throw new (0, _chunkX4P6BUV4cjs.MintError)("RPC_ERROR", "The cart cannot count holdings for this item.");
611
612
  const before = await adapter.readHoldings(a.ctx, query, a.recipient);
612
613
  const unit = a.drop.unitPrice;
613
614
  return {
@@ -635,8 +636,8 @@ async function withRetries(fn, delaysMs, isFinal, signal) {
635
636
  }
636
637
  }
637
638
  }
638
- var sendSwitch = (chainId) => _chunkGO4TR3HBcjs.requestSwitch.call(void 0, chainId);
639
- var sendAddChain = (chainId) => _chunkGO4TR3HBcjs.requestAddChain.call(void 0, chainId);
639
+ var sendSwitch = (chainId) => _chunkX4P6BUV4cjs.requestSwitch.call(void 0, chainId);
640
+ var sendAddChain = (chainId) => _chunkX4P6BUV4cjs.requestAddChain.call(void 0, chainId);
640
641
  var openCalls = /* @__PURE__ */ new Set();
641
642
  var notSentCalls = /* @__PURE__ */ new Set();
642
643
  var markCallOpen = (id) => void openCalls.add(id);
@@ -647,15 +648,15 @@ var wasNotSent = (id) => notSentCalls.has(id);
647
648
  var SEND_METHODS = /* @__PURE__ */ new Set(["eth_sendTransaction", "wallet_sendTransaction"]);
648
649
  async function sendMint(prepared, hooks) {
649
650
  const notSent = (message, cause) => new CartError("REQUEST_NOT_SENT", message, { cause });
650
- const live = _chunkGO4TR3HBcjs.getAccount.call(void 0, );
651
+ const live = _chunkX4P6BUV4cjs.getAccount.call(void 0, );
651
652
  if (!live || live.address.toLowerCase() !== prepared.payer.toLowerCase()) {
652
653
  throw notSent("The connected wallet changed before the transaction was sent.");
653
654
  }
654
655
  let provider;
655
656
  let chain;
656
657
  try {
657
- provider = _chunkGO4TR3HBcjs.getWalletProvider.call(void 0, );
658
- chain = _chunkGO4TR3HBcjs.getChain.call(void 0, prepared.config.chainId);
658
+ provider = _chunkX4P6BUV4cjs.getWalletProvider.call(void 0, );
659
+ chain = _chunkX4P6BUV4cjs.getChain.call(void 0, prepared.config.chainId);
659
660
  } catch (e) {
660
661
  throw notSent("No wallet is connected.", e);
661
662
  }
@@ -673,12 +674,13 @@ async function sendMint(prepared, hooks) {
673
674
  throw e;
674
675
  }
675
676
  hooks.onHash(hash);
677
+ void _chunkX4P6BUV4cjs.recordClaimMint.call(void 0, { instanceId: prepared.config.instanceId, hash });
676
678
  return hash;
677
679
  }
678
680
  var receiptOk = (status) => status === "success" || status === 1 || status === 1n || status === "0x1";
679
681
  function toMintReceipt(receipt, hash, tokenContract, recipient) {
680
682
  const ok = receiptOk(receipt.status);
681
- const parsed = ok ? _chunkGO4TR3HBcjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), { tokenContract, recipient }) : [];
683
+ const parsed = ok ? _chunkX4P6BUV4cjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), { tokenContract, recipient }) : [];
682
684
  const minted = parsed.reduce((n, t) => n + t.amount, 0n);
683
685
  const tokens = parsed.map((t) => ({ contract: t.contract, tokenId: t.tokenId.toString() }));
684
686
  return { status: ok ? "success" : "reverted", hash: _nullishCoalesce(receipt.transactionHash, () => ( hash)), minted, tokens };
@@ -811,7 +813,7 @@ function explorerTx(chainId, hash) {
811
813
  if (!hash) return null;
812
814
  let base;
813
815
  try {
814
- base = _optionalChain([_chunkGO4TR3HBcjs.getChain.call(void 0, chainId), 'access', _34 => _34.blockExplorers, 'optionalAccess', _35 => _35.default, 'access', _36 => _36.url]);
816
+ base = _optionalChain([_chunkX4P6BUV4cjs.getChain.call(void 0, chainId), 'access', _34 => _34.blockExplorers, 'optionalAccess', _35 => _35.default, 'access', _36 => _36.url]);
815
817
  } catch (e11) {
816
818
  return null;
817
819
  }
@@ -845,17 +847,17 @@ var StateContext = _react.createContext.call(void 0, null);
845
847
  var InternalsContext = _react.createContext.call(void 0, null);
846
848
  function useCartInternals() {
847
849
  const v = _react.useContext.call(void 0, InternalsContext);
848
- if (!v) throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", "useCheckout must be used inside <CartProvider>.");
850
+ if (!v) throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", "useCheckout must be used inside <CartProvider>.");
849
851
  return v;
850
852
  }
851
853
  function useCart() {
852
854
  const v = _react.useContext.call(void 0, StateContext);
853
- if (!v) throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", "useCart must be used inside <CartProvider>.");
855
+ if (!v) throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", "useCart must be used inside <CartProvider>.");
854
856
  return v;
855
857
  }
856
858
  var isFinalRead = (e) => {
857
859
  const r = cartReason(e).reason;
858
- return _chunkGO4TR3HBcjs.UNSUPPORTED_REASONS.includes(r) || r === "INVALID_CONFIG";
860
+ return _chunkX4P6BUV4cjs.UNSUPPORTED_REASONS.includes(r) || r === "INVALID_CONFIG";
859
861
  };
860
862
  var emptyValue = (chainId) => ({ v: 6, chainId, items: [], pending: [], results: [] });
861
863
  var LineBook = (_class3 = class {constructor() { _class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this);_class3.prototype.__init15.call(this); }
@@ -908,9 +910,9 @@ var Core = (_class4 = class {constructor() { _class4.prototype.__init16.call(thi
908
910
  return this.lifetime;
909
911
  }
910
912
  }, _class4);
911
- var subscribeAccountChanges = (notify) => _chunkGO4TR3HBcjs.subscribeAccount.call(void 0, () => notify());
913
+ var subscribeAccountChanges = (notify) => _chunkX4P6BUV4cjs.subscribeAccount.call(void 0, () => notify());
912
914
  var accountSnapshot = () => {
913
- const a = _chunkGO4TR3HBcjs.getAccount.call(void 0, );
915
+ const a = _chunkX4P6BUV4cjs.getAccount.call(void 0, );
914
916
  return a ? `${a.address}:${String(a.chainId)}` : "";
915
917
  };
916
918
  function buildLines(value, book, payer, now, version) {
@@ -944,7 +946,7 @@ function CartProvider(props) {
944
946
  _react.useEffect.call(void 0, () => core.sync(value.items, payer), [core, value.items, payer]);
945
947
  _react.useEffect.call(void 0, () => {
946
948
  if (activeKeys.has(storageKey)) {
947
- throw new (0, _chunkGO4TR3HBcjs.MintError)("INVALID_CONFIG", "Only one CartProvider per storageKey. Wrap your app once.", { field: "storageKey" });
949
+ throw new (0, _chunkX4P6BUV4cjs.MintError)("INVALID_CONFIG", "Only one CartProvider per storageKey. Wrap your app once.", { field: "storageKey" });
948
950
  }
949
951
  activeKeys.add(storageKey);
950
952
  core.setRegistered(storageKey);
@@ -963,7 +965,7 @@ function CartProvider(props) {
963
965
  }, []);
964
966
  const rpcKey = _nullishCoalesce(_optionalChain([rpcUrls, 'optionalAccess', _44 => _44[chainId]]), () => ( ""));
965
967
  const readClient = _react.useMemo.call(void 0,
966
- () => _chunkGO4TR3HBcjs.createReadClient.call(void 0, { chainId, ...rpcKey ? { rpcUrls: { [chainId]: rpcKey } } : {}, useBridge: true }),
968
+ () => _chunkX4P6BUV4cjs.createReadClient.call(void 0, { chainId, ...rpcKey ? { rpcUrls: { [chainId]: rpcKey } } : {}, useBridge: true }),
967
969
  [chainId, rpcKey]
968
970
  );
969
971
  const shared = _react.useMemo.call(void 0, () => sharedReadClient(readClient), [readClient]);
@@ -986,14 +988,14 @@ function CartProvider(props) {
986
988
  [shared, chainId, merkleFetch, core]
987
989
  );
988
990
  _react.useEffect.call(void 0, () => {
989
- const loading = _chunkGO4TR3HBcjs.loadConnectWidget.call(void 0, { chainIds: [chainId], ...projectId ? { walletConnectProjectId: projectId } : {} });
991
+ const loading = _chunkX4P6BUV4cjs.loadConnectWidget.call(void 0, { chainIds: [chainId], ...projectId ? { walletConnectProjectId: projectId } : {} });
990
992
  core.setWidgetLoad(loading);
991
993
  loading.catch(() => void 0);
992
994
  }, [chainId, projectId, core]);
993
995
  const connect = _react.useCallback.call(void 0, async () => {
994
996
  try {
995
997
  await core.widgetLoad;
996
- return await _chunkGO4TR3HBcjs.openConnectModal.call(void 0, );
998
+ return await _chunkX4P6BUV4cjs.openConnectModal.call(void 0, );
997
999
  } catch (e13) {
998
1000
  return "dismissed";
999
1001
  }
@@ -1290,11 +1292,11 @@ function useCheckout() {
1290
1292
  };
1291
1293
  try {
1292
1294
  if (!k.store.persistenceOk()) return blocked("PERSISTENCE_UNAVAILABLE", "The cart could not save its state in this tab, so nothing was sent.");
1293
- let account = _chunkGO4TR3HBcjs.getAccount.call(void 0, );
1295
+ let account = _chunkX4P6BUV4cjs.getAccount.call(void 0, );
1294
1296
  if (!account) {
1295
1297
  const outcome = await k.connect();
1296
1298
  if (!live()) return;
1297
- account = _chunkGO4TR3HBcjs.getAccount.call(void 0, );
1299
+ account = _chunkX4P6BUV4cjs.getAccount.call(void 0, );
1298
1300
  if (outcome === "dismissed" || !account) return idle();
1299
1301
  }
1300
1302
  const payer = account.address;
@@ -1561,7 +1563,7 @@ function useCheckout() {
1561
1563
  const out2 = await k.settle(pending.id);
1562
1564
  return applyOutcome(pending.lineKey, pending.id, out2, null);
1563
1565
  }
1564
- if (_chunkGO4TR3HBcjs.isRejection.call(void 0, e)) {
1566
+ if (_chunkX4P6BUV4cjs.isRejection.call(void 0, e)) {
1565
1567
  try {
1566
1568
  k.store.removePending(pending.id);
1567
1569
  } catch (e18) {