@meshsdk/core-cst 1.9.0-beta-39 → 1.9.0-beta-40

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/dist/index.cjs CHANGED
@@ -6252,7 +6252,10 @@ var CardanoSDKSerializerCore = class {
6252
6252
  validityRange,
6253
6253
  certificates,
6254
6254
  withdrawals,
6255
- votes
6255
+ votes,
6256
+ totalCollateral,
6257
+ collateralReturnAddress,
6258
+ changeAddress
6256
6259
  } = txBuilderBody;
6257
6260
  const uniqueRefInputs = this.removeBodyInputRefInputOverlap(
6258
6261
  inputs,
@@ -6267,6 +6270,14 @@ var CardanoSDKSerializerCore = class {
6267
6270
  this.addAllWithdrawals(withdrawals);
6268
6271
  this.addAllVotes(votes);
6269
6272
  this.addAllCollateralInputs(collaterals);
6273
+ if (totalCollateral) {
6274
+ this.txBody.setTotalCollateral(BigInt(totalCollateral));
6275
+ this.addCollateralReturn(
6276
+ totalCollateral,
6277
+ collaterals,
6278
+ collateralReturnAddress ?? changeAddress
6279
+ );
6280
+ }
6270
6281
  this.addAllReferenceInputs(uniqueRefInputs);
6271
6282
  this.removeInputRefInputOverlap();
6272
6283
  this.setValidityInterval(validityRange);
@@ -6800,6 +6811,22 @@ var CardanoSDKSerializerCore = class {
6800
6811
  this.utxoContext.set(cardanoTxIn, cardanoTxOut);
6801
6812
  this.txBody.setCollateral(collateralInputs);
6802
6813
  };
6814
+ addCollateralReturn = (totalCollateral, collaterals, collateralReturnAddress) => {
6815
+ let collateralReturnValue = Value.fromCore({
6816
+ coins: -BigInt(totalCollateral)
6817
+ });
6818
+ for (const collateral of collaterals) {
6819
+ collateralReturnValue = mergeValue(
6820
+ collateralReturnValue,
6821
+ toValue(collateral.txIn.amount)
6822
+ );
6823
+ }
6824
+ const collateralReturn = new TransactionOutput(
6825
+ toCardanoAddress(collateralReturnAddress),
6826
+ collateralReturnValue
6827
+ );
6828
+ this.txBody.setCollateralReturn(collateralReturn);
6829
+ };
6803
6830
  setValidityInterval = (validity) => {
6804
6831
  if (validity.invalidBefore) {
6805
6832
  this.txBody.setValidityStartInterval(Slot(validity.invalidBefore));
package/dist/index.js CHANGED
@@ -6102,7 +6102,10 @@ var CardanoSDKSerializerCore = class {
6102
6102
  validityRange,
6103
6103
  certificates,
6104
6104
  withdrawals,
6105
- votes
6105
+ votes,
6106
+ totalCollateral,
6107
+ collateralReturnAddress,
6108
+ changeAddress
6106
6109
  } = txBuilderBody;
6107
6110
  const uniqueRefInputs = this.removeBodyInputRefInputOverlap(
6108
6111
  inputs,
@@ -6117,6 +6120,14 @@ var CardanoSDKSerializerCore = class {
6117
6120
  this.addAllWithdrawals(withdrawals);
6118
6121
  this.addAllVotes(votes);
6119
6122
  this.addAllCollateralInputs(collaterals);
6123
+ if (totalCollateral) {
6124
+ this.txBody.setTotalCollateral(BigInt(totalCollateral));
6125
+ this.addCollateralReturn(
6126
+ totalCollateral,
6127
+ collaterals,
6128
+ collateralReturnAddress ?? changeAddress
6129
+ );
6130
+ }
6120
6131
  this.addAllReferenceInputs(uniqueRefInputs);
6121
6132
  this.removeInputRefInputOverlap();
6122
6133
  this.setValidityInterval(validityRange);
@@ -6650,6 +6661,22 @@ var CardanoSDKSerializerCore = class {
6650
6661
  this.utxoContext.set(cardanoTxIn, cardanoTxOut);
6651
6662
  this.txBody.setCollateral(collateralInputs);
6652
6663
  };
6664
+ addCollateralReturn = (totalCollateral, collaterals, collateralReturnAddress) => {
6665
+ let collateralReturnValue = Value.fromCore({
6666
+ coins: -BigInt(totalCollateral)
6667
+ });
6668
+ for (const collateral of collaterals) {
6669
+ collateralReturnValue = mergeValue(
6670
+ collateralReturnValue,
6671
+ toValue(collateral.txIn.amount)
6672
+ );
6673
+ }
6674
+ const collateralReturn = new TransactionOutput(
6675
+ toCardanoAddress(collateralReturnAddress),
6676
+ collateralReturnValue
6677
+ );
6678
+ this.txBody.setCollateralReturn(collateralReturn);
6679
+ };
6653
6680
  setValidityInterval = (validity) => {
6654
6681
  if (validity.invalidBefore) {
6655
6682
  this.txBody.setValidityStartInterval(Slot(validity.invalidBefore));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/core-cst",
3
- "version": "1.9.0-beta-39",
3
+ "version": "1.9.0-beta-40",
4
4
  "description": "Types and utilities functions between Mesh and cardano-js-sdk",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "@harmoniclabs/plutus-data": "1.2.4",
45
45
  "@harmoniclabs/uplc": "1.2.4",
46
46
  "@harmoniclabs/pair": "^1.0.0",
47
- "@meshsdk/common": "1.9.0-beta-39",
47
+ "@meshsdk/common": "1.9.0-beta-40",
48
48
  "@types/base32-encoding": "^1.0.2",
49
49
  "base32-encoding": "^1.0.0",
50
50
  "bech32": "^2.0.0",