@manifoldxyz/dropkit 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -0
- package/dist/cart.cjs +38 -36
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.js +12 -10
- package/dist/cart.js.map +1 -1
- package/dist/{chunk-MXKJAZDW.js → chunk-VHAAGH7Z.js} +60 -642
- package/dist/chunk-VHAAGH7Z.js.map +1 -0
- package/dist/chunk-W7OBZPCY.js +619 -0
- package/dist/chunk-W7OBZPCY.js.map +1 -0
- package/dist/{chunk-X4P6BUV4.cjs → chunk-XWONUCGA.cjs} +46 -628
- package/dist/chunk-XWONUCGA.cjs.map +1 -0
- package/dist/chunk-YGBIJOKQ.cjs +619 -0
- package/dist/chunk-YGBIJOKQ.cjs.map +1 -0
- package/dist/index.cjs +125 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/dist/status.cjs +570 -0
- package/dist/status.cjs.map +1 -0
- package/dist/status.d.cts +259 -0
- package/dist/status.d.ts +259 -0
- package/dist/status.js +570 -0
- package/dist/status.js.map +1 -0
- package/package.json +11 -1
- package/dist/chunk-MXKJAZDW.js.map +0 -1
- package/dist/chunk-X4P6BUV4.cjs.map +0 -1
package/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
|
|
|
@@ -28,7 +29,8 @@
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
var _chunkXWONUCGAcjs = require('./chunk-XWONUCGA.cjs');
|
|
32
34
|
|
|
33
35
|
// src/react/useMint.ts
|
|
34
36
|
var _react = require('react');
|
|
@@ -71,7 +73,7 @@ function revertReason(errorData) {
|
|
|
71
73
|
function parseQuote(body, originChainId) {
|
|
72
74
|
const b = obj(body);
|
|
73
75
|
const steps = Array.isArray(b.steps) ? b.steps.map(obj) : [];
|
|
74
|
-
const unknownStep = () => new (0,
|
|
76
|
+
const unknownStep = () => new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Relay returned a route this button cannot execute.");
|
|
75
77
|
if (steps.length !== 1 || steps[0].kind !== "transaction") throw unknownStep();
|
|
76
78
|
const step = steps[0];
|
|
77
79
|
const rawItems = Array.isArray(step.items) ? step.items.map(obj) : [];
|
|
@@ -164,21 +166,21 @@ async function requestQuote(a) {
|
|
|
164
166
|
body: JSON.stringify(body)
|
|
165
167
|
}, RELAY_TIMEOUTS.quoteMs);
|
|
166
168
|
} catch (e) {
|
|
167
|
-
throw new (0,
|
|
169
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Could not reach Relay for a cross-chain quote.", { cause: e });
|
|
168
170
|
}
|
|
169
171
|
const json = res.json;
|
|
170
172
|
if (res.ok) return parseQuote(json, a.originChainId);
|
|
171
173
|
const j = obj(json);
|
|
172
174
|
if (j.errorCode === "DESTINATION_TX_FAILED") {
|
|
173
175
|
const reason = revertReason(j.errorData);
|
|
174
|
-
throw new (0,
|
|
176
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", reason || "The mint would fail on the drop network.", { cause: json, domain: "relay" });
|
|
175
177
|
}
|
|
176
178
|
if (res.status === 401 || j.errorCode === "UNAUTHORIZED_QUOTE") {
|
|
177
179
|
console.warn("dropkit: Relay rejected the quote (401 UNAUTHORIZED_QUOTE). Relay gates quotes that carry a referrer or need an API key.");
|
|
178
|
-
throw new (0,
|
|
180
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_UNAVAILABLE", "Relay refused the cross-chain quote.", { cause: json });
|
|
179
181
|
}
|
|
180
|
-
if (res.status === 429) throw new (0,
|
|
181
|
-
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 });
|
|
182
184
|
}
|
|
183
185
|
function getQuote(a) {
|
|
184
186
|
const k = cacheKey(a);
|
|
@@ -337,7 +339,7 @@ var stacksAbi = [
|
|
|
337
339
|
var HASH = /^0x[0-9a-fA-F]{64}$/;
|
|
338
340
|
var UINT = /^\d+$/;
|
|
339
341
|
var MAX_UINT256 = 2n ** 256n - 1n;
|
|
340
|
-
var unavailable = (message, cause) => new (0,
|
|
342
|
+
var unavailable = (message, cause) => new (0, _chunkXWONUCGAcjs.MintError)("ALLOWLIST_UNAVAILABLE", message, cause === void 0 ? void 0 : { cause });
|
|
341
343
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
342
344
|
var hashWallet = (wallet) => _viem.keccak256.call(void 0, _viem.encodeAbiParameters.call(void 0, [{ type: "address" }], [_viem.getAddress.call(void 0, wallet)]));
|
|
343
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]))]));
|
|
@@ -446,14 +448,14 @@ async function fetchAndParse(fetchFn, url, signal) {
|
|
|
446
448
|
} catch (cause) {
|
|
447
449
|
throw unavailable("Could not reach the allowlist file.", cause);
|
|
448
450
|
}
|
|
449
|
-
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.");
|
|
450
452
|
if (!res.ok) throw unavailable(`The allowlist file is not available (HTTP ${res.status}).`);
|
|
451
453
|
let body;
|
|
452
454
|
try {
|
|
453
455
|
const text = await readCapped(res);
|
|
454
456
|
body = JSON.parse(text);
|
|
455
457
|
} catch (cause) {
|
|
456
|
-
if (cause instanceof
|
|
458
|
+
if (cause instanceof _chunkXWONUCGAcjs.MintError) throw cause;
|
|
457
459
|
throw unavailable("The allowlist file could not be read.", cause);
|
|
458
460
|
}
|
|
459
461
|
return parseAllowlist(body);
|
|
@@ -464,7 +466,7 @@ async function download(fetchFn, url, signal) {
|
|
|
464
466
|
const stopped = new Promise((_, reject) => {
|
|
465
467
|
onAbort = () => {
|
|
466
468
|
const reason = controller.signal.reason;
|
|
467
|
-
reject(reason instanceof
|
|
469
|
+
reject(reason instanceof _chunkXWONUCGAcjs.MintError ? reason : unavailable("The allowlist request was cancelled.", reason));
|
|
468
470
|
};
|
|
469
471
|
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
470
472
|
});
|
|
@@ -511,7 +513,7 @@ var FALLBACK_GAS_BASE = 150000n;
|
|
|
511
513
|
var FALLBACK_GAS_PER_TOKEN = 150000n;
|
|
512
514
|
var details = /* @__PURE__ */ new WeakMap();
|
|
513
515
|
function bad(field, message) {
|
|
514
|
-
throw new (0,
|
|
516
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} ${message}`, { field });
|
|
515
517
|
}
|
|
516
518
|
function validateTlStacksConfig(config) {
|
|
517
519
|
if (!Number.isInteger(config.chainId) || config.chainId <= 0) bad("chainId", "must be a positive integer");
|
|
@@ -545,8 +547,8 @@ function io(ctx, start) {
|
|
|
545
547
|
}
|
|
546
548
|
var shortMessage = (e) => e instanceof _viem.BaseError ? e.shortMessage : e instanceof Error ? e.message : String(e);
|
|
547
549
|
function rpcError(e) {
|
|
548
|
-
if (
|
|
549
|
-
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 });
|
|
550
552
|
}
|
|
551
553
|
async function readStacks(ctx, config, functionName, args = []) {
|
|
552
554
|
try {
|
|
@@ -555,9 +557,9 @@ async function readStacks(ctx, config, functionName, args = []) {
|
|
|
555
557
|
() => ctx.client.readContract({ address: _viem.getAddress.call(void 0, config.stacks), abi: stacksAbi, functionName, args })
|
|
556
558
|
);
|
|
557
559
|
} catch (e) {
|
|
558
|
-
if (
|
|
560
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e) || isAbortError(e)) throw e;
|
|
559
561
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.ContractFunctionRevertedError || x instanceof _viem.ContractFunctionZeroDataError)) {
|
|
560
|
-
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}?`, {
|
|
561
563
|
field: "stacks",
|
|
562
564
|
cause: e
|
|
563
565
|
});
|
|
@@ -597,7 +599,7 @@ function nativeMeta(ctx) {
|
|
|
597
599
|
return { decimals: _nullishCoalesce(_optionalChain([n, 'optionalAccess', _28 => _28.decimals]), () => ( 18)), symbol: _nullishCoalesce(_optionalChain([n, 'optionalAccess', _29 => _29.symbol]), () => ( "ETH")) };
|
|
598
600
|
}
|
|
599
601
|
function seconds(v, field) {
|
|
600
|
-
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 });
|
|
601
603
|
return Number(v);
|
|
602
604
|
}
|
|
603
605
|
function priceFor(drop, phase) {
|
|
@@ -616,7 +618,7 @@ async function readDrop(ctx, config) {
|
|
|
616
618
|
]);
|
|
617
619
|
const phase = Number(phaseRaw);
|
|
618
620
|
if (phase === DROP_PHASE.NOT_CONFIGURED) {
|
|
619
|
-
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.");
|
|
620
622
|
}
|
|
621
623
|
if (drop.currencyAddress !== _viem.zeroAddress) {
|
|
622
624
|
bad("nftContract", `is sold for an ERC-20 (${drop.currencyAddress}). Dropkit supports drops priced in the native token only.`);
|
|
@@ -707,12 +709,12 @@ async function readWallet(ctx, config, { payer, recipient, quantity, drop }) {
|
|
|
707
709
|
}
|
|
708
710
|
const remaining = walletMax > minted ? walletMax - minted : 0n;
|
|
709
711
|
if (presale && ineligible === null) {
|
|
710
|
-
allowlistRemaining = Number(remaining < BigInt(
|
|
712
|
+
allowlistRemaining = Number(remaining < BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY) ? remaining : BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY));
|
|
711
713
|
if (remaining === 0n) ineligible = { reason: "ALLOWLIST_USED", message: `This wallet has already minted its allowlist allocation of ${walletMax}.` };
|
|
712
714
|
} else if (!presale && remaining === 0n) {
|
|
713
715
|
ineligible = { reason: "WALLET_LIMIT", message: `This wallet has already minted its limit of ${walletMax}.` };
|
|
714
716
|
}
|
|
715
|
-
const maxQuantity = Number(remaining < BigInt(
|
|
717
|
+
const maxQuantity = Number(remaining < BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY) ? remaining : BigInt(_chunkYGBIJOKQcjs.MAX_QUANTITY));
|
|
716
718
|
const data = { presaleNumberCanMint, proof, unitPrice: drop.unitPrice.value, unitFee: drop.unitFee.value };
|
|
717
719
|
const qty = BigInt(quantity);
|
|
718
720
|
const value = qty * (data.unitPrice + data.unitFee);
|
|
@@ -750,7 +752,7 @@ function encodePurchase(config, recipient, quantity, data) {
|
|
|
750
752
|
function walletData(wallet) {
|
|
751
753
|
const d = wallet.data;
|
|
752
754
|
if (!d || typeof d.presaleNumberCanMint !== "bigint" || typeof d.unitPrice !== "bigint" || typeof d.unitFee !== "bigint" || !Array.isArray(d.proof)) {
|
|
753
|
-
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.");
|
|
754
756
|
}
|
|
755
757
|
return d;
|
|
756
758
|
}
|
|
@@ -759,7 +761,7 @@ async function buildPlan(ctx, attempt, wallet) {
|
|
|
759
761
|
validateTlStacksConfig(config);
|
|
760
762
|
throwIfAborted(ctx);
|
|
761
763
|
if (!Number.isInteger(attempt.quantity) || attempt.quantity < 1) {
|
|
762
|
-
throw new (0,
|
|
764
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", "Choose at least one token to mint.");
|
|
763
765
|
}
|
|
764
766
|
const data = walletData(wallet);
|
|
765
767
|
const qty = BigInt(attempt.quantity);
|
|
@@ -795,26 +797,26 @@ function revertData(e) {
|
|
|
795
797
|
return null;
|
|
796
798
|
}
|
|
797
799
|
function decodeTlRevert(e) {
|
|
798
|
-
if (
|
|
800
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) return e;
|
|
799
801
|
if (isAbortError(e)) throw e;
|
|
800
802
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.InsufficientFundsError)) {
|
|
801
|
-
return new (0,
|
|
803
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("INSUFFICIENT_FUNDS", `The wallet cannot cover the mint: ${e.shortMessage}`, { cause: e });
|
|
802
804
|
}
|
|
803
805
|
const data = revertData(e);
|
|
804
806
|
if (data) {
|
|
805
807
|
try {
|
|
806
808
|
const { errorName, args } = _viem.decodeErrorResult.call(void 0, { abi: stacksAbi, data });
|
|
807
809
|
const known = TL_MESSAGES[errorName];
|
|
808
|
-
if (known) return new (0,
|
|
810
|
+
if (known) return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", known, { cause: e, domain: "tl-stacks" });
|
|
809
811
|
const shown = (_nullishCoalesce(args, () => ( []))).map(String).join(", ");
|
|
810
|
-
return new (0,
|
|
812
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", `Transient Labs rejected the mint (${errorName}(${shown})).`, { cause: e, domain: "tl-stacks" });
|
|
811
813
|
} catch (e3) {
|
|
812
|
-
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" });
|
|
813
815
|
}
|
|
814
816
|
}
|
|
815
817
|
const reverted = e instanceof _viem.BaseError && e.walk((x) => x.code === 3 || /execution reverted/i.test(x.message));
|
|
816
|
-
if (reverted) return new (0,
|
|
817
|
-
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 });
|
|
818
820
|
}
|
|
819
821
|
async function simulate(ctx, attempt, plan) {
|
|
820
822
|
throwIfAborted(ctx);
|
|
@@ -826,11 +828,11 @@ async function simulate(ctx, attempt, plan) {
|
|
|
826
828
|
readStacks(ctx, config, "protocolFee")
|
|
827
829
|
]);
|
|
828
830
|
if (drop.currencyAddress !== _viem.zeroAddress) {
|
|
829
|
-
throw new (0,
|
|
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" });
|
|
830
832
|
}
|
|
831
833
|
const current = BigInt(attempt.quantity) * (priceFor(drop, Number(phaseRaw)).unitPrice + fee);
|
|
832
834
|
if (current !== plan.mint.value) {
|
|
833
|
-
throw new (0,
|
|
835
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", TL_MESSAGES.InsufficientFunds, { domain: "tl-stacks" });
|
|
834
836
|
}
|
|
835
837
|
try {
|
|
836
838
|
await io(ctx, () => ctx.client.call({ account: attempt.payer, to: plan.mint.to, data: plan.mint.data, value: plan.mint.value }));
|
|
@@ -898,7 +900,7 @@ var PLACEHOLDER_TOKEN = /\{[A-Za-z_]\w*\}/g;
|
|
|
898
900
|
var DISPLAY_AMOUNT = /^\d+(\.\d+)?$/;
|
|
899
901
|
var NUMERIC_TYPE = /^u?int\d*$/;
|
|
900
902
|
function bad2(field, message) {
|
|
901
|
-
throw new (0,
|
|
903
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} ${message}`, { field });
|
|
902
904
|
}
|
|
903
905
|
var isHexAddress = (a) => typeof a === "string" && _viem.isAddress.call(void 0, a, { strict: false });
|
|
904
906
|
function functionsNamed(abi, name) {
|
|
@@ -1113,7 +1115,7 @@ function validateOptional(abi, name, src, allowed) {
|
|
|
1113
1115
|
function varFor(token, vars) {
|
|
1114
1116
|
const key = token.slice(1, -1);
|
|
1115
1117
|
const v = vars[key];
|
|
1116
|
-
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`);
|
|
1117
1119
|
return typeof v === "string" ? _viem.getAddress.call(void 0, v) : v;
|
|
1118
1120
|
}
|
|
1119
1121
|
function fill(t, p, vars) {
|
|
@@ -1148,13 +1150,13 @@ function io2(ctx, start) {
|
|
|
1148
1150
|
});
|
|
1149
1151
|
}
|
|
1150
1152
|
function rpcError2(e) {
|
|
1151
|
-
if (
|
|
1152
|
-
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 });
|
|
1153
1155
|
}
|
|
1154
1156
|
function classifyReadError(e, field) {
|
|
1155
|
-
if (
|
|
1157
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e) || isAbortError2(e)) throw e;
|
|
1156
1158
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.ContractFunctionRevertedError || x instanceof _viem.ContractFunctionZeroDataError)) {
|
|
1157
|
-
throw new (0,
|
|
1159
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} read reverted or returned no data: ${e.shortMessage}`, { field, cause: e });
|
|
1158
1160
|
}
|
|
1159
1161
|
return rpcError2(e);
|
|
1160
1162
|
}
|
|
@@ -1167,8 +1169,8 @@ async function readCall(ctx, params, field) {
|
|
|
1167
1169
|
}
|
|
1168
1170
|
function toBigInt(v, field) {
|
|
1169
1171
|
const n = typeof v === "number" ? BigInt(v) : v;
|
|
1170
|
-
if (typeof n !== "bigint") throw new (0,
|
|
1171
|
-
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 });
|
|
1172
1174
|
return n;
|
|
1173
1175
|
}
|
|
1174
1176
|
async function readField(ctx, config, name, src, vars) {
|
|
@@ -1184,7 +1186,7 @@ async function readField(ctx, config, name, src, vars) {
|
|
|
1184
1186
|
}
|
|
1185
1187
|
const value = src.value;
|
|
1186
1188
|
if (typeof value === "bigint") return value;
|
|
1187
|
-
throw new (0,
|
|
1189
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${name} display units are only valid for price`, { field: name });
|
|
1188
1190
|
}
|
|
1189
1191
|
function tupleMembers(res, fn, index) {
|
|
1190
1192
|
if (Array.isArray(res)) return res;
|
|
@@ -1196,7 +1198,7 @@ function tupleMembers(res, fn, index) {
|
|
|
1196
1198
|
var optField = (ctx, config, name, src, vars) => src ? readField(ctx, config, name, src, vars) : Promise.resolve(null);
|
|
1197
1199
|
function toSeconds(v, field) {
|
|
1198
1200
|
if (v === null || v === 0n) return null;
|
|
1199
|
-
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 });
|
|
1200
1202
|
return Number(v);
|
|
1201
1203
|
}
|
|
1202
1204
|
function nativeMeta2(ctx) {
|
|
@@ -1213,14 +1215,14 @@ async function currencyMeta(ctx, config) {
|
|
|
1213
1215
|
readCall(ctx, { address: token, abi: ERC20_ABI, functionName: "decimals" }, field)
|
|
1214
1216
|
]);
|
|
1215
1217
|
if (typeof symbol !== "string" || typeof decimals !== "number") {
|
|
1216
|
-
throw new (0,
|
|
1218
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `${field} ${token} is not an ERC20 (symbol/decimals unreadable)`, { field });
|
|
1217
1219
|
}
|
|
1218
1220
|
return { token, decimals, symbol };
|
|
1219
1221
|
}
|
|
1220
1222
|
function parseDisplay(value, decimals) {
|
|
1221
1223
|
const frac = _nullishCoalesce(value.split(".")[1], () => ( ""));
|
|
1222
1224
|
if (frac.length > decimals) {
|
|
1223
|
-
throw new (0,
|
|
1225
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INVALID_CONFIG", `price.value "${value}" has more than ${decimals} decimal places`, { field: "price.value" });
|
|
1224
1226
|
}
|
|
1225
1227
|
return _viem.parseUnits.call(void 0, value, decimals);
|
|
1226
1228
|
}
|
|
@@ -1262,16 +1264,16 @@ function describeRevert(abi, data) {
|
|
|
1262
1264
|
}
|
|
1263
1265
|
}
|
|
1264
1266
|
function toSimulationError(e, abi) {
|
|
1265
|
-
if (
|
|
1267
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) return e;
|
|
1266
1268
|
if (isAbortError2(e)) throw e;
|
|
1267
1269
|
if (e instanceof _viem.BaseError && e.walk((x) => x instanceof _viem.InsufficientFundsError)) {
|
|
1268
|
-
return new (0,
|
|
1270
|
+
return new (0, _chunkXWONUCGAcjs.MintError)("INSUFFICIENT_FUNDS", `Payer cannot cover the mint: ${e.shortMessage}`, { cause: e });
|
|
1269
1271
|
}
|
|
1270
1272
|
const data = revertData2(e);
|
|
1271
|
-
if (data) return new (0,
|
|
1273
|
+
if (data) return new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", describeRevert(abi, data), { cause: e });
|
|
1272
1274
|
const isRevert = e instanceof _viem.BaseError && e.walk((x) => x.code === 3 || /execution reverted/i.test(x.message));
|
|
1273
|
-
if (isRevert) return new (0,
|
|
1274
|
-
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 });
|
|
1275
1277
|
}
|
|
1276
1278
|
async function simulateMint(ctx, config, call) {
|
|
1277
1279
|
try {
|
|
@@ -1285,8 +1287,8 @@ function encodeMint(config, vars) {
|
|
|
1285
1287
|
try {
|
|
1286
1288
|
return _viem.encodeFunctionData.call(void 0, { abi: [fn], functionName: fn.name, args: fillArgs(config.mint.args, fn.inputs, vars) });
|
|
1287
1289
|
} catch (e) {
|
|
1288
|
-
if (
|
|
1289
|
-
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 });
|
|
1290
1292
|
}
|
|
1291
1293
|
}
|
|
1292
1294
|
function mintValue(config, token, totalPrice) {
|
|
@@ -1342,7 +1344,7 @@ async function readWallet2(ctx, config, { payer, recipient, quantity, drop }) {
|
|
|
1342
1344
|
]);
|
|
1343
1345
|
const walletMax = rawMax === null || rawMax === 0n ? null : rawMax;
|
|
1344
1346
|
const remaining = walletMax === null ? null : walletMax > (_nullishCoalesce(walletMinted, () => ( 0n))) ? walletMax - (_nullishCoalesce(walletMinted, () => ( 0n))) : 0n;
|
|
1345
|
-
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));
|
|
1346
1348
|
let ineligible = null;
|
|
1347
1349
|
let gas = FALLBACK_MINT_GAS;
|
|
1348
1350
|
if (remaining === 0n) {
|
|
@@ -1355,7 +1357,7 @@ async function readWallet2(ctx, config, { payer, recipient, quantity, drop }) {
|
|
|
1355
1357
|
throw toSimulationError(e, config.abi);
|
|
1356
1358
|
});
|
|
1357
1359
|
} catch (e) {
|
|
1358
|
-
if (!
|
|
1360
|
+
if (!_chunkXWONUCGAcjs.isMintError.call(void 0, e) || e.reason !== "SIMULATION_REVERTED") throw e;
|
|
1359
1361
|
ineligible = { reason: "SIMULATION_REVERTED", message: e.message };
|
|
1360
1362
|
}
|
|
1361
1363
|
}
|
|
@@ -1425,7 +1427,7 @@ function configKeyOf(config) {
|
|
|
1425
1427
|
function adapterFor(config) {
|
|
1426
1428
|
switch (config.type) {
|
|
1427
1429
|
case "manifold-claim":
|
|
1428
|
-
return
|
|
1430
|
+
return _chunkXWONUCGAcjs.manifoldClaimAdapter;
|
|
1429
1431
|
case "contract":
|
|
1430
1432
|
return contractAdapter;
|
|
1431
1433
|
case "tl-stacks":
|
|
@@ -1450,12 +1452,12 @@ function routeChainOf(payChains, accountChainId, payChainId) {
|
|
|
1450
1452
|
var ROUTE_DEBOUNCE_MS = 500;
|
|
1451
1453
|
var symbolOf = (chainId) => {
|
|
1452
1454
|
try {
|
|
1453
|
-
return
|
|
1455
|
+
return _chunkXWONUCGAcjs.getChain.call(void 0, chainId).nativeCurrency.symbol;
|
|
1454
1456
|
} catch (e5) {
|
|
1455
1457
|
return "ETH";
|
|
1456
1458
|
}
|
|
1457
1459
|
};
|
|
1458
|
-
var shortOf = (chainId) => ({ chainId, symbol: symbolOf(chainId), name:
|
|
1460
|
+
var shortOf = (chainId) => ({ chainId, symbol: symbolOf(chainId), name: _chunkXWONUCGAcjs.chainName.call(void 0, chainId) });
|
|
1459
1461
|
function tokenContractOf(config) {
|
|
1460
1462
|
switch (config.type) {
|
|
1461
1463
|
case "manifold-claim":
|
|
@@ -1484,15 +1486,15 @@ function eventAddressOf(config) {
|
|
|
1484
1486
|
}
|
|
1485
1487
|
}
|
|
1486
1488
|
}
|
|
1487
|
-
var isUnsupported = (reason) =>
|
|
1489
|
+
var isUnsupported = (reason) => _chunkXWONUCGAcjs.UNSUPPORTED_REASONS.includes(reason);
|
|
1488
1490
|
function errorReasonOf(e) {
|
|
1489
|
-
const { reason, message } =
|
|
1491
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1490
1492
|
const ok = ["USER_REJECTED", "TX_REVERTED", "RATE_LIMITED", "RPC_ERROR", "CHAIN_SWITCH_FAILED", "ALLOWLIST_UNAVAILABLE"];
|
|
1491
1493
|
return { reason: ok.includes(reason) ? reason : "RPC_ERROR", message };
|
|
1492
1494
|
}
|
|
1493
1495
|
function explorerUrlFor(chainId, hash) {
|
|
1494
1496
|
try {
|
|
1495
|
-
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]);
|
|
1496
1498
|
return url ? `${url.replace(/\/$/, "")}/tx/${hash}` : null;
|
|
1497
1499
|
} catch (e6) {
|
|
1498
1500
|
return null;
|
|
@@ -1501,7 +1503,7 @@ function explorerUrlFor(chainId, hash) {
|
|
|
1501
1503
|
var receiptOk = (status) => status === "success" || status === 1 || status === 1n || status === "0x1";
|
|
1502
1504
|
function useMint(options) {
|
|
1503
1505
|
const { config, recipient, quantity: quantityProp, connect } = options;
|
|
1504
|
-
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 }));
|
|
1505
1507
|
const [widgetFail, setWidgetFail] = _react.useState.call(void 0, null);
|
|
1506
1508
|
const [widgetRetry, setWidgetRetry] = _react.useState.call(void 0, 0);
|
|
1507
1509
|
const configKey = configKeyOf(config);
|
|
@@ -1529,7 +1531,7 @@ function useMint(options) {
|
|
|
1529
1531
|
});
|
|
1530
1532
|
const dispatch = _react.useCallback.call(void 0, (event) => {
|
|
1531
1533
|
if (!mounted.current) return;
|
|
1532
|
-
stateRef.current =
|
|
1534
|
+
stateRef.current = _chunkYGBIJOKQcjs.reducer.call(void 0, stateRef.current, event);
|
|
1533
1535
|
rawDispatch(event);
|
|
1534
1536
|
}, []);
|
|
1535
1537
|
const emit = _react.useCallback.call(void 0, (type, over = {}) => {
|
|
@@ -1558,7 +1560,7 @@ function useMint(options) {
|
|
|
1558
1560
|
const rpcUrl = _optionalChain([propsRef, 'access', _55 => _55.current, 'access', _56 => _56.rpcUrls, 'optionalAccess', _57 => _57[cfg.chainId]]);
|
|
1559
1561
|
if (!life.client || life.rpcUrl !== rpcUrl) {
|
|
1560
1562
|
life.rpcUrl = rpcUrl;
|
|
1561
|
-
life.client =
|
|
1563
|
+
life.client = _chunkXWONUCGAcjs.createReadClient.call(void 0, { chainId: cfg.chainId, rpcUrls: propsRef.current.rpcUrls, useBridge: bridgeEnabled(cfg) });
|
|
1562
1564
|
}
|
|
1563
1565
|
return life.client;
|
|
1564
1566
|
}, []);
|
|
@@ -1580,7 +1582,7 @@ function useMint(options) {
|
|
|
1580
1582
|
dispatch({ type: "DROP_LOADED", gen, drop, now: Math.max(stateRef.current.now, nowSec()) });
|
|
1581
1583
|
} catch (e) {
|
|
1582
1584
|
if (life.controller.signal.aborted || life.gen !== gen || lifeRef.current !== life) return;
|
|
1583
|
-
const { reason, message } =
|
|
1585
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1584
1586
|
if (isUnsupported(reason)) dispatch({ type: "DROP_UNSUPPORTED", gen, reason, message });
|
|
1585
1587
|
else dispatch({ type: "READ_FAILED", gen, ...errorReasonOf(e) });
|
|
1586
1588
|
}
|
|
@@ -1617,7 +1619,7 @@ function useMint(options) {
|
|
|
1617
1619
|
);
|
|
1618
1620
|
const refresh = _react.useCallback.call(void 0, () => refreshNow("refresh"), [refreshNow]);
|
|
1619
1621
|
const isBusy = _react.useCallback.call(void 0,
|
|
1620
|
-
() => 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),
|
|
1621
1623
|
[]
|
|
1622
1624
|
);
|
|
1623
1625
|
const executeAttempt = _react.useCallback.call(void 0,
|
|
@@ -1633,20 +1635,20 @@ function useMint(options) {
|
|
|
1633
1635
|
};
|
|
1634
1636
|
const assertPayer = () => {
|
|
1635
1637
|
assertActive();
|
|
1636
|
-
const live =
|
|
1638
|
+
const live = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
1637
1639
|
if (!live || live.address.toLowerCase() !== attempt.payer.toLowerCase()) {
|
|
1638
|
-
throw new (0,
|
|
1640
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("USER_REJECTED", "The connected wallet changed before the transaction was sent.");
|
|
1639
1641
|
}
|
|
1640
1642
|
};
|
|
1641
1643
|
let wallet2 = null;
|
|
1642
1644
|
const walletFor = () => {
|
|
1643
|
-
if (!wallet2) wallet2 =
|
|
1645
|
+
if (!wallet2) wallet2 = _chunkYGBIJOKQcjs.getWalletClient.call(void 0, attempt.chainId);
|
|
1644
1646
|
return wallet2;
|
|
1645
1647
|
};
|
|
1646
1648
|
const submit = async (tx) => {
|
|
1647
1649
|
assertPayer();
|
|
1648
1650
|
const w = walletFor();
|
|
1649
|
-
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) });
|
|
1650
1652
|
};
|
|
1651
1653
|
const waitReceipt = async (hash2) => {
|
|
1652
1654
|
let cancelled = false;
|
|
@@ -1663,19 +1665,19 @@ function useMint(options) {
|
|
|
1663
1665
|
receipt2 = await client.waitForTransactionReceipt(params);
|
|
1664
1666
|
} catch (e) {
|
|
1665
1667
|
assertActive();
|
|
1666
|
-
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.");
|
|
1667
1669
|
if (await walletFor().getChainId() !== attempt.chainId) throw e;
|
|
1668
1670
|
assertActive();
|
|
1669
1671
|
receipt2 = await walletFor().extend(_viem.publicActions).waitForTransactionReceipt(params);
|
|
1670
1672
|
}
|
|
1671
1673
|
assertActive();
|
|
1672
|
-
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.");
|
|
1673
1675
|
return receipt2;
|
|
1674
1676
|
};
|
|
1675
1677
|
assertPayer();
|
|
1676
1678
|
if (account2.chainId !== attempt.chainId) {
|
|
1677
1679
|
dispatch({ type: "SWITCHING_CHAIN", attemptId: attempt.attemptId });
|
|
1678
|
-
await
|
|
1680
|
+
await _chunkYGBIJOKQcjs.switchToChain.call(void 0, attempt.chainId);
|
|
1679
1681
|
}
|
|
1680
1682
|
assertPayer();
|
|
1681
1683
|
let plan = await adapter.buildPlan(ctx, attempt, walletRead);
|
|
@@ -1685,13 +1687,13 @@ function useMint(options) {
|
|
|
1685
1687
|
try {
|
|
1686
1688
|
const simulated = await client.call({ account: attempt.payer, to: a.tx.to, data: a.tx.data, value: a.tx.value });
|
|
1687
1689
|
if (simulated.data && simulated.data !== "0x" && BigInt(simulated.data) === 0n) {
|
|
1688
|
-
throw new (0,
|
|
1690
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", "The token refused the approval.");
|
|
1689
1691
|
}
|
|
1690
1692
|
} catch (e) {
|
|
1691
|
-
if (
|
|
1693
|
+
if (_chunkXWONUCGAcjs.isMintError.call(void 0, e)) throw e;
|
|
1692
1694
|
const reverted = e instanceof _viem.BaseError ? e.walk((cause) => cause instanceof _viem.ExecutionRevertedError) : null;
|
|
1693
1695
|
if (reverted instanceof _viem.ExecutionRevertedError) {
|
|
1694
|
-
throw new (0,
|
|
1696
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("SIMULATION_REVERTED", reverted.shortMessage);
|
|
1695
1697
|
}
|
|
1696
1698
|
throw e;
|
|
1697
1699
|
}
|
|
@@ -1703,7 +1705,7 @@ function useMint(options) {
|
|
|
1703
1705
|
const approveReceipt = await waitReceipt(approveHash);
|
|
1704
1706
|
assertActive();
|
|
1705
1707
|
if (!receiptOk(approveReceipt.status)) {
|
|
1706
|
-
throw new (0,
|
|
1708
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("TX_REVERTED", `The approval transaction reverted (${approveHash}).`);
|
|
1707
1709
|
}
|
|
1708
1710
|
const freshDrop = await adapter.readDrop(ctx, cfg);
|
|
1709
1711
|
assertActive();
|
|
@@ -1714,11 +1716,11 @@ function useMint(options) {
|
|
|
1714
1716
|
drop: freshDrop
|
|
1715
1717
|
});
|
|
1716
1718
|
assertPayer();
|
|
1717
|
-
let checked =
|
|
1718
|
-
checked =
|
|
1719
|
-
checked =
|
|
1720
|
-
if (checked.name !== "live" || (_nullishCoalesce(
|
|
1721
|
-
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.")));
|
|
1722
1724
|
}
|
|
1723
1725
|
plan = await adapter.buildPlan(ctx, attempt, freshWallet);
|
|
1724
1726
|
assertPayer();
|
|
@@ -1727,7 +1729,7 @@ function useMint(options) {
|
|
|
1727
1729
|
assertPayer();
|
|
1728
1730
|
dispatch({ type: "MINT_PROMPTED", attemptId: attempt.attemptId });
|
|
1729
1731
|
const hash = await submit(plan.mint);
|
|
1730
|
-
if (cfg.type === "manifold-claim") void
|
|
1732
|
+
if (cfg.type === "manifold-claim") void _chunkYGBIJOKQcjs.recordClaimMint.call(void 0, { instanceId: cfg.instanceId, hash });
|
|
1731
1733
|
assertActive();
|
|
1732
1734
|
dispatch({ type: "TX_SUBMITTED", attemptId: attempt.attemptId });
|
|
1733
1735
|
emit("tx-submitted", { state: "confirming", reason: null, txHash: hash, quantity: attempt.quantity, chainId: attempt.chainId });
|
|
@@ -1735,9 +1737,9 @@ function useMint(options) {
|
|
|
1735
1737
|
assertActive();
|
|
1736
1738
|
const confirmedHash = _nullishCoalesce(receipt.transactionHash, () => ( hash));
|
|
1737
1739
|
if (!receiptOk(receipt.status)) {
|
|
1738
|
-
throw new (0,
|
|
1740
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("TX_REVERTED", `The mint transaction reverted (${confirmedHash}).`);
|
|
1739
1741
|
}
|
|
1740
|
-
const tokens =
|
|
1742
|
+
const tokens = _chunkYGBIJOKQcjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), {
|
|
1741
1743
|
tokenContract: _nullishCoalesce(plan.tokenContract, () => ( attempt.tokenContract)),
|
|
1742
1744
|
recipient: attempt.recipient
|
|
1743
1745
|
});
|
|
@@ -1758,29 +1760,29 @@ function useMint(options) {
|
|
|
1758
1760
|
};
|
|
1759
1761
|
const outcome = await pollUntilTerminal({ testnet: out.testnet, requestId: out.requestId, signal: life.controller.signal, assertActive });
|
|
1760
1762
|
assertActive();
|
|
1761
|
-
const where =
|
|
1763
|
+
const where = _chunkXWONUCGAcjs.chainName.call(void 0, out.originChainId);
|
|
1762
1764
|
if (outcome.kind === "timeout") {
|
|
1763
|
-
throw new (0,
|
|
1765
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_TIMEOUT", "The bridge is still processing. Your mint may still complete.");
|
|
1764
1766
|
}
|
|
1765
1767
|
const key = outstandingKey(attempt.config, attempt.payer);
|
|
1766
1768
|
const { status } = outcome;
|
|
1767
1769
|
if (status.status !== "success") clearOutstanding(key);
|
|
1768
1770
|
if (status.status === "refund") {
|
|
1769
|
-
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}.`);
|
|
1770
1772
|
}
|
|
1771
1773
|
if (status.status === "failure") {
|
|
1772
1774
|
const why = status.failReason ? ` (${status.failReason})` : "";
|
|
1773
1775
|
const noRefund = status.refundFailReason ? ` No automatic refund was sent. Contact support with Relay request ${out.requestId}.` : "";
|
|
1774
|
-
throw new (0,
|
|
1776
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("BRIDGE_FAILED", `Relay could not complete the mint paid on ${where}${why}.${noRefund}`);
|
|
1775
1777
|
}
|
|
1776
1778
|
const fillHash = _nullishCoalesce(status.txHashes[0], () => ( null));
|
|
1777
|
-
if (fillHash && cfg.type === "manifold-claim") void
|
|
1779
|
+
if (fillHash && cfg.type === "manifold-claim") void _chunkYGBIJOKQcjs.recordClaimMint.call(void 0, { instanceId: cfg.instanceId, hash: fillHash });
|
|
1778
1780
|
let tokens = [];
|
|
1779
1781
|
if (fillHash) {
|
|
1780
1782
|
try {
|
|
1781
1783
|
const receipt = await client.waitForTransactionReceipt({ hash: fillHash, confirmations: 1, timeout: 6e4 });
|
|
1782
1784
|
if (receiptOk(receipt.status)) {
|
|
1783
|
-
tokens =
|
|
1785
|
+
tokens = _chunkYGBIJOKQcjs.parseMintReceipt.call(void 0, _nullishCoalesce(receipt.logs, () => ( [])), { tokenContract: attempt.tokenContract, recipient: attempt.recipient });
|
|
1784
1786
|
}
|
|
1785
1787
|
} catch (e8) {
|
|
1786
1788
|
}
|
|
@@ -1811,19 +1813,19 @@ function useMint(options) {
|
|
|
1811
1813
|
if (!mounted.current || life.controller.signal.aborted || lifeRef.current !== life || attemptRef.current !== attempt) {
|
|
1812
1814
|
throw new DOMException("Mint attempt cancelled", "AbortError");
|
|
1813
1815
|
}
|
|
1814
|
-
const live =
|
|
1816
|
+
const live = _chunkYGBIJOKQcjs.getAccount.call(void 0, );
|
|
1815
1817
|
if (!live || live.address.toLowerCase() !== attempt.payer.toLowerCase()) {
|
|
1816
|
-
throw new (0,
|
|
1818
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("USER_REJECTED", "The connected wallet changed before the transaction was sent.");
|
|
1817
1819
|
}
|
|
1818
1820
|
};
|
|
1819
1821
|
assertPayer();
|
|
1820
1822
|
if (account2.chainId !== origin) {
|
|
1821
1823
|
dispatch({ type: "SWITCHING_CHAIN", attemptId: attempt.attemptId });
|
|
1822
|
-
await
|
|
1824
|
+
await _chunkYGBIJOKQcjs.switchToChain.call(void 0, origin);
|
|
1823
1825
|
}
|
|
1824
1826
|
assertPayer();
|
|
1825
1827
|
const plan = await adapter.buildPlan(ctx, attempt, walletRead);
|
|
1826
|
-
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.");
|
|
1827
1829
|
assertPayer();
|
|
1828
1830
|
const quote = await getQuote({
|
|
1829
1831
|
testnet,
|
|
@@ -1836,18 +1838,18 @@ function useMint(options) {
|
|
|
1836
1838
|
signal: life.controller.signal
|
|
1837
1839
|
});
|
|
1838
1840
|
assertPayer();
|
|
1839
|
-
const balance = await
|
|
1841
|
+
const balance = await _chunkYGBIJOKQcjs.getConnectedBalance.call(void 0, attempt.payer, origin);
|
|
1840
1842
|
if (balance < quote.amountIn.value + quote.originGas.value) {
|
|
1841
1843
|
const s = shortOf(origin);
|
|
1842
|
-
throw new (0,
|
|
1844
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("INSUFFICIENT_FUNDS", `Not enough ${s.symbol} on ${s.name}. Pick another network to pay from.`);
|
|
1843
1845
|
}
|
|
1844
1846
|
assertPayer();
|
|
1845
1847
|
const item = quote.items[0];
|
|
1846
1848
|
const key = outstandingKey(cfg, attempt.payer);
|
|
1847
|
-
const wallet2 =
|
|
1849
|
+
const wallet2 = _chunkYGBIJOKQcjs.getWalletClient.call(void 0, origin);
|
|
1848
1850
|
assertPayer();
|
|
1849
1851
|
if (!claimDeposit(key)) {
|
|
1850
|
-
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.");
|
|
1851
1853
|
}
|
|
1852
1854
|
let out;
|
|
1853
1855
|
try {
|
|
@@ -1859,7 +1861,7 @@ function useMint(options) {
|
|
|
1859
1861
|
data: item.data,
|
|
1860
1862
|
value: item.value,
|
|
1861
1863
|
...item.gas !== null && item.gas > 0n ? { gas: item.gas } : {},
|
|
1862
|
-
chain:
|
|
1864
|
+
chain: _chunkXWONUCGAcjs.getChain.call(void 0, origin)
|
|
1863
1865
|
});
|
|
1864
1866
|
out = { requestId: quote.requestId, testnet, originChainId: origin, originTxHash: originTxHash2, attempt };
|
|
1865
1867
|
setOutstanding(key, out);
|
|
@@ -1870,10 +1872,10 @@ function useMint(options) {
|
|
|
1870
1872
|
autoResumedRef.current.add(key);
|
|
1871
1873
|
dispatch({ type: "TX_SUBMITTED", attemptId: attempt.attemptId });
|
|
1872
1874
|
emit("tx-submitted", { state: "confirming", reason: null, txHash: originTxHash, quantity: attempt.quantity, chainId: cfg.chainId });
|
|
1873
|
-
const deposit = await
|
|
1875
|
+
const deposit = await _chunkYGBIJOKQcjs.waitForDeposit.call(void 0, origin, originTxHash);
|
|
1874
1876
|
if (deposit === "reverted") {
|
|
1875
1877
|
clearOutstanding(key);
|
|
1876
|
-
throw new (0,
|
|
1878
|
+
throw new (0, _chunkXWONUCGAcjs.MintError)("TX_REVERTED", `The payment transaction reverted (${originTxHash}).`);
|
|
1877
1879
|
}
|
|
1878
1880
|
await finishRelay(attempt, out, life);
|
|
1879
1881
|
},
|
|
@@ -1890,7 +1892,7 @@ function useMint(options) {
|
|
|
1890
1892
|
await finishRelay(attempt, out, life);
|
|
1891
1893
|
} catch (e) {
|
|
1892
1894
|
if (!mounted.current || life.controller.signal.aborted || lifeRef.current !== life) return;
|
|
1893
|
-
const { reason, message } =
|
|
1895
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1894
1896
|
dispatch({ type: "ATTEMPT_FAILED", attemptId: attempt.attemptId, reason, message });
|
|
1895
1897
|
emit("error", { quantity: attempt.quantity, chainId: attempt.chainId });
|
|
1896
1898
|
} finally {
|
|
@@ -1911,7 +1913,7 @@ function useMint(options) {
|
|
|
1911
1913
|
return;
|
|
1912
1914
|
}
|
|
1913
1915
|
const s = stateRef.current;
|
|
1914
|
-
if (!
|
|
1916
|
+
if (!_chunkYGBIJOKQcjs.canAct.call(void 0, s) || s.attempt !== null) return;
|
|
1915
1917
|
if (s.name === "disconnected") {
|
|
1916
1918
|
if (connectingRef.current) return;
|
|
1917
1919
|
connectingRef.current = true;
|
|
@@ -1921,12 +1923,12 @@ function useMint(options) {
|
|
|
1921
1923
|
try {
|
|
1922
1924
|
await widgetLoadRef.current;
|
|
1923
1925
|
if (!active()) return;
|
|
1924
|
-
const outcome = await
|
|
1926
|
+
const outcome = await _chunkYGBIJOKQcjs.openConnectModal.call(void 0, );
|
|
1925
1927
|
if (!active()) return;
|
|
1926
1928
|
connectingRef.current = false;
|
|
1927
1929
|
if (outcome === "connected") {
|
|
1928
1930
|
accountKeyRef.current = null;
|
|
1929
|
-
_optionalChain([pushAccountRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65(
|
|
1931
|
+
_optionalChain([pushAccountRef, 'access', _64 => _64.current, 'optionalCall', _65 => _65(_chunkYGBIJOKQcjs.getAccount.call(void 0, ))]);
|
|
1930
1932
|
} else dispatch({ type: "CONNECT_DISMISSED" });
|
|
1931
1933
|
} catch (e9) {
|
|
1932
1934
|
if (active()) dispatch({ type: "CONNECT_DISMISSED" });
|
|
@@ -1975,7 +1977,7 @@ function useMint(options) {
|
|
|
1975
1977
|
else await executeAttempt(attempt, walletRead, life, account2);
|
|
1976
1978
|
} catch (e) {
|
|
1977
1979
|
if (!mounted.current || life.controller.signal.aborted || lifeRef.current !== life) return;
|
|
1978
|
-
const { reason, message } =
|
|
1980
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
1979
1981
|
dispatch({ type: "ATTEMPT_FAILED", attemptId: attempt.attemptId, reason, message });
|
|
1980
1982
|
emit("error", { quantity: attempt.quantity, chainId: attempt.chainId });
|
|
1981
1983
|
} finally {
|
|
@@ -2004,8 +2006,8 @@ function useMint(options) {
|
|
|
2004
2006
|
dispatch({ type: "ACCOUNT_CHANGED", account: a });
|
|
2005
2007
|
};
|
|
2006
2008
|
pushAccountRef.current = push;
|
|
2007
|
-
push(
|
|
2008
|
-
const unsubscribe =
|
|
2009
|
+
push(_chunkYGBIJOKQcjs.getAccount.call(void 0, ));
|
|
2010
|
+
const unsubscribe = _chunkYGBIJOKQcjs.subscribeAccount.call(void 0, push);
|
|
2009
2011
|
return () => {
|
|
2010
2012
|
unsubscribe();
|
|
2011
2013
|
};
|
|
@@ -2015,13 +2017,13 @@ function useMint(options) {
|
|
|
2015
2017
|
if (isBusy() || recipientRef.current === recipient) return;
|
|
2016
2018
|
recipientRef.current = recipient;
|
|
2017
2019
|
accountKeyRef.current = null;
|
|
2018
|
-
_optionalChain([pushAccountRef, 'access', _74 => _74.current, 'optionalCall', _75 => _75(
|
|
2020
|
+
_optionalChain([pushAccountRef, 'access', _74 => _74.current, 'optionalCall', _75 => _75(_chunkYGBIJOKQcjs.getAccount.call(void 0, ))]);
|
|
2019
2021
|
}, [recipient, machine.attempt, isBusy]);
|
|
2020
2022
|
const projectId = _optionalChain([connect, 'optionalAccess', _76 => _76.walletConnectProjectId]);
|
|
2021
2023
|
const widgetChains = [config.chainId, ...payChainsOf(config, options.crossChain).filter((id) => id !== config.chainId)].join(",");
|
|
2022
2024
|
_react.useEffect.call(void 0, () => {
|
|
2023
2025
|
let alive = true;
|
|
2024
|
-
const loading =
|
|
2026
|
+
const loading = _chunkYGBIJOKQcjs.loadConnectWidget.call(void 0, { chainIds: widgetChains.split(",").map(Number), ...projectId ? { walletConnectProjectId: projectId } : {} });
|
|
2025
2027
|
widgetLoadRef.current = loading;
|
|
2026
2028
|
loading.then(
|
|
2027
2029
|
() => {
|
|
@@ -2029,7 +2031,7 @@ function useMint(options) {
|
|
|
2029
2031
|
},
|
|
2030
2032
|
(e) => {
|
|
2031
2033
|
if (!alive) return;
|
|
2032
|
-
const { reason, message } =
|
|
2034
|
+
const { reason, message } = _chunkXWONUCGAcjs.toReason.call(void 0, e);
|
|
2033
2035
|
setWidgetFail({ reason, message });
|
|
2034
2036
|
}
|
|
2035
2037
|
);
|
|
@@ -2100,7 +2102,7 @@ function useMint(options) {
|
|
|
2100
2102
|
drop
|
|
2101
2103
|
});
|
|
2102
2104
|
if (!alive || life.controller.signal.aborted || lifeRef.current !== life || life.gen !== readGen) return;
|
|
2103
|
-
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;
|
|
2104
2106
|
const fullRead = { ...read, ineligible };
|
|
2105
2107
|
const payChains = payChainsOf(cfg, propsRef.current.crossChain);
|
|
2106
2108
|
const crossChain = payChains.length > 0 && ineligible === null && (_nullishCoalesce(_optionalChain([adapter, 'access', _84 => _84.supportsRelay, 'optionalCall', _85 => _85(drop)]), () => ( false)));
|
|
@@ -2148,7 +2150,7 @@ function useMint(options) {
|
|
|
2148
2150
|
if (routeChain !== account.chainId) {
|
|
2149
2151
|
route = relay;
|
|
2150
2152
|
} else {
|
|
2151
|
-
const balance = await
|
|
2153
|
+
const balance = await _chunkYGBIJOKQcjs.getConnectedBalance.call(void 0, account.address, routeChain);
|
|
2152
2154
|
if (balance >= quote.amountIn.value + quote.originGas.value) route = relay;
|
|
2153
2155
|
else short = shortOf(routeChain);
|
|
2154
2156
|
}
|
|
@@ -2174,7 +2176,7 @@ function useMint(options) {
|
|
|
2174
2176
|
const state = stateRef.current;
|
|
2175
2177
|
if (!propChanged && state.account && !state.walletRead) return;
|
|
2176
2178
|
const event = { type: "SET_QUANTITY", quantity: quantityProp };
|
|
2177
|
-
const clamped =
|
|
2179
|
+
const clamped = _chunkYGBIJOKQcjs.reducer.call(void 0, state, event).quantity;
|
|
2178
2180
|
if (clamped !== state.quantity) dispatch(event);
|
|
2179
2181
|
if (clamped !== quantityProp) _optionalChain([propsRef, 'access', _86 => _86.current, 'access', _87 => _87.onQuantityChange, 'optionalCall', _88 => _88(clamped)]);
|
|
2180
2182
|
}, [quantityProp, machine.quantity, machine.drop, machine.walletRead, machine.attempt, dispatch, isBusy]);
|
|
@@ -2233,7 +2235,7 @@ function useMint(options) {
|
|
|
2233
2235
|
const setQuantity = _react.useCallback.call(void 0,
|
|
2234
2236
|
(next) => {
|
|
2235
2237
|
const s = stateRef.current;
|
|
2236
|
-
const max = _nullishCoalesce(
|
|
2238
|
+
const max = _nullishCoalesce(_chunkYGBIJOKQcjs.selectMaxQuantity.call(void 0, s), () => ( 65535));
|
|
2237
2239
|
const clamped = Math.max(1, Math.min(Math.floor(Number.isNaN(next) ? 1 : next), max));
|
|
2238
2240
|
const handler = propsRef.current.onQuantityChange;
|
|
2239
2241
|
if (handler) {
|
|
@@ -2268,13 +2270,13 @@ function useMint(options) {
|
|
|
2268
2270
|
wallet,
|
|
2269
2271
|
quantity: machine.quantity,
|
|
2270
2272
|
setQuantity,
|
|
2271
|
-
maxQuantity:
|
|
2272
|
-
total:
|
|
2273
|
+
maxQuantity: _chunkYGBIJOKQcjs.selectMaxQuantity.call(void 0, machine),
|
|
2274
|
+
total: _chunkYGBIJOKQcjs.selectTotal.call(void 0, machine),
|
|
2273
2275
|
mint,
|
|
2274
2276
|
result: machine.result,
|
|
2275
2277
|
refresh,
|
|
2276
2278
|
// An attempt claimed by a click is not clickable, even while the reducer still reads 'live'.
|
|
2277
|
-
canAct:
|
|
2279
|
+
canAct: _chunkYGBIJOKQcjs.canAct.call(void 0, { ...machine, name: effective.name }) && machine.attempt === null,
|
|
2278
2280
|
// Short on the wallet chain is neither route: nothing can be paid until the collector picks another chain.
|
|
2279
2281
|
route: _nullishCoalesce(machine.route, () => ( (machine.walletRead && machine.drop && !machine.routePending && machine.short === null ? { kind: "direct", chainId: machine.drop.chainId } : null))),
|
|
2280
2282
|
crossChain: machine.crossChain && machine.account && _optionalChain([crossChainInfo, 'optionalAccess', _95 => _95.gen]) === machine.walletGen ? crossChainInfo.info : null
|
|
@@ -2288,7 +2290,7 @@ var PICKER_REFRESH_MS = 2e4;
|
|
|
2288
2290
|
var PICKER_DEBOUNCE_MS = 500;
|
|
2289
2291
|
var RELAY_REASONS = /* @__PURE__ */ new Set(["BRIDGE_UNAVAILABLE", "BRIDGE_TIMEOUT", "BRIDGE_REFUNDED", "BRIDGE_FAILED"]);
|
|
2290
2292
|
var money3 = (value, chainId) => {
|
|
2291
|
-
const c =
|
|
2293
|
+
const c = _chunkXWONUCGAcjs.getChain.call(void 0, chainId).nativeCurrency;
|
|
2292
2294
|
return { value, decimals: c.decimals, symbol: c.symbol, formatted: _viem.formatUnits.call(void 0, value, c.decimals) };
|
|
2293
2295
|
};
|
|
2294
2296
|
function usePayOptions(mint, onSelect) {
|
|
@@ -2332,7 +2334,7 @@ function usePayOptions(mint, onSelect) {
|
|
|
2332
2334
|
_react.useEffect.call(void 0, () => {
|
|
2333
2335
|
if (!info || current === null || !mint.wallet) return;
|
|
2334
2336
|
let alive = true;
|
|
2335
|
-
|
|
2337
|
+
_chunkYGBIJOKQcjs.getConnectedBalance.call(void 0, mint.wallet.address, current).then(
|
|
2336
2338
|
(value) => {
|
|
2337
2339
|
if (alive) setBalance({ chainId: current, value });
|
|
2338
2340
|
},
|
|
@@ -2346,7 +2348,7 @@ function usePayOptions(mint, onSelect) {
|
|
|
2346
2348
|
}, [current, _optionalChain([mint, 'access', _99 => _99.wallet, 'optionalAccess', _100 => _100.address]), key, tick]);
|
|
2347
2349
|
const select = _react.useCallback.call(void 0,
|
|
2348
2350
|
(chainId) => {
|
|
2349
|
-
|
|
2351
|
+
_chunkYGBIJOKQcjs.switchToChain.call(void 0, chainId).then(
|
|
2350
2352
|
() => _optionalChain([onSelect, 'optionalCall', _101 => _101(chainId, null)]),
|
|
2351
2353
|
(e) => _optionalChain([onSelect, 'optionalCall', _102 => _102(chainId, e)])
|
|
2352
2354
|
);
|
|
@@ -2360,7 +2362,7 @@ function usePayOptions(mint, onSelect) {
|
|
|
2360
2362
|
const quoted = q && q !== "failed" ? q : null;
|
|
2361
2363
|
return {
|
|
2362
2364
|
chainId,
|
|
2363
|
-
name:
|
|
2365
|
+
name: _chunkXWONUCGAcjs.chainName.call(void 0, chainId),
|
|
2364
2366
|
selected: chainId === current,
|
|
2365
2367
|
isDropChain,
|
|
2366
2368
|
relayFee: isDropChain ? null : _nullishCoalesce(_optionalChain([quoted, 'optionalAccess', _103 => _103.relayFee]), () => ( null)),
|
|
@@ -2427,7 +2429,7 @@ function defaultLabel(m) {
|
|
|
2427
2429
|
case "live": {
|
|
2428
2430
|
const route = m.route;
|
|
2429
2431
|
if (_optionalChain([route, 'optionalAccess', _116 => _116.kind]) === "relay") {
|
|
2430
|
-
return `Mint \xB7 ${route.amountIn.formatted} ${route.amountIn.symbol} on ${
|
|
2432
|
+
return `Mint \xB7 ${route.amountIn.formatted} ${route.amountIn.symbol} on ${_chunkXWONUCGAcjs.chainName.call(void 0, route.originChainId)}`;
|
|
2431
2433
|
}
|
|
2432
2434
|
const total = m.total;
|
|
2433
2435
|
if (!total) return "Mint";
|
|
@@ -2476,7 +2478,7 @@ function MintButton(props) {
|
|
|
2476
2478
|
}
|
|
2477
2479
|
|
|
2478
2480
|
// src/index.ts
|
|
2479
|
-
var VERSION = "0.
|
|
2481
|
+
var VERSION = "0.5.0";
|
|
2480
2482
|
|
|
2481
2483
|
|
|
2482
2484
|
|
|
@@ -2489,5 +2491,5 @@ var VERSION = "0.4.1";
|
|
|
2489
2491
|
|
|
2490
2492
|
|
|
2491
2493
|
|
|
2492
|
-
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;
|
|
2493
2495
|
//# sourceMappingURL=index.cjs.map
|