@ghostspeak/sdk 2.0.5 → 2.0.7

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 (121) hide show
  1. package/README.md +152 -30
  2. package/dist/GhostSpeakClient-CWmGaM9Q.d.ts +1007 -0
  3. package/dist/StakingModule-C5rzuOWb.d.ts +2526 -0
  4. package/dist/{agent-M74TCRON.js → agent-5YLZ7DAC.js} +4 -4
  5. package/dist/{agent-M74TCRON.js.map → agent-5YLZ7DAC.js.map} +1 -1
  6. package/dist/batch-operations-45CQFEID.js +4 -0
  7. package/dist/batch-operations-45CQFEID.js.map +1 -0
  8. package/dist/browser.d.ts +45 -554
  9. package/dist/browser.js +15 -842
  10. package/dist/browser.js.map +1 -1
  11. package/dist/chunk-AL3HQN73.js +754 -0
  12. package/dist/chunk-AL3HQN73.js.map +1 -0
  13. package/dist/chunk-BF3IQ35I.js +284 -0
  14. package/dist/chunk-BF3IQ35I.js.map +1 -0
  15. package/dist/chunk-BQDGRTVP.js +168 -0
  16. package/dist/chunk-BQDGRTVP.js.map +1 -0
  17. package/dist/chunk-C5CDA3WX.js +7314 -0
  18. package/dist/chunk-C5CDA3WX.js.map +1 -0
  19. package/dist/chunk-E3FD2CNY.js +1869 -0
  20. package/dist/chunk-E3FD2CNY.js.map +1 -0
  21. package/dist/{chunk-V3SOFUAZ.js → chunk-G7S6B6WB.js} +327 -493
  22. package/dist/chunk-G7S6B6WB.js.map +1 -0
  23. package/dist/chunk-IHVDQ4YI.js +4231 -0
  24. package/dist/chunk-IHVDQ4YI.js.map +1 -0
  25. package/dist/chunk-JV2SWONF.js +98 -0
  26. package/dist/chunk-JV2SWONF.js.map +1 -0
  27. package/dist/chunk-KB6CKIUK.js +231 -0
  28. package/dist/chunk-KB6CKIUK.js.map +1 -0
  29. package/dist/chunk-RIZZPLLB.js +343 -0
  30. package/dist/chunk-RIZZPLLB.js.map +1 -0
  31. package/dist/chunk-S74EH3KD.js +7890 -0
  32. package/dist/chunk-S74EH3KD.js.map +1 -0
  33. package/dist/chunk-SFTSZ3LC.js +156 -0
  34. package/dist/chunk-SFTSZ3LC.js.map +1 -0
  35. package/dist/chunk-SKMJJ3Q6.js +125 -0
  36. package/dist/chunk-SKMJJ3Q6.js.map +1 -0
  37. package/dist/chunk-SZGFSCNU.js +3682 -0
  38. package/dist/chunk-SZGFSCNU.js.map +1 -0
  39. package/dist/chunk-TTB4OS2D.js +69 -0
  40. package/dist/chunk-TTB4OS2D.js.map +1 -0
  41. package/dist/chunk-UP2VWCW5.js +33 -0
  42. package/dist/{chunk-NSBPE2FW.js.map → chunk-UP2VWCW5.js.map} +1 -1
  43. package/dist/{chunk-UJUGGLMT.js → chunk-VQZQCHUT.js} +5 -5
  44. package/dist/{chunk-UJUGGLMT.js.map → chunk-VQZQCHUT.js.map} +1 -1
  45. package/dist/client.d.ts +6 -4
  46. package/dist/client.js +12 -10
  47. package/dist/createAgentAuthorization-ULG47ZJI.js +5 -0
  48. package/dist/createAgentAuthorization-ULG47ZJI.js.map +1 -0
  49. package/dist/credentials.d.ts +155 -0
  50. package/dist/credentials.js +4 -0
  51. package/dist/credentials.js.map +1 -0
  52. package/dist/crypto.js +2 -2
  53. package/dist/errors.js +1 -1
  54. package/dist/feature-flags-B1g0DCPe.d.ts +1181 -0
  55. package/dist/generated-EG5USUFG.js +9 -0
  56. package/dist/{generated-VNLHMR6Y.js.map → generated-EG5USUFG.js.map} +1 -1
  57. package/dist/{ghostspeak_wasm-SB2RPJ3D.js → ghostspeak_wasm-F227HOSM.js} +3 -3
  58. package/dist/{ghostspeak_wasm-SB2RPJ3D.js.map → ghostspeak_wasm-F227HOSM.js.map} +1 -1
  59. package/dist/index.d.ts +1210 -1506
  60. package/dist/index.js +601 -3532
  61. package/dist/index.js.map +1 -1
  62. package/dist/metafile-esm.json +1 -1
  63. package/dist/minimal/core-minimal.d.ts +2383 -1264
  64. package/dist/minimal/core-minimal.js +9 -9
  65. package/dist/minimal/core-minimal.js.map +1 -1
  66. package/dist/nacl-fast-W5BJ3KZ2.js +2229 -0
  67. package/dist/nacl-fast-W5BJ3KZ2.js.map +1 -0
  68. package/dist/pda-4KP7CURF.js +4 -0
  69. package/dist/pda-4KP7CURF.js.map +1 -0
  70. package/dist/pda-Ce7VYg4T.d.ts +25 -0
  71. package/dist/reputation-types-Yebf0Rm_.d.ts +1071 -0
  72. package/dist/revokeAuthorization-OK7E7OK3.js +5 -0
  73. package/dist/revokeAuthorization-OK7E7OK3.js.map +1 -0
  74. package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
  75. package/dist/types.js +1 -1
  76. package/dist/updateReputationWithAuth-Y4ONEVSP.js +5 -0
  77. package/dist/updateReputationWithAuth-Y4ONEVSP.js.map +1 -0
  78. package/dist/utils.d.ts +69 -203
  79. package/dist/utils.js +15 -153
  80. package/dist/utils.js.map +1 -1
  81. package/package.json +28 -31
  82. package/dist/.tsbuildinfo +0 -1
  83. package/dist/GhostSpeakClient-hsGuGg__.d.ts +0 -860
  84. package/dist/GovernanceModule-DQYYys-H.d.ts +0 -1766
  85. package/dist/chunk-ASQXX4IT.js +0 -572
  86. package/dist/chunk-ASQXX4IT.js.map +0 -1
  87. package/dist/chunk-COGZFWOT.js +0 -19657
  88. package/dist/chunk-COGZFWOT.js.map +0 -1
  89. package/dist/chunk-FKRN4PW5.js +0 -1667
  90. package/dist/chunk-FKRN4PW5.js.map +0 -1
  91. package/dist/chunk-GMHIUK2R.js +0 -7526
  92. package/dist/chunk-GMHIUK2R.js.map +0 -1
  93. package/dist/chunk-IAWBZYPE.js +0 -356
  94. package/dist/chunk-IAWBZYPE.js.map +0 -1
  95. package/dist/chunk-NSBPE2FW.js +0 -15
  96. package/dist/chunk-OWYHJG6H.js +0 -13311
  97. package/dist/chunk-OWYHJG6H.js.map +0 -1
  98. package/dist/chunk-RDDPOFR5.js +0 -3
  99. package/dist/chunk-RDDPOFR5.js.map +0 -1
  100. package/dist/chunk-RERCHKZP.js +0 -35
  101. package/dist/chunk-RERCHKZP.js.map +0 -1
  102. package/dist/chunk-TVVGXYCI.js +0 -2887
  103. package/dist/chunk-TVVGXYCI.js.map +0 -1
  104. package/dist/chunk-V3SOFUAZ.js.map +0 -1
  105. package/dist/chunk-ZGP5552B.js +0 -377
  106. package/dist/chunk-ZGP5552B.js.map +0 -1
  107. package/dist/chunk-ZWOYNHVK.js +0 -196
  108. package/dist/chunk-ZWOYNHVK.js.map +0 -1
  109. package/dist/dist/.tsbuildinfo +0 -1
  110. package/dist/elgamal-VZLWB3XK.js +0 -5
  111. package/dist/elgamal-VZLWB3XK.js.map +0 -1
  112. package/dist/feature-flags-V722ZuXO.d.ts +0 -3512
  113. package/dist/generated-VNLHMR6Y.js +0 -5
  114. package/dist/ipfs-types-BOt9ZNg4.d.ts +0 -592
  115. package/dist/multisigConfig-BzEhy6jy.d.ts +0 -58
  116. package/dist/pda-B_nS8SbD.d.ts +0 -114
  117. package/dist/pda-S4BFJVGE.js +0 -4
  118. package/dist/pda-S4BFJVGE.js.map +0 -1
  119. package/dist/system-addresses-BFNLEbFx.d.ts +0 -857
  120. package/dist/token-2022-rpc-RALH4RK7.js +0 -593
  121. package/dist/token-2022-rpc-RALH4RK7.js.map +0 -1
@@ -1,1667 +0,0 @@
1
- import { BaseModule, AgentModule, EscrowModule, ChannelModule, MarketplaceModule, GovernanceModule, Token2022Module } from './chunk-TVVGXYCI.js';
2
- import { deriveMultisigPda } from './chunk-ZGP5552B.js';
3
- import { getCreateMultisigInstruction, getInitializeGovernanceProposalInstructionAsync, getCastVoteInstruction, getExecuteProposalInstruction, GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS } from './chunk-COGZFWOT.js';
4
- import { sha256 } from '@noble/hashes/sha256';
5
- import bs58 from 'bs58';
6
-
7
- // src/modules/multisig/MultisigModule.ts
8
- var MultisigModule = class extends BaseModule {
9
- /**
10
- * Create a new multisig account
11
- */
12
- async createMultisig(params) {
13
- const defaultConfig = {
14
- max_signers: 10,
15
- default_timeout: 86400n,
16
- // 24 hours
17
- allow_emergency_override: false,
18
- emergency_threshold: { __option: "None" },
19
- auto_execute: true,
20
- signer_change_threshold: params.threshold,
21
- allowed_transaction_types: [],
22
- daily_limits: []
23
- };
24
- const config = { ...defaultConfig, ...params.config };
25
- const multisigPda = await deriveMultisigPda(this.programId, params.owner.address, params.multisigId);
26
- const instruction = getCreateMultisigInstruction({
27
- multisig: multisigPda,
28
- owner: params.owner,
29
- multisigId: params.multisigId,
30
- threshold: params.threshold,
31
- signers: params.signers,
32
- config
33
- });
34
- return this.execute("createMultisig", () => instruction, [params.owner]);
35
- }
36
- /**
37
- * Create a proposal (Uses Governance Protocol)
38
- *
39
- * Note: This creates a GovernanceProposal. The proposer must be a signer.
40
- */
41
- async createProposal(params) {
42
- const instruction = await getInitializeGovernanceProposalInstructionAsync({
43
- proposer: params.proposer,
44
- proposalId: params.proposalId,
45
- title: params.title,
46
- description: params.description,
47
- proposalType: params.proposalType,
48
- executionParams: params.executionParams
49
- }, { programAddress: this.programId });
50
- return this.execute("createProposal", () => instruction, [params.proposer]);
51
- }
52
- /**
53
- * Approve (Vote on) a proposal
54
- */
55
- async approveProposal(params) {
56
- const instruction = getCastVoteInstruction({
57
- proposal: params.proposalAddress,
58
- voter: params.voter,
59
- voterTokenAccount: params.voterTokenAccount,
60
- voteChoice: params.voteChoice ?? 0 /* For */,
61
- reasoning: params.reasoning ?? null
62
- });
63
- return this.execute("approveProposal", () => instruction, [params.voter]);
64
- }
65
- /**
66
- * Execute a proposal
67
- */
68
- async executeProposal(params) {
69
- const instruction = getExecuteProposalInstruction({
70
- proposal: params.proposalAddress,
71
- executor: params.executor,
72
- targetProgram: params.targetProgram
73
- });
74
- return this.execute("executeProposal", () => instruction, [params.executor]);
75
- }
76
- };
77
-
78
- // src/modules/credentials/CrossmintVCClient.ts
79
- var CROSSMINT_STAGING_URL = "https://staging.crossmint.com";
80
- var CROSSMINT_PROD_URL = "https://www.crossmint.com";
81
- var GHOSTSPEAK_CREDENTIAL_TYPES = {
82
- AGENT_IDENTITY: "GhostSpeakAgentIdentity",
83
- REPUTATION_SCORE: "GhostSpeakReputation",
84
- JOB_COMPLETION: "GhostSpeakJobCompletion"
85
- };
86
- var CrossmintVCClient = class {
87
- apiKey;
88
- baseUrl;
89
- chain;
90
- constructor(options) {
91
- this.apiKey = options.apiKey;
92
- this.baseUrl = options.environment === "production" ? CROSSMINT_PROD_URL : CROSSMINT_STAGING_URL;
93
- this.chain = options.chain || "base-sepolia";
94
- }
95
- // ===================================
96
- // Types & Templates
97
- // ===================================
98
- /**
99
- * Create the GhostSpeak Agent Identity credential type
100
- */
101
- async createAgentIdentityType() {
102
- const typeName = GHOSTSPEAK_CREDENTIAL_TYPES.AGENT_IDENTITY;
103
- const schema = {
104
- $schema: "https://json-schema.org/draft/2020-12/schema",
105
- title: "GhostSpeak Agent Identity",
106
- description: "Verified AI agent identity on the GhostSpeak Protocol",
107
- type: "object",
108
- properties: {
109
- credentialSubject: {
110
- type: "object",
111
- properties: {
112
- agentId: { type: "string" },
113
- owner: { type: "string" },
114
- capabilities: { type: "array", items: { type: "string" } },
115
- registeredAt: { type: "string" },
116
- reputationScore: { type: "number" },
117
- totalJobsCompleted: { type: "integer" },
118
- verified: { type: "boolean" },
119
- id: { type: "string" }
120
- // Auto-added by Crossmint
121
- },
122
- required: ["agentId", "owner", "capabilities", "registeredAt", "verified"],
123
- additionalProperties: false
124
- }
125
- }
126
- };
127
- return this.createCredentialType(typeName, schema);
128
- }
129
- /**
130
- * Create the GhostSpeak Reputation credential type
131
- */
132
- async createReputationType() {
133
- const typeName = GHOSTSPEAK_CREDENTIAL_TYPES.REPUTATION_SCORE;
134
- const schema = {
135
- $schema: "https://json-schema.org/draft/2020-12/schema",
136
- title: "GhostSpeak Reputation",
137
- description: "Verified reputation score for GhostSpeak users",
138
- type: "object",
139
- properties: {
140
- credentialSubject: {
141
- type: "object",
142
- properties: {
143
- userId: { type: "string" },
144
- walletAddress: { type: "string" },
145
- reputationScore: { type: "number" },
146
- totalTransactions: { type: "integer" },
147
- disputeRate: { type: "number" },
148
- memberSince: { type: "string" },
149
- id: { type: "string" }
150
- },
151
- required: ["userId", "walletAddress", "reputationScore", "memberSince"],
152
- additionalProperties: false
153
- }
154
- }
155
- };
156
- return this.createCredentialType(typeName, schema);
157
- }
158
- /**
159
- * Create the GhostSpeak Job Completion credential type
160
- */
161
- async createJobCompletionType() {
162
- const typeName = GHOSTSPEAK_CREDENTIAL_TYPES.JOB_COMPLETION;
163
- const schema = {
164
- $schema: "https://json-schema.org/draft/2020-12/schema",
165
- title: "GhostSpeak Job Completion",
166
- description: "Certificate of successful job completion on GhostSpeak",
167
- type: "object",
168
- properties: {
169
- credentialSubject: {
170
- type: "object",
171
- properties: {
172
- jobId: { type: "string" },
173
- agentId: { type: "string" },
174
- clientAddress: { type: "string" },
175
- completedAt: { type: "string" },
176
- amountPaid: { type: "string" },
177
- rating: { type: "integer" },
178
- review: { type: "string" },
179
- id: { type: "string" }
180
- },
181
- required: ["jobId", "agentId", "clientAddress", "completedAt", "amountPaid", "rating"],
182
- additionalProperties: false
183
- }
184
- }
185
- };
186
- return this.createCredentialType(typeName, schema);
187
- }
188
- /**
189
- * Initialize all GhostSpeak credential types
190
- */
191
- async initializeAllTypes() {
192
- const [agentIdentity, reputation, jobCompletion] = await Promise.all([
193
- this.createAgentIdentityType(),
194
- this.createReputationType(),
195
- this.createJobCompletionType()
196
- ]);
197
- return { agentIdentity, reputation, jobCompletion };
198
- }
199
- /**
200
- * Create all GhostSpeak credential templates
201
- */
202
- async createAllTemplates(types) {
203
- const [agentIdentityTemplate, reputationTemplate, jobCompletionTemplate] = await Promise.all([
204
- this.createTemplate(types.agentIdentity.id, {
205
- name: "GhostSpeak Agent Identity",
206
- description: "Verified AI agent identity on the GhostSpeak Protocol",
207
- imageUrl: "https://www.ghostspeak.io/assets/credential-agent.png"
208
- }),
209
- this.createTemplate(types.reputation.id, {
210
- name: "GhostSpeak Reputation",
211
- description: "Verified reputation score for GhostSpeak users",
212
- imageUrl: "https://www.ghostspeak.io/assets/credential-reputation.png"
213
- }),
214
- this.createTemplate(types.jobCompletion.id, {
215
- name: "GhostSpeak Job Completion Certificate",
216
- description: "Certificate of successful job completion on GhostSpeak",
217
- imageUrl: "https://www.ghostspeak.io/assets/credential-job.png"
218
- })
219
- ]);
220
- return { agentIdentityTemplate, reputationTemplate, jobCompletionTemplate };
221
- }
222
- /**
223
- * Issue an agent identity credential
224
- */
225
- async issueAgentCredential(templateId, recipientEmail, subject, expiresAt) {
226
- return this.issueCredential(templateId, recipientEmail, subject, expiresAt);
227
- }
228
- /**
229
- * Issue a reputation credential
230
- */
231
- async issueReputationCredential(templateId, recipientEmail, subject, expiresAt) {
232
- return this.issueCredential(templateId, recipientEmail, subject, expiresAt);
233
- }
234
- /**
235
- * Issue a job completion credential
236
- */
237
- async issueJobCompletionCredential(templateId, recipientEmail, subject, expiresAt) {
238
- return this.issueCredential(templateId, recipientEmail, subject, expiresAt);
239
- }
240
- /**
241
- * Create a credential type (JSON Schema)
242
- */
243
- async createCredentialType(typeName, schema) {
244
- const response = await fetch(
245
- `${this.baseUrl}/api/v1-alpha1/credentials/types/${typeName}`,
246
- {
247
- method: "PUT",
248
- headers: {
249
- "Content-Type": "application/json",
250
- "X-API-KEY": this.apiKey
251
- },
252
- body: JSON.stringify(schema)
253
- }
254
- );
255
- if (!response.ok) {
256
- const error = await response.json().catch(() => ({ message: response.statusText }));
257
- throw new Error(`Failed to create credential type: ${JSON.stringify(error)}`);
258
- }
259
- return response.json();
260
- }
261
- /**
262
- * Create a credential template
263
- */
264
- async createTemplate(typeId, metadata) {
265
- const response = await fetch(
266
- `${this.baseUrl}/api/v1-alpha1/credentials/templates/`,
267
- {
268
- method: "POST",
269
- headers: {
270
- "Content-Type": "application/json",
271
- "X-API-KEY": this.apiKey
272
- },
273
- body: JSON.stringify({
274
- credentials: {
275
- type: typeId,
276
- encryption: "none",
277
- storage: "crossmint"
278
- },
279
- metadata,
280
- chain: this.chain
281
- })
282
- }
283
- );
284
- if (!response.ok) {
285
- const text = await response.text();
286
- try {
287
- const error = JSON.parse(text);
288
- throw new Error(`Failed to create template: ${JSON.stringify(error)}`);
289
- } catch (e) {
290
- throw new Error(`Failed to create template (${response.status}): ${text}`);
291
- }
292
- }
293
- const action = await response.json();
294
- const result = await this.waitForAction(action.id);
295
- if (result.data && result.data.collection) {
296
- return result.data.collection;
297
- }
298
- return result.data || result;
299
- }
300
- /**
301
- * Poll an action until completion
302
- */
303
- async waitForAction(actionId) {
304
- let retries = 0;
305
- while (retries < 60) {
306
- await new Promise((resolve) => setTimeout(resolve, 2e3));
307
- const response = await fetch(
308
- `${this.baseUrl}/api/2022-06-09/actions/${actionId}`,
309
- {
310
- headers: {
311
- "X-API-KEY": this.apiKey
312
- }
313
- }
314
- );
315
- if (!response.ok) {
316
- throw new Error(`Failed to poll action: ${response.statusText}`);
317
- }
318
- const action = await response.json();
319
- if (action.status === "succeeded") {
320
- return action;
321
- }
322
- if (action.status === "failed") {
323
- throw new Error(`Action failed: ${JSON.stringify(action)}`);
324
- }
325
- retries++;
326
- }
327
- throw new Error("Action polling timed out");
328
- }
329
- // ===================================
330
- // Issuance
331
- // ===================================
332
- /**
333
- * Issue a credential using a template
334
- */
335
- async issueCredential(templateId, recipientEmail, subject, expiresAt) {
336
- const response = await fetch(
337
- `${this.baseUrl}/api/v1-alpha1/credentials/templates/${templateId}/vcs`,
338
- {
339
- method: "POST",
340
- headers: {
341
- "Content-Type": "application/json",
342
- "X-API-KEY": this.apiKey
343
- },
344
- body: JSON.stringify({
345
- recipient: `email:${recipientEmail}:${this.chain}`,
346
- credential: {
347
- subject,
348
- expiresAt: expiresAt || this.getDefaultExpiry()
349
- }
350
- })
351
- }
352
- );
353
- if (!response.ok) {
354
- const error = await response.json().catch(() => ({ message: response.statusText }));
355
- throw new Error(`Failed to issue credential: ${JSON.stringify(error)}`);
356
- }
357
- return response.json();
358
- }
359
- // ===================================
360
- // Verification & Retrieval
361
- // ===================================
362
- async getCredential(credentialId) {
363
- const response = await fetch(
364
- `${this.baseUrl}/api/v1-alpha1/credentials/${credentialId}`,
365
- {
366
- headers: {
367
- "X-API-KEY": this.apiKey
368
- }
369
- }
370
- );
371
- if (!response.ok) {
372
- const error = await response.json().catch(() => ({ message: response.statusText }));
373
- throw new Error(`Failed to get credential: ${JSON.stringify(error)}`);
374
- }
375
- return response.json();
376
- }
377
- async verifyCredential(credential) {
378
- const response = await fetch(
379
- `${this.baseUrl}/api/v1-alpha1/credentials/verification/verify`,
380
- {
381
- method: "POST",
382
- headers: {
383
- "Content-Type": "application/json",
384
- "X-API-KEY": this.apiKey
385
- },
386
- body: JSON.stringify({ credential })
387
- }
388
- );
389
- if (!response.ok) {
390
- const error = await response.json().catch(() => ({ message: response.statusText }));
391
- throw new Error(`Failed to verify credential: ${JSON.stringify(error)}`);
392
- }
393
- return response.json();
394
- }
395
- async revokeCredential(credentialId) {
396
- const response = await fetch(
397
- `${this.baseUrl}/api/v1-alpha1/credentials/${credentialId}`,
398
- {
399
- method: "DELETE",
400
- headers: {
401
- "X-API-KEY": this.apiKey
402
- }
403
- }
404
- );
405
- if (!response.ok) {
406
- const error = await response.json().catch(() => ({ message: response.statusText }));
407
- throw new Error(`Failed to revoke credential: ${JSON.stringify(error)}`);
408
- }
409
- return response.json();
410
- }
411
- getDefaultExpiry() {
412
- const date = /* @__PURE__ */ new Date();
413
- date.setFullYear(date.getFullYear() + 1);
414
- return date.toISOString().split("T")[0];
415
- }
416
- };
417
- var base58Encode = (data) => bs58.encode(data);
418
- var DEFAULT_PROGRAM_ID = "GHosT3wqDfNq9bKz8dNEQ1F5mLuN7bKdNYx3Z1111111";
419
- var CredentialKind = /* @__PURE__ */ ((CredentialKind2) => {
420
- CredentialKind2["AgentIdentity"] = "AgentIdentity";
421
- CredentialKind2["ReputationScore"] = "ReputationScore";
422
- CredentialKind2["JobCompletion"] = "JobCompletion";
423
- CredentialKind2["DelegatedSigner"] = "DelegatedSigner";
424
- CredentialKind2["Custom"] = "Custom";
425
- return CredentialKind2;
426
- })(CredentialKind || {});
427
- var CredentialStatus = /* @__PURE__ */ ((CredentialStatus2) => {
428
- CredentialStatus2["Pending"] = "Pending";
429
- CredentialStatus2["Active"] = "Active";
430
- CredentialStatus2["Revoked"] = "Revoked";
431
- CredentialStatus2["Expired"] = "Expired";
432
- return CredentialStatus2;
433
- })(CredentialStatus || {});
434
- var CredentialModule = class {
435
- programId;
436
- constructor(programId = DEFAULT_PROGRAM_ID) {
437
- this.programId = programId;
438
- }
439
- // --------------------------------------------------------------------------
440
- // Hashing
441
- // --------------------------------------------------------------------------
442
- hashSubjectData(subjectData) {
443
- const json = JSON.stringify(subjectData, Object.keys(subjectData).sort());
444
- return sha256(new TextEncoder().encode(json));
445
- }
446
- generateCredentialId(kind, subject) {
447
- const timestamp = Date.now();
448
- const input = `${kind}-${subject}-${timestamp}`;
449
- const hash = sha256(new TextEncoder().encode(input));
450
- const shortHash = base58Encode(hash.slice(0, 8));
451
- return `${kind.toLowerCase()}-${shortHash}`;
452
- }
453
- // --------------------------------------------------------------------------
454
- // Export W3C
455
- // --------------------------------------------------------------------------
456
- exportAsW3CCredential(credential, template, credentialType, subjectData, options) {
457
- const network = options?.network || "mainnet";
458
- const didPrefix = network === "mainnet" ? "did:sol:" : `did:sol:${network}:`;
459
- const statusId = `solana:${this.programId}:credential:${credential.credentialId}`;
460
- return {
461
- "@context": [
462
- "https://www.w3.org/ns/credentials/v2",
463
- "https://w3id.org/security/data-integrity/v2",
464
- "https://ghostspeak.io/ns/credentials/v1"
465
- ],
466
- type: ["VerifiableCredential", `GhostSpeak${credentialType.kind}Credential`],
467
- id: `urn:ghostspeak:${credential.credentialId}`,
468
- issuer: {
469
- id: `${didPrefix}${this.programId}`,
470
- name: "GhostSpeak Protocol"
471
- },
472
- validFrom: new Date(credential.issuedAt * 1e3).toISOString(),
473
- validUntil: credential.expiresAt ? new Date(credential.expiresAt * 1e3).toISOString() : void 0,
474
- credentialSubject: {
475
- id: `${didPrefix}${credential.subject}`,
476
- ...subjectData
477
- },
478
- credentialSchema: {
479
- id: credentialType.schemaUri,
480
- type: "JsonSchema"
481
- },
482
- credentialStatus: {
483
- id: statusId,
484
- type: "SolanaAccountStatus2025",
485
- statusPurpose: "revocation"
486
- },
487
- relatedResource: options?.includeRelatedResource ? [
488
- {
489
- id: credential.subjectDataUri,
490
- digestMultibase: `mEi${base58Encode(credential.subjectDataHash)}`
491
- }
492
- ] : void 0,
493
- proof: {
494
- type: "DataIntegrityProof",
495
- created: new Date(credential.issuedAt * 1e3).toISOString(),
496
- verificationMethod: `${didPrefix}${this.programId}#key-1`,
497
- cryptosuite: "eddsa-rdfc-2022",
498
- proofPurpose: "assertionMethod",
499
- proofValue: base58Encode(credential.signature)
500
- }
501
- };
502
- }
503
- // --------------------------------------------------------------------------
504
- // Helpers for Subject Building
505
- // --------------------------------------------------------------------------
506
- static buildAgentIdentitySubject(params) {
507
- return params;
508
- }
509
- };
510
-
511
- // src/modules/credentials/UnifiedCredentialService.ts
512
- var UnifiedCredentialService = class {
513
- constructor(config) {
514
- this.config = config;
515
- this.credentialModule = new CredentialModule(config.programId);
516
- if (config.crossmint) {
517
- this.crossmintClient = new CrossmintVCClient(config.crossmint);
518
- }
519
- }
520
- credentialModule;
521
- crossmintClient;
522
- /**
523
- * Issue an Agent Identity credential.
524
- * Note: logic simplified for SDK usage (mocking the on-chain part for now as per original implementation)
525
- */
526
- async issueAgentIdentityCredential(params) {
527
- const subjectData = CredentialModule.buildAgentIdentitySubject({
528
- agentId: params.agentId,
529
- owner: params.owner,
530
- name: params.name,
531
- capabilities: params.capabilities,
532
- serviceEndpoint: params.serviceEndpoint,
533
- frameworkOrigin: params.frameworkOrigin,
534
- x402Enabled: params.x402Enabled,
535
- registeredAt: params.registeredAt,
536
- verifiedAt: params.verifiedAt
537
- });
538
- const credentialId = this.credentialModule.generateCredentialId(
539
- "AgentIdentity" /* AgentIdentity */,
540
- params.owner
541
- );
542
- const subjectDataHash = this.credentialModule.hashSubjectData(subjectData);
543
- const credential = {
544
- template: "11111111111111111111111111111111",
545
- // Placeholder Address
546
- subject: params.owner,
547
- issuer: params.owner,
548
- // Self-issued for agent identity usually, or program
549
- credentialId,
550
- subjectDataHash,
551
- subjectDataUri: `ipfs://placeholder/${credentialId}`,
552
- status: "Active" /* Active */,
553
- signature: params.signature,
554
- // Use provided signature
555
- issuedAt: Math.floor(Date.now() / 1e3),
556
- expiresAt: void 0,
557
- revokedAt: void 0,
558
- crossmintCredentialId: void 0
559
- };
560
- const mockType = {
561
- authority: "11111111111111111111111111111111",
562
- name: "AgentIdentity",
563
- kind: "AgentIdentity" /* AgentIdentity */,
564
- schemaUri: "https://ghostspeak.io/schemas/agent-identity.json",
565
- description: "Verified AI agent identity on GhostSpeak Protocol",
566
- isActive: true,
567
- totalIssued: 1,
568
- createdAt: Math.floor(Date.now() / 1e3)
569
- };
570
- const mockTemplate = {
571
- credentialType: "11111111111111111111111111111111",
572
- name: "GhostSpeak Agent Identity",
573
- imageUri: "https://www.ghostspeak.io/assets/credential-agent.png",
574
- issuer: params.owner,
575
- isActive: true,
576
- totalIssued: 1,
577
- createdAt: Math.floor(Date.now() / 1e3),
578
- crossmintTemplateId: this.config.crossmintTemplates?.agentIdentity
579
- };
580
- const w3cCredential = this.credentialModule.exportAsW3CCredential(
581
- credential,
582
- mockTemplate,
583
- mockType,
584
- subjectData
585
- );
586
- const result = {
587
- solanaCredential: {
588
- credentialId
589
- },
590
- w3cCredential
591
- };
592
- if (params.syncToCrossmint && this.crossmintClient && params.recipientEmail) {
593
- if (!mockTemplate.crossmintTemplateId) {
594
- result.crossmintSync = { status: "failed", error: "No template ID configured" };
595
- } else {
596
- try {
597
- const crossmintResult = await this.crossmintClient.issueCredential(
598
- mockTemplate.crossmintTemplateId,
599
- params.recipientEmail,
600
- subjectData
601
- // enrichedSubject... logic handled here or in client?
602
- // In web it was in syncToCrossmint.
603
- );
604
- result.crossmintSync = {
605
- status: "synced",
606
- credentialId: crossmintResult.credentialId,
607
- chain: this.config.crossmint?.chain
608
- };
609
- } catch (error) {
610
- result.crossmintSync = {
611
- status: "failed",
612
- error: error instanceof Error ? error.message : "Unknown error"
613
- };
614
- }
615
- }
616
- }
617
- return result;
618
- }
619
- };
620
-
621
- // src/core/GhostSpeakClient.ts
622
- var GhostSpeakClient = class {
623
- config;
624
- constructor(config) {
625
- this.config = {
626
- programId: GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS,
627
- commitment: "confirmed",
628
- cluster: "devnet",
629
- rpcEndpoint: config?.rpcEndpoint ?? this.getDefaultRpcEndpoint(config?.cluster ?? "devnet"),
630
- ...config,
631
- rpc: config?.rpc ?? {}
632
- };
633
- }
634
- /**
635
- * Agent operations
636
- */
637
- agent() {
638
- return new AgentBuilder(this.config);
639
- }
640
- /**
641
- * Escrow operations
642
- */
643
- escrow() {
644
- return new EscrowBuilder(this.config);
645
- }
646
- /**
647
- * Channel operations
648
- */
649
- channel() {
650
- return new ChannelBuilder(this.config);
651
- }
652
- /**
653
- * Marketplace operations
654
- */
655
- marketplace() {
656
- return new MarketplaceBuilder(this.config);
657
- }
658
- /**
659
- * Governance operations
660
- */
661
- governance() {
662
- return new GovernanceBuilder(this.config);
663
- }
664
- /**
665
- * Multisig operations
666
- */
667
- multisig() {
668
- return new MultisigBuilder(this.config);
669
- }
670
- /**
671
- * Token-2022 operations
672
- */
673
- token2022() {
674
- return new Token2022Builder(this.config);
675
- }
676
- /**
677
- * Unified Credential operations (Solana + Crossmint)
678
- */
679
- credentials() {
680
- return new UnifiedCredentialService({
681
- programId: this.config.programId,
682
- crossmint: this.config.credentials?.crossmintApiKey ? {
683
- apiKey: this.config.credentials.crossmintApiKey,
684
- environment: this.config.credentials.crossmintEnvironment,
685
- chain: this.config.credentials.crossmintChain
686
- } : void 0,
687
- crossmintTemplates: this.config.credentials?.templates
688
- });
689
- }
690
- // H2A module has been removed - use A2A (Agent-to-Agent) instructions instead
691
- /**
692
- * Enable development mode features
693
- */
694
- enableDevMode() {
695
- console.log("\u{1F6E0}\uFE0F Development mode enabled");
696
- console.log(" - Transaction simulation before sending");
697
- console.log(" - Cost estimates for all operations");
698
- console.log(" - Enhanced error messages");
699
- this.config = {
700
- ...this.config
701
- // Add dev mode flags
702
- };
703
- return this;
704
- }
705
- /**
706
- * Configure network
707
- */
708
- useNetwork(cluster) {
709
- this.config.cluster = cluster;
710
- this.config.rpcEndpoint = this.getDefaultRpcEndpoint(cluster);
711
- return this;
712
- }
713
- /**
714
- * Configure custom RPC
715
- */
716
- useRpc(endpoint, wsEndpoint) {
717
- this.config.rpcEndpoint = endpoint;
718
- this.config.wsEndpoint = wsEndpoint;
719
- return this;
720
- }
721
- /**
722
- * Get default RPC endpoint for cluster
723
- */
724
- getDefaultRpcEndpoint(cluster) {
725
- switch (cluster) {
726
- case "mainnet-beta":
727
- return "https://api.mainnet-beta.solana.com";
728
- case "devnet":
729
- return "https://api.devnet.solana.com";
730
- case "testnet":
731
- return "https://api.testnet.solana.com";
732
- case "localnet":
733
- return "http://localhost:8899";
734
- default:
735
- return "https://api.devnet.solana.com";
736
- }
737
- }
738
- };
739
- var AgentBuilder = class {
740
- module;
741
- params = {};
742
- constructor(config) {
743
- this.module = new AgentModule(config);
744
- }
745
- create(params) {
746
- this.params = {
747
- ...this.params,
748
- agentType: 0,
749
- // Default type
750
- metadataUri: JSON.stringify(params),
751
- agentId: params.name.toLowerCase().replace(/\s+/g, "-"),
752
- name: params.name,
753
- description: params.description || ""
754
- };
755
- return this;
756
- }
757
- withDescription(description) {
758
- this.params.description = description;
759
- return this;
760
- }
761
- withType(agentType) {
762
- this.params.agentType = agentType;
763
- return this;
764
- }
765
- withIPFS() {
766
- this.params.forceIPFS = true;
767
- return this;
768
- }
769
- compressed() {
770
- this.params.compressed = true;
771
- return this;
772
- }
773
- debug() {
774
- this.module.debug();
775
- return this;
776
- }
777
- withSigner(signer) {
778
- this.params.signer = signer;
779
- return this;
780
- }
781
- validateParams() {
782
- if (!this.params.signer) {
783
- throw new Error("Agent builder requires a signer. Call with signer first.");
784
- }
785
- if (!this.params.metadataUri) {
786
- throw new Error("Agent builder requires metadata. Call create() first.");
787
- }
788
- if (!this.params.agentId) {
789
- throw new Error("Agent builder requires agent ID. Call create() first.");
790
- }
791
- this.params.agentType ??= 0;
792
- }
793
- async getCost() {
794
- this.validateParams();
795
- return this.module.getCost("registerAgent", () => ({
796
- programAddress: this.module.getProgramId(),
797
- accounts: [],
798
- data: new Uint8Array()
799
- }));
800
- }
801
- async simulate() {
802
- const instruction = () => ({
803
- // Placeholder for actual instruction generation
804
- programAddress: this.module.getProgramId(),
805
- accounts: [],
806
- data: new Uint8Array()
807
- });
808
- this.validateParams();
809
- return this.module.simulateInstruction("registerAgent", instruction, [this.params.signer]);
810
- }
811
- async explain() {
812
- this.validateParams();
813
- return this.module.explain("registerAgent", () => ({
814
- programAddress: this.module.getProgramId(),
815
- accounts: [],
816
- data: new Uint8Array()
817
- }));
818
- }
819
- async execute() {
820
- this.validateParams();
821
- if (this.params.compressed) {
822
- console.log("Creating compressed agent (5000x cheaper)...");
823
- }
824
- const signature = await this.module.register(this.params.signer, {
825
- agentType: this.params.agentType,
826
- name: this.params.name,
827
- description: this.params.description,
828
- metadataUri: this.params.metadataUri,
829
- agentId: this.params.agentId
830
- });
831
- const address = await this.deriveAgentAddress(this.params.agentId, this.params.signer);
832
- return { address, signature };
833
- }
834
- async deriveAgentAddress(agentId, signer) {
835
- const { deriveAgentPda } = await import('./pda-S4BFJVGE.js');
836
- const [address] = await deriveAgentPda({
837
- programAddress: this.module.getProgramId(),
838
- owner: signer.address,
839
- agentId
840
- });
841
- return address;
842
- }
843
- };
844
- var EscrowBuilder = class {
845
- module;
846
- params = {};
847
- constructor(config) {
848
- this.module = new EscrowModule(config);
849
- }
850
- between(buyer, seller) {
851
- this.params.buyer = buyer;
852
- this.params.seller = seller;
853
- return this;
854
- }
855
- amount(lamports) {
856
- this.params.amount = lamports;
857
- return this;
858
- }
859
- description(desc) {
860
- this.params.description = desc;
861
- return this;
862
- }
863
- withMilestones(milestones) {
864
- this.params.milestones = milestones;
865
- return this;
866
- }
867
- debug() {
868
- this.module.debug();
869
- return this;
870
- }
871
- withSigner(signer) {
872
- this.params.signer = signer;
873
- return this;
874
- }
875
- validateParams() {
876
- if (!this.params.buyer) {
877
- throw new Error("Escrow builder requires buyer address. Call between() first.");
878
- }
879
- if (!this.params.seller) {
880
- throw new Error("Escrow builder requires seller address. Call between() first.");
881
- }
882
- if (!this.params.amount) {
883
- throw new Error("Escrow builder requires amount. Call amount() first.");
884
- }
885
- if (!this.params.signer) {
886
- throw new Error("Escrow builder requires signer.");
887
- }
888
- }
889
- async getCost() {
890
- return this.module.getCost("createEscrow", () => ({
891
- // Placeholder for actual instruction
892
- programAddress: this.module.getProgramId(),
893
- accounts: [],
894
- data: new Uint8Array()
895
- }));
896
- }
897
- async explain() {
898
- return this.module.explain("createEscrow", () => ({
899
- // Placeholder for actual instruction
900
- programAddress: this.module.getProgramId(),
901
- accounts: [],
902
- data: new Uint8Array()
903
- }));
904
- }
905
- async execute() {
906
- this.validateParams();
907
- const signature = await this.module.create({
908
- signer: this.params.signer,
909
- amount: this.params.amount,
910
- buyer: this.params.buyer,
911
- seller: this.params.seller,
912
- description: this.params.description ?? "",
913
- milestones: this.params.milestones
914
- });
915
- const escrowId = `${Date.now()}_${Math.random().toString(36).substring(7)}`;
916
- const address = await this.deriveEscrowAddress(escrowId);
917
- return { address, signature };
918
- }
919
- async deriveEscrowAddress(escrowId) {
920
- const { deriveEscrowPDA } = await import('./pda-S4BFJVGE.js');
921
- const [address] = await deriveEscrowPDA({
922
- client: this.params.buyer,
923
- provider: this.params.seller,
924
- escrowId,
925
- programAddress: this.module.getProgramId()
926
- });
927
- return address;
928
- }
929
- };
930
- var ChannelBuilder = class {
931
- module;
932
- params = {};
933
- constructor(config) {
934
- this.module = new ChannelModule(config);
935
- }
936
- create(name) {
937
- this.params.name = name;
938
- this.params.channelType = 2 /* Public */;
939
- return this;
940
- }
941
- description(desc) {
942
- this.params.description = desc;
943
- return this;
944
- }
945
- private() {
946
- this.params.isPrivate = true;
947
- this.params.channelType = 3 /* Private */;
948
- return this;
949
- }
950
- maxMembers(max) {
951
- this.params.maxMembers = max;
952
- return this;
953
- }
954
- debug() {
955
- this.module.debug();
956
- return this;
957
- }
958
- withSigner(signer) {
959
- this.params.signer = signer;
960
- return this;
961
- }
962
- validateParams() {
963
- if (!this.params.name) {
964
- throw new Error("Channel builder requires name. Call create() first.");
965
- }
966
- if (!this.params.signer) {
967
- throw new Error("Channel builder requires signer.");
968
- }
969
- }
970
- async getCost() {
971
- return this.module.getCost("createChannel", () => ({
972
- // Placeholder for actual instruction
973
- programAddress: this.module.getProgramId(),
974
- accounts: [],
975
- data: new Uint8Array()
976
- }));
977
- }
978
- async explain() {
979
- return this.module.explain("createChannel", () => ({
980
- // Placeholder for actual instruction
981
- programAddress: this.module.getProgramId(),
982
- accounts: [],
983
- data: new Uint8Array()
984
- }));
985
- }
986
- async execute() {
987
- this.validateParams();
988
- const signature = await this.module.create({
989
- signer: this.params.signer,
990
- name: this.params.name,
991
- description: this.params.description ?? "",
992
- channelType: this.params.channelType ?? 2 /* Public */,
993
- isPrivate: this.params.isPrivate,
994
- maxMembers: this.params.maxMembers
995
- });
996
- const channelId = `${this.params.name}_${Date.now()}`;
997
- const address = await this.deriveChannelAddress(channelId);
998
- return { address, signature };
999
- }
1000
- async deriveChannelAddress(channelId) {
1001
- const { deriveChannelPda } = await import('./pda-S4BFJVGE.js');
1002
- const address = await deriveChannelPda(
1003
- this.module.getProgramId(),
1004
- channelId
1005
- );
1006
- return address;
1007
- }
1008
- };
1009
- var MarketplaceBuilder = class {
1010
- module;
1011
- params = {};
1012
- constructor(config) {
1013
- this.module = new MarketplaceModule(config);
1014
- }
1015
- /**
1016
- * Create a service listing
1017
- */
1018
- service() {
1019
- return new ServiceBuilder(this.module, this.params);
1020
- }
1021
- /**
1022
- * Create a job posting
1023
- */
1024
- job() {
1025
- return new JobBuilder(this.module, this.params);
1026
- }
1027
- /**
1028
- * Create an auction
1029
- */
1030
- auction() {
1031
- return new AuctionBuilder(this.module, this.params);
1032
- }
1033
- /**
1034
- * Get marketplace queries
1035
- */
1036
- query() {
1037
- return new MarketplaceQuery(this.module);
1038
- }
1039
- debug() {
1040
- this.module.debug();
1041
- return this;
1042
- }
1043
- withSigner(signer) {
1044
- this.params.signer = signer;
1045
- return this;
1046
- }
1047
- };
1048
- var ServiceBuilder = class {
1049
- constructor(module, builderParams) {
1050
- this.module = module;
1051
- this.builderParams = builderParams;
1052
- this.params.signer = builderParams.signer;
1053
- }
1054
- params = {};
1055
- create(params) {
1056
- this.params.title = params.title;
1057
- this.params.description = params.description;
1058
- this.params.agentAddress = params.agentAddress;
1059
- return this;
1060
- }
1061
- pricePerHour(price) {
1062
- this.params.pricePerHour = price;
1063
- return this;
1064
- }
1065
- category(cat) {
1066
- this.params.category = cat;
1067
- return this;
1068
- }
1069
- capabilities(caps) {
1070
- this.params.capabilities = caps;
1071
- return this;
1072
- }
1073
- validateParams() {
1074
- if (!this.params.signer) throw new Error("Signer required");
1075
- if (!this.params.title) throw new Error("Title required");
1076
- if (!this.params.description) throw new Error("Description required");
1077
- if (!this.params.agentAddress) throw new Error("Agent address required");
1078
- if (!this.params.pricePerHour) throw new Error("Price per hour required");
1079
- if (!this.params.category) throw new Error("Category required");
1080
- if (!this.params.capabilities) throw new Error("Capabilities required");
1081
- }
1082
- async execute() {
1083
- this.validateParams();
1084
- const signature = await this.module.createServiceListing({
1085
- signer: this.params.signer,
1086
- agentAddress: this.params.agentAddress,
1087
- title: this.params.title,
1088
- description: this.params.description,
1089
- pricePerHour: this.params.pricePerHour,
1090
- category: this.params.category,
1091
- capabilities: this.params.capabilities
1092
- });
1093
- const address = `service_${this.params.agentAddress}_${this.params.title}`;
1094
- return { address, signature };
1095
- }
1096
- withSigner(signer) {
1097
- this.params.signer = signer;
1098
- return this;
1099
- }
1100
- };
1101
- var JobBuilder = class {
1102
- constructor(module, builderParams) {
1103
- this.module = module;
1104
- this.builderParams = builderParams;
1105
- this.params.signer = builderParams.signer;
1106
- }
1107
- params = {};
1108
- create(params) {
1109
- this.params.title = params.title;
1110
- this.params.description = params.description;
1111
- return this;
1112
- }
1113
- budget(amount) {
1114
- this.params.budget = amount;
1115
- return this;
1116
- }
1117
- duration(hours) {
1118
- this.params.duration = hours;
1119
- return this;
1120
- }
1121
- skills(skillList) {
1122
- this.params.requiredSkills = skillList;
1123
- return this;
1124
- }
1125
- category(cat) {
1126
- this.params.category = cat;
1127
- return this;
1128
- }
1129
- validateParams() {
1130
- if (!this.params.signer) throw new Error("Signer required");
1131
- if (!this.params.title) throw new Error("Title required");
1132
- if (!this.params.description) throw new Error("Description required");
1133
- if (!this.params.budget) throw new Error("Budget required");
1134
- if (!this.params.duration) throw new Error("Duration required");
1135
- if (!this.params.requiredSkills) throw new Error("Required skills needed");
1136
- if (!this.params.category) throw new Error("Category required");
1137
- }
1138
- async execute() {
1139
- this.validateParams();
1140
- const signature = await this.module.createJobPosting({
1141
- signer: this.params.signer,
1142
- title: this.params.title,
1143
- description: this.params.description,
1144
- budget: this.params.budget,
1145
- duration: this.params.duration,
1146
- requiredSkills: this.params.requiredSkills,
1147
- category: this.params.category
1148
- });
1149
- const address = `job_${this.params.signer.address}_${this.params.title}`;
1150
- return { address, signature };
1151
- }
1152
- withSigner(signer) {
1153
- this.params.signer = signer;
1154
- return this;
1155
- }
1156
- };
1157
- var AuctionBuilder = class {
1158
- constructor(module, builderParams) {
1159
- this.module = module;
1160
- this.builderParams = builderParams;
1161
- this.params.signer = builderParams.signer;
1162
- }
1163
- params = {};
1164
- forService(serviceAddress) {
1165
- this.params.serviceListingAddress = serviceAddress;
1166
- return this;
1167
- }
1168
- startingPrice(price) {
1169
- this.params.startingPrice = price;
1170
- return this;
1171
- }
1172
- reservePrice(price) {
1173
- this.params.reservePrice = price;
1174
- return this;
1175
- }
1176
- duration(hours) {
1177
- this.params.duration = hours;
1178
- return this;
1179
- }
1180
- english() {
1181
- this.params.auctionType = "english";
1182
- return this;
1183
- }
1184
- dutch() {
1185
- this.params.auctionType = "dutch";
1186
- return this;
1187
- }
1188
- validateParams() {
1189
- if (!this.params.signer) throw new Error("Signer required");
1190
- if (!this.params.serviceListingAddress) throw new Error("Service listing address required");
1191
- if (!this.params.startingPrice) throw new Error("Starting price required");
1192
- if (!this.params.reservePrice) throw new Error("Reserve price required");
1193
- if (!this.params.duration) throw new Error("Duration required");
1194
- if (!this.params.auctionType) throw new Error("Auction type required");
1195
- }
1196
- async execute() {
1197
- this.validateParams();
1198
- const signature = await this.module.createServiceAuction({
1199
- signer: this.params.signer,
1200
- serviceListingAddress: this.params.serviceListingAddress,
1201
- startingPrice: this.params.startingPrice,
1202
- reservePrice: this.params.reservePrice,
1203
- duration: this.params.duration,
1204
- auctionType: this.params.auctionType
1205
- });
1206
- const address = `auction_${this.params.serviceListingAddress}`;
1207
- return { address, signature };
1208
- }
1209
- withSigner(signer) {
1210
- this.params.signer = signer;
1211
- return this;
1212
- }
1213
- };
1214
- var MarketplaceQuery = class {
1215
- constructor(module) {
1216
- this.module = module;
1217
- }
1218
- async serviceListings() {
1219
- return this.module.getAllServiceListings();
1220
- }
1221
- async serviceListingsByCategory(_category) {
1222
- const allListings = await this.module.getAllServiceListings();
1223
- return allListings.filter((_listing) => {
1224
- return allListings.length > 0;
1225
- });
1226
- }
1227
- async jobPostings() {
1228
- return this.module.getAllJobPostings();
1229
- }
1230
- async auctions() {
1231
- return this.module.getAllAuctions();
1232
- }
1233
- };
1234
- var GovernanceBuilder = class {
1235
- module;
1236
- params = {};
1237
- constructor(config) {
1238
- this.module = new GovernanceModule(config);
1239
- }
1240
- /**
1241
- * Create a governance proposal
1242
- */
1243
- proposal() {
1244
- return new ProposalBuilder(this.module, this.params);
1245
- }
1246
- /**
1247
- * Get governance queries
1248
- */
1249
- query() {
1250
- return new GovernanceQuery(this.module);
1251
- }
1252
- debug() {
1253
- this.module.debug();
1254
- return this;
1255
- }
1256
- withSigner(signer) {
1257
- this.params.signer = signer;
1258
- return this;
1259
- }
1260
- };
1261
- var ProposalBuilder = class {
1262
- constructor(module, builderParams) {
1263
- this.module = module;
1264
- this.builderParams = builderParams;
1265
- this.params.signer = builderParams.signer;
1266
- }
1267
- params = {};
1268
- create(params) {
1269
- this.params.title = params.title;
1270
- this.params.description = params.description;
1271
- return this;
1272
- }
1273
- type(proposalType) {
1274
- this.params.proposalType = proposalType;
1275
- return this;
1276
- }
1277
- votingDuration(hours) {
1278
- this.params.votingDuration = hours;
1279
- return this;
1280
- }
1281
- executionDelay(hours) {
1282
- this.params.executionDelay = hours;
1283
- return this;
1284
- }
1285
- validateParams() {
1286
- if (!this.params.signer) throw new Error("Signer required");
1287
- if (!this.params.title) throw new Error("Title required");
1288
- if (!this.params.description) throw new Error("Description required");
1289
- if (!this.params.proposalType) throw new Error("Proposal type required");
1290
- if (!this.params.votingDuration) throw new Error("Voting duration required");
1291
- }
1292
- async execute() {
1293
- this.validateParams();
1294
- const signature = await this.module.createProposal({
1295
- signer: this.params.signer,
1296
- title: this.params.title,
1297
- description: this.params.description,
1298
- proposalType: this.params.proposalType,
1299
- votingDuration: this.params.votingDuration,
1300
- executionDelay: this.params.executionDelay
1301
- });
1302
- const address = `proposal_${this.params.signer.address}_${this.params.title}`;
1303
- return { address, signature };
1304
- }
1305
- withSigner(signer) {
1306
- this.params.signer = signer;
1307
- return this;
1308
- }
1309
- };
1310
- var GovernanceQuery = class {
1311
- constructor(module) {
1312
- this.module = module;
1313
- }
1314
- async activeProposals() {
1315
- return this.module.getActiveProposals();
1316
- }
1317
- async proposalsByProposer(proposer) {
1318
- return this.module.getProposalsByProposer(proposer);
1319
- }
1320
- async proposalsByStatus(status) {
1321
- return this.module.getProposalsByStatus(status);
1322
- }
1323
- };
1324
- var MultisigBuilder = class {
1325
- module;
1326
- params = {};
1327
- constructor(config) {
1328
- this.module = new MultisigModule(config);
1329
- }
1330
- create() {
1331
- return new CreateMultisigBuilder(this.module, this.params);
1332
- }
1333
- proposal() {
1334
- return new MultisigProposalBuilder(this.module, this.params);
1335
- }
1336
- approve() {
1337
- return new MultisigApproveBuilder(this.module, this.params);
1338
- }
1339
- executeProposal() {
1340
- return new MultisigExecuteBuilder(this.module, this.params);
1341
- }
1342
- withSigner(signer) {
1343
- this.params.signer = signer;
1344
- return this;
1345
- }
1346
- debug() {
1347
- this.module.debug();
1348
- return this;
1349
- }
1350
- };
1351
- var CreateMultisigBuilder = class {
1352
- constructor(module, builderParams) {
1353
- this.module = module;
1354
- this.builderParams = builderParams;
1355
- this.params.signer = builderParams.signer;
1356
- }
1357
- params = {};
1358
- withId(id) {
1359
- this.params.multisigId = id;
1360
- return this;
1361
- }
1362
- threshold(t) {
1363
- this.params.threshold = t;
1364
- return this;
1365
- }
1366
- signers(s) {
1367
- this.params.signers = s;
1368
- return this;
1369
- }
1370
- async execute() {
1371
- if (!this.params.signer) throw new Error("Signer required");
1372
- if (!this.params.multisigId) throw new Error("Multisig ID required");
1373
- if (!this.params.threshold) throw new Error("Threshold required");
1374
- if (!this.params.signers) throw new Error("Signers required");
1375
- return {
1376
- signature: await this.module.createMultisig({
1377
- owner: this.params.signer,
1378
- multisigId: this.params.multisigId,
1379
- threshold: this.params.threshold,
1380
- signers: this.params.signers
1381
- })
1382
- };
1383
- }
1384
- withSigner(signer) {
1385
- this.params.signer = signer;
1386
- return this;
1387
- }
1388
- };
1389
- var MultisigProposalBuilder = class {
1390
- constructor(module, builderParams) {
1391
- this.module = module;
1392
- this.builderParams = builderParams;
1393
- this.params.signer = builderParams.signer;
1394
- }
1395
- params = {};
1396
- forMultisig(address) {
1397
- this.params.multisigAddress = address;
1398
- return this;
1399
- }
1400
- title(t) {
1401
- this.params.title = t;
1402
- return this;
1403
- }
1404
- description(d) {
1405
- this.params.description = d;
1406
- return this;
1407
- }
1408
- async execute() {
1409
- if (!this.params.signer) throw new Error("Signer required");
1410
- if (!this.params.title) throw new Error("Title required");
1411
- if (!this.params.description) throw new Error("Description required");
1412
- return {
1413
- signature: await this.module.createProposal({
1414
- multisigAddress: this.params.multisigAddress,
1415
- title: this.params.title,
1416
- description: this.params.description,
1417
- proposalType: 7 /* Custom */,
1418
- executionParams: {
1419
- instructions: [],
1420
- executionDelay: 0n,
1421
- executionConditions: [],
1422
- cancellable: true,
1423
- autoExecute: true,
1424
- executionAuthority: this.params.signer.address
1425
- },
1426
- proposalId: BigInt(Date.now()),
1427
- proposer: this.params.signer
1428
- })
1429
- };
1430
- }
1431
- withSigner(signer) {
1432
- this.params.signer = signer;
1433
- return this;
1434
- }
1435
- };
1436
- var MultisigApproveBuilder = class {
1437
- constructor(module, builderParams) {
1438
- this.module = module;
1439
- this.builderParams = builderParams;
1440
- this.params.signer = builderParams.signer;
1441
- }
1442
- params = {};
1443
- proposal(address) {
1444
- this.params.proposalAddress = address;
1445
- return this;
1446
- }
1447
- vote(choice) {
1448
- this.params.voteChoice = choice;
1449
- return this;
1450
- }
1451
- reason(text) {
1452
- this.params.reasoning = text;
1453
- return this;
1454
- }
1455
- tokenAccount(account) {
1456
- this.params.tokenAccount = account;
1457
- return this;
1458
- }
1459
- async execute() {
1460
- if (!this.params.signer) throw new Error("Signer required");
1461
- if (!this.params.proposalAddress) throw new Error("Proposal address required");
1462
- const voteChoice = this.params.voteChoice ?? 0 /* For */;
1463
- if (!this.params.tokenAccount) throw new Error("Voter token account required");
1464
- return {
1465
- signature: await this.module.approveProposal({
1466
- proposalAddress: this.params.proposalAddress,
1467
- voter: this.params.signer,
1468
- voterTokenAccount: this.params.tokenAccount,
1469
- voteChoice,
1470
- reasoning: this.params.reasoning
1471
- })
1472
- };
1473
- }
1474
- withSigner(signer) {
1475
- this.params.signer = signer;
1476
- return this;
1477
- }
1478
- };
1479
- var MultisigExecuteBuilder = class {
1480
- constructor(module, builderParams) {
1481
- this.module = module;
1482
- this.builderParams = builderParams;
1483
- this.params.signer = builderParams.signer;
1484
- }
1485
- params = {};
1486
- proposal(address) {
1487
- this.params.proposalAddress = address;
1488
- return this;
1489
- }
1490
- target(programId) {
1491
- this.params.targetProgram = programId;
1492
- return this;
1493
- }
1494
- async execute() {
1495
- if (!this.params.signer) throw new Error("Signer required");
1496
- if (!this.params.proposalAddress) throw new Error("Proposal address required");
1497
- if (!this.params.targetProgram) throw new Error("Target program required");
1498
- return {
1499
- signature: await this.module.executeProposal({
1500
- proposalAddress: this.params.proposalAddress,
1501
- executor: this.params.signer,
1502
- targetProgram: this.params.targetProgram
1503
- })
1504
- };
1505
- }
1506
- withSigner(signer) {
1507
- this.params.signer = signer;
1508
- return this;
1509
- }
1510
- };
1511
- var Token2022Builder = class {
1512
- module;
1513
- params = {};
1514
- constructor(config) {
1515
- this.module = new Token2022Module(config);
1516
- }
1517
- /**
1518
- * Create a basic mint
1519
- */
1520
- mint() {
1521
- return new MintBuilder(this.module, this.params);
1522
- }
1523
- /**
1524
- * Get Token2022 queries
1525
- */
1526
- query() {
1527
- return new Token2022Query(this.module);
1528
- }
1529
- debug() {
1530
- this.module.debug();
1531
- return this;
1532
- }
1533
- withSigner(signer) {
1534
- this.params.signer = signer;
1535
- return this;
1536
- }
1537
- };
1538
- var MintBuilder = class {
1539
- constructor(module, builderParams) {
1540
- this.module = module;
1541
- this.builderParams = builderParams;
1542
- this.params.signer = builderParams.signer;
1543
- }
1544
- params = {};
1545
- forAgent(agentAddress) {
1546
- this.params.agentAddress = agentAddress;
1547
- return this;
1548
- }
1549
- decimals(dec) {
1550
- this.params.decimals = dec;
1551
- return this;
1552
- }
1553
- freezeAuthority(authority) {
1554
- this.params.freezeAuthority = authority;
1555
- return this;
1556
- }
1557
- withTransferFees(basisPoints, maxFee) {
1558
- this.params.enableTransferFees = true;
1559
- this.params.transferFeeBasisPoints = basisPoints;
1560
- this.params.maxFee = maxFee;
1561
- return this;
1562
- }
1563
- withConfidentialTransfers(autoApprove = false) {
1564
- this.params.enableConfidentialTransfers = true;
1565
- this.params.autoApproveConfidential = autoApprove;
1566
- return this;
1567
- }
1568
- withInterestBearing(rate) {
1569
- this.params.enableInterestBearing = true;
1570
- this.params.interestRate = rate;
1571
- return this;
1572
- }
1573
- defaultAccountState(state) {
1574
- this.params.defaultAccountState = state;
1575
- return this;
1576
- }
1577
- validateParams() {
1578
- if (!this.params.signer) throw new Error("Signer required");
1579
- if (!this.params.agentAddress) throw new Error("Agent address required");
1580
- if (this.params.decimals === void 0) throw new Error("Decimals required");
1581
- if (this.params.enableTransferFees && (!this.params.transferFeeBasisPoints || !this.params.maxFee)) {
1582
- throw new Error("Transfer fee parameters required when fees enabled");
1583
- }
1584
- if (this.params.enableInterestBearing && this.params.interestRate === void 0) {
1585
- throw new Error("Interest rate required when interest bearing enabled");
1586
- }
1587
- }
1588
- async execute() {
1589
- this.validateParams();
1590
- let signature;
1591
- const hasMultipleFeatures = [
1592
- this.params.enableTransferFees,
1593
- this.params.enableConfidentialTransfers,
1594
- this.params.enableInterestBearing,
1595
- this.params.defaultAccountState
1596
- ].filter(Boolean).length > 1;
1597
- if (hasMultipleFeatures) {
1598
- signature = await this.module.createAdvancedMint({
1599
- signer: this.params.signer,
1600
- agentAddress: this.params.agentAddress,
1601
- decimals: this.params.decimals,
1602
- transferFeeBasisPoints: this.params.transferFeeBasisPoints ?? 0,
1603
- maxFee: this.params.maxFee ?? BigInt(0),
1604
- interestRate: this.params.interestRate ?? 0,
1605
- autoApproveConfidential: this.params.autoApproveConfidential,
1606
- defaultAccountState: this.params.defaultAccountState
1607
- });
1608
- } else if (this.params.enableTransferFees) {
1609
- signature = await this.module.createMintWithTransferFees({
1610
- signer: this.params.signer,
1611
- agentAddress: this.params.agentAddress,
1612
- decimals: this.params.decimals,
1613
- transferFeeBasisPoints: this.params.transferFeeBasisPoints,
1614
- maxFee: this.params.maxFee
1615
- });
1616
- } else if (this.params.enableConfidentialTransfers) {
1617
- signature = await this.module.createMintWithConfidentialTransfers({
1618
- signer: this.params.signer,
1619
- agentAddress: this.params.agentAddress,
1620
- decimals: this.params.decimals,
1621
- autoApproveNewAccounts: this.params.autoApproveConfidential
1622
- });
1623
- } else if (this.params.enableInterestBearing) {
1624
- signature = await this.module.createMintWithInterestBearing({
1625
- signer: this.params.signer,
1626
- agentAddress: this.params.agentAddress,
1627
- decimals: this.params.decimals,
1628
- interestRate: this.params.interestRate
1629
- });
1630
- } else {
1631
- signature = await this.module.createMint({
1632
- signer: this.params.signer,
1633
- agentAddress: this.params.agentAddress,
1634
- decimals: this.params.decimals,
1635
- freezeAuthority: this.params.freezeAuthority
1636
- });
1637
- }
1638
- const address = `mint_${this.params.agentAddress}_${this.params.decimals}`;
1639
- return { address, signature };
1640
- }
1641
- withSigner(signer) {
1642
- this.params.signer = signer;
1643
- return this;
1644
- }
1645
- };
1646
- var Token2022Query = class {
1647
- constructor(module) {
1648
- this.module = module;
1649
- }
1650
- async allMints() {
1651
- return this.module.getAllMints();
1652
- }
1653
- async mintsByAuthority(authority) {
1654
- return this.module.getMintsByAuthority(authority);
1655
- }
1656
- };
1657
- function sol(amount) {
1658
- return BigInt(Math.floor(amount * 1e9));
1659
- }
1660
- function lamportsToSol(lamports) {
1661
- return Number(lamports) / 1e9;
1662
- }
1663
- var GhostSpeakClient_default = GhostSpeakClient;
1664
-
1665
- export { CredentialKind, CredentialModule, CredentialStatus, CrossmintVCClient, GHOSTSPEAK_CREDENTIAL_TYPES, GhostSpeakClient, GhostSpeakClient_default, MultisigModule, UnifiedCredentialService, lamportsToSol, sol };
1666
- //# sourceMappingURL=chunk-FKRN4PW5.js.map
1667
- //# sourceMappingURL=chunk-FKRN4PW5.js.map