@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.
- package/SBOM.spdx.json +5 -5
- package/dist/agent.d.ts +26 -0
- package/dist/agent.js +91 -7
- package/dist/cli/swarm.js +29 -4
- package/dist/coordination-game/api.d.ts +49 -0
- package/dist/coordination-game/api.js +9 -0
- package/dist/coordination-game/evm/abi.d.ts +273 -5
- package/dist/coordination-game/evm/abi.js +347 -5
- package/dist/coordination-game/evm/cross-chain.d.ts +64 -1
- package/dist/coordination-game/evm/cross-chain.js +129 -6
- package/dist/coordination-game/evm/index.d.ts +2 -0
- package/dist/coordination-game/evm/index.js +1 -0
- package/dist/coordination-game/index.d.ts +1 -0
- package/dist/evm/index.d.ts +1 -1
- package/dist/evm/index.js +1 -1
- package/dist/evm/sign.d.ts +6 -0
- package/dist/evm/sign.js +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/shillbot/api.d.ts +11 -2
- package/dist/shillbot/api.js +22 -4
- package/dist/shillbot/index.d.ts +41 -3
- package/dist/shillbot/index.js +114 -7
- package/dist/shillbot/verify-tx.d.ts +9 -1
- package/dist/shillbot/verify-tx.js +128 -14
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -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.6",
|
|
6
|
+
"documentNamespace": "https://swarm.tips/sbom/client/0.4.6",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-11-
|
|
8
|
+
"created": "2026-11-17T04:19:23.433Z",
|
|
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.6",
|
|
19
|
+
"downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.6",
|
|
20
20
|
"filesAnalyzed": false,
|
|
21
21
|
"licenseConcluded": "MIT",
|
|
22
22
|
"licenseDeclared": "MIT"
|
package/dist/agent.d.ts
CHANGED
|
@@ -107,12 +107,18 @@ export declare class SwarmAgent {
|
|
|
107
107
|
buildVerify: (id: string) => Promise<PreparedTransactionResponse>;
|
|
108
108
|
verifyAndExecute: (id: string, opts?: {
|
|
109
109
|
connection?: Connection;
|
|
110
|
+
payoutTo?: string;
|
|
110
111
|
}) => Promise<ExecutedTaskResult>;
|
|
111
112
|
buildFinalize: (id: string) => Promise<PreparedTransactionResponse>;
|
|
112
113
|
finalizeAndExecute: (id: string, opts?: {
|
|
113
114
|
connection?: Connection;
|
|
114
115
|
payoutTo?: string;
|
|
115
116
|
}) => Promise<ExecutedTaskResult>;
|
|
117
|
+
buildExpire: (id: string) => Promise<PreparedTransactionResponse>;
|
|
118
|
+
expireAndExecute: (id: string, opts?: {
|
|
119
|
+
connection?: Connection;
|
|
120
|
+
chain?: string;
|
|
121
|
+
}) => Promise<ExecutedTaskResult>;
|
|
116
122
|
nextAction: (task: Record<string, unknown>) => NextTaskAction;
|
|
117
123
|
verifyVow: (urlOrJson: string | Record<string, unknown>, opts?: {
|
|
118
124
|
rpcUrl?: string;
|
|
@@ -139,6 +145,11 @@ export declare class SwarmAgent {
|
|
|
139
145
|
connection?: Connection;
|
|
140
146
|
chain?: string;
|
|
141
147
|
}) => Promise<ExecutedTaskResult>;
|
|
148
|
+
expire: (id: string) => Promise<PreparedTransactionResponse>;
|
|
149
|
+
expireAndExecute: (id: string, opts?: {
|
|
150
|
+
connection?: Connection;
|
|
151
|
+
chain?: string;
|
|
152
|
+
}) => Promise<ExecutedTaskResult>;
|
|
142
153
|
};
|
|
143
154
|
readonly inbox: {
|
|
144
155
|
list: (opts?: InboxListOptions) => Promise<InboxListPage>;
|
|
@@ -185,6 +196,21 @@ export declare class SwarmAgent {
|
|
|
185
196
|
constructor(options?: SwarmAgentOptions);
|
|
186
197
|
private requireSigner;
|
|
187
198
|
private executeClaimOrSubmit;
|
|
199
|
+
/**
|
|
200
|
+
* Resolve an authorized `payoutTo` pubkey (`P1-2` / `HIGH-02`):
|
|
201
|
+
* - If caller explicitly passed `explicitPayoutTo`, return it verbatim.
|
|
202
|
+
* - Otherwise, NEVER trust `advance_backer` from the API response alone:
|
|
203
|
+
* 1. Verify `advancePda(advance_backer, walletAddress) === prepared.payout_to`.
|
|
204
|
+
* 2. Fetch the PDA on-chain via `connection.getAccountInfo(derived, "confirmed")` and require:
|
|
205
|
+
* - account exists (`acct !== null && acct.lamports > 0`),
|
|
206
|
+
* - `acct.owner.equals(EXTENSION_CREDIT_PROGRAM_ID)`,
|
|
207
|
+
* - valid 113-byte `Advance` account (`sha256("account:Advance")[0..8]`) with
|
|
208
|
+
* `backer === advance_backer`, `recipient === walletAddress`, and
|
|
209
|
+
* `recouped_lamports < advance_lamports`.
|
|
210
|
+
* 3. On any mismatch or RPC error, return `undefined` so `validatePreparedTransaction`
|
|
211
|
+
* rejects any `set_payout_to` fail-closed.
|
|
212
|
+
*/
|
|
213
|
+
private static resolveVerifiedAdvancePayoutTo;
|
|
188
214
|
private executePreparedAction;
|
|
189
215
|
private executeEvmAction;
|
|
190
216
|
private executeSolanaAction;
|
package/dist/agent.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
|
-
import { Connection, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { Connection, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
3
3
|
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
7
|
import { ShillbotApiClient, estimateSolanaNetworkFeeLamports, normalizeEvmChainId, signBroadcastPreparedTransaction, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
|
|
8
|
-
import { SHILLBOT_PROGRAM_ID, inspectTransaction, shillbotInstructionDiscriminator, } from "./shillbot/index.js";
|
|
8
|
+
import { EXTENSION_CREDIT_PROGRAM_ID, SHILLBOT_PROGRAM_ID, advancePda, decodeExtensionCreditAdvance, inspectTransaction, shillbotInstructionDiscriminator, } from "./shillbot/index.js";
|
|
9
9
|
import { SwarmClient, } from "./swarm/index.js";
|
|
10
10
|
import { verifyVow } from "./vow/verify.js";
|
|
11
11
|
/** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
|
|
@@ -218,6 +218,7 @@ export class SwarmAgent {
|
|
|
218
218
|
const prepared = await self.tasks.buildVerify(id);
|
|
219
219
|
return self.executePreparedAction(id, "verify", prepared, {
|
|
220
220
|
connection: opts?.connection,
|
|
221
|
+
payoutTo: opts?.payoutTo,
|
|
221
222
|
});
|
|
222
223
|
},
|
|
223
224
|
buildFinalize: (id) => self.shillbotClient.buildFinalize(id),
|
|
@@ -228,6 +229,14 @@ export class SwarmAgent {
|
|
|
228
229
|
payoutTo: opts?.payoutTo,
|
|
229
230
|
});
|
|
230
231
|
},
|
|
232
|
+
buildExpire: (id) => self.shillbotClient.buildExpire(id),
|
|
233
|
+
async expireAndExecute(id, opts) {
|
|
234
|
+
const prepared = await self.tasks.buildExpire(id);
|
|
235
|
+
return self.executePreparedAction(id, "expire", prepared, {
|
|
236
|
+
connection: opts?.connection,
|
|
237
|
+
chain: opts?.chain,
|
|
238
|
+
});
|
|
239
|
+
},
|
|
231
240
|
nextAction: (task) => SwarmAgent.adviseNextAction(task),
|
|
232
241
|
async verifyVow(urlOrJson, opts) {
|
|
233
242
|
const customAgentRpc = self.rpcUrl !== DEFAULT_SOLANA_RPC[self.network] ? self.rpcUrl : undefined;
|
|
@@ -290,6 +299,14 @@ export class SwarmAgent {
|
|
|
290
299
|
chain: opts?.chain,
|
|
291
300
|
});
|
|
292
301
|
},
|
|
302
|
+
expire: (id) => self.shillbotClient.buildExpire(id),
|
|
303
|
+
async expireAndExecute(id, opts) {
|
|
304
|
+
const prepared = await self.shillbotClient.buildExpire(id);
|
|
305
|
+
return self.executePreparedAction(id, "expire", prepared, {
|
|
306
|
+
connection: opts?.connection,
|
|
307
|
+
chain: opts?.chain,
|
|
308
|
+
});
|
|
309
|
+
},
|
|
293
310
|
};
|
|
294
311
|
this.inbox = {
|
|
295
312
|
list: (opts) => self.inboxClient.listMessages(opts),
|
|
@@ -362,6 +379,13 @@ export class SwarmAgent {
|
|
|
362
379
|
throw err;
|
|
363
380
|
}
|
|
364
381
|
}
|
|
382
|
+
const connection = this.signer?.chain === "solana"
|
|
383
|
+
? (opts?.connection ?? new Connection(this.rpcUrl, "confirmed"))
|
|
384
|
+
: opts?.connection;
|
|
385
|
+
let resolvedPayoutTo = connection && this.signer?.chain === "solana"
|
|
386
|
+
? await SwarmAgent.resolveVerifiedAdvancePayoutTo(prepared, this.signer.address, connection, opts?.payoutTo)
|
|
387
|
+
: opts?.payoutTo;
|
|
388
|
+
let payoutToResolved = Boolean(connection && this.signer?.chain === "solana");
|
|
365
389
|
// If Solana transaction is a gasless sponsor template (fee_payer !== wallet & unsigned by sponsor),
|
|
366
390
|
// exchange it via POST /tasks/{id}/sponsor before signing locally.
|
|
367
391
|
if (prepared.transaction &&
|
|
@@ -372,10 +396,11 @@ export class SwarmAgent {
|
|
|
372
396
|
network: this.network,
|
|
373
397
|
wallet: this.signer.address,
|
|
374
398
|
taskPda: prepared.task_pda,
|
|
375
|
-
...(
|
|
399
|
+
...(resolvedPayoutTo !== undefined ? { payoutTo: resolvedPayoutTo } : {}),
|
|
376
400
|
});
|
|
377
401
|
if (inspected.fee_payer !== this.signer.address &&
|
|
378
402
|
!isFeePayerAlreadySigned(prepared.transaction)) {
|
|
403
|
+
const prevPayoutTo = prepared.payout_to;
|
|
379
404
|
const sponsored = await this.shillbotClient.sponsorTask(id, {
|
|
380
405
|
action,
|
|
381
406
|
unsigned_transaction: prepared.transaction,
|
|
@@ -385,13 +410,69 @@ export class SwarmAgent {
|
|
|
385
410
|
...sponsored,
|
|
386
411
|
task_pda: sponsored.task_pda ?? prepared.task_pda,
|
|
387
412
|
};
|
|
413
|
+
if (opts?.payoutTo === undefined && prepared.payout_to !== prevPayoutTo) {
|
|
414
|
+
resolvedPayoutTo = undefined;
|
|
415
|
+
payoutToResolved = false;
|
|
416
|
+
}
|
|
388
417
|
}
|
|
389
418
|
}
|
|
390
419
|
return this.executePreparedAction(id, action, prepared, {
|
|
391
|
-
connection
|
|
392
|
-
payoutTo:
|
|
420
|
+
connection,
|
|
421
|
+
payoutTo: resolvedPayoutTo,
|
|
422
|
+
payoutToResolved,
|
|
393
423
|
});
|
|
394
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* Resolve an authorized `payoutTo` pubkey (`P1-2` / `HIGH-02`):
|
|
427
|
+
* - If caller explicitly passed `explicitPayoutTo`, return it verbatim.
|
|
428
|
+
* - Otherwise, NEVER trust `advance_backer` from the API response alone:
|
|
429
|
+
* 1. Verify `advancePda(advance_backer, walletAddress) === prepared.payout_to`.
|
|
430
|
+
* 2. Fetch the PDA on-chain via `connection.getAccountInfo(derived, "confirmed")` and require:
|
|
431
|
+
* - account exists (`acct !== null && acct.lamports > 0`),
|
|
432
|
+
* - `acct.owner.equals(EXTENSION_CREDIT_PROGRAM_ID)`,
|
|
433
|
+
* - valid 113-byte `Advance` account (`sha256("account:Advance")[0..8]`) with
|
|
434
|
+
* `backer === advance_backer`, `recipient === walletAddress`, and
|
|
435
|
+
* `recouped_lamports < advance_lamports`.
|
|
436
|
+
* 3. On any mismatch or RPC error, return `undefined` so `validatePreparedTransaction`
|
|
437
|
+
* rejects any `set_payout_to` fail-closed.
|
|
438
|
+
*/
|
|
439
|
+
static async resolveVerifiedAdvancePayoutTo(prepared, walletAddress, connection, explicitPayoutTo) {
|
|
440
|
+
if (explicitPayoutTo !== undefined) {
|
|
441
|
+
return explicitPayoutTo;
|
|
442
|
+
}
|
|
443
|
+
if (!walletAddress || !prepared.payout_to || !prepared.advance_backer) {
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
try {
|
|
447
|
+
const expectedBacker = new PublicKey(prepared.advance_backer);
|
|
448
|
+
const expectedRecipient = new PublicKey(walletAddress);
|
|
449
|
+
const derived = advancePda(expectedBacker, expectedRecipient);
|
|
450
|
+
if (derived.toBase58() !== prepared.payout_to) {
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
const acct = await connection.getAccountInfo(derived, "confirmed");
|
|
454
|
+
if (!acct || acct.lamports <= 0) {
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
if (!acct.owner.equals(EXTENSION_CREDIT_PROGRAM_ID)) {
|
|
458
|
+
return undefined;
|
|
459
|
+
}
|
|
460
|
+
const decoded = decodeExtensionCreditAdvance(acct.data);
|
|
461
|
+
if (!decoded) {
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
if (!decoded.backer.equals(expectedBacker) ||
|
|
465
|
+
!decoded.recipient.equals(expectedRecipient) ||
|
|
466
|
+
decoded.advanceLamports === 0n ||
|
|
467
|
+
decoded.recoupedLamports >= decoded.advanceLamports) {
|
|
468
|
+
return undefined;
|
|
469
|
+
}
|
|
470
|
+
return derived.toBase58();
|
|
471
|
+
}
|
|
472
|
+
catch {
|
|
473
|
+
return undefined;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
395
476
|
async executePreparedAction(id, action, prepared, opts) {
|
|
396
477
|
const signer = this.requireSigner();
|
|
397
478
|
if (prepared.evm_call && signer.chain === "evm") {
|
|
@@ -503,18 +584,21 @@ export class SwarmAgent {
|
|
|
503
584
|
message: `Estimated Solana network fee ${estimatedFeeLamports} lamports exceeds maxNetworkFeeLamports (${this.maxNetworkFeeLamports})`,
|
|
504
585
|
});
|
|
505
586
|
}
|
|
587
|
+
const connection = opts.connection ?? new Connection(this.rpcUrl, "confirmed");
|
|
588
|
+
const resolvedPayoutTo = opts.payoutToResolved
|
|
589
|
+
? opts.payoutTo
|
|
590
|
+
: await SwarmAgent.resolveVerifiedAdvancePayoutTo(prepared, signer.address, connection, opts.payoutTo);
|
|
506
591
|
const expected = {
|
|
507
592
|
action,
|
|
508
593
|
network: this.network,
|
|
509
594
|
wallet: signer.address,
|
|
510
595
|
taskPda: prepared.task_pda,
|
|
511
|
-
...(
|
|
596
|
+
...(resolvedPayoutTo !== undefined ? { payoutTo: resolvedPayoutTo } : {}),
|
|
512
597
|
...(action === "create" && opts.expectedEscrowLamports !== undefined
|
|
513
598
|
? { escrowLamports: opts.expectedEscrowLamports }
|
|
514
599
|
: {}),
|
|
515
600
|
};
|
|
516
601
|
validatePreparedTransaction(prepared.transaction, expected);
|
|
517
|
-
const connection = opts.connection ?? new Connection(this.rpcUrl, "confirmed");
|
|
518
602
|
const signature = await signBroadcastPreparedTransaction({
|
|
519
603
|
connection,
|
|
520
604
|
transaction: prepared.transaction,
|
package/dist/cli/swarm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { SwarmAgent } from "../agent.js";
|
|
5
5
|
import { SwarmClientError } from "../errors.js";
|
|
6
6
|
import { VALID_TOPICS, isValidTopicId } from "../inbox/types.js";
|
|
7
|
-
import { validatePreparedTransaction } from "../shillbot/api.js";
|
|
7
|
+
import { validatePreparedTransaction, } from "../shillbot/api.js";
|
|
8
8
|
import { inspectTransaction } from "../shillbot/index.js";
|
|
9
9
|
import { CLIENT_VERSION } from "../version.js";
|
|
10
10
|
import { CliUsageError, assertNoSecretCliFlags, loadSignerFromCliOrEnv, } from "./keyfile.js";
|
|
@@ -106,6 +106,7 @@ Commands:
|
|
|
106
106
|
tasks submit <id> --content <str> [--payout-to <pubkey>] [--no-exec]
|
|
107
107
|
tasks verify <id> [--no-exec]
|
|
108
108
|
tasks finalize <id> [--no-exec]
|
|
109
|
+
tasks expire <id> [--no-exec] (client escrow refund past claim/submit deadline or past submitted_at + verification_timeout)
|
|
109
110
|
inbox list [--status pending|all] [--limit N]
|
|
110
111
|
inbox open <msg_id...>
|
|
111
112
|
inbox send <to_wallet> <body> [--thread <id>] [--intent <intent>]
|
|
@@ -114,7 +115,7 @@ Commands:
|
|
|
114
115
|
topics read <open-challenge|subcontract|town-square> [--limit N]
|
|
115
116
|
topics publish <open-challenge|subcontract|town-square> <body> [--ref <id>] [--reply-to <id>] [--intent <intent>]
|
|
116
117
|
tx inspect [--tx <base64>]
|
|
117
|
-
tx verify --action <claim|submit|verify|finalize|approve|create> --wallet <pubkey> [--task-pda <pda>] [--payout-to <pubkey>] [--tx <base64>]
|
|
118
|
+
tx verify --action <claim|submit|verify|finalize|expire|approve|create> --wallet <pubkey> [--task-pda <pda>] [--payout-to <pubkey>] [--expire-task-state <open|claimed|submitted|approved>] [--tx <base64>]
|
|
118
119
|
vow-verify <file-or-url> [--rpc <url>]
|
|
119
120
|
|
|
120
121
|
Global Options:
|
|
@@ -140,6 +141,13 @@ const VALID_ACTIONS = new Set([
|
|
|
140
141
|
"approve",
|
|
141
142
|
"verify",
|
|
142
143
|
"finalize",
|
|
144
|
+
"expire",
|
|
145
|
+
]);
|
|
146
|
+
const VALID_EXPIRE_STATES = new Set([
|
|
147
|
+
"open",
|
|
148
|
+
"claimed",
|
|
149
|
+
"submitted",
|
|
150
|
+
"approved",
|
|
143
151
|
]);
|
|
144
152
|
function writeOutput(stdout, jsonMode, payload) {
|
|
145
153
|
if (jsonMode) {
|
|
@@ -215,7 +223,7 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
215
223
|
if (sub === "verify") {
|
|
216
224
|
const rawAction = getStringFlag(flags, "--action");
|
|
217
225
|
if (!rawAction || !VALID_ACTIONS.has(rawAction)) {
|
|
218
|
-
throw new CliUsageError("Usage: swarm tx verify --action <claim|submit|verify|finalize|approve|create> --wallet <pubkey> [--task-pda <pda>] [--tx <base64>]");
|
|
226
|
+
throw new CliUsageError("Usage: swarm tx verify --action <claim|submit|verify|finalize|expire|approve|create> --wallet <pubkey> [--task-pda <pda>] [--tx <base64>]");
|
|
219
227
|
}
|
|
220
228
|
const wallet = getStringFlag(flags, "--wallet");
|
|
221
229
|
if (!wallet) {
|
|
@@ -228,6 +236,12 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
228
236
|
const taskPda = getStringFlag(flags, "--task-pda");
|
|
229
237
|
const feePayer = getStringFlag(flags, "--fee-payer");
|
|
230
238
|
const payoutTo = getStringFlag(flags, "--payout-to");
|
|
239
|
+
const rawExpireState = getStringFlag(flags, "--expire-task-state")?.trim().toLowerCase();
|
|
240
|
+
if (rawExpireState !== undefined &&
|
|
241
|
+
!VALID_EXPIRE_STATES.has(rawExpireState)) {
|
|
242
|
+
throw new CliUsageError(`Invalid --expire-task-state "${rawExpireState}". Expected open, claimed, submitted, or approved.`);
|
|
243
|
+
}
|
|
244
|
+
const expireTaskState = rawExpireState;
|
|
231
245
|
const oracleAuthority = getStringFlag(flags, "--oracle-authority");
|
|
232
246
|
const escrowLamports = getBigIntFlag(flags, "--escrow-lamports");
|
|
233
247
|
try {
|
|
@@ -238,6 +252,7 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
238
252
|
...(taskPda ? { taskPda } : {}),
|
|
239
253
|
...(feePayer ? { feePayer } : {}),
|
|
240
254
|
...(payoutTo ? { payoutTo } : {}),
|
|
255
|
+
...(expireTaskState ? { expireTaskState } : {}),
|
|
241
256
|
...(oracleAuthority ? { oracleAuthority } : {}),
|
|
242
257
|
...(escrowLamports !== undefined ? { escrowLamports } : {}),
|
|
243
258
|
});
|
|
@@ -391,7 +406,17 @@ export async function runSwarmCli(argv, io = {}) {
|
|
|
391
406
|
writeOutput(stdout, jsonMode, res);
|
|
392
407
|
return 0;
|
|
393
408
|
}
|
|
394
|
-
|
|
409
|
+
if (sub === "expire") {
|
|
410
|
+
const id = rest[0];
|
|
411
|
+
if (!id)
|
|
412
|
+
throw new CliUsageError("Usage: swarm tasks expire <task_id> [--no-exec]");
|
|
413
|
+
const res = noExec
|
|
414
|
+
? await agent.tasks.buildExpire(id)
|
|
415
|
+
: await agent.tasks.expireAndExecute(id);
|
|
416
|
+
writeOutput(stdout, jsonMode, res);
|
|
417
|
+
return 0;
|
|
418
|
+
}
|
|
419
|
+
throw new CliUsageError("Usage: swarm tasks <list|get|mine|earnings|next|claim|submit|verify|finalize|expire> ...");
|
|
395
420
|
}
|
|
396
421
|
if (cmd === "inbox") {
|
|
397
422
|
if (sub === "list") {
|
|
@@ -45,9 +45,12 @@ export interface XLegPayload {
|
|
|
45
45
|
export interface XMatchPayload {
|
|
46
46
|
match_id: string;
|
|
47
47
|
tournament_id: number;
|
|
48
|
+
matchup_commitment: string;
|
|
48
49
|
match_live_digest: string;
|
|
49
50
|
operator_signature: string;
|
|
50
51
|
create_match_operator_sig: string;
|
|
52
|
+
quote_timestamp: number;
|
|
53
|
+
quote_max_age_secs: number;
|
|
51
54
|
fund_deadline: number;
|
|
52
55
|
match_deadline: number;
|
|
53
56
|
claim_window_secs: number;
|
|
@@ -55,6 +58,35 @@ export interface XMatchPayload {
|
|
|
55
58
|
leg_a: XLegPayload;
|
|
56
59
|
leg_b: XLegPayload;
|
|
57
60
|
}
|
|
61
|
+
export interface XOutcomeCertPayload {
|
|
62
|
+
match_id: string;
|
|
63
|
+
match_live_digest: string;
|
|
64
|
+
outcome_digest: string;
|
|
65
|
+
outcome_kind: number;
|
|
66
|
+
step_count: number;
|
|
67
|
+
p1_guess: number;
|
|
68
|
+
p2_guess: number;
|
|
69
|
+
first_committer: number;
|
|
70
|
+
matchup_type: number;
|
|
71
|
+
transcript_hash: string;
|
|
72
|
+
operator_outcome_sig: string;
|
|
73
|
+
ready?: boolean;
|
|
74
|
+
live_sigs?: [string, string, string] | null;
|
|
75
|
+
oc_sigs?: [string, string, string] | null;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
export interface XSettleSigsResponse {
|
|
79
|
+
match_id: string;
|
|
80
|
+
ready: boolean;
|
|
81
|
+
live_sigs: [string, string, string] | null;
|
|
82
|
+
oc_sigs: [string, string, string] | null;
|
|
83
|
+
}
|
|
84
|
+
export interface XSolSettleTxResponse {
|
|
85
|
+
unsigned_tx: string;
|
|
86
|
+
blockhash: string;
|
|
87
|
+
match_id: string;
|
|
88
|
+
action: string;
|
|
89
|
+
}
|
|
58
90
|
export interface XQueueResponse {
|
|
59
91
|
status: "waiting" | "matched";
|
|
60
92
|
match?: XMatchPayload;
|
|
@@ -172,6 +204,23 @@ export declare class CoordinationGameApiClient {
|
|
|
172
204
|
} | {
|
|
173
205
|
wallet: string;
|
|
174
206
|
}): Promise<XGameplayView>;
|
|
207
|
+
submitCrossChainSettleSigs(body: {
|
|
208
|
+
handle?: string;
|
|
209
|
+
wallet?: string;
|
|
210
|
+
live_signature?: string;
|
|
211
|
+
outcome_signature?: string;
|
|
212
|
+
}, token?: string): Promise<XSettleSigsResponse>;
|
|
213
|
+
crossChainOutcomeCosign(body: {
|
|
214
|
+
handle?: string;
|
|
215
|
+
wallet?: string;
|
|
216
|
+
live_signature?: string;
|
|
217
|
+
outcome_signature?: string;
|
|
218
|
+
}, token?: string): Promise<XOutcomeCertPayload>;
|
|
219
|
+
buildCrossChainSolSettle(body: {
|
|
220
|
+
handle?: string;
|
|
221
|
+
wallet?: string;
|
|
222
|
+
payer?: string;
|
|
223
|
+
}, token?: string): Promise<XSolSettleTxResponse>;
|
|
175
224
|
joinEvmGame(body: {
|
|
176
225
|
wallet: string;
|
|
177
226
|
player_wallet?: string;
|
|
@@ -43,6 +43,15 @@ export class CoordinationGameApiClient {
|
|
|
43
43
|
: `wallet=${encodeURIComponent(by.wallet)}`;
|
|
44
44
|
return this.http.get(`/internal/xqueue/gameplay?${query}`);
|
|
45
45
|
}
|
|
46
|
+
submitCrossChainSettleSigs(body, token) {
|
|
47
|
+
return this.http.post("/internal/xqueue/settle-sigs", body, token);
|
|
48
|
+
}
|
|
49
|
+
crossChainOutcomeCosign(body, token) {
|
|
50
|
+
return this.http.post("/internal/xqueue/outcome-cosign", body, token);
|
|
51
|
+
}
|
|
52
|
+
buildCrossChainSolSettle(body, token) {
|
|
53
|
+
return this.http.post("/internal/xqueue/build-sol-settle", body, token);
|
|
54
|
+
}
|
|
46
55
|
joinEvmGame(body, token) {
|
|
47
56
|
return this.http.post("/internal/evmgame/join", body, token);
|
|
48
57
|
}
|