Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmoniclabs/plu-ts-offchain

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmoniclabs/plu-ts-offchain - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

dist/TxBuilder/CanResolveToUTxO/index.d.ts

21

dist/txBuild/ITxBuildArgs.d.ts

@@ -1,2 +0,2 @@

import { Address, AddressStr, ProtocolUpdateProposal, PubKeyHash, TxMetadata, UTxO } from "@harmoniclabs/cardano-ledger-ts";
import { Address, AddressStr, Hash32, ProtocolUpdateProposal, PubKeyHash, Script, TxMetadata, UTxO } from "@harmoniclabs/cardano-ledger-ts";
import { type ITxBuildCert } from "./ITxBuildCert.js";

@@ -8,5 +8,22 @@ import { type ITxBuildInput } from "./ITxBuildInput.js";

import { CanBeUInteger } from "../utils/ints.js";
import { CanBeData } from "../utils/CanBeData.js";
export interface ChangeInfos {
address: Address | AddressStr;
datum?: Hash32 | CanBeData;
refScript?: Script;
}
export declare function cloneChangeInfos(change: ChangeInfos): ChangeInfos;
export interface ITxBuildArgs {
inputs: ITxBuildInput[];
changeAddress: Address | AddressStr;
/**
* same as
* @example
* ```ts
* txBuilder.build({
* change: { address: "your_address" }
* });
* ```
*/
changeAddress?: Address | AddressStr;
change?: ChangeInfos;
outputs?: ITxBuildOutput[];

@@ -13,0 +30,0 @@ readonlyRefInputs?: UTxO[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneITxBuildArgs = void 0;
exports.cloneITxBuildArgs = exports.cloneChangeInfos = void 0;
var cardano_ledger_ts_1 = require("@harmoniclabs/cardano-ledger-ts");

@@ -10,2 +10,14 @@ var ITxBuildCert_1 = require("./ITxBuildCert.js");

var ITxBuildWithdrawal_1 = require("./ITxBuildWithdrawal.js");
var CanBeData_1 = require("../utils/CanBeData.js");
function cloneChangeInfos(change) {
return {
address: change.address.toString(),
datum: change.datum ? (change.datum instanceof cardano_ledger_ts_1.Hash32 ?
change.datum.clone() :
(0, CanBeData_1.cloneCanBeData)(change.datum)) :
undefined,
refScript: change.refScript ? change.refScript.clone() : undefined
};
}
exports.cloneChangeInfos = cloneChangeInfos;
function cloneITxBuildArgs(args) {

@@ -18,2 +30,3 @@ var _a, _b, _c, _d, _e, _f, _g, _h;

cardano_ledger_ts_1.Address.fromString(args.changeAddress.toString()),
change: args.change ? cloneChangeInfos(args.change) : undefined,
outputs: (_b = args.outputs) === null || _b === void 0 ? void 0 : _b.map(ITxBuildOutput_1.cloneITxBuildOutput),

@@ -20,0 +33,0 @@ // era: Era // latest

@@ -5,1 +5,2 @@ export * from "./TxBuilder.js";

export * from "./IProvider/index.js";
export * from "./CanResolveToUTxO/index.js";

@@ -21,1 +21,2 @@ "use strict";

__exportStar(require("./IProvider/index.js"), exports);
__exportStar(require("./CanResolveToUTxO/index.js"), exports);

41

dist/TxBuilder/TxBuilder.js

@@ -201,3 +201,3 @@ "use strict";

var _c = _a === void 0 ? {} : _a, onScriptInvalid = _c.onScriptInvalid, onScriptResult = _c.onScriptResult;
var _d = initTxBuild.bind(this)(buildArgs), tx = _d.tx, scriptsToExec = _d.scriptsToExec, minFee = _d.minFee, datumsScriptData = _d.datumsScriptData, languageViews = _d.languageViews, totInputValue = _d.totInputValue, requiredOutputValue = _d.requiredOutputValue, outs = _d.outs;
var _d = initTxBuild.bind(this)(buildArgs), tx = _d.tx, scriptsToExec = _d.scriptsToExec, minFee = _d.minFee, datumsScriptData = _d.datumsScriptData, languageViews = _d.languageViews, totInputValue = _d.totInputValue, requiredOutputValue = _d.requiredOutputValue, outs = _d.outs, change = _d.change;
var txOuts = new Array(outs.length + 1);

@@ -296,4 +296,8 @@ var rdmrs = (_b = tx.witnesses.redeemers) !== null && _b !== void 0 ? _b : [];

txOuts[txOuts.length - 1] = (new cardano_ledger_ts_1.TxOut({
address: buildArgs.changeAddress,
value: cardano_ledger_ts_1.Value.sub(totInputValue, cardano_ledger_ts_1.Value.add(requiredOutputValue, cardano_ledger_ts_1.Value.lovelaces(fee)))
address: change.address,
value: cardano_ledger_ts_1.Value.sub(totInputValue, cardano_ledger_ts_1.Value.add(requiredOutputValue, cardano_ledger_ts_1.Value.lovelaces(fee))),
datum: change.datum ? (change.datum instanceof cardano_ledger_ts_1.Hash32 ?
change.datum :
(0, CanBeData_1.forceData)(change.datum)) : undefined,
refScript: change.refScript
}));

@@ -330,3 +334,13 @@ tx = new cardano_ledger_ts_1.Tx(__assign(__assign({}, tx), { body: __assign(__assign({}, tx.body), { outputs: txOuts, fee: fee, scriptDataHash: getScriptDataHash(rdmrs, datumsScriptData, languageViews) }), witnesses: __assign(__assign({}, tx.witnesses), { redeemers: rdmrs }), isScriptValid: _isScriptValid }));

var _b, _c, _d;
var inputs = _a.inputs, changeAddress = _a.changeAddress, outputs = _a.outputs, readonlyRefInputs = _a.readonlyRefInputs, requiredSigners = _a.requiredSigners, collaterals = _a.collaterals, collateralReturn = _a.collateralReturn, mints = _a.mints, invalidBefore = _a.invalidBefore, invalidAfter = _a.invalidAfter, certificates = _a.certificates, withdrawals = _a.withdrawals, metadata = _a.metadata, protocolUpdateProposal = _a.protocolUpdateProposal;
var inputs = _a.inputs, change = _a.change, changeAddress = _a.changeAddress, outputs = _a.outputs, readonlyRefInputs = _a.readonlyRefInputs, requiredSigners = _a.requiredSigners, collaterals = _a.collaterals, collateralReturn = _a.collateralReturn, mints = _a.mints, invalidBefore = _a.invalidBefore, invalidAfter = _a.invalidAfter, certificates = _a.certificates, withdrawals = _a.withdrawals, metadata = _a.metadata, protocolUpdateProposal = _a.protocolUpdateProposal;
if (change) {
changeAddress = change.address;
}
if (!changeAddress) {
throw new Error("missing changAddress and change entry while constructing a transaciton; unable to balance inputs and outpus");
}
if (!change) {
change = { address: changeAddress };
}
;
var network = resolveNetwork(changeAddress);

@@ -465,4 +479,8 @@ var totInputValue = (_b = mints === null || mints === void 0 ? void 0 : mints.reduce(function (prev, curr) { return cardano_ledger_ts_1.Value.add(prev, curr.value); }, cardano_ledger_ts_1.Value.zero)) !== null && _b !== void 0 ? _b : cardano_ledger_ts_1.Value.zero;

dummyOuts.push(new cardano_ledger_ts_1.TxOut({
address: changeAddress,
value: cardano_ledger_ts_1.Value.sub(totInputValue, cardano_ledger_ts_1.Value.add(requiredOutputValue, cardano_ledger_ts_1.Value.lovelaces((0, ints_1.forceBigUInt)(this.protocolParamters.txFeePerByte))))
address: change.address,
value: cardano_ledger_ts_1.Value.sub(totInputValue, cardano_ledger_ts_1.Value.add(requiredOutputValue, cardano_ledger_ts_1.Value.lovelaces((0, ints_1.forceBigUInt)(this.protocolParamters.txFeePerByte)))),
datum: change.datum ? (change.datum instanceof cardano_ledger_ts_1.Hash32 ?
change.datum :
(0, CanBeData_1.forceData)(change.datum)) : undef,
refScript: change.refScript
}));

@@ -618,4 +636,8 @@ // index to be modified

txOuts[txOuts.length - 1] = (new cardano_ledger_ts_1.TxOut({
address: changeAddress,
value: cardano_ledger_ts_1.Value.sub(totInputValue, cardano_ledger_ts_1.Value.add(requiredOutputValue, cardano_ledger_ts_1.Value.lovelaces(minFee)))
address: change.address,
value: cardano_ledger_ts_1.Value.sub(totInputValue, cardano_ledger_ts_1.Value.add(requiredOutputValue, cardano_ledger_ts_1.Value.lovelaces(minFee))),
datum: change.datum ? (change.datum instanceof cardano_ledger_ts_1.Hash32 ?
change.datum :
(0, CanBeData_1.forceData)(change.datum)) : undef,
refScript: change.refScript
}));

@@ -631,3 +653,4 @@ var tx = new cardano_ledger_ts_1.Tx(__assign(__assign({}, dummyTx), { body: __assign(__assign({}, dummyTx.body), { outputs: txOuts, fee: minFee }) }));

requiredOutputValue: requiredOutputValue,
outs: outs
outs: outs,
change: change
};

@@ -634,0 +657,0 @@ }

{
"name": "@harmoniclabs/plu-ts-offchain",
"version": "0.1.1",
"version": "0.1.2",
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc