@harmoniclabs/buildooor 0.1.15 → 0.1.17

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.
@@ -21,7 +21,7 @@ export declare class TxBuilder {
21
21
  calcMinFee(tx: Tx, minimum?: CanBeUInteger | undefined): bigint;
22
22
  getMinimumOutputLovelaces(tx_out: TxOut | CanBeCborString): bigint;
23
23
  addMinLovelacesIfMissing(txOut: TxOut): TxOut;
24
- minimizeLovelaces(out: ITxOut): TxOut;
24
+ minimizeLovelaces(out: ITxOut, increment?: bigint | number): TxOut;
25
25
  /**
26
26
  *
27
27
  * @param slotN number of the slot
@@ -233,12 +233,18 @@ var TxBuilder = /** @class */ (function () {
233
233
  refScript: txOut.refScript
234
234
  });
235
235
  };
236
- TxBuilder.prototype.minimizeLovelaces = function (out) {
236
+ TxBuilder.prototype.minimizeLovelaces = function (out, increment) {
237
+ if (increment === void 0) { increment = 0; }
238
+ increment = BigInt(typeof increment === "number" ? increment :
239
+ typeof increment === "bigint" ? increment :
240
+ 0);
237
241
  var o = out instanceof cardano_ledger_ts_1.TxOut ? out : (0, txBuild_1.txBuildOutToTxOut)(out);
238
- var minLovelaces = this.getMinimumOutputLovelaces(o);
242
+ var minLovelaces = (this.getMinimumOutputLovelaces(o) +
243
+ // somehow we always underestimate a tiny bit
244
+ (BigInt(32) * BigInt(this.protocolParamters.utxoCostPerByte)));
239
245
  return new cardano_ledger_ts_1.TxOut({
240
246
  address: o.address,
241
- value: cardano_ledger_ts_1.Value.add(cardano_ledger_ts_1.Value.sub(o.value, cardano_ledger_ts_1.Value.lovelaces(o.value.lovelaces)), cardano_ledger_ts_1.Value.lovelaces(minLovelaces)),
247
+ value: cardano_ledger_ts_1.Value.add(cardano_ledger_ts_1.Value.sub(o.value, cardano_ledger_ts_1.Value.lovelaces(o.value.lovelaces)), cardano_ledger_ts_1.Value.lovelaces(minLovelaces + increment)),
242
248
  datum: o.datum,
243
249
  refScript: o.refScript
244
250
  });
@@ -1,6 +1,12 @@
1
- import { IUTxO, Script, UTxO } from "@harmoniclabs/cardano-ledger-ts";
1
+ import { IUTxO, Script, TxOut, UTxO } from "@harmoniclabs/cardano-ledger-ts";
2
2
  import { Data } from "@harmoniclabs/plutus-data";
3
3
  import { CanBeData } from "../utils/CanBeData.js";
4
+ export interface PlutusTxInterface {
5
+ inputs: UTxO[];
6
+ outputs: TxOut[];
7
+ refInputs: UTxO[];
8
+ }
9
+ export type PlutusDataCallback = (tx: PlutusTxInterface, scriptContextData: Data) => Data;
4
10
  export type ScriptWithRedeemer = {
5
11
  inline: Script;
6
12
  redeemer: Data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harmoniclabs/buildooor",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Cardano transaction builder in typescript",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",