@harmoniclabs/plu-ts-offchain
Advanced tools
Comparing version 0.1.13-dev6 to 0.1.13-dev7
import { TxBody, TxRedeemer } from "@harmoniclabs/cardano-ledger-ts"; | ||
import type { ToDataVersion } from "@harmoniclabs/cardano-ledger-ts/dist/toData/defaultToDataVersion"; | ||
import { Data, DataConstr } from "@harmoniclabs/plutus-data"; | ||
export declare function getSpendingPurposeData(rdmr: TxRedeemer, tx: TxBody, version: ToDataVersion): DataConstr; | ||
export declare function getSpendingPurposeData(rdmr: TxRedeemer, tx: TxBody, version?: ToDataVersion): DataConstr; | ||
export declare function getScriptInfoData(rdmr: TxRedeemer, tx: TxBody, version: ToDataVersion, datum?: Data | undefined): DataConstr; |
@@ -8,2 +8,3 @@ "use strict"; | ||
function getSpendingPurposeData(rdmr, tx, version) { | ||
if (version === void 0) { version = "v3"; } | ||
var scriptInfos = getScriptInfoData(rdmr, tx, version); | ||
@@ -10,0 +11,0 @@ // for all versions, purpose has never the datum, |
@@ -1,2 +0,2 @@ | ||
import { UTxO, IUTxO } from "@harmoniclabs/cardano-ledger-ts"; | ||
import { UTxO, Script, IUTxO, NativeScript, ScriptType } from "@harmoniclabs/cardano-ledger-ts"; | ||
import { ITxBuildInputRefScript, NormalizedITxBuildInputRefScript } from "./ITxBuildInputRefScript.js"; | ||
@@ -10,2 +10,3 @@ import { ITxBuildInputInlineScript, NormalizedITxBuildInputInlineScript } from "./ITxBuildInputInlineScript.js"; | ||
inputScript?: ITxBuildInputInlineScript; | ||
nativeScript?: NativeScript | Script; | ||
} | ||
@@ -16,2 +17,3 @@ export interface NormalizedITxBuildInput extends ITxBuildInput { | ||
inputScript?: NormalizedITxBuildInputInlineScript; | ||
nativeScript?: Script<"NativeScript" | ScriptType.NativeScript>; | ||
} | ||
@@ -23,2 +25,2 @@ export declare function normalizeITxBuildInput(input: ITxBuildInput): NormalizedITxBuildInput; | ||
*/ | ||
export declare function cloneITxBuildInput({ utxo, referenceScript: ref, inputScript: inScript }: ITxBuildInput): ITxBuildInput; | ||
export declare function cloneITxBuildInput({ utxo, referenceScript: ref, inputScript: inScript, nativeScript }: ITxBuildInput): ITxBuildInput; |
@@ -31,5 +31,25 @@ "use strict"; | ||
undefined; | ||
result.nativeScript = normalizeNativeScriptEntry(input.nativeScript); | ||
return result; | ||
} | ||
exports.normalizeITxBuildInput = normalizeITxBuildInput; | ||
function isNativeScript(stuff) { | ||
try { | ||
(0, cardano_ledger_ts_1.nativeScriptFromCbor)((0, cardano_ledger_ts_1.nativeScriptToCbor)(stuff)); | ||
return true; | ||
} | ||
catch (_a) { | ||
return false; | ||
} | ||
} | ||
function normalizeNativeScriptEntry(scr) { | ||
if (!scr) | ||
return undefined; | ||
if (isNativeScript(scr)) { | ||
return new cardano_ledger_ts_1.Script("NativeScript", (0, cardano_ledger_ts_1.nativeScriptToCbor)(scr).toBuffer()); | ||
} | ||
if (scr instanceof cardano_ledger_ts_1.Script && scr.type === cardano_ledger_ts_1.ScriptType.NativeScript) | ||
return scr.clone(); | ||
return undefined; | ||
} | ||
/** | ||
@@ -40,3 +60,3 @@ * @deprecated | ||
function cloneITxBuildInput(_a) { | ||
var utxo = _a.utxo, ref = _a.referenceScript, inScript = _a.inputScript; | ||
var utxo = _a.utxo, ref = _a.referenceScript, inScript = _a.inputScript, nativeScript = _a.nativeScript; | ||
var referenceScript = ref === undefined ? undefined : | ||
@@ -57,5 +77,6 @@ { | ||
referenceScript: referenceScript, | ||
inputScript: inputScript | ||
inputScript: inputScript, | ||
nativeScript: normalizeNativeScriptEntry(nativeScript) | ||
}; | ||
} | ||
exports.cloneITxBuildInput = cloneITxBuildInput; |
@@ -580,3 +580,3 @@ "use strict"; | ||
var _inputs = inputs.map(function (input) { | ||
var utxo = input.utxo, referenceScript = input.referenceScript, inputScript = input.inputScript; | ||
var utxo = input.utxo, referenceScript = input.referenceScript, inputScript = input.inputScript, nativeScript = input.nativeScript; | ||
var addr = utxo.resolved.address; | ||
@@ -586,6 +586,7 @@ totInputValue = cardano_ledger_ts_1.Value.add(totInputValue, utxo.resolved.value); | ||
referenceScript === undef && | ||
inputScript === undef) | ||
inputScript === undef && | ||
nativeScript === undef) | ||
throw new Error("spending script utxo \"" + utxo.utxoRef.toString() + "\" without script source"); | ||
if (referenceScript !== undef) { | ||
if (inputScript !== undef) | ||
if (inputScript !== undef || nativeScript !== undef) | ||
throw new Error("invalid input; multiple scripts specified"); | ||
@@ -613,3 +614,3 @@ var datum = referenceScript.datum, redeemer = referenceScript.redeemer, refUtxo_1 = referenceScript.refUtxo; | ||
if (inputScript !== undefined) { | ||
if (referenceScript !== undefined) | ||
if (referenceScript !== undefined || nativeScript !== undef) | ||
throw new Error("invalid input; multiple scripts specified"); | ||
@@ -630,2 +631,7 @@ var datum = inputScript.datum, redeemer = inputScript.redeemer, script = inputScript.script; | ||
} | ||
if (nativeScript instanceof cardano_ledger_ts_1.Script && nativeScript.type === cardano_ledger_ts_1.ScriptType.NativeScript) { | ||
if (referenceScript !== undefined || inputScript !== undef) | ||
throw new Error("invalid input; multiple scripts specified"); | ||
pushWitScript(nativeScript); | ||
} | ||
return new cardano_ledger_ts_1.TxIn(utxo); | ||
@@ -632,0 +638,0 @@ }); |
{ | ||
"name": "@harmoniclabs/plu-ts-offchain", | ||
"version": "0.1.13-dev6", | ||
"version": "0.1.13-dev7", | ||
"description": "An embedded DSL for Cardano smart contracts creation coupled with a library for Cardano transactions, all in Typescript", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
256035
4757