New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pythnetwork/client

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pythnetwork/client - npm Package Compare versions

Comparing version 2.13.1 to 2.14.0

lib/example_ws_single_feed.d.ts

3

lib/example_ws_usage.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var web3_js_1 = require("@solana/web3.js");
var PythConnection_1 = require("./PythConnection");
var _1 = require(".");

@@ -9,3 +8,3 @@ var PYTHNET_CLUSTER_NAME = 'pythnet';

var pythPublicKey = _1.getPythProgramKeyForCluster(PYTHNET_CLUSTER_NAME);
var pythConnection = new PythConnection_1.PythConnection(connection, pythPublicKey);
var pythConnection = new _1.PythConnection(connection, pythPublicKey);
pythConnection.onPriceChangeVerbose(function (productAccount, priceAccount) {

@@ -12,0 +11,0 @@ // The arguments to the callback include solana account information / the update slot if you need it.

@@ -27,2 +27,3 @@ import { Connection, PublicKey, Commitment, AccountInfo } from '@solana/web3.js';

commitment: Commitment;
feedIds?: PublicKey[];
productAccountKeyToProduct: Record<string, AccountUpdate<ProductData>>;

@@ -37,3 +38,3 @@ priceAccountKeyToProductAccountKey: Record<string, string>;

*/
constructor(connection: Connection, pythProgramKey: PublicKey, commitment?: Commitment);
constructor(connection: Connection, pythProgramKey: PublicKey, commitment?: Commitment, feedIds?: PublicKey[]);
/** Start receiving price updates. Once this method is called, any registered callbacks will be invoked

@@ -40,0 +41,0 @@ * each time a Pyth price account is updated.

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

*/
function PythConnection(connection, pythProgramKey, commitment) {
function PythConnection(connection, pythProgramKey, commitment, feedIds) {
if (commitment === void 0) { commitment = 'finalized'; }

@@ -70,2 +70,3 @@ this.productAccountKeyToProduct = {};

this.commitment = commitment;
this.feedIds = feedIds;
}

@@ -130,12 +131,17 @@ PythConnection.prototype.handleProductAccount = function (key, account, slot) {

return __awaiter(this, void 0, void 0, function () {
var accounts, currentSlot, _i, accounts_1, account;
var accounts, currentSlot, _i, accounts_1, account, rawIDs_1, _loop_1, this_1, _a, accounts_2, account;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.connection.getProgramAccounts(this.pythProgramKey, this.commitment)];
case 1:
accounts = _a.sent();
return [4 /*yield*/, this.connection.getSlot(this.commitment)];
accounts = _b.sent();
return [4 /*yield*/, this.connection.getSlot(this.commitment)
// Handle all accounts once since we need to handle product accounts
// at least once
];
case 2:
currentSlot = _a.sent();
currentSlot = _b.sent();
// Handle all accounts once since we need to handle product accounts
// at least once
for (_i = 0, accounts_1 = accounts; _i < accounts_1.length; _i++) {

@@ -145,5 +151,21 @@ account = accounts_1[_i];

}
this.connection.onProgramAccountChange(this.pythProgramKey, function (keyedAccountInfo, context) {
_this.handleAccount(keyedAccountInfo.accountId, keyedAccountInfo.accountInfo, false, context.slot);
}, this.commitment);
if (this.feedIds) {
rawIDs_1 = this.feedIds.map(function (feed) { return feed.toString(); });
accounts = accounts.filter(function (feed) { return rawIDs_1.includes(feed.pubkey.toString()); });
_loop_1 = function (account) {
this_1.connection.onAccountChange(account.pubkey, function (accountInfo, context) {
_this.handleAccount(account.pubkey, accountInfo, false, context.slot);
}, this_1.commitment);
};
this_1 = this;
for (_a = 0, accounts_2 = accounts; _a < accounts_2.length; _a++) {
account = accounts_2[_a];
_loop_1(account);
}
}
else {
this.connection.onProgramAccountChange(this.pythProgramKey, function (keyedAccountInfo, context) {
_this.handleAccount(keyedAccountInfo.accountId, keyedAccountInfo.accountInfo, false, context.slot);
}, this.commitment);
}
return [2 /*return*/];

@@ -150,0 +172,0 @@ }

{
"name": "@pythnetwork/client",
"version": "2.13.1",
"version": "2.14.0",
"description": "Client for consuming Pyth price data",

@@ -23,2 +23,3 @@ "homepage": "https://pyth.network",

"ws_example": "npm run build && node lib/example_ws_usage.js",
"ws_single_example": "npm run build && node lib/example_ws_usage.js",
"http_example": "npm run build && node lib/example_http_usage.js"

@@ -25,0 +26,0 @@ },

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