@harmoniclabs/buildooor 0.1.28 → 0.1.30
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];
|
|
@@ -379,7 +384,7 @@ var TxBuilder = /** @class */ (function () {
|
|
|
379
384
|
_isScriptValid = onEvaluationResult(i, totExBudget, rdmr, result, budgetSpent, logs, isV2OrLess ? [
|
|
380
385
|
rdmrData,
|
|
381
386
|
ctxData
|
|
382
|
-
] : [ctxData], rdmrs, script.hash.toString(), onScriptResult, onScriptInvalid);
|
|
387
|
+
] : [ctxData], rdmrs, script.hash.toString(), tx, onScriptResult, onScriptInvalid);
|
|
383
388
|
};
|
|
384
389
|
if (tag === cardano_ledger_ts_1.TxRedeemerTag.Spend) {
|
|
385
390
|
var entry = spendScriptsToExec.find(function (_a) {
|
|
@@ -396,14 +401,14 @@ 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,
|
|
405
410
|
ctxData
|
|
406
|
-
] : [ctxData], rdmrs, script.hash.toString(), onScriptResult, onScriptInvalid);
|
|
411
|
+
] : [ctxData], rdmrs, script.hash.toString(), tx, onScriptResult, onScriptInvalid);
|
|
407
412
|
}
|
|
408
413
|
else if (tag === cardano_ledger_ts_1.TxRedeemerTag.Mint)
|
|
409
414
|
onlyRedeemerArg(mintScriptsToExec);
|
|
@@ -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;
|
|
@@ -1238,17 +1243,17 @@ function getCtx(scriptType, spendingPurpose, scriptInfo, redeemerData, txInfosV1
|
|
|
1238
1243
|
else
|
|
1239
1244
|
throw new Error("unexpected native script execution");
|
|
1240
1245
|
}
|
|
1241
|
-
function onEvaluationResult(i, totExBudget, rdmr, result, budgetSpent, logs, callArgs, rdmrs, scritHashStr, onScriptResult, onScriptInvalid) {
|
|
1246
|
+
function onEvaluationResult(i, totExBudget, rdmr, result, budgetSpent, logs, callArgs, rdmrs, scritHashStr, tx, onScriptResult, onScriptInvalid) {
|
|
1242
1247
|
var _isScriptValid = true;
|
|
1243
1248
|
if (typeof onScriptResult === "function")
|
|
1244
|
-
onScriptResult(rdmr.clone(), result, budgetSpent.clone(), logs.slice(), callArgs.map(function (d) { return d.clone(); }), scritHashStr);
|
|
1249
|
+
onScriptResult(rdmr.clone(), result, budgetSpent.clone(), logs.slice(), callArgs.map(function (d) { return d.clone(); }), scritHashStr, tx);
|
|
1245
1250
|
if (result instanceof uplc_1.ErrorUPLC ||
|
|
1246
1251
|
(function (resultKeys) {
|
|
1247
1252
|
return resultKeys.includes("msg") &&
|
|
1248
1253
|
resultKeys.includes("addInfos");
|
|
1249
1254
|
})(Object.keys(result))) {
|
|
1250
1255
|
if (typeof onScriptInvalid === "function") {
|
|
1251
|
-
onScriptInvalid(rdmr.clone(), logs.slice(), callArgs.map(function (d) { return d.clone(); }));
|
|
1256
|
+
onScriptInvalid(rdmr.clone(), logs.slice(), callArgs.map(function (d) { return d.clone(); }), tx);
|
|
1252
1257
|
// _isScriptValid = false;
|
|
1253
1258
|
}
|
|
1254
1259
|
else {
|
|
@@ -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.30",
|
|
4
4
|
"description": "Cardano transaction builder in typescript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,25 +45,25 @@
|
|
|
45
45
|
"homepage": "https://github.com/HarmonicLabs/plu-ts#readme",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@harmoniclabs/bigint-utils": "^1.0.0",
|
|
48
|
-
"@harmoniclabs/crypto": "^0.3.0",
|
|
49
|
-
"@harmoniclabs/obj-utils": "^1.0.0",
|
|
50
|
-
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
51
48
|
"@harmoniclabs/bip32_ed25519": "^0.1.3",
|
|
52
49
|
"@harmoniclabs/bytestring": "^1.0.0",
|
|
53
50
|
"@harmoniclabs/cardano-costmodels-ts": "^1.3.0",
|
|
54
|
-
"@harmoniclabs/cardano-ledger-ts": "^0.4.
|
|
51
|
+
"@harmoniclabs/cardano-ledger-ts": "^0.4.8",
|
|
55
52
|
"@harmoniclabs/cbor": "^1.6.6",
|
|
53
|
+
"@harmoniclabs/crypto": "^0.3.0",
|
|
54
|
+
"@harmoniclabs/obj-utils": "^1.0.0",
|
|
56
55
|
"@harmoniclabs/pair": "^1.0.0",
|
|
57
56
|
"@harmoniclabs/plutus-data": "^1.2.6",
|
|
58
|
-
"@harmoniclabs/plutus-machine": "^2.1.
|
|
57
|
+
"@harmoniclabs/plutus-machine": "^2.1.3",
|
|
58
|
+
"@harmoniclabs/uint8array-utils": "^1.0.4",
|
|
59
59
|
"@harmoniclabs/uplc": "^1.4.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/preset-env": "^7.18.6",
|
|
63
63
|
"@babel/preset-typescript": "^7.18.6",
|
|
64
|
-
"@types/jest": "^
|
|
64
|
+
"@types/jest": "^30.0.0",
|
|
65
65
|
"@types/node": "^18.14.6",
|
|
66
|
-
"jest": "^
|
|
66
|
+
"jest": "^30.2.0",
|
|
67
67
|
"jest-environment-jsdom": "^29.4.3",
|
|
68
68
|
"tsc-alias": "^1.7.1",
|
|
69
69
|
"typescript": "^4.6.3"
|