@compose-market/sdk 0.8.19 → 0.8.20

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 +17 -0
  2. package/dist/blockchain/index.d.ts +2038 -0
  3. package/dist/blockchain/index.d.ts.map +1 -0
  4. package/dist/blockchain/index.js +945 -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,945 @@
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
+ metadata(values = []) {
370
+ this.vec(values, (entry) => {
371
+ this.string(entry.key);
372
+ this.vecBytes(entry.value);
373
+ });
374
+ }
375
+ done() {
376
+ return new Uint8Array(this.chunks);
377
+ }
378
+ fixedBigInt(value, byteLength) {
379
+ let next = value;
380
+ for (let i = 0; i < byteLength; i += 1) {
381
+ this.u8(Number(next & 0xffn));
382
+ next >>= 8n;
383
+ }
384
+ }
385
+ }
386
+ class BorshReader {
387
+ data;
388
+ offset = 0;
389
+ constructor(data) {
390
+ this.data = data;
391
+ }
392
+ u8() { return this.data[this.offset++]; }
393
+ bool() { return this.u8() !== 0; }
394
+ u16() {
395
+ const value = this.data[this.offset] | (this.data[this.offset + 1] << 8);
396
+ this.offset += 2;
397
+ return value;
398
+ }
399
+ u32() {
400
+ const view = new DataView(this.data.buffer, this.data.byteOffset + this.offset, 4);
401
+ const value = view.getUint32(0, true);
402
+ this.offset += 4;
403
+ return value;
404
+ }
405
+ u64() { return this.fixedBigInt(8, false); }
406
+ i64() { return this.fixedBigInt(8, true); }
407
+ i128() { return this.fixedBigInt(16, true); }
408
+ bytes(length) {
409
+ const value = this.data.slice(this.offset, this.offset + length);
410
+ this.offset += length;
411
+ return value;
412
+ }
413
+ fixed32() { return this.bytes(32); }
414
+ pubkey() { return addressDecoder.decode(this.bytes(32)); }
415
+ string() { return textDecoder.decode(this.vecBytes()); }
416
+ vecBytes() { return this.bytes(this.u32()); }
417
+ vec(read) {
418
+ return Array.from({ length: this.u32() }, read);
419
+ }
420
+ metadata() {
421
+ return this.vec(() => ({ key: this.string(), value: this.vecBytes() }));
422
+ }
423
+ fixedBigInt(byteLength, signed) {
424
+ let value = 0n;
425
+ for (let i = 0; i < byteLength; i += 1) {
426
+ value |= BigInt(this.data[this.offset + i]) << BigInt(i * 8);
427
+ }
428
+ this.offset += byteLength;
429
+ return signed ? BigInt.asIntN(byteLength * 8, value) : value;
430
+ }
431
+ }
432
+ const textEncoder = new TextEncoder();
433
+ const textDecoder = new TextDecoder();
434
+ const addressEncoder = getAddressEncoder();
435
+ const addressDecoder = getAddressDecoder();
436
+ function addressBytes(value) {
437
+ return new Uint8Array(addressEncoder.encode(address(value)));
438
+ }
439
+ export function decodeLengthPrefixedAccount(data) {
440
+ const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
441
+ if (bytes.length < 4)
442
+ throw new Error("Account data is smaller than Manowar account header");
443
+ const len = new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0, true);
444
+ if (len === 0)
445
+ throw new Error("Manowar account is not initialized");
446
+ if (4 + len > bytes.length)
447
+ throw new Error("Manowar account payload length exceeds account data");
448
+ return bytes.slice(4, 4 + len);
449
+ }
450
+ function reader(data) {
451
+ return new BorshReader(decodeLengthPrefixedAccount(data));
452
+ }
453
+ export function decodeIdentityRegistryAccount(data) {
454
+ const r = reader(data);
455
+ return { version: r.u8(), admin: r.pubkey(), nextAgentId: r.u64(), totalAgents: r.u64(), consumers: r.vec(() => r.pubkey()) };
456
+ }
457
+ export function decodeAgentAccount(data) {
458
+ const r = reader(data);
459
+ return {
460
+ version: r.u8(),
461
+ agentId: r.u64(),
462
+ owner: r.pubkey(),
463
+ creator: r.pubkey(),
464
+ dnaHash: r.fixed32(),
465
+ licenses: r.u64(),
466
+ licensesMinted: r.u64(),
467
+ licensePrice: r.u64(),
468
+ creatorFee: r.u64(),
469
+ cloneable: r.bool(),
470
+ isClone: r.bool(),
471
+ parentAgentId: r.u64(),
472
+ agentWallet: r.pubkey(),
473
+ uri: r.string(),
474
+ metadata: r.metadata(),
475
+ };
476
+ }
477
+ export function decodeU64IndexAccount(data) {
478
+ const r = reader(data);
479
+ return { version: r.u8(), page: r.u32(), total: r.u64(), values: r.vec(() => r.u64()) };
480
+ }
481
+ export function decodePubkeyIndexAccount(data) {
482
+ const r = reader(data);
483
+ return { version: r.u8(), page: r.u32(), total: r.u64(), values: r.vec(() => r.pubkey()) };
484
+ }
485
+ export function decodeMarketRegistryAccount(data) {
486
+ const r = reader(data);
487
+ return {
488
+ version: r.u8(),
489
+ admin: r.pubkey(),
490
+ treasuryToken: r.pubkey(),
491
+ paymentMint: r.pubkey(),
492
+ nextWorkflowId: r.u64(),
493
+ nextRfaId: r.u64(),
494
+ nextLeaseId: r.u64(),
495
+ totalWorkflows: r.u64(),
496
+ totalEscrowed: r.u64(),
497
+ };
498
+ }
499
+ export function decodeWorkflowAccount(data) {
500
+ const r = reader(data);
501
+ return {
502
+ version: r.u8(),
503
+ workflowId: r.u64(),
504
+ owner: r.pubkey(),
505
+ creator: r.pubkey(),
506
+ title: r.string(),
507
+ description: r.string(),
508
+ banner: r.string(),
509
+ uri: r.string(),
510
+ totalPrice: r.u64(),
511
+ units: r.u64(),
512
+ unitsMinted: r.u64(),
513
+ leaseEnabled: r.bool(),
514
+ leaseDuration: r.u64(),
515
+ leasePercent: r.u8(),
516
+ hasCoordinator: r.bool(),
517
+ coordinatorModel: r.string(),
518
+ hasActiveRfa: r.bool(),
519
+ rfaId: r.u64(),
520
+ activeLeaseId: r.u64(),
521
+ agents: r.vec(() => r.u64()),
522
+ };
523
+ }
524
+ export function decodeRfaAccount(data) {
525
+ const r = reader(data);
526
+ const version = r.u8();
527
+ const rfaId = r.u64();
528
+ const workflowId = r.u64();
529
+ const title = r.string();
530
+ const description = r.string();
531
+ const requiredSkills = r.vec(() => r.fixed32());
532
+ const offerAmount = r.u64();
533
+ const publisher = r.pubkey();
534
+ const createdAt = r.i64();
535
+ const status = ["open", "fulfilled", "cancelled"][r.u8()];
536
+ if (!status)
537
+ throw new Error("Unknown RFA status");
538
+ return {
539
+ version,
540
+ rfaId,
541
+ workflowId,
542
+ title,
543
+ description,
544
+ requiredSkills,
545
+ offerAmount,
546
+ publisher,
547
+ createdAt,
548
+ status,
549
+ fulfilledByAgentId: r.u64(),
550
+ agentCreator: r.pubkey(),
551
+ };
552
+ }
553
+ export function decodeSubmissionAccount(data) {
554
+ const r = reader(data);
555
+ return { version: r.u8(), rfaId: r.u64(), agentId: r.u64(), creator: r.pubkey(), submittedAt: r.i64() };
556
+ }
557
+ export function decodeReputationRegistryAccount(data) {
558
+ const r = reader(data);
559
+ return { version: r.u8(), admin: r.pubkey(), identityRegistry: r.pubkey() };
560
+ }
561
+ export function decodeFeedbackAccount(data) {
562
+ const r = reader(data);
563
+ return {
564
+ version: r.u8(),
565
+ agentId: r.u64(),
566
+ client: r.pubkey(),
567
+ feedbackIndex: r.u64(),
568
+ value: r.i128(),
569
+ valueDecimals: r.u8(),
570
+ isRevoked: r.bool(),
571
+ tag1: r.string(),
572
+ tag2: r.string(),
573
+ endpoint: r.string(),
574
+ feedbackUri: r.string(),
575
+ feedbackHash: r.fixed32(),
576
+ createdAt: r.i64(),
577
+ };
578
+ }
579
+ export function decodeValidationRegistryAccount(data) {
580
+ const r = reader(data);
581
+ return { version: r.u8(), admin: r.pubkey(), nextRequestId: r.u64(), totalRequests: r.u64() };
582
+ }
583
+ export function decodeValidationRequestAccount(data) {
584
+ const r = reader(data);
585
+ return {
586
+ version: r.u8(),
587
+ requestId: r.u64(),
588
+ agentId: r.u64(),
589
+ requester: r.pubkey(),
590
+ validatorType: r.string(),
591
+ taskHash: r.fixed32(),
592
+ requestUri: r.string(),
593
+ timestamp: r.i64(),
594
+ closed: r.bool(),
595
+ responseCount: r.u64(),
596
+ };
597
+ }
598
+ // ---------------------------------------------------------------------------
599
+ // Solana PDA helpers and instruction builders
600
+ // ---------------------------------------------------------------------------
601
+ export const ManowarSeeds = {
602
+ REGISTRY: "registry",
603
+ AGENT: "agent",
604
+ DNA: "dna",
605
+ WARP: "warp",
606
+ FEEDBACK: "feedback",
607
+ FEEDBACK_INDEX: "feedback-index",
608
+ RESPONSE: "response",
609
+ REQUEST: "request",
610
+ WORKFLOW: "workflow",
611
+ LICENSE_INDEX: "license-index",
612
+ LICENSE_RECORD: "license-record",
613
+ RFA: "rfa",
614
+ RFA_INDEX: "rfa-index",
615
+ OPEN_RFA_INDEX: "open-rfa-index",
616
+ PUBLISHER_RFA_INDEX: "publisher-rfa-index",
617
+ SUBMISSION: "submission",
618
+ SUBMISSION_INDEX: "submission-index",
619
+ LEASE: "lease",
620
+ LEASE_INDEX: "lease-index",
621
+ ACTIVE_LEASE: "active-lease",
622
+ ROYALTY: "royalty",
623
+ DEFAULT_ROYALTY: "default-royalty",
624
+ CLONE_INDEX: "clone-index",
625
+ IDENTITY_STATS: "identity-stats",
626
+ WARP_AGENT: "warp-agent",
627
+ CREATOR_WORKFLOW_INDEX: "creator-workflow-index",
628
+ COMPLETE_WORKFLOW_INDEX: "complete-workflow-index",
629
+ RFA_WORKFLOW_INDEX: "rfa-workflow-index",
630
+ MARKET_AUTHORITY: "market-authority",
631
+ MARKET_CONFIG: "market-config",
632
+ REPUTATION_REGISTRY: "reputation-registry",
633
+ FEEDBACK_CLIENT_INDEX: "feedback-client-index",
634
+ RESPONSE_COUNTER: "response-counter",
635
+ VALIDATION_AGENT_INDEX: "validation-agent-index",
636
+ VALIDATION_RESPONSE_INDEX: "validation-response-index",
637
+ };
638
+ function seed(value) {
639
+ return textEncoder.encode(value);
640
+ }
641
+ export function u64Seed(value) {
642
+ const bytes = new Uint8Array(8);
643
+ new DataView(bytes.buffer).setBigUint64(0, BigInt(value), true);
644
+ return bytes;
645
+ }
646
+ export function bytes32FromHex(hex) {
647
+ const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
648
+ if (clean.length !== 64)
649
+ throw new Error(`Expected bytes32 hex, got ${hex}`);
650
+ const out = new Uint8Array(32);
651
+ for (let i = 0; i < 32; i += 1)
652
+ out[i] = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
653
+ return out;
654
+ }
655
+ export function hexFromBytes32(bytes) {
656
+ if (bytes.length !== 32)
657
+ throw new Error(`Expected bytes32, got ${bytes.length} bytes`);
658
+ return `0x${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
659
+ }
660
+ export async function findManowarPda(programId, seeds) {
661
+ const [pda] = await getProgramDerivedAddress({ programAddress: address(programId), seeds: [...seeds] });
662
+ return pda;
663
+ }
664
+ export const identityPdas = {
665
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REGISTRY)]),
666
+ agent: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.AGENT), u64Seed(agentId)]),
667
+ dna: (programId, dnaHash) => findManowarPda(programId, [seed(ManowarSeeds.DNA), dnaHash]),
668
+ cloneIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.CLONE_INDEX), u64Seed(agentId)]),
669
+ stats: (programId) => findManowarPda(programId, [seed(ManowarSeeds.IDENTITY_STATS)]),
670
+ warp: (programId, originalHash) => findManowarPda(programId, [seed(ManowarSeeds.WARP), originalHash]),
671
+ warpAgent: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.WARP_AGENT), u64Seed(agentId)]),
672
+ licenseIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.LICENSE_INDEX), u64Seed(agentId)]),
673
+ licenseRecord: (programId, agentId, workflowProgram, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.LICENSE_RECORD), u64Seed(agentId), addressBytes(workflowProgram), u64Seed(workflowId)]),
674
+ };
675
+ export const marketPdas = {
676
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REGISTRY)]),
677
+ config: (programId) => findManowarPda(programId, [seed(ManowarSeeds.MARKET_CONFIG)]),
678
+ authority: (programId) => findManowarPda(programId, [seed(ManowarSeeds.MARKET_AUTHORITY)]),
679
+ workflow: (programId, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.WORKFLOW), u64Seed(workflowId)]),
680
+ creatorWorkflowIndex: (programId, creator) => findManowarPda(programId, [seed(ManowarSeeds.CREATOR_WORKFLOW_INDEX), addressBytes(creator)]),
681
+ completeWorkflowIndex: (programId) => findManowarPda(programId, [seed(ManowarSeeds.COMPLETE_WORKFLOW_INDEX)]),
682
+ openRfaIndex: (programId) => findManowarPda(programId, [seed(ManowarSeeds.OPEN_RFA_INDEX)]),
683
+ rfaWorkflowIndex: (programId) => findManowarPda(programId, [seed(ManowarSeeds.RFA_WORKFLOW_INDEX)]),
684
+ workflowRfaIndex: (programId, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.RFA_INDEX), u64Seed(workflowId)]),
685
+ publisherRfaIndex: (programId, publisher) => findManowarPda(programId, [seed(ManowarSeeds.PUBLISHER_RFA_INDEX), addressBytes(publisher)]),
686
+ rfa: (programId, rfaId) => findManowarPda(programId, [seed(ManowarSeeds.RFA), u64Seed(rfaId)]),
687
+ submission: (programId, rfaId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.SUBMISSION), u64Seed(rfaId), u64Seed(agentId)]),
688
+ submissionIndex: (programId, rfaId) => findManowarPda(programId, [seed(ManowarSeeds.SUBMISSION_INDEX), u64Seed(rfaId)]),
689
+ lease: (programId, leaseId) => findManowarPda(programId, [seed(ManowarSeeds.LEASE), u64Seed(leaseId)]),
690
+ leaseIndex: (programId, leaser) => findManowarPda(programId, [seed(ManowarSeeds.LEASE_INDEX), addressBytes(leaser)]),
691
+ activeLease: (programId, workflowId) => findManowarPda(programId, [seed(ManowarSeeds.ACTIVE_LEASE), u64Seed(workflowId)]),
692
+ royalty: (programId, tokenId) => findManowarPda(programId, [seed(ManowarSeeds.ROYALTY), u64Seed(tokenId)]),
693
+ defaultRoyalty: (programId) => findManowarPda(programId, [seed(ManowarSeeds.DEFAULT_ROYALTY)]),
694
+ };
695
+ export const reputationPdas = {
696
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REPUTATION_REGISTRY)]),
697
+ feedbackClientIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.FEEDBACK_CLIENT_INDEX), u64Seed(agentId)]),
698
+ feedbackIndex: (programId, agentId, client) => findManowarPda(programId, [seed(ManowarSeeds.FEEDBACK_INDEX), u64Seed(agentId), addressBytes(client)]),
699
+ feedback: (programId, agentId, client, feedbackIndex) => findManowarPda(programId, [seed(ManowarSeeds.FEEDBACK), u64Seed(agentId), addressBytes(client), u64Seed(feedbackIndex)]),
700
+ responseCounter: (programId, agentId, client, feedbackIndex, responder) => findManowarPda(programId, [seed(ManowarSeeds.RESPONSE_COUNTER), u64Seed(agentId), addressBytes(client), u64Seed(feedbackIndex), addressBytes(responder)]),
701
+ };
702
+ export const validationPdas = {
703
+ registry: (programId) => findManowarPda(programId, [seed(ManowarSeeds.REGISTRY)]),
704
+ request: (programId, requestId) => findManowarPda(programId, [seed(ManowarSeeds.REQUEST), u64Seed(requestId)]),
705
+ requestIndex: (programId, agentId) => findManowarPda(programId, [seed(ManowarSeeds.VALIDATION_AGENT_INDEX), u64Seed(agentId)]),
706
+ response: (programId, requestId, responseId) => findManowarPda(programId, [seed(ManowarSeeds.RESPONSE), u64Seed(requestId), u64Seed(responseId)]),
707
+ responseIndex: (programId, requestId) => findManowarPda(programId, [seed(ManowarSeeds.VALIDATION_RESPONSE_INDEX), u64Seed(requestId)]),
708
+ };
709
+ function ix(programAddress, accounts, data) {
710
+ return { programAddress: address(programAddress), accounts, data };
711
+ }
712
+ export function encodeIdentityInstruction(instruction) {
713
+ const w = new BorshWriter();
714
+ switch (instruction.type) {
715
+ case "initialize":
716
+ w.u8(0);
717
+ break;
718
+ case "mint":
719
+ w.u8(2);
720
+ w.fixed32(instruction.dnaHash);
721
+ w.u64(instruction.licenses);
722
+ w.u64(instruction.licensePrice);
723
+ w.u64(instruction.creatorFee);
724
+ w.bool(instruction.cloneable);
725
+ w.string(instruction.uri);
726
+ w.metadata(instruction.metadata);
727
+ break;
728
+ case "warp":
729
+ w.u8(4);
730
+ w.fixed32(instruction.originalHash);
731
+ w.pubkey(instruction.originalCreator);
732
+ w.u64(instruction.licenses);
733
+ w.u64(instruction.licensePrice);
734
+ w.string(instruction.uri);
735
+ w.metadata(instruction.metadata);
736
+ break;
737
+ case "consumeLicense":
738
+ case "revokeLicense":
739
+ w.u8(instruction.type === "consumeLicense" ? 14 : 15);
740
+ w.u64(instruction.agentId);
741
+ w.pubkey(instruction.workflow);
742
+ w.u64(instruction.workflowId);
743
+ break;
744
+ }
745
+ return w.done();
746
+ }
747
+ export async function buildIdentityMintInstruction(input) {
748
+ const registry = await identityPdas.registry(input.programId);
749
+ const agentPda = await identityPdas.agent(input.programId, input.nextAgentId);
750
+ const dna = await identityPdas.dna(input.programId, input.dnaHash);
751
+ return {
752
+ agent: agentPda,
753
+ dna,
754
+ instruction: ix(input.programId, [
755
+ { address: registry, role: AccountRole.WRITABLE },
756
+ { address: agentPda, role: AccountRole.WRITABLE },
757
+ { address: dna, role: AccountRole.WRITABLE },
758
+ { address: address(input.owner), role: AccountRole.WRITABLE_SIGNER },
759
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
760
+ ], encodeIdentityInstruction({
761
+ type: "mint",
762
+ dnaHash: input.dnaHash,
763
+ licenses: input.licenses,
764
+ licensePrice: input.licensePrice,
765
+ creatorFee: input.creatorFee ?? 1,
766
+ cloneable: input.cloneable,
767
+ uri: input.uri,
768
+ metadata: input.metadata,
769
+ })),
770
+ };
771
+ }
772
+ export async function buildIdentityWarpInstruction(input) {
773
+ const registry = await identityPdas.registry(input.programId);
774
+ const agentPda = await identityPdas.agent(input.programId, input.nextAgentId);
775
+ const dna = await identityPdas.dna(input.programId, input.originalHash);
776
+ const warp = await identityPdas.warp(input.programId, input.originalHash);
777
+ const warpAgent = await identityPdas.warpAgent(input.programId, input.nextAgentId);
778
+ return {
779
+ agent: agentPda,
780
+ dna,
781
+ warp,
782
+ warpAgent,
783
+ instruction: ix(input.programId, [
784
+ { address: registry, role: AccountRole.WRITABLE },
785
+ { address: agentPda, role: AccountRole.WRITABLE },
786
+ { address: dna, role: AccountRole.WRITABLE },
787
+ { address: warp, role: AccountRole.WRITABLE },
788
+ { address: warpAgent, role: AccountRole.WRITABLE },
789
+ { address: await identityPdas.stats(input.programId), role: AccountRole.WRITABLE },
790
+ { address: address(input.warper), role: AccountRole.WRITABLE_SIGNER },
791
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
792
+ ], encodeIdentityInstruction({
793
+ type: "warp",
794
+ originalHash: input.originalHash,
795
+ originalCreator: input.originalCreator,
796
+ licenses: input.licenses,
797
+ licensePrice: input.licensePrice,
798
+ uri: input.uri,
799
+ metadata: input.metadata,
800
+ })),
801
+ };
802
+ }
803
+ export function encodeMarketInstruction(instruction) {
804
+ const w = new BorshWriter();
805
+ switch (instruction.type) {
806
+ case "mintWorkflow":
807
+ w.u8(7);
808
+ w.string(instruction.title);
809
+ w.string(instruction.description);
810
+ w.string(instruction.banner);
811
+ w.string(instruction.uri);
812
+ w.u64(instruction.units);
813
+ w.bool(instruction.leaseEnabled);
814
+ w.u64(instruction.leaseDuration);
815
+ w.u8(instruction.leasePercent);
816
+ w.bool(instruction.hasCoordinator);
817
+ w.string(instruction.coordinatorModel);
818
+ break;
819
+ case "createRfa":
820
+ w.u8(16);
821
+ w.u64(instruction.workflowId);
822
+ w.string(instruction.title);
823
+ w.string(instruction.description);
824
+ w.vec(instruction.requiredSkills, (skill) => w.fixed32(skill));
825
+ w.u64(instruction.offerAmount);
826
+ break;
827
+ case "submitAgent":
828
+ case "acceptAgent":
829
+ w.u8(instruction.type === "submitAgent" ? 17 : 18);
830
+ w.u64(instruction.rfaId);
831
+ w.u64(instruction.agentId);
832
+ break;
833
+ case "cancelRfa":
834
+ w.u8(19);
835
+ w.u64(instruction.rfaId);
836
+ break;
837
+ }
838
+ return w.done();
839
+ }
840
+ export async function buildMarketMintWorkflowInstruction(input) {
841
+ const workflow = await marketPdas.workflow(input.marketProgramId, input.nextWorkflowId);
842
+ const identityRegistry = await identityPdas.registry(input.identityProgramId);
843
+ const marketAuthority = await marketPdas.authority(input.marketProgramId);
844
+ const accounts = [
845
+ { address: await marketPdas.registry(input.marketProgramId), role: AccountRole.WRITABLE },
846
+ { address: workflow, role: AccountRole.WRITABLE },
847
+ { address: await marketPdas.creatorWorkflowIndex(input.marketProgramId, input.owner), role: AccountRole.WRITABLE },
848
+ { address: await marketPdas.completeWorkflowIndex(input.marketProgramId), role: AccountRole.WRITABLE },
849
+ { address: address(input.owner), role: AccountRole.WRITABLE_SIGNER },
850
+ { address: address(input.identityProgramId), role: AccountRole.READONLY },
851
+ { address: identityRegistry, role: AccountRole.WRITABLE },
852
+ { address: marketAuthority, role: AccountRole.READONLY_SIGNER },
853
+ { address: address(input.tokenProgram), role: AccountRole.READONLY },
854
+ { address: address(input.payerToken), role: AccountRole.WRITABLE },
855
+ { address: address(input.treasuryToken), role: AccountRole.WRITABLE },
856
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
857
+ ];
858
+ for (const agent of input.agents ?? []) {
859
+ 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 });
860
+ }
861
+ return {
862
+ workflow,
863
+ instruction: ix(input.marketProgramId, accounts, encodeMarketInstruction({
864
+ type: "mintWorkflow",
865
+ title: input.title,
866
+ description: input.description,
867
+ banner: input.banner,
868
+ uri: input.uri,
869
+ units: input.units,
870
+ leaseEnabled: input.leaseEnabled,
871
+ leaseDuration: input.leaseDuration,
872
+ leasePercent: input.leasePercent,
873
+ hasCoordinator: input.hasCoordinator,
874
+ coordinatorModel: input.coordinatorModel,
875
+ })),
876
+ };
877
+ }
878
+ export async function buildMarketCreateRfaInstruction(input) {
879
+ const rfa = await marketPdas.rfa(input.marketProgramId, input.nextRfaId);
880
+ return {
881
+ rfa,
882
+ instruction: ix(input.marketProgramId, [
883
+ { address: await marketPdas.registry(input.marketProgramId), role: AccountRole.WRITABLE },
884
+ { address: rfa, role: AccountRole.WRITABLE },
885
+ { address: await marketPdas.workflow(input.marketProgramId, input.workflowId), role: AccountRole.WRITABLE },
886
+ { address: await marketPdas.openRfaIndex(input.marketProgramId), role: AccountRole.WRITABLE },
887
+ { address: await marketPdas.workflowRfaIndex(input.marketProgramId, input.workflowId), role: AccountRole.WRITABLE },
888
+ { address: await marketPdas.publisherRfaIndex(input.marketProgramId, input.publisher), role: AccountRole.WRITABLE },
889
+ { address: await marketPdas.completeWorkflowIndex(input.marketProgramId), role: AccountRole.WRITABLE },
890
+ { address: await marketPdas.rfaWorkflowIndex(input.marketProgramId), role: AccountRole.WRITABLE },
891
+ { address: address(input.publisher), role: AccountRole.WRITABLE_SIGNER },
892
+ { address: address(input.tokenProgram), role: AccountRole.READONLY },
893
+ { address: address(input.publisherToken), role: AccountRole.WRITABLE },
894
+ { address: address(input.escrowToken), role: AccountRole.WRITABLE },
895
+ { address: SYSTEM_PROGRAM_ADDRESS, role: AccountRole.READONLY },
896
+ ], encodeMarketInstruction({
897
+ type: "createRfa",
898
+ workflowId: input.workflowId,
899
+ title: input.title,
900
+ description: input.description,
901
+ requiredSkills: input.requiredSkills,
902
+ offerAmount: input.offerAmount,
903
+ })),
904
+ };
905
+ }
906
+ export function computeDnaHash(skills, networkOrChain, model) {
907
+ const sortedSkills = [...skills].sort();
908
+ const skillsValue = sortedSkills.join(",");
909
+ if (typeof networkOrChain === "number") {
910
+ return keccak256(encodePacked(["string", "uint256", "string"], [skillsValue, BigInt(networkOrChain), model]));
911
+ }
912
+ return keccak256(encodePacked(["string", "string", "string"], [skillsValue, networkOrChain, model]));
913
+ }
914
+ export function computeExternalAgentHash(registry, agentAddress) {
915
+ return keccak256(encodePacked(["string", "string"], [registry, agentAddress]));
916
+ }
917
+ export function encodeSkillAsBytes32(skill) {
918
+ return keccak256(encodePacked(["string"], [skill.toLowerCase()]));
919
+ }
920
+ export function createManowarBlockchainClient(input) {
921
+ const { network, deployment } = input;
922
+ const solana = deployment.solana;
923
+ return {
924
+ network,
925
+ deployment,
926
+ evm: {
927
+ mintAgent: (args) => buildEvmMintAgentOperation(network, deployment, args),
928
+ warpAgent: (args) => buildEvmWarpAgentOperation(network, deployment, args),
929
+ mintWorkflow: (args) => buildEvmMintWorkflowOperation(network, deployment, args),
930
+ createRfa: (args) => buildEvmCreateRfaOperation(network, deployment, args),
931
+ },
932
+ solana: solana ? {
933
+ pdas: { identity: identityPdas, market: marketPdas, reputation: reputationPdas, validation: validationPdas },
934
+ identity: {
935
+ mint: (args) => buildIdentityMintInstruction({ ...args, programId: solana.identityProgramId }),
936
+ warp: (args) => buildIdentityWarpInstruction({ ...args, programId: solana.identityProgramId }),
937
+ },
938
+ market: {
939
+ mintWorkflow: (args) => buildMarketMintWorkflowInstruction({ ...args, marketProgramId: solana.marketProgramId, identityProgramId: solana.identityProgramId }),
940
+ createRfa: (args) => buildMarketCreateRfaInstruction({ ...args, marketProgramId: solana.marketProgramId }),
941
+ },
942
+ } : null,
943
+ };
944
+ }
945
+ //# sourceMappingURL=index.js.map