1
- import { Connection , PublicKey , clusterApiUrl , Cluster , Commitment , AccountInfo , Account } from '@solana/web3.js'
1
+ import { Connection , PublicKey , clusterApiUrl , Cluster , Commitment , AccountInfo , Account } from '@solana/web3.js'
2
2
import {
3
- Base , Magic ,
3
+ Base ,
4
+ Magic ,
4
5
parseMappingData ,
5
6
parseBaseData ,
6
7
parsePriceData ,
7
- parseProductData , Price , PriceData , Product , ProductData ,
8
- Version , AccountType ,
8
+ parseProductData ,
9
+ Price ,
10
+ PriceData ,
11
+ Product ,
12
+ ProductData ,
13
+ Version ,
14
+ AccountType ,
9
15
} from './index'
10
16
11
17
const ONES = '11111111111111111111111111111111'
@@ -31,7 +37,7 @@ export class PythConnection {
31
37
callbacks : PythPriceCallback [ ] = [ ]
32
38
33
39
private handleProductAccount ( key : PublicKey , account : AccountInfo < Buffer > ) {
34
- const { priceAccountKey, type, product} = parseProductData ( account . data )
40
+ const { priceAccountKey, type, product } = parseProductData ( account . data )
35
41
this . productAccountKeyToProduct [ key . toString ( ) ] = product
36
42
if ( priceAccountKey . toString ( ) !== ONES ) {
37
43
this . priceAccountKeyToProductAccountKey [ priceAccountKey . toString ( ) ] = key . toString ( )
@@ -43,7 +49,9 @@ export class PythConnection {
43
49
if ( product === undefined ) {
44
50
// This shouldn't happen since we're subscribed to all of the program's accounts,
45
51
// but let's be good defensive programmers.
46
- throw new Error ( 'Got a price update for an unknown product. This is a bug in the library, please report it to the developers.' )
52
+ throw new Error (
53
+ 'Got a price update for an unknown product. This is a bug in the library, please report it to the developers.' ,
54
+ )
47
55
}
48
56
49
57
const priceData = parsePriceData ( account . data )
@@ -59,17 +67,17 @@ export class PythConnection {
59
67
switch ( AccountType [ base . type ] ) {
60
68
case 'Mapping' :
61
69
// We can skip these because we're going to get every account owned by this program anyway.
62
- break ;
70
+ break
63
71
case 'Product' :
64
72
this . handleProductAccount ( key , account )
65
- break ;
73
+ break
66
74
case 'Price' :
67
75
if ( ! productOnly ) {
68
76
this . handlePriceAccount ( key , account )
69
77
}
70
- break ;
78
+ break
71
79
case 'Test' :
72
- break ;
80
+ break
73
81
default :
74
82
throw new Error ( `Unknown account type: ${ base . type } . Try upgrading pyth-client.` )
75
83
}
@@ -115,4 +123,4 @@ export class PythConnection {
115
123
// In the interim, delete callbacks.
116
124
this . callbacks = [ ]
117
125
}
118
- }
126
+ }
0 commit comments