@5ive-tech/sdk 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @5ive-tech/sdk @solana/web3.js
13
13
  ### 1) Compile to `.five`
14
14
 
15
15
  ```bash
16
- 5ive compile src/main.v -o build/my-program.five
16
+ 5ive build
17
17
  ```
18
18
 
19
19
  ### 1b) Compile directly with SDK (optional)
package/dist/FiveSDK.d.ts CHANGED
@@ -98,10 +98,7 @@ export declare class FiveSDK {
98
98
  static compile(source: FiveScriptSource | string, options?: CompilationOptions & {
99
99
  debug?: boolean;
100
100
  }): Promise<CompilationResult>;
101
- static compileModules(mainSource: FiveScriptSource | string, modules: Array<{
102
- name: string;
103
- source: string;
104
- }>, options?: CompilationOptions & {
101
+ static compileProject(projectPath?: string, options?: CompilationOptions & {
105
102
  debug?: boolean;
106
103
  }): Promise<CompilationResult>;
107
104
  static compileWithDiscovery(entryPoint: string, options?: CompilationOptions & {
package/dist/FiveSDK.js CHANGED
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Five SDK client for Five VM scripts.
3
3
  */
4
+ import { dirname, isAbsolute, join, resolve, } from "path";
5
+ import { readFile, } from "fs/promises";
4
6
  import { FiveSDKError, } from "./types.js";
5
7
  import { BytecodeCompiler } from "./compiler/BytecodeCompiler.js";
6
8
  import { ParameterEncoder } from "./encoding/ParameterEncoder.js";
@@ -16,6 +18,8 @@ import * as Accounts from "./modules/accounts.js";
16
18
  import * as StateDiff from "./modules/state-diff.js";
17
19
  import * as Namespaces from "./modules/namespaces.js";
18
20
  import * as Admin from "./modules/admin.js";
21
+ import { parseToml } from "./project/toml.js";
22
+ import { parseProjectConfig } from "./project/config.js";
19
23
  /**
20
24
  * Main Five SDK class - entry point for all Five VM interactions
21
25
  */
@@ -130,7 +134,11 @@ export class FiveSDK {
130
134
  parameters: func.parameters?.map((param) => ({
131
135
  name: param.name,
132
136
  type: param.type,
137
+ param_type: param.param_type,
133
138
  optional: param.optional ?? false,
139
+ is_account: param.is_account ?? param.isAccount ?? false,
140
+ isAccount: param.isAccount ?? param.is_account ?? false,
141
+ attributes: Array.isArray(param.attributes) ? [...param.attributes] : [],
134
142
  })) || [],
135
143
  returnType: func.returnType,
136
144
  }));
@@ -155,16 +163,50 @@ export class FiveSDK {
155
163
  return result;
156
164
  }
157
165
  catch (error) {
158
- throw new FiveSDKError(`Compilation failed: ${error instanceof Error ? error.message : "Unknown error"}`, "COMPILATION_ERROR");
166
+ if (error instanceof FiveSDKError) {
167
+ throw error;
168
+ }
169
+ const inheritedDetails = error && typeof error === "object" && error.details
170
+ ? error.details
171
+ : undefined;
172
+ throw new FiveSDKError(`Compilation failed: ${error instanceof Error ? error.message : "Unknown error"}`, "COMPILATION_ERROR", {
173
+ ...(inheritedDetails || {}),
174
+ cause: error instanceof Error ? error.message : String(error),
175
+ });
159
176
  }
160
177
  }
161
- static async compileModules(mainSource, modules, options = {}) {
162
- const mainSourceObj = typeof mainSource === 'string' ? { content: mainSource, filename: 'main.v' } : mainSource;
178
+ static async compileProject(projectPath = process.cwd(), options = {}) {
163
179
  Validators.options(options);
164
180
  await this.initializeComponents(options.debug);
165
- if (!this.compiler)
181
+ if (!this.compiler) {
166
182
  throw new FiveSDKError("Compiler not initialized", "COMPILER_ERROR");
167
- return this.compiler.compileModules(mainSourceObj, modules, options);
183
+ }
184
+ const normalizedProjectPath = isAbsolute(projectPath)
185
+ ? projectPath
186
+ : resolve(process.cwd(), projectPath);
187
+ const configPath = normalizedProjectPath.endsWith(".toml")
188
+ ? normalizedProjectPath
189
+ : join(normalizedProjectPath, "five.toml");
190
+ const rootDir = dirname(configPath);
191
+ const rawToml = await readFile(configPath, "utf8");
192
+ const parsed = parseToml(rawToml);
193
+ const projectConfig = parseProjectConfig(parsed);
194
+ if (!projectConfig.entryPoint) {
195
+ throw new FiveSDKError(`Missing required project.entry_point in ${configPath}`, "PROJECT_CONFIG_ERROR");
196
+ }
197
+ const entryPoint = isAbsolute(projectConfig.entryPoint)
198
+ ? projectConfig.entryPoint
199
+ : resolve(rootDir, projectConfig.entryPoint);
200
+ return this.compiler.compileWithDiscovery(entryPoint, {
201
+ ...options,
202
+ target: options.target || projectConfig.target || "vm",
203
+ optimizationLevel: options.optimizationLevel ||
204
+ projectConfig.optimizations?.optimizationLevel ||
205
+ "production",
206
+ includeMetrics: options.includeMetrics,
207
+ metricsFormat: options.metricsFormat || "json",
208
+ errorFormat: options.errorFormat || "terminal",
209
+ });
168
210
  }
169
211
  static async compileWithDiscovery(entryPoint, options = {}) {
170
212
  Validators.options(options);
@@ -5,6 +5,7 @@
5
5
  * and account size calculations. Uses serialization instead of direct blockchain calls.
6
6
  */
7
7
  import { PDAUtils, SolanaPublicKeyUtils, RentCalculator, AccountValidator } from '../crypto/index.js';
8
+ import { ProgramIdResolver } from '../config/ProgramIdResolver.js';
8
9
  /**
9
10
  * AccountType enum for test compatibility
10
11
  */
@@ -22,8 +23,8 @@ export const AccountType = {
22
23
  * Account manager for Five VM scripts (serialization-based)
23
24
  */
24
25
  export class FiveAccountManager {
25
- constructor(programId = 'FiveProgramID11111111111111111111111111111') {
26
- this.programId = programId;
26
+ constructor(programId) {
27
+ this.programId = ProgramIdResolver.resolve(programId);
27
28
  }
28
29
  /**
29
30
  * Encode System Program CreateAccount instruction
File without changes