@cardano-ogmios/client
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -1,4 +0,4 @@ | ||
import { ProtocolParametersShelley } from '@cardano-ogmios/schema'; | ||
import { ProtocolParametersAlonzo, ProtocolParametersShelley } from '@cardano-ogmios/schema'; | ||
import { InteractionContext } from '../../Connection'; | ||
export declare const currentProtocolParameters: (context: InteractionContext) => Promise<ProtocolParametersShelley>; | ||
export declare const currentProtocolParameters: (context: InteractionContext) => Promise<ProtocolParametersAlonzo | ProtocolParametersShelley>; | ||
//# sourceMappingURL=currentProtocolParameters.d.ts.map |
@@ -7,3 +7,3 @@ "use strict"; | ||
const isEraMismatch = (result) => result.eraMismatch !== undefined; | ||
const isProtocolParameters = (result) => result.minFeeCoefficient !== undefined; | ||
const isProtocolParameters = (result) => result.coinsPerUtxoWord !== undefined || result.minUtxoValue !== undefined; | ||
const currentProtocolParameters = (context) => (0, Query_1.Query)({ | ||
@@ -10,0 +10,0 @@ methodName: 'Query', |
@@ -7,2 +7,3 @@ import { Address, Hash16, Lovelace, PointOrOrigin, PoolId, TxIn } from '@cardano-ogmios/schema'; | ||
acquire: (point: PointOrOrigin) => Promise<StateQueryClient>; | ||
release: () => Promise<void>; | ||
shutdown: () => Promise<void>; | ||
@@ -9,0 +10,0 @@ currentEpoch: () => ReturnType<typeof currentEpoch>; |
@@ -12,3 +12,2 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const requestId = (0, nanoid_1.nanoid)(5); | ||
const createClient = () => resolve({ | ||
@@ -20,2 +19,21 @@ context, | ||
}, | ||
async release() { | ||
(0, util_1.ensureSocketIsOpen)(socket); | ||
const requestId = (0, nanoid_1.nanoid)(5); | ||
return new Promise((resolve, reject) => { | ||
socket.once('message', (message) => { | ||
const response = util_1.safeJSON.parse(message); | ||
if (response.reflection.requestId !== requestId) { | ||
return; | ||
} | ||
if (response.result === 'Released') { | ||
resolve(); | ||
} | ||
else { | ||
reject(new errors_1.UnknownResultError(message)); | ||
} | ||
}); | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'Release', args: {}, mirror: { requestId } }))); | ||
}); | ||
}, | ||
shutdown: () => { | ||
@@ -86,35 +104,38 @@ (0, util_1.ensureSocketIsOpen)(socket); | ||
}); | ||
socket.once('message', (message) => { | ||
const response = util_1.safeJSON.parse(message); | ||
if (response.reflection.requestId !== requestId) { | ||
return; | ||
} | ||
if ('AcquireSuccess' in response.result) { | ||
createClient(); | ||
} | ||
else { | ||
socket.once('close', () => { | ||
if ('AcquireFailure' in response.result) { | ||
const { failure } = response.result.AcquireFailure; | ||
switch (failure) { | ||
case 'pointTooOld': { | ||
return reject(new errors_1.AcquirePointTooOldError()); | ||
if ((options === null || options === void 0 ? void 0 : options.point) !== undefined) { | ||
const point = options === null || options === void 0 ? void 0 : options.point; | ||
const requestId = (0, nanoid_1.nanoid)(5); | ||
(0, util_1.ensureSocketIsOpen)(socket); | ||
socket.once('error', e => reject(new errors_1.UnknownResultError(e))); | ||
socket.once('message', (message) => { | ||
const response = util_1.safeJSON.parse(message); | ||
if (response.reflection.requestId !== requestId) { | ||
return; | ||
} | ||
if ('AcquireSuccess' in response.result) { | ||
createClient(); | ||
} | ||
else { | ||
socket.once('close', () => { | ||
if ('AcquireFailure' in response.result) { | ||
const { failure } = response.result.AcquireFailure; | ||
switch (failure) { | ||
case 'pointTooOld': { | ||
return reject(new errors_1.AcquirePointTooOldError()); | ||
} | ||
case 'pointNotOnChain': { | ||
return reject(new errors_1.AcquirePointNotOnChainError()); | ||
} | ||
default: { | ||
return reject(new Error(`Unknown AcquirePointFailure ${failure}`)); | ||
} | ||
} | ||
case 'pointNotOnChain': { | ||
return reject(new errors_1.AcquirePointNotOnChainError()); | ||
} | ||
default: { | ||
return reject(new Error(`Unknown AcquirePointFailure ${failure}`)); | ||
} | ||
} | ||
} | ||
else { | ||
reject(new errors_1.UnknownResultError(response.result)); | ||
} | ||
}); | ||
socket.close(); | ||
} | ||
}); | ||
if ((options === null || options === void 0 ? void 0 : options.point) !== undefined) { | ||
const point = options === null || options === void 0 ? void 0 : options.point; | ||
else { | ||
reject(new errors_1.UnknownResultError(response.result)); | ||
} | ||
}); | ||
socket.close(); | ||
} | ||
}); | ||
socket.send(util_1.safeJSON.stringify(Object.assign(Object.assign({}, Request_1.baseRequest), { methodname: 'Acquire', args: { point }, mirror: { requestId } }))); | ||
@@ -121,0 +142,0 @@ } |
import { WebSocket } from './IsomorphicWebSocket'; | ||
import { InteractionContext } from './Connection'; | ||
import { Block, BlockAllegra, BlockAlonzo, BlockByron, BlockMary, BlockShelley, EpochBoundaryBlock, Point, StandardBlock } from '@cardano-ogmios/schema'; | ||
import { Block, BlockAllegra, BlockAlonzo, BlockByron, BlockMary, BlockShelley, EpochBoundaryBlock, Point, ProtocolParametersAlonzo, ProtocolParametersShelley, StandardBlock } from '@cardano-ogmios/schema'; | ||
export declare const safeJSON: { | ||
$: { | ||
parse: (text: string, reviver?: (this: any, key: string, value: any) => any) => any; | ||
stringify: { | ||
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; | ||
(value: any, replacer?: (string | number)[], space?: string | number): string; | ||
}; | ||
}; | ||
$: any; | ||
sanitize(json: any): [any, boolean]; | ||
@@ -40,2 +34,4 @@ parse(raw: string): any; | ||
export declare const isEmptyObject: (obj: Object) => boolean; | ||
export declare const isAlonzoProtocolParameters: (params: ProtocolParametersShelley | ProtocolParametersAlonzo) => params is ProtocolParametersAlonzo; | ||
export declare const isShelleyProtocolParameters: (params: ProtocolParametersShelley | ProtocolParametersAlonzo) => params is ProtocolParametersShelley; | ||
//# sourceMappingURL=util.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isEmptyObject = exports.isShelleyBlock = exports.isMaryBlock = exports.isByronEpochBoundaryBlock = exports.isByronStandardBlock = exports.isByronBlock = exports.isAlonzoBlock = exports.isAllegraBlock = exports.ensureSocketIsOpen = exports.createPointFromCurrentTip = exports.safeJSON = void 0; | ||
exports.isShelleyProtocolParameters = exports.isAlonzoProtocolParameters = exports.isEmptyObject = exports.isShelleyBlock = exports.isMaryBlock = exports.isByronEpochBoundaryBlock = exports.isByronStandardBlock = exports.isByronBlock = exports.isAlonzoBlock = exports.isAllegraBlock = exports.ensureSocketIsOpen = exports.createPointFromCurrentTip = exports.safeJSON = void 0; | ||
const ChainSync_1 = require("./ChainSync"); | ||
const errors_1 = require("./errors"); | ||
const json_bigint_1 = __importDefault(require("json-bigint")); | ||
const JSONBig = require('@cardanosolutions/json-bigint'); | ||
exports.safeJSON = { | ||
$: (0, json_bigint_1.default)({ useNativeBigInt: true }), | ||
$: JSONBig({ useNativeBigInt: true }), | ||
sanitize(json) { | ||
@@ -79,2 +76,6 @@ if (typeof json === 'object' && json !== null) { | ||
exports.isEmptyObject = isEmptyObject; | ||
const isAlonzoProtocolParameters = (params) => params.coinsPerUtxoWord !== undefined; | ||
exports.isAlonzoProtocolParameters = isAlonzoProtocolParameters; | ||
const isShelleyProtocolParameters = (params) => params.minUtxoValue !== undefined; | ||
exports.isShelleyProtocolParameters = isShelleyProtocolParameters; | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@cardano-ogmios/client", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "TypeScript client library for Cardano Ogmios", | ||
@@ -54,3 +54,4 @@ "engines": { | ||
"dependencies": { | ||
"@cardano-ogmios/schema": "4.1.0", | ||
"@cardano-ogmios/schema": "4.2.0", | ||
"@cardanosolutions/json-bigint": "^1.0.0", | ||
"@types/json-bigint": "^1.0.1", | ||
@@ -60,3 +61,2 @@ "cross-fetch": "^3.1.4", | ||
"isomorphic-ws": "^4.0.1", | ||
"json-bigint": "CardanoSolutions/json-bigint#d277387d", | ||
"nanoid": "^3.1.22", | ||
@@ -63,0 +63,0 @@ "ts-custom-error": "^3.2.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
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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
258549
3148
0
0
+ Added@cardano-ogmios/schema@4.2.0(transitive)
+ Added@cardanosolutions/json-bigint@1.0.1(transitive)
+ Addedbignumber.js@9.1.2(transitive)
- Removed@cardano-ogmios/schema@4.1.0(transitive)
Updated@cardano-ogmios/schema@4.2.0