@5ive-tech/sdk 1.1.18 → 1.1.20

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.
@@ -0,0 +1,250 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const log_to_console: (a: number, b: number) => void;
5
+ export const __wbg_testresult_free: (a: number, b: number) => void;
6
+ export const __wbg_get_testresult_compute_units_used: (a: number) => bigint;
7
+ export const __wbg_set_testresult_compute_units_used: (a: number, b: bigint) => void;
8
+ export const __wbg_get_testresult_instruction_pointer: (a: number) => number;
9
+ export const __wbg_set_testresult_instruction_pointer: (a: number, b: number) => void;
10
+ export const __wbg_get_testresult_stopped_at_opcode: (a: number) => number;
11
+ export const __wbg_set_testresult_stopped_at_opcode: (a: number, b: number) => void;
12
+ export const testresult_status: (a: number, b: number) => void;
13
+ export const testresult_has_result_value: (a: number) => number;
14
+ export const testresult_get_result_value: (a: number) => number;
15
+ export const testresult_final_stack: (a: number) => number;
16
+ export const testresult_final_memory: (a: number) => number;
17
+ export const testresult_final_accounts: (a: number) => number;
18
+ export const testresult_error_message: (a: number, b: number) => void;
19
+ export const testresult_execution_context: (a: number, b: number) => void;
20
+ export const testresult_stopped_at_opcode_name: (a: number, b: number) => void;
21
+ export const __wbg_fivevmstate_free: (a: number, b: number) => void;
22
+ export const fivevmstate_stack: (a: number) => number;
23
+ export const fivevmstate_instruction_pointer: (a: number) => number;
24
+ export const fivevmstate_compute_units: (a: number) => bigint;
25
+ export const __wbg_wasmaccount_free: (a: number, b: number) => void;
26
+ export const __wbg_get_wasmaccount_lamports: (a: number) => bigint;
27
+ export const __wbg_set_wasmaccount_lamports: (a: number, b: bigint) => void;
28
+ export const __wbg_get_wasmaccount_is_writable: (a: number) => number;
29
+ export const __wbg_set_wasmaccount_is_writable: (a: number, b: number) => void;
30
+ export const __wbg_get_wasmaccount_is_signer: (a: number) => number;
31
+ export const __wbg_set_wasmaccount_is_signer: (a: number, b: number) => void;
32
+ export const wasmaccount_new: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
33
+ export const wasmaccount_key: (a: number) => number;
34
+ export const wasmaccount_data: (a: number) => number;
35
+ export const wasmaccount_set_data: (a: number, b: number, c: number) => void;
36
+ export const wasmaccount_owner: (a: number) => number;
37
+ export const __wbg_fivevmwasm_free: (a: number, b: number) => void;
38
+ export const fivevmwasm_new: (a: number, b: number, c: number) => void;
39
+ export const fivevmwasm_execute: (a: number, b: number, c: number, d: number, e: number) => void;
40
+ export const fivevmwasm_execute_partial: (a: number, b: number, c: number, d: number, e: number) => void;
41
+ export const fivevmwasm_get_state: (a: number, b: number) => void;
42
+ export const fivevmwasm_validate_bytecode: (a: number, b: number, c: number) => void;
43
+ export const fivevmwasm_get_constants: () => number;
44
+ export const wrap_with_script_header: (a: number, b: number, c: number) => void;
45
+ export const parse_function_names: (a: number, b: number, c: number) => void;
46
+ export const get_public_function_count: (a: number, b: number, c: number) => void;
47
+ export const get_function_names: (a: number, b: number, c: number) => void;
48
+ export const js_value_to_vm_value: (a: number, b: number, c: number) => void;
49
+ export const __wbg_bytecodeanalyzer_free: (a: number, b: number) => void;
50
+ export const bytecodeanalyzer_analyze: (a: number, b: number, c: number) => void;
51
+ export const bytecodeanalyzer_analyze_semantic: (a: number, b: number, c: number) => void;
52
+ export const bytecodeanalyzer_analyze_instruction_at: (a: number, b: number, c: number, d: number) => void;
53
+ export const bytecodeanalyzer_get_bytecode_summary: (a: number, b: number, c: number) => void;
54
+ export const bytecodeanalyzer_analyze_execution_flow: (a: number, b: number, c: number) => void;
55
+ export const __wbg_wasmsuggestion_free: (a: number, b: number) => void;
56
+ export const wasmsuggestion_message: (a: number, b: number) => void;
57
+ export const wasmsuggestion_explanation: (a: number, b: number) => void;
58
+ export const wasmsuggestion_code_suggestion: (a: number, b: number) => void;
59
+ export const __wbg_wasmsourcelocation_free: (a: number, b: number) => void;
60
+ export const __wbg_get_wasmsourcelocation_line: (a: number) => number;
61
+ export const __wbg_set_wasmsourcelocation_line: (a: number, b: number) => void;
62
+ export const __wbg_get_wasmsourcelocation_column: (a: number) => number;
63
+ export const __wbg_set_wasmsourcelocation_column: (a: number, b: number) => void;
64
+ export const __wbg_get_wasmsourcelocation_offset: (a: number) => number;
65
+ export const __wbg_set_wasmsourcelocation_offset: (a: number, b: number) => void;
66
+ export const __wbg_get_wasmsourcelocation_length: (a: number) => number;
67
+ export const __wbg_set_wasmsourcelocation_length: (a: number, b: number) => void;
68
+ export const wasmsourcelocation_file: (a: number, b: number) => void;
69
+ export const __wbg_wasmcompilererror_free: (a: number, b: number) => void;
70
+ export const wasmcompilererror_code: (a: number, b: number) => void;
71
+ export const wasmcompilererror_line: (a: number) => number;
72
+ export const wasmcompilererror_column: (a: number) => number;
73
+ export const wasmcompilererror_severity: (a: number, b: number) => void;
74
+ export const wasmcompilererror_category: (a: number, b: number) => void;
75
+ export const wasmcompilererror_message: (a: number, b: number) => void;
76
+ export const wasmcompilererror_description: (a: number, b: number) => void;
77
+ export const wasmcompilererror_location: (a: number) => number;
78
+ export const wasmcompilererror_suggestions: (a: number, b: number) => void;
79
+ export const wasmcompilererror_source_line: (a: number, b: number) => void;
80
+ export const wasmcompilererror_format_terminal: (a: number, b: number) => void;
81
+ export const wasmcompilererror_format_json: (a: number, b: number) => void;
82
+ export const __wbg_wasmenhancedcompilationresult_free: (a: number, b: number) => void;
83
+ export const __wbg_get_wasmenhancedcompilationresult_bytecode_size: (a: number) => number;
84
+ export const __wbg_set_wasmenhancedcompilationresult_bytecode_size: (a: number, b: number) => void;
85
+ export const __wbg_get_wasmenhancedcompilationresult_error_count: (a: number) => number;
86
+ export const __wbg_set_wasmenhancedcompilationresult_error_count: (a: number, b: number) => void;
87
+ export const __wbg_get_wasmenhancedcompilationresult_warning_count: (a: number) => number;
88
+ export const __wbg_set_wasmenhancedcompilationresult_warning_count: (a: number, b: number) => void;
89
+ export const wasmenhancedcompilationresult_compiler_errors: (a: number, b: number) => void;
90
+ export const wasmenhancedcompilationresult_format_all_terminal: (a: number, b: number) => void;
91
+ export const wasmenhancedcompilationresult_format_all_json: (a: number, b: number) => void;
92
+ export const __wbg_wasmcompilationoptions_free: (a: number, b: number) => void;
93
+ export const __wbg_get_wasmcompilationoptions_v2_preview: (a: number) => number;
94
+ export const __wbg_set_wasmcompilationoptions_v2_preview: (a: number, b: number) => void;
95
+ export const __wbg_get_wasmcompilationoptions_enable_constraint_cache: (a: number) => number;
96
+ export const __wbg_set_wasmcompilationoptions_enable_constraint_cache: (a: number, b: number) => void;
97
+ export const __wbg_get_wasmcompilationoptions_enhanced_errors: (a: number) => number;
98
+ export const __wbg_set_wasmcompilationoptions_enhanced_errors: (a: number, b: number) => void;
99
+ export const __wbg_get_wasmcompilationoptions_include_metrics: (a: number) => number;
100
+ export const __wbg_set_wasmcompilationoptions_include_metrics: (a: number, b: number) => void;
101
+ export const __wbg_get_wasmcompilationoptions_comprehensive_metrics: (a: number) => number;
102
+ export const __wbg_set_wasmcompilationoptions_comprehensive_metrics: (a: number, b: number) => void;
103
+ export const __wbg_get_wasmcompilationoptions_performance_analysis: (a: number) => number;
104
+ export const __wbg_set_wasmcompilationoptions_performance_analysis: (a: number, b: number) => void;
105
+ export const __wbg_get_wasmcompilationoptions_complexity_analysis: (a: number) => number;
106
+ export const __wbg_set_wasmcompilationoptions_complexity_analysis: (a: number, b: number) => void;
107
+ export const __wbg_get_wasmcompilationoptions_summary: (a: number) => number;
108
+ export const __wbg_set_wasmcompilationoptions_summary: (a: number, b: number) => void;
109
+ export const __wbg_get_wasmcompilationoptions_verbose: (a: number) => number;
110
+ export const __wbg_set_wasmcompilationoptions_verbose: (a: number, b: number) => void;
111
+ export const __wbg_get_wasmcompilationoptions_quiet: (a: number) => number;
112
+ export const __wbg_set_wasmcompilationoptions_quiet: (a: number, b: number) => void;
113
+ export const __wbg_get_wasmcompilationoptions_include_debug_info: (a: number) => number;
114
+ export const __wbg_set_wasmcompilationoptions_include_debug_info: (a: number, b: number) => void;
115
+ export const __wbg_get_wasmcompilationoptions_compress_output: (a: number) => number;
116
+ export const __wbg_set_wasmcompilationoptions_compress_output: (a: number, b: number) => void;
117
+ export const __wbg_get_wasmcompilationoptions_enable_module_namespaces: (a: number) => number;
118
+ export const __wbg_set_wasmcompilationoptions_enable_module_namespaces: (a: number, b: number) => void;
119
+ export const __wbg_get_wasmcompilationoptions_disable_require_batch: (a: number) => number;
120
+ export const __wbg_set_wasmcompilationoptions_disable_require_batch: (a: number, b: number) => void;
121
+ export const wasmcompilationoptions_new: () => number;
122
+ export const wasmcompilationoptions_with_mode: (a: number, b: number, c: number) => number;
123
+ export const wasmcompilationoptions_with_optimization_level: (a: number, b: number, c: number) => number;
124
+ export const wasmcompilationoptions_with_v2_preview: (a: number, b: number) => number;
125
+ export const wasmcompilationoptions_with_constraint_cache: (a: number, b: number) => number;
126
+ export const wasmcompilationoptions_with_enhanced_errors: (a: number, b: number) => number;
127
+ export const wasmcompilationoptions_with_error_format: (a: number, b: number, c: number) => number;
128
+ export const wasmcompilationoptions_with_source_file: (a: number, b: number, c: number) => number;
129
+ export const wasmcompilationoptions_with_metrics: (a: number, b: number) => number;
130
+ export const wasmcompilationoptions_with_comprehensive_metrics: (a: number, b: number) => number;
131
+ export const wasmcompilationoptions_with_metrics_format: (a: number, b: number, c: number) => number;
132
+ export const wasmcompilationoptions_with_performance_analysis: (a: number, b: number) => number;
133
+ export const wasmcompilationoptions_with_complexity_analysis: (a: number, b: number) => number;
134
+ export const wasmcompilationoptions_with_summary: (a: number, b: number) => number;
135
+ export const wasmcompilationoptions_with_verbose: (a: number, b: number) => number;
136
+ export const wasmcompilationoptions_with_quiet: (a: number, b: number) => number;
137
+ export const wasmcompilationoptions_with_analysis_depth: (a: number, b: number, c: number) => number;
138
+ export const wasmcompilationoptions_with_export_format: (a: number, b: number, c: number) => number;
139
+ export const wasmcompilationoptions_with_debug_info: (a: number, b: number) => number;
140
+ export const wasmcompilationoptions_with_compression: (a: number, b: number) => number;
141
+ export const wasmcompilationoptions_with_module_namespaces: (a: number, b: number) => number;
142
+ export const wasmcompilationoptions_with_disable_require_batch: (a: number, b: number) => number;
143
+ export const wasmcompilationoptions_production_optimized: () => number;
144
+ export const wasmcompilationoptions_development_debug: () => number;
145
+ export const wasmcompilationoptions_fast_iteration: () => number;
146
+ export const wasmcompilationoptions_mode: (a: number, b: number) => void;
147
+ export const wasmcompilationoptions_optimization_level: (a: number, b: number) => void;
148
+ export const wasmcompilationoptions_error_format: (a: number, b: number) => void;
149
+ export const wasmcompilationoptions_source_file: (a: number, b: number) => void;
150
+ export const wasmcompilationoptions_metrics_format: (a: number, b: number) => void;
151
+ export const wasmcompilationoptions_analysis_depth: (a: number, b: number) => void;
152
+ export const wasmcompilationoptions_export_format: (a: number, b: number) => void;
153
+ export const __wbg_wasmmetricscollector_free: (a: number, b: number) => void;
154
+ export const wasmmetricscollector_new: () => number;
155
+ export const wasmmetricscollector_start_phase: (a: number, b: number, c: number) => void;
156
+ export const wasmmetricscollector_end_phase: (a: number) => void;
157
+ export const wasmmetricscollector_finalize: (a: number) => void;
158
+ export const wasmmetricscollector_reset: (a: number) => void;
159
+ export const wasmmetricscollector_export: (a: number, b: number, c: number, d: number) => void;
160
+ export const wasmmetricscollector_get_metrics_object: (a: number, b: number) => void;
161
+ export const __wbg_wasmcompilationresult_free: (a: number, b: number) => void;
162
+ export const __wbg_get_wasmcompilationresult_success: (a: number) => number;
163
+ export const __wbg_set_wasmcompilationresult_success: (a: number, b: number) => void;
164
+ export const __wbg_get_wasmcompilationresult_bytecode_size: (a: number) => number;
165
+ export const __wbg_set_wasmcompilationresult_bytecode_size: (a: number, b: number) => void;
166
+ export const __wbg_get_wasmcompilationresult_error_count: (a: number) => number;
167
+ export const __wbg_set_wasmcompilationresult_error_count: (a: number, b: number) => void;
168
+ export const __wbg_get_wasmcompilationresult_warning_count: (a: number) => number;
169
+ export const __wbg_set_wasmcompilationresult_warning_count: (a: number, b: number) => void;
170
+ export const __wbg_wasmcompilationwithmetrics_free: (a: number, b: number) => void;
171
+ export const __wbg_get_wasmcompilationwithmetrics_success: (a: number) => number;
172
+ export const __wbg_set_wasmcompilationwithmetrics_success: (a: number, b: number) => void;
173
+ export const __wbg_get_wasmcompilationwithmetrics_bytecode_size: (a: number) => number;
174
+ export const __wbg_set_wasmcompilationwithmetrics_bytecode_size: (a: number, b: number) => void;
175
+ export const __wbg_wasmanalysisresult_free: (a: number, b: number) => void;
176
+ export const __wbg_get_wasmanalysisresult_success: (a: number) => number;
177
+ export const __wbg_set_wasmanalysisresult_success: (a: number, b: number) => void;
178
+ export const __wbg_get_wasmanalysisresult_analysis_time: (a: number) => number;
179
+ export const __wbg_set_wasmanalysisresult_analysis_time: (a: number, b: number) => void;
180
+ export const wasmcompilationresult_bytecode: (a: number) => number;
181
+ export const wasmcompilationresult_abi: (a: number) => number;
182
+ export const wasmcompilationresult_warnings: (a: number) => number;
183
+ export const wasmcompilationresult_errors: (a: number) => number;
184
+ export const wasmcompilationresult_compiler_errors: (a: number, b: number) => void;
185
+ export const wasmcompilationresult_disassembly: (a: number) => number;
186
+ export const wasmcompilationresult_get_formatted_errors_terminal: (a: number, b: number) => void;
187
+ export const wasmcompilationresult_get_formatted_errors_json: (a: number, b: number) => void;
188
+ export const wasmcompilationresult_format_all_terminal: (a: number, b: number) => void;
189
+ export const wasmcompilationresult_format_all_json: (a: number, b: number) => void;
190
+ export const wasmcompilationresult_get_metrics_object: (a: number) => number;
191
+ export const wasmcompilationresult_get_metrics_detailed: (a: number, b: number) => void;
192
+ export const wasmcompilationresult_metrics: (a: number, b: number) => void;
193
+ export const wasmcompilationresult_metrics_format: (a: number, b: number) => void;
194
+ export const wasmcompilationwithmetrics_bytecode: (a: number) => number;
195
+ export const wasmcompilationwithmetrics_warnings: (a: number) => number;
196
+ export const wasmcompilationwithmetrics_errors: (a: number) => number;
197
+ export const wasmcompilationwithmetrics_metrics: (a: number, b: number) => void;
198
+ export const wasmcompilationwithmetrics_get_metrics_object: (a: number, b: number) => void;
199
+ export const wasmanalysisresult_summary: (a: number, b: number) => void;
200
+ export const wasmanalysisresult_metrics: (a: number, b: number) => void;
201
+ export const wasmanalysisresult_errors: (a: number) => number;
202
+ export const wasmanalysisresult_get_metrics_object: (a: number, b: number) => void;
203
+ export const wasmfivecompiler_new: () => number;
204
+ export const wasmfivecompiler_format_error_terminal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
205
+ export const wasmfivecompiler_compile: (a: number, b: number, c: number, d: number) => number;
206
+ export const wasmfivecompiler_compileMultiWithDiscovery: (a: number, b: number, c: number, d: number, e: number) => void;
207
+ export const wasmfivecompiler_discoverModules: (a: number, b: number, c: number, d: number) => void;
208
+ export const wasmfivecompiler_compileModules: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
209
+ export const wasmfivecompiler_extractFunctionMetadata: (a: number, b: number, c: number, d: number) => void;
210
+ export const wasmfivecompiler_compile_multi: (a: number, b: number, c: number, d: number, e: number) => number;
211
+ export const wasmfivecompiler_analyze_source: (a: number, b: number, c: number) => number;
212
+ export const wasmfivecompiler_get_opcode_usage: (a: number, b: number, c: number, d: number) => void;
213
+ export const wasmfivecompiler_get_opcode_analysis: (a: number, b: number, c: number, d: number) => void;
214
+ export const wasmfivecompiler_analyze_source_mode: (a: number, b: number, c: number, d: number, e: number) => number;
215
+ export const wasmfivecompiler_parse_dsl: (a: number, b: number, c: number, d: number) => void;
216
+ export const wasmfivecompiler_type_check: (a: number, b: number, c: number, d: number) => void;
217
+ export const wasmfivecompiler_optimize_bytecode: (a: number, b: number, c: number, d: number) => void;
218
+ export const wasmfivecompiler_extract_account_definitions: (a: number, b: number, c: number, d: number) => void;
219
+ export const wasmfivecompiler_extract_function_signatures: (a: number, b: number, c: number, d: number) => void;
220
+ export const wasmfivecompiler_validate_account_constraints: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
221
+ export const wasmfivecompiler_get_compiler_stats: (a: number) => number;
222
+ export const wasmfivecompiler_generate_abi: (a: number, b: number, c: number, d: number) => void;
223
+ export const wasmfivecompiler_compile_with_abi: (a: number, b: number, c: number, d: number) => void;
224
+ export const wasmfivecompiler_validate_syntax: (a: number, b: number, c: number) => number;
225
+ export const bytecodeencoder_encode_u32: (a: number) => number;
226
+ export const bytecodeencoder_encode_u16: (a: number) => number;
227
+ export const bytecodeencoder_decode_u32: (a: number, b: number) => number;
228
+ export const bytecodeencoder_decode_u16: (a: number, b: number) => number;
229
+ export const bytecodeencoder_encoded_size_u32: (a: number) => number;
230
+ export const bytecodeencoder_encoded_size_u16: (a: number) => number;
231
+ export const parameterencoder_encode_execute: (a: number, b: number, c: number) => void;
232
+ export const get_wasm_compiler_info: () => number;
233
+ export const __wbg_set_wasmsuggestion_confidence: (a: number, b: number) => void;
234
+ export const __wbg_set_wasmenhancedcompilationresult_compilation_time: (a: number, b: number) => void;
235
+ export const __wbg_set_wasmcompilationwithmetrics_compilation_time: (a: number, b: number) => void;
236
+ export const __wbg_set_wasmcompilationresult_compilation_time: (a: number, b: number) => void;
237
+ export const __wbg_get_wasmsuggestion_confidence: (a: number) => number;
238
+ export const __wbg_get_wasmenhancedcompilationresult_compilation_time: (a: number) => number;
239
+ export const __wbg_get_wasmcompilationwithmetrics_compilation_time: (a: number) => number;
240
+ export const __wbg_get_wasmcompilationresult_compilation_time: (a: number) => number;
241
+ export const __wbg_set_wasmenhancedcompilationresult_success: (a: number, b: number) => void;
242
+ export const __wbg_get_wasmenhancedcompilationresult_success: (a: number) => number;
243
+ export const __wbg_wasmfivecompiler_free: (a: number, b: number) => void;
244
+ export const __wbg_bytecodeencoder_free: (a: number, b: number) => void;
245
+ export const __wbg_parameterencoder_free: (a: number, b: number) => void;
246
+ export const __wbindgen_export: (a: number, b: number) => number;
247
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
248
+ export const __wbindgen_export3: (a: number) => void;
249
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
250
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "five-vm-wasm",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "files": [
6
+ "five_vm_wasm_bg.wasm",
7
+ "five_vm_wasm.js",
8
+ "five_vm_wasm_bg.js",
9
+ "five_vm_wasm.d.ts"
10
+ ],
11
+ "main": "five_vm_wasm.js",
12
+ "types": "five_vm_wasm.d.ts",
13
+ "sideEffects": [
14
+ "./five_vm_wasm.js",
15
+ "./snippets/*"
16
+ ]
17
+ }
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './wasm/loader.js';
17
17
  export * from './testing/index.js';
18
18
  export * from './utils/abi.js';
19
19
  export * from './program/index.js';
20
+ export * from './session/index.js';
20
21
  export * from './modules/namespaces.js';
21
22
  export { ProgramIdResolver } from './config/ProgramIdResolver.js';
22
23
  export { FIVE_VM_PROGRAM_ID } from './types.js';
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export * from './testing/index.js';
20
20
  export * from './utils/abi.js';
21
21
  // ==================== FiveProgram High-Level API ====================
22
22
  export * from './program/index.js';
23
+ export * from './session/index.js';
23
24
  export * from './modules/namespaces.js';
24
25
  // ==================== Program ID Resolution ====================
25
26
  export { ProgramIdResolver } from './config/ProgramIdResolver.js';
@@ -53,6 +53,7 @@ options?: {
53
53
  network?: string;
54
54
  maxRetries?: number;
55
55
  fiveVMProgramId?: string;
56
+ service?: "session_v1";
56
57
  progressCallback?: (chunk: number, total: number) => void;
57
58
  vmStateAccount?: string;
58
59
  adminAccount?: string;
@@ -76,6 +77,7 @@ options?: {
76
77
  network?: string;
77
78
  maxRetries?: number;
78
79
  fiveVMProgramId?: string;
80
+ service?: "session_v1";
79
81
  vmStateAccount?: string;
80
82
  adminAccount?: string;
81
83
  exportMetadata?: ExportMetadataInput;
@@ -568,6 +568,7 @@ options = {}) {
568
568
  fiveVMProgramId: options.fiveVMProgramId,
569
569
  vmStateAccount: options.vmStateAccount,
570
570
  adminAccount: options.adminAccount,
571
+ service: options.service,
571
572
  });
572
573
  }
573
574
  const { Keypair, PublicKey, Transaction, TransactionInstruction, SystemProgram, } = await import("@solana/web3.js");
@@ -841,6 +842,7 @@ options = {}) {
841
842
  vmStateAccount: options.vmStateAccount,
842
843
  adminAccount: options.adminAccount,
843
844
  exportMetadata: options.exportMetadata,
845
+ service: options.service,
844
846
  });
845
847
  }
846
848
  const { Keypair, PublicKey, Transaction, TransactionInstruction, SystemProgram, } = await import("@solana/web3.js");
@@ -52,6 +52,11 @@ export declare function generateExecuteInstruction(scriptAccount: string, functi
52
52
  isWritable: boolean;
53
53
  isSystemAccount?: boolean;
54
54
  }>;
55
+ orderedAccountMetadata?: Array<{
56
+ isSigner: boolean;
57
+ isWritable: boolean;
58
+ isSystemAccount?: boolean;
59
+ }>;
55
60
  feeShardIndex?: number;
56
61
  payerAccount?: string;
57
62
  }): Promise<SerializedExecution>;
@@ -70,6 +75,11 @@ export declare function executeOnSolana(scriptAccount: string, connection: any,
70
75
  isWritable: boolean;
71
76
  isSystemAccount?: boolean;
72
77
  }>;
78
+ orderedAccountMetadata?: Array<{
79
+ isSigner: boolean;
80
+ isWritable: boolean;
81
+ isSystemAccount?: boolean;
82
+ }>;
73
83
  feeShardIndex?: number;
74
84
  payerAccount?: string;
75
85
  }): Promise<{
@@ -57,8 +57,11 @@ async function readVMStateShardCount(connection, vmStateAddress) {
57
57
  function selectFeeShard(shardCount) {
58
58
  const totalShards = Math.max(1, shardCount | 0);
59
59
  if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
60
+ const unbiasedUpperBound = Math.floor(0x100000000 / totalShards) * totalShards;
60
61
  const bytes = new Uint32Array(1);
61
- crypto.getRandomValues(bytes);
62
+ do {
63
+ crypto.getRandomValues(bytes);
64
+ } while (bytes[0] >= unbiasedUpperBound);
62
65
  return bytes[0] % totalShards;
63
66
  }
64
67
  return Math.floor(Math.random() * totalShards);
@@ -372,11 +375,12 @@ export async function generateExecuteInstruction(scriptAccount, functionName, pa
372
375
  }
373
376
  }
374
377
  const unknownAccounts = [];
375
- const userInstructionAccounts = accounts.map((acc) => {
378
+ const userInstructionAccounts = accounts.map((acc, index) => {
376
379
  // Check both derived ABI metadata and passed-in metadata (from FunctionBuilder)
380
+ const orderedMetadata = options.orderedAccountMetadata?.[index];
377
381
  const abiMetadata = abiAccountMetadata.get(acc);
378
382
  const passedMetadata = options.accountMetadata?.get(acc);
379
- const metadata = passedMetadata || abiMetadata;
383
+ const metadata = orderedMetadata || passedMetadata || abiMetadata;
380
384
  const isSigner = metadata ? metadata.isSigner : false;
381
385
  const isWritable = metadata
382
386
  ? (metadata.isSystemAccount ? false : metadata.isWritable)
@@ -465,6 +469,7 @@ export async function executeOnSolana(scriptAccount, connection, signerKeypair,
465
469
  fiveVMProgramId: options.fiveVMProgramId,
466
470
  abi: options.abi,
467
471
  accountMetadata: options.accountMetadata,
472
+ orderedAccountMetadata: options.orderedAccountMetadata,
468
473
  feeShardIndex: options.feeShardIndex,
469
474
  payerAccount: options.payerAccount || signerKeypair.publicKey.toString(),
470
475
  });
@@ -22,6 +22,7 @@ import type { Provider } from '../types.js';
22
22
  import { FunctionBuilder } from './FunctionBuilder.js';
23
23
  import { ProgramAccount } from './ProgramAccount.js';
24
24
  import type { SessionManager } from './SessionManager.js';
25
+ import type { SessionExecutionConfig } from '../session/index.js';
25
26
  export interface FiveProgramOptions {
26
27
  /** Enable debug logging */
27
28
  debug?: boolean;
@@ -38,8 +39,9 @@ export interface FiveProgramOptions {
38
39
  /** Optional session helper for delegated signer flows */
39
40
  session?: {
40
41
  manager: SessionManager;
41
- mode?: 'auto' | 'force-direct' | 'force-session';
42
+ mode?: SessionExecutionConfig['mode'];
42
43
  sessionAccountByFunction?: Record<string, string>;
44
+ delegateSignerByFunction?: Record<string, any>;
43
45
  delegateAccountByFunction?: Record<string, string>;
44
46
  };
45
47
  }
@@ -214,11 +214,14 @@ export class FiveProgram {
214
214
  * Return a program instance that auto-applies session account/delegate mapping.
215
215
  */
216
216
  withSession(config) {
217
+ const delegateSignerByFunction = config.delegateSignerByFunction ||
218
+ config.delegateAccountByFunction;
217
219
  return new FiveProgram(this.scriptAccount, this.abi, {
218
220
  ...this.options,
219
221
  session: {
220
222
  mode: 'auto',
221
223
  ...config,
224
+ delegateSignerByFunction,
222
225
  },
223
226
  });
224
227
  }
@@ -99,6 +99,17 @@ export declare class FunctionBuilder {
99
99
  * @returns Map of pubkey to metadata
100
100
  */
101
101
  private buildAccountMetadata;
102
+ /**
103
+ * Build metadata aligned to account position order.
104
+ * This preserves distinct flags when duplicate pubkeys are intentionally
105
+ * used for different ABI account parameters (e.g. owner + __session).
106
+ */
107
+ private buildOrderedAccountMetadata;
108
+ /**
109
+ * Collect user-provided accounts that are not present in ABI function account
110
+ * params and are not auto-injected system/PDA accounts.
111
+ */
112
+ private getExtraExplicitAccounts;
102
113
  /**
103
114
  * Generate instruction data using serialization
104
115
  * Integrates with FiveSDK.generateExecuteInstruction() for parameter encoding
@@ -105,10 +105,17 @@ export class FunctionBuilder {
105
105
  this.validateParameters();
106
106
  // Merge parameters in ABI order (accounts first, then data)
107
107
  const { mergedParams, argParams, accountPubkeys } = this.mergeParameters();
108
- // Append system accounts to the account list (they go at the end)
109
- const allAccountPubkeys = [...accountPubkeys, ...systemAccountsList];
108
+ const extraExplicitAccounts = this.getExtraExplicitAccounts(resolvedSystemAccounts, resolvedPdaAccounts);
109
+ // Append explicit extra accounts (e.g. compiler-injected implicit accounts that
110
+ // may be absent in older ABIs), then system accounts.
111
+ const allAccountPubkeys = [
112
+ ...accountPubkeys,
113
+ ...extraExplicitAccounts,
114
+ ...systemAccountsList,
115
+ ];
110
116
  // Build account metadata from ABI attributes
111
117
  const accountMetadata = this.buildAccountMetadata(allAccountPubkeys, resolvedSystemAccounts);
118
+ const orderedAccountMetadata = this.buildOrderedAccountMetadata(allAccountPubkeys, resolvedSystemAccounts, extraExplicitAccounts.length);
112
119
  if (this.options.debug) {
113
120
  console.log(`[FunctionBuilder] Building instruction for function '${this.functionDef.name}'`);
114
121
  console.log(`[FunctionBuilder] Merged params:`, mergedParams);
@@ -116,7 +123,7 @@ export class FunctionBuilder {
116
123
  }
117
124
  // Call existing SDK method to generate instruction
118
125
  // This reuses the proven parameter encoding logic
119
- const instruction = await this.generateInstructionData(mergedParams, argParams, allAccountPubkeys, accountMetadata);
126
+ const instruction = await this.generateInstructionData(mergedParams, argParams, allAccountPubkeys, accountMetadata, orderedAccountMetadata);
120
127
  if (this.options.debug) {
121
128
  console.log(`[FunctionBuilder] Generated instruction:`, instruction);
122
129
  }
@@ -169,7 +176,7 @@ export class FunctionBuilder {
169
176
  }
170
177
  applySessionDefaults() {
171
178
  const session = this.options.session;
172
- if (session?.mode === 'force-direct') {
179
+ if (session?.mode === 'force-direct' || session?.mode === 'direct') {
173
180
  return;
174
181
  }
175
182
  const functionName = this.functionDef.name;
@@ -187,20 +194,25 @@ export class FunctionBuilder {
187
194
  this.accountsMap.set(param.name, sessionAddress);
188
195
  }
189
196
  // Direct-owner fallback for compiler-injected implicit session wiring:
190
- // if no session manager config is present, alias hidden session/delegate
191
- // accounts to owner/authority so @session can take the direct-owner path.
197
+ // if no session manager config is present, wire hidden session account
198
+ // to a stable non-signer shadow key (VM program id) to avoid signer
199
+ // aliasing collisions.
192
200
  if ((isImplicit || isLegacyInjectedSessionParam) && !this.accountsMap.has(param.name) && authorityAddress) {
193
201
  if (isLegacyInjectedSessionParam) {
194
- this.accountsMap.set(param.name, authorityAddress);
202
+ this.accountsMap.set(param.name, this.options.fiveVMProgramId || '11111111111111111111111111111111');
195
203
  }
196
204
  }
197
205
  }
198
206
  }
199
207
  resolveSessionSigner() {
200
208
  const session = this.options.session;
201
- if (!session || session.mode === 'force-direct') {
209
+ if (!session || session.mode === 'force-direct' || session.mode === 'direct') {
202
210
  return undefined;
203
211
  }
212
+ const fnSigner = session?.delegateSignerByFunction?.[this.functionDef.name];
213
+ if (fnSigner) {
214
+ return fnSigner;
215
+ }
204
216
  const maybeSigner = session.manager?.delegateSigner;
205
217
  return maybeSigner;
206
218
  }
@@ -331,6 +343,87 @@ export class FunctionBuilder {
331
343
  }
332
344
  return metadata;
333
345
  }
346
+ /**
347
+ * Build metadata aligned to account position order.
348
+ * This preserves distinct flags when duplicate pubkeys are intentionally
349
+ * used for different ABI account parameters (e.g. owner + __session).
350
+ */
351
+ buildOrderedAccountMetadata(accountPubkeys, systemAccounts, extraExplicitCount) {
352
+ const ordered = [];
353
+ // First pass: identify if there's an @init constraint and find the payer
354
+ let hasInit = false;
355
+ let payerParamName;
356
+ for (const param of this.functionDef.parameters) {
357
+ if (!param.is_account)
358
+ continue;
359
+ const attributes = param.attributes || [];
360
+ if (!attributes.includes('init'))
361
+ continue;
362
+ hasInit = true;
363
+ for (const payerParam of this.functionDef.parameters) {
364
+ if (payerParam.is_account &&
365
+ payerParam !== param &&
366
+ (payerParam.attributes || []).includes('signer')) {
367
+ payerParamName = payerParam.name;
368
+ break;
369
+ }
370
+ }
371
+ break;
372
+ }
373
+ // Function account parameters in ABI order (including duplicate pubkeys)
374
+ for (const param of this.functionDef.parameters) {
375
+ if (!param.is_account)
376
+ continue;
377
+ const attributes = param.attributes || [];
378
+ ordered.push({
379
+ isSigner: attributes.includes('signer'),
380
+ isWritable: attributes.includes('mut') ||
381
+ attributes.includes('init') ||
382
+ (hasInit && payerParamName === param.name),
383
+ });
384
+ }
385
+ // Explicit extra accounts (unknown to ABI) are appended after function
386
+ // parameters and default to readonly/non-signer.
387
+ for (let i = 0; i < extraExplicitCount; i++) {
388
+ ordered.push({
389
+ isSigner: false,
390
+ isWritable: false,
391
+ });
392
+ }
393
+ // System/PDA accounts are appended after function parameters + explicit extras
394
+ const systemAddresses = new Set(Object.values(systemAccounts));
395
+ for (let i = ordered.length; i < accountPubkeys.length; i++) {
396
+ const pubkey = accountPubkeys[i];
397
+ ordered.push({
398
+ isSigner: false,
399
+ isWritable: false,
400
+ isSystemAccount: systemAddresses.has(pubkey),
401
+ });
402
+ }
403
+ return ordered;
404
+ }
405
+ /**
406
+ * Collect user-provided accounts that are not present in ABI function account
407
+ * params and are not auto-injected system/PDA accounts.
408
+ */
409
+ getExtraExplicitAccounts(systemAccounts, pdaAccounts) {
410
+ const functionAccountNames = new Set(this.functionDef.parameters
411
+ .filter((param) => param.is_account)
412
+ .map((param) => param.name));
413
+ const autoNames = new Set([
414
+ ...Object.keys(systemAccounts),
415
+ ...Object.keys(pdaAccounts),
416
+ ]);
417
+ const extras = [];
418
+ for (const [name, pubkey] of this.accountsMap.entries()) {
419
+ if (functionAccountNames.has(name))
420
+ continue;
421
+ if (autoNames.has(name))
422
+ continue;
423
+ extras.push(pubkey);
424
+ }
425
+ return extras;
426
+ }
334
427
  /**
335
428
  * Generate instruction data using serialization
336
429
  * Integrates with FiveSDK.generateExecuteInstruction() for parameter encoding
@@ -340,7 +433,7 @@ export class FunctionBuilder {
340
433
  * @param accountMetadata - Account metadata (isSigner, isWritable)
341
434
  * @returns SerializedInstruction
342
435
  */
343
- async generateInstructionData(mergedParams, argParams, accountList, accountMetadata) {
436
+ async generateInstructionData(mergedParams, argParams, accountList, accountMetadata, orderedAccountMetadata) {
344
437
  // Account list is already passed in
345
438
  // Dynamically import FiveSDK to avoid circular dependencies
346
439
  const { FiveSDK } = await import('../FiveSDK.js');
@@ -359,6 +452,7 @@ export class FunctionBuilder {
359
452
  payerAccount: this.vmPayerAccount ||
360
453
  this.options.provider?.publicKey?.toBase58?.(),
361
454
  accountMetadata: accountMetadata, // Pass account metadata for correct isWritable flags
455
+ orderedAccountMetadata,
362
456
  });
363
457
  // Map SDK's instruction format (with 'accounts') to SerializedInstruction format (with 'keys')
364
458
  const sdkInstruction = executionResult.instruction;
@@ -25,7 +25,6 @@ export interface SessionRecord {
25
25
  export interface CanonicalSessionService {
26
26
  cluster: 'localnet' | 'devnet' | 'mainnet';
27
27
  scriptAccount: string;
28
- codeHash: string;
29
28
  version: number;
30
29
  status: 'active' | 'disabled';
31
30
  }
@@ -50,12 +49,11 @@ export declare class SessionManager {
50
49
  cluster?: 'localnet' | 'devnet' | 'mainnet';
51
50
  vmProgramId?: string;
52
51
  scriptAccount?: string;
53
- codeHash?: string;
54
52
  status?: 'active' | 'disabled';
55
53
  version?: number;
56
54
  }): CanonicalSessionService;
57
55
  static scopeHashForFunctions(functions: string[]): string;
58
56
  deriveSessionAddress(authority: string, delegate: string, targetProgram: string): Promise<string>;
59
- buildCreateSessionInstruction(params: SessionCreateParams): Promise<import("../types.js").SerializedInstruction>;
60
- buildRevokeSessionInstruction(authority: string, delegate: string, targetProgram: string, payer?: string): Promise<import("../types.js").SerializedInstruction>;
57
+ buildCreateSessionInstruction(params: SessionCreateParams): Promise<import("@solana/web3.js").TransactionInstruction>;
58
+ buildRevokeSessionInstruction(authority: string, delegate: string, targetProgram: string, payer?: string): Promise<import("@solana/web3.js").TransactionInstruction>;
61
59
  }