@swarm-tips/client 0.4.2 → 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.
- package/SBOM.spdx.json +5 -5
- package/dist/agent.d.ts +16 -0
- package/dist/agent.js +70 -53
- package/dist/cli/swarm.d.ts +5 -0
- package/dist/cli/swarm.js +37 -19
- package/dist/contracts/generated/coordination_game.d.ts +179 -1
- package/dist/contracts/generated/shillbot.d.ts +119 -12
- package/dist/contracts/idl/coordination_game.json +180 -2
- package/dist/contracts/idl/shillbot.json +119 -12
- package/dist/generated/openapi.d.ts +17 -2
- package/dist/generated/openapi.js +1 -1
- package/dist/inbox/client.d.ts +2 -4
- package/dist/inbox/client.js +11 -6
- package/dist/inbox/index.d.ts +1 -1
- package/dist/inbox/index.js +1 -1
- package/dist/inbox/types.d.ts +9 -0
- package/dist/inbox/types.js +10 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/shillbot/api.d.ts +7 -0
- package/dist/shillbot/api.js +41 -130
- package/dist/shillbot/index.d.ts +1 -0
- package/dist/shillbot/index.js +3 -0
- package/dist/shillbot/verify-tx.d.ts +62 -0
- package/dist/shillbot/verify-tx.js +643 -0
- package/dist/signer/evm.d.ts +1 -1
- package/dist/signer/evm.js +72 -2
- package/dist/signer/index.d.ts +1 -1
- package/dist/signer/types.d.ts +4 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vow/index.d.ts +1 -1
- package/dist/vow/index.js +1 -1
- package/dist/vow/verify.d.ts +36 -0
- package/dist/vow/verify.js +458 -1
- package/package.json +1 -1
package/SBOM.spdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"spdxVersion": "SPDX-2.3",
|
|
3
3
|
"dataLicense": "CC0-1.0",
|
|
4
4
|
"SPDXID": "SPDXRef-DOCUMENT",
|
|
5
|
-
"name": "@swarm-tips/client-0.4.
|
|
6
|
-
"documentNamespace": "https://swarm.tips/sbom/client/0.4.
|
|
5
|
+
"name": "@swarm-tips/client-0.4.3",
|
|
6
|
+
"documentNamespace": "https://swarm.tips/sbom/client/0.4.3",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-11-
|
|
8
|
+
"created": "2026-11-13T03:56:51.595Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Tool: sdk/client/scripts/generate-sbom.mjs",
|
|
11
11
|
"Organization: Swarm Tips"
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
{
|
|
16
16
|
"name": "@swarm-tips/client",
|
|
17
17
|
"SPDXID": "SPDXRef-Package",
|
|
18
|
-
"versionInfo": "0.4.
|
|
19
|
-
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.
|
|
18
|
+
"versionInfo": "0.4.3",
|
|
19
|
+
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.3",
|
|
20
20
|
"filesAnalyzed": false,
|
|
21
21
|
"licenseConcluded": "MIT",
|
|
22
22
|
"licenseDeclared": "MIT"
|
package/dist/agent.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { SwarmSigner } from "./signer/types.js";
|
|
|
6
6
|
import { type AgentJob, type AgentReputation, type EigenTrustRecord, type SearchHit } from "./swarm/index.js";
|
|
7
7
|
import type { Verdict } from "./vow/types.js";
|
|
8
8
|
export type SwarmNetwork = "mainnet" | "devnet";
|
|
9
|
+
/** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
|
|
10
|
+
export declare const DEFAULT_MAX_NETWORK_FEE_WEI = 50000000000n;
|
|
9
11
|
export interface SwarmAgentOptions {
|
|
10
12
|
signer?: SwarmSigner;
|
|
11
13
|
token?: string | (() => Promise<string | undefined>);
|
|
@@ -20,6 +22,8 @@ export interface SwarmAgentOptions {
|
|
|
20
22
|
maxEscrowSpendWei?: bigint;
|
|
21
23
|
/** Maximum Solana network fee (base + priority) allowed when wallet is fee payer; default `100_000n` = 0.0001 SOL (C9). */
|
|
22
24
|
maxNetworkFeeLamports?: bigint;
|
|
25
|
+
/** Maximum EVM gas price ceiling (`maxFeePerGas`) in wei; default `50_000_000_000n` = 50 gwei (C9). */
|
|
26
|
+
maxNetworkFeeWei?: bigint;
|
|
23
27
|
fetch?: typeof fetch;
|
|
24
28
|
}
|
|
25
29
|
export type TaskLifecycleStep = "claim" | "submit" | "wait_attestation" | "verify" | "wait_challenge" | "finalize" | "done";
|
|
@@ -36,8 +40,16 @@ export interface ExecutedTaskResult<TConfirm = unknown> {
|
|
|
36
40
|
export interface ExecuteTaskOptions {
|
|
37
41
|
sponsor?: "auto" | "true" | "none";
|
|
38
42
|
connection?: Connection;
|
|
43
|
+
/** Explicit authorized payout destination pubkey (base58) when `set_payout_to` is expected. */
|
|
44
|
+
payoutTo?: string;
|
|
39
45
|
extra?: Record<string, unknown>;
|
|
40
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Extract `escrow_lamports` (`u64` at bytes `[16..24]`) strictly from a Shillbot
|
|
49
|
+
* `create_task` instruction (`program_id === SHILLBOT_PROGRAM_ID` AND
|
|
50
|
+
* `data[0..8] === sha256("global:create_task")[0..8]`).
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractCreateEscrowLamports(encodedTx: string): bigint | undefined;
|
|
41
53
|
/**
|
|
42
54
|
* Unified non-custodial client for Swarm Tips, Shillbot, Inbox/Topics, and Coordination Game.
|
|
43
55
|
*/
|
|
@@ -50,6 +62,7 @@ export declare class SwarmAgent {
|
|
|
50
62
|
readonly maxEscrowSpendLamports: bigint;
|
|
51
63
|
readonly maxEscrowSpendWei: bigint;
|
|
52
64
|
readonly maxNetworkFeeLamports: bigint;
|
|
65
|
+
readonly maxNetworkFeeWei: bigint;
|
|
53
66
|
private readonly signer?;
|
|
54
67
|
private readonly fetchImpl;
|
|
55
68
|
private readonly tokenManager;
|
|
@@ -98,11 +111,14 @@ export declare class SwarmAgent {
|
|
|
98
111
|
buildFinalize: (id: string) => Promise<PreparedTransactionResponse>;
|
|
99
112
|
finalizeAndExecute: (id: string, opts?: {
|
|
100
113
|
connection?: Connection;
|
|
114
|
+
payoutTo?: string;
|
|
101
115
|
}) => Promise<ExecutedTaskResult>;
|
|
102
116
|
nextAction: (task: Record<string, unknown>) => NextTaskAction;
|
|
103
117
|
verifyVow: (urlOrJson: string | Record<string, unknown>, opts?: {
|
|
104
118
|
rpcUrl?: string;
|
|
105
119
|
connection?: Connection;
|
|
120
|
+
maxBytes?: number;
|
|
121
|
+
allowLocalhostHttp?: boolean;
|
|
106
122
|
}) => Promise<Verdict>;
|
|
107
123
|
};
|
|
108
124
|
readonly campaigns: {
|
package/dist/agent.js
CHANGED
|
@@ -4,11 +4,12 @@ import { WalletTokenManager } from "./auth/token-manager.js";
|
|
|
4
4
|
import { CoordinationGameApiClient } from "./coordination-game/api.js";
|
|
5
5
|
import { SwarmClientError } from "./errors.js";
|
|
6
6
|
import { InboxClient, } from "./inbox/client.js";
|
|
7
|
-
import { ShillbotApiClient, estimateSolanaNetworkFeeLamports, signBroadcastPreparedTransaction, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
|
|
8
|
-
import { inspectTransaction } from "./shillbot/index.js";
|
|
7
|
+
import { ShillbotApiClient, estimateSolanaNetworkFeeLamports, normalizeEvmChainId, signBroadcastPreparedTransaction, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
|
|
8
|
+
import { SHILLBOT_PROGRAM_ID, inspectTransaction, shillbotInstructionDiscriminator, } from "./shillbot/index.js";
|
|
9
9
|
import { SwarmClient, } from "./swarm/index.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import { verifyVow } from "./vow/verify.js";
|
|
11
|
+
/** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
|
|
12
|
+
export const DEFAULT_MAX_NETWORK_FEE_WEI = 50000000000n;
|
|
12
13
|
const DEFAULT_SOLANA_RPC = {
|
|
13
14
|
mainnet: "https://api.mainnet-beta.solana.com",
|
|
14
15
|
devnet: "https://api.devnet.solana.com",
|
|
@@ -60,12 +61,21 @@ function extractBodyBigInt(body, keys) {
|
|
|
60
61
|
}
|
|
61
62
|
return undefined;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
+
const SHILLBOT_PROGRAM_ID_B58 = SHILLBOT_PROGRAM_ID.toBase58();
|
|
65
|
+
const CREATE_TASK_DISCRIMINATOR = shillbotInstructionDiscriminator("create_task");
|
|
66
|
+
/**
|
|
67
|
+
* Extract `escrow_lamports` (`u64` at bytes `[16..24]`) strictly from a Shillbot
|
|
68
|
+
* `create_task` instruction (`program_id === SHILLBOT_PROGRAM_ID` AND
|
|
69
|
+
* `data[0..8] === sha256("global:create_task")[0..8]`).
|
|
70
|
+
*/
|
|
71
|
+
export function extractCreateEscrowLamports(encodedTx) {
|
|
64
72
|
try {
|
|
65
73
|
const inspected = inspectTransaction(encodedTx);
|
|
66
74
|
for (const ix of inspected.instructions) {
|
|
75
|
+
if (ix.program_id !== SHILLBOT_PROGRAM_ID_B58)
|
|
76
|
+
continue;
|
|
67
77
|
const data = Buffer.from(ix.data_base64, "base64");
|
|
68
|
-
if (data.length >= 24) {
|
|
78
|
+
if (data.length >= 24 && data.subarray(0, 8).equals(CREATE_TASK_DISCRIMINATOR)) {
|
|
69
79
|
const view = new DataView(data.buffer, data.byteOffset + 16, 8);
|
|
70
80
|
return view.getBigUint64(0, true);
|
|
71
81
|
}
|
|
@@ -88,6 +98,7 @@ export class SwarmAgent {
|
|
|
88
98
|
maxEscrowSpendLamports;
|
|
89
99
|
maxEscrowSpendWei;
|
|
90
100
|
maxNetworkFeeLamports;
|
|
101
|
+
maxNetworkFeeWei;
|
|
91
102
|
signer;
|
|
92
103
|
fetchImpl;
|
|
93
104
|
tokenManager;
|
|
@@ -111,6 +122,7 @@ export class SwarmAgent {
|
|
|
111
122
|
this.maxEscrowSpendLamports = options.maxEscrowSpendLamports ?? 0n;
|
|
112
123
|
this.maxEscrowSpendWei = options.maxEscrowSpendWei ?? 0n;
|
|
113
124
|
this.maxNetworkFeeLamports = options.maxNetworkFeeLamports ?? 100000n;
|
|
125
|
+
this.maxNetworkFeeWei = options.maxNetworkFeeWei ?? DEFAULT_MAX_NETWORK_FEE_WEI;
|
|
114
126
|
this.signer = options.signer;
|
|
115
127
|
const rawFetch = options.fetch ?? globalThis.fetch;
|
|
116
128
|
if (!rawFetch) {
|
|
@@ -213,47 +225,21 @@ export class SwarmAgent {
|
|
|
213
225
|
const prepared = await self.tasks.buildFinalize(id);
|
|
214
226
|
return self.executePreparedAction(id, "finalize", prepared, {
|
|
215
227
|
connection: opts?.connection,
|
|
228
|
+
payoutTo: opts?.payoutTo,
|
|
216
229
|
});
|
|
217
230
|
},
|
|
218
231
|
nextAction: (task) => SwarmAgent.adviseNextAction(task),
|
|
219
232
|
async verifyVow(urlOrJson, opts) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
status: resp.status,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
attestation = await resp.json();
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
try {
|
|
237
|
-
attestation = JSON.parse(trimmed);
|
|
238
|
-
}
|
|
239
|
-
catch (cause) {
|
|
240
|
-
throw new SwarmClientError({
|
|
241
|
-
code: "INVALID_ARGUMENT",
|
|
242
|
-
operation: "tasks.verifyVow",
|
|
243
|
-
message: "Expected VOW URL, JSON string, or object",
|
|
244
|
-
cause,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const net = attestation &&
|
|
250
|
-
typeof attestation === "object" &&
|
|
251
|
-
attestation.network === "devnet"
|
|
252
|
-
? "devnet"
|
|
253
|
-
: self.network;
|
|
254
|
-
const conn = opts?.connection ??
|
|
255
|
-
new Connection(opts?.rpcUrl ?? DEFAULT_SOLANA_RPC[net], "confirmed");
|
|
256
|
-
return verifyV1(attestation, shillbotProtocol, conn);
|
|
233
|
+
const customAgentRpc = self.rpcUrl !== DEFAULT_SOLANA_RPC[self.network] ? self.rpcUrl : undefined;
|
|
234
|
+
return verifyVow(urlOrJson, {
|
|
235
|
+
fetch: self.fetchImpl,
|
|
236
|
+
network: self.network,
|
|
237
|
+
rpcUrl: opts?.rpcUrl ?? customAgentRpc,
|
|
238
|
+
connection: opts?.connection,
|
|
239
|
+
maxBytes: opts?.maxBytes,
|
|
240
|
+
allowLocalhostHttp: opts?.allowLocalhostHttp,
|
|
241
|
+
operation: "tasks.verifyVow",
|
|
242
|
+
});
|
|
257
243
|
},
|
|
258
244
|
};
|
|
259
245
|
this.campaigns = {
|
|
@@ -386,6 +372,7 @@ export class SwarmAgent {
|
|
|
386
372
|
network: this.network,
|
|
387
373
|
wallet: this.signer.address,
|
|
388
374
|
taskPda: prepared.task_pda,
|
|
375
|
+
...(opts?.payoutTo !== undefined ? { payoutTo: opts.payoutTo } : {}),
|
|
389
376
|
});
|
|
390
377
|
if (inspected.fee_payer !== this.signer.address &&
|
|
391
378
|
!isFeePayerAlreadySigned(prepared.transaction)) {
|
|
@@ -402,6 +389,7 @@ export class SwarmAgent {
|
|
|
402
389
|
}
|
|
403
390
|
return this.executePreparedAction(id, action, prepared, {
|
|
404
391
|
connection: opts?.connection,
|
|
392
|
+
payoutTo: opts?.payoutTo,
|
|
405
393
|
});
|
|
406
394
|
}
|
|
407
395
|
async executePreparedAction(id, action, prepared, opts) {
|
|
@@ -443,10 +431,27 @@ export class SwarmAgent {
|
|
|
443
431
|
chain,
|
|
444
432
|
maxValueWei: action === "create" ? this.maxEscrowSpendWei : 0n,
|
|
445
433
|
});
|
|
434
|
+
if (signer.chainId !== undefined) {
|
|
435
|
+
const normalizedSignerChain = normalizeEvmChainId(signer.chainId);
|
|
436
|
+
if (normalizedSignerChain !== validated.chain) {
|
|
437
|
+
throw new SwarmClientError({
|
|
438
|
+
code: "TRANSACTION_MISMATCH",
|
|
439
|
+
operation: `tasks.${action}AndExecute`,
|
|
440
|
+
message: `EVM signer chain ${normalizedSignerChain} differs from validated call chain ${validated.chain}`,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const caipMatch = /^eip155:(\d+)$/.exec(validated.chain);
|
|
445
|
+
const numericChainId = caipMatch ? Number(caipMatch[1]) : undefined;
|
|
446
446
|
const txHash = await signer.sendTransaction({
|
|
447
447
|
to: validated.to,
|
|
448
448
|
data: validated.data,
|
|
449
449
|
value: validated.value,
|
|
450
|
+
chain: validated.chain,
|
|
451
|
+
...(numericChainId !== undefined && Number.isSafeInteger(numericChainId)
|
|
452
|
+
? { chainId: numericChainId }
|
|
453
|
+
: {}),
|
|
454
|
+
maxFeePerGas: this.maxNetworkFeeWei,
|
|
450
455
|
});
|
|
451
456
|
const confirmation = await this.shillbotClient.confirmTask(id, {
|
|
452
457
|
tx_signature: txHash,
|
|
@@ -478,25 +483,37 @@ export class SwarmAgent {
|
|
|
478
483
|
});
|
|
479
484
|
}
|
|
480
485
|
}
|
|
486
|
+
// C9 Network Fee Cap check first so fee cap breaches report SPEND_CAP_EXCEEDED
|
|
487
|
+
let preInspected;
|
|
488
|
+
try {
|
|
489
|
+
preInspected = inspectTransaction(prepared.transaction);
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
throw new SwarmClientError({
|
|
493
|
+
code: "TRANSACTION_MISMATCH",
|
|
494
|
+
operation: `tasks.${action}AndExecute`,
|
|
495
|
+
message: err instanceof Error ? err.message : `Malformed transaction: ${String(err)}`,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
const estimatedFeeLamports = estimateSolanaNetworkFeeLamports(preInspected, signer.address);
|
|
499
|
+
if (estimatedFeeLamports > this.maxNetworkFeeLamports) {
|
|
500
|
+
throw new SwarmClientError({
|
|
501
|
+
code: "SPEND_CAP_EXCEEDED",
|
|
502
|
+
operation: `tasks.${action}AndExecute`,
|
|
503
|
+
message: `Estimated Solana network fee ${estimatedFeeLamports} lamports exceeds maxNetworkFeeLamports (${this.maxNetworkFeeLamports})`,
|
|
504
|
+
});
|
|
505
|
+
}
|
|
481
506
|
const expected = {
|
|
482
507
|
action,
|
|
483
508
|
network: this.network,
|
|
484
509
|
wallet: signer.address,
|
|
485
510
|
taskPda: prepared.task_pda,
|
|
511
|
+
...(opts.payoutTo !== undefined ? { payoutTo: opts.payoutTo } : {}),
|
|
486
512
|
...(action === "create" && opts.expectedEscrowLamports !== undefined
|
|
487
513
|
? { escrowLamports: opts.expectedEscrowLamports }
|
|
488
514
|
: {}),
|
|
489
515
|
};
|
|
490
|
-
|
|
491
|
-
// C9 Network Fee Cap check whenever the agent's wallet pays transaction fees
|
|
492
|
-
const estimatedFeeLamports = estimateSolanaNetworkFeeLamports(inspected, signer.address);
|
|
493
|
-
if (estimatedFeeLamports > this.maxNetworkFeeLamports) {
|
|
494
|
-
throw new SwarmClientError({
|
|
495
|
-
code: "SPEND_CAP_EXCEEDED",
|
|
496
|
-
operation: `tasks.${action}AndExecute`,
|
|
497
|
-
message: `Estimated Solana network fee ${estimatedFeeLamports} lamports exceeds maxNetworkFeeLamports (${this.maxNetworkFeeLamports})`,
|
|
498
|
-
});
|
|
499
|
-
}
|
|
516
|
+
validatePreparedTransaction(prepared.transaction, expected);
|
|
500
517
|
const connection = opts.connection ?? new Connection(this.rpcUrl, "confirmed");
|
|
501
518
|
const signature = await signBroadcastPreparedTransaction({
|
|
502
519
|
connection,
|
package/dist/cli/swarm.d.ts
CHANGED
|
@@ -11,4 +11,9 @@ export interface CliIo {
|
|
|
11
11
|
env?: Record<string, string | undefined>;
|
|
12
12
|
fetch?: typeof fetch;
|
|
13
13
|
}
|
|
14
|
+
export interface ParsedCliArgs {
|
|
15
|
+
positionals: string[];
|
|
16
|
+
flags: Map<string, string | boolean>;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseCliArgs(argv: readonly string[]): ParsedCliArgs;
|
|
14
19
|
export declare function runSwarmCli(argv: readonly string[], io?: CliIo): Promise<number>;
|
package/dist/cli/swarm.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFileSync, realpathSync } from "node:fs";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { SwarmAgent } from "../agent.js";
|
|
5
5
|
import { SwarmClientError } from "../errors.js";
|
|
6
|
+
import { VALID_TOPICS, isValidTopicId } from "../inbox/types.js";
|
|
6
7
|
import { validatePreparedTransaction } from "../shillbot/api.js";
|
|
7
8
|
import { inspectTransaction } from "../shillbot/index.js";
|
|
8
9
|
import { CLIENT_VERSION } from "../version.js";
|
|
@@ -17,13 +18,19 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
17
18
|
"--no-exec",
|
|
18
19
|
"--unmute",
|
|
19
20
|
"--cursor",
|
|
21
|
+
"--allow-localhost-http",
|
|
20
22
|
]);
|
|
21
|
-
function parseCliArgs(argv) {
|
|
23
|
+
export function parseCliArgs(argv) {
|
|
22
24
|
assertNoSecretCliFlags(argv);
|
|
25
|
+
const effectiveArgv = argv[0] === "--" ? argv.slice(1) : argv;
|
|
23
26
|
const positionals = [];
|
|
24
27
|
const flags = new Map();
|
|
25
|
-
for (let i = 0; i <
|
|
26
|
-
const token =
|
|
28
|
+
for (let i = 0; i < effectiveArgv.length; i += 1) {
|
|
29
|
+
const token = effectiveArgv[i];
|
|
30
|
+
if (token === "--") {
|
|
31
|
+
positionals.push(...effectiveArgv.slice(i + 1));
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
27
34
|
if (!token.startsWith("-") || token === "-") {
|
|
28
35
|
positionals.push(token);
|
|
29
36
|
continue;
|
|
@@ -39,7 +46,7 @@ function parseCliArgs(argv) {
|
|
|
39
46
|
flags.set(token, true);
|
|
40
47
|
continue;
|
|
41
48
|
}
|
|
42
|
-
const next =
|
|
49
|
+
const next = effectiveArgv[i + 1];
|
|
43
50
|
if (next === undefined || (next.startsWith("--") && next.length > 2)) {
|
|
44
51
|
throw new CliUsageError(`Flag ${token} requires a value.`);
|
|
45
52
|
}
|
|
@@ -95,8 +102,8 @@ Commands:
|
|
|
95
102
|
listings [--limit N] [--category CAT] [--chain CHAIN]
|
|
96
103
|
reputation <wallet>
|
|
97
104
|
tasks list [--limit N] | mine | earnings | next <task-json-or-id>
|
|
98
|
-
tasks claim <id> [--no-exec]
|
|
99
|
-
tasks submit <id> --content <str> [--no-exec]
|
|
105
|
+
tasks claim <id> [--payout-to <pubkey>] [--no-exec]
|
|
106
|
+
tasks submit <id> --content <str> [--payout-to <pubkey>] [--no-exec]
|
|
100
107
|
tasks verify <id> [--no-exec]
|
|
101
108
|
tasks finalize <id> [--no-exec]
|
|
102
109
|
inbox list [--status pending|all] [--limit N]
|
|
@@ -104,10 +111,10 @@ Commands:
|
|
|
104
111
|
inbox send <to_wallet> <body> [--thread <id>] [--intent <intent>]
|
|
105
112
|
inbox ack <msg_id> [--cursor]
|
|
106
113
|
inbox mute <thread_id> [--unmute]
|
|
107
|
-
topics read <open-challenge|subcontract> [--limit N]
|
|
108
|
-
topics publish <
|
|
114
|
+
topics read <open-challenge|subcontract|town-square> [--limit N]
|
|
115
|
+
topics publish <open-challenge|subcontract|town-square> <body> [--ref <id>] [--reply-to <id>] [--intent <intent>]
|
|
109
116
|
tx inspect [--tx <base64>]
|
|
110
|
-
tx verify --action <claim|submit|verify|finalize|approve|create> --wallet <pubkey> [--task-pda <pda>] [--tx <base64>]
|
|
117
|
+
tx verify --action <claim|submit|verify|finalize|approve|create> --wallet <pubkey> [--task-pda <pda>] [--payout-to <pubkey>] [--tx <base64>]
|
|
111
118
|
vow-verify <file-or-url> [--rpc <url>]
|
|
112
119
|
|
|
113
120
|
Global Options:
|
|
@@ -220,6 +227,8 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
220
227
|
}
|
|
221
228
|
const taskPda = getStringFlag(flags, "--task-pda");
|
|
222
229
|
const feePayer = getStringFlag(flags, "--fee-payer");
|
|
230
|
+
const payoutTo = getStringFlag(flags, "--payout-to");
|
|
231
|
+
const oracleAuthority = getStringFlag(flags, "--oracle-authority");
|
|
223
232
|
const escrowLamports = getBigIntFlag(flags, "--escrow-lamports");
|
|
224
233
|
try {
|
|
225
234
|
const inspection = validatePreparedTransaction(txB64, {
|
|
@@ -228,6 +237,8 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
228
237
|
wallet,
|
|
229
238
|
...(taskPda ? { taskPda } : {}),
|
|
230
239
|
...(feePayer ? { feePayer } : {}),
|
|
240
|
+
...(payoutTo ? { payoutTo } : {}),
|
|
241
|
+
...(oracleAuthority ? { oracleAuthority } : {}),
|
|
231
242
|
...(escrowLamports !== undefined ? { escrowLamports } : {}),
|
|
232
243
|
});
|
|
233
244
|
writeOutput(stdout, jsonMode, { ok: true, inspection });
|
|
@@ -330,8 +341,11 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
330
341
|
if (sub === "claim") {
|
|
331
342
|
const id = rest[0];
|
|
332
343
|
if (!id)
|
|
333
|
-
throw new CliUsageError("Usage: swarm tasks claim <task_id> [--no-exec]");
|
|
334
|
-
const
|
|
344
|
+
throw new CliUsageError("Usage: swarm tasks claim <task_id> [--payout-to <pubkey>] [--no-exec]");
|
|
345
|
+
const payoutTo = getStringFlag(flags, "--payout-to");
|
|
346
|
+
const res = noExec
|
|
347
|
+
? await agent.tasks.claim(id)
|
|
348
|
+
: await agent.tasks.claimAndExecute(id, payoutTo ? { payoutTo } : undefined);
|
|
335
349
|
writeOutput(stdout, jsonMode, res);
|
|
336
350
|
return 0;
|
|
337
351
|
}
|
|
@@ -339,11 +353,12 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
339
353
|
const id = rest[0];
|
|
340
354
|
const content = getStringFlag(flags, "--content");
|
|
341
355
|
if (!id || !content) {
|
|
342
|
-
throw new CliUsageError("Usage: swarm tasks submit <task_id> --content <str> [--no-exec]");
|
|
356
|
+
throw new CliUsageError("Usage: swarm tasks submit <task_id> --content <str> [--payout-to <pubkey>] [--no-exec]");
|
|
343
357
|
}
|
|
358
|
+
const payoutTo = getStringFlag(flags, "--payout-to");
|
|
344
359
|
const res = noExec
|
|
345
360
|
? await agent.tasks.submit(id, { content_id: content })
|
|
346
|
-
: await agent.tasks.submitAndExecute(id, content);
|
|
361
|
+
: await agent.tasks.submitAndExecute(id, content, payoutTo ? { payoutTo } : undefined);
|
|
347
362
|
writeOutput(stdout, jsonMode, res);
|
|
348
363
|
return 0;
|
|
349
364
|
}
|
|
@@ -430,8 +445,8 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
430
445
|
if (cmd === "topics") {
|
|
431
446
|
if (sub === "read") {
|
|
432
447
|
const topic = rest[0];
|
|
433
|
-
if (topic
|
|
434
|
-
throw new CliUsageError(
|
|
448
|
+
if (!isValidTopicId(topic)) {
|
|
449
|
+
throw new CliUsageError(`Usage: swarm topics read <${VALID_TOPICS.join("|")}>`);
|
|
435
450
|
}
|
|
436
451
|
const res = await agent.topics.read(topic, {
|
|
437
452
|
limit: getIntFlag(flags, "--limit"),
|
|
@@ -441,8 +456,8 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
441
456
|
}
|
|
442
457
|
if (sub === "publish") {
|
|
443
458
|
const [topic, body] = rest;
|
|
444
|
-
if ((topic
|
|
445
|
-
throw new CliUsageError(
|
|
459
|
+
if (!isValidTopicId(topic) || !body) {
|
|
460
|
+
throw new CliUsageError(`Usage: swarm topics publish <${VALID_TOPICS.join("|")}> <body> [--ref <id>]`);
|
|
446
461
|
}
|
|
447
462
|
const res = await agent.topics.publish(topic, body, {
|
|
448
463
|
refId: getStringFlag(flags, "--ref"),
|
|
@@ -463,7 +478,7 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
463
478
|
if (target === "-") {
|
|
464
479
|
payload = await readStdinText(io);
|
|
465
480
|
}
|
|
466
|
-
else if (/^
|
|
481
|
+
else if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(target)) {
|
|
467
482
|
payload = target;
|
|
468
483
|
}
|
|
469
484
|
else {
|
|
@@ -474,7 +489,10 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
474
489
|
throw new CliUsageError(`Failed to read VOW JSON file ${target}: ${err instanceof Error ? err.message : String(err)}`);
|
|
475
490
|
}
|
|
476
491
|
}
|
|
477
|
-
const verdict = await agent.tasks.verifyVow(payload, {
|
|
492
|
+
const verdict = await agent.tasks.verifyVow(payload, {
|
|
493
|
+
rpcUrl,
|
|
494
|
+
allowLocalhostHttp: Boolean(flags.get("--allow-localhost-http")),
|
|
495
|
+
});
|
|
478
496
|
writeOutput(stdout, jsonMode, verdict);
|
|
479
497
|
return verdict.valid ? 0 : 1;
|
|
480
498
|
}
|
|
@@ -998,6 +998,31 @@ export type CoordinationGame = {
|
|
|
998
998
|
];
|
|
999
999
|
};
|
|
1000
1000
|
},
|
|
1001
|
+
{
|
|
1002
|
+
"name": "globalConfig";
|
|
1003
|
+
"pda": {
|
|
1004
|
+
"seeds": [
|
|
1005
|
+
{
|
|
1006
|
+
"kind": "const";
|
|
1007
|
+
"value": [
|
|
1008
|
+
103,
|
|
1009
|
+
108,
|
|
1010
|
+
111,
|
|
1011
|
+
98,
|
|
1012
|
+
97,
|
|
1013
|
+
108,
|
|
1014
|
+
95,
|
|
1015
|
+
99,
|
|
1016
|
+
111,
|
|
1017
|
+
110,
|
|
1018
|
+
102,
|
|
1019
|
+
105,
|
|
1020
|
+
103
|
|
1021
|
+
];
|
|
1022
|
+
}
|
|
1023
|
+
];
|
|
1024
|
+
};
|
|
1025
|
+
},
|
|
1001
1026
|
{
|
|
1002
1027
|
"name": "authority";
|
|
1003
1028
|
"writable": true;
|
|
@@ -1221,11 +1246,38 @@ export type CoordinationGame = {
|
|
|
1221
1246
|
{
|
|
1222
1247
|
"name": "tournament";
|
|
1223
1248
|
},
|
|
1249
|
+
{
|
|
1250
|
+
"name": "globalConfig";
|
|
1251
|
+
"pda": {
|
|
1252
|
+
"seeds": [
|
|
1253
|
+
{
|
|
1254
|
+
"kind": "const";
|
|
1255
|
+
"value": [
|
|
1256
|
+
103,
|
|
1257
|
+
108,
|
|
1258
|
+
111,
|
|
1259
|
+
98,
|
|
1260
|
+
97,
|
|
1261
|
+
108,
|
|
1262
|
+
95,
|
|
1263
|
+
99,
|
|
1264
|
+
111,
|
|
1265
|
+
110,
|
|
1266
|
+
102,
|
|
1267
|
+
105,
|
|
1268
|
+
103
|
|
1269
|
+
];
|
|
1270
|
+
}
|
|
1271
|
+
];
|
|
1272
|
+
};
|
|
1273
|
+
},
|
|
1224
1274
|
{
|
|
1225
1275
|
"name": "player";
|
|
1226
1276
|
"docs": [
|
|
1227
|
-
"Verified against session_authority.player in the handler."
|
|
1277
|
+
"Verified against session_authority.player in the handler. Mutable so any",
|
|
1278
|
+
"downward stake re-peg excess refunds strictly to the player wallet."
|
|
1228
1279
|
];
|
|
1280
|
+
"writable": true;
|
|
1229
1281
|
},
|
|
1230
1282
|
{
|
|
1231
1283
|
"name": "sessionAuthority";
|
|
@@ -2166,6 +2218,89 @@ export type CoordinationGame = {
|
|
|
2166
2218
|
}
|
|
2167
2219
|
];
|
|
2168
2220
|
},
|
|
2221
|
+
{
|
|
2222
|
+
"name": "proveLocalEquivocation";
|
|
2223
|
+
"discriminator": [
|
|
2224
|
+
57,
|
|
2225
|
+
20,
|
|
2226
|
+
235,
|
|
2227
|
+
37,
|
|
2228
|
+
36,
|
|
2229
|
+
185,
|
|
2230
|
+
45,
|
|
2231
|
+
214
|
|
2232
|
+
];
|
|
2233
|
+
"accounts": [
|
|
2234
|
+
{
|
|
2235
|
+
"name": "xmatch";
|
|
2236
|
+
"writable": true;
|
|
2237
|
+
"pda": {
|
|
2238
|
+
"seeds": [
|
|
2239
|
+
{
|
|
2240
|
+
"kind": "const";
|
|
2241
|
+
"value": [
|
|
2242
|
+
120,
|
|
2243
|
+
109,
|
|
2244
|
+
97,
|
|
2245
|
+
116,
|
|
2246
|
+
99,
|
|
2247
|
+
104
|
|
2248
|
+
];
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
"kind": "arg";
|
|
2252
|
+
"path": "matchId";
|
|
2253
|
+
}
|
|
2254
|
+
];
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
];
|
|
2258
|
+
"args": [
|
|
2259
|
+
{
|
|
2260
|
+
"name": "matchId";
|
|
2261
|
+
"type": {
|
|
2262
|
+
"array": [
|
|
2263
|
+
"u8",
|
|
2264
|
+
32
|
|
2265
|
+
];
|
|
2266
|
+
};
|
|
2267
|
+
},
|
|
2268
|
+
{
|
|
2269
|
+
"name": "cpA";
|
|
2270
|
+
"type": {
|
|
2271
|
+
"defined": {
|
|
2272
|
+
"name": "checkpointArg";
|
|
2273
|
+
};
|
|
2274
|
+
};
|
|
2275
|
+
},
|
|
2276
|
+
{
|
|
2277
|
+
"name": "cpB";
|
|
2278
|
+
"type": {
|
|
2279
|
+
"defined": {
|
|
2280
|
+
"name": "checkpointArg";
|
|
2281
|
+
};
|
|
2282
|
+
};
|
|
2283
|
+
},
|
|
2284
|
+
{
|
|
2285
|
+
"name": "sigA";
|
|
2286
|
+
"type": {
|
|
2287
|
+
"array": [
|
|
2288
|
+
"u8",
|
|
2289
|
+
65
|
|
2290
|
+
];
|
|
2291
|
+
};
|
|
2292
|
+
},
|
|
2293
|
+
{
|
|
2294
|
+
"name": "sigB";
|
|
2295
|
+
"type": {
|
|
2296
|
+
"array": [
|
|
2297
|
+
"u8",
|
|
2298
|
+
65
|
|
2299
|
+
];
|
|
2300
|
+
};
|
|
2301
|
+
}
|
|
2302
|
+
];
|
|
2303
|
+
},
|
|
2169
2304
|
{
|
|
2170
2305
|
"name": "refundPending";
|
|
2171
2306
|
"discriminator": [
|
|
@@ -4185,6 +4320,19 @@ export type CoordinationGame = {
|
|
|
4185
4320
|
226
|
|
4186
4321
|
];
|
|
4187
4322
|
},
|
|
4323
|
+
{
|
|
4324
|
+
"name": "xLocalEquivocationProven";
|
|
4325
|
+
"discriminator": [
|
|
4326
|
+
140,
|
|
4327
|
+
113,
|
|
4328
|
+
104,
|
|
4329
|
+
158,
|
|
4330
|
+
24,
|
|
4331
|
+
7,
|
|
4332
|
+
144,
|
|
4333
|
+
217
|
|
4334
|
+
];
|
|
4335
|
+
},
|
|
4188
4336
|
{
|
|
4189
4337
|
"name": "xMatchCreated";
|
|
4190
4338
|
"discriminator": [
|
|
@@ -5921,6 +6069,36 @@ export type CoordinationGame = {
|
|
|
5921
6069
|
];
|
|
5922
6070
|
};
|
|
5923
6071
|
},
|
|
6072
|
+
{
|
|
6073
|
+
"name": "xLocalEquivocationProven";
|
|
6074
|
+
"type": {
|
|
6075
|
+
"kind": "struct";
|
|
6076
|
+
"fields": [
|
|
6077
|
+
{
|
|
6078
|
+
"name": "matchId";
|
|
6079
|
+
"type": {
|
|
6080
|
+
"array": [
|
|
6081
|
+
"u8",
|
|
6082
|
+
32
|
|
6083
|
+
];
|
|
6084
|
+
};
|
|
6085
|
+
},
|
|
6086
|
+
{
|
|
6087
|
+
"name": "sessionKey";
|
|
6088
|
+
"type": {
|
|
6089
|
+
"array": [
|
|
6090
|
+
"u8",
|
|
6091
|
+
20
|
|
6092
|
+
];
|
|
6093
|
+
};
|
|
6094
|
+
},
|
|
6095
|
+
{
|
|
6096
|
+
"name": "newBestOutcome";
|
|
6097
|
+
"type": "u8";
|
|
6098
|
+
}
|
|
6099
|
+
];
|
|
6100
|
+
};
|
|
6101
|
+
},
|
|
5924
6102
|
{
|
|
5925
6103
|
"name": "xMatchCreated";
|
|
5926
6104
|
"type": {
|