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