@odatano/core 0.3.15 → 0.3.16
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing-helper.d.ts","sourceRoot":"","sources":["signing-helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signing-helper.d.ts","sourceRoot":"","sources":["signing-helper.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAC,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAyCtG;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAkBzD"}
|
|
@@ -40,7 +40,8 @@ exports.combineTransactionWithWitnesses = combineTransactionWithWitnesses;
|
|
|
40
40
|
exports.isWitnessSetCbor = isWitnessSetCbor;
|
|
41
41
|
const cds_1 = __importDefault(require("@sap/cds"));
|
|
42
42
|
const CSL = __importStar(require("@emurgo/cardano-serialization-lib-nodejs"));
|
|
43
|
-
const
|
|
43
|
+
const cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts");
|
|
44
|
+
const uint8array_utils_1 = require("@harmoniclabs/uint8array-utils");
|
|
44
45
|
const errors_1 = require("./errors");
|
|
45
46
|
const logger = cds_1.default.log('SigningHelper');
|
|
46
47
|
/**
|
|
@@ -58,54 +59,33 @@ const logger = cds_1.default.log('SigningHelper');
|
|
|
58
59
|
*/
|
|
59
60
|
function combineTransactionWithWitnesses(unsignedTxCbor, witnessSetCbor) {
|
|
60
61
|
try {
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const origWs = txArray[1];
|
|
79
|
-
const walletWs = walletWitnessSet;
|
|
80
|
-
if (walletWs instanceof Map && origWs instanceof Map) {
|
|
81
|
-
const vkeys = walletWs.get(0);
|
|
82
|
-
if (vkeys) {
|
|
83
|
-
origWs.set(0, vkeys);
|
|
84
|
-
}
|
|
85
|
-
txArray[1] = origWs;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
// Fallback for non-Map witness sets (simple transactions)
|
|
89
|
-
txArray[1] = walletWitnessSet;
|
|
90
|
-
}
|
|
91
|
-
// Re-encode to CBOR
|
|
92
|
-
const signedTxBytes = cbor.encodeOne(txArray);
|
|
93
|
-
const signedTxCbor = signedTxBytes.toString('hex');
|
|
94
|
-
// Count witnesses for logging
|
|
95
|
-
let witnessCount = 0;
|
|
96
|
-
let witnessKeys = [];
|
|
97
|
-
if (txArray[1] instanceof Map) {
|
|
98
|
-
const vkeys = txArray[1].get(0);
|
|
99
|
-
witnessCount = Array.isArray(vkeys) ? vkeys.length : 0;
|
|
100
|
-
witnessKeys = [...txArray[1].keys()];
|
|
62
|
+
// Parse unsigned transaction using harmoniclabs — preserves original CBOR encoding
|
|
63
|
+
// via SubCborRef. This is critical: the npm 'cbor' library normalizes encoding
|
|
64
|
+
// (indefinite→definite length, non-minimal integers) during round-trip, which
|
|
65
|
+
// changes redeemer bytes and causes PPViewHashesDontMatch on Plutus transactions.
|
|
66
|
+
// Harmoniclabs preserves body bytes via body.cborRef and individual witness element
|
|
67
|
+
// bytes via their own SubCborRef. See signature-verifier.ts for the same pattern.
|
|
68
|
+
const tx = cardano_ledger_ts_1.Tx.fromCbor((0, uint8array_utils_1.fromHex)(unsignedTxCbor));
|
|
69
|
+
// Parse wallet's witness set (CIP-30 signTx() returns only the witness set)
|
|
70
|
+
const walletWs = cardano_ledger_ts_1.TxWitnessSet.fromCbor((0, uint8array_utils_1.fromHex)(witnessSetCbor));
|
|
71
|
+
// Add each VKey witness from the wallet to the transaction.
|
|
72
|
+
// This follows the same pattern as harmoniclabs' own signWithCip30Wallet() (Tx.js:168).
|
|
73
|
+
// addVKeyWitness clears Tx.cborRef and TxWitnessSet.cborRef, but body.cborRef and
|
|
74
|
+
// individual redeemer/datum/script SubCborRefs are preserved. Re-serialization uses
|
|
75
|
+
// the same @harmoniclabs/cbor library as the builder, ensuring consistent encoding.
|
|
76
|
+
const vkeys = walletWs.vkeyWitnesses ?? [];
|
|
77
|
+
for (const vkeyWit of vkeys) {
|
|
78
|
+
tx.addVKeyWitness(vkeyWit);
|
|
101
79
|
}
|
|
80
|
+
// Export the signed transaction — body bytes preserved, witness set re-serialized
|
|
81
|
+
// with wallet VKeys merged into the builder's script witnesses
|
|
82
|
+
const signedTxCbor = (0, uint8array_utils_1.toHex)(tx.toCborBytes());
|
|
102
83
|
logger.info({
|
|
103
84
|
unsignedTxLength: unsignedTxCbor.length,
|
|
104
85
|
witnessSetLength: witnessSetCbor.length,
|
|
105
86
|
signedTxLength: signedTxCbor.length,
|
|
106
|
-
witnessCount,
|
|
107
|
-
|
|
108
|
-
}, 'Combined transaction with witness set (raw CBOR)');
|
|
87
|
+
witnessCount: vkeys.length,
|
|
88
|
+
}, 'Combined transaction with witness set (harmoniclabs byte-preserving)');
|
|
109
89
|
return signedTxCbor;
|
|
110
90
|
}
|
|
111
91
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing-helper.js","sourceRoot":"","sources":["signing-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"signing-helper.js","sourceRoot":"","sources":["signing-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,0EAyCC;AAWD,4CAkBC;AA3FD,mDAA2B;AAC3B,8EAAgE;AAChE,uEAAmE;AACnE,qEAAgE;AAChE,qCAAsD;A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