@cardano-ogmios/client
Advanced tools
Comparing version 5.5.8 to 5.6.0
@@ -34,3 +34,3 @@ "use strict"; | ||
}; | ||
const responseHandler = (options === null || options === void 0 ? void 0 : options.sequential) !== false | ||
const responseHandler = options?.sequential !== false | ||
? fastq_1.default.promise(messageHandler, 1).push | ||
@@ -37,0 +37,0 @@ : messageHandler; |
@@ -7,5 +7,9 @@ "use strict"; | ||
const requestNext = (socket, options) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'RequestNext', mirror: options === null || options === void 0 ? void 0 : options.mirror }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'RequestNext', | ||
mirror: options?.mirror | ||
})); | ||
}; | ||
exports.requestNext = requestNext; | ||
//# sourceMappingURL=requestNext.js.map |
@@ -8,19 +8,21 @@ "use strict"; | ||
const createConnectionObject = (config) => { | ||
var _a, _b, _c, _d; | ||
const _128MB = 128 * 1024 * 1024; | ||
const base = { | ||
host: (_a = config === null || config === void 0 ? void 0 : config.host) !== null && _a !== void 0 ? _a : 'localhost', | ||
port: (_b = config === null || config === void 0 ? void 0 : config.port) !== null && _b !== void 0 ? _b : 1337, | ||
tls: (_c = config === null || config === void 0 ? void 0 : config.tls) !== null && _c !== void 0 ? _c : false, | ||
maxPayload: (_d = config === null || config === void 0 ? void 0 : config.maxPayload) !== null && _d !== void 0 ? _d : _128MB | ||
host: config?.host ?? 'localhost', | ||
port: config?.port ?? 1337, | ||
tls: config?.tls ?? false, | ||
maxPayload: config?.maxPayload ?? _128MB | ||
}; | ||
const hostAndPort = `${base.host}:${base.port}`; | ||
return Object.assign(Object.assign({}, base), { address: { | ||
return { | ||
...base, | ||
address: { | ||
http: `${base.tls ? 'https' : 'http'}://${hostAndPort}`, | ||
webSocket: `${base.tls ? 'wss' : 'ws'}://${hostAndPort}` | ||
} }); | ||
} | ||
}; | ||
}; | ||
exports.createConnectionObject = createConnectionObject; | ||
const createInteractionContext = async (errorHandler, closeHandler, options) => { | ||
const connection = (0, exports.createConnectionObject)(options === null || options === void 0 ? void 0 : options.connection); | ||
const connection = (0, exports.createConnectionObject)(options?.connection); | ||
const health = await (0, ServerHealth_1.getServerHealth)({ connection }); | ||
@@ -32,3 +34,3 @@ return new Promise((resolve, reject) => { | ||
const socket = new IsomorphicWebSocket_1.WebSocket(connection.address.webSocket, { maxPayload: connection.maxPayload }); | ||
const closeOnCompletion = ((options === null || options === void 0 ? void 0 : options.interactionType) || 'LongRunning') === 'OneTime'; | ||
const closeOnCompletion = (options?.interactionType || 'LongRunning') === 'OneTime'; | ||
const afterEach = (cb) => { | ||
@@ -35,0 +37,0 @@ if (closeOnCompletion) { |
@@ -9,4 +9,3 @@ "use strict"; | ||
const getServerHealth = async (options) => { | ||
var _a; | ||
const response = await (0, cross_fetch_1.default)(`${(_a = options === null || options === void 0 ? void 0 : options.connection) === null || _a === void 0 ? void 0 : _a.address.http}/health`); | ||
const response = await (0, cross_fetch_1.default)(`${options?.connection?.address.http}/health`); | ||
const responseJson = await response.json(); | ||
@@ -13,0 +12,0 @@ if (response.ok) { |
@@ -11,5 +11,4 @@ "use strict"; | ||
async function listener(data) { | ||
var _a; | ||
const queryResponse = util_1.safeJSON.parse(data); | ||
if (((_a = queryResponse.reflection) === null || _a === void 0 ? void 0 : _a.requestId) !== requestId) { | ||
if (queryResponse.reflection?.requestId !== requestId) { | ||
return; | ||
@@ -26,5 +25,10 @@ } | ||
socket.on('message', listener); | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: request.methodName, args: request.args, mirror: { requestId } }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: request.methodName, | ||
args: request.args, | ||
mirror: { requestId } | ||
})); | ||
}), context); | ||
exports.Query = Query; | ||
//# sourceMappingURL=Query.js.map |
@@ -34,3 +34,8 @@ "use strict"; | ||
}); | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'Release', args: {}, mirror: { requestId } }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'Release', | ||
args: {}, | ||
mirror: { requestId } | ||
})); | ||
}); | ||
@@ -123,4 +128,4 @@ }, | ||
}); | ||
if ((options === null || options === void 0 ? void 0 : options.point) !== undefined) { | ||
const point = options === null || options === void 0 ? void 0 : options.point; | ||
if (options?.point !== undefined) { | ||
const point = options?.point; | ||
const requestId = (0, nanoid_1.nanoid)(5); | ||
@@ -160,3 +165,8 @@ (0, util_1.ensureSocketIsOpen)(socket); | ||
}); | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'Acquire', args: { point }, mirror: { requestId } }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'Acquire', | ||
args: { point }, | ||
mirror: { requestId } | ||
})); | ||
} | ||
@@ -163,0 +173,0 @@ else { |
@@ -28,3 +28,3 @@ "use strict"; | ||
const { result } = response; | ||
if ((args === null || args === void 0 ? void 0 : args.fields) === 'all') { | ||
if (args?.fields === 'all') { | ||
if ((0, exports.isNextTxResultAll)(result)) { | ||
@@ -31,0 +31,0 @@ return result; |
@@ -27,3 +27,7 @@ "use strict"; | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'AwaitAcquire', args: args }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'AwaitAcquire', | ||
args: args | ||
})); | ||
return (0, awaitAcquire_1.handleAwaitAcquireResponse)((await response.next()).value); | ||
@@ -35,3 +39,7 @@ }, context); | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'HasTx', args: { id } }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'HasTx', | ||
args: { id } | ||
})); | ||
return (0, hasTx_1.handleHasTxResponse)((await response.next()).value); | ||
@@ -43,3 +51,7 @@ }, context); | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'NextTx', args: args || {} }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'NextTx', | ||
args: args || {} | ||
})); | ||
return (0, nextTx_1.handleNextTxResponse)((await response.next()).value, args); | ||
@@ -51,3 +63,7 @@ }, context); | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'SizeAndCapacity', args: args }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'SizeAndCapacity', | ||
args: args | ||
})); | ||
return (0, sizeAndCapacity_1.handleSizeAndCapacityResponse)((await response.next()).value); | ||
@@ -59,3 +75,7 @@ }, context); | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'ReleaseMempool', args: args }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'ReleaseMempool', | ||
args: args | ||
})); | ||
return (0, release_1.handleReleaseResponse)((await response.next()).value); | ||
@@ -62,0 +82,0 @@ }, context); |
@@ -11,3 +11,6 @@ "use strict"; | ||
methodName: 'EvaluateTx', | ||
args: Object.assign(Object.assign({}, (additionalUtxoSet !== undefined ? { additionalUtxoSet } : {})), { evaluate: bytes }) | ||
args: { | ||
...(additionalUtxoSet !== undefined ? { additionalUtxoSet } : {}), | ||
evaluate: bytes | ||
} | ||
}, { | ||
@@ -14,0 +17,0 @@ handler: (response, resolve, reject) => { |
@@ -31,3 +31,10 @@ "use strict"; | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'EvaluateTx', args: Object.assign(Object.assign({}, (additionalUtxoSet !== undefined ? { additionalUtxoSet } : {})), { evaluate: bytes }) }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'EvaluateTx', | ||
args: { | ||
...(additionalUtxoSet !== undefined ? { additionalUtxoSet } : {}), | ||
evaluate: bytes | ||
} | ||
})); | ||
const response = (0, evaluateTx_1.handleEvaluateTxResponse)((await evaluateTxResponse.next()).value); | ||
@@ -45,3 +52,7 @@ if ((0, evaluateTx_1.isEvaluationResult)(response)) { | ||
return (0, Request_1.send)(async (socket) => { | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'SubmitTx', args: { submit: bytes } }))); | ||
socket.send(util_1.safeJSON.stringify({ | ||
...Request_1.baseRequest, | ||
methodname: 'SubmitTx', | ||
args: { submit: bytes } | ||
})); | ||
const response = (0, submitTx_1.handleSubmitTxResponse)((await submitTxResponse.next()).value); | ||
@@ -48,0 +59,0 @@ if ((0, submitTx_1.isTxId)(response)) { |
/// <reference types="node" /> | ||
import { WebSocket } from './IsomorphicWebSocket'; | ||
import { InteractionContext } from './Connection'; | ||
import { Block, BlockAllegra, BlockAlonzo, BlockBabbage, BlockByron, BlockMary, BlockShelley, EpochBoundaryBlock, Point, ProtocolParametersAlonzo, ProtocolParametersBabbage, ProtocolParametersShelley, StandardBlock } from '@cardano-ogmios/schema'; | ||
import { Block, BlockAllegra, BlockAlonzo, BlockBabbage, BlockByron, BlockMary, BlockShelley, EpochBoundaryBlock, Metadatum, Point, ProtocolParametersAlonzo, ProtocolParametersBabbage, ProtocolParametersShelley, StandardBlock } from '@cardano-ogmios/schema'; | ||
import { EventEmitter } from 'events'; | ||
@@ -17,2 +17,3 @@ export declare const safeJSON: { | ||
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 { | ||
@@ -19,0 +20,0 @@ allegra: BlockAllegra; |
"use strict"; | ||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var g = generator.apply(thisArg, _arguments || []), i, q = []; | ||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; | ||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } | ||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } | ||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } | ||
function fulfill(value) { resume("next", value); } | ||
function reject(value) { resume("throw", value); } | ||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } | ||
}; | ||
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.eventEmitterToGenerator = exports.ensureSocketIsOpen = exports.createPointFromCurrentTip = exports.safeJSON = void 0; | ||
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"); | ||
@@ -24,6 +12,9 @@ const errors_1 = require("./errors"); | ||
const len = Object.getOwnPropertyNames(json).length; | ||
if (len === 2 && json.coins !== undefined && json.assets !== undefined) { | ||
if (json.coins !== undefined) { | ||
const coins = json.coins; | ||
json.coins = typeof coins === 'number' ? BigInt(coins) : coins; | ||
return this.sanitizeAdditionalFields(json.assets); | ||
if (json.assets !== undefined) { | ||
return this.sanitizeAdditionalFields(json.assets); | ||
} | ||
return json; | ||
} | ||
@@ -118,18 +109,57 @@ if (parentKey === 'body' && json.fee !== undefined) { | ||
}); | ||
return function generator() { | ||
return __asyncGenerator(this, arguments, function* generator_1() { | ||
while (true) { | ||
yield yield __await(new Promise((resolve) => { | ||
if (events.length > 0) { | ||
resolve(events.shift()); | ||
} | ||
else { | ||
listeners.push(resolve); | ||
} | ||
})); | ||
} | ||
}); | ||
return async function* generator() { | ||
while (true) { | ||
yield new Promise((resolve) => { | ||
if (events.length > 0) { | ||
resolve(events.shift()); | ||
} | ||
else { | ||
listeners.push(resolve); | ||
} | ||
}); | ||
} | ||
}; | ||
} | ||
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.'); | ||
} | ||
if ('int' in o) { | ||
return o.int; | ||
} | ||
else if ('string' in o) { | ||
return o.string; | ||
} | ||
else if ('bytes' in o) { | ||
return Buffer.from(o.bytes, 'hex'); | ||
} | ||
else if ('list' in o) { | ||
return o.list.map(fromMetadatum); | ||
} | ||
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.'; | ||
} | ||
throw new Error(`${msg}${hint}`); | ||
} | ||
} | ||
function fromMetadatumMap(acc, { k, v }) { | ||
const kStr = fromMetadatum(k); | ||
if (typeof kStr !== 'string') { | ||
throw new Error(`Invalid non-string key: ${k}.`); | ||
} | ||
acc[kStr] = fromMetadatum(v); | ||
return acc; | ||
} | ||
return fromMetadatum(metadatum); | ||
} | ||
exports.unsafeMetadatumAsJSON = unsafeMetadatumAsJSON; | ||
const isAllegraBlock = (block) => block.allegra !== undefined; | ||
@@ -136,0 +166,0 @@ exports.isAllegraBlock = isAllegraBlock; |
{ | ||
"name": "@cardano-ogmios/client", | ||
"version": "5.5.8", | ||
"version": "5.6.0", | ||
"description": "TypeScript client library for Cardano Ogmios", | ||
@@ -56,3 +56,3 @@ "engines": { | ||
"dependencies": { | ||
"@cardano-ogmios/schema": "5.5.8", | ||
"@cardano-ogmios/schema": "5.6.0", | ||
"@cardanosolutions/json-bigint": "^1.0.0", | ||
@@ -59,0 +59,0 @@ "@types/json-bigint": "^1.0.1", |
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
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
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
352270
4405
+ Added@cardano-ogmios/schema@5.6.0(transitive)
- Removed@cardano-ogmios/schema@5.5.8(transitive)
Updated@cardano-ogmios/schema@5.6.0