@meshsdk/transaction 1.9.0-beta.101 → 1.9.0-beta.103
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 +273 -6
- package/dist/index.d.cts +91 -1
- package/dist/index.d.ts +91 -1
- package/dist/index.js +280 -9
- package/package.json +3 -3
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:
|
|
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) => {
|
|
@@ -2011,7 +2011,7 @@ var LargestFirstInputSelector = class {
|
|
|
2011
2011
|
newInputs: selectedUtxos,
|
|
2012
2012
|
newOutputs: /* @__PURE__ */ new Set(),
|
|
2013
2013
|
change: changeOutputs,
|
|
2014
|
-
fee:
|
|
2014
|
+
fee: BigInt(1e9)
|
|
2015
2015
|
})).fee;
|
|
2016
2016
|
}
|
|
2017
2017
|
}
|
|
@@ -3142,9 +3142,12 @@ var MeshTxBuilderCore = class {
|
|
|
3142
3142
|
* @returns The MeshTxBuilder instance
|
|
3143
3143
|
*/
|
|
3144
3144
|
proposalRedeemerValue = (redeemer, type = "Mesh", exUnits = { ...import_common.DEFAULT_REDEEMER_BUDGET }) => {
|
|
3145
|
-
if (!this.proposalItem)
|
|
3145
|
+
if (!this.proposalItem)
|
|
3146
|
+
throw Error("proposalRedeemerValue: Undefined proposal");
|
|
3146
3147
|
if (!(this.proposalItem.type === "ScriptProposal"))
|
|
3147
|
-
throw Error(
|
|
3148
|
+
throw Error(
|
|
3149
|
+
"proposalRedeemerValue: Adding redeemer to non plutus proposal"
|
|
3150
|
+
);
|
|
3148
3151
|
this.proposalItem.redeemer = this.castBuilderDataToRedeemer(
|
|
3149
3152
|
redeemer,
|
|
3150
3153
|
type,
|
|
@@ -3532,6 +3535,15 @@ var MeshTxBuilderCore = class {
|
|
|
3532
3535
|
this.meshTxBuilderBody.network = network;
|
|
3533
3536
|
return this;
|
|
3534
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
|
+
};
|
|
3535
3547
|
/**
|
|
3536
3548
|
* Add a transaction that is used as input, but not yet reflected on the global blockchain
|
|
3537
3549
|
* @param txHex The transaction hex of chained transaction
|
|
@@ -4024,6 +4036,37 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4024
4036
|
this._protocolParams
|
|
4025
4037
|
);
|
|
4026
4038
|
};
|
|
4039
|
+
completeCostModels = async () => {
|
|
4040
|
+
console.log("completing cost models...");
|
|
4041
|
+
if (Array.isArray(this.meshTxBuilderBody.network)) {
|
|
4042
|
+
return;
|
|
4043
|
+
}
|
|
4044
|
+
const defaults = [
|
|
4045
|
+
import_common3.DEFAULT_V1_COST_MODEL_LIST,
|
|
4046
|
+
import_common3.DEFAULT_V2_COST_MODEL_LIST,
|
|
4047
|
+
import_common3.DEFAULT_V3_COST_MODEL_LIST
|
|
4048
|
+
];
|
|
4049
|
+
if (this.fetcher) {
|
|
4050
|
+
try {
|
|
4051
|
+
console.log("fetching cost models from fetcher...");
|
|
4052
|
+
const costModels = await this.fetcher.fetchCostModels();
|
|
4053
|
+
if (Array.isArray(costModels) && costModels.length > 0) {
|
|
4054
|
+
this.meshTxBuilderBody.network = costModels;
|
|
4055
|
+
return;
|
|
4056
|
+
}
|
|
4057
|
+
console.warn(
|
|
4058
|
+
"fetchCostModels returned an invalid value, using default cost models:",
|
|
4059
|
+
costModels
|
|
4060
|
+
);
|
|
4061
|
+
} catch (error) {
|
|
4062
|
+
console.warn(
|
|
4063
|
+
"Failed to fetch cost models, using default cost models. Error: ",
|
|
4064
|
+
error
|
|
4065
|
+
);
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
this.meshTxBuilderBody.network = defaults;
|
|
4069
|
+
};
|
|
4027
4070
|
/**
|
|
4028
4071
|
* It builds the transaction query the blockchain for missing information
|
|
4029
4072
|
* @param customizedTx The optional customized transaction body
|
|
@@ -4067,6 +4110,7 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4067
4110
|
this.setFee(customizedTx.fee);
|
|
4068
4111
|
}
|
|
4069
4112
|
}
|
|
4113
|
+
await this.completeCostModels();
|
|
4070
4114
|
this.queueAllLastItem();
|
|
4071
4115
|
if (this.verbose) {
|
|
4072
4116
|
console.log(
|
|
@@ -4124,7 +4168,15 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4124
4168
|
const selectionCallbacks = {
|
|
4125
4169
|
computeMinimumCost: async (selectionSkeleton) => {
|
|
4126
4170
|
const clonedBuilder = this.clone();
|
|
4127
|
-
|
|
4171
|
+
if (this.manualFee) {
|
|
4172
|
+
const newSelectionSkeleton = {
|
|
4173
|
+
...selectionSkeleton,
|
|
4174
|
+
fee: BigInt(this.manualFee)
|
|
4175
|
+
};
|
|
4176
|
+
await clonedBuilder.updateByTxPrototype(newSelectionSkeleton);
|
|
4177
|
+
} else {
|
|
4178
|
+
await clonedBuilder.updateByTxPrototype(selectionSkeleton);
|
|
4179
|
+
}
|
|
4128
4180
|
try {
|
|
4129
4181
|
await clonedBuilder.evaluateRedeemers();
|
|
4130
4182
|
} catch (error) {
|
|
@@ -6205,6 +6257,8 @@ var TxParser = class {
|
|
|
6205
6257
|
this.serializer = serializer;
|
|
6206
6258
|
this.fetcher = fetcher;
|
|
6207
6259
|
}
|
|
6260
|
+
serializer;
|
|
6261
|
+
fetcher;
|
|
6208
6262
|
parse = async (txHex, providedUtxos = []) => {
|
|
6209
6263
|
const resolvedUtxos = [...providedUtxos];
|
|
6210
6264
|
const resolvedUtxosSet = new Set(
|
|
@@ -6247,11 +6301,224 @@ var TxParser = class {
|
|
|
6247
6301
|
getBuilderBodyWithoutChange = () => this.serializer.parser.getBuilderBodyWithoutChange();
|
|
6248
6302
|
toTester = () => this.serializer.parser.toTester();
|
|
6249
6303
|
};
|
|
6304
|
+
|
|
6305
|
+
// src/mesh-tx-builder-v2/index.ts
|
|
6306
|
+
var import_common5 = require("@meshsdk/common");
|
|
6307
|
+
var SpendBuilderImpl = class {
|
|
6308
|
+
constructor(builder) {
|
|
6309
|
+
this.builder = builder;
|
|
6310
|
+
}
|
|
6311
|
+
builder;
|
|
6312
|
+
script(scriptCbor) {
|
|
6313
|
+
this.builder.txInScript(scriptCbor);
|
|
6314
|
+
return this;
|
|
6315
|
+
}
|
|
6316
|
+
referenceScript(refTxHash, refTxIndex, scriptSize, scriptHash) {
|
|
6317
|
+
this.builder.spendingTxInReference(
|
|
6318
|
+
refTxHash,
|
|
6319
|
+
refTxIndex,
|
|
6320
|
+
scriptSize,
|
|
6321
|
+
scriptHash
|
|
6322
|
+
);
|
|
6323
|
+
return this;
|
|
6324
|
+
}
|
|
6325
|
+
redeemerJson(redeemer, exUnits) {
|
|
6326
|
+
this.builder.txInRedeemerValue(
|
|
6327
|
+
redeemer,
|
|
6328
|
+
"JSON",
|
|
6329
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6330
|
+
);
|
|
6331
|
+
return this;
|
|
6332
|
+
}
|
|
6333
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6334
|
+
this.builder.txInRedeemerValue(
|
|
6335
|
+
redeemer,
|
|
6336
|
+
"CBOR",
|
|
6337
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6338
|
+
);
|
|
6339
|
+
return this;
|
|
6340
|
+
}
|
|
6341
|
+
txOut(address, amount) {
|
|
6342
|
+
this.builder.txInInlineDatumPresent();
|
|
6343
|
+
this.builder.txOut(address, amount);
|
|
6344
|
+
return this;
|
|
6345
|
+
}
|
|
6346
|
+
datumJson(datum) {
|
|
6347
|
+
this.builder.txOutInlineDatumValue(datum, "JSON");
|
|
6348
|
+
return this.builder;
|
|
6349
|
+
}
|
|
6350
|
+
datumCbor(datum) {
|
|
6351
|
+
this.builder.txOutInlineDatumValue(datum, "CBOR");
|
|
6352
|
+
return this.builder;
|
|
6353
|
+
}
|
|
6354
|
+
datumHash(datumHash) {
|
|
6355
|
+
this.builder.txOutDatumHashValue(datumHash);
|
|
6356
|
+
return this.builder;
|
|
6357
|
+
}
|
|
6358
|
+
};
|
|
6359
|
+
var MintBuilderImpl = class {
|
|
6360
|
+
constructor(builder) {
|
|
6361
|
+
this.builder = builder;
|
|
6362
|
+
}
|
|
6363
|
+
builder;
|
|
6364
|
+
script(scriptCbor) {
|
|
6365
|
+
this.builder.mintingScript(scriptCbor);
|
|
6366
|
+
return this;
|
|
6367
|
+
}
|
|
6368
|
+
referenceScript(txHash, txIndex, scriptSize, scriptHash) {
|
|
6369
|
+
this.builder.mintTxInReference(txHash, txIndex, scriptSize, scriptHash);
|
|
6370
|
+
return this;
|
|
6371
|
+
}
|
|
6372
|
+
redeemerJson(redeemer, exUnits) {
|
|
6373
|
+
this.builder.mintRedeemerValue(
|
|
6374
|
+
redeemer,
|
|
6375
|
+
"JSON",
|
|
6376
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6377
|
+
);
|
|
6378
|
+
return this;
|
|
6379
|
+
}
|
|
6380
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6381
|
+
this.builder.mintRedeemerValue(
|
|
6382
|
+
redeemer,
|
|
6383
|
+
"CBOR",
|
|
6384
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6385
|
+
);
|
|
6386
|
+
return this;
|
|
6387
|
+
}
|
|
6388
|
+
txOut(address, amount) {
|
|
6389
|
+
this.builder.txOut(address, amount);
|
|
6390
|
+
return this.builder;
|
|
6391
|
+
}
|
|
6392
|
+
};
|
|
6393
|
+
var WithdrawBuilderImpl = class {
|
|
6394
|
+
constructor(builder) {
|
|
6395
|
+
this.builder = builder;
|
|
6396
|
+
}
|
|
6397
|
+
builder;
|
|
6398
|
+
script(scriptCbor) {
|
|
6399
|
+
this.builder.withdrawalScript(scriptCbor);
|
|
6400
|
+
return this;
|
|
6401
|
+
}
|
|
6402
|
+
referenceScript(txHash, txIndex, scriptSize, scriptHash) {
|
|
6403
|
+
this.builder.withdrawalTxInReference(txHash, txIndex, scriptSize, scriptHash);
|
|
6404
|
+
return this;
|
|
6405
|
+
}
|
|
6406
|
+
redeemerJson(redeemer, exUnits) {
|
|
6407
|
+
this.builder.withdrawalRedeemerValue(
|
|
6408
|
+
redeemer,
|
|
6409
|
+
"JSON",
|
|
6410
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6411
|
+
);
|
|
6412
|
+
return this.builder;
|
|
6413
|
+
}
|
|
6414
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6415
|
+
this.builder.withdrawalRedeemerValue(
|
|
6416
|
+
redeemer,
|
|
6417
|
+
"CBOR",
|
|
6418
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6419
|
+
);
|
|
6420
|
+
return this.builder;
|
|
6421
|
+
}
|
|
6422
|
+
};
|
|
6423
|
+
var VoteBuilderImpl = class {
|
|
6424
|
+
constructor(builder) {
|
|
6425
|
+
this.builder = builder;
|
|
6426
|
+
}
|
|
6427
|
+
builder;
|
|
6428
|
+
script(scriptCbor) {
|
|
6429
|
+
this.builder.voteScript(scriptCbor);
|
|
6430
|
+
return this;
|
|
6431
|
+
}
|
|
6432
|
+
referenceScript(txHash, txIndex, scriptSize, scriptHash) {
|
|
6433
|
+
this.builder.voteTxInReference(txHash, txIndex, scriptSize, scriptHash);
|
|
6434
|
+
return this;
|
|
6435
|
+
}
|
|
6436
|
+
redeemerJson(redeemer, exUnits) {
|
|
6437
|
+
this.builder.voteRedeemerValue(
|
|
6438
|
+
redeemer,
|
|
6439
|
+
"JSON",
|
|
6440
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6441
|
+
);
|
|
6442
|
+
return this.builder;
|
|
6443
|
+
}
|
|
6444
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6445
|
+
this.builder.voteRedeemerValue(
|
|
6446
|
+
redeemer,
|
|
6447
|
+
"CBOR",
|
|
6448
|
+
exUnits ?? { ...import_common5.DEFAULT_REDEEMER_BUDGET }
|
|
6449
|
+
);
|
|
6450
|
+
return this.builder;
|
|
6451
|
+
}
|
|
6452
|
+
};
|
|
6453
|
+
var TxBuilderV2 = class extends MeshTxBuilder {
|
|
6454
|
+
spendPlutusV1(txHash, txIndex) {
|
|
6455
|
+
this.spendingPlutusScriptV1();
|
|
6456
|
+
this.txIn(txHash, txIndex);
|
|
6457
|
+
return new SpendBuilderImpl(this);
|
|
6458
|
+
}
|
|
6459
|
+
spendPlutusV2(txHash, txIndex) {
|
|
6460
|
+
this.spendingPlutusScriptV2();
|
|
6461
|
+
this.txIn(txHash, txIndex);
|
|
6462
|
+
return new SpendBuilderImpl(this);
|
|
6463
|
+
}
|
|
6464
|
+
spendPlutusV3(txHash, txIndex) {
|
|
6465
|
+
this.spendingPlutusScriptV3();
|
|
6466
|
+
this.txIn(txHash, txIndex);
|
|
6467
|
+
return new SpendBuilderImpl(this);
|
|
6468
|
+
}
|
|
6469
|
+
mintPlutusV1(quantity, policyId, assetName) {
|
|
6470
|
+
this.mintPlutusScriptV1();
|
|
6471
|
+
this.mint(quantity, policyId, assetName);
|
|
6472
|
+
return new MintBuilderImpl(this);
|
|
6473
|
+
}
|
|
6474
|
+
mintPlutusV2(quantity, policyId, assetName) {
|
|
6475
|
+
this.mintPlutusScriptV2();
|
|
6476
|
+
this.mint(quantity, policyId, assetName);
|
|
6477
|
+
return new MintBuilderImpl(this);
|
|
6478
|
+
}
|
|
6479
|
+
mintPlutusV3(quantity, policyId, assetName) {
|
|
6480
|
+
this.mintPlutusScriptV3();
|
|
6481
|
+
this.mint(quantity, policyId, assetName);
|
|
6482
|
+
return new MintBuilderImpl(this);
|
|
6483
|
+
}
|
|
6484
|
+
withdrawPlutusV1(rewardAddress, amount) {
|
|
6485
|
+
this.withdrawalPlutusScriptV1();
|
|
6486
|
+
this.withdrawal(rewardAddress, amount);
|
|
6487
|
+
return new WithdrawBuilderImpl(this);
|
|
6488
|
+
}
|
|
6489
|
+
withdrawPlutusV2(rewardAddress, coin) {
|
|
6490
|
+
this.withdrawalPlutusScriptV2();
|
|
6491
|
+
this.withdrawal(rewardAddress, coin);
|
|
6492
|
+
return new WithdrawBuilderImpl(this);
|
|
6493
|
+
}
|
|
6494
|
+
withdrawPlutusV3(rewardAddress, coin) {
|
|
6495
|
+
this.withdrawalPlutusScriptV3();
|
|
6496
|
+
this.withdrawal(rewardAddress, coin);
|
|
6497
|
+
return new WithdrawBuilderImpl(this);
|
|
6498
|
+
}
|
|
6499
|
+
votePlutusV1(voter, govActionId, votingProcedure) {
|
|
6500
|
+
this.votePlutusScriptV1();
|
|
6501
|
+
this.vote(voter, govActionId, votingProcedure);
|
|
6502
|
+
return new VoteBuilderImpl(this);
|
|
6503
|
+
}
|
|
6504
|
+
votePlutusV2(voter, govActionId, votingProcedure) {
|
|
6505
|
+
this.votePlutusScriptV2();
|
|
6506
|
+
this.vote(voter, govActionId, votingProcedure);
|
|
6507
|
+
return new VoteBuilderImpl(this);
|
|
6508
|
+
}
|
|
6509
|
+
votePlutusV3(voter, govActionId, votingProcedure) {
|
|
6510
|
+
this.votePlutusScriptV3();
|
|
6511
|
+
this.vote(voter, govActionId, votingProcedure);
|
|
6512
|
+
return new VoteBuilderImpl(this);
|
|
6513
|
+
}
|
|
6514
|
+
};
|
|
6515
|
+
var MeshTxBuilderV2 = TxBuilderV2;
|
|
6250
6516
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6251
6517
|
0 && (module.exports = {
|
|
6252
6518
|
ForgeScript,
|
|
6253
6519
|
LargestFirstInputSelector,
|
|
6254
6520
|
MeshTxBuilder,
|
|
6521
|
+
MeshTxBuilderV2,
|
|
6255
6522
|
Transaction,
|
|
6256
6523
|
TxParser,
|
|
6257
6524
|
cloneOutput,
|
package/dist/index.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
@@ -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
|
-
|
|
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:
|
|
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) => {
|
|
@@ -1979,7 +1981,7 @@ var LargestFirstInputSelector = class {
|
|
|
1979
1981
|
newInputs: selectedUtxos,
|
|
1980
1982
|
newOutputs: /* @__PURE__ */ new Set(),
|
|
1981
1983
|
change: changeOutputs,
|
|
1982
|
-
fee:
|
|
1984
|
+
fee: BigInt(1e9)
|
|
1983
1985
|
})).fee;
|
|
1984
1986
|
}
|
|
1985
1987
|
}
|
|
@@ -2033,8 +2035,8 @@ import {
|
|
|
2033
2035
|
DEFAULT_PROTOCOL_PARAMETERS,
|
|
2034
2036
|
DEFAULT_REDEEMER_BUDGET,
|
|
2035
2037
|
DREP_DEPOSIT,
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
+
emptyTxBuilderBody,
|
|
2039
|
+
VOTING_PROPOSAL_DEPOSIT
|
|
2038
2040
|
} from "@meshsdk/common";
|
|
2039
2041
|
import { Address, CredentialType } from "@meshsdk/core-cst";
|
|
2040
2042
|
|
|
@@ -3117,9 +3119,12 @@ var MeshTxBuilderCore = class {
|
|
|
3117
3119
|
* @returns The MeshTxBuilder instance
|
|
3118
3120
|
*/
|
|
3119
3121
|
proposalRedeemerValue = (redeemer, type = "Mesh", exUnits = { ...DEFAULT_REDEEMER_BUDGET }) => {
|
|
3120
|
-
if (!this.proposalItem)
|
|
3122
|
+
if (!this.proposalItem)
|
|
3123
|
+
throw Error("proposalRedeemerValue: Undefined proposal");
|
|
3121
3124
|
if (!(this.proposalItem.type === "ScriptProposal"))
|
|
3122
|
-
throw Error(
|
|
3125
|
+
throw Error(
|
|
3126
|
+
"proposalRedeemerValue: Adding redeemer to non plutus proposal"
|
|
3127
|
+
);
|
|
3123
3128
|
this.proposalItem.redeemer = this.castBuilderDataToRedeemer(
|
|
3124
3129
|
redeemer,
|
|
3125
3130
|
type,
|
|
@@ -3507,6 +3512,15 @@ var MeshTxBuilderCore = class {
|
|
|
3507
3512
|
this.meshTxBuilderBody.network = network;
|
|
3508
3513
|
return this;
|
|
3509
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
|
+
};
|
|
3510
3524
|
/**
|
|
3511
3525
|
* Add a transaction that is used as input, but not yet reflected on the global blockchain
|
|
3512
3526
|
* @param txHex The transaction hex of chained transaction
|
|
@@ -4001,6 +4015,37 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4001
4015
|
this._protocolParams
|
|
4002
4016
|
);
|
|
4003
4017
|
};
|
|
4018
|
+
completeCostModels = async () => {
|
|
4019
|
+
console.log("completing cost models...");
|
|
4020
|
+
if (Array.isArray(this.meshTxBuilderBody.network)) {
|
|
4021
|
+
return;
|
|
4022
|
+
}
|
|
4023
|
+
const defaults = [
|
|
4024
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
4025
|
+
DEFAULT_V2_COST_MODEL_LIST,
|
|
4026
|
+
DEFAULT_V3_COST_MODEL_LIST
|
|
4027
|
+
];
|
|
4028
|
+
if (this.fetcher) {
|
|
4029
|
+
try {
|
|
4030
|
+
console.log("fetching cost models from fetcher...");
|
|
4031
|
+
const costModels = await this.fetcher.fetchCostModels();
|
|
4032
|
+
if (Array.isArray(costModels) && costModels.length > 0) {
|
|
4033
|
+
this.meshTxBuilderBody.network = costModels;
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
console.warn(
|
|
4037
|
+
"fetchCostModels returned an invalid value, using default cost models:",
|
|
4038
|
+
costModels
|
|
4039
|
+
);
|
|
4040
|
+
} catch (error) {
|
|
4041
|
+
console.warn(
|
|
4042
|
+
"Failed to fetch cost models, using default cost models. Error: ",
|
|
4043
|
+
error
|
|
4044
|
+
);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
this.meshTxBuilderBody.network = defaults;
|
|
4048
|
+
};
|
|
4004
4049
|
/**
|
|
4005
4050
|
* It builds the transaction query the blockchain for missing information
|
|
4006
4051
|
* @param customizedTx The optional customized transaction body
|
|
@@ -4044,6 +4089,7 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4044
4089
|
this.setFee(customizedTx.fee);
|
|
4045
4090
|
}
|
|
4046
4091
|
}
|
|
4092
|
+
await this.completeCostModels();
|
|
4047
4093
|
this.queueAllLastItem();
|
|
4048
4094
|
if (this.verbose) {
|
|
4049
4095
|
console.log(
|
|
@@ -4101,7 +4147,15 @@ var MeshTxBuilder = class _MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
4101
4147
|
const selectionCallbacks = {
|
|
4102
4148
|
computeMinimumCost: async (selectionSkeleton) => {
|
|
4103
4149
|
const clonedBuilder = this.clone();
|
|
4104
|
-
|
|
4150
|
+
if (this.manualFee) {
|
|
4151
|
+
const newSelectionSkeleton = {
|
|
4152
|
+
...selectionSkeleton,
|
|
4153
|
+
fee: BigInt(this.manualFee)
|
|
4154
|
+
};
|
|
4155
|
+
await clonedBuilder.updateByTxPrototype(newSelectionSkeleton);
|
|
4156
|
+
} else {
|
|
4157
|
+
await clonedBuilder.updateByTxPrototype(selectionSkeleton);
|
|
4158
|
+
}
|
|
4105
4159
|
try {
|
|
4106
4160
|
await clonedBuilder.evaluateRedeemers();
|
|
4107
4161
|
} catch (error) {
|
|
@@ -6205,6 +6259,8 @@ var TxParser = class {
|
|
|
6205
6259
|
this.serializer = serializer;
|
|
6206
6260
|
this.fetcher = fetcher;
|
|
6207
6261
|
}
|
|
6262
|
+
serializer;
|
|
6263
|
+
fetcher;
|
|
6208
6264
|
parse = async (txHex, providedUtxos = []) => {
|
|
6209
6265
|
const resolvedUtxos = [...providedUtxos];
|
|
6210
6266
|
const resolvedUtxosSet = new Set(
|
|
@@ -6247,10 +6303,225 @@ var TxParser = class {
|
|
|
6247
6303
|
getBuilderBodyWithoutChange = () => this.serializer.parser.getBuilderBodyWithoutChange();
|
|
6248
6304
|
toTester = () => this.serializer.parser.toTester();
|
|
6249
6305
|
};
|
|
6306
|
+
|
|
6307
|
+
// src/mesh-tx-builder-v2/index.ts
|
|
6308
|
+
import {
|
|
6309
|
+
DEFAULT_REDEEMER_BUDGET as DEFAULT_REDEEMER_BUDGET3
|
|
6310
|
+
} from "@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 ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
6334
|
+
);
|
|
6335
|
+
return this;
|
|
6336
|
+
}
|
|
6337
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6338
|
+
this.builder.txInRedeemerValue(
|
|
6339
|
+
redeemer,
|
|
6340
|
+
"CBOR",
|
|
6341
|
+
exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
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 ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
6381
|
+
);
|
|
6382
|
+
return this;
|
|
6383
|
+
}
|
|
6384
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6385
|
+
this.builder.mintRedeemerValue(
|
|
6386
|
+
redeemer,
|
|
6387
|
+
"CBOR",
|
|
6388
|
+
exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
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 ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
6415
|
+
);
|
|
6416
|
+
return this.builder;
|
|
6417
|
+
}
|
|
6418
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6419
|
+
this.builder.withdrawalRedeemerValue(
|
|
6420
|
+
redeemer,
|
|
6421
|
+
"CBOR",
|
|
6422
|
+
exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
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 ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
6445
|
+
);
|
|
6446
|
+
return this.builder;
|
|
6447
|
+
}
|
|
6448
|
+
redeemerCbor(redeemer, exUnits) {
|
|
6449
|
+
this.builder.voteRedeemerValue(
|
|
6450
|
+
redeemer,
|
|
6451
|
+
"CBOR",
|
|
6452
|
+
exUnits ?? { ...DEFAULT_REDEEMER_BUDGET3 }
|
|
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;
|
|
6250
6520
|
export {
|
|
6251
6521
|
ForgeScript,
|
|
6252
6522
|
LargestFirstInputSelector,
|
|
6253
6523
|
MeshTxBuilder,
|
|
6524
|
+
MeshTxBuilderV2,
|
|
6254
6525
|
Transaction,
|
|
6255
6526
|
TxParser,
|
|
6256
6527
|
cloneOutput,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/transaction",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.103",
|
|
4
4
|
"description": "Transactions - https://meshjs.dev/apis/transaction",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@meshsdk/common": "1.9.0-beta.
|
|
39
|
-
"@meshsdk/core-cst": "1.9.0-beta.
|
|
38
|
+
"@meshsdk/common": "1.9.0-beta.103",
|
|
39
|
+
"@meshsdk/core-cst": "1.9.0-beta.103",
|
|
40
40
|
"@cardano-sdk/core": "0.46.12",
|
|
41
41
|
"@cardano-sdk/util": "0.17.1",
|
|
42
42
|
"@cardano-sdk/input-selection": "0.14.28",
|