Skip to content

Commit 4120107

Browse files
authored
Add syntax highlighting so the example is readable (#1)
* Add syntax highlighting so the example is clear * Rework spacing and tabulation * Fix import
1 parent 2cd8aba commit 4120107

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@ See our [examples repo](https://github.com/pyth-network/pyth-examples) for real-
1010

1111
## Example Usage
1212

13-
```
13+
```javascript
1414
import { Connection, PublicKey } from '@solana/web3.js'
15-
import { parseMappingData, parsePriceData, parseProductData } from '@pythnetwork/pyth-client'
15+
import { parseMappingData, parsePriceData, parseProductData } from '@pythnetwork/client'
16+
1617
const connection = new Connection(SOLANA_CLUSTER_URL)
17-
const publicKey = new PublicKey(ORACLE_MAPPING_PUBLIC_KEY)
18-
connection.getAccountInfo(publicKey).then((accountInfo) => {
19-
const { productAccountKeys } = parseMappingData(accountInfo.data)
20-
connection.getAccountInfo(productAccountKeys[productAccountKeys.length - 1]).then((accountInfo) => {
21-
const { product, priceAccountKey } = parseProductData(accountInfo.data)
22-
connection.getAccountInfo(priceAccountKey).then((accountInfo) => {
23-
const { price, confidence } = parsePriceData(accountInfo.data)
24-
console.log(`${product.symbol}: $${price} \xB1$${confidence}`)
25-
// SRM/USD: $8.68725 ±$0.0131
26-
})
18+
const publicKey = new PublicKey(ORACLE_MAPPING_PUBLIC_KEY)
19+
20+
connection.getAccountInfo(publicKey).then((accountInfo) => {
21+
const { productAccountKeys } = parseMappingData(accountInfo.data)
22+
connection.getAccountInfo(productAccountKeys[productAccountKeys.length - 1]).then((accountInfo) => {
23+
const { product, priceAccountKey } = parseProductData(accountInfo.data)
24+
connection.getAccountInfo(priceAccountKey).then((accountInfo) => {
25+
const { price, confidence } = parsePriceData(accountInfo.data)
26+
console.log(`${product.symbol}: $${price} \xB1$${confidence}`)
27+
// SRM/USD: $8.68725 ±$0.0131
2728
})
2829
})
30+
})
2931
```
3032

3133
To get streaming price updates, you may want to use `connection.onAccountChange`

0 commit comments

Comments
 (0)