@manifoldxyz/dropkit 0.3.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 +51 -4
- package/dist/cart.cjs +37 -35
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.d.cts +1 -1
- package/dist/cart.d.ts +1 -1
- package/dist/cart.js +3 -1
- package/dist/cart.js.map +1 -1
- package/dist/{chunk-3PA74M2L.js → chunk-MXKJAZDW.js} +50 -7
- package/dist/chunk-MXKJAZDW.js.map +1 -0
- package/dist/{chunk-OO6QQT3M.cjs → chunk-X4P6BUV4.cjs} +73 -30
- package/dist/chunk-X4P6BUV4.cjs.map +1 -0
- package/dist/index.cjs +905 -235
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +803 -133
- package/dist/index.js.map +1 -1
- package/dist/{types-CFLoS6p4.d.cts → types-BjKGb6c7.d.cts} +23 -7
- package/dist/{types-CFLoS6p4.d.ts → types-BjKGb6c7.d.ts} +23 -7
- package/package.json +1 -1
- package/dist/chunk-3PA74M2L.js.map +0 -1
- package/dist/chunk-OO6QQT3M.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -97,6 +97,48 @@ function erc20ContractConfig(chainId: number, address: Address, paymentToken: Ad
|
|
|
97
97
|
The example charges 1,000,000 token base units per mint. The deployed contract must spend that token from the payer.
|
|
98
98
|
The adapter reads allowance and creates an approval leg when required. Manifold claims discover their payment token on-chain instead.
|
|
99
99
|
|
|
100
|
+
## Transient Labs drops
|
|
101
|
+
|
|
102
|
+
`tl-stacks` sells a drop that lives on Transient Labs (TL) Stacks 721 (v2.3.0 or v2.3.1) from your own page. Write three values; everything else is read from the chain.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { MintButton, type MintResult, type TlStacksConfig } from '@manifoldxyz/dropkit';
|
|
106
|
+
|
|
107
|
+
const boneMarket: TlStacksConfig = {
|
|
108
|
+
type: 'tl-stacks',
|
|
109
|
+
chainId: 1,
|
|
110
|
+
stacks: '0x384092784cfaa91efaa77870c04d958e20840242',
|
|
111
|
+
nftContract: '0x8da32357980b32d13f91c607ac52712d96f5e656',
|
|
112
|
+
// Only a presale needs this. See "Where allowlistUrl comes from".
|
|
113
|
+
allowlistUrl: 'https://example.com/stacks/drop-id/allowlist',
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export function Mint({ rpcUrl }: { rpcUrl: string }) {
|
|
117
|
+
return <MintButton config={boneMarket} rpcUrls={{ 1: rpcUrl }} />;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** "Minted 1 of 5. The rest was refunded." when the sale minted fewer than asked. */
|
|
121
|
+
export function mintedLine(result: MintResult): string {
|
|
122
|
+
const minted = result.tokens.length;
|
|
123
|
+
return minted < result.requested ? `Minted ${minted} of ${result.requested}. The rest was refunded.` : `Minted ${minted}.`;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- `stacks` is TL's sale contract. It is `0x384092784cfaa91efaa77870c04d958e20840242` on Ethereum, Base, Arbitrum, Shape, Sepolia and Base Sepolia. It has no default: a TL redeploy must be a config change.
|
|
128
|
+
- `nftContract` is the creator's TL contract (ERC721TL, ERC7160TL or ERC7160TLEditions). TL keeps one drop per NFT contract.
|
|
129
|
+
- The button shows the price for the current phase, TL's fee, supply left, the phase times and the per-wallet limit, all read from the chain. It refreshes by itself when the presale ends, so the price changes from presale to public with no reload.
|
|
130
|
+
- `rpcUrls`: the Manifold read bridge only serves Manifold contracts. Pass your own domain-restricted RPC key for the drop's chain. Without it, reads use the chain's public RPC.
|
|
131
|
+
|
|
132
|
+
**Where `allowlistUrl` comes from.** TL publishes an allowlist file for every presale. Its URL is the `allowlistUrl` field in the drop's page data on transient.xyz. It is an OpenZeppelin merkle tree dump (`format: "standard-v1"`, leaves `[keccak256(abi.encode(wallet)), allowance]`). A site can also host a copy in the same format. The button loads it once per page, only in the presale and only after a wallet connects, checks that its root equals the drop's on-chain `presaleMerkleRoot`, and builds the wallet's proof in the browser. Nothing is asked of the collector or the creator. A presale with no `allowlistUrl`, an unreachable file or a root that does not match fails with `ALLOWLIST_UNAVAILABLE`; the button never sends a presale mint it cannot prove. The public sale does not use the file. A page left open while TL changes the allowlist needs a reload.
|
|
133
|
+
|
|
134
|
+
**Limits (v1).** ERC-721 drops priced in the chain's native token only. No ERC-1155, ERC-20 prices, ERC-7160 version picker, Relay cross-chain payment or cart: a `tl-stacks` config in the cart is rejected with `INVALID_CONFIG`. Other Stacks versions are `unsupported` with `INVALID_CONFIG`. A chain with no drop for the NFT contract is `unsupported` with `DROP_NOT_FOUND`.
|
|
135
|
+
|
|
136
|
+
**Fee.** For `tl-stacks`, `DropInfo.unitFee` is TL's protocol fee, not a Manifold fee. Label it "TL fee" in a custom UI. The collector pays `quantity × (unitPrice + unitFee)`.
|
|
137
|
+
|
|
138
|
+
**Partial mints.** TL mints fewer tokens than asked when the wallet limit or the supply left is lower, and refunds the rest in the same transaction. `MintResult.requested` is the quantity asked for and `tokens.length` is what was minted, so a site can show "Minted 1 of 5. The rest was refunded." as above. For Manifold claims and contract drops `requested` equals the quantity, so their results read as before. A refund to a wallet that rejects a 100k-gas ETH transfer, such as some smart wallets, arrives as WETH instead of ETH.
|
|
139
|
+
|
|
140
|
+
**Price changes.** The amount sent is the last drop read before the click. If the price or fee went up since, the simulation fails and the next refresh shows the new amount. If it went down, TL refunds the difference.
|
|
141
|
+
|
|
100
142
|
## React API
|
|
101
143
|
|
|
102
144
|
`useMint(options)` and `MintButton` accept:
|
|
@@ -109,11 +151,15 @@ The adapter reads allowance and creates an approval leg when required. Manifold
|
|
|
109
151
|
| `quantity` | Initial quantity, or controlled quantity with `onQuantityChange`. Defaults to 1. |
|
|
110
152
|
| `onQuantityChange` | Receives the clamped requested quantity. The parent must update `quantity`. |
|
|
111
153
|
| `connect` | Optional `{ walletConnectProjectId }` forwarded to the shared connect widget. Defaults to Manifold's project id. |
|
|
112
|
-
| `onEvent` | Optional event callback.
|
|
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)). |
|
|
113
155
|
| `crossChain` | Manifold claims only. Default on. `false` turns cross-chain minting off; `{ chains: [8453] }` narrows the pay chains. |
|
|
114
156
|
| `payChainId` | Forces the pay chain. The drop chain means a direct mint. Must be a pay chain. |
|
|
115
157
|
|
|
116
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.
|
|
117
163
|
A function child receives the full `MintState` and replaces the default button.
|
|
118
164
|
|
|
119
165
|
```tsx
|
|
@@ -148,7 +194,7 @@ export function CustomMint({ config }: { config: MintConfig }) {
|
|
|
148
194
|
| `total` | `{ native: Money, erc20: Money \| null }`, or null before the drop loads. Includes the Manifold fee. |
|
|
149
195
|
| `mint` | Stable callback. Connects, submits an attempt, or resets a terminal state, depending on `state`. |
|
|
150
196
|
| `refresh` | Stable callback returning `Promise<void>`. Re-reads drop data. Queues refreshes during an attempt. |
|
|
151
|
-
| `result` | `{ txHash, explorerUrl, tokens }` after success, otherwise null. Token IDs and amounts are bigint. |
|
|
197
|
+
| `result` | `{ txHash, explorerUrl, tokens, requested }` after success, otherwise null. Token IDs and amounts are bigint. `requested` is the quantity asked for. |
|
|
152
198
|
| `canAct` | Whether a click can act. False during an attempt, including its pre-prompt planning phase. |
|
|
153
199
|
| `route` | `{ kind: 'direct', chainId }` or `{ kind: 'relay', originChainId, amountIn, relayFee, originGas, quotedAt }`. Null before the wallet read. |
|
|
154
200
|
| `crossChain` | Inputs for `PayWithPicker`. Null when Relay cannot mint this drop for this wallet. |
|
|
@@ -197,6 +243,7 @@ ERC20 totals include the token price and any native fee. Gas is checked separate
|
|
|
197
243
|
| `UNKNOWN_EXTENSION` | `unsupported` | Extension is not supported on this chain. |
|
|
198
244
|
| `AMBIGUOUS_EXTENSION` | `unsupported` | Discovery found multiple claims. Supply `extension`. |
|
|
199
245
|
| `CLAIM_NOT_FOUND` | `unsupported` | No supported extension contains this claim. |
|
|
246
|
+
| `DROP_NOT_FOUND` | `unsupported` | `tl-stacks` only: Stacks has no drop configured for this NFT contract. |
|
|
200
247
|
| `SIGNATURE_CLAIM` | `unsupported` | Signature or redemption-code minting is not supported. |
|
|
201
248
|
| `INVALID_CONFIG` | `unsupported` | Invalid field, ABI, function, placeholder, or chain. Read `message`. |
|
|
202
249
|
| `CONNECT_WIDGET_TOO_OLD` | `unsupported` | Host widget lacks the required modal API. |
|
|
@@ -334,13 +381,13 @@ From the repository root, use Node 24 and pnpm 10.34.5:
|
|
|
334
381
|
pnpm install --frozen-lockfile
|
|
335
382
|
cd packages/react/dropkit
|
|
336
383
|
pnpm test # fast unit and component tests, no network
|
|
337
|
-
pnpm test:chain # adapters against
|
|
384
|
+
pnpm test:chain # adapters against local Sepolia and Ethereum mainnet forks
|
|
338
385
|
pnpm run typecheck
|
|
339
386
|
pnpm run lint
|
|
340
387
|
pnpm run build
|
|
341
388
|
pnpm verify:package # packed tarball in clean React 18 and 19 consumers
|
|
342
389
|
```
|
|
343
390
|
|
|
344
|
-
`test:chain` requires `anvil` on `PATH` and `
|
|
391
|
+
`test:chain` requires `anvil` on `PATH`, `SEPOLIA_RPC_URL` and `MAINNET_RPC_URL`. The Sepolia tests fork block 11838500. The Transient Labs test forks Ethereum mainnet at blocks 26234702 and 26235901, so `MAINNET_RPC_URL` must be an archive endpoint. It fails rather than skips when any is missing.
|
|
345
392
|
`verify:package` needs npm registry access. It type-checks every TypeScript example in this README.
|
|
346
393
|
The repository's pnpm policy enforces a seven-day release age, except for `@manifoldxyz/*` packages.
|
package/dist/cart.cjs
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
|
|
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 (
|
|
38
|
-
return
|
|
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) =>
|
|
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(
|
|
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 (
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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),
|
|
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 <=
|
|
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 =
|
|
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
|
|
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,
|
|
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) =>
|
|
639
|
-
var sendAddChain = (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 =
|
|
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 =
|
|
658
|
-
chain =
|
|
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 ?
|
|
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([
|
|
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,
|
|
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,
|
|
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
|
|
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) =>
|
|
913
|
+
var subscribeAccountChanges = (notify) => _chunkX4P6BUV4cjs.subscribeAccount.call(void 0, () => notify());
|
|
912
914
|
var accountSnapshot = () => {
|
|
913
|
-
const a =
|
|
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,
|
|
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
|
-
() =>
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 (
|
|
1566
|
+
if (_chunkX4P6BUV4cjs.isRejection.call(void 0, e)) {
|
|
1565
1567
|
try {
|
|
1566
1568
|
k.store.removePending(pending.id);
|
|
1567
1569
|
} catch (e18) {
|