@odatano/core 2.0.0-rc.37 → 2.0.0-rc.39
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/db/schema.cds +2297 -2297
- package/package.json +2 -2
- package/srv/blockchain/backends/blockfrost-backend.js +2 -1
- package/srv/blockchain/backends/ogmios-backend.js +6 -3
- package/srv/blockchain/cardano-client.d.ts +8 -1
- package/srv/blockchain/cardano-client.js +19 -9
- package/srv/blockchain/cardano-tx-builder.d.ts +2 -1
- package/srv/blockchain/cardano-tx-builder.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odatano/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.39",
|
|
4
4
|
"description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#cds-models/*": "./@cds-models/*/index.js"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@sap/cds": ">=10"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@blockfrost/blockfrost-js": "~6.
|
|
29
|
+
"@blockfrost/blockfrost-js": "~6.2.0",
|
|
30
30
|
"@cap-js/hana": "^3",
|
|
31
31
|
"@cardano-ogmios/client": "^7.0.0",
|
|
32
32
|
"@harmoniclabs/buildooor": "0.2.9",
|
|
@@ -323,7 +323,8 @@ class BlockfrostBackend {
|
|
|
323
323
|
}
|
|
324
324
|
return {
|
|
325
325
|
stakeaddress: accountData.stake_address,
|
|
326
|
-
active
|
|
326
|
+
// `active` is the delegation state; registration lives in `registered`
|
|
327
|
+
active: accountData.registered,
|
|
327
328
|
activeEpoch: accountData.active_epoch ?? 0,
|
|
328
329
|
controlledAmount: accountData.controlled_amount,
|
|
329
330
|
rewardsSum: accountData.rewards_sum,
|
|
@@ -679,19 +679,22 @@ class OgmiosBackend {
|
|
|
679
679
|
async getAccount(stakeAddress) {
|
|
680
680
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
681
681
|
await this.ensureConnected();
|
|
682
|
-
|
|
682
|
+
// Ogmios keeps key-hash and script-hash credentials in separate lists. A script stake address
|
|
683
|
+
// asked under `keys` is never found.
|
|
684
|
+
const rawResult = await this.stateQueryClient.rewardAccountSummaries((0, mappers_1.decodeShelleyAddress)(stakeAddress).isScript ? { scripts: [stakeAddress] } : { keys: [stakeAddress] });
|
|
683
685
|
// Ogmios returns a record keyed by stake address; normalize to array
|
|
684
686
|
const summaries = Array.isArray(rawResult)
|
|
685
687
|
? rawResult
|
|
686
688
|
: Object.values(rawResult);
|
|
687
689
|
const account = summaries && summaries.length > 0 ? summaries[0] : null;
|
|
690
|
+
// The summary lists only credentials delegated to a pool or a DRep. A registered credential without
|
|
691
|
+
// delegation is absent here, so "not found" does not mean "not registered".
|
|
688
692
|
if (!account) {
|
|
689
693
|
throw new errors_1.NotFoundError('Account', this.name);
|
|
690
694
|
}
|
|
691
695
|
return {
|
|
692
696
|
stakeaddress: stakeAddress,
|
|
693
|
-
//
|
|
694
|
-
// reaching this point (summary found) therefore implies the account is active.
|
|
697
|
+
// a summary exists only for a registered credential
|
|
695
698
|
active: true,
|
|
696
699
|
activeEpoch: 0,
|
|
697
700
|
// reward-account summaries carry no controlled amount and no withdrawal totals
|
|
@@ -112,7 +112,14 @@ export declare class CardanoClient {
|
|
|
112
112
|
* Whether the reward account is registered in the ledger. Node first; the first backend that
|
|
113
113
|
* answers decides, its "not found" means not registered. Only a backend failure falls through.
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Whether the stake credential is registered. The node's reward-account summary proves it, but
|
|
117
|
+
* the summary lists only credentials delegated to a pool or a DRep, so its absence proves nothing and the
|
|
118
|
+
* providers answer from the certificate history; one that knows the account decides, one that
|
|
119
|
+
* knows no such account means not registered. `null`: nobody could tell (no summary on the
|
|
120
|
+
* node, no provider configured or reachable).
|
|
121
|
+
*/
|
|
122
|
+
isRewardAccountRegistered(stakeAddress: string): Promise<boolean | null>;
|
|
116
123
|
/** Asset info (supply, mint history, CIP-25/CIP-26 metadata); Blockfrost and Koios only. */
|
|
117
124
|
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
118
125
|
/**
|
|
@@ -362,17 +362,27 @@ class CardanoClient {
|
|
|
362
362
|
* Whether the reward account is registered in the ledger. Node first; the first backend that
|
|
363
363
|
* answers decides, its "not found" means not registered. Only a backend failure falls through.
|
|
364
364
|
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Whether the stake credential is registered. The node's reward-account summary proves it, but
|
|
367
|
+
* the summary lists only credentials delegated to a pool or a DRep, so its absence proves nothing and the
|
|
368
|
+
* providers answer from the certificate history; one that knows the account decides, one that
|
|
369
|
+
* knows no such account means not registered. `null`: nobody could tell (no summary on the
|
|
370
|
+
* node, no provider configured or reachable).
|
|
371
|
+
*/
|
|
372
|
+
async isRewardAccountRegistered(stakeAddress) {
|
|
373
|
+
try {
|
|
374
|
+
return await this.executeWithPriority(async (b) => (await b.getAccount(stakeAddress)).active, true, 'getAccount');
|
|
375
|
+
}
|
|
376
|
+
catch (err) {
|
|
377
|
+
if (err instanceof errors_1.AllBackendsFailedError) {
|
|
378
|
+
const providers = err.errors.filter(e => e.backendName !== this.liveBackend?.name);
|
|
379
|
+
if (providers.some(e => e.statusCode === 404))
|
|
372
380
|
return false;
|
|
373
|
-
|
|
381
|
+
if (err.errors.length > 0 && err.errors.every(e => e.statusCode === 404))
|
|
382
|
+
return null;
|
|
374
383
|
}
|
|
375
|
-
|
|
384
|
+
throw err;
|
|
385
|
+
}
|
|
376
386
|
}
|
|
377
387
|
/** Asset info (supply, mint history, CIP-25/CIP-26 metadata); Blockfrost and Koios only. */
|
|
378
388
|
getAssetInfo(unit) {
|
|
@@ -39,7 +39,8 @@ export declare class CardanoTransactionBuilder {
|
|
|
39
39
|
buildPlutusTransaction(req: TxBuildPlutusRequest, protocolParameters: LedgerProtocolParameter): Promise<TxBuildResult>;
|
|
40
40
|
/**
|
|
41
41
|
* The ledger rejects a withdrawal from an unregistered reward account (also a zero one), so the
|
|
42
|
-
* build fails here with the account named. A provider failure is passed on as it is.
|
|
42
|
+
* build fails here with the account named. A provider failure is passed on as it is. When no
|
|
43
|
+
* backend can tell, the build goes on and the node decides at submit.
|
|
43
44
|
*/
|
|
44
45
|
private _assertRewardAccountsRegistered;
|
|
45
46
|
/**
|
|
@@ -210,15 +210,20 @@ class CardanoTransactionBuilder {
|
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
212
|
* The ledger rejects a withdrawal from an unregistered reward account (also a zero one), so the
|
|
213
|
-
* build fails here with the account named. A provider failure is passed on as it is.
|
|
213
|
+
* build fails here with the account named. A provider failure is passed on as it is. When no
|
|
214
|
+
* backend can tell, the build goes on and the node decides at submit.
|
|
214
215
|
*/
|
|
215
216
|
async _assertRewardAccountsRegistered(withdrawals, registeredHere = new Set()) {
|
|
216
217
|
for (const [i, w] of withdrawals.entries()) {
|
|
217
218
|
if (registeredHere.has(w.rewardAddress.toLowerCase()))
|
|
218
219
|
continue;
|
|
219
|
-
|
|
220
|
+
const registered = await this.client.isRewardAccountRegistered(w.rewardAddress);
|
|
221
|
+
if (registered === false) {
|
|
220
222
|
throw new errors_1.TransactionValidationError(`withdrawals[${i}] reward account ${w.rewardAddress} is not registered on chain; register the stake credential first`);
|
|
221
223
|
}
|
|
224
|
+
if (registered === null) {
|
|
225
|
+
logger.warn(`withdrawals[${i}] reward account ${w.rewardAddress}: registration not verifiable (the node lists delegated accounts only, no provider answered); the node checks it at submit`);
|
|
226
|
+
}
|
|
222
227
|
}
|
|
223
228
|
}
|
|
224
229
|
/**
|