Socket
Socket
Sign inDemoInstall

@harmoniclabs/cardano-ledger-ts

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmoniclabs/cardano-ledger-ts - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

README.md

2

dist/ledger/certs/Certificate.d.ts

@@ -11,3 +11,3 @@ import { ToCbor, CborString, CborObj, CanBeCborString } from "@harmoniclabs/cbor";

import { MoveInstantRewardsCert } from "./MoveInstantRewardsCert.js";
export declare const enum CertificateType {
export declare enum CertificateType {
StakeRegistration = 0,

@@ -14,0 +14,0 @@ StakeDeRegistration = 1,

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.certificatesToDepositLovelaces = exports.certToDepositLovelaces = exports.Certificate = exports.certTypeToString = void 0;
exports.certificatesToDepositLovelaces = exports.certToDepositLovelaces = exports.Certificate = exports.certTypeToString = exports.CertificateType = void 0;
var cbor_1 = require("@harmoniclabs/cbor");

@@ -43,12 +43,24 @@ var obj_utils_1 = require("@harmoniclabs/obj-utils");

var MoveInstantRewardsCert_1 = require("./MoveInstantRewardsCert.js");
// number is important as it is included in serialization
var CertificateType;
(function (CertificateType) {
CertificateType[CertificateType["StakeRegistration"] = 0] = "StakeRegistration";
CertificateType[CertificateType["StakeDeRegistration"] = 1] = "StakeDeRegistration";
CertificateType[CertificateType["StakeDelegation"] = 2] = "StakeDelegation";
CertificateType[CertificateType["PoolRegistration"] = 3] = "PoolRegistration";
CertificateType[CertificateType["PoolRetirement"] = 4] = "PoolRetirement";
CertificateType[CertificateType["GenesisKeyDelegation"] = 5] = "GenesisKeyDelegation";
CertificateType[CertificateType["MoveInstantRewards"] = 6] = "MoveInstantRewards";
})(CertificateType = exports.CertificateType || (exports.CertificateType = {}));
;
Object.freeze(CertificateType);
function certTypeToString(certT) {
switch (certT) {
case 0 /* CertificateType.StakeRegistration */: return "StakeRegistration";
case 1 /* CertificateType.StakeDeRegistration */: return "StakeDeRegistration";
case 2 /* CertificateType.StakeDelegation */: return "StakeDelegation";
case 3 /* CertificateType.PoolRegistration */: return "PoolRegistration";
case 4 /* CertificateType.PoolRetirement */: return "PoolRetirement";
case 5 /* CertificateType.GenesisKeyDelegation */: return "GenesisKeyDelegation";
case 6 /* CertificateType.MoveInstantRewards */: return "MoveInstantRewards";
case CertificateType.StakeRegistration: return "StakeRegistration";
case CertificateType.StakeDeRegistration: return "StakeDeRegistration";
case CertificateType.StakeDelegation: return "StakeDelegation";
case CertificateType.PoolRegistration: return "PoolRegistration";
case CertificateType.PoolRetirement: return "PoolRetirement";
case CertificateType.GenesisKeyDelegation: return "GenesisKeyDelegation";
case CertificateType.MoveInstantRewards: return "MoveInstantRewards";
default:

@@ -70,8 +82,8 @@ throw new Error("unknown certificate type");

(0, assert_1.assert)(params.length > 0, "no certificate paramters provided");
if (certType === 0 /* CertificateType.StakeRegistration */ ||
certType === 1 /* CertificateType.StakeDeRegistration */) {
if (certType === CertificateType.StakeRegistration ||
certType === CertificateType.StakeDeRegistration) {
(0, assert_1.assert)(params.length >= 1 &&
params[0] instanceof StakeCredentials_1.StakeCredentials, "invalid paramters for stake registration / deregistration");
}
if (certType === 2 /* CertificateType.StakeDelegation */) {
if (certType === CertificateType.StakeDelegation) {
(0, assert_1.assert)(params.length >= 2 &&

@@ -81,7 +93,7 @@ params[0] instanceof StakeCredentials_1.StakeCredentials &&

}
if (certType === 3 /* CertificateType.PoolRegistration */) {
if (certType === CertificateType.PoolRegistration) {
(0, assert_1.assert)(params.length >= 1 &&
params[0] instanceof PoolParams_1.PoolParams, "invalid paramters for stake registration / deregistration");
}
if (certType === 4 /* CertificateType.PoolRetirement */) {
if (certType === CertificateType.PoolRetirement) {
(0, assert_1.assert)(params.length >= 2 &&

@@ -95,3 +107,3 @@ params[0] instanceof PoolKeyHash_1.PoolKeyHash &&

}
if (certType === 5 /* CertificateType.GenesisKeyDelegation */) {
if (certType === CertificateType.GenesisKeyDelegation) {
(0, assert_1.assert)(params.length >= 3 &&

@@ -102,3 +114,3 @@ params[0] instanceof GenesisHash_1.GenesisHash &&

}
if (certType === 6 /* CertificateType.MoveInstantRewards */) {
if (certType === CertificateType.MoveInstantRewards) {
(0, assert_1.assert)(params.length >= 1 &&

@@ -113,10 +125,10 @@ params[0] instanceof MoveInstantRewardsCert_1.MoveInstantRewardsCert, "invalid paramters for stake registration / deregistration");

switch (this.certType) {
case 0 /* CertificateType.StakeRegistration */:
case 1 /* CertificateType.StakeDeRegistration */:
case CertificateType.StakeRegistration:
case CertificateType.StakeDeRegistration:
if (!(fst instanceof StakeCredentials_1.StakeCredentials))
throw new Error("stake (de)registration parameter was not 'StakeCredentials'");
return new plutus_data_1.DataConstr(this.certType === 0 /* CertificateType.StakeRegistration */ ? 0 : 1, // KeyRegistration | KeyDeRegistration
return new plutus_data_1.DataConstr(this.certType === CertificateType.StakeRegistration ? 0 : 1, // KeyRegistration | KeyDeRegistration
[fst.toData()]);
break;
case 2 /* CertificateType.StakeDelegation */:
case CertificateType.StakeDelegation:
if (!(fst instanceof StakeCredentials_1.StakeCredentials))

@@ -129,3 +141,3 @@ throw new Error("stake delegation frist parameter was not 'StakeCredentials'");

break;
case 3 /* CertificateType.PoolRegistration */:
case CertificateType.PoolRegistration:
if (!(fst instanceof PoolParams_1.PoolParams))

@@ -139,3 +151,3 @@ throw new Error("PoolRegistration frist parameter was not 'PoolRegistration'");

break;
case 4 /* CertificateType.PoolRetirement */:
case CertificateType.PoolRetirement:
if (!(fst instanceof Hash28_1.Hash28))

@@ -148,5 +160,5 @@ throw new Error("invalid poolId for pool retirement certificate");

break;
case 5 /* CertificateType.GenesisKeyDelegation */:
case 6 /* CertificateType.MoveInstantRewards */:
return new plutus_data_1.DataConstr(this.certType === 5 /* CertificateType.GenesisKeyDelegation */ ? 5 : 6, []);
case CertificateType.GenesisKeyDelegation:
case CertificateType.MoveInstantRewards:
return new plutus_data_1.DataConstr(this.certType === CertificateType.GenesisKeyDelegation ? 5 : 6, []);
break;

@@ -161,3 +173,3 @@ default:

Certificate.prototype.toCborObj = function () {
if (this.certType === 4 /* CertificateType.PoolRetirement */) {
if (this.certType === CertificateType.PoolRetirement) {
return new cbor_1.CborArray([

@@ -169,3 +181,3 @@ new cbor_1.CborUInt(this.certType),

}
if (this.certType === 3 /* CertificateType.PoolRegistration */) {
if (this.certType === CertificateType.PoolRegistration) {
return new cbor_1.CborArray(__spreadArray([

@@ -190,16 +202,16 @@ new cbor_1.CborUInt(this.certType)

switch (type) {
case 0 /* CertificateType.StakeRegistration */:
case 1 /* CertificateType.StakeDeRegistration */:
case CertificateType.StakeRegistration:
case CertificateType.StakeDeRegistration:
return new Certificate(type, StakeCredentials_1.StakeCredentials.fromCborObj(_params[0]));
case 2 /* CertificateType.StakeDelegation */:
case CertificateType.StakeDelegation:
return new Certificate(type, StakeCredentials_1.StakeCredentials.fromCborObj(_params[0]), PoolKeyHash_1.PoolKeyHash.fromCborObj(_params[1]));
case 3 /* CertificateType.PoolRegistration */:
case CertificateType.PoolRegistration:
return new Certificate(type, PoolParams_1.PoolParams.fromCborObjArray(_params));
case 4 /* CertificateType.PoolRetirement */:
case CertificateType.PoolRetirement:
if (!(_params[1] instanceof cbor_1.CborUInt))
throw new Error("Invalid CBOR fromat for \"Certificate\"");
return new Certificate(type, PoolKeyHash_1.PoolKeyHash.fromCborObj(_params[0]), _params[1].num);
case 5 /* CertificateType.GenesisKeyDelegation */:
case CertificateType.GenesisKeyDelegation:
return new Certificate(type, GenesisHash_1.GenesisHash.fromCborObj(_params[0]), GenesisDelegateHash_1.GenesisDelegateHash.fromCborObj(_params[1]), VRFKeyHash_1.VRFKeyHash.fromCborObj(_params[2]));
case 6 /* CertificateType.MoveInstantRewards */:
case CertificateType.MoveInstantRewards:
return new Certificate(type, MoveInstantRewardsCert_1.MoveInstantRewardsCert.fromCborObj(_params[0]));

@@ -213,4 +225,4 @@ default:

switch (this.certType) {
case 0 /* CertificateType.StakeRegistration */:
case 1 /* CertificateType.StakeDeRegistration */:
case CertificateType.StakeRegistration:
case CertificateType.StakeDeRegistration:
return {

@@ -221,3 +233,3 @@ certType: certTypeStr,

break;
case 2 /* CertificateType.StakeDelegation */:
case CertificateType.StakeDelegation:
return {

@@ -229,3 +241,3 @@ certType: certTypeStr,

break;
case 3 /* CertificateType.PoolRegistration */:
case CertificateType.PoolRegistration:
return {

@@ -236,3 +248,3 @@ certType: certTypeStr,

break;
case 4 /* CertificateType.PoolRetirement */:
case CertificateType.PoolRetirement:
return {

@@ -244,3 +256,3 @@ certType: certTypeStr,

break;
case 5 /* CertificateType.GenesisKeyDelegation */:
case CertificateType.GenesisKeyDelegation:
return {

@@ -253,3 +265,3 @@ certType: certTypeStr,

break;
case 6 /* CertificateType.MoveInstantRewards */:
case CertificateType.MoveInstantRewards:
return {

@@ -270,9 +282,9 @@ certType: certTypeStr,

var t = cert.certType;
if (t === 0 /* CertificateType.StakeRegistration */)
if (t === CertificateType.StakeRegistration)
return BigInt(2) * ada;
if (t === 1 /* CertificateType.StakeDeRegistration */)
if (t === CertificateType.StakeDeRegistration)
return BigInt(-2) * ada;
if (t === 3 /* CertificateType.PoolRegistration */)
if (t === CertificateType.PoolRegistration)
return BigInt(500) * ada;
if (t === 4 /* CertificateType.PoolRetirement */)
if (t === CertificateType.PoolRetirement)
return BigInt(-500) * ada;

@@ -279,0 +291,0 @@ return BigInt(0);

import { CborObj, ToCbor, CborString } from "@harmoniclabs/cbor";
import { StakeCredentials } from "../../credentials/index.js";
import { Coin } from "../Coin.js";
export declare const enum InstantRewardsSource {
export declare enum InstantRewardsSource {
Reserves = 0,

@@ -6,0 +6,0 @@ Treasurery = 1

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.MoveInstantRewardsCert = exports.rewardSourceToStr = void 0;
exports.MoveInstantRewardsCert = exports.rewardSourceToStr = exports.InstantRewardsSource = void 0;
var cbor_1 = require("@harmoniclabs/cbor");

@@ -26,6 +26,12 @@ var credentials_1 = require("../../credentials/index.js");

var obj_utils_1 = require("@harmoniclabs/obj-utils");
var InstantRewardsSource;
(function (InstantRewardsSource) {
InstantRewardsSource[InstantRewardsSource["Reserves"] = 0] = "Reserves";
InstantRewardsSource[InstantRewardsSource["Treasurery"] = 1] = "Treasurery";
})(InstantRewardsSource = exports.InstantRewardsSource || (exports.InstantRewardsSource = {}));
Object.freeze(InstantRewardsSource);
function rewardSourceToStr(source) {
switch (source) {
case 0 /* InstantRewardsSource.Reserves */: return "Reserves";
case 1 /* InstantRewardsSource.Treasurery */: return "Treasurery";
case InstantRewardsSource.Reserves: return "Reserves";
case InstantRewardsSource.Treasurery: return "Treasurery";
default:

@@ -65,4 +71,4 @@ throw new Error("unknown instant rewards source");

function MoveInstantRewardsCert(source, destintaion) {
(0, assert_1.assert)(source === 0 /* InstantRewardsSource.Reserves */ ||
source === 1 /* InstantRewardsSource.Treasurery */, "invalid 'source' while constructing 'MoveInstantRewardsCert'");
(0, assert_1.assert)(source === InstantRewardsSource.Reserves ||
source === InstantRewardsSource.Treasurery, "invalid 'source' while constructing 'MoveInstantRewardsCert'");
(0, assert_1.assert)((0, ints_1.canBeUInteger)(destintaion) ||

@@ -69,0 +75,0 @@ (Array.isArray(destintaion) &&

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

export declare const enum Era {
export declare enum Era {
Byron = "byron",

@@ -3,0 +3,0 @@ Shelley = "shelley",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Era = void 0;
var Era;
(function (Era) {
Era["Byron"] = "byron";
Era["Shelley"] = "shelley";
Era["Allegra"] = "allegra";
Era["Mary"] = "mary";
Era["Alonzo"] = "alonzo";
Era["Babbage"] = "babbage";
})(Era = exports.Era || (exports.Era = {}));
Object.freeze(Era);

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

export declare const enum Network {
export declare enum Network {
mainnet = "mainnet",

@@ -3,0 +3,0 @@ testnet = "testnet"

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Network = void 0;
var Network;
(function (Network) {
Network["mainnet"] = "mainnet";
Network["testnet"] = "testnet";
})(Network = exports.Network || (exports.Network = {}));
Object.freeze(Network);

@@ -35,2 +35,3 @@ import { ToCbor, CborString, CborObj, CanBeCborString } from "@harmoniclabs/cbor";

static singleAssetEntry(policy: Hash28, name: Uint8Array, qty: number | bigint): IValuePolicyEntry;
static singleAsset(policy: Hash28, name: Uint8Array, qty: number | bigint): Value;
static entry(policy: Hash28, assets: IValueAssets): IValuePolicyEntry;

@@ -37,0 +38,0 @@ static add(a: Value, b: Value): Value;

@@ -243,2 +243,7 @@ "use strict";

};
Value.singleAsset = function (policy, name, qty) {
return new Value([
Value.singleAssetEntry(policy, name, qty)
]);
};
Value.entry = function (policy, assets) {

@@ -245,0 +250,0 @@ return { policy: policy, assets: assets };

import { ToCbor, CborString, CborObj, CanBeCborString } from "@harmoniclabs/cbor";
import { Hash28 } from "../hashes/index.js";
import { NativeScript } from "./NativeScript.js";
export declare const enum ScriptType {
export declare enum ScriptType {
NativeScript = "NativeScript",

@@ -42,4 +42,4 @@ PlutusV1 = "PlutusScriptV1",

toCborObj(): CborObj;
static fromCbor(cbor: CanBeCborString): Script;
static fromCbor(cbor: CanBeCborString, defType?: ScriptType): Script;
static fromCborObj(cObj: CborObj, defType?: ScriptType): Script;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Script = void 0;
exports.Script = exports.ScriptType = void 0;
var cbor_1 = require("@harmoniclabs/cbor");

@@ -11,12 +11,19 @@ var crypto_1 = require("@harmoniclabs/crypto");

var assert_1 = require("../utils/assert.js");
var ScriptType;
(function (ScriptType) {
ScriptType["NativeScript"] = "NativeScript";
ScriptType["PlutusV1"] = "PlutusScriptV1";
ScriptType["PlutusV2"] = "PlutusScriptV2";
})(ScriptType = exports.ScriptType || (exports.ScriptType = {}));
Object.freeze(ScriptType);
var Script = /** @class */ (function () {
function Script(scriptType, bytes) {
var _this = this;
(0, assert_1.assert)(scriptType === "NativeScript" /* ScriptType.NativeScript */ ||
scriptType === "PlutusScriptV1" /* ScriptType.PlutusV1 */ ||
scriptType === "PlutusScriptV2" /* ScriptType.PlutusV2 */, "invalid 'scriptType'");
(0, assert_1.assert)(scriptType === ScriptType.NativeScript ||
scriptType === ScriptType.PlutusV1 ||
scriptType === ScriptType.PlutusV2, "invalid 'scriptType'");
(0, obj_utils_1.defineReadOnlyProperty)(this, "type", scriptType);
if (!(0, uint8array_utils_1.isUint8Array)(bytes)) {
if (bytes.type === "PlutusScriptV1" /* ScriptType.PlutusV1 */ ||
bytes.type === "PlutusScriptV2" /* ScriptType.PlutusV2 */) {
if (bytes.type === ScriptType.PlutusV1 ||
bytes.type === ScriptType.PlutusV2) {
bytes = (0, uint8array_utils_1.fromHex)(bytes.cborHex);

@@ -30,4 +37,4 @@ }

bytes = bytes.slice();
if (scriptType === "PlutusScriptV1" /* ScriptType.PlutusV1 */ ||
scriptType === "PlutusScriptV2" /* ScriptType.PlutusV2 */) {
if (scriptType === ScriptType.PlutusV1 ||
scriptType === ScriptType.PlutusV2) {
// unwrap up to 2 cbor bytes

@@ -48,3 +55,3 @@ try {

(0, obj_utils_1.defineReadOnlyProperty)(this, "bytes", bytes);
(0, obj_utils_1.defineReadOnlyProperty)(this, "cbor", this.type === "NativeScript" /* ScriptType.NativeScript */ ? new cbor_1.CborString(bytes) :
(0, obj_utils_1.defineReadOnlyProperty)(this, "cbor", this.type === ScriptType.NativeScript ? new cbor_1.CborString(bytes) :
cbor_1.Cbor.encode(new cbor_1.CborBytes(cbor_1.Cbor.encode(new cbor_1.CborBytes(bytes.slice())).toBuffer())));

@@ -57,3 +64,3 @@ var _hash = undefined;

var scriptDataToBeHashed = [];
if (_this.type === "NativeScript" /* ScriptType.NativeScript */)
if (_this.type === ScriptType.NativeScript)
scriptDataToBeHashed = [0x00].concat(Array.from(_this.bytes));

@@ -63,3 +70,3 @@ else {

scriptDataToBeHashed = [
_this.type === "PlutusScriptV1" /* ScriptType.PlutusV1 */ ? 0x01 : 0x02
_this.type === ScriptType.PlutusV1 ? 0x01 : 0x02
].concat(singleCbor);

@@ -79,3 +86,3 @@ }

Script.prototype.toJson = function () {
if (this.type === "NativeScript" /* ScriptType.NativeScript */) {
if (this.type === ScriptType.NativeScript) {
return (0, NativeScript_1.nativeScriptFromCbor)(new cbor_1.CborString(this.bytes));

@@ -93,6 +100,6 @@ }

var t = json.type;
if (t === "PlutusScriptV1" /* ScriptType.PlutusV1 */ || t === "PlutusScriptV2" /* ScriptType.PlutusV2 */) {
if (t === ScriptType.PlutusV1 || t === ScriptType.PlutusV2) {
return new Script(t, (0, uint8array_utils_1.fromHex)(json.cborHex));
}
return new Script("NativeScript" /* ScriptType.NativeScript */, json);
return new Script(ScriptType.NativeScript, json);
};

@@ -109,3 +116,3 @@ /**

Script.prototype.toCborObj = function () {
if (this.type === "NativeScript" /* ScriptType.NativeScript */)
if (this.type === ScriptType.NativeScript)
return new cbor_1.CborArray([

@@ -116,11 +123,12 @@ new cbor_1.CborUInt(0),

return new cbor_1.CborArray([
new cbor_1.CborUInt(this.type === "PlutusScriptV1" /* ScriptType.PlutusV1 */ ? 1 : 2),
new cbor_1.CborUInt(this.type === ScriptType.PlutusV1 ? 1 : 2),
new cbor_1.CborBytes(cbor_1.Cbor.encode(new cbor_1.CborBytes(this.bytes.slice())).toBuffer())
]);
};
Script.fromCbor = function (cbor) {
return Script.fromCborObj(cbor_1.Cbor.parse((0, cbor_1.forceCborString)(cbor)));
Script.fromCbor = function (cbor, defType) {
if (defType === void 0) { defType = ScriptType.PlutusV2; }
return Script.fromCborObj(cbor_1.Cbor.parse((0, cbor_1.forceCborString)(cbor)), defType);
};
Script.fromCborObj = function (cObj, defType) {
if (defType === void 0) { defType = "PlutusScriptV2" /* ScriptType.PlutusV2 */; }
if (defType === void 0) { defType = ScriptType.PlutusV2; }
// read tx_witness_set

@@ -135,6 +143,6 @@ if (cObj instanceof cbor_1.CborBytes) {

var n = Number(cObj.array[0].num);
var t = n === 0 ? "NativeScript" /* ScriptType.NativeScript */ :
n === 1 ? "PlutusScriptV1" /* ScriptType.PlutusV1 */ :
"PlutusScriptV2" /* ScriptType.PlutusV2 */;
if (t === "NativeScript" /* ScriptType.NativeScript */)
var t = n === 0 ? ScriptType.NativeScript :
n === 1 ? ScriptType.PlutusV1 :
ScriptType.PlutusV2;
if (t === ScriptType.NativeScript)
return new Script(t, cbor_1.Cbor.encode(cObj.array[1]).toBuffer());

@@ -141,0 +149,0 @@ if (!(cObj.array[1] instanceof cbor_1.CborBytes))

@@ -159,11 +159,11 @@ "use strict";

_native.array.map(function (nativeCborObj) {
return new Script_1.Script("NativeScript" /* ScriptType.NativeScript */, cbor_1.Cbor.encode(nativeCborObj).toBuffer());
return new Script_1.Script(Script_1.ScriptType.NativeScript, cbor_1.Cbor.encode(nativeCborObj).toBuffer());
}),
plutusV1Scripts: _pV1 === undefined ? undefined :
_pV1.array.map(function (cbor) {
return new Script_1.Script("PlutusScriptV1" /* ScriptType.PlutusV1 */, cbor_1.Cbor.encode(cbor).toBuffer());
return new Script_1.Script(Script_1.ScriptType.PlutusV1, cbor_1.Cbor.encode(cbor).toBuffer());
}),
plutusV2Scripts: _pV2 === undefined ? undefined :
_pV2.array.map(function (cbor) {
return new Script_1.Script("PlutusScriptV2" /* ScriptType.PlutusV2 */, cbor_1.Cbor.encode(cbor).toBuffer());
return new Script_1.Script(Script_1.ScriptType.PlutusV2, cbor_1.Cbor.encode(cbor).toBuffer());
})

@@ -170,0 +170,0 @@ });

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

throw new InvalidCborFormatError_1.InvalidCborFormatError("TxOut");
refScript = new script_1.Script("PlutusScriptV2" /* ScriptType.PlutusV2 */, _refScript.data.buffer);
refScript = new script_1.Script(script_1.ScriptType.PlutusV2, _refScript.data.buffer);
}

@@ -206,0 +206,0 @@ if (_addr === undefined || _amt === undefined)

@@ -279,3 +279,3 @@ import { PrivateKey } from "../credentials/index.js";

redeemers: {
tag: "Cert" | "Mint" | "Spend" | "Withdraw";
tag: "Spend" | "Mint" | "Cert" | "Withdraw";
index: number;

@@ -282,0 +282,0 @@ execUnits: {

@@ -32,2 +32,3 @@ "use strict";

var TxWitnessSet_1 = require("./TxWitnessSet/index.js");
var ledger_1 = require("../ledger/index.js");
var cbor_1 = require("@harmoniclabs/cbor");

@@ -142,12 +143,12 @@ var crypto_1 = require("@harmoniclabs/crypto");

switch (cert.certType) {
case 0 /* CertificateType.StakeRegistration */:
case 1 /* CertificateType.StakeDeRegistration */:
case 2 /* CertificateType.StakeDelegation */:
case ledger_1.CertificateType.StakeRegistration:
case ledger_1.CertificateType.StakeDeRegistration:
case ledger_1.CertificateType.StakeDelegation:
hash = _0.hash;
break;
case 3 /* CertificateType.PoolRegistration */:
case ledger_1.CertificateType.PoolRegistration:
hash = _0.operator;
break;
case 4 /* CertificateType.PoolRetirement */:
case 5 /* CertificateType.GenesisKeyDelegation */:
case ledger_1.CertificateType.PoolRetirement:
case ledger_1.CertificateType.GenesisKeyDelegation:
hash = _0;

@@ -154,0 +155,0 @@ break;

@@ -8,3 +8,3 @@ import { TxBody } from "../body/TxBody.js";

import { CanBeUInteger } from "../../utils/ints.js";
export declare const enum TxRedeemerTag {
export declare enum TxRedeemerTag {
Spend = 0,

@@ -42,3 +42,3 @@ Mint = 1,

toJson(): {
tag: "Cert" | "Mint" | "Spend" | "Withdraw";
tag: "Spend" | "Mint" | "Cert" | "Withdraw";
index: number;

@@ -45,0 +45,0 @@ execUnits: {

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.TxRedeemer = exports.txRedeemerTagToString = exports.txRdmrTagToString = void 0;
exports.TxRedeemer = exports.txRedeemerTagToString = exports.txRdmrTagToString = exports.TxRedeemerTag = void 0;
var hashes_1 = require("../../hashes/index.js");

@@ -26,9 +26,17 @@ var cbor_1 = require("@harmoniclabs/cbor");

var ints_1 = require("../../utils/ints.js");
var TxRedeemerTag;
(function (TxRedeemerTag) {
TxRedeemerTag[TxRedeemerTag["Spend"] = 0] = "Spend";
TxRedeemerTag[TxRedeemerTag["Mint"] = 1] = "Mint";
TxRedeemerTag[TxRedeemerTag["Cert"] = 2] = "Cert";
TxRedeemerTag[TxRedeemerTag["Withdraw"] = 3] = "Withdraw";
})(TxRedeemerTag = exports.TxRedeemerTag || (exports.TxRedeemerTag = {}));
;
Object.freeze(TxRedeemerTag);
function txRdmrTagToString(tag) {
switch (tag) {
case 2 /* TxRedeemerTag.Cert */: return "Cert";
case 1 /* TxRedeemerTag.Mint */: return "Mint";
case 0 /* TxRedeemerTag.Spend */: return "Spend";
case 3 /* TxRedeemerTag.Withdraw */: return "Withdraw";
case TxRedeemerTag.Cert: return "Cert";
case TxRedeemerTag.Mint: return "Mint";
case TxRedeemerTag.Spend: return "Spend";
case TxRedeemerTag.Withdraw: return "Withdraw";
default: return "";

@@ -40,6 +48,6 @@ }

switch (tag) {
case 0 /* TxRedeemerTag.Spend */: return "Spend";
case 1 /* TxRedeemerTag.Mint */: return "Mint";
case 2 /* TxRedeemerTag.Cert */: return "Cert";
case 3 /* TxRedeemerTag.Withdraw */: return "Withdraw";
case TxRedeemerTag.Spend: return "Spend";
case TxRedeemerTag.Mint: return "Mint";
case TxRedeemerTag.Cert: return "Cert";
case TxRedeemerTag.Withdraw: return "Withdraw";
default:

@@ -119,3 +127,3 @@ throw new BasePlutsError_1.BasePlutsError("invalid TxRedeemerTag");

var purposeArgData;
if (tag === 1 /* TxRedeemerTag.Mint */) {
if (tag === TxRedeemerTag.Mint) {
ctorIdx = 0;

@@ -127,3 +135,3 @@ var policy = (_a = tx.mint) === null || _a === void 0 ? void 0 : _a.map[this.index + 1].policy;

}
else if (tag === 0 /* TxRedeemerTag.Spend */) {
else if (tag === TxRedeemerTag.Spend) {
ctorIdx = 1;

@@ -135,3 +143,3 @@ var utxoRef = tx.inputs[this.index].utxoRef;

}
else if (tag === 3 /* TxRedeemerTag.Withdraw */) {
else if (tag === TxRedeemerTag.Withdraw) {
ctorIdx = 2;

@@ -143,3 +151,3 @@ var stakeAddr = (_c = (_b = tx.withdrawals) === null || _b === void 0 ? void 0 : _b.map[this.index]) === null || _c === void 0 ? void 0 : _c.rewardAccount;

}
else if (tag === 2 /* TxRedeemerTag.Cert */) {
else if (tag === TxRedeemerTag.Cert) {
ctorIdx = 3;

@@ -146,0 +154,0 @@ var cert = (_d = tx.certs) === null || _d === void 0 ? void 0 : _d.at(this.index);

@@ -53,3 +53,3 @@ import { ToCbor, CborString, CborObj, CanBeCborString } from "@harmoniclabs/cbor";

redeemers: {
tag: "Cert" | "Mint" | "Spend" | "Withdraw";
tag: "Spend" | "Mint" | "Cert" | "Withdraw";
index: number;

@@ -56,0 +56,0 @@ execUnits: {

@@ -40,8 +40,8 @@ "use strict";

return (isUndefOrCheckedArr(vkeyWitnesses, function (vkeyWit) { return vkeyWit instanceof VKeyWitness_1.VKeyWitness; }) &&
isUndefOrCheckedArr(nativeScripts, function (ns) { return ns instanceof script_1.Script && ns.type === "NativeScript" /* ScriptType.NativeScript */; }) &&
isUndefOrCheckedArr(nativeScripts, function (ns) { return ns instanceof script_1.Script && ns.type === script_1.ScriptType.NativeScript; }) &&
isUndefOrCheckedArr(bootstrapWitnesses, function (bootWit) { return bootWit instanceof BootstrapWitness_1.BootstrapWitness; }) &&
isUndefOrCheckedArr(plutusV1Scripts, function (pv1) { return pv1 instanceof script_1.Script && pv1.type === "PlutusScriptV1" /* ScriptType.PlutusV1 */; }) &&
isUndefOrCheckedArr(plutusV1Scripts, function (pv1) { return pv1 instanceof script_1.Script && pv1.type === script_1.ScriptType.PlutusV1; }) &&
isUndefOrCheckedArr(datums, plutus_data_1.isData) &&
isUndefOrCheckedArr(redeemers, function (rdmr) { return rdmr instanceof TxRedeemer_1.TxRedeemer; }) &&
isUndefOrCheckedArr(plutusV2Scripts, function (pv2) { return pv2 instanceof script_1.Script && pv2.type === "PlutusScriptV2" /* ScriptType.PlutusV2 */; }));
isUndefOrCheckedArr(plutusV2Scripts, function (pv2) { return pv2 instanceof script_1.Script && pv2.type === script_1.ScriptType.PlutusV2; }));
}

@@ -188,3 +188,3 @@ exports.isITxWitnessSet = isITxWitnessSet;

_native.array.map(function (nativeCborObj) {
return new script_1.Script("NativeScript" /* ScriptType.NativeScript */, cbor_1.Cbor.encode(nativeCborObj).asBytes);
return new script_1.Script(script_1.ScriptType.NativeScript, cbor_1.Cbor.encode(nativeCborObj).asBytes);
}),

@@ -195,3 +195,3 @@ bootstrapWitnesses: _bootstrap === undefined ? undefined :

_plutusV1.array.map(function (cbor) {
return new script_1.Script("PlutusScriptV1" /* ScriptType.PlutusV1 */, cbor_1.Cbor.encode(cbor).asBytes);
return new script_1.Script(script_1.ScriptType.PlutusV1, cbor_1.Cbor.encode(cbor).asBytes);
}),

@@ -204,3 +204,3 @@ datums: _dats === undefined ? undefined :

_plutusV2.array.map(function (cbor) {
return new script_1.Script("PlutusScriptV2" /* ScriptType.PlutusV2 */, cbor_1.Cbor.encode(cbor).asBytes);
return new script_1.Script(script_1.ScriptType.PlutusV2, cbor_1.Cbor.encode(cbor).asBytes);
}),

@@ -207,0 +207,0 @@ });

{
"name": "@harmoniclabs/cardano-ledger-ts",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -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