@odatano/core 2.0.0-rc.42 → 2.0.0-rc.44
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/@cds-models/CardanoIndexerService/index.d.ts +78 -0
- package/@cds-models/CardanoIndexerService/index.js +11 -0
- package/@cds-models/CardanoODataService/index.d.ts +36 -0
- package/@cds-models/CardanoODataService/index.js +4 -0
- package/@cds-models/CardanoSignService/index.d.ts +1 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +1 -0
- package/@cds-models/index.d.ts +1 -0
- package/@cds-models/odatano/cardano/index.d.ts +25 -0
- package/@cds-models/odatano/cardano/index.js +3 -0
- package/README.md +195 -195
- package/db/schema.cds +27 -0
- package/db/types.cds +421 -417
- package/package.json +1 -1
- package/srv/blockchain/asset-decimals.d.ts +16 -0
- package/srv/blockchain/asset-decimals.js +86 -0
- package/srv/blockchain/backends/ogmios-backend.js +1 -0
- package/srv/blockchain/cardano-indexer.js +10 -1
- package/srv/blockchain/crawler/asset-decimals-backfill.d.ts +20 -0
- package/srv/blockchain/crawler/asset-decimals-backfill.js +59 -0
- package/srv/blockchain/crawler/credential-backfill.d.ts +38 -0
- package/srv/blockchain/crawler/credential-backfill.js +126 -0
- package/srv/blockchain/crawler/transaction-backfill.d.ts +3 -2
- package/srv/blockchain/crawler/transaction-backfill.js +8 -4
- package/srv/blockchain/ledger-state.d.ts +1 -0
- package/srv/blockchain/ledger-state.js +1 -0
- package/srv/blockchain/stored-chain.js +5 -1
- package/srv/blockchain/transaction-rows.d.ts +1 -1
- package/srv/blockchain/transaction-rows.js +2 -1
- package/srv/cardano-indexer-service.cds +48 -2
- package/srv/cardano-indexer-service.js +47 -2
- package/srv/cardano-service.cds +344 -332
- package/srv/cardano-service.js +9 -0
- package/srv/cbor/cip68.d.ts +17 -0
- package/srv/cbor/cip68.js +58 -0
- package/srv/cbor/index.d.ts +2 -0
- package/srv/cbor/index.js +9 -1
- package/srv/cbor/plutus-data-json.d.ts +24 -0
- package/srv/cbor/plutus-data-json.js +32 -0
- package/srv/utils/agent-grants.js +1 -1
- package/srv/utils/db-indexes.js +5 -0
- package/srv/utils/mappers.d.ts +6 -2
- package/srv/utils/mappers.js +16 -0
- package/srv/utils/types.d.ts +9 -0
package/README.md
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/npm/@odatano/brand@1/logos/odatano-core-logo-on-dark.svg">
|
|
4
|
-
<img src="https://cdn.jsdelivr.net/npm/@odatano/brand@1/logos/odatano-core-logo.svg" alt="ODATANO CORE" height="84">
|
|
5
|
-
</picture>
|
|
6
|
-
</p>
|
|
7
|
-
|
|
8
|
-
# Enterprise OData Services for the Cardano Blockchain
|
|
9
|
-
|
|
10
|
-
Funded by [Cardano Catalyst Fund 14](https://projectcatalyst.io/funds/14/sponsored-by-leftovers/sap-cardano-odata-v4-api-with-cap-and-sap-cardano-sdk) all four milestones completed and approved (April 2026).
|
|
11
|
-
|
|
12
|
-
**ODATANO** is an SAP CAP–based service that exposes the Cardano blockchain via a standardized **OData V4** interface, enabling enterprise-grade read and write access with native transaction building.
|
|
13
|
-
|
|
14
|
-
[](https://github.com/ODATANO/ODATANO/actions/workflows/test.yaml)
|
|
15
|
-
[](https://codecov.io/gh/ODATANO/ODATANO)
|
|
16
|
-
[](https://www.npmjs.com/package/@odatano/core)
|
|
17
|
-
[](https://www.npmjs.com/package/@odatano/core)
|
|
18
|
-
[](LICENSE)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Quick Start
|
|
22
|
-
|
|
23
|
-
### As CAP Plugin (recommended)
|
|
24
|
-
|
|
25
|
-
Add ODATANO to any existing SAP CAP project:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install @odatano/core @cap-js/sqlite
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```json
|
|
32
|
-
{
|
|
33
|
-
"cds": {
|
|
34
|
-
"requires": {
|
|
35
|
-
"db": { "kind": "sqlite" },
|
|
36
|
-
"odatano-core": {
|
|
37
|
-
"network": "preview",
|
|
38
|
-
"backends": ["blockfrost"]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Put your API key in a `.env` file in the project root (loaded automatically by `cds serve` / `cds watch`) — don't commit it to `package.json`:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# .env
|
|
49
|
-
BLOCKFROST_API_KEY=preview_your_api_key_here
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
cds deploy --to sqlite
|
|
54
|
-
cds serve
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
> Config in `cds.requires.odatano-core` takes precedence over environment
|
|
58
|
-
> variables; a `blockfrostApiKey` set there would override the `.env` value.
|
|
59
|
-
|
|
60
|
-
> **Self-hosted Blockfrost-compatible node?** (Dolos MiniBF, Demeter Self-Hosted)
|
|
61
|
-
> Set `blockfrostCustomBackend` to the node's base URL (e.g. `http://localhost:3010/api/v0`).
|
|
62
|
-
> When set, `blockfrostApiKey` becomes optional. See the [Backend Configuration Guide](docs/guides/BACKEND_CONFIGURATION.md#self-hosted-blockfrost-compatible-backends).
|
|
63
|
-
|
|
64
|
-
### Standalone
|
|
65
|
-
|
|
66
|
-
Run ODATANO as a self-contained service (no host CAP project needed):
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
git clone https://github.com/ODATANO/ODATANO && cd ODATANO
|
|
70
|
-
npm ci
|
|
71
|
-
cp .env.example .env # set BLOCKFROST_API_KEY, NETWORK, BACKENDS
|
|
72
|
-
cds deploy --to sqlite
|
|
73
|
-
cds serve
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Or with Docker — this brings up a local **cardano-node + Ogmios + ODATANO** stack
|
|
77
|
-
(Preview), with the service pre-wired to the local Ogmios backend:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
docker compose up -d # full stack
|
|
81
|
-
docker compose up -d cardano-node ogmios # just the chain backend (pre-sync)
|
|
82
|
-
docker compose logs -f ogmios # watch sync (/health: 202 syncing, 200 near tip)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
> First sync from genesis takes hours; the node DB persists in a Docker volume so
|
|
86
|
-
> restarts resume. Until Ogmios catches up, historical queries fall back to
|
|
87
|
-
> Blockfrost (set `BLOCKFROST_API_KEY`).
|
|
88
|
-
|
|
89
|
-
Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/QUICK_START.md#local-ogmios--cardano-node-docker) for the local Ogmios stack and full details.
|
|
90
|
-
|
|
91
|
-
## Dev Mode: Mocked Authentication
|
|
92
|
-
|
|
93
|
-
> **Heads-up.** `cds serve` uses CAP's mocked auth: `@requires: 'authenticated-user'` accepts any Basic-Auth header against a mock user (`alice`, `bob`, …) — passwords are not checked. Anonymous requests get 401, but anyone reaching the port can authenticate.
|
|
94
|
-
>
|
|
95
|
-
> Production needs the `[production]` profile (`NODE_ENV=production`), which switches to `auth: xsuaa`. Don't expose a dev-mode instance. See the [Security Guide](docs/guides/SECURITY_GUIDE.md#authentication-xsuaa).
|
|
96
|
-
>
|
|
97
|
-
> The Docker image runs `NODE_ENV=production` with HTTP basic auth via `@odatano/cap-auth` (`ODATANO_HTTP_PASSWORD` required, user `ODATANO_HTTP_USER` default `odatano`, roles `ODATANO_HTTP_ROLES` default `Admin`; 20 failed attempts per 15 min per client address and user, then 429). `ODATANO_AUTH=dummy` disables authentication for local testing only. `getLiveness()` and `VerifyDataSignature` stay anonymous.
|
|
98
|
-
>
|
|
99
|
-
> Database of the image: `ODATANO_DB_URL=postgres://user:pw@host:5432/db` selects PostgreSQL (schema deployed on every boot); otherwise SQLite at `ODATANO_DB_PATH` (default `/data/db.sqlite`). `docker compose run --rm --no-deps odatano migrate --from /data/db.sqlite` copies an existing SQLite file into a freshly deployed PostgreSQL.
|
|
100
|
-
|
|
101
|
-
## Services
|
|
102
|
-
|
|
103
|
-
| Service | Path | Purpose |
|
|
104
|
-
|---|---|---|
|
|
105
|
-
| CardanoODataService | `/odata/v4/cardano/` | Read blockchain data (
|
|
106
|
-
| CardanoTransactionService | `/odata/v4/cardano-transaction/` | Build & submit transactions (13 actions) |
|
|
107
|
-
| CardanoSignService | `/odata/v4/cardano-sign/` | External signing + HSM (9 actions) |
|
|
108
|
-
| CardanoIndexerService | `/odata/v4/cardano-indexer/` | Chain crawler / pre-sync control (v2.0, off by default) |
|
|
109
|
-
| CardanoWorkerService | `/odata/v4/cardano-worker/` | Asynchronous wallet jobs (v2.0, off by default) |
|
|
110
|
-
| CardanoAgentService | `/odata/v4/cardano-agent/` | Agent grants: scoped bearer tokens for agents (v2.0, off by default) |
|
|
111
|
-
|
|
112
|
-
Both v2.0 services also publish **CAP events**, so a consumer can subscribe instead of polling —
|
|
113
|
-
in-process, no broker required:
|
|
114
|
-
|
|
115
|
-
```js
|
|
116
|
-
(await cds.connect.to('CardanoWorkerService')).on('jobConfirmed', ({ data }) => …)
|
|
117
|
-
(await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Agent grants (v2.0, off by default)
|
|
121
|
-
|
|
122
|
-
Hand an agent a **scoped, budgeted token** instead of a user.
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
AGENT_GRANTS_ENABLED=true # or cds.requires.odatano-core.agentGrants.enabled
|
|
126
|
-
AGENT_GRANTS_DELEGATE=mocked # CAP auth kind that keeps authenticating non-token requests (default: configured kind)
|
|
127
|
-
AGENT_GRANT_ADMIN_RATE_LIMIT=10 # grant administration calls per principal per hour (or agentGrants.adminRateLimit)
|
|
128
|
-
AGENT_TOKEN_CACHE_MS=10000 # a resolved token is reused this long before the row is read again; 0 = off (or agentGrants.tokenCacheMs)
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
1. An **Admin** issues a grant (`POST /odata/v4/cardano-agent/CreateAgentGrant`): an allow list of
|
|
132
|
-
actions, optionally a worker `walletId` (required for `SubmitWalletJob`/`CancelJob`), allowed job
|
|
133
|
-
kinds, a daily budget and an expiry. The response carries the token `odat_…` **once**; the
|
|
134
|
-
server stores only its SHA-256.
|
|
135
|
-
2. The agent sends `x-agent-token: odat_…` on any of the six service paths. It runs as the principal
|
|
136
|
-
`agent:<grantId>` with the single role `agent-grant`, never as the operator: every
|
|
137
|
-
`@requires: 'Admin'` surface (pause/resume, HSM signing, grant administration) refuses it by
|
|
138
|
-
construction. Reads and compute-only actions are always allowed; allow-listed actions each cost
|
|
139
|
-
one budget unit per UTC day (a build is the service an agent buys); everything else is 403.
|
|
140
|
-
Wallet jobs are pinned to the grant's wallet and visible only to the grant that queued them.
|
|
141
|
-
3. `GET /odata/v4/cardano-agent/GetGrantStatus()` tells the agent what it may do and how much budget
|
|
142
|
-
is left; `RevokeAgentGrant` turns the token into an unknown token immediately.
|
|
143
|
-
4. Lifecycle (Admin; the same semantics as the gateway's peer services, so one client drives
|
|
144
|
-
them all): `UpdateAgentGrant` changes label, allow list, job kinds, daily budget or expiry
|
|
145
|
-
(absent = untouched, explicit `null` = cleared; the wallet binding is immutable, 409
|
|
146
|
-
`GRANT_REVOKED` on a revoked grant); `RotateAgentGrantToken` returns a fresh token once, the old
|
|
147
|
-
one is unknown from the next request; `GetGrantUsage(grantId, since, until)` lists admitted calls
|
|
148
|
-
per service and action over up to 366 days (an Admin for any grant, a token for its own). All
|
|
149
|
-
administration calls share the per-principal hourly rate limit above.
|
|
150
|
-
|
|
151
|
-
Grantable: `Build*`, `SetCollateral`, `CreateSigningRequest`, `VerifySignature`, `Submit*`,
|
|
152
|
-
`CheckSubmissionStatus`, `SubmitWalletJob`, `CancelJob`. Never: `SignWithHsm*`, `Pause*`/`Resume*`,
|
|
153
|
-
`pauseCrawler`/`resumeCrawler`, grant administration.
|
|
154
|
-
|
|
155
|
-
Programmatic seams for other packages (`@odatano/x402` sells grants against a 402 payment):
|
|
156
|
-
`issueAgentGrant()`, `updateAgentGrant()`, `rotateAgentGrantToken()`, `revokeAgentGrantById()`,
|
|
157
|
-
`getGrantUsage()`, `registerTransportLane()` from `@odatano/core`.
|
|
158
|
-
|
|
159
|
-
## Liveness probe
|
|
160
|
-
|
|
161
|
-
`GET /odata/v4/cardano-indexer/getLiveness()` answers `200 { status: "alive", timestamp, uptime,
|
|
162
|
-
version, network }` **without credentials** (`@requires: 'any'`) as long as the process runs — no
|
|
163
|
-
backend or DB probe, no secrets. The Docker `HEALTHCHECK`, compose and upstream probes use it
|
|
164
|
-
instead of the service document, so a wrong operator password no longer reads as "ODATANO down".
|
|
165
|
-
Readiness (crawler, worker, backends) stays authenticated: `getStatus()`, `GetWorkerStatus()`,
|
|
166
|
-
`GetNetworkInformation`.
|
|
167
|
-
|
|
168
|
-
## Requirements
|
|
169
|
-
|
|
170
|
-
- **Node.js >= 22.5** and **@sap/cds >= 10** (peer dependency). CAP 9 hosts cannot load `@odatano/core@2`.
|
|
171
|
-
- Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds six tables (`CardanoSyncState`,
|
|
172
|
-
`CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs`, `CardanoAgentGrants`,
|
|
173
|
-
`CardanoAgentGrantUsage`) plus a `dedupKey` column; without the redeploy the new services answer
|
|
174
|
-
`no such table` while the old ones keep working.
|
|
175
|
-
|
|
176
|
-
## Documentation
|
|
177
|
-
|
|
178
|
-
| Guide | Description |
|
|
179
|
-
|-------|-------------|
|
|
180
|
-
| [Quick Start](docs/QUICK_START.md) | Get running in 5 minutes |
|
|
181
|
-
| [User Guide](docs/guides/USER_GUIDE.md) | API usage, entities, and examples |
|
|
182
|
-
| [Developer Guide](docs/guides/DEVELOPER_GUIDE.md) | Architecture and development |
|
|
183
|
-
| [Transaction Workflow](docs/guides/TRANSACTION_WORKFLOW.md) | Build → Sign → Submit flow |
|
|
184
|
-
| [Security Guide](docs/guides/SECURITY_GUIDE.md) | Authentication, signing security, HSM |
|
|
185
|
-
| [Docker Deployment](docs/guides/DOCKER_DEPLOYMENT.md) | Container deployment |
|
|
186
|
-
|
|
187
|
-
## License
|
|
188
|
-
|
|
189
|
-
Apache License 2.0 - see [LICENSE](LICENSE)
|
|
190
|
-
|
|
191
|
-
## Support
|
|
192
|
-
|
|
193
|
-
- **Issues**: [GitHub Issues](https://github.com/ODATANO/ODATANO/issues)
|
|
194
|
-
- **Project Lead**: Max Weber
|
|
195
|
-
- **Contact**: info@odatano.dev
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/npm/@odatano/brand@1/logos/odatano-core-logo-on-dark.svg">
|
|
4
|
+
<img src="https://cdn.jsdelivr.net/npm/@odatano/brand@1/logos/odatano-core-logo.svg" alt="ODATANO CORE" height="84">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# Enterprise OData Services for the Cardano Blockchain
|
|
9
|
+
|
|
10
|
+
Funded by [Cardano Catalyst Fund 14](https://projectcatalyst.io/funds/14/sponsored-by-leftovers/sap-cardano-odata-v4-api-with-cap-and-sap-cardano-sdk) all four milestones completed and approved (April 2026).
|
|
11
|
+
|
|
12
|
+
**ODATANO** is an SAP CAP–based service that exposes the Cardano blockchain via a standardized **OData V4** interface, enabling enterprise-grade read and write access with native transaction building.
|
|
13
|
+
|
|
14
|
+
[](https://github.com/ODATANO/ODATANO/actions/workflows/test.yaml)
|
|
15
|
+
[](https://codecov.io/gh/ODATANO/ODATANO)
|
|
16
|
+
[](https://www.npmjs.com/package/@odatano/core)
|
|
17
|
+
[](https://www.npmjs.com/package/@odatano/core)
|
|
18
|
+
[](LICENSE)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### As CAP Plugin (recommended)
|
|
24
|
+
|
|
25
|
+
Add ODATANO to any existing SAP CAP project:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @odatano/core @cap-js/sqlite
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"cds": {
|
|
34
|
+
"requires": {
|
|
35
|
+
"db": { "kind": "sqlite" },
|
|
36
|
+
"odatano-core": {
|
|
37
|
+
"network": "preview",
|
|
38
|
+
"backends": ["blockfrost"]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Put your API key in a `.env` file in the project root (loaded automatically by `cds serve` / `cds watch`) — don't commit it to `package.json`:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# .env
|
|
49
|
+
BLOCKFROST_API_KEY=preview_your_api_key_here
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cds deploy --to sqlite
|
|
54
|
+
cds serve
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> Config in `cds.requires.odatano-core` takes precedence over environment
|
|
58
|
+
> variables; a `blockfrostApiKey` set there would override the `.env` value.
|
|
59
|
+
|
|
60
|
+
> **Self-hosted Blockfrost-compatible node?** (Dolos MiniBF, Demeter Self-Hosted)
|
|
61
|
+
> Set `blockfrostCustomBackend` to the node's base URL (e.g. `http://localhost:3010/api/v0`).
|
|
62
|
+
> When set, `blockfrostApiKey` becomes optional. See the [Backend Configuration Guide](docs/guides/BACKEND_CONFIGURATION.md#self-hosted-blockfrost-compatible-backends).
|
|
63
|
+
|
|
64
|
+
### Standalone
|
|
65
|
+
|
|
66
|
+
Run ODATANO as a self-contained service (no host CAP project needed):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/ODATANO/ODATANO && cd ODATANO
|
|
70
|
+
npm ci
|
|
71
|
+
cp .env.example .env # set BLOCKFROST_API_KEY, NETWORK, BACKENDS
|
|
72
|
+
cds deploy --to sqlite
|
|
73
|
+
cds serve
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or with Docker — this brings up a local **cardano-node + Ogmios + ODATANO** stack
|
|
77
|
+
(Preview), with the service pre-wired to the local Ogmios backend:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
docker compose up -d # full stack
|
|
81
|
+
docker compose up -d cardano-node ogmios # just the chain backend (pre-sync)
|
|
82
|
+
docker compose logs -f ogmios # watch sync (/health: 202 syncing, 200 near tip)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
> First sync from genesis takes hours; the node DB persists in a Docker volume so
|
|
86
|
+
> restarts resume. Until Ogmios catches up, historical queries fall back to
|
|
87
|
+
> Blockfrost (set `BLOCKFROST_API_KEY`).
|
|
88
|
+
|
|
89
|
+
Service available at `http://localhost:4004`. See the [Quick Start Guide](docs/QUICK_START.md#local-ogmios--cardano-node-docker) for the local Ogmios stack and full details.
|
|
90
|
+
|
|
91
|
+
## Dev Mode: Mocked Authentication
|
|
92
|
+
|
|
93
|
+
> **Heads-up.** `cds serve` uses CAP's mocked auth: `@requires: 'authenticated-user'` accepts any Basic-Auth header against a mock user (`alice`, `bob`, …) — passwords are not checked. Anonymous requests get 401, but anyone reaching the port can authenticate.
|
|
94
|
+
>
|
|
95
|
+
> Production needs the `[production]` profile (`NODE_ENV=production`), which switches to `auth: xsuaa`. Don't expose a dev-mode instance. See the [Security Guide](docs/guides/SECURITY_GUIDE.md#authentication-xsuaa).
|
|
96
|
+
>
|
|
97
|
+
> The Docker image runs `NODE_ENV=production` with HTTP basic auth via `@odatano/cap-auth` (`ODATANO_HTTP_PASSWORD` required, user `ODATANO_HTTP_USER` default `odatano`, roles `ODATANO_HTTP_ROLES` default `Admin`; 20 failed attempts per 15 min per client address and user, then 429). `ODATANO_AUTH=dummy` disables authentication for local testing only. `getLiveness()` and `VerifyDataSignature` stay anonymous.
|
|
98
|
+
>
|
|
99
|
+
> Database of the image: `ODATANO_DB_URL=postgres://user:pw@host:5432/db` selects PostgreSQL (schema deployed on every boot); otherwise SQLite at `ODATANO_DB_PATH` (default `/data/db.sqlite`). `docker compose run --rm --no-deps odatano migrate --from /data/db.sqlite` copies an existing SQLite file into a freshly deployed PostgreSQL.
|
|
100
|
+
|
|
101
|
+
## Services
|
|
102
|
+
|
|
103
|
+
| Service | Path | Purpose |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| CardanoODataService | `/odata/v4/cardano/` | Read blockchain data (32 entities, 21 actions) |
|
|
106
|
+
| CardanoTransactionService | `/odata/v4/cardano-transaction/` | Build & submit transactions (13 actions) |
|
|
107
|
+
| CardanoSignService | `/odata/v4/cardano-sign/` | External signing + HSM (9 actions) |
|
|
108
|
+
| CardanoIndexerService | `/odata/v4/cardano-indexer/` | Chain crawler / pre-sync control (v2.0, off by default) |
|
|
109
|
+
| CardanoWorkerService | `/odata/v4/cardano-worker/` | Asynchronous wallet jobs (v2.0, off by default) |
|
|
110
|
+
| CardanoAgentService | `/odata/v4/cardano-agent/` | Agent grants: scoped bearer tokens for agents (v2.0, off by default) |
|
|
111
|
+
|
|
112
|
+
Both v2.0 services also publish **CAP events**, so a consumer can subscribe instead of polling —
|
|
113
|
+
in-process, no broker required:
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
(await cds.connect.to('CardanoWorkerService')).on('jobConfirmed', ({ data }) => …)
|
|
117
|
+
(await cds.connect.to('CardanoIndexerService')).on('blockIndexed', ({ data }) => …)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Agent grants (v2.0, off by default)
|
|
121
|
+
|
|
122
|
+
Hand an agent a **scoped, budgeted token** instead of a user.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
AGENT_GRANTS_ENABLED=true # or cds.requires.odatano-core.agentGrants.enabled
|
|
126
|
+
AGENT_GRANTS_DELEGATE=mocked # CAP auth kind that keeps authenticating non-token requests (default: configured kind)
|
|
127
|
+
AGENT_GRANT_ADMIN_RATE_LIMIT=10 # grant administration calls per principal per hour (or agentGrants.adminRateLimit)
|
|
128
|
+
AGENT_TOKEN_CACHE_MS=10000 # a resolved token is reused this long before the row is read again; 0 = off (or agentGrants.tokenCacheMs)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
1. An **Admin** issues a grant (`POST /odata/v4/cardano-agent/CreateAgentGrant`): an allow list of
|
|
132
|
+
actions, optionally a worker `walletId` (required for `SubmitWalletJob`/`CancelJob`), allowed job
|
|
133
|
+
kinds, a daily budget and an expiry. The response carries the token `odat_…` **once**; the
|
|
134
|
+
server stores only its SHA-256.
|
|
135
|
+
2. The agent sends `x-agent-token: odat_…` on any of the six service paths. It runs as the principal
|
|
136
|
+
`agent:<grantId>` with the single role `agent-grant`, never as the operator: every
|
|
137
|
+
`@requires: 'Admin'` surface (pause/resume, HSM signing, grant administration) refuses it by
|
|
138
|
+
construction. Reads and compute-only actions are always allowed; allow-listed actions each cost
|
|
139
|
+
one budget unit per UTC day (a build is the service an agent buys); everything else is 403.
|
|
140
|
+
Wallet jobs are pinned to the grant's wallet and visible only to the grant that queued them.
|
|
141
|
+
3. `GET /odata/v4/cardano-agent/GetGrantStatus()` tells the agent what it may do and how much budget
|
|
142
|
+
is left; `RevokeAgentGrant` turns the token into an unknown token immediately.
|
|
143
|
+
4. Lifecycle (Admin; the same semantics as the gateway's peer services, so one client drives
|
|
144
|
+
them all): `UpdateAgentGrant` changes label, allow list, job kinds, daily budget or expiry
|
|
145
|
+
(absent = untouched, explicit `null` = cleared; the wallet binding is immutable, 409
|
|
146
|
+
`GRANT_REVOKED` on a revoked grant); `RotateAgentGrantToken` returns a fresh token once, the old
|
|
147
|
+
one is unknown from the next request; `GetGrantUsage(grantId, since, until)` lists admitted calls
|
|
148
|
+
per service and action over up to 366 days (an Admin for any grant, a token for its own). All
|
|
149
|
+
administration calls share the per-principal hourly rate limit above.
|
|
150
|
+
|
|
151
|
+
Grantable: `Build*`, `SetCollateral`, `CreateSigningRequest`, `VerifySignature`, `Submit*`,
|
|
152
|
+
`CheckSubmissionStatus`, `SubmitWalletJob`, `CancelJob`. Never: `SignWithHsm*`, `Pause*`/`Resume*`,
|
|
153
|
+
`pauseCrawler`/`resumeCrawler`, grant administration.
|
|
154
|
+
|
|
155
|
+
Programmatic seams for other packages (`@odatano/x402` sells grants against a 402 payment):
|
|
156
|
+
`issueAgentGrant()`, `updateAgentGrant()`, `rotateAgentGrantToken()`, `revokeAgentGrantById()`,
|
|
157
|
+
`getGrantUsage()`, `registerTransportLane()` from `@odatano/core`.
|
|
158
|
+
|
|
159
|
+
## Liveness probe
|
|
160
|
+
|
|
161
|
+
`GET /odata/v4/cardano-indexer/getLiveness()` answers `200 { status: "alive", timestamp, uptime,
|
|
162
|
+
version, network }` **without credentials** (`@requires: 'any'`) as long as the process runs — no
|
|
163
|
+
backend or DB probe, no secrets. The Docker `HEALTHCHECK`, compose and upstream probes use it
|
|
164
|
+
instead of the service document, so a wrong operator password no longer reads as "ODATANO down".
|
|
165
|
+
Readiness (crawler, worker, backends) stays authenticated: `getStatus()`, `GetWorkerStatus()`,
|
|
166
|
+
`GetNetworkInformation`.
|
|
167
|
+
|
|
168
|
+
## Requirements
|
|
169
|
+
|
|
170
|
+
- **Node.js >= 22.5** and **@sap/cds >= 10** (peer dependency). CAP 9 hosts cannot load `@odatano/core@2`.
|
|
171
|
+
- Upgrading a consumer from 1.x: run **`cds deploy`**. 2.0 adds six tables (`CardanoSyncState`,
|
|
172
|
+
`CardanoReorgLog`, `CardanoWorkerWallets`, `CardanoWalletJobs`, `CardanoAgentGrants`,
|
|
173
|
+
`CardanoAgentGrantUsage`) plus a `dedupKey` column; without the redeploy the new services answer
|
|
174
|
+
`no such table` while the old ones keep working.
|
|
175
|
+
|
|
176
|
+
## Documentation
|
|
177
|
+
|
|
178
|
+
| Guide | Description |
|
|
179
|
+
|-------|-------------|
|
|
180
|
+
| [Quick Start](docs/QUICK_START.md) | Get running in 5 minutes |
|
|
181
|
+
| [User Guide](docs/guides/USER_GUIDE.md) | API usage, entities, and examples |
|
|
182
|
+
| [Developer Guide](docs/guides/DEVELOPER_GUIDE.md) | Architecture and development |
|
|
183
|
+
| [Transaction Workflow](docs/guides/TRANSACTION_WORKFLOW.md) | Build → Sign → Submit flow |
|
|
184
|
+
| [Security Guide](docs/guides/SECURITY_GUIDE.md) | Authentication, signing security, HSM |
|
|
185
|
+
| [Docker Deployment](docs/guides/DOCKER_DEPLOYMENT.md) | Container deployment |
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
Apache License 2.0 - see [LICENSE](LICENSE)
|
|
190
|
+
|
|
191
|
+
## Support
|
|
192
|
+
|
|
193
|
+
- **Issues**: [GitHub Issues](https://github.com/ODATANO/ODATANO/issues)
|
|
194
|
+
- **Project Lead**: Max Weber
|
|
195
|
+
- **Contact**: info@odatano.dev
|
package/db/schema.cds
CHANGED
|
@@ -453,6 +453,10 @@ entity Assets : temporal {
|
|
|
453
453
|
@description: 'CIP-26 off-chain registry: decimal precision'
|
|
454
454
|
registryDecimals : Integer;
|
|
455
455
|
|
|
456
|
+
@title : 'Decimals'
|
|
457
|
+
@description: 'Decimal places of the token: the decimals field of the CIP-68 reference datum for a unit with label 333 or 444, else the CIP-26 registry value; null when neither is known'
|
|
458
|
+
decimals : Integer;
|
|
459
|
+
|
|
456
460
|
@title : 'Registry Description'
|
|
457
461
|
@description: 'CIP-26 off-chain registry: human-readable description'
|
|
458
462
|
registryDescription : LargeString;
|
|
@@ -786,6 +790,11 @@ entity Transactions {
|
|
|
786
790
|
withdrawals : Composition of many TransactionWithdrawals
|
|
787
791
|
on withdrawals.tx = $self;
|
|
788
792
|
|
|
793
|
+
@title : 'Transaction Datums'
|
|
794
|
+
@description: 'Witness-set datums of the transaction (the datums spent outputs with a datum hash refer to). Filled by the chain crawler on Ogmios chain-sync only; the lazy path leaves it empty.'
|
|
795
|
+
datums : Composition of many TransactionDatums
|
|
796
|
+
on datums.tx = $self;
|
|
797
|
+
|
|
789
798
|
@title : 'Transaction Has Metadata'
|
|
790
799
|
@description: 'Indicates if transaction has metadata'
|
|
791
800
|
hasMetadata : Boolean;
|
|
@@ -1153,6 +1162,24 @@ entity TransactionRedeemers {
|
|
|
1153
1162
|
policyId : Blake2b224;
|
|
1154
1163
|
}
|
|
1155
1164
|
|
|
1165
|
+
@title : 'Transaction Datums'
|
|
1166
|
+
@description: 'Datums of the transaction witness set as the chain crawler saw them (Ogmios chain-sync), byte for byte. They resolve outputs that carry a datum hash without an inline datum. Not written by the lazy path.'
|
|
1167
|
+
@readonly
|
|
1168
|
+
entity TransactionDatums {
|
|
1169
|
+
|
|
1170
|
+
@title : 'Transaction (key)'
|
|
1171
|
+
@description: 'The transaction whose witness set carries the datum'
|
|
1172
|
+
key tx : Association to Transactions;
|
|
1173
|
+
|
|
1174
|
+
@title : 'Datum Hash (key)'
|
|
1175
|
+
@description: 'Blake2b-256 hash of the datum bytes, as outputs reference it in utxo.dataHash'
|
|
1176
|
+
key dataHash : Blake2b256;
|
|
1177
|
+
|
|
1178
|
+
@title : 'Datum'
|
|
1179
|
+
@description: 'PlutusData CBOR hex, the original bytes of the witness set'
|
|
1180
|
+
datum : LargeString;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1156
1183
|
@title : 'Transaction Outputs'
|
|
1157
1184
|
@description: 'Projection for Transaction Outputs'
|
|
1158
1185
|
@readonly
|