@swarm-tips/client 0.4.7 → 0.4.9

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.
@@ -5,13 +5,21 @@ export type { Action } from "./index.js";
5
5
  export interface PreparedTransactionResponse {
6
6
  message?: string;
7
7
  task_id?: string;
8
- transaction: string;
8
+ transaction?: string;
9
9
  task_pda?: string;
10
10
  transaction_intent?: TransactionIntent;
11
11
  evm_call?: unknown;
12
12
  payout_to?: string;
13
13
  advance_backer?: string;
14
+ attempt_id?: string;
15
+ open_competition?: boolean;
16
+ status?: string;
17
+ onboarded_advance_tx?: string | null;
18
+ required_payout_to?: string | null;
19
+ co_signed_transaction?: string | null;
14
20
  }
21
+ export type SubmitTaskResponse = PreparedTransactionResponse;
22
+ export type BuildVerifyResponse = PreparedTransactionResponse;
15
23
  export interface VerificationDataResponse {
16
24
  task_id?: string;
17
25
  task_pda: string;
@@ -19,23 +27,181 @@ export interface VerificationDataResponse {
19
27
  verification_hash: string;
20
28
  global_state?: string;
21
29
  switchboard_feed: string;
22
- required_payout_to?: string;
23
- advance_backer?: string;
30
+ required_payout_to?: string | null;
31
+ advance_backer?: string | null;
24
32
  verification_kind?: number;
25
- co_signed_transaction?: string;
33
+ co_signed_transaction?: string | null;
26
34
  evm_verify_call?: unknown;
35
+ attempt_id?: string;
36
+ onboarded_advance_tx?: string | null;
27
37
  }
28
38
  export interface BuildVerifyOptions {
29
39
  payer?: string;
30
40
  mcpBaseUrl?: string;
31
41
  network?: "mainnet" | "devnet";
42
+ attemptId?: string;
32
43
  }
33
44
  export interface ConfirmTransactionRequest {
34
45
  tx_signature: string;
35
46
  action: Action;
36
47
  task_pda?: string;
37
48
  }
38
- export interface TaskListResponse<TTask = unknown> {
49
+ export interface LeanEnvironmentInfo {
50
+ lean_policy: number;
51
+ lean_toolchain: string;
52
+ mode: string;
53
+ mathlib_rev?: string | null;
54
+ zeta23_rev?: string | null;
55
+ swarm_proofs_rev?: string | null;
56
+ environment_id?: string | null;
57
+ import_allowlist: string[];
58
+ allows_disproof: boolean;
59
+ max_proof_lines?: number | null;
60
+ max_proof_bytes?: number | null;
61
+ max_line_width?: number | null;
62
+ }
63
+ export interface TaskAttemptSummary {
64
+ attempt_id: string;
65
+ task_id?: string;
66
+ agent?: string;
67
+ status: string;
68
+ score?: number | null;
69
+ check_detail?: string | null;
70
+ content_id?: string | null;
71
+ artifact_hash?: string | null;
72
+ submitted_at_unix?: number | null;
73
+ verified_at?: string | null;
74
+ updated_at?: string | null;
75
+ }
76
+ export interface TaskResponse {
77
+ task_id: string;
78
+ campaign_id?: string;
79
+ campaign_topic?: string;
80
+ state: string;
81
+ platform?: number;
82
+ estimated_payment_lamports?: number;
83
+ quality_threshold?: number;
84
+ created_at?: string;
85
+ submitted_at?: string | null;
86
+ claimed_at?: string | null;
87
+ approved_at?: string | null;
88
+ agent?: string | null;
89
+ client?: string | null;
90
+ task_pda?: string | null;
91
+ content_id?: string | null;
92
+ composite_score?: number | null;
93
+ payment_amount?: number | null;
94
+ requires_approval?: boolean;
95
+ chain?: string;
96
+ statement_lean?: string | null;
97
+ lean_policy?: number | null;
98
+ lean_environment?: LeanEnvironmentInfo | null;
99
+ check_detail?: string | null;
100
+ competing_attempts_count?: number | null;
101
+ my_latest_attempt?: TaskAttemptSummary | null;
102
+ brief?: unknown;
103
+ [key: string]: unknown;
104
+ }
105
+ export interface LeanDiagnostic {
106
+ file: string;
107
+ line: number;
108
+ column: number;
109
+ severity: "error" | "warning" | "info" | string;
110
+ message: string;
111
+ }
112
+ export interface ProofMetrics {
113
+ code_lines: number;
114
+ total_lines: number;
115
+ code_bytes: number;
116
+ raw_bytes: number;
117
+ max_line_width: number;
118
+ }
119
+ export interface ProofLimits {
120
+ max_proof_lines?: number | null;
121
+ max_proof_bytes?: number | null;
122
+ max_line_width?: number | null;
123
+ }
124
+ export interface PreflightTaskRequest {
125
+ proof_lean?: string;
126
+ compile?: boolean;
127
+ content_id?: string;
128
+ agent_wallet?: string;
129
+ }
130
+ export interface PreflightTaskResponse {
131
+ ok: boolean;
132
+ task_id: string;
133
+ lean_policy?: number;
134
+ detail: string;
135
+ status?: string | null;
136
+ compiled?: boolean;
137
+ verdict?: string | null;
138
+ axioms?: string[] | null;
139
+ diagnostics?: LeanDiagnostic[] | null;
140
+ metrics?: ProofMetrics | null;
141
+ limits?: ProofLimits | null;
142
+ lean_environment?: LeanEnvironmentInfo | null;
143
+ }
144
+ export interface SubmitTaskRequest {
145
+ content_id?: string;
146
+ proof_lean?: string;
147
+ agent_harness?: string;
148
+ model_family?: string;
149
+ [key: string]: unknown;
150
+ }
151
+ export interface VerifiedProofRecord {
152
+ task_id: string;
153
+ campaign_id?: string | null;
154
+ topic?: string | null;
155
+ task_pda?: string | null;
156
+ network?: string;
157
+ lean_policy: number;
158
+ solver_wallet: string;
159
+ agent_harness?: string | null;
160
+ model_family?: string | null;
161
+ reward_lamports?: number | null;
162
+ payment_amount?: number | null;
163
+ composite_score?: number | null;
164
+ artifact_sha256?: string | null;
165
+ statement_sha256?: string | null;
166
+ verification_hash?: string | null;
167
+ proof_url?: string | null;
168
+ statement_url?: string | null;
169
+ code_lines?: number | null;
170
+ code_bytes?: number | null;
171
+ metrics?: ProofMetrics | null;
172
+ verified_at?: string | null;
173
+ finalized_at?: string | null;
174
+ [key: string]: unknown;
175
+ }
176
+ export interface ProofsLeaderboardEntry {
177
+ key: string;
178
+ label?: string | null;
179
+ wallet?: string | null;
180
+ model_family?: string | null;
181
+ agent_harness?: string | null;
182
+ proofs_solved: number;
183
+ total_lamports: number;
184
+ median_code_lines?: number | null;
185
+ shortest_code_lines?: number | null;
186
+ [key: string]: unknown;
187
+ }
188
+ export interface ProofsResponse {
189
+ network?: string;
190
+ proofs: VerifiedProofRecord[];
191
+ total?: number;
192
+ leaderboard?: {
193
+ by_wallet?: ProofsLeaderboardEntry[];
194
+ by_model?: ProofsLeaderboardEntry[];
195
+ by_harness?: ProofsLeaderboardEntry[];
196
+ };
197
+ [key: string]: unknown;
198
+ }
199
+ export interface ListProofsOptions {
200
+ network?: "mainnet" | "devnet";
201
+ limit?: number;
202
+ policy?: number;
203
+ }
204
+ export interface TaskListResponse<TTask = TaskResponse> {
39
205
  tasks: TTask[];
40
206
  next_cursor?: string | null;
41
207
  }
@@ -72,11 +238,15 @@ export declare class ShillbotApiClient {
72
238
  action: "claim" | "submit";
73
239
  unsigned_transaction: string;
74
240
  }): Promise<PreparedTransactionResponse>;
75
- submitTask(id: string, body: unknown): Promise<PreparedTransactionResponse>;
76
- preflightTask<TResponse = unknown>(id: string, body?: unknown): Promise<TResponse>;
241
+ submitTask(id: string, body: SubmitTaskRequest | Record<string, unknown>): Promise<PreparedTransactionResponse>;
242
+ preflightTask<TResponse = PreflightTaskResponse>(taskId: string, body?: PreflightTaskRequest | Record<string, unknown>, opts?: {
243
+ network?: "mainnet" | "devnet";
244
+ token?: string | null;
245
+ }): Promise<TResponse>;
246
+ listProofs<TResponse = ProofsResponse>(opts?: ListProofsOptions): Promise<TResponse>;
77
247
  approveTask(id: string): Promise<PreparedTransactionResponse>;
78
- getVerificationData(id: string, network?: "mainnet" | "devnet"): Promise<VerificationDataResponse>;
79
- buildVerify(id: string, opts?: BuildVerifyOptions): Promise<PreparedTransactionResponse>;
248
+ getVerificationData(id: string, network?: "mainnet" | "devnet", attemptId?: string): Promise<VerificationDataResponse>;
249
+ buildVerify(id: string, optsOrAttemptId?: BuildVerifyOptions | string): Promise<BuildVerifyResponse>;
80
250
  buildFinalize(id: string): Promise<PreparedTransactionResponse>;
81
251
  buildExpire(id: string): Promise<PreparedTransactionResponse>;
82
252
  confirmTask<TResponse = unknown>(id: string, body: ConfirmTransactionRequest): Promise<TResponse>;
@@ -99,21 +99,54 @@ export class ShillbotApiClient {
99
99
  submitTask(id, body) {
100
100
  return this.post(`/tasks/${encodeURIComponent(id)}/submit`, body);
101
101
  }
102
- preflightTask(id, body) {
103
- return this.post(`/tasks/${encodeURIComponent(id)}/preflight`, body);
102
+ preflightTask(taskId, body, opts) {
103
+ const trimmed = taskId.trim();
104
+ if (!trimmed) {
105
+ throw new SwarmClientError({
106
+ code: "INVALID_ARGUMENT",
107
+ operation: "shillbot.preflightTask",
108
+ message: "Task id is required",
109
+ });
110
+ }
111
+ const suffix = opts?.network ? `?network=${encodeURIComponent(opts.network)}` : "";
112
+ return this.http.post(`/tasks/${encodeURIComponent(trimmed)}/preflight${suffix}`, body ?? {}, opts?.token);
113
+ }
114
+ listProofs(opts) {
115
+ const params = new URLSearchParams();
116
+ if (opts?.network)
117
+ params.set("network", opts.network);
118
+ if (opts?.limit !== undefined)
119
+ params.set("limit", String(opts.limit));
120
+ if (opts?.policy !== undefined)
121
+ params.set("policy", String(opts.policy));
122
+ const qs = params.toString();
123
+ const path = qs ? `/proofs?${qs}` : "/proofs";
124
+ return this.http.get(path, null);
104
125
  }
105
126
  approveTask(id) {
106
127
  return this.post(`/tasks/${encodeURIComponent(id)}/approve`);
107
128
  }
108
- getVerificationData(id, network) {
109
- const suffix = network && network !== "mainnet" ? `?network=${encodeURIComponent(network)}` : "";
129
+ getVerificationData(id, network, attemptId) {
130
+ const params = [];
131
+ if (network && network !== "mainnet") {
132
+ params.push(`network=${encodeURIComponent(network)}`);
133
+ }
134
+ const trimmedAttempt = attemptId?.trim();
135
+ if (trimmedAttempt) {
136
+ params.push(`attempt_id=${encodeURIComponent(trimmedAttempt)}`);
137
+ }
138
+ const suffix = params.length > 0 ? `?${params.join("&")}` : "";
110
139
  return this.post(`/tasks/${encodeURIComponent(id)}/build-verify${suffix}`);
111
140
  }
112
- async buildVerify(id, opts) {
141
+ async buildVerify(id, optsOrAttemptId) {
142
+ const opts = typeof optsOrAttemptId === "string"
143
+ ? { attemptId: optsOrAttemptId }
144
+ : optsOrAttemptId;
113
145
  const mcpBaseUrl = (opts?.mcpBaseUrl ?? "https://mcp.swarm.tips").replace(/\/$/, "");
114
146
  const resolvedNetwork = opts?.network ?? (this.http.network === "devnet" ? "devnet" : "mainnet");
115
147
  const token = await this.http.getToken?.();
116
148
  const payer = opts?.payer ?? decodeJwtWallet(token);
149
+ const attemptId = opts?.attemptId?.trim() || undefined;
117
150
  const postMcpBuildVerify = async (payload) => {
118
151
  const mcpHttp = new HttpClient({
119
152
  baseUrl: mcpBaseUrl,
@@ -122,6 +155,59 @@ export class ShillbotApiClient {
122
155
  });
123
156
  return mcpHttp.post("/internal/build-verify-tx", payload);
124
157
  };
158
+ const normalizePrepared = (raw, fallbackTaskPda) => {
159
+ const resolvedTx = raw.transaction || raw.co_signed_transaction || "";
160
+ const resolvedPayoutTo = raw.payout_to ?? raw.required_payout_to ?? undefined;
161
+ return {
162
+ ...raw,
163
+ task_id: raw.task_id ?? id,
164
+ transaction: resolvedTx,
165
+ task_pda: raw.task_pda ?? fallbackTaskPda,
166
+ transaction_intent: raw.transaction_intent,
167
+ ...(resolvedPayoutTo ? { payout_to: resolvedPayoutTo } : {}),
168
+ };
169
+ };
170
+ const formatVerificationData = (vdata) => ({
171
+ task_id: vdata.task_id ?? id,
172
+ transaction: vdata.co_signed_transaction ?? "",
173
+ task_pda: vdata.task_pda,
174
+ ...(vdata.evm_verify_call !== undefined ? { evm_call: vdata.evm_verify_call } : {}),
175
+ ...(vdata.required_payout_to
176
+ ? {
177
+ payout_to: vdata.required_payout_to,
178
+ required_payout_to: vdata.required_payout_to,
179
+ }
180
+ : {}),
181
+ ...(vdata.advance_backer ? { advance_backer: vdata.advance_backer } : {}),
182
+ ...(vdata.co_signed_transaction
183
+ ? { co_signed_transaction: vdata.co_signed_transaction }
184
+ : {}),
185
+ ...(vdata.attempt_id ? { attempt_id: vdata.attempt_id } : {}),
186
+ ...(vdata.onboarded_advance_tx !== undefined
187
+ ? { onboarded_advance_tx: vdata.onboarded_advance_tx }
188
+ : {}),
189
+ });
190
+ // When targeting a specific M2 Open-Competition attemptId, call shillbot-api
191
+ // `POST /tasks/:id/build-verify?attempt_id=...` directly (returns `co_signed_transaction`
192
+ // + proof-gated `onboarded_advance_tx` + `required_payout_to` in 1 hop).
193
+ if (attemptId) {
194
+ const vdata = await this.getVerificationData(id, resolvedNetwork, attemptId);
195
+ if (vdata.evm_verify_call || vdata.co_signed_transaction) {
196
+ return formatVerificationData(vdata);
197
+ }
198
+ const fallback = await postMcpBuildVerify({
199
+ task_id: id,
200
+ ...(payer ? { payer } : {}),
201
+ network: resolvedNetwork,
202
+ attempt_id: attemptId,
203
+ task_pda: vdata.task_pda,
204
+ score: vdata.composite_score,
205
+ hash: vdata.verification_hash,
206
+ feed: vdata.switchboard_feed,
207
+ ...(vdata.global_state ? { global_state: vdata.global_state } : {}),
208
+ });
209
+ return normalizePrepared(fallback, vdata.task_pda);
210
+ }
125
211
  const oneHopBody = {
126
212
  task_id: id,
127
213
  network: resolvedNetwork,
@@ -129,13 +215,7 @@ export class ShillbotApiClient {
129
215
  };
130
216
  try {
131
217
  const direct = await postMcpBuildVerify(oneHopBody);
132
- return {
133
- ...direct,
134
- task_id: direct.task_id ?? id,
135
- transaction: direct.transaction,
136
- task_pda: direct.task_pda,
137
- transaction_intent: direct.transaction_intent,
138
- };
218
+ return normalizePrepared(direct);
139
219
  }
140
220
  catch (err) {
141
221
  if (!(err instanceof SwarmClientError) ||
@@ -145,14 +225,7 @@ export class ShillbotApiClient {
145
225
  }
146
226
  const vdata = await this.getVerificationData(id, resolvedNetwork);
147
227
  if (vdata.evm_verify_call || vdata.co_signed_transaction) {
148
- return {
149
- task_id: vdata.task_id ?? id,
150
- transaction: vdata.co_signed_transaction ?? "",
151
- task_pda: vdata.task_pda,
152
- ...(vdata.evm_verify_call !== undefined ? { evm_call: vdata.evm_verify_call } : {}),
153
- ...(vdata.required_payout_to ? { payout_to: vdata.required_payout_to } : {}),
154
- ...(vdata.advance_backer ? { advance_backer: vdata.advance_backer } : {}),
155
- };
228
+ return formatVerificationData(vdata);
156
229
  }
157
230
  const fallback = await postMcpBuildVerify({
158
231
  task_id: id,
@@ -164,13 +237,7 @@ export class ShillbotApiClient {
164
237
  feed: vdata.switchboard_feed,
165
238
  ...(vdata.global_state ? { global_state: vdata.global_state } : {}),
166
239
  });
167
- return {
168
- ...fallback,
169
- task_id: fallback.task_id ?? id,
170
- transaction: fallback.transaction,
171
- task_pda: fallback.task_pda ?? vdata.task_pda,
172
- transaction_intent: fallback.transaction_intent,
173
- };
240
+ return normalizePrepared(fallback, vdata.task_pda);
174
241
  }
175
242
  }
176
243
  buildFinalize(id) {
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from "buffer";
2
- import { ComputeBudgetProgram, PublicKey, Secp256k1Program } from "@solana/web3.js";
2
+ import { ComputeBudgetProgram, PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, Secp256k1Program, } from "@solana/web3.js";
3
3
  import { SHILLBOT_PROGRAM_ID, shillbotInstructionDiscriminator } from "../contracts/index.js";
4
4
  import { SwarmClientError, TransactionMismatchError } from "../errors.js";
5
5
  import { EXTENSION_CREDIT_PROGRAM_ID, advancePda, inspectTransaction, routeAndRecoupDiscriminator, } from "./index.js";
@@ -9,6 +9,8 @@ export const deriveAdvancePda = advancePda;
9
9
  export const MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 100000n;
10
10
  /** Solana runtime ceiling for `ComputeBudget::SetComputeUnitLimit` (`1_400_000` CUs). */
11
11
  export const MAX_COMPUTE_UNIT_LIMIT = 1_400_000;
12
+ /** Full passing composite score (`1_000_000`) required on M2 Open-Competition 1-tx verify bundles. */
13
+ const MAX_VERIFY_SCORE = 1000000n;
12
14
  const MIN_HEAP_FRAME_BYTES = 32 * 1024;
13
15
  const MAX_HEAP_FRAME_BYTES = 256 * 1024;
14
16
  const SWITCHBOARD_PROGRAM_IDS = {
@@ -707,6 +709,112 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
707
709
  validateSetPayoutToInstruction(companions[0], expected.wallet, primary.ix.accounts[0], expectedPayoutPubkey, operation);
708
710
  return inspected;
709
711
  }
712
+ // M2 Open-Competition 1-tx verify bundle:
713
+ // `[ComputeBudget?, claim_task(sysvar), set_payout_to?, submit_work, verify_task_attested(MAX_SCORE)]`
714
+ const isM2VerifyNoPayout = isVerifyLifecycle &&
715
+ primary.spec.name === "verify_task_attested" &&
716
+ companions.length === 2 &&
717
+ companions[0].spec.name === "claim_task" &&
718
+ companions[1].spec.name === "submit_work";
719
+ const isM2VerifyWithPayout = isVerifyLifecycle &&
720
+ primary.spec.name === "verify_task_attested" &&
721
+ companions.length === 3 &&
722
+ companions[0].spec.name === "claim_task" &&
723
+ companions[1].spec.name === "set_payout_to" &&
724
+ companions[2].spec.name === "submit_work";
725
+ if (isM2VerifyNoPayout || isM2VerifyWithPayout) {
726
+ const disallowedInM2 = new Set([
727
+ SWITCHBOARD_PROGRAM_IDS[expected.network],
728
+ Secp256k1Program.programId.toBase58(),
729
+ ]);
730
+ for (const extraAllowed of expected.allowedProgramIds ?? []) {
731
+ disallowedInM2.delete(extraAllowed);
732
+ }
733
+ const unexpectedProgramInM2 = inspected.instructions.find((ix) => disallowedInM2.has(ix.program_id));
734
+ if (unexpectedProgramInM2) {
735
+ throw txMismatch(operation, `Unexpected program ${unexpectedProgramInM2.program_id} in M2 verify bundle`);
736
+ }
737
+ if (inspected.fee_payer !== expected.wallet) {
738
+ throw txMismatch(operation, `M2 verify bundle requires fee_payer ${expected.wallet}, got ${inspected.fee_payer}`);
739
+ }
740
+ if (primary.ix.accounts[2] === inspected.fee_payer) {
741
+ throw txMismatch(operation, "M2 verify bundle attester cannot be fee_payer");
742
+ }
743
+ if (primary.ix.accounts.length !== 3) {
744
+ throw txMismatch(operation, `M2 verify_task_attested must carry exact 3 accounts [task, global_state, attester], got ${primary.ix.accounts.length}`);
745
+ }
746
+ const scoreView = new DataView(primary.data.buffer, primary.data.byteOffset + 8, 8);
747
+ const verifyScore = scoreView.getBigUint64(0, true);
748
+ if (verifyScore !== MAX_VERIFY_SCORE) {
749
+ throw txMismatch(operation, `M2 verify bundle requires MAX_SCORE (${MAX_VERIFY_SCORE}), got ${verifyScore}`);
750
+ }
751
+ if (!primary.data.subarray(16, 48).some((b) => b !== 0)) {
752
+ throw txMismatch(operation, "M2 verify_task_attested verification_hash must be non-zero");
753
+ }
754
+ const lifecycleTaskPda = primary.ix.accounts[0];
755
+ const claimIx = companions[0];
756
+ const payoutIx = isM2VerifyWithPayout ? companions[1] : undefined;
757
+ const submitIx = isM2VerifyWithPayout ? companions[2] : companions[1];
758
+ if (payoutIx) {
759
+ if (payoutIx.txIndex !== claimIx.txIndex + 1 ||
760
+ submitIx.txIndex !== payoutIx.txIndex + 1 ||
761
+ primary.txIndex !== submitIx.txIndex + 1) {
762
+ throw txMismatch(operation, "M2 verify bundle instructions must execute in strict order claim_task < set_payout_to < submit_work < verify_task_attested");
763
+ }
764
+ }
765
+ else {
766
+ if (expectedPayoutPubkey) {
767
+ throw txMismatch(operation, "Expected set_payout_to instruction matching expected.payoutTo, but none was present");
768
+ }
769
+ if (submitIx.txIndex !== claimIx.txIndex + 1 ||
770
+ primary.txIndex !== submitIx.txIndex + 1) {
771
+ throw txMismatch(operation, "M2 verify bundle instructions must execute in strict order claim_task < submit_work < verify_task_attested");
772
+ }
773
+ }
774
+ // Validate companion claim_task
775
+ const validClaimAccounts = claimIx.ix.accounts.length === SHILLBOT_INSTRUCTION_SPECS.claim_task.minAccounts ||
776
+ (claimIx.ix.accounts.length === 6 &&
777
+ claimIx.ix.accounts[5] === SYSVAR_INSTRUCTIONS_PUBKEY.toBase58());
778
+ if (claimIx.data.length !== 8 || !validClaimAccounts) {
779
+ throw txMismatch(operation, "Malformed claim_task companion in M2 verify bundle");
780
+ }
781
+ if (claimIx.ix.accounts[0] !== lifecycleTaskPda) {
782
+ throw txMismatch(operation, "M2 verify bundle claim_task account [0] does not match expected task PDA");
783
+ }
784
+ if (claimIx.ix.accounts[3] !== expected.wallet ||
785
+ !inspected.signers.includes(claimIx.ix.accounts[3])) {
786
+ throw txMismatch(operation, "M2 verify bundle claim_task authority slot [3] does not match expected wallet signer");
787
+ }
788
+ // Validate optional companion set_payout_to
789
+ if (payoutIx) {
790
+ validateSetPayoutToInstruction(payoutIx, expected.wallet, lifecycleTaskPda, expectedPayoutPubkey, operation);
791
+ }
792
+ // Validate companion submit_work
793
+ if (submitIx.ix.accounts.length !== SHILLBOT_INSTRUCTION_SPECS.submit_work.minAccounts) {
794
+ throw txMismatch(operation, `M2 verify bundle submit_work must carry exact 4 accounts, got ${submitIx.ix.accounts.length}`);
795
+ }
796
+ if (submitIx.ix.accounts[0] !== lifecycleTaskPda) {
797
+ throw txMismatch(operation, "M2 verify bundle submit_work account [0] does not match expected task PDA");
798
+ }
799
+ if (submitIx.ix.accounts[3] !== expected.wallet ||
800
+ !inspected.signers.includes(submitIx.ix.accounts[3])) {
801
+ throw txMismatch(operation, "M2 verify bundle submit_work authority slot [3] does not match expected wallet signer");
802
+ }
803
+ if (submitIx.data.length < 12) {
804
+ throw txMismatch(operation, "M2 verify bundle submit_work instruction is truncated");
805
+ }
806
+ const submitContentLen = submitIx.data.readUInt32LE(8);
807
+ if (submitIx.data.length !== 12 + submitContentLen) {
808
+ throw txMismatch(operation, "M2 verify bundle submit_work content_id length mismatch");
809
+ }
810
+ if (expected.contentId !== undefined) {
811
+ const actualContent = submitIx.data.subarray(12, 12 + submitContentLen).toString("utf8");
812
+ if (actualContent !== expected.contentId) {
813
+ throw txMismatch(operation, "M2 verify bundle submit_work content_id differs from expectation");
814
+ }
815
+ }
816
+ return inspected;
817
+ }
710
818
  if ((isClaimLifecycle || isSubmitLifecycle) &&
711
819
  companions.length === 1 &&
712
820
  companions[0].spec.name === "set_payout_to") {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CLIENT_VERSION = "0.4.7";
1
+ export declare const CLIENT_VERSION = "0.4.9";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLIENT_VERSION = "0.4.7";
1
+ export const CLIENT_VERSION = "0.4.9";
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@swarm-tips/client",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
+ "mcpName": "io.github.corsur/swarm-tips",
4
5
  "description": "Typed browser and Node.js clients for Swarm Tips, Shillbot, and Coordination Game",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",