@memfork/cli 0.1.45 → 0.1.46

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.
@@ -125,8 +125,10 @@ export async function cmdDoctor() {
125
125
  process.exit(1);
126
126
  }
127
127
  // ── 5. MemoryTree on-chain ──────────────────────────────────────────────────
128
+ let treeOwner;
128
129
  try {
129
130
  const tree = await client.getTree();
131
+ treeOwner = tree.owner;
130
132
  checks.push({
131
133
  label: "MemoryTree on-chain",
132
134
  status: "ok",
@@ -141,7 +143,72 @@ export async function cmdDoctor() {
141
143
  fix: "Check the treeId in .memfork/config.json or run `memfork init`",
142
144
  });
143
145
  }
144
- // ── 6. Signer balance (warn if low) ─────────────────────────────────────────
146
+ // ── 6. Signer role (owner vs delegate) ──────────────────────────────────────
147
+ const signerAddr = client.keypair.toSuiAddress();
148
+ if (treeOwner) {
149
+ if (signerAddr === treeOwner) {
150
+ checks.push({
151
+ label: "Signer role",
152
+ status: "ok",
153
+ detail: `owner (${signerAddr.slice(0, 10)}…)`,
154
+ });
155
+ }
156
+ else {
157
+ // Look for a DelegateCap owned by this signer for this tree.
158
+ try {
159
+ if (!cfg.packageId)
160
+ throw new Error("packageId unknown");
161
+ const capType = `${cfg.packageId}::tree::DelegateCap`;
162
+ const owned = await client.suiClient.getOwnedObjects({
163
+ owner: signerAddr,
164
+ filter: { StructType: capType },
165
+ options: { showContent: true },
166
+ });
167
+ const cap = owned.data.find((o) => {
168
+ if (!o.data?.content || o.data.content.dataType !== "moveObject")
169
+ return false;
170
+ const f = o.data.content.fields;
171
+ return f["tree_id"] === cfg.treeId && !f["revoked"];
172
+ });
173
+ if (cap && cap.data?.content && cap.data.content.dataType === "moveObject") {
174
+ const f = cap.data.content.fields;
175
+ const raw = Number(f["permissions"] ?? 0);
176
+ const labels = [];
177
+ if (raw & 0x01)
178
+ labels.push("READ");
179
+ if (raw & 0x02)
180
+ labels.push("WRITE");
181
+ if (raw & 0x04)
182
+ labels.push("FORK");
183
+ if (raw & 0x08)
184
+ labels.push("MERGE");
185
+ if (raw & 0x10)
186
+ labels.push("PROPOSE");
187
+ checks.push({
188
+ label: "Signer role",
189
+ status: "ok",
190
+ detail: `delegate · ${labels.join(" · ") || "no permissions"} (${signerAddr.slice(0, 10)}…)`,
191
+ });
192
+ }
193
+ else {
194
+ checks.push({
195
+ label: "Signer role",
196
+ status: "warn",
197
+ detail: `no delegate cap found for this tree (${signerAddr.slice(0, 10)}…)`,
198
+ fix: "Ask the tree owner to run: memfork grant --agent " + signerAddr,
199
+ });
200
+ }
201
+ }
202
+ catch {
203
+ checks.push({
204
+ label: "Signer role",
205
+ status: "skip",
206
+ detail: "could not query delegate cap",
207
+ });
208
+ }
209
+ }
210
+ }
211
+ // ── 7. Signer balance (warn if low) ─────────────────────────────────────────
145
212
  try {
146
213
  const addr = client.keypair.toSuiAddress();
147
214
  const balance = await client.suiClient.getBalance({ owner: addr });
@@ -157,7 +224,7 @@ export async function cmdDoctor() {
157
224
  catch {
158
225
  checks.push({ label: "Signer balance", status: "skip", detail: "could not fetch" });
159
226
  }
160
- // ── 7. MemWal reachable ──────────────────────────────────────────────────────
227
+ // ── 8. MemWal reachable ──────────────────────────────────────────────────────
161
228
  try {
162
229
  const resp = await fetch(cfg.memwalRelayer + "/health", { signal: AbortSignal.timeout(5000) });
163
230
  checks.push({
@@ -175,7 +242,7 @@ export async function cmdDoctor() {
175
242
  fix: "Check your network. MemWal read/write will be unavailable.",
176
243
  });
177
244
  }
178
- // ── 8. Artifact storage (optional) ──────────────────────────────────────────
245
+ // ── 9. Artifact storage (optional) ──────────────────────────────────────────
179
246
  if (cfg.artifacts.enabled) {
180
247
  // Artifacts require WAL tokens. Fetch the signer's WAL coin balance.
181
248
  // The WAL package ID is identical on mainnet and testnet.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memfork/cli",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "MemForks CLI — init, commit, recall, merge, install plugins",
5
5
  "repository": {
6
6
  "type": "git",