@capxul/sandbox 3.2.0 → 4.0.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/dist/main.mjs +12 -32
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -231,10 +231,9 @@ function createConvexPathRunner({ target, env: sourceEnv = process.env, spawn =
|
|
|
231
231
|
};
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
|
-
const
|
|
234
|
+
const HANDLE_SHAPE_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
235
235
|
/**
|
|
236
|
-
* Classify a faucet recipient prompt value
|
|
237
|
-
* as an explicit escape hatch — a raw EVM address. Canonical normalization
|
|
236
|
+
* Classify a faucet recipient prompt value as an email, handle, or EVM address. Canonical normalization
|
|
238
237
|
* (email lowercasing, handle validation) is left to the backend resolver.
|
|
239
238
|
*/
|
|
240
239
|
function parseFaucetRecipient(value) {
|
|
@@ -247,12 +246,12 @@ function parseFaucetRecipient(value) {
|
|
|
247
246
|
kind: "email",
|
|
248
247
|
email: trimmed
|
|
249
248
|
};
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
252
|
-
kind: "
|
|
253
|
-
|
|
249
|
+
const handle = trimmed.startsWith("@") ? trimmed.slice(1) : trimmed;
|
|
250
|
+
if (handle.length > 0 && !handle.toLowerCase().startsWith("0x") && HANDLE_SHAPE_PATTERN.test(handle)) return {
|
|
251
|
+
kind: "handle",
|
|
252
|
+
handle
|
|
254
253
|
};
|
|
255
|
-
throw new Error("Recipient must be
|
|
254
|
+
throw new Error("Recipient must be an email, handle, or 0x address.");
|
|
256
255
|
}
|
|
257
256
|
function usdAmountToBaseUnits(value) {
|
|
258
257
|
const amount = value.trim();
|
|
@@ -281,18 +280,17 @@ function canonicalConvexRunner(env = process.env) {
|
|
|
281
280
|
//#endregion
|
|
282
281
|
//#region src/commands/faucet-send.ts
|
|
283
282
|
const DEFAULT_FAUCET_AMOUNT = "10";
|
|
284
|
-
const FAUCET_ADDRESS_FUNCTION = "dev/faucetMintTo:mintTo";
|
|
285
283
|
const FAUCET_RECIPIENT_FUNCTION = "dev/faucetMintTo:mintToRecipient";
|
|
286
284
|
function recipientLabel(recipient) {
|
|
287
285
|
switch (recipient.kind) {
|
|
288
286
|
case "address": return recipient.address;
|
|
289
287
|
case "email": return recipient.email;
|
|
290
|
-
case "
|
|
288
|
+
case "handle": return `@${recipient.handle}`;
|
|
291
289
|
}
|
|
292
290
|
}
|
|
293
291
|
function mintFailureMessage(recipient, output) {
|
|
294
292
|
const message = output.length > 0 ? output : "Faucet mint failed.";
|
|
295
|
-
if (recipient.kind === "
|
|
293
|
+
if (recipient.kind === "handle" && message.includes("INVALID_INPUT")) return `${message}\nHint: no Capxul account uses this handle.`;
|
|
296
294
|
return message;
|
|
297
295
|
}
|
|
298
296
|
async function runFaucetSend() {
|
|
@@ -304,7 +302,7 @@ async function runFaucetSend() {
|
|
|
304
302
|
"This command calls the canonical backend dev faucet and cannot select live/mainnet."
|
|
305
303
|
].join("\n"), "Canonical sandbox");
|
|
306
304
|
const recipientPrompt = await text({
|
|
307
|
-
message: "Recipient (
|
|
305
|
+
message: "Recipient (email, handle, or 0x address)",
|
|
308
306
|
validate(value) {
|
|
309
307
|
try {
|
|
310
308
|
parseFaucetRecipient(value ?? "");
|
|
@@ -336,16 +334,6 @@ async function runFaucetSend() {
|
|
|
336
334
|
const rawAmount = usdAmountToBaseUnits(amountPrompt);
|
|
337
335
|
const displayAmount = amountPrompt.trim();
|
|
338
336
|
const identity = recipientLabel(recipient);
|
|
339
|
-
if (recipient.kind === "address") {
|
|
340
|
-
const escapeHatch = await confirm({
|
|
341
|
-
message: `Raw-address escape hatch — this skips Capxul identity resolution. Fund ${identity} directly?`,
|
|
342
|
-
initialValue: false
|
|
343
|
-
});
|
|
344
|
-
if (isCancel(escapeHatch) || escapeHatch === false) {
|
|
345
|
-
cancel("No faucet funds sent.");
|
|
346
|
-
return 0;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
337
|
const shouldSend = await confirm({
|
|
350
338
|
message: `Mint ${displayAmount} test USDX to ${identity}?`,
|
|
351
339
|
initialValue: true
|
|
@@ -357,15 +345,7 @@ async function runFaucetSend() {
|
|
|
357
345
|
const s = spinner();
|
|
358
346
|
s.start("Minting testnet funds");
|
|
359
347
|
try {
|
|
360
|
-
const
|
|
361
|
-
const result = recipient.kind === "address" ? runConvex("", [
|
|
362
|
-
"run",
|
|
363
|
-
FAUCET_ADDRESS_FUNCTION,
|
|
364
|
-
JSON.stringify({
|
|
365
|
-
holderAddress: recipient.address,
|
|
366
|
-
rawAmount
|
|
367
|
-
})
|
|
368
|
-
]) : runConvex("", [
|
|
348
|
+
const result = canonicalConvexRunner()("", [
|
|
369
349
|
"run",
|
|
370
350
|
FAUCET_RECIPIENT_FUNCTION,
|
|
371
351
|
JSON.stringify({
|
|
@@ -375,7 +355,7 @@ async function runFaucetSend() {
|
|
|
375
355
|
]);
|
|
376
356
|
if (!result.ok) throw new Error(mintFailureMessage(recipient, result.output));
|
|
377
357
|
const txHash = extractField(result.output, "txHash");
|
|
378
|
-
const safeAddress =
|
|
358
|
+
const safeAddress = extractField(result.output, "safeAddress");
|
|
379
359
|
s.stop("Faucet funds sent");
|
|
380
360
|
note([
|
|
381
361
|
`Recipient: ${identity}`,
|