@swarm-tips/client 0.4.4 → 0.4.6

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.
@@ -2,9 +2,60 @@ import { Buffer } from "buffer";
2
2
  import { sha256 } from "js-sha256";
3
3
  import { BN, SHILLBOT_PROGRAM_ID, agentStatePda, buildShillbotInstruction, clientStatePda, globalStatePda, shillbotInstructionDiscriminator, taskPda, } from "../contracts/index.js";
4
4
  import bs58 from "bs58";
5
- import { PublicKey, Transaction, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
5
+ import { PublicKey, Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
6
6
  export { COORDINATION_GAME_IDL, COORDINATION_GAME_PROGRAM_ID, SHILLBOT_IDL, SHILLBOT_PROGRAM_ID, agentStatePda, buildShillbotInstruction, clientStatePda, globalStatePda, shillbotInstructionDiscriminator, taskPda, } from "../contracts/index.js";
7
7
  export const SCHEMA_VERSION = "swarm.shillbot.transaction-intent/v1";
8
+ export const EXTENSION_CREDIT_PROGRAM_ID = new PublicKey("Ec628D7GH3hwgnVf1gqrUh83qcZprYjmTzvtdHHEr7oh");
9
+ export function advancePda(backer, agent) {
10
+ return PublicKey.findProgramAddressSync([
11
+ Buffer.from("advance"),
12
+ new PublicKey(backer).toBuffer(),
13
+ new PublicKey(agent).toBuffer(),
14
+ ], EXTENSION_CREDIT_PROGRAM_ID)[0];
15
+ }
16
+ export function routeAndRecoupDiscriminator() {
17
+ return Buffer.from(sha256.arrayBuffer("global:route_and_recoup")).subarray(0, 8);
18
+ }
19
+ /** Exact Anchor account byte length of `extension-credit` `Advance` (`8 + 32 + 32 + 8 + 8 + 8 + 1 + 16 = 113`). */
20
+ export const ADVANCE_ACCOUNT_SPACE = 113;
21
+ export function advanceAccountDiscriminator() {
22
+ return Buffer.from(sha256.arrayBuffer("account:Advance")).subarray(0, 8);
23
+ }
24
+ /**
25
+ * Decode an on-chain `extension-credit` `Advance` account (`programs/extension-credit/src/state/advance.rs`).
26
+ * Returns `null` if the length (`113` bytes) or 8-byte Anchor discriminator (`account:Advance`) does not match.
27
+ */
28
+ export function decodeExtensionCreditAdvance(data) {
29
+ const buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
30
+ if (buf.length !== ADVANCE_ACCOUNT_SPACE) {
31
+ return null;
32
+ }
33
+ if (!buf.subarray(0, 8).equals(advanceAccountDiscriminator())) {
34
+ return null;
35
+ }
36
+ const backer = new PublicKey(buf.subarray(8, 40));
37
+ const recipient = new PublicKey(buf.subarray(40, 72));
38
+ const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
39
+ const advanceLamports = view.getBigUint64(72, true);
40
+ const recoupedLamports = view.getBigUint64(80, true);
41
+ return {
42
+ backer,
43
+ recipient,
44
+ advanceLamports,
45
+ recoupedLamports,
46
+ };
47
+ }
48
+ export function buildRouteAndRecoupInstruction(accounts) {
49
+ return new TransactionInstruction({
50
+ programId: EXTENSION_CREDIT_PROGRAM_ID,
51
+ keys: [
52
+ { pubkey: new PublicKey(accounts.advance), isSigner: false, isWritable: true },
53
+ { pubkey: new PublicKey(accounts.backer), isSigner: false, isWritable: true },
54
+ { pubkey: new PublicKey(accounts.recipient), isSigner: false, isWritable: true },
55
+ ],
56
+ data: routeAndRecoupDiscriminator(),
57
+ });
58
+ }
8
59
  export function buildInstruction(request) {
9
60
  const wallet = new PublicKey(request.wallet);
10
61
  if (request.action === "create") {
@@ -77,8 +128,26 @@ export function buildInstruction(request) {
77
128
  },
78
129
  });
79
130
  }
131
+ if (request.action === "expire") {
132
+ const ix = buildShillbotInstruction({
133
+ name: "expire_task",
134
+ accounts: {
135
+ task,
136
+ global_state: globalStatePda(),
137
+ client: request.client ?? wallet,
138
+ },
139
+ });
140
+ if (request.claimedAgent) {
141
+ ix.keys.push({
142
+ pubkey: agentStatePda(new PublicKey(request.claimedAgent)),
143
+ isSigner: false,
144
+ isWritable: true,
145
+ });
146
+ }
147
+ return ix;
148
+ }
80
149
  const finalize = request;
81
- return buildShillbotInstruction({
150
+ const ix = buildShillbotInstruction({
82
151
  name: "finalize_task",
83
152
  accounts: {
84
153
  task,
@@ -88,6 +157,14 @@ export function buildInstruction(request) {
88
157
  treasury: finalize.treasury,
89
158
  },
90
159
  });
160
+ if (finalize.agentStateOwner) {
161
+ ix.keys.push({
162
+ pubkey: agentStatePda(new PublicKey(finalize.agentStateOwner)),
163
+ isSigner: false,
164
+ isWritable: true,
165
+ });
166
+ }
167
+ return ix;
91
168
  }
92
169
  function payoutInstruction(request) {
93
170
  if (!request.payoutTo)
@@ -115,7 +192,7 @@ export function intentDigest(intent) {
115
192
  function actionRisk(action) {
116
193
  if (action === "create")
117
194
  return "spend";
118
- if (action === "approve")
195
+ if (action === "approve" || action === "expire")
119
196
  return "escrow_control";
120
197
  return "earn";
121
198
  }
@@ -146,10 +223,20 @@ export function buildTransaction(request) {
146
223
  ? request.crankInstructions
147
224
  : request.action === "claim"
148
225
  ? [payoutInstruction(request)].filter((ix) => ix !== undefined)
149
- : [];
150
- // set_payout_to authorizes against task.agent, which claim_task establishes.
151
- // Keep the two operations atomic, but execute the claim first.
152
- const instructions = request.action === "claim"
226
+ : request.action === "finalize" && request.recoupBacker
227
+ ? [
228
+ buildRouteAndRecoupInstruction({
229
+ advance: request.agent,
230
+ backer: request.recoupBacker,
231
+ recipient: request.recoupRecipient ??
232
+ request.agentStateOwner ??
233
+ request.wallet,
234
+ }),
235
+ ]
236
+ : [];
237
+ // set_payout_to authorizes against task.agent (after claim_task), and
238
+ // route_and_recoup sweeps after finalize_task lands escrow in the Advance PDA.
239
+ const instructions = request.action === "claim" || request.action === "finalize"
153
240
  ? [lifecycle, ...companions]
154
241
  : [...companions, lifecycle];
155
242
  const unsignedTx = serializeUnsigned(payer, request.recentBlockhash, instructions, request.version ?? (request.action === "verify" ? "v0" : "legacy"));
@@ -269,12 +356,14 @@ export function verifyIntent(encoded, intent) {
269
356
  if (!inspected.signers.includes(intent.wallet))
270
357
  throw new Error("wallet is not a required signer");
271
358
  const shillbotProgramId = SHILLBOT_PROGRAM_ID.toBase58();
359
+ const extensionCreditId = EXTENSION_CREDIT_PROGRAM_ID.toBase58();
272
360
  const allowedPrograms = new Set([
273
361
  shillbotProgramId,
274
362
  COMPUTE_BUDGET_PROGRAM_ID,
275
363
  ...(intent.action === "verify"
276
364
  ? [SWITCHBOARD_PROGRAM_IDS[intent.network], SECP256K1_PROGRAM_ID]
277
365
  : []),
366
+ ...(intent.action === "finalize" ? [extensionCreditId] : []),
278
367
  ]);
279
368
  for (const ix of inspected.instructions) {
280
369
  if (!allowedPrograms.has(ix.program_id)) {
@@ -313,6 +402,23 @@ export function verifyIntent(encoded, intent) {
313
402
  .toString("hex"))) {
314
403
  throw new Error("unexpected Shillbot companion instruction");
315
404
  }
405
+ const creditInstructions = inspected.instructions.filter((ix) => ix.program_id === extensionCreditId);
406
+ if (creditInstructions.length > 0) {
407
+ if (intent.action !== "finalize" || creditInstructions.length !== 1) {
408
+ throw new Error("unexpected extension-credit companion instruction");
409
+ }
410
+ const creditIx = creditInstructions[0];
411
+ if (inspected.instructions.indexOf(creditIx) <= lifecycleIndex) {
412
+ throw new Error("route_and_recoup must follow finalize_task");
413
+ }
414
+ const creditData = Buffer.from(creditIx.data_base64, "base64");
415
+ if (creditData.length !== 8 ||
416
+ !creditData.equals(routeAndRecoupDiscriminator()) ||
417
+ creditIx.accounts.length !== 3 ||
418
+ creditIx.accounts[0] !== intent.accounts[2]) {
419
+ throw new Error("malformed route_and_recoup companion instruction");
420
+ }
421
+ }
316
422
  if (lifecycle[0].accounts.join(",") !== intent.accounts.join(",")) {
317
423
  throw new Error("lifecycle accounts differ from intent");
318
424
  }
@@ -371,6 +477,7 @@ export const buildSubmit = (request) => buildTransaction({ ...request, action: "
371
477
  export const buildApprove = (request) => buildTransaction({ ...request, action: "approve" });
372
478
  export const buildVerify = (request) => buildTransaction({ ...request, action: "verify" });
373
479
  export const buildFinalize = (request) => buildTransaction({ ...request, action: "finalize" });
480
+ export const buildExpire = (request) => buildTransaction({ ...request, action: "expire" });
374
481
  export { buildSwitchboardCrankAndVerify } from "./switchboard.js";
375
482
  export * from "./payout-oracle.js";
376
483
  import { validateComputeBudgetInstructions } from "./verify-tx.js";
@@ -19,6 +19,7 @@ export interface ShillbotInstructionSpec {
19
19
  * derived directly from `programs/shillbot/src/instructions/*.rs` and `shillbot.json` IDL.
20
20
  */
21
21
  export declare const SHILLBOT_INSTRUCTION_SPECS: Readonly<Record<ShillbotInstructionName, ShillbotInstructionSpec>>;
22
+ export type ExpireTaskState = "open" | "claimed" | "submitted" | "approved";
22
23
  export interface VerifyBuiltTransactionExpectation {
23
24
  action?: Action;
24
25
  instructionName?: ShillbotInstructionName;
@@ -32,6 +33,12 @@ export interface VerifyBuiltTransactionExpectation {
32
33
  * `set_payout_to` instruction is rejected fail-closed.
33
34
  */
34
35
  payoutTo?: string;
36
+ /**
37
+ * Optional task state when validating `expire_task`: enforces exact 3 accounts
38
+ * `[task, global_state, client]` on `open | submitted | approved` (rejecting the
39
+ * 4-account `AgentState` form) and exact 4 accounts on `claimed`.
40
+ */
41
+ expireTaskState?: ExpireTaskState;
35
42
  oracleAuthority?: string;
36
43
  escrowLamports?: bigint;
37
44
  contentId?: string;
@@ -52,7 +59,8 @@ export declare function validateComputeBudgetInstructions(instructions: Transact
52
59
  * Strict fail-closed local validator for built or server-prepared Shillbot Solana transactions.
53
60
  *
54
61
  * Enforces:
55
- * - Allowed program IDs (Shillbot + ComputeBudget, plus Switchboard + Secp256k1 only on `verify`).
62
+ * - Allowed program IDs (Shillbot + ComputeBudget, Switchboard + Secp256k1 on `verify` / score-0 reopen,
63
+ * and `extension-credit` `route_and_recoup` strictly on `finalize`).
56
64
  * - Full loop validation of all `ComputeBudget` instructions (no early return on `RequestHeapFrame`),
57
65
  * capping `SetComputeUnitPrice <= MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS` (`100_000` micro-lamports/CU).
58
66
  * - Exact Anchor account-index positions for `task` PDA and authority signer slots per discriminator.
@@ -2,7 +2,7 @@ import { Buffer } from "buffer";
2
2
  import { ComputeBudgetProgram, PublicKey, Secp256k1Program } from "@solana/web3.js";
3
3
  import { SHILLBOT_PROGRAM_ID, shillbotInstructionDiscriminator } from "../contracts/index.js";
4
4
  import { SwarmClientError } from "../errors.js";
5
- import { inspectTransaction, } from "./index.js";
5
+ import { EXTENSION_CREDIT_PROGRAM_ID, advancePda, inspectTransaction, routeAndRecoupDiscriminator, } from "./index.js";
6
6
  /** Default maximum allowed Solana priority fee price per compute unit (`100_000` micro-lamports/CU). */
7
7
  export const MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 100000n;
8
8
  /** Solana runtime ceiling for `ComputeBudget::SetComputeUnitLimit` (`1_400_000` CUs). */
@@ -327,6 +327,8 @@ function allowedInstructionNamesForAction(action) {
327
327
  return ["verify_task", "verify_task_attested"];
328
328
  case "finalize":
329
329
  return ["finalize_task"];
330
+ case "expire":
331
+ return ["expire_task"];
330
332
  default:
331
333
  return [];
332
334
  }
@@ -435,7 +437,8 @@ function verifyInstructionAuthorityAndShape(decoded, inspected, expected, operat
435
437
  * Strict fail-closed local validator for built or server-prepared Shillbot Solana transactions.
436
438
  *
437
439
  * Enforces:
438
- * - Allowed program IDs (Shillbot + ComputeBudget, plus Switchboard + Secp256k1 only on `verify`).
440
+ * - Allowed program IDs (Shillbot + ComputeBudget, Switchboard + Secp256k1 on `verify` / score-0 reopen,
441
+ * and `extension-credit` `route_and_recoup` strictly on `finalize`).
439
442
  * - Full loop validation of all `ComputeBudget` instructions (no early return on `RequestHeapFrame`),
440
443
  * capping `SetComputeUnitPrice <= MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS` (`100_000` micro-lamports/CU).
441
444
  * - Exact Anchor account-index positions for `task` PDA and authority signer slots per discriminator.
@@ -482,13 +485,16 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
482
485
  const isVerifyContext = expected.action === "verify" ||
483
486
  expected.instructionName === "verify_task" ||
484
487
  expected.instructionName === "verify_task_attested";
488
+ const isFinalizeContext = expected.action === "finalize" || expected.instructionName === "finalize_task";
485
489
  const shillbotId = SHILLBOT_PROGRAM_ID.toBase58();
490
+ const extensionCreditId = EXTENSION_CREDIT_PROGRAM_ID.toBase58();
486
491
  const alwaysAllowed = new Set([
487
492
  shillbotId,
488
493
  ComputeBudgetProgram.programId.toBase58(),
489
494
  ...(isVerifyContext
490
495
  ? [SWITCHBOARD_PROGRAM_IDS[expected.network], Secp256k1Program.programId.toBase58()]
491
496
  : []),
497
+ ...(isFinalizeContext ? [extensionCreditId] : []),
492
498
  ...(expected.allowedProgramIds ?? []),
493
499
  ]);
494
500
  const unrelated = inspected.instructions.find((instruction) => !alwaysAllowed.has(instruction.program_id));
@@ -529,6 +535,43 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
529
535
  }
530
536
  }
531
537
  verifyInstructionAuthorityAndShape(primary, inspected, expected, operation);
538
+ // Validate optional `extension-credit::route_and_recoup` companion on `finalize`
539
+ const creditIxs = inspected.instructions
540
+ .map((ix, txIndex) => ({ ix, txIndex }))
541
+ .filter((entry) => entry.ix.program_id === extensionCreditId);
542
+ if (creditIxs.length > 0) {
543
+ if (!isFinalizeContext || primary.spec.name !== "finalize_task") {
544
+ throw txMismatch(operation, "extension-credit instruction only permitted on finalize_task");
545
+ }
546
+ if (creditIxs.length !== 1) {
547
+ throw txMismatch(operation, "At most one extension-credit instruction is permitted");
548
+ }
549
+ const { ix: creditIx, txIndex: creditTxIndex } = creditIxs[0];
550
+ if (creditTxIndex <= primary.txIndex) {
551
+ throw txMismatch(operation, "route_and_recoup must execute after finalize_task");
552
+ }
553
+ const creditData = Buffer.from(creditIx.data_base64, "base64");
554
+ if (creditData.length !== 8 || !creditData.equals(routeAndRecoupDiscriminator())) {
555
+ throw txMismatch(operation, "Unsupported or malformed extension-credit instruction");
556
+ }
557
+ if (creditIx.accounts.length !== 3) {
558
+ throw txMismatch(operation, `route_and_recoup requires exact 3 accounts [advance, backer, recipient], got ${creditIx.accounts.length}`);
559
+ }
560
+ const [advanceAcct, backerAcct, recipientAcct] = creditIx.accounts;
561
+ if (advanceAcct !== primary.ix.accounts[2]) {
562
+ throw txMismatch(operation, `route_and_recoup advance account (${advanceAcct}) must match finalize_task payout slot [2] (${primary.ix.accounts[2]})`);
563
+ }
564
+ if (expectedPayoutPubkey && advanceAcct !== expectedPayoutPubkey.toBase58()) {
565
+ throw txMismatch(operation, `route_and_recoup advance account (${advanceAcct}) differs from expected.payoutTo (${expectedPayoutPubkey.toBase58()})`);
566
+ }
567
+ if (recipientAcct !== expected.wallet) {
568
+ throw txMismatch(operation, `route_and_recoup recipient (${recipientAcct}) must equal caller wallet (${expected.wallet})`);
569
+ }
570
+ const derivedAdvance = advancePda(backerAcct, recipientAcct).toBase58();
571
+ if (advanceAcct !== derivedAdvance) {
572
+ throw txMismatch(operation, `route_and_recoup advance account (${advanceAcct}) does not match canonical Advance PDA (${derivedAdvance})`);
573
+ }
574
+ }
532
575
  // Instruction-specific payload validation
533
576
  if (primary.spec.name === "create_task") {
534
577
  if (primary.data.length < 24) {
@@ -566,6 +609,31 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
566
609
  throw txMismatch(operation, `finalize_task payout recipient slot [2] (${primary.ix.accounts[2]}) differs from expected.payoutTo ${expectedPayoutPubkey.toBase58()}`);
567
610
  }
568
611
  }
612
+ else if (primary.spec.name === "expire_task") {
613
+ if (primary.data.length !== 8) {
614
+ throw txMismatch(operation, `expire_task instruction data must be exact 8-byte discriminator, got ${primary.data.length}`);
615
+ }
616
+ if (primary.ix.accounts.length !== 3 && primary.ix.accounts.length !== 4) {
617
+ throw txMismatch(operation, `expire_task requires 3 accounts (or 4 when expiring a Claimed task), got ${primary.ix.accounts.length}`);
618
+ }
619
+ if (expected.expireTaskState !== undefined) {
620
+ if (expected.expireTaskState === "open" ||
621
+ expected.expireTaskState === "submitted" ||
622
+ expected.expireTaskState === "approved") {
623
+ if (primary.ix.accounts.length !== 3) {
624
+ throw txMismatch(operation, `expire_task on ${expected.expireTaskState} task requires exact 3 accounts [task, global_state, client], got ${primary.ix.accounts.length}`);
625
+ }
626
+ }
627
+ else if (expected.expireTaskState === "claimed") {
628
+ if (primary.ix.accounts.length !== 4) {
629
+ throw txMismatch(operation, `expire_task on claimed task requires exact 4 accounts [task, global_state, client, agent_state], got ${primary.ix.accounts.length}`);
630
+ }
631
+ }
632
+ else {
633
+ throw invalidArg(operation, `Unsupported expireTaskState: ${String(expected.expireTaskState)}`);
634
+ }
635
+ }
636
+ }
569
637
  // Validate companion Shillbot instructions (strictly fail-closed)
570
638
  const validateClaimCompanion = (claimIx) => {
571
639
  if (primary.spec.name === "submit_work") {
@@ -590,6 +658,9 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
590
658
  const isSubmitLifecycle = expected.action === "submit" ||
591
659
  primary.spec.name === "submit_work" ||
592
660
  primary.spec.name === "submit_work_session";
661
+ const isVerifyLifecycle = expected.action === "verify" ||
662
+ primary.spec.name === "verify_task" ||
663
+ primary.spec.name === "verify_task_attested";
593
664
  if (companions.length === 0) {
594
665
  if (expectedPayoutPubkey &&
595
666
  primary.spec.name !== "set_payout_to" &&
@@ -598,6 +669,15 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
598
669
  }
599
670
  return inspected;
600
671
  }
672
+ if (isVerifyLifecycle &&
673
+ companions.length === 1 &&
674
+ companions[0].spec.name === "set_payout_to") {
675
+ if (companions[0].txIndex >= primary.txIndex) {
676
+ throw txMismatch(operation, "set_payout_to must precede verify instruction");
677
+ }
678
+ validateSetPayoutToInstruction(companions[0], expected.wallet, primary.ix.accounts[0], expectedPayoutPubkey, operation);
679
+ return inspected;
680
+ }
601
681
  if (isClaimLifecycle &&
602
682
  companions.length === 1 &&
603
683
  companions[0].spec.name === "set_payout_to") {
@@ -610,30 +690,64 @@ export function verifyBuiltTransaction(encoded, expected, operation = "shillbot.
610
690
  validateSetPayoutToInstruction(companions[0], expected.wallet, primary.ix.accounts[0], expectedPayoutPubkey, operation);
611
691
  return inspected;
612
692
  }
693
+ // Optional leading score-0 reopen (`verify_task` or `verify_task_attested` with score == 0)
694
+ // before `[claim_task, (set_payout_to?), submit_work]` (1d / Q4).
695
+ let submitCompanions = companions;
613
696
  if (isSubmitLifecycle &&
614
- companions.length === 1 &&
615
- (companions[0].spec.name === "claim_task" ||
616
- companions[0].spec.name === "claim_task_session")) {
697
+ (companions[0].spec.name === "verify_task" ||
698
+ companions[0].spec.name === "verify_task_attested")) {
699
+ const reopenIx = companions[0];
700
+ if (reopenIx.data.length !== 48 || reopenIx.ix.accounts.length < 3) {
701
+ throw txMismatch(operation, "Malformed score-0 reopen verify companion");
702
+ }
703
+ if (reopenIx.ix.accounts[0] !== primary.ix.accounts[0]) {
704
+ throw txMismatch(operation, "Score-0 reopen verify companion targets a different task PDA");
705
+ }
706
+ const scoreView = new DataView(reopenIx.data.buffer, reopenIx.data.byteOffset + 8, 8);
707
+ if (scoreView.getBigUint64(0, true) !== 0n) {
708
+ throw txMismatch(operation, "Reopen verify companion in submit bundle must have composite_score === 0");
709
+ }
710
+ if (reopenIx.spec.name === "verify_task_attested") {
711
+ const attester = reopenIx.ix.accounts[2];
712
+ if (!inspected.signers.includes(attester)) {
713
+ throw txMismatch(operation, "verify_task_attested reopen attester must be a signer");
714
+ }
715
+ if (expected.oracleAuthority && attester !== expected.oracleAuthority) {
716
+ throw txMismatch(operation, "verify_task_attested reopen attester mismatch");
717
+ }
718
+ }
719
+ else if (expected.oracleAuthority && reopenIx.ix.accounts[2] !== expected.oracleAuthority) {
720
+ throw txMismatch(operation, "verify_task reopen oracle mismatch");
721
+ }
722
+ submitCompanions = companions.slice(1);
723
+ if (submitCompanions.length > 0 && reopenIx.txIndex >= submitCompanions[0].txIndex) {
724
+ throw txMismatch(operation, "Score-0 reopen verify must precede claim_task");
725
+ }
726
+ }
727
+ if (isSubmitLifecycle &&
728
+ submitCompanions.length === 1 &&
729
+ (submitCompanions[0].spec.name === "claim_task" ||
730
+ submitCompanions[0].spec.name === "claim_task_session")) {
617
731
  if (expectedPayoutPubkey) {
618
732
  throw txMismatch(operation, "Expected set_payout_to instruction matching expected.payoutTo, but none was present");
619
733
  }
620
- if (primary.txIndex !== companions[0].txIndex + 1 ||
621
- !validateClaimCompanion(companions[0])) {
734
+ if (primary.txIndex !== submitCompanions[0].txIndex + 1 ||
735
+ !validateClaimCompanion(submitCompanions[0])) {
622
736
  throw txMismatch(operation, "Expected exactly one matching Shillbot lifecycle instruction");
623
737
  }
624
738
  return inspected;
625
739
  }
626
740
  if (isSubmitLifecycle &&
627
- companions.length === 2 &&
628
- companions[0].spec.name === "claim_task" &&
629
- companions[1].spec.name === "set_payout_to") {
741
+ submitCompanions.length === 2 &&
742
+ submitCompanions[0].spec.name === "claim_task" &&
743
+ submitCompanions[1].spec.name === "set_payout_to") {
630
744
  if (primary.spec.name !== "submit_work" ||
631
- companions[1].txIndex !== companions[0].txIndex + 1 ||
632
- primary.txIndex !== companions[1].txIndex + 1 ||
633
- !validateClaimCompanion(companions[0])) {
745
+ submitCompanions[1].txIndex !== submitCompanions[0].txIndex + 1 ||
746
+ primary.txIndex !== submitCompanions[1].txIndex + 1 ||
747
+ !validateClaimCompanion(submitCompanions[0])) {
634
748
  throw txMismatch(operation, "Expected exactly one matching Shillbot lifecycle instruction");
635
749
  }
636
- validateSetPayoutToInstruction(companions[1], expected.wallet, primary.ix.accounts[0], expectedPayoutPubkey, operation);
750
+ validateSetPayoutToInstruction(submitCompanions[1], expected.wallet, primary.ix.accounts[0], expectedPayoutPubkey, operation);
637
751
  return inspected;
638
752
  }
639
753
  if (companions.some((c) => c.spec.name === "set_payout_to")) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CLIENT_VERSION = "0.4.4";
1
+ export declare const CLIENT_VERSION = "0.4.6";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLIENT_VERSION = "0.4.4";
1
+ export const CLIENT_VERSION = "0.4.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swarm-tips/client",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Typed browser and Node.js clients for Swarm Tips, Shillbot, and Coordination Game",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",