@openfort/cli 0.1.8 → 0.1.9
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/bin.js +6 -17
- package/dist/chunk-SVNLXGFY.js +68 -0
- package/dist/cli.js +695 -756
- package/package.json +1 -1
- package/src/bin.ts +5 -17
- package/dist/chunk-QJGHQ7ID.js +0 -25
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CREDENTIALS_PATH,
|
|
4
|
-
ensureConfigDir
|
|
5
|
-
|
|
4
|
+
ensureConfigDir,
|
|
5
|
+
loadEnvFile,
|
|
6
|
+
requireApiKey,
|
|
7
|
+
writeEnvKey
|
|
8
|
+
} from "./chunk-SVNLXGFY.js";
|
|
6
9
|
|
|
7
10
|
// src/cli.ts
|
|
8
|
-
import { readFileSync
|
|
9
|
-
import { Cli as Cli14, z as
|
|
10
|
-
import Openfort from "@openfort/openfort-node";
|
|
11
|
+
import { readFileSync } from "fs";
|
|
12
|
+
import { Cli as Cli14, z as z14 } from "incur";
|
|
11
13
|
|
|
12
|
-
// src/
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
14
|
+
// src/commands/login.ts
|
|
15
|
+
import { randomBytes } from "crypto";
|
|
16
|
+
import { createServer } from "http";
|
|
17
|
+
import open from "open";
|
|
18
|
+
import { Cli, z } from "incur";
|
|
17
19
|
|
|
18
20
|
// src/constants.ts
|
|
19
21
|
var API_BASE_URL = process.env.OPENFORT_BASE_URL || "https://api.openfort.io";
|
|
@@ -21,51 +23,7 @@ var OPENFORT_SHIELD_URL = process.env.OPENFORT_SHIELD_URL || "https://shield.ope
|
|
|
21
23
|
var AUTH_PAGE_URL = process.env.OPENFORT_AUTH_PAGE_URL || "https://dashboard.openfort.io";
|
|
22
24
|
var CLI_CALLBACK_PORT = Number(process.env.OPENFORT_CLI_CALLBACK_PORT) || 8271;
|
|
23
25
|
|
|
24
|
-
// src/env.ts
|
|
25
|
-
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
26
|
-
import { Errors } from "incur";
|
|
27
|
-
function loadEnvFile(envPath) {
|
|
28
|
-
const entries = /* @__PURE__ */ new Map();
|
|
29
|
-
if (!existsSync(envPath)) return entries;
|
|
30
|
-
const content = readFileSync(envPath, "utf-8");
|
|
31
|
-
for (const line of content.split("\n")) {
|
|
32
|
-
const trimmed = line.trim();
|
|
33
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
34
|
-
const eqIndex = trimmed.indexOf("=");
|
|
35
|
-
if (eqIndex === -1) continue;
|
|
36
|
-
const key = trimmed.slice(0, eqIndex).trim();
|
|
37
|
-
const value = trimmed.slice(eqIndex + 1).trim();
|
|
38
|
-
entries.set(key, value);
|
|
39
|
-
}
|
|
40
|
-
return entries;
|
|
41
|
-
}
|
|
42
|
-
function writeEnvKey(envPath, key, value) {
|
|
43
|
-
const entries = loadEnvFile(envPath);
|
|
44
|
-
entries.set(key, value);
|
|
45
|
-
const lines = [];
|
|
46
|
-
for (const [k, v] of entries) {
|
|
47
|
-
lines.push(`${k}=${v}`);
|
|
48
|
-
}
|
|
49
|
-
writeFileSync(envPath, `${lines.join("\n")}
|
|
50
|
-
`);
|
|
51
|
-
}
|
|
52
|
-
function requireApiKey() {
|
|
53
|
-
const apiKey = process.env.OPENFORT_API_KEY;
|
|
54
|
-
if (!apiKey) {
|
|
55
|
-
throw new Errors.IncurError({
|
|
56
|
-
code: "MISSING_API_KEY",
|
|
57
|
-
message: "OPENFORT_API_KEY is required.",
|
|
58
|
-
hint: "Run: openfort login"
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return apiKey;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
26
|
// src/commands/login.ts
|
|
65
|
-
import { randomBytes } from "crypto";
|
|
66
|
-
import { createServer } from "http";
|
|
67
|
-
import open from "open";
|
|
68
|
-
import { Cli, z as z2 } from "incur";
|
|
69
27
|
function base64url(buffer) {
|
|
70
28
|
return buffer.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
71
29
|
}
|
|
@@ -198,10 +156,10 @@ function waitForCallback(port, state) {
|
|
|
198
156
|
}
|
|
199
157
|
var login = Cli.create("login", {
|
|
200
158
|
description: "Log in to Openfort via browser and save your API key.",
|
|
201
|
-
output:
|
|
202
|
-
apiKey:
|
|
203
|
-
project:
|
|
204
|
-
credentialsPath:
|
|
159
|
+
output: z.object({
|
|
160
|
+
apiKey: z.string().describe("The API key saved to credentials"),
|
|
161
|
+
project: z.string().describe("The project name"),
|
|
162
|
+
credentialsPath: z.string().describe("Path to the credentials file")
|
|
205
163
|
}),
|
|
206
164
|
async run(c) {
|
|
207
165
|
const state = generateState();
|
|
@@ -249,7 +207,37 @@ var login = Cli.create("login", {
|
|
|
249
207
|
});
|
|
250
208
|
|
|
251
209
|
// src/commands/accounts.ts
|
|
252
|
-
import { Cli as Cli2, z as
|
|
210
|
+
import { Cli as Cli2, z as z2, middleware } from "incur";
|
|
211
|
+
|
|
212
|
+
// src/client.ts
|
|
213
|
+
import Openfort from "@openfort/openfort-node";
|
|
214
|
+
var cached;
|
|
215
|
+
function getOpenfort() {
|
|
216
|
+
if (cached) return cached;
|
|
217
|
+
let apiKey = process.env.OPENFORT_API_KEY;
|
|
218
|
+
if (!apiKey) {
|
|
219
|
+
const creds = loadEnvFile(CREDENTIALS_PATH);
|
|
220
|
+
apiKey = creds.get("OPENFORT_API_KEY");
|
|
221
|
+
if (apiKey) {
|
|
222
|
+
process.env.OPENFORT_API_KEY = apiKey;
|
|
223
|
+
const pk = creds.get("OPENFORT_PUBLISHABLE_KEY");
|
|
224
|
+
if (pk && !process.env.OPENFORT_PUBLISHABLE_KEY) process.env.OPENFORT_PUBLISHABLE_KEY = pk;
|
|
225
|
+
const ws = creds.get("OPENFORT_WALLET_SECRET");
|
|
226
|
+
if (ws && !process.env.OPENFORT_WALLET_SECRET) process.env.OPENFORT_WALLET_SECRET = ws;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (!apiKey) {
|
|
230
|
+
throw new Error("OPENFORT_API_KEY is required. Run: openfort login");
|
|
231
|
+
}
|
|
232
|
+
cached = new Openfort(apiKey, {
|
|
233
|
+
walletSecret: process.env.OPENFORT_WALLET_SECRET,
|
|
234
|
+
publishableKey: process.env.OPENFORT_PUBLISHABLE_KEY,
|
|
235
|
+
basePath: API_BASE_URL
|
|
236
|
+
});
|
|
237
|
+
return cached;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/commands/accounts.ts
|
|
253
241
|
var requireWallet = middleware((c, next) => {
|
|
254
242
|
const missing = [];
|
|
255
243
|
if (!process.env.OPENFORT_WALLET_SECRET) missing.push("OPENFORT_WALLET_SECRET");
|
|
@@ -267,8 +255,7 @@ var requireWallet = middleware((c, next) => {
|
|
|
267
255
|
return next();
|
|
268
256
|
});
|
|
269
257
|
var evm = Cli2.create("evm", {
|
|
270
|
-
description: "EVM wallet management."
|
|
271
|
-
vars: varsSchema
|
|
258
|
+
description: "EVM wallet management."
|
|
272
259
|
});
|
|
273
260
|
evm.command("create", {
|
|
274
261
|
description: "Create a new EVM backend wallet.",
|
|
@@ -277,13 +264,13 @@ evm.command("create", {
|
|
|
277
264
|
],
|
|
278
265
|
hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
|
|
279
266
|
middleware: [requireWallet],
|
|
280
|
-
output:
|
|
281
|
-
id:
|
|
282
|
-
address:
|
|
283
|
-
custody:
|
|
267
|
+
output: z2.object({
|
|
268
|
+
id: z2.string().describe("Account ID"),
|
|
269
|
+
address: z2.string().describe("Wallet address"),
|
|
270
|
+
custody: z2.string().describe("Custody type")
|
|
284
271
|
}),
|
|
285
272
|
async run(c) {
|
|
286
|
-
const account = await
|
|
273
|
+
const account = await getOpenfort().accounts.evm.backend.create();
|
|
287
274
|
return c.ok(
|
|
288
275
|
{ id: account.id, address: account.address, custody: account.custody },
|
|
289
276
|
{
|
|
@@ -300,25 +287,25 @@ evm.command("create", {
|
|
|
300
287
|
});
|
|
301
288
|
evm.command("list", {
|
|
302
289
|
description: "List EVM backend wallets.",
|
|
303
|
-
options:
|
|
304
|
-
limit:
|
|
305
|
-
skip:
|
|
290
|
+
options: z2.object({
|
|
291
|
+
limit: z2.number().optional().describe("Max results"),
|
|
292
|
+
skip: z2.number().optional().describe("Offset")
|
|
306
293
|
}),
|
|
307
294
|
alias: { limit: "l" },
|
|
308
295
|
examples: [
|
|
309
296
|
{ description: "List all EVM backend wallets" },
|
|
310
297
|
{ options: { limit: 5 }, description: "Show first 5 wallets" }
|
|
311
298
|
],
|
|
312
|
-
output:
|
|
313
|
-
accounts:
|
|
314
|
-
id:
|
|
315
|
-
address:
|
|
316
|
-
custody:
|
|
299
|
+
output: z2.object({
|
|
300
|
+
accounts: z2.array(z2.object({
|
|
301
|
+
id: z2.string(),
|
|
302
|
+
address: z2.string(),
|
|
303
|
+
custody: z2.string()
|
|
317
304
|
})),
|
|
318
|
-
total:
|
|
305
|
+
total: z2.number().optional()
|
|
319
306
|
}),
|
|
320
307
|
async run(c) {
|
|
321
|
-
const res = await
|
|
308
|
+
const res = await getOpenfort().accounts.evm.backend.list({
|
|
322
309
|
limit: c.options.limit,
|
|
323
310
|
skip: c.options.skip
|
|
324
311
|
});
|
|
@@ -334,25 +321,25 @@ evm.command("list", {
|
|
|
334
321
|
});
|
|
335
322
|
evm.command("list-delegated", {
|
|
336
323
|
description: "List EVM delegated accounts.",
|
|
337
|
-
options:
|
|
338
|
-
limit:
|
|
339
|
-
skip:
|
|
324
|
+
options: z2.object({
|
|
325
|
+
limit: z2.number().optional().describe("Max results"),
|
|
326
|
+
skip: z2.number().optional().describe("Offset")
|
|
340
327
|
}),
|
|
341
328
|
alias: { limit: "l" },
|
|
342
329
|
examples: [
|
|
343
330
|
{ description: "List all EVM delegated accounts" },
|
|
344
331
|
{ options: { limit: 5 }, description: "Show first 5 accounts" }
|
|
345
332
|
],
|
|
346
|
-
output:
|
|
347
|
-
accounts:
|
|
348
|
-
id:
|
|
349
|
-
address:
|
|
350
|
-
custody:
|
|
333
|
+
output: z2.object({
|
|
334
|
+
accounts: z2.array(z2.object({
|
|
335
|
+
id: z2.string(),
|
|
336
|
+
address: z2.string(),
|
|
337
|
+
custody: z2.string()
|
|
351
338
|
})),
|
|
352
|
-
total:
|
|
339
|
+
total: z2.number().optional()
|
|
353
340
|
}),
|
|
354
341
|
async run(c) {
|
|
355
|
-
const res = await
|
|
342
|
+
const res = await getOpenfort().accounts.evm.list({
|
|
356
343
|
accountType: "Delegated Account",
|
|
357
344
|
limit: c.options.limit,
|
|
358
345
|
skip: c.options.skip
|
|
@@ -369,25 +356,25 @@ evm.command("list-delegated", {
|
|
|
369
356
|
});
|
|
370
357
|
evm.command("list-smart", {
|
|
371
358
|
description: "List EVM smart accounts.",
|
|
372
|
-
options:
|
|
373
|
-
limit:
|
|
374
|
-
skip:
|
|
359
|
+
options: z2.object({
|
|
360
|
+
limit: z2.number().optional().describe("Max results"),
|
|
361
|
+
skip: z2.number().optional().describe("Offset")
|
|
375
362
|
}),
|
|
376
363
|
alias: { limit: "l" },
|
|
377
364
|
examples: [
|
|
378
365
|
{ description: "List all EVM smart accounts" },
|
|
379
366
|
{ options: { limit: 5 }, description: "Show first 5 accounts" }
|
|
380
367
|
],
|
|
381
|
-
output:
|
|
382
|
-
accounts:
|
|
383
|
-
id:
|
|
384
|
-
address:
|
|
385
|
-
custody:
|
|
368
|
+
output: z2.object({
|
|
369
|
+
accounts: z2.array(z2.object({
|
|
370
|
+
id: z2.string(),
|
|
371
|
+
address: z2.string(),
|
|
372
|
+
custody: z2.string()
|
|
386
373
|
})),
|
|
387
|
-
total:
|
|
374
|
+
total: z2.number().optional()
|
|
388
375
|
}),
|
|
389
376
|
async run(c) {
|
|
390
|
-
const res = await
|
|
377
|
+
const res = await getOpenfort().accounts.evm.list({
|
|
391
378
|
accountType: "Smart Account",
|
|
392
379
|
limit: c.options.limit,
|
|
393
380
|
skip: c.options.skip
|
|
@@ -404,19 +391,19 @@ evm.command("list-smart", {
|
|
|
404
391
|
});
|
|
405
392
|
evm.command("get", {
|
|
406
393
|
description: "Get an EVM backend wallet by ID or address.",
|
|
407
|
-
args:
|
|
408
|
-
id:
|
|
394
|
+
args: z2.object({
|
|
395
|
+
id: z2.string().describe("Account ID or address")
|
|
409
396
|
}),
|
|
410
397
|
examples: [
|
|
411
398
|
{ args: { id: "acc_1a2b3c4d" }, description: "Get wallet by ID" }
|
|
412
399
|
],
|
|
413
|
-
output:
|
|
414
|
-
id:
|
|
415
|
-
address:
|
|
416
|
-
custody:
|
|
400
|
+
output: z2.object({
|
|
401
|
+
id: z2.string(),
|
|
402
|
+
address: z2.string(),
|
|
403
|
+
custody: z2.string()
|
|
417
404
|
}),
|
|
418
405
|
async run(c) {
|
|
419
|
-
const a = await
|
|
406
|
+
const a = await getOpenfort().accounts.evm.backend.get({ id: c.args.id });
|
|
420
407
|
return c.ok({
|
|
421
408
|
id: a.id,
|
|
422
409
|
address: a.address,
|
|
@@ -426,43 +413,43 @@ evm.command("get", {
|
|
|
426
413
|
});
|
|
427
414
|
evm.command("delete", {
|
|
428
415
|
description: "Delete an EVM backend wallet.",
|
|
429
|
-
args:
|
|
430
|
-
id:
|
|
416
|
+
args: z2.object({
|
|
417
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
431
418
|
}),
|
|
432
419
|
examples: [
|
|
433
420
|
{ args: { id: "acc_1a2b3c4d" }, description: "Delete a wallet" }
|
|
434
421
|
],
|
|
435
|
-
output:
|
|
436
|
-
id:
|
|
437
|
-
deleted:
|
|
422
|
+
output: z2.object({
|
|
423
|
+
id: z2.string(),
|
|
424
|
+
deleted: z2.boolean()
|
|
438
425
|
}),
|
|
439
426
|
async run(c) {
|
|
440
|
-
const res = await
|
|
427
|
+
const res = await getOpenfort().accounts.evm.backend.delete(c.args.id);
|
|
441
428
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
442
429
|
}
|
|
443
430
|
});
|
|
444
431
|
evm.command("update", {
|
|
445
432
|
description: "Upgrade an EVM backend wallet to a delegated account (EIP-7702).",
|
|
446
|
-
args:
|
|
447
|
-
id:
|
|
433
|
+
args: z2.object({
|
|
434
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
448
435
|
}),
|
|
449
|
-
options:
|
|
450
|
-
chainId:
|
|
451
|
-
implementationType:
|
|
436
|
+
options: z2.object({
|
|
437
|
+
chainId: z2.number().describe("Chain ID to deploy on"),
|
|
438
|
+
implementationType: z2.string().describe("Target implementation type (e.g. CaliburV9)")
|
|
452
439
|
}),
|
|
453
440
|
examples: [
|
|
454
441
|
{ args: { id: "acc_1a2b3c4d" }, options: { chainId: 8453, implementationType: "CaliburV9" }, description: "Upgrade to delegated account on Base" }
|
|
455
442
|
],
|
|
456
|
-
output:
|
|
457
|
-
id:
|
|
458
|
-
address:
|
|
459
|
-
accountType:
|
|
460
|
-
chainId:
|
|
461
|
-
chainType:
|
|
443
|
+
output: z2.object({
|
|
444
|
+
id: z2.string(),
|
|
445
|
+
address: z2.string(),
|
|
446
|
+
accountType: z2.string(),
|
|
447
|
+
chainId: z2.number().optional(),
|
|
448
|
+
chainType: z2.string()
|
|
462
449
|
}),
|
|
463
450
|
async run(c) {
|
|
464
|
-
const account = await
|
|
465
|
-
const res = await
|
|
451
|
+
const account = await getOpenfort().accounts.evm.backend.get({ id: c.args.id });
|
|
452
|
+
const res = await getOpenfort().accounts.evm.backend.update({
|
|
466
453
|
walletId: account.walletId,
|
|
467
454
|
chainId: c.options.chainId,
|
|
468
455
|
accountId: account.id,
|
|
@@ -489,22 +476,22 @@ evm.command("update", {
|
|
|
489
476
|
});
|
|
490
477
|
evm.command("sign", {
|
|
491
478
|
description: "Sign data with an EVM backend wallet.",
|
|
492
|
-
args:
|
|
493
|
-
id:
|
|
479
|
+
args: z2.object({
|
|
480
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
494
481
|
}),
|
|
495
|
-
options:
|
|
496
|
-
data:
|
|
482
|
+
options: z2.object({
|
|
483
|
+
data: z2.string().describe("Hex-encoded data to sign")
|
|
497
484
|
}),
|
|
498
485
|
examples: [
|
|
499
486
|
{ args: { id: "acc_1a2b3c4d" }, options: { data: "0xdeadbeef" }, description: "Sign a message hash" }
|
|
500
487
|
],
|
|
501
488
|
hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
|
|
502
489
|
middleware: [requireWallet],
|
|
503
|
-
output:
|
|
504
|
-
signature:
|
|
490
|
+
output: z2.object({
|
|
491
|
+
signature: z2.string()
|
|
505
492
|
}),
|
|
506
493
|
async run(c) {
|
|
507
|
-
const signature = await
|
|
494
|
+
const signature = await getOpenfort().accounts.evm.backend.sign({
|
|
508
495
|
id: c.args.id,
|
|
509
496
|
data: c.options.data
|
|
510
497
|
});
|
|
@@ -513,21 +500,21 @@ evm.command("sign", {
|
|
|
513
500
|
});
|
|
514
501
|
evm.command("import", {
|
|
515
502
|
description: "Import a private key as an EVM backend wallet.",
|
|
516
|
-
options:
|
|
517
|
-
privateKey:
|
|
503
|
+
options: z2.object({
|
|
504
|
+
privateKey: z2.string().describe("Private key (hex string)")
|
|
518
505
|
}),
|
|
519
506
|
examples: [
|
|
520
507
|
{ options: { privateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" }, description: "Import a private key" }
|
|
521
508
|
],
|
|
522
509
|
hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
|
|
523
510
|
middleware: [requireWallet],
|
|
524
|
-
output:
|
|
525
|
-
id:
|
|
526
|
-
address:
|
|
527
|
-
custody:
|
|
511
|
+
output: z2.object({
|
|
512
|
+
id: z2.string(),
|
|
513
|
+
address: z2.string(),
|
|
514
|
+
custody: z2.string()
|
|
528
515
|
}),
|
|
529
516
|
async run(c) {
|
|
530
|
-
const account = await
|
|
517
|
+
const account = await getOpenfort().accounts.evm.backend.import({
|
|
531
518
|
privateKey: c.options.privateKey
|
|
532
519
|
});
|
|
533
520
|
return c.ok({
|
|
@@ -539,18 +526,18 @@ evm.command("import", {
|
|
|
539
526
|
});
|
|
540
527
|
evm.command("export", {
|
|
541
528
|
description: "Export an EVM backend wallet private key.",
|
|
542
|
-
args:
|
|
543
|
-
id:
|
|
529
|
+
args: z2.object({
|
|
530
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
544
531
|
}),
|
|
545
532
|
examples: [
|
|
546
533
|
{ args: { id: "acc_1a2b3c4d" }, description: "Export private key" }
|
|
547
534
|
],
|
|
548
535
|
middleware: [requireWallet],
|
|
549
|
-
output:
|
|
550
|
-
privateKey:
|
|
536
|
+
output: z2.object({
|
|
537
|
+
privateKey: z2.string()
|
|
551
538
|
}),
|
|
552
539
|
async run(c) {
|
|
553
|
-
const privateKey = await
|
|
540
|
+
const privateKey = await getOpenfort().accounts.evm.backend.export({
|
|
554
541
|
id: c.args.id
|
|
555
542
|
});
|
|
556
543
|
return c.ok({ privateKey });
|
|
@@ -558,13 +545,13 @@ evm.command("export", {
|
|
|
558
545
|
});
|
|
559
546
|
evm.command("send-transaction", {
|
|
560
547
|
description: "Send a gasless EVM transaction (auto-delegates via EIP-7702 if needed).",
|
|
561
|
-
args:
|
|
562
|
-
id:
|
|
548
|
+
args: z2.object({
|
|
549
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
563
550
|
}),
|
|
564
|
-
options:
|
|
565
|
-
chainId:
|
|
566
|
-
interactions:
|
|
567
|
-
policy:
|
|
551
|
+
options: z2.object({
|
|
552
|
+
chainId: z2.number().describe("Chain ID"),
|
|
553
|
+
interactions: z2.string().describe('Interactions as JSON: [{"to":"0x...","data":"0x...","value":"0"}]'),
|
|
554
|
+
policy: z2.string().optional().describe("Fee sponsorship ID (pol_...)")
|
|
568
555
|
}),
|
|
569
556
|
examples: [
|
|
570
557
|
{
|
|
@@ -577,15 +564,15 @@ evm.command("send-transaction", {
|
|
|
577
564
|
}
|
|
578
565
|
],
|
|
579
566
|
middleware: [requireWallet],
|
|
580
|
-
output:
|
|
581
|
-
id:
|
|
582
|
-
chainId:
|
|
583
|
-
transactionHash:
|
|
567
|
+
output: z2.object({
|
|
568
|
+
id: z2.string(),
|
|
569
|
+
chainId: z2.number(),
|
|
570
|
+
transactionHash: z2.string().optional()
|
|
584
571
|
}),
|
|
585
572
|
async run(c) {
|
|
586
|
-
const account = await
|
|
573
|
+
const account = await getOpenfort().accounts.evm.backend.get({ id: c.args.id });
|
|
587
574
|
const interactions = JSON.parse(c.options.interactions);
|
|
588
|
-
const res = await
|
|
575
|
+
const res = await getOpenfort().accounts.evm.backend.sendTransaction({
|
|
589
576
|
account,
|
|
590
577
|
chainId: c.options.chainId,
|
|
591
578
|
interactions,
|
|
@@ -599,8 +586,7 @@ evm.command("send-transaction", {
|
|
|
599
586
|
}
|
|
600
587
|
});
|
|
601
588
|
var solana = Cli2.create("solana", {
|
|
602
|
-
description: "Solana wallet management."
|
|
603
|
-
vars: varsSchema
|
|
589
|
+
description: "Solana wallet management."
|
|
604
590
|
});
|
|
605
591
|
solana.command("create", {
|
|
606
592
|
description: "Create a new Solana backend wallet.",
|
|
@@ -609,13 +595,13 @@ solana.command("create", {
|
|
|
609
595
|
],
|
|
610
596
|
hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
|
|
611
597
|
middleware: [requireWallet],
|
|
612
|
-
output:
|
|
613
|
-
id:
|
|
614
|
-
address:
|
|
615
|
-
custody:
|
|
598
|
+
output: z2.object({
|
|
599
|
+
id: z2.string().describe("Account ID"),
|
|
600
|
+
address: z2.string().describe("Wallet address"),
|
|
601
|
+
custody: z2.string().describe("Custody type")
|
|
616
602
|
}),
|
|
617
603
|
async run(c) {
|
|
618
|
-
const account = await
|
|
604
|
+
const account = await getOpenfort().accounts.solana.backend.create();
|
|
619
605
|
return c.ok(
|
|
620
606
|
{ id: account.id, address: account.address, custody: account.custody },
|
|
621
607
|
{
|
|
@@ -631,24 +617,24 @@ solana.command("create", {
|
|
|
631
617
|
});
|
|
632
618
|
solana.command("list", {
|
|
633
619
|
description: "List Solana backend wallets.",
|
|
634
|
-
options:
|
|
635
|
-
limit:
|
|
636
|
-
skip:
|
|
620
|
+
options: z2.object({
|
|
621
|
+
limit: z2.number().optional().describe("Max results"),
|
|
622
|
+
skip: z2.number().optional().describe("Offset")
|
|
637
623
|
}),
|
|
638
624
|
alias: { limit: "l" },
|
|
639
625
|
examples: [
|
|
640
626
|
{ description: "List all Solana wallets" }
|
|
641
627
|
],
|
|
642
|
-
output:
|
|
643
|
-
accounts:
|
|
644
|
-
id:
|
|
645
|
-
address:
|
|
646
|
-
custody:
|
|
628
|
+
output: z2.object({
|
|
629
|
+
accounts: z2.array(z2.object({
|
|
630
|
+
id: z2.string(),
|
|
631
|
+
address: z2.string(),
|
|
632
|
+
custody: z2.string()
|
|
647
633
|
})),
|
|
648
|
-
total:
|
|
634
|
+
total: z2.number().optional()
|
|
649
635
|
}),
|
|
650
636
|
async run(c) {
|
|
651
|
-
const res = await
|
|
637
|
+
const res = await getOpenfort().accounts.solana.backend.list({
|
|
652
638
|
limit: c.options.limit,
|
|
653
639
|
skip: c.options.skip
|
|
654
640
|
});
|
|
@@ -664,19 +650,19 @@ solana.command("list", {
|
|
|
664
650
|
});
|
|
665
651
|
solana.command("get", {
|
|
666
652
|
description: "Get a Solana backend wallet by ID or address.",
|
|
667
|
-
args:
|
|
668
|
-
id:
|
|
653
|
+
args: z2.object({
|
|
654
|
+
id: z2.string().describe("Account ID or address")
|
|
669
655
|
}),
|
|
670
656
|
examples: [
|
|
671
657
|
{ args: { id: "acc_1a2b3c4d" }, description: "Get wallet by ID" }
|
|
672
658
|
],
|
|
673
|
-
output:
|
|
674
|
-
id:
|
|
675
|
-
address:
|
|
676
|
-
custody:
|
|
659
|
+
output: z2.object({
|
|
660
|
+
id: z2.string(),
|
|
661
|
+
address: z2.string(),
|
|
662
|
+
custody: z2.string()
|
|
677
663
|
}),
|
|
678
664
|
async run(c) {
|
|
679
|
-
const a = await
|
|
665
|
+
const a = await getOpenfort().accounts.solana.backend.get({ id: c.args.id });
|
|
680
666
|
return c.ok({
|
|
681
667
|
id: a.id,
|
|
682
668
|
address: a.address,
|
|
@@ -686,18 +672,18 @@ solana.command("get", {
|
|
|
686
672
|
});
|
|
687
673
|
solana.command("sign", {
|
|
688
674
|
description: "Sign data with a Solana backend wallet.",
|
|
689
|
-
args:
|
|
690
|
-
id:
|
|
675
|
+
args: z2.object({
|
|
676
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
691
677
|
}),
|
|
692
|
-
options:
|
|
693
|
-
data:
|
|
678
|
+
options: z2.object({
|
|
679
|
+
data: z2.string().describe("Data to sign (base64-encoded)")
|
|
694
680
|
}),
|
|
695
681
|
alias: { data: "d" },
|
|
696
682
|
hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
|
|
697
683
|
middleware: [requireWallet],
|
|
698
|
-
output:
|
|
699
|
-
account:
|
|
700
|
-
signature:
|
|
684
|
+
output: z2.object({
|
|
685
|
+
account: z2.string(),
|
|
686
|
+
signature: z2.string()
|
|
701
687
|
}),
|
|
702
688
|
examples: [
|
|
703
689
|
{
|
|
@@ -707,44 +693,44 @@ solana.command("sign", {
|
|
|
707
693
|
}
|
|
708
694
|
],
|
|
709
695
|
async run(c) {
|
|
710
|
-
const signature = await
|
|
696
|
+
const signature = await getOpenfort().accounts.solana.backend.sign(c.args.id, c.options.data);
|
|
711
697
|
return c.ok({ account: c.args.id, signature });
|
|
712
698
|
}
|
|
713
699
|
});
|
|
714
700
|
solana.command("delete", {
|
|
715
701
|
description: "Delete a Solana backend wallet.",
|
|
716
|
-
args:
|
|
717
|
-
id:
|
|
702
|
+
args: z2.object({
|
|
703
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
718
704
|
}),
|
|
719
705
|
examples: [
|
|
720
706
|
{ args: { id: "acc_1a2b3c4d" }, description: "Delete a wallet" }
|
|
721
707
|
],
|
|
722
|
-
output:
|
|
723
|
-
id:
|
|
724
|
-
deleted:
|
|
708
|
+
output: z2.object({
|
|
709
|
+
id: z2.string(),
|
|
710
|
+
deleted: z2.boolean()
|
|
725
711
|
}),
|
|
726
712
|
async run(c) {
|
|
727
|
-
const res = await
|
|
713
|
+
const res = await getOpenfort().accounts.solana.backend.delete(c.args.id);
|
|
728
714
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
729
715
|
}
|
|
730
716
|
});
|
|
731
717
|
solana.command("import", {
|
|
732
718
|
description: "Import a private key as a Solana backend wallet.",
|
|
733
|
-
options:
|
|
734
|
-
privateKey:
|
|
719
|
+
options: z2.object({
|
|
720
|
+
privateKey: z2.string().describe("Private key (hex-encoded 32 bytes or base58)")
|
|
735
721
|
}),
|
|
736
722
|
examples: [
|
|
737
723
|
{ options: { privateKey: "abc123..." }, description: "Import a Solana private key" }
|
|
738
724
|
],
|
|
739
725
|
hint: "Requires OPENFORT_WALLET_SECRET and OPENFORT_PUBLISHABLE_KEY.",
|
|
740
726
|
middleware: [requireWallet],
|
|
741
|
-
output:
|
|
742
|
-
id:
|
|
743
|
-
address:
|
|
744
|
-
custody:
|
|
727
|
+
output: z2.object({
|
|
728
|
+
id: z2.string(),
|
|
729
|
+
address: z2.string(),
|
|
730
|
+
custody: z2.string()
|
|
745
731
|
}),
|
|
746
732
|
async run(c) {
|
|
747
|
-
const account = await
|
|
733
|
+
const account = await getOpenfort().accounts.solana.backend.import({
|
|
748
734
|
privateKey: c.options.privateKey
|
|
749
735
|
});
|
|
750
736
|
return c.ok({
|
|
@@ -756,18 +742,18 @@ solana.command("import", {
|
|
|
756
742
|
});
|
|
757
743
|
solana.command("export", {
|
|
758
744
|
description: "Export a Solana backend wallet private key.",
|
|
759
|
-
args:
|
|
760
|
-
id:
|
|
745
|
+
args: z2.object({
|
|
746
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
761
747
|
}),
|
|
762
748
|
examples: [
|
|
763
749
|
{ args: { id: "acc_1a2b3c4d" }, description: "Export private key" }
|
|
764
750
|
],
|
|
765
751
|
middleware: [requireWallet],
|
|
766
|
-
output:
|
|
767
|
-
privateKey:
|
|
752
|
+
output: z2.object({
|
|
753
|
+
privateKey: z2.string()
|
|
768
754
|
}),
|
|
769
755
|
async run(c) {
|
|
770
|
-
const privateKey = await
|
|
756
|
+
const privateKey = await getOpenfort().accounts.solana.backend.export({
|
|
771
757
|
id: c.args.id
|
|
772
758
|
});
|
|
773
759
|
return c.ok({ privateKey });
|
|
@@ -775,14 +761,14 @@ solana.command("export", {
|
|
|
775
761
|
});
|
|
776
762
|
solana.command("transfer", {
|
|
777
763
|
description: "Transfer SOL or SPL tokens.",
|
|
778
|
-
args:
|
|
779
|
-
id:
|
|
764
|
+
args: z2.object({
|
|
765
|
+
id: z2.string().describe("Account ID (acc_...)")
|
|
780
766
|
}),
|
|
781
|
-
options:
|
|
782
|
-
to:
|
|
783
|
-
amount:
|
|
784
|
-
token:
|
|
785
|
-
cluster:
|
|
767
|
+
options: z2.object({
|
|
768
|
+
to: z2.string().describe("Destination address (base58)"),
|
|
769
|
+
amount: z2.string().describe("Amount in base units (lamports for SOL)"),
|
|
770
|
+
token: z2.string().optional().describe('Token: "sol" (default), "usdc", or mint address'),
|
|
771
|
+
cluster: z2.enum(["devnet", "mainnet-beta"]).default("mainnet-beta").describe("Cluster: devnet or mainnet-beta")
|
|
786
772
|
}),
|
|
787
773
|
examples: [
|
|
788
774
|
{
|
|
@@ -797,12 +783,12 @@ solana.command("transfer", {
|
|
|
797
783
|
}
|
|
798
784
|
],
|
|
799
785
|
middleware: [requireWallet],
|
|
800
|
-
output:
|
|
801
|
-
signature:
|
|
786
|
+
output: z2.object({
|
|
787
|
+
signature: z2.string()
|
|
802
788
|
}),
|
|
803
789
|
async run(c) {
|
|
804
|
-
const account = await
|
|
805
|
-
const res = await
|
|
790
|
+
const account = await getOpenfort().accounts.solana.backend.get({ id: c.args.id });
|
|
791
|
+
const res = await getOpenfort().accounts.solana.backend.transfer({
|
|
806
792
|
account,
|
|
807
793
|
to: c.options.to,
|
|
808
794
|
amount: BigInt(c.options.amount),
|
|
@@ -813,16 +799,15 @@ solana.command("transfer", {
|
|
|
813
799
|
}
|
|
814
800
|
});
|
|
815
801
|
var accounts = Cli2.create("accounts", {
|
|
816
|
-
description: "Manage wallets and accounts."
|
|
817
|
-
vars: varsSchema
|
|
802
|
+
description: "Manage wallets and accounts."
|
|
818
803
|
});
|
|
819
804
|
accounts.command("list", {
|
|
820
805
|
description: "List all accounts across chains.",
|
|
821
|
-
options:
|
|
822
|
-
limit:
|
|
823
|
-
skip:
|
|
824
|
-
chainType:
|
|
825
|
-
custody:
|
|
806
|
+
options: z2.object({
|
|
807
|
+
limit: z2.number().optional().describe("Max results"),
|
|
808
|
+
skip: z2.number().optional().describe("Offset"),
|
|
809
|
+
chainType: z2.enum(["EVM", "SVM"]).optional().describe("Filter by chain type"),
|
|
810
|
+
custody: z2.enum(["Developer", "User"]).optional().describe("Filter by custody")
|
|
826
811
|
}),
|
|
827
812
|
alias: { limit: "l" },
|
|
828
813
|
examples: [
|
|
@@ -830,23 +815,23 @@ accounts.command("list", {
|
|
|
830
815
|
{ options: { chainType: "EVM" }, description: "Filter to EVM accounts only" },
|
|
831
816
|
{ options: { custody: "Developer", limit: 10 }, description: "List developer-custody wallets" }
|
|
832
817
|
],
|
|
833
|
-
output:
|
|
834
|
-
data:
|
|
835
|
-
id:
|
|
836
|
-
wallet:
|
|
837
|
-
accountType:
|
|
838
|
-
address:
|
|
839
|
-
ownerAddress:
|
|
840
|
-
chainType:
|
|
841
|
-
chainId:
|
|
842
|
-
custody:
|
|
843
|
-
createdAt:
|
|
844
|
-
updatedAt:
|
|
818
|
+
output: z2.object({
|
|
819
|
+
data: z2.array(z2.object({
|
|
820
|
+
id: z2.string(),
|
|
821
|
+
wallet: z2.string().describe("Wallet ID"),
|
|
822
|
+
accountType: z2.string().describe("Account type"),
|
|
823
|
+
address: z2.string(),
|
|
824
|
+
ownerAddress: z2.string().optional(),
|
|
825
|
+
chainType: z2.string(),
|
|
826
|
+
chainId: z2.number().optional(),
|
|
827
|
+
custody: z2.string(),
|
|
828
|
+
createdAt: z2.number(),
|
|
829
|
+
updatedAt: z2.number()
|
|
845
830
|
})),
|
|
846
|
-
total:
|
|
831
|
+
total: z2.number()
|
|
847
832
|
}),
|
|
848
833
|
async run(c) {
|
|
849
|
-
const res = await
|
|
834
|
+
const res = await getOpenfort().accounts.list({
|
|
850
835
|
limit: c.options.limit,
|
|
851
836
|
skip: c.options.skip,
|
|
852
837
|
chainType: c.options.chainType,
|
|
@@ -873,38 +858,37 @@ accounts.command(evm);
|
|
|
873
858
|
accounts.command(solana);
|
|
874
859
|
|
|
875
860
|
// src/commands/contracts.ts
|
|
876
|
-
import { Cli as Cli3, z as
|
|
877
|
-
var contractItem =
|
|
878
|
-
id:
|
|
879
|
-
createdAt:
|
|
880
|
-
name:
|
|
881
|
-
chainId:
|
|
882
|
-
address:
|
|
883
|
-
deleted:
|
|
884
|
-
abi:
|
|
885
|
-
publicVerification:
|
|
861
|
+
import { Cli as Cli3, z as z3 } from "incur";
|
|
862
|
+
var contractItem = z3.object({
|
|
863
|
+
id: z3.string(),
|
|
864
|
+
createdAt: z3.number(),
|
|
865
|
+
name: z3.string().nullable(),
|
|
866
|
+
chainId: z3.number(),
|
|
867
|
+
address: z3.string(),
|
|
868
|
+
deleted: z3.boolean(),
|
|
869
|
+
abi: z3.array(z3.record(z3.string(), z3.unknown())),
|
|
870
|
+
publicVerification: z3.boolean()
|
|
886
871
|
});
|
|
887
872
|
var contracts = Cli3.create("contracts", {
|
|
888
|
-
description: "Manage smart contracts."
|
|
889
|
-
vars: varsSchema
|
|
873
|
+
description: "Manage smart contracts."
|
|
890
874
|
});
|
|
891
875
|
contracts.command("list", {
|
|
892
876
|
description: "List registered contracts.",
|
|
893
|
-
options:
|
|
894
|
-
limit:
|
|
895
|
-
skip:
|
|
877
|
+
options: z3.object({
|
|
878
|
+
limit: z3.number().optional().describe("Max results"),
|
|
879
|
+
skip: z3.number().optional().describe("Offset")
|
|
896
880
|
}),
|
|
897
881
|
alias: { limit: "l" },
|
|
898
882
|
examples: [
|
|
899
883
|
{ description: "List all contracts" },
|
|
900
884
|
{ options: { limit: 5 }, description: "List first 5 contracts" }
|
|
901
885
|
],
|
|
902
|
-
output:
|
|
903
|
-
data:
|
|
904
|
-
total:
|
|
886
|
+
output: z3.object({
|
|
887
|
+
data: z3.array(contractItem),
|
|
888
|
+
total: z3.number()
|
|
905
889
|
}),
|
|
906
890
|
async run(c) {
|
|
907
|
-
const res = await
|
|
891
|
+
const res = await getOpenfort().contracts.list({
|
|
908
892
|
limit: c.options.limit,
|
|
909
893
|
skip: c.options.skip
|
|
910
894
|
});
|
|
@@ -925,11 +909,11 @@ contracts.command("list", {
|
|
|
925
909
|
});
|
|
926
910
|
contracts.command("create", {
|
|
927
911
|
description: "Register a smart contract.",
|
|
928
|
-
options:
|
|
929
|
-
name:
|
|
930
|
-
address:
|
|
931
|
-
chainId:
|
|
932
|
-
abi:
|
|
912
|
+
options: z3.object({
|
|
913
|
+
name: z3.string().describe("Contract name"),
|
|
914
|
+
address: z3.string().describe("Contract address"),
|
|
915
|
+
chainId: z3.number().describe("Chain ID"),
|
|
916
|
+
abi: z3.string().optional().describe("Contract ABI as JSON string")
|
|
933
917
|
}),
|
|
934
918
|
output: contractItem,
|
|
935
919
|
examples: [
|
|
@@ -943,7 +927,7 @@ contracts.command("create", {
|
|
|
943
927
|
}
|
|
944
928
|
],
|
|
945
929
|
async run(c) {
|
|
946
|
-
const res = await
|
|
930
|
+
const res = await getOpenfort().contracts.create({
|
|
947
931
|
name: c.options.name,
|
|
948
932
|
address: c.options.address,
|
|
949
933
|
chainId: c.options.chainId,
|
|
@@ -974,15 +958,15 @@ contracts.command("create", {
|
|
|
974
958
|
});
|
|
975
959
|
contracts.command("get", {
|
|
976
960
|
description: "Get a contract by ID.",
|
|
977
|
-
args:
|
|
978
|
-
id:
|
|
961
|
+
args: z3.object({
|
|
962
|
+
id: z3.string().describe("Contract ID (con_...)")
|
|
979
963
|
}),
|
|
980
964
|
examples: [
|
|
981
965
|
{ args: { id: "con_1a2b3c4d" }, description: "Get contract details" }
|
|
982
966
|
],
|
|
983
967
|
output: contractItem,
|
|
984
968
|
async run(c) {
|
|
985
|
-
const ct = await
|
|
969
|
+
const ct = await getOpenfort().contracts.get(c.args.id);
|
|
986
970
|
return c.ok({
|
|
987
971
|
id: ct.id,
|
|
988
972
|
createdAt: ct.createdAt,
|
|
@@ -997,21 +981,21 @@ contracts.command("get", {
|
|
|
997
981
|
});
|
|
998
982
|
contracts.command("update", {
|
|
999
983
|
description: "Update a contract.",
|
|
1000
|
-
args:
|
|
1001
|
-
id:
|
|
984
|
+
args: z3.object({
|
|
985
|
+
id: z3.string().describe("Contract ID (con_...)")
|
|
1002
986
|
}),
|
|
1003
|
-
options:
|
|
1004
|
-
name:
|
|
1005
|
-
address:
|
|
1006
|
-
chainId:
|
|
1007
|
-
abi:
|
|
987
|
+
options: z3.object({
|
|
988
|
+
name: z3.string().optional().describe("New name"),
|
|
989
|
+
address: z3.string().optional().describe("New address"),
|
|
990
|
+
chainId: z3.number().optional().describe("New chain ID"),
|
|
991
|
+
abi: z3.string().optional().describe("New ABI as JSON string")
|
|
1008
992
|
}),
|
|
1009
993
|
examples: [
|
|
1010
994
|
{ args: { id: "con_1a2b3c4d" }, options: { name: "USDC v2" }, description: "Rename a contract" }
|
|
1011
995
|
],
|
|
1012
996
|
output: contractItem,
|
|
1013
997
|
async run(c) {
|
|
1014
|
-
const res = await
|
|
998
|
+
const res = await getOpenfort().contracts.update(c.args.id, {
|
|
1015
999
|
name: c.options.name,
|
|
1016
1000
|
address: c.options.address,
|
|
1017
1001
|
chainId: c.options.chainId,
|
|
@@ -1031,48 +1015,47 @@ contracts.command("update", {
|
|
|
1031
1015
|
});
|
|
1032
1016
|
contracts.command("delete", {
|
|
1033
1017
|
description: "Delete a contract.",
|
|
1034
|
-
args:
|
|
1035
|
-
id:
|
|
1018
|
+
args: z3.object({
|
|
1019
|
+
id: z3.string().describe("Contract ID (con_...)")
|
|
1036
1020
|
}),
|
|
1037
1021
|
examples: [
|
|
1038
1022
|
{ args: { id: "con_1a2b3c4d" }, description: "Delete a contract" }
|
|
1039
1023
|
],
|
|
1040
|
-
output:
|
|
1041
|
-
id:
|
|
1042
|
-
deleted:
|
|
1024
|
+
output: z3.object({
|
|
1025
|
+
id: z3.string(),
|
|
1026
|
+
deleted: z3.boolean()
|
|
1043
1027
|
}),
|
|
1044
1028
|
async run(c) {
|
|
1045
|
-
const res = await
|
|
1029
|
+
const res = await getOpenfort().contracts.delete(c.args.id);
|
|
1046
1030
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1047
1031
|
}
|
|
1048
1032
|
});
|
|
1049
1033
|
|
|
1050
1034
|
// src/commands/paymasters.ts
|
|
1051
|
-
import { Cli as Cli4, z as
|
|
1052
|
-
var paymasterItem =
|
|
1053
|
-
id:
|
|
1054
|
-
createdAt:
|
|
1055
|
-
address:
|
|
1056
|
-
url:
|
|
1057
|
-
context:
|
|
1035
|
+
import { Cli as Cli4, z as z4 } from "incur";
|
|
1036
|
+
var paymasterItem = z4.object({
|
|
1037
|
+
id: z4.string(),
|
|
1038
|
+
createdAt: z4.number(),
|
|
1039
|
+
address: z4.string(),
|
|
1040
|
+
url: z4.string().optional(),
|
|
1041
|
+
context: z4.record(z4.string(), z4.unknown()).optional()
|
|
1058
1042
|
});
|
|
1059
1043
|
var paymasters = Cli4.create("paymasters", {
|
|
1060
|
-
description: "Manage ERC-4337 paymasters."
|
|
1061
|
-
vars: varsSchema
|
|
1044
|
+
description: "Manage ERC-4337 paymasters."
|
|
1062
1045
|
});
|
|
1063
1046
|
paymasters.command("create", {
|
|
1064
1047
|
description: "Create a paymaster.",
|
|
1065
|
-
options:
|
|
1066
|
-
address:
|
|
1067
|
-
name:
|
|
1068
|
-
url:
|
|
1048
|
+
options: z4.object({
|
|
1049
|
+
address: z4.string().describe("Paymaster contract address"),
|
|
1050
|
+
name: z4.string().optional().describe("Paymaster name"),
|
|
1051
|
+
url: z4.string().optional().describe("Paymaster URL")
|
|
1069
1052
|
}),
|
|
1070
1053
|
examples: [
|
|
1071
1054
|
{ options: { address: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", name: "EntryPoint v0.6 Paymaster" }, description: "Create a paymaster for ERC-4337 v0.6" }
|
|
1072
1055
|
],
|
|
1073
1056
|
output: paymasterItem,
|
|
1074
1057
|
async run(c) {
|
|
1075
|
-
const res = await
|
|
1058
|
+
const res = await getOpenfort().paymasters.create({
|
|
1076
1059
|
address: c.options.address,
|
|
1077
1060
|
name: c.options.name,
|
|
1078
1061
|
url: c.options.url
|
|
@@ -1099,15 +1082,15 @@ paymasters.command("create", {
|
|
|
1099
1082
|
});
|
|
1100
1083
|
paymasters.command("get", {
|
|
1101
1084
|
description: "Get a paymaster by ID.",
|
|
1102
|
-
args:
|
|
1103
|
-
id:
|
|
1085
|
+
args: z4.object({
|
|
1086
|
+
id: z4.string().describe("Paymaster ID (pay_...)")
|
|
1104
1087
|
}),
|
|
1105
1088
|
examples: [
|
|
1106
1089
|
{ args: { id: "pay_1a2b3c4d" }, description: "Get paymaster details" }
|
|
1107
1090
|
],
|
|
1108
1091
|
output: paymasterItem,
|
|
1109
1092
|
async run(c) {
|
|
1110
|
-
const p = await
|
|
1093
|
+
const p = await getOpenfort().paymasters.get(c.args.id);
|
|
1111
1094
|
return c.ok({
|
|
1112
1095
|
id: p.id,
|
|
1113
1096
|
createdAt: p.createdAt,
|
|
@@ -1119,20 +1102,20 @@ paymasters.command("get", {
|
|
|
1119
1102
|
});
|
|
1120
1103
|
paymasters.command("update", {
|
|
1121
1104
|
description: "Update a paymaster.",
|
|
1122
|
-
args:
|
|
1123
|
-
id:
|
|
1105
|
+
args: z4.object({
|
|
1106
|
+
id: z4.string().describe("Paymaster ID (pay_...)")
|
|
1124
1107
|
}),
|
|
1125
|
-
options:
|
|
1126
|
-
address:
|
|
1127
|
-
name:
|
|
1128
|
-
url:
|
|
1108
|
+
options: z4.object({
|
|
1109
|
+
address: z4.string().describe("Paymaster address"),
|
|
1110
|
+
name: z4.string().optional().describe("New name"),
|
|
1111
|
+
url: z4.string().optional().describe("New URL")
|
|
1129
1112
|
}),
|
|
1130
1113
|
examples: [
|
|
1131
1114
|
{ args: { id: "pay_1a2b3c4d" }, options: { address: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", name: "Updated Paymaster" }, description: "Update paymaster name" }
|
|
1132
1115
|
],
|
|
1133
1116
|
output: paymasterItem,
|
|
1134
1117
|
async run(c) {
|
|
1135
|
-
const res = await
|
|
1118
|
+
const res = await getOpenfort().paymasters.update(c.args.id, {
|
|
1136
1119
|
address: c.options.address,
|
|
1137
1120
|
name: c.options.name,
|
|
1138
1121
|
url: c.options.url
|
|
@@ -1148,57 +1131,56 @@ paymasters.command("update", {
|
|
|
1148
1131
|
});
|
|
1149
1132
|
paymasters.command("delete", {
|
|
1150
1133
|
description: "Delete a paymaster.",
|
|
1151
|
-
args:
|
|
1152
|
-
id:
|
|
1134
|
+
args: z4.object({
|
|
1135
|
+
id: z4.string().describe("Paymaster ID (pay_...)")
|
|
1153
1136
|
}),
|
|
1154
1137
|
examples: [
|
|
1155
1138
|
{ args: { id: "pay_1a2b3c4d" }, description: "Delete a paymaster" }
|
|
1156
1139
|
],
|
|
1157
|
-
output:
|
|
1158
|
-
id:
|
|
1159
|
-
deleted:
|
|
1140
|
+
output: z4.object({
|
|
1141
|
+
id: z4.string(),
|
|
1142
|
+
deleted: z4.boolean()
|
|
1160
1143
|
}),
|
|
1161
1144
|
async run(c) {
|
|
1162
|
-
const res = await
|
|
1145
|
+
const res = await getOpenfort().paymasters.delete(c.args.id);
|
|
1163
1146
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1164
1147
|
}
|
|
1165
1148
|
});
|
|
1166
1149
|
|
|
1167
1150
|
// src/commands/policies.ts
|
|
1168
|
-
import { Cli as Cli5, z as
|
|
1151
|
+
import { Cli as Cli5, z as z5 } from "incur";
|
|
1169
1152
|
var policyScopes = ["project", "account", "transaction"];
|
|
1170
1153
|
var policies = Cli5.create("policies", {
|
|
1171
|
-
description: "Manage rules and conditions for backend wallets and fee sponsorship."
|
|
1172
|
-
vars: varsSchema
|
|
1154
|
+
description: "Manage rules and conditions for backend wallets and fee sponsorship."
|
|
1173
1155
|
});
|
|
1174
1156
|
policies.command("list", {
|
|
1175
1157
|
description: "List policies.",
|
|
1176
|
-
options:
|
|
1177
|
-
limit:
|
|
1178
|
-
skip:
|
|
1179
|
-
scope:
|
|
1180
|
-
enabled:
|
|
1158
|
+
options: z5.object({
|
|
1159
|
+
limit: z5.number().optional().describe("Max results"),
|
|
1160
|
+
skip: z5.number().optional().describe("Offset"),
|
|
1161
|
+
scope: z5.enum(policyScopes).optional().describe("Filter by scope"),
|
|
1162
|
+
enabled: z5.boolean().optional().describe("Filter by enabled status")
|
|
1181
1163
|
}),
|
|
1182
1164
|
alias: { limit: "l" },
|
|
1183
1165
|
examples: [
|
|
1184
1166
|
{ description: "List all policies" },
|
|
1185
1167
|
{ options: { scope: "project", enabled: true }, description: "List enabled project-scope policies" }
|
|
1186
1168
|
],
|
|
1187
|
-
output:
|
|
1188
|
-
data:
|
|
1189
|
-
id:
|
|
1190
|
-
createdAt:
|
|
1191
|
-
scope:
|
|
1192
|
-
description:
|
|
1193
|
-
accountId:
|
|
1194
|
-
enabled:
|
|
1195
|
-
priority:
|
|
1169
|
+
output: z5.object({
|
|
1170
|
+
data: z5.array(z5.object({
|
|
1171
|
+
id: z5.string(),
|
|
1172
|
+
createdAt: z5.number(),
|
|
1173
|
+
scope: z5.string(),
|
|
1174
|
+
description: z5.string().nullable(),
|
|
1175
|
+
accountId: z5.string().nullable(),
|
|
1176
|
+
enabled: z5.boolean(),
|
|
1177
|
+
priority: z5.number()
|
|
1196
1178
|
})),
|
|
1197
|
-
total:
|
|
1179
|
+
total: z5.number()
|
|
1198
1180
|
}),
|
|
1199
1181
|
async run(c) {
|
|
1200
1182
|
const scopeFilter = c.options.scope ? [c.options.scope] : void 0;
|
|
1201
|
-
const res = await
|
|
1183
|
+
const res = await getOpenfort().policies.list({
|
|
1202
1184
|
limit: c.options.limit,
|
|
1203
1185
|
skip: c.options.skip,
|
|
1204
1186
|
scope: scopeFilter,
|
|
@@ -1220,19 +1202,19 @@ policies.command("list", {
|
|
|
1220
1202
|
});
|
|
1221
1203
|
policies.command("create", {
|
|
1222
1204
|
description: "Create a policy with criteria-based rules.",
|
|
1223
|
-
options:
|
|
1224
|
-
scope:
|
|
1225
|
-
description:
|
|
1226
|
-
priority:
|
|
1227
|
-
rules:
|
|
1205
|
+
options: z5.object({
|
|
1206
|
+
scope: z5.enum(policyScopes).describe("Policy scope"),
|
|
1207
|
+
description: z5.string().optional().describe("Policy description"),
|
|
1208
|
+
priority: z5.number().optional().describe("Priority (higher = evaluated first)"),
|
|
1209
|
+
rules: z5.string().describe("Rules as JSON string")
|
|
1228
1210
|
}),
|
|
1229
|
-
output:
|
|
1230
|
-
id:
|
|
1231
|
-
createdAt:
|
|
1232
|
-
scope:
|
|
1233
|
-
description:
|
|
1234
|
-
enabled:
|
|
1235
|
-
priority:
|
|
1211
|
+
output: z5.object({
|
|
1212
|
+
id: z5.string(),
|
|
1213
|
+
createdAt: z5.number(),
|
|
1214
|
+
scope: z5.string(),
|
|
1215
|
+
description: z5.string().nullable(),
|
|
1216
|
+
enabled: z5.boolean(),
|
|
1217
|
+
priority: z5.number()
|
|
1236
1218
|
}),
|
|
1237
1219
|
examples: [
|
|
1238
1220
|
{
|
|
@@ -1254,7 +1236,7 @@ policies.command("create", {
|
|
|
1254
1236
|
async run(c) {
|
|
1255
1237
|
const rules = JSON.parse(c.options.rules);
|
|
1256
1238
|
const scope = c.options.scope;
|
|
1257
|
-
const res = await
|
|
1239
|
+
const res = await getOpenfort().policies.create({
|
|
1258
1240
|
scope,
|
|
1259
1241
|
description: c.options.description,
|
|
1260
1242
|
priority: c.options.priority,
|
|
@@ -1283,24 +1265,24 @@ policies.command("create", {
|
|
|
1283
1265
|
});
|
|
1284
1266
|
policies.command("get", {
|
|
1285
1267
|
description: "Get a policy by ID.",
|
|
1286
|
-
args:
|
|
1287
|
-
id:
|
|
1268
|
+
args: z5.object({
|
|
1269
|
+
id: z5.string().describe("Policy ID (ply_...)")
|
|
1288
1270
|
}),
|
|
1289
1271
|
examples: [
|
|
1290
1272
|
{ args: { id: "ply_1a2b3c4d" }, description: "Get policy details with rules" }
|
|
1291
1273
|
],
|
|
1292
|
-
output:
|
|
1293
|
-
id:
|
|
1294
|
-
createdAt:
|
|
1295
|
-
scope:
|
|
1296
|
-
description:
|
|
1297
|
-
accountId:
|
|
1298
|
-
enabled:
|
|
1299
|
-
priority:
|
|
1300
|
-
rules:
|
|
1274
|
+
output: z5.object({
|
|
1275
|
+
id: z5.string(),
|
|
1276
|
+
createdAt: z5.number(),
|
|
1277
|
+
scope: z5.string(),
|
|
1278
|
+
description: z5.string().nullable(),
|
|
1279
|
+
accountId: z5.string().nullable(),
|
|
1280
|
+
enabled: z5.boolean(),
|
|
1281
|
+
priority: z5.number(),
|
|
1282
|
+
rules: z5.array(z5.record(z5.string(), z5.unknown()))
|
|
1301
1283
|
}),
|
|
1302
1284
|
async run(c) {
|
|
1303
|
-
const p = await
|
|
1285
|
+
const p = await getOpenfort().policies.get(c.args.id);
|
|
1304
1286
|
return c.ok({
|
|
1305
1287
|
id: p.id,
|
|
1306
1288
|
createdAt: p.createdAt,
|
|
@@ -1315,29 +1297,29 @@ policies.command("get", {
|
|
|
1315
1297
|
});
|
|
1316
1298
|
policies.command("update", {
|
|
1317
1299
|
description: "Update a policy.",
|
|
1318
|
-
args:
|
|
1319
|
-
id:
|
|
1300
|
+
args: z5.object({
|
|
1301
|
+
id: z5.string().describe("Policy ID (ply_...)")
|
|
1320
1302
|
}),
|
|
1321
|
-
options:
|
|
1322
|
-
description:
|
|
1323
|
-
enabled:
|
|
1324
|
-
priority:
|
|
1325
|
-
rules:
|
|
1303
|
+
options: z5.object({
|
|
1304
|
+
description: z5.string().optional().describe("New description"),
|
|
1305
|
+
enabled: z5.boolean().optional().describe("Enable or disable"),
|
|
1306
|
+
priority: z5.number().optional().describe("New priority"),
|
|
1307
|
+
rules: z5.string().optional().describe("New rules as JSON string")
|
|
1326
1308
|
}),
|
|
1327
1309
|
examples: [
|
|
1328
1310
|
{ args: { id: "ply_1a2b3c4d" }, options: { enabled: false }, description: "Disable a policy" },
|
|
1329
1311
|
{ args: { id: "ply_1a2b3c4d" }, options: { priority: 10 }, description: "Change policy priority" }
|
|
1330
1312
|
],
|
|
1331
|
-
output:
|
|
1332
|
-
id:
|
|
1333
|
-
createdAt:
|
|
1334
|
-
scope:
|
|
1335
|
-
description:
|
|
1336
|
-
enabled:
|
|
1337
|
-
priority:
|
|
1313
|
+
output: z5.object({
|
|
1314
|
+
id: z5.string(),
|
|
1315
|
+
createdAt: z5.number(),
|
|
1316
|
+
scope: z5.string(),
|
|
1317
|
+
description: z5.string().nullable(),
|
|
1318
|
+
enabled: z5.boolean(),
|
|
1319
|
+
priority: z5.number()
|
|
1338
1320
|
}),
|
|
1339
1321
|
async run(c) {
|
|
1340
|
-
const res = await
|
|
1322
|
+
const res = await getOpenfort().policies.update(c.args.id, {
|
|
1341
1323
|
description: c.options.description,
|
|
1342
1324
|
enabled: c.options.enabled,
|
|
1343
1325
|
priority: c.options.priority,
|
|
@@ -1355,41 +1337,41 @@ policies.command("update", {
|
|
|
1355
1337
|
});
|
|
1356
1338
|
policies.command("delete", {
|
|
1357
1339
|
description: "Delete a policy.",
|
|
1358
|
-
args:
|
|
1359
|
-
id:
|
|
1340
|
+
args: z5.object({
|
|
1341
|
+
id: z5.string().describe("Policy ID (ply_...)")
|
|
1360
1342
|
}),
|
|
1361
1343
|
examples: [
|
|
1362
1344
|
{ args: { id: "ply_1a2b3c4d" }, description: "Delete a policy" }
|
|
1363
1345
|
],
|
|
1364
|
-
output:
|
|
1365
|
-
id:
|
|
1366
|
-
deleted:
|
|
1346
|
+
output: z5.object({
|
|
1347
|
+
id: z5.string(),
|
|
1348
|
+
deleted: z5.boolean()
|
|
1367
1349
|
}),
|
|
1368
1350
|
async run(c) {
|
|
1369
|
-
const res = await
|
|
1351
|
+
const res = await getOpenfort().policies.delete(c.args.id);
|
|
1370
1352
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1371
1353
|
}
|
|
1372
1354
|
});
|
|
1373
1355
|
policies.command("evaluate", {
|
|
1374
1356
|
description: "Pre-flight check if an operation would be allowed.",
|
|
1375
|
-
options:
|
|
1376
|
-
operation:
|
|
1377
|
-
accountId:
|
|
1357
|
+
options: z5.object({
|
|
1358
|
+
operation: z5.string().describe("Operation to evaluate (e.g. signEvmTransaction)"),
|
|
1359
|
+
accountId: z5.string().optional().describe("Account ID")
|
|
1378
1360
|
}),
|
|
1379
1361
|
examples: [
|
|
1380
1362
|
{ options: { operation: "signEvmTransaction", accountId: "acc_1a2b3c4d" }, description: "Check if EVM signing is allowed" },
|
|
1381
1363
|
{ options: { operation: "sponsorEvmTransaction" }, description: "Check if gas sponsorship is allowed" }
|
|
1382
1364
|
],
|
|
1383
|
-
output:
|
|
1384
|
-
allowed:
|
|
1385
|
-
reason:
|
|
1386
|
-
operation:
|
|
1387
|
-
accountId:
|
|
1388
|
-
matchedPolicyId:
|
|
1389
|
-
matchedRuleId:
|
|
1365
|
+
output: z5.object({
|
|
1366
|
+
allowed: z5.boolean(),
|
|
1367
|
+
reason: z5.string(),
|
|
1368
|
+
operation: z5.string(),
|
|
1369
|
+
accountId: z5.string().optional(),
|
|
1370
|
+
matchedPolicyId: z5.string().optional(),
|
|
1371
|
+
matchedRuleId: z5.string().optional()
|
|
1390
1372
|
}),
|
|
1391
1373
|
async run(c) {
|
|
1392
|
-
const res = await
|
|
1374
|
+
const res = await getOpenfort().policies.evaluate({
|
|
1393
1375
|
operation: c.options.operation,
|
|
1394
1376
|
accountId: c.options.accountId
|
|
1395
1377
|
});
|
|
@@ -1405,45 +1387,44 @@ policies.command("evaluate", {
|
|
|
1405
1387
|
});
|
|
1406
1388
|
|
|
1407
1389
|
// src/commands/sponsorship.ts
|
|
1408
|
-
import { Cli as Cli6, z as
|
|
1390
|
+
import { Cli as Cli6, z as z6 } from "incur";
|
|
1409
1391
|
var sponsorSchemas = ["pay_for_user", "charge_custom_tokens", "fixed_rate"];
|
|
1410
|
-
var sponsorshipItem =
|
|
1411
|
-
id:
|
|
1412
|
-
createdAt:
|
|
1413
|
-
name:
|
|
1414
|
-
chainId:
|
|
1415
|
-
enabled:
|
|
1416
|
-
strategy:
|
|
1417
|
-
sponsorSchema:
|
|
1418
|
-
tokenContract:
|
|
1419
|
-
tokenContractAmount:
|
|
1420
|
-
dynamicExchangeRate:
|
|
1421
|
-
}),
|
|
1422
|
-
paymasterId:
|
|
1423
|
-
policyId:
|
|
1392
|
+
var sponsorshipItem = z6.object({
|
|
1393
|
+
id: z6.string(),
|
|
1394
|
+
createdAt: z6.number(),
|
|
1395
|
+
name: z6.string().nullable(),
|
|
1396
|
+
chainId: z6.number().nullable(),
|
|
1397
|
+
enabled: z6.boolean(),
|
|
1398
|
+
strategy: z6.object({
|
|
1399
|
+
sponsorSchema: z6.string(),
|
|
1400
|
+
tokenContract: z6.string().optional(),
|
|
1401
|
+
tokenContractAmount: z6.string().optional(),
|
|
1402
|
+
dynamicExchangeRate: z6.boolean().optional()
|
|
1403
|
+
}),
|
|
1404
|
+
paymasterId: z6.string().nullable(),
|
|
1405
|
+
policyId: z6.string().nullable()
|
|
1424
1406
|
});
|
|
1425
1407
|
var sponsorship = Cli6.create("sponsorship", {
|
|
1426
|
-
description: "Manage fee sponsorship strategies linked to policies."
|
|
1427
|
-
vars: varsSchema
|
|
1408
|
+
description: "Manage fee sponsorship strategies linked to policies."
|
|
1428
1409
|
});
|
|
1429
1410
|
sponsorship.command("list", {
|
|
1430
1411
|
description: "List fee sponsorships.",
|
|
1431
|
-
options:
|
|
1432
|
-
limit:
|
|
1433
|
-
skip:
|
|
1434
|
-
enabled:
|
|
1412
|
+
options: z6.object({
|
|
1413
|
+
limit: z6.number().optional().describe("Max results"),
|
|
1414
|
+
skip: z6.number().optional().describe("Offset"),
|
|
1415
|
+
enabled: z6.boolean().optional().describe("Filter by enabled status")
|
|
1435
1416
|
}),
|
|
1436
1417
|
alias: { limit: "l" },
|
|
1437
1418
|
examples: [
|
|
1438
1419
|
{ description: "List all sponsorships" },
|
|
1439
1420
|
{ options: { enabled: true }, description: "List active sponsorships only" }
|
|
1440
1421
|
],
|
|
1441
|
-
output:
|
|
1442
|
-
data:
|
|
1443
|
-
total:
|
|
1422
|
+
output: z6.object({
|
|
1423
|
+
data: z6.array(sponsorshipItem),
|
|
1424
|
+
total: z6.number()
|
|
1444
1425
|
}),
|
|
1445
1426
|
async run(c) {
|
|
1446
|
-
const res = await
|
|
1427
|
+
const res = await getOpenfort().feeSponsorship.list({
|
|
1447
1428
|
limit: c.options.limit,
|
|
1448
1429
|
skip: c.options.skip,
|
|
1449
1430
|
enabled: c.options.enabled
|
|
@@ -1465,11 +1446,11 @@ sponsorship.command("list", {
|
|
|
1465
1446
|
});
|
|
1466
1447
|
sponsorship.command("create", {
|
|
1467
1448
|
description: "Create a fee sponsorship linked to a policy.",
|
|
1468
|
-
options:
|
|
1469
|
-
policyId:
|
|
1470
|
-
name:
|
|
1471
|
-
strategy:
|
|
1472
|
-
chainId:
|
|
1449
|
+
options: z6.object({
|
|
1450
|
+
policyId: z6.string().describe("Policy ID to link (ply_...)"),
|
|
1451
|
+
name: z6.string().optional().describe("Sponsorship name"),
|
|
1452
|
+
strategy: z6.enum(sponsorSchemas).default("pay_for_user").describe("Sponsorship strategy"),
|
|
1453
|
+
chainId: z6.number().optional().describe("Chain ID")
|
|
1473
1454
|
}),
|
|
1474
1455
|
output: sponsorshipItem,
|
|
1475
1456
|
examples: [
|
|
@@ -1484,7 +1465,7 @@ sponsorship.command("create", {
|
|
|
1484
1465
|
],
|
|
1485
1466
|
async run(c) {
|
|
1486
1467
|
const strategy = { sponsorSchema: c.options.strategy };
|
|
1487
|
-
const res = await
|
|
1468
|
+
const res = await getOpenfort().feeSponsorship.create({
|
|
1488
1469
|
policyId: c.options.policyId,
|
|
1489
1470
|
name: c.options.name,
|
|
1490
1471
|
strategy,
|
|
@@ -1515,15 +1496,15 @@ sponsorship.command("create", {
|
|
|
1515
1496
|
});
|
|
1516
1497
|
sponsorship.command("get", {
|
|
1517
1498
|
description: "Get a fee sponsorship by ID.",
|
|
1518
|
-
args:
|
|
1519
|
-
id:
|
|
1499
|
+
args: z6.object({
|
|
1500
|
+
id: z6.string().describe("Fee sponsorship ID (pol_...)")
|
|
1520
1501
|
}),
|
|
1521
1502
|
examples: [
|
|
1522
1503
|
{ args: { id: "pol_1a2b3c4d" }, description: "Get sponsorship details" }
|
|
1523
1504
|
],
|
|
1524
1505
|
output: sponsorshipItem,
|
|
1525
1506
|
async run(c) {
|
|
1526
|
-
const s = await
|
|
1507
|
+
const s = await getOpenfort().feeSponsorship.get(c.args.id);
|
|
1527
1508
|
return c.ok({
|
|
1528
1509
|
id: s.id,
|
|
1529
1510
|
createdAt: s.createdAt,
|
|
@@ -1538,13 +1519,13 @@ sponsorship.command("get", {
|
|
|
1538
1519
|
});
|
|
1539
1520
|
sponsorship.command("update", {
|
|
1540
1521
|
description: "Update a fee sponsorship.",
|
|
1541
|
-
args:
|
|
1542
|
-
id:
|
|
1522
|
+
args: z6.object({
|
|
1523
|
+
id: z6.string().describe("Fee sponsorship ID (pol_...)")
|
|
1543
1524
|
}),
|
|
1544
|
-
options:
|
|
1545
|
-
name:
|
|
1546
|
-
strategy:
|
|
1547
|
-
policyId:
|
|
1525
|
+
options: z6.object({
|
|
1526
|
+
name: z6.string().optional().describe("New name"),
|
|
1527
|
+
strategy: z6.enum(sponsorSchemas).optional().describe("New strategy"),
|
|
1528
|
+
policyId: z6.string().optional().describe("New policy ID")
|
|
1548
1529
|
}),
|
|
1549
1530
|
examples: [
|
|
1550
1531
|
{ args: { id: "pol_1a2b3c4d" }, options: { name: "Mainnet Gas Sponsor" }, description: "Rename a sponsorship" }
|
|
@@ -1552,7 +1533,7 @@ sponsorship.command("update", {
|
|
|
1552
1533
|
output: sponsorshipItem,
|
|
1553
1534
|
async run(c) {
|
|
1554
1535
|
const strategy = c.options.strategy ? { sponsorSchema: c.options.strategy } : void 0;
|
|
1555
|
-
const res = await
|
|
1536
|
+
const res = await getOpenfort().feeSponsorship.update(c.args.id, {
|
|
1556
1537
|
name: c.options.name,
|
|
1557
1538
|
strategy,
|
|
1558
1539
|
policyId: c.options.policyId
|
|
@@ -1571,15 +1552,15 @@ sponsorship.command("update", {
|
|
|
1571
1552
|
});
|
|
1572
1553
|
sponsorship.command("enable", {
|
|
1573
1554
|
description: "Enable a fee sponsorship.",
|
|
1574
|
-
args:
|
|
1575
|
-
id:
|
|
1555
|
+
args: z6.object({
|
|
1556
|
+
id: z6.string().describe("Fee sponsorship ID (pol_...)")
|
|
1576
1557
|
}),
|
|
1577
1558
|
examples: [
|
|
1578
1559
|
{ args: { id: "pol_1a2b3c4d" }, description: "Enable a sponsorship" }
|
|
1579
1560
|
],
|
|
1580
1561
|
output: sponsorshipItem,
|
|
1581
1562
|
async run(c) {
|
|
1582
|
-
const res = await
|
|
1563
|
+
const res = await getOpenfort().feeSponsorship.enable(c.args.id);
|
|
1583
1564
|
return c.ok({
|
|
1584
1565
|
id: res.id,
|
|
1585
1566
|
createdAt: res.createdAt,
|
|
@@ -1594,15 +1575,15 @@ sponsorship.command("enable", {
|
|
|
1594
1575
|
});
|
|
1595
1576
|
sponsorship.command("disable", {
|
|
1596
1577
|
description: "Disable a fee sponsorship.",
|
|
1597
|
-
args:
|
|
1598
|
-
id:
|
|
1578
|
+
args: z6.object({
|
|
1579
|
+
id: z6.string().describe("Fee sponsorship ID (pol_...)")
|
|
1599
1580
|
}),
|
|
1600
1581
|
examples: [
|
|
1601
1582
|
{ args: { id: "pol_1a2b3c4d" }, description: "Disable a sponsorship" }
|
|
1602
1583
|
],
|
|
1603
1584
|
output: sponsorshipItem,
|
|
1604
1585
|
async run(c) {
|
|
1605
|
-
const res = await
|
|
1586
|
+
const res = await getOpenfort().feeSponsorship.disable(c.args.id);
|
|
1606
1587
|
return c.ok({
|
|
1607
1588
|
id: res.id,
|
|
1608
1589
|
createdAt: res.createdAt,
|
|
@@ -1617,24 +1598,24 @@ sponsorship.command("disable", {
|
|
|
1617
1598
|
});
|
|
1618
1599
|
sponsorship.command("delete", {
|
|
1619
1600
|
description: "Delete a fee sponsorship.",
|
|
1620
|
-
args:
|
|
1621
|
-
id:
|
|
1601
|
+
args: z6.object({
|
|
1602
|
+
id: z6.string().describe("Fee sponsorship ID (pol_...)")
|
|
1622
1603
|
}),
|
|
1623
1604
|
examples: [
|
|
1624
1605
|
{ args: { id: "pol_1a2b3c4d" }, description: "Delete a sponsorship" }
|
|
1625
1606
|
],
|
|
1626
|
-
output:
|
|
1627
|
-
id:
|
|
1628
|
-
deleted:
|
|
1607
|
+
output: z6.object({
|
|
1608
|
+
id: z6.string(),
|
|
1609
|
+
deleted: z6.boolean()
|
|
1629
1610
|
}),
|
|
1630
1611
|
async run(c) {
|
|
1631
|
-
const res = await
|
|
1612
|
+
const res = await getOpenfort().feeSponsorship.delete(c.args.id);
|
|
1632
1613
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1633
1614
|
}
|
|
1634
1615
|
});
|
|
1635
1616
|
|
|
1636
1617
|
// src/commands/subscriptions.ts
|
|
1637
|
-
import { Cli as Cli7, z as
|
|
1618
|
+
import { Cli as Cli7, z as z7 } from "incur";
|
|
1638
1619
|
var apiTopics = [
|
|
1639
1620
|
"transaction_intent.broadcast",
|
|
1640
1621
|
"transaction_intent.successful",
|
|
@@ -1651,27 +1632,26 @@ var apiTopics = [
|
|
|
1651
1632
|
];
|
|
1652
1633
|
var apiTriggerTypes = ["webhook", "email"];
|
|
1653
1634
|
var triggers = Cli7.create("triggers", {
|
|
1654
|
-
description: "Manage subscription triggers."
|
|
1655
|
-
vars: varsSchema
|
|
1635
|
+
description: "Manage subscription triggers."
|
|
1656
1636
|
});
|
|
1657
1637
|
triggers.command("list", {
|
|
1658
1638
|
description: "List triggers for a subscription.",
|
|
1659
|
-
args:
|
|
1660
|
-
subscriptionId:
|
|
1639
|
+
args: z7.object({
|
|
1640
|
+
subscriptionId: z7.string().describe("Subscription ID (sub_...)")
|
|
1661
1641
|
}),
|
|
1662
1642
|
examples: [
|
|
1663
1643
|
{ args: { subscriptionId: "sub_1a2b3c4d" }, description: "List triggers" }
|
|
1664
1644
|
],
|
|
1665
|
-
output:
|
|
1666
|
-
data:
|
|
1667
|
-
id:
|
|
1668
|
-
createdAt:
|
|
1669
|
-
target:
|
|
1670
|
-
type:
|
|
1645
|
+
output: z7.object({
|
|
1646
|
+
data: z7.array(z7.object({
|
|
1647
|
+
id: z7.string(),
|
|
1648
|
+
createdAt: z7.number(),
|
|
1649
|
+
target: z7.string(),
|
|
1650
|
+
type: z7.string()
|
|
1671
1651
|
}))
|
|
1672
1652
|
}),
|
|
1673
1653
|
async run(c) {
|
|
1674
|
-
const res = await
|
|
1654
|
+
const res = await getOpenfort().triggers.list(c.args.subscriptionId);
|
|
1675
1655
|
return c.ok({
|
|
1676
1656
|
data: res.data.map((t) => ({
|
|
1677
1657
|
id: t.id,
|
|
@@ -1684,12 +1664,12 @@ triggers.command("list", {
|
|
|
1684
1664
|
});
|
|
1685
1665
|
triggers.command("create", {
|
|
1686
1666
|
description: "Create a trigger for a subscription.",
|
|
1687
|
-
args:
|
|
1688
|
-
subscriptionId:
|
|
1667
|
+
args: z7.object({
|
|
1668
|
+
subscriptionId: z7.string().describe("Subscription ID (sub_...)")
|
|
1689
1669
|
}),
|
|
1690
|
-
options:
|
|
1691
|
-
target:
|
|
1692
|
-
type:
|
|
1670
|
+
options: z7.object({
|
|
1671
|
+
target: z7.string().describe("Webhook URL or email address"),
|
|
1672
|
+
type: z7.enum(apiTriggerTypes).default("webhook").describe("Trigger type: webhook or email")
|
|
1693
1673
|
}),
|
|
1694
1674
|
examples: [
|
|
1695
1675
|
{
|
|
@@ -1698,14 +1678,14 @@ triggers.command("create", {
|
|
|
1698
1678
|
description: "Create a webhook trigger"
|
|
1699
1679
|
}
|
|
1700
1680
|
],
|
|
1701
|
-
output:
|
|
1702
|
-
id:
|
|
1703
|
-
createdAt:
|
|
1704
|
-
target:
|
|
1705
|
-
type:
|
|
1681
|
+
output: z7.object({
|
|
1682
|
+
id: z7.string(),
|
|
1683
|
+
createdAt: z7.number(),
|
|
1684
|
+
target: z7.string(),
|
|
1685
|
+
type: z7.string()
|
|
1706
1686
|
}),
|
|
1707
1687
|
async run(c) {
|
|
1708
|
-
const res = await
|
|
1688
|
+
const res = await getOpenfort().triggers.create(c.args.subscriptionId, {
|
|
1709
1689
|
target: c.options.target,
|
|
1710
1690
|
type: c.options.type
|
|
1711
1691
|
});
|
|
@@ -1719,21 +1699,21 @@ triggers.command("create", {
|
|
|
1719
1699
|
});
|
|
1720
1700
|
triggers.command("get", {
|
|
1721
1701
|
description: "Get a trigger by ID.",
|
|
1722
|
-
args:
|
|
1723
|
-
subscriptionId:
|
|
1724
|
-
triggerId:
|
|
1702
|
+
args: z7.object({
|
|
1703
|
+
subscriptionId: z7.string().describe("Subscription ID (sub_...)"),
|
|
1704
|
+
triggerId: z7.string().describe("Trigger ID (tri_...)")
|
|
1725
1705
|
}),
|
|
1726
1706
|
examples: [
|
|
1727
1707
|
{ args: { subscriptionId: "sub_1a2b3c4d", triggerId: "tri_1a2b3c4d" }, description: "Get trigger details" }
|
|
1728
1708
|
],
|
|
1729
|
-
output:
|
|
1730
|
-
id:
|
|
1731
|
-
createdAt:
|
|
1732
|
-
target:
|
|
1733
|
-
type:
|
|
1709
|
+
output: z7.object({
|
|
1710
|
+
id: z7.string(),
|
|
1711
|
+
createdAt: z7.number(),
|
|
1712
|
+
target: z7.string(),
|
|
1713
|
+
type: z7.string()
|
|
1734
1714
|
}),
|
|
1735
1715
|
async run(c) {
|
|
1736
|
-
const t = await
|
|
1716
|
+
const t = await getOpenfort().triggers.get(c.args.subscriptionId, c.args.triggerId);
|
|
1737
1717
|
return c.ok({
|
|
1738
1718
|
id: t.id,
|
|
1739
1719
|
createdAt: t.createdAt,
|
|
@@ -1744,46 +1724,45 @@ triggers.command("get", {
|
|
|
1744
1724
|
});
|
|
1745
1725
|
triggers.command("delete", {
|
|
1746
1726
|
description: "Delete a trigger.",
|
|
1747
|
-
args:
|
|
1748
|
-
subscriptionId:
|
|
1749
|
-
triggerId:
|
|
1727
|
+
args: z7.object({
|
|
1728
|
+
subscriptionId: z7.string().describe("Subscription ID (sub_...)"),
|
|
1729
|
+
triggerId: z7.string().describe("Trigger ID (tri_...)")
|
|
1750
1730
|
}),
|
|
1751
1731
|
examples: [
|
|
1752
1732
|
{ args: { subscriptionId: "sub_1a2b3c4d", triggerId: "tri_1a2b3c4d" }, description: "Delete a trigger" }
|
|
1753
1733
|
],
|
|
1754
|
-
output:
|
|
1755
|
-
id:
|
|
1756
|
-
deleted:
|
|
1734
|
+
output: z7.object({
|
|
1735
|
+
id: z7.string(),
|
|
1736
|
+
deleted: z7.boolean()
|
|
1757
1737
|
}),
|
|
1758
1738
|
async run(c) {
|
|
1759
|
-
const res = await
|
|
1739
|
+
const res = await getOpenfort().triggers.delete(c.args.subscriptionId, c.args.triggerId);
|
|
1760
1740
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1761
1741
|
}
|
|
1762
1742
|
});
|
|
1763
1743
|
var subscriptions = Cli7.create("subscriptions", {
|
|
1764
|
-
description: "Manage webhook subscriptions."
|
|
1765
|
-
vars: varsSchema
|
|
1744
|
+
description: "Manage webhook subscriptions."
|
|
1766
1745
|
});
|
|
1767
1746
|
subscriptions.command("list", {
|
|
1768
1747
|
description: "List webhook subscriptions.",
|
|
1769
1748
|
examples: [
|
|
1770
1749
|
{ description: "List all subscriptions" }
|
|
1771
1750
|
],
|
|
1772
|
-
output:
|
|
1773
|
-
data:
|
|
1774
|
-
id:
|
|
1775
|
-
createdAt:
|
|
1776
|
-
topic:
|
|
1777
|
-
triggers:
|
|
1778
|
-
id:
|
|
1779
|
-
target:
|
|
1780
|
-
type:
|
|
1751
|
+
output: z7.object({
|
|
1752
|
+
data: z7.array(z7.object({
|
|
1753
|
+
id: z7.string(),
|
|
1754
|
+
createdAt: z7.number(),
|
|
1755
|
+
topic: z7.string(),
|
|
1756
|
+
triggers: z7.array(z7.object({
|
|
1757
|
+
id: z7.string(),
|
|
1758
|
+
target: z7.string(),
|
|
1759
|
+
type: z7.string()
|
|
1781
1760
|
}))
|
|
1782
1761
|
})),
|
|
1783
|
-
total:
|
|
1762
|
+
total: z7.number()
|
|
1784
1763
|
}),
|
|
1785
1764
|
async run(c) {
|
|
1786
|
-
const res = await
|
|
1765
|
+
const res = await getOpenfort().subscriptions.list();
|
|
1787
1766
|
return c.ok({
|
|
1788
1767
|
data: res.data.map((s) => ({
|
|
1789
1768
|
id: s.id,
|
|
@@ -1797,9 +1776,9 @@ subscriptions.command("list", {
|
|
|
1797
1776
|
});
|
|
1798
1777
|
subscriptions.command("create", {
|
|
1799
1778
|
description: "Create a webhook subscription.",
|
|
1800
|
-
options:
|
|
1801
|
-
topic:
|
|
1802
|
-
triggers:
|
|
1779
|
+
options: z7.object({
|
|
1780
|
+
topic: z7.enum(apiTopics).describe("Event topic (e.g. transaction_intent.successful, user.created)"),
|
|
1781
|
+
triggers: z7.string().describe('Triggers as JSON: [{"type":"webhook","target":"https://..."}]')
|
|
1803
1782
|
}),
|
|
1804
1783
|
examples: [
|
|
1805
1784
|
{
|
|
@@ -1810,19 +1789,19 @@ subscriptions.command("create", {
|
|
|
1810
1789
|
description: "Get notified when transactions succeed"
|
|
1811
1790
|
}
|
|
1812
1791
|
],
|
|
1813
|
-
output:
|
|
1814
|
-
id:
|
|
1815
|
-
createdAt:
|
|
1816
|
-
topic:
|
|
1817
|
-
triggers:
|
|
1818
|
-
id:
|
|
1819
|
-
target:
|
|
1820
|
-
type:
|
|
1792
|
+
output: z7.object({
|
|
1793
|
+
id: z7.string(),
|
|
1794
|
+
createdAt: z7.number(),
|
|
1795
|
+
topic: z7.string(),
|
|
1796
|
+
triggers: z7.array(z7.object({
|
|
1797
|
+
id: z7.string(),
|
|
1798
|
+
target: z7.string(),
|
|
1799
|
+
type: z7.string()
|
|
1821
1800
|
}))
|
|
1822
1801
|
}),
|
|
1823
1802
|
async run(c) {
|
|
1824
1803
|
const parsedTriggers = JSON.parse(c.options.triggers);
|
|
1825
|
-
const res = await
|
|
1804
|
+
const res = await getOpenfort().subscriptions.create({
|
|
1826
1805
|
topic: c.options.topic,
|
|
1827
1806
|
triggers: parsedTriggers
|
|
1828
1807
|
});
|
|
@@ -1847,24 +1826,24 @@ subscriptions.command("create", {
|
|
|
1847
1826
|
});
|
|
1848
1827
|
subscriptions.command("get", {
|
|
1849
1828
|
description: "Get a subscription by ID.",
|
|
1850
|
-
args:
|
|
1851
|
-
id:
|
|
1829
|
+
args: z7.object({
|
|
1830
|
+
id: z7.string().describe("Subscription ID (sub_...)")
|
|
1852
1831
|
}),
|
|
1853
1832
|
examples: [
|
|
1854
1833
|
{ args: { id: "sub_1a2b3c4d" }, description: "Get subscription details" }
|
|
1855
1834
|
],
|
|
1856
|
-
output:
|
|
1857
|
-
id:
|
|
1858
|
-
createdAt:
|
|
1859
|
-
topic:
|
|
1860
|
-
triggers:
|
|
1861
|
-
id:
|
|
1862
|
-
target:
|
|
1863
|
-
type:
|
|
1835
|
+
output: z7.object({
|
|
1836
|
+
id: z7.string(),
|
|
1837
|
+
createdAt: z7.number(),
|
|
1838
|
+
topic: z7.string(),
|
|
1839
|
+
triggers: z7.array(z7.object({
|
|
1840
|
+
id: z7.string(),
|
|
1841
|
+
target: z7.string(),
|
|
1842
|
+
type: z7.string()
|
|
1864
1843
|
}))
|
|
1865
1844
|
}),
|
|
1866
1845
|
async run(c) {
|
|
1867
|
-
const s = await
|
|
1846
|
+
const s = await getOpenfort().subscriptions.get(c.args.id);
|
|
1868
1847
|
return c.ok({
|
|
1869
1848
|
id: s.id,
|
|
1870
1849
|
createdAt: s.createdAt,
|
|
@@ -1875,65 +1854,64 @@ subscriptions.command("get", {
|
|
|
1875
1854
|
});
|
|
1876
1855
|
subscriptions.command("delete", {
|
|
1877
1856
|
description: "Delete a subscription.",
|
|
1878
|
-
args:
|
|
1879
|
-
id:
|
|
1857
|
+
args: z7.object({
|
|
1858
|
+
id: z7.string().describe("Subscription ID (sub_...)")
|
|
1880
1859
|
}),
|
|
1881
1860
|
examples: [
|
|
1882
1861
|
{ args: { id: "sub_1a2b3c4d" }, description: "Delete a subscription" }
|
|
1883
1862
|
],
|
|
1884
|
-
output:
|
|
1885
|
-
id:
|
|
1886
|
-
deleted:
|
|
1863
|
+
output: z7.object({
|
|
1864
|
+
id: z7.string(),
|
|
1865
|
+
deleted: z7.boolean()
|
|
1887
1866
|
}),
|
|
1888
1867
|
async run(c) {
|
|
1889
|
-
const res = await
|
|
1868
|
+
const res = await getOpenfort().subscriptions.delete(c.args.id);
|
|
1890
1869
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
1891
1870
|
}
|
|
1892
1871
|
});
|
|
1893
1872
|
subscriptions.command(triggers);
|
|
1894
1873
|
|
|
1895
1874
|
// src/commands/sessions.ts
|
|
1896
|
-
import { Cli as Cli8, z as
|
|
1897
|
-
var sessionItem =
|
|
1898
|
-
id:
|
|
1899
|
-
createdAt:
|
|
1900
|
-
updatedAt:
|
|
1901
|
-
address:
|
|
1902
|
-
validAfter:
|
|
1903
|
-
validUntil:
|
|
1904
|
-
whitelist:
|
|
1905
|
-
isActive:
|
|
1906
|
-
nextAction:
|
|
1907
|
-
type:
|
|
1908
|
-
payload:
|
|
1875
|
+
import { Cli as Cli8, z as z8 } from "incur";
|
|
1876
|
+
var sessionItem = z8.object({
|
|
1877
|
+
id: z8.string(),
|
|
1878
|
+
createdAt: z8.number(),
|
|
1879
|
+
updatedAt: z8.number(),
|
|
1880
|
+
address: z8.string(),
|
|
1881
|
+
validAfter: z8.string(),
|
|
1882
|
+
validUntil: z8.string(),
|
|
1883
|
+
whitelist: z8.array(z8.string()).optional(),
|
|
1884
|
+
isActive: z8.boolean(),
|
|
1885
|
+
nextAction: z8.object({
|
|
1886
|
+
type: z8.string(),
|
|
1887
|
+
payload: z8.record(z8.string(), z8.unknown()).optional()
|
|
1909
1888
|
}).optional()
|
|
1910
1889
|
});
|
|
1911
1890
|
var sessions = Cli8.create("sessions", {
|
|
1912
|
-
description: "Manage session keys."
|
|
1913
|
-
vars: varsSchema
|
|
1891
|
+
description: "Manage session keys."
|
|
1914
1892
|
});
|
|
1915
1893
|
sessions.command("list", {
|
|
1916
1894
|
description: "List session keys for a player.",
|
|
1917
|
-
options:
|
|
1918
|
-
player:
|
|
1919
|
-
limit:
|
|
1920
|
-
skip:
|
|
1895
|
+
options: z8.object({
|
|
1896
|
+
player: z8.string().describe("Player ID (pla_...)"),
|
|
1897
|
+
limit: z8.number().optional().describe("Max results"),
|
|
1898
|
+
skip: z8.number().optional().describe("Offset")
|
|
1921
1899
|
}),
|
|
1922
1900
|
alias: { limit: "l" },
|
|
1923
1901
|
examples: [
|
|
1924
1902
|
{ options: { player: "pla_1a2b3c4d" }, description: "List sessions for a player" }
|
|
1925
1903
|
],
|
|
1926
|
-
output:
|
|
1927
|
-
data:
|
|
1928
|
-
id:
|
|
1929
|
-
createdAt:
|
|
1930
|
-
address:
|
|
1931
|
-
isActive:
|
|
1904
|
+
output: z8.object({
|
|
1905
|
+
data: z8.array(z8.object({
|
|
1906
|
+
id: z8.string(),
|
|
1907
|
+
createdAt: z8.number(),
|
|
1908
|
+
address: z8.string(),
|
|
1909
|
+
isActive: z8.boolean()
|
|
1932
1910
|
})),
|
|
1933
|
-
total:
|
|
1911
|
+
total: z8.number()
|
|
1934
1912
|
}),
|
|
1935
1913
|
async run(c) {
|
|
1936
|
-
const res = await
|
|
1914
|
+
const res = await getOpenfort().sessions.list({
|
|
1937
1915
|
player: c.options.player,
|
|
1938
1916
|
limit: c.options.limit,
|
|
1939
1917
|
skip: c.options.skip
|
|
@@ -1951,16 +1929,16 @@ sessions.command("list", {
|
|
|
1951
1929
|
});
|
|
1952
1930
|
sessions.command("create", {
|
|
1953
1931
|
description: "Create a session key.",
|
|
1954
|
-
options:
|
|
1955
|
-
address:
|
|
1956
|
-
chainId:
|
|
1957
|
-
validAfter:
|
|
1958
|
-
validUntil:
|
|
1959
|
-
player:
|
|
1960
|
-
account:
|
|
1961
|
-
limit:
|
|
1962
|
-
policy:
|
|
1963
|
-
whitelist:
|
|
1932
|
+
options: z8.object({
|
|
1933
|
+
address: z8.string().describe("Session key address"),
|
|
1934
|
+
chainId: z8.number().describe("Chain ID"),
|
|
1935
|
+
validAfter: z8.number().describe("Valid after (unix timestamp in seconds)"),
|
|
1936
|
+
validUntil: z8.number().describe("Valid until (unix timestamp in seconds)"),
|
|
1937
|
+
player: z8.string().optional().describe("Player ID (pla_...)"),
|
|
1938
|
+
account: z8.string().optional().describe("Account ID (acc_...)"),
|
|
1939
|
+
limit: z8.number().optional().describe("Max session uses"),
|
|
1940
|
+
policy: z8.string().optional().describe("Fee sponsorship ID (pol_...)"),
|
|
1941
|
+
whitelist: z8.string().optional().describe("Whitelisted contract addresses as JSON array")
|
|
1964
1942
|
}),
|
|
1965
1943
|
examples: [
|
|
1966
1944
|
{
|
|
@@ -1976,7 +1954,7 @@ sessions.command("create", {
|
|
|
1976
1954
|
],
|
|
1977
1955
|
output: sessionItem,
|
|
1978
1956
|
async run(c) {
|
|
1979
|
-
const res = await
|
|
1957
|
+
const res = await getOpenfort().sessions.create({
|
|
1980
1958
|
address: c.options.address,
|
|
1981
1959
|
chainId: c.options.chainId,
|
|
1982
1960
|
validAfter: c.options.validAfter,
|
|
@@ -2012,15 +1990,15 @@ sessions.command("create", {
|
|
|
2012
1990
|
});
|
|
2013
1991
|
sessions.command("get", {
|
|
2014
1992
|
description: "Get a session key by ID.",
|
|
2015
|
-
args:
|
|
2016
|
-
id:
|
|
1993
|
+
args: z8.object({
|
|
1994
|
+
id: z8.string().describe("Session ID (ses_...)")
|
|
2017
1995
|
}),
|
|
2018
1996
|
examples: [
|
|
2019
1997
|
{ args: { id: "ses_1a2b3c4d" }, description: "Get session details" }
|
|
2020
1998
|
],
|
|
2021
1999
|
output: sessionItem,
|
|
2022
2000
|
async run(c) {
|
|
2023
|
-
const s = await
|
|
2001
|
+
const s = await getOpenfort().sessions.get(c.args.id);
|
|
2024
2002
|
return c.ok({
|
|
2025
2003
|
id: s.id,
|
|
2026
2004
|
createdAt: s.createdAt,
|
|
@@ -2036,18 +2014,18 @@ sessions.command("get", {
|
|
|
2036
2014
|
});
|
|
2037
2015
|
sessions.command("revoke", {
|
|
2038
2016
|
description: "Revoke a session key.",
|
|
2039
|
-
options:
|
|
2040
|
-
address:
|
|
2041
|
-
chainId:
|
|
2042
|
-
player:
|
|
2043
|
-
policy:
|
|
2017
|
+
options: z8.object({
|
|
2018
|
+
address: z8.string().describe("Session key address to revoke"),
|
|
2019
|
+
chainId: z8.number().describe("Chain ID"),
|
|
2020
|
+
player: z8.string().optional().describe("Player ID (pla_...)"),
|
|
2021
|
+
policy: z8.string().optional().describe("Fee sponsorship ID (pol_...)")
|
|
2044
2022
|
}),
|
|
2045
2023
|
examples: [
|
|
2046
2024
|
{ options: { address: "0x1234...", chainId: 137 }, description: "Revoke a session key" }
|
|
2047
2025
|
],
|
|
2048
2026
|
output: sessionItem,
|
|
2049
2027
|
async run(c) {
|
|
2050
|
-
const res = await
|
|
2028
|
+
const res = await getOpenfort().sessions.revoke({
|
|
2051
2029
|
address: c.options.address,
|
|
2052
2030
|
chainId: c.options.chainId,
|
|
2053
2031
|
player: c.options.player,
|
|
@@ -2068,19 +2046,19 @@ sessions.command("revoke", {
|
|
|
2068
2046
|
});
|
|
2069
2047
|
sessions.command("sign", {
|
|
2070
2048
|
description: "Sign and broadcast a session userOperationHash.",
|
|
2071
|
-
args:
|
|
2072
|
-
id:
|
|
2049
|
+
args: z8.object({
|
|
2050
|
+
id: z8.string().describe("Session ID (ses_...)")
|
|
2073
2051
|
}),
|
|
2074
|
-
options:
|
|
2075
|
-
signature:
|
|
2076
|
-
optimistic:
|
|
2052
|
+
options: z8.object({
|
|
2053
|
+
signature: z8.string().describe("Hex signature"),
|
|
2054
|
+
optimistic: z8.boolean().optional().describe("Return before on-chain confirmation")
|
|
2077
2055
|
}),
|
|
2078
2056
|
examples: [
|
|
2079
2057
|
{ args: { id: "ses_1a2b3c4d" }, options: { signature: "0xabcd1234..." }, description: "Sign a session" }
|
|
2080
2058
|
],
|
|
2081
2059
|
output: sessionItem,
|
|
2082
2060
|
async run(c) {
|
|
2083
|
-
const res = await
|
|
2061
|
+
const res = await getOpenfort().sessions.signature(c.args.id, {
|
|
2084
2062
|
signature: c.options.signature,
|
|
2085
2063
|
optimistic: c.options.optimistic
|
|
2086
2064
|
});
|
|
@@ -2099,61 +2077,60 @@ sessions.command("sign", {
|
|
|
2099
2077
|
});
|
|
2100
2078
|
|
|
2101
2079
|
// src/commands/transactions.ts
|
|
2102
|
-
import { Cli as Cli9, z as
|
|
2103
|
-
var transactionIntentItem =
|
|
2104
|
-
id:
|
|
2105
|
-
createdAt:
|
|
2106
|
-
updatedAt:
|
|
2107
|
-
chainId:
|
|
2108
|
-
abstractionType:
|
|
2109
|
-
userOperationHash:
|
|
2110
|
-
response:
|
|
2111
|
-
createdAt:
|
|
2112
|
-
blockNumber:
|
|
2113
|
-
transactionHash:
|
|
2114
|
-
gasUsed:
|
|
2115
|
-
gasFee:
|
|
2116
|
-
status:
|
|
2117
|
-
to:
|
|
2118
|
-
error:
|
|
2080
|
+
import { Cli as Cli9, z as z9 } from "incur";
|
|
2081
|
+
var transactionIntentItem = z9.object({
|
|
2082
|
+
id: z9.string(),
|
|
2083
|
+
createdAt: z9.number(),
|
|
2084
|
+
updatedAt: z9.number(),
|
|
2085
|
+
chainId: z9.number(),
|
|
2086
|
+
abstractionType: z9.string().describe("e.g. accountAbstractionV6, standard"),
|
|
2087
|
+
userOperationHash: z9.string().optional(),
|
|
2088
|
+
response: z9.object({
|
|
2089
|
+
createdAt: z9.number(),
|
|
2090
|
+
blockNumber: z9.number().optional(),
|
|
2091
|
+
transactionHash: z9.string().optional(),
|
|
2092
|
+
gasUsed: z9.string().optional(),
|
|
2093
|
+
gasFee: z9.string().optional(),
|
|
2094
|
+
status: z9.number().optional(),
|
|
2095
|
+
to: z9.string().optional(),
|
|
2096
|
+
error: z9.record(z9.string(), z9.unknown()).optional()
|
|
2119
2097
|
}).optional(),
|
|
2120
|
-
interactions:
|
|
2121
|
-
to:
|
|
2122
|
-
data:
|
|
2123
|
-
value:
|
|
2098
|
+
interactions: z9.array(z9.object({
|
|
2099
|
+
to: z9.string().optional(),
|
|
2100
|
+
data: z9.string().optional(),
|
|
2101
|
+
value: z9.string().optional()
|
|
2124
2102
|
})).optional(),
|
|
2125
|
-
nextAction:
|
|
2126
|
-
type:
|
|
2127
|
-
payload:
|
|
2103
|
+
nextAction: z9.object({
|
|
2104
|
+
type: z9.string(),
|
|
2105
|
+
payload: z9.record(z9.string(), z9.unknown()).optional()
|
|
2128
2106
|
}).optional()
|
|
2129
2107
|
});
|
|
2130
2108
|
var transactions = Cli9.create("transactions", {
|
|
2131
|
-
description: "Manage transaction intents."
|
|
2132
|
-
vars: varsSchema
|
|
2109
|
+
description: "Manage transaction intents."
|
|
2133
2110
|
});
|
|
2134
2111
|
transactions.command("list", {
|
|
2135
2112
|
description: "List transaction intents.",
|
|
2136
|
-
options:
|
|
2137
|
-
limit:
|
|
2138
|
-
skip:
|
|
2113
|
+
options: z9.object({
|
|
2114
|
+
limit: z9.number().optional().describe("Max results"),
|
|
2115
|
+
skip: z9.number().optional().describe("Offset")
|
|
2139
2116
|
}),
|
|
2140
2117
|
alias: { limit: "l" },
|
|
2141
2118
|
examples: [
|
|
2142
2119
|
{ description: "List all transactions" },
|
|
2143
2120
|
{ options: { limit: 10 }, description: "List last 10 transactions" }
|
|
2144
2121
|
],
|
|
2145
|
-
output:
|
|
2146
|
-
data:
|
|
2147
|
-
id:
|
|
2148
|
-
createdAt:
|
|
2149
|
-
updatedAt:
|
|
2150
|
-
chainId:
|
|
2151
|
-
abstractionType:
|
|
2122
|
+
output: z9.object({
|
|
2123
|
+
data: z9.array(z9.object({
|
|
2124
|
+
id: z9.string(),
|
|
2125
|
+
createdAt: z9.number(),
|
|
2126
|
+
updatedAt: z9.number(),
|
|
2127
|
+
chainId: z9.number(),
|
|
2128
|
+
abstractionType: z9.string()
|
|
2152
2129
|
})),
|
|
2153
|
-
total:
|
|
2130
|
+
total: z9.number()
|
|
2154
2131
|
}),
|
|
2155
2132
|
async run(c) {
|
|
2156
|
-
const res = await
|
|
2133
|
+
const res = await getOpenfort().transactionIntents.list({
|
|
2157
2134
|
limit: c.options.limit,
|
|
2158
2135
|
skip: c.options.skip
|
|
2159
2136
|
});
|
|
@@ -2171,12 +2148,12 @@ transactions.command("list", {
|
|
|
2171
2148
|
});
|
|
2172
2149
|
transactions.command("create", {
|
|
2173
2150
|
description: "Create a transaction intent.",
|
|
2174
|
-
options:
|
|
2175
|
-
account:
|
|
2176
|
-
chainId:
|
|
2177
|
-
interactions:
|
|
2178
|
-
policy:
|
|
2179
|
-
signedAuthorization:
|
|
2151
|
+
options: z9.object({
|
|
2152
|
+
account: z9.string().describe("Account ID (acc_...)"),
|
|
2153
|
+
chainId: z9.number().describe("Chain ID"),
|
|
2154
|
+
interactions: z9.string().describe('Interactions as JSON: [{"to":"0x...","data":"0x...","value":"0"}]'),
|
|
2155
|
+
policy: z9.string().optional().describe("Fee sponsorship ID (pol_...)."),
|
|
2156
|
+
signedAuthorization: z9.string().optional().describe("Signed EIP-7702 authorization hex (for delegated accounts)")
|
|
2180
2157
|
}),
|
|
2181
2158
|
output: transactionIntentItem,
|
|
2182
2159
|
examples: [
|
|
@@ -2200,7 +2177,7 @@ transactions.command("create", {
|
|
|
2200
2177
|
],
|
|
2201
2178
|
async run(c) {
|
|
2202
2179
|
const interactions = JSON.parse(c.options.interactions);
|
|
2203
|
-
const res = await
|
|
2180
|
+
const res = await getOpenfort().transactionIntents.create({
|
|
2204
2181
|
account: c.options.account,
|
|
2205
2182
|
chainId: c.options.chainId,
|
|
2206
2183
|
interactions,
|
|
@@ -2232,15 +2209,15 @@ transactions.command("create", {
|
|
|
2232
2209
|
});
|
|
2233
2210
|
transactions.command("get", {
|
|
2234
2211
|
description: "Get a transaction intent by ID.",
|
|
2235
|
-
args:
|
|
2236
|
-
id:
|
|
2212
|
+
args: z9.object({
|
|
2213
|
+
id: z9.string().describe("Transaction intent ID (tin_...)")
|
|
2237
2214
|
}),
|
|
2238
2215
|
examples: [
|
|
2239
2216
|
{ args: { id: "tin_1a2b3c4d" }, description: "Get transaction status and receipt" }
|
|
2240
2217
|
],
|
|
2241
2218
|
output: transactionIntentItem,
|
|
2242
2219
|
async run(c) {
|
|
2243
|
-
const t = await
|
|
2220
|
+
const t = await getOpenfort().transactionIntents.get(c.args.id);
|
|
2244
2221
|
return c.ok({
|
|
2245
2222
|
id: t.id,
|
|
2246
2223
|
createdAt: t.createdAt,
|
|
@@ -2256,12 +2233,12 @@ transactions.command("get", {
|
|
|
2256
2233
|
});
|
|
2257
2234
|
transactions.command("sign", {
|
|
2258
2235
|
description: "Sign and broadcast a transaction intent.",
|
|
2259
|
-
args:
|
|
2260
|
-
id:
|
|
2236
|
+
args: z9.object({
|
|
2237
|
+
id: z9.string().describe("Transaction intent ID (tin_...)")
|
|
2261
2238
|
}),
|
|
2262
|
-
options:
|
|
2263
|
-
signature:
|
|
2264
|
-
optimistic:
|
|
2239
|
+
options: z9.object({
|
|
2240
|
+
signature: z9.string().describe("Hex signature"),
|
|
2241
|
+
optimistic: z9.boolean().optional().describe("Return before on-chain confirmation")
|
|
2265
2242
|
}),
|
|
2266
2243
|
examples: [
|
|
2267
2244
|
{ args: { id: "tin_1a2b3c4d" }, options: { signature: "0xabcd1234..." }, description: "Sign and broadcast a transaction" },
|
|
@@ -2269,7 +2246,7 @@ transactions.command("sign", {
|
|
|
2269
2246
|
],
|
|
2270
2247
|
output: transactionIntentItem,
|
|
2271
2248
|
async run(c) {
|
|
2272
|
-
const res = await
|
|
2249
|
+
const res = await getOpenfort().transactionIntents.signature(c.args.id, {
|
|
2273
2250
|
signature: c.options.signature,
|
|
2274
2251
|
optimistic: c.options.optimistic
|
|
2275
2252
|
});
|
|
@@ -2298,11 +2275,11 @@ transactions.command("sign", {
|
|
|
2298
2275
|
});
|
|
2299
2276
|
transactions.command("estimate", {
|
|
2300
2277
|
description: "Estimate gas cost for a transaction.",
|
|
2301
|
-
options:
|
|
2302
|
-
account:
|
|
2303
|
-
chainId:
|
|
2304
|
-
interactions:
|
|
2305
|
-
policy:
|
|
2278
|
+
options: z9.object({
|
|
2279
|
+
account: z9.string().describe("Account ID (acc_...)"),
|
|
2280
|
+
chainId: z9.number().describe("Chain ID"),
|
|
2281
|
+
interactions: z9.string().describe("Interactions as JSON"),
|
|
2282
|
+
policy: z9.string().optional().describe("Fee sponsorship ID (pol_...)")
|
|
2306
2283
|
}),
|
|
2307
2284
|
examples: [
|
|
2308
2285
|
{
|
|
@@ -2310,16 +2287,16 @@ transactions.command("estimate", {
|
|
|
2310
2287
|
description: "Estimate gas for a USDC transfer on Polygon"
|
|
2311
2288
|
}
|
|
2312
2289
|
],
|
|
2313
|
-
output:
|
|
2314
|
-
estimatedTXGas:
|
|
2315
|
-
estimatedTXGasFee:
|
|
2316
|
-
estimatedTXGasFeeUSD:
|
|
2317
|
-
estimatedTXGasFeeToken:
|
|
2318
|
-
gasPrice:
|
|
2290
|
+
output: z9.object({
|
|
2291
|
+
estimatedTXGas: z9.string(),
|
|
2292
|
+
estimatedTXGasFee: z9.string(),
|
|
2293
|
+
estimatedTXGasFeeUSD: z9.string(),
|
|
2294
|
+
estimatedTXGasFeeToken: z9.string().optional(),
|
|
2295
|
+
gasPrice: z9.string()
|
|
2319
2296
|
}),
|
|
2320
2297
|
async run(c) {
|
|
2321
2298
|
const interactions = JSON.parse(c.options.interactions);
|
|
2322
|
-
const res = await
|
|
2299
|
+
const res = await getOpenfort().transactionIntents.estimateCost({
|
|
2323
2300
|
account: c.options.account,
|
|
2324
2301
|
chainId: c.options.chainId,
|
|
2325
2302
|
interactions,
|
|
@@ -2336,21 +2313,19 @@ transactions.command("estimate", {
|
|
|
2336
2313
|
});
|
|
2337
2314
|
|
|
2338
2315
|
// src/commands/embedded-wallet.ts
|
|
2339
|
-
import { Cli as Cli10, z as
|
|
2340
|
-
var SHIELD_API_URL = OPENFORT_SHIELD_URL;
|
|
2316
|
+
import { Cli as Cli10, z as z10, Errors } from "incur";
|
|
2341
2317
|
var embeddedWallet = Cli10.create("embedded-wallet", {
|
|
2342
|
-
description: "Configure embedded wallet (Shield) API keys."
|
|
2343
|
-
vars: varsSchema
|
|
2318
|
+
description: "Configure embedded wallet (Shield) API keys."
|
|
2344
2319
|
});
|
|
2345
2320
|
embeddedWallet.command("setup", {
|
|
2346
2321
|
description: "Generate and register embedded wallet (Shield) API keys.",
|
|
2347
|
-
options:
|
|
2348
|
-
project:
|
|
2322
|
+
options: z10.object({
|
|
2323
|
+
project: z10.string().optional().describe("Project ID (pro_...). Defaults to OPENFORT_PROJECT_ID env var.")
|
|
2349
2324
|
}),
|
|
2350
2325
|
alias: { project: "p" },
|
|
2351
|
-
output:
|
|
2352
|
-
message:
|
|
2353
|
-
credentialsPath:
|
|
2326
|
+
output: z10.object({
|
|
2327
|
+
message: z10.string(),
|
|
2328
|
+
credentialsPath: z10.string()
|
|
2354
2329
|
}),
|
|
2355
2330
|
examples: [
|
|
2356
2331
|
{
|
|
@@ -2362,7 +2337,7 @@ embeddedWallet.command("setup", {
|
|
|
2362
2337
|
async run(c) {
|
|
2363
2338
|
const publishableKey = process.env.OPENFORT_PUBLISHABLE_KEY;
|
|
2364
2339
|
if (!publishableKey) {
|
|
2365
|
-
throw new
|
|
2340
|
+
throw new Errors.IncurError({
|
|
2366
2341
|
code: "MISSING_PUBLISHABLE_KEY",
|
|
2367
2342
|
message: "OPENFORT_PUBLISHABLE_KEY environment variable is required to create Shield keys.",
|
|
2368
2343
|
hint: "Run: openfort login"
|
|
@@ -2372,13 +2347,13 @@ embeddedWallet.command("setup", {
|
|
|
2372
2347
|
const environment = apiKey.startsWith("sk_live_") ? "live" : "test";
|
|
2373
2348
|
const projectId = c.options.project || process.env.OPENFORT_PROJECT_ID;
|
|
2374
2349
|
if (!projectId) {
|
|
2375
|
-
throw new
|
|
2350
|
+
throw new Errors.IncurError({
|
|
2376
2351
|
code: "MISSING_PROJECT_ID",
|
|
2377
2352
|
message: "Project ID is required. Pass --project or set OPENFORT_PROJECT_ID.",
|
|
2378
2353
|
hint: "Run: openfort login"
|
|
2379
2354
|
});
|
|
2380
2355
|
}
|
|
2381
|
-
const registerRes = await fetch(`${
|
|
2356
|
+
const registerRes = await fetch(`${OPENFORT_SHIELD_URL}/register`, {
|
|
2382
2357
|
method: "POST",
|
|
2383
2358
|
headers: {
|
|
2384
2359
|
"Content-Type": "application/json",
|
|
@@ -2392,7 +2367,7 @@ embeddedWallet.command("setup", {
|
|
|
2392
2367
|
});
|
|
2393
2368
|
if (!registerRes.ok) {
|
|
2394
2369
|
const text = await registerRes.text();
|
|
2395
|
-
throw new
|
|
2370
|
+
throw new Errors.IncurError({
|
|
2396
2371
|
code: "SHIELD_REGISTER_FAILED",
|
|
2397
2372
|
message: `Shield registration failed: ${text}`,
|
|
2398
2373
|
retryable: true
|
|
@@ -2400,7 +2375,7 @@ embeddedWallet.command("setup", {
|
|
|
2400
2375
|
}
|
|
2401
2376
|
const shieldData = await registerRes.json();
|
|
2402
2377
|
if (shieldData.error) {
|
|
2403
|
-
throw new
|
|
2378
|
+
throw new Errors.IncurError({
|
|
2404
2379
|
code: "SHIELD_REGISTER_ERROR",
|
|
2405
2380
|
message: `Shield registration error: ${shieldData.error}`
|
|
2406
2381
|
});
|
|
@@ -2416,7 +2391,7 @@ embeddedWallet.command("setup", {
|
|
|
2416
2391
|
});
|
|
2417
2392
|
if (!res.ok) {
|
|
2418
2393
|
const text = await res.text();
|
|
2419
|
-
throw new
|
|
2394
|
+
throw new Errors.IncurError({
|
|
2420
2395
|
code: "PERSIST_KEY_FAILED",
|
|
2421
2396
|
message: `Failed to persist ${type} key: ${text}`,
|
|
2422
2397
|
retryable: true
|
|
@@ -2427,7 +2402,7 @@ embeddedWallet.command("setup", {
|
|
|
2427
2402
|
persistKey("pk_shield", shieldData.api_key),
|
|
2428
2403
|
persistKey("sk_shield", shieldData.api_secret)
|
|
2429
2404
|
]);
|
|
2430
|
-
const linkRes = await fetch(`${
|
|
2405
|
+
const linkRes = await fetch(`${OPENFORT_SHIELD_URL}/project/providers`, {
|
|
2431
2406
|
method: "POST",
|
|
2432
2407
|
headers: {
|
|
2433
2408
|
"Content-Type": "application/json",
|
|
@@ -2444,7 +2419,7 @@ embeddedWallet.command("setup", {
|
|
|
2444
2419
|
});
|
|
2445
2420
|
if (!linkRes.ok) {
|
|
2446
2421
|
const text = await linkRes.text();
|
|
2447
|
-
throw new
|
|
2422
|
+
throw new Errors.IncurError({
|
|
2448
2423
|
code: "SHIELD_LINK_FAILED",
|
|
2449
2424
|
message: `Failed to link Openfort provider to Shield: ${text}`,
|
|
2450
2425
|
retryable: true
|
|
@@ -2471,49 +2446,48 @@ embeddedWallet.command("setup", {
|
|
|
2471
2446
|
});
|
|
2472
2447
|
|
|
2473
2448
|
// src/commands/users.ts
|
|
2474
|
-
import { Cli as Cli11, z as
|
|
2475
|
-
var userItem =
|
|
2476
|
-
id:
|
|
2477
|
-
createdAt:
|
|
2478
|
-
name:
|
|
2479
|
-
email:
|
|
2480
|
-
emailVerified:
|
|
2481
|
-
phoneNumber:
|
|
2482
|
-
phoneNumberVerified:
|
|
2483
|
-
isAnonymous:
|
|
2484
|
-
linkedAccounts:
|
|
2485
|
-
provider:
|
|
2486
|
-
createdAt:
|
|
2487
|
-
updatedAt:
|
|
2488
|
-
accountId:
|
|
2489
|
-
chainType:
|
|
2490
|
-
connectorType:
|
|
2491
|
-
walletClientType:
|
|
2449
|
+
import { Cli as Cli11, z as z11 } from "incur";
|
|
2450
|
+
var userItem = z11.object({
|
|
2451
|
+
id: z11.string(),
|
|
2452
|
+
createdAt: z11.number(),
|
|
2453
|
+
name: z11.string(),
|
|
2454
|
+
email: z11.string().nullable(),
|
|
2455
|
+
emailVerified: z11.boolean(),
|
|
2456
|
+
phoneNumber: z11.string().nullable(),
|
|
2457
|
+
phoneNumberVerified: z11.boolean(),
|
|
2458
|
+
isAnonymous: z11.boolean().optional(),
|
|
2459
|
+
linkedAccounts: z11.array(z11.object({
|
|
2460
|
+
provider: z11.string(),
|
|
2461
|
+
createdAt: z11.number(),
|
|
2462
|
+
updatedAt: z11.number(),
|
|
2463
|
+
accountId: z11.string().optional(),
|
|
2464
|
+
chainType: z11.string().optional(),
|
|
2465
|
+
connectorType: z11.string().optional(),
|
|
2466
|
+
walletClientType: z11.string().optional()
|
|
2492
2467
|
}))
|
|
2493
2468
|
});
|
|
2494
2469
|
var users = Cli11.create("users", {
|
|
2495
|
-
description: "Manage authenticated users."
|
|
2496
|
-
vars: varsSchema
|
|
2470
|
+
description: "Manage authenticated users."
|
|
2497
2471
|
});
|
|
2498
2472
|
users.command("list", {
|
|
2499
2473
|
description: "List users.",
|
|
2500
|
-
options:
|
|
2501
|
-
limit:
|
|
2502
|
-
skip:
|
|
2503
|
-
email:
|
|
2504
|
-
name:
|
|
2474
|
+
options: z11.object({
|
|
2475
|
+
limit: z11.number().optional().describe("Max results"),
|
|
2476
|
+
skip: z11.number().optional().describe("Offset"),
|
|
2477
|
+
email: z11.string().optional().describe("Filter by email"),
|
|
2478
|
+
name: z11.string().optional().describe("Filter by name")
|
|
2505
2479
|
}),
|
|
2506
2480
|
alias: { limit: "l" },
|
|
2507
2481
|
examples: [
|
|
2508
2482
|
{ description: "List all users" },
|
|
2509
2483
|
{ options: { email: "user@example.com" }, description: "Find user by email" }
|
|
2510
2484
|
],
|
|
2511
|
-
output:
|
|
2512
|
-
data:
|
|
2513
|
-
total:
|
|
2485
|
+
output: z11.object({
|
|
2486
|
+
data: z11.array(userItem),
|
|
2487
|
+
total: z11.number()
|
|
2514
2488
|
}),
|
|
2515
2489
|
async run(c) {
|
|
2516
|
-
const res = await
|
|
2490
|
+
const res = await getOpenfort().iam.users.list({
|
|
2517
2491
|
limit: c.options.limit,
|
|
2518
2492
|
skip: c.options.skip,
|
|
2519
2493
|
email: c.options.email,
|
|
@@ -2537,15 +2511,15 @@ users.command("list", {
|
|
|
2537
2511
|
});
|
|
2538
2512
|
users.command("get", {
|
|
2539
2513
|
description: "Get a user by ID.",
|
|
2540
|
-
args:
|
|
2541
|
-
id:
|
|
2514
|
+
args: z11.object({
|
|
2515
|
+
id: z11.string().describe("User ID (usr_...)")
|
|
2542
2516
|
}),
|
|
2543
2517
|
examples: [
|
|
2544
2518
|
{ args: { id: "usr_1a2b3c4d" }, description: "Get user profile and linked accounts" }
|
|
2545
2519
|
],
|
|
2546
2520
|
output: userItem,
|
|
2547
2521
|
async run(c) {
|
|
2548
|
-
const u = await
|
|
2522
|
+
const u = await getOpenfort().iam.users.get(c.args.id);
|
|
2549
2523
|
return c.ok({
|
|
2550
2524
|
id: u.id,
|
|
2551
2525
|
createdAt: u.createdAt,
|
|
@@ -2561,25 +2535,25 @@ users.command("get", {
|
|
|
2561
2535
|
});
|
|
2562
2536
|
users.command("delete", {
|
|
2563
2537
|
description: "Delete a user.",
|
|
2564
|
-
args:
|
|
2565
|
-
id:
|
|
2538
|
+
args: z11.object({
|
|
2539
|
+
id: z11.string().describe("User ID (usr_...)")
|
|
2566
2540
|
}),
|
|
2567
2541
|
examples: [
|
|
2568
2542
|
{ args: { id: "usr_1a2b3c4d" }, description: "Delete a user and their accounts" }
|
|
2569
2543
|
],
|
|
2570
|
-
output:
|
|
2571
|
-
id:
|
|
2572
|
-
deleted:
|
|
2544
|
+
output: z11.object({
|
|
2545
|
+
id: z11.string(),
|
|
2546
|
+
deleted: z11.boolean()
|
|
2573
2547
|
}),
|
|
2574
2548
|
async run(c) {
|
|
2575
|
-
const res = await
|
|
2549
|
+
const res = await getOpenfort().iam.users.delete(c.args.id);
|
|
2576
2550
|
return c.ok({ id: res.id, deleted: res.deleted });
|
|
2577
2551
|
}
|
|
2578
2552
|
});
|
|
2579
2553
|
|
|
2580
2554
|
// src/commands/backend-wallet.ts
|
|
2581
2555
|
import { randomBytes as randomBytes2, subtle } from "crypto";
|
|
2582
|
-
import { Cli as Cli12, z as
|
|
2556
|
+
import { Cli as Cli12, z as z12, Errors as Errors2 } from "incur";
|
|
2583
2557
|
function arrayBufferToBase64(buffer) {
|
|
2584
2558
|
return Buffer.from(buffer).toString("base64");
|
|
2585
2559
|
}
|
|
@@ -2651,14 +2625,13 @@ async function signWalletAuthJwt(privateKey, method, path, body) {
|
|
|
2651
2625
|
return `${signingInput}.${arrayBufferToBase64Url(signature)}`;
|
|
2652
2626
|
}
|
|
2653
2627
|
var backendWallet = Cli12.create("backend-wallet", {
|
|
2654
|
-
description: "Configure backend wallet signing keys."
|
|
2655
|
-
vars: varsSchema
|
|
2628
|
+
description: "Configure backend wallet signing keys."
|
|
2656
2629
|
});
|
|
2657
2630
|
backendWallet.command("setup", {
|
|
2658
2631
|
description: "Generate and register backend wallet signing keys (ECDSA P-256).",
|
|
2659
|
-
output:
|
|
2660
|
-
message:
|
|
2661
|
-
credentialsPath:
|
|
2632
|
+
output: z12.object({
|
|
2633
|
+
message: z12.string(),
|
|
2634
|
+
credentialsPath: z12.string()
|
|
2662
2635
|
}),
|
|
2663
2636
|
examples: [
|
|
2664
2637
|
{
|
|
@@ -2689,7 +2662,7 @@ ${publicKey}
|
|
|
2689
2662
|
});
|
|
2690
2663
|
if (!registerRes.ok) {
|
|
2691
2664
|
const text = await registerRes.text();
|
|
2692
|
-
throw new
|
|
2665
|
+
throw new Errors2.IncurError({
|
|
2693
2666
|
code: "REGISTER_SECRET_FAILED",
|
|
2694
2667
|
message: `Failed to register wallet secret: ${text}`,
|
|
2695
2668
|
retryable: true
|
|
@@ -2705,7 +2678,7 @@ ${publicKey}
|
|
|
2705
2678
|
});
|
|
2706
2679
|
if (!storeRes.ok) {
|
|
2707
2680
|
const text = await storeRes.text();
|
|
2708
|
-
throw new
|
|
2681
|
+
throw new Errors2.IncurError({
|
|
2709
2682
|
code: "STORE_KEY_FAILED",
|
|
2710
2683
|
message: `Failed to store wallet key reference: ${text}`,
|
|
2711
2684
|
retryable: true
|
|
@@ -2730,10 +2703,10 @@ ${publicKey}
|
|
|
2730
2703
|
});
|
|
2731
2704
|
backendWallet.command("revoke", {
|
|
2732
2705
|
description: "Revoke the current backend wallet signing secret.",
|
|
2733
|
-
output:
|
|
2734
|
-
keyId:
|
|
2735
|
-
revoked:
|
|
2736
|
-
revokedAt:
|
|
2706
|
+
output: z12.object({
|
|
2707
|
+
keyId: z12.string(),
|
|
2708
|
+
revoked: z12.boolean(),
|
|
2709
|
+
revokedAt: z12.number()
|
|
2737
2710
|
}),
|
|
2738
2711
|
examples: [
|
|
2739
2712
|
{
|
|
@@ -2746,7 +2719,7 @@ backendWallet.command("revoke", {
|
|
|
2746
2719
|
const keyId = process.env.OPENFORT_WALLET_KEY_ID;
|
|
2747
2720
|
const privateKeyBase64 = process.env.OPENFORT_WALLET_SECRET;
|
|
2748
2721
|
if (!keyId || !privateKeyBase64) {
|
|
2749
|
-
throw new
|
|
2722
|
+
throw new Errors2.IncurError({
|
|
2750
2723
|
code: "MISSING_WALLET_KEY",
|
|
2751
2724
|
message: "OPENFORT_WALLET_KEY_ID and OPENFORT_WALLET_SECRET must be set. Run `backend-wallet setup` first.",
|
|
2752
2725
|
hint: "Run: openfort backend-wallet setup"
|
|
@@ -2767,7 +2740,7 @@ backendWallet.command("revoke", {
|
|
|
2767
2740
|
});
|
|
2768
2741
|
if (!res.ok) {
|
|
2769
2742
|
const text = await res.text();
|
|
2770
|
-
throw new
|
|
2743
|
+
throw new Errors2.IncurError({
|
|
2771
2744
|
code: "REVOKE_SECRET_FAILED",
|
|
2772
2745
|
message: `Failed to revoke wallet secret: ${text}`,
|
|
2773
2746
|
retryable: true
|
|
@@ -2779,9 +2752,9 @@ backendWallet.command("revoke", {
|
|
|
2779
2752
|
});
|
|
2780
2753
|
backendWallet.command("rotate", {
|
|
2781
2754
|
description: "Rotate backend wallet signing secret (generates new ECDSA P-256 key pair).",
|
|
2782
|
-
output:
|
|
2783
|
-
message:
|
|
2784
|
-
credentialsPath:
|
|
2755
|
+
output: z12.object({
|
|
2756
|
+
message: z12.string(),
|
|
2757
|
+
credentialsPath: z12.string()
|
|
2785
2758
|
}),
|
|
2786
2759
|
examples: [
|
|
2787
2760
|
{
|
|
@@ -2812,7 +2785,7 @@ ${publicKey}
|
|
|
2812
2785
|
});
|
|
2813
2786
|
if (!rotateRes.ok) {
|
|
2814
2787
|
const text = await rotateRes.text();
|
|
2815
|
-
throw new
|
|
2788
|
+
throw new Errors2.IncurError({
|
|
2816
2789
|
code: "ROTATE_SECRET_FAILED",
|
|
2817
2790
|
message: `Failed to rotate wallet secret: ${text}`,
|
|
2818
2791
|
retryable: true
|
|
@@ -2828,7 +2801,7 @@ ${publicKey}
|
|
|
2828
2801
|
});
|
|
2829
2802
|
if (!storeRes.ok) {
|
|
2830
2803
|
const text = await storeRes.text();
|
|
2831
|
-
throw new
|
|
2804
|
+
throw new Errors2.IncurError({
|
|
2832
2805
|
code: "STORE_KEY_FAILED",
|
|
2833
2806
|
message: `Failed to store rotated wallet key reference: ${text}`,
|
|
2834
2807
|
retryable: true
|
|
@@ -2843,22 +2816,21 @@ ${publicKey}
|
|
|
2843
2816
|
});
|
|
2844
2817
|
|
|
2845
2818
|
// src/commands/message.ts
|
|
2846
|
-
import { Cli as Cli13, z as
|
|
2819
|
+
import { Cli as Cli13, z as z13 } from "incur";
|
|
2847
2820
|
import { keccak256, toBytes } from "viem";
|
|
2848
2821
|
var message = Cli13.create("message", {
|
|
2849
|
-
description: "Message utilities."
|
|
2850
|
-
vars: varsSchema
|
|
2822
|
+
description: "Message utilities."
|
|
2851
2823
|
});
|
|
2852
2824
|
message.command("hash", {
|
|
2853
2825
|
description: "Hash a message using keccak256.",
|
|
2854
|
-
args:
|
|
2855
|
-
message:
|
|
2826
|
+
args: z13.object({
|
|
2827
|
+
message: z13.string().describe("The message to hash")
|
|
2856
2828
|
}),
|
|
2857
2829
|
examples: [
|
|
2858
2830
|
{ args: { message: "Hello World" }, description: "Hash a message" }
|
|
2859
2831
|
],
|
|
2860
|
-
output:
|
|
2861
|
-
hash:
|
|
2832
|
+
output: z13.object({
|
|
2833
|
+
hash: z13.string()
|
|
2862
2834
|
}),
|
|
2863
2835
|
async run(c) {
|
|
2864
2836
|
const hash = keccak256(toBytes(c.args.message));
|
|
@@ -2867,16 +2839,15 @@ message.command("hash", {
|
|
|
2867
2839
|
});
|
|
2868
2840
|
|
|
2869
2841
|
// src/cli.ts
|
|
2870
|
-
var pkg = JSON.parse(
|
|
2842
|
+
var pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
2871
2843
|
var cli = Cli14.create("openfort", {
|
|
2872
2844
|
version: pkg.version,
|
|
2873
2845
|
description: "Openfort CLI \u2014 manage wallets, policies, and transactions from the terminal.",
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
OPENFORT_BASE_URL: z15.string().optional().describe("Custom API base URL")
|
|
2846
|
+
env: z14.object({
|
|
2847
|
+
OPENFORT_API_KEY: z14.string().optional().describe("Openfort secret API key (sk_test_... or sk_live_...)"),
|
|
2848
|
+
OPENFORT_WALLET_SECRET: z14.string().optional().describe("Wallet encryption secret"),
|
|
2849
|
+
OPENFORT_PUBLISHABLE_KEY: z14.string().optional().describe("Publishable key for client-side ops"),
|
|
2850
|
+
OPENFORT_BASE_URL: z14.string().optional().describe("Custom API base URL")
|
|
2880
2851
|
}),
|
|
2881
2852
|
sync: {
|
|
2882
2853
|
depth: 2,
|
|
@@ -2894,38 +2865,6 @@ var cli = Cli14.create("openfort", {
|
|
|
2894
2865
|
}
|
|
2895
2866
|
});
|
|
2896
2867
|
cli.command(login);
|
|
2897
|
-
cli.use(async (c, next) => {
|
|
2898
|
-
const isLoginCommand = process.argv.slice(2).some((arg) => arg === "login");
|
|
2899
|
-
if (isLoginCommand) {
|
|
2900
|
-
await next();
|
|
2901
|
-
return;
|
|
2902
|
-
}
|
|
2903
|
-
let apiKey = process.env.OPENFORT_API_KEY;
|
|
2904
|
-
if (!apiKey) {
|
|
2905
|
-
const creds = loadEnvFile(CREDENTIALS_PATH);
|
|
2906
|
-
apiKey = creds.get("OPENFORT_API_KEY");
|
|
2907
|
-
if (apiKey) {
|
|
2908
|
-
process.env.OPENFORT_API_KEY = apiKey;
|
|
2909
|
-
const pk = creds.get("OPENFORT_PUBLISHABLE_KEY");
|
|
2910
|
-
if (pk && !process.env.OPENFORT_PUBLISHABLE_KEY) process.env.OPENFORT_PUBLISHABLE_KEY = pk;
|
|
2911
|
-
const ws = creds.get("OPENFORT_WALLET_SECRET");
|
|
2912
|
-
if (ws && !process.env.OPENFORT_WALLET_SECRET) process.env.OPENFORT_WALLET_SECRET = ws;
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
if (!apiKey) {
|
|
2916
|
-
throw new Errors5.IncurError({
|
|
2917
|
-
code: "MISSING_API_KEY",
|
|
2918
|
-
message: "OPENFORT_API_KEY environment variable is required.",
|
|
2919
|
-
hint: "Run: openfort login"
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
c.set("openfort", new Openfort(apiKey, {
|
|
2923
|
-
walletSecret: process.env.OPENFORT_WALLET_SECRET,
|
|
2924
|
-
publishableKey: process.env.OPENFORT_PUBLISHABLE_KEY,
|
|
2925
|
-
basePath: API_BASE_URL
|
|
2926
|
-
}));
|
|
2927
|
-
await next();
|
|
2928
|
-
});
|
|
2929
2868
|
cli.command(accounts).command(contracts).command(paymasters).command(policies).command(embeddedWallet).command(sponsorship).command(sessions).command(subscriptions).command(transactions).command(users).command(backendWallet).command(message);
|
|
2930
2869
|
var cli_default = cli;
|
|
2931
2870
|
export {
|