@odatano/core 2.0.0-rc.23 → 2.0.0-rc.25
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/CardanoBackendService/index.d.ts +357 -0
- package/@cds-models/CardanoBackendService/index.js +40 -0
- package/@cds-models/CardanoIndexerService/index.d.ts +37 -0
- package/@cds-models/CardanoIndexerService/index.js +4 -0
- package/@cds-models/CardanoODataService/index.d.ts +27 -2
- package/@cds-models/CardanoODataService/index.js +3 -0
- package/@cds-models/CardanoSignService/index.d.ts +23 -1
- package/@cds-models/CardanoSignService/index.js +3 -0
- package/@cds-models/CardanoTransactionService/index.d.ts +34 -1
- package/@cds-models/CardanoTransactionService/index.js +4 -0
- package/@cds-models/index.d.ts +18 -0
- package/@cds-models/index.js +3 -0
- package/@cds-models/odatano/cardano/index.d.ts +49 -2
- package/@cds-models/odatano/cardano/index.js +6 -0
- package/db/schema.cds +74 -3
- package/db/types.cds +27 -0
- package/package.json +182 -181
- package/srv/blockchain/backends/blockfrost-backend.js +4 -2
- package/srv/blockchain/backends/cardano-backend.d.ts +0 -2
- package/srv/blockchain/backends/koios-backend.d.ts +1 -1
- package/srv/blockchain/backends/koios-backend.js +61 -14
- package/srv/blockchain/backends/odatano-backend.d.ts +64 -0
- package/srv/blockchain/backends/odatano-backend.js +166 -0
- package/srv/blockchain/backends/ogmios-backend.d.ts +12 -2
- package/srv/blockchain/backends/ogmios-backend.js +91 -21
- package/srv/blockchain/cardano-client.d.ts +23 -9
- package/srv/blockchain/cardano-client.js +77 -25
- package/srv/blockchain/cardano-indexer.d.ts +61 -15
- package/srv/blockchain/cardano-indexer.js +248 -79
- package/srv/blockchain/cardano-tx-builder.d.ts +11 -1
- package/srv/blockchain/cardano-tx-builder.js +59 -4
- package/srv/blockchain/crawler/certificate-backfill.d.ts +22 -0
- package/srv/blockchain/crawler/certificate-backfill.js +49 -30
- package/srv/blockchain/crawler/crawler.d.ts +3 -1
- package/srv/blockchain/crawler/crawler.js +12 -7
- package/srv/blockchain/crawler/sync-state.d.ts +3 -1
- package/srv/blockchain/crawler/sync-state.js +15 -2
- 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 +9 -0
- package/srv/blockchain/crawler/utxo-set-import.js +138 -47
- package/srv/blockchain/ledger-state.d.ts +16 -1
- package/srv/blockchain/ledger-state.js +38 -18
- package/srv/blockchain/pending-spends.d.ts +28 -0
- package/srv/blockchain/pending-spends.js +89 -0
- 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 +12 -3
- package/srv/blockchain/transaction-building/buildooor-tx.js +203 -21
- package/srv/blockchain/transaction-building/cardano-tx.d.ts +2 -1
- package/srv/blockchain/transaction-rows.d.ts +1 -1
- package/srv/blockchain/transaction-rows.js +2 -1
- package/srv/blockchain/wallet-worker/build-request.js +1 -1
- 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 -176
- package/srv/cardano-indexer-service.js +104 -10
- package/srv/cardano-service.cds +5 -0
- package/srv/cardano-tx-service.cds +39 -0
- package/srv/cardano-tx-service.js +88 -14
- package/srv/server.js +20 -2
- package/srv/utils/agent-grants.js +8 -0
- package/srv/utils/const.d.ts +5 -0
- package/srv/utils/const.js +6 -1
- package/srv/utils/error-codes.d.ts +2 -0
- package/srv/utils/error-codes.js +2 -0
- package/srv/utils/errors.d.ts +7 -0
- package/srv/utils/errors.js +11 -1
- package/srv/utils/mappers.d.ts +24 -2
- package/srv/utils/mappers.js +49 -0
- package/srv/utils/pg-inline-json.d.ts +8 -0
- package/srv/utils/pg-inline-json.js +63 -0
- package/srv/utils/tx-build-helper.d.ts +2 -0
- package/srv/utils/tx-build-helper.js +12 -0
- package/srv/utils/tx-request-parsers.d.ts +46 -5
- package/srv/utils/tx-request-parsers.js +227 -16
- package/srv/utils/types.d.ts +59 -0
- package/srv/utils/validators.d.ts +5 -1
- package/srv/utils/validators.js +19 -9
package/package.json
CHANGED
|
@@ -1,181 +1,182 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@odatano/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
4
|
-
"description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
|
|
5
|
-
"imports": {
|
|
6
|
-
"#cds-models/*": "./@cds-models/*/index.js"
|
|
7
|
-
},
|
|
8
|
-
"main": "src/index.js",
|
|
9
|
-
"types": "src/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"cds-plugin.js",
|
|
12
|
-
"src/**/*.js",
|
|
13
|
-
"src/**/*.d.ts",
|
|
14
|
-
"srv/**/*.js",
|
|
15
|
-
"srv/**/*.d.ts",
|
|
16
|
-
"srv/**/*.cds",
|
|
17
|
-
"db/**/*.cds",
|
|
18
|
-
"@cds-models/",
|
|
19
|
-
"scripts/migrate-txseq.mjs",
|
|
20
|
-
"scripts/migrate-slot-leader.mjs"
|
|
21
|
-
],
|
|
22
|
-
"engines": {
|
|
23
|
-
"node": ">=22.5"
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@sap/cds": ">=10"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@blockfrost/blockfrost-js": "~6.0.0",
|
|
30
|
-
"@cap-js/hana": "^3",
|
|
31
|
-
"@cardano-ogmios/client": "^7.0.0",
|
|
32
|
-
"@harmoniclabs/buildooor": "0.2.9",
|
|
33
|
-
"@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
|
|
34
|
-
"@harmoniclabs/cardano-ledger-ts": "^0.5.6",
|
|
35
|
-
"@harmoniclabs/cbor": "^2.0.1",
|
|
36
|
-
"@harmoniclabs/crypto": "^0.3.0",
|
|
37
|
-
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
38
|
-
"@odatano/cap-auth": "^0.1.0",
|
|
39
|
-
"@sap/xssec": "^4",
|
|
40
|
-
"axios": "^1.18.0",
|
|
41
|
-
"bech32": "^2.0.0",
|
|
42
|
-
"blake2b": "^2.1.4"
|
|
43
|
-
},
|
|
44
|
-
"optionalDependencies": {
|
|
45
|
-
"pkcs11js": "^2.1.6"
|
|
46
|
-
},
|
|
47
|
-
"overrides": {
|
|
48
|
-
"axios": "^1.18.0",
|
|
49
|
-
"esbuild": "0.28.1",
|
|
50
|
-
"form-data": "^4.0.6",
|
|
51
|
-
"fast-uri": "^3.1.7",
|
|
52
|
-
"ws": "7.5.11",
|
|
53
|
-
"@sap/approuter": {
|
|
54
|
-
"body-parser": "^2.2.3"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"@cap-js/cds-test": "^0.4.1",
|
|
59
|
-
"@cap-js/cds-typer": "^0.40.0",
|
|
60
|
-
"@cap-js/cds-types": "^0.18.0",
|
|
61
|
-
"@cap-js/postgres": "^3.1.1",
|
|
62
|
-
"@cap-js/sqlite": "^3",
|
|
63
|
-
"@sap/cds": "^10",
|
|
64
|
-
"@sap/cds-dk": "^10",
|
|
65
|
-
"@sap/eslint-plugin-cds": "^4.2.4",
|
|
66
|
-
"@types/blake2b": "^2.1.3",
|
|
67
|
-
"@types/node": "^22.19.7",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
69
|
-
"@typescript-eslint/parser": "^8.50.1",
|
|
70
|
-
"@vitest/coverage-v8": "^4.1.10",
|
|
71
|
-
"dotenv": "^16.3.1",
|
|
72
|
-
"eslint": "^9.39.2",
|
|
73
|
-
"nock": "^13.5.6",
|
|
74
|
-
"ts-node": "^10.9.2",
|
|
75
|
-
"tsx": "^4.21.0",
|
|
76
|
-
"typescript": "^5.9.3",
|
|
77
|
-
"vitest": "^4.1.10"
|
|
78
|
-
},
|
|
79
|
-
"cds": {
|
|
80
|
-
"typer": {
|
|
81
|
-
"ieee754compatible": true
|
|
82
|
-
},
|
|
83
|
-
"build": {
|
|
84
|
-
"tasks": [
|
|
85
|
-
{
|
|
86
|
-
"for": "node-cf",
|
|
87
|
-
"src": "srv",
|
|
88
|
-
"dest": "../gen/srv"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"for": "hana",
|
|
92
|
-
"src": "db",
|
|
93
|
-
"dest": "../gen/db"
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
"requires": {
|
|
98
|
-
"db": {
|
|
99
|
-
"kind": "sqlite",
|
|
100
|
-
"credentials": {
|
|
101
|
-
"url": "db.sqlite"
|
|
102
|
-
},
|
|
103
|
-
"client": {
|
|
104
|
-
"timeout": 5000
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"[production]": {
|
|
108
|
-
"db": {
|
|
109
|
-
"kind": "hana",
|
|
110
|
-
"pool": {
|
|
111
|
-
"acquireTimeoutMillis": 30000,
|
|
112
|
-
"min": 0,
|
|
113
|
-
"max": 10
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"auth": "xsuaa"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
"scripts": {
|
|
121
|
-
"clean": "node -e \"const fs=require('fs');fs.globSync('{srv,db,src}/**/*.{js,js.map,d.ts,d.ts.map}').filter(f=>!f.includes('node_modules')).forEach(f=>fs.unlinkSync(f));console.log('Clean complete')\"",
|
|
122
|
-
"clean:models": "node -e \"require('fs').rmSync('@cds-models',{recursive:true,force:true});console.log('Removed @cds-models')\"",
|
|
123
|
-
"build": "npm run cds:types && tsc",
|
|
124
|
-
"build:plugin": "npm run cds:types && tsc -p tsconfig.build.json",
|
|
125
|
-
"build:package": "npm run clean && npm run clean:models && npm run build:plugin",
|
|
126
|
-
"prepare": "npm run build:package",
|
|
127
|
-
"start": "cds-serve",
|
|
128
|
-
"cds:watch": "cds watch",
|
|
129
|
-
"cds:serve": "cds serve --with-mocks",
|
|
130
|
-
"cds:types": "cds-typer \"*\" --outputDirectory @cds-models",
|
|
131
|
-
"lint": "eslint .",
|
|
132
|
-
"typecheck": "tsc --noEmit",
|
|
133
|
-
"db:deploy": "cds deploy",
|
|
134
|
-
"pretest": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
135
|
-
"test": "vitest run",
|
|
136
|
-
"pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
137
|
-
"test:coverage": "vitest run --coverage",
|
|
138
|
-
"pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
139
|
-
"test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
|
|
140
|
-
"pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
141
|
-
"test:ci:coverage": "vitest run --coverage --exclude \"**/core-ogmios.test.ts\"",
|
|
142
|
-
"pretest:integration": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
143
|
-
"test:integration": "vitest run --project integration",
|
|
144
|
-
"test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
|
|
145
|
-
"test:integration:koios": "vitest run test/integration/core.koios.test.ts",
|
|
146
|
-
"test:integration:ogmios": "vitest run test/integration/core-ogmios.test.ts",
|
|
147
|
-
"test:integration:both": "npm run test:integration:blockfrost && npm run test:integration:koios",
|
|
148
|
-
"pretest:unit": "npm run cds:types",
|
|
149
|
-
"test:unit": "vitest run --project unit",
|
|
150
|
-
"watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
|
|
151
|
-
"watch-wallet": "cds watch --open wallet/webapp/index.html",
|
|
152
|
-
"release:check": "node scripts/release-check.mjs"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
"
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
"
|
|
176
|
-
"
|
|
177
|
-
"
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@odatano/core",
|
|
3
|
+
"version": "2.0.0-rc.25",
|
|
4
|
+
"description": "SAP CAP plugin for Cardano blockchain OData V4 integration",
|
|
5
|
+
"imports": {
|
|
6
|
+
"#cds-models/*": "./@cds-models/*/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"types": "src/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"cds-plugin.js",
|
|
12
|
+
"src/**/*.js",
|
|
13
|
+
"src/**/*.d.ts",
|
|
14
|
+
"srv/**/*.js",
|
|
15
|
+
"srv/**/*.d.ts",
|
|
16
|
+
"srv/**/*.cds",
|
|
17
|
+
"db/**/*.cds",
|
|
18
|
+
"@cds-models/",
|
|
19
|
+
"scripts/migrate-txseq.mjs",
|
|
20
|
+
"scripts/migrate-slot-leader.mjs"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22.5"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@sap/cds": ">=10"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@blockfrost/blockfrost-js": "~6.0.0",
|
|
30
|
+
"@cap-js/hana": "^3",
|
|
31
|
+
"@cardano-ogmios/client": "^7.0.0",
|
|
32
|
+
"@harmoniclabs/buildooor": "0.2.9",
|
|
33
|
+
"@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
|
|
34
|
+
"@harmoniclabs/cardano-ledger-ts": "^0.5.6",
|
|
35
|
+
"@harmoniclabs/cbor": "^2.0.1",
|
|
36
|
+
"@harmoniclabs/crypto": "^0.3.0",
|
|
37
|
+
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
38
|
+
"@odatano/cap-auth": "^0.1.0",
|
|
39
|
+
"@sap/xssec": "^4",
|
|
40
|
+
"axios": "^1.18.0",
|
|
41
|
+
"bech32": "^2.0.0",
|
|
42
|
+
"blake2b": "^2.1.4"
|
|
43
|
+
},
|
|
44
|
+
"optionalDependencies": {
|
|
45
|
+
"pkcs11js": "^2.1.6"
|
|
46
|
+
},
|
|
47
|
+
"overrides": {
|
|
48
|
+
"axios": "^1.18.0",
|
|
49
|
+
"esbuild": "0.28.1",
|
|
50
|
+
"form-data": "^4.0.6",
|
|
51
|
+
"fast-uri": "^3.1.7",
|
|
52
|
+
"ws": "7.5.11",
|
|
53
|
+
"@sap/approuter": {
|
|
54
|
+
"body-parser": "^2.2.3"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@cap-js/cds-test": "^0.4.1",
|
|
59
|
+
"@cap-js/cds-typer": "^0.40.0",
|
|
60
|
+
"@cap-js/cds-types": "^0.18.0",
|
|
61
|
+
"@cap-js/postgres": "^3.1.1",
|
|
62
|
+
"@cap-js/sqlite": "^3",
|
|
63
|
+
"@sap/cds": "^10",
|
|
64
|
+
"@sap/cds-dk": "^10",
|
|
65
|
+
"@sap/eslint-plugin-cds": "^4.2.4",
|
|
66
|
+
"@types/blake2b": "^2.1.3",
|
|
67
|
+
"@types/node": "^22.19.7",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
69
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
70
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
71
|
+
"dotenv": "^16.3.1",
|
|
72
|
+
"eslint": "^9.39.2",
|
|
73
|
+
"nock": "^13.5.6",
|
|
74
|
+
"ts-node": "^10.9.2",
|
|
75
|
+
"tsx": "^4.21.0",
|
|
76
|
+
"typescript": "^5.9.3",
|
|
77
|
+
"vitest": "^4.1.10"
|
|
78
|
+
},
|
|
79
|
+
"cds": {
|
|
80
|
+
"typer": {
|
|
81
|
+
"ieee754compatible": true
|
|
82
|
+
},
|
|
83
|
+
"build": {
|
|
84
|
+
"tasks": [
|
|
85
|
+
{
|
|
86
|
+
"for": "node-cf",
|
|
87
|
+
"src": "srv",
|
|
88
|
+
"dest": "../gen/srv"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"for": "hana",
|
|
92
|
+
"src": "db",
|
|
93
|
+
"dest": "../gen/db"
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"requires": {
|
|
98
|
+
"db": {
|
|
99
|
+
"kind": "sqlite",
|
|
100
|
+
"credentials": {
|
|
101
|
+
"url": "db.sqlite"
|
|
102
|
+
},
|
|
103
|
+
"client": {
|
|
104
|
+
"timeout": 5000
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"[production]": {
|
|
108
|
+
"db": {
|
|
109
|
+
"kind": "hana",
|
|
110
|
+
"pool": {
|
|
111
|
+
"acquireTimeoutMillis": 30000,
|
|
112
|
+
"min": 0,
|
|
113
|
+
"max": 10
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"auth": "xsuaa"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"scripts": {
|
|
121
|
+
"clean": "node -e \"const fs=require('fs');fs.globSync('{srv,db,src}/**/*.{js,js.map,d.ts,d.ts.map}').filter(f=>!f.includes('node_modules')).forEach(f=>fs.unlinkSync(f));console.log('Clean complete')\"",
|
|
122
|
+
"clean:models": "node -e \"require('fs').rmSync('@cds-models',{recursive:true,force:true});console.log('Removed @cds-models')\"",
|
|
123
|
+
"build": "npm run cds:types && tsc",
|
|
124
|
+
"build:plugin": "npm run cds:types && tsc -p tsconfig.build.json",
|
|
125
|
+
"build:package": "npm run clean && npm run clean:models && npm run build:plugin",
|
|
126
|
+
"prepare": "npm run build:package",
|
|
127
|
+
"start": "cds-serve",
|
|
128
|
+
"cds:watch": "cds watch",
|
|
129
|
+
"cds:serve": "cds serve --with-mocks",
|
|
130
|
+
"cds:types": "cds-typer \"*\" --outputDirectory @cds-models",
|
|
131
|
+
"lint": "eslint .",
|
|
132
|
+
"typecheck": "tsc --noEmit",
|
|
133
|
+
"db:deploy": "cds deploy",
|
|
134
|
+
"pretest": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
135
|
+
"test": "vitest run",
|
|
136
|
+
"pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
137
|
+
"test:coverage": "vitest run --coverage",
|
|
138
|
+
"pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
139
|
+
"test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
|
|
140
|
+
"pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
141
|
+
"test:ci:coverage": "vitest run --coverage --exclude \"**/core-ogmios.test.ts\"",
|
|
142
|
+
"pretest:integration": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
143
|
+
"test:integration": "vitest run --project integration",
|
|
144
|
+
"test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
|
|
145
|
+
"test:integration:koios": "vitest run test/integration/core.koios.test.ts",
|
|
146
|
+
"test:integration:ogmios": "vitest run test/integration/core-ogmios.test.ts",
|
|
147
|
+
"test:integration:both": "npm run test:integration:blockfrost && npm run test:integration:koios",
|
|
148
|
+
"pretest:unit": "npm run cds:types",
|
|
149
|
+
"test:unit": "vitest run --project unit",
|
|
150
|
+
"watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
|
|
151
|
+
"watch-wallet": "cds watch --open wallet/webapp/index.html",
|
|
152
|
+
"release:check": "node scripts/release-check.mjs",
|
|
153
|
+
"prepublishOnly": "node scripts/publish-guard.mjs"
|
|
154
|
+
},
|
|
155
|
+
"sapux": [
|
|
156
|
+
"app/odatano"
|
|
157
|
+
],
|
|
158
|
+
"directories": {
|
|
159
|
+
"doc": "docs",
|
|
160
|
+
"test": "test"
|
|
161
|
+
},
|
|
162
|
+
"repository": {
|
|
163
|
+
"type": "git",
|
|
164
|
+
"url": "git+https://github.com/ODATANO/ODATANO.git"
|
|
165
|
+
},
|
|
166
|
+
"keywords": [
|
|
167
|
+
"CAP",
|
|
168
|
+
"CDS",
|
|
169
|
+
"plugin",
|
|
170
|
+
"Cardano",
|
|
171
|
+
"blockchain",
|
|
172
|
+
"OData",
|
|
173
|
+
"SAP"
|
|
174
|
+
],
|
|
175
|
+
"author": "Maximilian Weber",
|
|
176
|
+
"license": "Apache-2.0",
|
|
177
|
+
"type": "commonjs",
|
|
178
|
+
"bugs": {
|
|
179
|
+
"url": "https://github.com/ODATANO/ODATANO/issues"
|
|
180
|
+
},
|
|
181
|
+
"homepage": "https://github.com/ODATANO/ODATANO#readme"
|
|
182
|
+
}
|
|
@@ -84,7 +84,8 @@ class BlockfrostBackend {
|
|
|
84
84
|
label: md.label,
|
|
85
85
|
json: md.json_metadata,
|
|
86
86
|
})) : undefined;
|
|
87
|
-
|
|
87
|
+
// ledger view: inputs in ledger order, only what the ledger applied (see ledgerView)
|
|
88
|
+
return (0, mappers_1.ledgerView)({
|
|
88
89
|
hash: tx.hash,
|
|
89
90
|
blockHash: tx.block,
|
|
90
91
|
blockHeight: tx.block_height,
|
|
@@ -97,6 +98,7 @@ class BlockfrostBackend {
|
|
|
97
98
|
// `spends === 'collaterals'` in Ogmios terms: the script phase failed, so the
|
|
98
99
|
// ledger applied neither the declared inputs/outputs nor the declared mint.
|
|
99
100
|
spendsCollaterals: tx.valid_contract === false,
|
|
101
|
+
// one mixed list in Blockfrost's order; ledgerView groups and sorts it
|
|
100
102
|
inputs: txUtxos.inputs.map(input => ({
|
|
101
103
|
address: input.address,
|
|
102
104
|
txHash: input.tx_hash,
|
|
@@ -119,7 +121,7 @@ class BlockfrostBackend {
|
|
|
119
121
|
referenceScriptHash: output.reference_script_hash,
|
|
120
122
|
})),
|
|
121
123
|
metadata: metadata,
|
|
122
|
-
};
|
|
124
|
+
});
|
|
123
125
|
}, this.name);
|
|
124
126
|
}
|
|
125
127
|
/** Metadata labels of a transaction (hash hex); NotFoundError when it has none. */
|
|
@@ -130,8 +130,6 @@ export interface LedgerStateBackend extends CardanoBackend {
|
|
|
130
130
|
txHash: string;
|
|
131
131
|
outputIndex: number;
|
|
132
132
|
}>): Promise<UTxO[]>;
|
|
133
|
-
/** Unspent outputs of several addresses at the tip. */
|
|
134
|
-
getUtxosByAddresses?(addresses: string[]): Promise<UTxO[]>;
|
|
135
133
|
}
|
|
136
134
|
export declare function isLedgerStateBackend(backend: CardanoBackend): backend is LedgerStateBackend;
|
|
137
135
|
/**
|
|
@@ -259,7 +259,7 @@ export declare class KoiosBackend implements CardanoBackend, PaginatingBackend,
|
|
|
259
259
|
* Accepts both the flattened ({tx_hash} per row) and the {tx_hashes:[...]} shape.
|
|
260
260
|
*/
|
|
261
261
|
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
262
|
-
/** Map a Koios /tx_info row to the normalized Transaction. */
|
|
262
|
+
/** Map a Koios /tx_info row to the normalized Transaction (ledger view, see ledgerView). */
|
|
263
263
|
private _mapKoiosTx;
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
@@ -46,6 +46,29 @@ function koiosRefScriptHash(ref) {
|
|
|
46
46
|
function sortAddressTxsDesc(rows) {
|
|
47
47
|
return [...rows].sort((a, b) => Number(b.block_height ?? b.block_time ?? 0) - Number(a.block_height ?? a.block_time ?? 0));
|
|
48
48
|
}
|
|
49
|
+
/** The `error` entries of a cardano-submit-api rejection, else the body as text. */
|
|
50
|
+
function nodeRejection(body) {
|
|
51
|
+
const errors = [];
|
|
52
|
+
const walk = (v) => {
|
|
53
|
+
if (!v || typeof v !== 'object')
|
|
54
|
+
return;
|
|
55
|
+
const o = v;
|
|
56
|
+
if (Array.isArray(o.error))
|
|
57
|
+
errors.push(...o.error.map(String));
|
|
58
|
+
else if (typeof o.error === 'string')
|
|
59
|
+
errors.push(o.error);
|
|
60
|
+
for (const child of Object.values(o))
|
|
61
|
+
walk(child);
|
|
62
|
+
};
|
|
63
|
+
walk(typeof body === 'string' ? (() => { try {
|
|
64
|
+
return JSON.parse(body);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
} })() : body);
|
|
69
|
+
const text = errors.length > 0 ? errors.join('; ') : (typeof body === 'string' ? body : JSON.stringify(body));
|
|
70
|
+
return text.slice(0, 1000);
|
|
71
|
+
}
|
|
49
72
|
/** CardanoBackend implementation on the Koios REST API (Axios). */
|
|
50
73
|
class KoiosBackend {
|
|
51
74
|
name = 'koios';
|
|
@@ -520,8 +543,9 @@ class KoiosBackend {
|
|
|
520
543
|
}
|
|
521
544
|
const policyId = unit.slice(0, 56);
|
|
522
545
|
const assetNameHex = unit.slice(56);
|
|
523
|
-
|
|
524
|
-
|
|
546
|
+
// GET only: Koios answers a POST to /asset_history with 404
|
|
547
|
+
const { data } = await this.api.get('/asset_history', {
|
|
548
|
+
params: { _asset_policy: policyId, _asset_name: assetNameHex },
|
|
525
549
|
});
|
|
526
550
|
if (!Array.isArray(data) || data.length === 0)
|
|
527
551
|
return [];
|
|
@@ -627,12 +651,27 @@ class KoiosBackend {
|
|
|
627
651
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
628
652
|
// Koios /submittx expects raw CBOR bytes with Content-Type: application/cbor
|
|
629
653
|
const cborBytes = Buffer.from(signedTxCbor, 'hex');
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
654
|
+
try {
|
|
655
|
+
const { data } = await this.api.post('/submittx', cborBytes, {
|
|
656
|
+
headers: { 'Content-Type': 'application/cbor' },
|
|
657
|
+
// Prevent axios from JSON-serializing the Buffer
|
|
658
|
+
transformRequest: [(d) => d],
|
|
659
|
+
});
|
|
660
|
+
return data.trim().replace(/^"|"$/g, '');
|
|
661
|
+
}
|
|
662
|
+
catch (err) {
|
|
663
|
+
// 400 carries the node's rejection (e.g. ExtraneousScriptWitnessesUTXOW); keep it
|
|
664
|
+
const response = err.response;
|
|
665
|
+
if (response?.status === 400 && response.data) {
|
|
666
|
+
const reason = nodeRejection(response.data);
|
|
667
|
+
// known kinds keep their class (already submitted = 409, script failure = 400)
|
|
668
|
+
const known = (0, errors_1.normalizeBackendError)(new Error(reason), this.name);
|
|
669
|
+
if (known.statusCode === 409 || known instanceof errors_1.ScriptValidationError)
|
|
670
|
+
throw known;
|
|
671
|
+
throw new errors_1.TransactionValidationError(`node rejected the transaction: ${reason}`, err);
|
|
672
|
+
}
|
|
673
|
+
throw err;
|
|
674
|
+
}
|
|
636
675
|
}, this.name);
|
|
637
676
|
}
|
|
638
677
|
/**
|
|
@@ -641,10 +680,17 @@ class KoiosBackend {
|
|
|
641
680
|
*/
|
|
642
681
|
async getProtocolParameters() {
|
|
643
682
|
return (0, backend_request_handler_1.handleBackendRequest)(async () => {
|
|
644
|
-
|
|
683
|
+
// /cli_protocol_params carries no epoch; the tip does. Without it the epoch stays 0.
|
|
684
|
+
const [{ data }, epoch] = await Promise.all([
|
|
685
|
+
this.api.get('/cli_protocol_params'),
|
|
686
|
+
this.api.get('/tip').then((r) => Number(r.data?.[0]?.epoch_no ?? 0), (err) => {
|
|
687
|
+
logger.warn(`Koios /tip failed, protocol parameters without epoch: ${err instanceof Error ? err.message : String(err)}`);
|
|
688
|
+
return 0;
|
|
689
|
+
}),
|
|
690
|
+
]);
|
|
645
691
|
return {
|
|
646
692
|
network: this.network,
|
|
647
|
-
epoch
|
|
693
|
+
epoch,
|
|
648
694
|
// --- Fees / Sizes ---
|
|
649
695
|
minFeeA: data.txFeePerByte,
|
|
650
696
|
minFeeB: data.txFeeFixed,
|
|
@@ -989,7 +1035,7 @@ class KoiosBackend {
|
|
|
989
1035
|
//-----------------------------------------------------------------------------
|
|
990
1036
|
// Private Helpers
|
|
991
1037
|
//-----------------------------------------------------------------------------
|
|
992
|
-
/** Map a Koios /tx_info row to the normalized Transaction. */
|
|
1038
|
+
/** Map a Koios /tx_info row to the normalized Transaction (ledger view, see ledgerView). */
|
|
993
1039
|
_mapKoiosTx(tx) {
|
|
994
1040
|
let labels = [];
|
|
995
1041
|
if (tx.metadata) {
|
|
@@ -999,7 +1045,7 @@ class KoiosBackend {
|
|
|
999
1045
|
json: json,
|
|
1000
1046
|
}));
|
|
1001
1047
|
}
|
|
1002
|
-
return {
|
|
1048
|
+
return (0, mappers_1.ledgerView)({
|
|
1003
1049
|
hash: tx.tx_hash,
|
|
1004
1050
|
blockHash: tx.block_hash,
|
|
1005
1051
|
blockHeight: Number(tx.block_height),
|
|
@@ -1023,6 +1069,7 @@ class KoiosBackend {
|
|
|
1023
1069
|
// Phase-2 validity as db-sync records it; undefined on a Koios without the field, so the
|
|
1024
1070
|
// indexer keeps treating such a source as "no phase-2 information".
|
|
1025
1071
|
spendsCollaterals: typeof tx.valid_contract === 'boolean' ? tx.valid_contract === false : undefined,
|
|
1072
|
+
// Koios lists inputs in its own order; ledgerView sorts them like the ledger
|
|
1026
1073
|
inputs: [
|
|
1027
1074
|
...asKoiosList(tx.inputs).map((input) => mapKoiosInput(input)),
|
|
1028
1075
|
...asKoiosList(tx.collateral_inputs).map((input) => mapKoiosInput(input, { isCollateral: true })),
|
|
@@ -1030,7 +1077,7 @@ class KoiosBackend {
|
|
|
1030
1077
|
],
|
|
1031
1078
|
outputs: [
|
|
1032
1079
|
...asKoiosList(tx.outputs).map((output) => mapKoiosOutput(tx.tx_hash, output, false)),
|
|
1033
|
-
// CIP-40 collateral return: produced only when the script phase failed
|
|
1080
|
+
// CIP-40 collateral return: produced only when the script phase failed (ledgerView keeps it then)
|
|
1034
1081
|
...asKoiosList(tx.collateral_output).map((output) => mapKoiosOutput(tx.tx_hash, output, true)),
|
|
1035
1082
|
],
|
|
1036
1083
|
metadata: labels,
|
|
@@ -1042,7 +1089,7 @@ class KoiosBackend {
|
|
|
1042
1089
|
.filter((w) => !!w.stake_addr)
|
|
1043
1090
|
.map((w) => ({ stakeAddress: String(w.stake_addr), amount: String(w.amount ?? '0') }))
|
|
1044
1091
|
: undefined,
|
|
1045
|
-
};
|
|
1092
|
+
});
|
|
1046
1093
|
}
|
|
1047
1094
|
}
|
|
1048
1095
|
exports.KoiosBackend = KoiosBackend;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CardanoBackend, EvaluatingBackend, PaginatingBackend, EnumeratingBackend } from './cardano-backend';
|
|
2
|
+
import type { Transaction, Address, UTxO, NetworkInformation, EpochData, MetadataLabelTx, BlockData, PoolData, DrepData, AccountData, AssetInfo, AssetHistoryEntry, LedgerProtocolParameters, ScriptEvaluationResult } from '../../utils/types';
|
|
3
|
+
import { Network } from '../cardano-client';
|
|
4
|
+
/** Public ODATANO API per network (ACCESS gateway); mainnet has no default and needs `odatanoUrl`. */
|
|
5
|
+
export declare const ODATANO_API_URLS: Partial<Record<Network, string>>;
|
|
6
|
+
/**
|
|
7
|
+
* Backend over another ODATANO instance (typically the hosted API behind the ACCESS gateway),
|
|
8
|
+
* speaking its `CardanoBackendService`. Answers arrive in the provider shape, so everything above
|
|
9
|
+
* this class treats it like Koios. The key goes as `Authorization: Bearer`.
|
|
10
|
+
*/
|
|
11
|
+
export declare class OdatanoBackend implements CardanoBackend, EvaluatingBackend, PaginatingBackend, EnumeratingBackend {
|
|
12
|
+
readonly name = "odatano";
|
|
13
|
+
private readonly api;
|
|
14
|
+
/** Units left on the key, from the gateway's `x-access-units-left` header; null when not reported. */
|
|
15
|
+
unitsLeft: number | null;
|
|
16
|
+
constructor(network: Network, timeoutMs: number, url: string | undefined, apiKey: string | undefined);
|
|
17
|
+
/** Probe the remote instance with its cheapest call. */
|
|
18
|
+
init(): Promise<boolean>;
|
|
19
|
+
getTransaction(txHash: string): Promise<Transaction>;
|
|
20
|
+
getAddress(address: string): Promise<Address>;
|
|
21
|
+
getAddressUtxos(address: string): Promise<UTxO[]>;
|
|
22
|
+
getAddressTransactions(address: string, limit: number): Promise<Transaction[]>;
|
|
23
|
+
getAddressTransactionHashes(address: string, limit: number): Promise<string[]>;
|
|
24
|
+
getTransactionsBatch(txHashes: string[]): Promise<Map<string, Transaction>>;
|
|
25
|
+
getCredentialUtxos(credHash: string): Promise<UTxO[]>;
|
|
26
|
+
/** Unspent outputs among `refs`, from the remote's node (with reference-script bytes). */
|
|
27
|
+
getUnspentOutputs(refs: Array<{
|
|
28
|
+
txHash: string;
|
|
29
|
+
outputIndex: number;
|
|
30
|
+
}>): Promise<UTxO[]>;
|
|
31
|
+
getNetworkInformation(): Promise<NetworkInformation>;
|
|
32
|
+
getTransactionMetadata(txHash: string): Promise<MetadataLabelTx[]>;
|
|
33
|
+
getBlock(blockHash: string): Promise<BlockData>;
|
|
34
|
+
getEpoch(epochNumber: number): Promise<EpochData>;
|
|
35
|
+
getLatestEpoch(): Promise<EpochData>;
|
|
36
|
+
getLatestBlock(): Promise<BlockData>;
|
|
37
|
+
getCurrentSlot(): Promise<number>;
|
|
38
|
+
isUtxoUnspent(txHash: string, outputIndex: number): Promise<boolean>;
|
|
39
|
+
getPool(poolId: string): Promise<PoolData>;
|
|
40
|
+
getDrep(drepId: string): Promise<DrepData>;
|
|
41
|
+
getAccount(stakeAddress: string): Promise<AccountData>;
|
|
42
|
+
getAssetInfo(unit: string): Promise<AssetInfo>;
|
|
43
|
+
getAssetHistory(unit: string, limit?: number): Promise<AssetHistoryEntry[]>;
|
|
44
|
+
getProtocolParameters(): Promise<LedgerProtocolParameters>;
|
|
45
|
+
submitTransaction(signedTxCbor: string): Promise<string>;
|
|
46
|
+
evaluateTransaction(unsignedTxCbor: string): Promise<ScriptEvaluationResult[]>;
|
|
47
|
+
getBlockByHeight(height: number): Promise<BlockData>;
|
|
48
|
+
getNextBlocks(afterHash: string, count: number, afterHeight?: number): Promise<BlockData[]>;
|
|
49
|
+
getBlockTransactions(blockHash: string): Promise<Transaction[]>;
|
|
50
|
+
getPoolIds(): Promise<string[]>;
|
|
51
|
+
getPools(poolIds: string[]): Promise<PoolData[]>;
|
|
52
|
+
getDrepIds(): Promise<string[]>;
|
|
53
|
+
getDreps(drepIds: string[]): Promise<DrepData[]>;
|
|
54
|
+
shutdown(): Promise<void>;
|
|
55
|
+
private batched;
|
|
56
|
+
/**
|
|
57
|
+
* POST one operation, parse the JSON string it answers (safeJSON keeps big integers) and map
|
|
58
|
+
* HTTP failures to the backend error classes. The remote message is kept verbatim, so markers
|
|
59
|
+
* such as `CHAIN_POINT_MISMATCH:` reach the crawler unchanged.
|
|
60
|
+
*/
|
|
61
|
+
private call;
|
|
62
|
+
private mapError;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=odatano-backend.d.ts.map
|