@odatano/core 2.0.0-rc.4 → 2.0.0-rc.41
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/CardanoAgentService/index.d.ts +251 -0
- package/@cds-models/CardanoAgentService/index.js +36 -0
- package/@cds-models/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +194 -2
- package/@cds-models/CardanoIndexerService/index.js +25 -0
- package/@cds-models/CardanoODataService/index.d.ts +305 -7
- package/@cds-models/CardanoODataService/index.js +34 -0
- package/@cds-models/CardanoSignService/index.d.ts +28 -3
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +46 -13
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +72 -0
- package/@cds-models/index.js +12 -0
- package/@cds-models/odatano/cardano/index.d.ts +408 -7
- package/@cds-models/odatano/cardano/index.js +42 -0
- package/README.md +64 -5
- package/db/schema.cds +2297 -1633
- package/db/types.cds +114 -0
- package/package.json +27 -6
- package/scripts/migrate-slot-leader.mjs +104 -0
- package/scripts/migrate-txseq.mjs +147 -0
- package/src/index.d.ts +18 -11
- package/src/index.js +44 -14
- package/src/plugin.js +42 -52
- package/srv/blockchain/backends/blockfrost-backend.d.ts +29 -131
- package/srv/blockchain/backends/blockfrost-backend.js +53 -162
- package/srv/blockchain/backends/cardano-backend.d.ts +104 -158
- package/srv/blockchain/backends/cardano-backend.js +19 -5
- package/srv/blockchain/backends/koios-backend.d.ts +126 -60
- package/srv/blockchain/backends/koios-backend.js +376 -235
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +170 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +162 -94
- package/srv/blockchain/backends/ogmios-backend.js +556 -201
- package/srv/blockchain/backends/ogmios-frame-guard.d.ts +32 -0
- package/srv/blockchain/backends/ogmios-frame-guard.js +142 -0
- package/srv/blockchain/cardano-client.d.ts +87 -202
- package/srv/blockchain/cardano-client.js +210 -240
- package/srv/blockchain/cardano-indexer.d.ts +311 -242
- package/srv/blockchain/cardano-indexer.js +1238 -362
- package/srv/blockchain/cardano-tx-builder.d.ts +44 -81
- package/srv/blockchain/cardano-tx-builder.js +173 -132
- package/srv/blockchain/crawler/certificate-backfill.d.ts +67 -0
- package/srv/blockchain/crawler/certificate-backfill.js +169 -0
- package/srv/blockchain/crawler/crawler.d.ts +139 -54
- package/srv/blockchain/crawler/crawler.js +478 -96
- package/srv/blockchain/crawler/hooks.d.ts +3 -14
- package/srv/blockchain/crawler/index.d.ts +5 -0
- package/srv/blockchain/crawler/index.js +35 -7
- package/srv/blockchain/crawler/sync-state.d.ts +46 -28
- package/srv/blockchain/crawler/sync-state.js +128 -43
- package/srv/blockchain/crawler/transaction-backfill.d.ts +52 -0
- package/srv/blockchain/crawler/transaction-backfill.js +283 -0
- package/srv/blockchain/crawler/utxo-set-import.d.ts +78 -0
- package/srv/blockchain/crawler/utxo-set-import.js +363 -0
- package/srv/blockchain/ledger-state.d.ts +101 -0
- package/srv/blockchain/ledger-state.js +432 -0
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- package/srv/blockchain/signing/cose-verifier.d.ts +5 -12
- package/srv/blockchain/signing/cose-verifier.js +6 -12
- package/srv/blockchain/signing/external-signer.d.ts +16 -113
- package/srv/blockchain/signing/external-signer.js +19 -122
- package/srv/blockchain/signing/hsm-signer.d.ts +13 -45
- package/srv/blockchain/signing/hsm-signer.js +23 -63
- package/srv/blockchain/signing/signature-verifier.d.ts +14 -45
- package/srv/blockchain/signing/signature-verifier.js +73 -76
- package/srv/blockchain/signing/submission-finalizer.d.ts +9 -36
- package/srv/blockchain/signing/submission-finalizer.js +16 -49
- package/srv/blockchain/stored-chain.d.ts +33 -0
- package/srv/blockchain/stored-chain.js +234 -0
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +111 -173
- package/srv/blockchain/transaction-building/buildooor-tx.js +649 -326
- package/srv/blockchain/transaction-building/caller-datums.d.ts +29 -0
- package/srv/blockchain/transaction-building/caller-datums.js +139 -0
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +10 -35
- package/srv/blockchain/transaction-rows.d.ts +12 -0
- package/srv/blockchain/transaction-rows.js +43 -0
- package/srv/blockchain/wallet-worker/build-request.d.ts +4 -17
- package/srv/blockchain/wallet-worker/build-request.js +18 -23
- package/srv/blockchain/wallet-worker/confirmation-tracker.d.ts +25 -17
- package/srv/blockchain/wallet-worker/confirmation-tracker.js +87 -41
- package/srv/blockchain/wallet-worker/index.js +2 -8
- package/srv/blockchain/wallet-worker/job-store.d.ts +36 -103
- package/srv/blockchain/wallet-worker/job-store.js +0 -0
- package/srv/blockchain/wallet-worker/lease-heartbeat.d.ts +4 -20
- package/srv/blockchain/wallet-worker/lease-heartbeat.js +4 -20
- package/srv/blockchain/wallet-worker/signers.d.ts +6 -19
- package/srv/blockchain/wallet-worker/signers.js +3 -8
- package/srv/blockchain/wallet-worker/wallet-worker.d.ts +15 -71
- package/srv/blockchain/wallet-worker/wallet-worker.js +40 -91
- package/srv/cardano-agent-service.cds +146 -0
- package/srv/cardano-agent-service.d.ts +2 -0
- package/srv/cardano-agent-service.js +12 -0
- package/srv/cardano-backend-service.cds +52 -0
- package/srv/cardano-backend-service.d.ts +2 -0
- package/srv/cardano-backend-service.js +244 -0
- package/srv/cardano-indexer-service.cds +201 -73
- package/srv/cardano-indexer-service.js +280 -11
- package/srv/cardano-service.cds +65 -2
- package/srv/cardano-service.js +170 -129
- package/srv/cardano-sign-service.cds +200 -180
- package/srv/cardano-sign-service.js +57 -184
- package/srv/cardano-tx-service.cds +439 -370
- package/srv/cardano-tx-service.js +231 -190
- package/srv/cardano-ui.cds +16 -16
- package/srv/cardano-worker-service.js +7 -15
- package/srv/cbor/index.d.ts +1 -1
- package/srv/cbor/parse.d.ts +27 -0
- package/srv/cbor/parse.js +63 -2
- package/srv/server.d.ts +28 -86
- package/srv/server.js +132 -135
- package/srv/utils/agent-grants-config.d.ts +37 -0
- package/srv/utils/agent-grants-config.js +138 -0
- package/srv/utils/agent-grants.d.ts +262 -0
- package/srv/utils/agent-grants.js +922 -0
- package/srv/utils/agent-token-auth.d.ts +16 -0
- package/srv/utils/agent-token-auth.js +78 -0
- package/srv/utils/backend-request-handler.d.ts +2 -16
- package/srv/utils/backend-request-handler.js +3 -18
- package/srv/utils/collections.d.ts +4 -8
- package/srv/utils/collections.js +4 -8
- package/srv/utils/const.d.ts +30 -67
- package/srv/utils/const.js +32 -72
- package/srv/utils/crypto.d.ts +3 -12
- package/srv/utils/crypto.js +5 -18
- package/srv/utils/db-indexes.d.ts +25 -0
- package/srv/utils/db-indexes.js +94 -0
- package/srv/utils/db-sanitize.d.ts +27 -0
- package/srv/utils/db-sanitize.js +85 -0
- package/srv/utils/epoch-slots.d.ts +20 -0
- package/srv/utils/epoch-slots.js +43 -0
- package/srv/utils/error-codes.d.ts +20 -73
- package/srv/utils/error-codes.js +19 -70
- package/srv/utils/errors.d.ts +50 -177
- package/srv/utils/errors.js +94 -218
- package/srv/utils/legacy-service-paths.d.ts +11 -0
- package/srv/utils/legacy-service-paths.js +58 -0
- package/srv/utils/liveness.d.ts +16 -0
- package/srv/utils/liveness.js +40 -0
- package/srv/utils/mappers.d.ts +128 -214
- package/srv/utils/mappers.js +354 -299
- package/srv/utils/network-context.js +2 -11
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +62 -0
- package/srv/utils/pg-order-nulls.d.ts +14 -0
- package/srv/utils/pg-order-nulls.js +56 -0
- package/srv/utils/plutus-placeholders.d.ts +23 -16
- package/srv/utils/plutus-placeholders.js +63 -27
- package/srv/utils/rate-limiter.d.ts +46 -0
- package/srv/utils/rate-limiter.js +116 -0
- package/srv/utils/service-events.d.ts +2 -22
- package/srv/utils/service-events.js +3 -23
- package/srv/utils/signing-helper.d.ts +6 -16
- package/srv/utils/signing-helper.js +36 -60
- package/srv/utils/tx-build-helper.d.ts +28 -93
- package/srv/utils/tx-build-helper.js +75 -124
- package/srv/utils/tx-request-parsers.d.ts +101 -28
- package/srv/utils/tx-request-parsers.js +410 -43
- package/srv/utils/tx-utils.d.ts +4 -23
- package/srv/utils/tx-utils.js +12 -41
- package/srv/utils/types.d.ts +252 -179
- package/srv/utils/types.js +2 -6
- package/srv/utils/validators.d.ts +24 -90
- package/srv/utils/validators.js +50 -147
|
@@ -2,32 +2,9 @@ import type { CardanoClient } from '../cardano-client';
|
|
|
2
2
|
import type { CardanoIndexer } from '../cardano-indexer';
|
|
3
3
|
import { type WorkerSigner, type WorkerWalletConfig } from './signers';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* with pending work and NO active job (building or submitted — the queue stays
|
|
9
|
-
* blocked until the previous job CONFIRMS, which makes per-wallet UTxO contention
|
|
10
|
-
* impossible by construction), acquire the per-wallet DB lease and execute:
|
|
11
|
-
*
|
|
12
|
-
* building → CardanoIndexer.index<Kind>BuildResult (build + TransactionBuilds row)
|
|
13
|
-
* → signer.signTransaction
|
|
14
|
-
* submitting → signed CBOR + hash committed, THEN client.submitTransaction
|
|
15
|
-
* submitted → hand to the ConfirmationTracker (crawler hook or polling)
|
|
16
|
-
*
|
|
17
|
-
* The `submitting` commit is what makes the submit boundary crash-safe: the exact
|
|
18
|
-
* bytes that may be on-chain are durable before the network call, and the row stays
|
|
19
|
-
* non-terminal, so it keeps holding its idempotency key. Anything that goes wrong
|
|
20
|
-
* from there on is reconciled against the chain (`reconcileSubmitting`) — the same
|
|
21
|
-
* transaction is re-submitted, never a rebuild.
|
|
22
|
-
*
|
|
23
|
-
* Transient failures BEFORE the signed tx exists (provider outages, rate limits,
|
|
24
|
-
* HSM hiccups during build/sign) re-queue the job with exponential backoff up to
|
|
25
|
-
* `maxAttempts`; deterministic rejections (validation, insufficient funds) fail
|
|
26
|
-
* immediately.
|
|
27
|
-
*
|
|
28
|
-
* All DB access runs in short fresh transactions (ambient context cleared —
|
|
29
|
-
* NIGHTGATE lesson 2) so the single pooled SQLite connection is never held
|
|
30
|
-
* across build/submit round-trips.
|
|
5
|
+
* Dispatch loop over `CardanoWalletJobs`: each tick leases every wallet with pending work and no active job
|
|
6
|
+
* and runs building → submitting (signed CBOR committed BEFORE submit) → submitted → ConfirmationTracker.
|
|
7
|
+
* After the `submitting` commit failures are reconciled against the chain, never rebuilt; transient pre-sign failures re-queue with backoff.
|
|
31
8
|
*/
|
|
32
9
|
export interface WalletWorkerConfig {
|
|
33
10
|
enabled: boolean;
|
|
@@ -48,10 +25,7 @@ export interface WalletWorkerDeps {
|
|
|
48
25
|
}
|
|
49
26
|
/** Retry backoff: 5s · 2^(attempt-1), capped at 60s. */
|
|
50
27
|
export declare function retryBackoffMs(attempt: number): number;
|
|
51
|
-
/**
|
|
52
|
-
* Transient errors are worth a bounded retry; everything else is deterministic
|
|
53
|
-
* (a retry cannot change the outcome) and fails the job immediately.
|
|
54
|
-
*/
|
|
28
|
+
/** Transient errors get a bounded retry; everything else fails the job immediately. */
|
|
55
29
|
export declare function isTransientJobError(err: unknown): boolean;
|
|
56
30
|
export declare class CardanoWalletWorker {
|
|
57
31
|
private readonly deps;
|
|
@@ -79,66 +53,36 @@ export declare class CardanoWalletWorker {
|
|
|
79
53
|
/** One dispatch round; serialized (overlapping timers collapse into one run). */
|
|
80
54
|
private tickSafe;
|
|
81
55
|
private tick;
|
|
82
|
-
/**
|
|
83
|
-
* Adopt `submitting` rows left behind by a dead executor (this process before a
|
|
84
|
-
* restart, or another instance whose lease expired) and resolve them against the
|
|
85
|
-
* chain. Runs per wallet under the same lease the executor would hold.
|
|
86
|
-
*/
|
|
56
|
+
/** Adopt `submitting` rows left by a dead executor and resolve them against the chain, under the wallet lease. */
|
|
87
57
|
private reconcileOrphanedSubmissions;
|
|
88
58
|
/** Run one wallet's work in the background, tracked for concurrency + shutdown. */
|
|
89
59
|
private spawn;
|
|
90
60
|
/** A heartbeat that keeps this instance's lease on `walletId` alive while it works. */
|
|
91
61
|
private leaseHeartbeat;
|
|
92
62
|
/**
|
|
93
|
-
* Execute one job: building → (build → sign) → submitting → submit → submitted
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* (queue serialization continues via the job row, not the lease).
|
|
97
|
-
*
|
|
98
|
-
* Everything up to and including the `submitting` commit may fail freely — nothing
|
|
99
|
-
* has been sent, so the job re-queues or fails normally. Past that commit the job
|
|
100
|
-
* belongs to `reconcileSubmitting`.
|
|
63
|
+
* Execute one job: building → (build → sign) → submitting → submit → submitted → tracker.
|
|
64
|
+
* The wallet lease is heartbeat-renewed for the duration. Up to the `submitting` commit failures
|
|
65
|
+
* re-queue or fail normally; past it the job belongs to `reconcileSubmitting`.
|
|
101
66
|
*/
|
|
102
67
|
private executeJob;
|
|
103
68
|
/**
|
|
104
|
-
* Send a
|
|
105
|
-
* the job
|
|
106
|
-
*
|
|
107
|
-
* A submit failure is NEVER propagated as a job failure here: a rejection from one
|
|
108
|
-
* backend does not prove the tx is absent from every mempool (failover, timeouts,
|
|
109
|
-
* a node that accepted before the connection dropped). The row simply stays
|
|
110
|
-
* `submitting` and the next tick reconciles it against the chain.
|
|
69
|
+
* Send a tx already durable in its `submitting` row and advance to `submitted`. A submit failure
|
|
70
|
+
* never fails the job here (one rejection does not prove absence from every mempool); the row
|
|
71
|
+
* stays `submitting` for the next tick's reconciliation.
|
|
111
72
|
*/
|
|
112
73
|
private submitStoredTransaction;
|
|
113
74
|
/** submitting → submitted + hand to the confirmation tracker. */
|
|
114
75
|
private adoptSubmitted;
|
|
115
76
|
/**
|
|
116
|
-
* Resolve a `submitting` job
|
|
117
|
-
*
|
|
118
|
-
* only
|
|
119
|
-
*
|
|
120
|
-
* 1. Re-submit the same CBOR: mempool/ledger dedup makes this a no-op if it was
|
|
121
|
-
* accepted before, so success (or "already known") simply promotes the job.
|
|
122
|
-
* 2. If that fails, ask the chain: found → the tx did make it, promote it.
|
|
123
|
-
* 3. Only when the chain proves absence AND the node rejects the tx for good (or
|
|
124
|
-
* it has been absent past the confirmation timeout) is the job failed —
|
|
125
|
-
* failing releases the idempotency key, so it needs that proof.
|
|
126
|
-
* Anything else leaves the row as-is; the next tick tries again.
|
|
127
|
-
*
|
|
128
|
-
* Runs under the same heartbeat-kept wallet lease as an execution: the chain
|
|
129
|
-
* lookups here are slow enough to outlive the raw TTL. Losing the lease mid-way
|
|
130
|
-
* is not dangerous (the re-submit is the same transaction, and every terminal
|
|
131
|
-
* transition is row-guarded), so it only stops further work.
|
|
77
|
+
* Resolve a `submitting` job with an unknown submit outcome; the stored tx is re-submitted verbatim,
|
|
78
|
+
* never rebuilt. Order: re-submit (already-known = success) → chain lookup (found = promote) →
|
|
79
|
+
* fail only when proven absent AND rejected for good or past the confirmation timeout; else retry next tick.
|
|
132
80
|
*/
|
|
133
81
|
private reconcileSubmitting;
|
|
134
82
|
private failReconciled;
|
|
135
83
|
/** Dispatch the job kind to the matching indexer build method. */
|
|
136
84
|
private buildForKind;
|
|
137
|
-
/**
|
|
138
|
-
* Submit tolerant of "already known": after a crash between submit and the
|
|
139
|
-
* `submitted` transition, the retry re-submits the same CBOR — mempool dedup
|
|
140
|
-
* answers with an already-submitted error that IS our success case.
|
|
141
|
-
*/
|
|
85
|
+
/** Submit treating "already known" as success: a re-submit of the same CBOR after a crash hits mempool dedup. */
|
|
142
86
|
private submitWithAlreadyKnownTolerance;
|
|
143
87
|
private handleExecutionFailure;
|
|
144
88
|
}
|
|
@@ -21,10 +21,7 @@ const logger = cds_1.default.log('CardanoWalletWorker');
|
|
|
21
21
|
function retryBackoffMs(attempt) {
|
|
22
22
|
return Math.min(5_000 * 2 ** Math.max(0, attempt - 1), 60_000);
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Transient errors are worth a bounded retry; everything else is deterministic
|
|
26
|
-
* (a retry cannot change the outcome) and fails the job immediately.
|
|
27
|
-
*/
|
|
24
|
+
/** Transient errors get a bounded retry; everything else fails the job immediately. */
|
|
28
25
|
function isTransientJobError(err) {
|
|
29
26
|
if (err instanceof errors_1.ProviderUnavailableError)
|
|
30
27
|
return true;
|
|
@@ -46,7 +43,7 @@ function terminalErrorCode(err) {
|
|
|
46
43
|
class CardanoWalletWorker {
|
|
47
44
|
deps;
|
|
48
45
|
signers = new Map();
|
|
49
|
-
executing = new Set(); // walletIds
|
|
46
|
+
executing = new Set(); // walletIds executing in THIS process
|
|
50
47
|
executionPromises = new Set();
|
|
51
48
|
tracker;
|
|
52
49
|
dispatchTimer = null;
|
|
@@ -64,8 +61,7 @@ class CardanoWalletWorker {
|
|
|
64
61
|
},
|
|
65
62
|
onFinal: ({ jobId, walletId, outcome, kind, txHash, errorCode, errorMessage }) => {
|
|
66
63
|
logger.debug(`Wallet ${walletId} unblocked (job ${outcome}) — next tick dispatches`);
|
|
67
|
-
//
|
|
68
|
-
// subscriber that reads the job row sees the state the event announces.
|
|
64
|
+
// Terminal outcomes only, after the commit, so subscribers reading the row see the announced state.
|
|
69
65
|
(0, service_events_1.emitServiceEvent)('CardanoWorkerService', outcome === 'confirmed' ? 'jobConfirmed' : 'jobFailed', {
|
|
70
66
|
jobId,
|
|
71
67
|
walletId,
|
|
@@ -123,9 +119,8 @@ class CardanoWalletWorker {
|
|
|
123
119
|
logger.error('Wallet worker not started: no wallet signer could be initialized');
|
|
124
120
|
return;
|
|
125
121
|
}
|
|
126
|
-
// 2. Crash recovery: fail interrupted builds, re-watch submitted jobs
|
|
127
|
-
//
|
|
128
|
-
// reconciles them against the chain (reconcileOrphanedSubmissions).
|
|
122
|
+
// 2. Crash recovery: fail interrupted builds, re-watch submitted jobs; `submitting`
|
|
123
|
+
// rows are reconciled by the first tick.
|
|
129
124
|
const recovery = await cds_1.default.tx((tx) => (0, job_store_1.recoverInterruptedJobs)(tx));
|
|
130
125
|
if (recovery.submittingToReconcile.length) {
|
|
131
126
|
logger.warn(`${recovery.submittingToReconcile.length} job(s) with an unresolved submit will be reconciled on the next dispatch tick`);
|
|
@@ -161,7 +156,7 @@ class CardanoWalletWorker {
|
|
|
161
156
|
this.dispatchTimer = null;
|
|
162
157
|
}
|
|
163
158
|
this.tracker.stop();
|
|
164
|
-
//
|
|
159
|
+
// Await in-flight executions so teardown never races a write.
|
|
165
160
|
await Promise.allSettled([...this.executionPromises]);
|
|
166
161
|
for (const walletId of this.getWalletIds()) {
|
|
167
162
|
try {
|
|
@@ -189,8 +184,7 @@ class CardanoWalletWorker {
|
|
|
189
184
|
}
|
|
190
185
|
}
|
|
191
186
|
async tick() {
|
|
192
|
-
// Interrupted submits first: a stuck `submitting` row blocks its wallet queue
|
|
193
|
-
// and may be the only work there is (no pending job would ever surface it).
|
|
187
|
+
// Interrupted submits first: a stuck `submitting` row blocks its wallet queue.
|
|
194
188
|
await this.reconcileOrphanedSubmissions();
|
|
195
189
|
const due = await (0, job_store_1.runWithoutAmbientTx)(() => cds_1.default.tx((tx) => (0, job_store_1.findDueJobs)(tx)));
|
|
196
190
|
if (!due.length)
|
|
@@ -212,12 +206,10 @@ class CardanoWalletWorker {
|
|
|
212
206
|
if (!signer)
|
|
213
207
|
continue; // job for a wallet this instance cannot sign for
|
|
214
208
|
const dispatched = await (0, job_store_1.runWithoutAmbientTx)(() => cds_1.default.tx(async (tx) => {
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
// needing a reboot (boot recovery only covers restarts of THIS instance).
|
|
209
|
+
// A building row whose wallet lease expired belongs to a dead executor — fail it
|
|
210
|
+
// so the wallet unblocks without a reboot.
|
|
218
211
|
await (0, job_store_1.failOrphanedBuildingJobs)(tx, walletId);
|
|
219
|
-
//
|
|
220
|
-
// job blocks the wallet queue until the tracker finalizes it (design §6).
|
|
212
|
+
// An active job blocks the wallet queue until the tracker finalizes it.
|
|
221
213
|
if (await (0, job_store_1.walletHasActiveJob)(tx, walletId))
|
|
222
214
|
return false;
|
|
223
215
|
return (0, job_store_1.tryAcquireWalletLease)(tx, walletId, this.deps.instanceId);
|
|
@@ -227,11 +219,7 @@ class CardanoWalletWorker {
|
|
|
227
219
|
this.spawn(walletId, () => this.executeJob(job, signer));
|
|
228
220
|
}
|
|
229
221
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Adopt `submitting` rows left behind by a dead executor (this process before a
|
|
232
|
-
* restart, or another instance whose lease expired) and resolve them against the
|
|
233
|
-
* chain. Runs per wallet under the same lease the executor would hold.
|
|
234
|
-
*/
|
|
222
|
+
/** Adopt `submitting` rows left by a dead executor and resolve them against the chain, under the wallet lease. */
|
|
235
223
|
async reconcileOrphanedSubmissions() {
|
|
236
224
|
const { instanceId } = this.deps;
|
|
237
225
|
for (const walletId of this.getWalletIds()) {
|
|
@@ -271,14 +259,9 @@ class CardanoWalletWorker {
|
|
|
271
259
|
return heartbeat;
|
|
272
260
|
}
|
|
273
261
|
/**
|
|
274
|
-
* Execute one job: building → (build → sign) → submitting → submit → submitted
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* (queue serialization continues via the job row, not the lease).
|
|
278
|
-
*
|
|
279
|
-
* Everything up to and including the `submitting` commit may fail freely — nothing
|
|
280
|
-
* has been sent, so the job re-queues or fails normally. Past that commit the job
|
|
281
|
-
* belongs to `reconcileSubmitting`.
|
|
262
|
+
* Execute one job: building → (build → sign) → submitting → submit → submitted → tracker.
|
|
263
|
+
* The wallet lease is heartbeat-renewed for the duration. Up to the `submitting` commit failures
|
|
264
|
+
* re-queue or fail normally; past it the job belongs to `reconcileSubmitting`.
|
|
282
265
|
*/
|
|
283
266
|
async executeJob(job, signer) {
|
|
284
267
|
const { instanceId } = this.deps;
|
|
@@ -301,19 +284,13 @@ class CardanoWalletWorker {
|
|
|
301
284
|
}
|
|
302
285
|
else {
|
|
303
286
|
const rawReq = JSON.parse(job.request ?? '{}');
|
|
304
|
-
// The worker wallet is ALWAYS the sender/change target —
|
|
305
|
-
// spend from foreign addresses through a worker wallet.
|
|
287
|
+
// The worker wallet is ALWAYS the sender/change target — no spending from foreign addresses.
|
|
306
288
|
rawReq.network = this.deps.network;
|
|
307
289
|
rawReq.senderAddress = signer.getAddress();
|
|
308
290
|
if (!rawReq.changeAddress)
|
|
309
291
|
rawReq.changeAddress = signer.getAddress();
|
|
310
|
-
// The stored request has the documented Build*-action payload shape
|
|
311
|
-
// (assetsJson/mintActionsJson/… strings) — transform it into the
|
|
312
|
-
// TxBuildRequest shape the indexer build methods expect.
|
|
313
292
|
const buildReq = (0, build_request_1.prepareWorkerBuildRequest)(job.kind, rawReq, this.deps.network);
|
|
314
|
-
//
|
|
315
|
-
// instance may have taken over the wallet), abort BEFORE building — the
|
|
316
|
-
// orphan cleanup will fail the row once the lease is provably dead.
|
|
293
|
+
// Lease lost → abort BEFORE building; orphan cleanup fails the row once the lease is provably dead.
|
|
317
294
|
if (!(await heartbeat.fence())) {
|
|
318
295
|
logger.warn(`Job ${job.ID}: wallet lease for ${job.walletId} lost before build — aborting execution`);
|
|
319
296
|
return;
|
|
@@ -324,22 +301,16 @@ class CardanoWalletWorker {
|
|
|
324
301
|
buildId = buildResult.id ?? null;
|
|
325
302
|
signedTxCbor = signer.signTransaction(unsignedTxCbor, buildResult.txBodyHash);
|
|
326
303
|
}
|
|
327
|
-
//
|
|
328
|
-
// row can name the transaction before anyone has seen it.
|
|
304
|
+
// Hash from the signed bytes, so the row can name the tx before anyone has seen it.
|
|
329
305
|
const txHash = (0, tx_build_helper_1.getTxHashFromCbor)(signedTxCbor);
|
|
330
|
-
// Last fence before the irreversible part
|
|
331
|
-
//
|
|
332
|
-
// to spend the same UTxOs — submitting now would race it. Nothing has been sent
|
|
333
|
-
// yet, so standing down here costs only a rebuild.
|
|
306
|
+
// Last fence before the irreversible part: another instance owning the wallet now
|
|
307
|
+
// may spend the same UTxOs. Nothing has been sent, so standing down costs only a rebuild.
|
|
334
308
|
if (!(await heartbeat.fence())) {
|
|
335
309
|
logger.warn(`Job ${job.ID}: wallet lease for ${job.walletId} lost after signing — NOT submitting tx ${txHash}`);
|
|
336
310
|
return;
|
|
337
311
|
}
|
|
338
|
-
// Point of no return: commit the signed tx BEFORE it can reach a backend.
|
|
339
|
-
//
|
|
340
|
-
// a crash before it leaves a `building` row that was provably never sent.
|
|
341
|
-
// The guard on `building` is also the second half of the fence: if a takeover
|
|
342
|
-
// already failed this row, the transition returns false and nothing is sent.
|
|
312
|
+
// Point of no return: commit the signed tx BEFORE it can reach a backend. The guard on
|
|
313
|
+
// `building` is the second half of the fence: a row already failed by a takeover returns false.
|
|
343
314
|
const stored = await (0, job_store_1.runWithoutAmbientTx)(() => cds_1.default.tx((tx) => (0, job_store_1.markSubmitting)(tx, job.ID, { txHash, unsignedTxCbor, signedTxCbor, fee })));
|
|
344
315
|
if (!stored) {
|
|
345
316
|
logger.warn(`Job ${job.ID}: submitting transition was fenced — not submitting (another executor owns this job)`);
|
|
@@ -357,13 +328,9 @@ class CardanoWalletWorker {
|
|
|
357
328
|
}
|
|
358
329
|
}
|
|
359
330
|
/**
|
|
360
|
-
* Send a
|
|
361
|
-
* the job
|
|
362
|
-
*
|
|
363
|
-
* A submit failure is NEVER propagated as a job failure here: a rejection from one
|
|
364
|
-
* backend does not prove the tx is absent from every mempool (failover, timeouts,
|
|
365
|
-
* a node that accepted before the connection dropped). The row simply stays
|
|
366
|
-
* `submitting` and the next tick reconciles it against the chain.
|
|
331
|
+
* Send a tx already durable in its `submitting` row and advance to `submitted`. A submit failure
|
|
332
|
+
* never fails the job here (one rejection does not prove absence from every mempool); the row
|
|
333
|
+
* stays `submitting` for the next tick's reconciliation.
|
|
367
334
|
*/
|
|
368
335
|
async submitStoredTransaction(job, tx) {
|
|
369
336
|
let submittedHash;
|
|
@@ -375,7 +342,7 @@ class CardanoWalletWorker {
|
|
|
375
342
|
return;
|
|
376
343
|
}
|
|
377
344
|
if (job.kind !== 'submitSigned') {
|
|
378
|
-
//
|
|
345
|
+
// Record the submission row as the synchronous flow does.
|
|
379
346
|
await (0, job_store_1.runWithoutAmbientTx)(() => cds_1.default.tx((t) => this.deps.indexer.persistTransactionSubmission(t, { signedTxCbor: tx.signedTxCbor, txHash: submittedHash, buildId: tx.buildId }))).catch((err) => logger.warn(`Job ${job.ID}: submission bookkeeping failed (job continues):`, err));
|
|
380
347
|
}
|
|
381
348
|
await this.adoptSubmitted(job, submittedHash, tx.signedTxCbor);
|
|
@@ -397,30 +364,16 @@ class CardanoWalletWorker {
|
|
|
397
364
|
});
|
|
398
365
|
}
|
|
399
366
|
/**
|
|
400
|
-
* Resolve a `submitting` job
|
|
401
|
-
*
|
|
402
|
-
* only
|
|
403
|
-
*
|
|
404
|
-
* 1. Re-submit the same CBOR: mempool/ledger dedup makes this a no-op if it was
|
|
405
|
-
* accepted before, so success (or "already known") simply promotes the job.
|
|
406
|
-
* 2. If that fails, ask the chain: found → the tx did make it, promote it.
|
|
407
|
-
* 3. Only when the chain proves absence AND the node rejects the tx for good (or
|
|
408
|
-
* it has been absent past the confirmation timeout) is the job failed —
|
|
409
|
-
* failing releases the idempotency key, so it needs that proof.
|
|
410
|
-
* Anything else leaves the row as-is; the next tick tries again.
|
|
411
|
-
*
|
|
412
|
-
* Runs under the same heartbeat-kept wallet lease as an execution: the chain
|
|
413
|
-
* lookups here are slow enough to outlive the raw TTL. Losing the lease mid-way
|
|
414
|
-
* is not dangerous (the re-submit is the same transaction, and every terminal
|
|
415
|
-
* transition is row-guarded), so it only stops further work.
|
|
367
|
+
* Resolve a `submitting` job with an unknown submit outcome; the stored tx is re-submitted verbatim,
|
|
368
|
+
* never rebuilt. Order: re-submit (already-known = success) → chain lookup (found = promote) →
|
|
369
|
+
* fail only when proven absent AND rejected for good or past the confirmation timeout; else retry next tick.
|
|
416
370
|
*/
|
|
417
371
|
async reconcileSubmitting(job) {
|
|
418
372
|
const { instanceId } = this.deps;
|
|
419
373
|
const heartbeat = this.leaseHeartbeat(job.walletId);
|
|
420
374
|
try {
|
|
421
375
|
if (!job.signedTxCbor || !job.txHash) {
|
|
422
|
-
// Cannot happen via markSubmitting; treat as
|
|
423
|
-
// leaving the wallet queue blocked forever.
|
|
376
|
+
// Cannot happen via markSubmitting; treat as never sent rather than blocking the wallet queue forever.
|
|
424
377
|
logger.error(`Job ${job.ID}: submitting row without signed transaction — failing as PROCESS_RESTART`);
|
|
425
378
|
await this.failReconciled(job, job_store_1.JOB_ERROR_CODES.PROCESS_RESTART, new Error('Job was interrupted before its signed transaction was stored.'));
|
|
426
379
|
return;
|
|
@@ -436,11 +389,15 @@ class CardanoWalletWorker {
|
|
|
436
389
|
catch (err) {
|
|
437
390
|
submitError = err;
|
|
438
391
|
}
|
|
439
|
-
//
|
|
440
|
-
// (its inputs are spent), so the chain — not the rejection — decides.
|
|
392
|
+
// A rejection may mean the tx is already on-chain (inputs spent), so the chain decides.
|
|
441
393
|
let onChain;
|
|
442
394
|
try {
|
|
443
|
-
|
|
395
|
+
// the local index first (filled by the crawler), then the backends
|
|
396
|
+
const txHash = job.txHash;
|
|
397
|
+
const indexed = await (0, job_store_1.runWithoutAmbientTx)(() => cds_1.default.tx((t) => this.deps.indexer.findIndexedTransaction(t, txHash)));
|
|
398
|
+
if (!indexed) {
|
|
399
|
+
await this.deps.client.getTransaction(txHash);
|
|
400
|
+
}
|
|
444
401
|
onChain = true;
|
|
445
402
|
}
|
|
446
403
|
catch (lookupErr) {
|
|
@@ -461,9 +418,7 @@ class CardanoWalletWorker {
|
|
|
461
418
|
logger.warn(`Job ${job.ID}: re-submit failed transiently and tx is not on-chain — retrying next tick:`, submitError);
|
|
462
419
|
return;
|
|
463
420
|
}
|
|
464
|
-
// Proven absent
|
|
465
|
-
// mempool lifetime): no transaction of this job can reach the chain anymore,
|
|
466
|
-
// so releasing the idempotency key is safe.
|
|
421
|
+
// Proven absent and not submittable anymore: releasing the idempotency key is safe.
|
|
467
422
|
const code = expired ? job_store_1.JOB_ERROR_CODES.TX_DROPPED : job_store_1.JOB_ERROR_CODES.SUBMIT_REJECTED;
|
|
468
423
|
logger.error(`Job ${job.ID}: tx ${job.txHash} is not on-chain and cannot be submitted (${code}) — failing:`, submitError);
|
|
469
424
|
await this.failReconciled(job, code, submitError);
|
|
@@ -494,11 +449,7 @@ class CardanoWalletWorker {
|
|
|
494
449
|
throw new errors_1.BackendError(`Unsupported job kind "${job.kind}"`, 400, error_codes_1.ERROR_CODES.INVALID_INPUT);
|
|
495
450
|
}
|
|
496
451
|
}
|
|
497
|
-
/**
|
|
498
|
-
* Submit tolerant of "already known": after a crash between submit and the
|
|
499
|
-
* `submitted` transition, the retry re-submits the same CBOR — mempool dedup
|
|
500
|
-
* answers with an already-submitted error that IS our success case.
|
|
501
|
-
*/
|
|
452
|
+
/** Submit treating "already known" as success: a re-submit of the same CBOR after a crash hits mempool dedup. */
|
|
502
453
|
async submitWithAlreadyKnownTolerance(signedTxCbor) {
|
|
503
454
|
try {
|
|
504
455
|
return await this.deps.client.submitTransaction(signedTxCbor);
|
|
@@ -513,10 +464,8 @@ class CardanoWalletWorker {
|
|
|
513
464
|
}
|
|
514
465
|
}
|
|
515
466
|
async handleExecutionFailure(job, attempt, err) {
|
|
516
|
-
// Only a pre-submit job may be re-queued
|
|
517
|
-
//
|
|
518
|
-
// would double-pay and failing it would release the idempotency key on a
|
|
519
|
-
// transaction the chain has not ruled on. Those rows go to reconciliation.
|
|
467
|
+
// Only a pre-submit (`building`) job may be re-queued or failed here; a `submitting` row's
|
|
468
|
+
// tx may be in a mempool, so it goes to reconciliation.
|
|
520
469
|
const current = await (0, job_store_1.runWithoutAmbientTx)(() => cds_1.default.tx((tx) => (0, job_store_1.getJobById)(tx, job.ID)))
|
|
521
470
|
.catch(() => null);
|
|
522
471
|
if (current && current.status !== 'building') {
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
using {odatano.cardano as db} from '../db/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cardano Agent Service (v2.0)
|
|
5
|
+
*
|
|
6
|
+
* Agent grants: scoped, budgeted bearer capabilities an Admin hands to an agent
|
|
7
|
+
* instead of a full user.
|
|
8
|
+
*
|
|
9
|
+
* - CreateAgentGrant / UpdateAgentGrant / RotateAgentGrantToken / RevokeAgentGrant:
|
|
10
|
+
* Admin-only administration, rate limited per principal per hour
|
|
11
|
+
* (AGENT_GRANT_ADMIN_RATE_LIMIT, default 10). The token is returned ONCE from
|
|
12
|
+
* CreateAgentGrant and RotateAgentGrantToken and stored as SHA-256 only.
|
|
13
|
+
* - AgentGrants: Admin-only projection (no token hash). A request carrying a token
|
|
14
|
+
* runs as the principal `agent:<grantId>` with the role `agent-grant` and sees
|
|
15
|
+
* exactly its own row through the row-level restriction below.
|
|
16
|
+
* - GetGrantStatus: token self-service — what am I allowed to do, how much budget
|
|
17
|
+
* is left, when do I expire. What an MCP tool needs to describe itself honestly.
|
|
18
|
+
* - GetGrantUsage: admitted calls per service and action over a window — an Admin
|
|
19
|
+
* for any grant, a token for its own (a partner usage view, ledger reconciliation).
|
|
20
|
+
*
|
|
21
|
+
* A token request never inherits the operator's roles: `@requires: 'Admin'` on the
|
|
22
|
+
* four actions, on PauseWorker / ResumeWorker / pauseCrawler / resumeCrawler and on
|
|
23
|
+
* every other Admin surface therefore refuses it by construction. The allow list,
|
|
24
|
+
* wallet pinning and daily budget are enforced by a before('*') hook on all six
|
|
25
|
+
* ODATANO services (srv/utils/agent-grants.ts). The `x-agent-token` header only
|
|
26
|
+
* reaches the services when cds.requires.odatano-core.agentGrants.enabled is set
|
|
27
|
+
* (srv/utils/agent-token-auth.ts).
|
|
28
|
+
*/
|
|
29
|
+
@requires: 'authenticated-user'
|
|
30
|
+
service CardanoAgentService @(impl: './cardano-agent-service') {
|
|
31
|
+
|
|
32
|
+
@readonly
|
|
33
|
+
@title : 'Agent Grants'
|
|
34
|
+
@description: 'Issued grants (token hash excluded). Admins see all, a token sees its own row.'
|
|
35
|
+
@restrict : [
|
|
36
|
+
{ grant: 'READ', to: 'Admin' },
|
|
37
|
+
{ grant: 'READ', to: 'agent-grant', where: 'ID = $user.grantId' }
|
|
38
|
+
]
|
|
39
|
+
entity AgentGrants as projection on db.CardanoAgentGrants excluding { tokenHash };
|
|
40
|
+
|
|
41
|
+
@title : 'Grant Status'
|
|
42
|
+
type GrantStatus {
|
|
43
|
+
grantId : UUID;
|
|
44
|
+
agentLabel : String(100);
|
|
45
|
+
allowedActions : many String;
|
|
46
|
+
walletId : String(50);
|
|
47
|
+
allowedJobKinds : many String;
|
|
48
|
+
maxJobsPerDay : Integer;
|
|
49
|
+
jobsUsedToday : Integer;
|
|
50
|
+
budgetWindow : String(10);
|
|
51
|
+
validUntil : Timestamp;
|
|
52
|
+
isActive : Boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@title : 'Issued Grant'
|
|
56
|
+
type IssuedGrant {
|
|
57
|
+
grantId : UUID;
|
|
58
|
+
token : String; // shown once, never stored
|
|
59
|
+
allowedActions : many String;
|
|
60
|
+
walletId : String(50);
|
|
61
|
+
allowedJobKinds : many String;
|
|
62
|
+
maxJobsPerDay : Integer;
|
|
63
|
+
validUntil : Timestamp;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@title : 'Get Grant Status'
|
|
67
|
+
@description: 'The calling token''s own grant: allow list, wallet, remaining daily budget, expiry. 400 without a token — an operator lists AgentGrants instead.'
|
|
68
|
+
function GetGrantStatus() returns GrantStatus;
|
|
69
|
+
|
|
70
|
+
@title : 'Create Agent Grant'
|
|
71
|
+
@description: 'Issue a scoped bearer token for an agent. Admin only. The token is returned once and stored as SHA-256. allowedActions must be a non-empty subset of the grantable set; walletId is required when SubmitWalletJob or CancelJob is allowed.'
|
|
72
|
+
@requires : 'Admin'
|
|
73
|
+
action CreateAgentGrant(
|
|
74
|
+
@title: 'Allowed Actions' allowedActions : many String,
|
|
75
|
+
@title: 'Wallet Id' walletId : String(50),
|
|
76
|
+
@title: 'Allowed Job Kinds' allowedJobKinds : many String,
|
|
77
|
+
@title: 'Max Jobs Per Day' maxJobsPerDay : Integer,
|
|
78
|
+
@title: 'Valid Until' validUntil : Timestamp,
|
|
79
|
+
@title: 'Agent Label' agentLabel : String(100)
|
|
80
|
+
) returns IssuedGrant;
|
|
81
|
+
|
|
82
|
+
@title : 'Revoke Agent Grant'
|
|
83
|
+
@description: 'Deactivate a grant. Admin only. Its token becomes an unknown token immediately.'
|
|
84
|
+
@requires : 'Admin'
|
|
85
|
+
action RevokeAgentGrant(
|
|
86
|
+
@title: 'Grant Id' grantId : UUID
|
|
87
|
+
) returns Boolean;
|
|
88
|
+
|
|
89
|
+
@title : 'Rotated Grant'
|
|
90
|
+
type RotatedGrant {
|
|
91
|
+
grantId : UUID;
|
|
92
|
+
token : String; // shown once, never stored
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@title : 'Rotate Agent Grant Token'
|
|
96
|
+
@description: 'Replace the grant token; the old token is unknown from the next request. Budget, wallet, allow list and expiry survive. Admin only. 404 when the grant does not exist or is revoked.'
|
|
97
|
+
@requires : 'Admin'
|
|
98
|
+
action RotateAgentGrantToken(
|
|
99
|
+
@title: 'Grant Id' grantId : UUID
|
|
100
|
+
) returns RotatedGrant;
|
|
101
|
+
|
|
102
|
+
@title : 'Updated Grant'
|
|
103
|
+
type UpdatedGrant {
|
|
104
|
+
grantId : UUID;
|
|
105
|
+
updated : many String; // parameter names that were applied
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@title : 'Update Agent Grant'
|
|
109
|
+
@description: 'Change label, allow list, job kinds, daily budget or expiry of an active grant. An absent parameter stays as it is; an explicit null clears agentLabel, allowedJobKinds, maxJobsPerDay or validUntil. allowedActions cannot be emptied; the wallet binding is immutable (issue a new grant). Admin only. 404 unknown grant, 409 GRANT_REVOKED.'
|
|
110
|
+
@requires : 'Admin'
|
|
111
|
+
action UpdateAgentGrant(
|
|
112
|
+
@title: 'Grant Id' grantId : UUID,
|
|
113
|
+
@title: 'Agent Label' agentLabel : String(100),
|
|
114
|
+
@title: 'Allowed Actions' allowedActions : many String,
|
|
115
|
+
@title: 'Allowed Job Kinds' allowedJobKinds : many String,
|
|
116
|
+
@title: 'Max Jobs Per Day' maxJobsPerDay : Integer,
|
|
117
|
+
@title: 'Valid Until' validUntil : Timestamp
|
|
118
|
+
) returns UpdatedGrant;
|
|
119
|
+
|
|
120
|
+
@title : 'Grant Usage Call'
|
|
121
|
+
type GrantUsageCall {
|
|
122
|
+
service : String(60); // CardanoTransactionService, CardanoSignService, ...
|
|
123
|
+
action : String(100); // BuildSimpleAdaTransaction, SubmitTransaction, ...
|
|
124
|
+
count : Integer; // admitted and kept (budget charged and not refunded)
|
|
125
|
+
refunded : Integer; // admitted, then refunded because the handler refused the input
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@title : 'Grant Usage'
|
|
129
|
+
type GrantUsage {
|
|
130
|
+
grantId : UUID;
|
|
131
|
+
since : Timestamp;
|
|
132
|
+
until : Timestamp;
|
|
133
|
+
calls : many GrantUsageCall;
|
|
134
|
+
total : Integer;
|
|
135
|
+
jobsUsedToday : Integer;
|
|
136
|
+
maxJobsPerDay : Integer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@title : 'Get Grant Usage'
|
|
140
|
+
@description: 'Admitted calls under a grant between since (default until - 30 days) and until (default now), at most 366 days, per UTC day, grouped by service and action. An Admin sees any grant (revoked ones keep their history); a token sees only its own.'
|
|
141
|
+
function GetGrantUsage(
|
|
142
|
+
@title: 'Grant Id' grantId : UUID,
|
|
143
|
+
@title: 'Since' since : Timestamp,
|
|
144
|
+
@title: 'Until' until : Timestamp
|
|
145
|
+
) returns GrantUsage;
|
|
146
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const agent_grants_1 = require("./utils/agent-grants");
|
|
4
|
+
/**
|
|
5
|
+
* CardanoAgentService handlers. Grant administration and token self-service live in
|
|
6
|
+
* srv/utils/agent-grants.ts so the OData actions and the programmatic API share one path.
|
|
7
|
+
* The token enforcement hook is attached to all services from src/plugin.ts, not here.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = (srv) => {
|
|
10
|
+
(0, agent_grants_1.registerAgentGrantHandlers)(srv);
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=cardano-agent-service.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cardano Backend Service
|
|
3
|
+
*
|
|
4
|
+
* The data a CardanoBackend needs, for another ODATANO instance that uses this one as its
|
|
5
|
+
* backend (`backends: ["odatano"]`). Every operation answers the provider shape as a JSON
|
|
6
|
+
* string (`value`), so the caller maps it exactly like a Koios or Blockfrost answer.
|
|
7
|
+
* Stored blocks and transactions come from this instance's index; everything else goes
|
|
8
|
+
* through its own backends and crawled data, as the read service does. Nothing is persisted
|
|
9
|
+
* for the caller.
|
|
10
|
+
*/
|
|
11
|
+
@requires: 'authenticated-user'
|
|
12
|
+
service CardanoBackendService @(impl: './cardano-backend-service') {
|
|
13
|
+
|
|
14
|
+
// --- blocks and transactions -------------------------------------------------------------
|
|
15
|
+
action GetTransaction(hash: String) returns LargeString;
|
|
16
|
+
action GetTransactionsBatch(hashes: LargeString) returns LargeString;
|
|
17
|
+
action GetTransactionMetadata(hash: String) returns LargeString;
|
|
18
|
+
action GetBlock(hash: String) returns LargeString;
|
|
19
|
+
action GetBlockByHeight(height: Integer64) returns LargeString;
|
|
20
|
+
action GetNextBlocks(afterHash: String, count: Integer, afterHeight: Integer64) returns LargeString;
|
|
21
|
+
action GetBlockTransactions(blockHash: String) returns LargeString;
|
|
22
|
+
action GetLatestBlock() returns LargeString;
|
|
23
|
+
action GetCurrentSlot() returns LargeString;
|
|
24
|
+
action GetEpoch(epoch: Integer) returns LargeString;
|
|
25
|
+
action GetLatestEpoch() returns LargeString;
|
|
26
|
+
|
|
27
|
+
// --- addresses and UTxOs ------------------------------------------------------------------
|
|
28
|
+
action GetAddress(address: String) returns LargeString;
|
|
29
|
+
action GetAddressUtxos(address: String) returns LargeString;
|
|
30
|
+
action GetAddressTransactions(address: String, limit: Integer) returns LargeString;
|
|
31
|
+
action GetAddressTransactionHashes(address: String, limit: Integer) returns LargeString;
|
|
32
|
+
action GetCredentialUtxos(credential: String) returns LargeString;
|
|
33
|
+
action IsUtxoUnspent(txHash: String, outputIndex: Integer) returns LargeString;
|
|
34
|
+
action GetUnspentOutputs(refs: LargeString) returns LargeString;
|
|
35
|
+
|
|
36
|
+
// --- stake, governance, assets, network ------------------------------------------------
|
|
37
|
+
action GetAccount(stakeAddress: String) returns LargeString;
|
|
38
|
+
action GetPool(poolId: String) returns LargeString;
|
|
39
|
+
action GetPoolIds() returns LargeString;
|
|
40
|
+
action GetPools(ids: LargeString) returns LargeString;
|
|
41
|
+
action GetDrep(drepId: String) returns LargeString;
|
|
42
|
+
action GetDrepIds() returns LargeString;
|
|
43
|
+
action GetDreps(ids: LargeString) returns LargeString;
|
|
44
|
+
action GetAssetInfo(unit: String) returns LargeString;
|
|
45
|
+
action GetAssetHistory(unit: String, limit: Integer) returns LargeString;
|
|
46
|
+
action GetNetworkInformation() returns LargeString;
|
|
47
|
+
action GetProtocolParameters() returns LargeString;
|
|
48
|
+
|
|
49
|
+
// --- transactions in flight ------------------------------------------------------------
|
|
50
|
+
action EvaluateTransaction(cbor: LargeString) returns LargeString;
|
|
51
|
+
action SubmitTransaction(cbor: LargeString) returns LargeString;
|
|
52
|
+
}
|