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