@compose-market/sdk 0.8.19 → 0.8.21

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 (41) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/blockchain/index.d.ts +2033 -0
  3. package/dist/blockchain/index.d.ts.map +1 -0
  4. package/dist/blockchain/index.js +935 -0
  5. package/dist/blockchain/index.js.map +1 -0
  6. package/dist/chains/index.d.ts +2 -0
  7. package/dist/chains/index.d.ts.map +1 -1
  8. package/dist/chains/index.js.map +1 -1
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/resources/svm.d.ts +13 -0
  14. package/dist/resources/svm.d.ts.map +1 -0
  15. package/dist/resources/svm.js +35 -0
  16. package/dist/resources/svm.js.map +1 -0
  17. package/dist/types/index.d.ts +11 -0
  18. package/dist/types/index.d.ts.map +1 -1
  19. package/dist/version.d.ts +1 -1
  20. package/dist/version.js +1 -1
  21. package/generated/channels/esm/lib/config.d.ts +3 -3
  22. package/generated/channels/esm/lib/config.js +3 -3
  23. package/generated/channels/package.json +1 -1
  24. package/generated/channels/src/lib/config.ts +3 -3
  25. package/generated/inference/esm/lib/config.d.ts +3 -3
  26. package/generated/inference/esm/lib/config.js +3 -3
  27. package/generated/inference/package.json +1 -1
  28. package/generated/inference/src/lib/config.ts +3 -3
  29. package/generated/manowar/esm/lib/config.d.ts +3 -3
  30. package/generated/manowar/esm/lib/config.js +3 -3
  31. package/generated/manowar/package.json +1 -1
  32. package/generated/manowar/src/lib/config.ts +3 -3
  33. package/generated/memory/esm/lib/config.d.ts +3 -3
  34. package/generated/memory/esm/lib/config.js +3 -3
  35. package/generated/memory/package.json +1 -1
  36. package/generated/memory/src/lib/config.ts +3 -3
  37. package/generated/x402/esm/lib/config.d.ts +3 -3
  38. package/generated/x402/esm/lib/config.js +3 -3
  39. package/generated/x402/package.json +1 -1
  40. package/generated/x402/src/lib/config.ts +3 -3
  41. package/package.json +12 -6
@@ -0,0 +1,935 @@
1
+ import { AccountRole, address, getAddressDecoder, getAddressEncoder, getProgramDerivedAddress, } from "@solana/kit";
2
+ import { encodeFunctionData, encodePacked, keccak256 } from "viem";
3
+ export const SYSTEM_PROGRAM_ADDRESS = address("11111111111111111111111111111111");
4
+ export const TOKEN_PROGRAM_ADDRESS = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
5
+ export const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = address("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
6
+ // ---------------------------------------------------------------------------
7
+ // EVM ABIs
8
+ // ---------------------------------------------------------------------------
9
+ export const AgentFactoryABI = [
10
+ {
11
+ name: "getAgentData",
12
+ type: "function",
13
+ stateMutability: "view",
14
+ inputs: [{ name: "agentId", type: "uint256" }],
15
+ outputs: [{
16
+ name: "data",
17
+ type: "tuple",
18
+ components: [
19
+ { name: "dnaHash", type: "bytes32" },
20
+ { name: "licenses", type: "uint256" },
21
+ { name: "licensesMinted", type: "uint256" },
22
+ { name: "licensePrice", type: "uint256" },
23
+ { name: "creatorFee", type: "uint256" },
24
+ { name: "creator", type: "address" },
25
+ { name: "cloneable", type: "bool" },
26
+ { name: "isClone", type: "bool" },
27
+ { name: "parentAgentId", type: "uint256" },
28
+ { name: "agentCardUri", type: "string" },
29
+ ],
30
+ }],
31
+ },
32
+ { name: "totalAgents", type: "function", stateMutability: "view", inputs: [], outputs: [{ name: "total", type: "uint256" }] },
33
+ { name: "hasAvailableLicenses", type: "function", stateMutability: "view", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ name: "available", type: "bool" }] },
34
+ { name: "getDnaHash", type: "function", stateMutability: "view", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ name: "dnaHash", type: "bytes32" }] },
35
+ { name: "ownerOf", type: "function", stateMutability: "view", inputs: [{ name: "tokenId", type: "uint256" }], outputs: [{ name: "owner", type: "address" }] },
36
+ { name: "tokenURI", type: "function", stateMutability: "view", inputs: [{ name: "tokenId", type: "uint256" }], outputs: [{ name: "uri", type: "string" }] },
37
+ {
38
+ name: "isLicensedTo",
39
+ type: "function",
40
+ stateMutability: "view",
41
+ inputs: [
42
+ { name: "agentId", type: "uint256" },
43
+ { name: "workflowContract", type: "address" },
44
+ { name: "workflowId", type: "uint256" },
45
+ ],
46
+ outputs: [{ name: "licensed", type: "bool" }],
47
+ },
48
+ {
49
+ name: "getLicenseRecords",
50
+ type: "function",
51
+ stateMutability: "view",
52
+ inputs: [{ name: "agentId", type: "uint256" }],
53
+ outputs: [{
54
+ name: "records",
55
+ type: "tuple[]",
56
+ components: [
57
+ { name: "workflowContract", type: "address" },
58
+ { name: "workflowId", type: "uint256" },
59
+ { name: "licensedAt", type: "uint256" },
60
+ ],
61
+ }],
62
+ },
63
+ { name: "agentExists", type: "function", stateMutability: "view", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ name: "exists", type: "bool" }] },
64
+ {
65
+ name: "mintAgent",
66
+ type: "function",
67
+ stateMutability: "nonpayable",
68
+ inputs: [
69
+ { name: "dnaHash", type: "bytes32" },
70
+ { name: "licenses", type: "uint256" },
71
+ { name: "licensePrice", type: "uint256" },
72
+ { name: "creatorFee", type: "uint256" },
73
+ { name: "cloneable", type: "bool" },
74
+ { name: "agentCardUri", type: "string" },
75
+ ],
76
+ outputs: [{ name: "agentId", type: "uint256" }],
77
+ },
78
+ {
79
+ name: "updatePrice",
80
+ type: "function",
81
+ stateMutability: "nonpayable",
82
+ inputs: [
83
+ { name: "agentId", type: "uint256" },
84
+ { name: "newPrice", type: "uint256" },
85
+ ],
86
+ outputs: [],
87
+ },
88
+ ];
89
+ export const WorkflowABI = [
90
+ {
91
+ name: "getWorkflowData",
92
+ type: "function",
93
+ stateMutability: "view",
94
+ inputs: [{ name: "workflowId", type: "uint256" }],
95
+ outputs: [{
96
+ name: "data",
97
+ type: "tuple",
98
+ components: [
99
+ { name: "title", type: "string" },
100
+ { name: "description", type: "string" },
101
+ { name: "banner", type: "string" },
102
+ { name: "workflowCardUri", type: "string" },
103
+ { name: "totalPrice", type: "uint256" },
104
+ { name: "units", type: "uint256" },
105
+ { name: "unitsMinted", type: "uint256" },
106
+ { name: "creator", type: "address" },
107
+ { name: "leaseEnabled", type: "bool" },
108
+ { name: "leaseDuration", type: "uint256" },
109
+ { name: "leasePercent", type: "uint8" },
110
+ { name: "hasCoordinator", type: "bool" },
111
+ { name: "coordinatorModel", type: "string" },
112
+ { name: "hasActiveRfa", type: "bool" },
113
+ { name: "rfaId", type: "uint256" },
114
+ ],
115
+ }],
116
+ },
117
+ { name: "totalWorkflows", type: "function", stateMutability: "view", inputs: [], outputs: [{ name: "total", type: "uint256" }] },
118
+ { name: "tokenURI", type: "function", stateMutability: "view", inputs: [{ name: "tokenId", type: "uint256" }], outputs: [{ name: "uri", type: "string" }] },
119
+ { name: "getAgents", type: "function", stateMutability: "view", inputs: [{ name: "workflowId", type: "uint256" }], outputs: [{ name: "agentIds", type: "uint256[]" }] },
120
+ { name: "getAgentCount", type: "function", stateMutability: "view", inputs: [{ name: "workflowId", type: "uint256" }], outputs: [{ name: "count", type: "uint256" }] },
121
+ { name: "isComplete", type: "function", stateMutability: "view", inputs: [{ name: "workflowId", type: "uint256" }], outputs: [{ name: "complete", type: "bool" }] },
122
+ { name: "getCompleteWorkflows", type: "function", stateMutability: "view", inputs: [], outputs: [{ name: "workflowIds", type: "uint256[]" }] },
123
+ { name: "getWorkflowsWithRFA", type: "function", stateMutability: "view", inputs: [], outputs: [{ name: "workflowIds", type: "uint256[]" }] },
124
+ { name: "getWorkflowsByCreator", type: "function", stateMutability: "view", inputs: [{ name: "creator", type: "address" }], outputs: [{ name: "workflowIds", type: "uint256[]" }] },
125
+ { name: "calculateTotalPrice", type: "function", stateMutability: "view", inputs: [{ name: "workflowId", type: "uint256" }], outputs: [{ name: "total", type: "uint256" }] },
126
+ {
127
+ name: "mintWorkflow",
128
+ type: "function",
129
+ stateMutability: "nonpayable",
130
+ inputs: [
131
+ {
132
+ name: "params",
133
+ type: "tuple",
134
+ components: [
135
+ { name: "title", type: "string" },
136
+ { name: "description", type: "string" },
137
+ { name: "banner", type: "string" },
138
+ { name: "workflowCardUri", type: "string" },
139
+ { name: "units", type: "uint256" },
140
+ { name: "leaseEnabled", type: "bool" },
141
+ { name: "leaseDuration", type: "uint256" },
142
+ { name: "leasePercent", type: "uint8" },
143
+ { name: "hasCoordinator", type: "bool" },
144
+ { name: "coordinatorModel", type: "string" },
145
+ ],
146
+ },
147
+ { name: "agentIds", type: "uint256[]" },
148
+ ],
149
+ outputs: [{ name: "workflowId", type: "uint256" }],
150
+ },
151
+ { name: "addAgent", type: "function", stateMutability: "nonpayable", inputs: [{ name: "workflowId", type: "uint256" }, { name: "agentId", type: "uint256" }], outputs: [] },
152
+ { name: "removeAgent", type: "function", stateMutability: "nonpayable", inputs: [{ name: "workflowId", type: "uint256" }, { name: "agentId", type: "uint256" }], outputs: [] },
153
+ { name: "setCoordinator", type: "function", stateMutability: "nonpayable", inputs: [{ name: "workflowId", type: "uint256" }, { name: "hasCoordinator", type: "bool" }, { name: "model", type: "string" }], outputs: [] },
154
+ { name: "updateLeaseSettings", type: "function", stateMutability: "nonpayable", inputs: [{ name: "workflowId", type: "uint256" }, { name: "enabled", type: "bool" }, { name: "duration", type: "uint256" }, { name: "percent", type: "uint8" }], outputs: [] },
155
+ ];
156
+ export const CloneABI = [
157
+ {
158
+ name: "cloneAgent",
159
+ type: "function",
160
+ stateMutability: "nonpayable",
161
+ inputs: [
162
+ { name: "originalAgentId", type: "uint256" },
163
+ {
164
+ name: "params",
165
+ type: "tuple",
166
+ components: [
167
+ { name: "chainId", type: "uint256" },
168
+ { name: "licensePrice", type: "uint256" },
169
+ { name: "model", type: "string" },
170
+ { name: "licenses", type: "uint256" },
171
+ ],
172
+ },
173
+ { name: "newAgentCardUri", type: "string" },
174
+ ],
175
+ outputs: [{ name: "clonedAgentId", type: "uint256" }],
176
+ },
177
+ { name: "canClone", type: "function", stateMutability: "view", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ name: "canClone", type: "bool" }] },
178
+ { name: "getClonesOf", type: "function", stateMutability: "view", inputs: [{ name: "originalAgentId", type: "uint256" }], outputs: [{ name: "cloneIds", type: "uint256[]" }] },
179
+ ];
180
+ export const WarpABI = [
181
+ {
182
+ name: "warpAgent",
183
+ type: "function",
184
+ stateMutability: "nonpayable",
185
+ inputs: [
186
+ { name: "originalAgentHash", type: "bytes32" },
187
+ { name: "originalCreator", type: "address" },
188
+ { name: "licenses", type: "uint256" },
189
+ { name: "licensePrice", type: "uint256" },
190
+ { name: "agentCardUri", type: "string" },
191
+ ],
192
+ outputs: [{ name: "warpedAgentId", type: "uint256" }],
193
+ },
194
+ { name: "isWarped", type: "function", stateMutability: "view", inputs: [{ name: "agentId", type: "uint256" }], outputs: [{ name: "isWarped", type: "bool" }] },
195
+ {
196
+ name: "getWarpedData",
197
+ type: "function",
198
+ stateMutability: "view",
199
+ inputs: [{ name: "warpedAgentId", type: "uint256" }],
200
+ outputs: [{
201
+ name: "data",
202
+ type: "tuple",
203
+ components: [
204
+ { name: "originalCreator", type: "address" },
205
+ { name: "warper", type: "address" },
206
+ { name: "originalAgentHash", type: "bytes32" },
207
+ { name: "royaltyExpiryDate", type: "uint256" },
208
+ { name: "royaltiesClaimed", type: "bool" },
209
+ { name: "accumulatedRoyalties", type: "uint256" },
210
+ ],
211
+ }],
212
+ },
213
+ { name: "totalWarped", type: "function", stateMutability: "view", inputs: [], outputs: [{ name: "total", type: "uint256" }] },
214
+ { name: "getWarpedAgentId", type: "function", stateMutability: "view", inputs: [{ name: "externalHash", type: "bytes32" }], outputs: [{ name: "warpedAgentId", type: "uint256" }] },
215
+ ];
216
+ export const RFAABI = [
217
+ {
218
+ name: "createRFA",
219
+ type: "function",
220
+ stateMutability: "nonpayable",
221
+ inputs: [
222
+ { name: "workflowId", type: "uint256" },
223
+ { name: "title", type: "string" },
224
+ { name: "description", type: "string" },
225
+ { name: "requiredSkills", type: "bytes32[]" },
226
+ { name: "offerAmount", type: "uint256" },
227
+ ],
228
+ outputs: [{ name: "rfaId", type: "uint256" }],
229
+ },
230
+ { name: "submitAgent", type: "function", stateMutability: "nonpayable", inputs: [{ name: "rfaId", type: "uint256" }, { name: "agentId", type: "uint256" }], outputs: [] },
231
+ { name: "acceptAgent", type: "function", stateMutability: "nonpayable", inputs: [{ name: "rfaId", type: "uint256" }, { name: "agentId", type: "uint256" }], outputs: [] },
232
+ { name: "cancelRFA", type: "function", stateMutability: "nonpayable", inputs: [{ name: "rfaId", type: "uint256" }], outputs: [] },
233
+ {
234
+ name: "getRFAData",
235
+ type: "function",
236
+ stateMutability: "view",
237
+ inputs: [{ name: "rfaId", type: "uint256" }],
238
+ outputs: [{
239
+ name: "data",
240
+ type: "tuple",
241
+ components: [
242
+ { name: "workflowId", type: "uint256" },
243
+ { name: "title", type: "string" },
244
+ { name: "description", type: "string" },
245
+ { name: "requiredSkills", type: "bytes32[]" },
246
+ { name: "offerAmount", type: "uint256" },
247
+ { name: "publisher", type: "address" },
248
+ { name: "createdAt", type: "uint256" },
249
+ { name: "status", type: "uint8" },
250
+ { name: "fulfilledByAgentId", type: "uint256" },
251
+ { name: "agentCreator", type: "address" },
252
+ ],
253
+ }],
254
+ },
255
+ { name: "getOpenRFAs", type: "function", stateMutability: "view", inputs: [], outputs: [{ name: "rfaIds", type: "uint256[]" }] },
256
+ {
257
+ name: "getSubmissions",
258
+ type: "function",
259
+ stateMutability: "view",
260
+ inputs: [{ name: "rfaId", type: "uint256" }],
261
+ outputs: [{
262
+ name: "submissions",
263
+ type: "tuple[]",
264
+ components: [
265
+ { name: "agentId", type: "uint256" },
266
+ { name: "creator", type: "address" },
267
+ { name: "submittedAt", type: "uint256" },
268
+ ],
269
+ }],
270
+ },
271
+ { name: "getRFAsForWorkflow", type: "function", stateMutability: "view", inputs: [{ name: "workflowId", type: "uint256" }], outputs: [{ name: "rfaIds", type: "uint256[]" }] },
272
+ { name: "getRFAsByPublisher", type: "function", stateMutability: "view", inputs: [{ name: "publisher", type: "address" }], outputs: [{ name: "rfaIds", type: "uint256[]" }] },
273
+ ];
274
+ export const ManowarEvmABIs = {
275
+ AgentFactory: AgentFactoryABI,
276
+ Workflow: WorkflowABI,
277
+ Clone: CloneABI,
278
+ Warp: WarpABI,
279
+ RFA: RFAABI,
280
+ };
281
+ function evmOperation(network, deployment, contractName, abi, functionName, args) {
282
+ const to = deployment.evm?.contracts[contractName];
283
+ if (!to)
284
+ throw new Error(`Missing ${contractName} contract for ${network}`);
285
+ return {
286
+ kind: "evm",
287
+ network,
288
+ contractName,
289
+ to,
290
+ abi: abi,
291
+ functionName,
292
+ args,
293
+ data: encodeFunctionData({ abi: abi, functionName, args: args }),
294
+ };
295
+ }
296
+ export function buildEvmMintAgentOperation(network, deployment, args) {
297
+ return evmOperation(network, deployment, "AgentFactory", AgentFactoryABI, "mintAgent", [
298
+ args.dnaHash,
299
+ args.licenses,
300
+ args.licensePrice,
301
+ BigInt(args.creatorFee ?? 1),
302
+ args.cloneable,
303
+ args.agentCardUri,
304
+ ]);
305
+ }
306
+ export function buildEvmWarpAgentOperation(network, deployment, args) {
307
+ return evmOperation(network, deployment, "Warp", WarpABI, "warpAgent", [
308
+ args.originalAgentHash,
309
+ args.originalCreator,
310
+ args.licenses,
311
+ args.licensePrice,
312
+ args.agentCardUri,
313
+ ]);
314
+ }
315
+ export function buildEvmMintWorkflowOperation(network, deployment, args) {
316
+ return evmOperation(network, deployment, "Workflow", WorkflowABI, "mintWorkflow", [args.params, args.agentIds]);
317
+ }
318
+ export function buildEvmCreateRfaOperation(network, deployment, args) {
319
+ return evmOperation(network, deployment, "RFA", RFAABI, "createRFA", [
320
+ args.workflowId,
321
+ args.title,
322
+ args.description,
323
+ args.requiredSkills,
324
+ args.offerAmount,
325
+ ]);
326
+ }
327
+ class BorshWriter {
328
+ chunks = [];
329
+ u8(value) { this.chunks.push(value & 0xff); }
330
+ bool(value) { this.u8(value ? 1 : 0); }
331
+ u16(value) {
332
+ this.chunks.push(value & 0xff, (value >> 8) & 0xff);
333
+ }
334
+ u32(value) {
335
+ this.chunks.push(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
336
+ }
337
+ u64(value) {
338
+ this.fixedBigInt(BigInt(value), 8);
339
+ }
340
+ i64(value) {
341
+ this.fixedBigInt(BigInt.asUintN(64, BigInt(value)), 8);
342
+ }
343
+ i128(value) {
344
+ this.fixedBigInt(BigInt.asUintN(128, BigInt(value)), 16);
345
+ }
346
+ bytes(bytes) {
347
+ this.chunks.push(...bytes);
348
+ }
349
+ fixed32(bytes) {
350
+ if (bytes.length !== 32)
351
+ throw new Error(`Expected 32 bytes, got ${bytes.length}`);
352
+ this.chunks.push(...bytes);
353
+ }
354
+ pubkey(value) {
355
+ this.bytes(addressBytes(value));
356
+ }
357
+ string(value) {
358
+ this.vecBytes(textEncoder.encode(value));
359
+ }
360
+ vecBytes(value) {
361
+ this.u32(value.length);
362
+ this.bytes(value);
363
+ }
364
+ vec(values, encode) {
365
+ this.u32(values.length);
366
+ for (const value of values)
367
+ encode(value);
368
+ }
369
+ done() {
370
+ return new Uint8Array(this.chunks);
371
+ }
372
+ fixedBigInt(value, byteLength) {
373
+ let next = value;
374
+ for (let i = 0; i < byteLength; i += 1) {
375
+ this.u8(Number(next & 0xffn));
376
+ next >>= 8n;
377
+ }
378
+ }
379
+ }
380
+ class BorshReader {
381
+ data;
382
+ offset = 0;
383
+ constructor(data) {
384
+ this.data = data;
385
+ }
386
+ u8() { return this.data[this.offset++]; }
387
+ bool() { return this.u8() !== 0; }
388
+ u16() {
389
+ const value = this.data[this.offset] | (this.data[this.offset + 1] << 8);
390
+ this.offset += 2;
391
+ return value;
392
+ }
393
+ u32() {
394
+ const view = new DataView(this.data.buffer, this.data.byteOffset + this.offset, 4);
395
+ const value = view.getUint32(0, true);
396
+ this.offset += 4;
397
+ return value;
398
+ }
399
+ u64() { return this.fixedBigInt(8, false); }
400
+ i64() { return this.fixedBigInt(8, true); }
401
+ i128() { return this.fixedBigInt(16, true); }
402
+ bytes(length) {
403
+ const value = this.data.slice(this.offset, this.offset + length);
404
+ this.offset += length;
405
+ return value;
406
+ }
407
+ fixed32() { return this.bytes(32); }
408
+ pubkey() { return addressDecoder.decode(this.bytes(32)); }
409
+ string() { return textDecoder.decode(this.vecBytes()); }
410
+ vecBytes() { return this.bytes(this.u32()); }
411
+ vec(read) {
412
+ return Array.from({ length: this.u32() }, read);
413
+ }
414
+ fixedBigInt(byteLength, signed) {
415
+ let value = 0n;
416
+ for (let i = 0; i < byteLength; i += 1) {
417
+ value |= BigInt(this.data[this.offset + i]) << BigInt(i * 8);
418
+ }
419
+ this.offset += byteLength;
420
+ return signed ? BigInt.asIntN(byteLength * 8, value) : value;
421
+ }
422
+ }
423
+ const textEncoder = new TextEncoder();
424
+ const textDecoder = new TextDecoder();
425
+ const addressEncoder = getAddressEncoder();
426
+ const addressDecoder = getAddressDecoder();
427
+ function addressBytes(value) {
428
+ return new Uint8Array(addressEncoder.encode(address(value)));
429
+ }
430
+ export function decodeLengthPrefixedAccount(data) {
431
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
432
+ if (bytes.length < 4)
433
+ throw new Error("Account data is smaller than Manowar account header");
434
+ const len = new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0, true);
435
+ if (len === 0)
436
+ throw new Error("Manowar account is not initialized");
437
+ if (4 + len > bytes.length)
438
+ throw new Error("Manowar account payload length exceeds account data");
439
+ return bytes.slice(4, 4 + len);
440
+ }
441
+ function reader(data) {
442
+ return new BorshReader(decodeLengthPrefixedAccount(data));
443
+ }
444
+ export function decodeIdentityRegistryAccount(data) {
445
+ const r = reader(data);
446
+ return { version: r.u8(), admin: r.pubkey(), nextAgentId: r.u64(), totalAgents: r.u64(), consumers: r.vec(() => r.pubkey()) };
447
+ }
448
+ export function decodeAgentAccount(data) {
449
+ const r = reader(data);
450
+ return {
451
+ version: r.u8(),
452
+ agentId: r.u64(),
453
+ owner: r.pubkey(),
454
+ creator: r.pubkey(),
455
+ dnaHash: r.fixed32(),
456
+ licenses: r.u64(),
457
+ licensesMinted: r.u64(),
458
+ licensePrice: r.u64(),
459
+ creatorFee: r.u64(),
460
+ cloneable: r.bool(),
461
+ isClone: r.bool(),
462
+ parentAgentId: r.u64(),
463
+ agentWallet: r.pubkey(),
464
+ uri: r.string(),
465
+ };
466
+ }
467
+ export function decodeU64IndexAccount(data) {
468
+ const r = reader(data);
469
+ return { version: r.u8(), page: r.u32(), total: r.u64(), values: r.vec(() => r.u64()) };
470
+ }
471
+ export function decodePubkeyIndexAccount(data) {
472
+ const r = reader(data);
473
+ return { version: r.u8(), page: r.u32(), total: r.u64(), values: r.vec(() => r.pubkey()) };
474
+ }
475
+ export function decodeMarketRegistryAccount(data) {
476
+ const r = reader(data);
477
+ return {
478
+ version: r.u8(),
479
+ admin: r.pubkey(),
480
+ treasuryToken: r.pubkey(),
481
+ paymentMint: r.pubkey(),
482
+ nextWorkflowId: r.u64(),
483
+ nextRfaId: r.u64(),
484
+ nextLeaseId: r.u64(),
485
+ totalWorkflows: r.u64(),
486
+ totalEscrowed: r.u64(),
487
+ };
488
+ }
489
+ export function decodeWorkflowAccount(data) {
490
+ const r = reader(data);
491
+ return {
492
+ version: r.u8(),
493
+ workflowId: r.u64(),
494
+ owner: r.pubkey(),
495
+ creator: r.pubkey(),
496
+ title: r.string(),
497
+ description: r.string(),
498
+ banner: r.string(),
499
+ uri: r.string(),
500
+ totalPrice: r.u64(),
501
+ units: r.u64(),
502
+ unitsMinted: r.u64(),
503
+ leaseEnabled: r.bool(),
504
+ leaseDuration: r.u64(),
505
+ leasePercent: r.u8(),
506
+ hasCoordinator: r.bool(),
507
+ coordinatorModel: r.string(),
508
+ hasActiveRfa: r.bool(),
509
+ rfaId: r.u64(),
510
+ activeLeaseId: r.u64(),
511
+ agents: r.vec(() => r.u64()),
512
+ };
513
+ }
514
+ export function decodeRfaAccount(data) {
515
+ const r = reader(data);
516
+ const version = r.u8();
517
+ const rfaId = r.u64();
518
+ const workflowId = r.u64();
519
+ const title = r.string();
520
+ const description = r.string();
521
+ const requiredSkills = r.vec(() => r.fixed32());
522
+ const offerAmount = r.u64();
523
+ const publisher = r.pubkey();
524
+ const createdAt = r.i64();
525
+ const status = ["open", "fulfilled", "cancelled"][r.u8()];
526
+ if (!status)
527
+ throw new Error("Unknown RFA status");
528
+ return {
529
+ version,
530
+ rfaId,
531
+ workflowId,
532
+ title,
533
+ description,
534
+ requiredSkills,
535
+ offerAmount,
536
+ publisher,
537
+ createdAt,
538
+ status,
539
+ fulfilledByAgentId: r.u64(),
540
+ agentCreator: r.pubkey(),
541
+ };
542
+ }
543
+ export function decodeSubmissionAccount(data) {
544
+ const r = reader(data);
545
+ return { version: r.u8(), rfaId: r.u64(), agentId: r.u64(), creator: r.pubkey(), submittedAt: r.i64() };
546
+ }
547
+ export function decodeReputationRegistryAccount(data) {
548
+ const r = reader(data);
549
+ return { version: r.u8(), admin: r.pubkey(), identityRegistry: r.pubkey() };
550
+ }
551
+ export function decodeFeedbackAccount(data) {
552
+ const r = reader(data);
553
+ return {
554
+ version: r.u8(),
555
+ agentId: r.u64(),
556
+ client: r.pubkey(),
557
+ feedbackIndex: r.u64(),
558
+ value: r.i128(),
559
+ valueDecimals: r.u8(),
560
+ isRevoked: r.bool(),
561
+ tag1: r.string(),
562
+ tag2: r.string(),
563
+ endpoint: r.string(),
564
+ feedbackUri: r.string(),
565
+ feedbackHash: r.fixed32(),
566
+ createdAt: r.i64(),
567
+ };
568
+ }
569
+ export function decodeValidationRegistryAccount(data) {
570
+ const r = reader(data);
571
+ return { version: r.u8(), admin: r.pubkey(), nextRequestId: r.u64(), totalRequests: r.u64() };
572
+ }
573
+ export function decodeValidationRequestAccount(data) {
574
+ const r = reader(data);
575
+ return {
576
+ version: r.u8(),
577
+ requestId: r.u64(),
578
+ agentId: r.u64(),
579
+ requester: r.pubkey(),
580
+ validatorType: r.string(),
581
+ taskHash: r.fixed32(),
582
+ requestUri: r.string(),
583
+ timestamp: r.i64(),
584
+ closed: r.bool(),
585
+ responseCount: r.u64(),
586
+ };
587
+ }
588
+ // ---------------------------------------------------------------------------
589
+ // Solana PDA helpers and instruction builders
590
+ // ---------------------------------------------------------------------------
591
+ export const ManowarSeeds = {
592
+ REGISTRY: "registry",
593
+ AGENT: "agent",
594
+ DNA: "dna",
595
+ WARP: "warp",
596
+ FEEDBACK: "feedback",
597
+ FEEDBACK_INDEX: "feedback-index",
598
+ RESPONSE: "response",
599
+ REQUEST: "request",
600
+ WORKFLOW: "workflow",
601
+ LICENSE_INDEX: "license-index",
602
+ LICENSE_RECORD: "license-record",
603
+ RFA: "rfa",
604
+ RFA_INDEX: "rfa-index",
605
+ OPEN_RFA_INDEX: "open-rfa-index",
606
+ PUBLISHER_RFA_INDEX: "publisher-rfa-index",
607
+ SUBMISSION: "submission",
608
+ SUBMISSION_INDEX: "submission-index",
609
+ LEASE: "lease",
610
+ LEASE_INDEX: "lease-index",
611
+ ACTIVE_LEASE: "active-lease",
612
+ ROYALTY: "royalty",
613
+ DEFAULT_ROYALTY: "default-royalty",
614
+ CLONE_INDEX: "clone-index",
615
+ IDENTITY_STATS: "identity-stats",
616
+ WARP_AGENT: "warp-agent",
617
+ CREATOR_WORKFLOW_INDEX: "creator-workflow-index",
618
+ COMPLETE_WORKFLOW_INDEX: "complete-workflow-index",
619
+ RFA_WORKFLOW_INDEX: "rfa-workflow-index",
620
+ MARKET_AUTHORITY: "market-authority",
621
+ MARKET_CONFIG: "market-config",
622
+ REPUTATION_REGISTRY: "reputation-registry",
623
+ FEEDBACK_CLIENT_INDEX: "feedback-client-index",
624
+ RESPONSE_COUNTER: "response-counter",
625
+ VALIDATION_AGENT_INDEX: "validation-agent-index",
626
+ VALIDATION_RESPONSE_INDEX: "validation-response-index",
627
+ };
628
+ function seed(value) {
629
+ return textEncoder.encode(value);
630
+ }
631
+ export function u64Seed(value) {
632
+ const bytes = new Uint8Array(8);
633
+ new DataView(bytes.buffer).setBigUint64(0, BigInt(value), true);
634
+ return bytes;
635
+ }
636
+ export function bytes32FromHex(hex) {
637
+ const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
638
+ if (clean.length !== 64)
639
+ throw new Error(`Expected bytes32 hex, got ${hex}`);
640
+ const out = new Uint8Array(32);
641
+ for (let i = 0; i < 32; i += 1)
642
+ out[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
643
+ return out;
644
+ }
645
+ export function hexFromBytes32(bytes) {
646
+ if (bytes.length !== 32)
647
+ throw new Error(`Expected bytes32, got ${bytes.length} bytes`);
648
+ return `0x${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
649
+ }
650
+ export async function findManowarPda(programId, seeds) {
651
+ const [pda] = await getProgramDerivedAddress({ programAddress: address(programId), seeds: [...seeds] });
652
+ return pda;
653
+ }
654
+ export const identityPdas = {
655
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REGISTRY)]),
656
+ agent: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.AGENT), u64Seed(agentId)]),
657
+ dna: (programId, dnaHash) => findManowarPda(programId, [seed(ManowarSeeds.DNA), dnaHash]),
658
+ cloneIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.CLONE_INDEX), u64Seed(agentId)]),
659
+ stats: (programId) => findManowarPda(programId, [seed(ManowarSeeds.IDENTITY_STATS)]),
660
+ warp: (programId, originalHash) => findManowarPda(programId, [seed(ManowarSeeds.WARP), originalHash]),
661
+ warpAgent: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.WARP_AGENT), u64Seed(agentId)]),
662
+ licenseIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.LICENSE_INDEX), u64Seed(agentId)]),
663
+ licenseRecord: (programId, agentId, workflowProgram, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.LICENSE_RECORD), u64Seed(agentId), addressBytes(workflowProgram), u64Seed(workflowId)]),
664
+ };
665
+ export const marketPdas = {
666
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REGISTRY)]),
667
+ config: (programId) => findManowarPda(programId, [seed(ManowarSeeds.MARKET_CONFIG)]),
668
+ authority: (programId) => findManowarPda(programId, [seed(ManowarSeeds.MARKET_AUTHORITY)]),
669
+ workflow: (programId, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.WORKFLOW), u64Seed(workflowId)]),
670
+ creatorWorkflowIndex: (programId, creator) => findManowarPda(programId, [seed(ManowarSeeds.CREATOR_WORKFLOW_INDEX), addressBytes(creator)]),
671
+ completeWorkflowIndex: (programId) => findManowarPda(programId, [seed(ManowarSeeds.COMPLETE_WORKFLOW_INDEX)]),
672
+ openRfaIndex: (programId) => findManowarPda(programId, [seed(ManowarSeeds.OPEN_RFA_INDEX)]),
673
+ rfaWorkflowIndex: (programId) => findManowarPda(programId, [seed(ManowarSeeds.RFA_WORKFLOW_INDEX)]),
674
+ workflowRfaIndex: (programId, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.RFA_INDEX), u64Seed(workflowId)]),
675
+ publisherRfaIndex: (programId, publisher) => findManowarPda(programId, [seed(ManowarSeeds.PUBLISHER_RFA_INDEX), addressBytes(publisher)]),
676
+ rfa: (programId, rfaId) => findManowarPda(programId, [seed(ManowarSeeds.RFA), u64Seed(rfaId)]),
677
+ submission: (programId, rfaId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.SUBMISSION), u64Seed(rfaId), u64Seed(agentId)]),
678
+ submissionIndex: (programId, rfaId) => findManowarPda(programId, [seed(ManowarSeeds.SUBMISSION_INDEX), u64Seed(rfaId)]),
679
+ lease: (programId, leaseId) => findManowarPda(programId, [seed(ManowarSeeds.LEASE), u64Seed(leaseId)]),
680
+ leaseIndex: (programId, leaser) => findManowarPda(programId, [seed(ManowarSeeds.LEASE_INDEX), addressBytes(leaser)]),
681
+ activeLease: (programId, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.ACTIVE_LEASE), u64Seed(workflowId)]),
682
+ royalty: (programId, tokenId) => findManowarPda(programId, [seed(ManowarSeeds.ROYALTY), u64Seed(tokenId)]),
683
+ defaultRoyalty: (programId) => findManowarPda(programId, [seed(ManowarSeeds.DEFAULT_ROYALTY)]),
684
+ };
685
+ export const reputationPdas = {
686
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REPUTATION_REGISTRY)]),
687
+ feedbackClientIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.FEEDBACK_CLIENT_INDEX), u64Seed(agentId)]),
688
+ feedbackIndex: (programId, agentId, client) => findManowarPda(programId, [seed(ManowarSeeds.FEEDBACK_INDEX), u64Seed(agentId), addressBytes(client)]),
689
+ feedback: (programId, agentId, client, feedbackIndex) => findManowarPda(programId, [seed(ManowarSeeds.FEEDBACK), u64Seed(agentId), addressBytes(client), u64Seed(feedbackIndex)]),
690
+ responseCounter: (programId, agentId, client, feedbackIndex, responder) => findManowarPda(programId, [seed(ManowarSeeds.RESPONSE_COUNTER), u64Seed(agentId), addressBytes(client), u64Seed(feedbackIndex), addressBytes(responder)]),
691
+ };
692
+ export const validationPdas = {
693
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REGISTRY)]),
694
+ request: (programId, requestId) => findManowarPda(programId, [seed(ManowarSeeds.REQUEST), u64Seed(requestId)]),
695
+ requestIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.VALIDATION_AGENT_INDEX), u64Seed(agentId)]),
696
+ response: (programId, requestId, responseId) => findManowarPda(programId, [seed(ManowarSeeds.RESPONSE), u64Seed(requestId), u64Seed(responseId)]),
697
+ responseIndex: (programId, requestId) => findManowarPda(programId, [seed(ManowarSeeds.VALIDATION_RESPONSE_INDEX), u64Seed(requestId)]),
698
+ };
699
+ function ix(programAddress, accounts, data) {
700
+ return { programAddress: address(programAddress), accounts, data };
701
+ }
702
+ export function encodeIdentityInstruction(instruction) {
703
+ const w = new BorshWriter();
704
+ switch (instruction.type) {
705
+ case "initialize":
706
+ w.u8(0);
707
+ break;
708
+ case "mint":
709
+ w.u8(2);
710
+ w.fixed32(instruction.dnaHash);
711
+ w.u64(instruction.licenses);
712
+ w.u64(instruction.licensePrice);
713
+ w.u64(instruction.creatorFee);
714
+ w.bool(instruction.cloneable);
715
+ w.string(instruction.uri);
716
+ break;
717
+ case "warp":
718
+ w.u8(4);
719
+ w.fixed32(instruction.originalHash);
720
+ w.pubkey(instruction.originalCreator);
721
+ w.u64(instruction.licenses);
722
+ w.u64(instruction.licensePrice);
723
+ w.string(instruction.uri);
724
+ break;
725
+ case "consumeLicense":
726
+ case "revokeLicense":
727
+ w.u8(instruction.type === "consumeLicense" ? 14 : 15);
728
+ w.u64(instruction.agentId);
729
+ w.pubkey(instruction.workflow);
730
+ w.u64(instruction.workflowId);
731
+ break;
732
+ }
733
+ return w.done();
734
+ }
735
+ export async function buildIdentityMintInstruction(input) {
736
+ const registry = await identityPdas.registry(input.programId);
737
+ const agentPda = await identityPdas.agent(input.programId, input.nextAgentId);
738
+ const dna = await identityPdas.dna(input.programId, input.dnaHash);
739
+ return {
740
+ agent: agentPda,
741
+ dna,
742
+ instruction: ix(input.programId, [
743
+ { address: registry, role: AccountRole.WRITABLE },
744
+ { address: agentPda, role: AccountRole.WRITABLE },
745
+ { address: dna, role: AccountRole.WRITABLE },
746
+ { address: address(input.owner), role: AccountRole.WRITABLE_SIGNER },
747
+ { address: address(input.rentPayer), role: AccountRole.WRITABLE_SIGNER },
748
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
749
+ ], encodeIdentityInstruction({
750
+ type: "mint",
751
+ dnaHash: input.dnaHash,
752
+ licenses: input.licenses,
753
+ licensePrice: input.licensePrice,
754
+ creatorFee: input.creatorFee ?? 1,
755
+ cloneable: input.cloneable,
756
+ uri: input.uri,
757
+ })),
758
+ };
759
+ }
760
+ export async function buildIdentityWarpInstruction(input) {
761
+ const registry = await identityPdas.registry(input.programId);
762
+ const agentPda = await identityPdas.agent(input.programId, input.nextAgentId);
763
+ const dna = await identityPdas.dna(input.programId, input.originalHash);
764
+ const warp = await identityPdas.warp(input.programId, input.originalHash);
765
+ const warpAgent = await identityPdas.warpAgent(input.programId, input.nextAgentId);
766
+ return {
767
+ agent: agentPda,
768
+ dna,
769
+ warp,
770
+ warpAgent,
771
+ instruction: ix(input.programId, [
772
+ { address: registry, role: AccountRole.WRITABLE },
773
+ { address: agentPda, role: AccountRole.WRITABLE },
774
+ { address: dna, role: AccountRole.WRITABLE },
775
+ { address: warp, role: AccountRole.WRITABLE },
776
+ { address: warpAgent, role: AccountRole.WRITABLE },
777
+ { address: await identityPdas.stats(input.programId), role: AccountRole.WRITABLE },
778
+ { address: address(input.warper), role: AccountRole.WRITABLE_SIGNER },
779
+ { address: address(input.rentPayer), role: AccountRole.WRITABLE_SIGNER },
780
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
781
+ ], encodeIdentityInstruction({
782
+ type: "warp",
783
+ originalHash: input.originalHash,
784
+ originalCreator: input.originalCreator,
785
+ licenses: input.licenses,
786
+ licensePrice: input.licensePrice,
787
+ uri: input.uri,
788
+ })),
789
+ };
790
+ }
791
+ export function encodeMarketInstruction(instruction) {
792
+ const w = new BorshWriter();
793
+ switch (instruction.type) {
794
+ case "mintWorkflow":
795
+ w.u8(7);
796
+ w.string(instruction.title);
797
+ w.string(instruction.description);
798
+ w.string(instruction.banner);
799
+ w.string(instruction.uri);
800
+ w.u64(instruction.units);
801
+ w.bool(instruction.leaseEnabled);
802
+ w.u64(instruction.leaseDuration);
803
+ w.u8(instruction.leasePercent);
804
+ w.bool(instruction.hasCoordinator);
805
+ w.string(instruction.coordinatorModel);
806
+ break;
807
+ case "createRfa":
808
+ w.u8(16);
809
+ w.u64(instruction.workflowId);
810
+ w.string(instruction.title);
811
+ w.string(instruction.description);
812
+ w.vec(instruction.requiredSkills, (skill) => w.fixed32(skill));
813
+ w.u64(instruction.offerAmount);
814
+ break;
815
+ case "submitAgent":
816
+ case "acceptAgent":
817
+ w.u8(instruction.type === "submitAgent" ? 17 : 18);
818
+ w.u64(instruction.rfaId);
819
+ w.u64(instruction.agentId);
820
+ break;
821
+ case "cancelRfa":
822
+ w.u8(19);
823
+ w.u64(instruction.rfaId);
824
+ break;
825
+ }
826
+ return w.done();
827
+ }
828
+ export async function buildMarketMintWorkflowInstruction(input) {
829
+ const workflow = await marketPdas.workflow(input.marketProgramId, input.nextWorkflowId);
830
+ const identityRegistry = await identityPdas.registry(input.identityProgramId);
831
+ const marketAuthority = await marketPdas.authority(input.marketProgramId);
832
+ const accounts = [
833
+ { address: await marketPdas.registry(input.marketProgramId), role: AccountRole.WRITABLE },
834
+ { address: workflow, role: AccountRole.WRITABLE },
835
+ { address: await marketPdas.creatorWorkflowIndex(input.marketProgramId, input.owner), role: AccountRole.WRITABLE },
836
+ { address: await marketPdas.completeWorkflowIndex(input.marketProgramId), role: AccountRole.WRITABLE },
837
+ { address: address(input.owner), role: AccountRole.WRITABLE_SIGNER },
838
+ { address: address(input.identityProgramId), role: AccountRole.READONLY },
839
+ { address: identityRegistry, role: AccountRole.WRITABLE },
840
+ { address: marketAuthority, role: AccountRole.READONLY_SIGNER },
841
+ { address: address(input.tokenProgram), role: AccountRole.READONLY },
842
+ { address: address(input.payerToken), role: AccountRole.WRITABLE },
843
+ { address: address(input.treasuryToken), role: AccountRole.WRITABLE },
844
+ { address: address(input.rentPayer), role: AccountRole.WRITABLE_SIGNER },
845
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
846
+ ];
847
+ for (const agent of input.agents ?? []) {
848
+ accounts.push({ address: await identityPdas.agent(input.identityProgramId, agent.agentId), role: AccountRole.WRITABLE }, { address: await identityPdas.licenseIndex(input.identityProgramId, agent.agentId), role: AccountRole.WRITABLE }, { address: await identityPdas.licenseRecord(input.identityProgramId, agent.agentId, input.marketProgramId, input.nextWorkflowId), role: AccountRole.WRITABLE }, { address: address(agent.creatorToken), role: AccountRole.WRITABLE });
849
+ }
850
+ return {
851
+ workflow,
852
+ instruction: ix(input.marketProgramId, accounts, encodeMarketInstruction({
853
+ type: "mintWorkflow",
854
+ title: input.title,
855
+ description: input.description,
856
+ banner: input.banner,
857
+ uri: input.uri,
858
+ units: input.units,
859
+ leaseEnabled: input.leaseEnabled,
860
+ leaseDuration: input.leaseDuration,
861
+ leasePercent: input.leasePercent,
862
+ hasCoordinator: input.hasCoordinator,
863
+ coordinatorModel: input.coordinatorModel,
864
+ })),
865
+ };
866
+ }
867
+ export async function buildMarketCreateRfaInstruction(input) {
868
+ const rfa = await marketPdas.rfa(input.marketProgramId, input.nextRfaId);
869
+ return {
870
+ rfa,
871
+ instruction: ix(input.marketProgramId, [
872
+ { address: await marketPdas.registry(input.marketProgramId), role: AccountRole.WRITABLE },
873
+ { address: rfa, role: AccountRole.WRITABLE },
874
+ { address: await marketPdas.workflow(input.marketProgramId, input.workflowId), role: AccountRole.WRITABLE },
875
+ { address: await marketPdas.openRfaIndex(input.marketProgramId), role: AccountRole.WRITABLE },
876
+ { address: await marketPdas.workflowRfaIndex(input.marketProgramId, input.workflowId), role: AccountRole.WRITABLE },
877
+ { address: await marketPdas.publisherRfaIndex(input.marketProgramId, input.publisher), role: AccountRole.WRITABLE },
878
+ { address: await marketPdas.completeWorkflowIndex(input.marketProgramId), role: AccountRole.WRITABLE },
879
+ { address: await marketPdas.rfaWorkflowIndex(input.marketProgramId), role: AccountRole.WRITABLE },
880
+ { address: address(input.publisher), role: AccountRole.WRITABLE_SIGNER },
881
+ { address: address(input.tokenProgram), role: AccountRole.READONLY },
882
+ { address: address(input.publisherToken), role: AccountRole.WRITABLE },
883
+ { address: address(input.escrowToken), role: AccountRole.WRITABLE },
884
+ { address: address(input.rentPayer), role: AccountRole.WRITABLE_SIGNER },
885
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
886
+ ], encodeMarketInstruction({
887
+ type: "createRfa",
888
+ workflowId: input.workflowId,
889
+ title: input.title,
890
+ description: input.description,
891
+ requiredSkills: input.requiredSkills,
892
+ offerAmount: input.offerAmount,
893
+ })),
894
+ };
895
+ }
896
+ export function computeDnaHash(skills, networkOrChain, model) {
897
+ const sortedSkills = [...skills].sort();
898
+ const skillsValue = sortedSkills.join(",");
899
+ if (typeof networkOrChain === "number") {
900
+ return keccak256(encodePacked(["string", "uint256", "string"], [skillsValue, BigInt(networkOrChain), model]));
901
+ }
902
+ return keccak256(encodePacked(["string", "string", "string"], [skillsValue, networkOrChain, model]));
903
+ }
904
+ export function computeExternalAgentHash(registry, agentAddress) {
905
+ return keccak256(encodePacked(["string", "string"], [registry, agentAddress]));
906
+ }
907
+ export function encodeSkillAsBytes32(skill) {
908
+ return keccak256(encodePacked(["string"], [skill.toLowerCase()]));
909
+ }
910
+ export function createManowarBlockchainClient(input) {
911
+ const { network, deployment } = input;
912
+ const solana = deployment.solana;
913
+ return {
914
+ network,
915
+ deployment,
916
+ evm: {
917
+ mintAgent: (args) => buildEvmMintAgentOperation(network, deployment, args),
918
+ warpAgent: (args) => buildEvmWarpAgentOperation(network, deployment, args),
919
+ mintWorkflow: (args) => buildEvmMintWorkflowOperation(network, deployment, args),
920
+ createRfa: (args) => buildEvmCreateRfaOperation(network, deployment, args),
921
+ },
922
+ solana: solana ? {
923
+ pdas: { identity: identityPdas, market: marketPdas, reputation: reputationPdas, validation: validationPdas },
924
+ identity: {
925
+ mint: (args) => buildIdentityMintInstruction({ ...args, programId: solana.identityProgramId }),
926
+ warp: (args) => buildIdentityWarpInstruction({ ...args, programId: solana.identityProgramId }),
927
+ },
928
+ market: {
929
+ mintWorkflow: (args) => buildMarketMintWorkflowInstruction({ ...args, marketProgramId: solana.marketProgramId, identityProgramId: solana.identityProgramId }),
930
+ createRfa: (args) => buildMarketCreateRfaInstruction({ ...args, marketProgramId: solana.marketProgramId }),
931
+ },
932
+ } : null,
933
+ };
934
+ }
935
+ //# sourceMappingURL=index.js.map