@fastxyz/cli 1.0.2 → 1.1.0

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.
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  NetworkConfigService
4
- } from "./chunk-F4CXF26J.js";
5
- import "./chunk-ECO24H3M.js";
6
- import "./chunk-T7HRTMD7.js";
4
+ } from "./chunk-WIODTF63.js";
5
+ import "./chunk-FLVU732R.js";
6
+ import "./chunk-WXSBQOV4.js";
7
7
  import "./chunk-77HVPD4G.js";
8
8
  export {
9
9
  NetworkConfigService
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fastxyz/cli",
3
3
  "description": "Fast CLI - Account, network, and transaction management",
4
- "version": "1.0.2",
4
+ "version": "1.1.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/fastxyz/fast-sdk",
@@ -39,10 +39,10 @@
39
39
  "@types/node": "^25.5.0",
40
40
  "@types/uuid": "^10.0.0",
41
41
  "drizzle-kit": "^0.31.10",
42
- "@fastxyz/allset-sdk": "1.0.2",
42
+ "@fastxyz/allset-sdk": "1.0.5",
43
43
  "@fastxyz/schema": "2.0.0",
44
- "@fastxyz/x402-client": "1.0.3",
45
- "@fastxyz/sdk": "2.0.0"
44
+ "@fastxyz/x402-client": "1.0.6",
45
+ "@fastxyz/sdk": "2.3.0"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",
@@ -50,6 +50,7 @@
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup",
53
- "dev": "tsup --watch"
53
+ "dev": "tsup --watch",
54
+ "test": "vitest run"
54
55
  }
55
56
  }
@@ -1,146 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- AppConfig,
4
- NetworkConfigSchema
5
- } from "./chunk-ECO24H3M.js";
6
- import {
7
- DatabaseService,
8
- DefaultNetworkError,
9
- FileIOError,
10
- InvalidNetworkConfigError,
11
- NetworkExistsError,
12
- NetworkNotFoundError,
13
- NoDefaultNetworkError,
14
- ReservedNameError,
15
- customNetworks,
16
- metadata
17
- } from "./chunk-T7HRTMD7.js";
18
-
19
- // src/services/storage/network.ts
20
- import { readFileSync } from "fs";
21
- import { eq } from "drizzle-orm";
22
- import { Effect, Schema } from "effect";
23
- var getDefaultNetwork = (db) => db.select().from(metadata).where(eq(metadata.key, "default_network")).get();
24
- var listCustomNetworks = (db) => db.select({ name: customNetworks.name }).from(customNetworks).all();
25
- var getCustomNetwork = (db, name) => db.select().from(customNetworks).where(eq(customNetworks.name, name)).get();
26
- var setDefaultNetwork = (db, name) => db.insert(metadata).values({ key: "default_network", value: name }).onConflictDoUpdate({ target: metadata.key, set: { value: name } }).run();
27
- var deleteCustomNetwork = (db, name) => db.delete(customNetworks).where(eq(customNetworks.name, name)).run();
28
- var getDefault = (handle) => Effect.flatMap(
29
- handle.query(
30
- (db) => getDefaultNetwork(db),
31
- "Failed to get default network"
32
- ),
33
- (row) => row?.value !== void 0 ? Effect.succeed(row.value) : Effect.fail(new NoDefaultNetworkError())
34
- );
35
- var resolve = (context, name) => Effect.gen(function* () {
36
- const bundled = context.config.getBundledNetwork(name);
37
- if (bundled) return bundled;
38
- const row = yield* context.handle.query(
39
- (db) => getCustomNetwork(db, name),
40
- "Failed to get network config"
41
- );
42
- if (!row) {
43
- return yield* Effect.fail(new NetworkNotFoundError({ name }));
44
- }
45
- const json = JSON.parse(row.config);
46
- return yield* Schema.decodeUnknown(NetworkConfigSchema)(json).pipe(
47
- Effect.mapError(() => new InvalidNetworkConfigError({ name }))
48
- );
49
- });
50
- var list = (context) => Effect.gen(function* () {
51
- const defaultName = yield* getDefault(context.handle);
52
- const customRows = yield* context.handle.query(
53
- (db) => listCustomNetworks(db),
54
- "Failed to list networks"
55
- );
56
- const names = [
57
- ...Object.keys(context.config.bundledNetworks),
58
- ...customRows.map((r) => r.name)
59
- ];
60
- return names.map((name) => {
61
- const type = context.config.isBundledNetwork(name) ? "bundled" : "custom";
62
- const isDefault = name === defaultName;
63
- return { name, type, isDefault };
64
- });
65
- });
66
- var setDefault = (context, name) => Effect.gen(function* () {
67
- if (!context.config.isBundledNetwork(name)) {
68
- const row = yield* context.handle.query(
69
- (db) => getCustomNetwork(db, name),
70
- "Failed to get network config"
71
- );
72
- if (!row) return yield* Effect.fail(new NetworkNotFoundError({ name }));
73
- }
74
- yield* context.handle.query(
75
- (db) => setDefaultNetwork(db, name),
76
- "Failed to set default network"
77
- );
78
- });
79
- var add = (context, name, configPath) => Effect.gen(function* () {
80
- if (context.config.isBundledNetwork(name)) {
81
- return yield* Effect.fail(new ReservedNameError({ name }));
82
- }
83
- const existing = yield* context.handle.query(
84
- (db) => getCustomNetwork(db, name),
85
- "Failed to check existing networks"
86
- );
87
- if (existing) {
88
- return yield* Effect.fail(new NetworkExistsError({ name }));
89
- }
90
- const raw = yield* Effect.try({
91
- try: () => readFileSync(configPath, "utf-8"),
92
- catch: (cause) => new FileIOError({
93
- message: `Failed to read network config file at "${configPath}"`,
94
- cause
95
- })
96
- });
97
- yield* Schema.decodeUnknown(NetworkConfigSchema)(JSON.parse(raw)).pipe(
98
- Effect.mapError(() => new InvalidNetworkConfigError({ name }))
99
- );
100
- yield* context.handle.query(
101
- (db) => db.insert(customNetworks).values({ name, config: raw }).run(),
102
- "Failed to save network config"
103
- );
104
- });
105
- var remove = (context, name) => Effect.gen(function* () {
106
- if (context.config.isBundledNetwork(name)) {
107
- return yield* Effect.fail(new ReservedNameError({ name }));
108
- }
109
- const row = yield* context.handle.query(
110
- (db) => getCustomNetwork(db, name),
111
- "Failed to check network exists"
112
- );
113
- if (!row) {
114
- return yield* Effect.fail(new NetworkNotFoundError({ name }));
115
- }
116
- const defaultName = yield* getDefault(context.handle);
117
- if (defaultName === name) {
118
- return yield* Effect.fail(new DefaultNetworkError({ name }));
119
- }
120
- yield* context.handle.query(
121
- (db) => deleteCustomNetwork(db, name),
122
- "Failed to remove network"
123
- );
124
- });
125
- var ServiceEffect = Effect.gen(function* () {
126
- const handle = yield* DatabaseService;
127
- const config = yield* AppConfig;
128
- const context = { handle, config };
129
- return {
130
- resolve: (name) => resolve(context, name),
131
- list: () => list(context),
132
- setDefault: (name) => setDefault(context, name),
133
- add: (name, configPath) => add(context, name, configPath),
134
- remove: (name) => remove(context, name),
135
- getDefault: () => getDefault(context.handle)
136
- };
137
- });
138
- var NetworkConfigService = class extends Effect.Service()(
139
- "NetworkConfigService",
140
- { effect: ServiceEffect }
141
- ) {
142
- };
143
-
144
- export {
145
- NetworkConfigService
146
- };