@harmoniclabs/buildooor 0.1.27 → 0.1.29
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.
|
@@ -56,7 +56,7 @@ export declare class TxBuilder {
|
|
|
56
56
|
* 3) `tx.witnesses.vkeyWitnesses` (empty)
|
|
57
57
|
*/
|
|
58
58
|
overrideTxRedeemers(tx: Tx, newRedeemers: TxRedeemer[], opts?: CostModelsToLanguageViewCborOpts): Tx;
|
|
59
|
-
buildSync(buildArgs: ITxBuildArgs, { onScriptInvalid, onScriptResult }?: ITxBuildSyncOptions): Tx;
|
|
59
|
+
buildSync(buildArgs: ITxBuildArgs, { onScriptInvalid, onScriptResult, ...otps }?: ITxBuildSyncOptions): Tx;
|
|
60
60
|
validatePhaseTwoVerbose(tx: Tx): {
|
|
61
61
|
result: CEKValue;
|
|
62
62
|
budgetSpent: ExBudget;
|
|
@@ -310,7 +310,8 @@ var TxBuilder = /** @class */ (function () {
|
|
|
310
310
|
};
|
|
311
311
|
TxBuilder.prototype.buildSync = function (buildArgs, _a) {
|
|
312
312
|
var _b;
|
|
313
|
-
|
|
313
|
+
if (_a === void 0) { _a = {}; }
|
|
314
|
+
var onScriptInvalid = _a.onScriptInvalid, onScriptResult = _a.onScriptResult, otps = __rest(_a, ["onScriptInvalid", "onScriptResult"]);
|
|
314
315
|
var _initBuild = this.initTxBuild(buildArgs);
|
|
315
316
|
var
|
|
316
317
|
// tx,
|
|
@@ -334,7 +335,7 @@ var TxBuilder = /** @class */ (function () {
|
|
|
334
335
|
executionUnitPrices.priceMemory,
|
|
335
336
|
executionUnitPrices.priceSteps,
|
|
336
337
|
];
|
|
337
|
-
var
|
|
338
|
+
var _c = __read(executionUnitPrices, 2), memRational = _c[0], cpuRational = _c[1];
|
|
338
339
|
memRational = typeof memRational === "number" ? cbor_1.CborPositiveRational.fromNumber(memRational) : memRational;
|
|
339
340
|
cpuRational = typeof cpuRational === "number" ? cbor_1.CborPositiveRational.fromNumber(cpuRational) : cpuRational;
|
|
340
341
|
// group by purpose so we can use the redeemer index to find the script
|
|
@@ -345,12 +346,16 @@ var TxBuilder = /** @class */ (function () {
|
|
|
345
346
|
var voteScriptsToExec = scriptsToExec.filter(function (elem) { return elem.rdmrTag === cardano_ledger_ts_1.TxRedeemerTag.Voting; });
|
|
346
347
|
var proposeScriptsToExec = scriptsToExec.filter(function (elem) { return elem.rdmrTag === cardano_ledger_ts_1.TxRedeemerTag.Proposing; });
|
|
347
348
|
var maxRound = 3;
|
|
349
|
+
var defaultRounds = 1;
|
|
348
350
|
var _isScriptValid = true;
|
|
349
351
|
var fee = minFee;
|
|
350
352
|
var prevFee;
|
|
353
|
+
var nRounds = (typeof otps.nScriptExecitionRounds === "number" ?
|
|
354
|
+
Math.max(0, Math.min(otps.nScriptExecitionRounds, maxRound))
|
|
355
|
+
: defaultRounds);
|
|
351
356
|
var _loop_1 = function (round) {
|
|
352
357
|
prevFee = fee;
|
|
353
|
-
var
|
|
358
|
+
var _d = (0, toOnChain_1.getTxInfos)(tx, this_1.genesisInfos), txInfosV1 = _d.v1, txInfosV2 = _d.v2, txInfosV3 = _d.v3;
|
|
354
359
|
var totExBudget = new plutus_machine_1.ExBudget({ mem: 0, cpu: 0 });
|
|
355
360
|
var _loop_2 = function (i) {
|
|
356
361
|
var rdmr = rdmrs[i];
|
|
@@ -396,9 +401,9 @@ var TxBuilder = /** @class */ (function () {
|
|
|
396
401
|
if (typeof expectedVersion !== "string")
|
|
397
402
|
throw new Error("unexpected redeemer for native script");
|
|
398
403
|
var ctxData = getCtx(script.type, (0, getSpendingPurposeData_1.getSpendingPurposeData)(rdmr, tx.body, expectedVersion), (0, getSpendingPurposeData_1.getScriptInfoData)(rdmr, tx.body, expectedVersion, datum), rdmrData, txInfosV1, txInfosV2, txInfosV3);
|
|
399
|
-
var
|
|
404
|
+
var _e = cek.eval(isV2OrLess ?
|
|
400
405
|
new uplc_1.Application(new uplc_1.Application(new uplc_1.Application(getScriptLikeUplc(script), uplc_1.UPLCConst.data(datum)), uplc_1.UPLCConst.data(rdmrData)), uplc_1.UPLCConst.data(ctxData)) :
|
|
401
|
-
new uplc_1.Application(getScriptLikeUplc(script), uplc_1.UPLCConst.data(ctxData))), result =
|
|
406
|
+
new uplc_1.Application(getScriptLikeUplc(script), uplc_1.UPLCConst.data(ctxData))), result = _e.result, budgetSpent = _e.budgetSpent, logs = _e.logs;
|
|
402
407
|
_isScriptValid = onEvaluationResult(i, totExBudget, rdmr, result, budgetSpent, logs, isV2OrLess ? [
|
|
403
408
|
datum,
|
|
404
409
|
rdmrData,
|
|
@@ -451,7 +456,7 @@ var TxBuilder = /** @class */ (function () {
|
|
|
451
456
|
totExBudget = new plutus_machine_1.ExBudget({ mem: 0, cpu: 0 });
|
|
452
457
|
};
|
|
453
458
|
var this_1 = this;
|
|
454
|
-
for (var round = 0; round <
|
|
459
|
+
for (var round = 0; round < nRounds; round++) {
|
|
455
460
|
var state_1 = _loop_1(round);
|
|
456
461
|
if (state_1 === "break")
|
|
457
462
|
break;
|
|
@@ -3,6 +3,11 @@ import { Data } from "@harmoniclabs/plutus-data";
|
|
|
3
3
|
import { ExBudget } from "@harmoniclabs/plutus-machine";
|
|
4
4
|
import { PureUPLCTerm } from "@harmoniclabs/uplc";
|
|
5
5
|
export interface ITxBuildSyncOptions {
|
|
6
|
+
/**
|
|
7
|
+
* @default 1
|
|
8
|
+
* @max 3
|
|
9
|
+
**/
|
|
10
|
+
nScriptExecitionRounds?: number;
|
|
6
11
|
onScriptInvalid?: (rdmr: TxRedeemer, logs: string[], callArgs: Data[]) => void;
|
|
7
12
|
onScriptResult?: (rdmr: TxRedeemer, result: PureUPLCTerm, exBudget: ExBudget, logs: string[], callArgs: Data[]) => void;
|
|
8
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harmoniclabs/buildooor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "Cardano transaction builder in typescript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@harmoniclabs/bip32_ed25519": "^0.1.3",
|
|
52
52
|
"@harmoniclabs/bytestring": "^1.0.0",
|
|
53
53
|
"@harmoniclabs/cardano-costmodels-ts": "^1.3.0",
|
|
54
|
-
"@harmoniclabs/cardano-ledger-ts": "^0.4.
|
|
54
|
+
"@harmoniclabs/cardano-ledger-ts": "^0.4.6",
|
|
55
55
|
"@harmoniclabs/cbor": "^1.6.6",
|
|
56
56
|
"@harmoniclabs/pair": "^1.0.0",
|
|
57
57
|
"@harmoniclabs/plutus-data": "^1.2.6",
|