@cancore/contracts 0.2.0-rc.3 → 0.2.0-rc.7
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/README.md +137 -28
- package/dist/abi.d.ts +110 -178
- package/dist/abi.js +1 -1
- package/dist/{chunk-NV5IUURP.js → chunk-GJPX4H5K.js} +132 -232
- package/dist/chunk-GJPX4H5K.js.map +1 -0
- package/dist/{chunk-VODZRADO.js → chunk-IAPV7XWJ.js} +2 -2
- package/dist/chunk-IAPV7XWJ.js.map +1 -0
- package/dist/index.d.ts +416 -86
- package/dist/index.js +699 -165
- package/dist/index.js.map +1 -1
- package/dist/networks.d.ts +1 -1
- package/dist/networks.js +1 -1
- package/package.json +1 -1
- package/spec/abi/CancoreRouter.json +64 -155
- package/spec/abi/ICancoreRouter.json +64 -69
- package/spec/protocol/asyncapi.json +265 -27
- package/spec/protocol/messages.schema.json +135 -24
- package/spec/protocol/records.schema.json +3 -2
- package/spec/protocol/rest.schema.json +7 -4
- package/spec/protocol/typed-data/FillerKeyRegistration.json +69 -0
- package/spec/protocol/typed-data/FillerMessage.json +115 -0
- package/spec/protocol/typed-data/FillerQuote.json +12 -12
- package/spec/protocol/typed-data/GatewayMessage.json +12 -9
- package/spec/protocol/typed-data/TicketIntent.json +57 -9
- package/spec/protocol/typed-data/TicketReceipt.json +2 -2
- package/spec/protocol/vectors/messages.json +190 -10
- package/spec/protocol/vectors/settle-attestations.json +542 -0
- package/spec/typed-data/FillProof.json +61 -33
- package/spec/typed-data/FillTicket.json +46 -13
- package/dist/chunk-NV5IUURP.js.map +0 -1
- package/dist/chunk-VODZRADO.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { NETWORKS, NETWORK_ALIASES, Network, NetworkKind, networkByChainId, netw
|
|
|
10
10
|
* the backend of that period talks to; `htlcBlock` is where to start an event
|
|
11
11
|
* scan, not before.
|
|
12
12
|
*
|
|
13
|
-
* `
|
|
13
|
+
* `BUILD_HASHES` pins the build of each release: sha256 of the UTF-8 text of
|
|
14
14
|
* the artifact's 0x-prefixed hex, not keccak256 and not over `eth_getCode`, so it
|
|
15
15
|
* identifies what was built rather than proving what an address runs
|
|
16
16
|
* (immutables alone change runtime code).
|
|
@@ -30,7 +30,7 @@ declare const DEPLOYMENTS: Readonly<Record<DeploymentEnv, readonly EvmDeployment
|
|
|
30
30
|
declare const PERMIT2_ADDRESS: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
31
31
|
declare function deploymentOf(env: DeploymentEnv, network: string): EvmDeployment | undefined;
|
|
32
32
|
|
|
33
|
-
/** `FillProof(uint8 kind,bytes32 orderHash,bytes32 destination,bytes32 fillRef,bytes32 recipient,bytes32 outputAsset,uint256 amountDelivered,uint64 filledAt,
|
|
33
|
+
/** `FillProof(uint8 kind,bytes32 orderHash,bytes32 destination,bytes32 fillRef,bytes32 recipient,bytes32 outputAsset,uint256 amountDelivered,uint64 filledAt,bytes32 fillerId,bytes32 repayTo,uint32 attempt,uint32 setId)` — from evm-contracts/abi/typed-data/FillProof.json. */
|
|
34
34
|
declare const FILL_PROOF_TYPES: {
|
|
35
35
|
readonly FillProof: readonly [{
|
|
36
36
|
readonly name: "kind";
|
|
@@ -57,8 +57,11 @@ declare const FILL_PROOF_TYPES: {
|
|
|
57
57
|
readonly name: "filledAt";
|
|
58
58
|
readonly type: "uint64";
|
|
59
59
|
}, {
|
|
60
|
-
readonly name: "
|
|
61
|
-
readonly type: "
|
|
60
|
+
readonly name: "fillerId";
|
|
61
|
+
readonly type: "bytes32";
|
|
62
|
+
}, {
|
|
63
|
+
readonly name: "repayTo";
|
|
64
|
+
readonly type: "bytes32";
|
|
62
65
|
}, {
|
|
63
66
|
readonly name: "attempt";
|
|
64
67
|
readonly type: "uint32";
|
|
@@ -67,7 +70,7 @@ declare const FILL_PROOF_TYPES: {
|
|
|
67
70
|
readonly type: "uint32";
|
|
68
71
|
}];
|
|
69
72
|
};
|
|
70
|
-
declare const FILL_PROOF_TYPE_STRING = "FillProof(uint8 kind,bytes32 orderHash,bytes32 destination,bytes32 fillRef,bytes32 recipient,bytes32 outputAsset,uint256 amountDelivered,uint64 filledAt,
|
|
73
|
+
declare const FILL_PROOF_TYPE_STRING = "FillProof(uint8 kind,bytes32 orderHash,bytes32 destination,bytes32 fillRef,bytes32 recipient,bytes32 outputAsset,uint256 amountDelivered,uint64 filledAt,bytes32 fillerId,bytes32 repayTo,uint32 attempt,uint32 setId)";
|
|
71
74
|
/** Name and version of the domain; chain id and verifying contract are the deployment's. */
|
|
72
75
|
declare const FILL_PROOF_DOMAIN: {
|
|
73
76
|
readonly name: "CancoreRouter";
|
|
@@ -121,7 +124,7 @@ declare const PROOF_KIND_ATTESTATION = 1;
|
|
|
121
124
|
interface FillProof {
|
|
122
125
|
kind: number;
|
|
123
126
|
orderHash: `0x${string}`;
|
|
124
|
-
/** bytes32: the destination chain id, left-padded
|
|
127
|
+
/** bytes32: EVM — the destination chain id, left-padded; Canton — `keccak256(utf8("canton:<network>"))`. */
|
|
125
128
|
destination: `0x${string}`;
|
|
126
129
|
/** EVM: the delivery transaction hash; Canton: keccak256 of the update id. */
|
|
127
130
|
fillRef: `0x${string}`;
|
|
@@ -130,8 +133,10 @@ interface FillProof {
|
|
|
130
133
|
/** What arrived, not what was sent. */
|
|
131
134
|
amountDelivered: bigint;
|
|
132
135
|
filledAt: bigint;
|
|
133
|
-
/**
|
|
134
|
-
|
|
136
|
+
/** `fillerIdHash(fillerId)`: `Filled.fillerId` (EVM destination) or the hashed `DeliveryReceipt.fillerId` (Canton destination). */
|
|
137
|
+
fillerId: `0x${string}`;
|
|
138
|
+
/** The payee of `settle`, encoded for the source chain: `Filled.repayTo` or `DeliveryReceipt.repayTo`. */
|
|
139
|
+
repayTo: `0x${string}`;
|
|
135
140
|
attempt: number;
|
|
136
141
|
/** The attestor set live when the order opened — `attestationSetFor(orderHash)`, never `currentSetId`. */
|
|
137
142
|
setId: number;
|
|
@@ -148,6 +153,12 @@ declare function fillProofDomain(chainId: number | bigint, verifyingContract: `0
|
|
|
148
153
|
readonly name: "CancoreRouter";
|
|
149
154
|
readonly version: "1";
|
|
150
155
|
};
|
|
156
|
+
/**
|
|
157
|
+
* The router's `hashFillProof`: the digest attestors sign and `settle` (or Daml
|
|
158
|
+
* `SwapIntent_SettleWithProof` on a Canton source) verifies, in the domain of
|
|
159
|
+
* the order's source router.
|
|
160
|
+
*/
|
|
161
|
+
declare function hashFillProof(proof: FillProof, chainId: number | bigint, verifyingContract: `0x${string}`): `0x${string}`;
|
|
151
162
|
|
|
152
163
|
/**
|
|
153
164
|
* The EIP-712 types and domains of the Cancore intent rail, filler protocol v1.
|
|
@@ -156,10 +167,13 @@ declare function fillProofDomain(chainId: number | bigint, verifyingContract: `0
|
|
|
156
167
|
* lives in `../eip712`) are the router's own structs — here they are
|
|
157
168
|
* provisional hand copies of `CancoreRouter.sol` until evm-contracts publishes
|
|
158
169
|
* them under `abi/typed-data` (follow-up F-1); `Order` is pinned by the synced
|
|
159
|
-
* `spec/vectors/canton-order.json`.
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* `
|
|
170
|
+
* `spec/vectors/canton-order.json`. `FillTicket` and `FillProof` carry the
|
|
171
|
+
* variant A fields (`fillerId`, `deliveryKey`, `repayTo`) the router takes
|
|
172
|
+
* before its first deployment (CAN-2140). The PROTOCOL types are off-chain,
|
|
173
|
+
* signed in the `CancoreFillerProtocol` domain by the filler's one message key
|
|
174
|
+
* (or the gateway key), and fixed by this package: a field reordered here
|
|
175
|
+
* changes every digest, and the golden vectors under `spec/protocol/typed-data`
|
|
176
|
+
* fail the moment it happens.
|
|
163
177
|
*/
|
|
164
178
|
type Hex = `0x${string}`;
|
|
165
179
|
/** A wide unsigned integer as the wire carries it (decimal string) or as code holds it. */
|
|
@@ -228,14 +242,23 @@ declare const QUOTE_TYPES: {
|
|
|
228
242
|
readonly type: "uint64";
|
|
229
243
|
}];
|
|
230
244
|
};
|
|
231
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* `FillTicket(bytes32 orderHash,bytes32 fillerId,address deliveryKey,bytes32 repayTo,uint32 attempt,uint64 validFrom,uint64 validUntil)`
|
|
247
|
+
* — signed by a Cancore ticket signer, ticket domain. `fill` requires `msg.sender == deliveryKey`.
|
|
248
|
+
*/
|
|
232
249
|
declare const FILL_TICKET_TYPES: {
|
|
233
250
|
readonly FillTicket: readonly [{
|
|
234
251
|
readonly name: "orderHash";
|
|
235
252
|
readonly type: "bytes32";
|
|
236
253
|
}, {
|
|
237
|
-
readonly name: "
|
|
254
|
+
readonly name: "fillerId";
|
|
255
|
+
readonly type: "bytes32";
|
|
256
|
+
}, {
|
|
257
|
+
readonly name: "deliveryKey";
|
|
238
258
|
readonly type: "address";
|
|
259
|
+
}, {
|
|
260
|
+
readonly name: "repayTo";
|
|
261
|
+
readonly type: "bytes32";
|
|
239
262
|
}, {
|
|
240
263
|
readonly name: "attempt";
|
|
241
264
|
readonly type: "uint32";
|
|
@@ -247,14 +270,14 @@ declare const FILL_TICKET_TYPES: {
|
|
|
247
270
|
readonly type: "uint64";
|
|
248
271
|
}];
|
|
249
272
|
};
|
|
250
|
-
/** `FillerQuote(bytes32 requestId,
|
|
273
|
+
/** `FillerQuote(bytes32 requestId,string fillerId,uint256 amountOut,uint64 validUntil,uint64 nonce)` — signed by the message key. */
|
|
251
274
|
declare const FILLER_QUOTE_TYPES: {
|
|
252
275
|
readonly FillerQuote: readonly [{
|
|
253
276
|
readonly name: "requestId";
|
|
254
277
|
readonly type: "bytes32";
|
|
255
278
|
}, {
|
|
256
|
-
readonly name: "
|
|
257
|
-
readonly type: "
|
|
279
|
+
readonly name: "fillerId";
|
|
280
|
+
readonly type: "string";
|
|
258
281
|
}, {
|
|
259
282
|
readonly name: "amountOut";
|
|
260
283
|
readonly type: "uint256";
|
|
@@ -266,7 +289,10 @@ declare const FILLER_QUOTE_TYPES: {
|
|
|
266
289
|
readonly type: "uint64";
|
|
267
290
|
}];
|
|
268
291
|
};
|
|
269
|
-
/**
|
|
292
|
+
/**
|
|
293
|
+
* `TicketIntent(bytes32 orderHash,uint32 attempt,uint64 validFrom,uint64 validUntil,string fillerId,address deliveryKey,bytes32 repayTo)`
|
|
294
|
+
* — the filler's consent to an offered ticket, signed by its message key; `deliveryKey` and `repayTo` go into the `FillTicket` as they are.
|
|
295
|
+
*/
|
|
270
296
|
declare const TICKET_INTENT_TYPES: {
|
|
271
297
|
readonly TicketIntent: readonly [{
|
|
272
298
|
readonly name: "orderHash";
|
|
@@ -280,9 +306,18 @@ declare const TICKET_INTENT_TYPES: {
|
|
|
280
306
|
}, {
|
|
281
307
|
readonly name: "validUntil";
|
|
282
308
|
readonly type: "uint64";
|
|
309
|
+
}, {
|
|
310
|
+
readonly name: "fillerId";
|
|
311
|
+
readonly type: "string";
|
|
312
|
+
}, {
|
|
313
|
+
readonly name: "deliveryKey";
|
|
314
|
+
readonly type: "address";
|
|
315
|
+
}, {
|
|
316
|
+
readonly name: "repayTo";
|
|
317
|
+
readonly type: "bytes32";
|
|
283
318
|
}];
|
|
284
319
|
};
|
|
285
|
-
/** `TicketReceipt(bytes32 ticketHash,bytes32 ticketSigHash)` — signed by the
|
|
320
|
+
/** `TicketReceipt(bytes32 ticketHash,bytes32 ticketSigHash)` — signed by the message key. */
|
|
286
321
|
declare const TICKET_RECEIPT_TYPES: {
|
|
287
322
|
readonly TicketReceipt: readonly [{
|
|
288
323
|
readonly name: "ticketHash";
|
|
@@ -308,7 +343,7 @@ declare const STAKE_BINDING_TYPES: {
|
|
|
308
343
|
readonly type: "uint64";
|
|
309
344
|
}];
|
|
310
345
|
};
|
|
311
|
-
/** `FillerAuth(string fillerId,bytes32 nonce,uint64 expiresAt)` — signed by the
|
|
346
|
+
/** `FillerAuth(string fillerId,bytes32 nonce,uint64 expiresAt)` — signed by the message key. */
|
|
312
347
|
declare const FILLER_AUTH_TYPES: {
|
|
313
348
|
readonly FillerAuth: readonly [{
|
|
314
349
|
readonly name: "fillerId";
|
|
@@ -328,6 +363,29 @@ declare const GATEWAY_MESSAGE_TYPES: {
|
|
|
328
363
|
readonly type: "bytes32";
|
|
329
364
|
}];
|
|
330
365
|
};
|
|
366
|
+
/** `FillerMessage(bytes32 bodyHash)` — the envelope `msgSig` of every filler message, by the message key; `bodyHash = fillerMessageBodyHash(message)`. */
|
|
367
|
+
declare const FILLER_MESSAGE_TYPES: {
|
|
368
|
+
readonly FillerMessage: readonly [{
|
|
369
|
+
readonly name: "bodyHash";
|
|
370
|
+
readonly type: "bytes32";
|
|
371
|
+
}];
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* `FillerKeyRegistration(string fillerId,address messageKey,uint64 issuedAt)` — proof of possession of a message key,
|
|
375
|
+
* signed by that key: at onboarding, and with the NEW key at a manual key change by Cancore staff. There is no rotation type.
|
|
376
|
+
*/
|
|
377
|
+
declare const FILLER_KEY_REGISTRATION_TYPES: {
|
|
378
|
+
readonly FillerKeyRegistration: readonly [{
|
|
379
|
+
readonly name: "fillerId";
|
|
380
|
+
readonly type: "string";
|
|
381
|
+
}, {
|
|
382
|
+
readonly name: "messageKey";
|
|
383
|
+
readonly type: "address";
|
|
384
|
+
}, {
|
|
385
|
+
readonly name: "issuedAt";
|
|
386
|
+
readonly type: "uint64";
|
|
387
|
+
}];
|
|
388
|
+
};
|
|
331
389
|
interface Order {
|
|
332
390
|
user: Hex;
|
|
333
391
|
originChainId: UintLike;
|
|
@@ -347,7 +405,12 @@ interface Quote {
|
|
|
347
405
|
}
|
|
348
406
|
interface FillTicket {
|
|
349
407
|
orderHash: Hex;
|
|
350
|
-
filler
|
|
408
|
+
/** `fillerIdHash(fillerId)`: the on-chain form of the filler's id. */
|
|
409
|
+
fillerId: Hex;
|
|
410
|
+
/** The only address `fill` accepts this ticket from; the zero address never reaches a router (Canton destinations have no `FillTicket`). */
|
|
411
|
+
deliveryKey: Hex;
|
|
412
|
+
/** Where `settle` pays, encoded for the source chain (`repayToFromEvm`, `repayToFromParty`). */
|
|
413
|
+
repayTo: Hex;
|
|
351
414
|
attempt: number;
|
|
352
415
|
validFrom: UintLike;
|
|
353
416
|
validUntil: UintLike;
|
|
@@ -355,7 +418,7 @@ interface FillTicket {
|
|
|
355
418
|
interface FillerQuote {
|
|
356
419
|
/** `requestIdHash(requestId)`, not the string. */
|
|
357
420
|
requestId: Hex;
|
|
358
|
-
|
|
421
|
+
fillerId: string;
|
|
359
422
|
amountOut: UintLike;
|
|
360
423
|
validUntil: UintLike;
|
|
361
424
|
nonce: UintLike;
|
|
@@ -365,6 +428,12 @@ interface TicketIntent {
|
|
|
365
428
|
attempt: number;
|
|
366
429
|
validFrom: UintLike;
|
|
367
430
|
validUntil: UintLike;
|
|
431
|
+
/** The signer's own id, the string form. */
|
|
432
|
+
fillerId: string;
|
|
433
|
+
/** The address that will send `fill` on the destination; the zero address for a Canton destination. */
|
|
434
|
+
deliveryKey: Hex;
|
|
435
|
+
/** Where `settle` pays, encoded for the source chain. */
|
|
436
|
+
repayTo: Hex;
|
|
368
437
|
}
|
|
369
438
|
interface TicketReceipt {
|
|
370
439
|
/** `hashTypedData` of the `FillTicket` in `FILL_TICKET_DOMAIN`. */
|
|
@@ -386,6 +455,16 @@ interface FillerAuth {
|
|
|
386
455
|
interface GatewayMessage {
|
|
387
456
|
bodyHash: Hex;
|
|
388
457
|
}
|
|
458
|
+
interface FillerMessage {
|
|
459
|
+
bodyHash: Hex;
|
|
460
|
+
}
|
|
461
|
+
interface FillerKeyRegistration {
|
|
462
|
+
fillerId: string;
|
|
463
|
+
/** The address derived from the key being registered. */
|
|
464
|
+
messageKey: Hex;
|
|
465
|
+
/** Unix seconds. */
|
|
466
|
+
issuedAt: UintLike;
|
|
467
|
+
}
|
|
389
468
|
|
|
390
469
|
interface TypedField {
|
|
391
470
|
readonly name: string;
|
|
@@ -427,52 +506,125 @@ declare function hashTypedData({ domain, types, primaryType, message }: TypedDat
|
|
|
427
506
|
declare function jcs(value: unknown): string;
|
|
428
507
|
/** `GatewayMessage.bodyHash`: keccak256 of the JCS text of an S→F message without its `sig`. */
|
|
429
508
|
declare function gatewayBodyHash(message: Readonly<Record<string, unknown>>): Hex;
|
|
509
|
+
/** `FillerMessage.bodyHash`: keccak256 of the JCS text of a filler message without its `msgSig`; `id`, `fillerId`, `sentAt` and any inner `sig` stay in. */
|
|
510
|
+
declare function fillerMessageBodyHash(message: object): Hex;
|
|
430
511
|
/** `FillerQuote.requestId`: keccak256(utf8(requestId)); the id is 1..64 printable ASCII (`Canonical.daml:90-93`). */
|
|
431
512
|
declare function requestIdHash(requestId: string): Hex;
|
|
432
513
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
514
|
+
/** `fillerId`: issued by Cancore at onboarding, ASCII so the draw's UTF-8 byte order is plain byte order (D-H). */
|
|
515
|
+
declare const FILLER_ID_PATTERN: RegExp;
|
|
516
|
+
/** The on-chain form of a filler id, `keccak256(utf8(fillerId))` — `FillTicket`, `Filled`, `FillProof`, `Settled`. */
|
|
517
|
+
declare function fillerIdHash(fillerId: string): Hex;
|
|
518
|
+
/**
|
|
519
|
+
* `repayTo` for an EVM source: the address left-padded with zeros to 32 bytes.
|
|
520
|
+
* Refuses the zero address, which `settle` refuses too (`ZeroAddress`).
|
|
521
|
+
*/
|
|
522
|
+
declare function repayToFromEvm(address: string): Hex;
|
|
523
|
+
/** `repayTo` for a Canton source: `keccak256(utf8(partyId))` of the filler's party registered under its `fillerId`. */
|
|
524
|
+
declare function repayToFromParty(partyId: string): Hex;
|
|
525
|
+
/** Whether `repayTo` is payable on an EVM source: zero top 12 bytes (`InvalidBytes32Address`) and not the zero address (`ZeroAddress`). */
|
|
526
|
+
declare function isEvmRepayTo(repayTo: string): boolean;
|
|
527
|
+
/** The address `settle` pays on an EVM source, `address(uint160(uint256(repayTo)))`; throws where the router reverts. */
|
|
528
|
+
declare function evmAddressFromRepayTo(repayTo: string): Hex;
|
|
529
|
+
/**
|
|
530
|
+
* Whether `sig` has the shape a message key (an EOA) produces and the protocol
|
|
531
|
+
* accepts: 65 bytes `r ‖ s ‖ v`, `v ∈ {27, 28}`, `0 < r < n`, low-s
|
|
532
|
+
* `0 < s ≤ n/2`. Anything else is refused before recovery — an EIP-1271
|
|
533
|
+
* smart-wallet signature among them: the message key is an EOA, verified by
|
|
534
|
+
* ecrecover only. Passing this check says nothing about WHO signed: recover
|
|
535
|
+
* the address and compare it with the registered key.
|
|
536
|
+
*/
|
|
537
|
+
declare function isEoaSignature(sig: unknown): sig is Hex;
|
|
538
|
+
|
|
539
|
+
/** `hashTicket` of the router: the `FillTicket` digest in the ticket domain, the same on every chain. */
|
|
540
|
+
declare const hashFillTicket: (ticket: FillTicket) => Hex;
|
|
541
|
+
/** The `FillerQuote` digest; `quote.requestId` is already `requestIdHash(requestId)`. */
|
|
542
|
+
declare const hashFillerQuote: (quote: FillerQuote) => Hex;
|
|
543
|
+
/** The `TicketIntent` digest — the inner `sig` of `ticket.intent`. */
|
|
544
|
+
declare const hashTicketIntent: (intent: TicketIntent) => Hex;
|
|
545
|
+
/** What `msgSig` of a filler → filler-gateway message is over: `FillerMessage{bodyHash}` of the message without `msgSig`. */
|
|
546
|
+
declare const hashFillerMessage: (message: object) => Hex;
|
|
547
|
+
/** The `FillerKeyRegistration` digest; the registered key signs it, and it must recover to `messageKey`. */
|
|
548
|
+
declare const hashFillerKeyRegistration: (registration: FillerKeyRegistration) => Hex;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* `FillProof` on the wire (§3.1), field for field the struct the source router
|
|
552
|
+
* hashes (`FILL_PROOF_TYPES`, the twelve variant A fields of protocol §3.3).
|
|
553
|
+
*/
|
|
554
|
+
interface FillProofJson {
|
|
555
|
+
kind: number;
|
|
556
|
+
orderHash: Hex;
|
|
557
|
+
destination: Hex;
|
|
558
|
+
fillRef: Hex;
|
|
559
|
+
recipient: Hex;
|
|
560
|
+
outputAsset: Hex;
|
|
561
|
+
amountDelivered: DecString;
|
|
562
|
+
filledAt: DecString;
|
|
563
|
+
/** `fillerIdHash(fillerId)` of the filler that delivered. */
|
|
564
|
+
fillerId: Hex;
|
|
565
|
+
/** The payee of `settle`, encoded for the source chain: the `repayTo` of the filler's ticket. */
|
|
566
|
+
repayTo: Hex;
|
|
567
|
+
attempt: number;
|
|
568
|
+
setId: number;
|
|
437
569
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
570
|
+
/** EVM source: 65-byte `r ‖ s ‖ v`; in payload order the `signature` values are the `sigs` of `settle`. */
|
|
571
|
+
interface AttestationEvm {
|
|
572
|
+
signer: Hex;
|
|
573
|
+
signature: Hex;
|
|
441
574
|
}
|
|
442
|
-
/** drand quicknet, the randomness beacon of the draw (auction-and-draw §4). */
|
|
443
|
-
declare const DRAND_QUICKNET: {
|
|
444
|
-
readonly chainHash: "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971";
|
|
445
|
-
readonly publicKey: "83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a";
|
|
446
|
-
readonly scheme: "bls-unchained-g1-rfc9380";
|
|
447
|
-
readonly genesisTime: 1692803367;
|
|
448
|
-
readonly period: 3;
|
|
449
|
-
};
|
|
450
|
-
/** The first quicknet round whose time is at or after `unixSeconds` (A-20: `round_k` for `t_k + δ_drand`). */
|
|
451
|
-
declare function firstRoundAtOrAfter(unixSeconds: bigint | number): bigint;
|
|
452
|
-
/** `h = uint256(keccak256(randomness ‖ orderHash ‖ uint32be(attempt)))` — the 68-byte preimage of A-21. */
|
|
453
|
-
declare function drawValue(randomness: Hex | string, orderHash: Hex, attempt: number): bigint;
|
|
454
575
|
/**
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
576
|
+
* Canton source: a `SigEntry` of `SwapIntent_SettleWithProof` with `0x`
|
|
577
|
+
* (strip it for Daml) — the 88-byte DER SubjectPublicKeyInfo of the signer's
|
|
578
|
+
* uncompressed key and a minimal DER signature — plus the address Daml derives
|
|
579
|
+
* from the key.
|
|
458
580
|
*/
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
interface FillerGateway {
|
|
464
|
-
/** The key every S→F message is signed with (`GatewayMessage`); null until the environment has one. */
|
|
465
|
-
gateway: Hex | null;
|
|
466
|
-
/** Keys that sign `FillTicket`; the same set is registered on every router of the environment. */
|
|
467
|
-
ticketSigners: readonly Hex[];
|
|
581
|
+
interface AttestationCanton {
|
|
582
|
+
signer: Hex;
|
|
583
|
+
pubKey: Hex;
|
|
584
|
+
signature: Hex;
|
|
468
585
|
}
|
|
586
|
+
interface SettleAttestations extends S2FBase {
|
|
587
|
+
type: 'settle.attestations';
|
|
588
|
+
fillerId: string;
|
|
589
|
+
orderHash: Hex;
|
|
590
|
+
/** Equals `proof.attempt`. */
|
|
591
|
+
attempt: number;
|
|
592
|
+
/** CAIP-2 of the chain `settle` is submitted on: `eip155:<id>` or `canton:<network>`. */
|
|
593
|
+
sourceChainId: string;
|
|
594
|
+
proof: FillProofJson;
|
|
595
|
+
/** At least `threshold`, strictly ascending by `signer`. */
|
|
596
|
+
signatures: AttestationEvm[] | AttestationCanton[];
|
|
597
|
+
/** Equals `proof.setId`; EVM: `attestationSetFor(orderHash)`. */
|
|
598
|
+
setId: number;
|
|
599
|
+
threshold: number;
|
|
600
|
+
/** Unix seconds: `settle` must be included before it. */
|
|
601
|
+
refundAfter: DecString;
|
|
602
|
+
}
|
|
603
|
+
/** What `settle.attestations` carries apart from its envelope: identical on WebSocket and REST. */
|
|
604
|
+
type SettleAttestationsPayload = Omit<SettleAttestations, 'type' | 'id' | 'fillerId' | 'sentAt' | 'sig' | 're'>;
|
|
605
|
+
/** The payload of a `settle.attestations` frame or REST body: everything but `type`, `id`, `fillerId`, `sentAt`, `sig`, `re`. */
|
|
606
|
+
declare function settleAttestationsPayload(frame: object): SettleAttestationsPayload;
|
|
469
607
|
/**
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* takes from a gateway message. Empty in the RC: the keys do not exist yet
|
|
473
|
-
* (O-6); the gateway release fills them in. Test keys never appear here.
|
|
608
|
+
* `keccak256(utf8(JCS(payload)))`: equal for the pushed frame and the pulled
|
|
609
|
+
* body of the same delivery, whatever their `id`, `sentAt` and `sig`.
|
|
474
610
|
*/
|
|
475
|
-
declare
|
|
611
|
+
declare function settleAttestationsPayloadHash(frame: object): Hex;
|
|
612
|
+
/** Whether `settle` for this payload goes to Daml (`SwapIntent_SettleWithProof`) rather than an EVM router. */
|
|
613
|
+
declare const isCantonSource: (sourceChainId: string) => boolean;
|
|
614
|
+
/**
|
|
615
|
+
* The rules of a schema-valid `settle.attestations` that JSON Schema cannot
|
|
616
|
+
* state: `attempt`, `setId` and `orderHash` equal the proof's, at least
|
|
617
|
+
* `threshold` signatures, signers strictly ascending (no duplicates).
|
|
618
|
+
* Returns one message per broken rule, empty when none is.
|
|
619
|
+
*/
|
|
620
|
+
declare function settleAttestationsErrors(payload: SettleAttestationsPayload): string[];
|
|
621
|
+
/** EVM source: the `sigs` argument of `CancoreRouter.settle(order, proof, sigs)`, in payload order. */
|
|
622
|
+
declare function settleSigs(payload: SettleAttestationsPayload): Hex[];
|
|
623
|
+
/** Canton source: the `bundle : [SigEntry]` of `SwapIntent_SettleWithProof` — lowercase hex without `0x`, in payload order. */
|
|
624
|
+
declare function cantonSigEntries(payload: SettleAttestationsPayload): {
|
|
625
|
+
pubKey: string;
|
|
626
|
+
sig: string;
|
|
627
|
+
}[];
|
|
476
628
|
|
|
477
629
|
/**
|
|
478
630
|
* The wire shapes of filler protocol v1 — WebSocket frames on `/v1`, REST
|
|
@@ -482,6 +634,10 @@ declare const FILLER_GATEWAYS: Readonly<Record<DeploymentEnv, FillerGateway>>;
|
|
|
482
634
|
* uint8/16/32 as JSON integers, on-chain times in seconds (decimal string),
|
|
483
635
|
* gateway times in milliseconds (JSON integer), hex lowercase.
|
|
484
636
|
*
|
|
637
|
+
* Every frame in both directions is signed by its sender (protocol §3.4):
|
|
638
|
+
* `sig` (gateway key, `GatewayMessage`) on S→F, `msgSig` (the filler's message
|
|
639
|
+
* key, `FillerMessage`) on F→S, and carries `id`, `fillerId` and `sentAt`.
|
|
640
|
+
*
|
|
485
641
|
* Receivers ignore unknown fields and unknown S→F types (V-2), so none of
|
|
486
642
|
* these types is closed. The enum types list the known values; the schemas
|
|
487
643
|
* accept any UPPER_SNAKE value besides them, and a receiver treats an unknown
|
|
@@ -498,9 +654,11 @@ type WireAsset = Hex | {
|
|
|
498
654
|
id: string;
|
|
499
655
|
};
|
|
500
656
|
declare const DECLINE_REASONS: readonly ["NO_INVENTORY", "RISK_LIMIT", "PRICE_MOVED", "PAUSED", "OTHER", "TICKET_SIGNER_UNKNOWN", "TICKET_MISMATCH", "TICKET_TTL_TOO_SHORT", "TICKET_ISSUED_LATE", "TICKET_BEYOND_DEADLINE", "ESCROW_NOT_OPEN", "ESCROW_MISMATCH", "PROOF_WINDOW_TOO_SHORT", "SKEW_MARGIN_TOO_SHORT", "DRAW_MISMATCH"];
|
|
501
|
-
declare const ERROR_CODES: readonly ["BAD_REQUEST", "UNAUTHENTICATED", "UNSUPPORTED_VERSION", "UNSUPPORTED_TYPE", "BAD_SIGNATURE", "UNKNOWN_REQUEST", "UNKNOWN_TICKET", "TICKET_CLOSED", "NOT_ELIGIBLE", "RATE_LIMITED", "INTERNAL"];
|
|
657
|
+
declare const ERROR_CODES: readonly ["BAD_REQUEST", "UNAUTHENTICATED", "UNSUPPORTED_VERSION", "UNSUPPORTED_TYPE", "BAD_SIGNATURE", "STALE_MESSAGE", "REPLAYED_MESSAGE", "TICKET_REFUSED", "UNKNOWN_REQUEST", "UNKNOWN_TICKET", "TICKET_CLOSED", "NOT_ELIGIBLE", "RATE_LIMITED", "INTERNAL", "ATTESTATIONS_NOT_READY"];
|
|
502
658
|
/** HTTP status of each error code on the REST fallback. */
|
|
503
659
|
declare const ERROR_HTTP_STATUS: Readonly<Record<ErrorCode, number>>;
|
|
660
|
+
/** `error.reason` with `TICKET_REFUSED`: the pre-ticket check that failed (S-21). */
|
|
661
|
+
declare const TICKET_REFUSED_REASONS: readonly ["REPAY_TO_INVALID", "REPAY_TO_BLOCKLISTED", "DELIVERY_KEY_INVALID", "PAYOUT_NOT_READY", "RECIPIENT_NOT_READY", "OPEN_TICKET_LIMIT", "PROOF_WINDOW_TOO_SHORT", "ATTESTOR_REVOCATION_PENDING", "SERVICE_DEGRADED", "OTHER"];
|
|
504
662
|
declare const EXPIRED_RESULTS: readonly ["FILLED", "NO_SHOW", "NO_SHOW_UNCONFIRMED", "EXEMPT"];
|
|
505
663
|
declare const EXEMPT_REASONS: readonly ["DESTINATION_HALTED", "GATEWAY_FAULT", "REORGED_AFTER_INCLUSION", "RECIPIENT_NOT_READY", "OTHER"];
|
|
506
664
|
/** Verdict at receipt time, on the `quote.ack`. */
|
|
@@ -512,6 +670,7 @@ declare const DRAW_CLOSED_BY: readonly ["OFFER_TIMEOUT", "OFFER_DECLINE", "TICKE
|
|
|
512
670
|
declare const TICKET_LIST_STATUSES: readonly ["OFFERED", "ISSUED"];
|
|
513
671
|
type DeclineReason = (typeof DECLINE_REASONS)[number];
|
|
514
672
|
type ErrorCode = (typeof ERROR_CODES)[number];
|
|
673
|
+
type TicketRefusedReason = (typeof TICKET_REFUSED_REASONS)[number];
|
|
515
674
|
type ExpiredResult = (typeof EXPIRED_RESULTS)[number];
|
|
516
675
|
type ExemptReason = (typeof EXEMPT_REASONS)[number];
|
|
517
676
|
type QuoteAckStatus = (typeof QUOTE_ACK_STATUSES)[number];
|
|
@@ -535,6 +694,7 @@ interface OrderJson {
|
|
|
535
694
|
/** Every S→F frame: signed by the gateway (`GatewayMessage`), addressed (`fillerId`) and timed (`sentAt`). */
|
|
536
695
|
interface S2FBase {
|
|
537
696
|
type: string;
|
|
697
|
+
id: string;
|
|
538
698
|
/** The addressee. Absent only on `auth.challenge` and on pre-auth `error`. */
|
|
539
699
|
fillerId?: string;
|
|
540
700
|
sentAt: TimeMs;
|
|
@@ -542,10 +702,21 @@ interface S2FBase {
|
|
|
542
702
|
/** The F→S `id` this frame answers. */
|
|
543
703
|
re?: string;
|
|
544
704
|
}
|
|
545
|
-
/**
|
|
546
|
-
|
|
547
|
-
|
|
705
|
+
/**
|
|
706
|
+
* What every filler → filler-gateway message and REST request body carries (S-19, T-13): `id` unique per
|
|
707
|
+
* `fillerId` and direction, ≤ 64 characters; the sender's `fillerId`; `sentAt`; `msgSig` by the message key over
|
|
708
|
+
* `FillerMessage{bodyHash: fillerMessageBodyHash(message)}`.
|
|
709
|
+
*/
|
|
710
|
+
interface F2SEnvelope {
|
|
548
711
|
id: string;
|
|
712
|
+
fillerId: string;
|
|
713
|
+
sentAt: TimeMs;
|
|
714
|
+
msgSig: Hex;
|
|
715
|
+
/** The S→F `id` this message answers. */
|
|
716
|
+
re?: string;
|
|
717
|
+
}
|
|
718
|
+
interface F2SBase extends F2SEnvelope {
|
|
719
|
+
type: string;
|
|
549
720
|
}
|
|
550
721
|
interface AuthChallenge extends S2FBase {
|
|
551
722
|
type: 'auth.challenge';
|
|
@@ -557,6 +728,8 @@ interface AuthResponse extends F2SBase {
|
|
|
557
728
|
fillerId: string;
|
|
558
729
|
keyAddress: Hex;
|
|
559
730
|
protocolVersion: '1';
|
|
731
|
+
/** Optional: the `auth.challenge` nonce this answers, so the REST login finds its challenge directly. */
|
|
732
|
+
nonce?: Hex;
|
|
560
733
|
sig: Hex;
|
|
561
734
|
}
|
|
562
735
|
interface AuthOk extends S2FBase {
|
|
@@ -564,21 +737,18 @@ interface AuthOk extends S2FBase {
|
|
|
564
737
|
fillerId: string;
|
|
565
738
|
heartbeatIntervalMs: number;
|
|
566
739
|
}
|
|
567
|
-
/** Heartbeat from the
|
|
568
|
-
interface PingF2S {
|
|
740
|
+
/** Heartbeat from the filler: signed with `msgSig`, like every F→S frame. */
|
|
741
|
+
interface PingF2S extends F2SBase {
|
|
569
742
|
type: 'ping';
|
|
570
|
-
id: string;
|
|
571
743
|
}
|
|
572
|
-
interface PongF2S {
|
|
744
|
+
interface PongF2S extends F2SBase {
|
|
573
745
|
type: 'pong';
|
|
574
746
|
re: string;
|
|
575
|
-
id?: string;
|
|
576
747
|
}
|
|
577
748
|
/** Heartbeat from the gateway: signed, addressed and timed, like every S→F frame (D-C). */
|
|
578
749
|
interface PingS2F extends S2FBase {
|
|
579
750
|
type: 'ping';
|
|
580
751
|
fillerId: string;
|
|
581
|
-
id: string;
|
|
582
752
|
}
|
|
583
753
|
interface PongS2F extends S2FBase {
|
|
584
754
|
type: 'pong';
|
|
@@ -591,6 +761,14 @@ interface ErrorMessage extends S2FBase {
|
|
|
591
761
|
type: 'error';
|
|
592
762
|
code: ErrorCode;
|
|
593
763
|
message: string;
|
|
764
|
+
reason?: TicketRefusedReason;
|
|
765
|
+
}
|
|
766
|
+
/** The filler's reply to a gateway frame it cannot handle; informational. */
|
|
767
|
+
interface ErrorF2S extends F2SBase {
|
|
768
|
+
type: 'error';
|
|
769
|
+
re: string;
|
|
770
|
+
code: ErrorCode;
|
|
771
|
+
message: string;
|
|
594
772
|
}
|
|
595
773
|
interface EpochWeights extends S2FBase {
|
|
596
774
|
type: 'epoch.weights';
|
|
@@ -619,10 +797,10 @@ interface QuoteRequest extends S2FBase {
|
|
|
619
797
|
netFlow24hUsd: string;
|
|
620
798
|
};
|
|
621
799
|
}
|
|
800
|
+
/** `sig` = `FillerQuote{requestIdHash(requestId), fillerId, amountOut, validUntil, nonce}` by the message key. */
|
|
622
801
|
interface QuoteMessage extends F2SBase {
|
|
623
802
|
type: 'quote';
|
|
624
803
|
requestId: string;
|
|
625
|
-
filler: Hex;
|
|
626
804
|
amountOut: DecString;
|
|
627
805
|
validUntil: DecString;
|
|
628
806
|
nonce: DecString;
|
|
@@ -662,12 +840,17 @@ interface TicketOffer extends S2FBase {
|
|
|
662
840
|
validUntil: DecString;
|
|
663
841
|
acceptBy: TimeMs;
|
|
664
842
|
}
|
|
843
|
+
/** `sig` = `TicketIntent{orderHash, attempt, validFrom, validUntil, fillerId, deliveryKey, repayTo}` by the message key. */
|
|
665
844
|
interface TicketIntentMessage extends F2SBase {
|
|
666
845
|
type: 'ticket.intent';
|
|
667
846
|
orderHash: Hex;
|
|
668
847
|
attempt: number;
|
|
669
848
|
validFrom: DecString;
|
|
670
849
|
validUntil: DecString;
|
|
850
|
+
/** The address that will send `fill`; the zero address for a Canton destination. */
|
|
851
|
+
deliveryKey: Hex;
|
|
852
|
+
/** Where `settle` pays, encoded for the source chain. */
|
|
853
|
+
repayTo: Hex;
|
|
671
854
|
sig: Hex;
|
|
672
855
|
}
|
|
673
856
|
interface TicketDecline extends F2SBase {
|
|
@@ -684,9 +867,12 @@ interface TicketIntentAck extends S2FBase {
|
|
|
684
867
|
intentHash: Hex;
|
|
685
868
|
receivedAt: TimeMs;
|
|
686
869
|
}
|
|
870
|
+
/** `FillTicket` on the wire; `fillerId` is the on-chain form, `fillerIdHash(fillerId)`. */
|
|
687
871
|
interface TicketJson {
|
|
688
872
|
orderHash: Hex;
|
|
689
|
-
|
|
873
|
+
fillerId: Hex;
|
|
874
|
+
deliveryKey: Hex;
|
|
875
|
+
repayTo: Hex;
|
|
690
876
|
attempt: number;
|
|
691
877
|
validFrom: DecString;
|
|
692
878
|
validUntil: DecString;
|
|
@@ -706,6 +892,7 @@ interface TicketIssuedCanton extends S2FBase {
|
|
|
706
892
|
attempt: number;
|
|
707
893
|
deliveryOrderCid: string;
|
|
708
894
|
validUntil: DecString;
|
|
895
|
+
repayTo: Hex;
|
|
709
896
|
}
|
|
710
897
|
type TicketIssued = TicketIssuedEvm | TicketIssuedCanton;
|
|
711
898
|
interface TicketReceiptMessage extends F2SBase {
|
|
@@ -744,8 +931,8 @@ interface PenaltyApplied extends S2FBase {
|
|
|
744
931
|
step: PenaltyStep;
|
|
745
932
|
details: Record<string, unknown>;
|
|
746
933
|
}
|
|
747
|
-
type S2FMessage = AuthChallenge | AuthOk | PingS2F | PongS2F | ErrorMessage | EpochWeights | QuoteRequest | QuoteAck | QuoteReconfirm | TicketOffer | TicketIntentAck | TicketIssued | TicketExpired | OrderSettled | PenaltyApplied;
|
|
748
|
-
type F2SMessage = AuthResponse | PingF2S | PongF2S | QuoteMessage | QuoteReconfirmReply | TicketIntentMessage | TicketDecline | TicketReceiptMessage | FillReported;
|
|
934
|
+
type S2FMessage = AuthChallenge | AuthOk | PingS2F | PongS2F | ErrorMessage | EpochWeights | QuoteRequest | QuoteAck | QuoteReconfirm | TicketOffer | TicketIntentAck | TicketIssued | TicketExpired | OrderSettled | PenaltyApplied | SettleAttestations;
|
|
935
|
+
type F2SMessage = AuthResponse | PingF2S | PongF2S | ErrorF2S | QuoteMessage | QuoteReconfirmReply | TicketIntentMessage | TicketDecline | TicketReceiptMessage | FillReported;
|
|
749
936
|
interface AuthToken {
|
|
750
937
|
token: string;
|
|
751
938
|
expiresAt: TimeMs;
|
|
@@ -761,7 +948,9 @@ interface QuoteRecord {
|
|
|
761
948
|
status: QuoteFinalStatus;
|
|
762
949
|
}
|
|
763
950
|
type QuoteList = Page<QuoteRecord>;
|
|
764
|
-
|
|
951
|
+
/** `GET /v1/filler/attestations/{orderHash}`: the `settle.attestations` frame itself, freshly signed. */
|
|
952
|
+
type AttestationsResponse = SettleAttestations;
|
|
953
|
+
interface StakeBindingRequest extends F2SEnvelope {
|
|
765
954
|
partnerId: string;
|
|
766
955
|
stakingAddress: Hex;
|
|
767
956
|
chainId: DecString;
|
|
@@ -838,7 +1027,90 @@ interface GatewayInfo {
|
|
|
838
1027
|
gateway: Hex;
|
|
839
1028
|
ticketSigners: Hex[];
|
|
840
1029
|
protocolVersion: '1';
|
|
1030
|
+
maxMessageAgeMs: number;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* `FillerKeyRegistration` with its signature by the key being registered (§3.16): handed to Cancore at
|
|
1034
|
+
* onboarding and, signed by the NEW key, at a manual key change by staff. Not a frame — no message changes a key.
|
|
1035
|
+
*/
|
|
1036
|
+
interface SignedFillerKeyRegistration {
|
|
1037
|
+
fillerId: string;
|
|
1038
|
+
messageKey: Hex;
|
|
1039
|
+
issuedAt: DecString;
|
|
1040
|
+
sig: Hex;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
interface FillerEnvelopeContext {
|
|
1044
|
+
/** The `fillerId` the session (or bearer token) is authenticated for. */
|
|
1045
|
+
fillerId: string;
|
|
1046
|
+
/** Arrival time, unix ms, the receiver's clock. */
|
|
1047
|
+
receivedAt: number;
|
|
1048
|
+
/** `GET /v1/gateway` `maxMessageAgeMs`. */
|
|
1049
|
+
maxMessageAgeMs: number;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* The error code the gateway answers for the first envelope check `message`
|
|
1053
|
+
* fails, in the order of §3.4, or `null` when every key-free check passes:
|
|
1054
|
+
* `BAD_SIGNATURE` — `msgSig` missing or not a 65-byte low-s EOA signature;
|
|
1055
|
+
* `UNAUTHENTICATED` — `fillerId` is not the session's; `BAD_REQUEST` — `sentAt`
|
|
1056
|
+
* not unix milliseconds, or no valid `id`; `STALE_MESSAGE` — `sentAt` further
|
|
1057
|
+
* than `maxMessageAgeMs` from `receivedAt`.
|
|
1058
|
+
*/
|
|
1059
|
+
declare function fillerEnvelopeError(message: object, ctx: FillerEnvelopeContext): ErrorCode | null;
|
|
1060
|
+
/**
|
|
1061
|
+
* Until when (unix ms, receiver clock) the receiver must remember an accepted
|
|
1062
|
+
* message `id` to refuse its replay: `max(receivedAt, sentAt) + maxMessageAgeMs`.
|
|
1063
|
+
* Freshness is symmetric (`|receivedAt − sentAt| ≤ maxMessageAgeMs`), so a
|
|
1064
|
+
* message whose `sentAt` runs ahead of the receiver's clock stays fresh until
|
|
1065
|
+
* `sentAt + maxMessageAgeMs` — later than `receivedAt + maxMessageAgeMs`.
|
|
1066
|
+
* Forgetting the id earlier would let the byte-identical message in again;
|
|
1067
|
+
* after this time a replay fails the freshness check by itself.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function messageIdRetainUntil(sentAt: number, receivedAt: number, maxMessageAgeMs: number): number;
|
|
1070
|
+
|
|
1071
|
+
interface DrawCandidate {
|
|
1072
|
+
fillerId: string;
|
|
1073
|
+
/** Decimal string on the wire; the integer weight of auction-and-draw A-11. */
|
|
1074
|
+
weight: string | bigint;
|
|
1075
|
+
}
|
|
1076
|
+
interface DrawOutcome {
|
|
1077
|
+
r: bigint;
|
|
1078
|
+
winnerFillerId: string;
|
|
1079
|
+
}
|
|
1080
|
+
/** drand quicknet, the randomness beacon of the draw (auction-and-draw §4). */
|
|
1081
|
+
declare const DRAND_QUICKNET: {
|
|
1082
|
+
readonly chainHash: "52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971";
|
|
1083
|
+
readonly publicKey: "83cf0f2896adee7eb8b5f01fcad3912212c437e0073e911fb90022d3e760183c8c4b450b6a0a6c3ac6a5776a2d1064510d1fec758c921cc22b0e17e63aaf4bcb5ed66304de9cf809bd274ca73bab4af5a6e9c76a4bc09e76eae8991ef5ece45a";
|
|
1084
|
+
readonly scheme: "bls-unchained-g1-rfc9380";
|
|
1085
|
+
readonly genesisTime: 1692803367;
|
|
1086
|
+
readonly period: 3;
|
|
1087
|
+
};
|
|
1088
|
+
/** The first quicknet round whose time is at or after `unixSeconds` (A-20: `round_k` for `t_k + δ_drand`). */
|
|
1089
|
+
declare function firstRoundAtOrAfter(unixSeconds: bigint | number): bigint;
|
|
1090
|
+
/** `h = uint256(keccak256(randomness ‖ orderHash ‖ uint32be(attempt)))` — the 68-byte preimage of A-21. */
|
|
1091
|
+
declare function drawValue(randomness: Hex | string, orderHash: Hex, attempt: number): bigint;
|
|
1092
|
+
/**
|
|
1093
|
+
* `r = h mod Σw`; the winner is the first candidate, in ascending UTF-8 byte
|
|
1094
|
+
* order of `fillerId` (A-22), whose cumulative weight exceeds `r`. Sorts a copy
|
|
1095
|
+
* itself, so a verifier compares the outcome, not the order it was served in.
|
|
1096
|
+
*/
|
|
1097
|
+
declare function drawWinner(h: bigint, candidates: readonly DrawCandidate[]): DrawOutcome;
|
|
1098
|
+
|
|
1099
|
+
/** The protocol major this package describes: the `/v1` path and `auth.response.protocolVersion`. */
|
|
1100
|
+
declare const PROTOCOL_VERSION = "1";
|
|
1101
|
+
interface FillerGateway {
|
|
1102
|
+
/** The key every S→F message is signed with (`GatewayMessage`); null until the environment has one. */
|
|
1103
|
+
gateway: Hex | null;
|
|
1104
|
+
/** Keys that sign `FillTicket`; the same set is registered on every router of the environment. */
|
|
1105
|
+
ticketSigners: readonly Hex[];
|
|
841
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* The published gateway key and ticket signers per environment — the release
|
|
1109
|
+
* data a taker checks every S→F signature and every ticket against, and never
|
|
1110
|
+
* takes from a gateway message. Empty in the RC: the keys do not exist yet
|
|
1111
|
+
* (O-6); the gateway release fills them in. Test keys never appear here.
|
|
1112
|
+
*/
|
|
1113
|
+
declare const FILLER_GATEWAYS: Readonly<Record<DeploymentEnv, FillerGateway>>;
|
|
842
1114
|
|
|
843
1115
|
type JsonSchema = Readonly<Record<string, unknown>>;
|
|
844
1116
|
type MessageDirection = 'S2F' | 'F2S' | 'both';
|
|
@@ -869,20 +1141,78 @@ declare const REST_ENDPOINTS: readonly RestEndpoint[];
|
|
|
869
1141
|
*/
|
|
870
1142
|
declare function messageSchemaRef(type: string, direction?: 'S2F' | 'F2S'): string;
|
|
871
1143
|
|
|
872
|
-
/** The evm-contracts release these ABIs were taken from. */
|
|
1144
|
+
/** The evm-contracts release these ABIs were taken from, and the commit of the checkout they were read at. */
|
|
873
1145
|
declare const CONTRACTS_RELEASE: {
|
|
874
1146
|
readonly version: "1.4.0-dev";
|
|
875
1147
|
readonly releaseChannel: "dev";
|
|
876
1148
|
readonly updatedAt: "2026-07-24T19:55:00Z";
|
|
1149
|
+
readonly commit: "c214f56f6fe5a62097833c5f1335b0cb5351b225";
|
|
1150
|
+
};
|
|
1151
|
+
/**
|
|
1152
|
+
* Per contract, the build of the release, as evm-contracts
|
|
1153
|
+
* scripts/tools/check-bytecode-match.mjs records it. `creationHexSha256` and
|
|
1154
|
+
* `runtimeHexSha256` are sha256 of the UTF-8 text of the artifact's 0x-prefixed hex of the
|
|
1155
|
+
* creation and runtime bytecode (not keccak256, not of the bytes); `creationHexLength` and
|
|
1156
|
+
* `runtimeHexLength` are the length of that text including the 0x. It pins the build a
|
|
1157
|
+
* release was made from. It is not a hash of `eth_getCode` — a contract with immutables
|
|
1158
|
+
* (CancoreRouter, FeeVault) never matches one — so checking a live deployment against it
|
|
1159
|
+
* needs a rebuild, not a lookup.
|
|
1160
|
+
*/
|
|
1161
|
+
declare const BUILD_HASHES: {
|
|
1162
|
+
readonly HTLC: {
|
|
1163
|
+
readonly creationHexSha256: "93a991d3a6451f7c3f02dfb70b365a48d29bebccc7f16d8dbe3d56d3dfee0af1";
|
|
1164
|
+
readonly runtimeHexSha256: "40ab52456c3b5a04365fc1fad837eb79bbe4b85c8dbd990f549468ae48f97e3a";
|
|
1165
|
+
readonly creationHexLength: 14976;
|
|
1166
|
+
readonly runtimeHexLength: 14686;
|
|
1167
|
+
};
|
|
1168
|
+
readonly FeeVault: {
|
|
1169
|
+
readonly creationHexSha256: "1c97d27c8d3e584f879bb57549d75ef10394a56a298eaf4a772516b9316e2248";
|
|
1170
|
+
readonly runtimeHexSha256: "0631177a64cde0829c2cec8426c08a507564f7d8b084e0237d724ed63faea0e9";
|
|
1171
|
+
readonly creationHexLength: 13176;
|
|
1172
|
+
readonly runtimeHexLength: 10968;
|
|
1173
|
+
};
|
|
1174
|
+
readonly MultiBalanceChecker: {
|
|
1175
|
+
readonly creationHexSha256: "c0a0326694f2a1594e332ba06120692cc98bc06c57d6d8981cb3768e01fad423";
|
|
1176
|
+
readonly runtimeHexSha256: "93a1f0aa251715cc6a1b6a472f10762463b5c24668886630cbc6da5632e5739b";
|
|
1177
|
+
readonly creationHexLength: 2456;
|
|
1178
|
+
readonly runtimeHexLength: 2394;
|
|
1179
|
+
};
|
|
1180
|
+
readonly CancoreRouter: {
|
|
1181
|
+
readonly creationHexSha256: "43f61c94c1bb04ee4a0f3ad39356744e6b542eb9945ce4f0561665e049d451b0";
|
|
1182
|
+
readonly runtimeHexSha256: "0c826474f8df21fdceefaf5234d3c50e0a8afcdf3124beb002aed4585227de72";
|
|
1183
|
+
readonly creationHexLength: 40820;
|
|
1184
|
+
readonly runtimeHexLength: 35248;
|
|
1185
|
+
};
|
|
1186
|
+
readonly CNRXStaking: {
|
|
1187
|
+
readonly creationHexSha256: "dfda056ee22b593e2f2e1fc4e679fbb9dc34b04964f389b46914402c422b40fb";
|
|
1188
|
+
readonly runtimeHexSha256: "d11534242f166e52f4ad063b5b6b59146e31634d3932f7ad63db05d83a1485f6";
|
|
1189
|
+
readonly creationHexLength: 7412;
|
|
1190
|
+
readonly runtimeHexLength: 6240;
|
|
1191
|
+
};
|
|
1192
|
+
readonly PointsClaim: {
|
|
1193
|
+
readonly creationHexSha256: "0f29890b609f7e15ef4dbcda17a7f2cd7482d016a0057a5f6c4270d7780ff38d";
|
|
1194
|
+
readonly runtimeHexSha256: "f2b10c4ec8458c0d6ab0f465481e645524f618f7a3327822e8ae5d3fd42fa46c";
|
|
1195
|
+
readonly creationHexLength: 14300;
|
|
1196
|
+
readonly runtimeHexLength: 11504;
|
|
1197
|
+
};
|
|
1198
|
+
readonly BurnMintTokenPool: {
|
|
1199
|
+
readonly creationHexSha256: "b5b19721149d9dd63e0650d0a1f95ac82affa4b9c650fdffd375db6ea361e416";
|
|
1200
|
+
readonly runtimeHexSha256: "c9aaa6a40ef4f0caadeb66f0a9adc68b1191949e9e0bdb420f331132bf651c3a";
|
|
1201
|
+
readonly creationHexLength: 41756;
|
|
1202
|
+
readonly runtimeHexLength: 39936;
|
|
1203
|
+
};
|
|
1204
|
+
readonly CNRX: {
|
|
1205
|
+
readonly creationHexSha256: "61b4e114722e99f93aac4bd4ef3cfb7973dd050b66e6ffb326efad29d4cc8c95";
|
|
1206
|
+
readonly runtimeHexSha256: "2b23774e41fb25f820227a50de4f48d7ad79b0bd131c1956aab07c100e0c3948";
|
|
1207
|
+
readonly creationHexLength: 21266;
|
|
1208
|
+
readonly runtimeHexLength: 17374;
|
|
1209
|
+
};
|
|
877
1210
|
};
|
|
878
1211
|
/**
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
883
|
-
* build a release was made from. It is not a hash of `eth_getCode` — a contract with
|
|
884
|
-
* immutables (CancoreRouter, FeeVault) never matches one — so checking a live
|
|
885
|
-
* deployment against it needs a rebuild, not a lookup.
|
|
1212
|
+
* @deprecated Use `BUILD_HASHES`: the same values under names that say what they are
|
|
1213
|
+
* (bytecodeHash → creationHexSha256, deployedBytecodeHash → runtimeHexSha256,
|
|
1214
|
+
* bytecodeLength → creationHexLength, deployedBytecodeLength → runtimeHexLength).
|
|
1215
|
+
* Kept for one release candidate; removed before 0.2.0.
|
|
886
1216
|
*/
|
|
887
1217
|
declare const BYTECODE_HASHES: {
|
|
888
1218
|
readonly HTLC: {
|
|
@@ -904,10 +1234,10 @@ declare const BYTECODE_HASHES: {
|
|
|
904
1234
|
readonly deployedBytecodeLength: 2394;
|
|
905
1235
|
};
|
|
906
1236
|
readonly CancoreRouter: {
|
|
907
|
-
readonly bytecodeHash: "
|
|
908
|
-
readonly deployedBytecodeHash: "
|
|
909
|
-
readonly bytecodeLength:
|
|
910
|
-
readonly deployedBytecodeLength:
|
|
1237
|
+
readonly bytecodeHash: "43f61c94c1bb04ee4a0f3ad39356744e6b542eb9945ce4f0561665e049d451b0";
|
|
1238
|
+
readonly deployedBytecodeHash: "0c826474f8df21fdceefaf5234d3c50e0a8afcdf3124beb002aed4585227de72";
|
|
1239
|
+
readonly bytecodeLength: 40820;
|
|
1240
|
+
readonly deployedBytecodeLength: 35248;
|
|
911
1241
|
};
|
|
912
1242
|
readonly CNRXStaking: {
|
|
913
1243
|
readonly bytecodeHash: "dfda056ee22b593e2f2e1fc4e679fbb9dc34b04964f389b46914402c422b40fb";
|
|
@@ -949,4 +1279,4 @@ declare const BYTECODE_HASHES: {
|
|
|
949
1279
|
/** Decode a revert's 4-byte selector into the custom error it names, if it is one of ours. */
|
|
950
1280
|
declare function describeRevert(selectorOrData: string, tables: ReadonlyArray<Readonly<Record<string, string>>>): string | undefined;
|
|
951
1281
|
|
|
952
|
-
export { ASYNCAPI, type AuthChallenge, type AuthOk, type AuthResponse, type AuthToken, BYTECODE_HASHES, CONTRACTS_RELEASE, DECLINE_REASONS, DEPLOYMENTS, DRAND_QUICKNET, DRAW_CLOSED_BY, type DecString, type DeclineReason, type DeploymentEnv, type DrawAttempt, type DrawCandidate, type DrawClosedBy, type DrawOutcome, type DrawRecord, ERROR_CODES, ERROR_HTTP_STATUS, EXEMPT_REASONS, EXPIRED_RESULTS, type EpochLeaf, type EpochRecord, type EpochWeights, type ErrorCode, type ErrorMessage, type EvmDeployment, type ExemptReason, type ExpiredResult, type F2SBase, type F2SMessage, FEE_CLAIM_DOMAIN_NAME, FEE_CLAIM_DOMAIN_VERSION, FEE_CLAIM_TYPES, FILLER_AUTH_TYPES, FILLER_GATEWAYS, FILLER_PROTOCOL_DOMAIN, FILLER_QUOTE_TYPES, FILL_PROOF_DOMAIN, FILL_PROOF_TYPES, FILL_PROOF_TYPE_STRING, FILL_TICKET_DOMAIN, FILL_TICKET_TYPES, type FeeClaim, type FillProof, type FillReported, type FillTicket, type FillerAuth, type FillerGateway, type FillerQuote, type FillerStats, GATEWAY_MESSAGE_TYPES, type GatewayInfo, type GatewayMessage, type Hex, type JsonSchema, type JsonValue, MESSAGE_DIRECTIONS, type MessageDirection, ORDER_TYPES, type Order, type OrderJson, type OrderSettled, PENALTY_STEPS, PERMIT2_ADDRESS, PROOF_KIND_ATTESTATION, PROTOCOL_SCHEMAS, PROTOCOL_VERSION, type Page, type PenaltyApplied, type PenaltyList, type PenaltyRecord, type PenaltyStep, type Ping, type PingF2S, type PingS2F, type Pong, type PongF2S, type PongS2F, QUOTE_ACK_STATUSES, QUOTE_FINAL_STATUSES, QUOTE_TYPES, type Quote, type QuoteAck, type QuoteAckStatus, type QuoteFinalStatus, type QuoteList, type QuoteMessage, type QuoteReconfirm, type QuoteReconfirmReply, type QuoteRecord, type QuoteRequest, REST_ENDPOINTS, type RestEndpoint, type S2FBase, type S2FMessage, SCHEMA_VOCABULARY, STAKE_BINDING_TYPES, type StakeBinding, type StakeBindingRequest, TICKET_INTENT_TYPES, TICKET_LIST_STATUSES, TICKET_RECEIPT_TYPES, type TicketDecline, type TicketExpired, type TicketIntent, type TicketIntentAck, type TicketIntentMessage, type TicketIssued, type TicketIssuedCanton, type TicketIssuedEvm, type TicketJson, type TicketList, type TicketOffer, type TicketReceipt, type TicketReceiptMessage, type TimeMs, type TypedDataDomain, type TypedDataInput, type TypedDataTypes, type TypedField, type TypedValue, type UintLike, type WireAsset, deploymentOf, describeRevert, drawValue, drawWinner, encodeType, feeClaimDomain, fillProofDomain, firstRoundAtOrAfter, gatewayBodyHash, hashDomain, hashStruct, hashTypedData, jcs, messageSchemaRef, requestIdHash, routerDomain, typeHash };
|
|
1282
|
+
export { ASYNCAPI, type AttestationCanton, type AttestationEvm, type AttestationsResponse, type AuthChallenge, type AuthOk, type AuthResponse, type AuthToken, BUILD_HASHES, BYTECODE_HASHES, CONTRACTS_RELEASE, DECLINE_REASONS, DEPLOYMENTS, DRAND_QUICKNET, DRAW_CLOSED_BY, type DecString, type DeclineReason, type DeploymentEnv, type DrawAttempt, type DrawCandidate, type DrawClosedBy, type DrawOutcome, type DrawRecord, ERROR_CODES, ERROR_HTTP_STATUS, EXEMPT_REASONS, EXPIRED_RESULTS, type EpochLeaf, type EpochRecord, type EpochWeights, type ErrorCode, type ErrorF2S, type ErrorMessage, type EvmDeployment, type ExemptReason, type ExpiredResult, type F2SBase, type F2SEnvelope, type F2SMessage, FEE_CLAIM_DOMAIN_NAME, FEE_CLAIM_DOMAIN_VERSION, FEE_CLAIM_TYPES, FILLER_AUTH_TYPES, FILLER_GATEWAYS, FILLER_ID_PATTERN, FILLER_KEY_REGISTRATION_TYPES, FILLER_MESSAGE_TYPES, FILLER_PROTOCOL_DOMAIN, FILLER_QUOTE_TYPES, FILL_PROOF_DOMAIN, FILL_PROOF_TYPES, FILL_PROOF_TYPE_STRING, FILL_TICKET_DOMAIN, FILL_TICKET_TYPES, type FeeClaim, type FillProof, type FillProofJson, type FillReported, type FillTicket, type FillerAuth, type FillerEnvelopeContext, type FillerGateway, type FillerKeyRegistration, type FillerMessage, type FillerQuote, type FillerStats, GATEWAY_MESSAGE_TYPES, type GatewayInfo, type GatewayMessage, type Hex, type JsonSchema, type JsonValue, MESSAGE_DIRECTIONS, type MessageDirection, ORDER_TYPES, type Order, type OrderJson, type OrderSettled, PENALTY_STEPS, PERMIT2_ADDRESS, PROOF_KIND_ATTESTATION, PROTOCOL_SCHEMAS, PROTOCOL_VERSION, type Page, type PenaltyApplied, type PenaltyList, type PenaltyRecord, type PenaltyStep, type Ping, type PingF2S, type PingS2F, type Pong, type PongF2S, type PongS2F, QUOTE_ACK_STATUSES, QUOTE_FINAL_STATUSES, QUOTE_TYPES, type Quote, type QuoteAck, type QuoteAckStatus, type QuoteFinalStatus, type QuoteList, type QuoteMessage, type QuoteReconfirm, type QuoteReconfirmReply, type QuoteRecord, type QuoteRequest, REST_ENDPOINTS, type RestEndpoint, type S2FBase, type S2FMessage, SCHEMA_VOCABULARY, STAKE_BINDING_TYPES, type SettleAttestations, type SettleAttestationsPayload, type SignedFillerKeyRegistration, type StakeBinding, type StakeBindingRequest, TICKET_INTENT_TYPES, TICKET_LIST_STATUSES, TICKET_RECEIPT_TYPES, TICKET_REFUSED_REASONS, type TicketDecline, type TicketExpired, type TicketIntent, type TicketIntentAck, type TicketIntentMessage, type TicketIssued, type TicketIssuedCanton, type TicketIssuedEvm, type TicketJson, type TicketList, type TicketOffer, type TicketReceipt, type TicketReceiptMessage, type TicketRefusedReason, type TimeMs, type TypedDataDomain, type TypedDataInput, type TypedDataTypes, type TypedField, type TypedValue, type UintLike, type WireAsset, cantonSigEntries, deploymentOf, describeRevert, drawValue, drawWinner, encodeType, evmAddressFromRepayTo, feeClaimDomain, fillProofDomain, fillerEnvelopeError, fillerIdHash, fillerMessageBodyHash, firstRoundAtOrAfter, gatewayBodyHash, hashDomain, hashFillProof, hashFillTicket, hashFillerKeyRegistration, hashFillerMessage, hashFillerQuote, hashStruct, hashTicketIntent, hashTypedData, isCantonSource, isEoaSignature, isEvmRepayTo, jcs, messageIdRetainUntil, messageSchemaRef, repayToFromEvm, repayToFromParty, requestIdHash, routerDomain, settleAttestationsErrors, settleAttestationsPayload, settleAttestationsPayloadHash, settleSigs, typeHash };
|