@toon-protocol/rig 2.4.0 → 2.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/dist/cli/rig.js +42 -12
- package/dist/cli/rig.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/rig.js
CHANGED
|
@@ -3439,7 +3439,9 @@ pays). The identity comes from RIG_MNEMONIC (env or a project .env) or the
|
|
|
3439
3439
|
~/.toon-client keystore/config; the faucet from TOON_CLIENT_FAUCET_URL, the
|
|
3440
3440
|
faucetUrl config field, or the deployed devnet faucet when the network is
|
|
3441
3441
|
devnet \u2014 including when a configured *.devnet.toonprotocol.dev origin infers
|
|
3442
|
-
it
|
|
3442
|
+
it (a devnet relay/proxy/btp endpoint, or the git origin remote from
|
|
3443
|
+
\`rig remote add origin <devnet relay>\`). The faucet drips a FIXED amount per
|
|
3444
|
+
chain (there is no --amount). On a
|
|
3443
3445
|
network without a faucet, prints the wallet address(es) to fund externally
|
|
3444
3446
|
instead.
|
|
3445
3447
|
|
|
@@ -3450,24 +3452,50 @@ Options:
|
|
|
3450
3452
|
--json machine-readable envelope
|
|
3451
3453
|
-h, --help show this help`;
|
|
3452
3454
|
var SHARED_DEVNET_SUFFIX = ".devnet.toonprotocol.dev";
|
|
3453
|
-
function
|
|
3455
|
+
function devnetHost(url) {
|
|
3456
|
+
if (!url) return void 0;
|
|
3457
|
+
try {
|
|
3458
|
+
const { hostname } = new URL(url);
|
|
3459
|
+
if (hostname.endsWith(SHARED_DEVNET_SUFFIX) || hostname === SHARED_DEVNET_SUFFIX.slice(1)) {
|
|
3460
|
+
return url;
|
|
3461
|
+
}
|
|
3462
|
+
} catch {
|
|
3463
|
+
}
|
|
3464
|
+
return void 0;
|
|
3465
|
+
}
|
|
3466
|
+
function sharedDevnetOrigin(env, file, originRelays = []) {
|
|
3454
3467
|
const candidates = [
|
|
3455
3468
|
env["TOON_CLIENT_RELAY_URL"] ?? file.relayUrl,
|
|
3456
3469
|
env["TOON_CLIENT_PROXY_URL"] ?? file.proxyUrl,
|
|
3457
|
-
env["TOON_CLIENT_BTP_URL"] ?? file.btpUrl
|
|
3470
|
+
env["TOON_CLIENT_BTP_URL"] ?? file.btpUrl,
|
|
3471
|
+
...originRelays
|
|
3458
3472
|
];
|
|
3459
3473
|
for (const url of candidates) {
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
const { hostname } = new URL(url);
|
|
3463
|
-
if (hostname.endsWith(SHARED_DEVNET_SUFFIX) || hostname === SHARED_DEVNET_SUFFIX.slice(1)) {
|
|
3464
|
-
return url;
|
|
3465
|
-
}
|
|
3466
|
-
} catch {
|
|
3467
|
-
}
|
|
3474
|
+
const hit = devnetHost(url);
|
|
3475
|
+
if (hit) return hit;
|
|
3468
3476
|
}
|
|
3469
3477
|
return void 0;
|
|
3470
3478
|
}
|
|
3479
|
+
async function resolveOriginRelays(cwd) {
|
|
3480
|
+
let repoRoot;
|
|
3481
|
+
try {
|
|
3482
|
+
repoRoot = await resolveRepoRoot(cwd);
|
|
3483
|
+
} catch {
|
|
3484
|
+
return [];
|
|
3485
|
+
}
|
|
3486
|
+
try {
|
|
3487
|
+
const toonConfig = await readToonConfig(repoRoot);
|
|
3488
|
+
const resolved = await resolveRelays({
|
|
3489
|
+
relayFlags: [],
|
|
3490
|
+
remoteName: void 0,
|
|
3491
|
+
repoRoot,
|
|
3492
|
+
toonRelays: toonConfig.relays
|
|
3493
|
+
});
|
|
3494
|
+
return resolved.relays;
|
|
3495
|
+
} catch {
|
|
3496
|
+
return [];
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3471
3499
|
function noFaucetGuidance(network, devnetOrigin) {
|
|
3472
3500
|
const head = `no faucet is configured for network ${JSON.stringify(network ?? "custom")}`;
|
|
3473
3501
|
const external = "To fund the wallet externally instead, send the settlement token plus native gas to the address below for the chain your channels settle on.";
|
|
@@ -3534,7 +3562,9 @@ async function runFund(args, deps) {
|
|
|
3534
3562
|
);
|
|
3535
3563
|
}
|
|
3536
3564
|
const network = env["TOON_CLIENT_NETWORK"] ?? file.network;
|
|
3537
|
-
const
|
|
3565
|
+
const canInfer = network === void 0 || network === "custom";
|
|
3566
|
+
const originRelays = canInfer ? await resolveOriginRelays(deps.cwd) : [];
|
|
3567
|
+
const devnetOrigin = sharedDevnetOrigin(env, file, originRelays);
|
|
3538
3568
|
const inferredDevnet = devnetOrigin !== void 0 && (network === void 0 || network === "custom");
|
|
3539
3569
|
const effectiveNetwork = inferredDevnet ? "devnet" : network;
|
|
3540
3570
|
const faucetUrl = env["TOON_CLIENT_FAUCET_URL"] ?? file.faucetUrl ?? (effectiveNetwork === "devnet" ? DEVNET_FAUCET_URL : void 0);
|