@odatano/core 2.0.0-rc.3 → 2.0.0-rc.4
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/CardanoTransactionService/index.d.ts +9 -9
- package/package.json +173 -173
- package/srv/blockchain/transaction-building/buildooor-tx.d.ts +20 -0
- package/srv/blockchain/transaction-building/buildooor-tx.js +104 -20
- package/srv/blockchain/wallet-worker/build-request.js +35 -6
- package/srv/cardano-tx-service.cds +32 -26
- package/srv/cardano-tx-service.js +96 -38
- package/srv/utils/tx-request-parsers.d.ts +13 -0
- package/srv/utils/tx-request-parsers.js +32 -0
- package/srv/utils/types.d.ts +15 -0
|
@@ -196,17 +196,17 @@ export declare function _TransactionSubmissionAspect<TBase extends new (...args:
|
|
|
196
196
|
};
|
|
197
197
|
/**
|
|
198
198
|
* TransactionSubmissions status flow:
|
|
199
|
-
* pending
|
|
200
|
-
* submitted
|
|
201
|
-
* pending | submitted
|
|
199
|
+
* pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
|
|
200
|
+
* submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
|
|
201
|
+
* pending | submitted -> failed (blockchain error)
|
|
202
202
|
*/
|
|
203
203
|
export class TransactionSubmission extends _TransactionSubmissionAspect(__.Entity) {
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* TransactionSubmissions status flow:
|
|
207
|
-
* pending
|
|
208
|
-
* submitted
|
|
209
|
-
* pending | submitted
|
|
207
|
+
* pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
|
|
208
|
+
* submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
|
|
209
|
+
* pending | submitted -> failed (blockchain error)
|
|
210
210
|
*/
|
|
211
211
|
export class TransactionSubmissions extends Array<TransactionSubmission> {
|
|
212
212
|
$count?: number
|
|
@@ -420,11 +420,11 @@ export declare const BuildMultiAssetTransaction: {
|
|
|
420
420
|
|
|
421
421
|
export declare const BuildMintTransaction: {
|
|
422
422
|
// positional
|
|
423
|
-
(senderAddress: _.Bech32 | null, recipientAddress: _.Bech32 | null, lovelaceAmount: _.Lovelace | null, mintActionsJson: string | null, mintingPolicyScript: string | null, changeAddress: _.Bech32 | null, requiredSignersJson: string | null, scriptParamsJson: string | null, inlineDatumJson: string | null, mintRedeemerJson: string | null, lockOnScript: boolean | null, forceInputsJson: string | null, referenceInputsJson: string | null, metadataJson: string | null, referenceScriptHex: string | null, validityStartMs: string | null, validityEndMs: string | null): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
423
|
+
(senderAddress: _.Bech32 | null, recipientAddress: _.Bech32 | null, lovelaceAmount: _.Lovelace | null, mintActionsJson: string | null, mintingPolicyScript: string | null, changeAddress: _.Bech32 | null, requiredSignersJson: string | null, scriptParamsJson: string | null, inlineDatumJson: string | null, mintRedeemerJson: string | null, lockOnScript: boolean | null, forceInputsJson: string | null, referenceInputsJson: string | null, extraOutputsJson: string | null, metadataJson: string | null, referenceScriptHex: string | null, validityStartMs: string | null, validityEndMs: string | null): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
424
424
|
// named
|
|
425
|
-
({senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, changeAddress, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, metadataJson, referenceScriptHex, validityStartMs, validityEndMs}: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
425
|
+
({senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, changeAddress, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, extraOutputsJson, metadataJson, referenceScriptHex, validityStartMs, validityEndMs}: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, extraOutputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}): globalThis.Promise<TransactionBuild | null> | TransactionBuild | null
|
|
426
426
|
// metadata (do not use)
|
|
427
|
-
__parameters: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}, __returns: globalThis.Promise<TransactionBuild | null> | TransactionBuild | null, __self: never
|
|
427
|
+
__parameters: {senderAddress?: _.Bech32 | null, recipientAddress?: _.Bech32 | null, lovelaceAmount?: _.Lovelace | null, mintActionsJson?: string | null, mintingPolicyScript?: string | null, changeAddress?: _.Bech32 | null, requiredSignersJson?: string | null, scriptParamsJson?: string | null, inlineDatumJson?: string | null, mintRedeemerJson?: string | null, lockOnScript?: boolean | null, forceInputsJson?: string | null, referenceInputsJson?: string | null, extraOutputsJson?: string | null, metadataJson?: string | null, referenceScriptHex?: string | null, validityStartMs?: string | null, validityEndMs?: string | null}, __returns: globalThis.Promise<TransactionBuild | null> | TransactionBuild | null, __self: never
|
|
428
428
|
kind: 'action'
|
|
429
429
|
}
|
|
430
430
|
|
package/package.json
CHANGED
|
@@ -1,173 +1,173 @@
|
|
|
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
|
-
],
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=22.5"
|
|
22
|
-
},
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"@sap/cds": ">=10"
|
|
25
|
-
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@blockfrost/blockfrost-js": "~6.0.0",
|
|
28
|
-
"@cap-js/hana": "^3",
|
|
29
|
-
"@cardano-ogmios/client": "^6.14.0",
|
|
30
|
-
"@harmoniclabs/buildooor": "0.2.9",
|
|
31
|
-
"@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
|
|
32
|
-
"@harmoniclabs/cardano-ledger-ts": "^0.5.6",
|
|
33
|
-
"@harmoniclabs/cbor": "^2.0.1",
|
|
34
|
-
"@harmoniclabs/crypto": "^0.3.0",
|
|
35
|
-
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
36
|
-
"@sap/xssec": "^4",
|
|
37
|
-
"axios": "^1.18.0",
|
|
38
|
-
"bech32": "^2.0.0",
|
|
39
|
-
"blake2b": "^2.1.4"
|
|
40
|
-
},
|
|
41
|
-
"optionalDependencies": {
|
|
42
|
-
"pkcs11js": "^2.1.6"
|
|
43
|
-
},
|
|
44
|
-
"overrides": {
|
|
45
|
-
"axios": "^1.18.0",
|
|
46
|
-
"esbuild": "0.28.1",
|
|
47
|
-
"form-data": "^4.0.6",
|
|
48
|
-
"fast-uri": "^3.1.5",
|
|
49
|
-
"ws": "7.5.11",
|
|
50
|
-
"@sap/approuter": {
|
|
51
|
-
"body-parser": "^2.2.3"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@cap-js/cds-test": "^0.4.1",
|
|
56
|
-
"@cap-js/cds-typer": "^0.40.0",
|
|
57
|
-
"@cap-js/cds-types": "^0.18.0",
|
|
58
|
-
"@cap-js/sqlite": "^3",
|
|
59
|
-
"@sap/cds": "^10",
|
|
60
|
-
"@sap/cds-dk": "^10",
|
|
61
|
-
"@sap/eslint-plugin-cds": "^4.2.4",
|
|
62
|
-
"@types/blake2b": "^2.1.3",
|
|
63
|
-
"@types/node": "^22.19.7",
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
65
|
-
"@typescript-eslint/parser": "^8.50.1",
|
|
66
|
-
"@vitest/coverage-v8": "^4.1.10",
|
|
67
|
-
"dotenv": "^16.3.1",
|
|
68
|
-
"eslint": "^9.39.2",
|
|
69
|
-
"nock": "^13.5.6",
|
|
70
|
-
"ts-node": "^10.9.2",
|
|
71
|
-
"tsx": "^4.21.0",
|
|
72
|
-
"typescript": "^5.9.3",
|
|
73
|
-
"vitest": "^4.1.10"
|
|
74
|
-
},
|
|
75
|
-
"cds": {
|
|
76
|
-
"typer": {
|
|
77
|
-
"ieee754compatible": true
|
|
78
|
-
},
|
|
79
|
-
"build": {
|
|
80
|
-
"tasks": [
|
|
81
|
-
{
|
|
82
|
-
"for": "node-cf",
|
|
83
|
-
"src": "srv",
|
|
84
|
-
"dest": "../gen/srv"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"for": "hana",
|
|
88
|
-
"src": "db",
|
|
89
|
-
"dest": "../gen/db"
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
},
|
|
93
|
-
"requires": {
|
|
94
|
-
"db": {
|
|
95
|
-
"kind": "sqlite",
|
|
96
|
-
"credentials": {
|
|
97
|
-
"url": "db.sqlite"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"[production]": {
|
|
101
|
-
"db": {
|
|
102
|
-
"kind": "hana",
|
|
103
|
-
"pool": {
|
|
104
|
-
"acquireTimeoutMillis": 30000,
|
|
105
|
-
"min": 0,
|
|
106
|
-
"max": 10
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
"auth": "xsuaa"
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
"scripts": {
|
|
114
|
-
"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')\"",
|
|
115
|
-
"clean:models": "node -e \"require('fs').rmSync('@cds-models',{recursive:true,force:true});console.log('Removed @cds-models')\"",
|
|
116
|
-
"build": "npm run cds:types && tsc",
|
|
117
|
-
"build:plugin": "npm run cds:types && tsc -p tsconfig.build.json",
|
|
118
|
-
"build:package": "npm run clean && npm run clean:models && npm run build:plugin",
|
|
119
|
-
"prepare": "npm run build:package",
|
|
120
|
-
"start": "cds-serve",
|
|
121
|
-
"cds:watch": "cds watch",
|
|
122
|
-
"cds:serve": "cds serve --with-mocks",
|
|
123
|
-
"cds:types": "cds-typer \"*\" --outputDirectory @cds-models",
|
|
124
|
-
"lint": "eslint .",
|
|
125
|
-
"typecheck": "tsc --noEmit",
|
|
126
|
-
"db:deploy": "cds deploy",
|
|
127
|
-
"pretest": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
128
|
-
"test": "vitest run",
|
|
129
|
-
"pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
130
|
-
"test:coverage": "vitest run --coverage",
|
|
131
|
-
"pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
132
|
-
"test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
|
|
133
|
-
"pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
134
|
-
"test:ci:coverage": "vitest run --coverage --exclude \"**/core-ogmios.test.ts\"",
|
|
135
|
-
"pretest:integration": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
136
|
-
"test:integration": "vitest run --project integration",
|
|
137
|
-
"test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
|
|
138
|
-
"test:integration:koios": "vitest run test/integration/core.koios.test.ts",
|
|
139
|
-
"test:integration:ogmios": "vitest run test/integration/core-ogmios.test.ts",
|
|
140
|
-
"test:integration:both": "npm run test:integration:blockfrost && npm run test:integration:koios",
|
|
141
|
-
"pretest:unit": "npm run cds:types",
|
|
142
|
-
"test:unit": "vitest run --project unit",
|
|
143
|
-
"watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
|
|
144
|
-
"watch-wallet": "cds watch --open wallet/webapp/index.html"
|
|
145
|
-
},
|
|
146
|
-
"sapux": [
|
|
147
|
-
"app/odatano"
|
|
148
|
-
],
|
|
149
|
-
"directories": {
|
|
150
|
-
"doc": "docs",
|
|
151
|
-
"test": "test"
|
|
152
|
-
},
|
|
153
|
-
"repository": {
|
|
154
|
-
"type": "git",
|
|
155
|
-
"url": "git+https://github.com/ODATANO/ODATANO.git"
|
|
156
|
-
},
|
|
157
|
-
"keywords": [
|
|
158
|
-
"CAP",
|
|
159
|
-
"CDS",
|
|
160
|
-
"plugin",
|
|
161
|
-
"Cardano",
|
|
162
|
-
"blockchain",
|
|
163
|
-
"OData",
|
|
164
|
-
"SAP"
|
|
165
|
-
],
|
|
166
|
-
"author": "Maximilian Weber",
|
|
167
|
-
"license": "Apache-2.0",
|
|
168
|
-
"type": "commonjs",
|
|
169
|
-
"bugs": {
|
|
170
|
-
"url": "https://github.com/ODATANO/ODATANO/issues"
|
|
171
|
-
},
|
|
172
|
-
"homepage": "https://github.com/ODATANO/ODATANO#readme"
|
|
173
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@odatano/core",
|
|
3
|
+
"version": "2.0.0-rc.4",
|
|
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
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=22.5"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@sap/cds": ">=10"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@blockfrost/blockfrost-js": "~6.0.0",
|
|
28
|
+
"@cap-js/hana": "^3",
|
|
29
|
+
"@cardano-ogmios/client": "^6.14.0",
|
|
30
|
+
"@harmoniclabs/buildooor": "0.2.9",
|
|
31
|
+
"@harmoniclabs/cardano-costmodels-ts": "~1.6.1",
|
|
32
|
+
"@harmoniclabs/cardano-ledger-ts": "^0.5.6",
|
|
33
|
+
"@harmoniclabs/cbor": "^2.0.1",
|
|
34
|
+
"@harmoniclabs/crypto": "^0.3.0",
|
|
35
|
+
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
36
|
+
"@sap/xssec": "^4",
|
|
37
|
+
"axios": "^1.18.0",
|
|
38
|
+
"bech32": "^2.0.0",
|
|
39
|
+
"blake2b": "^2.1.4"
|
|
40
|
+
},
|
|
41
|
+
"optionalDependencies": {
|
|
42
|
+
"pkcs11js": "^2.1.6"
|
|
43
|
+
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"axios": "^1.18.0",
|
|
46
|
+
"esbuild": "0.28.1",
|
|
47
|
+
"form-data": "^4.0.6",
|
|
48
|
+
"fast-uri": "^3.1.5",
|
|
49
|
+
"ws": "7.5.11",
|
|
50
|
+
"@sap/approuter": {
|
|
51
|
+
"body-parser": "^2.2.3"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@cap-js/cds-test": "^0.4.1",
|
|
56
|
+
"@cap-js/cds-typer": "^0.40.0",
|
|
57
|
+
"@cap-js/cds-types": "^0.18.0",
|
|
58
|
+
"@cap-js/sqlite": "^3",
|
|
59
|
+
"@sap/cds": "^10",
|
|
60
|
+
"@sap/cds-dk": "^10",
|
|
61
|
+
"@sap/eslint-plugin-cds": "^4.2.4",
|
|
62
|
+
"@types/blake2b": "^2.1.3",
|
|
63
|
+
"@types/node": "^22.19.7",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
65
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
66
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
67
|
+
"dotenv": "^16.3.1",
|
|
68
|
+
"eslint": "^9.39.2",
|
|
69
|
+
"nock": "^13.5.6",
|
|
70
|
+
"ts-node": "^10.9.2",
|
|
71
|
+
"tsx": "^4.21.0",
|
|
72
|
+
"typescript": "^5.9.3",
|
|
73
|
+
"vitest": "^4.1.10"
|
|
74
|
+
},
|
|
75
|
+
"cds": {
|
|
76
|
+
"typer": {
|
|
77
|
+
"ieee754compatible": true
|
|
78
|
+
},
|
|
79
|
+
"build": {
|
|
80
|
+
"tasks": [
|
|
81
|
+
{
|
|
82
|
+
"for": "node-cf",
|
|
83
|
+
"src": "srv",
|
|
84
|
+
"dest": "../gen/srv"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"for": "hana",
|
|
88
|
+
"src": "db",
|
|
89
|
+
"dest": "../gen/db"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"requires": {
|
|
94
|
+
"db": {
|
|
95
|
+
"kind": "sqlite",
|
|
96
|
+
"credentials": {
|
|
97
|
+
"url": "db.sqlite"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"[production]": {
|
|
101
|
+
"db": {
|
|
102
|
+
"kind": "hana",
|
|
103
|
+
"pool": {
|
|
104
|
+
"acquireTimeoutMillis": 30000,
|
|
105
|
+
"min": 0,
|
|
106
|
+
"max": 10
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"auth": "xsuaa"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"scripts": {
|
|
114
|
+
"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')\"",
|
|
115
|
+
"clean:models": "node -e \"require('fs').rmSync('@cds-models',{recursive:true,force:true});console.log('Removed @cds-models')\"",
|
|
116
|
+
"build": "npm run cds:types && tsc",
|
|
117
|
+
"build:plugin": "npm run cds:types && tsc -p tsconfig.build.json",
|
|
118
|
+
"build:package": "npm run clean && npm run clean:models && npm run build:plugin",
|
|
119
|
+
"prepare": "npm run build:package",
|
|
120
|
+
"start": "cds-serve",
|
|
121
|
+
"cds:watch": "cds watch",
|
|
122
|
+
"cds:serve": "cds serve --with-mocks",
|
|
123
|
+
"cds:types": "cds-typer \"*\" --outputDirectory @cds-models",
|
|
124
|
+
"lint": "eslint .",
|
|
125
|
+
"typecheck": "tsc --noEmit",
|
|
126
|
+
"db:deploy": "cds deploy",
|
|
127
|
+
"pretest": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
128
|
+
"test": "vitest run",
|
|
129
|
+
"pretest:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
130
|
+
"test:coverage": "vitest run --coverage",
|
|
131
|
+
"pretest:ci": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
132
|
+
"test:ci": "vitest run --exclude \"**/core-ogmios.test.ts\"",
|
|
133
|
+
"pretest:ci:coverage": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
134
|
+
"test:ci:coverage": "vitest run --coverage --exclude \"**/core-ogmios.test.ts\"",
|
|
135
|
+
"pretest:integration": "npm run clean && npm run cds:types && npm run db:deploy",
|
|
136
|
+
"test:integration": "vitest run --project integration",
|
|
137
|
+
"test:integration:blockfrost": "vitest run test/integration/core.blockfrost.test.ts",
|
|
138
|
+
"test:integration:koios": "vitest run test/integration/core.koios.test.ts",
|
|
139
|
+
"test:integration:ogmios": "vitest run test/integration/core-ogmios.test.ts",
|
|
140
|
+
"test:integration:both": "npm run test:integration:blockfrost && npm run test:integration:koios",
|
|
141
|
+
"pretest:unit": "npm run cds:types",
|
|
142
|
+
"test:unit": "vitest run --project unit",
|
|
143
|
+
"watch-odatano": "cds watch --open odatano/index.html?sap-ui-xx-viewCache=false --livereload false",
|
|
144
|
+
"watch-wallet": "cds watch --open wallet/webapp/index.html"
|
|
145
|
+
},
|
|
146
|
+
"sapux": [
|
|
147
|
+
"app/odatano"
|
|
148
|
+
],
|
|
149
|
+
"directories": {
|
|
150
|
+
"doc": "docs",
|
|
151
|
+
"test": "test"
|
|
152
|
+
},
|
|
153
|
+
"repository": {
|
|
154
|
+
"type": "git",
|
|
155
|
+
"url": "git+https://github.com/ODATANO/ODATANO.git"
|
|
156
|
+
},
|
|
157
|
+
"keywords": [
|
|
158
|
+
"CAP",
|
|
159
|
+
"CDS",
|
|
160
|
+
"plugin",
|
|
161
|
+
"Cardano",
|
|
162
|
+
"blockchain",
|
|
163
|
+
"OData",
|
|
164
|
+
"SAP"
|
|
165
|
+
],
|
|
166
|
+
"author": "Maximilian Weber",
|
|
167
|
+
"license": "Apache-2.0",
|
|
168
|
+
"type": "commonjs",
|
|
169
|
+
"bugs": {
|
|
170
|
+
"url": "https://github.com/ODATANO/ODATANO/issues"
|
|
171
|
+
},
|
|
172
|
+
"homepage": "https://github.com/ODATANO/ODATANO#readme"
|
|
173
|
+
}
|
|
@@ -140,10 +140,30 @@ export declare class BuildooorTxBuilder implements CardanoTxBuilder {
|
|
|
140
140
|
* Returns empty array when no reference inputs are provided.
|
|
141
141
|
*/
|
|
142
142
|
private _mapReferenceInputs;
|
|
143
|
+
/**
|
|
144
|
+
* Funding requirement contributed by extra outputs on a mint build:
|
|
145
|
+
* the summed lovelace of all entries plus, per asset unit, the demand the
|
|
146
|
+
* transaction's own positive mints do NOT cover. Minted quantities are
|
|
147
|
+
* aggregated per unit and subtracted from the aggregated output demand;
|
|
148
|
+
* only a positive remainder is requested from the wallet (a fully covered
|
|
149
|
+
* unit is not requested at all — it does not exist before this tx).
|
|
150
|
+
*/
|
|
151
|
+
private _extraOutputsFundingAfterMint;
|
|
152
|
+
/**
|
|
153
|
+
* The script an individual mint action executes under: its own
|
|
154
|
+
* per-action policy when set (multi-policy mint FR), else the request's
|
|
155
|
+
* top-level policy script.
|
|
156
|
+
*/
|
|
157
|
+
private _mintActionScript;
|
|
143
158
|
/**
|
|
144
159
|
* Build the Buildooor mint-entry array shared by the mint-only flow and the
|
|
145
160
|
* combined spend+mint flow (Buildooor ignores caller-supplied execution units;
|
|
146
161
|
* they are stamped into the redeemers post-build by _buildScriptTx).
|
|
162
|
+
*
|
|
163
|
+
* Multi-policy mint FR: each action may carry its own policy script and
|
|
164
|
+
* redeemer; absent fields fall back to the request-level ones. The ledger
|
|
165
|
+
* carries ONE redeemer per policy, so actions resolving to the same policy
|
|
166
|
+
* must agree on their redeemer, checked here.
|
|
147
167
|
*/
|
|
148
168
|
private _buildMintEntries;
|
|
149
169
|
/**
|
|
@@ -246,13 +246,15 @@ class BuildooorTxBuilder {
|
|
|
246
246
|
const changeAddress = cardano_ledger_ts_1.Address.fromString(req.changeAddress ?? req.senderAddress);
|
|
247
247
|
// Parse the minting policy script once
|
|
248
248
|
const script = this._parsePlutusV3Script(req.mintingPolicyScript, 'mintingPolicyScript');
|
|
249
|
-
// Calculate total mint value for output (only positive quantities - mints, not burns)
|
|
249
|
+
// Calculate total mint value for output (only positive quantities - mints, not burns).
|
|
250
|
+
// Multi-policy mint FR: each action mints under ITS script (own or top-level).
|
|
250
251
|
let mintValue = cardano_ledger_ts_1.Value.lovelaces(0n);
|
|
251
|
-
for (const mintAction of req.mintActions) {
|
|
252
|
+
for (const [index, mintAction] of req.mintActions.entries()) {
|
|
252
253
|
const quantity = BigInt(mintAction.quantity);
|
|
253
254
|
if (quantity > 0n) {
|
|
255
|
+
const actionScript = this._mintActionScript(mintAction, script, index);
|
|
254
256
|
const { assetName } = (0, tx_build_helper_1.parseAssetUnit)(mintAction.assetUnit);
|
|
255
|
-
mintValue = cardano_ledger_ts_1.Value.add(mintValue, cardano_ledger_ts_1.Value.singleAsset(
|
|
257
|
+
mintValue = cardano_ledger_ts_1.Value.add(mintValue, cardano_ledger_ts_1.Value.singleAsset(actionScript.hash, Buffer.from(assetName, 'hex'), quantity));
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
260
|
// Partition forced vs candidate UTxOs. Forced inputs are already committed;
|
|
@@ -264,8 +266,15 @@ class BuildooorTxBuilder {
|
|
|
264
266
|
coinSelectionContext = this._collateralPartitionContext(collateralUtxos, fundingUtxos);
|
|
265
267
|
const fundingLedgerUtxos = fundingUtxos.map(utxo => this._mapMultiAssetUtxoToLedgerUtxo(utxo));
|
|
266
268
|
const allFundingInputs = fundingLedgerUtxos.map(utxo => ({ utxo }));
|
|
267
|
-
// Coin selection: only need enough ADA from funding UTxOs (minted tokens come from
|
|
268
|
-
|
|
269
|
+
// Coin selection: only need enough ADA from funding UTxOs (minted tokens come from
|
|
270
|
+
// thin air). Extra outputs (FR-2 on mint) add their lovelace plus, per unit, the
|
|
271
|
+
// demand the mint does NOT cover (e.g. minting 1 while placing 2 means 1 must come
|
|
272
|
+
// from the wallet).
|
|
273
|
+
let requiredFundingValue = cardano_ledger_ts_1.Value.lovelaces(BigInt(req.lovelaceAmount));
|
|
274
|
+
if (req.extraOutputs && req.extraOutputs.length > 0) {
|
|
275
|
+
const { lovelace, assets } = this._extraOutputsFundingAfterMint(req.mintActions, req.extraOutputs);
|
|
276
|
+
requiredFundingValue = cardano_ledger_ts_1.Value.add(requiredFundingValue, this._buildLedgerValue(lovelace, assets));
|
|
277
|
+
}
|
|
269
278
|
const selectedFunding = this.txBuilder.keepRelevant(requiredFundingValue, allFundingInputs);
|
|
270
279
|
const inputs = [...forcedInputs, ...selectedFunding];
|
|
271
280
|
logger.debug(`Coin selection: ${selectedFunding.length}/${allFundingInputs.length} UTxOs selected (${forcedInputs.length} forced) for mint`);
|
|
@@ -281,15 +290,24 @@ class BuildooorTxBuilder {
|
|
|
281
290
|
const resolvedInlineDatum = req.inlineDatum
|
|
282
291
|
? (0, plutus_placeholders_1.resolveIndexPlaceholders)(req.inlineDatum, resolveCtx)
|
|
283
292
|
: undefined;
|
|
284
|
-
|
|
293
|
+
const resolvedExtraOutputs = this._resolveExtraOutputPlaceholders(req.extraOutputs, resolveCtx);
|
|
294
|
+
// Build output — recipient gets the minted assets + min ADA. When extra
|
|
295
|
+
// outputs are declared (FR-2 on mint) THEY carry the minted assets (each
|
|
296
|
+
// token on its own output with its own datum, e.g. datum-bound predicate
|
|
297
|
+
// tokens), so the primary output stays ADA(+datum)-only.
|
|
285
298
|
let outputValue = cardano_ledger_ts_1.Value.lovelaces(BigInt(req.lovelaceAmount));
|
|
286
|
-
|
|
299
|
+
if (!resolvedExtraOutputs || resolvedExtraOutputs.length === 0) {
|
|
300
|
+
outputValue = cardano_ledger_ts_1.Value.add(outputValue, mintValue);
|
|
301
|
+
}
|
|
287
302
|
const refScript = this._parseReferenceScript(req.referenceScript);
|
|
288
303
|
const outputs = [this._buildTxOut(recipientAddress, outputValue, resolvedInlineDatum, refScript)];
|
|
289
|
-
//
|
|
290
|
-
|
|
304
|
+
// Append extra outputs, each independently min-ADA checked.
|
|
305
|
+
this._appendExtraOutputs(outputs, resolvedExtraOutputs);
|
|
306
|
+
// Mint entries for the build args (uses pre-resolved redeemers; per-action
|
|
307
|
+
// redeemers resolve their own placeholders). Note: Buildooor ignores
|
|
308
|
+
// caller-supplied execution units — the real units are stamped into the
|
|
291
309
|
// redeemers post-build by _buildScriptTx.
|
|
292
|
-
const mints = this._buildMintEntries(req.mintActions, script, resolvedMintRedeemer);
|
|
310
|
+
const mints = this._buildMintEntries(req.mintActions, script, resolvedMintRedeemer, resolveCtx);
|
|
293
311
|
// CIP-31: map resolved reference input UTxOs to Buildooor LedgerUTxO format
|
|
294
312
|
const readonlyRefInputs = this._mapReferenceInputs(ctx.referenceInputUtxos);
|
|
295
313
|
// Resolve validity bounds once — both passes must share them so redeemer ExUnits
|
|
@@ -394,11 +412,12 @@ class BuildooorTxBuilder {
|
|
|
394
412
|
}
|
|
395
413
|
// If mints are present and no extraOutputs handle the minted assets, attach positive mints to the primary output.
|
|
396
414
|
if (hasMint && (!resolvedExtraOutputs || resolvedExtraOutputs.length === 0)) {
|
|
397
|
-
for (const action of req.mintActions) {
|
|
415
|
+
for (const [index, action] of req.mintActions.entries()) {
|
|
398
416
|
const qty = BigInt(action.quantity);
|
|
399
417
|
if (qty > 0n) {
|
|
418
|
+
const actionScript = this._mintActionScript(action, mintScript, index);
|
|
400
419
|
const { assetName } = (0, tx_build_helper_1.parseAssetUnit)(action.assetUnit);
|
|
401
|
-
outputValue = cardano_ledger_ts_1.Value.add(outputValue, cardano_ledger_ts_1.Value.singleAsset(
|
|
420
|
+
outputValue = cardano_ledger_ts_1.Value.add(outputValue, cardano_ledger_ts_1.Value.singleAsset(actionScript.hash, Buffer.from(assetName, 'hex'), qty));
|
|
402
421
|
}
|
|
403
422
|
}
|
|
404
423
|
}
|
|
@@ -411,7 +430,7 @@ class BuildooorTxBuilder {
|
|
|
411
430
|
// caller-supplied execution units — the real units are stamped into the
|
|
412
431
|
// redeemers post-build by _buildScriptTx.
|
|
413
432
|
const mints = hasMint
|
|
414
|
-
? this._buildMintEntries(req.mintActions, mintScript, resolvedMintRedeemer)
|
|
433
|
+
? this._buildMintEntries(req.mintActions, mintScript, resolvedMintRedeemer, resolveCtx)
|
|
415
434
|
: undefined;
|
|
416
435
|
const scriptInput = {
|
|
417
436
|
utxo: scriptLedgerUtxo,
|
|
@@ -760,21 +779,86 @@ class BuildooorTxBuilder {
|
|
|
760
779
|
return [];
|
|
761
780
|
return referenceInputUtxos.map(u => this._mapMultiAssetUtxoToLedgerUtxo(u));
|
|
762
781
|
}
|
|
782
|
+
/**
|
|
783
|
+
* Funding requirement contributed by extra outputs on a mint build:
|
|
784
|
+
* the summed lovelace of all entries plus, per asset unit, the demand the
|
|
785
|
+
* transaction's own positive mints do NOT cover. Minted quantities are
|
|
786
|
+
* aggregated per unit and subtracted from the aggregated output demand;
|
|
787
|
+
* only a positive remainder is requested from the wallet (a fully covered
|
|
788
|
+
* unit is not requested at all — it does not exist before this tx).
|
|
789
|
+
*/
|
|
790
|
+
_extraOutputsFundingAfterMint(mintActions, extraOutputs) {
|
|
791
|
+
const mintedByUnit = new Map();
|
|
792
|
+
for (const action of mintActions) {
|
|
793
|
+
const quantity = BigInt(action.quantity);
|
|
794
|
+
if (quantity > 0n) {
|
|
795
|
+
const unit = action.assetUnit.toLowerCase();
|
|
796
|
+
mintedByUnit.set(unit, (mintedByUnit.get(unit) ?? 0n) + quantity);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const demandByUnit = new Map();
|
|
800
|
+
let lovelace = 0n;
|
|
801
|
+
for (const extra of extraOutputs) {
|
|
802
|
+
lovelace += BigInt(extra.lovelaceAmount);
|
|
803
|
+
for (const asset of extra.assets ?? []) {
|
|
804
|
+
const unit = asset.unit.toLowerCase();
|
|
805
|
+
demandByUnit.set(unit, (demandByUnit.get(unit) ?? 0n) + BigInt(asset.quantity));
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const assets = [];
|
|
809
|
+
for (const [unit, demand] of demandByUnit) {
|
|
810
|
+
const uncovered = demand - (mintedByUnit.get(unit) ?? 0n);
|
|
811
|
+
if (uncovered > 0n)
|
|
812
|
+
assets.push({ unit, quantity: uncovered.toString() });
|
|
813
|
+
}
|
|
814
|
+
return { lovelace, ...(assets.length > 0 ? { assets } : {}) };
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* The script an individual mint action executes under: its own
|
|
818
|
+
* per-action policy when set (multi-policy mint FR), else the request's
|
|
819
|
+
* top-level policy script.
|
|
820
|
+
*/
|
|
821
|
+
_mintActionScript(action, defaultScript, index) {
|
|
822
|
+
if (!action.mintingPolicyScript)
|
|
823
|
+
return defaultScript;
|
|
824
|
+
return this._parsePlutusV3Script(action.mintingPolicyScript, `mintActions[${index}].mintingPolicyScript`);
|
|
825
|
+
}
|
|
763
826
|
/**
|
|
764
827
|
* Build the Buildooor mint-entry array shared by the mint-only flow and the
|
|
765
828
|
* combined spend+mint flow (Buildooor ignores caller-supplied execution units;
|
|
766
829
|
* they are stamped into the redeemers post-build by _buildScriptTx).
|
|
830
|
+
*
|
|
831
|
+
* Multi-policy mint FR: each action may carry its own policy script and
|
|
832
|
+
* redeemer; absent fields fall back to the request-level ones. The ledger
|
|
833
|
+
* carries ONE redeemer per policy, so actions resolving to the same policy
|
|
834
|
+
* must agree on their redeemer, checked here.
|
|
767
835
|
*/
|
|
768
|
-
_buildMintEntries(mintActions, mintScript, resolvedMintRedeemer) {
|
|
769
|
-
|
|
836
|
+
_buildMintEntries(mintActions, mintScript, resolvedMintRedeemer, resolveCtx) {
|
|
837
|
+
const redeemerByPolicy = new Map();
|
|
838
|
+
return mintActions.map((action, index) => {
|
|
839
|
+
const script = this._mintActionScript(action, mintScript, index);
|
|
840
|
+
const actionRedeemer = action.redeemerJson !== undefined
|
|
841
|
+
? (resolveCtx ? (0, plutus_placeholders_1.resolveIndexPlaceholders)(action.redeemerJson, resolveCtx) : action.redeemerJson)
|
|
842
|
+
: resolvedMintRedeemer;
|
|
843
|
+
const redeemerData = actionRedeemer !== undefined
|
|
844
|
+
? (0, tx_build_helper_1.jsonToPlutusData)(actionRedeemer)
|
|
845
|
+
: new plutus_data_1.DataI(action.redeemer ?? 0);
|
|
846
|
+
const policyId = script.hash.toString();
|
|
847
|
+
// Canonical comparison over the encoded PlutusData: JSON key order must
|
|
848
|
+
// not matter, and a JSON {int:0} equals the DataI(0) fallback.
|
|
849
|
+
const redeemerFingerprint = (0, plutus_data_1.dataToCbor)(redeemerData).toString();
|
|
850
|
+
const seen = redeemerByPolicy.get(policyId);
|
|
851
|
+
if (seen !== undefined && seen !== redeemerFingerprint) {
|
|
852
|
+
throw new Error(`mint actions under policy ${policyId} carry different redeemers — the ledger allows one redeemer per policy; ` +
|
|
853
|
+
'split them into separate transactions or align the redeemers');
|
|
854
|
+
}
|
|
855
|
+
redeemerByPolicy.set(policyId, redeemerFingerprint);
|
|
770
856
|
const { assetName } = (0, tx_build_helper_1.parseAssetUnit)(action.assetUnit);
|
|
771
857
|
return {
|
|
772
|
-
value: cardano_ledger_ts_1.Value.singleAsset(
|
|
858
|
+
value: cardano_ledger_ts_1.Value.singleAsset(script.hash, Buffer.from(assetName, 'hex'), BigInt(action.quantity)),
|
|
773
859
|
script: {
|
|
774
|
-
inline:
|
|
775
|
-
redeemer:
|
|
776
|
-
? (0, tx_build_helper_1.jsonToPlutusData)(resolvedMintRedeemer)
|
|
777
|
-
: new plutus_data_1.DataI(action.redeemer ?? 0)
|
|
860
|
+
inline: script,
|
|
861
|
+
redeemer: redeemerData
|
|
778
862
|
}
|
|
779
863
|
};
|
|
780
864
|
});
|
|
@@ -42,12 +42,13 @@ function parseScriptParams(raw) {
|
|
|
42
42
|
fail('scriptParamsJson must be a JSON array');
|
|
43
43
|
return parsed;
|
|
44
44
|
}
|
|
45
|
-
/** Mirrors the BuildMint/BuildPlutusSpend mint-action parsing (bigint quantities
|
|
45
|
+
/** Mirrors the BuildMint/BuildPlutusSpend mint-action parsing (bigint quantities,
|
|
46
|
+
* multi-policy per-action fields). */
|
|
46
47
|
function parseMintActions(raw, allowBareNames) {
|
|
47
48
|
const parsed = parseJsonField(raw, 'mintActionsJson');
|
|
48
49
|
if (!Array.isArray(parsed))
|
|
49
50
|
fail('mintActionsJson must be a JSON array');
|
|
50
|
-
return parsed.map((rawAction) => {
|
|
51
|
+
return parsed.map((rawAction, i) => {
|
|
51
52
|
if (!rawAction || typeof rawAction !== 'object') {
|
|
52
53
|
fail('Each mint action must be an object with assetUnit and quantity');
|
|
53
54
|
}
|
|
@@ -57,14 +58,37 @@ function parseMintActions(raw, allowBareNames) {
|
|
|
57
58
|
}
|
|
58
59
|
if (typeof action.assetUnit !== 'string')
|
|
59
60
|
fail('Each mint action must have an assetUnit string');
|
|
60
|
-
|
|
61
|
+
// Multi-policy mint FR: optional per-action mintingPolicyScript + redeemerJson.
|
|
62
|
+
const policyFields = (0, tx_request_parsers_1.parseMintActionPolicyFields)(action, i);
|
|
63
|
+
if (policyFields.error)
|
|
64
|
+
fail(policyFields.error);
|
|
65
|
+
let actionPolicyId;
|
|
66
|
+
if (policyFields.script) {
|
|
67
|
+
actionPolicyId = scriptHashOf(policyFields.script, `mintActions[${i}].mintingPolicyScript is not a valid Plutus script`);
|
|
68
|
+
}
|
|
69
|
+
const bareAssetNameForExpansion = (allowBareNames || !!actionPolicyId) &&
|
|
61
70
|
action.assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH &&
|
|
62
71
|
action.assetUnit.length % 2 === 0 &&
|
|
63
72
|
/^[0-9a-fA-F]*$/.test(action.assetUnit);
|
|
64
73
|
if (!(0, validators_1.isAssetUnit)(action.assetUnit) && !bareAssetNameForExpansion) {
|
|
65
|
-
fail(`Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson is set)`);
|
|
74
|
+
fail(`Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson or a per-action mintingPolicyScript is set)`);
|
|
75
|
+
}
|
|
76
|
+
let assetUnit = action.assetUnit;
|
|
77
|
+
if (actionPolicyId) {
|
|
78
|
+
if (assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH) {
|
|
79
|
+
assetUnit = actionPolicyId + assetUnit;
|
|
80
|
+
}
|
|
81
|
+
else if (!assetUnit.toLowerCase().startsWith(actionPolicyId)) {
|
|
82
|
+
fail(`mintActions[${i}].assetUnit "${assetUnit}" does not start with its own policy id ${actionPolicyId}`);
|
|
83
|
+
}
|
|
66
84
|
}
|
|
67
|
-
return {
|
|
85
|
+
return {
|
|
86
|
+
assetUnit,
|
|
87
|
+
quantity: BigInt(action.quantity),
|
|
88
|
+
...(typeof action.redeemer === 'number' ? { redeemer: action.redeemer } : {}),
|
|
89
|
+
...(policyFields.script ? { mintingPolicyScript: policyFields.script } : {}),
|
|
90
|
+
...(policyFields.redeemer !== undefined ? { redeemerJson: policyFields.redeemer } : {})
|
|
91
|
+
};
|
|
68
92
|
});
|
|
69
93
|
}
|
|
70
94
|
function scriptHashOf(scriptHex, context) {
|
|
@@ -81,7 +105,9 @@ function scriptHashOf(scriptHex, context) {
|
|
|
81
105
|
* would mint a truncated asset name.
|
|
82
106
|
*/
|
|
83
107
|
function assertPolicyPrefix(actions, policyId) {
|
|
84
|
-
|
|
108
|
+
// Actions with their own per-action script were already checked against THAT
|
|
109
|
+
// script's policy id during parsing.
|
|
110
|
+
const mismatch = actions.find((a) => !a.mintingPolicyScript && !a.assetUnit.toLowerCase().startsWith(policyId));
|
|
85
111
|
if (mismatch) {
|
|
86
112
|
fail(`assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId} — pass the full unit as policyId+assetName (asset names longer than 28 bytes cannot be passed bare)`);
|
|
87
113
|
}
|
|
@@ -153,6 +179,7 @@ function prepareMint(raw, network) {
|
|
|
153
179
|
const mintRedeemer = parseJsonField(raw, 'mintRedeemerJson');
|
|
154
180
|
const forceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.forceInputsJson, 'forceInputsJson'));
|
|
155
181
|
const referenceInputs = takeParsed((0, tx_request_parsers_1.parseUtxoRefArray)(raw.referenceInputsJson, 'referenceInputsJson'));
|
|
182
|
+
const extraOutputs = takeParsed((0, tx_request_parsers_1.parseExtraOutputs)(raw.extraOutputsJson));
|
|
156
183
|
if (raw.lockOnScript && (!scriptParams || scriptParams.length === 0)) {
|
|
157
184
|
fail('lockOnScript requires scriptParamsJson to derive script address');
|
|
158
185
|
}
|
|
@@ -172,6 +199,7 @@ function prepareMint(raw, network) {
|
|
|
172
199
|
delete clean.lockOnScript;
|
|
173
200
|
delete clean.forceInputsJson;
|
|
174
201
|
delete clean.referenceInputsJson;
|
|
202
|
+
delete clean.extraOutputsJson;
|
|
175
203
|
if (parsedMetadata)
|
|
176
204
|
clean.metadataJson = parsedMetadata;
|
|
177
205
|
else
|
|
@@ -219,6 +247,7 @@ function prepareMint(raw, network) {
|
|
|
219
247
|
mintRedeemer,
|
|
220
248
|
forceInputs,
|
|
221
249
|
referenceInputs,
|
|
250
|
+
extraOutputs,
|
|
222
251
|
};
|
|
223
252
|
}
|
|
224
253
|
function preparePlutusSpend(raw, network) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
using {odatano.cardano as db} from '../db/schema';
|
|
2
|
-
using {
|
|
2
|
+
using {
|
|
3
|
+
Bech32,
|
|
4
|
+
Lovelace
|
|
5
|
+
} from '../db/types';
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -43,20 +46,21 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
43
46
|
@description: 'Projection for Transaction Build Output Assets'
|
|
44
47
|
entity TransactionBuildOutputAssets as projection on db.TransactionBuildOutputAssets;
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
@readonly
|
|
50
|
+
@title : 'Transaction Submissions'
|
|
51
|
+
@description: 'Projection for Transaction Submissions'
|
|
49
52
|
entity TransactionSubmissions as projection on db.TransactionSubmissions
|
|
50
53
|
actions {
|
|
51
54
|
@title : 'Check Submission Status'
|
|
52
55
|
@description: 'Check the status of a submitted transaction by querying the blockchain for confirmation'
|
|
53
56
|
action CheckSubmissionStatus() returns TransactionSubmissions;
|
|
54
57
|
};
|
|
58
|
+
|
|
55
59
|
/**
|
|
56
60
|
* TransactionSubmissions status flow:
|
|
57
|
-
* pending
|
|
58
|
-
* submitted
|
|
59
|
-
* pending | submitted
|
|
61
|
+
* pending -> [submit to chain] -> submitted (internal, in SubmitTransaction handler)
|
|
62
|
+
* submitted -> [CheckSubmissionStatus] confirmed | stays submitted (conditional)
|
|
63
|
+
* pending | submitted -> failed (blockchain error)
|
|
60
64
|
*/
|
|
61
65
|
annotate CardanoTransactionService.TransactionSubmissions with @flow.status: status actions {
|
|
62
66
|
CheckSubmissionStatus @from : [ #submitted];
|
|
@@ -117,7 +121,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
117
121
|
validityStartMs: String,
|
|
118
122
|
@title: 'Validity End (Posix ms)'
|
|
119
123
|
@description: 'Optional. Validity-interval end in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
|
|
120
|
-
validityEndMs: String)
|
|
124
|
+
validityEndMs: String) returns TransactionBuilds;
|
|
121
125
|
|
|
122
126
|
@title : 'Build Transaction with Metadata'
|
|
123
127
|
@description: 'Build a transaction with custom metadata from sender to recipient with specified amount and change address'
|
|
@@ -136,7 +140,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
136
140
|
changeAddress: Bech32,
|
|
137
141
|
@title: 'Metadata JSON'
|
|
138
142
|
@description: 'The JSON representation of the transaction metadata as string'
|
|
139
|
-
metadataJson: String)
|
|
143
|
+
metadataJson: String) returns TransactionBuilds;
|
|
140
144
|
|
|
141
145
|
@title : 'Build Multi-Asset Transaction'
|
|
142
146
|
@description: 'Build a transaction to send native assets (tokens) along with ADA'
|
|
@@ -167,7 +171,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
167
171
|
validityStartMs: String,
|
|
168
172
|
@title: 'Validity End (Posix ms)'
|
|
169
173
|
@description: 'Optional. Validity-interval end in Posix milliseconds. Passed through to the builder only; for non-script transfers the builder leaves bounds unset unless provided.'
|
|
170
|
-
validityEndMs: String)
|
|
174
|
+
validityEndMs: String) returns TransactionBuilds;
|
|
171
175
|
|
|
172
176
|
@title : 'Build Minting Transaction'
|
|
173
177
|
@description: 'Build a transaction to mint or burn native assets'
|
|
@@ -182,10 +186,10 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
182
186
|
@description: 'The amount of ADA to send with minted assets in lovelace'
|
|
183
187
|
lovelaceAmount: Lovelace,
|
|
184
188
|
@title: 'Mint Actions JSON'
|
|
185
|
-
@description: 'JSON array of mint/burn actions (format: [{"assetUnit":"policyId+assetName","quantity":"amount"}])'
|
|
189
|
+
@description: 'JSON array of mint/burn actions (format: [{"assetUnit":"policyId+assetName","quantity":"amount"}]). Multi-policy mints: each action may additionally carry its own "mintingPolicyScript" (CBOR hex, pre-applied) and "redeemerJson" (JSON-encoded PlutusData string), overriding the top-level policy/redeemer for that action. Actions resolving to the same policy must agree on their redeemer (the ledger carries one redeemer per policy).'
|
|
186
190
|
mintActionsJson: String,
|
|
187
191
|
@title: 'Minting Policy Script'
|
|
188
|
-
@description: 'The minting policy script in CBOR hex format'
|
|
192
|
+
@description: 'The minting policy script in CBOR hex format. Actions without a per-action mintingPolicyScript mint under this script.'
|
|
189
193
|
mintingPolicyScript: String,
|
|
190
194
|
@title: 'Change Address'
|
|
191
195
|
@description: 'The Bech32 encoded address for returning change -defaults to sender address if not specified'
|
|
@@ -211,6 +215,9 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
211
215
|
@title: 'Reference Inputs JSON'
|
|
212
216
|
@description: 'Optional JSON array of {txHash, outputIndex} UTxOs to include as CIP-31 reference inputs (read-only, not consumed). Use for oracle feeds, shared config UTxOs, or script reference UTxOs. Buildooor builder only.'
|
|
213
217
|
referenceInputsJson: String,
|
|
218
|
+
@title: 'Extra Outputs JSON'
|
|
219
|
+
@description: 'Optional JSON array of additional outputs [{address, lovelaceAmount, assets?, inlineDatumJson?, referenceScriptHex?}] appended after the primary recipient output. When present, the extra outputs carry the minted assets (declare each minted unit in an entry''s assets) and the primary output stays ADA-only — used to place each minted token on its own output with its own inline datum (e.g. datum-bound predicate tokens). Each entry is independently min-ADA checked.'
|
|
220
|
+
extraOutputsJson: String,
|
|
214
221
|
@title: 'Metadata JSON'
|
|
215
222
|
@description: 'Optional transaction metadata as JSON (CIP-20 / label-674 etc.). Object keyed by numeric label string. Attached as auxiliary_data to the mint tx so chain-watchers can correlate off-chain context (receipt IDs, free-form notes).'
|
|
216
223
|
metadataJson: String,
|
|
@@ -222,14 +229,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
222
229
|
validityStartMs: String,
|
|
223
230
|
@title: 'Validity End (Posix ms)'
|
|
224
231
|
@description: 'Optional. Sets the transaction validity-interval end in Posix milliseconds. Required finite value for Plutus validators that call expect Finite(upper) on tx.validity_range.upper_bound. Defaults to now + 3 600 000 ms when omitted.'
|
|
225
|
-
validityEndMs: String)
|
|
232
|
+
validityEndMs: String) returns TransactionBuilds;
|
|
226
233
|
|
|
227
234
|
@title : 'Get Build Details'
|
|
228
235
|
@description: 'Retrieve transaction build details using the Build Id'
|
|
229
236
|
action GetBuildDetails(
|
|
230
237
|
@title: 'Build Id'
|
|
231
238
|
@description: 'The unique identifier of the transaction build'
|
|
232
|
-
buildId: UUID)
|
|
239
|
+
buildId: UUID) returns TransactionBuilds;
|
|
233
240
|
|
|
234
241
|
@title : 'Submit Transaction'
|
|
235
242
|
@description: 'Submit a transaction to the Cardano network using a build ID and signed CBOR'
|
|
@@ -239,7 +246,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
239
246
|
buildId: UUID,
|
|
240
247
|
@title: 'Signed Transaction CBOR'
|
|
241
248
|
@description: 'The CBOR of the signed transaction'
|
|
242
|
-
signedTxCbor: String)
|
|
249
|
+
signedTxCbor: String) returns TransactionSubmissions;
|
|
243
250
|
|
|
244
251
|
@title : 'Submit Signed Transaction'
|
|
245
252
|
@description: 'Submit a signed transaction to the Cardano network'
|
|
@@ -249,7 +256,7 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
249
256
|
signedTxCbor: String,
|
|
250
257
|
@title: 'Network'
|
|
251
258
|
@description: 'The Cardano network to submit the transaction to (e.g., mainnet, testnet)'
|
|
252
|
-
network: String(10))
|
|
259
|
+
network: String(10)) returns TransactionSubmissions;
|
|
253
260
|
|
|
254
261
|
@title : 'Build Plutus Spend Transaction'
|
|
255
262
|
@description: 'Build a transaction to spend a UTxO locked at a Plutus script address'
|
|
@@ -326,13 +333,14 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
326
333
|
action SetCollateral(
|
|
327
334
|
@title: 'Address'
|
|
328
335
|
@description: 'The Bech32 encoded address to check and set up collateral for'
|
|
329
|
-
address: Bech32)
|
|
336
|
+
address: Bech32) returns TransactionBuilds;
|
|
337
|
+
|
|
330
338
|
@title : 'Address Transaction Builds'
|
|
331
339
|
@description: 'Projection for retrieving transaction builds by address'
|
|
332
340
|
action GetTransactionBuildsByAddress(
|
|
333
341
|
@title: 'Bech32 Address'
|
|
334
342
|
@description: 'The Bech32 encoded address to retrieve transaction builds for'
|
|
335
|
-
address: Bech32)
|
|
343
|
+
address: Bech32) returns array of AddressTransactionBuilds;
|
|
336
344
|
|
|
337
345
|
@title : 'Derive Script Address'
|
|
338
346
|
@description: 'Utility: Apply optional PlutusData parameters to a validator script and return its enterprise script address (bech32) and script hash (28-byte hex). Pure derivation, no transaction built, no blockchain call.'
|
|
@@ -346,19 +354,17 @@ service CardanoTransactionService @(impl: './cardano-tx-service') {
|
|
|
346
354
|
@title: 'Network'
|
|
347
355
|
@description: 'Optional network override (mainnet, preview, preprod). Defaults to the configured network.'
|
|
348
356
|
network: String(10)) returns {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
357
|
+
scriptAddress : String(120);
|
|
358
|
+
scriptHash : String(56);
|
|
359
|
+
};
|
|
352
360
|
|
|
353
361
|
@title : 'Extract Payment Key Hash'
|
|
354
362
|
@description: 'Utility: Decode a Bech32 Cardano address and return its 28-byte payment credential hash (hex). Pure bech32 decoding — no blockchain call. Use to obtain the key hash for requiredSignersJson on Plutus actions.'
|
|
355
363
|
action ExtractPaymentKeyHash(
|
|
356
364
|
@title: 'Address'
|
|
357
365
|
@description: 'The Bech32 encoded Cardano address (addr / addr_test)'
|
|
358
|
-
address: Bech32)
|
|
359
|
-
|
|
360
|
-
|
|
366
|
+
address: Bech32) returns {
|
|
367
|
+
paymentKeyHash : String(56);
|
|
368
|
+
};
|
|
361
369
|
|
|
362
370
|
}
|
|
363
|
-
|
|
364
|
-
|
|
@@ -117,7 +117,7 @@ module.exports = (srv) => {
|
|
|
117
117
|
});
|
|
118
118
|
/**
|
|
119
119
|
* Build a transaction with metadata
|
|
120
|
-
* @param req - CDS request object
|
|
120
|
+
* @param req - CDS request object
|
|
121
121
|
* @returns {TransactionBuild} Transaction build details
|
|
122
122
|
*/
|
|
123
123
|
srv.on('BuildTransactionWithMetadata', async (req) => {
|
|
@@ -138,7 +138,7 @@ module.exports = (srv) => {
|
|
|
138
138
|
});
|
|
139
139
|
/**
|
|
140
140
|
* Build a multi-asset transaction
|
|
141
|
-
* @param req
|
|
141
|
+
* @param req CDS request object
|
|
142
142
|
* @returns {TransactionBuild} Transaction build details
|
|
143
143
|
*/
|
|
144
144
|
srv.on('BuildMultiAssetTransaction', async (req) => {
|
|
@@ -157,10 +157,10 @@ module.exports = (srv) => {
|
|
|
157
157
|
if (!parsedAssets || parsedAssets.length === 0) {
|
|
158
158
|
return (0, errors_1.rejectInvalid)(req, 'BuildMultiAssetTransaction', 'assetsJson must contain at least one asset', 'assetsJson');
|
|
159
159
|
}
|
|
160
|
-
// Validation BEFORE handleRequest
|
|
160
|
+
// Validation BEFORE handleRequest
|
|
161
161
|
const cleanData = { ...req.data };
|
|
162
162
|
delete cleanData.assetsJson;
|
|
163
|
-
// parse optional output datum
|
|
163
|
+
// parse optional output datum
|
|
164
164
|
if (outputDatumJson) {
|
|
165
165
|
const jsonResult = (0, validators_1.validateJsonWithLimits)(outputDatumJson, 'outputDatumJson');
|
|
166
166
|
if (!jsonResult.valid)
|
|
@@ -182,11 +182,11 @@ module.exports = (srv) => {
|
|
|
182
182
|
});
|
|
183
183
|
/**
|
|
184
184
|
* Build a minting transaction
|
|
185
|
-
* @param req
|
|
185
|
+
* @param req CDS request object
|
|
186
186
|
* @returns {TransactionBuild} Transaction build details
|
|
187
187
|
*/
|
|
188
188
|
srv.on('BuildMintTransaction', async (req) => {
|
|
189
|
-
const { senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, referenceScriptHex, metadataJson, validityStartMs, validityEndMs } = req.data;
|
|
189
|
+
const { senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, requiredSignersJson, scriptParamsJson, inlineDatumJson, mintRedeemerJson, lockOnScript, forceInputsJson, referenceInputsJson, referenceScriptHex, extraOutputsJson, metadataJson, validityStartMs, validityEndMs } = req.data;
|
|
190
190
|
// validate inputs (includes JSON and CBOR validation)
|
|
191
191
|
const errors = (0, validators_1.validateTransactionInputs)({ senderAddress, recipientAddress, lovelaceAmount, mintActionsJson, mintingPolicyScript, referenceScriptHex, metadataJson, validityStartMs, validityEndMs }, ['senderAddress', 'recipientAddress', 'lovelaceAmount', 'mintActionsJson', 'mintingPolicyScript']);
|
|
192
192
|
(0, errors_1.throwIfValidationErrors)(req, 'BuildMintTransaction', errors);
|
|
@@ -198,21 +198,41 @@ module.exports = (srv) => {
|
|
|
198
198
|
if (!Array.isArray(parsedMintActionsRaw)) {
|
|
199
199
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'mintActionsJson must be a JSON array', 'mintActionsJson');
|
|
200
200
|
}
|
|
201
|
-
const parsedMintActions = parsedMintActionsRaw.map((action) => {
|
|
201
|
+
const parsedMintActions = parsedMintActionsRaw.map((action, actionIndex) => {
|
|
202
202
|
if (!action || typeof action !== 'object') {
|
|
203
203
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'Each mint action must be an object with assetUnit and quantity', 'mintActionsJson');
|
|
204
204
|
}
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
// Multi-policy mint FR: optional per-action mintingPolicyScript + redeemerJson.
|
|
206
|
+
const policyFields = (0, tx_request_parsers_1.parseMintActionPolicyFields)(action, actionIndex);
|
|
207
|
+
if (policyFields.error) {
|
|
208
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', policyFields.error, 'mintActionsJson');
|
|
209
|
+
}
|
|
210
|
+
let actionPolicyId;
|
|
211
|
+
if (policyFields.script) {
|
|
212
|
+
try {
|
|
213
|
+
actionPolicyId = cardano_ledger_ts_1.Script.fromCbor(Buffer.from(policyFields.script, 'hex')).hash.toString();
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
217
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `mintActions[${actionIndex}].mintingPolicyScript is not a valid Plutus script: ${errMsg}`, 'mintActionsJson');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const bareAssetNameForExpansion = (!!scriptParamsJson || !!actionPolicyId) &&
|
|
210
221
|
typeof action.assetUnit === 'string' &&
|
|
211
222
|
action.assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH &&
|
|
212
223
|
action.assetUnit.length % 2 === 0 &&
|
|
213
224
|
/^[0-9a-fA-F]*$/.test(action.assetUnit);
|
|
214
225
|
if (typeof action.assetUnit !== 'string' || (!(0, validators_1.isAssetUnit)(action.assetUnit) && !bareAssetNameForExpansion)) {
|
|
215
|
-
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson is set)`, 'mintActionsJson');
|
|
226
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson or a per-action mintingPolicyScript is set)`, 'mintActionsJson');
|
|
227
|
+
}
|
|
228
|
+
let assetUnit = action.assetUnit;
|
|
229
|
+
if (actionPolicyId) {
|
|
230
|
+
if (assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH) {
|
|
231
|
+
assetUnit = actionPolicyId + assetUnit;
|
|
232
|
+
}
|
|
233
|
+
else if (!assetUnit.toLowerCase().startsWith(actionPolicyId)) {
|
|
234
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `mintActions[${actionIndex}].assetUnit "${assetUnit}" does not start with its own policy id ${actionPolicyId}`, 'mintActionsJson');
|
|
235
|
+
}
|
|
216
236
|
}
|
|
217
237
|
if (typeof action.quantity !== 'string') {
|
|
218
238
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'Each mint action must have a string quantity', 'mintActionsJson');
|
|
@@ -221,7 +241,13 @@ module.exports = (srv) => {
|
|
|
221
241
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid quantity format: "${action.quantity}" — must be an integer string`, 'mintActionsJson');
|
|
222
242
|
}
|
|
223
243
|
try {
|
|
224
|
-
return {
|
|
244
|
+
return {
|
|
245
|
+
assetUnit,
|
|
246
|
+
quantity: BigInt(action.quantity),
|
|
247
|
+
...(action.redeemer !== undefined ? { redeemer: action.redeemer } : {}),
|
|
248
|
+
...(policyFields.script ? { mintingPolicyScript: policyFields.script } : {}),
|
|
249
|
+
...(policyFields.redeemer !== undefined ? { redeemerJson: policyFields.redeemer } : {})
|
|
250
|
+
};
|
|
225
251
|
}
|
|
226
252
|
catch {
|
|
227
253
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `Invalid quantity: "${action.quantity}" — cannot parse as integer`, 'mintActionsJson');
|
|
@@ -263,6 +289,12 @@ module.exports = (srv) => {
|
|
|
263
289
|
if (lockOnScript && (!scriptParams || scriptParams.length === 0)) {
|
|
264
290
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', 'lockOnScript requires scriptParamsJson to derive script address', 'lockOnScript');
|
|
265
291
|
}
|
|
292
|
+
// Parse and validate optional extraOutputsJson (FR-2 on mint: each minted
|
|
293
|
+
// token can sit on its own output with its own inline datum)
|
|
294
|
+
const extraOutputsResult = (0, tx_request_parsers_1.parseExtraOutputs)(extraOutputsJson);
|
|
295
|
+
if (extraOutputsResult.error)
|
|
296
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', extraOutputsResult.error, 'extraOutputsJson');
|
|
297
|
+
const extraOutputs = extraOutputsResult.parsed;
|
|
266
298
|
// Parse and validate optional forceInputsJson
|
|
267
299
|
const forceInputsResult = (0, tx_request_parsers_1.parseUtxoRefArray)(forceInputsJson, 'forceInputsJson');
|
|
268
300
|
if (forceInputsResult.error)
|
|
@@ -273,9 +305,7 @@ module.exports = (srv) => {
|
|
|
273
305
|
if (refInputsResult.error)
|
|
274
306
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', refInputsResult.error, 'referenceInputsJson');
|
|
275
307
|
const referenceInputs = refInputsResult.parsed;
|
|
276
|
-
// Parse and validate optional metadataJson
|
|
277
|
-
// validateTransactionInputs has already JSON-validated the string; re-parse here
|
|
278
|
-
// and enforce the label-object shape that the builder's metadata mapper expects.
|
|
308
|
+
// Parse and validate optional metadataJson
|
|
279
309
|
let parsedMetadata;
|
|
280
310
|
if (metadataJson) {
|
|
281
311
|
try {
|
|
@@ -302,6 +332,7 @@ module.exports = (srv) => {
|
|
|
302
332
|
delete cleanData.lockOnScript;
|
|
303
333
|
delete cleanData.forceInputsJson;
|
|
304
334
|
delete cleanData.referenceInputsJson;
|
|
335
|
+
delete cleanData.extraOutputsJson;
|
|
305
336
|
if (parsedMetadata) {
|
|
306
337
|
cleanData.metadataJson = parsedMetadata;
|
|
307
338
|
}
|
|
@@ -346,14 +377,9 @@ module.exports = (srv) => {
|
|
|
346
377
|
// invalid script CBOR — skip the prefix check; the builder rejects it with its own message
|
|
347
378
|
}
|
|
348
379
|
}
|
|
349
|
-
// BUG 9 fix: the builder mints every action under the policy script's hash and
|
|
350
|
-
// parseAssetUnit silently discards the unit's first 56 hex chars. A bare asset name
|
|
351
|
-
// of 29-32 bytes is length-indistinguishable from a full unit, so a mismatched
|
|
352
|
-
// prefix would mint a truncated name. At this point every action holds a full
|
|
353
|
-
// unit (bare names were expanded above), so all of them must carry the policyId.
|
|
354
380
|
if (effectivePolicyId) {
|
|
355
381
|
const policyId = effectivePolicyId;
|
|
356
|
-
const mismatch = parsedMintActions.find((action) => !action.assetUnit.toLowerCase().startsWith(policyId));
|
|
382
|
+
const mismatch = parsedMintActions.find((action) => !action.mintingPolicyScript && !action.assetUnit.toLowerCase().startsWith(policyId));
|
|
357
383
|
if (mismatch) {
|
|
358
384
|
return (0, errors_1.rejectInvalid)(req, 'BuildMintTransaction', `assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId} — pass the full unit as policyId+assetName (asset names longer than 28 bytes cannot be passed bare)`, 'mintActionsJson');
|
|
359
385
|
}
|
|
@@ -366,7 +392,8 @@ module.exports = (srv) => {
|
|
|
366
392
|
inlineDatum,
|
|
367
393
|
mintRedeemer,
|
|
368
394
|
forceInputs,
|
|
369
|
-
referenceInputs
|
|
395
|
+
referenceInputs,
|
|
396
|
+
extraOutputs
|
|
370
397
|
});
|
|
371
398
|
// Post-build: compute CIP-14 fingerprint and scriptAddress
|
|
372
399
|
if (buildResult.scriptHash) {
|
|
@@ -374,12 +401,15 @@ module.exports = (srv) => {
|
|
|
374
401
|
const updates = {};
|
|
375
402
|
// CIP-14 asset fingerprint for the first minted asset. The unit is always a
|
|
376
403
|
// full policyId+assetName here: bare names were expanded before the build and
|
|
377
|
-
// the
|
|
378
|
-
// asset name, not a bare 28-byte name).
|
|
404
|
+
// the prefix checks rejected everything else (a 56-hex unit is an empty
|
|
405
|
+
// asset name, not a bare 28-byte name). The policy id comes from the UNIT,
|
|
406
|
+
// not from buildResult.scriptHash: with a per-action mintingPolicyScript the
|
|
407
|
+
// first action may mint under a different policy than the top-level script.
|
|
379
408
|
if (parsedMintActions.length > 0) {
|
|
380
409
|
const firstAssetUnit = parsedMintActions[0].assetUnit;
|
|
410
|
+
const firstPolicyId = firstAssetUnit.slice(0, const_1.POLICY_ID_HEX_LENGTH);
|
|
381
411
|
const assetNameHex = firstAssetUnit.slice(const_1.POLICY_ID_HEX_LENGTH);
|
|
382
|
-
buildResult.fingerprint = (0, mappers_1.computeCip14Fingerprint)(
|
|
412
|
+
buildResult.fingerprint = (0, mappers_1.computeCip14Fingerprint)(firstPolicyId, assetNameHex);
|
|
383
413
|
updates.fingerprint = buildResult.fingerprint;
|
|
384
414
|
}
|
|
385
415
|
// lockOnScript: persist the derived script address on the build record (only when scriptParams were applied)
|
|
@@ -459,8 +489,7 @@ module.exports = (srv) => {
|
|
|
459
489
|
if (extraOutputsResult.error)
|
|
460
490
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', extraOutputsResult.error, 'extraOutputsJson');
|
|
461
491
|
const extraOutputs = extraOutputsResult.parsed;
|
|
462
|
-
//
|
|
463
|
-
// mintingPolicyScript is required alongside it. mintRedeemerJson is optional.
|
|
492
|
+
// Optional combined spend+mint parameters
|
|
464
493
|
let parsedMintActions;
|
|
465
494
|
let parsedMintRedeemer;
|
|
466
495
|
if (mintActionsJson) {
|
|
@@ -473,7 +502,7 @@ module.exports = (srv) => {
|
|
|
473
502
|
if (!Array.isArray(mintJson.parsed)) {
|
|
474
503
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', 'mintActionsJson must be a JSON array', 'mintActionsJson');
|
|
475
504
|
}
|
|
476
|
-
parsedMintActions = mintJson.parsed.map((rawAction) => {
|
|
505
|
+
parsedMintActions = mintJson.parsed.map((rawAction, actionIndex) => {
|
|
477
506
|
if (!rawAction || typeof rawAction !== 'object') {
|
|
478
507
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', 'Each mint action must be an object with assetUnit and quantity', 'mintActionsJson');
|
|
479
508
|
}
|
|
@@ -484,18 +513,45 @@ module.exports = (srv) => {
|
|
|
484
513
|
if (typeof action.assetUnit !== 'string') {
|
|
485
514
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', 'Each mint action must have assetUnit string', 'mintActionsJson');
|
|
486
515
|
}
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
516
|
+
// Multi-policy mint FR: optional per-action mintingPolicyScript + redeemerJson
|
|
517
|
+
// (same rules as BuildMintTransaction).
|
|
518
|
+
const policyFields = (0, tx_request_parsers_1.parseMintActionPolicyFields)(action, actionIndex);
|
|
519
|
+
if (policyFields.error) {
|
|
520
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', policyFields.error, 'mintActionsJson');
|
|
521
|
+
}
|
|
522
|
+
let actionPolicyId;
|
|
523
|
+
if (policyFields.script) {
|
|
524
|
+
try {
|
|
525
|
+
actionPolicyId = cardano_ledger_ts_1.Script.fromCbor(Buffer.from(policyFields.script, 'hex')).hash.toString();
|
|
526
|
+
}
|
|
527
|
+
catch (err) {
|
|
528
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
529
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `mintActions[${actionIndex}].mintingPolicyScript is not a valid Plutus script: ${errMsg}`, 'mintActionsJson');
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const bareAssetNameForExpansion = ((!!scriptParamsJson && mintingPolicyScript === validatorScript) || !!actionPolicyId) &&
|
|
492
533
|
action.assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH &&
|
|
493
534
|
action.assetUnit.length % 2 === 0 &&
|
|
494
535
|
/^[0-9a-fA-F]*$/.test(action.assetUnit);
|
|
495
536
|
if (!(0, validators_1.isAssetUnit)(action.assetUnit) && !bareAssetNameForExpansion) {
|
|
496
|
-
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when scriptParamsJson is set and the policy equals the validator)`, 'mintActionsJson');
|
|
537
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `Invalid assetUnit: "${action.assetUnit}" — must be policyId+assetName hex (or a bare assetName hex when a per-action mintingPolicyScript is set, or scriptParamsJson is set and the policy equals the validator)`, 'mintActionsJson');
|
|
497
538
|
}
|
|
498
|
-
|
|
539
|
+
let assetUnit = action.assetUnit;
|
|
540
|
+
if (actionPolicyId) {
|
|
541
|
+
if (assetUnit.length < const_1.MIN_FULL_ASSET_UNIT_LENGTH) {
|
|
542
|
+
assetUnit = actionPolicyId + assetUnit;
|
|
543
|
+
}
|
|
544
|
+
else if (!assetUnit.toLowerCase().startsWith(actionPolicyId)) {
|
|
545
|
+
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `mintActions[${actionIndex}].assetUnit "${assetUnit}" does not start with its own policy id ${actionPolicyId}`, 'mintActionsJson');
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
assetUnit,
|
|
550
|
+
quantity: BigInt(action.quantity),
|
|
551
|
+
...(typeof action.redeemer === 'number' ? { redeemer: action.redeemer } : {}),
|
|
552
|
+
...(policyFields.script ? { mintingPolicyScript: policyFields.script } : {}),
|
|
553
|
+
...(policyFields.redeemer !== undefined ? { redeemerJson: policyFields.redeemer } : {})
|
|
554
|
+
};
|
|
499
555
|
});
|
|
500
556
|
if (mintRedeemerJson) {
|
|
501
557
|
const mrJson = (0, validators_1.validateJsonWithLimits)(mintRedeemerJson, 'mintRedeemerJson');
|
|
@@ -556,7 +612,9 @@ module.exports = (srv) => {
|
|
|
556
612
|
}
|
|
557
613
|
if (mintPolicyId) {
|
|
558
614
|
const policyId = mintPolicyId;
|
|
559
|
-
|
|
615
|
+
// Actions with their own per-action script were already checked
|
|
616
|
+
// against THAT script's policy id during parsing.
|
|
617
|
+
const mismatch = parsedMintActions.find((action) => !action.mintingPolicyScript && !action.assetUnit.toLowerCase().startsWith(policyId));
|
|
560
618
|
if (mismatch) {
|
|
561
619
|
return (0, errors_1.rejectInvalid)(req, 'BuildPlutusSpendTransaction', `assetUnit "${mismatch.assetUnit}" does not start with the minting policy id ${policyId} — pass the full unit as policyId+assetName (asset names longer than 28 bytes cannot be passed bare)`, 'mintActionsJson');
|
|
562
620
|
}
|
|
@@ -55,4 +55,17 @@ export declare function parseExtraOutputs(extraOutputsJson: string | undefined):
|
|
|
55
55
|
parsed?: ParsedExtraOutput[];
|
|
56
56
|
error?: string;
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Parse the optional PER-ACTION policy fields of a mintActionsJson entry
|
|
60
|
+
* (multi-policy mint FR): `mintingPolicyScript` (CBOR hex, applied as-is; a
|
|
61
|
+
* parameterized per-action script must be pre-applied by the caller) and
|
|
62
|
+
* `redeemerJson` (a JSON-encoded string, same convention as extraOutputs'
|
|
63
|
+
* inlineDatumJson). Absent fields fall back to the action's top-level
|
|
64
|
+
* script/redeemer at build time.
|
|
65
|
+
*/
|
|
66
|
+
export declare function parseMintActionPolicyFields(entry: Record<string, unknown>, i: number): {
|
|
67
|
+
script?: string;
|
|
68
|
+
redeemer?: JSONValue;
|
|
69
|
+
error?: string;
|
|
70
|
+
};
|
|
58
71
|
//# sourceMappingURL=tx-request-parsers.d.ts.map
|
|
@@ -5,6 +5,7 @@ exports.parseUtxoRefArray = parseUtxoRefArray;
|
|
|
5
5
|
exports.parseRequiredSigners = parseRequiredSigners;
|
|
6
6
|
exports.parseAssetsArray = parseAssetsArray;
|
|
7
7
|
exports.parseExtraOutputs = parseExtraOutputs;
|
|
8
|
+
exports.parseMintActionPolicyFields = parseMintActionPolicyFields;
|
|
8
9
|
const validators_1 = require("./validators");
|
|
9
10
|
/**
|
|
10
11
|
* Shared parsers for the Build*-action JSON payload fields. Used by the
|
|
@@ -167,4 +168,35 @@ function parseExtraOutputs(extraOutputsJson) {
|
|
|
167
168
|
}
|
|
168
169
|
return { parsed: out };
|
|
169
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Parse the optional PER-ACTION policy fields of a mintActionsJson entry
|
|
173
|
+
* (multi-policy mint FR): `mintingPolicyScript` (CBOR hex, applied as-is; a
|
|
174
|
+
* parameterized per-action script must be pre-applied by the caller) and
|
|
175
|
+
* `redeemerJson` (a JSON-encoded string, same convention as extraOutputs'
|
|
176
|
+
* inlineDatumJson). Absent fields fall back to the action's top-level
|
|
177
|
+
* script/redeemer at build time.
|
|
178
|
+
*/
|
|
179
|
+
function parseMintActionPolicyFields(entry, i) {
|
|
180
|
+
let script;
|
|
181
|
+
if (entry.mintingPolicyScript !== undefined && entry.mintingPolicyScript !== null) {
|
|
182
|
+
if (typeof entry.mintingPolicyScript !== 'string' || !(0, validators_1.isValidCbor)(entry.mintingPolicyScript)) {
|
|
183
|
+
return { error: `mintActions[${i}].mintingPolicyScript must be even-length CBOR hex` };
|
|
184
|
+
}
|
|
185
|
+
script = entry.mintingPolicyScript;
|
|
186
|
+
}
|
|
187
|
+
let redeemer;
|
|
188
|
+
if (entry.redeemerJson !== undefined && entry.redeemerJson !== null) {
|
|
189
|
+
if (typeof entry.redeemerJson !== 'string') {
|
|
190
|
+
return { error: `mintActions[${i}].redeemerJson must be a JSON string` };
|
|
191
|
+
}
|
|
192
|
+
const jsonResult = (0, validators_1.validateJsonWithLimits)(entry.redeemerJson, `mintActions[${i}].redeemerJson`);
|
|
193
|
+
if (!jsonResult.valid)
|
|
194
|
+
return { error: jsonResult.error };
|
|
195
|
+
redeemer = jsonResult.parsed;
|
|
196
|
+
}
|
|
197
|
+
if (redeemer !== undefined && script === undefined) {
|
|
198
|
+
return { error: `mintActions[${i}].redeemerJson requires mintActions[${i}].mintingPolicyScript` };
|
|
199
|
+
}
|
|
200
|
+
return { script, redeemer };
|
|
201
|
+
}
|
|
170
202
|
//# sourceMappingURL=tx-request-parsers.js.map
|
package/srv/utils/types.d.ts
CHANGED
|
@@ -288,6 +288,21 @@ export type MintAction = {
|
|
|
288
288
|
quantity: bigint;
|
|
289
289
|
/** Optional redeemer data (integer). Defaults to 0 if not specified. */
|
|
290
290
|
redeemer?: number;
|
|
291
|
+
/**
|
|
292
|
+
* Optional PER-ACTION minting policy (CBOR hex). When set, this action
|
|
293
|
+
* mints under THIS script instead of the request's top-level
|
|
294
|
+
* mintingPolicyScript, enabling multiple policies in one transaction.
|
|
295
|
+
* Passed as-is (a parameterized script must be pre-applied); the action's
|
|
296
|
+
* assetUnit must carry this script's policyId.
|
|
297
|
+
*/
|
|
298
|
+
mintingPolicyScript?: string;
|
|
299
|
+
/**
|
|
300
|
+
* Optional PER-ACTION redeemer (parsed PlutusData JSON). Only valid
|
|
301
|
+
* together with mintingPolicyScript; falls back to the request's
|
|
302
|
+
* mintRedeemer when absent. Actions resolving to the SAME policy must
|
|
303
|
+
* agree on their redeemer (the ledger carries one redeemer per policy).
|
|
304
|
+
*/
|
|
305
|
+
redeemerJson?: JSONValue;
|
|
291
306
|
};
|
|
292
307
|
/**
|
|
293
308
|
* Plutus Script Execution Type - For spending from script addresses
|