@5ive-tech/sdk 1.1.2

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.
Files changed (119) hide show
  1. package/README.md +279 -0
  2. package/dist/FiveSDK.d.ts +336 -0
  3. package/dist/FiveSDK.js +395 -0
  4. package/dist/accounts/index.d.ts +254 -0
  5. package/dist/accounts/index.js +543 -0
  6. package/dist/assets/vm/dummy.file +0 -0
  7. package/dist/assets/vm/five_vm_wasm.d.ts +762 -0
  8. package/dist/assets/vm/five_vm_wasm.js +3754 -0
  9. package/dist/assets/vm/five_vm_wasm_bg.js +3307 -0
  10. package/dist/assets/vm/five_vm_wasm_bg.wasm +0 -0
  11. package/dist/assets/vm/five_vm_wasm_bg.wasm.d.ts +247 -0
  12. package/dist/assets/vm/package.json +11 -0
  13. package/dist/bin/gen-types.d.ts +2 -0
  14. package/dist/bin/gen-types.js +35 -0
  15. package/dist/compiler/BytecodeCompiler.d.ts +83 -0
  16. package/dist/compiler/BytecodeCompiler.js +379 -0
  17. package/dist/config/ConfigManager.d.ts +13 -0
  18. package/dist/config/ConfigManager.js +27 -0
  19. package/dist/config/ProgramIdResolver.d.ts +62 -0
  20. package/dist/config/ProgramIdResolver.js +104 -0
  21. package/dist/crypto/index.d.ts +211 -0
  22. package/dist/crypto/index.js +451 -0
  23. package/dist/encoding/ParameterEncoder.d.ts +31 -0
  24. package/dist/encoding/ParameterEncoder.js +278 -0
  25. package/dist/index.d.ts +21 -0
  26. package/dist/index.js +28 -0
  27. package/dist/lib/bytecode-encoder.d.ts +62 -0
  28. package/dist/lib/bytecode-encoder.js +281 -0
  29. package/dist/logging/index.d.ts +9 -0
  30. package/dist/logging/index.js +10 -0
  31. package/dist/metadata/index.d.ts +213 -0
  32. package/dist/metadata/index.js +296 -0
  33. package/dist/modules/accounts.d.ts +60 -0
  34. package/dist/modules/accounts.js +275 -0
  35. package/dist/modules/deploy.d.ts +90 -0
  36. package/dist/modules/deploy.js +1118 -0
  37. package/dist/modules/execute.d.ts +90 -0
  38. package/dist/modules/execute.js +649 -0
  39. package/dist/modules/fees.d.ts +14 -0
  40. package/dist/modules/fees.js +112 -0
  41. package/dist/modules/namespaces.d.ts +39 -0
  42. package/dist/modules/namespaces.js +190 -0
  43. package/dist/modules/state-diff.d.ts +35 -0
  44. package/dist/modules/state-diff.js +342 -0
  45. package/dist/modules/vm-state.d.ts +7 -0
  46. package/dist/modules/vm-state.js +44 -0
  47. package/dist/program/AccountResolver.d.ts +67 -0
  48. package/dist/program/AccountResolver.js +134 -0
  49. package/dist/program/BorshSchemaGenerator.d.ts +8 -0
  50. package/dist/program/BorshSchemaGenerator.js +57 -0
  51. package/dist/program/FiveProgram.d.ts +144 -0
  52. package/dist/program/FiveProgram.js +282 -0
  53. package/dist/program/FunctionBuilder.d.ts +114 -0
  54. package/dist/program/FunctionBuilder.js +347 -0
  55. package/dist/program/ProgramAccount.d.ts +38 -0
  56. package/dist/program/ProgramAccount.js +170 -0
  57. package/dist/program/TypeGenerator.d.ts +90 -0
  58. package/dist/program/TypeGenerator.js +195 -0
  59. package/dist/program/index.d.ts +24 -0
  60. package/dist/program/index.js +21 -0
  61. package/dist/project/config.d.ts +5 -0
  62. package/dist/project/config.js +33 -0
  63. package/dist/project/toml.d.ts +6 -0
  64. package/dist/project/toml.js +43 -0
  65. package/dist/project/workspace.d.ts +160 -0
  66. package/dist/project/workspace.js +73 -0
  67. package/dist/testing/AccountMetaGenerator.d.ts +121 -0
  68. package/dist/testing/AccountMetaGenerator.js +261 -0
  69. package/dist/testing/AccountTestFixture.d.ts +211 -0
  70. package/dist/testing/AccountTestFixture.js +530 -0
  71. package/dist/testing/OnChainAccountManager.d.ts +81 -0
  72. package/dist/testing/OnChainAccountManager.js +260 -0
  73. package/dist/testing/StateSerializer.d.ts +65 -0
  74. package/dist/testing/StateSerializer.js +330 -0
  75. package/dist/testing/TestDiscovery.d.ts +79 -0
  76. package/dist/testing/TestDiscovery.js +274 -0
  77. package/dist/testing/TestRunner.d.ts +117 -0
  78. package/dist/testing/TestRunner.js +346 -0
  79. package/dist/testing/index.d.ts +14 -0
  80. package/dist/testing/index.js +13 -0
  81. package/dist/types.d.ts +356 -0
  82. package/dist/types.js +32 -0
  83. package/dist/utils/abi.d.ts +31 -0
  84. package/dist/utils/abi.js +92 -0
  85. package/dist/utils/transaction.d.ts +5 -0
  86. package/dist/utils/transaction.js +48 -0
  87. package/dist/validation/InputValidator.d.ts +142 -0
  88. package/dist/validation/InputValidator.js +332 -0
  89. package/dist/validation/index.d.ts +4 -0
  90. package/dist/validation/index.js +4 -0
  91. package/dist/wasm/compiler/AbiLogic.d.ts +4 -0
  92. package/dist/wasm/compiler/AbiLogic.js +37 -0
  93. package/dist/wasm/compiler/AnalysisLogic.d.ts +6 -0
  94. package/dist/wasm/compiler/AnalysisLogic.js +61 -0
  95. package/dist/wasm/compiler/CompilationLogic.d.ts +10 -0
  96. package/dist/wasm/compiler/CompilationLogic.js +431 -0
  97. package/dist/wasm/compiler/FiveCompiler.d.ts +48 -0
  98. package/dist/wasm/compiler/FiveCompiler.js +183 -0
  99. package/dist/wasm/compiler/InfoLogic.d.ts +6 -0
  100. package/dist/wasm/compiler/InfoLogic.js +24 -0
  101. package/dist/wasm/compiler/OptimizationLogic.d.ts +2 -0
  102. package/dist/wasm/compiler/OptimizationLogic.js +13 -0
  103. package/dist/wasm/compiler/ValidationLogic.d.ts +7 -0
  104. package/dist/wasm/compiler/ValidationLogic.js +26 -0
  105. package/dist/wasm/compiler/index.d.ts +2 -0
  106. package/dist/wasm/compiler/index.js +2 -0
  107. package/dist/wasm/compiler/types.d.ts +8 -0
  108. package/dist/wasm/compiler/types.js +1 -0
  109. package/dist/wasm/compiler/utils.d.ts +8 -0
  110. package/dist/wasm/compiler/utils.js +75 -0
  111. package/dist/wasm/index.d.ts +9 -0
  112. package/dist/wasm/index.js +12 -0
  113. package/dist/wasm/instance.d.ts +1 -0
  114. package/dist/wasm/instance.js +26 -0
  115. package/dist/wasm/loader.d.ts +7 -0
  116. package/dist/wasm/loader.js +112 -0
  117. package/dist/wasm/vm.d.ts +33 -0
  118. package/dist/wasm/vm.js +250 -0
  119. package/package.json +59 -0
package/README.md ADDED
@@ -0,0 +1,279 @@
1
+ # Five SDK
2
+
3
+ Client-agnostic TypeScript SDK for interacting with 5ive DSL programs on Solana.
4
+
5
+ This README is for external developers using:
6
+ - `five-cli`
7
+ - `five-sdk`
8
+ - [5ive.tech](https://5ive.tech)
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @5ive-tech/sdk @solana/web3.js
14
+ ```
15
+
16
+ Note: Some older examples may use `@5ive-tech/sdk`. Use the package name your registry currently publishes for your release channel.
17
+
18
+ ## Quick Start
19
+
20
+ ### 1. Compile with `five-cli` to `.five` artifact
21
+
22
+ ```bash
23
+ five compile src/main.v -o build/my-program.five
24
+ ```
25
+
26
+ ### 1b. Compile directly with `five-sdk` (optional)
27
+
28
+ ```ts
29
+ import { FiveSDK } from '@5ive-tech/sdk';
30
+ import fs from 'fs';
31
+
32
+ const source = `
33
+ pub add(a: u64, b: u64) -> u64 {
34
+ return a + b;
35
+ }
36
+ `;
37
+
38
+ const result = await FiveSDK.compile(source, {
39
+ optimize: true,
40
+ debug: false,
41
+ });
42
+
43
+ if (!result.success || !result.fiveFile) {
44
+ throw new Error(`Compilation failed: ${JSON.stringify(result.errors ?? [])}`);
45
+ }
46
+
47
+ fs.writeFileSync('build/my-program.five', JSON.stringify(result.fiveFile, null, 2));
48
+ ```
49
+
50
+ Compile from file path:
51
+
52
+ ```ts
53
+ const fileResult = await FiveSDK.compileFile('src/main.v', { optimize: true });
54
+ ```
55
+
56
+ Compile multi-file/module source:
57
+
58
+ ```ts
59
+ const multi = await FiveSDK.compileModules(
60
+ { filename: 'main.v', content: mainSource },
61
+ [{ name: 'math', source: mathModuleSource }],
62
+ { optimize: true }
63
+ );
64
+ ```
65
+
66
+ ### 2. Load ABI from `.five`
67
+
68
+ ```ts
69
+ import fs from 'fs';
70
+ import { FiveSDK } from '@5ive-tech/sdk';
71
+
72
+ const fiveFileText = fs.readFileSync('build/my-program.five', 'utf-8');
73
+ const { abi } = await FiveSDK.loadFiveFile(fiveFileText);
74
+ ```
75
+
76
+ ### 3. Configure program ID resolution
77
+
78
+ On-chain instruction generation requires a resolvable Five VM program ID.
79
+ Resolution precedence:
80
+ 1. Explicit `fiveVMProgramId`
81
+ 2. `FiveSDK.setDefaultProgramId(...)`
82
+ 3. `FIVE_PROGRAM_ID` environment variable
83
+ 4. Release-baked default
84
+
85
+ ```ts
86
+ import { FiveSDK } from '@5ive-tech/sdk';
87
+
88
+ FiveSDK.setDefaultProgramId('YourFiveVMProgramIdBase58');
89
+ ```
90
+
91
+ ### 4. Create `FiveProgram`
92
+
93
+ ```ts
94
+ import { FiveProgram } from '@5ive-tech/sdk';
95
+
96
+ const program = FiveProgram.fromABI('ScriptAccountBase58', abi, {
97
+ fiveVMProgramId: 'YourFiveVMProgramIdBase58',
98
+ vmStateAccount: 'VmStatePdaBase58',
99
+ feeReceiverAccount: 'FeeReceiverBase58',
100
+ debug: false,
101
+ });
102
+ ```
103
+
104
+ ## Build and Send Instructions
105
+
106
+ ```ts
107
+ import {
108
+ Connection,
109
+ PublicKey,
110
+ Transaction,
111
+ TransactionInstruction,
112
+ sendAndConfirmTransaction,
113
+ } from '@solana/web3.js';
114
+
115
+ const connection = new Connection('http://127.0.0.1:8899', 'confirmed');
116
+
117
+ const ixData = await program
118
+ .function('transfer')
119
+ .accounts({
120
+ source_account: sourcePubkey,
121
+ destination_account: destinationPubkey,
122
+ owner: ownerPubkey,
123
+ })
124
+ .args({ amount: 100 })
125
+ .instruction();
126
+
127
+ const ix = new TransactionInstruction({
128
+ programId: new PublicKey(ixData.programId),
129
+ keys: ixData.keys.map((k) => ({
130
+ pubkey: new PublicKey(k.pubkey),
131
+ isSigner: k.isSigner,
132
+ isWritable: k.isWritable,
133
+ })),
134
+ data: Buffer.from(ixData.data, 'base64'),
135
+ });
136
+
137
+ const tx = new Transaction().add(ix);
138
+ const signature = await sendAndConfirmTransaction(connection, tx, [payer], {
139
+ skipPreflight: false,
140
+ commitment: 'confirmed',
141
+ });
142
+
143
+ const txDetails = await connection.getTransaction(signature, {
144
+ maxSupportedTransactionVersion: 0,
145
+ commitment: 'confirmed',
146
+ });
147
+
148
+ if (txDetails?.meta?.err) {
149
+ throw new Error(`On-chain error: ${JSON.stringify(txDetails.meta.err)}`);
150
+ }
151
+
152
+ console.log('signature', signature);
153
+ console.log('computeUnits', txDetails?.meta?.computeUnitsConsumed);
154
+ ```
155
+
156
+ ## Operational Patterns
157
+
158
+ ### Function naming in multi-file programs
159
+
160
+ Function names must match ABI names exactly, including namespaced forms such as `math::add`.
161
+
162
+ ```ts
163
+ console.log(program.getFunctions());
164
+ ```
165
+
166
+ ### Account wiring behavior
167
+
168
+ `FunctionBuilder` automatically handles:
169
+ - system-account injection when ABI constraints require it
170
+ - PDA account resolution from ABI metadata
171
+ - signer/writable metadata derivation from ABI attributes
172
+
173
+ You still must pass all required business accounts and arguments.
174
+
175
+ ### Deterministic error handling
176
+
177
+ Recommended send pattern:
178
+ 1. send with `skipPreflight: false`
179
+ 2. fetch confirmed transaction
180
+ 3. assert `meta.err` is null
181
+ 4. record CU from `meta.computeUnitsConsumed`
182
+
183
+ ## Advanced SDK APIs (Optional)
184
+
185
+ Most builders should use `FiveProgram` first. Use these lower-level APIs when you need finer control.
186
+
187
+ ### 1) Local VM testing without RPC
188
+
189
+ ```ts
190
+ const run = await FiveSDK.compileAndExecuteLocally(
191
+ sourceCode,
192
+ 'transfer',
193
+ [100],
194
+ { optimize: true, trace: true, computeUnitLimit: 1_000_000 }
195
+ );
196
+ ```
197
+
198
+ ### 2) Instruction-only generation (bring your own sender)
199
+
200
+ ```ts
201
+ const deploy = await FiveSDK.generateDeployInstruction(bytecode, deployerPubkeyBase58, {
202
+ debug: false,
203
+ });
204
+
205
+ const exec = await FiveSDK.generateExecuteInstruction(
206
+ scriptAccountBase58,
207
+ 'transfer',
208
+ [100],
209
+ [ownerPubkeyBase58],
210
+ connection,
211
+ { computeUnitLimit: 1_000_000 }
212
+ );
213
+ ```
214
+
215
+ ### 3) On-chain convenience helpers
216
+
217
+ ```ts
218
+ const deployResult = await FiveSDK.deployToSolana(bytecode, connection, payerKeypair, {
219
+ fiveVMProgramId: 'YourFiveVMProgramIdBase58',
220
+ });
221
+
222
+ const execResult = await FiveSDK.executeOnSolana(
223
+ deployResult.scriptAccount,
224
+ connection,
225
+ payerKeypair,
226
+ 'transfer',
227
+ [100],
228
+ [ownerPubkeyBase58],
229
+ { fiveVMProgramId: 'YourFiveVMProgramIdBase58' }
230
+ );
231
+ ```
232
+
233
+ ### 4) Metadata, decoding, and diagnostics
234
+
235
+ ```ts
236
+ const meta = await FiveSDK.getScriptMetadataWithConnection(scriptAccountBase58, connection);
237
+ const names = await FiveSDK.getFunctionNamesFromScriptAccount(scriptAccountBase58, connection);
238
+ const account = await FiveSDK.fetchAccountAndDeserialize(scriptAccountBase58, connection, {
239
+ parseMetadata: true,
240
+ });
241
+ ```
242
+
243
+ ### 5) Namespace helpers (5NS)
244
+
245
+ ```ts
246
+ const ns = FiveSDK.canonicalizeNamespace('@acme/payments');
247
+ const derived = await FiveSDK.deriveNamespaceAccounts(ns.canonical, 'YourFiveVMProgramIdBase58');
248
+ ```
249
+
250
+ ### 6) Test utilities
251
+
252
+ ```ts
253
+ import { FiveTestRunner } from '@5ive-tech/sdk';
254
+
255
+ const runner = new FiveTestRunner({ verbose: true, maxComputeUnits: 1_000_000 });
256
+ ```
257
+
258
+ ## Frontend Usage (`5ive.tech`)
259
+
260
+ For frontend integration patterns and UI workflows, use [5ive.tech](https://5ive.tech).
261
+ Typical flow:
262
+ 1. compile/deploy with `five-cli`
263
+ 2. use `five-sdk` in your app/backend to generate instructions
264
+ 3. submit signed transactions from wallet-enabled frontend
265
+
266
+ ## Troubleshooting
267
+
268
+ ### `No program ID resolved for Five VM`
269
+ Set one via explicit `fiveVMProgramId`, `FiveSDK.setDefaultProgramId`, or `FIVE_PROGRAM_ID`.
270
+
271
+ ### `Function '<name>' not found in ABI`
272
+ Use exact ABI function names (including namespace prefixes).
273
+
274
+ ### `Missing required account` / `Missing required argument`
275
+ Provide all required fields in `.accounts(...)` and `.args(...)`.
276
+
277
+ ## Next Doc
278
+
279
+ For API-level usage details, see `FIVEPROGRAM_USAGE_GUIDE.md`.
@@ -0,0 +1,336 @@
1
+ /**
2
+ * Five SDK client for Five VM scripts.
3
+ */
4
+ import { FiveSDKConfig, FiveScriptSource, FiveBytecode, CompilationOptions, CompilationResult, DeploymentOptions, SerializedDeployment, SerializedExecution, FiveCompiledFile, FunctionNameEntry, FeeInformation } from "./types.js";
5
+ import { ScriptMetadata } from "./metadata/index.js";
6
+ import * as Namespaces from "./modules/namespaces.js";
7
+ /**
8
+ * Main Five SDK class - entry point for all Five VM interactions
9
+ */
10
+ export declare class FiveSDK {
11
+ private static compiler;
12
+ private static parameterEncoder;
13
+ private static metadataCache;
14
+ private fiveVMProgramId?;
15
+ private debug;
16
+ private network?;
17
+ constructor(config?: FiveSDKConfig);
18
+ getConfig(): FiveSDKConfig & {
19
+ network?: string;
20
+ };
21
+ private static initializeComponents;
22
+ static create(options?: {
23
+ debug?: boolean;
24
+ fiveVMProgramId?: string;
25
+ }): FiveSDK;
26
+ static devnet(options?: {
27
+ debug?: boolean;
28
+ fiveVMProgramId?: string;
29
+ }): FiveSDK;
30
+ static mainnet(options?: {
31
+ debug?: boolean;
32
+ fiveVMProgramId?: string;
33
+ }): FiveSDK;
34
+ static localnet(options?: {
35
+ debug?: boolean;
36
+ fiveVMProgramId?: string;
37
+ }): FiveSDK;
38
+ /**
39
+ * Set the default program ID for all SDK instances and operations
40
+ * Useful when deploying to a known program ID across your application
41
+ * @param programId - Solana public key (base58 encoded)
42
+ */
43
+ static setDefaultProgramId(programId: string): void;
44
+ /**
45
+ * Get the currently set default program ID
46
+ * @returns The default program ID, or undefined if not set
47
+ */
48
+ static getDefaultProgramId(): string | undefined;
49
+ static canonicalizeNamespace(value: string): Namespaces.ScopedNamespace;
50
+ static namespaceSeedBytes(value: string): Uint8Array;
51
+ static resolveNamespaceFromLockfile(value: string, lockfile: any): string | undefined;
52
+ static deriveNamespaceAccounts(value: string, fiveVMProgramId: string): Promise<Namespaces.NamespaceDerivedAccounts>;
53
+ static registerNamespaceTldOnChain(namespaceValue: string, options: {
54
+ managerScriptAccount: string;
55
+ connection: any;
56
+ signerKeypair: any;
57
+ fiveVMProgramId?: string;
58
+ debug?: boolean;
59
+ }): Promise<{
60
+ transactionId?: string;
61
+ tldAddress: string;
62
+ owner: string;
63
+ treasuryAccount: string;
64
+ }>;
65
+ static bindNamespaceOnChain(namespaceValue: string, scriptAccount: string, options: {
66
+ managerScriptAccount: string;
67
+ connection: any;
68
+ signerKeypair: any;
69
+ fiveVMProgramId?: string;
70
+ debug?: boolean;
71
+ }): Promise<{
72
+ transactionId?: string;
73
+ bindingAddress: string;
74
+ owner: string;
75
+ }>;
76
+ static resolveNamespaceOnChain(namespaceValue: string, options: {
77
+ managerScriptAccount: string;
78
+ connection: any;
79
+ signerKeypair: any;
80
+ fiveVMProgramId?: string;
81
+ debug?: boolean;
82
+ }): Promise<{
83
+ transactionId?: string;
84
+ resolvedScript?: string;
85
+ bindingAddress: string;
86
+ }>;
87
+ static compile(source: FiveScriptSource | string, options?: CompilationOptions & {
88
+ debug?: boolean;
89
+ }): Promise<CompilationResult>;
90
+ static compileModules(mainSource: FiveScriptSource | string, modules: Array<{
91
+ name: string;
92
+ source: string;
93
+ }>, options?: CompilationOptions & {
94
+ debug?: boolean;
95
+ }): Promise<CompilationResult>;
96
+ static compileWithDiscovery(entryPoint: string, options?: CompilationOptions & {
97
+ debug?: boolean;
98
+ }): Promise<CompilationResult>;
99
+ static discoverModules(entryPoint: string, options?: {
100
+ debug?: boolean;
101
+ }): Promise<string[]>;
102
+ static compileFile(filePath: string, options?: CompilationOptions & {
103
+ debug?: boolean;
104
+ }): Promise<CompilationResult>;
105
+ static loadFiveFile(fileContent: string): Promise<{
106
+ bytecode: FiveBytecode;
107
+ abi: any;
108
+ debug?: any;
109
+ }>;
110
+ static extractBytecode(fiveFile: FiveCompiledFile): FiveBytecode;
111
+ static resolveFunctionIndex(abi: any, functionName: string): number;
112
+ static executeLocally(bytecode: FiveBytecode, functionName: string | number, parameters?: any[], options?: {
113
+ debug?: boolean;
114
+ trace?: boolean;
115
+ computeUnitLimit?: number;
116
+ abi?: any;
117
+ accounts?: string[];
118
+ }): Promise<any>;
119
+ static execute(source: FiveScriptSource | string, functionName: string | number, parameters?: any[], options?: {
120
+ debug?: boolean;
121
+ trace?: boolean;
122
+ optimize?: boolean;
123
+ computeUnitLimit?: number;
124
+ vmStateAccount?: string;
125
+ accounts?: string[];
126
+ }): Promise<{
127
+ success: boolean;
128
+ compilationErrors: import("./types.js").CompilationError[];
129
+ error: string;
130
+ } | {
131
+ compilation: CompilationResult;
132
+ bytecodeSize: number;
133
+ functions: any[];
134
+ success: boolean;
135
+ result?: any;
136
+ logs?: string[];
137
+ computeUnitsUsed?: number;
138
+ executionTime?: number;
139
+ error?: string;
140
+ trace?: any[];
141
+ compilationErrors?: undefined;
142
+ }>;
143
+ static validateBytecode(bytecode: FiveBytecode, options?: {
144
+ debug?: boolean;
145
+ }): Promise<{
146
+ valid: boolean;
147
+ errors?: string[];
148
+ metadata?: any;
149
+ functions?: any[];
150
+ }>;
151
+ static generateDeployInstruction(bytecode: FiveBytecode, deployer: string, options?: DeploymentOptions & {
152
+ debug?: boolean;
153
+ }, connection?: any): Promise<SerializedDeployment>;
154
+ static generateExecuteInstruction(scriptAccount: string, functionName: string | number, parameters?: any[], accounts?: string[], connection?: any, options?: {
155
+ debug?: boolean;
156
+ computeUnitLimit?: number;
157
+ vmStateAccount?: string;
158
+ fiveVMProgramId?: string;
159
+ abi?: any;
160
+ adminAccount?: string;
161
+ estimateFees?: boolean;
162
+ accountMetadata?: Map<string, {
163
+ isSigner: boolean;
164
+ isWritable: boolean;
165
+ isSystemAccount?: boolean;
166
+ }>;
167
+ }): Promise<SerializedExecution>;
168
+ static getVMState(connection: any, fiveVMProgramId?: string): Promise<{
169
+ authority: string;
170
+ scriptCount: number;
171
+ deployFeeBps: number;
172
+ executeFeeBps: number;
173
+ isInitialized: boolean;
174
+ }>;
175
+ static getFees(connection: any, fiveVMProgramId?: string): Promise<{
176
+ deployFeeBps: number;
177
+ executeFeeBps: number;
178
+ adminAccount: string | null;
179
+ }>;
180
+ static calculateDeployFee(bytecodeSize: number, connection?: any, fiveVMProgramId?: string): Promise<FeeInformation>;
181
+ static calculateExecuteFee(connection?: any, fiveVMProgramId?: string): Promise<FeeInformation>;
182
+ static getFeeInformation(bytecodeSize: number, connection?: any, fiveVMProgramId?: string): Promise<{
183
+ deploy: FeeInformation;
184
+ execute: FeeInformation;
185
+ adminAccount: string | null;
186
+ feesEnabled: boolean;
187
+ }>;
188
+ static getScriptMetadata(scriptAccount: string, connection?: any): Promise<{
189
+ functions: any[];
190
+ }>;
191
+ static getScriptMetadataWithConnection(scriptAccount: string, connection: any): Promise<ScriptMetadata>;
192
+ static parseScriptMetadata(accountData: Uint8Array, address: string): ScriptMetadata;
193
+ static getCachedScriptMetadata(scriptAccount: string, connection: any, cacheTTL?: number): Promise<ScriptMetadata>;
194
+ static invalidateMetadataCache(scriptAccount: string): void;
195
+ static getMetadataCacheStats(): any;
196
+ static executeOnSolana(scriptAccount: string, connection: any, signerKeypair: any, functionName: string | number, parameters?: any[], accounts?: string[], options?: any): Promise<{
197
+ success: boolean;
198
+ result?: any;
199
+ transactionId?: string;
200
+ computeUnitsUsed?: number;
201
+ cost?: number;
202
+ error?: string;
203
+ logs?: string[];
204
+ }>;
205
+ static executeScriptAccount(scriptAccount: string, functionIndex: number, parameters: any[], connection: any, signerKeypair: any, options?: any): Promise<{
206
+ success: boolean;
207
+ result?: any;
208
+ transactionId?: string;
209
+ computeUnitsUsed?: number;
210
+ cost?: number;
211
+ error?: string;
212
+ logs?: string[];
213
+ }>;
214
+ static getFunctionNames(bytecode: FiveBytecode): Promise<FunctionNameEntry[]>;
215
+ static callFunctionByName(scriptAccount: string, functionName: string, parameters?: any[], accounts?: string[], connection?: any, options?: any): Promise<SerializedExecution>;
216
+ static executeByIndex(scriptAccount: string, functionIndex: number, parameters?: any[], accounts?: string[], connection?: any, options?: any): Promise<SerializedExecution>;
217
+ static getFunctionNamesFromScriptAccount(scriptAccount: string, connection?: any): Promise<FunctionNameEntry[] | null>;
218
+ static createDeploymentTransaction(bytecode: FiveBytecode, connection: any, deployerPublicKey: any, options?: any): Promise<{
219
+ transaction: any;
220
+ scriptKeypair: any;
221
+ vmStateKeypair: any;
222
+ programId: string;
223
+ rentLamports: number;
224
+ }>;
225
+ static deployToSolana(bytecode: FiveBytecode, connection: any, deployerKeypair: any, options?: any): Promise<{
226
+ success: boolean;
227
+ programId?: string;
228
+ transactionId?: string;
229
+ deploymentCost?: number;
230
+ error?: string;
231
+ logs?: string[];
232
+ vmStateAccount?: string;
233
+ }>;
234
+ static deployLargeProgramToSolana(bytecode: FiveBytecode, connection: any, deployerKeypair: any, options?: any): Promise<{
235
+ success: boolean;
236
+ scriptAccount?: string;
237
+ transactionIds?: string[];
238
+ totalTransactions?: number;
239
+ deploymentCost?: number;
240
+ chunksUsed?: number;
241
+ vmStateAccount?: string;
242
+ error?: string;
243
+ logs?: string[];
244
+ }>;
245
+ static deployLargeProgramOptimizedToSolana(bytecode: FiveBytecode, connection: any, deployerKeypair: any, options?: any): Promise<{
246
+ success: boolean;
247
+ scriptAccount?: string;
248
+ transactionIds?: string[];
249
+ totalTransactions?: number;
250
+ deploymentCost?: number;
251
+ chunksUsed?: number;
252
+ vmStateAccount?: string;
253
+ optimizationSavings?: {
254
+ transactionsSaved: number;
255
+ estimatedCostSaved: number;
256
+ };
257
+ error?: string;
258
+ logs?: string[];
259
+ }>;
260
+ static fetchAccountAndDeserialize(accountAddress: string, connection: any, options?: any): Promise<{
261
+ success: boolean;
262
+ accountInfo?: {
263
+ address: string;
264
+ owner: string;
265
+ lamports: number;
266
+ dataLength: number;
267
+ };
268
+ scriptMetadata?: ScriptMetadata;
269
+ rawBytecode?: Uint8Array;
270
+ decodedData?: {
271
+ header: any;
272
+ bytecode: Uint8Array;
273
+ abi?: any;
274
+ functions?: Array<{
275
+ name: string;
276
+ index: number;
277
+ parameters: any[];
278
+ }>;
279
+ };
280
+ error?: string;
281
+ logs?: string[];
282
+ }>;
283
+ static fetchMultipleAccountsAndDeserialize(accountAddresses: string[], connection: any, options?: any): Promise<Map<string, {
284
+ success: boolean;
285
+ accountInfo?: any;
286
+ scriptMetadata?: ScriptMetadata;
287
+ rawBytecode?: Uint8Array;
288
+ decodedData?: any;
289
+ error?: string;
290
+ logs?: string[];
291
+ }>>;
292
+ static deserializeParameters(instructionData: Uint8Array, expectedTypes?: string[], options?: any): Promise<{
293
+ success: boolean;
294
+ parameters?: Array<{
295
+ type: string;
296
+ value: any;
297
+ }>;
298
+ functionIndex?: number;
299
+ discriminator?: number;
300
+ error?: string;
301
+ }>;
302
+ static validateBytecodeEncoding(bytecode: Uint8Array, debug?: boolean): Promise<{
303
+ valid: boolean;
304
+ error?: string;
305
+ info?: string;
306
+ }>;
307
+ static executeWithStateDiff(scriptAccount: string, connection: any, signerKeypair: any, functionName: string | number, parameters?: any[], options?: any): Promise<{
308
+ success: boolean;
309
+ execution?: {
310
+ transactionId?: string;
311
+ result?: any;
312
+ computeUnitsUsed?: number;
313
+ logs?: string[];
314
+ };
315
+ stateDiff?: {
316
+ beforeState: Map<string, any>;
317
+ afterState: Map<string, any>;
318
+ changes: Array<{
319
+ account: string;
320
+ fieldName?: string;
321
+ oldValue: any;
322
+ newValue: any;
323
+ changeType: "created" | "modified" | "deleted";
324
+ }>;
325
+ globalFieldChanges?: Array<{
326
+ fieldName: string;
327
+ oldValue: any;
328
+ newValue: any;
329
+ }>;
330
+ };
331
+ error?: string;
332
+ logs?: string[];
333
+ }>;
334
+ }
335
+ export declare const createFiveSDK: (config?: FiveSDKConfig) => FiveSDK;
336
+ export default FiveSDK;