@meshsdk/transaction 1.9.0-beta.99 → 1.9.1

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
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  ForgeScript: () => ForgeScript,
34
34
  LargestFirstInputSelector: () => LargestFirstInputSelector,
35
35
  MeshTxBuilder: () => MeshTxBuilder,
36
+ MeshTxBuilderV2: () => MeshTxBuilderV2,
36
37
  Transaction: () => Transaction,
37
38
  TxParser: () => TxParser,
38
39
  cloneOutput: () => cloneOutput,
@@ -1422,7 +1423,7 @@ var BuilderCallbacksSdkBridge = class {
1422
1423
  change: selectionSkeleton.change.map(
1423
1424
  (output) => CSDKOutputToMeshOutput(output)
1424
1425
  ),
1425
- fee: selectionSkeleton.fee
1426
+ fee: BigInt(1e9)
1426
1427
  });
1427
1428
  return {
1428
1429
  fee: costs.fee,
@@ -1764,7 +1765,6 @@ var CSDKRedeemerTagToMeshRedeemerTag = (tag) => {
1764
1765
  };
1765
1766
 
1766
1767
  // src/mesh-tx-builder/coin-selection/largest-first-selector.ts
1767
- var MAX_U64 = 18446744073709551615n;
1768
1768
  var mergeValue = (a, b) => {
1769
1769
  const merged = new Map(a);
1770
1770
  b.forEach((quantity, unit) => {
@@ -1873,10 +1873,10 @@ var LargestFirstInputSelector = class {
1873
1873
  computeChangeOutputs = (remainingValue, changeAddress, constraints) => {
1874
1874
  let lovelaceAvailable = remainingValue.get("lovelace") || 0n;
1875
1875
  let valueFulfilled = true;
1876
- const valueAssets = remainingValue.entries().filter(([_, quantity]) => quantity > 0n).map(([unit, quantity]) => ({
1876
+ const valueAssets = Array.from(remainingValue.entries()).filter(([_, quantity]) => quantity > 0n).map(([unit, quantity]) => ({
1877
1877
  unit,
1878
1878
  quantity: String(quantity)
1879
- })).toArray();
1879
+ }));
1880
1880
  const changeOutputs = [];
1881
1881
  let currentBundle = [
1882
1882
  {
@@ -1952,9 +1952,11 @@ var LargestFirstInputSelector = class {
1952
1952
  let remainingUtxos = [...availableUtxos];
1953
1953
  const selectedUtxos = /* @__PURE__ */ new Set();
1954
1954
  while (remainingUtxos.length > 0) {
1955
- const assetToSelect = remainingValue.entries().find(([_2, quantity]) => {
1956
- return quantity < 0n;
1957
- });
1955
+ const assetToSelect = Array.from(remainingValue.entries()).find(
1956
+ ([_2, quantity]) => {
1957
+ return quantity < 0n;
1958
+ }
1959
+ );
1958
1960
  if (!assetToSelect) {
1959
1961
  break;
1960
1962
  }
@@ -2009,7 +2011,7 @@ var LargestFirstInputSelector = class {
2009
2011
  newInputs: selectedUtxos,
2010
2012
  newOutputs: /* @__PURE__ */ new Set(),
2011
2013
  change: changeOutputs,
2012
- fee: MAX_U64
2014
+ fee: BigInt(1e9)
2013
2015
  })).fee;
2014
2016
  }
2015
2017
  }
@@ -3140,9 +3142,12 @@ var MeshTxBuilderCore = class {
3140
3142
  * @returns The MeshTxBuilder instance
3141
3143
  */
3142
3144
  proposalRedeemerValue = (redeemer, type = "Mesh", exUnits = { ...import_common.DEFAULT_REDEEMER_BUDGET }) => {
3143
- if (!this.proposalItem) throw Error("proposalRedeemerValue: Undefined proposal");
3145
+ if (!this.proposalItem)
3146
+ throw Error("proposalRedeemerValue: Undefined proposal");
3144
3147
  if (!(this.proposalItem.type === "ScriptProposal"))
3145
- throw Error("proposalRedeemerValue: Adding redeemer to non plutus proposal");
3148
+ throw Error(
3149
+ "proposalRedeemerValue: Adding redeemer to non plutus proposal"
3150
+ );
3146
3151
  this.proposalItem.redeemer = this.castBuilderDataToRedeemer(
3147
3152
  redeemer,
3148
3153
  type,
@@ -3530,6 +3535,15 @@ var MeshTxBuilderCore = class {
3530
3535
  this.meshTxBuilderBody.network = network;
3531
3536
  return this;
3532
3537
  };
3538
+ /**
3539
+ * Alias for setNetwork for custom cost models
3540
+ * @param costModels
3541
+ * @returns The MeshTxBuilder instance
3542
+ */
3543
+ setCostModels = (costModels) => {
3544
+ this.setNetwork(costModels);
3545
+ return this;
3546
+ };
3533
3547
  /**
3534
3548
  * Add a transaction that is used as input, but not yet reflected on the global blockchain
3535
3549
  * @param txHex The transaction hex of chained transaction
@@ -4022,6 +4036,35 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
4022
4036
  this._protocolParams
4023
4037
  );
4024
4038
  };
4039
+ completeCostModels = async () => {
4040
+ if (Array.isArray(this.meshTxBuilderBody.network)) {
4041
+ return;
4042
+ }
4043
+ const defaults = [
4044
+ import_common3.DEFAULT_V1_COST_MODEL_LIST,
4045
+ import_common3.DEFAULT_V2_COST_MODEL_LIST,
4046
+ import_common3.DEFAULT_V3_COST_MODEL_LIST
4047
+ ];
4048
+ if (this.fetcher) {
4049
+ try {
4050
+ const costModels = await this.fetcher.fetchCostModels();
4051
+ if (Array.isArray(costModels) && costModels.length > 0) {
4052
+ this.meshTxBuilderBody.network = costModels;
4053
+ return;
4054
+ }
4055
+ console.warn(
4056
+ "fetchCostModels returned an invalid value, using default cost models:",
4057
+ costModels
4058
+ );
4059
+ } catch (error) {
4060
+ console.warn(
4061
+ "Failed to fetch cost models, using default cost models. Error: ",
4062
+ error
4063
+ );
4064
+ }
4065
+ }
4066
+ this.meshTxBuilderBody.network = defaults;
4067
+ };
4025
4068
  /**
4026
4069
  * It builds the transaction query the blockchain for missing information
4027
4070
  * @param customizedTx The optional customized transaction body
@@ -4065,6 +4108,7 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
4065
4108
  this.setFee(customizedTx.fee);
4066
4109
  }
4067
4110
  }
4111
+ await this.completeCostModels();
4068
4112
  this.queueAllLastItem();
4069
4113
  if (this.verbose) {
4070
4114
  console.log(
@@ -4122,7 +4166,15 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
4122
4166
  const selectionCallbacks = {
4123
4167
  computeMinimumCost: async (selectionSkeleton) => {
4124
4168
  const clonedBuilder = this.clone();
4125
- await clonedBuilder.updateByTxPrototype(selectionSkeleton);
4169
+ if (this.manualFee) {
4170
+ const newSelectionSkeleton = {
4171
+ ...selectionSkeleton,
4172
+ fee: BigInt(this.manualFee)
4173
+ };
4174
+ await clonedBuilder.updateByTxPrototype(newSelectionSkeleton);
4175
+ } else {
4176
+ await clonedBuilder.updateByTxPrototype(selectionSkeleton);
4177
+ }
4126
4178
  try {
4127
4179
  await clonedBuilder.evaluateRedeemers();
4128
4180
  } catch (error) {
@@ -5347,6 +5399,12 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
5347
5399
  stepUnits += BigInt(vote.redeemer.exUnits.steps);
5348
5400
  }
5349
5401
  }
5402
+ for (let proposal of this.meshTxBuilderBody.proposals) {
5403
+ if (proposal.type === "ScriptProposal" && proposal.redeemer) {
5404
+ memUnits += BigInt(proposal.redeemer.exUnits.mem);
5405
+ stepUnits += BigInt(proposal.redeemer.exUnits.steps);
5406
+ }
5407
+ }
5350
5408
  memUnits = BigInt(
5351
5409
  new bignumber_default(memUnits).integerValue(bignumber_default.ROUND_CEIL).toString()
5352
5410
  );
@@ -6203,6 +6261,8 @@ var TxParser = class {
6203
6261
  this.serializer = serializer;
6204
6262
  this.fetcher = fetcher;
6205
6263
  }
6264
+ serializer;
6265
+ fetcher;
6206
6266
  parse = async (txHex, providedUtxos = []) => {
6207
6267
  const resolvedUtxos = [...providedUtxos];
6208
6268
  const resolvedUtxosSet = new Set(
@@ -6245,11 +6305,224 @@ var TxParser = class {
6245
6305
  getBuilderBodyWithoutChange = () => this.serializer.parser.getBuilderBodyWithoutChange();
6246
6306
  toTester = () => this.serializer.parser.toTester();
6247
6307
  };
6308
+
6309
+ // src/mesh-tx-builder-v2/index.ts
6310
+ var import_common5 = require("@meshsdk/common");
6311
+ var SpendBuilderImpl = class {
6312
+ constructor(builder) {
6313
+ this.builder = builder;
6314
+ }
6315
+ builder;
6316
+ script(scriptCbor) {
6317
+ this.builder.txInScript(scriptCbor);
6318
+ return this;
6319
+ }
6320
+ referenceScript(refTxHash, refTxIndex, scriptSize, scriptHash) {
6321
+ this.builder.spendingTxInReference(
6322
+ refTxHash,
6323
+ refTxIndex,
6324
+ scriptSize,
6325
+ scriptHash
6326
+ );
6327
+ return this;
6328
+ }
6329
+ redeemerJson(redeemer, exUnits) {
6330
+ this.builder.txInRedeemerValue(
6331
+ redeemer,
6332
+ "JSON",
6333
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6334
+ );
6335
+ return this;
6336
+ }
6337
+ redeemerCbor(redeemer, exUnits) {
6338
+ this.builder.txInRedeemerValue(
6339
+ redeemer,
6340
+ "CBOR",
6341
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6342
+ );
6343
+ return this;
6344
+ }
6345
+ txOut(address, amount) {
6346
+ this.builder.txInInlineDatumPresent();
6347
+ this.builder.txOut(address, amount);
6348
+ return this;
6349
+ }
6350
+ datumJson(datum) {
6351
+ this.builder.txOutInlineDatumValue(datum, "JSON");
6352
+ return this.builder;
6353
+ }
6354
+ datumCbor(datum) {
6355
+ this.builder.txOutInlineDatumValue(datum, "CBOR");
6356
+ return this.builder;
6357
+ }
6358
+ datumHash(datumHash) {
6359
+ this.builder.txOutDatumHashValue(datumHash);
6360
+ return this.builder;
6361
+ }
6362
+ };
6363
+ var MintBuilderImpl = class {
6364
+ constructor(builder) {
6365
+ this.builder = builder;
6366
+ }
6367
+ builder;
6368
+ script(scriptCbor) {
6369
+ this.builder.mintingScript(scriptCbor);
6370
+ return this;
6371
+ }
6372
+ referenceScript(txHash, txIndex, scriptSize, scriptHash) {
6373
+ this.builder.mintTxInReference(txHash, txIndex, scriptSize, scriptHash);
6374
+ return this;
6375
+ }
6376
+ redeemerJson(redeemer, exUnits) {
6377
+ this.builder.mintRedeemerValue(
6378
+ redeemer,
6379
+ "JSON",
6380
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6381
+ );
6382
+ return this;
6383
+ }
6384
+ redeemerCbor(redeemer, exUnits) {
6385
+ this.builder.mintRedeemerValue(
6386
+ redeemer,
6387
+ "CBOR",
6388
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6389
+ );
6390
+ return this;
6391
+ }
6392
+ txOut(address, amount) {
6393
+ this.builder.txOut(address, amount);
6394
+ return this.builder;
6395
+ }
6396
+ };
6397
+ var WithdrawBuilderImpl = class {
6398
+ constructor(builder) {
6399
+ this.builder = builder;
6400
+ }
6401
+ builder;
6402
+ script(scriptCbor) {
6403
+ this.builder.withdrawalScript(scriptCbor);
6404
+ return this;
6405
+ }
6406
+ referenceScript(txHash, txIndex, scriptSize, scriptHash) {
6407
+ this.builder.withdrawalTxInReference(txHash, txIndex, scriptSize, scriptHash);
6408
+ return this;
6409
+ }
6410
+ redeemerJson(redeemer, exUnits) {
6411
+ this.builder.withdrawalRedeemerValue(
6412
+ redeemer,
6413
+ "JSON",
6414
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6415
+ );
6416
+ return this.builder;
6417
+ }
6418
+ redeemerCbor(redeemer, exUnits) {
6419
+ this.builder.withdrawalRedeemerValue(
6420
+ redeemer,
6421
+ "CBOR",
6422
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6423
+ );
6424
+ return this.builder;
6425
+ }
6426
+ };
6427
+ var VoteBuilderImpl = class {
6428
+ constructor(builder) {
6429
+ this.builder = builder;
6430
+ }
6431
+ builder;
6432
+ script(scriptCbor) {
6433
+ this.builder.voteScript(scriptCbor);
6434
+ return this;
6435
+ }
6436
+ referenceScript(txHash, txIndex, scriptSize, scriptHash) {
6437
+ this.builder.voteTxInReference(txHash, txIndex, scriptSize, scriptHash);
6438
+ return this;
6439
+ }
6440
+ redeemerJson(redeemer, exUnits) {
6441
+ this.builder.voteRedeemerValue(
6442
+ redeemer,
6443
+ "JSON",
6444
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6445
+ );
6446
+ return this.builder;
6447
+ }
6448
+ redeemerCbor(redeemer, exUnits) {
6449
+ this.builder.voteRedeemerValue(
6450
+ redeemer,
6451
+ "CBOR",
6452
+ exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
6453
+ );
6454
+ return this.builder;
6455
+ }
6456
+ };
6457
+ var TxBuilderV2 = class extends MeshTxBuilder {
6458
+ spendPlutusV1(txHash, txIndex) {
6459
+ this.spendingPlutusScriptV1();
6460
+ this.txIn(txHash, txIndex);
6461
+ return new SpendBuilderImpl(this);
6462
+ }
6463
+ spendPlutusV2(txHash, txIndex) {
6464
+ this.spendingPlutusScriptV2();
6465
+ this.txIn(txHash, txIndex);
6466
+ return new SpendBuilderImpl(this);
6467
+ }
6468
+ spendPlutusV3(txHash, txIndex) {
6469
+ this.spendingPlutusScriptV3();
6470
+ this.txIn(txHash, txIndex);
6471
+ return new SpendBuilderImpl(this);
6472
+ }
6473
+ mintPlutusV1(quantity, policyId, assetName) {
6474
+ this.mintPlutusScriptV1();
6475
+ this.mint(quantity, policyId, assetName);
6476
+ return new MintBuilderImpl(this);
6477
+ }
6478
+ mintPlutusV2(quantity, policyId, assetName) {
6479
+ this.mintPlutusScriptV2();
6480
+ this.mint(quantity, policyId, assetName);
6481
+ return new MintBuilderImpl(this);
6482
+ }
6483
+ mintPlutusV3(quantity, policyId, assetName) {
6484
+ this.mintPlutusScriptV3();
6485
+ this.mint(quantity, policyId, assetName);
6486
+ return new MintBuilderImpl(this);
6487
+ }
6488
+ withdrawPlutusV1(rewardAddress, amount) {
6489
+ this.withdrawalPlutusScriptV1();
6490
+ this.withdrawal(rewardAddress, amount);
6491
+ return new WithdrawBuilderImpl(this);
6492
+ }
6493
+ withdrawPlutusV2(rewardAddress, coin) {
6494
+ this.withdrawalPlutusScriptV2();
6495
+ this.withdrawal(rewardAddress, coin);
6496
+ return new WithdrawBuilderImpl(this);
6497
+ }
6498
+ withdrawPlutusV3(rewardAddress, coin) {
6499
+ this.withdrawalPlutusScriptV3();
6500
+ this.withdrawal(rewardAddress, coin);
6501
+ return new WithdrawBuilderImpl(this);
6502
+ }
6503
+ votePlutusV1(voter, govActionId, votingProcedure) {
6504
+ this.votePlutusScriptV1();
6505
+ this.vote(voter, govActionId, votingProcedure);
6506
+ return new VoteBuilderImpl(this);
6507
+ }
6508
+ votePlutusV2(voter, govActionId, votingProcedure) {
6509
+ this.votePlutusScriptV2();
6510
+ this.vote(voter, govActionId, votingProcedure);
6511
+ return new VoteBuilderImpl(this);
6512
+ }
6513
+ votePlutusV3(voter, govActionId, votingProcedure) {
6514
+ this.votePlutusScriptV3();
6515
+ this.vote(voter, govActionId, votingProcedure);
6516
+ return new VoteBuilderImpl(this);
6517
+ }
6518
+ };
6519
+ var MeshTxBuilderV2 = TxBuilderV2;
6248
6520
  // Annotate the CommonJS export names for ESM import in node:
6249
6521
  0 && (module.exports = {
6250
6522
  ForgeScript,
6251
6523
  LargestFirstInputSelector,
6252
6524
  MeshTxBuilder,
6525
+ MeshTxBuilderV2,
6253
6526
  Transaction,
6254
6527
  TxParser,
6255
6528
  cloneOutput,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _meshsdk_common from '@meshsdk/common';
2
- import { TxIn, Output, Asset, UTxO, TxOutput, Action, Protocol, MintItem, Withdrawal, Vote, Proposal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, BuilderData, LanguageVersion, Voter, VotingProcedure, GovernanceAction, Anchor, RewardAddress, PoolParams, DRep, Metadatum, Network, Redeemer, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, Certificate, MintParam, NativeScript as NativeScript$1, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
2
+ import { TxIn, Output, Asset, UTxO, TxOutput, Action, Protocol, MintItem, Withdrawal, Vote, Proposal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, BuilderData, LanguageVersion, Voter, VotingProcedure, GovernanceAction, Anchor, RewardAddress, PoolParams, DRep, Metadatum, Network, Redeemer, IMeshTxSerializer, IFetcher, ISubmitter, IEvaluator, ScriptSource, SimpleScriptSourceInfo, Certificate, MintParam, NativeScript as NativeScript$1, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
3
3
  import { CredentialCore, NativeScript } from '@meshsdk/core-cst';
4
4
 
5
5
  interface TransactionPrototype {
@@ -582,6 +582,12 @@ declare class MeshTxBuilderCore {
582
582
  * @returns The MeshTxBuilder instance
583
583
  */
584
584
  setNetwork: (network: Network | number[][]) => this;
585
+ /**
586
+ * Alias for setNetwork for custom cost models
587
+ * @param costModels
588
+ * @returns The MeshTxBuilder instance
589
+ */
590
+ setCostModels: (costModels: number[][]) => this;
585
591
  /**
586
592
  * Add a transaction that is used as input, but not yet reflected on the global blockchain
587
593
  * @param txHex The transaction hex of chained transaction
@@ -652,6 +658,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
652
658
  protected utxosWithRefScripts: UTxO[];
653
659
  constructor({ serializer, selector, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
654
660
  serializeMockTx: () => string;
661
+ completeCostModels: () => Promise<void>;
655
662
  /**
656
663
  * It builds the transaction query the blockchain for missing information
657
664
  * @param customizedTx The optional customized transaction body
@@ -1053,4 +1060,87 @@ declare class TxParser {
1053
1060
  toTester: () => _meshsdk_common.TxTester;
1054
1061
  }
1055
1062
 
1056
- export { ForgeScript, LargestFirstInputSelector, MeshTxBuilder, type MeshTxBuilderOptions, type MetadataMergeLevel, Transaction, type TransactionOptions, TxParser, cloneOutput, getLovelace, getOutputMinLovelace, getUtxoMinLovelace, mergeContents, metadataObjToMap, setLoveLace, utxoToTxIn };
1063
+ interface _MeshTxBuilderV2 extends Omit<MeshTxBuilder, ScriptMethodsToDrop> {
1064
+ spendPlutusV1(txHash: string, txIndex: number): SpendScriptBuilder;
1065
+ spendPlutusV2(txHash: string, txIndex: number): SpendScriptBuilder;
1066
+ spendPlutusV3(txHash: string, txIndex: number): SpendScriptBuilder;
1067
+ mintPlutusV1(quantity: string, policyId: string, assetName: string): MintScriptBuilder;
1068
+ mintPlutusV2(quantity: string, policyId: string, assetName: string): MintScriptBuilder;
1069
+ mintPlutusV3(quantity: string, policyId: string, assetName: string): MintScriptBuilder;
1070
+ withdrawPlutusV1(rewardAddress: string, amount: string): WithdrawScriptBuilder;
1071
+ withdrawPlutusV2(rewardAddress: string, amount: string): WithdrawScriptBuilder;
1072
+ withdrawPlutusV3(rewardAddress: string, amount: string): WithdrawScriptBuilder;
1073
+ votePlutusV1(voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure): VoteScriptBuilder;
1074
+ votePlutusV2(voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure): VoteScriptBuilder;
1075
+ votePlutusV3(voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure): VoteScriptBuilder;
1076
+ }
1077
+ type ScriptMethodsToDrop = "spendingPlutusScript" | "spendingPlutusScriptV1" | "spendingPlutusScriptV2" | "spendingPlutusScriptV3" | "spendingTxInReference" | "spendingReferenceTxInInlineDatumPresent" | "spendingReferenceTxInRedeemerValue" | "mintPlutusScript" | "mintPlutusScriptV1" | "mintPlutusScriptV2" | "mintPlutusScriptV3" | "mintingScript" | "mintTxInReference" | "mintReferenceTxInRedeemerValue" | "mintRedeemerValue" | "withdrawalPlutusScript" | "withdrawalPlutusScriptV1" | "withdrawalPlutusScriptV2" | "withdrawalPlutusScriptV3" | "withdrawalScript" | "withdrawalTxInReference" | "withdrawalReferenceTxInRedeemerValue" | "withdrawalRedeemerValue" | "votePlutusScript" | "votePlutusScriptV1" | "votePlutusScriptV2" | "votePlutusScriptV3" | "voteScript" | "voteTxInReference" | "voteReferenceTxInRedeemerValue" | "voteRedeemerValue" | "txInScript" | "txInDatumValue" | "txInInlineDatumPresent" | "txInRedeemerValue";
1078
+ interface SpendScriptBuilder {
1079
+ script(scriptCbor: string): SpendRedeemerBuilder;
1080
+ referenceScript(refTxHash: string, refTxIndex: number, scriptSize?: string, scriptHash?: string): SpendRedeemerBuilder;
1081
+ }
1082
+ interface SpendRedeemerBuilder {
1083
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): SpendTxOutBuilder;
1084
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): SpendTxOutBuilder;
1085
+ }
1086
+ interface SpendTxOutBuilder {
1087
+ txOut(address: string, amount: Asset[]): SpendDatumBuilder;
1088
+ }
1089
+ interface SpendDatumBuilder {
1090
+ datumHash(datumHash: string): _MeshTxBuilderV2;
1091
+ datumCbor(datumCbor: BuilderData["content"]): _MeshTxBuilderV2;
1092
+ datumJson(datumJson: BuilderData["content"]): _MeshTxBuilderV2;
1093
+ }
1094
+ interface MintScriptBuilder {
1095
+ script(scriptCbor: string): MintRedeemerBuilder;
1096
+ referenceScript(txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string): MintRedeemerBuilder;
1097
+ }
1098
+ interface MintRedeemerBuilder {
1099
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): MintTxOutBuilder;
1100
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): MintTxOutBuilder;
1101
+ }
1102
+ interface MintTxOutBuilder {
1103
+ txOut(address: string, amount: Asset[]): _MeshTxBuilderV2;
1104
+ }
1105
+ interface VoteScriptBuilder {
1106
+ script(scriptCbor: string): VoteRedeemerBuilder;
1107
+ referenceScript(txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string): VoteRedeemerBuilder;
1108
+ }
1109
+ interface VoteRedeemerBuilder {
1110
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1111
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1112
+ }
1113
+ interface WithdrawScriptBuilder {
1114
+ script(scriptCbor: string): WithdrawRedeemerBuilder;
1115
+ referenceScript(txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string): WithdrawRedeemerBuilder;
1116
+ }
1117
+ interface WithdrawRedeemerBuilder {
1118
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1119
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1120
+ }
1121
+
1122
+ /**
1123
+ * \`MeshTxBuilderV2\` is a strongly-typed wrapper around the core \`MeshTxBuilder\`
1124
+ * that enforces a rigid Type-State machine for Plutus operations.
1125
+ *
1126
+ * It natively provides TypeScript autocomplete restrictions (Script -> Redeemer -> TxOut -> Datum)
1127
+ * for transactions like spending, minting, withdrawing, and voting, dropping standalone
1128
+ * script methods to prevent incorrect chained execution ordering.
1129
+ *
1130
+ * @example
1131
+ * ```typescript
1132
+ * const tx = new MeshTxBuilderV2({
1133
+ * fetcher: provider,
1134
+ * evaluator: provider,
1135
+ * });
1136
+ *
1137
+ * tx.spendPlutusV3(txHash, index)
1138
+ * .script(scriptCbor)
1139
+ * .redeemerJson(redeemerValue)
1140
+ * .txOut(address, assets)
1141
+ * .datumJson(datumValue); // Drops you back into the main builder methods
1142
+ * ```
1143
+ */
1144
+ declare const MeshTxBuilderV2: new (options?: MeshTxBuilderOptions) => _MeshTxBuilderV2;
1145
+
1146
+ export { ForgeScript, LargestFirstInputSelector, MeshTxBuilder, type MeshTxBuilderOptions, MeshTxBuilderV2, type MetadataMergeLevel, Transaction, type TransactionOptions, TxParser, cloneOutput, getLovelace, getOutputMinLovelace, getUtxoMinLovelace, mergeContents, metadataObjToMap, setLoveLace, utxoToTxIn };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _meshsdk_common from '@meshsdk/common';
2
- import { TxIn, Output, Asset, UTxO, TxOutput, Action, Protocol, MintItem, Withdrawal, Vote, Proposal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, BuilderData, LanguageVersion, Voter, VotingProcedure, GovernanceAction, Anchor, RewardAddress, PoolParams, DRep, Metadatum, Network, Redeemer, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, Certificate, MintParam, NativeScript as NativeScript$1, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
2
+ import { TxIn, Output, Asset, UTxO, TxOutput, Action, Protocol, MintItem, Withdrawal, Vote, Proposal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, BuilderData, LanguageVersion, Voter, VotingProcedure, GovernanceAction, Anchor, RewardAddress, PoolParams, DRep, Metadatum, Network, Redeemer, IMeshTxSerializer, IFetcher, ISubmitter, IEvaluator, ScriptSource, SimpleScriptSourceInfo, Certificate, MintParam, NativeScript as NativeScript$1, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
3
3
  import { CredentialCore, NativeScript } from '@meshsdk/core-cst';
4
4
 
5
5
  interface TransactionPrototype {
@@ -582,6 +582,12 @@ declare class MeshTxBuilderCore {
582
582
  * @returns The MeshTxBuilder instance
583
583
  */
584
584
  setNetwork: (network: Network | number[][]) => this;
585
+ /**
586
+ * Alias for setNetwork for custom cost models
587
+ * @param costModels
588
+ * @returns The MeshTxBuilder instance
589
+ */
590
+ setCostModels: (costModels: number[][]) => this;
585
591
  /**
586
592
  * Add a transaction that is used as input, but not yet reflected on the global blockchain
587
593
  * @param txHex The transaction hex of chained transaction
@@ -652,6 +658,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
652
658
  protected utxosWithRefScripts: UTxO[];
653
659
  constructor({ serializer, selector, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
654
660
  serializeMockTx: () => string;
661
+ completeCostModels: () => Promise<void>;
655
662
  /**
656
663
  * It builds the transaction query the blockchain for missing information
657
664
  * @param customizedTx The optional customized transaction body
@@ -1053,4 +1060,87 @@ declare class TxParser {
1053
1060
  toTester: () => _meshsdk_common.TxTester;
1054
1061
  }
1055
1062
 
1056
- export { ForgeScript, LargestFirstInputSelector, MeshTxBuilder, type MeshTxBuilderOptions, type MetadataMergeLevel, Transaction, type TransactionOptions, TxParser, cloneOutput, getLovelace, getOutputMinLovelace, getUtxoMinLovelace, mergeContents, metadataObjToMap, setLoveLace, utxoToTxIn };
1063
+ interface _MeshTxBuilderV2 extends Omit<MeshTxBuilder, ScriptMethodsToDrop> {
1064
+ spendPlutusV1(txHash: string, txIndex: number): SpendScriptBuilder;
1065
+ spendPlutusV2(txHash: string, txIndex: number): SpendScriptBuilder;
1066
+ spendPlutusV3(txHash: string, txIndex: number): SpendScriptBuilder;
1067
+ mintPlutusV1(quantity: string, policyId: string, assetName: string): MintScriptBuilder;
1068
+ mintPlutusV2(quantity: string, policyId: string, assetName: string): MintScriptBuilder;
1069
+ mintPlutusV3(quantity: string, policyId: string, assetName: string): MintScriptBuilder;
1070
+ withdrawPlutusV1(rewardAddress: string, amount: string): WithdrawScriptBuilder;
1071
+ withdrawPlutusV2(rewardAddress: string, amount: string): WithdrawScriptBuilder;
1072
+ withdrawPlutusV3(rewardAddress: string, amount: string): WithdrawScriptBuilder;
1073
+ votePlutusV1(voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure): VoteScriptBuilder;
1074
+ votePlutusV2(voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure): VoteScriptBuilder;
1075
+ votePlutusV3(voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure): VoteScriptBuilder;
1076
+ }
1077
+ type ScriptMethodsToDrop = "spendingPlutusScript" | "spendingPlutusScriptV1" | "spendingPlutusScriptV2" | "spendingPlutusScriptV3" | "spendingTxInReference" | "spendingReferenceTxInInlineDatumPresent" | "spendingReferenceTxInRedeemerValue" | "mintPlutusScript" | "mintPlutusScriptV1" | "mintPlutusScriptV2" | "mintPlutusScriptV3" | "mintingScript" | "mintTxInReference" | "mintReferenceTxInRedeemerValue" | "mintRedeemerValue" | "withdrawalPlutusScript" | "withdrawalPlutusScriptV1" | "withdrawalPlutusScriptV2" | "withdrawalPlutusScriptV3" | "withdrawalScript" | "withdrawalTxInReference" | "withdrawalReferenceTxInRedeemerValue" | "withdrawalRedeemerValue" | "votePlutusScript" | "votePlutusScriptV1" | "votePlutusScriptV2" | "votePlutusScriptV3" | "voteScript" | "voteTxInReference" | "voteReferenceTxInRedeemerValue" | "voteRedeemerValue" | "txInScript" | "txInDatumValue" | "txInInlineDatumPresent" | "txInRedeemerValue";
1078
+ interface SpendScriptBuilder {
1079
+ script(scriptCbor: string): SpendRedeemerBuilder;
1080
+ referenceScript(refTxHash: string, refTxIndex: number, scriptSize?: string, scriptHash?: string): SpendRedeemerBuilder;
1081
+ }
1082
+ interface SpendRedeemerBuilder {
1083
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): SpendTxOutBuilder;
1084
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): SpendTxOutBuilder;
1085
+ }
1086
+ interface SpendTxOutBuilder {
1087
+ txOut(address: string, amount: Asset[]): SpendDatumBuilder;
1088
+ }
1089
+ interface SpendDatumBuilder {
1090
+ datumHash(datumHash: string): _MeshTxBuilderV2;
1091
+ datumCbor(datumCbor: BuilderData["content"]): _MeshTxBuilderV2;
1092
+ datumJson(datumJson: BuilderData["content"]): _MeshTxBuilderV2;
1093
+ }
1094
+ interface MintScriptBuilder {
1095
+ script(scriptCbor: string): MintRedeemerBuilder;
1096
+ referenceScript(txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string): MintRedeemerBuilder;
1097
+ }
1098
+ interface MintRedeemerBuilder {
1099
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): MintTxOutBuilder;
1100
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): MintTxOutBuilder;
1101
+ }
1102
+ interface MintTxOutBuilder {
1103
+ txOut(address: string, amount: Asset[]): _MeshTxBuilderV2;
1104
+ }
1105
+ interface VoteScriptBuilder {
1106
+ script(scriptCbor: string): VoteRedeemerBuilder;
1107
+ referenceScript(txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string): VoteRedeemerBuilder;
1108
+ }
1109
+ interface VoteRedeemerBuilder {
1110
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1111
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1112
+ }
1113
+ interface WithdrawScriptBuilder {
1114
+ script(scriptCbor: string): WithdrawRedeemerBuilder;
1115
+ referenceScript(txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string): WithdrawRedeemerBuilder;
1116
+ }
1117
+ interface WithdrawRedeemerBuilder {
1118
+ redeemerJson(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1119
+ redeemerCbor(redeemer: BuilderData["content"], exUnits?: Budget): _MeshTxBuilderV2;
1120
+ }
1121
+
1122
+ /**
1123
+ * \`MeshTxBuilderV2\` is a strongly-typed wrapper around the core \`MeshTxBuilder\`
1124
+ * that enforces a rigid Type-State machine for Plutus operations.
1125
+ *
1126
+ * It natively provides TypeScript autocomplete restrictions (Script -> Redeemer -> TxOut -> Datum)
1127
+ * for transactions like spending, minting, withdrawing, and voting, dropping standalone
1128
+ * script methods to prevent incorrect chained execution ordering.
1129
+ *
1130
+ * @example
1131
+ * ```typescript
1132
+ * const tx = new MeshTxBuilderV2({
1133
+ * fetcher: provider,
1134
+ * evaluator: provider,
1135
+ * });
1136
+ *
1137
+ * tx.spendPlutusV3(txHash, index)
1138
+ * .script(scriptCbor)
1139
+ * .redeemerJson(redeemerValue)
1140
+ * .txOut(address, assets)
1141
+ * .datumJson(datumValue); // Drops you back into the main builder methods
1142
+ * ```
1143
+ */
1144
+ declare const MeshTxBuilderV2: new (options?: MeshTxBuilderOptions) => _MeshTxBuilderV2;
1145
+
1146
+ export { ForgeScript, LargestFirstInputSelector, MeshTxBuilder, type MeshTxBuilderOptions, MeshTxBuilderV2, type MetadataMergeLevel, Transaction, type TransactionOptions, TxParser, cloneOutput, getLovelace, getOutputMinLovelace, getUtxoMinLovelace, mergeContents, metadataObjToMap, setLoveLace, utxoToTxIn };
package/dist/index.js CHANGED
@@ -1345,7 +1345,10 @@ var bignumber_default = BigNumber;
1345
1345
  // src/mesh-tx-builder/index.ts
1346
1346
  import JSONBig3 from "json-bigint";
1347
1347
  import {
1348
- DEFAULT_PROTOCOL_PARAMETERS as DEFAULT_PROTOCOL_PARAMETERS3
1348
+ DEFAULT_PROTOCOL_PARAMETERS as DEFAULT_PROTOCOL_PARAMETERS3,
1349
+ DEFAULT_V1_COST_MODEL_LIST,
1350
+ DEFAULT_V2_COST_MODEL_LIST,
1351
+ DEFAULT_V3_COST_MODEL_LIST
1349
1352
  } from "@meshsdk/common";
1350
1353
  import {
1351
1354
  CardanoSDKSerializer,
@@ -1390,7 +1393,7 @@ var BuilderCallbacksSdkBridge = class {
1390
1393
  change: selectionSkeleton.change.map(
1391
1394
  (output) => CSDKOutputToMeshOutput(output)
1392
1395
  ),
1393
- fee: selectionSkeleton.fee
1396
+ fee: BigInt(1e9)
1394
1397
  });
1395
1398
  return {
1396
1399
  fee: costs.fee,
@@ -1732,7 +1735,6 @@ var CSDKRedeemerTagToMeshRedeemerTag = (tag) => {
1732
1735
  };
1733
1736
 
1734
1737
  // src/mesh-tx-builder/coin-selection/largest-first-selector.ts
1735
- var MAX_U64 = 18446744073709551615n;
1736
1738
  var mergeValue = (a, b) => {
1737
1739
  const merged = new Map(a);
1738
1740
  b.forEach((quantity, unit) => {
@@ -1841,10 +1843,10 @@ var LargestFirstInputSelector = class {
1841
1843
  computeChangeOutputs = (remainingValue, changeAddress, constraints) => {
1842
1844
  let lovelaceAvailable = remainingValue.get("lovelace") || 0n;
1843
1845
  let valueFulfilled = true;
1844
- const valueAssets = remainingValue.entries().filter(([_, quantity]) => quantity > 0n).map(([unit, quantity]) => ({
1846
+ const valueAssets = Array.from(remainingValue.entries()).filter(([_, quantity]) => quantity > 0n).map(([unit, quantity]) => ({
1845
1847
  unit,
1846
1848
  quantity: String(quantity)
1847
- })).toArray();
1849
+ }));
1848
1850
  const changeOutputs = [];
1849
1851
  let currentBundle = [
1850
1852
  {
@@ -1920,9 +1922,11 @@ var LargestFirstInputSelector = class {
1920
1922
  let remainingUtxos = [...availableUtxos];
1921
1923
  const selectedUtxos = /* @__PURE__ */ new Set();
1922
1924
  while (remainingUtxos.length > 0) {
1923
- const assetToSelect = remainingValue.entries().find(([_2, quantity]) => {
1924
- return quantity < 0n;
1925
- });
1925
+ const assetToSelect = Array.from(remainingValue.entries()).find(
1926
+ ([_2, quantity]) => {
1927
+ return quantity < 0n;
1928
+ }
1929
+ );
1926
1930
  if (!assetToSelect) {
1927
1931
  break;
1928
1932
  }
@@ -1977,7 +1981,7 @@ var LargestFirstInputSelector = class {
1977
1981
  newInputs: selectedUtxos,
1978
1982
  newOutputs: /* @__PURE__ */ new Set(),
1979
1983
  change: changeOutputs,
1980
- fee: MAX_U64
1984
+ fee: BigInt(1e9)
1981
1985
  })).fee;
1982
1986
  }
1983
1987
  }
@@ -2031,8 +2035,8 @@ import {
2031
2035
  DEFAULT_PROTOCOL_PARAMETERS,
2032
2036
  DEFAULT_REDEEMER_BUDGET,
2033
2037
  DREP_DEPOSIT,
2034
- VOTING_PROPOSAL_DEPOSIT,
2035
- emptyTxBuilderBody
2038
+ emptyTxBuilderBody,
2039
+ VOTING_PROPOSAL_DEPOSIT
2036
2040
  } from "@meshsdk/common";
2037
2041
  import { Address, CredentialType } from "@meshsdk/core-cst";
2038
2042
 
@@ -3115,9 +3119,12 @@ var MeshTxBuilderCore = class {
3115
3119
  * @returns The MeshTxBuilder instance
3116
3120
  */
3117
3121
  proposalRedeemerValue = (redeemer, type = "Mesh", exUnits = { ...DEFAULT_REDEEMER_BUDGET }) => {
3118
- if (!this.proposalItem) throw Error("proposalRedeemerValue: Undefined proposal");
3122
+ if (!this.proposalItem)
3123
+ throw Error("proposalRedeemerValue: Undefined proposal");
3119
3124
  if (!(this.proposalItem.type === "ScriptProposal"))
3120
- throw Error("proposalRedeemerValue: Adding redeemer to non plutus proposal");
3125
+ throw Error(
3126
+ "proposalRedeemerValue: Adding redeemer to non plutus proposal"
3127
+ );
3121
3128
  this.proposalItem.redeemer = this.castBuilderDataToRedeemer(
3122
3129
  redeemer,
3123
3130
  type,
@@ -3505,6 +3512,15 @@ var MeshTxBuilderCore = class {
3505
3512
  this.meshTxBuilderBody.network = network;
3506
3513
  return this;
3507
3514
  };
3515
+ /**
3516
+ * Alias for setNetwork for custom cost models
3517
+ * @param costModels
3518
+ * @returns The MeshTxBuilder instance
3519
+ */
3520
+ setCostModels = (costModels) => {
3521
+ this.setNetwork(costModels);
3522
+ return this;
3523
+ };
3508
3524
  /**
3509
3525
  * Add a transaction that is used as input, but not yet reflected on the global blockchain
3510
3526
  * @param txHex The transaction hex of chained transaction
@@ -3999,6 +4015,35 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
3999
4015
  this._protocolParams
4000
4016
  );
4001
4017
  };
4018
+ completeCostModels = async () => {
4019
+ if (Array.isArray(this.meshTxBuilderBody.network)) {
4020
+ return;
4021
+ }
4022
+ const defaults = [
4023
+ DEFAULT_V1_COST_MODEL_LIST,
4024
+ DEFAULT_V2_COST_MODEL_LIST,
4025
+ DEFAULT_V3_COST_MODEL_LIST
4026
+ ];
4027
+ if (this.fetcher) {
4028
+ try {
4029
+ const costModels = await this.fetcher.fetchCostModels();
4030
+ if (Array.isArray(costModels) && costModels.length > 0) {
4031
+ this.meshTxBuilderBody.network = costModels;
4032
+ return;
4033
+ }
4034
+ console.warn(
4035
+ "fetchCostModels returned an invalid value, using default cost models:",
4036
+ costModels
4037
+ );
4038
+ } catch (error) {
4039
+ console.warn(
4040
+ "Failed to fetch cost models, using default cost models. Error: ",
4041
+ error
4042
+ );
4043
+ }
4044
+ }
4045
+ this.meshTxBuilderBody.network = defaults;
4046
+ };
4002
4047
  /**
4003
4048
  * It builds the transaction query the blockchain for missing information
4004
4049
  * @param customizedTx The optional customized transaction body
@@ -4042,6 +4087,7 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
4042
4087
  this.setFee(customizedTx.fee);
4043
4088
  }
4044
4089
  }
4090
+ await this.completeCostModels();
4045
4091
  this.queueAllLastItem();
4046
4092
  if (this.verbose) {
4047
4093
  console.log(
@@ -4099,7 +4145,15 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
4099
4145
  const selectionCallbacks = {
4100
4146
  computeMinimumCost: async (selectionSkeleton) => {
4101
4147
  const clonedBuilder = this.clone();
4102
- await clonedBuilder.updateByTxPrototype(selectionSkeleton);
4148
+ if (this.manualFee) {
4149
+ const newSelectionSkeleton = {
4150
+ ...selectionSkeleton,
4151
+ fee: BigInt(this.manualFee)
4152
+ };
4153
+ await clonedBuilder.updateByTxPrototype(newSelectionSkeleton);
4154
+ } else {
4155
+ await clonedBuilder.updateByTxPrototype(selectionSkeleton);
4156
+ }
4103
4157
  try {
4104
4158
  await clonedBuilder.evaluateRedeemers();
4105
4159
  } catch (error) {
@@ -5324,6 +5378,12 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
5324
5378
  stepUnits += BigInt(vote.redeemer.exUnits.steps);
5325
5379
  }
5326
5380
  }
5381
+ for (let proposal of this.meshTxBuilderBody.proposals) {
5382
+ if (proposal.type === "ScriptProposal" && proposal.redeemer) {
5383
+ memUnits += BigInt(proposal.redeemer.exUnits.mem);
5384
+ stepUnits += BigInt(proposal.redeemer.exUnits.steps);
5385
+ }
5386
+ }
5327
5387
  memUnits = BigInt(
5328
5388
  new bignumber_default(memUnits).integerValue(bignumber_default.ROUND_CEIL).toString()
5329
5389
  );
@@ -6203,6 +6263,8 @@ var TxParser = class {
6203
6263
  this.serializer = serializer;
6204
6264
  this.fetcher = fetcher;
6205
6265
  }
6266
+ serializer;
6267
+ fetcher;
6206
6268
  parse = async (txHex, providedUtxos = []) => {
6207
6269
  const resolvedUtxos = [...providedUtxos];
6208
6270
  const resolvedUtxosSet = new Set(
@@ -6245,10 +6307,225 @@ var TxParser = class {
6245
6307
  getBuilderBodyWithoutChange = () => this.serializer.parser.getBuilderBodyWithoutChange();
6246
6308
  toTester = () => this.serializer.parser.toTester();
6247
6309
  };
6310
+
6311
+ // src/mesh-tx-builder-v2/index.ts
6312
+ import {
6313
+ DEFAULT_REDEEMER_BUDGET as DEFAULT_REDEEMER_BUDGET3
6314
+ } from "@meshsdk/common";
6315
+ var SpendBuilderImpl = class {
6316
+ constructor(builder) {
6317
+ this.builder = builder;
6318
+ }
6319
+ builder;
6320
+ script(scriptCbor) {
6321
+ this.builder.txInScript(scriptCbor);
6322
+ return this;
6323
+ }
6324
+ referenceScript(refTxHash, refTxIndex, scriptSize, scriptHash) {
6325
+ this.builder.spendingTxInReference(
6326
+ refTxHash,
6327
+ refTxIndex,
6328
+ scriptSize,
6329
+ scriptHash
6330
+ );
6331
+ return this;
6332
+ }
6333
+ redeemerJson(redeemer, exUnits) {
6334
+ this.builder.txInRedeemerValue(
6335
+ redeemer,
6336
+ "JSON",
6337
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6338
+ );
6339
+ return this;
6340
+ }
6341
+ redeemerCbor(redeemer, exUnits) {
6342
+ this.builder.txInRedeemerValue(
6343
+ redeemer,
6344
+ "CBOR",
6345
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6346
+ );
6347
+ return this;
6348
+ }
6349
+ txOut(address, amount) {
6350
+ this.builder.txInInlineDatumPresent();
6351
+ this.builder.txOut(address, amount);
6352
+ return this;
6353
+ }
6354
+ datumJson(datum) {
6355
+ this.builder.txOutInlineDatumValue(datum, "JSON");
6356
+ return this.builder;
6357
+ }
6358
+ datumCbor(datum) {
6359
+ this.builder.txOutInlineDatumValue(datum, "CBOR");
6360
+ return this.builder;
6361
+ }
6362
+ datumHash(datumHash) {
6363
+ this.builder.txOutDatumHashValue(datumHash);
6364
+ return this.builder;
6365
+ }
6366
+ };
6367
+ var MintBuilderImpl = class {
6368
+ constructor(builder) {
6369
+ this.builder = builder;
6370
+ }
6371
+ builder;
6372
+ script(scriptCbor) {
6373
+ this.builder.mintingScript(scriptCbor);
6374
+ return this;
6375
+ }
6376
+ referenceScript(txHash, txIndex, scriptSize, scriptHash) {
6377
+ this.builder.mintTxInReference(txHash, txIndex, scriptSize, scriptHash);
6378
+ return this;
6379
+ }
6380
+ redeemerJson(redeemer, exUnits) {
6381
+ this.builder.mintRedeemerValue(
6382
+ redeemer,
6383
+ "JSON",
6384
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6385
+ );
6386
+ return this;
6387
+ }
6388
+ redeemerCbor(redeemer, exUnits) {
6389
+ this.builder.mintRedeemerValue(
6390
+ redeemer,
6391
+ "CBOR",
6392
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6393
+ );
6394
+ return this;
6395
+ }
6396
+ txOut(address, amount) {
6397
+ this.builder.txOut(address, amount);
6398
+ return this.builder;
6399
+ }
6400
+ };
6401
+ var WithdrawBuilderImpl = class {
6402
+ constructor(builder) {
6403
+ this.builder = builder;
6404
+ }
6405
+ builder;
6406
+ script(scriptCbor) {
6407
+ this.builder.withdrawalScript(scriptCbor);
6408
+ return this;
6409
+ }
6410
+ referenceScript(txHash, txIndex, scriptSize, scriptHash) {
6411
+ this.builder.withdrawalTxInReference(txHash, txIndex, scriptSize, scriptHash);
6412
+ return this;
6413
+ }
6414
+ redeemerJson(redeemer, exUnits) {
6415
+ this.builder.withdrawalRedeemerValue(
6416
+ redeemer,
6417
+ "JSON",
6418
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6419
+ );
6420
+ return this.builder;
6421
+ }
6422
+ redeemerCbor(redeemer, exUnits) {
6423
+ this.builder.withdrawalRedeemerValue(
6424
+ redeemer,
6425
+ "CBOR",
6426
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6427
+ );
6428
+ return this.builder;
6429
+ }
6430
+ };
6431
+ var VoteBuilderImpl = class {
6432
+ constructor(builder) {
6433
+ this.builder = builder;
6434
+ }
6435
+ builder;
6436
+ script(scriptCbor) {
6437
+ this.builder.voteScript(scriptCbor);
6438
+ return this;
6439
+ }
6440
+ referenceScript(txHash, txIndex, scriptSize, scriptHash) {
6441
+ this.builder.voteTxInReference(txHash, txIndex, scriptSize, scriptHash);
6442
+ return this;
6443
+ }
6444
+ redeemerJson(redeemer, exUnits) {
6445
+ this.builder.voteRedeemerValue(
6446
+ redeemer,
6447
+ "JSON",
6448
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6449
+ );
6450
+ return this.builder;
6451
+ }
6452
+ redeemerCbor(redeemer, exUnits) {
6453
+ this.builder.voteRedeemerValue(
6454
+ redeemer,
6455
+ "CBOR",
6456
+ exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
6457
+ );
6458
+ return this.builder;
6459
+ }
6460
+ };
6461
+ var TxBuilderV2 = class extends MeshTxBuilder {
6462
+ spendPlutusV1(txHash, txIndex) {
6463
+ this.spendingPlutusScriptV1();
6464
+ this.txIn(txHash, txIndex);
6465
+ return new SpendBuilderImpl(this);
6466
+ }
6467
+ spendPlutusV2(txHash, txIndex) {
6468
+ this.spendingPlutusScriptV2();
6469
+ this.txIn(txHash, txIndex);
6470
+ return new SpendBuilderImpl(this);
6471
+ }
6472
+ spendPlutusV3(txHash, txIndex) {
6473
+ this.spendingPlutusScriptV3();
6474
+ this.txIn(txHash, txIndex);
6475
+ return new SpendBuilderImpl(this);
6476
+ }
6477
+ mintPlutusV1(quantity, policyId, assetName) {
6478
+ this.mintPlutusScriptV1();
6479
+ this.mint(quantity, policyId, assetName);
6480
+ return new MintBuilderImpl(this);
6481
+ }
6482
+ mintPlutusV2(quantity, policyId, assetName) {
6483
+ this.mintPlutusScriptV2();
6484
+ this.mint(quantity, policyId, assetName);
6485
+ return new MintBuilderImpl(this);
6486
+ }
6487
+ mintPlutusV3(quantity, policyId, assetName) {
6488
+ this.mintPlutusScriptV3();
6489
+ this.mint(quantity, policyId, assetName);
6490
+ return new MintBuilderImpl(this);
6491
+ }
6492
+ withdrawPlutusV1(rewardAddress, amount) {
6493
+ this.withdrawalPlutusScriptV1();
6494
+ this.withdrawal(rewardAddress, amount);
6495
+ return new WithdrawBuilderImpl(this);
6496
+ }
6497
+ withdrawPlutusV2(rewardAddress, coin) {
6498
+ this.withdrawalPlutusScriptV2();
6499
+ this.withdrawal(rewardAddress, coin);
6500
+ return new WithdrawBuilderImpl(this);
6501
+ }
6502
+ withdrawPlutusV3(rewardAddress, coin) {
6503
+ this.withdrawalPlutusScriptV3();
6504
+ this.withdrawal(rewardAddress, coin);
6505
+ return new WithdrawBuilderImpl(this);
6506
+ }
6507
+ votePlutusV1(voter, govActionId, votingProcedure) {
6508
+ this.votePlutusScriptV1();
6509
+ this.vote(voter, govActionId, votingProcedure);
6510
+ return new VoteBuilderImpl(this);
6511
+ }
6512
+ votePlutusV2(voter, govActionId, votingProcedure) {
6513
+ this.votePlutusScriptV2();
6514
+ this.vote(voter, govActionId, votingProcedure);
6515
+ return new VoteBuilderImpl(this);
6516
+ }
6517
+ votePlutusV3(voter, govActionId, votingProcedure) {
6518
+ this.votePlutusScriptV3();
6519
+ this.vote(voter, govActionId, votingProcedure);
6520
+ return new VoteBuilderImpl(this);
6521
+ }
6522
+ };
6523
+ var MeshTxBuilderV2 = TxBuilderV2;
6248
6524
  export {
6249
6525
  ForgeScript,
6250
6526
  LargestFirstInputSelector,
6251
6527
  MeshTxBuilder,
6528
+ MeshTxBuilderV2,
6252
6529
  Transaction,
6253
6530
  TxParser,
6254
6531
  cloneOutput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/transaction",
3
- "version": "1.9.0-beta.99",
3
+ "version": "1.9.1",
4
4
  "description": "Transactions - https://meshjs.dev/apis/transaction",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -35,13 +35,12 @@
35
35
  "typescript": "^5.3.3"
36
36
  },
37
37
  "dependencies": {
38
- "@meshsdk/common": "1.9.0-beta.99",
39
- "@meshsdk/core-cst": "1.9.0-beta.99",
40
- "@cardano-sdk/core": "^0.46.11",
41
- "@cardano-sdk/util": "^0.17.1",
42
- "@cardano-sdk/input-selection": "^0.14.27",
43
- "json-bigint": "^1.0.0",
44
- "libsodium-wrappers-sumo": "0.7.15"
38
+ "@meshsdk/common": "1.9.1",
39
+ "@meshsdk/core-cst": "1.9.1",
40
+ "@cardano-sdk/core": "0.46.12",
41
+ "@cardano-sdk/util": "0.17.1",
42
+ "@cardano-sdk/input-selection": "0.14.28",
43
+ "json-bigint": "^1.0.0"
45
44
  },
46
45
  "prettier": "@meshsdk/configs/prettier",
47
46
  "publishConfig": {