@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 +1 -1
- package/dist/FiveSDK.d.ts +1 -4
- package/dist/FiveSDK.js +47 -5
- package/dist/accounts/index.js +3 -2
- package/dist/assets/vm/dummy.file +0 -0
- package/dist/assets/vm/five_vm_wasm_bg.js +3307 -0
- package/dist/assets/vm/five_vm_wasm_bg.wasm +0 -0
- package/dist/assets/vm/five_vm_wasm_bg.wasm.d.ts +5 -5
- package/dist/compiler/BytecodeCompiler.d.ts +1 -7
- package/dist/compiler/BytecodeCompiler.js +105 -44
- package/dist/config/ProgramIdResolver.d.ts +1 -6
- package/dist/config/ProgramIdResolver.js +11 -16
- package/dist/config/VmClusterConfigResolver.d.ts +27 -0
- package/dist/config/VmClusterConfigResolver.js +111 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/accounts.js +7 -1
- package/dist/modules/admin.js +25 -12
- package/dist/modules/deploy.js +55 -21
- package/dist/modules/execute.js +58 -32
- package/dist/modules/vm-state.js +6 -1
- package/dist/project/config.js +0 -1
- package/dist/testing/TestRunner.js +6 -1
- package/dist/types.d.ts +19 -2
- package/dist/utils/abi.d.ts +4 -0
- package/dist/utils/abi.js +3 -0
- package/dist/utils/transaction.d.ts +22 -0
- package/dist/utils/transaction.js +94 -12
- package/dist/wasm/compiler/CompilationLogic.d.ts +0 -5
- package/dist/wasm/compiler/CompilationLogic.js +45 -163
- package/dist/wasm/compiler/FiveCompiler.d.ts +0 -5
- package/dist/wasm/compiler/FiveCompiler.js +0 -6
- package/dist/wasm/compiler/utils.d.ts +34 -1
- package/dist/wasm/compiler/utils.js +223 -5
- package/package.json +4 -3
package/README.md
CHANGED
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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);
|
package/dist/accounts/index.js
CHANGED
|
@@ -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
|
|
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
|