@memfork/cli 0.1.11 → 0.1.12
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/commands/init.js +6 -6
- package/dist/commands/provision.js +31 -2
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -32,7 +32,7 @@ export async function cmdInit(opts = {}) {
|
|
|
32
32
|
choices: [
|
|
33
33
|
{
|
|
34
34
|
value: "quick",
|
|
35
|
-
name: "Quick setup " + chalk.dim("— auto-provision: keygen →
|
|
35
|
+
name: "Quick setup " + chalk.dim("— auto-provision: keygen → funding → MemWal → tree (recommended)"),
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
value: "manual",
|
|
@@ -50,7 +50,7 @@ export async function cmdInit(opts = {}) {
|
|
|
50
50
|
// ─── Quick path ───────────────────────────────────────────────────────────────
|
|
51
51
|
async function cmdInitQuick() {
|
|
52
52
|
console.log("");
|
|
53
|
-
console.log(dim(" We'll generate a fresh keypair,
|
|
53
|
+
console.log(dim(" We'll generate a fresh keypair, guide wallet funding if needed,"));
|
|
54
54
|
console.log(dim(" create your MemWal account and memory tree automatically."));
|
|
55
55
|
console.log(dim(" Nothing to copy-paste."));
|
|
56
56
|
console.log("");
|
|
@@ -58,8 +58,8 @@ async function cmdInitQuick() {
|
|
|
58
58
|
message: "Sui network",
|
|
59
59
|
default: "mainnet",
|
|
60
60
|
choices: [
|
|
61
|
-
{ value: "mainnet", name: "mainnet (
|
|
62
|
-
{ value: "testnet", name: "testnet (free
|
|
61
|
+
{ value: "mainnet", name: "mainnet " + chalk.dim("— gas sponsored by MemForks (recommended)") },
|
|
62
|
+
{ value: "testnet", name: "testnet " + chalk.dim("— free funding via faucet") },
|
|
63
63
|
],
|
|
64
64
|
});
|
|
65
65
|
const existingKey = readProjectConfig()
|
|
@@ -115,8 +115,8 @@ async function cmdInitManual() {
|
|
|
115
115
|
message: "Sui network",
|
|
116
116
|
default: existing?.network ?? "mainnet",
|
|
117
117
|
choices: [
|
|
118
|
-
{ value: "mainnet", name: "mainnet (
|
|
119
|
-
{ value: "testnet", name: "testnet (free
|
|
118
|
+
{ value: "mainnet", name: "mainnet (requires funded wallet for setup)" },
|
|
119
|
+
{ value: "testnet", name: "testnet (free funding via faucet)" },
|
|
120
120
|
{ value: "devnet", name: "devnet" },
|
|
121
121
|
{ value: "localnet", name: "localnet" },
|
|
122
122
|
],
|
|
@@ -66,8 +66,37 @@ export async function autoProvision(opts) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// Mainnet: request a gas drip from the sponsor service so the fresh
|
|
70
|
+
// wallet can pay for the two MemWal calls (createAccount + addDelegateKey).
|
|
71
|
+
// All subsequent MemForks ops are covered by /sponsor, but those two calls
|
|
72
|
+
// happen before the tree exists and must self-pay.
|
|
73
|
+
step(2, "Requesting mainnet gas from MemForks sponsor");
|
|
74
|
+
const sponsorUrl = process.env.MEMFORK_SPONSOR_URL ?? "https://sponsor.memforks.ai";
|
|
75
|
+
try {
|
|
76
|
+
const res = await fetch(`${sponsorUrl}/drip`, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
headers: { "Content-Type": "application/json" },
|
|
79
|
+
body: JSON.stringify({ address }),
|
|
80
|
+
});
|
|
81
|
+
const data = await res.json();
|
|
82
|
+
if (!res.ok) {
|
|
83
|
+
throw new Error(data.error ?? `HTTP ${res.status}`);
|
|
84
|
+
}
|
|
85
|
+
if (data.skipped) {
|
|
86
|
+
skip("address already has gas");
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
done();
|
|
90
|
+
console.log(chalk.dim(` drip tx: ${data.digest}`));
|
|
91
|
+
console.log(chalk.dim(` amount: ${((data.amount ?? 0) / 1_000_000_000).toFixed(3)} SUI`));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
console.log(chalk.red("failed"));
|
|
96
|
+
throw new Error(`Could not get gas from sponsor (${sponsorUrl}/drip): ${String(e)}\n` +
|
|
97
|
+
` Fund the address manually then re-run:\n` +
|
|
98
|
+
` ${address}`);
|
|
99
|
+
}
|
|
71
100
|
}
|
|
72
101
|
// ── 3. MemWal account ────────────────────────────────────────────────────────
|
|
73
102
|
step(3, "Creating MemWal account on-chain");
|