@pythnetwork/client
Advanced tools
Comparing version 2.3.2 to 2.4.0
# Changelog | ||
### 2.3.2 | ||
Added PythConnection | ||
## 2.2.0 | ||
@@ -4,0 +8,0 @@ |
@@ -13,4 +13,10 @@ "use strict"; | ||
// SRM/USD: $8.68725 ±$0.0131 | ||
// tslint:disable-next-line:no-console | ||
console.log(product.symbol + ": $" + price.price + " \u00B1$" + price.confidence); | ||
if (price.price && price.confidence) { | ||
// tslint:disable-next-line:no-console | ||
console.log(product.symbol + ": $" + price.price + " \u00B1$" + price.confidence); | ||
} | ||
else { | ||
// tslint:disable-next-line:no-console | ||
console.log(product.symbol + ": price currently unavailable"); | ||
} | ||
}); | ||
@@ -17,0 +23,0 @@ // tslint:disable-next-line:no-console |
@@ -56,3 +56,3 @@ /// <reference types="node" /> | ||
} | ||
export interface PriceData extends Base, Price { | ||
export interface PriceData extends Base { | ||
priceType: number; | ||
@@ -80,2 +80,5 @@ exponent: number; | ||
priceComponents: PriceComponent[]; | ||
aggregate: Price; | ||
price: number | undefined; | ||
confidence: number | undefined; | ||
} | ||
@@ -82,0 +85,0 @@ /** Parse data as a generic Pyth account. Use this method if you don't know the account type. */ |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -194,3 +183,9 @@ exports.getPythProgramKeyForCluster = exports.PythConnection = exports.parsePriceData = exports.parseProductData = exports.parseMappingData = exports.parseBaseData = exports.MAX_SLOT_DIFFERENCE = exports.AccountType = exports.DeriveType = exports.PriceType = exports.CorpAction = exports.PriceStatus = exports.Version = exports.Version2 = exports.Magic = void 0; | ||
var drv3 = Number(drv3Component) * Math.pow(10, exponent); | ||
var aggregatePriceInfo = parsePriceInfo(data.slice(208, 240), exponent); | ||
var aggregate = parsePriceInfo(data.slice(208, 240), exponent); | ||
var price; | ||
var confidence; | ||
if (aggregate.status === 1) { | ||
price = aggregate.price; | ||
confidence = aggregate.confidence; | ||
} | ||
// price components - up to 32 | ||
@@ -204,7 +199,7 @@ var priceComponents = []; | ||
if (publisher) { | ||
var aggregate = parsePriceInfo(data.slice(offset, offset + 32), exponent); | ||
var componentAggregate = parsePriceInfo(data.slice(offset, offset + 32), exponent); | ||
offset += 32; | ||
var latest = parsePriceInfo(data.slice(offset, offset + 32), exponent); | ||
offset += 32; | ||
priceComponents.push({ publisher: publisher, aggregate: aggregate, latest: latest }); | ||
priceComponents.push({ publisher: publisher, aggregate: componentAggregate, latest: latest }); | ||
} | ||
@@ -215,3 +210,4 @@ else { | ||
} | ||
return __assign(__assign({ magic: magic, | ||
return { | ||
magic: magic, | ||
version: version, | ||
@@ -240,3 +236,8 @@ type: type, | ||
drv3Component: drv3Component, | ||
drv3: drv3 }, aggregatePriceInfo), { priceComponents: priceComponents }); | ||
drv3: drv3, | ||
aggregate: aggregate, | ||
priceComponents: priceComponents, | ||
price: price, | ||
confidence: confidence | ||
}; | ||
}; | ||
@@ -243,0 +244,0 @@ exports.parsePriceData = parsePriceData; |
{ | ||
"name": "@pythnetwork/client", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"description": "Client for consuming Pyth price data", | ||
@@ -40,3 +40,3 @@ "homepage": "https://pyth.network", | ||
"dependencies": { | ||
"@solana/web3.js": "^1.10.1", | ||
"@solana/web3.js": "^1.30.2", | ||
"assert": "^2.0.0", | ||
@@ -43,0 +43,0 @@ "buffer": "^6.0.1" |
@@ -50,2 +50,9 @@ # @pythnetwork/client | ||
You may also register to specific account updates using `connection.onAccountChange` in the solana web3 API, then | ||
use the methods in `index.ts` to parse the on-chain data structures into Javascript-friendly objects. | ||
use the methods in `index.ts` to parse the on-chain data structures into Javascript-friendly objects. | ||
## Releases | ||
In order to release a new version of this library and publish it to npm, follow these steps: | ||
1. Update `CHANGELOG.md` with a description of the changes in this version. | ||
2. Run `npm version <new version number>`. This command will update the version of the package, tag the branch in git, and push your changes to github. | ||
3. Once your change is merged into `main`, a github action will automatically publish a new version of the package to npm. |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
43048
613
58
0
Updated@solana/web3.js@^1.30.2