Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/configs/typescript/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"sourceMap": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": false
"noUnusedLocals": false,
"types": ["node", "jest"]
}
}
2 changes: 1 addition & 1 deletion packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"blakejs": "^1.2.1",
"bn.js": "^5.2.0",
"hash.js": "^1.1.7",
"scalus": "^0.14.2"
"scalus": "^0.17.0"
},
"overrides": {
"@cardano-sdk/crypto": {
Expand Down
38 changes: 38 additions & 0 deletions packages/mesh-core-cst/src/utils/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,41 @@ export const toPlutusLanguageVersion = (
return PlutusLanguageVersion.V3;
}
};

export const utxosToCborMap = (utxos: UTxO[]): string => {
const cborWriter = new Serialization.CborWriter();
cborWriter.writeStartMap(utxos.length);
for (const utxo of utxos) {
const cardanoUtxo = toTxUnspentOutput(utxo);
cborWriter.writeEncodedValue(
Buffer.from(cardanoUtxo.input().toCbor(), "hex"),
);
cborWriter.writeEncodedValue(
Buffer.from(cardanoUtxo.output().toCbor(), "hex"),
);
}
return cborWriter.encodeAsHex();
};

export const cborMapToUtxos = (cborMaps: string[]): UTxO[] => {
const utxos: UTxO[] = [];
for (const cborMap of cborMaps) {
const cborReader = new Serialization.CborReader(
Buffer.from(cborMap, "hex"),
);
const mapLength = cborReader.readStartMap();
if (!mapLength) {
throw new Error("Invalid CBOR map: expected a map of UTxOs");
}
for (let i = 0; i < mapLength; i++) {
const inputCbor = cborReader.readEncodedValue();
const outputCbor = cborReader.readEncodedValue();
const utxo = Serialization.TransactionUnspentOutput.fromCore([
Serialization.TransactionInput.fromCbor(inputCbor).toCore(),
Serialization.TransactionOutput.fromCbor(outputCbor).toCore(),
]);
utxos.push(fromTxUnspentOutput(utxo));
}
}
return utxos;
};
3 changes: 2 additions & 1 deletion packages/mesh-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@meshsdk/core-cst": "1.9.0-beta.102",
"@meshsdk/provider": "1.9.0-beta.100",
"@meshsdk/transaction": "1.9.0-beta.102",
"@meshsdk/wallet": "1.9.0-beta.102"
"@meshsdk/wallet": "1.9.0-beta.102",
"scalus": "^0.17.0"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
Loading
Loading