@swarm-tips/client 0.4.4 → 0.4.5

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 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.4",
6
- "documentNamespace": "https://swarm.tips/sbom/client/0.4.4",
5
+ "name": "@swarm-tips/client-0.4.5",
6
+ "documentNamespace": "https://swarm.tips/sbom/client/0.4.5",
7
7
  "creationInfo": {
8
- "created": "2026-11-14T20:49:11.555Z",
8
+ "created": "2026-11-15T20:57:08.285Z",
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.4",
19
- "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.4",
18
+ "versionInfo": "0.4.5",
19
+ "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.5",
20
20
  "filesAnalyzed": false,
21
21
  "licenseConcluded": "MIT",
22
22
  "licenseDeclared": "MIT"
@@ -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
  }
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Minimal CrossChainGame ABI for client-side EVM-leg calls (viem
3
3
  * encodeFunctionData). Vendored from the Foundry artifact
4
- * (swarm-tips-repo/evm/out/CrossChainGame.sol/CrossChainGame.json) — only the
5
- * functions the cross-chain match UX needs: fund (createMatch), refund
6
- * (refundTimeout/refundNoCert), and the read views (stakeWei, CHAIN_TAG,
7
- * matches). Settle is permissionless and operator/harness-driven, so it is not
8
- * vendored here. Regenerate if the contract ABI changes.
4
+ * (swarm-tips-repo/evm/out/CrossChainGame.sol/CrossChainGame.json) — covers
5
+ * fund (createMatch), lock (lockTranche), settle, refund
6
+ * (refundTimeout/refundNoCert), and the read views (stakeWei, poolFree,
7
+ * CHAIN_TAG, matches). Regenerate if the contract ABI changes.
9
8
  */
10
9
  export declare const CROSS_CHAIN_GAME_ABI: readonly [{
11
10
  readonly type: "function";
@@ -51,6 +50,111 @@ export declare const CROSS_CHAIN_GAME_ABI: readonly [{
51
50
  }];
52
51
  readonly outputs: readonly [];
53
52
  readonly stateMutability: "payable";
53
+ }, {
54
+ readonly type: "function";
55
+ readonly name: "lockTranche";
56
+ readonly inputs: readonly [{
57
+ readonly name: "cert";
58
+ readonly type: "tuple";
59
+ readonly internalType: "struct CertLib.MatchLiveCert";
60
+ readonly components: readonly [{
61
+ readonly name: "matchId";
62
+ readonly type: "bytes32";
63
+ readonly internalType: "bytes32";
64
+ }, {
65
+ readonly name: "tournamentId";
66
+ readonly type: "uint64";
67
+ readonly internalType: "uint64";
68
+ }, {
69
+ readonly name: "matchupCommitment";
70
+ readonly type: "bytes32";
71
+ readonly internalType: "bytes32";
72
+ }, {
73
+ readonly name: "legA";
74
+ readonly type: "tuple";
75
+ readonly internalType: "struct CertLib.Leg";
76
+ readonly components: readonly [{
77
+ readonly name: "chainTag";
78
+ readonly type: "bytes32";
79
+ readonly internalType: "bytes32";
80
+ }, {
81
+ readonly name: "contractId";
82
+ readonly type: "bytes32";
83
+ readonly internalType: "bytes32";
84
+ }, {
85
+ readonly name: "player";
86
+ readonly type: "bytes32";
87
+ readonly internalType: "bytes32";
88
+ }, {
89
+ readonly name: "sessionKey";
90
+ readonly type: "address";
91
+ readonly internalType: "address";
92
+ }, {
93
+ readonly name: "stake";
94
+ readonly type: "uint128";
95
+ readonly internalType: "uint128";
96
+ }, {
97
+ readonly name: "tranche";
98
+ readonly type: "uint128";
99
+ readonly internalType: "uint128";
100
+ }];
101
+ }, {
102
+ readonly name: "legB";
103
+ readonly type: "tuple";
104
+ readonly internalType: "struct CertLib.Leg";
105
+ readonly components: readonly [{
106
+ readonly name: "chainTag";
107
+ readonly type: "bytes32";
108
+ readonly internalType: "bytes32";
109
+ }, {
110
+ readonly name: "contractId";
111
+ readonly type: "bytes32";
112
+ readonly internalType: "bytes32";
113
+ }, {
114
+ readonly name: "player";
115
+ readonly type: "bytes32";
116
+ readonly internalType: "bytes32";
117
+ }, {
118
+ readonly name: "sessionKey";
119
+ readonly type: "address";
120
+ readonly internalType: "address";
121
+ }, {
122
+ readonly name: "stake";
123
+ readonly type: "uint128";
124
+ readonly internalType: "uint128";
125
+ }, {
126
+ readonly name: "tranche";
127
+ readonly type: "uint128";
128
+ readonly internalType: "uint128";
129
+ }];
130
+ }, {
131
+ readonly name: "quoteTimestamp";
132
+ readonly type: "uint64";
133
+ readonly internalType: "uint64";
134
+ }, {
135
+ readonly name: "quoteMaxAgeSecs";
136
+ readonly type: "uint32";
137
+ readonly internalType: "uint32";
138
+ }, {
139
+ readonly name: "matchDeadline";
140
+ readonly type: "uint64";
141
+ readonly internalType: "uint64";
142
+ }, {
143
+ readonly name: "claimWindowSecs";
144
+ readonly type: "uint32";
145
+ readonly internalType: "uint32";
146
+ }, {
147
+ readonly name: "aIsP1";
148
+ readonly type: "uint8";
149
+ readonly internalType: "uint8";
150
+ }];
151
+ }, {
152
+ readonly name: "operatorSig";
153
+ readonly type: "bytes";
154
+ readonly internalType: "bytes";
155
+ }];
156
+ readonly outputs: readonly [];
157
+ readonly stateMutability: "nonpayable";
54
158
  }, {
55
159
  readonly type: "function";
56
160
  readonly name: "matches";
@@ -123,6 +227,20 @@ export declare const CROSS_CHAIN_GAME_ABI: readonly [{
123
227
  readonly name: "bestOutcomeKind";
124
228
  readonly type: "uint8";
125
229
  readonly internalType: "uint8";
230
+ }, {
231
+ readonly name: "timeoutOpensAt";
232
+ readonly type: "uint64";
233
+ readonly internalType: "uint64";
234
+ }];
235
+ readonly stateMutability: "view";
236
+ }, {
237
+ readonly type: "function";
238
+ readonly name: "poolFree";
239
+ readonly inputs: readonly [];
240
+ readonly outputs: readonly [{
241
+ readonly name: "";
242
+ readonly type: "uint256";
243
+ readonly internalType: "uint256";
126
244
  }];
127
245
  readonly stateMutability: "view";
128
246
  }, {
@@ -145,6 +263,156 @@ export declare const CROSS_CHAIN_GAME_ABI: readonly [{
145
263
  }];
146
264
  readonly outputs: readonly [];
147
265
  readonly stateMutability: "nonpayable";
266
+ }, {
267
+ readonly type: "function";
268
+ readonly name: "settle";
269
+ readonly inputs: readonly [{
270
+ readonly name: "cert";
271
+ readonly type: "tuple";
272
+ readonly internalType: "struct CertLib.MatchLiveCert";
273
+ readonly components: readonly [{
274
+ readonly name: "matchId";
275
+ readonly type: "bytes32";
276
+ readonly internalType: "bytes32";
277
+ }, {
278
+ readonly name: "tournamentId";
279
+ readonly type: "uint64";
280
+ readonly internalType: "uint64";
281
+ }, {
282
+ readonly name: "matchupCommitment";
283
+ readonly type: "bytes32";
284
+ readonly internalType: "bytes32";
285
+ }, {
286
+ readonly name: "legA";
287
+ readonly type: "tuple";
288
+ readonly internalType: "struct CertLib.Leg";
289
+ readonly components: readonly [{
290
+ readonly name: "chainTag";
291
+ readonly type: "bytes32";
292
+ readonly internalType: "bytes32";
293
+ }, {
294
+ readonly name: "contractId";
295
+ readonly type: "bytes32";
296
+ readonly internalType: "bytes32";
297
+ }, {
298
+ readonly name: "player";
299
+ readonly type: "bytes32";
300
+ readonly internalType: "bytes32";
301
+ }, {
302
+ readonly name: "sessionKey";
303
+ readonly type: "address";
304
+ readonly internalType: "address";
305
+ }, {
306
+ readonly name: "stake";
307
+ readonly type: "uint128";
308
+ readonly internalType: "uint128";
309
+ }, {
310
+ readonly name: "tranche";
311
+ readonly type: "uint128";
312
+ readonly internalType: "uint128";
313
+ }];
314
+ }, {
315
+ readonly name: "legB";
316
+ readonly type: "tuple";
317
+ readonly internalType: "struct CertLib.Leg";
318
+ readonly components: readonly [{
319
+ readonly name: "chainTag";
320
+ readonly type: "bytes32";
321
+ readonly internalType: "bytes32";
322
+ }, {
323
+ readonly name: "contractId";
324
+ readonly type: "bytes32";
325
+ readonly internalType: "bytes32";
326
+ }, {
327
+ readonly name: "player";
328
+ readonly type: "bytes32";
329
+ readonly internalType: "bytes32";
330
+ }, {
331
+ readonly name: "sessionKey";
332
+ readonly type: "address";
333
+ readonly internalType: "address";
334
+ }, {
335
+ readonly name: "stake";
336
+ readonly type: "uint128";
337
+ readonly internalType: "uint128";
338
+ }, {
339
+ readonly name: "tranche";
340
+ readonly type: "uint128";
341
+ readonly internalType: "uint128";
342
+ }];
343
+ }, {
344
+ readonly name: "quoteTimestamp";
345
+ readonly type: "uint64";
346
+ readonly internalType: "uint64";
347
+ }, {
348
+ readonly name: "quoteMaxAgeSecs";
349
+ readonly type: "uint32";
350
+ readonly internalType: "uint32";
351
+ }, {
352
+ readonly name: "matchDeadline";
353
+ readonly type: "uint64";
354
+ readonly internalType: "uint64";
355
+ }, {
356
+ readonly name: "claimWindowSecs";
357
+ readonly type: "uint32";
358
+ readonly internalType: "uint32";
359
+ }, {
360
+ readonly name: "aIsP1";
361
+ readonly type: "uint8";
362
+ readonly internalType: "uint8";
363
+ }];
364
+ }, {
365
+ readonly name: "oc";
366
+ readonly type: "tuple";
367
+ readonly internalType: "struct CertLib.OutcomeCert";
368
+ readonly components: readonly [{
369
+ readonly name: "matchId";
370
+ readonly type: "bytes32";
371
+ readonly internalType: "bytes32";
372
+ }, {
373
+ readonly name: "matchLiveDigest";
374
+ readonly type: "bytes32";
375
+ readonly internalType: "bytes32";
376
+ }, {
377
+ readonly name: "outcomeKind";
378
+ readonly type: "uint8";
379
+ readonly internalType: "uint8";
380
+ }, {
381
+ readonly name: "stepCount";
382
+ readonly type: "uint8";
383
+ readonly internalType: "uint8";
384
+ }, {
385
+ readonly name: "p1Guess";
386
+ readonly type: "uint8";
387
+ readonly internalType: "uint8";
388
+ }, {
389
+ readonly name: "p2Guess";
390
+ readonly type: "uint8";
391
+ readonly internalType: "uint8";
392
+ }, {
393
+ readonly name: "firstCommitter";
394
+ readonly type: "uint8";
395
+ readonly internalType: "uint8";
396
+ }, {
397
+ readonly name: "matchupType";
398
+ readonly type: "uint8";
399
+ readonly internalType: "uint8";
400
+ }, {
401
+ readonly name: "transcriptHash";
402
+ readonly type: "bytes32";
403
+ readonly internalType: "bytes32";
404
+ }];
405
+ }, {
406
+ readonly name: "liveSigs";
407
+ readonly type: "bytes[3]";
408
+ readonly internalType: "bytes[3]";
409
+ }, {
410
+ readonly name: "ocSigs";
411
+ readonly type: "bytes[3]";
412
+ readonly internalType: "bytes[3]";
413
+ }];
414
+ readonly outputs: readonly [];
415
+ readonly stateMutability: "nonpayable";
148
416
  }, {
149
417
  readonly type: "function";
150
418
  readonly name: "stakeWei";
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Minimal CrossChainGame ABI for client-side EVM-leg calls (viem
3
3
  * encodeFunctionData). Vendored from the Foundry artifact
4
- * (swarm-tips-repo/evm/out/CrossChainGame.sol/CrossChainGame.json) — only the
5
- * functions the cross-chain match UX needs: fund (createMatch), refund
6
- * (refundTimeout/refundNoCert), and the read views (stakeWei, CHAIN_TAG,
7
- * matches). Settle is permissionless and operator/harness-driven, so it is not
8
- * vendored here. Regenerate if the contract ABI changes.
4
+ * (swarm-tips-repo/evm/out/CrossChainGame.sol/CrossChainGame.json) — covers
5
+ * fund (createMatch), lock (lockTranche), settle, refund
6
+ * (refundTimeout/refundNoCert), and the read views (stakeWei, poolFree,
7
+ * CHAIN_TAG, matches). Regenerate if the contract ABI changes.
9
8
  */
10
9
  export const CROSS_CHAIN_GAME_ABI = [
11
10
  {
@@ -64,6 +63,140 @@ export const CROSS_CHAIN_GAME_ABI = [
64
63
  "outputs": [],
65
64
  "stateMutability": "payable"
66
65
  },
66
+ {
67
+ "type": "function",
68
+ "name": "lockTranche",
69
+ "inputs": [
70
+ {
71
+ "name": "cert",
72
+ "type": "tuple",
73
+ "internalType": "struct CertLib.MatchLiveCert",
74
+ "components": [
75
+ {
76
+ "name": "matchId",
77
+ "type": "bytes32",
78
+ "internalType": "bytes32"
79
+ },
80
+ {
81
+ "name": "tournamentId",
82
+ "type": "uint64",
83
+ "internalType": "uint64"
84
+ },
85
+ {
86
+ "name": "matchupCommitment",
87
+ "type": "bytes32",
88
+ "internalType": "bytes32"
89
+ },
90
+ {
91
+ "name": "legA",
92
+ "type": "tuple",
93
+ "internalType": "struct CertLib.Leg",
94
+ "components": [
95
+ {
96
+ "name": "chainTag",
97
+ "type": "bytes32",
98
+ "internalType": "bytes32"
99
+ },
100
+ {
101
+ "name": "contractId",
102
+ "type": "bytes32",
103
+ "internalType": "bytes32"
104
+ },
105
+ {
106
+ "name": "player",
107
+ "type": "bytes32",
108
+ "internalType": "bytes32"
109
+ },
110
+ {
111
+ "name": "sessionKey",
112
+ "type": "address",
113
+ "internalType": "address"
114
+ },
115
+ {
116
+ "name": "stake",
117
+ "type": "uint128",
118
+ "internalType": "uint128"
119
+ },
120
+ {
121
+ "name": "tranche",
122
+ "type": "uint128",
123
+ "internalType": "uint128"
124
+ }
125
+ ]
126
+ },
127
+ {
128
+ "name": "legB",
129
+ "type": "tuple",
130
+ "internalType": "struct CertLib.Leg",
131
+ "components": [
132
+ {
133
+ "name": "chainTag",
134
+ "type": "bytes32",
135
+ "internalType": "bytes32"
136
+ },
137
+ {
138
+ "name": "contractId",
139
+ "type": "bytes32",
140
+ "internalType": "bytes32"
141
+ },
142
+ {
143
+ "name": "player",
144
+ "type": "bytes32",
145
+ "internalType": "bytes32"
146
+ },
147
+ {
148
+ "name": "sessionKey",
149
+ "type": "address",
150
+ "internalType": "address"
151
+ },
152
+ {
153
+ "name": "stake",
154
+ "type": "uint128",
155
+ "internalType": "uint128"
156
+ },
157
+ {
158
+ "name": "tranche",
159
+ "type": "uint128",
160
+ "internalType": "uint128"
161
+ }
162
+ ]
163
+ },
164
+ {
165
+ "name": "quoteTimestamp",
166
+ "type": "uint64",
167
+ "internalType": "uint64"
168
+ },
169
+ {
170
+ "name": "quoteMaxAgeSecs",
171
+ "type": "uint32",
172
+ "internalType": "uint32"
173
+ },
174
+ {
175
+ "name": "matchDeadline",
176
+ "type": "uint64",
177
+ "internalType": "uint64"
178
+ },
179
+ {
180
+ "name": "claimWindowSecs",
181
+ "type": "uint32",
182
+ "internalType": "uint32"
183
+ },
184
+ {
185
+ "name": "aIsP1",
186
+ "type": "uint8",
187
+ "internalType": "uint8"
188
+ }
189
+ ]
190
+ },
191
+ {
192
+ "name": "operatorSig",
193
+ "type": "bytes",
194
+ "internalType": "bytes"
195
+ }
196
+ ],
197
+ "outputs": [],
198
+ "stateMutability": "nonpayable"
199
+ },
67
200
  {
68
201
  "type": "function",
69
202
  "name": "matches",
@@ -154,6 +287,24 @@ export const CROSS_CHAIN_GAME_ABI = [
154
287
  "name": "bestOutcomeKind",
155
288
  "type": "uint8",
156
289
  "internalType": "uint8"
290
+ },
291
+ {
292
+ "name": "timeoutOpensAt",
293
+ "type": "uint64",
294
+ "internalType": "uint64"
295
+ }
296
+ ],
297
+ "stateMutability": "view"
298
+ },
299
+ {
300
+ "type": "function",
301
+ "name": "poolFree",
302
+ "inputs": [],
303
+ "outputs": [
304
+ {
305
+ "name": "",
306
+ "type": "uint256",
307
+ "internalType": "uint256"
157
308
  }
158
309
  ],
159
310
  "stateMutability": "view"
@@ -184,6 +335,197 @@ export const CROSS_CHAIN_GAME_ABI = [
184
335
  "outputs": [],
185
336
  "stateMutability": "nonpayable"
186
337
  },
338
+ {
339
+ "type": "function",
340
+ "name": "settle",
341
+ "inputs": [
342
+ {
343
+ "name": "cert",
344
+ "type": "tuple",
345
+ "internalType": "struct CertLib.MatchLiveCert",
346
+ "components": [
347
+ {
348
+ "name": "matchId",
349
+ "type": "bytes32",
350
+ "internalType": "bytes32"
351
+ },
352
+ {
353
+ "name": "tournamentId",
354
+ "type": "uint64",
355
+ "internalType": "uint64"
356
+ },
357
+ {
358
+ "name": "matchupCommitment",
359
+ "type": "bytes32",
360
+ "internalType": "bytes32"
361
+ },
362
+ {
363
+ "name": "legA",
364
+ "type": "tuple",
365
+ "internalType": "struct CertLib.Leg",
366
+ "components": [
367
+ {
368
+ "name": "chainTag",
369
+ "type": "bytes32",
370
+ "internalType": "bytes32"
371
+ },
372
+ {
373
+ "name": "contractId",
374
+ "type": "bytes32",
375
+ "internalType": "bytes32"
376
+ },
377
+ {
378
+ "name": "player",
379
+ "type": "bytes32",
380
+ "internalType": "bytes32"
381
+ },
382
+ {
383
+ "name": "sessionKey",
384
+ "type": "address",
385
+ "internalType": "address"
386
+ },
387
+ {
388
+ "name": "stake",
389
+ "type": "uint128",
390
+ "internalType": "uint128"
391
+ },
392
+ {
393
+ "name": "tranche",
394
+ "type": "uint128",
395
+ "internalType": "uint128"
396
+ }
397
+ ]
398
+ },
399
+ {
400
+ "name": "legB",
401
+ "type": "tuple",
402
+ "internalType": "struct CertLib.Leg",
403
+ "components": [
404
+ {
405
+ "name": "chainTag",
406
+ "type": "bytes32",
407
+ "internalType": "bytes32"
408
+ },
409
+ {
410
+ "name": "contractId",
411
+ "type": "bytes32",
412
+ "internalType": "bytes32"
413
+ },
414
+ {
415
+ "name": "player",
416
+ "type": "bytes32",
417
+ "internalType": "bytes32"
418
+ },
419
+ {
420
+ "name": "sessionKey",
421
+ "type": "address",
422
+ "internalType": "address"
423
+ },
424
+ {
425
+ "name": "stake",
426
+ "type": "uint128",
427
+ "internalType": "uint128"
428
+ },
429
+ {
430
+ "name": "tranche",
431
+ "type": "uint128",
432
+ "internalType": "uint128"
433
+ }
434
+ ]
435
+ },
436
+ {
437
+ "name": "quoteTimestamp",
438
+ "type": "uint64",
439
+ "internalType": "uint64"
440
+ },
441
+ {
442
+ "name": "quoteMaxAgeSecs",
443
+ "type": "uint32",
444
+ "internalType": "uint32"
445
+ },
446
+ {
447
+ "name": "matchDeadline",
448
+ "type": "uint64",
449
+ "internalType": "uint64"
450
+ },
451
+ {
452
+ "name": "claimWindowSecs",
453
+ "type": "uint32",
454
+ "internalType": "uint32"
455
+ },
456
+ {
457
+ "name": "aIsP1",
458
+ "type": "uint8",
459
+ "internalType": "uint8"
460
+ }
461
+ ]
462
+ },
463
+ {
464
+ "name": "oc",
465
+ "type": "tuple",
466
+ "internalType": "struct CertLib.OutcomeCert",
467
+ "components": [
468
+ {
469
+ "name": "matchId",
470
+ "type": "bytes32",
471
+ "internalType": "bytes32"
472
+ },
473
+ {
474
+ "name": "matchLiveDigest",
475
+ "type": "bytes32",
476
+ "internalType": "bytes32"
477
+ },
478
+ {
479
+ "name": "outcomeKind",
480
+ "type": "uint8",
481
+ "internalType": "uint8"
482
+ },
483
+ {
484
+ "name": "stepCount",
485
+ "type": "uint8",
486
+ "internalType": "uint8"
487
+ },
488
+ {
489
+ "name": "p1Guess",
490
+ "type": "uint8",
491
+ "internalType": "uint8"
492
+ },
493
+ {
494
+ "name": "p2Guess",
495
+ "type": "uint8",
496
+ "internalType": "uint8"
497
+ },
498
+ {
499
+ "name": "firstCommitter",
500
+ "type": "uint8",
501
+ "internalType": "uint8"
502
+ },
503
+ {
504
+ "name": "matchupType",
505
+ "type": "uint8",
506
+ "internalType": "uint8"
507
+ },
508
+ {
509
+ "name": "transcriptHash",
510
+ "type": "bytes32",
511
+ "internalType": "bytes32"
512
+ }
513
+ ]
514
+ },
515
+ {
516
+ "name": "liveSigs",
517
+ "type": "bytes[3]",
518
+ "internalType": "bytes[3]"
519
+ },
520
+ {
521
+ "name": "ocSigs",
522
+ "type": "bytes[3]",
523
+ "internalType": "bytes[3]"
524
+ }
525
+ ],
526
+ "outputs": [],
527
+ "stateMutability": "nonpayable"
528
+ },
187
529
  {
188
530
  "type": "function",
189
531
  "name": "stakeWei",
@@ -1,6 +1,13 @@
1
1
  import { type Hex } from "viem";
2
- import type { CoordinationGameApiClient, XMatchPayload } from "../api.js";
2
+ import type { CoordinationGameApiClient, XMatchPayload, XOutcomeCertPayload } from "../api.js";
3
3
  export declare function unpadAddress(word: string): Hex;
4
+ /**
5
+ * Normalize a 65-byte `0x` secp256k1 `[r||s||v]` signature so `v` is in the
6
+ * EVM `ecrecover` / OpenZeppelin `ECDSA.recover` domain (`27 | 28`). The
7
+ * off-chain relay stores signatures with `v = 0 | 1`; passing `v < 27` directly
8
+ * to `CrossChainGame` reverts with `ECDSAInvalidSignature`.
9
+ */
10
+ export declare function normalizeEvmSigV(sig: string): Hex;
4
11
  export interface CrossChainMatchResult {
5
12
  match: XMatchPayload;
6
13
  handle: string | undefined;
@@ -24,7 +31,63 @@ export interface EvmFundPin {
24
31
  contract: Hex;
25
32
  stakeWei: bigint;
26
33
  }
34
+ /**
35
+ * Reconstruct the `CertLib.MatchLiveCert` tuple expected by `CrossChainGame`
36
+ * (`lockTranche`, `settle`, `openClaim`, `supersedeClaim`,
37
+ * `submitEquivocationProof`) from a matched `XMatchPayload`. `chainTag` is
38
+ * recomputed as `keccak256(utf8(leg.chain))`, matching `game-api`.
39
+ */
40
+ export declare function certTupleFromMatchPayload(match: XMatchPayload): {
41
+ readonly matchId: Hex;
42
+ readonly tournamentId: bigint;
43
+ readonly matchupCommitment: Hex;
44
+ readonly legA: {
45
+ readonly chainTag: `0x${string}`;
46
+ readonly contractId: Hex;
47
+ readonly player: Hex;
48
+ readonly sessionKey: `0x${string}`;
49
+ readonly stake: bigint;
50
+ readonly tranche: bigint;
51
+ };
52
+ readonly legB: {
53
+ readonly chainTag: `0x${string}`;
54
+ readonly contractId: Hex;
55
+ readonly player: Hex;
56
+ readonly sessionKey: `0x${string}`;
57
+ readonly stake: bigint;
58
+ readonly tranche: bigint;
59
+ };
60
+ readonly quoteTimestamp: bigint;
61
+ readonly quoteMaxAgeSecs: number;
62
+ readonly matchDeadline: bigint;
63
+ readonly claimWindowSecs: number;
64
+ readonly aIsP1: number;
65
+ };
27
66
  export declare function buildEvmFundCall(match: XMatchPayload, pin: EvmFundPin): EvmFundCall;
67
+ /**
68
+ * Build the unsigned permissionless `CrossChainGame.lockTranche(cert, operatorSig)`
69
+ * call (`value === 0n`) from the matched `XMatchPayload`, verifying `leg_b`
70
+ * against `pin` and normalizing `operator_signature` `v` to `27 | 28`.
71
+ */
72
+ export declare function buildEvmLockTrancheCall(match: XMatchPayload, pin: EvmFundPin): EvmFundCall;
73
+ export interface XSettleBundle {
74
+ outcome: Pick<XOutcomeCertPayload, "match_id" | "match_live_digest" | "outcome_kind" | "step_count" | "p1_guess" | "p2_guess" | "first_committer" | "matchup_type" | "transcript_hash">;
75
+ live_sigs: readonly [string, string, string];
76
+ oc_sigs: readonly [string, string, string];
77
+ }
78
+ /**
79
+ * Build the unsigned permissionless `CrossChainGame.settle(cert, oc, liveSigs, ocSigs)`
80
+ * call (`value === 0n`), verifying `leg_b` against `pin`, checking `match_id`
81
+ * and `match_live_digest` consistency, and normalizing all 6 signatures to
82
+ * EVM `v = 27 | 28`.
83
+ */
84
+ export declare function buildEvmSettleCall(match: XMatchPayload, bundle: XSettleBundle, pin: EvmFundPin): EvmFundCall;
85
+ /**
86
+ * Read `CrossChainGame.matches(matchId).status` (`0 = None, 1 = Funded,
87
+ * 2 = Locked, 3 = Claiming, 4 = Settled, 5 = ClaimSettled, 6 = RefundedNoCert,
88
+ * 7 = RefundedTimeout`).
89
+ */
90
+ export declare function readEvmXMatchStatus(rpcUrl: string, contract: Hex, matchId: Hex): Promise<number>;
28
91
  export interface FundTargetReader {
29
92
  stakeWei(contract: Hex): Promise<bigint>;
30
93
  matchStatus(contract: Hex, matchId: Hex): Promise<number>;
@@ -1,9 +1,26 @@
1
- import { createPublicClient, encodeFunctionData, http } from "viem";
1
+ import { createPublicClient, encodeFunctionData, http, keccak256, toBytes, } from "viem";
2
2
  import { CROSS_CHAIN_GAME_ABI } from "./abi.js";
3
3
  export function unpadAddress(word) {
4
4
  const hex = word.startsWith("0x") ? word.slice(2) : word;
5
5
  return `0x${hex.slice(-40)}`;
6
6
  }
7
+ /**
8
+ * Normalize a 65-byte `0x` secp256k1 `[r||s||v]` signature so `v` is in the
9
+ * EVM `ecrecover` / OpenZeppelin `ECDSA.recover` domain (`27 | 28`). The
10
+ * off-chain relay stores signatures with `v = 0 | 1`; passing `v < 27` directly
11
+ * to `CrossChainGame` reverts with `ECDSAInvalidSignature`.
12
+ */
13
+ export function normalizeEvmSigV(sig) {
14
+ if (!/^0x[0-9a-fA-F]{130}$/.test(sig)) {
15
+ throw new Error(`expected 65-byte 0x signature (130 hex chars), got length ${sig.length}`);
16
+ }
17
+ const body = sig.slice(2).toLowerCase();
18
+ const rs = body.slice(0, 128);
19
+ let v = parseInt(body.slice(128, 130), 16);
20
+ if (v < 27)
21
+ v += 27;
22
+ return `0x${rs}${v.toString(16).padStart(2, "0")}`;
23
+ }
7
24
  export async function findCrossChainMatch(api, input, options = {}) {
8
25
  const joined = await api.joinCrossChainQueue({
9
26
  wallet: input.wallet,
@@ -23,15 +40,49 @@ export async function findCrossChainMatch(api, input, options = {}) {
23
40
  }
24
41
  throw new Error("no opponent found before timeout");
25
42
  }
26
- export function buildEvmFundCall(match, pin) {
43
+ function verifyPin(match, pin) {
27
44
  const to = unpadAddress(match.leg_b.contract);
28
45
  if (to.toLowerCase() !== pin.contract.toLowerCase()) {
29
46
  throw new Error(`relay leg_b.contract ${to} != pinned CrossChainGame ${pin.contract}`);
30
47
  }
31
- const value = BigInt(match.leg_b.stake_base_units);
32
- if (value !== pin.stakeWei) {
33
- throw new Error(`relay leg_b.stake ${value} != pinned stake ${pin.stakeWei}`);
48
+ const stakeWei = BigInt(match.leg_b.stake_base_units);
49
+ if (stakeWei !== pin.stakeWei) {
50
+ throw new Error(`relay leg_b.stake ${stakeWei} != pinned stake ${pin.stakeWei}`);
34
51
  }
52
+ return { to, stakeWei };
53
+ }
54
+ function legTupleFromPayload(leg) {
55
+ return {
56
+ chainTag: keccak256(toBytes(leg.chain)),
57
+ contractId: leg.contract,
58
+ player: leg.player,
59
+ sessionKey: unpadAddress(leg.session_key),
60
+ stake: BigInt(leg.stake_base_units),
61
+ tranche: BigInt(leg.tranche_base_units),
62
+ };
63
+ }
64
+ /**
65
+ * Reconstruct the `CertLib.MatchLiveCert` tuple expected by `CrossChainGame`
66
+ * (`lockTranche`, `settle`, `openClaim`, `supersedeClaim`,
67
+ * `submitEquivocationProof`) from a matched `XMatchPayload`. `chainTag` is
68
+ * recomputed as `keccak256(utf8(leg.chain))`, matching `game-api`.
69
+ */
70
+ export function certTupleFromMatchPayload(match) {
71
+ return {
72
+ matchId: match.match_id,
73
+ tournamentId: BigInt(match.tournament_id),
74
+ matchupCommitment: match.matchup_commitment,
75
+ legA: legTupleFromPayload(match.leg_a),
76
+ legB: legTupleFromPayload(match.leg_b),
77
+ quoteTimestamp: BigInt(match.quote_timestamp),
78
+ quoteMaxAgeSecs: Number(match.quote_max_age_secs),
79
+ matchDeadline: BigInt(match.match_deadline),
80
+ claimWindowSecs: Number(match.claim_window_secs),
81
+ aIsP1: Number(match.a_is_p1),
82
+ };
83
+ }
84
+ export function buildEvmFundCall(match, pin) {
85
+ const { to, stakeWei } = verifyPin(match, pin);
35
86
  const data = encodeFunctionData({
36
87
  abi: CROSS_CHAIN_GAME_ABI,
37
88
  functionName: "createMatch",
@@ -45,7 +96,79 @@ export function buildEvmFundCall(match, pin) {
45
96
  match.create_match_operator_sig,
46
97
  ],
47
98
  });
48
- return { to, data, value };
99
+ return { to, data, value: stakeWei };
100
+ }
101
+ /**
102
+ * Build the unsigned permissionless `CrossChainGame.lockTranche(cert, operatorSig)`
103
+ * call (`value === 0n`) from the matched `XMatchPayload`, verifying `leg_b`
104
+ * against `pin` and normalizing `operator_signature` `v` to `27 | 28`.
105
+ */
106
+ export function buildEvmLockTrancheCall(match, pin) {
107
+ const { to } = verifyPin(match, pin);
108
+ const data = encodeFunctionData({
109
+ abi: CROSS_CHAIN_GAME_ABI,
110
+ functionName: "lockTranche",
111
+ args: [certTupleFromMatchPayload(match), normalizeEvmSigV(match.operator_signature)],
112
+ });
113
+ return { to, data, value: 0n };
114
+ }
115
+ /**
116
+ * Build the unsigned permissionless `CrossChainGame.settle(cert, oc, liveSigs, ocSigs)`
117
+ * call (`value === 0n`), verifying `leg_b` against `pin`, checking `match_id`
118
+ * and `match_live_digest` consistency, and normalizing all 6 signatures to
119
+ * EVM `v = 27 | 28`.
120
+ */
121
+ export function buildEvmSettleCall(match, bundle, pin) {
122
+ const { to } = verifyPin(match, pin);
123
+ if (bundle.outcome.match_id.toLowerCase() !== match.match_id.toLowerCase()) {
124
+ throw new Error(`outcome.match_id ${bundle.outcome.match_id} != match.match_id ${match.match_id}`);
125
+ }
126
+ if (match.match_live_digest &&
127
+ bundle.outcome.match_live_digest.toLowerCase() !== match.match_live_digest.toLowerCase()) {
128
+ throw new Error(`outcome.match_live_digest ${bundle.outcome.match_live_digest} != match.match_live_digest ${match.match_live_digest}`);
129
+ }
130
+ const oc = {
131
+ matchId: bundle.outcome.match_id,
132
+ matchLiveDigest: bundle.outcome.match_live_digest,
133
+ outcomeKind: Number(bundle.outcome.outcome_kind),
134
+ stepCount: Number(bundle.outcome.step_count),
135
+ p1Guess: Number(bundle.outcome.p1_guess),
136
+ p2Guess: Number(bundle.outcome.p2_guess),
137
+ firstCommitter: Number(bundle.outcome.first_committer),
138
+ matchupType: Number(bundle.outcome.matchup_type),
139
+ transcriptHash: bundle.outcome.transcript_hash,
140
+ };
141
+ const liveSigs = [
142
+ normalizeEvmSigV(bundle.live_sigs[0]),
143
+ normalizeEvmSigV(bundle.live_sigs[1]),
144
+ normalizeEvmSigV(bundle.live_sigs[2]),
145
+ ];
146
+ const ocSigs = [
147
+ normalizeEvmSigV(bundle.oc_sigs[0]),
148
+ normalizeEvmSigV(bundle.oc_sigs[1]),
149
+ normalizeEvmSigV(bundle.oc_sigs[2]),
150
+ ];
151
+ const data = encodeFunctionData({
152
+ abi: CROSS_CHAIN_GAME_ABI,
153
+ functionName: "settle",
154
+ args: [certTupleFromMatchPayload(match), oc, liveSigs, ocSigs],
155
+ });
156
+ return { to, data, value: 0n };
157
+ }
158
+ /**
159
+ * Read `CrossChainGame.matches(matchId).status` (`0 = None, 1 = Funded,
160
+ * 2 = Locked, 3 = Claiming, 4 = Settled, 5 = ClaimSettled, 6 = RefundedNoCert,
161
+ * 7 = RefundedTimeout`).
162
+ */
163
+ export async function readEvmXMatchStatus(rpcUrl, contract, matchId) {
164
+ const client = createPublicClient({ transport: http(rpcUrl) });
165
+ const result = (await client.readContract({
166
+ address: contract,
167
+ abi: CROSS_CHAIN_GAME_ABI,
168
+ functionName: "matches",
169
+ args: [matchId],
170
+ }));
171
+ return Number(result[0]);
49
172
  }
50
173
  export async function verifyEvmFundTarget(match, pin, readers) {
51
174
  if (readers.length < 2)
@@ -5,3 +5,5 @@ export * from "./session-funding.js";
5
5
  export * from "./transactions.js";
6
6
  export * from "./cross-chain.js";
7
7
  export * from "../chains.js";
8
+ export { signDigest, signDigestForRelay } from "../../evm/sign.js";
9
+ export type { XLegPayload, XMatchPayload, XOutcomeCertPayload, XSettleSigsResponse, XSolSettleTxResponse, } from "../api.js";
@@ -5,3 +5,4 @@ export * from "./session-funding.js";
5
5
  export * from "./transactions.js";
6
6
  export * from "./cross-chain.js";
7
7
  export * from "../chains.js";
8
+ export { signDigest, signDigestForRelay } from "../../evm/sign.js";
@@ -4,3 +4,4 @@ export * from "./outcome-oracle.js";
4
4
  export * from "./battery.js";
5
5
  export * from "./protocol.js";
6
6
  export * from "./chains.js";
7
+ export type { XLegPayload, XMatchPayload, XOutcomeCertPayload, XSettleSigsResponse, XSolSettleTxResponse, } from "./api.js";
@@ -1,3 +1,3 @@
1
- export { signDigestForRelay } from "./sign.js";
1
+ export { signDigest, signDigestForRelay } from "./sign.js";
2
2
  export { sendUnsignedCall, sendContractCall, type UnsignedEvmCall, type CallSender, } from "./tx.js";
3
3
  export { buildWagmiConfig, getEvmTestWalletKey, getEvmRpcOverride, type ChainWithRpcs, type WagmiConfigOpts, } from "./wallet.js";
package/dist/evm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Product-agnostic EVM frontend primitives shared across
2
2
  // Swarm Tips frontends (coordination-game today; a future shillbot EVM flow
3
3
  // just adds this package as a dependency + brings its own ABI/flow).
4
- export { signDigestForRelay } from "./sign.js";
4
+ export { signDigest, signDigestForRelay } from "./sign.js";
5
5
  export { sendUnsignedCall, sendContractCall, } from "./tx.js";
6
6
  export { buildWagmiConfig, getEvmTestWalletKey, getEvmRpcOverride, } from "./wallet.js";
@@ -10,3 +10,9 @@ import type { Hex } from "viem";
10
10
  * (the inverse axis; see chain-core `sign_digest_eth` / `evm_operator_sig_v_convention`).
11
11
  */
12
12
  export declare function signDigestForRelay(privateKey: Hex, digestHex: Hex): Promise<Hex>;
13
+ /**
14
+ * Sign a `0x` 32-byte digest with an EVM private key, returning a `0x` 65-byte
15
+ * `[r||s||v]` secp256k1 signature with `v = 27 | 28` (the EVM `ecrecover` /
16
+ * OpenZeppelin `ECDSA.recover` convention verified by on-chain EVM contracts).
17
+ */
18
+ export declare function signDigest(privateKey: Hex, digestHex: Hex): Promise<Hex>;
package/dist/evm/sign.js CHANGED
@@ -21,3 +21,20 @@ export async function signDigestForRelay(privateKey, digestHex) {
21
21
  v -= 27; // 27|28 -> 0|1 for the relay's k256 recover_address
22
22
  return `0x${rs}${v.toString(16).padStart(2, "0")}`;
23
23
  }
24
+ /**
25
+ * Sign a `0x` 32-byte digest with an EVM private key, returning a `0x` 65-byte
26
+ * `[r||s||v]` secp256k1 signature with `v = 27 | 28` (the EVM `ecrecover` /
27
+ * OpenZeppelin `ECDSA.recover` convention verified by on-chain EVM contracts).
28
+ */
29
+ export async function signDigest(privateKey, digestHex) {
30
+ const serialized = await sign({ hash: digestHex, privateKey, to: "hex" });
31
+ const body = serialized.slice(2); // 130 hex chars: r(64) || s(64) || v(2)
32
+ if (body.length !== 130) {
33
+ throw new Error(`unexpected signature length: ${serialized}`);
34
+ }
35
+ const rs = body.slice(0, 128);
36
+ let v = parseInt(body.slice(128, 130), 16);
37
+ if (v < 27)
38
+ v += 27;
39
+ return `0x${rs}${v.toString(16).padStart(2, "0")}`;
40
+ }
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.5";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLIENT_VERSION = "0.4.4";
1
+ export const CLIENT_VERSION = "0.4.5";
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.5",
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",