@ghostspeak/sdk 1.7.1 → 2.0.1

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,396 @@
1
+ import { Address } from '@solana/addresses';
2
+
3
+ /**
4
+ * Comprehensive Type System for GhostSpeak SDK
5
+ *
6
+ * All types are exported as individual named exports using ES2015 module syntax
7
+ * for better tree-shaking and compatibility with ESLint rules.
8
+ */
9
+
10
+ type Signature = string;
11
+ /**
12
+ * Transaction result with success/failure handling
13
+ */
14
+ type Result<T> = {
15
+ success: true;
16
+ data: T;
17
+ signature: Signature;
18
+ explorer: string;
19
+ } | {
20
+ success: false;
21
+ error: SDKError;
22
+ };
23
+ /**
24
+ * Generic transaction interface
25
+ */
26
+ interface Transaction<T> {
27
+ execute(): Promise<Result<T>>;
28
+ simulate(): Promise<SimulationResult>;
29
+ getCost(): Promise<bigint>;
30
+ debug(): this;
31
+ }
32
+ /**
33
+ * Simulation result
34
+ */
35
+ interface SimulationResult {
36
+ success: boolean;
37
+ logs: string[];
38
+ unitsConsumed?: bigint;
39
+ error?: string;
40
+ }
41
+ /**
42
+ * Agent entity
43
+ */
44
+ interface Agent {
45
+ address: Address;
46
+ type: AgentType;
47
+ owner: Address;
48
+ metadata: AgentMetadata;
49
+ reputation: Reputation;
50
+ isActive: boolean;
51
+ isVerified: boolean;
52
+ createdAt: Date;
53
+ }
54
+ /**
55
+ * Agent types
56
+ */
57
+ declare enum AgentType {
58
+ General = 0,
59
+ Specialized = 1,
60
+ Oracle = 2,
61
+ Validator = 3
62
+ }
63
+ /**
64
+ * Agent metadata
65
+ */
66
+ interface AgentMetadata {
67
+ name: string;
68
+ description: string;
69
+ capabilities: string[];
70
+ avatar?: string;
71
+ website?: string;
72
+ socialLinks?: Record<string, string>;
73
+ }
74
+ /**
75
+ * Reputation data
76
+ */
77
+ interface Reputation {
78
+ score: number;
79
+ jobsCompleted: number;
80
+ successRate: number;
81
+ totalEarnings: bigint;
82
+ ratings: Rating[];
83
+ }
84
+ /**
85
+ * Rating entry
86
+ */
87
+ interface Rating {
88
+ from: Address;
89
+ score: number;
90
+ comment?: string;
91
+ timestamp: Date;
92
+ }
93
+ /**
94
+ * Escrow entity
95
+ */
96
+ interface Escrow {
97
+ address: Address;
98
+ buyer: Address;
99
+ seller: Address;
100
+ amount: bigint;
101
+ status: EscrowStatus;
102
+ description: string;
103
+ milestones?: Milestone[];
104
+ createdAt: Date;
105
+ completedAt?: Date;
106
+ }
107
+ /**
108
+ * Escrow status
109
+ */
110
+ declare enum EscrowStatus {
111
+ Active = "active",
112
+ Completed = "completed",
113
+ Cancelled = "cancelled",
114
+ Disputed = "disputed",
115
+ Refunded = "refunded"
116
+ }
117
+ /**
118
+ * Milestone for escrow
119
+ */
120
+ interface Milestone {
121
+ amount: bigint;
122
+ description: string;
123
+ completed: boolean;
124
+ completedAt?: Date;
125
+ }
126
+ /**
127
+ * Channel entity
128
+ */
129
+ interface Channel {
130
+ address: Address;
131
+ name: string;
132
+ description: string;
133
+ type: ChannelType;
134
+ creator: Address;
135
+ members: Address[];
136
+ isPrivate: boolean;
137
+ maxMembers: number;
138
+ messageCount: number;
139
+ createdAt: Date;
140
+ }
141
+ /**
142
+ * Channel types
143
+ */
144
+ declare enum ChannelType {
145
+ Public = "public",
146
+ Private = "private",
147
+ Direct = "direct",
148
+ Group = "group"
149
+ }
150
+ /**
151
+ * Message entity
152
+ */
153
+ interface Message {
154
+ address: Address;
155
+ channel: Address;
156
+ sender: Address;
157
+ content: string;
158
+ type: MessageType;
159
+ attachments?: Attachment[];
160
+ reactions?: Reaction[];
161
+ replyTo?: Address;
162
+ editedAt?: Date;
163
+ timestamp: Date;
164
+ }
165
+ /**
166
+ * Message types
167
+ */
168
+ declare enum MessageType {
169
+ Text = "text",
170
+ Image = "image",
171
+ File = "file",
172
+ Code = "code",
173
+ System = "system"
174
+ }
175
+ /**
176
+ * Message attachment
177
+ */
178
+ interface Attachment {
179
+ uri: string;
180
+ mimeType: string;
181
+ size: number;
182
+ name: string;
183
+ }
184
+ /**
185
+ * Message reaction
186
+ */
187
+ interface Reaction {
188
+ emoji: string;
189
+ users: Address[];
190
+ }
191
+ /**
192
+ * Confidential balance
193
+ */
194
+ interface ConfidentialBalance {
195
+ encrypted: Uint8Array;
196
+ decrypted?: bigint;
197
+ }
198
+ /**
199
+ * Transfer with proof
200
+ */
201
+ interface ConfidentialTransfer {
202
+ from: Address;
203
+ to: Address;
204
+ encryptedAmount: Uint8Array;
205
+ proof: TransferProof;
206
+ }
207
+ /**
208
+ * Transfer proof data
209
+ */
210
+ interface TransferProof {
211
+ rangeProof: Uint8Array;
212
+ validityProof: Uint8Array;
213
+ equalityProof: Uint8Array;
214
+ }
215
+ /**
216
+ * SDK error with context
217
+ */
218
+ interface SDKError {
219
+ code: ErrorCode;
220
+ message: string;
221
+ context?: Record<string, unknown>;
222
+ solution?: string;
223
+ instruction?: string;
224
+ }
225
+ /**
226
+ * Error codes
227
+ */
228
+ declare enum ErrorCode {
229
+ NETWORK_ERROR = "NETWORK_ERROR",
230
+ RPC_ERROR = "RPC_ERROR",
231
+ TIMEOUT = "TIMEOUT",
232
+ INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
233
+ TRANSACTION_FAILED = "TRANSACTION_FAILED",
234
+ SIMULATION_FAILED = "SIMULATION_FAILED",
235
+ ACCOUNT_NOT_FOUND = "ACCOUNT_NOT_FOUND",
236
+ INVALID_ACCOUNT = "INVALID_ACCOUNT",
237
+ UNAUTHORIZED = "UNAUTHORIZED",
238
+ INVALID_INPUT = "INVALID_INPUT",
239
+ INVALID_ADDRESS = "INVALID_ADDRESS",
240
+ INVALID_AMOUNT = "INVALID_AMOUNT",
241
+ PROGRAM_ERROR = "PROGRAM_ERROR",
242
+ INSTRUCTION_ERROR = "INSTRUCTION_ERROR",
243
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
244
+ }
245
+ /**
246
+ * Agent creation parameters
247
+ */
248
+ interface AgentCreationParams {
249
+ name: string;
250
+ capabilities: string[];
251
+ type?: AgentType;
252
+ metadata?: Partial<AgentMetadata>;
253
+ compressed?: boolean;
254
+ }
255
+ /**
256
+ * Escrow creation parameters
257
+ */
258
+ interface EscrowCreationParams {
259
+ buyer: Address;
260
+ seller: Address;
261
+ amount: bigint;
262
+ description: string;
263
+ milestones?: Milestone[];
264
+ }
265
+ /**
266
+ * Channel creation parameters
267
+ */
268
+ interface ChannelCreationParams {
269
+ name: string;
270
+ description: string;
271
+ type?: ChannelType;
272
+ isPrivate?: boolean;
273
+ maxMembers?: number;
274
+ }
275
+ /**
276
+ * Pagination options
277
+ */
278
+ interface PaginationOptions {
279
+ limit?: number;
280
+ offset?: number;
281
+ cursor?: string;
282
+ }
283
+ /**
284
+ * Filter options
285
+ */
286
+ interface FilterOptions<T> {
287
+ where?: Partial<T>;
288
+ orderBy?: keyof T;
289
+ orderDirection?: 'asc' | 'desc';
290
+ }
291
+ /**
292
+ * Query result with pagination
293
+ */
294
+ interface QueryResult<T> {
295
+ items: T[];
296
+ total: number;
297
+ hasMore: boolean;
298
+ nextCursor?: string;
299
+ }
300
+ /**
301
+ * Base event interface
302
+ */
303
+ interface Event<T = unknown> {
304
+ type: string;
305
+ timestamp: Date;
306
+ data: T;
307
+ }
308
+ /**
309
+ * Agent events
310
+ */
311
+ type AgentEvent = Event<{
312
+ agent: Agent;
313
+ }> & {
314
+ type: 'agent.created';
315
+ } | Event<{
316
+ agent: Agent;
317
+ changes: Partial<Agent>;
318
+ }> & {
319
+ type: 'agent.updated';
320
+ } | Event<{
321
+ agent: Agent;
322
+ }> & {
323
+ type: 'agent.verified';
324
+ };
325
+ /**
326
+ * Escrow events
327
+ */
328
+ type EscrowEvent = Event<{
329
+ escrow: Escrow;
330
+ }> & {
331
+ type: 'escrow.created';
332
+ } | Event<{
333
+ escrow: Escrow;
334
+ }> & {
335
+ type: 'escrow.completed';
336
+ } | Event<{
337
+ escrow: Escrow;
338
+ reason: string;
339
+ }> & {
340
+ type: 'escrow.disputed';
341
+ };
342
+ /**
343
+ * Channel events
344
+ */
345
+ type ChannelEvent = Event<{
346
+ channel: Channel;
347
+ message: Message;
348
+ }> & {
349
+ type: 'channel.message';
350
+ } | Event<{
351
+ channel: Channel;
352
+ member: Address;
353
+ }> & {
354
+ type: 'channel.member.joined';
355
+ } | Event<{
356
+ channel: Channel;
357
+ member: Address;
358
+ }> & {
359
+ type: 'channel.member.left';
360
+ };
361
+ /**
362
+ * Check if result is successful
363
+ */
364
+ declare function isSuccess<T>(result: Result<T>): result is Result<T> & {
365
+ success: true;
366
+ };
367
+ /**
368
+ * Check if result is error
369
+ */
370
+ declare function isError<T>(result: Result<T>): result is Result<T> & {
371
+ success: false;
372
+ };
373
+ /**
374
+ * Extract data from successful result
375
+ */
376
+ declare function unwrap<T>(result: Result<T>): T;
377
+ /**
378
+ * Make all properties optional recursively
379
+ */
380
+ type DeepPartial<T> = {
381
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
382
+ };
383
+ /**
384
+ * Extract addresses from entities
385
+ */
386
+ type AddressOf<T> = T extends {
387
+ address: Address;
388
+ } ? T['address'] : never;
389
+ /**
390
+ * Entity with address
391
+ */
392
+ type WithAddress<T> = T & {
393
+ address: Address;
394
+ };
395
+
396
+ export { type AddressOf, type Agent, type AgentCreationParams, type AgentEvent, type AgentMetadata, AgentType, type Attachment, type Channel, type ChannelCreationParams, type ChannelEvent, ChannelType, type ConfidentialBalance, type ConfidentialTransfer, type DeepPartial, ErrorCode, type Escrow, type EscrowCreationParams, type EscrowEvent, EscrowStatus, type Event, type FilterOptions, type Message, MessageType, type Milestone, type PaginationOptions, type QueryResult, type Rating, type Reaction, type Reputation, type Result, type SDKError, type SimulationResult, type Transaction, type TransferProof, type WithAddress, isError, isSuccess, unwrap };
@@ -0,0 +1,19 @@
1
+ export { E as ErrorContext, G as GhostSpeakSDKError, T as TokenProgram, n as accounts, m as confidential, j as createErrorContext, d as deriveAgentPda, b as deriveAssociatedTokenAddress, a as deriveListingPda, c as detectTokenProgram, h as enhanceTransactionError, q as features, f as findProgramDerivedAddress, e as formatTokenAmount, g as getTokenProgramType, o as governance, k as ipfs, i as isToken2022Mint, p as parseTokenAmount, l as privacy, t as token2022, w as withEnhancedErrors } from './feature-flags-3POmoO_Z.js';
2
+ import '@solana/kit';
3
+ import '@solana/addresses';
4
+ import './ipfs-types-KJcvy9Qk.js';
5
+ import '@solana/rpc';
6
+
7
+ /**
8
+ * Common utility functions for GhostSpeak SDK
9
+ */
10
+ /**
11
+ * Convert SOL to lamports
12
+ */
13
+ declare function sol(amount: number): bigint;
14
+ /**
15
+ * Convert lamports to SOL
16
+ */
17
+ declare function lamportsToSol(lamports: bigint): number;
18
+
19
+ export { lamportsToSol, sol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostspeak/sdk",
3
- "version": "1.7.1",
3
+ "version": "2.0.1",
4
4
  "description": "TypeScript SDK for GhostSpeak AI Agent Commerce Protocol - Production Ready Beta",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,30 @@
10
10
  ".": {
11
11
  "import": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts"
13
+ },
14
+ "./client": {
15
+ "import": "./dist/client.js",
16
+ "types": "./dist/client.d.ts"
17
+ },
18
+ "./types": {
19
+ "import": "./dist/types.js",
20
+ "types": "./dist/types.d.ts"
21
+ },
22
+ "./errors": {
23
+ "import": "./dist/errors.js",
24
+ "types": "./dist/errors.d.ts"
25
+ },
26
+ "./crypto": {
27
+ "import": "./dist/crypto.js",
28
+ "types": "./dist/crypto.d.ts"
29
+ },
30
+ "./utils": {
31
+ "import": "./dist/utils.js",
32
+ "types": "./dist/utils.d.ts"
33
+ },
34
+ "./minimal": {
35
+ "import": "./dist/minimal/core-minimal.js",
36
+ "types": "./dist/minimal/core-minimal.d.ts"
13
37
  }
14
38
  },
15
39
  "files": [
@@ -26,41 +50,17 @@
26
50
  "test:unit": "vitest run tests/unit",
27
51
  "test:integration": "vitest run tests/integration",
28
52
  "test:e2e": "vitest run tests/e2e",
29
- "test:benchmarks": "vitest run tests/benchmarks",
30
53
  "test:watch": "vitest watch",
31
- "test:coverage": "COVERAGE=true vitest run --coverage",
32
- "test:coverage:quick": "COVERAGE=true QUICK_TEST=true vitest run --coverage",
33
- "test:ui": "vitest --ui",
34
- "test:quick": "QUICK_TEST=true vitest run",
35
- "test:quick:watch": "QUICK_TEST=true vitest watch",
36
- "test:full": "FULL_TEST_RUN=1 vitest run --reporter=verbose",
37
- "test:full:coverage": "FULL_TEST_RUN=1 COVERAGE=true vitest run --coverage",
38
- "test:shard": "vitest run --shard",
39
- "test:crypto": "vitest run tests/**/crypto/**/*.test.ts tests/**/elgamal-complete.test.ts tests/**/bulletproofs.test.ts",
40
- "test:utils": "vitest run tests/unit/utils --exclude='**/wasm-crypto-bridge.test.ts'",
41
- "test:smart": "bun scripts/test-runner.ts",
42
- "test:smart:quick": "bun scripts/test-runner.ts --quick",
43
- "test:smart:all": "bun scripts/test-runner.ts --all",
44
- "test:smart:coverage": "bun scripts/test-runner.ts --coverage",
45
- "test:real": "RUN_REAL_TESTS=1 vitest run tests/integration/*-real-integration.test.ts",
54
+ "test:coverage": "vitest run --coverage",
55
+ "test:real": "RUN_REAL_TESTS=1 vitest run tests/integration/*real-integration.test.ts",
46
56
  "test:real:token": "RUN_REAL_TESTS=1 vitest run tests/integration/token-2022-real-integration.test.ts",
47
57
  "test:real:confidential": "RUN_REAL_TESTS=1 vitest run tests/integration/confidential-transfer-real-integration.test.ts",
48
- "benchmark": "bun run test:benchmarks",
49
- "benchmark:crypto": "vitest run tests/benchmarks/crypto-performance.test.ts",
50
58
  "wasm:build": "cd src/wasm/crypto-wasm && wasm-pack build --target web --out-dir ../../../dist/wasm --scope ghostspeak",
51
- "wasm:build:dev": "cd src/wasm/crypto-wasm && wasm-pack build --dev --target web --out-dir ../../../dist/wasm --scope ghostspeak",
52
59
  "wasm:clean": "rm -rf dist/wasm src/wasm/crypto-wasm/pkg",
53
60
  "wasm:install": "cargo install wasm-pack",
54
61
  "lint": "eslint src --no-error-on-unmatched-pattern --ignore-pattern 'src/generated/**' && eslint src/generated --no-error-on-unmatched-pattern --config .eslintrc.generated.js",
55
62
  "lint:fix": "eslint src --fix --ignore-pattern 'src/generated/**' && eslint src/generated --fix --config .eslintrc.generated.js",
56
- "generate": "tsx scripts/generate.ts && tsx scripts/post-process-lint.ts && tsx scripts/fix-circular-deps.ts",
57
- "clean": "rm -rf dist coverage && bun run wasm:clean",
58
- "fix-imports": "tsx scripts/fix-imports.ts",
59
- "fix-coded-errors": "tsx scripts/fix-coded-errors.ts",
60
- "fix-instruction-types": "tsx scripts/fix-instruction-types.ts",
61
- "fix-generated-types": "tsx scripts/fix-generated-types.ts",
62
- "fix-all-types": "tsx scripts/fix-all-types.ts",
63
- "fix-final-types": "tsx scripts/fix-final-types.ts"
63
+ "clean": "rm -rf dist coverage && bun run wasm:clean"
64
64
  },
65
65
  "keywords": [
66
66
  "solana",
@@ -111,6 +111,7 @@
111
111
  "@solana/rpc-transport": "^2.0.0-experimental.9741939",
112
112
  "@solana/rpc-types": "^2.3.0",
113
113
  "@solana/signers": "^2.3.0",
114
+ "@solana/spl-account-compression": "^0.4.1",
114
115
  "@solana/spl-token": "^0.4.13",
115
116
  "@solana/sysvars": "^2.3.0",
116
117
  "@solana/transactions": "^2.3.0",
@@ -127,6 +128,7 @@
127
128
  "@vitest/coverage-v8": "^3.2.4",
128
129
  "@vitest/ui": "^3.2.4",
129
130
  "eslint": "^9.31.0",
131
+ "glob": "^10.4.5",
130
132
  "tsup": "^8.0.0",
131
133
  "tsx": "^4.20.3",
132
134
  "typescript": "^5.3.0",