@meshsdk/transaction 1.7.8 → 1.7.10

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
@@ -136,7 +136,7 @@ var MeshTxBuilderCore = class {
136
136
  /**
137
137
  * Set the input datum for transaction input
138
138
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
139
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
139
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
140
140
  * @returns The MeshTxBuilder instance
141
141
  */
142
142
  txInDatumValue = (datum, type = "Mesh") => {
@@ -233,7 +233,7 @@ var MeshTxBuilderCore = class {
233
233
  /**
234
234
  * Set the redeemer for the reference input to be spent in same transaction
235
235
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
236
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
236
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
237
237
  * @param exUnits The execution units budget for the redeemer
238
238
  * @returns The MeshTxBuilder instance
239
239
  */
@@ -274,7 +274,7 @@ var MeshTxBuilderCore = class {
274
274
  /**
275
275
  * Set the output datum hash for transaction
276
276
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
277
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
277
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
278
278
  * @returns The MeshTxBuilder instance
279
279
  */
280
280
  txOutDatumHashValue = (datum, type = "Mesh") => {
@@ -306,7 +306,7 @@ var MeshTxBuilderCore = class {
306
306
  /**
307
307
  * Set the output inline datum for transaction
308
308
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
309
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
309
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
310
310
  * @returns The MeshTxBuilder instance
311
311
  */
312
312
  txOutInlineDatumValue = (datum, type = "Mesh") => {
@@ -338,7 +338,7 @@ var MeshTxBuilderCore = class {
338
338
  /**
339
339
  * Set the output embed datum for transaction
340
340
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
341
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
341
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
342
342
  * @returns The MeshTxBuilder instance
343
343
  */
344
344
  txOutDatumEmbedValue = (datum, type = "Mesh") => {
@@ -370,10 +370,10 @@ var MeshTxBuilderCore = class {
370
370
  /**
371
371
  * Set the reference script to be attached with the output
372
372
  * @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
373
- * @param version Optional - The Plutus script version
373
+ * @param version Optional - The Plutus script version. Default to be V3 (Plutus V3)
374
374
  * @returns The MeshTxBuilder instance
375
375
  */
376
- txOutReferenceScript = (scriptCbor, version = "V2") => {
376
+ txOutReferenceScript = (scriptCbor, version = "V3") => {
377
377
  if (this.txOutput) {
378
378
  this.txOutput.referenceScript = { code: scriptCbor, version };
379
379
  }
@@ -457,7 +457,7 @@ var MeshTxBuilderCore = class {
457
457
  /**
458
458
  * [Alias of txInRedeemerValue] Set the redeemer for the reference input to be spent in same transaction
459
459
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
460
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
460
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
461
461
  * @param exUnits The execution units budget for the redeemer
462
462
  * @returns The MeshTxBuilder instance
463
463
  */
@@ -471,8 +471,12 @@ var MeshTxBuilderCore = class {
471
471
  * @param txIndex The transaction index of the reference UTxO
472
472
  * @returns The MeshTxBuilder instance
473
473
  */
474
- readOnlyTxInReference = (txHash, txIndex) => {
475
- this.meshTxBuilderBody.referenceInputs.push({ txHash, txIndex });
474
+ readOnlyTxInReference = (txHash, txIndex, scriptSize) => {
475
+ this.meshTxBuilderBody.referenceInputs.push({
476
+ txHash,
477
+ txIndex,
478
+ scriptSize
479
+ });
476
480
  return this;
477
481
  };
478
482
  /**
@@ -589,7 +593,7 @@ var MeshTxBuilderCore = class {
589
593
  /**
590
594
  * Set the redeemer for minting
591
595
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
592
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
596
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
593
597
  * @param exUnits The execution units budget for the redeemer
594
598
  * @returns The MeshTxBuilder instance
595
599
  */
@@ -613,7 +617,7 @@ var MeshTxBuilderCore = class {
613
617
  /**
614
618
  * Set the redeemer for the reference input to be spent in same transaction
615
619
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
616
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
620
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
617
621
  * @param exUnits The execution units budget for the redeemer
618
622
  * @returns The MeshTxBuilder instance
619
623
  */
@@ -774,7 +778,7 @@ var MeshTxBuilderCore = class {
774
778
  /**
775
779
  * Set the transaction withdrawal redeemer value in the MeshTxBuilder instance
776
780
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
777
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
781
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
778
782
  * @param exUnits The execution units budget for the redeemer
779
783
  * @returns The MeshTxBuilder instance
780
784
  */
@@ -903,9 +907,7 @@ var MeshTxBuilderCore = class {
903
907
  voteTxInReference = (txHash, txIndex, scriptSize, scriptHash) => {
904
908
  if (!this.voteItem) throw Error("voteTxInReference: Undefined vote");
905
909
  if (this.voteItem.type === "BasicVote")
906
- throw Error(
907
- "voteTxInReference: Adding script reference to a basic vote"
908
- );
910
+ throw Error("voteTxInReference: Adding script reference to a basic vote");
909
911
  if (this.voteItem.type === "ScriptVote") {
910
912
  this.voteItem.scriptSource = {
911
913
  type: "Inline",
@@ -1246,7 +1248,7 @@ var MeshTxBuilderCore = class {
1246
1248
  * @param strategy The strategy to be used in utxo selection
1247
1249
  * @param threshold Extra value needed to be selected for, usually for paying fees and min UTxO value of change output
1248
1250
  */
1249
- selectUtxosFrom = (extraInputs, strategy = "experimental", threshold = "5000000", includeTxFees = true) => {
1251
+ selectUtxosFrom = (extraInputs, strategy = "keepRelevant", threshold = "5000000", includeTxFees = true) => {
1250
1252
  this.meshTxBuilderBody.extraInputs = extraInputs;
1251
1253
  const newConfig = {
1252
1254
  threshold,
@@ -1536,6 +1538,13 @@ var MeshTxBuilderCore = class {
1536
1538
  }
1537
1539
  };
1538
1540
  this.meshTxBuilderBody.inputs.push(pubKeyTxIn);
1541
+ if (input.output.scriptRef) {
1542
+ this.meshTxBuilderBody.referenceInputs.push({
1543
+ txHash: input.input.txHash,
1544
+ txIndex: input.input.outputIndex,
1545
+ scriptSize: input.output.scriptRef.length / 2
1546
+ });
1547
+ }
1539
1548
  });
1540
1549
  };
1541
1550
  removeDuplicateInputs = () => {
@@ -1599,6 +1608,7 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
1599
1608
  txHex = "";
1600
1609
  queriedTxHashes = /* @__PURE__ */ new Set();
1601
1610
  queriedUTxOs = {};
1611
+ utxosWithRefScripts = [];
1602
1612
  constructor({
1603
1613
  serializer,
1604
1614
  fetcher,
@@ -1642,11 +1652,31 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
1642
1652
  }
1643
1653
  this.removeDuplicateInputs();
1644
1654
  const { inputs, collaterals, mints } = this.meshTxBuilderBody;
1645
- const incompleteTxIns = [...inputs, ...collaterals].filter(
1646
- (txIn) => !this.isInputComplete(txIn)
1647
- );
1655
+ const incompleteTxIns = [...inputs, ...collaterals];
1648
1656
  const incompleteMints = mints.filter((mint) => !this.isMintComplete(mint));
1649
1657
  await this.queryAllTxInfo(incompleteTxIns, incompleteMints);
1658
+ Object.values(this.queriedUTxOs).forEach((utxos) => {
1659
+ for (let utxo of utxos) {
1660
+ if (utxo.output.scriptRef !== void 0) {
1661
+ this.utxosWithRefScripts.push(utxo);
1662
+ }
1663
+ }
1664
+ });
1665
+ const missingRefInput = this.utxosWithRefScripts.filter((utxo) => {
1666
+ this.meshTxBuilderBody.referenceInputs.forEach((refInput) => {
1667
+ if (refInput.txHash === utxo.input.txHash && refInput.txIndex === utxo.input.outputIndex) {
1668
+ return false;
1669
+ }
1670
+ });
1671
+ return true;
1672
+ });
1673
+ missingRefInput.forEach((utxo) => {
1674
+ this.meshTxBuilderBody.referenceInputs.push({
1675
+ txHash: utxo.input.txHash,
1676
+ txIndex: utxo.input.outputIndex,
1677
+ scriptSize: utxo.output.scriptRef.length / 2
1678
+ });
1679
+ });
1650
1680
  incompleteTxIns.forEach((txIn) => {
1651
1681
  this.completeTxInformation(txIn);
1652
1682
  });
package/dist/index.d.cts CHANGED
@@ -39,7 +39,7 @@ declare class MeshTxBuilderCore {
39
39
  /**
40
40
  * Set the input datum for transaction input
41
41
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
42
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
42
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
43
43
  * @returns The MeshTxBuilder instance
44
44
  */
45
45
  txInDatumValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
@@ -59,7 +59,7 @@ declare class MeshTxBuilderCore {
59
59
  /**
60
60
  * Set the redeemer for the reference input to be spent in same transaction
61
61
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
62
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
62
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
63
63
  * @param exUnits The execution units budget for the redeemer
64
64
  * @returns The MeshTxBuilder instance
65
65
  */
@@ -77,28 +77,28 @@ declare class MeshTxBuilderCore {
77
77
  /**
78
78
  * Set the output datum hash for transaction
79
79
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
80
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
80
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
81
81
  * @returns The MeshTxBuilder instance
82
82
  */
83
83
  txOutDatumHashValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
84
84
  /**
85
85
  * Set the output inline datum for transaction
86
86
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
87
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
87
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
88
88
  * @returns The MeshTxBuilder instance
89
89
  */
90
90
  txOutInlineDatumValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
91
91
  /**
92
92
  * Set the output embed datum for transaction
93
93
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
94
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
94
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
95
95
  * @returns The MeshTxBuilder instance
96
96
  */
97
97
  txOutDatumEmbedValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
98
98
  /**
99
99
  * Set the reference script to be attached with the output
100
100
  * @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
101
- * @param version Optional - The Plutus script version
101
+ * @param version Optional - The Plutus script version. Default to be V3 (Plutus V3)
102
102
  * @returns The MeshTxBuilder instance
103
103
  */
104
104
  txOutReferenceScript: (scriptCbor: string, version?: LanguageVersion) => this;
@@ -140,7 +140,7 @@ declare class MeshTxBuilderCore {
140
140
  /**
141
141
  * [Alias of txInRedeemerValue] Set the redeemer for the reference input to be spent in same transaction
142
142
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
143
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
143
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
144
144
  * @param exUnits The execution units budget for the redeemer
145
145
  * @returns The MeshTxBuilder instance
146
146
  */
@@ -154,7 +154,7 @@ declare class MeshTxBuilderCore {
154
154
  * @param txIndex The transaction index of the reference UTxO
155
155
  * @returns The MeshTxBuilder instance
156
156
  */
157
- readOnlyTxInReference: (txHash: string, txIndex: number) => this;
157
+ readOnlyTxInReference: (txHash: string, txIndex: number, scriptSize?: number) => this;
158
158
  /**
159
159
  * Set the minting script for the current mint
160
160
  * @param languageVersion The Plutus script version
@@ -203,7 +203,7 @@ declare class MeshTxBuilderCore {
203
203
  /**
204
204
  * Set the redeemer for minting
205
205
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
206
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
206
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
207
207
  * @param exUnits The execution units budget for the redeemer
208
208
  * @returns The MeshTxBuilder instance
209
209
  */
@@ -214,7 +214,7 @@ declare class MeshTxBuilderCore {
214
214
  /**
215
215
  * Set the redeemer for the reference input to be spent in same transaction
216
216
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
217
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
217
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
218
218
  * @param exUnits The execution units budget for the redeemer
219
219
  * @returns The MeshTxBuilder instance
220
220
  */
@@ -283,7 +283,7 @@ declare class MeshTxBuilderCore {
283
283
  /**
284
284
  * Set the transaction withdrawal redeemer value in the MeshTxBuilder instance
285
285
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
286
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
286
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
287
287
  * @param exUnits The execution units budget for the redeemer
288
288
  * @returns The MeshTxBuilder instance
289
289
  */
@@ -519,6 +519,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
519
519
  protected queriedUTxOs: {
520
520
  [x: string]: UTxO[];
521
521
  };
522
+ protected utxosWithRefScripts: UTxO[];
522
523
  constructor({ serializer, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
523
524
  /**
524
525
  * It builds the transaction and query the blockchain for missing information
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ declare class MeshTxBuilderCore {
39
39
  /**
40
40
  * Set the input datum for transaction input
41
41
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
42
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
42
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
43
43
  * @returns The MeshTxBuilder instance
44
44
  */
45
45
  txInDatumValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
@@ -59,7 +59,7 @@ declare class MeshTxBuilderCore {
59
59
  /**
60
60
  * Set the redeemer for the reference input to be spent in same transaction
61
61
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
62
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
62
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
63
63
  * @param exUnits The execution units budget for the redeemer
64
64
  * @returns The MeshTxBuilder instance
65
65
  */
@@ -77,28 +77,28 @@ declare class MeshTxBuilderCore {
77
77
  /**
78
78
  * Set the output datum hash for transaction
79
79
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
80
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
80
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
81
81
  * @returns The MeshTxBuilder instance
82
82
  */
83
83
  txOutDatumHashValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
84
84
  /**
85
85
  * Set the output inline datum for transaction
86
86
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
87
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
87
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
88
88
  * @returns The MeshTxBuilder instance
89
89
  */
90
90
  txOutInlineDatumValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
91
91
  /**
92
92
  * Set the output embed datum for transaction
93
93
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
94
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
94
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
95
95
  * @returns The MeshTxBuilder instance
96
96
  */
97
97
  txOutDatumEmbedValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
98
98
  /**
99
99
  * Set the reference script to be attached with the output
100
100
  * @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
101
- * @param version Optional - The Plutus script version
101
+ * @param version Optional - The Plutus script version. Default to be V3 (Plutus V3)
102
102
  * @returns The MeshTxBuilder instance
103
103
  */
104
104
  txOutReferenceScript: (scriptCbor: string, version?: LanguageVersion) => this;
@@ -140,7 +140,7 @@ declare class MeshTxBuilderCore {
140
140
  /**
141
141
  * [Alias of txInRedeemerValue] Set the redeemer for the reference input to be spent in same transaction
142
142
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
143
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
143
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
144
144
  * @param exUnits The execution units budget for the redeemer
145
145
  * @returns The MeshTxBuilder instance
146
146
  */
@@ -154,7 +154,7 @@ declare class MeshTxBuilderCore {
154
154
  * @param txIndex The transaction index of the reference UTxO
155
155
  * @returns The MeshTxBuilder instance
156
156
  */
157
- readOnlyTxInReference: (txHash: string, txIndex: number) => this;
157
+ readOnlyTxInReference: (txHash: string, txIndex: number, scriptSize?: number) => this;
158
158
  /**
159
159
  * Set the minting script for the current mint
160
160
  * @param languageVersion The Plutus script version
@@ -203,7 +203,7 @@ declare class MeshTxBuilderCore {
203
203
  /**
204
204
  * Set the redeemer for minting
205
205
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
206
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
206
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
207
207
  * @param exUnits The execution units budget for the redeemer
208
208
  * @returns The MeshTxBuilder instance
209
209
  */
@@ -214,7 +214,7 @@ declare class MeshTxBuilderCore {
214
214
  /**
215
215
  * Set the redeemer for the reference input to be spent in same transaction
216
216
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
217
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
217
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
218
218
  * @param exUnits The execution units budget for the redeemer
219
219
  * @returns The MeshTxBuilder instance
220
220
  */
@@ -283,7 +283,7 @@ declare class MeshTxBuilderCore {
283
283
  /**
284
284
  * Set the transaction withdrawal redeemer value in the MeshTxBuilder instance
285
285
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
286
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
286
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
287
287
  * @param exUnits The execution units budget for the redeemer
288
288
  * @returns The MeshTxBuilder instance
289
289
  */
@@ -519,6 +519,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
519
519
  protected queriedUTxOs: {
520
520
  [x: string]: UTxO[];
521
521
  };
522
+ protected utxosWithRefScripts: UTxO[];
522
523
  constructor({ serializer, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
523
524
  /**
524
525
  * It builds the transaction and query the blockchain for missing information
package/dist/index.js CHANGED
@@ -103,7 +103,7 @@ var MeshTxBuilderCore = class {
103
103
  /**
104
104
  * Set the input datum for transaction input
105
105
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
106
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
106
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
107
107
  * @returns The MeshTxBuilder instance
108
108
  */
109
109
  txInDatumValue = (datum, type = "Mesh") => {
@@ -200,7 +200,7 @@ var MeshTxBuilderCore = class {
200
200
  /**
201
201
  * Set the redeemer for the reference input to be spent in same transaction
202
202
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
203
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
203
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
204
204
  * @param exUnits The execution units budget for the redeemer
205
205
  * @returns The MeshTxBuilder instance
206
206
  */
@@ -241,7 +241,7 @@ var MeshTxBuilderCore = class {
241
241
  /**
242
242
  * Set the output datum hash for transaction
243
243
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
244
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
244
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
245
245
  * @returns The MeshTxBuilder instance
246
246
  */
247
247
  txOutDatumHashValue = (datum, type = "Mesh") => {
@@ -273,7 +273,7 @@ var MeshTxBuilderCore = class {
273
273
  /**
274
274
  * Set the output inline datum for transaction
275
275
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
276
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
276
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
277
277
  * @returns The MeshTxBuilder instance
278
278
  */
279
279
  txOutInlineDatumValue = (datum, type = "Mesh") => {
@@ -305,7 +305,7 @@ var MeshTxBuilderCore = class {
305
305
  /**
306
306
  * Set the output embed datum for transaction
307
307
  * @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
308
- * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
308
+ * @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
309
309
  * @returns The MeshTxBuilder instance
310
310
  */
311
311
  txOutDatumEmbedValue = (datum, type = "Mesh") => {
@@ -337,10 +337,10 @@ var MeshTxBuilderCore = class {
337
337
  /**
338
338
  * Set the reference script to be attached with the output
339
339
  * @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
340
- * @param version Optional - The Plutus script version
340
+ * @param version Optional - The Plutus script version. Default to be V3 (Plutus V3)
341
341
  * @returns The MeshTxBuilder instance
342
342
  */
343
- txOutReferenceScript = (scriptCbor, version = "V2") => {
343
+ txOutReferenceScript = (scriptCbor, version = "V3") => {
344
344
  if (this.txOutput) {
345
345
  this.txOutput.referenceScript = { code: scriptCbor, version };
346
346
  }
@@ -424,7 +424,7 @@ var MeshTxBuilderCore = class {
424
424
  /**
425
425
  * [Alias of txInRedeemerValue] Set the redeemer for the reference input to be spent in same transaction
426
426
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
427
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
427
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
428
428
  * @param exUnits The execution units budget for the redeemer
429
429
  * @returns The MeshTxBuilder instance
430
430
  */
@@ -438,8 +438,12 @@ var MeshTxBuilderCore = class {
438
438
  * @param txIndex The transaction index of the reference UTxO
439
439
  * @returns The MeshTxBuilder instance
440
440
  */
441
- readOnlyTxInReference = (txHash, txIndex) => {
442
- this.meshTxBuilderBody.referenceInputs.push({ txHash, txIndex });
441
+ readOnlyTxInReference = (txHash, txIndex, scriptSize) => {
442
+ this.meshTxBuilderBody.referenceInputs.push({
443
+ txHash,
444
+ txIndex,
445
+ scriptSize
446
+ });
443
447
  return this;
444
448
  };
445
449
  /**
@@ -556,7 +560,7 @@ var MeshTxBuilderCore = class {
556
560
  /**
557
561
  * Set the redeemer for minting
558
562
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
559
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
563
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
560
564
  * @param exUnits The execution units budget for the redeemer
561
565
  * @returns The MeshTxBuilder instance
562
566
  */
@@ -580,7 +584,7 @@ var MeshTxBuilderCore = class {
580
584
  /**
581
585
  * Set the redeemer for the reference input to be spent in same transaction
582
586
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
583
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
587
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
584
588
  * @param exUnits The execution units budget for the redeemer
585
589
  * @returns The MeshTxBuilder instance
586
590
  */
@@ -741,7 +745,7 @@ var MeshTxBuilderCore = class {
741
745
  /**
742
746
  * Set the transaction withdrawal redeemer value in the MeshTxBuilder instance
743
747
  * @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
744
- * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
748
+ * @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string. Default to be Mesh type
745
749
  * @param exUnits The execution units budget for the redeemer
746
750
  * @returns The MeshTxBuilder instance
747
751
  */
@@ -870,9 +874,7 @@ var MeshTxBuilderCore = class {
870
874
  voteTxInReference = (txHash, txIndex, scriptSize, scriptHash) => {
871
875
  if (!this.voteItem) throw Error("voteTxInReference: Undefined vote");
872
876
  if (this.voteItem.type === "BasicVote")
873
- throw Error(
874
- "voteTxInReference: Adding script reference to a basic vote"
875
- );
877
+ throw Error("voteTxInReference: Adding script reference to a basic vote");
876
878
  if (this.voteItem.type === "ScriptVote") {
877
879
  this.voteItem.scriptSource = {
878
880
  type: "Inline",
@@ -1213,7 +1215,7 @@ var MeshTxBuilderCore = class {
1213
1215
  * @param strategy The strategy to be used in utxo selection
1214
1216
  * @param threshold Extra value needed to be selected for, usually for paying fees and min UTxO value of change output
1215
1217
  */
1216
- selectUtxosFrom = (extraInputs, strategy = "experimental", threshold = "5000000", includeTxFees = true) => {
1218
+ selectUtxosFrom = (extraInputs, strategy = "keepRelevant", threshold = "5000000", includeTxFees = true) => {
1217
1219
  this.meshTxBuilderBody.extraInputs = extraInputs;
1218
1220
  const newConfig = {
1219
1221
  threshold,
@@ -1503,6 +1505,13 @@ var MeshTxBuilderCore = class {
1503
1505
  }
1504
1506
  };
1505
1507
  this.meshTxBuilderBody.inputs.push(pubKeyTxIn);
1508
+ if (input.output.scriptRef) {
1509
+ this.meshTxBuilderBody.referenceInputs.push({
1510
+ txHash: input.input.txHash,
1511
+ txIndex: input.input.outputIndex,
1512
+ scriptSize: input.output.scriptRef.length / 2
1513
+ });
1514
+ }
1506
1515
  });
1507
1516
  };
1508
1517
  removeDuplicateInputs = () => {
@@ -1566,6 +1575,7 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
1566
1575
  txHex = "";
1567
1576
  queriedTxHashes = /* @__PURE__ */ new Set();
1568
1577
  queriedUTxOs = {};
1578
+ utxosWithRefScripts = [];
1569
1579
  constructor({
1570
1580
  serializer,
1571
1581
  fetcher,
@@ -1609,11 +1619,31 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
1609
1619
  }
1610
1620
  this.removeDuplicateInputs();
1611
1621
  const { inputs, collaterals, mints } = this.meshTxBuilderBody;
1612
- const incompleteTxIns = [...inputs, ...collaterals].filter(
1613
- (txIn) => !this.isInputComplete(txIn)
1614
- );
1622
+ const incompleteTxIns = [...inputs, ...collaterals];
1615
1623
  const incompleteMints = mints.filter((mint) => !this.isMintComplete(mint));
1616
1624
  await this.queryAllTxInfo(incompleteTxIns, incompleteMints);
1625
+ Object.values(this.queriedUTxOs).forEach((utxos) => {
1626
+ for (let utxo of utxos) {
1627
+ if (utxo.output.scriptRef !== void 0) {
1628
+ this.utxosWithRefScripts.push(utxo);
1629
+ }
1630
+ }
1631
+ });
1632
+ const missingRefInput = this.utxosWithRefScripts.filter((utxo) => {
1633
+ this.meshTxBuilderBody.referenceInputs.forEach((refInput) => {
1634
+ if (refInput.txHash === utxo.input.txHash && refInput.txIndex === utxo.input.outputIndex) {
1635
+ return false;
1636
+ }
1637
+ });
1638
+ return true;
1639
+ });
1640
+ missingRefInput.forEach((utxo) => {
1641
+ this.meshTxBuilderBody.referenceInputs.push({
1642
+ txHash: utxo.input.txHash,
1643
+ txIndex: utxo.input.outputIndex,
1644
+ scriptSize: utxo.output.scriptRef.length / 2
1645
+ });
1646
+ });
1617
1647
  incompleteTxIns.forEach((txIn) => {
1618
1648
  this.completeTxInformation(txIn);
1619
1649
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/transaction",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -9,9 +9,9 @@
9
9
  "type": "module",
10
10
  "exports": {
11
11
  ".": {
12
+ "types": "./dist/index.d.ts",
12
13
  "import": "./dist/index.js",
13
- "require": "./dist/index.cjs",
14
- "types": "./dist/index.d.ts"
14
+ "require": "./dist/index.cjs"
15
15
  }
16
16
  },
17
17
  "files": [
@@ -35,9 +35,9 @@
35
35
  "typescript": "^5.3.3"
36
36
  },
37
37
  "dependencies": {
38
- "@meshsdk/common": "1.7.8",
39
- "@meshsdk/core-csl": "1.7.8",
40
- "@meshsdk/core-cst": "1.7.8",
38
+ "@meshsdk/common": "1.7.10",
39
+ "@meshsdk/core-csl": "1.7.10",
40
+ "@meshsdk/core-cst": "1.7.10",
41
41
  "json-bigint": "^1.0.0"
42
42
  },
43
43
  "prettier": "@meshsdk/configs/prettier",