@@ -80,7 +80,7 @@ export interface Price {
80
80
}
81
81
82
82
export interface PriceComponent {
83
- publisher : PublicKey | null
83
+ publisher : PublicKey
84
84
aggregate : Price
85
85
latest : Price
86
86
}
@@ -329,19 +329,14 @@ export const parsePriceData = (data: Buffer, currentSlot?: number): PriceData =>
329
329
// price components - up to 32
330
330
const priceComponents : PriceComponent [ ] = [ ]
331
331
let offset = 240
332
- let shouldContinue = true
333
- while ( offset < data . length && shouldContinue ) {
334
- const publisher = PKorNull ( data . slice ( offset , offset + 32 ) )
332
+ while ( priceComponents . length < numComponentPrices ) {
333
+ const publisher = new PublicKey ( data . slice ( offset , offset + 32 ) )
335
334
offset += 32
336
- if ( publisher ) {
337
- const componentAggregate = parsePriceInfo ( data . slice ( offset , offset + 32 ) , exponent )
338
- offset += 32
339
- const latest = parsePriceInfo ( data . slice ( offset , offset + 32 ) , exponent )
340
- offset += 32
341
- priceComponents . push ( { publisher, aggregate : componentAggregate , latest } )
342
- } else {
343
- shouldContinue = false
344
- }
335
+ const componentAggregate = parsePriceInfo ( data . slice ( offset , offset + 32 ) , exponent )
336
+ offset += 32
337
+ const latest = parsePriceInfo ( data . slice ( offset , offset + 32 ) , exponent )
338
+ offset += 32
339
+ priceComponents . push ( { publisher, aggregate : componentAggregate , latest } )
345
340
}
346
341
347
342
return {
0 commit comments