@manifoldxyz/dropkit 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/cart.cjs +38 -36
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.js +12 -10
- package/dist/cart.js.map +1 -1
- package/dist/{chunk-MXKJAZDW.js → chunk-VHAAGH7Z.js} +60 -642
- package/dist/chunk-VHAAGH7Z.js.map +1 -0
- package/dist/chunk-W7OBZPCY.js +619 -0
- package/dist/chunk-W7OBZPCY.js.map +1 -0
- package/dist/{chunk-X4P6BUV4.cjs → chunk-XWONUCGA.cjs} +46 -628
- package/dist/chunk-XWONUCGA.cjs.map +1 -0
- package/dist/chunk-YGBIJOKQ.cjs +619 -0
- package/dist/chunk-YGBIJOKQ.cjs.map +1 -0
- package/dist/index.cjs +125 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/dist/status.cjs +570 -0
- package/dist/status.cjs.map +1 -0
- package/dist/status.d.cts +259 -0
- package/dist/status.d.ts +259 -0
- package/dist/status.js +570 -0
- package/dist/status.js.map +1 -0
- package/package.json +11 -1
- package/dist/chunk-MXKJAZDW.js.map +0 -1
- package/dist/chunk-X4P6BUV4.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -373,6 +373,96 @@ Things to know:
|
|
|
373
373
|
- **A mint that cannot be confirmed** is never retried for you. It is listed in `cart.unconfirmed` until the collector dismisses it or adds the item back. Each entry has `wallet` (the wallet that sent it) and `message`, which names that wallet: "We couldn't confirm this. Check wallet 0x1234…abcd. If it didn't go through, add it again."
|
|
374
374
|
- **Any wallet works**, smart accounts included. A wallet that returns a request id instead of a transaction hash (a Safe through WalletConnect, for example) shows "Still confirming", then settles from the collector's holdings: Collected if the mint landed, otherwise Unconfirmed. The cart never resends it.
|
|
375
375
|
|
|
376
|
+
## Drop status
|
|
377
|
+
|
|
378
|
+
`@manifoldxyz/dropkit/status` tells a sale page whether each of many drops is upcoming, live, ended or sold out, how much supply is left, what the current bid is, and shows a countdown that can appear only close to a start or end time. It is read-only: no wallet, no mint. Use it for the strip of status around your mint buttons. Importing only `@manifoldxyz/dropkit` never loads it.
|
|
379
|
+
|
|
380
|
+
Read dates and status from Manifold; never ask the creator to type a date Studio already has.
|
|
381
|
+
|
|
382
|
+
```tsx
|
|
383
|
+
import { DropCountdown, useDropStatus } from '@manifoldxyz/dropkit/status';
|
|
384
|
+
import type { StatusSource } from '@manifoldxyz/dropkit/status';
|
|
385
|
+
|
|
386
|
+
const sources: StatusSource[] = [
|
|
387
|
+
{ type: 'manifold-claim', chainId: 1, creatorContract: '0x0000000000000000000000000000000000000001', instanceId: '1' },
|
|
388
|
+
{ type: 'marketplace-listing', chainId: 1, listingId: '1538' },
|
|
389
|
+
];
|
|
390
|
+
|
|
391
|
+
export function Strip({ rpcUrl }: { rpcUrl: string }) {
|
|
392
|
+
// A new array every render is fine: sources are keyed by content.
|
|
393
|
+
const [edition, auction] = useDropStatus(sources, { rpcUrls: { 1: rpcUrl }, refreshMs: 30_000 });
|
|
394
|
+
return (
|
|
395
|
+
<div>
|
|
396
|
+
<p data-phase={edition?.phase}>{edition?.remaining === null ? 'Open edition' : `${edition?.remaining ?? '…'} left`}</p>
|
|
397
|
+
<p data-phase={auction?.phase}>{auction?.bid ? `Current bid ${auction.bid.amount} wei` : auction?.phase}</p>
|
|
398
|
+
{/* Only inside the last 6 hours before the claim opens. */}
|
|
399
|
+
<DropCountdown to={edition?.startTime ?? null} showWithin="6h" className="countdown" />
|
|
400
|
+
</div>
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Each status is `{ phase, startTime, endTime, durationAfterFirstBid, totalMinted, maxSupply, remaining, price, paymentToken, bid, soldFor, stale, updatedAt, error, clockOffsetMs }`, aligned with the sources you pass:
|
|
406
|
+
|
|
407
|
+
- `phase` is `'upcoming' | 'live' | 'ended' | 'sold-out' | 'unknown'`. Times are unix seconds, supply and amounts are `bigint` in base units, and `maxSupply` / `remaining` are `null` for an open edition. `paymentToken` is `null` for the chain's native currency.
|
|
408
|
+
- `soldFor` is set when the phase is `'sold-out'`: the winning bid for an auction, the price for a fixed-price listing.
|
|
409
|
+
- `bid` is the highest bid of an auction listing. The marketplace API reports no bid count.
|
|
410
|
+
- A listing whose timer starts on the first bid or purchase has `startTime: null`, `endTime: null` and `durationAfterFirstBid` set to the seconds it will then run. Its phase is `'live'`.
|
|
411
|
+
|
|
412
|
+
**Sources.**
|
|
413
|
+
|
|
414
|
+
- `{ type: 'manifold-claim', chainId, creatorContract, instanceId, extensionAddress? }` reads the claim from its extension contract. Every claim of one chain is read with one multicall per refresh. `extensionAddress` pins the extension; without it the claim is looked up on all of Manifold's extensions on that chain, and once found, only on that one.
|
|
415
|
+
- `{ type: 'marketplace-listing', chainId, listingId, marketplace? }` reads a Manifold marketplace listing. All listings are read with one batch request per refresh, plus one request for each listing that is running or has just ended, because the batch answer has no bid and no units sold. At most 3 of those run at once, and a finalized listing is never read again. Mainnet, Optimism, Base, Shape and Sepolia have a default `marketplace` address; on other chains the listing cannot be read.
|
|
416
|
+
|
|
417
|
+
**A failed read never changes the page.** If a read fails, each affected status keeps its last good values with `stale: true` and `error` set, and the next good read clears both. If there has been no good read yet, `phase` is `'unknown'` and every value is `null`. A failed read never becomes `'upcoming'`, so a sale page cannot hide a live drop because an RPC call failed. Show `'unknown'` as a loading or retry state, not as "not open yet".
|
|
418
|
+
|
|
419
|
+
**Polling.** The hook reads on mount, every `refreshMs` (default 30 s) while the tab is visible, when the tab becomes visible again, and about a second after the nearest start or end time passes. Options: `rpcUrls`, `enabled` (false reads nothing), `getClient(chainId)` to bring your own viem client, and `fetch` to replace `fetch`.
|
|
420
|
+
|
|
421
|
+
**Clock.** A device clock that is wrong must not flip a phase. After each read the hook compares device time with server time (the HTTP `Date` header for listings, the block timestamp for claims) and, when they differ by more than 30 s, sets `clockOffsetMs` to the difference. Phases are computed on server time. Give the countdown the same clock with its `now` prop:
|
|
422
|
+
|
|
423
|
+
```tsx
|
|
424
|
+
import { DropCountdown, useDropStatus } from '@manifoldxyz/dropkit/status';
|
|
425
|
+
|
|
426
|
+
export function OpensIn({ rpcUrl }: { rpcUrl: string }) {
|
|
427
|
+
const [claim] = useDropStatus(
|
|
428
|
+
[{ type: 'manifold-claim', chainId: 1, creatorContract: '0x0000000000000000000000000000000000000001', instanceId: '1' }],
|
|
429
|
+
{ rpcUrls: { 1: rpcUrl } },
|
|
430
|
+
);
|
|
431
|
+
const clockOffsetMs = claim?.clockOffsetMs ?? 0;
|
|
432
|
+
return (
|
|
433
|
+
<DropCountdown to={claim?.startTime ?? null} showWithin="6h" hideAfter="1m" now={() => Date.now() + clockOffsetMs}>
|
|
434
|
+
{(c) => (c.visible ? <b data-state={c.state}>{c.state === 'done' ? 'Open now' : `Opens in ${c.text}`}</b> : null)}
|
|
435
|
+
</DropCountdown>
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**`<DropCountdown to showWithin? hideAfter? now? format? className? children? />`** is unstyled.
|
|
441
|
+
|
|
442
|
+
- `to` is unix seconds. `null` renders nothing.
|
|
443
|
+
- `showWithin` (`'6h'`, `'30m'`, `'2d'`, `'90s'`, `'1w'` or seconds) shows it only that long before `to`. Outside the window it renders nothing and does not tick.
|
|
444
|
+
- `hideAfter` (same units) keeps the done state on screen that long after `to`. By default it disappears when `to` passes.
|
|
445
|
+
- The default markup is `<span role="timer" data-state="counting" | "done">2d 03h 04m 05s</span>`. `format` picks the units (`"dhms"`, `"hms"` turns 2 days into 48 hours). A string `children` replaces the text. A function child gets `{ state, visible, secondsLeft, parts: { d, h, m, s }, text }` and replaces the markup entirely.
|
|
446
|
+
- It ticks once a second only while the tab is visible and `to` is inside the window. The server render and the first client render are both empty, so hydration always matches.
|
|
447
|
+
|
|
448
|
+
The logic is plain functions you can call on a server, with no React and no browser globals: `phaseOf(snapshot, nowSeconds)`, `statusOf`, `readSources(sources, deps)`, `parseDuration` and `countdownParts`.
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
import { readSources, statusOf } from '@manifoldxyz/dropkit/status';
|
|
452
|
+
|
|
453
|
+
export async function phases(rpcUrl: string): Promise<string[]> {
|
|
454
|
+
const { outcomes } = await readSources(
|
|
455
|
+
[{ type: 'marketplace-listing', chainId: 1, listingId: '1538' }],
|
|
456
|
+
{ rpcUrls: { 1: rpcUrl } },
|
|
457
|
+
);
|
|
458
|
+
const now = Math.floor(Date.now() / 1000);
|
|
459
|
+
const meta = { stale: false, updatedAt: Date.now(), error: null, clockOffsetMs: 0 };
|
|
460
|
+
return outcomes.map((o) => (o.ok ? statusOf(o.snapshot, now, meta).phase : 'unknown'));
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Out of scope: hiding a drop that is not published yet. The hook reads published state only.
|
|
465
|
+
|
|
376
466
|
## Local verification
|
|
377
467
|
|
|
378
468
|
From the repository root, use Node 24 and pnpm 10.34.5:
|
package/dist/cart.cjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
var _chunkYGBIJOKQcjs = require('./chunk-YGBIJOKQ.cjs');
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
@@ -19,7 +20,8 @@
|
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
var _chunkXWONUCGAcjs = require('./chunk-XWONUCGA.cjs');
|
|
23
25
|
|
|
24
26
|
// src/cart/react.ts
|
|
25
27
|
var _react = require('react');
|
|
@@ -35,13 +37,13 @@ var CartError = class extends Error {
|
|
|
35
37
|
};
|
|
36
38
|
function cartReason(e) {
|
|
37
39
|
if (e instanceof CartError) return { reason: e.reason, message: e.message };
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
40
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) return _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
41
|
+
return _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
// src/cart/line.ts
|
|
43
45
|
var _viem = require('viem');
|
|
44
|
-
var isUnsupportedReason = (r) =>
|
|
46
|
+
var isUnsupportedReason = (r) => _chunkXWONUCGAcjs.UNSUPPORTED_REASONS.includes(r);
|
|
45
47
|
function deriveLine(args) {
|
|
46
48
|
const { drop, walletRead, readError, now, pending, walletConnected } = args;
|
|
47
49
|
const out = (state, reason = null, message = null) => ({ state, reason, message });
|
|
@@ -64,7 +66,7 @@ function lineMaxQuantity(drop, walletRead) {
|
|
|
64
66
|
let max = null;
|
|
65
67
|
if (drop.maxSupply !== null && drop.maxSupply > 0n) {
|
|
66
68
|
const left = drop.maxSupply - drop.totalMinted;
|
|
67
|
-
max = left > 0n ? left < BigInt(
|
|
69
|
+
max = left > 0n ? left < BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY) ? Number(left) : _chunkYGBIJOKQcjs.MAX_QUANTITY : 0;
|
|
68
70
|
}
|
|
69
71
|
if (walletRead !== null && walletRead.maxQuantity !== null) {
|
|
70
72
|
const cap = Math.max(0, Math.floor(walletRead.maxQuantity));
|
|
@@ -101,7 +103,7 @@ function sharedReadClient(raw) {
|
|
|
101
103
|
const overrides = {
|
|
102
104
|
getCode: (args) => {
|
|
103
105
|
const address = args.address.toLowerCase();
|
|
104
|
-
if (
|
|
106
|
+
if (_chunkXWONUCGAcjs.findExtension.call(void 0, chainId(), address)) return memo(forever, `code:${address}`, () => raw.getCode(args));
|
|
105
107
|
return raw.getCode(args);
|
|
106
108
|
},
|
|
107
109
|
readContract: (args) => {
|
|
@@ -186,19 +188,19 @@ function itemKey(config) {
|
|
|
186
188
|
function canonicalConfig(config, chainId) {
|
|
187
189
|
const c = _nullishCoalesce(config, () => ( {}));
|
|
188
190
|
if (c.type !== "manifold-claim") {
|
|
189
|
-
throw new (0,
|
|
191
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", 'The cart takes only Manifold claims (type: "manifold-claim").', { field: "type" });
|
|
190
192
|
}
|
|
191
193
|
if (c.chainId !== chainId) {
|
|
192
|
-
throw new (0,
|
|
194
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `This cart is on chain ${String(chainId)}; the config is on chain ${String(c.chainId)}.`, { field: "chainId" });
|
|
193
195
|
}
|
|
194
196
|
if (typeof c.creatorContract !== "string" || !_viem.isAddress.call(void 0, c.creatorContract, { strict: false })) {
|
|
195
|
-
throw new (0,
|
|
197
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", "creatorContract is not a valid address.", { field: "creatorContract" });
|
|
196
198
|
}
|
|
197
199
|
if (typeof c.extension !== "string" || !_viem.isAddress.call(void 0, c.extension, { strict: false })) {
|
|
198
|
-
throw new (0,
|
|
200
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", "Cart configs must set extension (the claim extension address).", { field: "extension" });
|
|
199
201
|
}
|
|
200
202
|
if (typeof c.instanceId !== "string" || !/^\d+$/.test(c.instanceId)) {
|
|
201
|
-
throw new (0,
|
|
203
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", "instanceId must be a non-negative integer string.", { field: "instanceId" });
|
|
202
204
|
}
|
|
203
205
|
return {
|
|
204
206
|
type: "manifold-claim",
|
|
@@ -208,13 +210,13 @@ function canonicalConfig(config, chainId) {
|
|
|
208
210
|
extension: _viem.getAddress.call(void 0, c.extension)
|
|
209
211
|
};
|
|
210
212
|
}
|
|
211
|
-
var clampQuantity = (q) => Math.max(1, Math.min(Math.floor(Number.isFinite(q) ? q : 1),
|
|
213
|
+
var clampQuantity = (q) => Math.max(1, Math.min(Math.floor(Number.isFinite(q) ? q : 1), _chunkYGBIJOKQcjs.MAX_QUANTITY));
|
|
212
214
|
var EMPTY_VALUE = (chainId) => ({ v: CART_VALUE_VERSION, chainId, items: [], pending: [], results: [] });
|
|
213
215
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
214
216
|
var isHash = (v) => typeof v === "string" && /^0x[0-9a-fA-F]{64}$/.test(v);
|
|
215
217
|
var isAddr = (v) => typeof v === "string" && _viem.isAddress.call(void 0, v, { strict: false });
|
|
216
218
|
var isIntStr = (v) => typeof v === "string" && /^\d+$/.test(v);
|
|
217
|
-
var isQuantity = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v <=
|
|
219
|
+
var isQuantity = (v) => typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= _chunkYGBIJOKQcjs.MAX_QUANTITY;
|
|
218
220
|
function restoreConfig(v, chainId) {
|
|
219
221
|
try {
|
|
220
222
|
return canonicalConfig(v, chainId);
|
|
@@ -553,7 +555,7 @@ var CART_TIMING = {
|
|
|
553
555
|
merklePerMinute: 10
|
|
554
556
|
};
|
|
555
557
|
var nowSec = () => Math.floor(Date.now() / 1e3);
|
|
556
|
-
var adapter =
|
|
558
|
+
var adapter = _chunkXWONUCGAcjs.manifoldClaimAdapter;
|
|
557
559
|
var LineSkipped = class extends Error {
|
|
558
560
|
|
|
559
561
|
|
|
@@ -604,11 +606,11 @@ async function prepareLine(env, line, payer) {
|
|
|
604
606
|
try {
|
|
605
607
|
await adapter.simulate(a.ctx, a.attempt, a.plan);
|
|
606
608
|
} catch (e) {
|
|
607
|
-
if (e instanceof
|
|
609
|
+
if (e instanceof _chunkXWONUCGAcjs.MintError && e.reason === "SIMULATION_REVERTED") throw new LineSkipped("ineligible", "SIMULATION_REVERTED", _chunkXWONUCGAcjs.friendlyErrorMessage.call(void 0, e));
|
|
608
610
|
throw e;
|
|
609
611
|
}
|
|
610
612
|
const query = _nullishCoalesce(_optionalChain([adapter, 'access', _27 => _27.holdingsQuery, 'optionalCall', _28 => _28(a.drop)]), () => ( null));
|
|
611
|
-
if (!query || !adapter.readHoldings) throw new (0,
|
|
613
|
+
if (!query || !adapter.readHoldings) throw new (0, _chunkXWONUCGAcjs.MintError)("RPC_ERROR", "The cart cannot count holdings for this item.");
|
|
612
614
|
const before = await adapter.readHoldings(a.ctx, query, a.recipient);
|
|
613
615
|
const unit = a.drop.unitPrice;
|
|
614
616
|
return {
|
|
@@ -636,8 +638,8 @@ async function withRetries(fn, delaysMs, isFinal, signal) {
|
|
|
636
638
|
}
|
|
637
639
|
}
|
|
638
640
|
}
|
|
639
|
-
var sendSwitch = (chainId) =>
|
|
640
|
-
var sendAddChain = (chainId) =>
|
|
641
|
+
var sendSwitch = (chainId) => _chunkYGBIJOKQcjs.requestSwitch.call(void 0, chainId);
|
|
642
|
+
var sendAddChain = (chainId) => _chunkYGBIJOKQcjs.requestAddChain.call(void 0, chainId);
|
|
641
643
|
var openCalls = /* @__PURE__ */ new Set();
|
|
642
644
|
var notSentCalls = /* @__PURE__ */ new Set();
|
|
643
645
|
var markCallOpen = (id) => void openCalls.add(id);
|
|
@@ -648,15 +650,15 @@ var wasNotSent = (id) => notSentCalls.has(id);
|
|
|
648
650
|
var SEND_METHODS = /* @__PURE__ */ new Set(["eth_sendTransaction", "wallet_sendTransaction"]);
|
|
649
651
|
async function sendMint(prepared, hooks) {
|
|
650
652
|
const notSent = (message, cause) => new CartError("REQUEST_NOT_SENT", message, { cause });
|
|
651
|
-
const live =
|
|
653
|
+
const live = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
652
654
|
if (!live || live.address.toLowerCase() !== prepared.payer.toLowerCase()) {
|
|
653
655
|
throw notSent("The connected wallet changed before the transaction was sent.");
|
|
654
656
|
}
|
|
655
657
|
let provider;
|
|
656
658
|
let chain;
|
|
657
659
|
try {
|
|
658
|
-
provider =
|
|
659
|
-
chain =
|
|
660
|
+
provider = _chunkYGBIJOKQcjs.getWalletProvider.call(void 0, );
|
|
661
|
+
chain = _chunkXWONUCGAcjs.getChain.call(void 0, prepared.config.chainId);
|
|
660
662
|
} catch (e) {
|
|
661
663
|
throw notSent("No wallet is connected.", e);
|
|
662
664
|
}
|
|
@@ -674,13 +676,13 @@ async function sendMint(prepared, hooks) {
|
|
|
674
676
|
throw e;
|
|
675
677
|
}
|
|
676
678
|
hooks.onHash(hash);
|
|
677
|
-
void
|
|
679
|
+
void _chunkYGBIJOKQcjs.recordClaimMint.call(void 0, { instanceId: prepared.config.instanceId, hash });
|
|
678
680
|
return hash;
|
|
679
681
|
}
|
|
680
682
|
var receiptOk = (status) => status === "success" || status === 1 || status === 1n || status === "0x1";
|
|
681
683
|
function toMintReceipt(receipt, hash, tokenContract, recipient) {
|
|
682
684
|
const ok = receiptOk(receipt.status);
|
|
683
|
-
const parsed = ok ?
|
|
685
|
+
const parsed = ok ? _chunkYGBIJOKQcjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), { tokenContract, recipient }) : [];
|
|
684
686
|
const minted = parsed.reduce((n, t) => n + t.amount, 0n);
|
|
685
687
|
const tokens = parsed.map((t) => ({ contract: t.contract, tokenId: t.tokenId.toString() }));
|
|
686
688
|
return { status: ok ? "success" : "reverted", hash: _nullishCoalesce(receipt.transactionHash, () => ( hash)), minted, tokens };
|
|
@@ -813,7 +815,7 @@ function explorerTx(chainId, hash) {
|
|
|
813
815
|
if (!hash) return null;
|
|
814
816
|
let base;
|
|
815
817
|
try {
|
|
816
|
-
base = _optionalChain([
|
|
818
|
+
base = _optionalChain([_chunkXWONUCGAcjs.getChain.call(void 0, chainId), 'access', _34 => _34.blockExplorers, 'optionalAccess', _35 => _35.default, 'access', _36 => _36.url]);
|
|
817
819
|
} catch (e11) {
|
|
818
820
|
return null;
|
|
819
821
|
}
|
|
@@ -847,17 +849,17 @@ var StateContext = _react.createContext.call(void 0, null);
|
|
|
847
849
|
var InternalsContext = _react.createContext.call(void 0, null);
|
|
848
850
|
function useCartInternals() {
|
|
849
851
|
const v = _react.useContext.call(void 0, InternalsContext);
|
|
850
|
-
if (!v) throw new (0,
|
|
852
|
+
if (!v) throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", "useCheckout must be used inside <CartProvider>.");
|
|
851
853
|
return v;
|
|
852
854
|
}
|
|
853
855
|
function useCart() {
|
|
854
856
|
const v = _react.useContext.call(void 0, StateContext);
|
|
855
|
-
if (!v) throw new (0,
|
|
857
|
+
if (!v) throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", "useCart must be used inside <CartProvider>.");
|
|
856
858
|
return v;
|
|
857
859
|
}
|
|
858
860
|
var isFinalRead = (e) => {
|
|
859
861
|
const r = cartReason(e).reason;
|
|
860
|
-
return
|
|
862
|
+
return _chunkXWONUCGAcjs.UNSUPPORTED_REASONS.includes(r) || r === "INVALID_CONFIG";
|
|
861
863
|
};
|
|
862
864
|
var emptyValue = (chainId) => ({ v: 6, chainId, items: [], pending: [], results: [] });
|
|
863
865
|
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); }
|
|
@@ -910,9 +912,9 @@ var Core = (_class4 = class {constructor() { _class4.prototype.__init16.call(thi
|
|
|
910
912
|
return this.lifetime;
|
|
911
913
|
}
|
|
912
914
|
}, _class4);
|
|
913
|
-
var subscribeAccountChanges = (notify) =>
|
|
915
|
+
var subscribeAccountChanges = (notify) => _chunkYGBIJOKQcjs.subscribeAccount.call(void 0, () => notify());
|
|
914
916
|
var accountSnapshot = () => {
|
|
915
|
-
const a =
|
|
917
|
+
const a = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
916
918
|
return a ? `${a.address}:${String(a.chainId)}` : "";
|
|
917
919
|
};
|
|
918
920
|
function buildLines(value, book, payer, now, version) {
|
|
@@ -946,7 +948,7 @@ function CartProvider(props) {
|
|
|
946
948
|
_react.useEffect.call(void 0, () => core.sync(value.items, payer), [core, value.items, payer]);
|
|
947
949
|
_react.useEffect.call(void 0, () => {
|
|
948
950
|
if (activeKeys.has(storageKey)) {
|
|
949
|
-
throw new (0,
|
|
951
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", "Only one CartProvider per storageKey. Wrap your app once.", { field: "storageKey" });
|
|
950
952
|
}
|
|
951
953
|
activeKeys.add(storageKey);
|
|
952
954
|
core.setRegistered(storageKey);
|
|
@@ -965,7 +967,7 @@ function CartProvider(props) {
|
|
|
965
967
|
}, []);
|
|
966
968
|
const rpcKey = _nullishCoalesce(_optionalChain([rpcUrls, 'optionalAccess', _44 => _44[chainId]]), () => ( ""));
|
|
967
969
|
const readClient = _react.useMemo.call(void 0,
|
|
968
|
-
() =>
|
|
970
|
+
() => _chunkXWONUCGAcjs.createReadClient.call(void 0, { chainId, ...rpcKey ? { rpcUrls: { [chainId]: rpcKey } } : {}, useBridge: true }),
|
|
969
971
|
[chainId, rpcKey]
|
|
970
972
|
);
|
|
971
973
|
const shared = _react.useMemo.call(void 0, () => sharedReadClient(readClient), [readClient]);
|
|
@@ -988,14 +990,14 @@ function CartProvider(props) {
|
|
|
988
990
|
[shared, chainId, merkleFetch, core]
|
|
989
991
|
);
|
|
990
992
|
_react.useEffect.call(void 0, () => {
|
|
991
|
-
const loading =
|
|
993
|
+
const loading = _chunkYGBIJOKQcjs.loadConnectWidget.call(void 0, { chainIds: [chainId], ...projectId ? { walletConnectProjectId: projectId } : {} });
|
|
992
994
|
core.setWidgetLoad(loading);
|
|
993
995
|
loading.catch(() => void 0);
|
|
994
996
|
}, [chainId, projectId, core]);
|
|
995
997
|
const connect = _react.useCallback.call(void 0, async () => {
|
|
996
998
|
try {
|
|
997
999
|
await core.widgetLoad;
|
|
998
|
-
return await
|
|
1000
|
+
return await _chunkYGBIJOKQcjs.openConnectModal.call(void 0, );
|
|
999
1001
|
} catch (e13) {
|
|
1000
1002
|
return "dismissed";
|
|
1001
1003
|
}
|
|
@@ -1292,11 +1294,11 @@ function useCheckout() {
|
|
|
1292
1294
|
};
|
|
1293
1295
|
try {
|
|
1294
1296
|
if (!k.store.persistenceOk()) return blocked("PERSISTENCE_UNAVAILABLE", "The cart could not save its state in this tab, so nothing was sent.");
|
|
1295
|
-
let account =
|
|
1297
|
+
let account = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
1296
1298
|
if (!account) {
|
|
1297
1299
|
const outcome = await k.connect();
|
|
1298
1300
|
if (!live()) return;
|
|
1299
|
-
account =
|
|
1301
|
+
account = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
1300
1302
|
if (outcome === "dismissed" || !account) return idle();
|
|
1301
1303
|
}
|
|
1302
1304
|
const payer = account.address;
|
|
@@ -1563,7 +1565,7 @@ function useCheckout() {
|
|
|
1563
1565
|
const out2 = await k.settle(pending.id);
|
|
1564
1566
|
return applyOutcome(pending.lineKey, pending.id, out2, null);
|
|
1565
1567
|
}
|
|
1566
|
-
if (
|
|
1568
|
+
if (_chunkXWONUCGAcjs.isRejection.call(void 0, e)) {
|
|
1567
1569
|
try {
|
|
1568
1570
|
k.store.removePending(pending.id);
|
|
1569
1571
|
} catch (e18) {
|