@meshsdk/transaction 1.7.2 → 1.7.4

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
@@ -376,6 +376,16 @@ var MeshTxBuilderCore = class {
376
376
  }
377
377
  return this;
378
378
  };
379
+ /**
380
+ * Set the reference script to be attached with the output
381
+ * @param languageVersion The Plutus script version
382
+ * @returns The MeshTxBuilder instance
383
+ */
384
+ spendingPlutusScript = (languageVersion) => {
385
+ this.addingPlutusScriptInput = true;
386
+ this.plutusSpendingScriptVersion = languageVersion;
387
+ return this;
388
+ };
379
389
  /**
380
390
  * Set the instruction that it is currently using V1 Plutus spending scripts
381
391
  * @returns The MeshTxBuilder instance
@@ -462,6 +472,16 @@ var MeshTxBuilderCore = class {
462
472
  this.meshTxBuilderBody.referenceInputs.push({ txHash, txIndex });
463
473
  return this;
464
474
  };
475
+ /**
476
+ * Set the minting script for the current mint
477
+ * @param languageVersion The Plutus script version
478
+ * @returns The MeshTxBuilder instance
479
+ */
480
+ mintPlutusScript = (languageVersion) => {
481
+ this.addingPlutusMint = true;
482
+ this.plutusMintingScriptVersion = languageVersion;
483
+ return this;
484
+ };
465
485
  /**
466
486
  * Set the instruction that it is currently using V1 Plutus minting scripts
467
487
  * @returns The MeshTxBuilder instance
@@ -630,6 +650,16 @@ var MeshTxBuilderCore = class {
630
650
  };
631
651
  return this;
632
652
  };
653
+ /**
654
+ * Set the instruction that it is currently using V1 Plutus withdrawal scripts
655
+ * @param languageVersion The Plutus script version
656
+ * @returns The MeshTxBuilder instance
657
+ */
658
+ withdrawalPlutusScript = (languageVersion) => {
659
+ this.addingPlutusWithdrawal = true;
660
+ this.plutusWithdrawalScriptVersion = languageVersion;
661
+ return this;
662
+ };
633
663
  /**
634
664
  * Set the instruction that it is currently using V1 Plutus withdrawal scripts
635
665
  * @returns The MeshTxBuilder instance
@@ -839,6 +869,42 @@ var MeshTxBuilderCore = class {
839
869
  });
840
870
  return this;
841
871
  };
872
+ /**
873
+ * Registers DRep certificate, and adds it to the transaction
874
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
875
+ * @param anchor The DRep anchor, consists of a URL and a hash of the doc
876
+ * @param coin DRep registration deposit
877
+ * @returns The MeshTxBuilder instance
878
+ */
879
+ drepRegistrationCertificate = (drepId, anchor, coin = import_common.DREP_DEPOSIT) => {
880
+ this.meshTxBuilderBody.certificates.push({
881
+ type: "BasicCertificate",
882
+ certType: {
883
+ type: "DRepRegistration",
884
+ drepId,
885
+ coin: Number(coin),
886
+ anchor
887
+ }
888
+ });
889
+ return this;
890
+ };
891
+ /**
892
+ * Dregister DRep certificate, and adds it to the transaction
893
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
894
+ * @param coin DRep registration deposit
895
+ * @returns The MeshTxBuilder instance
896
+ */
897
+ drepDeregistrationCertificate = (drepId, coin = import_common.DREP_DEPOSIT) => {
898
+ this.meshTxBuilderBody.certificates.push({
899
+ type: "BasicCertificate",
900
+ certType: {
901
+ type: "DRepDeregistration",
902
+ drepId,
903
+ coin: Number(coin)
904
+ }
905
+ });
906
+ return this;
907
+ };
842
908
  /**
843
909
  * Adds a script witness to the certificate
844
910
  * @param scriptCbor The CborHex of the script
@@ -2100,8 +2166,10 @@ var Transaction = class {
2100
2166
  }
2101
2167
  }
2102
2168
  async addTxInputsAsNeeded() {
2103
- const utxos = await this.initiator.getUtxos();
2104
- this.txBuilder.selectUtxosFrom(utxos);
2169
+ if (this.txBuilder.meshTxBuilderBody.extraInputs.length === 0) {
2170
+ const utxos = await this.initiator.getUtxos();
2171
+ this.txBuilder.selectUtxosFrom(utxos);
2172
+ }
2105
2173
  }
2106
2174
  async addChangeAddress() {
2107
2175
  if (this.txBuilder.meshTxBuilderBody.changeAddress === "") {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Protocol, MintItem, TxIn, Withdrawal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, PoolParams, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
1
+ import { Protocol, MintItem, TxIn, Withdrawal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, PoolParams, Anchor, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
2
2
 
3
3
  declare class MeshTxBuilderCore {
4
4
  txEvaluationMultiplier: number;
@@ -99,6 +99,12 @@ declare class MeshTxBuilderCore {
99
99
  * @returns The MeshTxBuilder instance
100
100
  */
101
101
  txOutReferenceScript: (scriptCbor: string, version?: LanguageVersion) => this;
102
+ /**
103
+ * Set the reference script to be attached with the output
104
+ * @param languageVersion The Plutus script version
105
+ * @returns The MeshTxBuilder instance
106
+ */
107
+ spendingPlutusScript: (languageVersion: LanguageVersion) => this;
102
108
  /**
103
109
  * Set the instruction that it is currently using V1 Plutus spending scripts
104
110
  * @returns The MeshTxBuilder instance
@@ -146,6 +152,12 @@ declare class MeshTxBuilderCore {
146
152
  * @returns The MeshTxBuilder instance
147
153
  */
148
154
  readOnlyTxInReference: (txHash: string, txIndex: number) => this;
155
+ /**
156
+ * Set the minting script for the current mint
157
+ * @param languageVersion The Plutus script version
158
+ * @returns The MeshTxBuilder instance
159
+ */
160
+ mintPlutusScript: (languageVersion: LanguageVersion) => this;
149
161
  /**
150
162
  * Set the instruction that it is currently using V1 Plutus minting scripts
151
163
  * @returns The MeshTxBuilder instance
@@ -222,6 +234,12 @@ declare class MeshTxBuilderCore {
222
234
  * @returns The MeshTxBuilder instance
223
235
  */
224
236
  txInCollateral: (txHash: string, txIndex: number, amount?: Asset[], address?: string) => this;
237
+ /**
238
+ * Set the instruction that it is currently using V1 Plutus withdrawal scripts
239
+ * @param languageVersion The Plutus script version
240
+ * @returns The MeshTxBuilder instance
241
+ */
242
+ withdrawalPlutusScript: (languageVersion: LanguageVersion) => this;
225
243
  /**
226
244
  * Set the instruction that it is currently using V1 Plutus withdrawal scripts
227
245
  * @returns The MeshTxBuilder instance
@@ -303,6 +321,21 @@ declare class MeshTxBuilderCore {
303
321
  * @returns The MeshTxBuilder instance
304
322
  */
305
323
  retirePoolCertificate: (poolId: string, epoch: number) => this;
324
+ /**
325
+ * Registers DRep certificate, and adds it to the transaction
326
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
327
+ * @param anchor The DRep anchor, consists of a URL and a hash of the doc
328
+ * @param coin DRep registration deposit
329
+ * @returns The MeshTxBuilder instance
330
+ */
331
+ drepRegistrationCertificate: (drepId: string, anchor?: Anchor, coin?: string) => this;
332
+ /**
333
+ * Dregister DRep certificate, and adds it to the transaction
334
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
335
+ * @param coin DRep registration deposit
336
+ * @returns The MeshTxBuilder instance
337
+ */
338
+ drepDeregistrationCertificate: (drepId: string, coin?: string) => this;
306
339
  /**
307
340
  * Adds a script witness to the certificate
308
341
  * @param scriptCbor The CborHex of the script
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Protocol, MintItem, TxIn, Withdrawal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, PoolParams, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
1
+ import { Protocol, MintItem, TxIn, Withdrawal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, PoolParams, Anchor, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
2
2
 
3
3
  declare class MeshTxBuilderCore {
4
4
  txEvaluationMultiplier: number;
@@ -99,6 +99,12 @@ declare class MeshTxBuilderCore {
99
99
  * @returns The MeshTxBuilder instance
100
100
  */
101
101
  txOutReferenceScript: (scriptCbor: string, version?: LanguageVersion) => this;
102
+ /**
103
+ * Set the reference script to be attached with the output
104
+ * @param languageVersion The Plutus script version
105
+ * @returns The MeshTxBuilder instance
106
+ */
107
+ spendingPlutusScript: (languageVersion: LanguageVersion) => this;
102
108
  /**
103
109
  * Set the instruction that it is currently using V1 Plutus spending scripts
104
110
  * @returns The MeshTxBuilder instance
@@ -146,6 +152,12 @@ declare class MeshTxBuilderCore {
146
152
  * @returns The MeshTxBuilder instance
147
153
  */
148
154
  readOnlyTxInReference: (txHash: string, txIndex: number) => this;
155
+ /**
156
+ * Set the minting script for the current mint
157
+ * @param languageVersion The Plutus script version
158
+ * @returns The MeshTxBuilder instance
159
+ */
160
+ mintPlutusScript: (languageVersion: LanguageVersion) => this;
149
161
  /**
150
162
  * Set the instruction that it is currently using V1 Plutus minting scripts
151
163
  * @returns The MeshTxBuilder instance
@@ -222,6 +234,12 @@ declare class MeshTxBuilderCore {
222
234
  * @returns The MeshTxBuilder instance
223
235
  */
224
236
  txInCollateral: (txHash: string, txIndex: number, amount?: Asset[], address?: string) => this;
237
+ /**
238
+ * Set the instruction that it is currently using V1 Plutus withdrawal scripts
239
+ * @param languageVersion The Plutus script version
240
+ * @returns The MeshTxBuilder instance
241
+ */
242
+ withdrawalPlutusScript: (languageVersion: LanguageVersion) => this;
225
243
  /**
226
244
  * Set the instruction that it is currently using V1 Plutus withdrawal scripts
227
245
  * @returns The MeshTxBuilder instance
@@ -303,6 +321,21 @@ declare class MeshTxBuilderCore {
303
321
  * @returns The MeshTxBuilder instance
304
322
  */
305
323
  retirePoolCertificate: (poolId: string, epoch: number) => this;
324
+ /**
325
+ * Registers DRep certificate, and adds it to the transaction
326
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
327
+ * @param anchor The DRep anchor, consists of a URL and a hash of the doc
328
+ * @param coin DRep registration deposit
329
+ * @returns The MeshTxBuilder instance
330
+ */
331
+ drepRegistrationCertificate: (drepId: string, anchor?: Anchor, coin?: string) => this;
332
+ /**
333
+ * Dregister DRep certificate, and adds it to the transaction
334
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
335
+ * @param coin DRep registration deposit
336
+ * @returns The MeshTxBuilder instance
337
+ */
338
+ drepDeregistrationCertificate: (drepId: string, coin?: string) => this;
306
339
  /**
307
340
  * Adds a script witness to the certificate
308
341
  * @param scriptCbor The CborHex of the script
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import JSONBig from "json-bigint";
6
6
  import {
7
7
  DEFAULT_PROTOCOL_PARAMETERS,
8
8
  DEFAULT_REDEEMER_BUDGET,
9
+ DREP_DEPOSIT,
9
10
  emptyTxBuilderBody,
10
11
  UtxoSelection
11
12
  } from "@meshsdk/common";
@@ -342,6 +343,16 @@ var MeshTxBuilderCore = class {
342
343
  }
343
344
  return this;
344
345
  };
346
+ /**
347
+ * Set the reference script to be attached with the output
348
+ * @param languageVersion The Plutus script version
349
+ * @returns The MeshTxBuilder instance
350
+ */
351
+ spendingPlutusScript = (languageVersion) => {
352
+ this.addingPlutusScriptInput = true;
353
+ this.plutusSpendingScriptVersion = languageVersion;
354
+ return this;
355
+ };
345
356
  /**
346
357
  * Set the instruction that it is currently using V1 Plutus spending scripts
347
358
  * @returns The MeshTxBuilder instance
@@ -428,6 +439,16 @@ var MeshTxBuilderCore = class {
428
439
  this.meshTxBuilderBody.referenceInputs.push({ txHash, txIndex });
429
440
  return this;
430
441
  };
442
+ /**
443
+ * Set the minting script for the current mint
444
+ * @param languageVersion The Plutus script version
445
+ * @returns The MeshTxBuilder instance
446
+ */
447
+ mintPlutusScript = (languageVersion) => {
448
+ this.addingPlutusMint = true;
449
+ this.plutusMintingScriptVersion = languageVersion;
450
+ return this;
451
+ };
431
452
  /**
432
453
  * Set the instruction that it is currently using V1 Plutus minting scripts
433
454
  * @returns The MeshTxBuilder instance
@@ -596,6 +617,16 @@ var MeshTxBuilderCore = class {
596
617
  };
597
618
  return this;
598
619
  };
620
+ /**
621
+ * Set the instruction that it is currently using V1 Plutus withdrawal scripts
622
+ * @param languageVersion The Plutus script version
623
+ * @returns The MeshTxBuilder instance
624
+ */
625
+ withdrawalPlutusScript = (languageVersion) => {
626
+ this.addingPlutusWithdrawal = true;
627
+ this.plutusWithdrawalScriptVersion = languageVersion;
628
+ return this;
629
+ };
599
630
  /**
600
631
  * Set the instruction that it is currently using V1 Plutus withdrawal scripts
601
632
  * @returns The MeshTxBuilder instance
@@ -805,6 +836,42 @@ var MeshTxBuilderCore = class {
805
836
  });
806
837
  return this;
807
838
  };
839
+ /**
840
+ * Registers DRep certificate, and adds it to the transaction
841
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
842
+ * @param anchor The DRep anchor, consists of a URL and a hash of the doc
843
+ * @param coin DRep registration deposit
844
+ * @returns The MeshTxBuilder instance
845
+ */
846
+ drepRegistrationCertificate = (drepId, anchor, coin = DREP_DEPOSIT) => {
847
+ this.meshTxBuilderBody.certificates.push({
848
+ type: "BasicCertificate",
849
+ certType: {
850
+ type: "DRepRegistration",
851
+ drepId,
852
+ coin: Number(coin),
853
+ anchor
854
+ }
855
+ });
856
+ return this;
857
+ };
858
+ /**
859
+ * Dregister DRep certificate, and adds it to the transaction
860
+ * @param drepId The bech32 drep id (i.e. starts with `drep1xxxxx`)
861
+ * @param coin DRep registration deposit
862
+ * @returns The MeshTxBuilder instance
863
+ */
864
+ drepDeregistrationCertificate = (drepId, coin = DREP_DEPOSIT) => {
865
+ this.meshTxBuilderBody.certificates.push({
866
+ type: "BasicCertificate",
867
+ certType: {
868
+ type: "DRepDeregistration",
869
+ drepId,
870
+ coin: Number(coin)
871
+ }
872
+ });
873
+ return this;
874
+ };
808
875
  /**
809
876
  * Adds a script witness to the certificate
810
877
  * @param scriptCbor The CborHex of the script
@@ -2084,8 +2151,10 @@ var Transaction = class {
2084
2151
  }
2085
2152
  }
2086
2153
  async addTxInputsAsNeeded() {
2087
- const utxos = await this.initiator.getUtxos();
2088
- this.txBuilder.selectUtxosFrom(utxos);
2154
+ if (this.txBuilder.meshTxBuilderBody.extraInputs.length === 0) {
2155
+ const utxos = await this.initiator.getUtxos();
2156
+ this.txBuilder.selectUtxosFrom(utxos);
2157
+ }
2089
2158
  }
2090
2159
  async addChangeAddress() {
2091
2160
  if (this.txBuilder.meshTxBuilderBody.changeAddress === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/transaction",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -34,9 +34,9 @@
34
34
  "typescript": "^5.3.3"
35
35
  },
36
36
  "dependencies": {
37
- "@meshsdk/common": "1.7.2",
38
- "@meshsdk/core-csl": "1.7.2",
39
- "@meshsdk/core-cst": "1.7.2",
37
+ "@meshsdk/common": "1.7.4",
38
+ "@meshsdk/core-csl": "1.7.4",
39
+ "@meshsdk/core-cst": "1.7.4",
40
40
  "json-bigint": "^1.0.0"
41
41
  },
42
42
  "prettier": "@meshsdk/configs/prettier",