@generalprotocols/price-oracle
Advanced tools
Comparing version 2.0.0-development.2089041649 to 2.0.0-development.2117217816
@@ -47,22 +47,29 @@ 'use strict'; | ||
// Import library for parsing hex strings. | ||
// Export the protocol constants. | ||
/** | ||
* Oracle Protocol Constants | ||
* @namespace | ||
*/ | ||
const OracleProtocol = { | ||
// Oracle protocol identified to use in OP_RETURN outputs. | ||
/** Oracle protocol identified to use in OP_RETURN outputs. */ | ||
IDENTIFIER: libauth.hexToBin('71808079'), | ||
// Network port numbers. | ||
/** Network Port to use for requests. */ | ||
PORT_REQUEST: 7083, | ||
/** Network Port to use for broadcasts. */ | ||
PORT_BROADCAST: 7084, | ||
/** Network Port to use for relays. */ | ||
PORT_RELAY: 7085, | ||
// Network addresses. | ||
/** Network Host for all interfaces (*). */ | ||
ADDRESS_ANY: '*', | ||
/** Network Host to use for local interface (127.0.0.1). */ | ||
ADDRESS_LOCAL: '127.0.0.1', | ||
// The minimum message length in bytes of an oracle message, assuming the content of the message is exactly 1 byte large. | ||
/** The minimum message length in bytes of an oracle message, assuming the content of the message is exactly 1 byte large. */ | ||
MINIMUM_MESSAGE_LENGTH: 12, | ||
// Type identifier for price messages. | ||
/** Type identifier for price messages. */ | ||
// NOTE: for now, we've just arbitrarily picked 128 for price messages. | ||
TYPE_PRICE_MESSAGE: 128, | ||
// Network topics. | ||
/** Topic header for ping message. */ | ||
TOPIC_PING: '6A04718080790100', | ||
/** Topic header for price messages. */ | ||
TOPIC_PRICE_MESSAGE: '6A04718080790101', | ||
// | ||
/** Message Types */ | ||
MESSAGE_TYPES: { | ||
@@ -80,3 +87,3 @@ // Metadata types. | ||
const OP_RETURN = libauth.hexToBin('6A'); | ||
/* | ||
/** | ||
* Functions to manage oracle messages. | ||
@@ -602,30 +609,6 @@ */ | ||
// Import the debug logging facility. | ||
/* | ||
/** | ||
* Oracle Network Management Class | ||
*/ | ||
class OracleNetwork { | ||
// Counter for number of broadcast packets received | ||
static broadcastedPacketCounter; | ||
// List of Broadcasting Sockets we are listening to (as SocketUrl to ZeroMQ Subscriber) | ||
static broadcastSubscriber; | ||
// List of SocketUrl to boolean to indicate whether to listen for broadcasts on a given SocketURL | ||
static shouldReconnectWithBroadcast; | ||
// ZeroMQ Publisher Socket for broadcasting packets | ||
static broadcastPublisher; | ||
// List of Relay Sockets we will relay packets to (as SocketUrl to ZeroMQ Publisher) | ||
static relayPublishers; | ||
// Counter for number of relay packets received | ||
static relayedPacketCounter; | ||
// ZeroMQ Subscriber Socket for listening to relays | ||
static relaySubscriber; | ||
// Boolean to specify whether we should continuously listen to relays | ||
static shouldReconnectWithRelays; | ||
// Counter for number of request packets received | ||
static requestPacketCounter; | ||
// List of SocketUrl to ZeroMQ for listening to Requests | ||
static requestSockets; | ||
// Boolean to specify whether we should listen for requests | ||
static shouldReconnectWithRequests; | ||
// Reply Socket for ZeroMQ | ||
static replySocket; | ||
/** | ||
@@ -659,3 +642,2 @@ * Getter used to craft consistent socket urls. | ||
if (!this.shouldReconnectWithBroadcast) { | ||
/** @type {{ [index: string]: boolean }} */ | ||
this.shouldReconnectWithBroadcast = {}; | ||
@@ -725,3 +707,2 @@ } | ||
if (!this.broadcastSubscriber) { | ||
/** @type {{ [index: string]: Subscriber }} */ | ||
this.broadcastSubscriber = {}; | ||
@@ -866,3 +847,2 @@ } | ||
if (!this.relayPublishers) { | ||
/** @type {{ [index: string]: Publisher }} */ | ||
this.relayPublishers = {}; | ||
@@ -900,3 +880,2 @@ } | ||
if (!this.relayPublishers) { | ||
/** @type {{ [index: string]: Publisher }} */ | ||
this.relayPublishers = {}; | ||
@@ -1013,3 +992,3 @@ } | ||
* | ||
* @return {Promise<Array<Promise<void>>>>} an array with the relay promises. | ||
* @return {Promise<Array<Promise<void>>>} an array with the relay promises. | ||
*/ | ||
@@ -1148,3 +1127,2 @@ static async relay(topic, content) { | ||
if (!this.requestSockets) { | ||
/** @type {{ [index: string]: Request }} */ | ||
this.requestSockets = {}; | ||
@@ -1151,0 +1129,0 @@ } |
@@ -87,2 +87,5 @@ import { Subscriber, Publisher, Request, Reply } from 'zeromq'; | ||
/** | ||
* Functions to manage oracle messages. | ||
*/ | ||
declare class OracleData { | ||
@@ -329,14 +332,62 @@ /** | ||
/** | ||
* Oracle Network Management Class | ||
*/ | ||
declare class OracleNetwork { | ||
/** | ||
* Counter for number of broadcast packets received. | ||
*/ | ||
static broadcastedPacketCounter: number; | ||
/** | ||
* List of SocketUrl to boolean to indicate whether to listen for broadcasts on a given SocketURL. | ||
* @private | ||
*/ | ||
static shouldReconnectWithBroadcast: Record<string, boolean>; | ||
/** | ||
* List of Broadcasting Sockets we are listening to (as SocketUrl to ZeroMQ Subscriber). | ||
* @private | ||
*/ | ||
static broadcastSubscriber: Record<string, Subscriber>; | ||
static shouldReconnectWithBroadcast: Record<string, boolean>; | ||
/** | ||
* ZeroMQ Publisher Socket for broadcasting packets. | ||
* @private | ||
*/ | ||
static broadcastPublisher: Publisher | undefined; | ||
/** | ||
* List of Relay Sockets we will relay packets to (as SocketUrl to ZeroMQ Publisher). | ||
* @private | ||
*/ | ||
static relayPublishers: Record<string, Publisher>; | ||
/** | ||
* Counter for number of relay packets received. | ||
*/ | ||
static relayedPacketCounter: number; | ||
/** | ||
* ZeroMQ Subscriber Socket for listening to relays. | ||
* @private | ||
*/ | ||
static relaySubscriber: Subscriber | undefined; | ||
/** | ||
* Boolean to specify whether we should continuously listen to relays. | ||
* @private | ||
*/ | ||
static shouldReconnectWithRelays: boolean; | ||
/** | ||
* Counter for number of request packets received. | ||
*/ | ||
static requestPacketCounter: number; | ||
/** | ||
* List of SocketUrl to ZeroMQ for listening to Requests. | ||
* @private | ||
*/ | ||
static requestSockets: Record<string, Request>; | ||
/** | ||
* Boolean to specify whether we should listen for requests. | ||
* @private | ||
*/ | ||
static shouldReconnectWithRequests: boolean; | ||
/** | ||
* Reply Socket for ZeroMQ. | ||
* @private | ||
*/ | ||
static replySocket: Reply | undefined; | ||
@@ -458,3 +509,3 @@ /** | ||
* | ||
* @return {Promise<Array<Promise<void>>>>} an array with the relay promises. | ||
* @return {Promise<Array<Promise<void>>>} an array with the relay promises. | ||
*/ | ||
@@ -508,13 +559,28 @@ static relay(topic: string, content: string): Promise<Array<Promise<void>>>; | ||
/** | ||
* Oracle Protocol Constants | ||
* @namespace | ||
*/ | ||
declare const OracleProtocol: { | ||
/** Oracle protocol identified to use in OP_RETURN outputs. */ | ||
IDENTIFIER: Uint8Array; | ||
/** Network Port to use for requests. */ | ||
PORT_REQUEST: number; | ||
/** Network Port to use for broadcasts. */ | ||
PORT_BROADCAST: number; | ||
/** Network Port to use for relays. */ | ||
PORT_RELAY: number; | ||
/** Network Host for all interfaces (*). */ | ||
ADDRESS_ANY: string; | ||
/** Network Host to use for local interface (127.0.0.1). */ | ||
ADDRESS_LOCAL: string; | ||
/** The minimum message length in bytes of an oracle message, assuming the content of the message is exactly 1 byte large. */ | ||
MINIMUM_MESSAGE_LENGTH: number; | ||
/** Type identifier for price messages. */ | ||
TYPE_PRICE_MESSAGE: number; | ||
/** Topic header for ping message. */ | ||
TOPIC_PING: string; | ||
/** Topic header for price messages. */ | ||
TOPIC_PRICE_MESSAGE: string; | ||
/** Message Types */ | ||
MESSAGE_TYPES: { | ||
@@ -521,0 +587,0 @@ 0: string; |
@@ -43,22 +43,29 @@ import { hexToBin, numberToBinInt32LE, flattenBinArray, binToHex, binToNumberInt32LE, instantiateSha256, instantiateSecp256k1, decodePrivateKeyWif, parseBytecode, authenticationInstructionsAreMalformed } from '@bitauth/libauth'; | ||
// Import library for parsing hex strings. | ||
// Export the protocol constants. | ||
/** | ||
* Oracle Protocol Constants | ||
* @namespace | ||
*/ | ||
const OracleProtocol = { | ||
// Oracle protocol identified to use in OP_RETURN outputs. | ||
/** Oracle protocol identified to use in OP_RETURN outputs. */ | ||
IDENTIFIER: hexToBin('71808079'), | ||
// Network port numbers. | ||
/** Network Port to use for requests. */ | ||
PORT_REQUEST: 7083, | ||
/** Network Port to use for broadcasts. */ | ||
PORT_BROADCAST: 7084, | ||
/** Network Port to use for relays. */ | ||
PORT_RELAY: 7085, | ||
// Network addresses. | ||
/** Network Host for all interfaces (*). */ | ||
ADDRESS_ANY: '*', | ||
/** Network Host to use for local interface (127.0.0.1). */ | ||
ADDRESS_LOCAL: '127.0.0.1', | ||
// The minimum message length in bytes of an oracle message, assuming the content of the message is exactly 1 byte large. | ||
/** The minimum message length in bytes of an oracle message, assuming the content of the message is exactly 1 byte large. */ | ||
MINIMUM_MESSAGE_LENGTH: 12, | ||
// Type identifier for price messages. | ||
/** Type identifier for price messages. */ | ||
// NOTE: for now, we've just arbitrarily picked 128 for price messages. | ||
TYPE_PRICE_MESSAGE: 128, | ||
// Network topics. | ||
/** Topic header for ping message. */ | ||
TOPIC_PING: '6A04718080790100', | ||
/** Topic header for price messages. */ | ||
TOPIC_PRICE_MESSAGE: '6A04718080790101', | ||
// | ||
/** Message Types */ | ||
MESSAGE_TYPES: { | ||
@@ -76,3 +83,3 @@ // Metadata types. | ||
const OP_RETURN = hexToBin('6A'); | ||
/* | ||
/** | ||
* Functions to manage oracle messages. | ||
@@ -598,30 +605,6 @@ */ | ||
// Import the debug logging facility. | ||
/* | ||
/** | ||
* Oracle Network Management Class | ||
*/ | ||
class OracleNetwork { | ||
// Counter for number of broadcast packets received | ||
static broadcastedPacketCounter; | ||
// List of Broadcasting Sockets we are listening to (as SocketUrl to ZeroMQ Subscriber) | ||
static broadcastSubscriber; | ||
// List of SocketUrl to boolean to indicate whether to listen for broadcasts on a given SocketURL | ||
static shouldReconnectWithBroadcast; | ||
// ZeroMQ Publisher Socket for broadcasting packets | ||
static broadcastPublisher; | ||
// List of Relay Sockets we will relay packets to (as SocketUrl to ZeroMQ Publisher) | ||
static relayPublishers; | ||
// Counter for number of relay packets received | ||
static relayedPacketCounter; | ||
// ZeroMQ Subscriber Socket for listening to relays | ||
static relaySubscriber; | ||
// Boolean to specify whether we should continuously listen to relays | ||
static shouldReconnectWithRelays; | ||
// Counter for number of request packets received | ||
static requestPacketCounter; | ||
// List of SocketUrl to ZeroMQ for listening to Requests | ||
static requestSockets; | ||
// Boolean to specify whether we should listen for requests | ||
static shouldReconnectWithRequests; | ||
// Reply Socket for ZeroMQ | ||
static replySocket; | ||
/** | ||
@@ -655,3 +638,2 @@ * Getter used to craft consistent socket urls. | ||
if (!this.shouldReconnectWithBroadcast) { | ||
/** @type {{ [index: string]: boolean }} */ | ||
this.shouldReconnectWithBroadcast = {}; | ||
@@ -721,3 +703,2 @@ } | ||
if (!this.broadcastSubscriber) { | ||
/** @type {{ [index: string]: Subscriber }} */ | ||
this.broadcastSubscriber = {}; | ||
@@ -862,3 +843,2 @@ } | ||
if (!this.relayPublishers) { | ||
/** @type {{ [index: string]: Publisher }} */ | ||
this.relayPublishers = {}; | ||
@@ -896,3 +876,2 @@ } | ||
if (!this.relayPublishers) { | ||
/** @type {{ [index: string]: Publisher }} */ | ||
this.relayPublishers = {}; | ||
@@ -1009,3 +988,3 @@ } | ||
* | ||
* @return {Promise<Array<Promise<void>>>>} an array with the relay promises. | ||
* @return {Promise<Array<Promise<void>>>} an array with the relay promises. | ||
*/ | ||
@@ -1144,3 +1123,2 @@ static async relay(topic, content) { | ||
if (!this.requestSockets) { | ||
/** @type {{ [index: string]: Request }} */ | ||
this.requestSockets = {}; | ||
@@ -1147,0 +1125,0 @@ } |
{ | ||
"name": "@generalprotocols/price-oracle", | ||
"version": "2.0.0-development.2089041649", | ||
"version": "2.0.0-development.2117217816", | ||
"description": "Library for creating, parsing, signing, verifying and transferring PriceOracle messages.", | ||
@@ -17,2 +17,3 @@ "main": "dist/index.cjs.js", | ||
"rename-namespace": "replace 'namespace' 'declare namespace' dist/typings/index.d.ts", | ||
"docs": "jsdoc -c jsdoc.json", | ||
"lint": "eslint .", | ||
@@ -54,4 +55,6 @@ "rollup": "rollup -c", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"better-docs": "2.3.2", | ||
"cspell": "^5.17.0", | ||
"del-cli": "^3.0.1", | ||
"docdash": "^1.2.0", | ||
"eslint": "^7.32.0", | ||
@@ -61,2 +64,3 @@ "eslint-plugin-import": "^2.25.4", | ||
"jest-junit": "^12.3.0", | ||
"jsdoc": "3.6.10", | ||
"replace": "^1.2.1", | ||
@@ -63,0 +67,0 @@ "rollup": "^2.53.0", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2911
0
153256
19