@swarm-tips/client 0.4.1 → 0.4.3

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.
@@ -113,3 +113,4 @@ export declare const buildFinalize: (request: Omit<FinalizeBuild, "action">) =>
113
113
  export { buildSwitchboardCrankAndVerify } from "./switchboard.js";
114
114
  export type { SwitchboardVerifyRequest } from "./switchboard.js";
115
115
  export * from "./payout-oracle.js";
116
+ export { MAX_COMPUTE_UNIT_LIMIT, MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS, SHILLBOT_INSTRUCTION_SPECS, validateComputeBudgetInstruction, validateComputeBudgetInstructions, verifyBuiltTransaction, type AuthoritySlotRule, type ShillbotInstructionName, type ShillbotInstructionSpec, type VerifyBuiltTransactionExpectation, } from "./verify-tx.js";
@@ -281,6 +281,7 @@ export function verifyIntent(encoded, intent) {
281
281
  throw new Error(`unexpected companion program ${ix.program_id}`);
282
282
  }
283
283
  }
284
+ validateComputeBudgetInstructions(inspected.instructions);
284
285
  const expectedDiscriminator = shillbotInstructionDiscriminator(intent.action === "submit" ? "submit_work" : `${intent.action}_task`);
285
286
  const lifecycle = inspected.instructions.filter((ix) => ix.program_id === shillbotProgramId &&
286
287
  Buffer.from(ix.data_base64, "base64")
@@ -372,3 +373,5 @@ export const buildVerify = (request) => buildTransaction({ ...request, action: "
372
373
  export const buildFinalize = (request) => buildTransaction({ ...request, action: "finalize" });
373
374
  export { buildSwitchboardCrankAndVerify } from "./switchboard.js";
374
375
  export * from "./payout-oracle.js";
376
+ import { validateComputeBudgetInstructions } from "./verify-tx.js";
377
+ export { MAX_COMPUTE_UNIT_LIMIT, MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS, SHILLBOT_INSTRUCTION_SPECS, validateComputeBudgetInstruction, validateComputeBudgetInstructions, verifyBuiltTransaction, } from "./verify-tx.js";
@@ -0,0 +1,62 @@
1
+ import { type Action, type Network, type TransactionInspection } from "./index.js";
2
+ /** Default maximum allowed Solana priority fee price per compute unit (`100_000` micro-lamports/CU). */
3
+ export declare const MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS = 100000n;
4
+ /** Solana runtime ceiling for `ComputeBudget::SetComputeUnitLimit` (`1_400_000` CUs). */
5
+ export declare const MAX_COMPUTE_UNIT_LIMIT = 1400000;
6
+ export type ShillbotInstructionName = "initialize" | "create_task" | "claim_task" | "claim_task_session" | "set_payout_to" | "submit_work" | "submit_work_session" | "approve_task" | "verify_task" | "verify_task_attested" | "challenge_task" | "finalize_task" | "expire_task" | "resolve_challenge" | "resolve_challenge_default" | "update_params" | "transfer_authority" | "update_treasury" | "update_oracle_authority" | "emergency_return" | "create_session" | "revoke_session" | "register_identity" | "revoke_identity" | "close_agent_state" | "migrate_agent_state" | "migrate_task";
7
+ export type AuthoritySlotRule = number | "fee_payer" | "verify_task" | "verify_task_attested";
8
+ export interface ShillbotInstructionSpec {
9
+ readonly name: ShillbotInstructionName;
10
+ readonly minAccounts: number;
11
+ readonly exactAccounts?: number;
12
+ readonly taskSlot: number | null;
13
+ readonly authoritySlot: AuthoritySlotRule;
14
+ /** True when third-party gas sponsorship (`fee_payer !== wallet`) is permitted by protocol design. */
15
+ readonly allowsSponsoredFeePayer: boolean;
16
+ }
17
+ /**
18
+ * Exact Anchor account-index and authority-slot specification for every Shillbot instruction,
19
+ * derived directly from `programs/shillbot/src/instructions/*.rs` and `shillbot.json` IDL.
20
+ */
21
+ export declare const SHILLBOT_INSTRUCTION_SPECS: Readonly<Record<ShillbotInstructionName, ShillbotInstructionSpec>>;
22
+ export interface VerifyBuiltTransactionExpectation {
23
+ action?: Action;
24
+ instructionName?: ShillbotInstructionName;
25
+ network: Network;
26
+ wallet: string;
27
+ taskPda?: string;
28
+ feePayer?: string;
29
+ /**
30
+ * Explicit authorized payout destination pubkey (base58).
31
+ * Required whenever a `set_payout_to` instruction is present; otherwise any
32
+ * `set_payout_to` instruction is rejected fail-closed.
33
+ */
34
+ payoutTo?: string;
35
+ oracleAuthority?: string;
36
+ escrowLamports?: bigint;
37
+ contentId?: string;
38
+ maxComputeUnitPriceMicroLamports?: bigint;
39
+ allowedProgramIds?: string[];
40
+ }
41
+ /**
42
+ * Validate a single `ComputeBudget111111111111111111111111111111` instruction's tag,
43
+ * byte length, and value bounds. Never early-returns from a multi-instruction loop.
44
+ */
45
+ export declare function validateComputeBudgetInstruction(data: Uint8Array, maxComputeUnitPriceMicroLamports?: bigint, operation?: string): void;
46
+ /**
47
+ * Validate every `ComputeBudget` instruction in an inspected transaction without
48
+ * short-circuiting on `RequestHeapFrame` (tag 1) or any preceding instruction.
49
+ */
50
+ export declare function validateComputeBudgetInstructions(instructions: TransactionInspection["instructions"], maxComputeUnitPriceMicroLamports?: bigint, operation?: string): void;
51
+ /**
52
+ * Strict fail-closed local validator for built or server-prepared Shillbot Solana transactions.
53
+ *
54
+ * Enforces:
55
+ * - Allowed program IDs (Shillbot + ComputeBudget, plus Switchboard + Secp256k1 only on `verify`).
56
+ * - Full loop validation of all `ComputeBudget` instructions (no early return on `RequestHeapFrame`),
57
+ * capping `SetComputeUnitPrice <= MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS` (`100_000` micro-lamports/CU).
58
+ * - Exact Anchor account-index positions for `task` PDA and authority signer slots per discriminator.
59
+ * - Explicit `set_payout_to` opt-in guard: rejects any `set_payout_to` instruction unless
60
+ * `expected.payoutTo` is explicitly provided AND matches `ix.data[8..40]` and `accounts == [task, wallet]`.
61
+ */
62
+ export declare function verifyBuiltTransaction(encoded: string, expected: VerifyBuiltTransactionExpectation, operation?: string): TransactionInspection;