File tree 4 files changed +6
-11
lines changed
4 files changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export class PythConnection {
46
46
data : productData ,
47
47
} ,
48
48
}
49
- if ( productData . priceAccountKey . toString ( ) !== ONES ) {
49
+ if ( productData . priceAccountKey ) {
50
50
this . priceAccountKeyToProductAccountKey [ productData . priceAccountKey . toString ( ) ] = key . toString ( )
51
51
}
52
52
}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ test('Mapping', (done) => {
20
20
return
21
21
}
22
22
const { product, priceAccountKey } = parseProductData ( accountInfo . data )
23
- connection . getAccountInfo ( priceAccountKey ) . then ( ( accountInfo ) => {
23
+ connection . getAccountInfo ( priceAccountKey ! ) . then ( ( accountInfo ) => {
24
24
if ( ! accountInfo ) {
25
25
done ( 'No price accountInfo' )
26
26
return
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ test('Price', (done) => {
23
23
connection . getAccountInfo ( mapping . productAccountKeys [ 0 ] ) . then ( ( accountInfo ) => {
24
24
if ( accountInfo && accountInfo . data ) {
25
25
const product = parseProductData ( accountInfo . data )
26
- connection . getAccountInfo ( product . priceAccountKey ) . then ( ( accountInfo ) => {
26
+ connection . getAccountInfo ( product . priceAccountKey ! ) . then ( ( accountInfo ) => {
27
27
if ( accountInfo && accountInfo . data ) {
28
28
const price = parsePriceData ( accountInfo . data )
29
29
console . log ( product . product . symbol )
Original file line number Diff line number Diff line change @@ -56,16 +56,11 @@ export interface MappingData extends Base {
56
56
}
57
57
58
58
export interface Product {
59
- symbol : string
60
- asset_type : string
61
- quote_currency : string
62
- tenor : string
63
- price_account : string
64
59
[ index : string ] : string
65
60
}
66
61
67
62
export interface ProductData extends Base {
68
- priceAccountKey : PublicKey
63
+ priceAccountKey : PublicKey | null
69
64
product : Product
70
65
}
71
66
@@ -203,9 +198,9 @@ export const parseProductData = (data: Buffer): ProductData => {
203
198
const size = data . readUInt32LE ( 12 )
204
199
// first price account in list
205
200
const priceAccountBytes = data . slice ( 16 , 48 )
206
- const priceAccountKey = new PublicKey ( priceAccountBytes )
201
+ const priceAccountKey = PKorNull ( priceAccountBytes )
207
202
const product = { } as Product
208
- product . price_account = priceAccountKey . toBase58 ( )
203
+ if ( priceAccountKey ) product . price_account = priceAccountKey . toBase58 ( )
209
204
let idx = 48
210
205
while ( idx < size ) {
211
206
const keyLength = data [ idx ]
You can’t perform that action at this time.
0 commit comments