@manifoldxyz/dropkit 0.4.0 → 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 +95 -1
- package/dist/cart.cjs +39 -35
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.js +13 -9
- package/dist/cart.js.map +1 -1
- package/dist/{chunk-SUJQB3SL.js → chunk-VHAAGH7Z.js} +60 -605
- 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-GO4TR3HB.cjs → chunk-XWONUCGA.cjs} +46 -591
- 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 +184 -139
- 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 +62 -17
- 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-GO4TR3HB.cjs.map +0 -1
- package/dist/chunk-SUJQB3SL.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
var _chunkYGBIJOKQcjs = require('./chunk-YGBIJOKQ.cjs');
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
|
|
@@ -27,7 +28,9 @@
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _chunkXWONUCGAcjs = require('./chunk-XWONUCGA.cjs');
|
|
31
34
|
|
|
32
35
|
// src/react/useMint.ts
|
|
33
36
|
var _react = require('react');
|
|
@@ -70,7 +73,7 @@ function revertReason(errorData) {
|
|
|
70
73
|
function parseQuote(body, originChainId) {
|
|
71
74
|
const b = obj(body);
|
|
72
75
|
const steps = Array.isArray(b.steps) ? b.steps.map(obj) : [];
|
|
73
|
-
const unknownStep = () => new (0,
|
|
76
|
+
const unknownStep = () => new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Relay returned a route this button cannot execute.");
|
|
74
77
|
if (steps.length !== 1 || steps[0].kind !== "transaction") throw unknownStep();
|
|
75
78
|
const step = steps[0];
|
|
76
79
|
const rawItems = Array.isArray(step.items) ? step.items.map(obj) : [];
|
|
@@ -163,21 +166,21 @@ async function requestQuote(a) {
|
|
|
163
166
|
body: JSON.stringify(body)
|
|
164
167
|
}, RELAY_TIMEOUTS.quoteMs);
|
|
165
168
|
} catch (e) {
|
|
166
|
-
throw new (0,
|
|
169
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Could not reach Relay for a cross-chain quote.", { cause: e });
|
|
167
170
|
}
|
|
168
171
|
const json = res.json;
|
|
169
172
|
if (res.ok) return parseQuote(json, a.originChainId);
|
|
170
173
|
const j = obj(json);
|
|
171
174
|
if (j.errorCode === "DESTINATION_TX_FAILED") {
|
|
172
175
|
const reason = revertReason(j.errorData);
|
|
173
|
-
throw new (0,
|
|
176
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", reason || "The mint would fail on the drop network.", { cause: json, domain: "relay" });
|
|
174
177
|
}
|
|
175
178
|
if (res.status === 401 || j.errorCode === "UNAUTHORIZED_QUOTE") {
|
|
176
179
|
console.warn("dropkit: Relay rejected the quote (401 UNAUTHORIZED_QUOTE). Relay gates quotes that carry a referrer or need an API key.");
|
|
177
|
-
throw new (0,
|
|
180
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Relay refused the cross-chain quote.", { cause: json });
|
|
178
181
|
}
|
|
179
|
-
if (res.status === 429) throw new (0,
|
|
180
|
-
throw new (0,
|
|
182
|
+
if (res.status === 429) throw new (0, _chunkXWONUCGAcjs.MintError)("RATE_LIMITED", "Relay is rate limiting quotes. Try again in a moment.", { cause: json });
|
|
183
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", `Relay could not quote this mint (${String(res.status)}).`, { cause: json });
|
|
181
184
|
}
|
|
182
185
|
function getQuote(a) {
|
|
183
186
|
const k = cacheKey(a);
|
|
@@ -336,7 +339,7 @@ var stacksAbi = [
|
|
|
336
339
|
var HASH = /^0x[0-9a-fA-F]{64}$/;
|
|
337
340
|
var UINT = /^\d+$/;
|
|
338
341
|
var MAX_UINT256 = 2n ** 256n - 1n;
|
|
339
|
-
var unavailable = (message, cause) => new (0,
|
|
342
|
+
var unavailable = (message, cause) => new (0, _chunkXWONUCGAcjs.MintError)("ALLOWLIST_UNAVAILABLE", message, cause === void 0 ? void 0 : { cause });
|
|
340
343
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
341
344
|
var hashWallet = (wallet) => _viem.keccak256.call(void 0, _viem.encodeAbiParameters.call(void 0, [{ type: "address" }], [_viem.getAddress.call(void 0, wallet)]));
|
|
342
345
|
var leafOf = (hashedWallet, allowance) => _viem.keccak256.call(void 0, _viem.concatHex.call(void 0, [_viem.keccak256.call(void 0, _viem.encodeAbiParameters.call(void 0, [{ type: "bytes32" }, { type: "uint256" }], [hashedWallet, allowance]))]));
|
|
@@ -445,14 +448,14 @@ async function fetchAndParse(fetchFn, url, signal) {
|
|
|
445
448
|
} catch (cause) {
|
|
446
449
|
throw unavailable("Could not reach the allowlist file.", cause);
|
|
447
450
|
}
|
|
448
|
-
if (res.status === 429) throw new (0,
|
|
451
|
+
if (res.status === 429) throw new (0, _chunkXWONUCGAcjs.MintError)("RATE_LIMITED", "The allowlist host is rate limiting requests. Try again shortly.");
|
|
449
452
|
if (!res.ok) throw unavailable(`The allowlist file is not available (HTTP ${res.status}).`);
|
|
450
453
|
let body;
|
|
451
454
|
try {
|
|
452
455
|
const text = await readCapped(res);
|
|
453
456
|
body = JSON.parse(text);
|
|
454
457
|
} catch (cause) {
|
|
455
|
-
if (cause instanceof
|
|
458
|
+
if (cause instanceof _chunkXWONUCGAcjs.MintError) throw cause;
|
|
456
459
|
throw unavailable("The allowlist file could not be read.", cause);
|
|
457
460
|
}
|
|
458
461
|
return parseAllowlist(body);
|
|
@@ -463,7 +466,7 @@ async function download(fetchFn, url, signal) {
|
|
|
463
466
|
const stopped = new Promise((_, reject) => {
|
|
464
467
|
onAbort = () => {
|
|
465
468
|
const reason = controller.signal.reason;
|
|
466
|
-
reject(reason instanceof
|
|
469
|
+
reject(reason instanceof _chunkXWONUCGAcjs.MintError ? reason : unavailable("The allowlist request was cancelled.", reason));
|
|
467
470
|
};
|
|
468
471
|
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
469
472
|
});
|
|
@@ -510,7 +513,7 @@ var FALLBACK_GAS_BASE = 150000n;
|
|
|
510
513
|
var FALLBACK_GAS_PER_TOKEN = 150000n;
|
|
511
514
|
var details = /* @__PURE__ */ new WeakMap();
|
|
512
515
|
function bad(field, message) {
|
|
513
|
-
throw new (0,
|
|
516
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} ${message}`, { field });
|
|
514
517
|
}
|
|
515
518
|
function validateTlStacksConfig(config) {
|
|
516
519
|
if (!Number.isInteger(config.chainId) || config.chainId <= 0) bad("chainId", "must be a positive integer");
|
|
@@ -544,8 +547,8 @@ function io(ctx, start) {
|
|
|
544
547
|
}
|
|
545
548
|
var shortMessage = (e) => e instanceof _viem.BaseError ? e.shortMessage : e instanceof Error ? e.message : String(e);
|
|
546
549
|
function rpcError(e) {
|
|
547
|
-
if (
|
|
548
|
-
throw new (0,
|
|
550
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e) || isAbortError(e)) throw e;
|
|
551
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("RPC_ERROR", `RPC request failed: ${shortMessage(e)}`, { cause: e });
|
|
549
552
|
}
|
|
550
553
|
async function readStacks(ctx, config, functionName, args = []) {
|
|
551
554
|
try {
|
|
@@ -554,9 +557,9 @@ async function readStacks(ctx, config, functionName, args = []) {
|
|
|
554
557
|
() => ctx.client.readContract({ address: _viem.getAddress.call(void 0, config.stacks), abi: stacksAbi, functionName, args })
|
|
555
558
|
);
|
|
556
559
|
} catch (e) {
|
|
557
|
-
if (
|
|
560
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e) || isAbortError(e)) throw e;
|
|
558
561
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.ContractFunctionRevertedError || x instanceof _viem.ContractFunctionZeroDataError)) {
|
|
559
|
-
throw new (0,
|
|
562
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `stacks ${functionName}() reverted or returned no data. Is ${config.stacks} a TL Stacks 721 contract on chain ${config.chainId}?`, {
|
|
560
563
|
field: "stacks",
|
|
561
564
|
cause: e
|
|
562
565
|
});
|
|
@@ -596,9 +599,13 @@ function nativeMeta(ctx) {
|
|
|
596
599
|
return { decimals: _nullishCoalesce(_optionalChain([n, 'optionalAccess', _28 => _28.decimals]), () => ( 18)), symbol: _nullishCoalesce(_optionalChain([n, 'optionalAccess', _29 => _29.symbol]), () => ( "ETH")) };
|
|
597
600
|
}
|
|
598
601
|
function seconds(v, field) {
|
|
599
|
-
if (v > BigInt(Number.MAX_SAFE_INTEGER)) throw new (0,
|
|
602
|
+
if (v > BigInt(Number.MAX_SAFE_INTEGER)) throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} is too large for a unix timestamp`, { field });
|
|
600
603
|
return Number(v);
|
|
601
604
|
}
|
|
605
|
+
function priceFor(drop, phase) {
|
|
606
|
+
const presalePrice = phase === DROP_PHASE.PRESALE || phase === DROP_PHASE.NOT_STARTED && drop.presaleDuration > 0n;
|
|
607
|
+
return { presalePrice, unitPrice: presalePrice ? drop.presaleCost : drop.publicCost };
|
|
608
|
+
}
|
|
602
609
|
async function readDrop(ctx, config) {
|
|
603
610
|
validateTlStacksConfig(config);
|
|
604
611
|
throwIfAborted(ctx);
|
|
@@ -611,14 +618,12 @@ async function readDrop(ctx, config) {
|
|
|
611
618
|
]);
|
|
612
619
|
const phase = Number(phaseRaw);
|
|
613
620
|
if (phase === DROP_PHASE.NOT_CONFIGURED) {
|
|
614
|
-
throw new (0,
|
|
621
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("DROP_NOT_FOUND", "No Transient Labs drop is configured for this NFT contract on this chain.");
|
|
615
622
|
}
|
|
616
623
|
if (drop.currencyAddress !== _viem.zeroAddress) {
|
|
617
624
|
bad("nftContract", `is sold for an ERC-20 (${drop.currencyAddress}). Dropkit supports drops priced in the native token only.`);
|
|
618
625
|
}
|
|
619
|
-
const
|
|
620
|
-
const presalePrice = phase === DROP_PHASE.PRESALE || phase === DROP_PHASE.NOT_STARTED && hasPresale;
|
|
621
|
-
const unitPrice = presalePrice ? drop.presaleCost : drop.publicCost;
|
|
626
|
+
const { presalePrice, unitPrice } = priceFor(drop, phase);
|
|
622
627
|
const startTime = seconds(drop.startTime, "startTime");
|
|
623
628
|
const presaleEnd = seconds(drop.startTime + drop.presaleDuration, "presaleDuration");
|
|
624
629
|
const soldOut = drop.supply === 0n;
|
|
@@ -704,12 +709,12 @@ async function readWallet(ctx, config, { payer, recipient, quantity, drop }) {
|
|
|
704
709
|
}
|
|
705
710
|
const remaining = walletMax > minted ? walletMax - minted : 0n;
|
|
706
711
|
if (presale && ineligible === null) {
|
|
707
|
-
allowlistRemaining = Number(remaining < BigInt(
|
|
712
|
+
allowlistRemaining = Number(remaining < BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY) ? remaining : BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY));
|
|
708
713
|
if (remaining === 0n) ineligible = { reason: "ALLOWLIST_USED", message: `This wallet has already minted its allowlist allocation of ${walletMax}.` };
|
|
709
714
|
} else if (!presale && remaining === 0n) {
|
|
710
715
|
ineligible = { reason: "WALLET_LIMIT", message: `This wallet has already minted its limit of ${walletMax}.` };
|
|
711
716
|
}
|
|
712
|
-
const maxQuantity = Number(remaining < BigInt(
|
|
717
|
+
const maxQuantity = Number(remaining < BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY) ? remaining : BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY));
|
|
713
718
|
const data = { presaleNumberCanMint, proof, unitPrice: drop.unitPrice.value, unitFee: drop.unitFee.value };
|
|
714
719
|
const qty = BigInt(quantity);
|
|
715
720
|
const value = qty * (data.unitPrice + data.unitFee);
|
|
@@ -747,7 +752,7 @@ function encodePurchase(config, recipient, quantity, data) {
|
|
|
747
752
|
function walletData(wallet) {
|
|
748
753
|
const d = wallet.data;
|
|
749
754
|
if (!d || typeof d.presaleNumberCanMint !== "bigint" || typeof d.unitPrice !== "bigint" || typeof d.unitFee !== "bigint" || !Array.isArray(d.proof)) {
|
|
750
|
-
throw new (0,
|
|
755
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("RPC_ERROR", "The wallet read is missing the data this mint needs. Reload and try again.");
|
|
751
756
|
}
|
|
752
757
|
return d;
|
|
753
758
|
}
|
|
@@ -756,7 +761,7 @@ async function buildPlan(ctx, attempt, wallet) {
|
|
|
756
761
|
validateTlStacksConfig(config);
|
|
757
762
|
throwIfAborted(ctx);
|
|
758
763
|
if (!Number.isInteger(attempt.quantity) || attempt.quantity < 1) {
|
|
759
|
-
throw new (0,
|
|
764
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", "Choose at least one token to mint.");
|
|
760
765
|
}
|
|
761
766
|
const data = walletData(wallet);
|
|
762
767
|
const qty = BigInt(attempt.quantity);
|
|
@@ -792,29 +797,43 @@ function revertData(e) {
|
|
|
792
797
|
return null;
|
|
793
798
|
}
|
|
794
799
|
function decodeTlRevert(e) {
|
|
795
|
-
if (
|
|
800
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) return e;
|
|
796
801
|
if (isAbortError(e)) throw e;
|
|
797
802
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.InsufficientFundsError)) {
|
|
798
|
-
return new (0,
|
|
803
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("INSUFFICIENT_FUNDS", `The wallet cannot cover the mint: ${e.shortMessage}`, { cause: e });
|
|
799
804
|
}
|
|
800
805
|
const data = revertData(e);
|
|
801
806
|
if (data) {
|
|
802
807
|
try {
|
|
803
808
|
const { errorName, args } = _viem.decodeErrorResult.call(void 0, { abi: stacksAbi, data });
|
|
804
809
|
const known = TL_MESSAGES[errorName];
|
|
805
|
-
if (known) return new (0,
|
|
810
|
+
if (known) return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", known, { cause: e, domain: "tl-stacks" });
|
|
806
811
|
const shown = (_nullishCoalesce(args, () => ( []))).map(String).join(", ");
|
|
807
|
-
return new (0,
|
|
812
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", `Transient Labs rejected the mint (${errorName}(${shown})).`, { cause: e, domain: "tl-stacks" });
|
|
808
813
|
} catch (e3) {
|
|
809
|
-
return new (0,
|
|
814
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", `Transient Labs rejected the mint (unrecognized error ${data.slice(0, 10)}).`, { cause: e, domain: "tl-stacks" });
|
|
810
815
|
}
|
|
811
816
|
}
|
|
812
817
|
const reverted = e instanceof _viem.BaseError && e.walk((x) => x.code === 3 || /execution reverted/i.test(x.message));
|
|
813
|
-
if (reverted) return new (0,
|
|
814
|
-
return new (0,
|
|
818
|
+
if (reverted) return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", shortMessage(e), { cause: e });
|
|
819
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("RPC_ERROR", `RPC request failed: ${shortMessage(e)}`, { cause: e });
|
|
815
820
|
}
|
|
816
821
|
async function simulate(ctx, attempt, plan) {
|
|
817
822
|
throwIfAborted(ctx);
|
|
823
|
+
const { config } = attempt;
|
|
824
|
+
const nft = _viem.getAddress.call(void 0, config.nftContract);
|
|
825
|
+
const [drop, phaseRaw, fee] = await Promise.all([
|
|
826
|
+
readStacks(ctx, config, "getDrop", [nft]),
|
|
827
|
+
readStacks(ctx, config, "getDropPhase", [nft]),
|
|
828
|
+
readStacks(ctx, config, "protocolFee")
|
|
829
|
+
]);
|
|
830
|
+
if (drop.currencyAddress !== _viem.zeroAddress) {
|
|
831
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", "This drop is now sold for a token instead of the native currency, so it cannot be minted here. Reload the page.", { domain: "tl-stacks" });
|
|
832
|
+
}
|
|
833
|
+
const current = BigInt(attempt.quantity) * (priceFor(drop, Number(phaseRaw)).unitPrice + fee);
|
|
834
|
+
if (current !== plan.mint.value) {
|
|
835
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", TL_MESSAGES.InsufficientFunds, { domain: "tl-stacks" });
|
|
836
|
+
}
|
|
818
837
|
try {
|
|
819
838
|
await io(ctx, () => ctx.client.call({ account: attempt.payer, to: plan.mint.to, data: plan.mint.data, value: plan.mint.value }));
|
|
820
839
|
} catch (e) {
|
|
@@ -881,7 +900,7 @@ var PLACEHOLDER_TOKEN = /\{[A-Za-z_]\w*\}/g;
|
|
|
881
900
|
var DISPLAY_AMOUNT = /^\d+(\.\d+)?$/;
|
|
882
901
|
var NUMERIC_TYPE = /^u?int\d*$/;
|
|
883
902
|
function bad2(field, message) {
|
|
884
|
-
throw new (0,
|
|
903
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} ${message}`, { field });
|
|
885
904
|
}
|
|
886
905
|
var isHexAddress = (a) => typeof a === "string" && _viem.isAddress.call(void 0, a, { strict: false });
|
|
887
906
|
function functionsNamed(abi, name) {
|
|
@@ -1096,7 +1115,7 @@ function validateOptional(abi, name, src, allowed) {
|
|
|
1096
1115
|
function varFor(token, vars) {
|
|
1097
1116
|
const key = token.slice(1, -1);
|
|
1098
1117
|
const v = vars[key];
|
|
1099
|
-
if (v === void 0) throw new (0,
|
|
1118
|
+
if (v === void 0) throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `placeholder ${token} has no value here`);
|
|
1100
1119
|
return typeof v === "string" ? _viem.getAddress.call(void 0, v) : v;
|
|
1101
1120
|
}
|
|
1102
1121
|
function fill(t, p, vars) {
|
|
@@ -1131,13 +1150,13 @@ function io2(ctx, start) {
|
|
|
1131
1150
|
});
|
|
1132
1151
|
}
|
|
1133
1152
|
function rpcError2(e) {
|
|
1134
|
-
if (
|
|
1135
|
-
throw new (0,
|
|
1153
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e) || isAbortError2(e)) throw e;
|
|
1154
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("RPC_ERROR", `RPC request failed: ${shortMessage2(e)}`, { cause: e });
|
|
1136
1155
|
}
|
|
1137
1156
|
function classifyReadError(e, field) {
|
|
1138
|
-
if (
|
|
1157
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e) || isAbortError2(e)) throw e;
|
|
1139
1158
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.ContractFunctionRevertedError || x instanceof _viem.ContractFunctionZeroDataError)) {
|
|
1140
|
-
throw new (0,
|
|
1159
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} read reverted or returned no data: ${e.shortMessage}`, { field, cause: e });
|
|
1141
1160
|
}
|
|
1142
1161
|
return rpcError2(e);
|
|
1143
1162
|
}
|
|
@@ -1150,8 +1169,8 @@ async function readCall(ctx, params, field) {
|
|
|
1150
1169
|
}
|
|
1151
1170
|
function toBigInt(v, field) {
|
|
1152
1171
|
const n = typeof v === "number" ? BigInt(v) : v;
|
|
1153
|
-
if (typeof n !== "bigint") throw new (0,
|
|
1154
|
-
if (n < 0n) throw new (0,
|
|
1172
|
+
if (typeof n !== "bigint") throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} did not return a number`, { field });
|
|
1173
|
+
if (n < 0n) throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} returned a negative number`, { field });
|
|
1155
1174
|
return n;
|
|
1156
1175
|
}
|
|
1157
1176
|
async function readField(ctx, config, name, src, vars) {
|
|
@@ -1167,7 +1186,7 @@ async function readField(ctx, config, name, src, vars) {
|
|
|
1167
1186
|
}
|
|
1168
1187
|
const value = src.value;
|
|
1169
1188
|
if (typeof value === "bigint") return value;
|
|
1170
|
-
throw new (0,
|
|
1189
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${name} display units are only valid for price`, { field: name });
|
|
1171
1190
|
}
|
|
1172
1191
|
function tupleMembers(res, fn, index) {
|
|
1173
1192
|
if (Array.isArray(res)) return res;
|
|
@@ -1179,7 +1198,7 @@ function tupleMembers(res, fn, index) {
|
|
|
1179
1198
|
var optField = (ctx, config, name, src, vars) => src ? readField(ctx, config, name, src, vars) : Promise.resolve(null);
|
|
1180
1199
|
function toSeconds(v, field) {
|
|
1181
1200
|
if (v === null || v === 0n) return null;
|
|
1182
|
-
if (v > BigInt(Number.MAX_SAFE_INTEGER)) throw new (0,
|
|
1201
|
+
if (v > BigInt(Number.MAX_SAFE_INTEGER)) throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} is too large for a unix timestamp`, { field });
|
|
1183
1202
|
return Number(v);
|
|
1184
1203
|
}
|
|
1185
1204
|
function nativeMeta2(ctx) {
|
|
@@ -1196,14 +1215,14 @@ async function currencyMeta(ctx, config) {
|
|
|
1196
1215
|
readCall(ctx, { address: token, abi: ERC20_ABI, functionName: "decimals" }, field)
|
|
1197
1216
|
]);
|
|
1198
1217
|
if (typeof symbol !== "string" || typeof decimals !== "number") {
|
|
1199
|
-
throw new (0,
|
|
1218
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} ${token} is not an ERC20 (symbol/decimals unreadable)`, { field });
|
|
1200
1219
|
}
|
|
1201
1220
|
return { token, decimals, symbol };
|
|
1202
1221
|
}
|
|
1203
1222
|
function parseDisplay(value, decimals) {
|
|
1204
1223
|
const frac = _nullishCoalesce(value.split(".")[1], () => ( ""));
|
|
1205
1224
|
if (frac.length > decimals) {
|
|
1206
|
-
throw new (0,
|
|
1225
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `price.value "${value}" has more than ${decimals} decimal places`, { field: "price.value" });
|
|
1207
1226
|
}
|
|
1208
1227
|
return _viem.parseUnits.call(void 0, value, decimals);
|
|
1209
1228
|
}
|
|
@@ -1245,16 +1264,16 @@ function describeRevert(abi, data) {
|
|
|
1245
1264
|
}
|
|
1246
1265
|
}
|
|
1247
1266
|
function toSimulationError(e, abi) {
|
|
1248
|
-
if (
|
|
1267
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) return e;
|
|
1249
1268
|
if (isAbortError2(e)) throw e;
|
|
1250
1269
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.InsufficientFundsError)) {
|
|
1251
|
-
return new (0,
|
|
1270
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("INSUFFICIENT_FUNDS", `Payer cannot cover the mint: ${e.shortMessage}`, { cause: e });
|
|
1252
1271
|
}
|
|
1253
1272
|
const data = revertData2(e);
|
|
1254
|
-
if (data) return new (0,
|
|
1273
|
+
if (data) return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", describeRevert(abi, data), { cause: e });
|
|
1255
1274
|
const isRevert = e instanceof _viem.BaseError && e.walk((x) => x.code === 3 || /execution reverted/i.test(x.message));
|
|
1256
|
-
if (isRevert) return new (0,
|
|
1257
|
-
return new (0,
|
|
1275
|
+
if (isRevert) return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", shortMessage2(e), { cause: e });
|
|
1276
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("RPC_ERROR", `RPC request failed: ${shortMessage2(e)}`, { cause: e });
|
|
1258
1277
|
}
|
|
1259
1278
|
async function simulateMint(ctx, config, call) {
|
|
1260
1279
|
try {
|
|
@@ -1268,8 +1287,8 @@ function encodeMint(config, vars) {
|
|
|
1268
1287
|
try {
|
|
1269
1288
|
return _viem.encodeFunctionData.call(void 0, { abi: [fn], functionName: fn.name, args: fillArgs(config.mint.args, fn.inputs, vars) });
|
|
1270
1289
|
} catch (e) {
|
|
1271
|
-
if (
|
|
1272
|
-
throw new (0,
|
|
1290
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) throw e;
|
|
1291
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `mint.args cannot be encoded for ${signature(fn)}: ${shortMessage2(e)}`, { field: "mint.args", cause: e });
|
|
1273
1292
|
}
|
|
1274
1293
|
}
|
|
1275
1294
|
function mintValue(config, token, totalPrice) {
|
|
@@ -1325,7 +1344,7 @@ async function readWallet2(ctx, config, { payer, recipient, quantity, drop }) {
|
|
|
1325
1344
|
]);
|
|
1326
1345
|
const walletMax = rawMax === null || rawMax === 0n ? null : rawMax;
|
|
1327
1346
|
const remaining = walletMax === null ? null : walletMax > (_nullishCoalesce(walletMinted, () => ( 0n))) ? walletMax - (_nullishCoalesce(walletMinted, () => ( 0n))) : 0n;
|
|
1328
|
-
const maxQuantity = remaining === null ? null : Number(remaining < BigInt(
|
|
1347
|
+
const maxQuantity = remaining === null ? null : Number(remaining < BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY) ? remaining : BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY));
|
|
1329
1348
|
let ineligible = null;
|
|
1330
1349
|
let gas = FALLBACK_MINT_GAS;
|
|
1331
1350
|
if (remaining === 0n) {
|
|
@@ -1338,7 +1357,7 @@ async function readWallet2(ctx, config, { payer, recipient, quantity, drop }) {
|
|
|
1338
1357
|
throw toSimulationError(e, config.abi);
|
|
1339
1358
|
});
|
|
1340
1359
|
} catch (e) {
|
|
1341
|
-
if (!
|
|
1360
|
+
if (!_chunkXWONUCGAcjs.isMintError.call(void 0, e) || e.reason !== "SIMULATION_REVERTED") throw e;
|
|
1342
1361
|
ineligible = { reason: "SIMULATION_REVERTED", message: e.message };
|
|
1343
1362
|
}
|
|
1344
1363
|
}
|
|
@@ -1395,6 +1414,8 @@ var contractAdapter = { readDrop: readDrop2, readWallet: readWallet2, buildPlan:
|
|
|
1395
1414
|
// src/react/useMint.ts
|
|
1396
1415
|
var REFRESH_MS = 3e4;
|
|
1397
1416
|
var TICK_MS = 1e3;
|
|
1417
|
+
var BOUNDARY_RETRY_MS = 3e3;
|
|
1418
|
+
var BOUNDARY_RETRY_MAX = 10;
|
|
1398
1419
|
var ASYNC_STATES = ["loading", "connecting", "switching-chain", "approving", "minting", "confirming"];
|
|
1399
1420
|
function isAsyncState(name) {
|
|
1400
1421
|
return ASYNC_STATES.includes(name);
|
|
@@ -1406,7 +1427,7 @@ function configKeyOf(config) {
|
|
|
1406
1427
|
function adapterFor(config) {
|
|
1407
1428
|
switch (config.type) {
|
|
1408
1429
|
case "manifold-claim":
|
|
1409
|
-
return
|
|
1430
|
+
return _chunkXWONUCGAcjs.manifoldClaimAdapter;
|
|
1410
1431
|
case "contract":
|
|
1411
1432
|
return contractAdapter;
|
|
1412
1433
|
case "tl-stacks":
|
|
@@ -1431,12 +1452,12 @@ function routeChainOf(payChains, accountChainId, payChainId) {
|
|
|
1431
1452
|
var ROUTE_DEBOUNCE_MS = 500;
|
|
1432
1453
|
var symbolOf = (chainId) => {
|
|
1433
1454
|
try {
|
|
1434
|
-
return
|
|
1455
|
+
return _chunkXWONUCGAcjs.getChain.call(void 0, chainId).nativeCurrency.symbol;
|
|
1435
1456
|
} catch (e5) {
|
|
1436
1457
|
return "ETH";
|
|
1437
1458
|
}
|
|
1438
1459
|
};
|
|
1439
|
-
var shortOf = (chainId) => ({ chainId, symbol: symbolOf(chainId), name:
|
|
1460
|
+
var shortOf = (chainId) => ({ chainId, symbol: symbolOf(chainId), name: _chunkXWONUCGAcjs.chainName.call(void 0, chainId) });
|
|
1440
1461
|
function tokenContractOf(config) {
|
|
1441
1462
|
switch (config.type) {
|
|
1442
1463
|
case "manifold-claim":
|
|
@@ -1465,15 +1486,15 @@ function eventAddressOf(config) {
|
|
|
1465
1486
|
}
|
|
1466
1487
|
}
|
|
1467
1488
|
}
|
|
1468
|
-
var isUnsupported = (reason) =>
|
|
1489
|
+
var isUnsupported = (reason) => _chunkXWONUCGAcjs.UNSUPPORTED_REASONS.includes(reason);
|
|
1469
1490
|
function errorReasonOf(e) {
|
|
1470
|
-
const { reason, message } =
|
|
1491
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1471
1492
|
const ok = ["USER_REJECTED", "TX_REVERTED", "RATE_LIMITED", "RPC_ERROR", "CHAIN_SWITCH_FAILED", "ALLOWLIST_UNAVAILABLE"];
|
|
1472
1493
|
return { reason: ok.includes(reason) ? reason : "RPC_ERROR", message };
|
|
1473
1494
|
}
|
|
1474
1495
|
function explorerUrlFor(chainId, hash) {
|
|
1475
1496
|
try {
|
|
1476
|
-
const url = _optionalChain([
|
|
1497
|
+
const url = _optionalChain([_chunkXWONUCGAcjs.getChain.call(void 0, chainId), 'access', _44 => _44.blockExplorers, 'optionalAccess', _45 => _45.default, 'access', _46 => _46.url]);
|
|
1477
1498
|
return url ? `${url.replace(/\/$/, "")}/tx/${hash}` : null;
|
|
1478
1499
|
} catch (e6) {
|
|
1479
1500
|
return null;
|
|
@@ -1482,7 +1503,7 @@ function explorerUrlFor(chainId, hash) {
|
|
|
1482
1503
|
var receiptOk = (status) => status === "success" || status === 1 || status === 1n || status === "0x1";
|
|
1483
1504
|
function useMint(options) {
|
|
1484
1505
|
const { config, recipient, quantity: quantityProp, connect } = options;
|
|
1485
|
-
const [machine, rawDispatch] = _react.useReducer.call(void 0,
|
|
1506
|
+
const [machine, rawDispatch] = _react.useReducer.call(void 0, _chunkYGBIJOKQcjs.reducer, void 0, () => _chunkYGBIJOKQcjs.initialState.call(void 0, { quantity: quantityProp }));
|
|
1486
1507
|
const [widgetFail, setWidgetFail] = _react.useState.call(void 0, null);
|
|
1487
1508
|
const [widgetRetry, setWidgetRetry] = _react.useState.call(void 0, 0);
|
|
1488
1509
|
const configKey = configKeyOf(config);
|
|
@@ -1496,6 +1517,7 @@ function useMint(options) {
|
|
|
1496
1517
|
const accountKeyRef = _react.useRef.call(void 0, null);
|
|
1497
1518
|
const connectingRef = _react.useRef.call(void 0, false);
|
|
1498
1519
|
const pendingRefreshRef = _react.useRef.call(void 0, false);
|
|
1520
|
+
const boundaryRetryRef = _react.useRef.call(void 0, null);
|
|
1499
1521
|
const pendingQuantityRef = _react.useRef.call(void 0, null);
|
|
1500
1522
|
const widgetFailRef = _react.useRef.call(void 0, null);
|
|
1501
1523
|
const widgetLoadRef = _react.useRef.call(void 0, null);
|
|
@@ -1509,7 +1531,7 @@ function useMint(options) {
|
|
|
1509
1531
|
});
|
|
1510
1532
|
const dispatch = _react.useCallback.call(void 0, (event) => {
|
|
1511
1533
|
if (!mounted.current) return;
|
|
1512
|
-
stateRef.current =
|
|
1534
|
+
stateRef.current = _chunkYGBIJOKQcjs.reducer.call(void 0, stateRef.current, event);
|
|
1513
1535
|
rawDispatch(event);
|
|
1514
1536
|
}, []);
|
|
1515
1537
|
const emit = _react.useCallback.call(void 0, (type, over = {}) => {
|
|
@@ -1538,7 +1560,7 @@ function useMint(options) {
|
|
|
1538
1560
|
const rpcUrl = _optionalChain([propsRef, 'access', _55 => _55.current, 'access', _56 => _56.rpcUrls, 'optionalAccess', _57 => _57[cfg.chainId]]);
|
|
1539
1561
|
if (!life.client || life.rpcUrl !== rpcUrl) {
|
|
1540
1562
|
life.rpcUrl = rpcUrl;
|
|
1541
|
-
life.client =
|
|
1563
|
+
life.client = _chunkXWONUCGAcjs.createReadClient.call(void 0, { chainId: cfg.chainId, rpcUrls: propsRef.current.rpcUrls, useBridge: bridgeEnabled(cfg) });
|
|
1542
1564
|
}
|
|
1543
1565
|
return life.client;
|
|
1544
1566
|
}, []);
|
|
@@ -1560,7 +1582,7 @@ function useMint(options) {
|
|
|
1560
1582
|
dispatch({ type: "DROP_LOADED", gen, drop, now: Math.max(stateRef.current.now, nowSec()) });
|
|
1561
1583
|
} catch (e) {
|
|
1562
1584
|
if (life.controller.signal.aborted || life.gen !== gen || lifeRef.current !== life) return;
|
|
1563
|
-
const { reason, message } =
|
|
1585
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1564
1586
|
if (isUnsupported(reason)) dispatch({ type: "DROP_UNSUPPORTED", gen, reason, message });
|
|
1565
1587
|
else dispatch({ type: "READ_FAILED", gen, ...errorReasonOf(e) });
|
|
1566
1588
|
}
|
|
@@ -1597,7 +1619,7 @@ function useMint(options) {
|
|
|
1597
1619
|
);
|
|
1598
1620
|
const refresh = _react.useCallback.call(void 0, () => refreshNow("refresh"), [refreshNow]);
|
|
1599
1621
|
const isBusy = _react.useCallback.call(void 0,
|
|
1600
|
-
() => connectingRef.current || attemptRef.current !== null || stateRef.current.attempt !== null ||
|
|
1622
|
+
() => connectingRef.current || attemptRef.current !== null || stateRef.current.attempt !== null || _chunkYGBIJOKQcjs.IN_FLIGHT_STATES.includes(stateRef.current.name),
|
|
1601
1623
|
[]
|
|
1602
1624
|
);
|
|
1603
1625
|
const executeAttempt = _react.useCallback.call(void 0,
|
|
@@ -1613,20 +1635,20 @@ function useMint(options) {
|
|
|
1613
1635
|
};
|
|
1614
1636
|
const assertPayer = () => {
|
|
1615
1637
|
assertActive();
|
|
1616
|
-
const live =
|
|
1638
|
+
const live = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
1617
1639
|
if (!live || live.address.toLowerCase() !== attempt.payer.toLowerCase()) {
|
|
1618
|
-
throw new (0,
|
|
1640
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("USER_REJECTED", "The connected wallet changed before the transaction was sent.");
|
|
1619
1641
|
}
|
|
1620
1642
|
};
|
|
1621
1643
|
let wallet2 = null;
|
|
1622
1644
|
const walletFor = () => {
|
|
1623
|
-
if (!wallet2) wallet2 =
|
|
1645
|
+
if (!wallet2) wallet2 = _chunkYGBIJOKQcjs.getWalletClient.call(void 0, attempt.chainId);
|
|
1624
1646
|
return wallet2;
|
|
1625
1647
|
};
|
|
1626
1648
|
const submit = async (tx) => {
|
|
1627
1649
|
assertPayer();
|
|
1628
1650
|
const w = walletFor();
|
|
1629
|
-
return w.sendTransaction({ account: attempt.payer, to: tx.to, data: tx.data, value: tx.value, chain:
|
|
1651
|
+
return w.sendTransaction({ account: attempt.payer, to: tx.to, data: tx.data, value: tx.value, chain: _chunkXWONUCGAcjs.getChain.call(void 0, attempt.chainId) });
|
|
1630
1652
|
};
|
|
1631
1653
|
const waitReceipt = async (hash2) => {
|
|
1632
1654
|
let cancelled = false;
|
|
@@ -1643,19 +1665,19 @@ function useMint(options) {
|
|
|
1643
1665
|
receipt2 = await client.waitForTransactionReceipt(params);
|
|
1644
1666
|
} catch (e) {
|
|
1645
1667
|
assertActive();
|
|
1646
|
-
if (cancelled) throw new (0,
|
|
1668
|
+
if (cancelled) throw new (0, _chunkXWONUCGAcjs.MintError)("USER_REJECTED", "The transaction was cancelled or replaced with a different transaction.");
|
|
1647
1669
|
if (await walletFor().getChainId() !== attempt.chainId) throw e;
|
|
1648
1670
|
assertActive();
|
|
1649
1671
|
receipt2 = await walletFor().extend(_viem.publicActions).waitForTransactionReceipt(params);
|
|
1650
1672
|
}
|
|
1651
1673
|
assertActive();
|
|
1652
|
-
if (cancelled) throw new (0,
|
|
1674
|
+
if (cancelled) throw new (0, _chunkXWONUCGAcjs.MintError)("USER_REJECTED", "The transaction was cancelled or replaced with a different transaction.");
|
|
1653
1675
|
return receipt2;
|
|
1654
1676
|
};
|
|
1655
1677
|
assertPayer();
|
|
1656
1678
|
if (account2.chainId !== attempt.chainId) {
|
|
1657
1679
|
dispatch({ type: "SWITCHING_CHAIN", attemptId: attempt.attemptId });
|
|
1658
|
-
await
|
|
1680
|
+
await _chunkYGBIJOKQcjs.switchToChain.call(void 0, attempt.chainId);
|
|
1659
1681
|
}
|
|
1660
1682
|
assertPayer();
|
|
1661
1683
|
let plan = await adapter.buildPlan(ctx, attempt, walletRead);
|
|
@@ -1665,13 +1687,13 @@ function useMint(options) {
|
|
|
1665
1687
|
try {
|
|
1666
1688
|
const simulated = await client.call({ account: attempt.payer, to: a.tx.to, data: a.tx.data, value: a.tx.value });
|
|
1667
1689
|
if (simulated.data && simulated.data !== "0x" && BigInt(simulated.data) === 0n) {
|
|
1668
|
-
throw new (0,
|
|
1690
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", "The token refused the approval.");
|
|
1669
1691
|
}
|
|
1670
1692
|
} catch (e) {
|
|
1671
|
-
if (
|
|
1693
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) throw e;
|
|
1672
1694
|
const reverted = e instanceof _viem.BaseError ? e.walk((cause) => cause instanceof _viem.ExecutionRevertedError) : null;
|
|
1673
1695
|
if (reverted instanceof _viem.ExecutionRevertedError) {
|
|
1674
|
-
throw new (0,
|
|
1696
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", reverted.shortMessage);
|
|
1675
1697
|
}
|
|
1676
1698
|
throw e;
|
|
1677
1699
|
}
|
|
@@ -1683,7 +1705,7 @@ function useMint(options) {
|
|
|
1683
1705
|
const approveReceipt = await waitReceipt(approveHash);
|
|
1684
1706
|
assertActive();
|
|
1685
1707
|
if (!receiptOk(approveReceipt.status)) {
|
|
1686
|
-
throw new (0,
|
|
1708
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("TX_REVERTED", `The approval transaction reverted (${approveHash}).`);
|
|
1687
1709
|
}
|
|
1688
1710
|
const freshDrop = await adapter.readDrop(ctx, cfg);
|
|
1689
1711
|
assertActive();
|
|
@@ -1694,11 +1716,11 @@ function useMint(options) {
|
|
|
1694
1716
|
drop: freshDrop
|
|
1695
1717
|
});
|
|
1696
1718
|
assertPayer();
|
|
1697
|
-
let checked =
|
|
1698
|
-
checked =
|
|
1699
|
-
checked =
|
|
1700
|
-
if (checked.name !== "live" || (_nullishCoalesce(
|
|
1701
|
-
throw new (0,
|
|
1719
|
+
let checked = _chunkYGBIJOKQcjs.reducer.call(void 0, _chunkYGBIJOKQcjs.initialState.call(void 0, { quantity: attempt.quantity }), { type: "ACCOUNT_CHANGED", account: account2 });
|
|
1720
|
+
checked = _chunkYGBIJOKQcjs.reducer.call(void 0, checked, { type: "DROP_LOADED", gen: checked.readGen, drop: freshDrop, now: nowSec() });
|
|
1721
|
+
checked = _chunkYGBIJOKQcjs.reducer.call(void 0, checked, { type: "WALLET_LOADED", gen: checked.walletGen, read: freshWallet });
|
|
1722
|
+
if (checked.name !== "live" || (_nullishCoalesce(_chunkYGBIJOKQcjs.selectMaxQuantity.call(void 0, checked), () => ( 0))) < attempt.quantity) {
|
|
1723
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)(_nullishCoalesce(checked.reason, () => ( "SIMULATION_REVERTED")), _nullishCoalesce(checked.message, () => ( "The drop is no longer available for this quantity.")));
|
|
1702
1724
|
}
|
|
1703
1725
|
plan = await adapter.buildPlan(ctx, attempt, freshWallet);
|
|
1704
1726
|
assertPayer();
|
|
@@ -1707,6 +1729,7 @@ function useMint(options) {
|
|
|
1707
1729
|
assertPayer();
|
|
1708
1730
|
dispatch({ type: "MINT_PROMPTED", attemptId: attempt.attemptId });
|
|
1709
1731
|
const hash = await submit(plan.mint);
|
|
1732
|
+
if (cfg.type === "manifold-claim") void _chunkYGBIJOKQcjs.recordClaimMint.call(void 0, { instanceId: cfg.instanceId, hash });
|
|
1710
1733
|
assertActive();
|
|
1711
1734
|
dispatch({ type: "TX_SUBMITTED", attemptId: attempt.attemptId });
|
|
1712
1735
|
emit("tx-submitted", { state: "confirming", reason: null, txHash: hash, quantity: attempt.quantity, chainId: attempt.chainId });
|
|
@@ -1714,9 +1737,9 @@ function useMint(options) {
|
|
|
1714
1737
|
assertActive();
|
|
1715
1738
|
const confirmedHash = _nullishCoalesce(receipt.transactionHash, () => ( hash));
|
|
1716
1739
|
if (!receiptOk(receipt.status)) {
|
|
1717
|
-
throw new (0,
|
|
1740
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("TX_REVERTED", `The mint transaction reverted (${confirmedHash}).`);
|
|
1718
1741
|
}
|
|
1719
|
-
const tokens =
|
|
1742
|
+
const tokens = _chunkYGBIJOKQcjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), {
|
|
1720
1743
|
tokenContract: _nullishCoalesce(plan.tokenContract, () => ( attempt.tokenContract)),
|
|
1721
1744
|
recipient: attempt.recipient
|
|
1722
1745
|
});
|
|
@@ -1737,28 +1760,29 @@ function useMint(options) {
|
|
|
1737
1760
|
};
|
|
1738
1761
|
const outcome = await pollUntilTerminal({ testnet: out.testnet, requestId: out.requestId, signal: life.controller.signal, assertActive });
|
|
1739
1762
|
assertActive();
|
|
1740
|
-
const where =
|
|
1763
|
+
const where = _chunkXWONUCGAcjs.chainName.call(void 0, out.originChainId);
|
|
1741
1764
|
if (outcome.kind === "timeout") {
|
|
1742
|
-
throw new (0,
|
|
1765
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_TIMEOUT", "The bridge is still processing. Your mint may still complete.");
|
|
1743
1766
|
}
|
|
1744
1767
|
const key = outstandingKey(attempt.config, attempt.payer);
|
|
1745
1768
|
const { status } = outcome;
|
|
1746
1769
|
if (status.status !== "success") clearOutstanding(key);
|
|
1747
1770
|
if (status.status === "refund") {
|
|
1748
|
-
throw new (0,
|
|
1771
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_REFUNDED", `Relay could not complete the mint and is refunding your payment. Relay request ${out.requestId}.`);
|
|
1749
1772
|
}
|
|
1750
1773
|
if (status.status === "failure") {
|
|
1751
1774
|
const why = status.failReason ? ` (${status.failReason})` : "";
|
|
1752
1775
|
const noRefund = status.refundFailReason ? ` No automatic refund was sent. Contact support with Relay request ${out.requestId}.` : "";
|
|
1753
|
-
throw new (0,
|
|
1776
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_FAILED", `Relay could not complete the mint paid on ${where}${why}.${noRefund}`);
|
|
1754
1777
|
}
|
|
1755
1778
|
const fillHash = _nullishCoalesce(status.txHashes[0], () => ( null));
|
|
1779
|
+
if (fillHash && cfg.type === "manifold-claim") void _chunkYGBIJOKQcjs.recordClaimMint.call(void 0, { instanceId: cfg.instanceId, hash: fillHash });
|
|
1756
1780
|
let tokens = [];
|
|
1757
1781
|
if (fillHash) {
|
|
1758
1782
|
try {
|
|
1759
1783
|
const receipt = await client.waitForTransactionReceipt({ hash: fillHash, confirmations: 1, timeout: 6e4 });
|
|
1760
1784
|
if (receiptOk(receipt.status)) {
|
|
1761
|
-
tokens =
|
|
1785
|
+
tokens = _chunkYGBIJOKQcjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), { tokenContract: attempt.tokenContract, recipient: attempt.recipient });
|
|
1762
1786
|
}
|
|
1763
1787
|
} catch (e8) {
|
|
1764
1788
|
}
|
|
@@ -1789,19 +1813,19 @@ function useMint(options) {
|
|
|
1789
1813
|
if (!mounted.current || life.controller.signal.aborted || lifeRef.current !== life || attemptRef.current !== attempt) {
|
|
1790
1814
|
throw new DOMException("Mint attempt cancelled", "AbortError");
|
|
1791
1815
|
}
|
|
1792
|
-
const live =
|
|
1816
|
+
const live = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
1793
1817
|
if (!live || live.address.toLowerCase() !== attempt.payer.toLowerCase()) {
|
|
1794
|
-
throw new (0,
|
|
1818
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("USER_REJECTED", "The connected wallet changed before the transaction was sent.");
|
|
1795
1819
|
}
|
|
1796
1820
|
};
|
|
1797
1821
|
assertPayer();
|
|
1798
1822
|
if (account2.chainId !== origin) {
|
|
1799
1823
|
dispatch({ type: "SWITCHING_CHAIN", attemptId: attempt.attemptId });
|
|
1800
|
-
await
|
|
1824
|
+
await _chunkYGBIJOKQcjs.switchToChain.call(void 0, origin);
|
|
1801
1825
|
}
|
|
1802
1826
|
assertPayer();
|
|
1803
1827
|
const plan = await adapter.buildPlan(ctx, attempt, walletRead);
|
|
1804
|
-
if (plan.approve) throw new (0,
|
|
1828
|
+
if (plan.approve) throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Cross-chain mint supports native-priced drops only.");
|
|
1805
1829
|
assertPayer();
|
|
1806
1830
|
const quote = await getQuote({
|
|
1807
1831
|
testnet,
|
|
@@ -1814,18 +1838,18 @@ function useMint(options) {
|
|
|
1814
1838
|
signal: life.controller.signal
|
|
1815
1839
|
});
|
|
1816
1840
|
assertPayer();
|
|
1817
|
-
const balance = await
|
|
1841
|
+
const balance = await _chunkYGBIJOKQcjs.getConnectedBalance.call(void 0, attempt.payer, origin);
|
|
1818
1842
|
if (balance < quote.amountIn.value + quote.originGas.value) {
|
|
1819
1843
|
const s = shortOf(origin);
|
|
1820
|
-
throw new (0,
|
|
1844
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INSUFFICIENT_FUNDS", `Not enough ${s.symbol} on ${s.name}. Pick another network to pay from.`);
|
|
1821
1845
|
}
|
|
1822
1846
|
assertPayer();
|
|
1823
1847
|
const item = quote.items[0];
|
|
1824
1848
|
const key = outstandingKey(cfg, attempt.payer);
|
|
1825
|
-
const wallet2 =
|
|
1849
|
+
const wallet2 = _chunkYGBIJOKQcjs.getWalletClient.call(void 0, origin);
|
|
1826
1850
|
assertPayer();
|
|
1827
1851
|
if (!claimDeposit(key)) {
|
|
1828
|
-
throw new (0,
|
|
1852
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "A cross-chain payment for this drop is already in progress. Try again once it finishes.");
|
|
1829
1853
|
}
|
|
1830
1854
|
let out;
|
|
1831
1855
|
try {
|
|
@@ -1837,7 +1861,7 @@ function useMint(options) {
|
|
|
1837
1861
|
data: item.data,
|
|
1838
1862
|
value: item.value,
|
|
1839
1863
|
...item.gas !== null && item.gas > 0n ? { gas: item.gas } : {},
|
|
1840
|
-
chain:
|
|
1864
|
+
chain: _chunkXWONUCGAcjs.getChain.call(void 0, origin)
|
|
1841
1865
|
});
|
|
1842
1866
|
out = { requestId: quote.requestId, testnet, originChainId: origin, originTxHash: originTxHash2, attempt };
|
|
1843
1867
|
setOutstanding(key, out);
|
|
@@ -1848,10 +1872,10 @@ function useMint(options) {
|
|
|
1848
1872
|
autoResumedRef.current.add(key);
|
|
1849
1873
|
dispatch({ type: "TX_SUBMITTED", attemptId: attempt.attemptId });
|
|
1850
1874
|
emit("tx-submitted", { state: "confirming", reason: null, txHash: originTxHash, quantity: attempt.quantity, chainId: cfg.chainId });
|
|
1851
|
-
const deposit = await
|
|
1875
|
+
const deposit = await _chunkYGBIJOKQcjs.waitForDeposit.call(void 0, origin, originTxHash);
|
|
1852
1876
|
if (deposit === "reverted") {
|
|
1853
1877
|
clearOutstanding(key);
|
|
1854
|
-
throw new (0,
|
|
1878
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("TX_REVERTED", `The payment transaction reverted (${originTxHash}).`);
|
|
1855
1879
|
}
|
|
1856
1880
|
await finishRelay(attempt, out, life);
|
|
1857
1881
|
},
|
|
@@ -1868,7 +1892,7 @@ function useMint(options) {
|
|
|
1868
1892
|
await finishRelay(attempt, out, life);
|
|
1869
1893
|
} catch (e) {
|
|
1870
1894
|
if (!mounted.current || life.controller.signal.aborted || lifeRef.current !== life) return;
|
|
1871
|
-
const { reason, message } =
|
|
1895
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1872
1896
|
dispatch({ type: "ATTEMPT_FAILED", attemptId: attempt.attemptId, reason, message });
|
|
1873
1897
|
emit("error", { quantity: attempt.quantity, chainId: attempt.chainId });
|
|
1874
1898
|
} finally {
|
|
@@ -1889,7 +1913,7 @@ function useMint(options) {
|
|
|
1889
1913
|
return;
|
|
1890
1914
|
}
|
|
1891
1915
|
const s = stateRef.current;
|
|
1892
|
-
if (!
|
|
1916
|
+
if (!_chunkYGBIJOKQcjs.canAct.call(void 0, s) || s.attempt !== null) return;
|
|
1893
1917
|
if (s.name === "disconnected") {
|
|
1894
1918
|
if (connectingRef.current) return;
|
|
1895
1919
|
connectingRef.current = true;
|
|
@@ -1899,12 +1923,12 @@ function useMint(options) {
|
|
|
1899
1923
|
try {
|
|
1900
1924
|
await widgetLoadRef.current;
|
|
1901
1925
|
if (!active()) return;
|
|
1902
|
-
const outcome = await
|
|
1926
|
+
const outcome = await _chunkYGBIJOKQcjs.openConnectModal.call(void 0, );
|
|
1903
1927
|
if (!active()) return;
|
|
1904
1928
|
connectingRef.current = false;
|
|
1905
1929
|
if (outcome === "connected") {
|
|
1906
1930
|
accountKeyRef.current = null;
|
|
1907
|
-
_optionalChain([pushAccountRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65(
|
|
1931
|
+
_optionalChain([pushAccountRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65(_chunkYGBIJOKQcjs.getAccount.call(void 0, ))]);
|
|
1908
1932
|
} else dispatch({ type: "CONNECT_DISMISSED" });
|
|
1909
1933
|
} catch (e9) {
|
|
1910
1934
|
if (active()) dispatch({ type: "CONNECT_DISMISSED" });
|
|
@@ -1953,7 +1977,7 @@ function useMint(options) {
|
|
|
1953
1977
|
else await executeAttempt(attempt, walletRead, life, account2);
|
|
1954
1978
|
} catch (e) {
|
|
1955
1979
|
if (!mounted.current || life.controller.signal.aborted || lifeRef.current !== life) return;
|
|
1956
|
-
const { reason, message } =
|
|
1980
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1957
1981
|
dispatch({ type: "ATTEMPT_FAILED", attemptId: attempt.attemptId, reason, message });
|
|
1958
1982
|
emit("error", { quantity: attempt.quantity, chainId: attempt.chainId });
|
|
1959
1983
|
} finally {
|
|
@@ -1967,6 +1991,8 @@ function useMint(options) {
|
|
|
1967
1991
|
mounted.current = true;
|
|
1968
1992
|
return () => {
|
|
1969
1993
|
mounted.current = false;
|
|
1994
|
+
if (boundaryRetryRef.current) clearTimeout(boundaryRetryRef.current);
|
|
1995
|
+
boundaryRetryRef.current = null;
|
|
1970
1996
|
_optionalChain([lifeRef, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.controller, 'access', _72 => _72.abort, 'call', _73 => _73()]);
|
|
1971
1997
|
lifeRef.current = null;
|
|
1972
1998
|
};
|
|
@@ -1980,8 +2006,8 @@ function useMint(options) {
|
|
|
1980
2006
|
dispatch({ type: "ACCOUNT_CHANGED", account: a });
|
|
1981
2007
|
};
|
|
1982
2008
|
pushAccountRef.current = push;
|
|
1983
|
-
push(
|
|
1984
|
-
const unsubscribe =
|
|
2009
|
+
push(_chunkYGBIJOKQcjs.getAccount.call(void 0, ));
|
|
2010
|
+
const unsubscribe = _chunkYGBIJOKQcjs.subscribeAccount.call(void 0, push);
|
|
1985
2011
|
return () => {
|
|
1986
2012
|
unsubscribe();
|
|
1987
2013
|
};
|
|
@@ -1991,13 +2017,13 @@ function useMint(options) {
|
|
|
1991
2017
|
if (isBusy() || recipientRef.current === recipient) return;
|
|
1992
2018
|
recipientRef.current = recipient;
|
|
1993
2019
|
accountKeyRef.current = null;
|
|
1994
|
-
_optionalChain([pushAccountRef, 'access', _74 => _74.current, 'optionalCall', _75 => _75(
|
|
2020
|
+
_optionalChain([pushAccountRef, 'access', _74 => _74.current, 'optionalCall', _75 => _75(_chunkYGBIJOKQcjs.getAccount.call(void 0, ))]);
|
|
1995
2021
|
}, [recipient, machine.attempt, isBusy]);
|
|
1996
2022
|
const projectId = _optionalChain([connect, 'optionalAccess', _76 => _76.walletConnectProjectId]);
|
|
1997
2023
|
const widgetChains = [config.chainId, ...payChainsOf(config, options.crossChain).filter((id) => id !== config.chainId)].join(",");
|
|
1998
2024
|
_react.useEffect.call(void 0, () => {
|
|
1999
2025
|
let alive = true;
|
|
2000
|
-
const loading =
|
|
2026
|
+
const loading = _chunkYGBIJOKQcjs.loadConnectWidget.call(void 0, { chainIds: widgetChains.split(",").map(Number), ...projectId ? { walletConnectProjectId: projectId } : {} });
|
|
2001
2027
|
widgetLoadRef.current = loading;
|
|
2002
2028
|
loading.then(
|
|
2003
2029
|
() => {
|
|
@@ -2005,7 +2031,7 @@ function useMint(options) {
|
|
|
2005
2031
|
},
|
|
2006
2032
|
(e) => {
|
|
2007
2033
|
if (!alive) return;
|
|
2008
|
-
const { reason, message } =
|
|
2034
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
2009
2035
|
setWidgetFail({ reason, message });
|
|
2010
2036
|
}
|
|
2011
2037
|
);
|
|
@@ -2076,7 +2102,7 @@ function useMint(options) {
|
|
|
2076
2102
|
drop
|
|
2077
2103
|
});
|
|
2078
2104
|
if (!alive || life.controller.signal.aborted || lifeRef.current !== life || life.gen !== readGen) return;
|
|
2079
|
-
const ineligible = _optionalChain([read, 'access', _82 => _82.ineligible, 'optionalAccess', _83 => _83.reason]) === "SIMULATION_REVERTED" ? { ...read.ineligible, message:
|
|
2105
|
+
const ineligible = _optionalChain([read, 'access', _82 => _82.ineligible, 'optionalAccess', _83 => _83.reason]) === "SIMULATION_REVERTED" ? { ...read.ineligible, message: _chunkXWONUCGAcjs.friendlyErrorMessage.call(void 0, new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", read.ineligible.message)) } : read.ineligible;
|
|
2080
2106
|
const fullRead = { ...read, ineligible };
|
|
2081
2107
|
const payChains = payChainsOf(cfg, propsRef.current.crossChain);
|
|
2082
2108
|
const crossChain = payChains.length > 0 && ineligible === null && (_nullishCoalesce(_optionalChain([adapter, 'access', _84 => _84.supportsRelay, 'optionalCall', _85 => _85(drop)]), () => ( false)));
|
|
@@ -2124,7 +2150,7 @@ function useMint(options) {
|
|
|
2124
2150
|
if (routeChain !== account.chainId) {
|
|
2125
2151
|
route = relay;
|
|
2126
2152
|
} else {
|
|
2127
|
-
const balance = await
|
|
2153
|
+
const balance = await _chunkYGBIJOKQcjs.getConnectedBalance.call(void 0, account.address, routeChain);
|
|
2128
2154
|
if (balance >= quote.amountIn.value + quote.originGas.value) route = relay;
|
|
2129
2155
|
else short = shortOf(routeChain);
|
|
2130
2156
|
}
|
|
@@ -2150,7 +2176,7 @@ function useMint(options) {
|
|
|
2150
2176
|
const state = stateRef.current;
|
|
2151
2177
|
if (!propChanged && state.account && !state.walletRead) return;
|
|
2152
2178
|
const event = { type: "SET_QUANTITY", quantity: quantityProp };
|
|
2153
|
-
const clamped =
|
|
2179
|
+
const clamped = _chunkYGBIJOKQcjs.reducer.call(void 0, state, event).quantity;
|
|
2154
2180
|
if (clamped !== state.quantity) dispatch(event);
|
|
2155
2181
|
if (clamped !== quantityProp) _optionalChain([propsRef, 'access', _86 => _86.current, 'access', _87 => _87.onQuantityChange, 'optionalCall', _88 => _88(clamped)]);
|
|
2156
2182
|
}, [quantityProp, machine.quantity, machine.drop, machine.walletRead, machine.attempt, dispatch, isBusy]);
|
|
@@ -2168,6 +2194,22 @@ function useMint(options) {
|
|
|
2168
2194
|
document.removeEventListener("visibilitychange", onVisible);
|
|
2169
2195
|
};
|
|
2170
2196
|
}, [refreshNow]);
|
|
2197
|
+
const retryWhileStale = _react.useCallback.call(void 0,
|
|
2198
|
+
(staleKey, life) => {
|
|
2199
|
+
if (staleKey === void 0) return;
|
|
2200
|
+
const step = (tries) => {
|
|
2201
|
+
if (tries >= BOUNDARY_RETRY_MAX || !mounted.current || lifeRef.current !== life || _optionalChain([stateRef, 'access', _89 => _89.current, 'access', _90 => _90.drop, 'optionalAccess', _91 => _91.walletKey]) !== staleKey) return;
|
|
2202
|
+
if (boundaryRetryRef.current) clearTimeout(boundaryRetryRef.current);
|
|
2203
|
+
boundaryRetryRef.current = setTimeout(() => {
|
|
2204
|
+
boundaryRetryRef.current = null;
|
|
2205
|
+
if (!mounted.current || lifeRef.current !== life) return;
|
|
2206
|
+
void refreshNow().then(() => step(tries + 1));
|
|
2207
|
+
}, BOUNDARY_RETRY_MS);
|
|
2208
|
+
};
|
|
2209
|
+
step(0);
|
|
2210
|
+
},
|
|
2211
|
+
[refreshNow]
|
|
2212
|
+
);
|
|
2171
2213
|
const boundary = machine.drop ? [machine.drop.startTime, machine.drop.endTime, _nullishCoalesce(machine.drop.phaseEndsAt, () => ( null))].some((t) => t !== null && t > machine.now) : false;
|
|
2172
2214
|
_react.useEffect.call(void 0, () => {
|
|
2173
2215
|
if (!boundary) return;
|
|
@@ -2176,21 +2218,24 @@ function useMint(options) {
|
|
|
2176
2218
|
const now = nowSec();
|
|
2177
2219
|
const crossed = s.drop && [s.drop.startTime, s.drop.endTime, _nullishCoalesce(s.drop.phaseEndsAt, () => ( null))].some((t) => t !== null && t > s.now && t <= now);
|
|
2178
2220
|
dispatch({ type: "TICK", now });
|
|
2179
|
-
if (crossed)
|
|
2221
|
+
if (crossed) {
|
|
2222
|
+
const life = lifeRef.current;
|
|
2223
|
+
void refreshNow().then(() => life && retryWhileStale(_optionalChain([s, 'access', _92 => _92.drop, 'optionalAccess', _93 => _93.walletKey]), life));
|
|
2224
|
+
}
|
|
2180
2225
|
}, TICK_MS);
|
|
2181
2226
|
return () => clearInterval(timer);
|
|
2182
|
-
}, [boundary, dispatch, refreshNow]);
|
|
2227
|
+
}, [boundary, dispatch, refreshNow, retryWhileStale]);
|
|
2183
2228
|
const prevName = _react.useRef.call(void 0, null);
|
|
2184
2229
|
_react.useEffect.call(void 0, () => {
|
|
2185
2230
|
const name = widgetFail ? isUnsupported(widgetFail.reason) ? "unsupported" : "error" : machine.name;
|
|
2186
2231
|
if (prevName.current === name) return;
|
|
2187
2232
|
prevName.current = name;
|
|
2188
|
-
emit("state", { state: name, reason: _nullishCoalesce(_optionalChain([widgetFail, 'optionalAccess',
|
|
2233
|
+
emit("state", { state: name, reason: _nullishCoalesce(_optionalChain([widgetFail, 'optionalAccess', _94 => _94.reason]), () => ( machine.reason)) });
|
|
2189
2234
|
}, [machine.name, machine.reason, widgetFail, emit]);
|
|
2190
2235
|
const setQuantity = _react.useCallback.call(void 0,
|
|
2191
2236
|
(next) => {
|
|
2192
2237
|
const s = stateRef.current;
|
|
2193
|
-
const max = _nullishCoalesce(
|
|
2238
|
+
const max = _nullishCoalesce(_chunkYGBIJOKQcjs.selectMaxQuantity.call(void 0, s), () => ( 65535));
|
|
2194
2239
|
const clamped = Math.max(1, Math.min(Math.floor(Number.isNaN(next) ? 1 : next), max));
|
|
2195
2240
|
const handler = propsRef.current.onQuantityChange;
|
|
2196
2241
|
if (handler) {
|
|
@@ -2225,16 +2270,16 @@ function useMint(options) {
|
|
|
2225
2270
|
wallet,
|
|
2226
2271
|
quantity: machine.quantity,
|
|
2227
2272
|
setQuantity,
|
|
2228
|
-
maxQuantity:
|
|
2229
|
-
total:
|
|
2273
|
+
maxQuantity: _chunkYGBIJOKQcjs.selectMaxQuantity.call(void 0, machine),
|
|
2274
|
+
total: _chunkYGBIJOKQcjs.selectTotal.call(void 0, machine),
|
|
2230
2275
|
mint,
|
|
2231
2276
|
result: machine.result,
|
|
2232
2277
|
refresh,
|
|
2233
2278
|
// An attempt claimed by a click is not clickable, even while the reducer still reads 'live'.
|
|
2234
|
-
canAct:
|
|
2279
|
+
canAct: _chunkYGBIJOKQcjs.canAct.call(void 0, { ...machine, name: effective.name }) && machine.attempt === null,
|
|
2235
2280
|
// Short on the wallet chain is neither route: nothing can be paid until the collector picks another chain.
|
|
2236
2281
|
route: _nullishCoalesce(machine.route, () => ( (machine.walletRead && machine.drop && !machine.routePending && machine.short === null ? { kind: "direct", chainId: machine.drop.chainId } : null))),
|
|
2237
|
-
crossChain: machine.crossChain && machine.account && _optionalChain([crossChainInfo, 'optionalAccess',
|
|
2282
|
+
crossChain: machine.crossChain && machine.account && _optionalChain([crossChainInfo, 'optionalAccess', _95 => _95.gen]) === machine.walletGen ? crossChainInfo.info : null
|
|
2238
2283
|
};
|
|
2239
2284
|
}
|
|
2240
2285
|
|
|
@@ -2245,12 +2290,12 @@ var PICKER_REFRESH_MS = 2e4;
|
|
|
2245
2290
|
var PICKER_DEBOUNCE_MS = 500;
|
|
2246
2291
|
var RELAY_REASONS = /* @__PURE__ */ new Set(["BRIDGE_UNAVAILABLE", "BRIDGE_TIMEOUT", "BRIDGE_REFUNDED", "BRIDGE_FAILED"]);
|
|
2247
2292
|
var money3 = (value, chainId) => {
|
|
2248
|
-
const c =
|
|
2293
|
+
const c = _chunkXWONUCGAcjs.getChain.call(void 0, chainId).nativeCurrency;
|
|
2249
2294
|
return { value, decimals: c.decimals, symbol: c.symbol, formatted: _viem.formatUnits.call(void 0, value, c.decimals) };
|
|
2250
2295
|
};
|
|
2251
2296
|
function usePayOptions(mint, onSelect) {
|
|
2252
2297
|
const info = mint.crossChain;
|
|
2253
|
-
const current = _nullishCoalesce(_optionalChain([mint, 'access',
|
|
2298
|
+
const current = _nullishCoalesce(_optionalChain([mint, 'access', _96 => _96.wallet, 'optionalAccess', _97 => _97.chainId]), () => ( null));
|
|
2254
2299
|
const [quotes, setQuotes] = _react.useState.call(void 0, {});
|
|
2255
2300
|
const [balance, setBalance] = _react.useState.call(void 0, null);
|
|
2256
2301
|
const [tick, setTick] = _react.useState.call(void 0, 0);
|
|
@@ -2275,7 +2320,7 @@ function usePayOptions(mint, onSelect) {
|
|
|
2275
2320
|
if (!controller.signal.aborted) setQuotes((prev) => ({ ...prev, [chainId]: { relayFee: q.relayFee, amountIn: q.amountIn } }));
|
|
2276
2321
|
},
|
|
2277
2322
|
(e) => {
|
|
2278
|
-
if (controller.signal.aborted || _optionalChain([e, 'optionalAccess',
|
|
2323
|
+
if (controller.signal.aborted || _optionalChain([e, 'optionalAccess', _98 => _98.reason]) === "RATE_LIMITED") return;
|
|
2279
2324
|
setQuotes((prev) => ({ ...prev, [chainId]: "failed" }));
|
|
2280
2325
|
}
|
|
2281
2326
|
);
|
|
@@ -2289,7 +2334,7 @@ function usePayOptions(mint, onSelect) {
|
|
|
2289
2334
|
_react.useEffect.call(void 0, () => {
|
|
2290
2335
|
if (!info || current === null || !mint.wallet) return;
|
|
2291
2336
|
let alive = true;
|
|
2292
|
-
|
|
2337
|
+
_chunkYGBIJOKQcjs.getConnectedBalance.call(void 0, mint.wallet.address, current).then(
|
|
2293
2338
|
(value) => {
|
|
2294
2339
|
if (alive) setBalance({ chainId: current, value });
|
|
2295
2340
|
},
|
|
@@ -2300,12 +2345,12 @@ function usePayOptions(mint, onSelect) {
|
|
|
2300
2345
|
return () => {
|
|
2301
2346
|
alive = false;
|
|
2302
2347
|
};
|
|
2303
|
-
}, [current, _optionalChain([mint, 'access',
|
|
2348
|
+
}, [current, _optionalChain([mint, 'access', _99 => _99.wallet, 'optionalAccess', _100 => _100.address]), key, tick]);
|
|
2304
2349
|
const select = _react.useCallback.call(void 0,
|
|
2305
2350
|
(chainId) => {
|
|
2306
|
-
|
|
2307
|
-
() => _optionalChain([onSelect, 'optionalCall',
|
|
2308
|
-
(e) => _optionalChain([onSelect, 'optionalCall',
|
|
2351
|
+
_chunkYGBIJOKQcjs.switchToChain.call(void 0, chainId).then(
|
|
2352
|
+
() => _optionalChain([onSelect, 'optionalCall', _101 => _101(chainId, null)]),
|
|
2353
|
+
(e) => _optionalChain([onSelect, 'optionalCall', _102 => _102(chainId, e)])
|
|
2309
2354
|
);
|
|
2310
2355
|
},
|
|
2311
2356
|
[onSelect]
|
|
@@ -2317,11 +2362,11 @@ function usePayOptions(mint, onSelect) {
|
|
|
2317
2362
|
const quoted = q && q !== "failed" ? q : null;
|
|
2318
2363
|
return {
|
|
2319
2364
|
chainId,
|
|
2320
|
-
name:
|
|
2365
|
+
name: _chunkXWONUCGAcjs.chainName.call(void 0, chainId),
|
|
2321
2366
|
selected: chainId === current,
|
|
2322
2367
|
isDropChain,
|
|
2323
|
-
relayFee: isDropChain ? null : _nullishCoalesce(_optionalChain([quoted, 'optionalAccess',
|
|
2324
|
-
amountIn: isDropChain ? null : _nullishCoalesce(_optionalChain([quoted, 'optionalAccess',
|
|
2368
|
+
relayFee: isDropChain ? null : _nullishCoalesce(_optionalChain([quoted, 'optionalAccess', _103 => _103.relayFee]), () => ( null)),
|
|
2369
|
+
amountIn: isDropChain ? null : _nullishCoalesce(_optionalChain([quoted, 'optionalAccess', _104 => _104.amountIn]), () => ( null)),
|
|
2325
2370
|
balance: balance && balance.chainId === chainId && chainId === current ? money3(balance.value, chainId) : null,
|
|
2326
2371
|
loading: !isDropChain && q === void 0,
|
|
2327
2372
|
select: () => select(chainId)
|
|
@@ -2363,14 +2408,14 @@ function PayWithPicker(props) {
|
|
|
2363
2408
|
// src/react/MintButton.ts
|
|
2364
2409
|
|
|
2365
2410
|
function defaultLabel(m) {
|
|
2366
|
-
const symbol = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([m, 'access',
|
|
2411
|
+
const symbol = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([m, 'access', _105 => _105.total, 'optionalAccess', _106 => _106.erc20, 'optionalAccess', _107 => _107.symbol]), () => ( _optionalChain([m, 'access', _108 => _108.total, 'optionalAccess', _109 => _109.native, 'access', _110 => _110.symbol]))), () => ( _optionalChain([m, 'access', _111 => _111.drop, 'optionalAccess', _112 => _112.unitPrice, 'access', _113 => _113.symbol]))), () => ( ""));
|
|
2367
2412
|
switch (m.state) {
|
|
2368
2413
|
case "loading":
|
|
2369
2414
|
return "Loading\u2026";
|
|
2370
2415
|
case "unsupported":
|
|
2371
2416
|
return "Unavailable";
|
|
2372
2417
|
case "upcoming": {
|
|
2373
|
-
const t = _optionalChain([m, 'access',
|
|
2418
|
+
const t = _optionalChain([m, 'access', _114 => _114.drop, 'optionalAccess', _115 => _115.startTime]);
|
|
2374
2419
|
return `Starts ${t ? new Date(t * 1e3).toLocaleString() : "soon"}`;
|
|
2375
2420
|
}
|
|
2376
2421
|
case "ended":
|
|
@@ -2383,8 +2428,8 @@ function defaultLabel(m) {
|
|
|
2383
2428
|
return "Connecting\u2026";
|
|
2384
2429
|
case "live": {
|
|
2385
2430
|
const route = m.route;
|
|
2386
|
-
if (_optionalChain([route, 'optionalAccess',
|
|
2387
|
-
return `Mint \xB7 ${route.amountIn.formatted} ${route.amountIn.symbol} on ${
|
|
2431
|
+
if (_optionalChain([route, 'optionalAccess', _116 => _116.kind]) === "relay") {
|
|
2432
|
+
return `Mint \xB7 ${route.amountIn.formatted} ${route.amountIn.symbol} on ${_chunkXWONUCGAcjs.chainName.call(void 0, route.originChainId)}`;
|
|
2388
2433
|
}
|
|
2389
2434
|
const total = m.total;
|
|
2390
2435
|
if (!total) return "Mint";
|
|
@@ -2394,8 +2439,8 @@ function defaultLabel(m) {
|
|
|
2394
2439
|
case "ineligible":
|
|
2395
2440
|
return "Not eligible";
|
|
2396
2441
|
case "insufficient-funds": {
|
|
2397
|
-
const erc20 = _optionalChain([m, 'access',
|
|
2398
|
-
const shortage = erc20 && m.message === `Not enough ${erc20.symbol} to cover the mint.` ? erc20.symbol : _nullishCoalesce(_optionalChain([m, 'access',
|
|
2442
|
+
const erc20 = _optionalChain([m, 'access', _117 => _117.total, 'optionalAccess', _118 => _118.erc20]);
|
|
2443
|
+
const shortage = erc20 && m.message === `Not enough ${erc20.symbol} to cover the mint.` ? erc20.symbol : _nullishCoalesce(_optionalChain([m, 'access', _119 => _119.total, 'optionalAccess', _120 => _120.native, 'access', _121 => _121.symbol]), () => ( symbol));
|
|
2399
2444
|
return `Insufficient ${shortage}`.trimEnd();
|
|
2400
2445
|
}
|
|
2401
2446
|
case "switching-chain":
|
|
@@ -2416,7 +2461,7 @@ function MintButton(props) {
|
|
|
2416
2461
|
const { className, labels, children, ...options } = props;
|
|
2417
2462
|
const m = useMint(options);
|
|
2418
2463
|
if (typeof children === "function") return children(m);
|
|
2419
|
-
const label = _nullishCoalesce(_optionalChain([labels, 'optionalAccess',
|
|
2464
|
+
const label = _nullishCoalesce(_optionalChain([labels, 'optionalAccess', _122 => _122[m.state]]), () => ( defaultLabel(m)));
|
|
2420
2465
|
return _react.createElement.call(void 0,
|
|
2421
2466
|
"button",
|
|
2422
2467
|
{
|
|
@@ -2433,7 +2478,7 @@ function MintButton(props) {
|
|
|
2433
2478
|
}
|
|
2434
2479
|
|
|
2435
2480
|
// src/index.ts
|
|
2436
|
-
var VERSION = "0.
|
|
2481
|
+
var VERSION = "0.5.0";
|
|
2437
2482
|
|
|
2438
2483
|
|
|
2439
2484
|
|
|
@@ -2446,5 +2491,5 @@ var VERSION = "0.4.0";
|
|
|
2446
2491
|
|
|
2447
2492
|
|
|
2448
2493
|
|
|
2449
|
-
exports.CLICKABLE_STATES =
|
|
2494
|
+
exports.CLICKABLE_STATES = _chunkYGBIJOKQcjs.CLICKABLE_STATES; exports.MAX_QUANTITY = _chunkYGBIJOKQcjs.MAX_QUANTITY; exports.MINT_STATES = _chunkYGBIJOKQcjs.MINT_STATES; exports.MintButton = MintButton; exports.MintError = _chunkXWONUCGAcjs.MintError; exports.PayWithPicker = PayWithPicker; exports.REASON_CODES = _chunkXWONUCGAcjs.REASON_CODES; exports.VERSION = VERSION; exports.isMintError = _chunkXWONUCGAcjs.isMintError; exports.useMint = useMint; exports.usePayOptions = usePayOptions;
|
|
2450
2495
|
//# sourceMappingURL=index.cjs.map
|