@cancore/contracts 0.2.0-rc.13 → 0.2.0-rc.15
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 +19 -9
- package/dist/index.d.ts +72 -3
- package/dist/index.js +83 -7
- package/dist/index.js.map +1 -1
- package/dist/networks.d.ts +2 -1
- package/package.json +1 -1
- package/spec/constants.json +1 -1
- package/spec/protocol/asyncapi.json +1 -1
- package/spec/protocol/messages.schema.json +1 -1
- package/spec/protocol/rest.schema.json +72 -2
- package/spec/protocol/vectors/messages.json +1 -1
package/dist/networks.d.ts
CHANGED
|
@@ -36,4 +36,5 @@ declare function networkKindOf(id: string): NetworkKind | undefined;
|
|
|
36
36
|
/** The network for an EIP-155 chain id, e.g. from a wallet's `eth_chainId`. */
|
|
37
37
|
declare function networkByChainId(chainId: number): Network | undefined;
|
|
38
38
|
|
|
39
|
-
export { NETWORKS, NETWORK_ALIASES,
|
|
39
|
+
export { NETWORKS, NETWORK_ALIASES, networkByChainId, networkKindOf, networkOf };
|
|
40
|
+
export type { Network, NetworkKind };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cancore/contracts",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Cancore EVM contracts as data: the ABIs of the Cancore EVM contracts and their custom-error selectors, the EIP-712 FeeClaim voucher and FillProof, the network registry; and the filler protocol v1: EIP-712 types and domains, hashing helpers, JSON Schemas, AsyncAPI, golden vectors.",
|
|
6
6
|
"exports": {
|
package/spec/constants.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "Public constants of CancoreRouter and AttestorSet, read by scripts/sync.mjs from their Solidity source at `commit` (the same checkout as the ABIs). Values are decimal strings for integers, the text for strings, the hash for keccak256 of a string literal. src/constants.test.ts holds the package's constants to this file (SDK-6). Not edited by hand.",
|
|
3
|
-
"commit": "
|
|
3
|
+
"commit": "2f681b9bb74db55c0fe9fec31282bca54b997985",
|
|
4
4
|
"contracts": {
|
|
5
5
|
"CancoreRouter": {
|
|
6
6
|
"ORDER_TYPEHASH": {
|
|
@@ -1208,7 +1208,7 @@
|
|
|
1208
1208
|
"sentAt": 1790001000000,
|
|
1209
1209
|
"violationId": "v-1",
|
|
1210
1210
|
"code": "NO_SHOW",
|
|
1211
|
-
"step": "
|
|
1211
|
+
"step": "RECORDED",
|
|
1212
1212
|
"details": {
|
|
1213
1213
|
"orderHash": "0x65f9010d612499d381eefba1a2385b76982c9bdaf9ed15bedbafd7b09fb3b73b",
|
|
1214
1214
|
"attempt": 0
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"expiredResult": { "anyOf": [{ "enum": ["FILLED", "NO_SHOW", "NO_SHOW_UNCONFIRMED", "EXEMPT"] }, { "$ref": "#/$defs/futureEnumValue" }] },
|
|
87
87
|
"exemptReason": { "anyOf": [{ "enum": ["DESTINATION_HALTED", "GATEWAY_FAULT", "REORGED_AFTER_INCLUSION", "RECIPIENT_NOT_READY", "OTHER"] }, { "$ref": "#/$defs/futureEnumValue" }] },
|
|
88
88
|
"quoteAckStatus": { "anyOf": [{ "enum": ["COUNTED", "LATE", "SHORT_TTL"] }, { "$ref": "#/$defs/futureEnumValue" }], "description": "verdict at receipt time; the final status is on GET /v1/filler/quotes" },
|
|
89
|
-
"penaltyStep": { "anyOf": [{ "enum": ["
|
|
89
|
+
"penaltyStep": { "anyOf": [{ "enum": ["RECORDED", "BANNED", "UNBANNED"] }, { "$ref": "#/$defs/futureEnumValue" }] },
|
|
90
90
|
"s2fEnvelope": {
|
|
91
91
|
"type": "object",
|
|
92
92
|
"required": ["type", "id", "sentAt", "sig"],
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://cancore.io/schemas/filler-protocol/v1/rest.schema.json",
|
|
4
4
|
"title": "Cancore filler protocol v1 — REST fallback",
|
|
5
|
-
"$comment": "protocol §3.6. Bodies are the WebSocket frames: every request body is a filler message with its envelope (id, fillerId, sentAt) and msgSig, verified before processing as on the WebSocket (S-19); every response is a freshly signed S→F message. Login: GET /v1/filler/auth/challenge?fillerId= returns a signed auth.challenge addressed to that fillerId; POST /v1/filler/auth with the auth.response (FillerAuth over it) returns {token, expiresAt}. The challenge route is anonymous and its refusals are UNSIGNED (unsignedErrorBody, no sig, nothing journalled): 400 BAD_REQUEST — fillerId missing or not a fillerId; 404 UNKNOWN_REQUEST — fillerId unknown or not ACTIVE; the anonymous login steps are charged to no fillerId's rate limits (knowing a fillerId cannot lock its filler out); a 429 here comes only from the per-IP limit in front of filler-gateway. POST /v1/filler/auth refuses UNSIGNED too as long as it has checked no signature: 400 BAD_REQUEST — no or a malformed fillerId; 404 UNKNOWN_REQUEST — fillerId unknown or not ACTIVE; 401 UNAUTHENTICATED — the fillerId holds no live challenge (evicted, expired or used: ask for a new one). Its refusals after the signature checks (BAD_SIGNATURE, STALE_MESSAGE, REPLAYED_MESSAGE, UNSUPPORTED_VERSION, NOT_ELIGIBLE, UNAUTHENTICATED) are the signed error. The other /v1/filler/* routes need `Authorization: Bearer <token>`; the token is bound to (fillerId, message key) and stops working when it expires, when the message key is changed, or when the filler is no longer ACTIVE. The same token opens the WebSocket (asyncapi.json: offered as the subprotocol bearer.<token>). A ticket of another filler is 404 UNKNOWN_TICKET. Rate limits are per fillerId and rate class (quote, ticket, service, read for every bearer GET, login, cantonPrepare for canton.prepare of §3.19 — an hourly budget per filler, 60 by default — and canton for canton.submit, so a spent prepare budget never holds back the submit of an operation already prepared), shared by REST and every WebSocket session of it: over the limit a bearer route answers 429 with an UNSIGNED unsignedErrorBody {type: error, code: RATE_LIMITED, message, retryAfterMs} and a Retry-After header (seconds, rounded up), journals nothing one by one, and the request changes nothing; during the cooldown after sustained excess every bearer route answers so. Every 429 is unsigned, on every route; a filler decides by the status and takes retryAfterMs (else Retry-After) as a hint. Every other non-2xx of a bearer route is the signed error. GET /v1/filler/attestations/{orderHash} answers 404 ATTESTATIONS_NOT_READY until the gateway holds ≥ threshold verified signatures for this filler's fill, and 404 UNKNOWN_TICKET when this filler holds no ticket on the order. /v1/filler/canton/* (§3.19) serve only the caller's own party: POST prepare and submit take the canton.prepare and canton.submit messages and answer canton.prepared and canton.submitted (the same frames as on the WebSocket); GET party, holdings
|
|
5
|
+
"$comment": "protocol §3.6. Bodies are the WebSocket frames: every request body is a filler message with its envelope (id, fillerId, sentAt) and msgSig, verified before processing as on the WebSocket (S-19); every response is a freshly signed S→F message. Login: GET /v1/filler/auth/challenge?fillerId= returns a signed auth.challenge addressed to that fillerId; POST /v1/filler/auth with the auth.response (FillerAuth over it) returns {token, expiresAt}. The challenge route is anonymous and its refusals are UNSIGNED (unsignedErrorBody, no sig, nothing journalled): 400 BAD_REQUEST — fillerId missing or not a fillerId; 404 UNKNOWN_REQUEST — fillerId unknown or not ACTIVE; the anonymous login steps are charged to no fillerId's rate limits (knowing a fillerId cannot lock its filler out); a 429 here comes only from the per-IP limit in front of filler-gateway. POST /v1/filler/auth refuses UNSIGNED too as long as it has checked no signature: 400 BAD_REQUEST — no or a malformed fillerId; 404 UNKNOWN_REQUEST — fillerId unknown or not ACTIVE; 401 UNAUTHENTICATED — the fillerId holds no live challenge (evicted, expired or used: ask for a new one). Its refusals after the signature checks (BAD_SIGNATURE, STALE_MESSAGE, REPLAYED_MESSAGE, UNSUPPORTED_VERSION, NOT_ELIGIBLE, UNAUTHENTICATED) are the signed error. The other /v1/filler/* routes need `Authorization: Bearer <token>`; the token is bound to (fillerId, message key) and stops working when it expires, when the message key is changed, or when the filler is no longer ACTIVE. The same token opens the WebSocket (asyncapi.json: offered as the subprotocol bearer.<token>). A ticket of another filler is 404 UNKNOWN_TICKET. Rate limits are per fillerId and rate class (quote, ticket, service, read for every bearer GET, login, cantonPrepare for canton.prepare of §3.19 — an hourly budget per filler, 60 by default — and canton for canton.submit, so a spent prepare budget never holds back the submit of an operation already prepared), shared by REST and every WebSocket session of it: over the limit a bearer route answers 429 with an UNSIGNED unsignedErrorBody {type: error, code: RATE_LIMITED, message, retryAfterMs} and a Retry-After header (seconds, rounded up), journals nothing one by one, and the request changes nothing; during the cooldown after sustained excess every bearer route answers so. Every 429 is unsigned, on every route; a filler decides by the status and takes retryAfterMs (else Retry-After) as a hint. Every other non-2xx of a bearer route is the signed error. GET /v1/filler/attestations/{orderHash} answers 404 ATTESTATIONS_NOT_READY until the gateway holds ≥ threshold verified signatures for this filler's fill, and 404 UNKNOWN_TICKET when this filler holds no ticket on the order. /v1/filler/canton/* (§3.19) serve only the caller's own party: POST prepare and submit take the canton.prepare and canton.submit messages and answer canton.prepared and canton.submitted (the same frames as on the WebSocket); GET party, holdings, delivery-orders and intents/{orderHash} read the party registered for the fillerId, and answer 409 CANTON_NOT_READY while it has none; intents/{orderHash} answers 404 UNKNOWN_TICKET when no live SwapIntent with that orderHash names the party. /v1/draws/* and /v1/gateway are public. Every non-2xx body is the signed `error` frame, with the HTTP status of x-error-status — except a 429 (always unsignedErrorBody) and the unsigned refusals of an endpoint that names an errorBody. x-endpoints: request/query/response/errorBody name a $def here or in messages.schema.json.",
|
|
6
6
|
"x-endpoints": [
|
|
7
7
|
{ "method": "GET", "path": "/v1/filler/auth/challenge", "auth": "none", "query": "#/$defs/challengeQuery", "response": "messages.schema.json#/$defs/auth.challenge", "errorBody": "#/$defs/unsignedErrorBody" },
|
|
8
8
|
{ "method": "POST", "path": "/v1/filler/auth", "auth": "none", "request": "messages.schema.json#/$defs/auth.response", "response": "#/$defs/authToken", "errorBody": "#/$defs/unsignedErrorBody" },
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
{ "method": "POST", "path": "/v1/filler/canton/submit", "auth": "bearer", "request": "messages.schema.json#/$defs/canton.submit", "response": "messages.schema.json#/$defs/canton.submitted" },
|
|
23
23
|
{ "method": "GET", "path": "/v1/filler/canton/party", "auth": "bearer", "response": "#/$defs/cantonParty" },
|
|
24
24
|
{ "method": "GET", "path": "/v1/filler/canton/holdings", "auth": "bearer", "query": "#/$defs/pageQuery", "response": "#/$defs/cantonHoldingList" },
|
|
25
|
-
{ "method": "GET", "path": "/v1/filler/canton/delivery-orders", "auth": "bearer", "query": "#/$defs/pageQuery", "response": "#/$defs/cantonDeliveryOrderList" }
|
|
25
|
+
{ "method": "GET", "path": "/v1/filler/canton/delivery-orders", "auth": "bearer", "query": "#/$defs/pageQuery", "response": "#/$defs/cantonDeliveryOrderList" },
|
|
26
|
+
{ "method": "GET", "path": "/v1/filler/canton/intents/{orderHash}", "auth": "bearer", "response": "#/$defs/cantonIntent" }
|
|
26
27
|
],
|
|
27
28
|
"x-error-status": {
|
|
28
29
|
"BAD_REQUEST": 400, "UNAUTHENTICATED": 401, "UNSUPPORTED_VERSION": 400, "UNSUPPORTED_TYPE": 400, "BAD_SIGNATURE": 422,
|
|
@@ -188,6 +189,75 @@
|
|
|
188
189
|
"description": "The live DeliveryOrders naming the party as filler, oldest first",
|
|
189
190
|
"required": ["items", "nextCursor"],
|
|
190
191
|
"properties": { "items": { "type": "array", "items": { "$ref": "#/$defs/cantonDeliveryOrder" } }, "nextCursor": { "type": ["string", "null"] } }
|
|
192
|
+
},
|
|
193
|
+
"cantonIntent": {
|
|
194
|
+
"type": "object",
|
|
195
|
+
"description": "A live SwapIntent of a Canton source that names the caller's party as its filler, as that party sees it (an observer), with its committed allocation as the operator reads it (an executor). What the node checks before ticket.receipt (fillers.md V-C1…V-C6); the node recomputes orderHash from these fields itself. 404 UNKNOWN_TICKET when no live SwapIntent with this orderHash names the party; 409 CANTON_NOT_READY when the fillerId has no party",
|
|
196
|
+
"required": ["intentCid", "templateId", "orderHash", "owner", "operator", "filler", "fillerId", "requestId", "asset", "amount", "destination", "minReceived", "feeRate", "fillDeadline", "refundAfter", "orderCreatedAt", "allocationCid", "allocation"],
|
|
197
|
+
"properties": {
|
|
198
|
+
"intentCid": { "type": "string", "minLength": 1 },
|
|
199
|
+
"templateId": { "type": "string", "pattern": "^[0-9a-f]{64}:[A-Za-z0-9_.]+:[A-Za-z0-9_]+$", "description": "<package id>:Intent.SwapIntent:SwapIntent" },
|
|
200
|
+
"orderHash": { "$ref": "messages.schema.json#/$defs/bytes32" },
|
|
201
|
+
"owner": { "type": "string", "minLength": 1 },
|
|
202
|
+
"operator": { "type": "string", "minLength": 1 },
|
|
203
|
+
"filler": { "type": "string", "minLength": 1 },
|
|
204
|
+
"fillerId": { "type": "string", "minLength": 1 },
|
|
205
|
+
"requestId": { "type": "string", "minLength": 1 },
|
|
206
|
+
"asset": { "$ref": "messages.schema.json#/$defs/cantonAsset", "description": "SwapIntent.instrumentId" },
|
|
207
|
+
"amount": { "type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", "description": "Daml Decimal: the committed give, fee-inclusive" },
|
|
208
|
+
"destination": {
|
|
209
|
+
"type": "object",
|
|
210
|
+
"description": "an EVM destination (Destination.Evm); an intent to any other destination is not served",
|
|
211
|
+
"required": ["chainId", "token", "recipient"],
|
|
212
|
+
"properties": {
|
|
213
|
+
"chainId": { "$ref": "messages.schema.json#/$defs/uintDec64" },
|
|
214
|
+
"token": { "$ref": "messages.schema.json#/$defs/address" },
|
|
215
|
+
"recipient": { "$ref": "messages.schema.json#/$defs/address" }
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"minReceived": {
|
|
219
|
+
"type": "object",
|
|
220
|
+
"required": ["units", "decimals"],
|
|
221
|
+
"properties": { "units": { "$ref": "messages.schema.json#/$defs/uintDec256" }, "decimals": { "type": "integer", "minimum": 0, "maximum": 255 } }
|
|
222
|
+
},
|
|
223
|
+
"feeRate": { "type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", "description": "Daml Decimal" },
|
|
224
|
+
"fillDeadline": { "$ref": "messages.schema.json#/$defs/timeS" },
|
|
225
|
+
"refundAfter": { "$ref": "messages.schema.json#/$defs/timeS" },
|
|
226
|
+
"orderCreatedAt": { "$ref": "messages.schema.json#/$defs/timeS", "description": "the owner's signing time: the order's createdAt" },
|
|
227
|
+
"allocationCid": { "type": "string", "minLength": 1, "description": "SwapIntent.allocationCid" },
|
|
228
|
+
"allocation": {
|
|
229
|
+
"anyOf": [{ "$ref": "#/$defs/cantonAllocation" }, { "type": "null" }],
|
|
230
|
+
"description": "the contract allocationCid names, by its AllocationV2 view; null when it is not live"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"cantonAllocation": {
|
|
235
|
+
"type": "object",
|
|
236
|
+
"required": ["contractId", "templateId", "admin", "authorizer", "committed", "settlementId", "executors", "settlementDeadline", "legs"],
|
|
237
|
+
"properties": {
|
|
238
|
+
"contractId": { "type": "string", "minLength": 1 },
|
|
239
|
+
"templateId": { "type": "string", "pattern": "^[0-9a-f]{64}:[A-Za-z0-9_.]+:[A-Za-z0-9_]+$" },
|
|
240
|
+
"admin": { "type": "string", "minLength": 1 },
|
|
241
|
+
"authorizer": { "type": ["string", "null"], "minLength": 1, "description": "the owner of the authorizer account; null for an account without one" },
|
|
242
|
+
"committed": { "type": "boolean" },
|
|
243
|
+
"settlementId": { "type": "string" },
|
|
244
|
+
"executors": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
245
|
+
"settlementDeadline": { "anyOf": [{ "$ref": "messages.schema.json#/$defs/timeS" }, { "type": "null" }] },
|
|
246
|
+
"legs": {
|
|
247
|
+
"type": "array",
|
|
248
|
+
"items": {
|
|
249
|
+
"type": "object",
|
|
250
|
+
"required": ["legId", "side", "otherside", "amount", "instrumentId"],
|
|
251
|
+
"properties": {
|
|
252
|
+
"legId": { "type": "string" },
|
|
253
|
+
"side": { "anyOf": [{ "enum": ["SENDER", "RECEIVER"] }, { "$ref": "messages.schema.json#/$defs/futureEnumValue" }], "description": "a side the node does not know is refused by it" },
|
|
254
|
+
"otherside": { "type": ["string", "null"], "minLength": 1, "description": "the owner of the other side's account" },
|
|
255
|
+
"amount": { "type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]{1,10})?$", "description": "Daml Decimal" },
|
|
256
|
+
"instrumentId": { "type": "string", "minLength": 1 }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
191
261
|
}
|
|
192
262
|
}
|
|
193
263
|
}
|