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

@cardano-ogmios/client

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cardano-ogmios/client - npm Package Compare versions

Comparing version 5.6.0 to 6.0.0-rc1

dist/ChainSynchronization/Client.d.ts

40

dist/Connection.d.ts

@@ -18,12 +18,40 @@ import { WebSocket, CloseEvent } from './IsomorphicWebSocket';

socket: WebSocket;
afterEach: (cb: () => void) => void;
}
export declare type InteractionType = ('LongRunning' | 'OneTime');
export declare type WebSocketErrorHandler = (error: Error) => void;
export declare type WebSocketCloseHandler = (code: CloseEvent['code'], reason: CloseEvent['reason']) => void;
export declare const createConnectionObject: (config?: ConnectionConfig) => Connection;
export type InteractionType = ('LongRunning' | 'OneTime');
export type Mirror = {
[k: string]: unknown;
};
export type WebSocketErrorHandler = (error: Error) => void;
export type WebSocketCloseHandler = (code: CloseEvent['code'], reason: CloseEvent['reason']) => void;
export declare class JSONRPCError extends Error {
code: number;
data?: any;
id?: any;
constructor(code: number, message: string, data?: any, id?: any);
static tryFrom(any: any): JSONRPCError;
}
export declare function createConnectionObject(config?: ConnectionConfig): Connection;
export declare const createInteractionContext: (errorHandler: WebSocketErrorHandler, closeHandler: WebSocketCloseHandler, options?: {
connection?: ConnectionConfig;
interactionType?: InteractionType;
maxEventListeners?: number;
}) => Promise<InteractionContext>;
export declare const baseRequest: {
jsonrpc: string;
};
export declare const ensureSocketIsOpen: (socket: WebSocket) => void;
export declare const send: <T>(send: (socket: WebSocket) => Promise<T>, context: InteractionContext) => Promise<T>;
export declare const Method: <Request_1 extends {
method: string;
params?: any;
}, Response_1 extends {
method: string;
id?: {
requestId?: string;
};
}, A>(req: {
method: Request_1["method"];
params?: Request_1["params"];
}, res: {
handler?: (response: Response_1, resolve: (value?: A | PromiseLike<A>) => void, reject: (reason?: any) => void) => void;
}, context: InteractionContext) => Promise<A>;
//# sourceMappingURL=Connection.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createInteractionContext = exports.createConnectionObject = void 0;
exports.Method = exports.send = exports.ensureSocketIsOpen = exports.baseRequest = exports.createInteractionContext = exports.createConnectionObject = exports.JSONRPCError = void 0;
const nanoid_1 = require("nanoid");
const IsomorphicWebSocket_1 = require("./IsomorphicWebSocket");
const ServerHealth_1 = require("./ServerHealth");
const errors_1 = require("./errors");
const createConnectionObject = (config) => {
const util_1 = require("./util");
class JSONRPCError extends Error {
constructor(code, message, data, id) {
super(message);
this.stack = '';
this.code = code;
if (typeof data !== 'undefined') {
this.data = data;
}
if (typeof id !== 'undefined') {
this.id = Object.assign({}, id || {});
}
}
static tryFrom(any) {
if ('error' in any && 'jsonrpc' in any && any.jsonrpc === '2.0') {
const { error: e } = any;
if ('code' in e && 'message' in e) {
if (Number.isInteger(e.code) && typeof e.message === 'string') {
return new JSONRPCError(e.code, e.message, e?.data, any?.id);
}
}
}
return null;
}
}
exports.JSONRPCError = JSONRPCError;
function createConnectionObject(config) {
const _128MB = 128 * 1024 * 1024;

@@ -23,22 +49,12 @@ const base = {

};
};
}
exports.createConnectionObject = createConnectionObject;
const createInteractionContext = async (errorHandler, closeHandler, options) => {
const connection = (0, exports.createConnectionObject)(options?.connection);
const connection = createConnectionObject(options?.connection);
const health = await (0, ServerHealth_1.getServerHealth)({ connection });
return new Promise((resolve, reject) => {
if (health.lastTipUpdate === null) {
return reject(new errors_1.ServerNotReady(health));
return reject(new ServerHealth_1.ServerNotReady(health));
}
const socket = new IsomorphicWebSocket_1.WebSocket(connection.address.webSocket, { maxPayload: connection.maxPayload });
const closeOnCompletion = (options?.interactionType || 'LongRunning') === 'OneTime';
const afterEach = (cb) => {
if (closeOnCompletion) {
socket.once('close', cb);
socket.close();
}
else {
cb();
}
};
const onInitialError = (error) => {

@@ -48,2 +64,3 @@ socket.removeAllListeners();

};
socket.setMaxListeners(options.maxEventListeners || 10);
socket.on('error', onInitialError);

@@ -60,4 +77,3 @@ socket.once('close', (_code, reason) => {

connection,
socket,
afterEach
socket
});

@@ -68,2 +84,53 @@ });

exports.createInteractionContext = createInteractionContext;
exports.baseRequest = {
jsonrpc: '2.0'
};
const ensureSocketIsOpen = (socket) => {
if (socket.readyState !== socket.OPEN) {
throw new Error('WebSocket is closed');
}
};
exports.ensureSocketIsOpen = ensureSocketIsOpen;
const send = async (send, context) => {
const { socket } = context;
return new Promise((resolve, reject) => {
send(socket)
.then(resolve)
.catch(error => reject(JSONRPCError.tryFrom(error) || error));
});
};
exports.send = send;
const Method = (req, res, context) => (0, exports.send)((socket) => new Promise((resolve, reject) => {
const requestId = (0, nanoid_1.nanoid)(16);
async function listener(data) {
const response = util_1.safeJSON.parse(data);
if (response?.id?.requestId !== requestId) {
return;
}
socket.removeListener('message', listener);
try {
const handler = res.handler || ((response, resolve, reject) => {
if (response.method === req.method && 'result' in response) {
resolve(response.result);
}
else {
reject(response);
}
});
await handler(response, resolve, reject);
}
catch (e) {
return reject(e);
}
}
socket.on('message', listener);
(0, exports.ensureSocketIsOpen)(socket);
socket.send(util_1.safeJSON.stringify({
...exports.baseRequest,
method: req.method,
params: req.params,
id: { requestId }
}));
}), context);
exports.Method = Method;
//# sourceMappingURL=Connection.js.map

17

dist/index.d.ts
export * as Schema from '@cardano-ogmios/schema';
export * from './Connection';
export * from './ServerHealth';
export * from './errors';
export * from './util';
export { createChainSyncClient } from './ChainSync';
export * as ChainSync from './ChainSync';
export { createStateQueryClient } from './StateQuery';
export * as StateQuery from './StateQuery';
export { createTxSubmissionClient } from './TxSubmission';
export * as TxSubmission from './TxSubmission';
export { createTxMonitorClient } from './TxMonitor';
export * as TxMonitor from './TxMonitor';
export { createChainSynchronizationClient } from './ChainSynchronization';
export * as ChainSynchronization from './ChainSynchronization';
export { createTransactionSubmissionClient } from './TransactionSubmission';
export * as TransactionSubmission from './TransactionSubmission';
export { createMempoolMonitoringClient } from './MempoolMonitoring';
export * as MempoolMonitoring from './MempoolMonitoring';
export { createLedgerStateQueryClient } from './LedgerStateQuery';
export * as LedgerStateQuery from './LedgerStateQuery';
//# sourceMappingURL=index.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,20 +29,19 @@ if (k2 === undefined) k2 = k;

Object.defineProperty(exports, "__esModule", { value: true });
exports.TxMonitor = exports.createTxMonitorClient = exports.TxSubmission = exports.createTxSubmissionClient = exports.StateQuery = exports.createStateQueryClient = exports.ChainSync = exports.createChainSyncClient = exports.Schema = void 0;
exports.LedgerStateQuery = exports.createLedgerStateQueryClient = exports.MempoolMonitoring = exports.createMempoolMonitoringClient = exports.TransactionSubmission = exports.createTransactionSubmissionClient = exports.ChainSynchronization = exports.createChainSynchronizationClient = exports.Schema = void 0;
exports.Schema = __importStar(require("@cardano-ogmios/schema"));
__exportStar(require("./Connection"), exports);
__exportStar(require("./ServerHealth"), exports);
__exportStar(require("./errors"), exports);
__exportStar(require("./util"), exports);
var ChainSync_1 = require("./ChainSync");
Object.defineProperty(exports, "createChainSyncClient", { enumerable: true, get: function () { return ChainSync_1.createChainSyncClient; } });
exports.ChainSync = __importStar(require("./ChainSync"));
var StateQuery_1 = require("./StateQuery");
Object.defineProperty(exports, "createStateQueryClient", { enumerable: true, get: function () { return StateQuery_1.createStateQueryClient; } });
exports.StateQuery = __importStar(require("./StateQuery"));
var TxSubmission_1 = require("./TxSubmission");
Object.defineProperty(exports, "createTxSubmissionClient", { enumerable: true, get: function () { return TxSubmission_1.createTxSubmissionClient; } });
exports.TxSubmission = __importStar(require("./TxSubmission"));
var TxMonitor_1 = require("./TxMonitor");
Object.defineProperty(exports, "createTxMonitorClient", { enumerable: true, get: function () { return TxMonitor_1.createTxMonitorClient; } });
exports.TxMonitor = __importStar(require("./TxMonitor"));
var ChainSynchronization_1 = require("./ChainSynchronization");
Object.defineProperty(exports, "createChainSynchronizationClient", { enumerable: true, get: function () { return ChainSynchronization_1.createChainSynchronizationClient; } });
exports.ChainSynchronization = __importStar(require("./ChainSynchronization"));
var TransactionSubmission_1 = require("./TransactionSubmission");
Object.defineProperty(exports, "createTransactionSubmissionClient", { enumerable: true, get: function () { return TransactionSubmission_1.createTransactionSubmissionClient; } });
exports.TransactionSubmission = __importStar(require("./TransactionSubmission"));
var MempoolMonitoring_1 = require("./MempoolMonitoring");
Object.defineProperty(exports, "createMempoolMonitoringClient", { enumerable: true, get: function () { return MempoolMonitoring_1.createMempoolMonitoringClient; } });
exports.MempoolMonitoring = __importStar(require("./MempoolMonitoring"));
var LedgerStateQuery_1 = require("./LedgerStateQuery");
Object.defineProperty(exports, "createLedgerStateQueryClient", { enumerable: true, get: function () { return LedgerStateQuery_1.createLedgerStateQueryClient; } });
exports.LedgerStateQuery = __importStar(require("./LedgerStateQuery"));
//# sourceMappingURL=index.js.map

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

},
setMaxListeners(_n) { },
removeListener,

@@ -51,0 +52,0 @@ removeAllListeners() {

@@ -0,5 +1,6 @@

import { CustomError } from 'ts-custom-error';
import { Connection } from './Connection';
import { Tip } from '@cardano-ogmios/schema';
import { Era, Tip } from '@cardano-ogmios/schema';
export interface ServerHealth {
currentEra: 'Alonzo' | 'Byron' | 'Mary' | 'Shelley';
currentEra: Era;
lastKnownTip: Tip;

@@ -25,3 +26,5 @@ lastTipUpdate: string | null;

startTime: string;
network: 'mainnet' | 'preview' | 'preprod';
networkSynchronization: number;
version: string;
}

@@ -31,2 +34,5 @@ export declare const getServerHealth: (options?: {

}) => Promise<ServerHealth>;
export declare class ServerNotReady extends CustomError {
constructor(health: ServerHealth);
}
//# sourceMappingURL=ServerHealth.d.ts.map

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerHealth = void 0;
exports.ServerNotReady = exports.getServerHealth = void 0;
const cross_fetch_1 = __importDefault(require("cross-fetch"));
const ts_custom_error_1 = require("ts-custom-error");
const getServerHealth = async (options) => {

@@ -20,2 +21,10 @@ const response = await (0, cross_fetch_1.default)(`${options?.connection?.address.http}/health`);

exports.getServerHealth = getServerHealth;
class ServerNotReady extends ts_custom_error_1.CustomError {
constructor(health) {
super();
this.message =
`Server is not ready. Network synchronization at ${health.networkSynchronization}%`;
}
}
exports.ServerNotReady = ServerNotReady;
//# sourceMappingURL=ServerHealth.js.map
/// <reference types="node" />
import { WebSocket } from './IsomorphicWebSocket';
import { InteractionContext } from './Connection';
import { Block, BlockAllegra, BlockAlonzo, BlockBabbage, BlockByron, BlockMary, BlockShelley, EpochBoundaryBlock, Metadatum, Point, ProtocolParametersAlonzo, ProtocolParametersBabbage, ProtocolParametersShelley, StandardBlock } from '@cardano-ogmios/schema';
import { Block, BlockBFT, BlockEBB, BlockPraos, TransactionOutput, UInt64 } from '@cardano-ogmios/schema';
import { EventEmitter } from 'events';

@@ -10,38 +8,14 @@ export declare const safeJSON: {

sanitizeFields(json: any, fields: string[]): any;
sanitizeAdditionalFields(json: any): any;
sanitizeAdditionalFields(json: any, depth: number): any;
sanitizeMetadatum(json: any): any;
parse(raw: string): any;
stringify(...args: any[]): string;
};
export declare const createPointFromCurrentTip: (context?: InteractionContext) => Promise<Point>;
export declare const ensureSocketIsOpen: (socket: WebSocket) => void;
export declare function eventEmitterToGenerator<T>(eventEmitter: EventEmitter, eventName: string, match: (e: string) => T | null): () => AsyncGenerator<unknown, never, unknown>;
export declare function unsafeMetadatumAsJSON(metadatum: Metadatum): any;
export declare const isAllegraBlock: (block: Block) => block is {
allegra: BlockAllegra;
};
export declare const isAlonzoBlock: (block: Block) => block is {
alonzo: BlockAlonzo;
};
export declare const isBabbageBlock: (block: Block) => block is {
babbage: BlockBabbage;
};
export declare const isByronBlock: (block: Block) => block is {
byron: BlockByron;
};
export declare const isByronStandardBlock: (block: Block) => block is {
byron: StandardBlock;
};
export declare const isByronEpochBoundaryBlock: (block: Block) => block is {
byron: EpochBoundaryBlock;
};
export declare const isMaryBlock: (block: Block) => block is {
mary: BlockMary;
};
export declare const isShelleyBlock: (block: Block) => block is {
shelley: BlockShelley;
};
export declare const isEmptyObject: (obj: Object) => boolean;
export declare const isShelleyProtocolParameters: (params: ProtocolParametersShelley | ProtocolParametersAlonzo | ProtocolParametersBabbage) => params is ProtocolParametersShelley;
export declare const isAlonzoProtocolParameters: (params: ProtocolParametersShelley | ProtocolParametersAlonzo | ProtocolParametersBabbage) => params is ProtocolParametersAlonzo;
export declare const isBabbageProtocolParameters: (params: ProtocolParametersShelley | ProtocolParametersAlonzo | ProtocolParametersBabbage) => params is ProtocolParametersBabbage;
export declare function isObject($: any): $ is Object;
export declare function isBlockEBB(block: Block): block is BlockEBB;
export declare function isBlockBFT(block: Block): block is BlockBFT;
export declare function isBlockPraos(block: Block): block is BlockPraos;
export declare const CONSTANT_OUTPUT_SERIALIZATION_OVERHEAD = 160;
export declare const utxoSize: (output: TransactionOutput) => UInt64;
//# sourceMappingURL=util.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBabbageProtocolParameters = exports.isAlonzoProtocolParameters = exports.isShelleyProtocolParameters = exports.isEmptyObject = exports.isShelleyBlock = exports.isMaryBlock = exports.isByronEpochBoundaryBlock = exports.isByronStandardBlock = exports.isByronBlock = exports.isBabbageBlock = exports.isAlonzoBlock = exports.isAllegraBlock = exports.unsafeMetadatumAsJSON = exports.eventEmitterToGenerator = exports.ensureSocketIsOpen = exports.createPointFromCurrentTip = exports.safeJSON = void 0;
const ChainSync_1 = require("./ChainSync");
const errors_1 = require("./errors");
exports.utxoSize = exports.CONSTANT_OUTPUT_SERIALIZATION_OVERHEAD = exports.isBlockPraos = exports.isBlockBFT = exports.isBlockEBB = exports.isObject = exports.eventEmitterToGenerator = exports.safeJSON = void 0;
const bech32_1 = require("bech32");
const JSONBig = require('@cardanosolutions/json-bigint');

@@ -11,41 +10,20 @@ exports.safeJSON = {

if (typeof json === 'object' && json !== null) {
const len = Object.getOwnPropertyNames(json).length;
if (json.coins !== undefined) {
const coins = json.coins;
json.coins = typeof coins === 'number' ? BigInt(coins) : coins;
if (json.assets !== undefined) {
return this.sanitizeAdditionalFields(json.assets);
}
return json;
if (json.lovelace !== undefined) {
return this.sanitizeFields(json, ['lovelace']);
}
if (parentKey === 'body' && json.fee !== undefined) {
return this.sanitizeFields(json, ['fee', 'totalCollateral']);
if (json.ada !== undefined || parentKey === 'mint' || parentKey === 'value') {
return this.sanitizeAdditionalFields(json, 2);
}
if (parentKey === 'withdrawals') {
return this.sanitizeAdditionalFields(json);
if (json.clause === 'some' && json.atLeast !== undefined) {
this.sanitizeFields(json, ['atLeast']);
return this.sanitize(json.from, 'from');
}
if (len === 1 && json.int !== undefined) {
return this.sanitizeFields(json, ['int']);
if (parentKey === 'labels') {
return this.sanitizeMetadatum(json);
}
if (json.poolInfluence !== undefined && json.pools !== undefined) {
return this.sanitizeFields(json, ['totalRewards', 'activeStake']);
}
if (json.stake !== undefined && json.approximatePerformance !== undefined) {
return this.sanitizeFields(json, ['stake', 'ownerStake']);
}
if (parentKey === 'poolParameters' || (json.vrf !== undefined && json.pledge !== undefined)) {
return this.sanitizeFields(json, ['cost', 'pledge']);
}
if (parentKey === 'moveInstantaneousRewards') {
this.sanitizeAdditionalFields(json.rewards);
return this.sanitizeFields(json, ['value']);
}
if (json.rewards !== undefined) {
return this.sanitizeFields(json, ['rewards']);
}
for (const k in json) {
this.sanitize(json[k], k);
}
return json;
}
return json;
},

@@ -64,9 +42,23 @@ sanitizeFields(json, fields) {

},
sanitizeAdditionalFields(json) {
sanitizeAdditionalFields(json, depth) {
for (const k in json) {
const v = json[k];
json[k] = typeof v === 'number' ? BigInt(v) : v;
if (depth > 1) {
this.sanitizeAdditionalFields(v, depth - 1);
}
else {
json[k] = typeof v === 'number' ? BigInt(v) : v;
}
}
return json;
},
sanitizeMetadatum(json) {
if (typeof json === 'object' && json !== null) {
for (const k in json) {
const v = json[k];
json[k] = typeof v === 'number' ? BigInt(v) : this.sanitizeMetadatum(v);
}
}
return json;
},
parse(raw) {

@@ -79,19 +71,2 @@ return this.sanitize(this.$.parse(raw));

};
const createPointFromCurrentTip = async (context) => {
const { tip } = await (0, ChainSync_1.findIntersect)(context, ['origin']);
if (tip === 'origin') {
throw new errors_1.TipIsOriginError();
}
return {
hash: tip.hash,
slot: tip.slot
};
};
exports.createPointFromCurrentTip = createPointFromCurrentTip;
const ensureSocketIsOpen = (socket) => {
if (socket.readyState !== socket.OPEN) {
throw new errors_1.WebSocketClosed();
}
};
exports.ensureSocketIsOpen = ensureSocketIsOpen;
function eventEmitterToGenerator(eventEmitter, eventName, match) {

@@ -125,67 +100,123 @@ const events = [];

exports.eventEmitterToGenerator = eventEmitterToGenerator;
function unsafeMetadatumAsJSON(metadatum) {
function fromMetadatum(o) {
if (Object.keys(o).length > 1) {
throw new Error('Malformed metadatum object. A JSON object that describes CBOR encoded datum is expected.');
const BYRON_ERA = 'byron';
function isObject($) {
return typeof $ === 'object' && $ !== null;
}
exports.isObject = isObject;
function isBlockEBB(block) {
return block.era === BYRON_ERA && typeof block.issuer === 'undefined';
}
exports.isBlockEBB = isBlockEBB;
function isBlockBFT(block) {
return block.era === BYRON_ERA && typeof block.issuer !== 'undefined';
}
exports.isBlockBFT = isBlockBFT;
function isBlockPraos(block) {
return block.era !== BYRON_ERA;
}
exports.isBlockPraos = isBlockPraos;
exports.CONSTANT_OUTPUT_SERIALIZATION_OVERHEAD = 160;
const utxoSize = (output) => {
return exports.CONSTANT_OUTPUT_SERIALIZATION_OVERHEAD +
sizeOfArrayDef(1) +
sizeOfAddress(output.address) +
sizeOfValue(output.value) +
sizeOfInlineDatum(output.datum) +
sizeOfDatumHash(output.datumHash) +
sizeOfScript(output.script);
function sizeOfInteger(n) {
let size = 0;
if (n < 24n) {
size = 1;
}
if ('int' in o) {
return o.int;
else if (n < 256n) {
size = 2;
}
else if ('string' in o) {
return o.string;
else if (n < 65536n) {
size = 3;
}
else if ('bytes' in o) {
return Buffer.from(o.bytes, 'hex');
else if (n < 4294967296n) {
size = 5;
}
else if ('list' in o) {
return o.list.map(fromMetadatum);
else {
size = 9;
}
else if ('map' in o) {
return o.map.reduce(fromMetadatumMap, {});
}
else {
const type = Object.keys(o)[0];
const msg = `Unexpected metadatum type '${type}'.`;
let hint = '';
if (Number.isInteger(Number.parseInt(type, 10))) {
hint = ' Hint: this function expects metadatum objects without metadatum label.';
return size;
}
function sizeOfBytesDef(n) {
return sizeOfInteger(BigInt(n));
}
function sizeOfArrayDef(n) {
return n < 24 ? 1 : 2;
}
function sizeOfAddress(address) {
const cborOverhead = 3;
const payloadSize = bech32_1.bech32.fromWords(bech32_1.bech32.decode(address, 999).words).length;
return cborOverhead + payloadSize;
}
function sizeOfValue(value) {
const POLICY_ID_SIZE = 28;
const { ada: { lovelace }, ...assets } = value;
const lovelaceSize = lovelace >= 4294967296n ? 9 : 5;
const [assetsSize, policies] = Object.keys(assets).reduce(([total, policies], policyId) => {
const assetsSize = Object.keys(assets[policyId]).reduce((assetsSize, assetName) => {
registerAssetId(policies, policyId, assetName);
const quantitySize = sizeOfInteger(assets[policyId][assetName]);
const assetNameSize = assetName.length / 2;
const assetNameOverhead = sizeOfBytesDef(assetNameSize);
return assetsSize + assetNameSize + assetNameOverhead + quantitySize;
}, 0);
const policyIdSize = 2 + POLICY_ID_SIZE;
return [total + policyIdSize + assetsSize, policies];
}, [0, new Map()]);
const policiesOverhead = sizeOfArrayDef(policies.size);
const assetsOverhead = Array.from(policies).reduce((total, [_, policy]) => {
return total + sizeOfArrayDef(policy.size);
}, 0);
const cborOverhead = 1 + (Object.keys(assets).length === 0 ? 0 : (1 + policiesOverhead + assetsOverhead));
return cborOverhead + lovelaceSize + assetsSize;
function registerAssetId(assets, policyId, assetName) {
let policy = assets.get(policyId);
if (policy === undefined) {
policy = new Set();
policy.add(assetName);
assets.set(policyId, policy);
return false;
}
throw new Error(`${msg}${hint}`);
else {
policy.add(assetName);
return true;
}
}
}
function fromMetadatumMap(acc, { k, v }) {
const kStr = fromMetadatum(k);
if (typeof kStr !== 'string') {
throw new Error(`Invalid non-string key: ${k}.`);
function sizeOfInlineDatum(datum) {
if (datum === undefined) {
return 0;
}
acc[kStr] = fromMetadatum(v);
return acc;
const cborOverhead = 5 + sizeOfBytesDef(datum.length);
const datumSize = datum.length / 2;
return cborOverhead + datumSize;
}
return fromMetadatum(metadatum);
}
exports.unsafeMetadatumAsJSON = unsafeMetadatumAsJSON;
const isAllegraBlock = (block) => block.allegra !== undefined;
exports.isAllegraBlock = isAllegraBlock;
const isAlonzoBlock = (block) => block.alonzo !== undefined;
exports.isAlonzoBlock = isAlonzoBlock;
const isBabbageBlock = (block) => block.babbage !== undefined;
exports.isBabbageBlock = isBabbageBlock;
const isByronBlock = (block) => block.byron !== undefined;
exports.isByronBlock = isByronBlock;
const isByronStandardBlock = (block) => (0, exports.isByronBlock)(block) && block.byron.body !== undefined;
exports.isByronStandardBlock = isByronStandardBlock;
const isByronEpochBoundaryBlock = (block) => (0, exports.isByronBlock)(block) && block.byron.body === undefined;
exports.isByronEpochBoundaryBlock = isByronEpochBoundaryBlock;
const isMaryBlock = (block) => block.mary !== undefined;
exports.isMaryBlock = isMaryBlock;
const isShelleyBlock = (block) => block.shelley !== undefined;
exports.isShelleyBlock = isShelleyBlock;
const isEmptyObject = (obj) => obj !== undefined && Object.keys(obj).length === 0 && (obj.constructor === Object || obj.constructor === undefined);
exports.isEmptyObject = isEmptyObject;
const isShelleyProtocolParameters = (params) => params.minUtxoValue !== undefined;
exports.isShelleyProtocolParameters = isShelleyProtocolParameters;
const isAlonzoProtocolParameters = (params) => params.coinsPerUtxoWord !== undefined;
exports.isAlonzoProtocolParameters = isAlonzoProtocolParameters;
const isBabbageProtocolParameters = (params) => params.coinsPerUtxoByte !== undefined;
exports.isBabbageProtocolParameters = isBabbageProtocolParameters;
function sizeOfDatumHash(datumHash) {
if (datumHash === undefined) {
return 0;
}
const cborOverhead = 5;
const hashDigestSize = datumHash.length / 2;
return cborOverhead + hashDigestSize;
}
function sizeOfScript(script) {
if (script === undefined) {
return 0;
}
let scriptSize = script.cbor.length / 2;
if (script.language !== 'native') {
scriptSize += sizeOfBytesDef(scriptSize);
}
scriptSize += 2;
const cborOverhead = 3 + sizeOfBytesDef(scriptSize);
return cborOverhead + scriptSize;
}
};
exports.utxoSize = utxoSize;
//# sourceMappingURL=util.js.map
{
"name": "@cardano-ogmios/client",
"version": "5.6.0",
"version": "6.0.0-rc1",
"description": "TypeScript client library for Cardano Ogmios",

@@ -18,18 +18,14 @@ "engines": {

"build": "tsc --build ./src",
"build-all": "tsc --build ./src && tsc --build ./test",
"cleanup": "shx rm -rf dist node_modules",
"lint": "eslint --ignore-path ../../.eslintignore \"**/*.ts\"",
"prepack": "yarn build",
"test": "yarn test:nodejs && yarn test:chrome",
"test:nodejs": "jest -c ./jest.config.js",
"test:chrome": "jest -c ./jest.config.puppeteer.js"
"test": "jest -c ./jest.config.js"
},
"devDependencies": {
"@types/events": "^3.0.0",
"@types/expect-puppeteer": "^4.4.5",
"@types/jest": "^26.0.20",
"@types/jest-environment-puppeteer": "^4.4.1",
"@types/json-bigint": "^1.0.1",
"@types/node": "^14.14.32",
"@types/node-fetch": "^2.5.10",
"@types/puppeteer": "^5.4.3",
"@types/ws": "^7.4.0",

@@ -49,5 +45,3 @@ "@typescript-eslint/eslint-plugin": "^4.17.0",

"jest": "^26.6.3",
"jest-puppeteer": "^4.4.0",
"json-schema-to-typescript": "CardanoSolutions/json-schema-to-typescript",
"puppeteer": "^8.0.0",
"json-schema-to-typescript": "https://github.com/CardanoSolutions/json-schema-to-typescript",
"shx": "^0.3.3",

@@ -58,5 +52,6 @@ "ts-jest": "^26.5.3",

"dependencies": {
"@cardano-ogmios/schema": "5.6.0",
"@cardanosolutions/json-bigint": "^1.0.0",
"@cardano-ogmios/schema": "6.0.0-rc1",
"@cardanosolutions/json-bigint": "^1.0.1",
"@types/json-bigint": "^1.0.1",
"bech32": "^2.0.0",
"cross-fetch": "^3.1.4",

@@ -63,0 +58,0 @@ "fastq": "^1.11.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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